@ckc-net/puck-extended 0.2.1 → 0.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Hugo Debard
3
+ Copyright (c) 2025 CKC-Net
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,182 @@
1
+ ![puck-extended](/.github/puck-extended-banner.jpg)
2
+
3
+ # Puck Extended
4
+
5
+ A component library that extends [Puck](https://github.com/puckeditor/puck) — the open-source, headless visual page editor for React — with additional UI components, field overrides, media/page pickers, rich text extensions, and design system utilities.
6
+
7
+ ## What is Puck?
8
+
9
+ [Puck](https://puckeditor.com/) is an open-source visual editor for React that lets developers build custom drag-and-drop page builders. You define your components and their editable fields; Puck provides the editing interface and renders the result. `puck-extended` is a companion package that augments Puck with ready-to-use components and helpers.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @ckc-net/puck-extended
15
+ ```
16
+
17
+ ## Features
18
+
19
+ ### Editor overrides plugin
20
+
21
+ Drop-in replacements for Puck's default editor UI: improved field labels with tooltips, grouped fields, and polished inputs (text, textarea, number with unit, select, radio, checkbox).
22
+
23
+ ```tsx
24
+ import { createPuckOverridesPlugin } from '@ckc-net/puck-extended'
25
+
26
+ const puckConfig = {
27
+ components: { /* ... */ },
28
+ plugins: [createPuckOverridesPlugin()],
29
+ }
30
+ ```
31
+
32
+ ### MediaPicker
33
+
34
+ A full-featured media browser field: paginated library, search, drag-and-drop upload with progress, and support for images, videos and PDFs. Works in URL mode or ID-reference mode.
35
+
36
+ ```tsx
37
+ import { MediaPicker } from '@ckc-net/puck-extended'
38
+
39
+ // Inside a Puck field render
40
+ <MediaPicker
41
+ value={value}
42
+ onChange={onChange}
43
+ mode="reference"
44
+ />
45
+ ```
46
+
47
+ Resolve a media reference to a URL at render time:
48
+
49
+ ```tsx
50
+ import { useMediaUrl } from '@ckc-net/puck-extended'
51
+
52
+ const url = useMediaUrl(value) // returns resolved URL string
53
+ ```
54
+
55
+ ### PagePicker
56
+
57
+ Browse and search published pages, returning either a URL string or a page reference object. Useful for internal link fields.
58
+
59
+ ```tsx
60
+ import { PagePicker } from '@ckc-net/puck-extended'
61
+
62
+ <PagePicker value={value} onChange={onChange} />
63
+ ```
64
+
65
+ ```tsx
66
+ import { usePageUrl } from '@ckc-net/puck-extended'
67
+
68
+ const url = usePageUrl(value)
69
+ ```
70
+
71
+ ### ColorPicker
72
+
73
+ Color selection with a predefined palette (Tailwind-inspired swatches), a grayscale row, and a free hex input.
74
+
75
+ ```tsx
76
+ import { ColorPicker } from '@ckc-net/puck-extended'
77
+
78
+ <ColorPicker value={color} onChange={setColor} />
79
+ ```
80
+
81
+ ### Rich text extensions
82
+
83
+ Extensions for Puck's rich text toolbar (requires Tiptap):
84
+
85
+ - **RichTextMenuColorPicker** — inline text color picker with preset colors and custom hex input
86
+ - **RichTextMenuLink** — link insertion popover backed by PagePicker
87
+
88
+ ```tsx
89
+ import { RichTextMenuColorPicker, RichTextMenuLink } from '@ckc-net/puck-extended'
90
+ ```
91
+
92
+ ### Template block
93
+
94
+ Save and restore full page layouts. Supports localStorage (default) or a REST API backend for sharing templates across users.
95
+
96
+ ```tsx
97
+ import { createTemplateBlock } from '@ckc-net/puck-extended'
98
+
99
+ const TemplateBlock = createTemplateBlock({
100
+ storageKey: 'my-project',
101
+ // optional: use a REST API instead of localStorage
102
+ apiUrl: () => '/api/templates',
103
+ getHeaders: () => ({ 'X-CSRF-TOKEN': getCsrfToken() }),
104
+ })
105
+ ```
106
+
107
+ Register `TemplateBlock` as a Puck component to let editors save and reload layouts.
108
+
109
+ ### UI components
110
+
111
+ A set of accessible Base UI wrapper components, all styled with Tailwind CSS:
112
+
113
+ | Component | Description |
114
+ |-----------|-------------|
115
+ | `Accordion` | Collapsible sections |
116
+ | `Badge` | Status labels |
117
+ | `Button` | Action button with variants |
118
+ | `Checkbox` | Controlled checkbox |
119
+ | `Dialog` | Modal dialog |
120
+ | `Input` / `InputGroup` | Text input with optional addons |
121
+ | `Menu` | Dropdown menu |
122
+ | `Pagination` | Page navigation |
123
+ | `Popover` | Floating popover |
124
+ | `Radio` / `RadioGroup` | Radio selection |
125
+ | `ScrollArea` | Custom scrollable container |
126
+ | `Select` | Dropdown select |
127
+ | `Switch` | Toggle switch |
128
+ | `Tabs` | Tabbed panels |
129
+ | `Textarea` | Multi-line input |
130
+ | `Toast` | Notification toasts |
131
+ | `Tooltip` | Hover tooltip |
132
+
133
+ ### Design utilities
134
+
135
+ Field-ready helpers for common CSS properties, ready to plug into any Puck component config:
136
+
137
+ ```ts
138
+ import {
139
+ animation,
140
+ customClasses,
141
+ display,
142
+ fontWeight,
143
+ lineHeight,
144
+ margin,
145
+ padding,
146
+ position,
147
+ size,
148
+ spacing,
149
+ textAlign,
150
+ textColor,
151
+ textDecoration,
152
+ textSize,
153
+ textTransform,
154
+ typography,
155
+ } from '@ckc-net/puck-extended'
156
+ ```
157
+
158
+ Each utility exports a Puck field definition (or a set of fields) that can be spread into a component's `fields` config.
159
+
160
+ ### Image optimization hook
161
+
162
+ Generate responsive `srcSet` and `sizes` attributes from a single image URL:
163
+
164
+ ```tsx
165
+ import { useOptimizedImage } from '@ckc-net/puck-extended'
166
+
167
+ const { src, srcSet, sizes } = useOptimizedImage(url, {
168
+ breakpoints: [640, 1024, 1920],
169
+ })
170
+ ```
171
+
172
+ ## Development
173
+
174
+ ```bash
175
+ npm run dev # Watch mode (JS + CSS)
176
+ npm run build # Production build
177
+ npm run format # Prettier
178
+ ```
179
+
180
+ ## License
181
+
182
+ MIT — [CKC-Net](https://github.com/ckc-net)