@delmaredigital/payload-puck 0.1.0
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/LICENSE +73 -0
- package/README.md +1580 -0
- package/dist/AccordionClient.d.mts +24 -0
- package/dist/AccordionClient.d.ts +24 -0
- package/dist/AccordionClient.js +786 -0
- package/dist/AccordionClient.js.map +1 -0
- package/dist/AccordionClient.mjs +784 -0
- package/dist/AccordionClient.mjs.map +1 -0
- package/dist/AnimatedWrapper.d.mts +30 -0
- package/dist/AnimatedWrapper.d.ts +30 -0
- package/dist/AnimatedWrapper.js +379 -0
- package/dist/AnimatedWrapper.js.map +1 -0
- package/dist/AnimatedWrapper.mjs +377 -0
- package/dist/AnimatedWrapper.mjs.map +1 -0
- package/dist/admin/client.d.mts +108 -0
- package/dist/admin/client.d.ts +108 -0
- package/dist/admin/client.js +177 -0
- package/dist/admin/client.js.map +1 -0
- package/dist/admin/client.mjs +173 -0
- package/dist/admin/client.mjs.map +1 -0
- package/dist/admin/index.d.mts +157 -0
- package/dist/admin/index.d.ts +157 -0
- package/dist/admin/index.js +31 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/index.mjs +29 -0
- package/dist/admin/index.mjs.map +1 -0
- package/dist/api/index.d.mts +460 -0
- package/dist/api/index.d.ts +460 -0
- package/dist/api/index.js +588 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +578 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/components/index.css +339 -0
- package/dist/components/index.css.map +1 -0
- package/dist/components/index.d.mts +222 -0
- package/dist/components/index.d.ts +222 -0
- package/dist/components/index.js +9177 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +9130 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/config.editor.css +339 -0
- package/dist/config/config.editor.css.map +1 -0
- package/dist/config/config.editor.d.mts +153 -0
- package/dist/config/config.editor.d.ts +153 -0
- package/dist/config/config.editor.js +9400 -0
- package/dist/config/config.editor.js.map +1 -0
- package/dist/config/config.editor.mjs +9368 -0
- package/dist/config/config.editor.mjs.map +1 -0
- package/dist/config/index.d.mts +68 -0
- package/dist/config/index.d.ts +68 -0
- package/dist/config/index.js +2017 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.mjs +1991 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/editor/index.d.mts +784 -0
- package/dist/editor/index.d.ts +784 -0
- package/dist/editor/index.js +4517 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/index.mjs +4483 -0
- package/dist/editor/index.mjs.map +1 -0
- package/dist/fields/index.css +339 -0
- package/dist/fields/index.css.map +1 -0
- package/dist/fields/index.d.mts +600 -0
- package/dist/fields/index.d.ts +600 -0
- package/dist/fields/index.js +7739 -0
- package/dist/fields/index.js.map +1 -0
- package/dist/fields/index.mjs +7590 -0
- package/dist/fields/index.mjs.map +1 -0
- package/dist/index-CQu6SzDg.d.mts +327 -0
- package/dist/index-CoUQnyC3.d.ts +327 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +569 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +555 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layouts/index.d.mts +96 -0
- package/dist/layouts/index.d.ts +96 -0
- package/dist/layouts/index.js +394 -0
- package/dist/layouts/index.js.map +1 -0
- package/dist/layouts/index.mjs +378 -0
- package/dist/layouts/index.mjs.map +1 -0
- package/dist/plugin/index.d.mts +289 -0
- package/dist/plugin/index.d.ts +289 -0
- package/dist/plugin/index.js +569 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/index.mjs +555 -0
- package/dist/plugin/index.mjs.map +1 -0
- package/dist/render/index.d.mts +109 -0
- package/dist/render/index.d.ts +109 -0
- package/dist/render/index.js +2146 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/index.mjs +2123 -0
- package/dist/render/index.mjs.map +1 -0
- package/dist/shared-DMAF1AcH.d.mts +545 -0
- package/dist/shared-DMAF1AcH.d.ts +545 -0
- package/dist/theme/index.d.mts +155 -0
- package/dist/theme/index.d.ts +155 -0
- package/dist/theme/index.js +201 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/index.mjs +186 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/types-D7D3rZ1J.d.mts +116 -0
- package/dist/types-D7D3rZ1J.d.ts +116 -0
- package/dist/types-_6MvjyKv.d.mts +104 -0
- package/dist/types-_6MvjyKv.d.ts +104 -0
- package/dist/utils/index.d.mts +267 -0
- package/dist/utils/index.d.ts +267 -0
- package/dist/utils/index.js +426 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +412 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils-DaRs9t0J.d.mts +85 -0
- package/dist/utils-gAvt0Vhw.d.ts +85 -0
- package/examples/README.md +240 -0
- package/examples/api/puck/pages/[id]/route.ts +64 -0
- package/examples/api/puck/pages/[id]/versions/route.ts +47 -0
- package/examples/api/puck/pages/route.ts +45 -0
- package/examples/app/(frontend)/page.tsx +94 -0
- package/examples/app/[...slug]/page.tsx +101 -0
- package/examples/app/pages/[id]/edit/page.tsx +148 -0
- package/examples/components/CustomBanner.tsx +368 -0
- package/examples/config/custom-config.ts +223 -0
- package/examples/config/payload.config.example.ts +64 -0
- package/examples/lib/puck-layouts.ts +258 -0
- package/examples/lib/puck-theme.ts +94 -0
- package/examples/styles/puck-theme.css +171 -0
- package/package.json +157 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { c as PuckPluginOptions, d as PuckAdminConfig } from '../index-CoUQnyC3.js';
|
|
2
|
+
import { Field, CollectionConfig, Plugin } from 'payload';
|
|
3
|
+
import { L as LayoutDefinition } from '../types-D7D3rZ1J.js';
|
|
4
|
+
import '@measured/puck';
|
|
5
|
+
import 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Types for Puck field utilities
|
|
9
|
+
*
|
|
10
|
+
* These types support the getPuckFields() utility for hybrid collection integration.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Conversion type option for the conversion tracking field
|
|
15
|
+
*/
|
|
16
|
+
interface ConversionTypeOption {
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for getPuckFields() utility function
|
|
22
|
+
*
|
|
23
|
+
* Use this to configure which Puck-related fields to include
|
|
24
|
+
* when adding Puck support to an existing collection.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { getPuckFields } from '@delmaredigital/payload-puck'
|
|
29
|
+
*
|
|
30
|
+
* const Pages: CollectionConfig = {
|
|
31
|
+
* slug: 'pages',
|
|
32
|
+
* fields: [
|
|
33
|
+
* // Your existing fields...
|
|
34
|
+
* { name: 'layout', type: 'blocks', blocks: [...] },
|
|
35
|
+
*
|
|
36
|
+
* // Add Puck support
|
|
37
|
+
* ...getPuckFields({
|
|
38
|
+
* includeSEO: false, // Using your own SEO fields
|
|
39
|
+
* includeConversion: true,
|
|
40
|
+
* }),
|
|
41
|
+
* ],
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
interface GetPuckFieldsOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Include SEO field group using official @payloadcms/plugin-seo convention
|
|
48
|
+
* (meta.title, meta.description, meta.image, noindex, nofollow, excludeFromSitemap)
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
includeSEO?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Include conversion tracking field group (isConversionPage, conversionType, conversionValue)
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
includeConversion?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Include editor version field ('legacy' | 'puck' discriminator)
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
includeEditorVersion?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Include page layout selector field
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
includePageLayout?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Include isHomepage checkbox field
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
includeIsHomepage?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Custom layouts for the page layout selector.
|
|
74
|
+
* If not provided, uses the plugin's DEFAULT_LAYOUTS.
|
|
75
|
+
*
|
|
76
|
+
* Only the `value` and `label` properties are used for the Payload field.
|
|
77
|
+
* Header/footer components are used by the editor and renderer.
|
|
78
|
+
*/
|
|
79
|
+
layouts?: LayoutDefinition[];
|
|
80
|
+
/**
|
|
81
|
+
* Default editor version value for new pages.
|
|
82
|
+
* @default 'puck'
|
|
83
|
+
*/
|
|
84
|
+
defaultEditorVersion?: 'legacy' | 'puck';
|
|
85
|
+
/**
|
|
86
|
+
* Name of the legacy blocks field to check when detecting editor version.
|
|
87
|
+
* Used by the smart detection hook to determine if existing pages have legacy content.
|
|
88
|
+
* @default 'layout'
|
|
89
|
+
*/
|
|
90
|
+
legacyBlocksFieldName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Whether to place applicable fields in the sidebar.
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
sidebarPosition?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Custom conversion type options for the conversion tracking field.
|
|
98
|
+
* Only used when includeConversion is true.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* ...getPuckFields({
|
|
103
|
+
* includeConversion: true,
|
|
104
|
+
* conversionTypeOptions: [
|
|
105
|
+
* { label: 'Registration', value: 'registration' },
|
|
106
|
+
* { label: 'Donation', value: 'donation' },
|
|
107
|
+
* { label: 'Course Start', value: 'course_start' },
|
|
108
|
+
* ],
|
|
109
|
+
* })
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
conversionTypeOptions?: ConversionTypeOption[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Puck Field Utilities
|
|
117
|
+
*
|
|
118
|
+
* Provides reusable field definitions for adding Puck support to existing collections.
|
|
119
|
+
* Use getPuckFields() for easy integration, or import individual fields for granular control.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Option 1: Use getPuckFields() for recommended defaults
|
|
124
|
+
* import { getPuckFields } from '@delmaredigital/payload-puck'
|
|
125
|
+
*
|
|
126
|
+
* const Pages: CollectionConfig = {
|
|
127
|
+
* slug: 'pages',
|
|
128
|
+
* fields: [
|
|
129
|
+
* // Your existing fields...
|
|
130
|
+
* ...getPuckFields({ includeSEO: false }),
|
|
131
|
+
* ],
|
|
132
|
+
* }
|
|
133
|
+
*
|
|
134
|
+
* // Option 2: Import individual fields
|
|
135
|
+
* import { puckDataField, editorVersionField } from '@delmaredigital/payload-puck'
|
|
136
|
+
*
|
|
137
|
+
* const Pages: CollectionConfig = {
|
|
138
|
+
* slug: 'pages',
|
|
139
|
+
* fields: [
|
|
140
|
+
* // Your existing fields...
|
|
141
|
+
* puckDataField,
|
|
142
|
+
* editorVersionField,
|
|
143
|
+
* ],
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Puck data field - stores the visual editor JSON data.
|
|
150
|
+
* This field is always hidden in the admin UI as it's managed via the visual editor.
|
|
151
|
+
*/
|
|
152
|
+
declare const puckDataField: Field;
|
|
153
|
+
/**
|
|
154
|
+
* Creates an editor version field with smart detection for hybrid setups.
|
|
155
|
+
*
|
|
156
|
+
* The field uses a beforeValidate hook to intelligently determine the editor version:
|
|
157
|
+
* - New pages: Default to 'puck' (or custom defaultValue)
|
|
158
|
+
* - Existing pages with legacy blocks but no puckData: Set to 'legacy'
|
|
159
|
+
* - Existing pages with puckData: Set to 'puck'
|
|
160
|
+
*
|
|
161
|
+
* This prevents existing legacy content from being incorrectly marked as 'puck'
|
|
162
|
+
* when the field is first added to a collection.
|
|
163
|
+
*
|
|
164
|
+
* @param defaultValue - The default editor version for NEW pages ('puck' or 'legacy')
|
|
165
|
+
* @param sidebar - Whether to position in the sidebar (default: true)
|
|
166
|
+
* @param legacyBlocksFieldName - Name of the legacy blocks field to check (default: 'layout')
|
|
167
|
+
*/
|
|
168
|
+
declare function createEditorVersionField(defaultValue?: 'legacy' | 'puck', sidebar?: boolean, legacyBlocksFieldName?: string): Field;
|
|
169
|
+
/**
|
|
170
|
+
* Pre-configured editor version field with 'puck' as default.
|
|
171
|
+
* Use createEditorVersionField() for custom configuration.
|
|
172
|
+
*/
|
|
173
|
+
declare const editorVersionField: Field;
|
|
174
|
+
/**
|
|
175
|
+
* Creates a page layout field with custom layouts.
|
|
176
|
+
*
|
|
177
|
+
* @param layouts - Array of layout definitions (defaults to DEFAULT_LAYOUTS)
|
|
178
|
+
* @param sidebar - Whether to position in the sidebar (default: true)
|
|
179
|
+
*/
|
|
180
|
+
declare function createPageLayoutField(layouts?: LayoutDefinition[], sidebar?: boolean): Field;
|
|
181
|
+
/**
|
|
182
|
+
* Pre-configured page layout field with DEFAULT_LAYOUTS.
|
|
183
|
+
* Use createPageLayoutField() for custom layouts.
|
|
184
|
+
*/
|
|
185
|
+
declare const pageLayoutField: Field;
|
|
186
|
+
/**
|
|
187
|
+
* Homepage flag field - marks a page as the site homepage.
|
|
188
|
+
*/
|
|
189
|
+
declare const isHomepageField: Field;
|
|
190
|
+
/**
|
|
191
|
+
* SEO/Meta field group with all metadata fields.
|
|
192
|
+
* Uses the official @payloadcms/plugin-seo convention: meta.title, meta.description
|
|
193
|
+
*
|
|
194
|
+
* Includes: title, description, image, noindex, nofollow, excludeFromSitemap
|
|
195
|
+
*/
|
|
196
|
+
declare const seoFieldGroup: Field;
|
|
197
|
+
/**
|
|
198
|
+
* Pre-configured conversion tracking field group with default options.
|
|
199
|
+
* Use createConversionFieldGroup() for custom conversion types.
|
|
200
|
+
*/
|
|
201
|
+
declare const conversionFieldGroup: Field;
|
|
202
|
+
/**
|
|
203
|
+
* Returns an array of Puck-related field definitions for hybrid collection integration.
|
|
204
|
+
*
|
|
205
|
+
* Use this when you have an existing collection with legacy Payload blocks and want
|
|
206
|
+
* to ADD Puck support without replacing your entire collection configuration.
|
|
207
|
+
*
|
|
208
|
+
* @param options - Configuration options for which fields to include
|
|
209
|
+
* @returns Array of Field definitions to spread into your collection's fields array
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* import { getPuckFields } from '@delmaredigital/payload-puck'
|
|
214
|
+
*
|
|
215
|
+
* export const Pages: CollectionConfig = {
|
|
216
|
+
* slug: 'pages',
|
|
217
|
+
* fields: [
|
|
218
|
+
* // Your existing fields
|
|
219
|
+
* { name: 'title', type: 'text', required: true },
|
|
220
|
+
* { name: 'slug', type: 'text', required: true },
|
|
221
|
+
*
|
|
222
|
+
* // Legacy Payload blocks (keep these!)
|
|
223
|
+
* { name: 'layout', type: 'blocks', blocks: [...] },
|
|
224
|
+
*
|
|
225
|
+
* // Add Puck fields for hybrid editing
|
|
226
|
+
* ...getPuckFields({
|
|
227
|
+
* includeSEO: false, // You have your own SEO fields
|
|
228
|
+
* includeConversion: true, // Include conversion tracking
|
|
229
|
+
* includeEditorVersion: true,
|
|
230
|
+
* }),
|
|
231
|
+
* ],
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare function getPuckFields(options?: GetPuckFieldsOptions): Field[];
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Generates a Pages collection configuration for Puck
|
|
239
|
+
*/
|
|
240
|
+
declare function generatePagesCollection(slug: string, options: PuckPluginOptions): CollectionConfig;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Templates Collection - Stores reusable Puck component configurations
|
|
244
|
+
*
|
|
245
|
+
* This collection stores serialized Puck component data that can be
|
|
246
|
+
* loaded into Template components for reuse across pages.
|
|
247
|
+
*/
|
|
248
|
+
declare const TemplatesCollection: CollectionConfig;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Generates the UI field configuration for the Edit with Puck button
|
|
252
|
+
*/
|
|
253
|
+
declare function generatePuckEditField(collectionSlug: string, adminConfig?: PuckAdminConfig): Field;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a Payload plugin that integrates Puck visual page builder
|
|
256
|
+
*
|
|
257
|
+
* This plugin:
|
|
258
|
+
* - Generates a Pages collection with puckData field
|
|
259
|
+
* - Adds an "Edit with Puck" button in the admin document view
|
|
260
|
+
*
|
|
261
|
+
* The Puck editor itself runs outside of Payload admin. Create your own
|
|
262
|
+
* editor page (e.g., /pages/[id]/edit) using the PuckEditor component.
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* import { createPuckPlugin } from '@delmaredigital/payload-puck/plugin'
|
|
267
|
+
*
|
|
268
|
+
* export default buildConfig({
|
|
269
|
+
* plugins: [
|
|
270
|
+
* createPuckPlugin({
|
|
271
|
+
* pagesCollection: 'pages',
|
|
272
|
+
* access: {
|
|
273
|
+
* read: () => true,
|
|
274
|
+
* create: ({ req }) => !!req.user,
|
|
275
|
+
* update: ({ req }) => !!req.user,
|
|
276
|
+
* delete: ({ req }) => req.user?.role === 'admin',
|
|
277
|
+
* },
|
|
278
|
+
* admin: {
|
|
279
|
+
* editorPathPattern: '/pages/{id}/edit',
|
|
280
|
+
* buttonLabel: 'Visual Editor',
|
|
281
|
+
* },
|
|
282
|
+
* }),
|
|
283
|
+
* ],
|
|
284
|
+
* })
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
declare function createPuckPlugin(options?: PuckPluginOptions): Plugin;
|
|
288
|
+
|
|
289
|
+
export { type GetPuckFieldsOptions, PuckAdminConfig, PuckPluginOptions, TemplatesCollection, conversionFieldGroup, createEditorVersionField, createPageLayoutField, createPuckPlugin, editorVersionField, generatePagesCollection, generatePuckEditField, getPuckFields, isHomepageField, pageLayoutField, puckDataField, seoFieldGroup };
|