@vasttrader/puck-config 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 +22 -0
- package/README.md +130 -0
- package/dist/index.d.mts +164 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +783 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +753 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# For MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vast Trader
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
EOF
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @vasttrader/puck-config
|
|
2
|
+
|
|
3
|
+
Prebuilt Puck editor components with TinyMCE integration for Next.js applications.
|
|
4
|
+
|
|
5
|
+
## 🚀 Installation
|
|
6
|
+
```bash
|
|
7
|
+
npm install @vasttrader/puck-config
|
|
8
|
+
# or
|
|
9
|
+
yarn add @vasttrader/puck-config
|
|
10
|
+
# or
|
|
11
|
+
pnpm add @vasttrader/puck-config
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 📦 Peer Dependencies
|
|
15
|
+
|
|
16
|
+
Make sure you have these installed:
|
|
17
|
+
```bash
|
|
18
|
+
npm install react react-dom next @measured/puck
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 🎯 Components
|
|
22
|
+
|
|
23
|
+
- **Editor**: Rich text editor
|
|
24
|
+
- **Space**: Flexible spacing component with responsive controls
|
|
25
|
+
- **Image**: Image component.
|
|
26
|
+
- **Accordion**: Collapsible accordion with multiple variants
|
|
27
|
+
|
|
28
|
+
## 📖 Usage
|
|
29
|
+
|
|
30
|
+
### Basic Setup
|
|
31
|
+
```typescript
|
|
32
|
+
// app/editor/page.tsx
|
|
33
|
+
"use client";
|
|
34
|
+
|
|
35
|
+
import { Puck } from "@measured/puck";
|
|
36
|
+
import { puckConfig } from "@vasttrader/puck-config";
|
|
37
|
+
import "@measured/puck/puck.css";
|
|
38
|
+
|
|
39
|
+
export default function EditorPage() {
|
|
40
|
+
return (
|
|
41
|
+
<Puck
|
|
42
|
+
config={puckConfig}
|
|
43
|
+
data={{
|
|
44
|
+
content: [],
|
|
45
|
+
root: {},
|
|
46
|
+
}}
|
|
47
|
+
onPublish={(data) => {
|
|
48
|
+
console.log("Published:", data);
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Using Individual Components
|
|
56
|
+
```typescript
|
|
57
|
+
import type { Config } from "@measured/puck";
|
|
58
|
+
import { Editor, Space, Image, Accordion } from "puck-config";
|
|
59
|
+
|
|
60
|
+
export const puckConfig: Config = {
|
|
61
|
+
categories: {
|
|
62
|
+
typography: {
|
|
63
|
+
components: ["Editor"],
|
|
64
|
+
},
|
|
65
|
+
media: {
|
|
66
|
+
components: ["Image"],
|
|
67
|
+
},
|
|
68
|
+
layout: {
|
|
69
|
+
components: ["Space"],
|
|
70
|
+
},
|
|
71
|
+
surfaces: {
|
|
72
|
+
components: ["Accordion"],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
components: {
|
|
76
|
+
Editor,
|
|
77
|
+
Image,
|
|
78
|
+
Space,
|
|
79
|
+
Accordion,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 🎨 Customization
|
|
86
|
+
|
|
87
|
+
All components include CSS classes for easy customization. See individual component documentation for class names.
|
|
88
|
+
|
|
89
|
+
### Example: Custom Accordion Styling
|
|
90
|
+
```css
|
|
91
|
+
.puck-accordion-trigger {
|
|
92
|
+
background: linear-gradient(to right, #eff6ff, #ffffff);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.puck-accordion-title {
|
|
96
|
+
color: #1e40af;
|
|
97
|
+
font-family: 'Inter', sans-serif;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 🔧 Next.js Configuration
|
|
102
|
+
|
|
103
|
+
For external images, configure `next.config.js`:
|
|
104
|
+
```javascript
|
|
105
|
+
/** @type {import('next').NextConfig} */
|
|
106
|
+
const nextConfig = {
|
|
107
|
+
images: {
|
|
108
|
+
remotePatterns: [
|
|
109
|
+
{
|
|
110
|
+
protocol: 'https',
|
|
111
|
+
hostname: '**',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
module.exports = nextConfig;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 📄 License
|
|
121
|
+
|
|
122
|
+
MIT © Vast Trader
|
|
123
|
+
|
|
124
|
+
## 🤝 Contributing
|
|
125
|
+
|
|
126
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
127
|
+
|
|
128
|
+
## 🐛 Issues
|
|
129
|
+
|
|
130
|
+
Report issues at: https://github.com/vasttrader/puck-config/issues
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as _measured_puck from '@measured/puck';
|
|
2
|
+
import { ComponentConfig } from '@measured/puck';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
type AccordionItem = {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
content: string;
|
|
9
|
+
isOpen?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type AccordionProps = {
|
|
12
|
+
items: AccordionItem[];
|
|
13
|
+
allowMultiple?: boolean;
|
|
14
|
+
defaultOpenFirst?: boolean;
|
|
15
|
+
variant?: "default" | "bordered" | "separated" | "minimal";
|
|
16
|
+
iconPosition?: "left" | "right";
|
|
17
|
+
icon?: "chevron" | "plus" | "arrow";
|
|
18
|
+
animationDuration?: number;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const Accordion: ComponentConfig<AccordionProps>;
|
|
22
|
+
|
|
23
|
+
type EditorProps = {
|
|
24
|
+
text?: string;
|
|
25
|
+
};
|
|
26
|
+
declare const Editor: {
|
|
27
|
+
fields: {
|
|
28
|
+
text: {
|
|
29
|
+
type: "custom";
|
|
30
|
+
render: ({ value, onChange }: {
|
|
31
|
+
field: _measured_puck.CustomField<string | undefined>;
|
|
32
|
+
name: string;
|
|
33
|
+
id: string;
|
|
34
|
+
value: string | undefined;
|
|
35
|
+
onChange: (value: string | undefined) => void;
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
defaultProps: {
|
|
41
|
+
text: string;
|
|
42
|
+
};
|
|
43
|
+
render: ({ text }: _measured_puck.WithId<_measured_puck.WithPuckProps<{
|
|
44
|
+
text?: string | undefined;
|
|
45
|
+
}>>) => react_jsx_runtime.JSX.Element;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type ImageProps = {
|
|
49
|
+
src: string;
|
|
50
|
+
alt: string;
|
|
51
|
+
width?: number;
|
|
52
|
+
height?: number;
|
|
53
|
+
objectFit?: "contain" | "cover" | "fill" | "none" | "scale-down";
|
|
54
|
+
objectPosition?: string;
|
|
55
|
+
alignment?: "left" | "center" | "right";
|
|
56
|
+
caption?: string;
|
|
57
|
+
link?: string;
|
|
58
|
+
openInNewTab?: boolean;
|
|
59
|
+
borderRadius?: number;
|
|
60
|
+
shadow?: "none" | "sm" | "md" | "lg" | "xl";
|
|
61
|
+
aspectRatio?: "16:9" | "4:3" | "1:1" | "21:9" | "custom" | "none";
|
|
62
|
+
customAspectRatio?: string;
|
|
63
|
+
maxWidth?: number;
|
|
64
|
+
loading?: "lazy" | "eager";
|
|
65
|
+
};
|
|
66
|
+
declare const Image: ComponentConfig<ImageProps>;
|
|
67
|
+
|
|
68
|
+
type SpaceProps = {
|
|
69
|
+
height?: number;
|
|
70
|
+
width?: number;
|
|
71
|
+
mobileHeight?: number;
|
|
72
|
+
mobileWidth?: number;
|
|
73
|
+
backgroundColor?: string;
|
|
74
|
+
showDivider?: boolean;
|
|
75
|
+
dividerColor?: string;
|
|
76
|
+
dividerStyle?: "solid" | "dashed" | "dotted";
|
|
77
|
+
dividerThickness?: number;
|
|
78
|
+
};
|
|
79
|
+
declare const Space: {
|
|
80
|
+
label: string;
|
|
81
|
+
fields: {
|
|
82
|
+
height: {
|
|
83
|
+
type: "number";
|
|
84
|
+
label: string;
|
|
85
|
+
min: number;
|
|
86
|
+
max: number;
|
|
87
|
+
};
|
|
88
|
+
mobileHeight: {
|
|
89
|
+
type: "number";
|
|
90
|
+
label: string;
|
|
91
|
+
min: number;
|
|
92
|
+
max: number;
|
|
93
|
+
};
|
|
94
|
+
width: {
|
|
95
|
+
type: "number";
|
|
96
|
+
label: string;
|
|
97
|
+
min: number;
|
|
98
|
+
max: number;
|
|
99
|
+
};
|
|
100
|
+
mobileWidth: {
|
|
101
|
+
type: "number";
|
|
102
|
+
label: string;
|
|
103
|
+
min: number;
|
|
104
|
+
max: number;
|
|
105
|
+
};
|
|
106
|
+
backgroundColor: {
|
|
107
|
+
type: "text";
|
|
108
|
+
label: string;
|
|
109
|
+
};
|
|
110
|
+
showDivider: {
|
|
111
|
+
type: "radio";
|
|
112
|
+
label: string;
|
|
113
|
+
options: ({
|
|
114
|
+
label: string;
|
|
115
|
+
value: true;
|
|
116
|
+
} | {
|
|
117
|
+
label: string;
|
|
118
|
+
value: false;
|
|
119
|
+
})[];
|
|
120
|
+
};
|
|
121
|
+
dividerColor: {
|
|
122
|
+
type: "text";
|
|
123
|
+
label: string;
|
|
124
|
+
};
|
|
125
|
+
dividerStyle: {
|
|
126
|
+
type: "select";
|
|
127
|
+
label: string;
|
|
128
|
+
options: {
|
|
129
|
+
label: string;
|
|
130
|
+
value: string;
|
|
131
|
+
}[];
|
|
132
|
+
};
|
|
133
|
+
dividerThickness: {
|
|
134
|
+
type: "number";
|
|
135
|
+
label: string;
|
|
136
|
+
min: number;
|
|
137
|
+
max: number;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
defaultProps: {
|
|
141
|
+
height: number;
|
|
142
|
+
width: number;
|
|
143
|
+
mobileHeight: number;
|
|
144
|
+
mobileWidth: number;
|
|
145
|
+
backgroundColor: string;
|
|
146
|
+
showDivider: false;
|
|
147
|
+
dividerColor: string;
|
|
148
|
+
dividerStyle: "solid";
|
|
149
|
+
dividerThickness: number;
|
|
150
|
+
};
|
|
151
|
+
render: ({ height, width, mobileHeight, mobileWidth, backgroundColor, showDivider, dividerColor, dividerStyle, dividerThickness, }: _measured_puck.WithId<_measured_puck.WithPuckProps<{
|
|
152
|
+
height?: number | undefined;
|
|
153
|
+
width?: number | undefined;
|
|
154
|
+
mobileHeight?: number | undefined;
|
|
155
|
+
mobileWidth?: number | undefined;
|
|
156
|
+
backgroundColor?: string | undefined;
|
|
157
|
+
showDivider?: boolean | undefined;
|
|
158
|
+
dividerColor?: string | undefined;
|
|
159
|
+
dividerStyle?: "solid" | "dashed" | "dotted" | undefined;
|
|
160
|
+
dividerThickness?: number | undefined;
|
|
161
|
+
}>>) => react_jsx_runtime.JSX.Element;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { Accordion, type AccordionItem, type AccordionProps, Editor, type EditorProps, Image, type ImageProps, Space, type SpaceProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as _measured_puck from '@measured/puck';
|
|
2
|
+
import { ComponentConfig } from '@measured/puck';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
type AccordionItem = {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
content: string;
|
|
9
|
+
isOpen?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type AccordionProps = {
|
|
12
|
+
items: AccordionItem[];
|
|
13
|
+
allowMultiple?: boolean;
|
|
14
|
+
defaultOpenFirst?: boolean;
|
|
15
|
+
variant?: "default" | "bordered" | "separated" | "minimal";
|
|
16
|
+
iconPosition?: "left" | "right";
|
|
17
|
+
icon?: "chevron" | "plus" | "arrow";
|
|
18
|
+
animationDuration?: number;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const Accordion: ComponentConfig<AccordionProps>;
|
|
22
|
+
|
|
23
|
+
type EditorProps = {
|
|
24
|
+
text?: string;
|
|
25
|
+
};
|
|
26
|
+
declare const Editor: {
|
|
27
|
+
fields: {
|
|
28
|
+
text: {
|
|
29
|
+
type: "custom";
|
|
30
|
+
render: ({ value, onChange }: {
|
|
31
|
+
field: _measured_puck.CustomField<string | undefined>;
|
|
32
|
+
name: string;
|
|
33
|
+
id: string;
|
|
34
|
+
value: string | undefined;
|
|
35
|
+
onChange: (value: string | undefined) => void;
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
defaultProps: {
|
|
41
|
+
text: string;
|
|
42
|
+
};
|
|
43
|
+
render: ({ text }: _measured_puck.WithId<_measured_puck.WithPuckProps<{
|
|
44
|
+
text?: string | undefined;
|
|
45
|
+
}>>) => react_jsx_runtime.JSX.Element;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type ImageProps = {
|
|
49
|
+
src: string;
|
|
50
|
+
alt: string;
|
|
51
|
+
width?: number;
|
|
52
|
+
height?: number;
|
|
53
|
+
objectFit?: "contain" | "cover" | "fill" | "none" | "scale-down";
|
|
54
|
+
objectPosition?: string;
|
|
55
|
+
alignment?: "left" | "center" | "right";
|
|
56
|
+
caption?: string;
|
|
57
|
+
link?: string;
|
|
58
|
+
openInNewTab?: boolean;
|
|
59
|
+
borderRadius?: number;
|
|
60
|
+
shadow?: "none" | "sm" | "md" | "lg" | "xl";
|
|
61
|
+
aspectRatio?: "16:9" | "4:3" | "1:1" | "21:9" | "custom" | "none";
|
|
62
|
+
customAspectRatio?: string;
|
|
63
|
+
maxWidth?: number;
|
|
64
|
+
loading?: "lazy" | "eager";
|
|
65
|
+
};
|
|
66
|
+
declare const Image: ComponentConfig<ImageProps>;
|
|
67
|
+
|
|
68
|
+
type SpaceProps = {
|
|
69
|
+
height?: number;
|
|
70
|
+
width?: number;
|
|
71
|
+
mobileHeight?: number;
|
|
72
|
+
mobileWidth?: number;
|
|
73
|
+
backgroundColor?: string;
|
|
74
|
+
showDivider?: boolean;
|
|
75
|
+
dividerColor?: string;
|
|
76
|
+
dividerStyle?: "solid" | "dashed" | "dotted";
|
|
77
|
+
dividerThickness?: number;
|
|
78
|
+
};
|
|
79
|
+
declare const Space: {
|
|
80
|
+
label: string;
|
|
81
|
+
fields: {
|
|
82
|
+
height: {
|
|
83
|
+
type: "number";
|
|
84
|
+
label: string;
|
|
85
|
+
min: number;
|
|
86
|
+
max: number;
|
|
87
|
+
};
|
|
88
|
+
mobileHeight: {
|
|
89
|
+
type: "number";
|
|
90
|
+
label: string;
|
|
91
|
+
min: number;
|
|
92
|
+
max: number;
|
|
93
|
+
};
|
|
94
|
+
width: {
|
|
95
|
+
type: "number";
|
|
96
|
+
label: string;
|
|
97
|
+
min: number;
|
|
98
|
+
max: number;
|
|
99
|
+
};
|
|
100
|
+
mobileWidth: {
|
|
101
|
+
type: "number";
|
|
102
|
+
label: string;
|
|
103
|
+
min: number;
|
|
104
|
+
max: number;
|
|
105
|
+
};
|
|
106
|
+
backgroundColor: {
|
|
107
|
+
type: "text";
|
|
108
|
+
label: string;
|
|
109
|
+
};
|
|
110
|
+
showDivider: {
|
|
111
|
+
type: "radio";
|
|
112
|
+
label: string;
|
|
113
|
+
options: ({
|
|
114
|
+
label: string;
|
|
115
|
+
value: true;
|
|
116
|
+
} | {
|
|
117
|
+
label: string;
|
|
118
|
+
value: false;
|
|
119
|
+
})[];
|
|
120
|
+
};
|
|
121
|
+
dividerColor: {
|
|
122
|
+
type: "text";
|
|
123
|
+
label: string;
|
|
124
|
+
};
|
|
125
|
+
dividerStyle: {
|
|
126
|
+
type: "select";
|
|
127
|
+
label: string;
|
|
128
|
+
options: {
|
|
129
|
+
label: string;
|
|
130
|
+
value: string;
|
|
131
|
+
}[];
|
|
132
|
+
};
|
|
133
|
+
dividerThickness: {
|
|
134
|
+
type: "number";
|
|
135
|
+
label: string;
|
|
136
|
+
min: number;
|
|
137
|
+
max: number;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
defaultProps: {
|
|
141
|
+
height: number;
|
|
142
|
+
width: number;
|
|
143
|
+
mobileHeight: number;
|
|
144
|
+
mobileWidth: number;
|
|
145
|
+
backgroundColor: string;
|
|
146
|
+
showDivider: false;
|
|
147
|
+
dividerColor: string;
|
|
148
|
+
dividerStyle: "solid";
|
|
149
|
+
dividerThickness: number;
|
|
150
|
+
};
|
|
151
|
+
render: ({ height, width, mobileHeight, mobileWidth, backgroundColor, showDivider, dividerColor, dividerStyle, dividerThickness, }: _measured_puck.WithId<_measured_puck.WithPuckProps<{
|
|
152
|
+
height?: number | undefined;
|
|
153
|
+
width?: number | undefined;
|
|
154
|
+
mobileHeight?: number | undefined;
|
|
155
|
+
mobileWidth?: number | undefined;
|
|
156
|
+
backgroundColor?: string | undefined;
|
|
157
|
+
showDivider?: boolean | undefined;
|
|
158
|
+
dividerColor?: string | undefined;
|
|
159
|
+
dividerStyle?: "solid" | "dashed" | "dotted" | undefined;
|
|
160
|
+
dividerThickness?: number | undefined;
|
|
161
|
+
}>>) => react_jsx_runtime.JSX.Element;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { Accordion, type AccordionItem, type AccordionProps, Editor, type EditorProps, Image, type ImageProps, Space, type SpaceProps };
|