@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,4483 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { IconArrowLeft, IconPointer, IconHandClick, IconCheck, IconAlertTriangle, IconEye, IconExternalLink, IconLoader2, IconDeviceFloppy, IconUpload, IconX, IconHistory, IconChevronDown, IconRotate } from '@tabler/icons-react';
|
|
3
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { memo, useCallback, useMemo, useEffect, useState, useRef, createContext, createElement } from 'react';
|
|
6
|
+
import { clsx } from 'clsx';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { createUsePuck, Render, Puck } from '@measured/puck';
|
|
9
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
10
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
12
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
13
|
+
import { useRouter, useParams, useSearchParams } from 'next/navigation';
|
|
14
|
+
import '@measured/puck/puck.css';
|
|
15
|
+
import headingAnalyzer from '@measured/puck-plugin-heading-analyzer';
|
|
16
|
+
export { default as headingAnalyzer } from '@measured/puck-plugin-heading-analyzer';
|
|
17
|
+
import '@measured/puck-plugin-heading-analyzer/dist/index.css';
|
|
18
|
+
import dynamic from 'next/dynamic';
|
|
19
|
+
|
|
20
|
+
var __defProp = Object.defineProperty;
|
|
21
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
22
|
+
var __esm = (fn, res) => function __init() {
|
|
23
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
24
|
+
};
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
function LoadingState({ message = "Loading editor..." }) {
|
|
30
|
+
return /* @__PURE__ */ jsx("div", { className: "h-screen flex items-center justify-center bg-gray-50", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
31
|
+
/* @__PURE__ */ jsx(IconLoader2, { className: "h-8 w-8 animate-spin text-gray-600 mx-auto mb-4" }),
|
|
32
|
+
/* @__PURE__ */ jsx("p", { className: "text-gray-600", children: message })
|
|
33
|
+
] }) });
|
|
34
|
+
}
|
|
35
|
+
var init_LoadingState = __esm({
|
|
36
|
+
"src/editor/components/LoadingState.tsx"() {
|
|
37
|
+
"use client";
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
var VersionHistory;
|
|
41
|
+
var init_VersionHistory = __esm({
|
|
42
|
+
"src/editor/components/VersionHistory.tsx"() {
|
|
43
|
+
"use client";
|
|
44
|
+
VersionHistory = memo(function VersionHistory2({
|
|
45
|
+
pageId,
|
|
46
|
+
apiEndpoint = "/api/puck/pages",
|
|
47
|
+
onRestore,
|
|
48
|
+
disabled
|
|
49
|
+
}) {
|
|
50
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
51
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
52
|
+
const [isRestoring, setIsRestoring] = useState(false);
|
|
53
|
+
const [versions, setVersions] = useState([]);
|
|
54
|
+
const [error, setError] = useState(null);
|
|
55
|
+
const [isAvailable, setIsAvailable] = useState(null);
|
|
56
|
+
const dropdownRef = useRef(null);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
async function checkAvailability() {
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(`${apiEndpoint}/${pageId}/versions?limit=1`, {
|
|
61
|
+
method: "GET"
|
|
62
|
+
});
|
|
63
|
+
setIsAvailable(response.status !== 404);
|
|
64
|
+
} catch {
|
|
65
|
+
setIsAvailable(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
checkAvailability();
|
|
69
|
+
}, [apiEndpoint, pageId]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
function handleClickOutside(event) {
|
|
72
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
73
|
+
setIsOpen(false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
77
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
78
|
+
}, []);
|
|
79
|
+
const fetchVersions = useCallback(async () => {
|
|
80
|
+
setIsLoading(true);
|
|
81
|
+
setError(null);
|
|
82
|
+
try {
|
|
83
|
+
const response = await fetch(`${apiEndpoint}/${pageId}/versions?limit=20`);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
throw new Error("Failed to fetch versions");
|
|
86
|
+
}
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
setVersions(data.docs || []);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
setError(err instanceof Error ? err.message : "Failed to load versions");
|
|
91
|
+
console.error("Error fetching versions:", err);
|
|
92
|
+
} finally {
|
|
93
|
+
setIsLoading(false);
|
|
94
|
+
}
|
|
95
|
+
}, [apiEndpoint, pageId]);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (isOpen) {
|
|
98
|
+
fetchVersions();
|
|
99
|
+
}
|
|
100
|
+
}, [isOpen, fetchVersions]);
|
|
101
|
+
const handleRestore = useCallback(
|
|
102
|
+
async (version) => {
|
|
103
|
+
if (!confirm(`Restore this version from ${formatDate(version.updatedAt)}? This will overwrite current changes.`)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setIsRestoring(true);
|
|
107
|
+
try {
|
|
108
|
+
const response = await fetch(`${apiEndpoint}/${pageId}/versions`, {
|
|
109
|
+
method: "POST",
|
|
110
|
+
headers: { "Content-Type": "application/json" },
|
|
111
|
+
body: JSON.stringify({ versionId: version.id })
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error("Failed to restore version");
|
|
115
|
+
}
|
|
116
|
+
onRestore?.(version);
|
|
117
|
+
setIsOpen(false);
|
|
118
|
+
window.location.reload();
|
|
119
|
+
} catch (err) {
|
|
120
|
+
setError(err instanceof Error ? err.message : "Failed to restore version");
|
|
121
|
+
console.error("Error restoring version:", err);
|
|
122
|
+
} finally {
|
|
123
|
+
setIsRestoring(false);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[apiEndpoint, pageId, onRestore]
|
|
127
|
+
);
|
|
128
|
+
function formatDate(dateStr) {
|
|
129
|
+
const date = new Date(dateStr);
|
|
130
|
+
const now = /* @__PURE__ */ new Date();
|
|
131
|
+
const diffMs = now.getTime() - date.getTime();
|
|
132
|
+
const diffMins = Math.floor(diffMs / 6e4);
|
|
133
|
+
const diffHours = Math.floor(diffMs / 36e5);
|
|
134
|
+
const diffDays = Math.floor(diffMs / 864e5);
|
|
135
|
+
if (diffMins < 1) return "Just now";
|
|
136
|
+
if (diffMins < 60) return `${diffMins}m ago`;
|
|
137
|
+
if (diffHours < 24) return `${diffHours}h ago`;
|
|
138
|
+
if (diffDays < 7) return `${diffDays}d ago`;
|
|
139
|
+
return date.toLocaleDateString();
|
|
140
|
+
}
|
|
141
|
+
function formatTime(dateStr) {
|
|
142
|
+
const date = new Date(dateStr);
|
|
143
|
+
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
144
|
+
}
|
|
145
|
+
if (isAvailable !== true) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const baseBtn = "inline-flex items-center whitespace-nowrap px-3 py-1.5 text-sm font-medium rounded-md transition-colors";
|
|
149
|
+
const secondaryBtn = `${baseBtn} text-gray-700 bg-white border border-gray-300 hover:bg-gray-100`;
|
|
150
|
+
return /* @__PURE__ */ jsxs("div", { ref: dropdownRef, className: "relative", children: [
|
|
151
|
+
/* @__PURE__ */ jsxs(
|
|
152
|
+
"button",
|
|
153
|
+
{
|
|
154
|
+
type: "button",
|
|
155
|
+
onClick: () => setIsOpen(!isOpen),
|
|
156
|
+
disabled,
|
|
157
|
+
className: `${secondaryBtn} disabled:opacity-50 disabled:cursor-not-allowed`,
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ jsx(IconHistory, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
|
|
160
|
+
"History",
|
|
161
|
+
/* @__PURE__ */ jsx(IconChevronDown, { className: "h-3 w-3 ml-1 flex-shrink-0" })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
isOpen && /* @__PURE__ */ jsxs(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
className: "absolute top-full right-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-80 max-h-[400px] overflow-hidden",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsxs(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: "border-b border-gray-200 flex items-center justify-between px-4 py-3",
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-sm text-gray-900", children: "Version History" }),
|
|
176
|
+
/* @__PURE__ */ jsx(
|
|
177
|
+
"button",
|
|
178
|
+
{
|
|
179
|
+
type: "button",
|
|
180
|
+
onClick: () => setIsOpen(false),
|
|
181
|
+
className: "text-gray-400 hover:text-gray-600 transition-colors p-1",
|
|
182
|
+
children: /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" })
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[340px] overflow-y-auto", children: isLoading ? /* @__PURE__ */ jsx(
|
|
189
|
+
"div",
|
|
190
|
+
{
|
|
191
|
+
className: "flex items-center justify-center p-8",
|
|
192
|
+
children: /* @__PURE__ */ jsx(IconLoader2, { className: "h-5 w-5 animate-spin text-gray-400" })
|
|
193
|
+
}
|
|
194
|
+
) : error ? /* @__PURE__ */ jsx(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
className: "text-sm text-red-600 p-4 text-center",
|
|
198
|
+
children: error
|
|
199
|
+
}
|
|
200
|
+
) : versions.length === 0 ? /* @__PURE__ */ jsx(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
className: "text-sm text-gray-500 p-4 text-center",
|
|
204
|
+
children: "No version history available"
|
|
205
|
+
}
|
|
206
|
+
) : /* @__PURE__ */ jsx("div", { className: "p-2", children: versions.map((version, index) => /* @__PURE__ */ jsxs(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
className: "hover:bg-gray-50 rounded-md transition-colors flex items-center justify-between px-3 py-2.5 gap-3",
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
212
|
+
/* @__PURE__ */ jsxs(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
className: "flex items-center gap-2",
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-gray-900", children: formatDate(version.updatedAt) }),
|
|
218
|
+
index === 0 && /* @__PURE__ */ jsx(
|
|
219
|
+
"span",
|
|
220
|
+
{
|
|
221
|
+
className: "text-xs font-medium rounded-full px-2 py-0.5 bg-blue-100 text-blue-700",
|
|
222
|
+
children: "Current"
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
version.version._status === "published" && /* @__PURE__ */ jsx(
|
|
226
|
+
"span",
|
|
227
|
+
{
|
|
228
|
+
className: "text-xs font-medium rounded-full px-2 py-0.5 bg-green-100 text-green-700",
|
|
229
|
+
children: "Published"
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
version.autosave && /* @__PURE__ */ jsx(
|
|
233
|
+
"span",
|
|
234
|
+
{
|
|
235
|
+
className: "text-xs text-gray-400",
|
|
236
|
+
title: "Autosaved",
|
|
237
|
+
children: "(auto)"
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
/* @__PURE__ */ jsxs("div", { className: "text-xs text-gray-500 mt-0.5", children: [
|
|
244
|
+
formatTime(version.updatedAt),
|
|
245
|
+
version.version.title && /* @__PURE__ */ jsxs("span", { children: [
|
|
246
|
+
" \xB7 ",
|
|
247
|
+
version.version.title
|
|
248
|
+
] })
|
|
249
|
+
] })
|
|
250
|
+
] }),
|
|
251
|
+
index > 0 && /* @__PURE__ */ jsxs(
|
|
252
|
+
"button",
|
|
253
|
+
{
|
|
254
|
+
type: "button",
|
|
255
|
+
onClick: () => handleRestore(version),
|
|
256
|
+
disabled: isRestoring,
|
|
257
|
+
className: "text-xs font-medium text-blue-600 hover:text-blue-800 transition-colors disabled:opacity-50 flex items-center gap-1 px-2 py-1 flex-shrink-0",
|
|
258
|
+
children: [
|
|
259
|
+
isRestoring ? /* @__PURE__ */ jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ jsx(IconRotate, { className: "h-3 w-3" }),
|
|
260
|
+
"Restore"
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
index === 0 && /* @__PURE__ */ jsx("span", { className: "text-gray-400 flex-shrink-0", children: /* @__PURE__ */ jsx(IconCheck, { className: "h-4 w-4" }) })
|
|
265
|
+
]
|
|
266
|
+
},
|
|
267
|
+
version.id
|
|
268
|
+
)) }) })
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
] });
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
function cn(...inputs) {
|
|
277
|
+
return twMerge(clsx(inputs));
|
|
278
|
+
}
|
|
279
|
+
var init_utils = __esm({
|
|
280
|
+
"src/lib/utils.ts"() {
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
var usePuck, HeaderActions;
|
|
284
|
+
var init_HeaderActions = __esm({
|
|
285
|
+
"src/editor/components/HeaderActions.tsx"() {
|
|
286
|
+
"use client";
|
|
287
|
+
init_VersionHistory();
|
|
288
|
+
init_utils();
|
|
289
|
+
usePuck = createUsePuck();
|
|
290
|
+
HeaderActions = memo(function HeaderActions2({
|
|
291
|
+
children,
|
|
292
|
+
onBack,
|
|
293
|
+
onPreview,
|
|
294
|
+
onSave,
|
|
295
|
+
onPublish,
|
|
296
|
+
isSaving,
|
|
297
|
+
hasUnsavedChanges,
|
|
298
|
+
lastSaved,
|
|
299
|
+
documentStatus,
|
|
300
|
+
wasPublished,
|
|
301
|
+
actionsStart,
|
|
302
|
+
actionsEnd,
|
|
303
|
+
showSaveDraft = true,
|
|
304
|
+
showViewPage = true,
|
|
305
|
+
showInteractiveToggle = false,
|
|
306
|
+
showPreviewButton = true,
|
|
307
|
+
onOpenPreview,
|
|
308
|
+
showVersionHistory = true,
|
|
309
|
+
pageId,
|
|
310
|
+
apiEndpoint = "/api/puck/pages",
|
|
311
|
+
saveError,
|
|
312
|
+
onDismissError
|
|
313
|
+
}) {
|
|
314
|
+
const appState = usePuck((s) => s.appState);
|
|
315
|
+
const dispatch = usePuck((s) => s.dispatch);
|
|
316
|
+
const isInteractive = appState.ui.previewMode === "interactive";
|
|
317
|
+
const togglePreviewMode = useCallback(() => {
|
|
318
|
+
dispatch({
|
|
319
|
+
type: "setUi",
|
|
320
|
+
ui: {
|
|
321
|
+
previewMode: isInteractive ? "edit" : "interactive"
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}, [dispatch, isInteractive]);
|
|
325
|
+
const handleSaveClick = useCallback(() => {
|
|
326
|
+
onSave(appState.data);
|
|
327
|
+
}, [onSave, appState.data]);
|
|
328
|
+
const handlePublishClick = useCallback(() => {
|
|
329
|
+
if (onPublish) {
|
|
330
|
+
onPublish(appState.data);
|
|
331
|
+
}
|
|
332
|
+
}, [onPublish, appState.data]);
|
|
333
|
+
const btnBase = "inline-flex items-center whitespace-nowrap text-sm font-medium rounded-md transition-colors";
|
|
334
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
335
|
+
actionsStart,
|
|
336
|
+
/* @__PURE__ */ jsxs(
|
|
337
|
+
"button",
|
|
338
|
+
{
|
|
339
|
+
type: "button",
|
|
340
|
+
onClick: onBack,
|
|
341
|
+
className: cn(btnBase, "px-3 py-1.5 bg-white text-gray-700 border border-gray-300 rounded hover:bg-gray-50"),
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsx(IconArrowLeft, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
|
|
344
|
+
"Back"
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
documentStatus && (() => {
|
|
349
|
+
const isPublished = documentStatus === "published";
|
|
350
|
+
const hasUnpublishedChanges = documentStatus === "draft" && wasPublished;
|
|
351
|
+
let badgeLabel;
|
|
352
|
+
if (isPublished) {
|
|
353
|
+
badgeLabel = "Published";
|
|
354
|
+
} else if (hasUnpublishedChanges) {
|
|
355
|
+
badgeLabel = "Unpublished Changes";
|
|
356
|
+
} else {
|
|
357
|
+
badgeLabel = "Draft";
|
|
358
|
+
}
|
|
359
|
+
return /* @__PURE__ */ jsx(
|
|
360
|
+
"span",
|
|
361
|
+
{
|
|
362
|
+
className: cn(
|
|
363
|
+
"px-2.5 py-1 border rounded-full text-xs font-medium whitespace-nowrap",
|
|
364
|
+
isPublished && "bg-green-100 text-green-800 border-green-300",
|
|
365
|
+
hasUnpublishedChanges && "bg-orange-100 text-orange-700 border-orange-200",
|
|
366
|
+
!isPublished && !hasUnpublishedChanges && "bg-amber-100 text-amber-700 border-amber-200"
|
|
367
|
+
),
|
|
368
|
+
children: badgeLabel
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
})(),
|
|
372
|
+
showInteractiveToggle && /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
373
|
+
/* @__PURE__ */ jsxs(
|
|
374
|
+
"button",
|
|
375
|
+
{
|
|
376
|
+
type: "button",
|
|
377
|
+
onClick: () => isInteractive && togglePreviewMode(),
|
|
378
|
+
className: cn(
|
|
379
|
+
"inline-flex items-center gap-1 text-xs font-medium rounded transition-colors px-2.5 py-1.5 border",
|
|
380
|
+
!isInteractive ? "bg-blue-500 text-white border-blue-500" : "bg-gray-100 text-gray-500 border-gray-200"
|
|
381
|
+
),
|
|
382
|
+
children: [
|
|
383
|
+
/* @__PURE__ */ jsx(IconPointer, { className: "h-3.5 w-3.5" }),
|
|
384
|
+
"Edit"
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
),
|
|
388
|
+
/* @__PURE__ */ jsxs(
|
|
389
|
+
"button",
|
|
390
|
+
{
|
|
391
|
+
type: "button",
|
|
392
|
+
onClick: () => !isInteractive && togglePreviewMode(),
|
|
393
|
+
className: cn(
|
|
394
|
+
"inline-flex items-center gap-1 text-xs font-medium rounded transition-colors px-2.5 py-1.5 border",
|
|
395
|
+
isInteractive ? "bg-blue-500 text-white border-blue-500" : "bg-gray-100 text-gray-500 border-gray-200"
|
|
396
|
+
),
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ jsx(IconHandClick, { className: "h-3.5 w-3.5" }),
|
|
399
|
+
"Interactive"
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
] }),
|
|
404
|
+
lastSaved && !saveError && /* @__PURE__ */ jsxs("span", { className: "text-xs text-gray-500 flex items-center gap-1 whitespace-nowrap", children: [
|
|
405
|
+
/* @__PURE__ */ jsx(IconCheck, { className: "h-3 w-3 flex-shrink-0" }),
|
|
406
|
+
"Saved ",
|
|
407
|
+
lastSaved.toLocaleTimeString()
|
|
408
|
+
] }),
|
|
409
|
+
hasUnsavedChanges && !saveError && /* @__PURE__ */ jsx("span", { className: "text-xs text-amber-600 font-medium whitespace-nowrap", children: "Unsaved" }),
|
|
410
|
+
saveError && /* @__PURE__ */ jsxs(
|
|
411
|
+
"button",
|
|
412
|
+
{
|
|
413
|
+
type: "button",
|
|
414
|
+
onClick: () => {
|
|
415
|
+
},
|
|
416
|
+
className: "flex items-center gap-1.5 px-2.5 py-1.5 bg-red-50 border border-red-200 rounded-md text-red-700 text-xs font-medium",
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ jsx(IconAlertTriangle, { className: "h-4 w-4 text-red-500 flex-shrink-0" }),
|
|
419
|
+
"Error"
|
|
420
|
+
]
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
saveError && /* @__PURE__ */ jsx(
|
|
424
|
+
"div",
|
|
425
|
+
{
|
|
426
|
+
className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/50",
|
|
427
|
+
onClick: onDismissError,
|
|
428
|
+
children: /* @__PURE__ */ jsxs(
|
|
429
|
+
"div",
|
|
430
|
+
{
|
|
431
|
+
className: "bg-white rounded-lg shadow-xl max-w-md w-full mx-4 overflow-hidden",
|
|
432
|
+
onClick: (e) => e.stopPropagation(),
|
|
433
|
+
children: [
|
|
434
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-5 py-4 border-b border-gray-200 bg-red-50", children: [
|
|
435
|
+
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0 w-10 h-10 rounded-full bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsx(IconAlertTriangle, { className: "h-5 w-5 text-red-600" }) }),
|
|
436
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
437
|
+
/* @__PURE__ */ jsx("h3", { className: "text-base font-semibold text-gray-900", children: "Save Failed" }),
|
|
438
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: "Unable to save your changes" })
|
|
439
|
+
] })
|
|
440
|
+
] }),
|
|
441
|
+
/* @__PURE__ */ jsx("div", { className: "px-5 py-4", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-700", children: saveError }) }),
|
|
442
|
+
/* @__PURE__ */ jsx("div", { className: "px-5 py-4 bg-gray-50 border-t border-gray-200 flex justify-end", children: /* @__PURE__ */ jsx(
|
|
443
|
+
"button",
|
|
444
|
+
{
|
|
445
|
+
type: "button",
|
|
446
|
+
onClick: onDismissError,
|
|
447
|
+
className: "px-4 py-2 bg-gray-900 text-white text-sm font-medium rounded-md hover:bg-gray-800 transition-colors",
|
|
448
|
+
children: "Close"
|
|
449
|
+
}
|
|
450
|
+
) })
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
)
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
showPreviewButton && onOpenPreview && /* @__PURE__ */ jsxs(
|
|
457
|
+
"button",
|
|
458
|
+
{
|
|
459
|
+
type: "button",
|
|
460
|
+
onClick: onOpenPreview,
|
|
461
|
+
disabled: isSaving,
|
|
462
|
+
className: cn(
|
|
463
|
+
btnBase,
|
|
464
|
+
"px-3 py-1.5 bg-blue-600 text-white border border-blue-600 rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
465
|
+
),
|
|
466
|
+
children: [
|
|
467
|
+
/* @__PURE__ */ jsx(IconEye, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
|
|
468
|
+
"Preview"
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
),
|
|
472
|
+
showViewPage && /* @__PURE__ */ jsxs(
|
|
473
|
+
"button",
|
|
474
|
+
{
|
|
475
|
+
type: "button",
|
|
476
|
+
onClick: onPreview,
|
|
477
|
+
className: cn(btnBase, "px-3 py-1.5 bg-white text-gray-700 border border-gray-300 rounded hover:bg-gray-50"),
|
|
478
|
+
children: [
|
|
479
|
+
/* @__PURE__ */ jsx(IconExternalLink, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
|
|
480
|
+
"View"
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
),
|
|
484
|
+
showVersionHistory && pageId && /* @__PURE__ */ jsx(
|
|
485
|
+
VersionHistory,
|
|
486
|
+
{
|
|
487
|
+
pageId,
|
|
488
|
+
apiEndpoint,
|
|
489
|
+
disabled: isSaving
|
|
490
|
+
}
|
|
491
|
+
),
|
|
492
|
+
showSaveDraft && /* @__PURE__ */ jsxs(
|
|
493
|
+
"button",
|
|
494
|
+
{
|
|
495
|
+
type: "button",
|
|
496
|
+
onClick: handleSaveClick,
|
|
497
|
+
disabled: isSaving || !hasUnsavedChanges,
|
|
498
|
+
className: cn(
|
|
499
|
+
btnBase,
|
|
500
|
+
"px-3 py-1.5 bg-white text-gray-700 border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
501
|
+
),
|
|
502
|
+
children: [
|
|
503
|
+
isSaving ? /* @__PURE__ */ jsx(IconLoader2, { className: "h-4 w-4 mr-1 flex-shrink-0 animate-spin" }) : /* @__PURE__ */ jsx(IconDeviceFloppy, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
|
|
504
|
+
"Save"
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
onPublish && /* @__PURE__ */ jsxs(
|
|
509
|
+
"button",
|
|
510
|
+
{
|
|
511
|
+
type: "button",
|
|
512
|
+
onClick: handlePublishClick,
|
|
513
|
+
disabled: isSaving,
|
|
514
|
+
className: cn(
|
|
515
|
+
btnBase,
|
|
516
|
+
"px-3 py-1.5 bg-blue-600 text-white border border-blue-600 rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
517
|
+
),
|
|
518
|
+
children: [
|
|
519
|
+
isSaving ? /* @__PURE__ */ jsx(IconLoader2, { className: "h-4 w-4 mr-1 flex-shrink-0 animate-spin" }) : /* @__PURE__ */ jsx(IconUpload, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
|
|
520
|
+
"Publish"
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
),
|
|
524
|
+
actionsEnd,
|
|
525
|
+
!onPublish && children
|
|
526
|
+
] });
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// src/fields/shared.ts
|
|
532
|
+
function cn2(...classes) {
|
|
533
|
+
return classes.filter(Boolean).join(" ");
|
|
534
|
+
}
|
|
535
|
+
function isLegacyWidthValue(value) {
|
|
536
|
+
if (!value || typeof value !== "object") return false;
|
|
537
|
+
const v = value;
|
|
538
|
+
return typeof v.maxWidth === "number" && typeof v.unit === "string" && typeof v.mode === "string" && !("minWidth" in v) && !("minHeight" in v) && !("maxHeight" in v);
|
|
539
|
+
}
|
|
540
|
+
function hexToRgb(hex) {
|
|
541
|
+
const clean = hex.replace(/^#/, "");
|
|
542
|
+
if (clean.length !== 6) return null;
|
|
543
|
+
const r = parseInt(clean.substring(0, 2), 16);
|
|
544
|
+
const g = parseInt(clean.substring(2, 4), 16);
|
|
545
|
+
const b = parseInt(clean.substring(4, 6), 16);
|
|
546
|
+
if (isNaN(r) || isNaN(g) || isNaN(b)) return null;
|
|
547
|
+
return { r, g, b };
|
|
548
|
+
}
|
|
549
|
+
function colorValueToCSS(color) {
|
|
550
|
+
if (!color?.hex) return void 0;
|
|
551
|
+
const rgb = hexToRgb(color.hex);
|
|
552
|
+
if (!rgb) return color.hex;
|
|
553
|
+
const opacity = (color.opacity ?? 100) / 100;
|
|
554
|
+
if (opacity === 1) {
|
|
555
|
+
return color.hex;
|
|
556
|
+
}
|
|
557
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
|
|
558
|
+
}
|
|
559
|
+
function paddingValueToCSS(padding) {
|
|
560
|
+
if (!padding) return void 0;
|
|
561
|
+
const { top, right, bottom, left, unit } = padding;
|
|
562
|
+
if (top === right && right === bottom && bottom === left) {
|
|
563
|
+
return `${top}${unit}`;
|
|
564
|
+
}
|
|
565
|
+
if (top === bottom && left === right) {
|
|
566
|
+
return `${top}${unit} ${right}${unit}`;
|
|
567
|
+
}
|
|
568
|
+
if (left === right) {
|
|
569
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit}`;
|
|
570
|
+
}
|
|
571
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit} ${left}${unit}`;
|
|
572
|
+
}
|
|
573
|
+
function marginValueToCSS(margin) {
|
|
574
|
+
if (!margin) return void 0;
|
|
575
|
+
const { top, right, bottom, left, unit } = margin;
|
|
576
|
+
if (top === right && right === bottom && bottom === left) {
|
|
577
|
+
return `${top}${unit}`;
|
|
578
|
+
}
|
|
579
|
+
if (top === bottom && left === right) {
|
|
580
|
+
return `${top}${unit} ${right}${unit}`;
|
|
581
|
+
}
|
|
582
|
+
if (left === right) {
|
|
583
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit}`;
|
|
584
|
+
}
|
|
585
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit} ${left}${unit}`;
|
|
586
|
+
}
|
|
587
|
+
function borderValueToCSS(border) {
|
|
588
|
+
if (!border || border.style === "none") return void 0;
|
|
589
|
+
const color = colorValueToCSS(border.color) || "#000000";
|
|
590
|
+
const style = {};
|
|
591
|
+
if (border.sides.top) {
|
|
592
|
+
style.borderTopWidth = `${border.width}px`;
|
|
593
|
+
style.borderTopStyle = border.style;
|
|
594
|
+
style.borderTopColor = color;
|
|
595
|
+
}
|
|
596
|
+
if (border.sides.right) {
|
|
597
|
+
style.borderRightWidth = `${border.width}px`;
|
|
598
|
+
style.borderRightStyle = border.style;
|
|
599
|
+
style.borderRightColor = color;
|
|
600
|
+
}
|
|
601
|
+
if (border.sides.bottom) {
|
|
602
|
+
style.borderBottomWidth = `${border.width}px`;
|
|
603
|
+
style.borderBottomStyle = border.style;
|
|
604
|
+
style.borderBottomColor = color;
|
|
605
|
+
}
|
|
606
|
+
if (border.sides.left) {
|
|
607
|
+
style.borderLeftWidth = `${border.width}px`;
|
|
608
|
+
style.borderLeftStyle = border.style;
|
|
609
|
+
style.borderLeftColor = color;
|
|
610
|
+
}
|
|
611
|
+
if (border.radius > 0) {
|
|
612
|
+
style.borderRadius = `${border.radius}px`;
|
|
613
|
+
}
|
|
614
|
+
return Object.keys(style).length > 0 ? style : void 0;
|
|
615
|
+
}
|
|
616
|
+
function widthValueToCSS(width) {
|
|
617
|
+
if (!width) return void 0;
|
|
618
|
+
const style = {};
|
|
619
|
+
if (width.mode === "full") {
|
|
620
|
+
style.width = "100%";
|
|
621
|
+
style.maxWidth = "100%";
|
|
622
|
+
} else {
|
|
623
|
+
style.maxWidth = `${width.maxWidth}${width.unit}`;
|
|
624
|
+
style.width = "100%";
|
|
625
|
+
}
|
|
626
|
+
switch (width.alignment) {
|
|
627
|
+
case "left":
|
|
628
|
+
style.marginLeft = "0";
|
|
629
|
+
style.marginRight = "auto";
|
|
630
|
+
break;
|
|
631
|
+
case "center":
|
|
632
|
+
style.marginLeft = "auto";
|
|
633
|
+
style.marginRight = "auto";
|
|
634
|
+
break;
|
|
635
|
+
case "right":
|
|
636
|
+
style.marginLeft = "auto";
|
|
637
|
+
style.marginRight = "0";
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
return style;
|
|
641
|
+
}
|
|
642
|
+
function dimensionsValueToCSS(dimensions) {
|
|
643
|
+
if (!dimensions) return void 0;
|
|
644
|
+
if (isLegacyWidthValue(dimensions)) {
|
|
645
|
+
return widthValueToCSS(dimensions);
|
|
646
|
+
}
|
|
647
|
+
const dim = dimensions;
|
|
648
|
+
const style = {};
|
|
649
|
+
if (dim.mode === "full") {
|
|
650
|
+
style.width = "100%";
|
|
651
|
+
style.maxWidth = "100%";
|
|
652
|
+
} else {
|
|
653
|
+
style.width = "100%";
|
|
654
|
+
if (dim.maxWidth?.enabled !== false && dim.maxWidth?.value > 0) {
|
|
655
|
+
style.maxWidth = `${dim.maxWidth.value}${dim.maxWidth.unit}`;
|
|
656
|
+
}
|
|
657
|
+
if (dim.minWidth?.enabled && dim.minWidth.value > 0) {
|
|
658
|
+
style.minWidth = `${dim.minWidth.value}${dim.minWidth.unit}`;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (dim.minHeight?.enabled && dim.minHeight.value > 0) {
|
|
662
|
+
style.minHeight = `${dim.minHeight.value}${dim.minHeight.unit}`;
|
|
663
|
+
}
|
|
664
|
+
if (dim.maxHeight?.enabled && dim.maxHeight.value > 0) {
|
|
665
|
+
style.maxHeight = `${dim.maxHeight.value}${dim.maxHeight.unit}`;
|
|
666
|
+
}
|
|
667
|
+
switch (dim.alignment) {
|
|
668
|
+
case "left":
|
|
669
|
+
style.marginLeft = "0";
|
|
670
|
+
style.marginRight = "auto";
|
|
671
|
+
break;
|
|
672
|
+
case "center":
|
|
673
|
+
style.marginLeft = "auto";
|
|
674
|
+
style.marginRight = "auto";
|
|
675
|
+
break;
|
|
676
|
+
case "right":
|
|
677
|
+
style.marginLeft = "auto";
|
|
678
|
+
style.marginRight = "0";
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
return style;
|
|
682
|
+
}
|
|
683
|
+
function gradientValueToCSS(gradient) {
|
|
684
|
+
if (!gradient?.stops || gradient.stops.length === 0) {
|
|
685
|
+
return "transparent";
|
|
686
|
+
}
|
|
687
|
+
const sortedStops = [...gradient.stops].sort((a, b) => a.position - b.position);
|
|
688
|
+
const stopsCSS = sortedStops.map((stop) => {
|
|
689
|
+
const color = colorValueToCSS(stop.color) || "transparent";
|
|
690
|
+
return `${color} ${stop.position}%`;
|
|
691
|
+
}).join(", ");
|
|
692
|
+
if (gradient.type === "radial") {
|
|
693
|
+
const shape = gradient.radialShape || "circle";
|
|
694
|
+
const position = gradient.radialPosition || "center";
|
|
695
|
+
return `radial-gradient(${shape} at ${position}, ${stopsCSS})`;
|
|
696
|
+
}
|
|
697
|
+
return `linear-gradient(${gradient.angle}deg, ${stopsCSS})`;
|
|
698
|
+
}
|
|
699
|
+
function positionToCSS(position) {
|
|
700
|
+
const positionMap = {
|
|
701
|
+
center: "center",
|
|
702
|
+
top: "top",
|
|
703
|
+
bottom: "bottom",
|
|
704
|
+
left: "left",
|
|
705
|
+
right: "right",
|
|
706
|
+
"top-left": "top left",
|
|
707
|
+
"top-right": "top right",
|
|
708
|
+
"bottom-left": "bottom left",
|
|
709
|
+
"bottom-right": "bottom right"
|
|
710
|
+
};
|
|
711
|
+
return position ? positionMap[position] || "center" : "center";
|
|
712
|
+
}
|
|
713
|
+
function maskDirectionToCSS(direction) {
|
|
714
|
+
const directionMap = {
|
|
715
|
+
"to-top": "to top",
|
|
716
|
+
"to-bottom": "to bottom",
|
|
717
|
+
"to-left": "to left",
|
|
718
|
+
"to-right": "to right",
|
|
719
|
+
"to-top-left": "to top left",
|
|
720
|
+
"to-top-right": "to top right",
|
|
721
|
+
"to-bottom-left": "to bottom left",
|
|
722
|
+
"to-bottom-right": "to bottom right",
|
|
723
|
+
"from-center": "radial"
|
|
724
|
+
// Not used for linear, handled separately in maskToCSS
|
|
725
|
+
};
|
|
726
|
+
return directionMap[direction] || "to bottom";
|
|
727
|
+
}
|
|
728
|
+
function maskToCSS(mask) {
|
|
729
|
+
const startAlpha = (mask.startOpacity ?? 100) / 100;
|
|
730
|
+
const endAlpha = (mask.endOpacity ?? 0) / 100;
|
|
731
|
+
if (mask.direction === "from-center") {
|
|
732
|
+
return `radial-gradient(circle at center, rgba(0,0,0,${startAlpha}) ${mask.startPosition}%, rgba(0,0,0,${endAlpha}) ${mask.endPosition}%)`;
|
|
733
|
+
}
|
|
734
|
+
const direction = maskDirectionToCSS(mask.direction);
|
|
735
|
+
return `linear-gradient(${direction}, rgba(0,0,0,${startAlpha}) ${mask.startPosition}%, rgba(0,0,0,${endAlpha}) ${mask.endPosition}%)`;
|
|
736
|
+
}
|
|
737
|
+
function backgroundValueToCSS(bg) {
|
|
738
|
+
if (!bg || bg.type === "none") {
|
|
739
|
+
return {};
|
|
740
|
+
}
|
|
741
|
+
const style = {};
|
|
742
|
+
switch (bg.type) {
|
|
743
|
+
case "solid":
|
|
744
|
+
if (bg.solid?.hex) {
|
|
745
|
+
style.backgroundColor = colorValueToCSS(bg.solid);
|
|
746
|
+
}
|
|
747
|
+
break;
|
|
748
|
+
case "gradient":
|
|
749
|
+
if (bg.gradient && bg.gradient.stops && bg.gradient.stops.length > 0) {
|
|
750
|
+
style.background = gradientValueToCSS(bg.gradient);
|
|
751
|
+
}
|
|
752
|
+
break;
|
|
753
|
+
case "image":
|
|
754
|
+
if (bg.image?.media?.url) {
|
|
755
|
+
const imageUrl = bg.image.media.url;
|
|
756
|
+
const size = bg.image.size || "cover";
|
|
757
|
+
const position = positionToCSS(bg.image.position);
|
|
758
|
+
const repeat = bg.image.repeat || "no-repeat";
|
|
759
|
+
const attachment = bg.image.attachment || "scroll";
|
|
760
|
+
if (bg.overlay?.enabled) {
|
|
761
|
+
const overlayCSS = bg.overlay.type === "solid" ? colorValueToCSS(bg.overlay.solid) : gradientValueToCSS(bg.overlay.gradient);
|
|
762
|
+
if (bg.overlay.type === "solid" && overlayCSS) {
|
|
763
|
+
style.backgroundImage = `linear-gradient(${overlayCSS}, ${overlayCSS}), url(${imageUrl})`;
|
|
764
|
+
} else {
|
|
765
|
+
style.backgroundImage = `${overlayCSS}, url(${imageUrl})`;
|
|
766
|
+
}
|
|
767
|
+
style.backgroundSize = `auto, ${size}`;
|
|
768
|
+
style.backgroundPosition = `center, ${position}`;
|
|
769
|
+
style.backgroundRepeat = `no-repeat, ${repeat}`;
|
|
770
|
+
style.backgroundAttachment = `scroll, ${attachment}`;
|
|
771
|
+
} else {
|
|
772
|
+
style.backgroundImage = `url(${imageUrl})`;
|
|
773
|
+
style.backgroundSize = size;
|
|
774
|
+
style.backgroundPosition = position;
|
|
775
|
+
style.backgroundRepeat = repeat;
|
|
776
|
+
style.backgroundAttachment = attachment;
|
|
777
|
+
}
|
|
778
|
+
if (bg.image.mask?.enabled) {
|
|
779
|
+
const maskCSS = maskToCSS(bg.image.mask);
|
|
780
|
+
style.maskImage = maskCSS;
|
|
781
|
+
style.WebkitMaskImage = maskCSS;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
return style;
|
|
787
|
+
}
|
|
788
|
+
function transformOriginToCSS(origin) {
|
|
789
|
+
const originMap = {
|
|
790
|
+
center: "center",
|
|
791
|
+
top: "top",
|
|
792
|
+
bottom: "bottom",
|
|
793
|
+
left: "left",
|
|
794
|
+
right: "right",
|
|
795
|
+
"top-left": "top left",
|
|
796
|
+
"top-right": "top right",
|
|
797
|
+
"bottom-left": "bottom left",
|
|
798
|
+
"bottom-right": "bottom right"
|
|
799
|
+
};
|
|
800
|
+
return originMap[origin] || "center";
|
|
801
|
+
}
|
|
802
|
+
function transformValueToCSS(transform) {
|
|
803
|
+
if (!transform) return void 0;
|
|
804
|
+
const style = {};
|
|
805
|
+
const transforms = [];
|
|
806
|
+
if (transform.enable3D && transform.perspective) {
|
|
807
|
+
style.perspective = `${transform.perspective}px`;
|
|
808
|
+
}
|
|
809
|
+
if (transform.translateX !== 0 || transform.translateY !== 0) {
|
|
810
|
+
transforms.push(
|
|
811
|
+
`translate(${transform.translateX}${transform.translateUnit}, ${transform.translateY}${transform.translateUnit})`
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
if (transform.rotate !== 0) {
|
|
815
|
+
transforms.push(`rotate(${transform.rotate}deg)`);
|
|
816
|
+
}
|
|
817
|
+
if (transform.enable3D) {
|
|
818
|
+
if (transform.rotateX && transform.rotateX !== 0) {
|
|
819
|
+
transforms.push(`rotateX(${transform.rotateX}deg)`);
|
|
820
|
+
}
|
|
821
|
+
if (transform.rotateY && transform.rotateY !== 0) {
|
|
822
|
+
transforms.push(`rotateY(${transform.rotateY}deg)`);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
if (transform.scaleX !== 1 || transform.scaleY !== 1) {
|
|
826
|
+
if (transform.scaleX === transform.scaleY) {
|
|
827
|
+
transforms.push(`scale(${transform.scaleX})`);
|
|
828
|
+
} else {
|
|
829
|
+
transforms.push(`scale(${transform.scaleX}, ${transform.scaleY})`);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (transform.skewX !== 0 || transform.skewY !== 0) {
|
|
833
|
+
if (transform.skewX !== 0 && transform.skewY !== 0) {
|
|
834
|
+
transforms.push(`skew(${transform.skewX}deg, ${transform.skewY}deg)`);
|
|
835
|
+
} else if (transform.skewX !== 0) {
|
|
836
|
+
transforms.push(`skewX(${transform.skewX}deg)`);
|
|
837
|
+
} else {
|
|
838
|
+
transforms.push(`skewY(${transform.skewY}deg)`);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (transforms.length > 0) {
|
|
842
|
+
style.transform = transforms.join(" ");
|
|
843
|
+
}
|
|
844
|
+
if (transform.origin !== "center") {
|
|
845
|
+
style.transformOrigin = transformOriginToCSS(transform.origin);
|
|
846
|
+
}
|
|
847
|
+
if (transform.enable3D) {
|
|
848
|
+
style.transformStyle = "preserve-3d";
|
|
849
|
+
}
|
|
850
|
+
return Object.keys(style).length > 0 ? style : void 0;
|
|
851
|
+
}
|
|
852
|
+
function isResponsiveValue(value) {
|
|
853
|
+
if (!value || typeof value !== "object") return false;
|
|
854
|
+
return "base" in value;
|
|
855
|
+
}
|
|
856
|
+
function camelToKebab(str) {
|
|
857
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
858
|
+
}
|
|
859
|
+
function cssPropertiesToString(styles) {
|
|
860
|
+
return Object.entries(styles).filter(([, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => `${camelToKebab(key)}: ${value}`).join("; ");
|
|
861
|
+
}
|
|
862
|
+
function responsiveValueToCSS(value, converter, uniqueId) {
|
|
863
|
+
if (value === null || value === void 0) {
|
|
864
|
+
return { baseStyles: {}, mediaQueryCSS: "" };
|
|
865
|
+
}
|
|
866
|
+
if (!isResponsiveValue(value)) {
|
|
867
|
+
const styles = converter(value);
|
|
868
|
+
return {
|
|
869
|
+
baseStyles: styles || {},
|
|
870
|
+
mediaQueryCSS: ""
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
const mediaQueries = [];
|
|
874
|
+
let baseStyles = {};
|
|
875
|
+
BREAKPOINTS.forEach((bp) => {
|
|
876
|
+
const bpValue = value[bp.key];
|
|
877
|
+
if (bpValue === void 0) return;
|
|
878
|
+
const cssProps = converter(bpValue);
|
|
879
|
+
if (!cssProps) return;
|
|
880
|
+
if (bp.key === "base") {
|
|
881
|
+
baseStyles = cssProps;
|
|
882
|
+
} else {
|
|
883
|
+
const styleString = cssPropertiesToString(cssProps);
|
|
884
|
+
if (styleString) {
|
|
885
|
+
mediaQueries.push(
|
|
886
|
+
`@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
return { baseStyles, mediaQueryCSS: mediaQueries.join("\n") };
|
|
892
|
+
}
|
|
893
|
+
function visibilityValueToCSS(visibility, uniqueId) {
|
|
894
|
+
if (!visibility) return "";
|
|
895
|
+
const mediaQueries = [];
|
|
896
|
+
if (visibility.base === false) {
|
|
897
|
+
mediaQueries.push(`.${uniqueId} { display: none; }`);
|
|
898
|
+
}
|
|
899
|
+
let lastVisibility = visibility.base;
|
|
900
|
+
BREAKPOINTS.slice(1).forEach((bp) => {
|
|
901
|
+
const bpValue = visibility[bp.key];
|
|
902
|
+
if (bpValue === void 0) return;
|
|
903
|
+
if (bpValue !== lastVisibility) {
|
|
904
|
+
if (bpValue === false) {
|
|
905
|
+
mediaQueries.push(
|
|
906
|
+
`@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: none; } }`
|
|
907
|
+
);
|
|
908
|
+
} else {
|
|
909
|
+
mediaQueries.push(
|
|
910
|
+
`@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: block; } }`
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
lastVisibility = bpValue;
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
return mediaQueries.join("\n");
|
|
917
|
+
}
|
|
918
|
+
function animationOriginToCSS(origin) {
|
|
919
|
+
if (!origin) return "center";
|
|
920
|
+
const originMap = {
|
|
921
|
+
center: "center",
|
|
922
|
+
top: "top",
|
|
923
|
+
bottom: "bottom",
|
|
924
|
+
left: "left",
|
|
925
|
+
right: "right",
|
|
926
|
+
"top-left": "top left",
|
|
927
|
+
"top-right": "top right",
|
|
928
|
+
"bottom-left": "bottom left",
|
|
929
|
+
"bottom-right": "bottom right"
|
|
930
|
+
};
|
|
931
|
+
return originMap[origin] || "center";
|
|
932
|
+
}
|
|
933
|
+
function animationValueToCSS(anim) {
|
|
934
|
+
if (!anim || anim.mode !== "custom") return void 0;
|
|
935
|
+
const duration = anim.duration ?? 300;
|
|
936
|
+
const delay = anim.delay ?? 0;
|
|
937
|
+
const easing = anim.easing ?? "ease";
|
|
938
|
+
const easingCSS = EASING_CSS_MAP[easing] || "ease";
|
|
939
|
+
return {
|
|
940
|
+
transition: `all ${duration}ms ${easingCSS} ${delay}ms`,
|
|
941
|
+
transitionProperty: "opacity, transform, filter, background-color, color, border-color, box-shadow"
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function getEntranceAnimationStyles(anim) {
|
|
945
|
+
const defaultResult = {
|
|
946
|
+
initial: {},
|
|
947
|
+
animate: {},
|
|
948
|
+
duration: 500,
|
|
949
|
+
delay: 0,
|
|
950
|
+
easing: "ease",
|
|
951
|
+
origin: "center"
|
|
952
|
+
};
|
|
953
|
+
if (!anim || anim.mode !== "preset" || anim.entrance === "none") {
|
|
954
|
+
return defaultResult;
|
|
955
|
+
}
|
|
956
|
+
const duration = anim.entranceDuration ?? 500;
|
|
957
|
+
const delay = anim.entranceDelay ?? 0;
|
|
958
|
+
const easing = EASING_CSS_MAP[anim.easing ?? "ease"] || "ease";
|
|
959
|
+
const origin = animationOriginToCSS(anim.origin);
|
|
960
|
+
const distance = anim.distance ?? 24;
|
|
961
|
+
const scaleFrom = anim.scaleFrom ?? 0.9;
|
|
962
|
+
const rotateAngle = anim.rotateAngle ?? 15;
|
|
963
|
+
const blurAmount = anim.blurAmount ?? 8;
|
|
964
|
+
const entrance = anim.entrance ?? "none";
|
|
965
|
+
let initial = {};
|
|
966
|
+
let animate = {};
|
|
967
|
+
switch (entrance) {
|
|
968
|
+
// ==================== FADE (6) ====================
|
|
969
|
+
case "fade-in":
|
|
970
|
+
initial = { opacity: 0 };
|
|
971
|
+
animate = { opacity: 1 };
|
|
972
|
+
break;
|
|
973
|
+
case "fade-up":
|
|
974
|
+
initial = { opacity: 0, transform: `translateY(${distance}px)` };
|
|
975
|
+
animate = { opacity: 1, transform: "translateY(0)" };
|
|
976
|
+
break;
|
|
977
|
+
case "fade-down":
|
|
978
|
+
initial = { opacity: 0, transform: `translateY(-${distance}px)` };
|
|
979
|
+
animate = { opacity: 1, transform: "translateY(0)" };
|
|
980
|
+
break;
|
|
981
|
+
case "fade-left":
|
|
982
|
+
initial = { opacity: 0, transform: `translateX(${distance}px)` };
|
|
983
|
+
animate = { opacity: 1, transform: "translateX(0)" };
|
|
984
|
+
break;
|
|
985
|
+
case "fade-right":
|
|
986
|
+
initial = { opacity: 0, transform: `translateX(-${distance}px)` };
|
|
987
|
+
animate = { opacity: 1, transform: "translateX(0)" };
|
|
988
|
+
break;
|
|
989
|
+
case "fade-scale":
|
|
990
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom})` };
|
|
991
|
+
animate = { opacity: 1, transform: "scale(1)" };
|
|
992
|
+
break;
|
|
993
|
+
// ==================== SCALE (4) ====================
|
|
994
|
+
case "scale-in":
|
|
995
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom})` };
|
|
996
|
+
animate = { opacity: 1, transform: "scale(1)" };
|
|
997
|
+
break;
|
|
998
|
+
case "scale-up":
|
|
999
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom}) translateY(${distance}px)` };
|
|
1000
|
+
animate = { opacity: 1, transform: "scale(1) translateY(0)" };
|
|
1001
|
+
break;
|
|
1002
|
+
case "scale-down":
|
|
1003
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom}) translateY(-${distance}px)` };
|
|
1004
|
+
animate = { opacity: 1, transform: "scale(1) translateY(0)" };
|
|
1005
|
+
break;
|
|
1006
|
+
case "scale-out":
|
|
1007
|
+
initial = { opacity: 0, transform: `scale(${2 - scaleFrom})` };
|
|
1008
|
+
animate = { opacity: 1, transform: "scale(1)" };
|
|
1009
|
+
break;
|
|
1010
|
+
// ==================== SLIDE (4) ====================
|
|
1011
|
+
case "slide-up":
|
|
1012
|
+
initial = { transform: `translateY(${distance}px)` };
|
|
1013
|
+
animate = { transform: "translateY(0)" };
|
|
1014
|
+
break;
|
|
1015
|
+
case "slide-down":
|
|
1016
|
+
initial = { transform: `translateY(-${distance}px)` };
|
|
1017
|
+
animate = { transform: "translateY(0)" };
|
|
1018
|
+
break;
|
|
1019
|
+
case "slide-left":
|
|
1020
|
+
initial = { transform: `translateX(${distance}px)` };
|
|
1021
|
+
animate = { transform: "translateX(0)" };
|
|
1022
|
+
break;
|
|
1023
|
+
case "slide-right":
|
|
1024
|
+
initial = { transform: `translateX(-${distance}px)` };
|
|
1025
|
+
animate = { transform: "translateX(0)" };
|
|
1026
|
+
break;
|
|
1027
|
+
// ==================== BLUR (3) ====================
|
|
1028
|
+
case "blur-in":
|
|
1029
|
+
initial = { opacity: 0, filter: `blur(${blurAmount}px)` };
|
|
1030
|
+
animate = { opacity: 1, filter: "blur(0)" };
|
|
1031
|
+
break;
|
|
1032
|
+
case "blur-up":
|
|
1033
|
+
initial = { opacity: 0, filter: `blur(${blurAmount}px)`, transform: `translateY(${distance}px)` };
|
|
1034
|
+
animate = { opacity: 1, filter: "blur(0)", transform: "translateY(0)" };
|
|
1035
|
+
break;
|
|
1036
|
+
case "blur-down":
|
|
1037
|
+
initial = { opacity: 0, filter: `blur(${blurAmount}px)`, transform: `translateY(-${distance}px)` };
|
|
1038
|
+
animate = { opacity: 1, filter: "blur(0)", transform: "translateY(0)" };
|
|
1039
|
+
break;
|
|
1040
|
+
// ==================== ROTATE (3) ====================
|
|
1041
|
+
case "rotate-in":
|
|
1042
|
+
initial = { opacity: 0, transform: `rotate(${rotateAngle}deg) scale(${scaleFrom})` };
|
|
1043
|
+
animate = { opacity: 1, transform: "rotate(0) scale(1)" };
|
|
1044
|
+
break;
|
|
1045
|
+
case "rotate-up":
|
|
1046
|
+
initial = { opacity: 0, transform: `rotate(${rotateAngle}deg) translateY(${distance}px)` };
|
|
1047
|
+
animate = { opacity: 1, transform: "rotate(0) translateY(0)" };
|
|
1048
|
+
break;
|
|
1049
|
+
case "rotate-down":
|
|
1050
|
+
initial = { opacity: 0, transform: `rotate(-${rotateAngle}deg) translateY(-${distance}px)` };
|
|
1051
|
+
animate = { opacity: 1, transform: "rotate(0) translateY(0)" };
|
|
1052
|
+
break;
|
|
1053
|
+
// ==================== BOUNCE (3) ====================
|
|
1054
|
+
// These use spring/bounce easing by default for the effect
|
|
1055
|
+
case "bounce-in":
|
|
1056
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom * 0.8})` };
|
|
1057
|
+
animate = { opacity: 1, transform: "scale(1)" };
|
|
1058
|
+
break;
|
|
1059
|
+
case "bounce-up":
|
|
1060
|
+
initial = { opacity: 0, transform: `translateY(${distance * 1.5}px)` };
|
|
1061
|
+
animate = { opacity: 1, transform: "translateY(0)" };
|
|
1062
|
+
break;
|
|
1063
|
+
case "bounce-down":
|
|
1064
|
+
initial = { opacity: 0, transform: `translateY(-${distance * 1.5}px)` };
|
|
1065
|
+
animate = { opacity: 1, transform: "translateY(0)" };
|
|
1066
|
+
break;
|
|
1067
|
+
// ==================== FLIP (2) ====================
|
|
1068
|
+
// Flip uses perspective in transform for proper 3D effect
|
|
1069
|
+
// Starts from -90deg (tilted back) so the flip motion is visible
|
|
1070
|
+
case "flip-x":
|
|
1071
|
+
initial = {
|
|
1072
|
+
transform: "perspective(1000px) rotateX(-90deg)",
|
|
1073
|
+
opacity: 0.2,
|
|
1074
|
+
backfaceVisibility: "hidden"
|
|
1075
|
+
};
|
|
1076
|
+
animate = {
|
|
1077
|
+
transform: "perspective(1000px) rotateX(0deg)",
|
|
1078
|
+
opacity: 1,
|
|
1079
|
+
backfaceVisibility: "hidden"
|
|
1080
|
+
};
|
|
1081
|
+
break;
|
|
1082
|
+
case "flip-y":
|
|
1083
|
+
initial = {
|
|
1084
|
+
transform: "perspective(1000px) rotateY(-90deg)",
|
|
1085
|
+
opacity: 0.2,
|
|
1086
|
+
backfaceVisibility: "hidden"
|
|
1087
|
+
};
|
|
1088
|
+
animate = {
|
|
1089
|
+
transform: "perspective(1000px) rotateY(0deg)",
|
|
1090
|
+
opacity: 1,
|
|
1091
|
+
backfaceVisibility: "hidden"
|
|
1092
|
+
};
|
|
1093
|
+
break;
|
|
1094
|
+
// ==================== ZOOM (2) ====================
|
|
1095
|
+
case "zoom-in":
|
|
1096
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom * 0.5})` };
|
|
1097
|
+
animate = { opacity: 1, transform: "scale(1)" };
|
|
1098
|
+
break;
|
|
1099
|
+
case "zoom-out":
|
|
1100
|
+
initial = { opacity: 0, transform: `scale(${2.5 - scaleFrom})` };
|
|
1101
|
+
animate = { opacity: 1, transform: "scale(1)" };
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
return {
|
|
1105
|
+
initial,
|
|
1106
|
+
animate,
|
|
1107
|
+
duration,
|
|
1108
|
+
delay,
|
|
1109
|
+
easing,
|
|
1110
|
+
origin
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
var alignmentMap, shadowMap, headingLevelMap, textSizeMap, aspectRatioMap, dividerStyleMap, justifyContentMap, alignItemsMap, BREAKPOINTS, EASING_CSS_MAP;
|
|
1114
|
+
var init_shared = __esm({
|
|
1115
|
+
"src/fields/shared.ts"() {
|
|
1116
|
+
alignmentMap = {
|
|
1117
|
+
left: "text-left",
|
|
1118
|
+
center: "text-center",
|
|
1119
|
+
right: "text-right"
|
|
1120
|
+
};
|
|
1121
|
+
shadowMap = {
|
|
1122
|
+
none: "",
|
|
1123
|
+
sm: "shadow-sm",
|
|
1124
|
+
md: "shadow-md",
|
|
1125
|
+
lg: "shadow-lg",
|
|
1126
|
+
xl: "shadow-xl",
|
|
1127
|
+
"2xl": "shadow-2xl"
|
|
1128
|
+
};
|
|
1129
|
+
headingLevelMap = {
|
|
1130
|
+
h1: "text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight",
|
|
1131
|
+
h2: "text-3xl md:text-4xl font-bold tracking-tight",
|
|
1132
|
+
h3: "text-2xl md:text-3xl font-semibold",
|
|
1133
|
+
h4: "text-xl md:text-2xl font-semibold",
|
|
1134
|
+
h5: "text-lg md:text-xl font-medium",
|
|
1135
|
+
h6: "text-base md:text-lg font-medium"
|
|
1136
|
+
};
|
|
1137
|
+
textSizeMap = {
|
|
1138
|
+
xs: "text-xs",
|
|
1139
|
+
sm: "text-sm",
|
|
1140
|
+
base: "text-base",
|
|
1141
|
+
lg: "text-lg",
|
|
1142
|
+
xl: "text-xl",
|
|
1143
|
+
"2xl": "text-2xl"
|
|
1144
|
+
};
|
|
1145
|
+
aspectRatioMap = {
|
|
1146
|
+
auto: "",
|
|
1147
|
+
square: "aspect-square",
|
|
1148
|
+
video: "aspect-video",
|
|
1149
|
+
portrait: "aspect-[3/4]",
|
|
1150
|
+
landscape: "aspect-[4/3]",
|
|
1151
|
+
wide: "aspect-[21/9]"
|
|
1152
|
+
};
|
|
1153
|
+
dividerStyleMap = {
|
|
1154
|
+
solid: "border-solid",
|
|
1155
|
+
dashed: "border-dashed",
|
|
1156
|
+
dotted: "border-dotted"
|
|
1157
|
+
};
|
|
1158
|
+
justifyContentMap = {
|
|
1159
|
+
start: "justify-start",
|
|
1160
|
+
"flex-start": "justify-start",
|
|
1161
|
+
center: "justify-center",
|
|
1162
|
+
end: "justify-end",
|
|
1163
|
+
"flex-end": "justify-end",
|
|
1164
|
+
between: "justify-between",
|
|
1165
|
+
"space-between": "justify-between",
|
|
1166
|
+
around: "justify-around",
|
|
1167
|
+
"space-around": "justify-around",
|
|
1168
|
+
evenly: "justify-evenly",
|
|
1169
|
+
"space-evenly": "justify-evenly"
|
|
1170
|
+
};
|
|
1171
|
+
alignItemsMap = {
|
|
1172
|
+
start: "items-start",
|
|
1173
|
+
"flex-start": "items-start",
|
|
1174
|
+
center: "items-center",
|
|
1175
|
+
end: "items-end",
|
|
1176
|
+
"flex-end": "items-end",
|
|
1177
|
+
stretch: "items-stretch",
|
|
1178
|
+
baseline: "items-baseline"
|
|
1179
|
+
};
|
|
1180
|
+
BREAKPOINTS = [
|
|
1181
|
+
{ key: "base", label: "Base", minWidth: null },
|
|
1182
|
+
{ key: "sm", label: "SM", minWidth: 640 },
|
|
1183
|
+
{ key: "md", label: "MD", minWidth: 768 },
|
|
1184
|
+
{ key: "lg", label: "LG", minWidth: 1024 },
|
|
1185
|
+
{ key: "xl", label: "XL", minWidth: 1280 }
|
|
1186
|
+
];
|
|
1187
|
+
EASING_CSS_MAP = {
|
|
1188
|
+
linear: "linear",
|
|
1189
|
+
ease: "ease",
|
|
1190
|
+
"ease-in": "ease-in",
|
|
1191
|
+
"ease-out": "ease-out",
|
|
1192
|
+
"ease-in-out": "ease-in-out",
|
|
1193
|
+
spring: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
|
|
1194
|
+
"spring-gentle": "cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
1195
|
+
bounce: "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
1196
|
+
"bounce-in": "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
|
|
1197
|
+
"bounce-out": "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
|
|
1198
|
+
"back-in": "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
|
|
1199
|
+
"back-out": "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
|
|
1200
|
+
"back-in-out": "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
1201
|
+
elastic: "cubic-bezier(0.68, -0.6, 0.32, 1.6)"
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
});
|
|
1205
|
+
var usePuck2, DEFAULT_LAYOUT_CONFIG, IframeWrapper;
|
|
1206
|
+
var init_IframeWrapper = __esm({
|
|
1207
|
+
"src/editor/components/IframeWrapper.tsx"() {
|
|
1208
|
+
"use client";
|
|
1209
|
+
init_shared();
|
|
1210
|
+
usePuck2 = createUsePuck();
|
|
1211
|
+
DEFAULT_LAYOUT_CONFIG = {
|
|
1212
|
+
background: "#ffffff",
|
|
1213
|
+
isDark: false
|
|
1214
|
+
};
|
|
1215
|
+
IframeWrapper = memo(function IframeWrapper2({
|
|
1216
|
+
children,
|
|
1217
|
+
document: iframeDoc,
|
|
1218
|
+
layouts,
|
|
1219
|
+
layoutStyles,
|
|
1220
|
+
layoutKey = "pageLayout",
|
|
1221
|
+
defaultLayout: defaultLayout2 = "default"
|
|
1222
|
+
}) {
|
|
1223
|
+
const appState = usePuck2((s) => s.appState);
|
|
1224
|
+
const isInteractive = appState.ui.previewMode === "interactive";
|
|
1225
|
+
const rootProps = appState.data.root?.props;
|
|
1226
|
+
const layoutValue = rootProps?.[layoutKey] || defaultLayout2;
|
|
1227
|
+
const showHeaderOverride = rootProps?.showHeader;
|
|
1228
|
+
const showFooterOverride = rootProps?.showFooter;
|
|
1229
|
+
const pageBackground = rootProps?.pageBackground;
|
|
1230
|
+
const layoutConfigMap = useMemo(() => {
|
|
1231
|
+
if (layouts) {
|
|
1232
|
+
const map = {};
|
|
1233
|
+
for (const layout of layouts) {
|
|
1234
|
+
map[layout.value] = {
|
|
1235
|
+
background: layout.editorBackground ?? "#ffffff",
|
|
1236
|
+
isDark: layout.editorDarkMode ?? false,
|
|
1237
|
+
header: layout.header,
|
|
1238
|
+
footer: layout.footer,
|
|
1239
|
+
stickyHeaderHeight: layout.stickyHeaderHeight
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
return map;
|
|
1243
|
+
}
|
|
1244
|
+
if (layoutStyles) {
|
|
1245
|
+
return layoutStyles;
|
|
1246
|
+
}
|
|
1247
|
+
return { default: DEFAULT_LAYOUT_CONFIG };
|
|
1248
|
+
}, [layouts, layoutStyles]);
|
|
1249
|
+
const layoutConfig = layoutConfigMap[layoutValue] || layoutConfigMap[defaultLayout2] || DEFAULT_LAYOUT_CONFIG;
|
|
1250
|
+
useEffect(() => {
|
|
1251
|
+
if (!iframeDoc) return;
|
|
1252
|
+
const body = iframeDoc.body;
|
|
1253
|
+
const html = iframeDoc.documentElement;
|
|
1254
|
+
if (pageBackground) {
|
|
1255
|
+
const bgStyles = backgroundValueToCSS(pageBackground);
|
|
1256
|
+
body.style.background = "";
|
|
1257
|
+
body.style.backgroundColor = "";
|
|
1258
|
+
body.style.backgroundImage = "";
|
|
1259
|
+
Object.assign(body.style, bgStyles);
|
|
1260
|
+
} else {
|
|
1261
|
+
body.style.background = layoutConfig.background;
|
|
1262
|
+
}
|
|
1263
|
+
body.style.backgroundAttachment = "fixed";
|
|
1264
|
+
body.style.minHeight = "100vh";
|
|
1265
|
+
if (layoutConfig.isDark) {
|
|
1266
|
+
html.classList.add("dark");
|
|
1267
|
+
html.classList.remove("light");
|
|
1268
|
+
body.style.color = "#ffffff";
|
|
1269
|
+
} else {
|
|
1270
|
+
html.classList.remove("dark");
|
|
1271
|
+
html.classList.add("light");
|
|
1272
|
+
body.style.color = "#1f2937";
|
|
1273
|
+
}
|
|
1274
|
+
const RICHTEXT_STYLES_ID = "puck-richtext-output-styles";
|
|
1275
|
+
if (!iframeDoc.getElementById(RICHTEXT_STYLES_ID)) {
|
|
1276
|
+
const style = iframeDoc.createElement("style");
|
|
1277
|
+
style.id = RICHTEXT_STYLES_ID;
|
|
1278
|
+
style.textContent = `
|
|
1279
|
+
/* Rich Text Output Styles for Puck Preview */
|
|
1280
|
+
.richtext-output {
|
|
1281
|
+
font-size: 1.125rem;
|
|
1282
|
+
line-height: 1.75;
|
|
1283
|
+
color: inherit;
|
|
1284
|
+
}
|
|
1285
|
+
.richtext-output h1 {
|
|
1286
|
+
margin-top: 2rem;
|
|
1287
|
+
margin-bottom: 1rem;
|
|
1288
|
+
font-weight: 700;
|
|
1289
|
+
font-size: 2.25rem;
|
|
1290
|
+
line-height: 1.2;
|
|
1291
|
+
}
|
|
1292
|
+
.richtext-output h1:first-child { margin-top: 0; }
|
|
1293
|
+
.richtext-output h2 {
|
|
1294
|
+
margin-top: 2rem;
|
|
1295
|
+
margin-bottom: 1rem;
|
|
1296
|
+
font-weight: 700;
|
|
1297
|
+
font-size: 1.875rem;
|
|
1298
|
+
line-height: 1.25;
|
|
1299
|
+
}
|
|
1300
|
+
.richtext-output h2:first-child { margin-top: 0; }
|
|
1301
|
+
.richtext-output h3 {
|
|
1302
|
+
margin-top: 2rem;
|
|
1303
|
+
margin-bottom: 1rem;
|
|
1304
|
+
font-weight: 700;
|
|
1305
|
+
font-size: 1.5rem;
|
|
1306
|
+
line-height: 1.3;
|
|
1307
|
+
}
|
|
1308
|
+
.richtext-output h3:first-child { margin-top: 0; }
|
|
1309
|
+
.richtext-output h4 {
|
|
1310
|
+
margin-top: 2rem;
|
|
1311
|
+
margin-bottom: 1rem;
|
|
1312
|
+
font-weight: 700;
|
|
1313
|
+
font-size: 1.25rem;
|
|
1314
|
+
line-height: 1.35;
|
|
1315
|
+
}
|
|
1316
|
+
.richtext-output h4:first-child { margin-top: 0; }
|
|
1317
|
+
.richtext-output p {
|
|
1318
|
+
margin-bottom: 1.25rem;
|
|
1319
|
+
}
|
|
1320
|
+
.richtext-output p:last-child { margin-bottom: 0; }
|
|
1321
|
+
.richtext-output ul {
|
|
1322
|
+
margin-bottom: 1.25rem;
|
|
1323
|
+
padding-left: 2rem;
|
|
1324
|
+
list-style-type: disc !important;
|
|
1325
|
+
}
|
|
1326
|
+
.richtext-output ol {
|
|
1327
|
+
margin-bottom: 1.25rem;
|
|
1328
|
+
padding-left: 2rem;
|
|
1329
|
+
list-style-type: decimal !important;
|
|
1330
|
+
}
|
|
1331
|
+
.richtext-output li {
|
|
1332
|
+
margin-bottom: 0.5rem;
|
|
1333
|
+
display: list-item !important;
|
|
1334
|
+
}
|
|
1335
|
+
.richtext-output li::marker {
|
|
1336
|
+
color: currentColor;
|
|
1337
|
+
}
|
|
1338
|
+
.richtext-output ul ul,
|
|
1339
|
+
.richtext-output ol ul {
|
|
1340
|
+
list-style-type: circle !important;
|
|
1341
|
+
margin-top: 0.5rem;
|
|
1342
|
+
margin-bottom: 0;
|
|
1343
|
+
}
|
|
1344
|
+
.richtext-output ul ul ul,
|
|
1345
|
+
.richtext-output ol ul ul {
|
|
1346
|
+
list-style-type: square !important;
|
|
1347
|
+
}
|
|
1348
|
+
.richtext-output ol ol,
|
|
1349
|
+
.richtext-output ul ol {
|
|
1350
|
+
list-style-type: lower-alpha !important;
|
|
1351
|
+
margin-top: 0.5rem;
|
|
1352
|
+
margin-bottom: 0;
|
|
1353
|
+
}
|
|
1354
|
+
.richtext-output blockquote {
|
|
1355
|
+
margin: 1.5rem 0;
|
|
1356
|
+
padding-left: 1.5rem;
|
|
1357
|
+
border-left: 4px solid #e5e7eb;
|
|
1358
|
+
font-style: italic;
|
|
1359
|
+
}
|
|
1360
|
+
.richtext-output a {
|
|
1361
|
+
color: #2563eb;
|
|
1362
|
+
text-decoration: underline;
|
|
1363
|
+
}
|
|
1364
|
+
.richtext-output a:hover { opacity: 0.8; }
|
|
1365
|
+
.richtext-output code {
|
|
1366
|
+
background-color: #f3f4f6;
|
|
1367
|
+
padding: 0.125rem 0.25rem;
|
|
1368
|
+
border-radius: 0.25rem;
|
|
1369
|
+
font-size: 0.875rem;
|
|
1370
|
+
}
|
|
1371
|
+
.richtext-output mark {
|
|
1372
|
+
background-color: #fef08a;
|
|
1373
|
+
padding: 0.125rem 0.25rem;
|
|
1374
|
+
border-radius: 0.125rem;
|
|
1375
|
+
}
|
|
1376
|
+
.richtext-output s,
|
|
1377
|
+
.richtext-output strike {
|
|
1378
|
+
text-decoration: line-through;
|
|
1379
|
+
}
|
|
1380
|
+
@media (max-width: 768px) {
|
|
1381
|
+
.richtext-output { font-size: 1rem; }
|
|
1382
|
+
.richtext-output h1 { font-size: 1.875rem; }
|
|
1383
|
+
.richtext-output h2 { font-size: 1.5rem; }
|
|
1384
|
+
.richtext-output h3 { font-size: 1.25rem; }
|
|
1385
|
+
}
|
|
1386
|
+
`;
|
|
1387
|
+
iframeDoc.head.appendChild(style);
|
|
1388
|
+
}
|
|
1389
|
+
}, [iframeDoc, layoutConfig, pageBackground]);
|
|
1390
|
+
const LayoutHeader = layoutConfig.header;
|
|
1391
|
+
const LayoutFooter = layoutConfig.footer;
|
|
1392
|
+
const shouldShowHeader = showHeaderOverride === "hide" ? false : showHeaderOverride === "show" ? !!LayoutHeader : !!LayoutHeader;
|
|
1393
|
+
const shouldShowFooter = showFooterOverride === "hide" ? false : showFooterOverride === "show" ? !!LayoutFooter : !!LayoutFooter;
|
|
1394
|
+
if (shouldShowHeader || shouldShowFooter) {
|
|
1395
|
+
const contentStyle = {
|
|
1396
|
+
flex: 1,
|
|
1397
|
+
position: "relative",
|
|
1398
|
+
// Add padding-top for sticky headers so content doesn't render behind them
|
|
1399
|
+
...shouldShowHeader && layoutConfig.stickyHeaderHeight && { paddingTop: layoutConfig.stickyHeaderHeight }
|
|
1400
|
+
};
|
|
1401
|
+
const headerFooterStyle = isInteractive ? {} : { pointerEvents: "none" };
|
|
1402
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", minHeight: "100vh" }, children: [
|
|
1403
|
+
shouldShowHeader && LayoutHeader && /* @__PURE__ */ jsx("div", { style: headerFooterStyle, children: /* @__PURE__ */ jsx(LayoutHeader, {}) }),
|
|
1404
|
+
/* @__PURE__ */ jsx("div", { style: contentStyle, children }),
|
|
1405
|
+
shouldShowFooter && LayoutFooter && /* @__PURE__ */ jsx("div", { style: headerFooterStyle, children: /* @__PURE__ */ jsx(LayoutFooter, {}) })
|
|
1406
|
+
] });
|
|
1407
|
+
}
|
|
1408
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
var Dialog, DialogPortal, DialogOverlay, DialogContent, DialogContentFullscreen, DialogHeader, DialogFooter, DialogTitle, DialogDescription;
|
|
1413
|
+
var init_dialog = __esm({
|
|
1414
|
+
"src/components/ui/dialog.tsx"() {
|
|
1415
|
+
"use client";
|
|
1416
|
+
init_utils();
|
|
1417
|
+
Dialog = DialogPrimitive.Root;
|
|
1418
|
+
DialogPortal = DialogPrimitive.Portal;
|
|
1419
|
+
DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1420
|
+
DialogPrimitive.Overlay,
|
|
1421
|
+
{
|
|
1422
|
+
ref,
|
|
1423
|
+
className: cn(
|
|
1424
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
1425
|
+
className
|
|
1426
|
+
),
|
|
1427
|
+
...props
|
|
1428
|
+
}
|
|
1429
|
+
));
|
|
1430
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
1431
|
+
DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
1432
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
1433
|
+
/* @__PURE__ */ jsxs(
|
|
1434
|
+
DialogPrimitive.Content,
|
|
1435
|
+
{
|
|
1436
|
+
ref,
|
|
1437
|
+
className: cn(
|
|
1438
|
+
"fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-4xl translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg max-h-[85vh] overflow-hidden p-6",
|
|
1439
|
+
className
|
|
1440
|
+
),
|
|
1441
|
+
...props,
|
|
1442
|
+
children: [
|
|
1443
|
+
children,
|
|
1444
|
+
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
1445
|
+
/* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" }),
|
|
1446
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
1447
|
+
] })
|
|
1448
|
+
]
|
|
1449
|
+
}
|
|
1450
|
+
)
|
|
1451
|
+
] }));
|
|
1452
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
1453
|
+
DialogContentFullscreen = React.forwardRef(({ className, children, hideCloseButton = false, accessibleTitle = "Dialog", ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
1454
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
1455
|
+
/* @__PURE__ */ jsxs(
|
|
1456
|
+
DialogPrimitive.Content,
|
|
1457
|
+
{
|
|
1458
|
+
ref,
|
|
1459
|
+
className: cn(
|
|
1460
|
+
"fixed inset-0 z-50 flex flex-col bg-background duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
1461
|
+
className
|
|
1462
|
+
),
|
|
1463
|
+
...props,
|
|
1464
|
+
children: [
|
|
1465
|
+
/* @__PURE__ */ jsx(DialogPrimitive.Title, { className: "sr-only", children: accessibleTitle }),
|
|
1466
|
+
children,
|
|
1467
|
+
!hideCloseButton && /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
1468
|
+
/* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" }),
|
|
1469
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
1470
|
+
] })
|
|
1471
|
+
]
|
|
1472
|
+
}
|
|
1473
|
+
)
|
|
1474
|
+
] }));
|
|
1475
|
+
DialogContentFullscreen.displayName = "DialogContentFullscreen";
|
|
1476
|
+
DialogHeader = ({
|
|
1477
|
+
className,
|
|
1478
|
+
...props
|
|
1479
|
+
}) => /* @__PURE__ */ jsx(
|
|
1480
|
+
"div",
|
|
1481
|
+
{
|
|
1482
|
+
className: cn(
|
|
1483
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
1484
|
+
className
|
|
1485
|
+
),
|
|
1486
|
+
...props
|
|
1487
|
+
}
|
|
1488
|
+
);
|
|
1489
|
+
DialogHeader.displayName = "DialogHeader";
|
|
1490
|
+
DialogFooter = ({
|
|
1491
|
+
className,
|
|
1492
|
+
...props
|
|
1493
|
+
}) => /* @__PURE__ */ jsx(
|
|
1494
|
+
"div",
|
|
1495
|
+
{
|
|
1496
|
+
className: cn(
|
|
1497
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
1498
|
+
className
|
|
1499
|
+
),
|
|
1500
|
+
...props
|
|
1501
|
+
}
|
|
1502
|
+
);
|
|
1503
|
+
DialogFooter.displayName = "DialogFooter";
|
|
1504
|
+
DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1505
|
+
DialogPrimitive.Title,
|
|
1506
|
+
{
|
|
1507
|
+
ref,
|
|
1508
|
+
className: cn(
|
|
1509
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
1510
|
+
className
|
|
1511
|
+
),
|
|
1512
|
+
...props
|
|
1513
|
+
}
|
|
1514
|
+
));
|
|
1515
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
1516
|
+
DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1517
|
+
DialogPrimitive.Description,
|
|
1518
|
+
{
|
|
1519
|
+
ref,
|
|
1520
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
1521
|
+
...props
|
|
1522
|
+
}
|
|
1523
|
+
));
|
|
1524
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
// src/layouts/defaults.ts
|
|
1529
|
+
var defaultLayout, landingLayout, fullWidthLayout, DEFAULT_LAYOUTS;
|
|
1530
|
+
var init_defaults = __esm({
|
|
1531
|
+
"src/layouts/defaults.ts"() {
|
|
1532
|
+
defaultLayout = {
|
|
1533
|
+
value: "default",
|
|
1534
|
+
label: "Default",
|
|
1535
|
+
description: "Standard page layout with contained content width",
|
|
1536
|
+
classes: {
|
|
1537
|
+
wrapper: "",
|
|
1538
|
+
container: "mx-auto px-4 sm:px-6 lg:px-8",
|
|
1539
|
+
content: ""
|
|
1540
|
+
},
|
|
1541
|
+
maxWidth: "1200px",
|
|
1542
|
+
fullWidth: false
|
|
1543
|
+
};
|
|
1544
|
+
landingLayout = {
|
|
1545
|
+
value: "landing",
|
|
1546
|
+
label: "Landing",
|
|
1547
|
+
description: "Full-width sections with no global container constraints",
|
|
1548
|
+
classes: {
|
|
1549
|
+
wrapper: "",
|
|
1550
|
+
container: "",
|
|
1551
|
+
content: ""
|
|
1552
|
+
},
|
|
1553
|
+
fullWidth: true
|
|
1554
|
+
};
|
|
1555
|
+
fullWidthLayout = {
|
|
1556
|
+
value: "full-width",
|
|
1557
|
+
label: "Full Width",
|
|
1558
|
+
description: "Content spans the full viewport width",
|
|
1559
|
+
classes: {
|
|
1560
|
+
wrapper: "w-full",
|
|
1561
|
+
container: "w-full",
|
|
1562
|
+
content: ""
|
|
1563
|
+
},
|
|
1564
|
+
maxWidth: "100%",
|
|
1565
|
+
fullWidth: true
|
|
1566
|
+
};
|
|
1567
|
+
DEFAULT_LAYOUTS = [
|
|
1568
|
+
defaultLayout,
|
|
1569
|
+
landingLayout,
|
|
1570
|
+
fullWidthLayout
|
|
1571
|
+
];
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
|
|
1575
|
+
// src/layouts/utils.ts
|
|
1576
|
+
function getLayout(layouts, value, fallback = "default") {
|
|
1577
|
+
const layout = layouts.find((l) => l.value === value);
|
|
1578
|
+
if (layout) return layout;
|
|
1579
|
+
if (value !== fallback) {
|
|
1580
|
+
return layouts.find((l) => l.value === fallback);
|
|
1581
|
+
}
|
|
1582
|
+
return layouts[0];
|
|
1583
|
+
}
|
|
1584
|
+
function layoutsToOptions(layouts) {
|
|
1585
|
+
return layouts.map(({ value, label, description }) => ({
|
|
1586
|
+
value,
|
|
1587
|
+
label,
|
|
1588
|
+
description
|
|
1589
|
+
}));
|
|
1590
|
+
}
|
|
1591
|
+
var init_utils2 = __esm({
|
|
1592
|
+
"src/layouts/utils.ts"() {
|
|
1593
|
+
init_defaults();
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
function LayoutWrapper({ children, layout, className, overrides }) {
|
|
1597
|
+
if (!layout) {
|
|
1598
|
+
if (overrides?.background) {
|
|
1599
|
+
const bgStyles = backgroundValueToCSS(overrides.background);
|
|
1600
|
+
return /* @__PURE__ */ jsx("div", { style: { minHeight: "100vh", ...bgStyles }, children });
|
|
1601
|
+
}
|
|
1602
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1603
|
+
}
|
|
1604
|
+
const Header = layout.header;
|
|
1605
|
+
const Footer = layout.footer;
|
|
1606
|
+
const shouldShowHeader = overrides?.showHeader === "hide" ? false : overrides?.showHeader === "show" ? true : !!Header;
|
|
1607
|
+
const shouldShowFooter = overrides?.showFooter === "hide" ? false : overrides?.showFooter === "show" ? true : !!Footer;
|
|
1608
|
+
const useStickyFooter = layout.stickyFooter !== false;
|
|
1609
|
+
const mainStyle = {
|
|
1610
|
+
...layout.stickyHeaderHeight && shouldShowHeader ? { paddingTop: layout.stickyHeaderHeight } : {},
|
|
1611
|
+
...useStickyFooter ? stickyFooterMainStyle : {}
|
|
1612
|
+
};
|
|
1613
|
+
const outerBackgroundStyles = overrides?.background ? backgroundValueToCSS(overrides.background) : {
|
|
1614
|
+
...layout.styles?.wrapper?.background !== void 0 ? { background: layout.styles.wrapper.background } : {},
|
|
1615
|
+
...layout.styles?.wrapper?.backgroundAttachment !== void 0 ? { backgroundAttachment: layout.styles.wrapper.backgroundAttachment } : {}
|
|
1616
|
+
};
|
|
1617
|
+
const effectiveMaxWidth = overrides?.maxWidth && overrides.maxWidth !== "default" ? overrides.maxWidth : layout.maxWidth;
|
|
1618
|
+
const wrapWithStickyFooter = (content) => {
|
|
1619
|
+
if (useStickyFooter) {
|
|
1620
|
+
return /* @__PURE__ */ jsx("div", { style: { ...stickyFooterContainerStyle, ...outerBackgroundStyles }, children: content });
|
|
1621
|
+
}
|
|
1622
|
+
const hasBackground = Object.keys(outerBackgroundStyles).length > 0;
|
|
1623
|
+
if (hasBackground) {
|
|
1624
|
+
return /* @__PURE__ */ jsx("div", { style: { minHeight: "100vh", ...outerBackgroundStyles }, children: content });
|
|
1625
|
+
}
|
|
1626
|
+
return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
1627
|
+
};
|
|
1628
|
+
if (layout.wrapper) {
|
|
1629
|
+
const CustomWrapper = layout.wrapper;
|
|
1630
|
+
return wrapWithStickyFooter(
|
|
1631
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1632
|
+
shouldShowHeader && Header && /* @__PURE__ */ jsx(Header, {}),
|
|
1633
|
+
/* @__PURE__ */ jsx("main", { style: Object.keys(mainStyle).length > 0 ? mainStyle : void 0, children: /* @__PURE__ */ jsx(CustomWrapper, { children }) }),
|
|
1634
|
+
shouldShowFooter && Footer && /* @__PURE__ */ jsx(Footer, {})
|
|
1635
|
+
] })
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
const wrapperStyle = {
|
|
1639
|
+
...layout.styles?.wrapper
|
|
1640
|
+
};
|
|
1641
|
+
const containerStyle = {
|
|
1642
|
+
...effectiveMaxWidth && !layout.fullWidth ? { maxWidth: effectiveMaxWidth } : {},
|
|
1643
|
+
...layout.styles?.container
|
|
1644
|
+
};
|
|
1645
|
+
const contentStyle = {
|
|
1646
|
+
...layout.styles?.content
|
|
1647
|
+
};
|
|
1648
|
+
const dataAttrs = {
|
|
1649
|
+
"data-layout": layout.value,
|
|
1650
|
+
...layout.dataAttributes
|
|
1651
|
+
};
|
|
1652
|
+
if (layout.fullWidth) {
|
|
1653
|
+
return wrapWithStickyFooter(
|
|
1654
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1655
|
+
shouldShowHeader && Header && /* @__PURE__ */ jsx(Header, {}),
|
|
1656
|
+
/* @__PURE__ */ jsx(
|
|
1657
|
+
"main",
|
|
1658
|
+
{
|
|
1659
|
+
className: [layout.classes?.wrapper, className].filter(Boolean).join(" ") || void 0,
|
|
1660
|
+
style: {
|
|
1661
|
+
...mainStyle,
|
|
1662
|
+
...Object.keys(wrapperStyle).length > 0 ? wrapperStyle : {}
|
|
1663
|
+
},
|
|
1664
|
+
...dataAttrs,
|
|
1665
|
+
children
|
|
1666
|
+
}
|
|
1667
|
+
),
|
|
1668
|
+
shouldShowFooter && Footer && /* @__PURE__ */ jsx(Footer, {})
|
|
1669
|
+
] })
|
|
1670
|
+
);
|
|
1671
|
+
}
|
|
1672
|
+
return wrapWithStickyFooter(
|
|
1673
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1674
|
+
shouldShowHeader && Header && /* @__PURE__ */ jsx(Header, {}),
|
|
1675
|
+
/* @__PURE__ */ jsx(
|
|
1676
|
+
"main",
|
|
1677
|
+
{
|
|
1678
|
+
className: layout.classes?.wrapper || void 0,
|
|
1679
|
+
style: {
|
|
1680
|
+
...mainStyle,
|
|
1681
|
+
...Object.keys(wrapperStyle).length > 0 ? wrapperStyle : {}
|
|
1682
|
+
},
|
|
1683
|
+
...dataAttrs,
|
|
1684
|
+
children: /* @__PURE__ */ jsx(
|
|
1685
|
+
"div",
|
|
1686
|
+
{
|
|
1687
|
+
className: [layout.classes?.container, className].filter(Boolean).join(" ") || void 0,
|
|
1688
|
+
style: Object.keys(containerStyle).length > 0 ? containerStyle : void 0,
|
|
1689
|
+
children: /* @__PURE__ */ jsx(
|
|
1690
|
+
"div",
|
|
1691
|
+
{
|
|
1692
|
+
className: layout.classes?.content || void 0,
|
|
1693
|
+
style: Object.keys(contentStyle).length > 0 ? contentStyle : void 0,
|
|
1694
|
+
children
|
|
1695
|
+
}
|
|
1696
|
+
)
|
|
1697
|
+
}
|
|
1698
|
+
)
|
|
1699
|
+
}
|
|
1700
|
+
),
|
|
1701
|
+
shouldShowFooter && Footer && /* @__PURE__ */ jsx(Footer, {})
|
|
1702
|
+
] })
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
var stickyFooterContainerStyle, stickyFooterMainStyle;
|
|
1706
|
+
var init_LayoutWrapper = __esm({
|
|
1707
|
+
"src/layouts/LayoutWrapper.tsx"() {
|
|
1708
|
+
init_shared();
|
|
1709
|
+
stickyFooterContainerStyle = {
|
|
1710
|
+
minHeight: "100vh",
|
|
1711
|
+
display: "flex",
|
|
1712
|
+
flexDirection: "column"
|
|
1713
|
+
};
|
|
1714
|
+
stickyFooterMainStyle = {
|
|
1715
|
+
flex: 1
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
|
|
1720
|
+
// src/layouts/index.ts
|
|
1721
|
+
var init_layouts = __esm({
|
|
1722
|
+
"src/layouts/index.ts"() {
|
|
1723
|
+
init_defaults();
|
|
1724
|
+
init_utils2();
|
|
1725
|
+
init_LayoutWrapper();
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
function useScrollAnimation(options = {}) {
|
|
1729
|
+
const {
|
|
1730
|
+
triggerOnScroll = true,
|
|
1731
|
+
threshold = 0.1,
|
|
1732
|
+
once = true,
|
|
1733
|
+
rootMargin = "0px",
|
|
1734
|
+
delay = 0
|
|
1735
|
+
} = options;
|
|
1736
|
+
const ref = useRef(null);
|
|
1737
|
+
const [isInView, setIsInView] = useState(false);
|
|
1738
|
+
const [hasAnimated, setHasAnimated] = useState(false);
|
|
1739
|
+
const timeoutRef = useRef(null);
|
|
1740
|
+
const hasMountedRef = useRef(false);
|
|
1741
|
+
const reset = useCallback(() => {
|
|
1742
|
+
setIsInView(false);
|
|
1743
|
+
setHasAnimated(false);
|
|
1744
|
+
hasMountedRef.current = false;
|
|
1745
|
+
if (timeoutRef.current) {
|
|
1746
|
+
clearTimeout(timeoutRef.current);
|
|
1747
|
+
timeoutRef.current = null;
|
|
1748
|
+
}
|
|
1749
|
+
}, []);
|
|
1750
|
+
useEffect(() => {
|
|
1751
|
+
if (!triggerOnScroll) {
|
|
1752
|
+
if (hasMountedRef.current) return;
|
|
1753
|
+
hasMountedRef.current = true;
|
|
1754
|
+
requestAnimationFrame(() => {
|
|
1755
|
+
requestAnimationFrame(() => {
|
|
1756
|
+
if (delay > 0) {
|
|
1757
|
+
timeoutRef.current = setTimeout(() => {
|
|
1758
|
+
setIsInView(true);
|
|
1759
|
+
setHasAnimated(true);
|
|
1760
|
+
}, delay);
|
|
1761
|
+
} else {
|
|
1762
|
+
setIsInView(true);
|
|
1763
|
+
setHasAnimated(true);
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
});
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
if (once && hasAnimated) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
const element = ref.current;
|
|
1773
|
+
if (!element) return;
|
|
1774
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
1775
|
+
setIsInView(true);
|
|
1776
|
+
setHasAnimated(true);
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
const observer = new IntersectionObserver(
|
|
1780
|
+
(entries) => {
|
|
1781
|
+
const [entry] = entries;
|
|
1782
|
+
const inView = entry.isIntersecting;
|
|
1783
|
+
if (inView) {
|
|
1784
|
+
if (delay > 0) {
|
|
1785
|
+
timeoutRef.current = setTimeout(() => {
|
|
1786
|
+
setIsInView(true);
|
|
1787
|
+
setHasAnimated(true);
|
|
1788
|
+
}, delay);
|
|
1789
|
+
} else {
|
|
1790
|
+
setIsInView(true);
|
|
1791
|
+
setHasAnimated(true);
|
|
1792
|
+
}
|
|
1793
|
+
if (once) {
|
|
1794
|
+
observer.disconnect();
|
|
1795
|
+
}
|
|
1796
|
+
} else if (!once) {
|
|
1797
|
+
if (timeoutRef.current) {
|
|
1798
|
+
clearTimeout(timeoutRef.current);
|
|
1799
|
+
timeoutRef.current = null;
|
|
1800
|
+
}
|
|
1801
|
+
setIsInView(false);
|
|
1802
|
+
}
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
threshold,
|
|
1806
|
+
rootMargin
|
|
1807
|
+
}
|
|
1808
|
+
);
|
|
1809
|
+
observer.observe(element);
|
|
1810
|
+
return () => {
|
|
1811
|
+
observer.disconnect();
|
|
1812
|
+
if (timeoutRef.current) {
|
|
1813
|
+
clearTimeout(timeoutRef.current);
|
|
1814
|
+
timeoutRef.current = null;
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
}, [triggerOnScroll, threshold, once, rootMargin, delay, hasAnimated]);
|
|
1818
|
+
return {
|
|
1819
|
+
ref,
|
|
1820
|
+
isInView,
|
|
1821
|
+
hasAnimated,
|
|
1822
|
+
reset
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
var init_useScrollAnimation = __esm({
|
|
1826
|
+
"src/hooks/useScrollAnimation.ts"() {
|
|
1827
|
+
"use client";
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
function AnimatedWrapper({
|
|
1831
|
+
animation,
|
|
1832
|
+
children,
|
|
1833
|
+
className,
|
|
1834
|
+
style,
|
|
1835
|
+
as: Component = "div"
|
|
1836
|
+
}) {
|
|
1837
|
+
const hasAnimation = animation && (animation.mode === "preset" && animation.entrance && animation.entrance !== "none" || animation.mode === "custom");
|
|
1838
|
+
if (!hasAnimation) {
|
|
1839
|
+
if (className || style) {
|
|
1840
|
+
return /* @__PURE__ */ jsx(Component, { className, style, children });
|
|
1841
|
+
}
|
|
1842
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1843
|
+
}
|
|
1844
|
+
const { ref, isInView } = useScrollAnimation({
|
|
1845
|
+
triggerOnScroll: animation.triggerOnScroll ?? true,
|
|
1846
|
+
threshold: animation.triggerThreshold ?? 0.1,
|
|
1847
|
+
once: animation.triggerOnce ?? true,
|
|
1848
|
+
rootMargin: animation.triggerMargin
|
|
1849
|
+
});
|
|
1850
|
+
if (animation.mode === "preset") {
|
|
1851
|
+
const { initial, animate, duration, delay, easing, origin } = getEntranceAnimationStyles(animation);
|
|
1852
|
+
const animationStyles = isInView ? animate : initial;
|
|
1853
|
+
const transitionProperties = [
|
|
1854
|
+
`opacity ${duration}ms ${easing} ${delay}ms`,
|
|
1855
|
+
`transform ${duration}ms ${easing} ${delay}ms`,
|
|
1856
|
+
`filter ${duration}ms ${easing} ${delay}ms`
|
|
1857
|
+
].join(", ");
|
|
1858
|
+
return /* @__PURE__ */ jsx(
|
|
1859
|
+
Component,
|
|
1860
|
+
{
|
|
1861
|
+
ref,
|
|
1862
|
+
className,
|
|
1863
|
+
style: {
|
|
1864
|
+
...style,
|
|
1865
|
+
...animationStyles,
|
|
1866
|
+
transition: transitionProperties,
|
|
1867
|
+
transformOrigin: origin
|
|
1868
|
+
},
|
|
1869
|
+
children
|
|
1870
|
+
}
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
const customStyles = animationValueToCSS(animation);
|
|
1874
|
+
return /* @__PURE__ */ jsx(
|
|
1875
|
+
Component,
|
|
1876
|
+
{
|
|
1877
|
+
ref,
|
|
1878
|
+
className,
|
|
1879
|
+
style: {
|
|
1880
|
+
...style,
|
|
1881
|
+
...customStyles,
|
|
1882
|
+
// Apply opacity for visibility-based transitions
|
|
1883
|
+
opacity: isInView ? 1 : 0
|
|
1884
|
+
},
|
|
1885
|
+
children
|
|
1886
|
+
}
|
|
1887
|
+
);
|
|
1888
|
+
}
|
|
1889
|
+
var init_AnimatedWrapper = __esm({
|
|
1890
|
+
"src/components/AnimatedWrapper.tsx"() {
|
|
1891
|
+
"use client";
|
|
1892
|
+
init_useScrollAnimation();
|
|
1893
|
+
init_shared();
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
function generateUniqueId() {
|
|
1897
|
+
return `c${(++idCounter).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
1898
|
+
}
|
|
1899
|
+
var idCounter, defaultProps, ContainerConfig;
|
|
1900
|
+
var init_Container_server = __esm({
|
|
1901
|
+
"src/components/layout/Container.server.tsx"() {
|
|
1902
|
+
init_shared();
|
|
1903
|
+
init_AnimatedWrapper();
|
|
1904
|
+
idCounter = 0;
|
|
1905
|
+
defaultProps = {
|
|
1906
|
+
content: [],
|
|
1907
|
+
background: null,
|
|
1908
|
+
customPadding: null,
|
|
1909
|
+
dimensions: null,
|
|
1910
|
+
border: null,
|
|
1911
|
+
margin: null,
|
|
1912
|
+
animation: null,
|
|
1913
|
+
innerBackground: null,
|
|
1914
|
+
innerPadding: null,
|
|
1915
|
+
innerBorder: null,
|
|
1916
|
+
visibility: null
|
|
1917
|
+
};
|
|
1918
|
+
ContainerConfig = {
|
|
1919
|
+
label: "Container",
|
|
1920
|
+
fields: {
|
|
1921
|
+
content: { type: "slot" }
|
|
1922
|
+
},
|
|
1923
|
+
defaultProps,
|
|
1924
|
+
render: ({
|
|
1925
|
+
content: Content2,
|
|
1926
|
+
background,
|
|
1927
|
+
customPadding,
|
|
1928
|
+
dimensions,
|
|
1929
|
+
border,
|
|
1930
|
+
margin,
|
|
1931
|
+
animation,
|
|
1932
|
+
innerBackground,
|
|
1933
|
+
innerPadding,
|
|
1934
|
+
innerBorder,
|
|
1935
|
+
visibility
|
|
1936
|
+
}) => {
|
|
1937
|
+
const uniqueId = generateUniqueId();
|
|
1938
|
+
const outerClass = `puck-container-outer-${uniqueId}`;
|
|
1939
|
+
const innerClass = `puck-container-inner-${uniqueId}`;
|
|
1940
|
+
const mediaQueries = [];
|
|
1941
|
+
const outerBackgroundStyles = backgroundValueToCSS(background);
|
|
1942
|
+
const outerStyles = {
|
|
1943
|
+
...outerBackgroundStyles
|
|
1944
|
+
};
|
|
1945
|
+
const outerPaddingResult = responsiveValueToCSS(
|
|
1946
|
+
customPadding,
|
|
1947
|
+
(v) => ({ padding: paddingValueToCSS(v) }),
|
|
1948
|
+
outerClass
|
|
1949
|
+
);
|
|
1950
|
+
Object.assign(outerStyles, outerPaddingResult.baseStyles);
|
|
1951
|
+
if (outerPaddingResult.mediaQueryCSS) {
|
|
1952
|
+
mediaQueries.push(outerPaddingResult.mediaQueryCSS);
|
|
1953
|
+
}
|
|
1954
|
+
const outerBorderStyles = borderValueToCSS(border);
|
|
1955
|
+
if (outerBorderStyles) {
|
|
1956
|
+
Object.assign(outerStyles, outerBorderStyles);
|
|
1957
|
+
}
|
|
1958
|
+
const marginResult = responsiveValueToCSS(
|
|
1959
|
+
margin,
|
|
1960
|
+
(v) => ({ margin: marginValueToCSS(v) }),
|
|
1961
|
+
outerClass
|
|
1962
|
+
);
|
|
1963
|
+
Object.assign(outerStyles, marginResult.baseStyles);
|
|
1964
|
+
if (marginResult.mediaQueryCSS) {
|
|
1965
|
+
mediaQueries.push(marginResult.mediaQueryCSS);
|
|
1966
|
+
}
|
|
1967
|
+
const innerBackgroundStyles = backgroundValueToCSS(innerBackground);
|
|
1968
|
+
const innerStyles = {
|
|
1969
|
+
...innerBackgroundStyles
|
|
1970
|
+
};
|
|
1971
|
+
const dimensionsResult = responsiveValueToCSS(
|
|
1972
|
+
dimensions,
|
|
1973
|
+
dimensionsValueToCSS,
|
|
1974
|
+
innerClass
|
|
1975
|
+
);
|
|
1976
|
+
Object.assign(innerStyles, dimensionsResult.baseStyles);
|
|
1977
|
+
if (dimensionsResult.mediaQueryCSS) {
|
|
1978
|
+
mediaQueries.push(dimensionsResult.mediaQueryCSS);
|
|
1979
|
+
}
|
|
1980
|
+
const innerPaddingResult = responsiveValueToCSS(
|
|
1981
|
+
innerPadding,
|
|
1982
|
+
(v) => ({ padding: paddingValueToCSS(v) }),
|
|
1983
|
+
innerClass
|
|
1984
|
+
);
|
|
1985
|
+
Object.assign(innerStyles, innerPaddingResult.baseStyles);
|
|
1986
|
+
if (innerPaddingResult.mediaQueryCSS) {
|
|
1987
|
+
mediaQueries.push(innerPaddingResult.mediaQueryCSS);
|
|
1988
|
+
}
|
|
1989
|
+
const innerBorderStyles = borderValueToCSS(innerBorder);
|
|
1990
|
+
if (innerBorderStyles) {
|
|
1991
|
+
Object.assign(innerStyles, innerBorderStyles);
|
|
1992
|
+
}
|
|
1993
|
+
const visibilityCSS = visibilityValueToCSS(visibility, outerClass);
|
|
1994
|
+
if (visibilityCSS) {
|
|
1995
|
+
mediaQueries.push(visibilityCSS);
|
|
1996
|
+
}
|
|
1997
|
+
const contentClasses = cn2("px-4", innerClass);
|
|
1998
|
+
const hasInnerStyles = Object.keys(innerStyles).length > 0;
|
|
1999
|
+
const allMediaQueryCSS = mediaQueries.join("\n");
|
|
2000
|
+
const ContentSlot = Content2;
|
|
2001
|
+
return /* @__PURE__ */ jsxs(AnimatedWrapper, { animation, children: [
|
|
2002
|
+
allMediaQueryCSS && /* @__PURE__ */ jsx("style", { children: allMediaQueryCSS }),
|
|
2003
|
+
/* @__PURE__ */ jsx("div", { className: outerClass, style: outerStyles, children: hasInnerStyles ? /* @__PURE__ */ jsx("div", { className: contentClasses, style: innerStyles, children: /* @__PURE__ */ jsx(ContentSlot, {}) }) : /* @__PURE__ */ jsx(ContentSlot, { className: contentClasses, style: innerStyles }) })
|
|
2004
|
+
] });
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
2009
|
+
function generateUniqueId2() {
|
|
2010
|
+
return `f${(++idCounter2).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2011
|
+
}
|
|
2012
|
+
var idCounter2, flexDirectionMap, flexWrapMap, defaultProps2, FlexConfig;
|
|
2013
|
+
var init_Flex_server = __esm({
|
|
2014
|
+
"src/components/layout/Flex.server.tsx"() {
|
|
2015
|
+
init_shared();
|
|
2016
|
+
init_AnimatedWrapper();
|
|
2017
|
+
idCounter2 = 0;
|
|
2018
|
+
flexDirectionMap = {
|
|
2019
|
+
row: "flex-row",
|
|
2020
|
+
column: "flex-col",
|
|
2021
|
+
"row-reverse": "flex-row-reverse",
|
|
2022
|
+
"column-reverse": "flex-col-reverse"
|
|
2023
|
+
};
|
|
2024
|
+
flexWrapMap = {
|
|
2025
|
+
wrap: "flex-wrap",
|
|
2026
|
+
nowrap: "flex-nowrap",
|
|
2027
|
+
"wrap-reverse": "flex-wrap-reverse"
|
|
2028
|
+
};
|
|
2029
|
+
defaultProps2 = {
|
|
2030
|
+
content: [],
|
|
2031
|
+
direction: "row",
|
|
2032
|
+
justifyContent: null,
|
|
2033
|
+
alignItems: null,
|
|
2034
|
+
gap: 24,
|
|
2035
|
+
wrap: "wrap",
|
|
2036
|
+
background: null,
|
|
2037
|
+
customPadding: null,
|
|
2038
|
+
margin: null,
|
|
2039
|
+
dimensions: null,
|
|
2040
|
+
border: null,
|
|
2041
|
+
animation: null,
|
|
2042
|
+
visibility: null
|
|
2043
|
+
};
|
|
2044
|
+
FlexConfig = {
|
|
2045
|
+
label: "Flex",
|
|
2046
|
+
fields: {
|
|
2047
|
+
content: { type: "slot" }
|
|
2048
|
+
},
|
|
2049
|
+
defaultProps: defaultProps2,
|
|
2050
|
+
render: ({
|
|
2051
|
+
content: Content2,
|
|
2052
|
+
direction,
|
|
2053
|
+
justifyContent,
|
|
2054
|
+
alignItems,
|
|
2055
|
+
gap,
|
|
2056
|
+
wrap,
|
|
2057
|
+
background,
|
|
2058
|
+
customPadding,
|
|
2059
|
+
margin,
|
|
2060
|
+
dimensions,
|
|
2061
|
+
border,
|
|
2062
|
+
animation,
|
|
2063
|
+
visibility
|
|
2064
|
+
}) => {
|
|
2065
|
+
const uniqueId = generateUniqueId2();
|
|
2066
|
+
const wrapperClass = `puck-flex-${uniqueId}`;
|
|
2067
|
+
const contentClass = `puck-flex-content-${uniqueId}`;
|
|
2068
|
+
const mediaQueries = [];
|
|
2069
|
+
const backgroundStyles = backgroundValueToCSS(background);
|
|
2070
|
+
const wrapperStyles = {
|
|
2071
|
+
...backgroundStyles
|
|
2072
|
+
};
|
|
2073
|
+
const paddingResult = responsiveValueToCSS(
|
|
2074
|
+
customPadding,
|
|
2075
|
+
(v) => ({ padding: paddingValueToCSS(v) }),
|
|
2076
|
+
wrapperClass
|
|
2077
|
+
);
|
|
2078
|
+
Object.assign(wrapperStyles, paddingResult.baseStyles);
|
|
2079
|
+
if (paddingResult.mediaQueryCSS) {
|
|
2080
|
+
mediaQueries.push(paddingResult.mediaQueryCSS);
|
|
2081
|
+
}
|
|
2082
|
+
const borderStyles = borderValueToCSS(border);
|
|
2083
|
+
if (borderStyles) {
|
|
2084
|
+
Object.assign(wrapperStyles, borderStyles);
|
|
2085
|
+
}
|
|
2086
|
+
const marginResult = responsiveValueToCSS(
|
|
2087
|
+
margin,
|
|
2088
|
+
(v) => ({ margin: marginValueToCSS(v) }),
|
|
2089
|
+
wrapperClass
|
|
2090
|
+
);
|
|
2091
|
+
Object.assign(wrapperStyles, marginResult.baseStyles);
|
|
2092
|
+
if (marginResult.mediaQueryCSS) {
|
|
2093
|
+
mediaQueries.push(marginResult.mediaQueryCSS);
|
|
2094
|
+
}
|
|
2095
|
+
const dimensionsResult = responsiveValueToCSS(
|
|
2096
|
+
dimensions,
|
|
2097
|
+
dimensionsValueToCSS,
|
|
2098
|
+
contentClass
|
|
2099
|
+
);
|
|
2100
|
+
const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
|
|
2101
|
+
if (visibilityCSS) {
|
|
2102
|
+
mediaQueries.push(visibilityCSS);
|
|
2103
|
+
}
|
|
2104
|
+
const contentClasses = cn2(
|
|
2105
|
+
"flex w-full min-h-[50px]",
|
|
2106
|
+
flexDirectionMap[direction],
|
|
2107
|
+
justifyContent && justifyContentMap[justifyContent],
|
|
2108
|
+
alignItems && alignItemsMap[alignItems],
|
|
2109
|
+
flexWrapMap[wrap],
|
|
2110
|
+
"[&>*]:min-w-0",
|
|
2111
|
+
contentClass
|
|
2112
|
+
);
|
|
2113
|
+
const contentStyles = {
|
|
2114
|
+
gap,
|
|
2115
|
+
...dimensionsResult.baseStyles
|
|
2116
|
+
};
|
|
2117
|
+
if (dimensionsResult.mediaQueryCSS) {
|
|
2118
|
+
mediaQueries.push(dimensionsResult.mediaQueryCSS);
|
|
2119
|
+
}
|
|
2120
|
+
const allMediaQueryCSS = mediaQueries.join("\n");
|
|
2121
|
+
const ContentSlot = Content2;
|
|
2122
|
+
return /* @__PURE__ */ jsxs(AnimatedWrapper, { animation, children: [
|
|
2123
|
+
allMediaQueryCSS && /* @__PURE__ */ jsx("style", { children: allMediaQueryCSS }),
|
|
2124
|
+
/* @__PURE__ */ jsx("div", { className: wrapperClass, style: wrapperStyles, children: /* @__PURE__ */ jsx(ContentSlot, { className: contentClasses, style: contentStyles }) })
|
|
2125
|
+
] });
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
function generateUniqueId3() {
|
|
2131
|
+
return `g${(++idCounter3).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2132
|
+
}
|
|
2133
|
+
var idCounter3, defaultProps3, GridConfig;
|
|
2134
|
+
var init_Grid_server = __esm({
|
|
2135
|
+
"src/components/layout/Grid.server.tsx"() {
|
|
2136
|
+
init_shared();
|
|
2137
|
+
init_AnimatedWrapper();
|
|
2138
|
+
idCounter3 = 0;
|
|
2139
|
+
defaultProps3 = {
|
|
2140
|
+
content: [],
|
|
2141
|
+
numColumns: 3,
|
|
2142
|
+
gap: 24,
|
|
2143
|
+
background: null,
|
|
2144
|
+
customPadding: null,
|
|
2145
|
+
dimensions: null,
|
|
2146
|
+
border: null,
|
|
2147
|
+
margin: null,
|
|
2148
|
+
animation: null,
|
|
2149
|
+
visibility: null
|
|
2150
|
+
};
|
|
2151
|
+
GridConfig = {
|
|
2152
|
+
label: "Grid",
|
|
2153
|
+
fields: {
|
|
2154
|
+
content: { type: "slot" }
|
|
2155
|
+
},
|
|
2156
|
+
defaultProps: defaultProps3,
|
|
2157
|
+
render: ({
|
|
2158
|
+
content: Content2,
|
|
2159
|
+
numColumns,
|
|
2160
|
+
gap,
|
|
2161
|
+
background,
|
|
2162
|
+
customPadding,
|
|
2163
|
+
dimensions,
|
|
2164
|
+
border,
|
|
2165
|
+
margin,
|
|
2166
|
+
animation,
|
|
2167
|
+
visibility
|
|
2168
|
+
}) => {
|
|
2169
|
+
const uniqueId = generateUniqueId3();
|
|
2170
|
+
const wrapperClass = `puck-grid-${uniqueId}`;
|
|
2171
|
+
const contentClass = `puck-grid-content-${uniqueId}`;
|
|
2172
|
+
const mediaQueries = [];
|
|
2173
|
+
const backgroundStyles = backgroundValueToCSS(background);
|
|
2174
|
+
const wrapperStyles = {
|
|
2175
|
+
...backgroundStyles
|
|
2176
|
+
};
|
|
2177
|
+
const paddingResult = responsiveValueToCSS(
|
|
2178
|
+
customPadding,
|
|
2179
|
+
(v) => ({ padding: paddingValueToCSS(v) }),
|
|
2180
|
+
wrapperClass
|
|
2181
|
+
);
|
|
2182
|
+
Object.assign(wrapperStyles, paddingResult.baseStyles);
|
|
2183
|
+
if (paddingResult.mediaQueryCSS) {
|
|
2184
|
+
mediaQueries.push(paddingResult.mediaQueryCSS);
|
|
2185
|
+
}
|
|
2186
|
+
const borderStyles = borderValueToCSS(border);
|
|
2187
|
+
if (borderStyles) {
|
|
2188
|
+
Object.assign(wrapperStyles, borderStyles);
|
|
2189
|
+
}
|
|
2190
|
+
const marginResult = responsiveValueToCSS(
|
|
2191
|
+
margin,
|
|
2192
|
+
(v) => ({ margin: marginValueToCSS(v) }),
|
|
2193
|
+
wrapperClass
|
|
2194
|
+
);
|
|
2195
|
+
Object.assign(wrapperStyles, marginResult.baseStyles);
|
|
2196
|
+
if (marginResult.mediaQueryCSS) {
|
|
2197
|
+
mediaQueries.push(marginResult.mediaQueryCSS);
|
|
2198
|
+
}
|
|
2199
|
+
const dimensionsResult = responsiveValueToCSS(
|
|
2200
|
+
dimensions,
|
|
2201
|
+
dimensionsValueToCSS,
|
|
2202
|
+
contentClass
|
|
2203
|
+
);
|
|
2204
|
+
const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
|
|
2205
|
+
if (visibilityCSS) {
|
|
2206
|
+
mediaQueries.push(visibilityCSS);
|
|
2207
|
+
}
|
|
2208
|
+
const contentClasses = cn2(
|
|
2209
|
+
"flex flex-col w-full",
|
|
2210
|
+
"md:grid",
|
|
2211
|
+
contentClass
|
|
2212
|
+
);
|
|
2213
|
+
const contentStyles = {
|
|
2214
|
+
gap,
|
|
2215
|
+
...dimensionsResult.baseStyles
|
|
2216
|
+
};
|
|
2217
|
+
if (dimensionsResult.mediaQueryCSS) {
|
|
2218
|
+
mediaQueries.push(dimensionsResult.mediaQueryCSS);
|
|
2219
|
+
}
|
|
2220
|
+
const gridStyles = {
|
|
2221
|
+
...contentStyles,
|
|
2222
|
+
"--grid-cols": numColumns
|
|
2223
|
+
};
|
|
2224
|
+
const allMediaQueryCSS = mediaQueries.join("\n");
|
|
2225
|
+
const ContentSlot = Content2;
|
|
2226
|
+
return /* @__PURE__ */ jsxs(AnimatedWrapper, { animation, children: [
|
|
2227
|
+
allMediaQueryCSS && /* @__PURE__ */ jsx("style", { children: allMediaQueryCSS }),
|
|
2228
|
+
/* @__PURE__ */ jsxs("div", { className: wrapperClass, style: wrapperStyles, children: [
|
|
2229
|
+
/* @__PURE__ */ jsx(ContentSlot, { className: contentClasses, style: gridStyles }),
|
|
2230
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
2231
|
+
@media (min-width: 768px) {
|
|
2232
|
+
.flex.md\\:grid {
|
|
2233
|
+
grid-template-columns: repeat(var(--grid-cols), 1fr);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
` })
|
|
2237
|
+
] })
|
|
2238
|
+
] });
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
function generateUniqueId4() {
|
|
2244
|
+
return `s${(++idCounter4).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2245
|
+
}
|
|
2246
|
+
var idCounter4, defaultProps4, SectionConfig;
|
|
2247
|
+
var init_Section_server = __esm({
|
|
2248
|
+
"src/components/layout/Section.server.tsx"() {
|
|
2249
|
+
init_shared();
|
|
2250
|
+
init_AnimatedWrapper();
|
|
2251
|
+
idCounter4 = 0;
|
|
2252
|
+
defaultProps4 = {
|
|
2253
|
+
id: "",
|
|
2254
|
+
content: [],
|
|
2255
|
+
background: null,
|
|
2256
|
+
fullWidth: false,
|
|
2257
|
+
customPadding: null,
|
|
2258
|
+
dimensions: null,
|
|
2259
|
+
border: null,
|
|
2260
|
+
margin: null,
|
|
2261
|
+
animation: null,
|
|
2262
|
+
visibility: null
|
|
2263
|
+
};
|
|
2264
|
+
SectionConfig = {
|
|
2265
|
+
label: "Section",
|
|
2266
|
+
fields: {
|
|
2267
|
+
content: { type: "slot" }
|
|
2268
|
+
},
|
|
2269
|
+
defaultProps: defaultProps4,
|
|
2270
|
+
render: ({
|
|
2271
|
+
id,
|
|
2272
|
+
content: Content2,
|
|
2273
|
+
background,
|
|
2274
|
+
fullWidth,
|
|
2275
|
+
customPadding,
|
|
2276
|
+
dimensions,
|
|
2277
|
+
border,
|
|
2278
|
+
margin,
|
|
2279
|
+
animation,
|
|
2280
|
+
visibility
|
|
2281
|
+
}) => {
|
|
2282
|
+
const uniqueId = generateUniqueId4();
|
|
2283
|
+
const sectionClass = `puck-section-${uniqueId}`;
|
|
2284
|
+
const contentClass = `puck-section-content-${uniqueId}`;
|
|
2285
|
+
const mediaQueries = [];
|
|
2286
|
+
const backgroundStyles = backgroundValueToCSS(background);
|
|
2287
|
+
const sectionStyles = {
|
|
2288
|
+
...backgroundStyles
|
|
2289
|
+
};
|
|
2290
|
+
const paddingResult = responsiveValueToCSS(
|
|
2291
|
+
customPadding,
|
|
2292
|
+
(v) => ({ padding: paddingValueToCSS(v) }),
|
|
2293
|
+
sectionClass
|
|
2294
|
+
);
|
|
2295
|
+
Object.assign(sectionStyles, paddingResult.baseStyles);
|
|
2296
|
+
if (paddingResult.mediaQueryCSS) {
|
|
2297
|
+
mediaQueries.push(paddingResult.mediaQueryCSS);
|
|
2298
|
+
}
|
|
2299
|
+
const borderStyles = borderValueToCSS(border);
|
|
2300
|
+
if (borderStyles) {
|
|
2301
|
+
Object.assign(sectionStyles, borderStyles);
|
|
2302
|
+
}
|
|
2303
|
+
const marginResult = responsiveValueToCSS(
|
|
2304
|
+
margin,
|
|
2305
|
+
(v) => ({ margin: marginValueToCSS(v) }),
|
|
2306
|
+
sectionClass
|
|
2307
|
+
);
|
|
2308
|
+
Object.assign(sectionStyles, marginResult.baseStyles);
|
|
2309
|
+
if (marginResult.mediaQueryCSS) {
|
|
2310
|
+
mediaQueries.push(marginResult.mediaQueryCSS);
|
|
2311
|
+
}
|
|
2312
|
+
const visibilityCSS = visibilityValueToCSS(visibility, sectionClass);
|
|
2313
|
+
if (visibilityCSS) {
|
|
2314
|
+
mediaQueries.push(visibilityCSS);
|
|
2315
|
+
}
|
|
2316
|
+
const sectionClasses = cn2("relative w-full", sectionClass);
|
|
2317
|
+
const dimensionsResult = responsiveValueToCSS(
|
|
2318
|
+
dimensions,
|
|
2319
|
+
dimensionsValueToCSS,
|
|
2320
|
+
contentClass
|
|
2321
|
+
);
|
|
2322
|
+
if (dimensionsResult.mediaQueryCSS) {
|
|
2323
|
+
mediaQueries.push(dimensionsResult.mediaQueryCSS);
|
|
2324
|
+
}
|
|
2325
|
+
const contentClasses = cn2(
|
|
2326
|
+
"relative z-10",
|
|
2327
|
+
// Only apply preset content width if no dimensions set
|
|
2328
|
+
!dimensions && !fullWidth && "max-w-[1200px] mx-auto px-4",
|
|
2329
|
+
contentClass
|
|
2330
|
+
);
|
|
2331
|
+
const allMediaQueryCSS = mediaQueries.join("\n");
|
|
2332
|
+
const ContentSlot = Content2;
|
|
2333
|
+
return /* @__PURE__ */ jsxs(AnimatedWrapper, { animation, children: [
|
|
2334
|
+
allMediaQueryCSS && /* @__PURE__ */ jsx("style", { children: allMediaQueryCSS }),
|
|
2335
|
+
/* @__PURE__ */ jsx(
|
|
2336
|
+
"section",
|
|
2337
|
+
{
|
|
2338
|
+
id: id || void 0,
|
|
2339
|
+
className: sectionClasses,
|
|
2340
|
+
style: sectionStyles,
|
|
2341
|
+
children: /* @__PURE__ */ jsx(ContentSlot, { className: contentClasses, style: dimensionsResult.baseStyles })
|
|
2342
|
+
}
|
|
2343
|
+
)
|
|
2344
|
+
] });
|
|
2345
|
+
}
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
function generateUniqueId5() {
|
|
2350
|
+
return `sp${(++idCounter5).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2351
|
+
}
|
|
2352
|
+
var idCounter5, heightMap, widthMap, defaultProps5, SpacerConfig;
|
|
2353
|
+
var init_Spacer_server = __esm({
|
|
2354
|
+
"src/components/layout/Spacer.server.tsx"() {
|
|
2355
|
+
init_shared();
|
|
2356
|
+
idCounter5 = 0;
|
|
2357
|
+
heightMap = {
|
|
2358
|
+
"8px": "h-2",
|
|
2359
|
+
"16px": "h-4",
|
|
2360
|
+
"24px": "h-6",
|
|
2361
|
+
"32px": "h-8",
|
|
2362
|
+
"48px": "h-12",
|
|
2363
|
+
"64px": "h-16",
|
|
2364
|
+
"80px": "h-20",
|
|
2365
|
+
"96px": "h-24",
|
|
2366
|
+
"128px": "h-32"
|
|
2367
|
+
};
|
|
2368
|
+
widthMap = {
|
|
2369
|
+
"8px": "w-2",
|
|
2370
|
+
"16px": "w-4",
|
|
2371
|
+
"24px": "w-6",
|
|
2372
|
+
"32px": "w-8",
|
|
2373
|
+
"48px": "w-12",
|
|
2374
|
+
"64px": "w-16",
|
|
2375
|
+
"80px": "w-20",
|
|
2376
|
+
"96px": "w-24",
|
|
2377
|
+
"128px": "w-32"
|
|
2378
|
+
};
|
|
2379
|
+
defaultProps5 = {
|
|
2380
|
+
size: "24px",
|
|
2381
|
+
direction: "vertical",
|
|
2382
|
+
visibility: null
|
|
2383
|
+
};
|
|
2384
|
+
SpacerConfig = {
|
|
2385
|
+
label: "Spacer",
|
|
2386
|
+
defaultProps: defaultProps5,
|
|
2387
|
+
render: ({ size, direction, visibility }) => {
|
|
2388
|
+
const uniqueId = generateUniqueId5();
|
|
2389
|
+
const wrapperClass = `puck-spacer-${uniqueId}`;
|
|
2390
|
+
const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
|
|
2391
|
+
const getClasses = () => {
|
|
2392
|
+
const heightClass = heightMap[size] || "h-6";
|
|
2393
|
+
const widthClass = widthMap[size] || "w-6";
|
|
2394
|
+
if (direction === "vertical") {
|
|
2395
|
+
return `block ${heightClass} w-full`;
|
|
2396
|
+
}
|
|
2397
|
+
if (direction === "horizontal") {
|
|
2398
|
+
return `inline-block ${widthClass} h-full`;
|
|
2399
|
+
}
|
|
2400
|
+
return `block ${heightClass} ${widthClass}`;
|
|
2401
|
+
};
|
|
2402
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2403
|
+
visibilityCSS && /* @__PURE__ */ jsx("style", { children: visibilityCSS }),
|
|
2404
|
+
/* @__PURE__ */ jsx("div", { className: cn2(getClasses(), wrapperClass), "aria-hidden": "true" })
|
|
2405
|
+
] });
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
});
|
|
2410
|
+
function generateUniqueId6() {
|
|
2411
|
+
return `t${(++idCounter6).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2412
|
+
}
|
|
2413
|
+
var idCounter6, defaultProps6, TemplateServerConfig;
|
|
2414
|
+
var init_Template_server = __esm({
|
|
2415
|
+
"src/components/layout/Template.server.tsx"() {
|
|
2416
|
+
init_shared();
|
|
2417
|
+
idCounter6 = 0;
|
|
2418
|
+
defaultProps6 = {
|
|
2419
|
+
content: [],
|
|
2420
|
+
templateId: null,
|
|
2421
|
+
dimensions: null,
|
|
2422
|
+
customPadding: null,
|
|
2423
|
+
margin: null,
|
|
2424
|
+
visibility: null
|
|
2425
|
+
};
|
|
2426
|
+
TemplateServerConfig = {
|
|
2427
|
+
label: "Template",
|
|
2428
|
+
fields: {
|
|
2429
|
+
// In server config, templateId is just for reference (no loading UI)
|
|
2430
|
+
templateId: {
|
|
2431
|
+
type: "text",
|
|
2432
|
+
label: "Template ID"
|
|
2433
|
+
},
|
|
2434
|
+
content: {
|
|
2435
|
+
type: "slot"
|
|
2436
|
+
}
|
|
2437
|
+
},
|
|
2438
|
+
defaultProps: defaultProps6,
|
|
2439
|
+
render: ({ content: Content2, dimensions, customPadding, margin, visibility }) => {
|
|
2440
|
+
const uniqueId = generateUniqueId6();
|
|
2441
|
+
const wrapperClass = `puck-template-${uniqueId}`;
|
|
2442
|
+
const contentClass = `puck-template-content-${uniqueId}`;
|
|
2443
|
+
const mediaQueries = [];
|
|
2444
|
+
const wrapperStyles = {};
|
|
2445
|
+
const paddingResult = responsiveValueToCSS(
|
|
2446
|
+
customPadding,
|
|
2447
|
+
(v) => ({ padding: paddingValueToCSS(v) }),
|
|
2448
|
+
wrapperClass
|
|
2449
|
+
);
|
|
2450
|
+
Object.assign(wrapperStyles, paddingResult.baseStyles);
|
|
2451
|
+
if (paddingResult.mediaQueryCSS) {
|
|
2452
|
+
mediaQueries.push(paddingResult.mediaQueryCSS);
|
|
2453
|
+
}
|
|
2454
|
+
const marginResult = responsiveValueToCSS(
|
|
2455
|
+
margin,
|
|
2456
|
+
(v) => ({ margin: marginValueToCSS(v) }),
|
|
2457
|
+
wrapperClass
|
|
2458
|
+
);
|
|
2459
|
+
Object.assign(wrapperStyles, marginResult.baseStyles);
|
|
2460
|
+
if (marginResult.mediaQueryCSS) {
|
|
2461
|
+
mediaQueries.push(marginResult.mediaQueryCSS);
|
|
2462
|
+
}
|
|
2463
|
+
const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
|
|
2464
|
+
if (visibilityCSS) {
|
|
2465
|
+
mediaQueries.push(visibilityCSS);
|
|
2466
|
+
}
|
|
2467
|
+
const dimensionsResult = responsiveValueToCSS(
|
|
2468
|
+
dimensions,
|
|
2469
|
+
dimensionsValueToCSS,
|
|
2470
|
+
contentClass
|
|
2471
|
+
);
|
|
2472
|
+
if (dimensionsResult.mediaQueryCSS) {
|
|
2473
|
+
mediaQueries.push(dimensionsResult.mediaQueryCSS);
|
|
2474
|
+
}
|
|
2475
|
+
const allMediaQueryCSS = mediaQueries.join("\n");
|
|
2476
|
+
const ContentSlot = Content2;
|
|
2477
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2478
|
+
allMediaQueryCSS && /* @__PURE__ */ jsx("style", { children: allMediaQueryCSS }),
|
|
2479
|
+
/* @__PURE__ */ jsx(
|
|
2480
|
+
"div",
|
|
2481
|
+
{
|
|
2482
|
+
className: cn2("template-wrapper", wrapperClass),
|
|
2483
|
+
style: Object.keys(wrapperStyles).length > 0 ? wrapperStyles : void 0,
|
|
2484
|
+
children: /* @__PURE__ */ jsx(ContentSlot, { className: contentClass, style: dimensionsResult.baseStyles })
|
|
2485
|
+
}
|
|
2486
|
+
)
|
|
2487
|
+
] });
|
|
2488
|
+
}
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
});
|
|
2492
|
+
var defaultProps7, HeadingConfig;
|
|
2493
|
+
var init_Heading_server = __esm({
|
|
2494
|
+
"src/components/typography/Heading.server.tsx"() {
|
|
2495
|
+
init_shared();
|
|
2496
|
+
init_AnimatedWrapper();
|
|
2497
|
+
defaultProps7 = {
|
|
2498
|
+
text: "Heading Text",
|
|
2499
|
+
level: "h2",
|
|
2500
|
+
alignment: null,
|
|
2501
|
+
textColor: null,
|
|
2502
|
+
dimensions: null,
|
|
2503
|
+
animation: null,
|
|
2504
|
+
margin: null,
|
|
2505
|
+
customPadding: null
|
|
2506
|
+
};
|
|
2507
|
+
HeadingConfig = {
|
|
2508
|
+
label: "Heading",
|
|
2509
|
+
defaultProps: defaultProps7,
|
|
2510
|
+
render: ({ text, level, alignment, textColor, dimensions, animation, margin, customPadding }) => {
|
|
2511
|
+
const tag = level || "h2";
|
|
2512
|
+
const alignmentValue = alignment ?? "left";
|
|
2513
|
+
const classes = cn2(
|
|
2514
|
+
headingLevelMap[level] || headingLevelMap.h2,
|
|
2515
|
+
alignmentMap[alignmentValue] || alignmentMap.left
|
|
2516
|
+
);
|
|
2517
|
+
const dimensionsStyles = dimensions ? dimensionsValueToCSS(dimensions) : void 0;
|
|
2518
|
+
const style = {
|
|
2519
|
+
...dimensionsStyles
|
|
2520
|
+
};
|
|
2521
|
+
const marginCSS = marginValueToCSS(margin);
|
|
2522
|
+
if (marginCSS) {
|
|
2523
|
+
style.margin = marginCSS;
|
|
2524
|
+
}
|
|
2525
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
2526
|
+
if (paddingCSS) {
|
|
2527
|
+
style.padding = paddingCSS;
|
|
2528
|
+
}
|
|
2529
|
+
const colorCSS = colorValueToCSS(textColor);
|
|
2530
|
+
if (colorCSS) {
|
|
2531
|
+
style.color = colorCSS;
|
|
2532
|
+
}
|
|
2533
|
+
const headingElement = createElement(tag, { className: classes, style: Object.keys(style).length > 0 ? style : void 0 }, text);
|
|
2534
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: headingElement });
|
|
2535
|
+
}
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
var defaultProps8, TextConfig;
|
|
2540
|
+
var init_Text_server = __esm({
|
|
2541
|
+
"src/components/typography/Text.server.tsx"() {
|
|
2542
|
+
init_shared();
|
|
2543
|
+
init_AnimatedWrapper();
|
|
2544
|
+
defaultProps8 = {
|
|
2545
|
+
content: "Enter your text here...",
|
|
2546
|
+
size: "base",
|
|
2547
|
+
alignment: null,
|
|
2548
|
+
textColor: null,
|
|
2549
|
+
dimensions: null,
|
|
2550
|
+
animation: null,
|
|
2551
|
+
margin: null,
|
|
2552
|
+
customPadding: null
|
|
2553
|
+
};
|
|
2554
|
+
TextConfig = {
|
|
2555
|
+
label: "Text",
|
|
2556
|
+
defaultProps: defaultProps8,
|
|
2557
|
+
render: ({ content, size, alignment, textColor, dimensions, animation, margin, customPadding }) => {
|
|
2558
|
+
const dimensionsStyles = dimensions ? dimensionsValueToCSS(dimensions) : void 0;
|
|
2559
|
+
const style = {
|
|
2560
|
+
...dimensionsStyles
|
|
2561
|
+
};
|
|
2562
|
+
const marginCSS = marginValueToCSS(margin);
|
|
2563
|
+
if (marginCSS) {
|
|
2564
|
+
style.margin = marginCSS;
|
|
2565
|
+
}
|
|
2566
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
2567
|
+
if (paddingCSS) {
|
|
2568
|
+
style.padding = paddingCSS;
|
|
2569
|
+
}
|
|
2570
|
+
const colorCSS = colorValueToCSS(textColor);
|
|
2571
|
+
if (colorCSS) {
|
|
2572
|
+
style.color = colorCSS;
|
|
2573
|
+
}
|
|
2574
|
+
const alignmentValue = alignment ?? "left";
|
|
2575
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx(
|
|
2576
|
+
"p",
|
|
2577
|
+
{
|
|
2578
|
+
className: cn2(
|
|
2579
|
+
textSizeMap[size] || textSizeMap.base,
|
|
2580
|
+
alignmentMap[alignmentValue] || alignmentMap.left
|
|
2581
|
+
),
|
|
2582
|
+
style: Object.keys(style).length > 0 ? style : void 0,
|
|
2583
|
+
children: content
|
|
2584
|
+
}
|
|
2585
|
+
) });
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
});
|
|
2590
|
+
var defaultProps9, RichTextConfig;
|
|
2591
|
+
var init_RichText_server = __esm({
|
|
2592
|
+
"src/components/typography/RichText.server.tsx"() {
|
|
2593
|
+
init_shared();
|
|
2594
|
+
init_AnimatedWrapper();
|
|
2595
|
+
defaultProps9 = {
|
|
2596
|
+
content: "<p>Enter your content here...</p>",
|
|
2597
|
+
alignment: null,
|
|
2598
|
+
textColor: null,
|
|
2599
|
+
dimensions: null,
|
|
2600
|
+
animation: null,
|
|
2601
|
+
margin: null,
|
|
2602
|
+
customPadding: null
|
|
2603
|
+
};
|
|
2604
|
+
RichTextConfig = {
|
|
2605
|
+
label: "Rich Text",
|
|
2606
|
+
defaultProps: defaultProps9,
|
|
2607
|
+
render: ({ content, alignment, textColor, dimensions, animation, margin, customPadding }) => {
|
|
2608
|
+
const dimensionsStyles = dimensions ? dimensionsValueToCSS(dimensions) : void 0;
|
|
2609
|
+
const style = {
|
|
2610
|
+
...dimensionsStyles
|
|
2611
|
+
};
|
|
2612
|
+
const marginCSS = marginValueToCSS(margin);
|
|
2613
|
+
if (marginCSS) {
|
|
2614
|
+
style.margin = marginCSS;
|
|
2615
|
+
}
|
|
2616
|
+
const customPaddingCSS = paddingValueToCSS(customPadding);
|
|
2617
|
+
if (customPaddingCSS) {
|
|
2618
|
+
style.padding = customPaddingCSS;
|
|
2619
|
+
}
|
|
2620
|
+
const colorCSS = colorValueToCSS(textColor);
|
|
2621
|
+
if (colorCSS) {
|
|
2622
|
+
style.color = colorCSS;
|
|
2623
|
+
}
|
|
2624
|
+
const alignmentValue = alignment ?? "left";
|
|
2625
|
+
const alignmentClass = alignmentMap[alignmentValue] || alignmentMap.left;
|
|
2626
|
+
if (!content || content === "<p></p>") {
|
|
2627
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("section", { className: cn2("relative overflow-hidden px-4", alignmentClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsx("div", { className: "prose dark:prose-invert", children: /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("em", { children: "No content available" }) }) }) }) });
|
|
2628
|
+
}
|
|
2629
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("section", { className: cn2("relative overflow-hidden px-4", alignmentClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsx(
|
|
2630
|
+
"div",
|
|
2631
|
+
{
|
|
2632
|
+
className: "prose dark:prose-invert",
|
|
2633
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
2634
|
+
}
|
|
2635
|
+
) }) });
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
});
|
|
2640
|
+
function generateUniqueId7() {
|
|
2641
|
+
return `i${(++idCounter7).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2642
|
+
}
|
|
2643
|
+
var idCounter7, defaultProps10, ImageConfig;
|
|
2644
|
+
var init_Image_server = __esm({
|
|
2645
|
+
"src/components/media/Image.server.tsx"() {
|
|
2646
|
+
init_shared();
|
|
2647
|
+
init_AnimatedWrapper();
|
|
2648
|
+
idCounter7 = 0;
|
|
2649
|
+
defaultProps10 = {
|
|
2650
|
+
image: null,
|
|
2651
|
+
alt: "",
|
|
2652
|
+
aspectRatio: "auto",
|
|
2653
|
+
link: "",
|
|
2654
|
+
openInNewTab: false,
|
|
2655
|
+
margin: null,
|
|
2656
|
+
border: null,
|
|
2657
|
+
dimensions: null,
|
|
2658
|
+
alignment: null,
|
|
2659
|
+
transform: null,
|
|
2660
|
+
animation: null,
|
|
2661
|
+
customPadding: null,
|
|
2662
|
+
visibility: null
|
|
2663
|
+
};
|
|
2664
|
+
ImageConfig = {
|
|
2665
|
+
label: "Image",
|
|
2666
|
+
defaultProps: defaultProps10,
|
|
2667
|
+
render: ({ image, alt, aspectRatio, link, openInNewTab, dimensions, alignment, margin, border, transform, animation, customPadding, visibility }) => {
|
|
2668
|
+
const uniqueId = generateUniqueId7();
|
|
2669
|
+
const wrapperClass = `puck-image-${uniqueId}`;
|
|
2670
|
+
const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
|
|
2671
|
+
const dimensionsStyles = dimensionsValueToCSS(dimensions);
|
|
2672
|
+
const style = {
|
|
2673
|
+
...dimensionsStyles
|
|
2674
|
+
};
|
|
2675
|
+
const marginCSS = marginValueToCSS(margin);
|
|
2676
|
+
if (marginCSS) {
|
|
2677
|
+
style.margin = marginCSS;
|
|
2678
|
+
}
|
|
2679
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
2680
|
+
if (paddingCSS) {
|
|
2681
|
+
style.padding = paddingCSS;
|
|
2682
|
+
}
|
|
2683
|
+
const borderStyles = borderValueToCSS(border);
|
|
2684
|
+
if (borderStyles) {
|
|
2685
|
+
Object.assign(style, borderStyles);
|
|
2686
|
+
}
|
|
2687
|
+
const transformStyles = transformValueToCSS(transform);
|
|
2688
|
+
if (transformStyles) {
|
|
2689
|
+
Object.assign(style, transformStyles);
|
|
2690
|
+
}
|
|
2691
|
+
const alignmentValue = alignment ?? "center";
|
|
2692
|
+
const alignmentClasses = cn2(
|
|
2693
|
+
"flex",
|
|
2694
|
+
alignmentValue === "left" && "justify-start",
|
|
2695
|
+
alignmentValue === "center" && "justify-center",
|
|
2696
|
+
alignmentValue === "right" && "justify-end"
|
|
2697
|
+
);
|
|
2698
|
+
if (!image?.url) {
|
|
2699
|
+
return /* @__PURE__ */ jsxs(AnimatedWrapper, { animation, children: [
|
|
2700
|
+
visibilityCSS && /* @__PURE__ */ jsx("style", { children: visibilityCSS }),
|
|
2701
|
+
/* @__PURE__ */ jsx("div", { className: cn2("py-4 px-4", wrapperClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsx("div", { className: alignmentClasses, children: /* @__PURE__ */ jsx(
|
|
2702
|
+
"div",
|
|
2703
|
+
{
|
|
2704
|
+
className: cn2(
|
|
2705
|
+
"relative overflow-hidden rounded-lg w-full max-w-md bg-muted flex items-center justify-center min-h-[200px]",
|
|
2706
|
+
aspectRatioMap[aspectRatio] || ""
|
|
2707
|
+
),
|
|
2708
|
+
children: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "No image selected" })
|
|
2709
|
+
}
|
|
2710
|
+
) }) })
|
|
2711
|
+
] });
|
|
2712
|
+
}
|
|
2713
|
+
const imageElement = aspectRatio === "auto" ? /* @__PURE__ */ jsx("div", { className: "relative overflow-hidden rounded-lg w-full", children: /* @__PURE__ */ jsx(
|
|
2714
|
+
"img",
|
|
2715
|
+
{
|
|
2716
|
+
src: image.url,
|
|
2717
|
+
alt: alt || image.alt || "",
|
|
2718
|
+
className: "w-full h-auto object-cover"
|
|
2719
|
+
}
|
|
2720
|
+
) }) : /* @__PURE__ */ jsx("div", { className: cn2("relative overflow-hidden rounded-lg w-full", aspectRatioMap[aspectRatio]), children: /* @__PURE__ */ jsx(
|
|
2721
|
+
"img",
|
|
2722
|
+
{
|
|
2723
|
+
src: image.url,
|
|
2724
|
+
alt: alt || image.alt || "",
|
|
2725
|
+
className: "absolute inset-0 w-full h-full object-cover"
|
|
2726
|
+
}
|
|
2727
|
+
) });
|
|
2728
|
+
const content = link ? /* @__PURE__ */ jsx(
|
|
2729
|
+
"a",
|
|
2730
|
+
{
|
|
2731
|
+
href: link,
|
|
2732
|
+
target: openInNewTab ? "_blank" : void 0,
|
|
2733
|
+
rel: openInNewTab ? "noopener noreferrer" : void 0,
|
|
2734
|
+
className: "block transition-opacity hover:opacity-90",
|
|
2735
|
+
children: imageElement
|
|
2736
|
+
}
|
|
2737
|
+
) : imageElement;
|
|
2738
|
+
return /* @__PURE__ */ jsxs(AnimatedWrapper, { animation, children: [
|
|
2739
|
+
visibilityCSS && /* @__PURE__ */ jsx("style", { children: visibilityCSS }),
|
|
2740
|
+
/* @__PURE__ */ jsx("div", { className: cn2("py-4 px-4", wrapperClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsx("div", { className: alignmentClasses, children: content }) })
|
|
2741
|
+
] });
|
|
2742
|
+
}
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
var buttonVariants, Button;
|
|
2747
|
+
var init_button = __esm({
|
|
2748
|
+
"src/components/ui/button.tsx"() {
|
|
2749
|
+
init_utils();
|
|
2750
|
+
buttonVariants = cva(
|
|
2751
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
2752
|
+
{
|
|
2753
|
+
variants: {
|
|
2754
|
+
variant: {
|
|
2755
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2756
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
2757
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
2758
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
2759
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2760
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
2761
|
+
},
|
|
2762
|
+
size: {
|
|
2763
|
+
default: "h-10 px-4 py-2",
|
|
2764
|
+
sm: "h-8 px-3 text-xs",
|
|
2765
|
+
lg: "h-11 px-8",
|
|
2766
|
+
icon: "h-10 w-10 p-2",
|
|
2767
|
+
"icon-sm": "h-8 w-8 p-1.5"
|
|
2768
|
+
}
|
|
2769
|
+
},
|
|
2770
|
+
defaultVariants: {
|
|
2771
|
+
variant: "default",
|
|
2772
|
+
size: "default"
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
);
|
|
2776
|
+
Button = React.forwardRef(
|
|
2777
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
2778
|
+
const Comp = asChild ? Slot : "button";
|
|
2779
|
+
return /* @__PURE__ */ jsx(
|
|
2780
|
+
Comp,
|
|
2781
|
+
{
|
|
2782
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
2783
|
+
ref,
|
|
2784
|
+
...props
|
|
2785
|
+
}
|
|
2786
|
+
);
|
|
2787
|
+
}
|
|
2788
|
+
);
|
|
2789
|
+
Button.displayName = "Button";
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2792
|
+
var Input;
|
|
2793
|
+
var init_input = __esm({
|
|
2794
|
+
"src/components/ui/input.tsx"() {
|
|
2795
|
+
init_utils();
|
|
2796
|
+
Input = React.forwardRef(
|
|
2797
|
+
({ className, type, ...props }, ref) => {
|
|
2798
|
+
return /* @__PURE__ */ jsx(
|
|
2799
|
+
"input",
|
|
2800
|
+
{
|
|
2801
|
+
type,
|
|
2802
|
+
className: cn(
|
|
2803
|
+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
2804
|
+
className
|
|
2805
|
+
),
|
|
2806
|
+
ref,
|
|
2807
|
+
...props
|
|
2808
|
+
}
|
|
2809
|
+
);
|
|
2810
|
+
}
|
|
2811
|
+
);
|
|
2812
|
+
Input.displayName = "Input";
|
|
2813
|
+
}
|
|
2814
|
+
});
|
|
2815
|
+
var labelVariants, Label;
|
|
2816
|
+
var init_label = __esm({
|
|
2817
|
+
"src/components/ui/label.tsx"() {
|
|
2818
|
+
"use client";
|
|
2819
|
+
init_utils();
|
|
2820
|
+
labelVariants = cva(
|
|
2821
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
2822
|
+
);
|
|
2823
|
+
Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2824
|
+
LabelPrimitive.Root,
|
|
2825
|
+
{
|
|
2826
|
+
ref,
|
|
2827
|
+
className: cn(labelVariants(), className),
|
|
2828
|
+
...props
|
|
2829
|
+
}
|
|
2830
|
+
));
|
|
2831
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
2832
|
+
}
|
|
2833
|
+
});
|
|
2834
|
+
function SizeFieldInner({
|
|
2835
|
+
value,
|
|
2836
|
+
onChange,
|
|
2837
|
+
label = "Size",
|
|
2838
|
+
readOnly,
|
|
2839
|
+
showHeight = true,
|
|
2840
|
+
showFontSize = true
|
|
2841
|
+
}) {
|
|
2842
|
+
const currentValue = value || DEFAULT_VALUE;
|
|
2843
|
+
const handleModeChange = useCallback((mode) => {
|
|
2844
|
+
if (mode === "custom") {
|
|
2845
|
+
onChange({
|
|
2846
|
+
mode,
|
|
2847
|
+
...CUSTOM_DEFAULTS
|
|
2848
|
+
});
|
|
2849
|
+
} else {
|
|
2850
|
+
onChange({ mode });
|
|
2851
|
+
}
|
|
2852
|
+
}, [onChange]);
|
|
2853
|
+
const handleValueChange = useCallback((field, val) => {
|
|
2854
|
+
onChange({
|
|
2855
|
+
...currentValue,
|
|
2856
|
+
[field]: val
|
|
2857
|
+
});
|
|
2858
|
+
}, [currentValue, onChange]);
|
|
2859
|
+
const handleUnitChange = useCallback((unit) => {
|
|
2860
|
+
onChange({
|
|
2861
|
+
...currentValue,
|
|
2862
|
+
unit
|
|
2863
|
+
});
|
|
2864
|
+
}, [currentValue, onChange]);
|
|
2865
|
+
const handleClear = useCallback(() => {
|
|
2866
|
+
onChange(null);
|
|
2867
|
+
}, [onChange]);
|
|
2868
|
+
const presets = [
|
|
2869
|
+
{ mode: "sm", label: "SM" },
|
|
2870
|
+
{ mode: "default", label: "Default" },
|
|
2871
|
+
{ mode: "lg", label: "LG" },
|
|
2872
|
+
{ mode: "custom", label: "Custom" }
|
|
2873
|
+
];
|
|
2874
|
+
return /* @__PURE__ */ jsxs("div", { className: "puck-field space-y-3", children: [
|
|
2875
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2876
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-foreground", children: label }),
|
|
2877
|
+
value && !readOnly && /* @__PURE__ */ jsx(
|
|
2878
|
+
Button,
|
|
2879
|
+
{
|
|
2880
|
+
type: "button",
|
|
2881
|
+
variant: "ghost",
|
|
2882
|
+
size: "icon-sm",
|
|
2883
|
+
onClick: handleClear,
|
|
2884
|
+
className: "text-muted-foreground hover:text-destructive",
|
|
2885
|
+
title: "Reset to default",
|
|
2886
|
+
children: /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" })
|
|
2887
|
+
}
|
|
2888
|
+
)
|
|
2889
|
+
] }),
|
|
2890
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: presets.map(({ mode, label: modeLabel }) => {
|
|
2891
|
+
const isActive = currentValue.mode === mode;
|
|
2892
|
+
return /* @__PURE__ */ jsx(
|
|
2893
|
+
Button,
|
|
2894
|
+
{
|
|
2895
|
+
type: "button",
|
|
2896
|
+
variant: isActive ? "default" : "secondary",
|
|
2897
|
+
size: "sm",
|
|
2898
|
+
onClick: () => handleModeChange(mode),
|
|
2899
|
+
disabled: readOnly,
|
|
2900
|
+
className: cn(
|
|
2901
|
+
"text-xs",
|
|
2902
|
+
isActive && "bg-primary hover:bg-primary/90"
|
|
2903
|
+
),
|
|
2904
|
+
children: modeLabel
|
|
2905
|
+
},
|
|
2906
|
+
mode
|
|
2907
|
+
);
|
|
2908
|
+
}) }),
|
|
2909
|
+
currentValue.mode === "custom" && /* @__PURE__ */ jsxs("div", { className: "space-y-3 p-3 bg-muted/50 rounded-md", children: [
|
|
2910
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2911
|
+
/* @__PURE__ */ jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground flex-shrink-0", children: "Unit:" }),
|
|
2912
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-1", children: ["px", "rem"].map((unit) => {
|
|
2913
|
+
const isActive = (currentValue.unit || "px") === unit;
|
|
2914
|
+
return /* @__PURE__ */ jsx(
|
|
2915
|
+
Button,
|
|
2916
|
+
{
|
|
2917
|
+
type: "button",
|
|
2918
|
+
variant: isActive ? "default" : "outline",
|
|
2919
|
+
size: "sm",
|
|
2920
|
+
onClick: () => handleUnitChange(unit),
|
|
2921
|
+
disabled: readOnly,
|
|
2922
|
+
className: cn(
|
|
2923
|
+
"text-xs font-mono h-7 px-2",
|
|
2924
|
+
isActive && "bg-primary hover:bg-primary/90"
|
|
2925
|
+
),
|
|
2926
|
+
children: unit
|
|
2927
|
+
},
|
|
2928
|
+
unit
|
|
2929
|
+
);
|
|
2930
|
+
}) })
|
|
2931
|
+
] }),
|
|
2932
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
2933
|
+
showHeight && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
2934
|
+
/* @__PURE__ */ jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Height" }),
|
|
2935
|
+
/* @__PURE__ */ jsx(
|
|
2936
|
+
Input,
|
|
2937
|
+
{
|
|
2938
|
+
type: "number",
|
|
2939
|
+
min: 0,
|
|
2940
|
+
value: currentValue.height ?? CUSTOM_DEFAULTS.height,
|
|
2941
|
+
onChange: (e) => handleValueChange("height", parseInt(e.target.value, 10) || 0),
|
|
2942
|
+
disabled: readOnly,
|
|
2943
|
+
className: "h-8 text-sm font-mono"
|
|
2944
|
+
}
|
|
2945
|
+
)
|
|
2946
|
+
] }),
|
|
2947
|
+
showFontSize && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
2948
|
+
/* @__PURE__ */ jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Font Size" }),
|
|
2949
|
+
/* @__PURE__ */ jsx(
|
|
2950
|
+
Input,
|
|
2951
|
+
{
|
|
2952
|
+
type: "number",
|
|
2953
|
+
min: 0,
|
|
2954
|
+
value: currentValue.fontSize ?? CUSTOM_DEFAULTS.fontSize,
|
|
2955
|
+
onChange: (e) => handleValueChange("fontSize", parseInt(e.target.value, 10) || 0),
|
|
2956
|
+
disabled: readOnly,
|
|
2957
|
+
className: "h-8 text-sm font-mono"
|
|
2958
|
+
}
|
|
2959
|
+
)
|
|
2960
|
+
] }),
|
|
2961
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
2962
|
+
/* @__PURE__ */ jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Padding X" }),
|
|
2963
|
+
/* @__PURE__ */ jsx(
|
|
2964
|
+
Input,
|
|
2965
|
+
{
|
|
2966
|
+
type: "number",
|
|
2967
|
+
min: 0,
|
|
2968
|
+
value: currentValue.paddingX ?? CUSTOM_DEFAULTS.paddingX,
|
|
2969
|
+
onChange: (e) => handleValueChange("paddingX", parseInt(e.target.value, 10) || 0),
|
|
2970
|
+
disabled: readOnly,
|
|
2971
|
+
className: "h-8 text-sm font-mono"
|
|
2972
|
+
}
|
|
2973
|
+
)
|
|
2974
|
+
] }),
|
|
2975
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
2976
|
+
/* @__PURE__ */ jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Padding Y" }),
|
|
2977
|
+
/* @__PURE__ */ jsx(
|
|
2978
|
+
Input,
|
|
2979
|
+
{
|
|
2980
|
+
type: "number",
|
|
2981
|
+
min: 0,
|
|
2982
|
+
value: currentValue.paddingY ?? CUSTOM_DEFAULTS.paddingY,
|
|
2983
|
+
onChange: (e) => handleValueChange("paddingY", parseInt(e.target.value, 10) || 0),
|
|
2984
|
+
disabled: readOnly,
|
|
2985
|
+
className: "h-8 text-sm font-mono"
|
|
2986
|
+
}
|
|
2987
|
+
)
|
|
2988
|
+
] })
|
|
2989
|
+
] }),
|
|
2990
|
+
/* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground font-mono pt-1 border-t border-border/50", children: [
|
|
2991
|
+
showHeight && `h: ${currentValue.height ?? CUSTOM_DEFAULTS.height}${currentValue.unit || "px"}`,
|
|
2992
|
+
showHeight && " | ",
|
|
2993
|
+
`p: ${currentValue.paddingY ?? CUSTOM_DEFAULTS.paddingY}${currentValue.unit || "px"} ${currentValue.paddingX ?? CUSTOM_DEFAULTS.paddingX}${currentValue.unit || "px"}`,
|
|
2994
|
+
showFontSize && ` | font: ${currentValue.fontSize ?? CUSTOM_DEFAULTS.fontSize}${currentValue.unit || "px"}`
|
|
2995
|
+
] })
|
|
2996
|
+
] })
|
|
2997
|
+
] });
|
|
2998
|
+
}
|
|
2999
|
+
function sizeValueToCSS(size) {
|
|
3000
|
+
if (!size || size.mode !== "custom") return void 0;
|
|
3001
|
+
const unit = size.unit || "px";
|
|
3002
|
+
const style = {};
|
|
3003
|
+
if (size.height != null) {
|
|
3004
|
+
style.height = `${size.height}${unit}`;
|
|
3005
|
+
}
|
|
3006
|
+
if (size.paddingX != null || size.paddingY != null) {
|
|
3007
|
+
const py = size.paddingY ?? 0;
|
|
3008
|
+
const px = size.paddingX ?? 0;
|
|
3009
|
+
style.padding = `${py}${unit} ${px}${unit}`;
|
|
3010
|
+
}
|
|
3011
|
+
if (size.fontSize != null) {
|
|
3012
|
+
style.fontSize = `${size.fontSize}${unit}`;
|
|
3013
|
+
}
|
|
3014
|
+
return Object.keys(style).length > 0 ? style : void 0;
|
|
3015
|
+
}
|
|
3016
|
+
function getSizeClasses(size, sizeMap) {
|
|
3017
|
+
if (!size) return sizeMap.default || "";
|
|
3018
|
+
if (size.mode === "custom") return "";
|
|
3019
|
+
return sizeMap[size.mode] || sizeMap.default || "";
|
|
3020
|
+
}
|
|
3021
|
+
var DEFAULT_VALUE, CUSTOM_DEFAULTS;
|
|
3022
|
+
var init_SizeField = __esm({
|
|
3023
|
+
"src/fields/SizeField.tsx"() {
|
|
3024
|
+
"use client";
|
|
3025
|
+
init_button();
|
|
3026
|
+
init_input();
|
|
3027
|
+
init_label();
|
|
3028
|
+
init_utils();
|
|
3029
|
+
DEFAULT_VALUE = {
|
|
3030
|
+
mode: "default"
|
|
3031
|
+
};
|
|
3032
|
+
CUSTOM_DEFAULTS = {
|
|
3033
|
+
height: 40,
|
|
3034
|
+
paddingX: 16,
|
|
3035
|
+
paddingY: 8,
|
|
3036
|
+
fontSize: 14,
|
|
3037
|
+
unit: "px"
|
|
3038
|
+
};
|
|
3039
|
+
memo(SizeFieldInner);
|
|
3040
|
+
}
|
|
3041
|
+
});
|
|
3042
|
+
|
|
3043
|
+
// src/theme/defaults.ts
|
|
3044
|
+
var DEFAULT_BUTTON_VARIANTS, DEFAULT_CTA_BUTTON_VARIANTS, DEFAULT_CTA_BACKGROUND_STYLES, DEFAULT_COLOR_PRESETS, DEFAULT_FOCUS_RING, DEFAULT_THEME;
|
|
3045
|
+
var init_defaults2 = __esm({
|
|
3046
|
+
"src/theme/defaults.ts"() {
|
|
3047
|
+
DEFAULT_BUTTON_VARIANTS = {
|
|
3048
|
+
default: { classes: "bg-primary text-primary-foreground hover:bg-primary/90" },
|
|
3049
|
+
secondary: { classes: "bg-secondary text-secondary-foreground hover:bg-secondary/80" },
|
|
3050
|
+
outline: { classes: "border border-input bg-background hover:bg-accent hover:text-accent-foreground" },
|
|
3051
|
+
ghost: { classes: "bg-transparent hover:bg-accent hover:text-accent-foreground" },
|
|
3052
|
+
destructive: { classes: "bg-destructive text-destructive-foreground hover:bg-destructive/90" },
|
|
3053
|
+
link: { classes: "text-primary underline-offset-4 hover:underline bg-transparent" }
|
|
3054
|
+
};
|
|
3055
|
+
DEFAULT_CTA_BUTTON_VARIANTS = {
|
|
3056
|
+
primary: { classes: "bg-primary text-primary-foreground hover:bg-primary/90" },
|
|
3057
|
+
secondary: { classes: "bg-secondary text-secondary-foreground hover:bg-secondary/80" },
|
|
3058
|
+
outline: { classes: "border border-input bg-background hover:bg-accent hover:text-accent-foreground" },
|
|
3059
|
+
ghost: { classes: "bg-transparent hover:bg-accent hover:text-accent-foreground" },
|
|
3060
|
+
link: { classes: "text-primary underline-offset-4 hover:underline bg-transparent" }
|
|
3061
|
+
};
|
|
3062
|
+
DEFAULT_CTA_BACKGROUND_STYLES = {
|
|
3063
|
+
default: "bg-muted",
|
|
3064
|
+
dark: "bg-foreground text-background",
|
|
3065
|
+
light: "bg-background"
|
|
3066
|
+
};
|
|
3067
|
+
DEFAULT_COLOR_PRESETS = [
|
|
3068
|
+
{ hex: "#ffffff", label: "White" },
|
|
3069
|
+
{ hex: "#f9fafb", label: "Gray 50" },
|
|
3070
|
+
{ hex: "#f3f4f6", label: "Gray 100" },
|
|
3071
|
+
{ hex: "#1f2937", label: "Gray 800" },
|
|
3072
|
+
{ hex: "#111827", label: "Gray 900" },
|
|
3073
|
+
{ hex: "#000000", label: "Black" },
|
|
3074
|
+
{ hex: "#3b82f6", label: "Blue" },
|
|
3075
|
+
{ hex: "#10b981", label: "Green" },
|
|
3076
|
+
{ hex: "#f59e0b", label: "Amber" },
|
|
3077
|
+
{ hex: "#ef4444", label: "Red" }
|
|
3078
|
+
];
|
|
3079
|
+
DEFAULT_FOCUS_RING = "focus:ring-ring";
|
|
3080
|
+
DEFAULT_THEME = {
|
|
3081
|
+
buttonVariants: DEFAULT_BUTTON_VARIANTS,
|
|
3082
|
+
ctaButtonVariants: DEFAULT_CTA_BUTTON_VARIANTS,
|
|
3083
|
+
ctaBackgroundStyles: DEFAULT_CTA_BACKGROUND_STYLES,
|
|
3084
|
+
colorPresets: DEFAULT_COLOR_PRESETS,
|
|
3085
|
+
focusRingColor: DEFAULT_FOCUS_RING
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
3088
|
+
});
|
|
3089
|
+
|
|
3090
|
+
// src/theme/utils.ts
|
|
3091
|
+
function resolveTheme(config) {
|
|
3092
|
+
if (!config) return DEFAULT_THEME;
|
|
3093
|
+
return {
|
|
3094
|
+
buttonVariants: mergeVariants(DEFAULT_BUTTON_VARIANTS, config.buttonVariants),
|
|
3095
|
+
ctaButtonVariants: mergeVariants(DEFAULT_CTA_BUTTON_VARIANTS, config.ctaButtonVariants),
|
|
3096
|
+
ctaBackgroundStyles: mergeBackgroundStyles(
|
|
3097
|
+
DEFAULT_CTA_BACKGROUND_STYLES,
|
|
3098
|
+
config.ctaBackgroundStyles
|
|
3099
|
+
),
|
|
3100
|
+
colorPresets: resolveColorPresets(config),
|
|
3101
|
+
focusRingColor: config.focusRingColor ?? DEFAULT_FOCUS_RING
|
|
3102
|
+
};
|
|
3103
|
+
}
|
|
3104
|
+
function mergeVariants(defaults, overrides) {
|
|
3105
|
+
if (!overrides) return defaults;
|
|
3106
|
+
const result = { ...defaults };
|
|
3107
|
+
for (const key of Object.keys(overrides)) {
|
|
3108
|
+
const override = overrides[key];
|
|
3109
|
+
if (override) {
|
|
3110
|
+
result[key] = override;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
return result;
|
|
3114
|
+
}
|
|
3115
|
+
function mergeBackgroundStyles(defaults, overrides) {
|
|
3116
|
+
if (!overrides) return defaults;
|
|
3117
|
+
return { ...defaults, ...overrides };
|
|
3118
|
+
}
|
|
3119
|
+
function resolveColorPresets(config) {
|
|
3120
|
+
if (!config.colorPresets) {
|
|
3121
|
+
return DEFAULT_COLOR_PRESETS;
|
|
3122
|
+
}
|
|
3123
|
+
if (config.extendColorPresets) {
|
|
3124
|
+
return [...DEFAULT_COLOR_PRESETS, ...config.colorPresets];
|
|
3125
|
+
}
|
|
3126
|
+
return config.colorPresets;
|
|
3127
|
+
}
|
|
3128
|
+
function getVariantClasses(variants, variant, fallback = "default") {
|
|
3129
|
+
const config = variants[variant];
|
|
3130
|
+
if (config?.classes) {
|
|
3131
|
+
return config.classes;
|
|
3132
|
+
}
|
|
3133
|
+
const fallbackConfig = variants[fallback];
|
|
3134
|
+
return fallbackConfig?.classes ?? "";
|
|
3135
|
+
}
|
|
3136
|
+
var init_utils3 = __esm({
|
|
3137
|
+
"src/theme/utils.ts"() {
|
|
3138
|
+
init_defaults2();
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
var sizeStyles, alignmentWrapperMap, defaultProps11, ButtonConfig;
|
|
3142
|
+
var init_Button_server = __esm({
|
|
3143
|
+
"src/components/interactive/Button.server.tsx"() {
|
|
3144
|
+
init_shared();
|
|
3145
|
+
init_AnimatedWrapper();
|
|
3146
|
+
init_SizeField();
|
|
3147
|
+
init_defaults2();
|
|
3148
|
+
init_utils3();
|
|
3149
|
+
sizeStyles = {
|
|
3150
|
+
sm: "h-8 px-3 text-sm",
|
|
3151
|
+
default: "h-10 px-4",
|
|
3152
|
+
lg: "h-12 px-8 text-lg"
|
|
3153
|
+
};
|
|
3154
|
+
alignmentWrapperMap = {
|
|
3155
|
+
left: "text-left",
|
|
3156
|
+
center: "text-center",
|
|
3157
|
+
right: "text-right"
|
|
3158
|
+
};
|
|
3159
|
+
defaultProps11 = {
|
|
3160
|
+
text: "Click Me",
|
|
3161
|
+
link: "",
|
|
3162
|
+
variant: "default",
|
|
3163
|
+
size: null,
|
|
3164
|
+
openInNewTab: "no",
|
|
3165
|
+
margin: null,
|
|
3166
|
+
customBackgroundColor: null,
|
|
3167
|
+
customTextColor: null,
|
|
3168
|
+
customBorder: null,
|
|
3169
|
+
alignment: null,
|
|
3170
|
+
transform: null,
|
|
3171
|
+
animation: null,
|
|
3172
|
+
customPadding: null
|
|
3173
|
+
};
|
|
3174
|
+
ButtonConfig = {
|
|
3175
|
+
label: "Button",
|
|
3176
|
+
defaultProps: defaultProps11,
|
|
3177
|
+
render: ({ text, link, variant, size, openInNewTab, alignment, margin, customBackgroundColor, customTextColor, customBorder, transform, animation, customPadding }) => {
|
|
3178
|
+
const hasCustomBackground = customBackgroundColor?.hex;
|
|
3179
|
+
const hasCustomTextColor = customTextColor?.hex;
|
|
3180
|
+
const hasCustomPadding = customPadding;
|
|
3181
|
+
const hasCustomSize = size?.mode === "custom";
|
|
3182
|
+
const variantClasses = getVariantClasses(DEFAULT_BUTTON_VARIANTS, variant, "default");
|
|
3183
|
+
const sizeClasses = getSizeClasses(size, sizeStyles);
|
|
3184
|
+
const buttonClasses = cn2(
|
|
3185
|
+
"inline-flex items-center justify-center font-medium transition-colors",
|
|
3186
|
+
`focus:outline-none focus:ring-2 focus:ring-offset-2 ${DEFAULT_FOCUS_RING}`,
|
|
3187
|
+
"disabled:opacity-50 disabled:pointer-events-none",
|
|
3188
|
+
// Only apply variant styles if no custom background/text color
|
|
3189
|
+
!hasCustomBackground && !hasCustomTextColor && variantClasses,
|
|
3190
|
+
// Only apply background portion of variant if no custom background
|
|
3191
|
+
hasCustomBackground && !hasCustomTextColor && "hover:opacity-90",
|
|
3192
|
+
// Only apply size classes if not using custom size or custom padding
|
|
3193
|
+
!hasCustomPadding && !hasCustomSize && sizeClasses,
|
|
3194
|
+
// Apply rounded-md unless custom border has radius
|
|
3195
|
+
!customBorder?.radius && "rounded-md"
|
|
3196
|
+
);
|
|
3197
|
+
const buttonStyle = {};
|
|
3198
|
+
if (hasCustomBackground) {
|
|
3199
|
+
buttonStyle.backgroundColor = colorValueToCSS(customBackgroundColor);
|
|
3200
|
+
}
|
|
3201
|
+
if (hasCustomTextColor) {
|
|
3202
|
+
buttonStyle.color = colorValueToCSS(customTextColor);
|
|
3203
|
+
}
|
|
3204
|
+
const borderStyles = borderValueToCSS(customBorder);
|
|
3205
|
+
if (borderStyles) {
|
|
3206
|
+
Object.assign(buttonStyle, borderStyles);
|
|
3207
|
+
}
|
|
3208
|
+
const customSizeStyles = sizeValueToCSS(size);
|
|
3209
|
+
if (customSizeStyles) {
|
|
3210
|
+
Object.assign(buttonStyle, customSizeStyles);
|
|
3211
|
+
}
|
|
3212
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
3213
|
+
if (paddingCSS) {
|
|
3214
|
+
buttonStyle.padding = paddingCSS;
|
|
3215
|
+
}
|
|
3216
|
+
const transformStyles = transformValueToCSS(transform);
|
|
3217
|
+
if (transformStyles) {
|
|
3218
|
+
Object.assign(buttonStyle, transformStyles);
|
|
3219
|
+
}
|
|
3220
|
+
const buttonElement = link ? /* @__PURE__ */ jsx(
|
|
3221
|
+
"a",
|
|
3222
|
+
{
|
|
3223
|
+
href: link,
|
|
3224
|
+
target: openInNewTab === "yes" ? "_blank" : void 0,
|
|
3225
|
+
rel: openInNewTab === "yes" ? "noopener noreferrer" : void 0,
|
|
3226
|
+
className: buttonClasses,
|
|
3227
|
+
style: buttonStyle,
|
|
3228
|
+
children: text
|
|
3229
|
+
}
|
|
3230
|
+
) : /* @__PURE__ */ jsx("button", { type: "button", className: buttonClasses, style: buttonStyle, children: text });
|
|
3231
|
+
const wrapperStyle = {};
|
|
3232
|
+
const marginCSS = marginValueToCSS(margin);
|
|
3233
|
+
if (marginCSS) {
|
|
3234
|
+
wrapperStyle.margin = marginCSS;
|
|
3235
|
+
}
|
|
3236
|
+
const alignmentValue = alignment ?? "left";
|
|
3237
|
+
return /* @__PURE__ */ jsx(
|
|
3238
|
+
AnimatedWrapper,
|
|
3239
|
+
{
|
|
3240
|
+
animation,
|
|
3241
|
+
className: alignmentWrapperMap[alignmentValue] || alignmentWrapperMap.left,
|
|
3242
|
+
style: wrapperStyle,
|
|
3243
|
+
children: buttonElement
|
|
3244
|
+
}
|
|
3245
|
+
);
|
|
3246
|
+
}
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
});
|
|
3250
|
+
var defaultProps12, CardConfig;
|
|
3251
|
+
var init_Card_server = __esm({
|
|
3252
|
+
"src/components/interactive/Card.server.tsx"() {
|
|
3253
|
+
init_shared();
|
|
3254
|
+
init_AnimatedWrapper();
|
|
3255
|
+
defaultProps12 = {
|
|
3256
|
+
image: null,
|
|
3257
|
+
heading: "Card Heading",
|
|
3258
|
+
text: "Card description text goes here.",
|
|
3259
|
+
link: "",
|
|
3260
|
+
openInNewTab: false,
|
|
3261
|
+
shadow: "md",
|
|
3262
|
+
margin: null,
|
|
3263
|
+
background: null,
|
|
3264
|
+
border: null,
|
|
3265
|
+
dimensions: null,
|
|
3266
|
+
alignment: null,
|
|
3267
|
+
transform: null,
|
|
3268
|
+
animation: null,
|
|
3269
|
+
customPadding: null
|
|
3270
|
+
};
|
|
3271
|
+
CardConfig = {
|
|
3272
|
+
label: "Card",
|
|
3273
|
+
defaultProps: defaultProps12,
|
|
3274
|
+
render: ({ image, heading, text, link, openInNewTab, shadow, background, dimensions, alignment, margin, border, transform, animation, customPadding }) => {
|
|
3275
|
+
const hasBorderRadius = border?.radius && border.radius > 0;
|
|
3276
|
+
const cardClasses = cn2(
|
|
3277
|
+
"overflow-hidden transition-all bg-card",
|
|
3278
|
+
!hasBorderRadius && "rounded-lg",
|
|
3279
|
+
shadowMap[shadow] || "",
|
|
3280
|
+
link && "hover:shadow-lg cursor-pointer"
|
|
3281
|
+
);
|
|
3282
|
+
const wrapperStyle = {};
|
|
3283
|
+
const marginCSS = marginValueToCSS(margin);
|
|
3284
|
+
if (marginCSS) {
|
|
3285
|
+
wrapperStyle.margin = marginCSS;
|
|
3286
|
+
}
|
|
3287
|
+
const dimensionsStyles = dimensionsValueToCSS(dimensions);
|
|
3288
|
+
if (dimensionsStyles) {
|
|
3289
|
+
Object.assign(wrapperStyle, dimensionsStyles);
|
|
3290
|
+
}
|
|
3291
|
+
const transformStyles = transformValueToCSS(transform);
|
|
3292
|
+
if (transformStyles) {
|
|
3293
|
+
Object.assign(wrapperStyle, transformStyles);
|
|
3294
|
+
}
|
|
3295
|
+
const alignmentValue = alignment ?? "left";
|
|
3296
|
+
const alignmentClasses = cn2(
|
|
3297
|
+
"flex",
|
|
3298
|
+
alignmentValue === "left" && "justify-start",
|
|
3299
|
+
alignmentValue === "center" && "justify-center",
|
|
3300
|
+
alignmentValue === "right" && "justify-end"
|
|
3301
|
+
);
|
|
3302
|
+
const backgroundStyles = backgroundValueToCSS(background);
|
|
3303
|
+
const cardStyle = {
|
|
3304
|
+
...backgroundStyles
|
|
3305
|
+
};
|
|
3306
|
+
const borderStyles = borderValueToCSS(border);
|
|
3307
|
+
if (borderStyles) {
|
|
3308
|
+
Object.assign(cardStyle, borderStyles);
|
|
3309
|
+
}
|
|
3310
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
3311
|
+
if (paddingCSS) {
|
|
3312
|
+
cardStyle.padding = paddingCSS;
|
|
3313
|
+
}
|
|
3314
|
+
const cardContent = /* @__PURE__ */ jsxs("div", { className: cardClasses, style: cardStyle, children: [
|
|
3315
|
+
image?.url ? /* @__PURE__ */ jsx("div", { className: "relative aspect-video w-full overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
3316
|
+
"img",
|
|
3317
|
+
{
|
|
3318
|
+
src: image.url,
|
|
3319
|
+
alt: image.alt || heading || "",
|
|
3320
|
+
className: "w-full h-full object-cover"
|
|
3321
|
+
}
|
|
3322
|
+
) }) : /* @__PURE__ */ jsx("div", { className: "aspect-video w-full bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "No image" }) }),
|
|
3323
|
+
/* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
3324
|
+
heading && /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: heading }),
|
|
3325
|
+
text && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: text })
|
|
3326
|
+
] })
|
|
3327
|
+
] });
|
|
3328
|
+
if (link) {
|
|
3329
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("div", { className: alignmentClasses, children: /* @__PURE__ */ jsx(
|
|
3330
|
+
"a",
|
|
3331
|
+
{
|
|
3332
|
+
href: link,
|
|
3333
|
+
target: openInNewTab ? "_blank" : void 0,
|
|
3334
|
+
rel: openInNewTab ? "noopener noreferrer" : void 0,
|
|
3335
|
+
className: "block",
|
|
3336
|
+
style: wrapperStyle,
|
|
3337
|
+
children: cardContent
|
|
3338
|
+
}
|
|
3339
|
+
) }) });
|
|
3340
|
+
}
|
|
3341
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("div", { className: alignmentClasses, children: /* @__PURE__ */ jsx("div", { style: wrapperStyle, children: cardContent }) }) });
|
|
3342
|
+
}
|
|
3343
|
+
};
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
var defaultProps13, DividerConfig;
|
|
3347
|
+
var init_Divider_server = __esm({
|
|
3348
|
+
"src/components/interactive/Divider.server.tsx"() {
|
|
3349
|
+
init_shared();
|
|
3350
|
+
init_AnimatedWrapper();
|
|
3351
|
+
defaultProps13 = {
|
|
3352
|
+
style: "solid",
|
|
3353
|
+
color: null,
|
|
3354
|
+
margin: null,
|
|
3355
|
+
dimensions: null,
|
|
3356
|
+
transform: null,
|
|
3357
|
+
animation: null,
|
|
3358
|
+
customPadding: null
|
|
3359
|
+
};
|
|
3360
|
+
DividerConfig = {
|
|
3361
|
+
label: "Divider",
|
|
3362
|
+
defaultProps: defaultProps13,
|
|
3363
|
+
render: ({ style, color, dimensions, margin, transform, animation, customPadding }) => {
|
|
3364
|
+
const dimensionsStyles = dimensionsValueToCSS(dimensions);
|
|
3365
|
+
const wrapperStyle = {
|
|
3366
|
+
...dimensionsStyles
|
|
3367
|
+
};
|
|
3368
|
+
const marginCSS = marginValueToCSS(margin);
|
|
3369
|
+
if (marginCSS) {
|
|
3370
|
+
wrapperStyle.margin = marginCSS;
|
|
3371
|
+
}
|
|
3372
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
3373
|
+
if (paddingCSS) {
|
|
3374
|
+
wrapperStyle.padding = paddingCSS;
|
|
3375
|
+
}
|
|
3376
|
+
const transformStyles = transformValueToCSS(transform);
|
|
3377
|
+
if (transformStyles) {
|
|
3378
|
+
Object.assign(wrapperStyle, transformStyles);
|
|
3379
|
+
}
|
|
3380
|
+
const customColor = colorValueToCSS(color);
|
|
3381
|
+
const hrStyle = customColor ? { borderColor: customColor } : void 0;
|
|
3382
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("div", { className: "px-4", style: Object.keys(wrapperStyle).length > 0 ? wrapperStyle : void 0, children: /* @__PURE__ */ jsx(
|
|
3383
|
+
"hr",
|
|
3384
|
+
{
|
|
3385
|
+
className: cn2(
|
|
3386
|
+
"border-t border-border",
|
|
3387
|
+
dividerStyleMap[style] || dividerStyleMap.solid
|
|
3388
|
+
),
|
|
3389
|
+
style: hrStyle
|
|
3390
|
+
}
|
|
3391
|
+
) }) });
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
}
|
|
3395
|
+
});
|
|
3396
|
+
function AccordionItem({
|
|
3397
|
+
item,
|
|
3398
|
+
isOpen,
|
|
3399
|
+
onToggle,
|
|
3400
|
+
textColorCSS
|
|
3401
|
+
}) {
|
|
3402
|
+
const textStyle = textColorCSS ? { color: textColorCSS } : {};
|
|
3403
|
+
return /* @__PURE__ */ jsxs("div", { className: "border-b border-border last:border-b-0", children: [
|
|
3404
|
+
/* @__PURE__ */ jsxs(
|
|
3405
|
+
"button",
|
|
3406
|
+
{
|
|
3407
|
+
type: "button",
|
|
3408
|
+
onClick: onToggle,
|
|
3409
|
+
className: "flex w-full items-center justify-between py-4 px-4 text-left font-medium transition-all hover:bg-muted/50 text-foreground",
|
|
3410
|
+
style: textStyle,
|
|
3411
|
+
children: [
|
|
3412
|
+
/* @__PURE__ */ jsx("span", { children: item.title }),
|
|
3413
|
+
/* @__PURE__ */ jsx(
|
|
3414
|
+
IconChevronDown,
|
|
3415
|
+
{
|
|
3416
|
+
className: cn2(
|
|
3417
|
+
"h-4 w-4 shrink-0 transition-transform duration-200",
|
|
3418
|
+
isOpen && "rotate-180"
|
|
3419
|
+
)
|
|
3420
|
+
}
|
|
3421
|
+
)
|
|
3422
|
+
]
|
|
3423
|
+
}
|
|
3424
|
+
),
|
|
3425
|
+
/* @__PURE__ */ jsx(
|
|
3426
|
+
"div",
|
|
3427
|
+
{
|
|
3428
|
+
className: cn2(
|
|
3429
|
+
"overflow-hidden transition-all duration-200",
|
|
3430
|
+
isOpen ? "max-h-[1000px] opacity-100" : "max-h-0 opacity-0"
|
|
3431
|
+
),
|
|
3432
|
+
children: /* @__PURE__ */ jsx(
|
|
3433
|
+
"div",
|
|
3434
|
+
{
|
|
3435
|
+
className: "px-4 pb-4 text-muted-foreground",
|
|
3436
|
+
style: textColorCSS ? { color: textColorCSS } : void 0,
|
|
3437
|
+
children: item.content
|
|
3438
|
+
}
|
|
3439
|
+
)
|
|
3440
|
+
}
|
|
3441
|
+
)
|
|
3442
|
+
] });
|
|
3443
|
+
}
|
|
3444
|
+
function AccordionClient({
|
|
3445
|
+
items,
|
|
3446
|
+
allowMultiple,
|
|
3447
|
+
textColor,
|
|
3448
|
+
margin,
|
|
3449
|
+
background,
|
|
3450
|
+
dimensions,
|
|
3451
|
+
transform,
|
|
3452
|
+
animation,
|
|
3453
|
+
customPadding
|
|
3454
|
+
}) {
|
|
3455
|
+
const [openItems, setOpenItems] = useState(() => {
|
|
3456
|
+
const initialOpen = /* @__PURE__ */ new Set();
|
|
3457
|
+
items?.forEach((item, index) => {
|
|
3458
|
+
if (item.defaultOpen) {
|
|
3459
|
+
initialOpen.add(index);
|
|
3460
|
+
}
|
|
3461
|
+
});
|
|
3462
|
+
return initialOpen;
|
|
3463
|
+
});
|
|
3464
|
+
const handleToggle = (index) => {
|
|
3465
|
+
setOpenItems((prev) => {
|
|
3466
|
+
const newSet = new Set(prev);
|
|
3467
|
+
if (newSet.has(index)) {
|
|
3468
|
+
newSet.delete(index);
|
|
3469
|
+
} else {
|
|
3470
|
+
if (!allowMultiple) {
|
|
3471
|
+
newSet.clear();
|
|
3472
|
+
}
|
|
3473
|
+
newSet.add(index);
|
|
3474
|
+
}
|
|
3475
|
+
return newSet;
|
|
3476
|
+
});
|
|
3477
|
+
};
|
|
3478
|
+
const textColorCSS = colorValueToCSS(textColor);
|
|
3479
|
+
const dimensionsStyles = dimensionsValueToCSS(dimensions);
|
|
3480
|
+
const accordionClasses = "rounded-lg border border-border overflow-hidden bg-card";
|
|
3481
|
+
const backgroundStyles = backgroundValueToCSS(background);
|
|
3482
|
+
const accordionStyle = backgroundStyles && Object.keys(backgroundStyles).length > 0 ? backgroundStyles : {};
|
|
3483
|
+
const style = {
|
|
3484
|
+
...dimensionsStyles
|
|
3485
|
+
};
|
|
3486
|
+
const marginCSS = marginValueToCSS(margin);
|
|
3487
|
+
if (marginCSS) {
|
|
3488
|
+
style.margin = marginCSS;
|
|
3489
|
+
}
|
|
3490
|
+
const paddingCSS = paddingValueToCSS(customPadding);
|
|
3491
|
+
if (paddingCSS) {
|
|
3492
|
+
style.padding = paddingCSS;
|
|
3493
|
+
}
|
|
3494
|
+
const transformStyles = transformValueToCSS(transform);
|
|
3495
|
+
if (transformStyles) {
|
|
3496
|
+
Object.assign(style, transformStyles);
|
|
3497
|
+
}
|
|
3498
|
+
if (!items || items.length === 0) {
|
|
3499
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("div", { className: "px-4", style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsx("div", { className: accordionClasses, style: accordionStyle, children: /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-muted-foreground", children: "No accordion items. Add items in the editor." }) }) }) });
|
|
3500
|
+
}
|
|
3501
|
+
return /* @__PURE__ */ jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsx("div", { className: "px-4", style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsx("div", { className: accordionClasses, style: accordionStyle, children: items.map((item, index) => /* @__PURE__ */ jsx(
|
|
3502
|
+
AccordionItem,
|
|
3503
|
+
{
|
|
3504
|
+
item,
|
|
3505
|
+
isOpen: openItems.has(index),
|
|
3506
|
+
onToggle: () => handleToggle(index),
|
|
3507
|
+
textColorCSS
|
|
3508
|
+
},
|
|
3509
|
+
index
|
|
3510
|
+
)) }) }) });
|
|
3511
|
+
}
|
|
3512
|
+
var init_AccordionClient = __esm({
|
|
3513
|
+
"src/components/AccordionClient.tsx"() {
|
|
3514
|
+
"use client";
|
|
3515
|
+
init_shared();
|
|
3516
|
+
init_AnimatedWrapper();
|
|
3517
|
+
}
|
|
3518
|
+
});
|
|
3519
|
+
var defaultProps14, AccordionConfig;
|
|
3520
|
+
var init_Accordion_server = __esm({
|
|
3521
|
+
"src/components/interactive/Accordion.server.tsx"() {
|
|
3522
|
+
init_AccordionClient();
|
|
3523
|
+
defaultProps14 = {
|
|
3524
|
+
items: [
|
|
3525
|
+
{
|
|
3526
|
+
title: "What is this?",
|
|
3527
|
+
content: "This is an accordion component that can expand and collapse.",
|
|
3528
|
+
defaultOpen: false
|
|
3529
|
+
},
|
|
3530
|
+
{
|
|
3531
|
+
title: "How do I use it?",
|
|
3532
|
+
content: "Click on each item to expand or collapse it.",
|
|
3533
|
+
defaultOpen: false
|
|
3534
|
+
}
|
|
3535
|
+
],
|
|
3536
|
+
allowMultiple: false,
|
|
3537
|
+
textColor: null,
|
|
3538
|
+
margin: null,
|
|
3539
|
+
background: null,
|
|
3540
|
+
dimensions: null,
|
|
3541
|
+
transform: null,
|
|
3542
|
+
animation: null,
|
|
3543
|
+
customPadding: null
|
|
3544
|
+
};
|
|
3545
|
+
AccordionConfig = {
|
|
3546
|
+
label: "Accordion",
|
|
3547
|
+
defaultProps: defaultProps14,
|
|
3548
|
+
render: (props) => /* @__PURE__ */ jsx(
|
|
3549
|
+
AccordionClient,
|
|
3550
|
+
{
|
|
3551
|
+
items: props.items,
|
|
3552
|
+
allowMultiple: props.allowMultiple,
|
|
3553
|
+
textColor: props.textColor,
|
|
3554
|
+
margin: props.margin,
|
|
3555
|
+
background: props.background,
|
|
3556
|
+
dimensions: props.dimensions,
|
|
3557
|
+
transform: props.transform,
|
|
3558
|
+
animation: props.animation,
|
|
3559
|
+
customPadding: props.customPadding
|
|
3560
|
+
}
|
|
3561
|
+
)
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3564
|
+
});
|
|
3565
|
+
|
|
3566
|
+
// src/config/merge.ts
|
|
3567
|
+
var init_merge = __esm({
|
|
3568
|
+
"src/config/merge.ts"() {
|
|
3569
|
+
}
|
|
3570
|
+
});
|
|
3571
|
+
function createConfig(layouts = DEFAULT_LAYOUTS) {
|
|
3572
|
+
const layoutOptions = layoutsToOptions(layouts);
|
|
3573
|
+
return {
|
|
3574
|
+
root: {
|
|
3575
|
+
fields: {
|
|
3576
|
+
title: {
|
|
3577
|
+
type: "text",
|
|
3578
|
+
label: "Page Title"
|
|
3579
|
+
},
|
|
3580
|
+
pageLayout: {
|
|
3581
|
+
type: "select",
|
|
3582
|
+
label: "Page Layout",
|
|
3583
|
+
options: layoutOptions.map(({ value, label }) => ({ value, label }))
|
|
3584
|
+
}
|
|
3585
|
+
},
|
|
3586
|
+
defaultProps: {
|
|
3587
|
+
title: "New Page",
|
|
3588
|
+
pageLayout: "default"
|
|
3589
|
+
},
|
|
3590
|
+
render: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children })
|
|
3591
|
+
},
|
|
3592
|
+
categories: {
|
|
3593
|
+
layout: {
|
|
3594
|
+
title: "Layout",
|
|
3595
|
+
components: ["Container", "Flex", "Grid", "Section", "Spacer", "Template"],
|
|
3596
|
+
defaultExpanded: true
|
|
3597
|
+
},
|
|
3598
|
+
typography: {
|
|
3599
|
+
title: "Typography",
|
|
3600
|
+
components: ["Heading", "Text", "RichText"]
|
|
3601
|
+
},
|
|
3602
|
+
media: {
|
|
3603
|
+
title: "Media",
|
|
3604
|
+
components: ["Image"]
|
|
3605
|
+
},
|
|
3606
|
+
interactive: {
|
|
3607
|
+
title: "Interactive",
|
|
3608
|
+
components: ["Button", "Card", "Divider", "Accordion"]
|
|
3609
|
+
}
|
|
3610
|
+
},
|
|
3611
|
+
components: {
|
|
3612
|
+
// Layout
|
|
3613
|
+
Container: ContainerConfig,
|
|
3614
|
+
Flex: FlexConfig,
|
|
3615
|
+
Grid: GridConfig,
|
|
3616
|
+
Section: SectionConfig,
|
|
3617
|
+
Spacer: SpacerConfig,
|
|
3618
|
+
Template: TemplateServerConfig,
|
|
3619
|
+
// Typography
|
|
3620
|
+
Heading: HeadingConfig,
|
|
3621
|
+
Text: TextConfig,
|
|
3622
|
+
RichText: RichTextConfig,
|
|
3623
|
+
// Media
|
|
3624
|
+
Image: ImageConfig,
|
|
3625
|
+
// Interactive
|
|
3626
|
+
Button: ButtonConfig,
|
|
3627
|
+
Card: CardConfig,
|
|
3628
|
+
Divider: DividerConfig,
|
|
3629
|
+
Accordion: AccordionConfig
|
|
3630
|
+
}
|
|
3631
|
+
};
|
|
3632
|
+
}
|
|
3633
|
+
var baseConfig;
|
|
3634
|
+
var init_config = __esm({
|
|
3635
|
+
"src/config/index.tsx"() {
|
|
3636
|
+
init_layouts();
|
|
3637
|
+
init_Container_server();
|
|
3638
|
+
init_Flex_server();
|
|
3639
|
+
init_Grid_server();
|
|
3640
|
+
init_Section_server();
|
|
3641
|
+
init_Spacer_server();
|
|
3642
|
+
init_Template_server();
|
|
3643
|
+
init_Heading_server();
|
|
3644
|
+
init_Text_server();
|
|
3645
|
+
init_RichText_server();
|
|
3646
|
+
init_Image_server();
|
|
3647
|
+
init_Button_server();
|
|
3648
|
+
init_Card_server();
|
|
3649
|
+
init_Divider_server();
|
|
3650
|
+
init_Accordion_server();
|
|
3651
|
+
init_merge();
|
|
3652
|
+
init_layouts();
|
|
3653
|
+
baseConfig = createConfig(DEFAULT_LAYOUTS);
|
|
3654
|
+
}
|
|
3655
|
+
});
|
|
3656
|
+
function PageRenderer({
|
|
3657
|
+
data,
|
|
3658
|
+
config = baseConfig,
|
|
3659
|
+
wrapper: Wrapper,
|
|
3660
|
+
className,
|
|
3661
|
+
layouts = DEFAULT_LAYOUTS
|
|
3662
|
+
}) {
|
|
3663
|
+
if (!data || !data.content) {
|
|
3664
|
+
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("p", { children: "No content available" }) });
|
|
3665
|
+
}
|
|
3666
|
+
const content = /* @__PURE__ */ jsx(Render, { config, data });
|
|
3667
|
+
const rootProps = data.root?.props;
|
|
3668
|
+
const overrides = {
|
|
3669
|
+
showHeader: rootProps?.showHeader,
|
|
3670
|
+
showFooter: rootProps?.showFooter,
|
|
3671
|
+
background: rootProps?.pageBackground,
|
|
3672
|
+
maxWidth: rootProps?.pageMaxWidth
|
|
3673
|
+
};
|
|
3674
|
+
let result = content;
|
|
3675
|
+
if (Wrapper) {
|
|
3676
|
+
result = /* @__PURE__ */ jsx(Wrapper, { children: result });
|
|
3677
|
+
} else {
|
|
3678
|
+
const pageLayout = rootProps?.pageLayout;
|
|
3679
|
+
const layout = pageLayout ? getLayout(layouts, pageLayout) : void 0;
|
|
3680
|
+
if (layout) {
|
|
3681
|
+
result = /* @__PURE__ */ jsx(LayoutWrapper, { layout, className, overrides, children: result });
|
|
3682
|
+
} else if (className || overrides.background) {
|
|
3683
|
+
result = /* @__PURE__ */ jsx(LayoutWrapper, { className, overrides, children: result });
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
return result;
|
|
3687
|
+
}
|
|
3688
|
+
var init_PageRenderer = __esm({
|
|
3689
|
+
"src/render/PageRenderer.tsx"() {
|
|
3690
|
+
init_config();
|
|
3691
|
+
init_layouts();
|
|
3692
|
+
}
|
|
3693
|
+
});
|
|
3694
|
+
var PreviewModal;
|
|
3695
|
+
var init_PreviewModal = __esm({
|
|
3696
|
+
"src/editor/components/PreviewModal.tsx"() {
|
|
3697
|
+
"use client";
|
|
3698
|
+
init_dialog();
|
|
3699
|
+
init_utils();
|
|
3700
|
+
init_PageRenderer();
|
|
3701
|
+
PreviewModal = memo(function PreviewModal2({
|
|
3702
|
+
isOpen,
|
|
3703
|
+
onClose,
|
|
3704
|
+
data,
|
|
3705
|
+
pageTitle,
|
|
3706
|
+
onOpenInNewTab,
|
|
3707
|
+
layouts,
|
|
3708
|
+
hasUnsavedChanges = false,
|
|
3709
|
+
onSave,
|
|
3710
|
+
isSaving = false
|
|
3711
|
+
}) {
|
|
3712
|
+
const [pendingNavigation, setPendingNavigation] = useState(null);
|
|
3713
|
+
const [isNavigating, setIsNavigating] = useState(false);
|
|
3714
|
+
const handleContentClick = useCallback((e) => {
|
|
3715
|
+
const target = e.target;
|
|
3716
|
+
const anchor = target.closest("a");
|
|
3717
|
+
if (anchor) {
|
|
3718
|
+
const href = anchor.getAttribute("href");
|
|
3719
|
+
if (href?.startsWith("#") && !href.includes("/")) {
|
|
3720
|
+
return;
|
|
3721
|
+
}
|
|
3722
|
+
e.preventDefault();
|
|
3723
|
+
e.stopPropagation();
|
|
3724
|
+
if (href) {
|
|
3725
|
+
setPendingNavigation(href);
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
}, []);
|
|
3729
|
+
const handleNavigate = useCallback((saveFirst) => {
|
|
3730
|
+
if (!pendingNavigation) return;
|
|
3731
|
+
const navigate = () => {
|
|
3732
|
+
setIsNavigating(true);
|
|
3733
|
+
onClose();
|
|
3734
|
+
window.location.href = pendingNavigation;
|
|
3735
|
+
};
|
|
3736
|
+
if (saveFirst && onSave) {
|
|
3737
|
+
onSave().then(navigate).catch(() => {
|
|
3738
|
+
setIsNavigating(false);
|
|
3739
|
+
});
|
|
3740
|
+
} else {
|
|
3741
|
+
navigate();
|
|
3742
|
+
}
|
|
3743
|
+
}, [pendingNavigation, onClose, onSave]);
|
|
3744
|
+
const handleCancelNavigation = useCallback(() => {
|
|
3745
|
+
setPendingNavigation(null);
|
|
3746
|
+
}, []);
|
|
3747
|
+
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(
|
|
3748
|
+
DialogContentFullscreen,
|
|
3749
|
+
{
|
|
3750
|
+
hideCloseButton: true,
|
|
3751
|
+
accessibleTitle: `Preview: ${pageTitle || "Page"}`,
|
|
3752
|
+
className: "p-0",
|
|
3753
|
+
children: [
|
|
3754
|
+
/* @__PURE__ */ jsxs("div", { className: "fixed top-1/2 right-4 -translate-y-1/2 z-[9998] flex flex-col gap-2 items-end", children: [
|
|
3755
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-white rounded-lg shadow-lg border border-gray-200 p-2 flex flex-col gap-1", children: [
|
|
3756
|
+
/* @__PURE__ */ jsxs(
|
|
3757
|
+
"button",
|
|
3758
|
+
{
|
|
3759
|
+
type: "button",
|
|
3760
|
+
onClick: onClose,
|
|
3761
|
+
className: "flex items-center gap-2 px-3 py-2 text-sm font-medium text-white bg-gray-900 hover:bg-gray-800 rounded-md transition-colors",
|
|
3762
|
+
title: "Close preview (Esc)",
|
|
3763
|
+
children: [
|
|
3764
|
+
/* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" }),
|
|
3765
|
+
"Close Preview"
|
|
3766
|
+
]
|
|
3767
|
+
}
|
|
3768
|
+
),
|
|
3769
|
+
onOpenInNewTab && /* @__PURE__ */ jsxs(
|
|
3770
|
+
"button",
|
|
3771
|
+
{
|
|
3772
|
+
type: "button",
|
|
3773
|
+
onClick: onOpenInNewTab,
|
|
3774
|
+
className: "flex items-center gap-2 px-3 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors",
|
|
3775
|
+
title: "Open published page in new tab",
|
|
3776
|
+
children: [
|
|
3777
|
+
/* @__PURE__ */ jsx(IconExternalLink, { className: "h-4 w-4" }),
|
|
3778
|
+
"View Page"
|
|
3779
|
+
]
|
|
3780
|
+
}
|
|
3781
|
+
)
|
|
3782
|
+
] }),
|
|
3783
|
+
hasUnsavedChanges && /* @__PURE__ */ jsx("div", { className: "bg-amber-100 text-amber-700 px-3 py-1.5 rounded-full text-xs font-medium shadow-sm", children: "Unsaved changes" })
|
|
3784
|
+
] }),
|
|
3785
|
+
/* @__PURE__ */ jsx(
|
|
3786
|
+
"div",
|
|
3787
|
+
{
|
|
3788
|
+
className: "h-full overflow-auto bg-white",
|
|
3789
|
+
onClickCapture: handleContentClick,
|
|
3790
|
+
children: data ? /* @__PURE__ */ jsx(PageRenderer, { data, layouts }) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full text-gray-500", children: "No content to preview" })
|
|
3791
|
+
}
|
|
3792
|
+
),
|
|
3793
|
+
pendingNavigation && /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: /* @__PURE__ */ jsxs(
|
|
3794
|
+
"div",
|
|
3795
|
+
{
|
|
3796
|
+
className: "bg-white rounded-lg shadow-xl max-w-md w-full mx-4 overflow-hidden",
|
|
3797
|
+
onClick: (e) => e.stopPropagation(),
|
|
3798
|
+
children: [
|
|
3799
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-5 py-4 border-b border-gray-200 bg-amber-50", children: [
|
|
3800
|
+
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 flex items-center justify-center", children: /* @__PURE__ */ jsx(IconAlertTriangle, { className: "h-5 w-5 text-amber-600" }) }),
|
|
3801
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3802
|
+
/* @__PURE__ */ jsx("h3", { className: "text-base font-semibold text-gray-900", children: "Navigate away?" }),
|
|
3803
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: "This will close the preview" })
|
|
3804
|
+
] })
|
|
3805
|
+
] }),
|
|
3806
|
+
/* @__PURE__ */ jsxs("div", { className: "px-5 py-4", children: [
|
|
3807
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-700 mb-2", children: "You're about to navigate to:" }),
|
|
3808
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-mono bg-gray-100 px-3 py-2 rounded text-gray-800 break-all", children: pendingNavigation }),
|
|
3809
|
+
hasUnsavedChanges && /* @__PURE__ */ jsx("p", { className: "text-sm text-amber-600 mt-3 font-medium", children: "You have unsaved changes that will be lost." })
|
|
3810
|
+
] }),
|
|
3811
|
+
/* @__PURE__ */ jsxs("div", { className: "px-5 py-4 bg-gray-50 border-t border-gray-200 flex flex-col sm:flex-row gap-2 sm:justify-end", children: [
|
|
3812
|
+
/* @__PURE__ */ jsx(
|
|
3813
|
+
"button",
|
|
3814
|
+
{
|
|
3815
|
+
type: "button",
|
|
3816
|
+
onClick: handleCancelNavigation,
|
|
3817
|
+
disabled: isNavigating || isSaving,
|
|
3818
|
+
className: "px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors disabled:opacity-50",
|
|
3819
|
+
children: "Cancel"
|
|
3820
|
+
}
|
|
3821
|
+
),
|
|
3822
|
+
hasUnsavedChanges && onSave && /* @__PURE__ */ jsx(
|
|
3823
|
+
"button",
|
|
3824
|
+
{
|
|
3825
|
+
type: "button",
|
|
3826
|
+
onClick: () => handleNavigate(true),
|
|
3827
|
+
disabled: isNavigating || isSaving,
|
|
3828
|
+
className: "px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50",
|
|
3829
|
+
children: isSaving ? "Saving..." : "Save & Navigate"
|
|
3830
|
+
}
|
|
3831
|
+
),
|
|
3832
|
+
/* @__PURE__ */ jsx(
|
|
3833
|
+
"button",
|
|
3834
|
+
{
|
|
3835
|
+
type: "button",
|
|
3836
|
+
onClick: () => handleNavigate(false),
|
|
3837
|
+
disabled: isNavigating || isSaving,
|
|
3838
|
+
className: cn(
|
|
3839
|
+
"px-4 py-2 text-sm font-medium rounded-md transition-colors disabled:opacity-50",
|
|
3840
|
+
hasUnsavedChanges ? "text-red-700 bg-red-50 border border-red-200 hover:bg-red-100" : "text-white bg-gray-900 hover:bg-gray-800"
|
|
3841
|
+
),
|
|
3842
|
+
children: isNavigating ? "Navigating..." : hasUnsavedChanges ? "Navigate without saving" : "Navigate"
|
|
3843
|
+
}
|
|
3844
|
+
)
|
|
3845
|
+
] })
|
|
3846
|
+
]
|
|
3847
|
+
}
|
|
3848
|
+
) })
|
|
3849
|
+
]
|
|
3850
|
+
}
|
|
3851
|
+
) });
|
|
3852
|
+
});
|
|
3853
|
+
}
|
|
3854
|
+
});
|
|
3855
|
+
function useUnsavedChanges() {
|
|
3856
|
+
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
|
3857
|
+
const hasUnsavedChangesRef = useRef(hasUnsavedChanges);
|
|
3858
|
+
hasUnsavedChangesRef.current = hasUnsavedChanges;
|
|
3859
|
+
useEffect(() => {
|
|
3860
|
+
const handleBeforeUnload = (e) => {
|
|
3861
|
+
if (hasUnsavedChangesRef.current) {
|
|
3862
|
+
e.preventDefault();
|
|
3863
|
+
e.returnValue = "";
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
3866
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
3867
|
+
return () => window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
3868
|
+
}, []);
|
|
3869
|
+
const markClean = useCallback(() => {
|
|
3870
|
+
hasUnsavedChangesRef.current = false;
|
|
3871
|
+
setHasUnsavedChanges(false);
|
|
3872
|
+
}, []);
|
|
3873
|
+
const markDirty = useCallback(() => {
|
|
3874
|
+
hasUnsavedChangesRef.current = true;
|
|
3875
|
+
setHasUnsavedChanges(true);
|
|
3876
|
+
}, []);
|
|
3877
|
+
return {
|
|
3878
|
+
hasUnsavedChanges,
|
|
3879
|
+
markClean,
|
|
3880
|
+
markDirty
|
|
3881
|
+
};
|
|
3882
|
+
}
|
|
3883
|
+
var init_useUnsavedChanges = __esm({
|
|
3884
|
+
"src/editor/hooks/useUnsavedChanges.ts"() {
|
|
3885
|
+
"use client";
|
|
3886
|
+
}
|
|
3887
|
+
});
|
|
3888
|
+
function ThemeProvider({ children, theme }) {
|
|
3889
|
+
const resolvedTheme = useMemo(() => resolveTheme(theme), [theme]);
|
|
3890
|
+
const value = useMemo(
|
|
3891
|
+
() => ({
|
|
3892
|
+
theme: resolvedTheme
|
|
3893
|
+
}),
|
|
3894
|
+
[resolvedTheme]
|
|
3895
|
+
);
|
|
3896
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
3897
|
+
}
|
|
3898
|
+
var ThemeContext;
|
|
3899
|
+
var init_context = __esm({
|
|
3900
|
+
"src/theme/context.tsx"() {
|
|
3901
|
+
"use client";
|
|
3902
|
+
init_defaults2();
|
|
3903
|
+
init_utils3();
|
|
3904
|
+
ThemeContext = createContext(null);
|
|
3905
|
+
}
|
|
3906
|
+
});
|
|
3907
|
+
|
|
3908
|
+
// src/theme/example.ts
|
|
3909
|
+
var init_example = __esm({
|
|
3910
|
+
"src/theme/example.ts"() {
|
|
3911
|
+
}
|
|
3912
|
+
});
|
|
3913
|
+
|
|
3914
|
+
// src/theme/index.ts
|
|
3915
|
+
var init_theme = __esm({
|
|
3916
|
+
"src/theme/index.ts"() {
|
|
3917
|
+
init_context();
|
|
3918
|
+
init_defaults2();
|
|
3919
|
+
init_utils3();
|
|
3920
|
+
init_example();
|
|
3921
|
+
}
|
|
3922
|
+
});
|
|
3923
|
+
|
|
3924
|
+
// src/editor/PuckEditorCore.client.tsx
|
|
3925
|
+
var PuckEditorCore_client_exports = {};
|
|
3926
|
+
__export(PuckEditorCore_client_exports, {
|
|
3927
|
+
PuckEditorCore: () => PuckEditorCore
|
|
3928
|
+
});
|
|
3929
|
+
function PuckEditorCore({
|
|
3930
|
+
pageId,
|
|
3931
|
+
initialData,
|
|
3932
|
+
config,
|
|
3933
|
+
pageTitle,
|
|
3934
|
+
pageSlug,
|
|
3935
|
+
apiEndpoint = "/api/puck/pages",
|
|
3936
|
+
backUrl,
|
|
3937
|
+
previewUrl,
|
|
3938
|
+
enableViewports = true,
|
|
3939
|
+
plugins,
|
|
3940
|
+
layouts,
|
|
3941
|
+
layoutStyles,
|
|
3942
|
+
layoutKey = "pageLayout",
|
|
3943
|
+
headerActionsStart,
|
|
3944
|
+
headerActionsEnd,
|
|
3945
|
+
overrides: customOverrides,
|
|
3946
|
+
onSaveSuccess,
|
|
3947
|
+
onSaveError,
|
|
3948
|
+
onChange: onChangeProp,
|
|
3949
|
+
initialStatus,
|
|
3950
|
+
theme
|
|
3951
|
+
}) {
|
|
3952
|
+
const router = useRouter();
|
|
3953
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
3954
|
+
const [lastSaved, setLastSaved] = useState(null);
|
|
3955
|
+
const [saveError, setSaveError] = useState(null);
|
|
3956
|
+
const [documentStatus, setDocumentStatus] = useState(initialStatus);
|
|
3957
|
+
const [wasPublished, setWasPublished] = useState(initialStatus === "published");
|
|
3958
|
+
const { hasUnsavedChanges, markClean, markDirty } = useUnsavedChanges();
|
|
3959
|
+
const [isPreviewOpen, setIsPreviewOpen] = useState(false);
|
|
3960
|
+
const dataWithSlug = useMemo(() => {
|
|
3961
|
+
const data = initialData;
|
|
3962
|
+
return {
|
|
3963
|
+
...data,
|
|
3964
|
+
root: {
|
|
3965
|
+
...data.root,
|
|
3966
|
+
props: {
|
|
3967
|
+
...data.root?.props,
|
|
3968
|
+
slug: data.root?.props?.slug || pageSlug
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
};
|
|
3972
|
+
}, [initialData, pageSlug]);
|
|
3973
|
+
const latestDataRef = useRef(dataWithSlug);
|
|
3974
|
+
const handleSave = useCallback(
|
|
3975
|
+
async (data) => {
|
|
3976
|
+
setIsSaving(true);
|
|
3977
|
+
const typedData = data;
|
|
3978
|
+
try {
|
|
3979
|
+
const response = await fetch(`${apiEndpoint}/${pageId}`, {
|
|
3980
|
+
method: "PATCH",
|
|
3981
|
+
headers: { "Content-Type": "application/json" },
|
|
3982
|
+
body: JSON.stringify({
|
|
3983
|
+
puckData: data,
|
|
3984
|
+
title: typedData.root?.props?.title || pageTitle,
|
|
3985
|
+
slug: typedData.root?.props?.slug || pageSlug,
|
|
3986
|
+
draft: true
|
|
3987
|
+
// Save as draft, don't publish
|
|
3988
|
+
})
|
|
3989
|
+
});
|
|
3990
|
+
if (!response.ok) {
|
|
3991
|
+
const errorData = await response.json();
|
|
3992
|
+
const errorMessage = errorData.error || errorData.message || "Failed to save page";
|
|
3993
|
+
const err = new Error(errorMessage);
|
|
3994
|
+
err.field = errorData.field;
|
|
3995
|
+
err.details = errorData.details;
|
|
3996
|
+
throw err;
|
|
3997
|
+
}
|
|
3998
|
+
setLastSaved(/* @__PURE__ */ new Date());
|
|
3999
|
+
setSaveError(null);
|
|
4000
|
+
setDocumentStatus("draft");
|
|
4001
|
+
markClean();
|
|
4002
|
+
onSaveSuccess?.(data);
|
|
4003
|
+
} catch (error) {
|
|
4004
|
+
console.error("Error saving page:", error);
|
|
4005
|
+
setSaveError(error instanceof Error ? error.message : "Unknown error");
|
|
4006
|
+
onSaveError?.(error instanceof Error ? error : new Error("Unknown error"));
|
|
4007
|
+
} finally {
|
|
4008
|
+
setIsSaving(false);
|
|
4009
|
+
}
|
|
4010
|
+
},
|
|
4011
|
+
[apiEndpoint, pageId, pageTitle, pageSlug, markClean, onSaveSuccess, onSaveError]
|
|
4012
|
+
);
|
|
4013
|
+
const handlePublish = useCallback(
|
|
4014
|
+
async (data) => {
|
|
4015
|
+
setIsSaving(true);
|
|
4016
|
+
const typedData = data;
|
|
4017
|
+
try {
|
|
4018
|
+
const response = await fetch(`${apiEndpoint}/${pageId}`, {
|
|
4019
|
+
method: "PATCH",
|
|
4020
|
+
headers: { "Content-Type": "application/json" },
|
|
4021
|
+
body: JSON.stringify({
|
|
4022
|
+
puckData: data,
|
|
4023
|
+
title: typedData.root?.props?.title || pageTitle,
|
|
4024
|
+
slug: typedData.root?.props?.slug || pageSlug,
|
|
4025
|
+
status: "published"
|
|
4026
|
+
})
|
|
4027
|
+
});
|
|
4028
|
+
if (!response.ok) {
|
|
4029
|
+
const errorData = await response.json();
|
|
4030
|
+
const errorMessage = errorData.error || errorData.message || "Failed to publish page";
|
|
4031
|
+
const err = new Error(errorMessage);
|
|
4032
|
+
err.field = errorData.field;
|
|
4033
|
+
err.details = errorData.details;
|
|
4034
|
+
throw err;
|
|
4035
|
+
}
|
|
4036
|
+
setLastSaved(/* @__PURE__ */ new Date());
|
|
4037
|
+
setSaveError(null);
|
|
4038
|
+
setDocumentStatus("published");
|
|
4039
|
+
setWasPublished(true);
|
|
4040
|
+
markClean();
|
|
4041
|
+
onSaveSuccess?.(data);
|
|
4042
|
+
} catch (error) {
|
|
4043
|
+
console.error("Error publishing page:", error);
|
|
4044
|
+
setSaveError(error instanceof Error ? error.message : "Unknown error");
|
|
4045
|
+
onSaveError?.(error instanceof Error ? error : new Error("Unknown error"));
|
|
4046
|
+
} finally {
|
|
4047
|
+
setIsSaving(false);
|
|
4048
|
+
}
|
|
4049
|
+
},
|
|
4050
|
+
[apiEndpoint, pageId, pageTitle, pageSlug, markClean, onSaveSuccess, onSaveError]
|
|
4051
|
+
);
|
|
4052
|
+
const handleChange = useCallback(
|
|
4053
|
+
(data) => {
|
|
4054
|
+
latestDataRef.current = data;
|
|
4055
|
+
markDirty();
|
|
4056
|
+
onChangeProp?.(data);
|
|
4057
|
+
},
|
|
4058
|
+
[markDirty, onChangeProp]
|
|
4059
|
+
);
|
|
4060
|
+
const handleBack = useCallback(() => {
|
|
4061
|
+
if (hasUnsavedChanges) {
|
|
4062
|
+
if (!confirm("You have unsaved changes. Are you sure you want to leave?")) {
|
|
4063
|
+
return;
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
if (backUrl) {
|
|
4067
|
+
router.push(backUrl);
|
|
4068
|
+
} else {
|
|
4069
|
+
router.back();
|
|
4070
|
+
}
|
|
4071
|
+
}, [hasUnsavedChanges, router, backUrl]);
|
|
4072
|
+
const handlePreview = useCallback(() => {
|
|
4073
|
+
const currentSlug = latestDataRef.current?.root?.props?.slug || pageSlug;
|
|
4074
|
+
let url;
|
|
4075
|
+
if (typeof previewUrl === "function") {
|
|
4076
|
+
url = previewUrl(currentSlug);
|
|
4077
|
+
} else if (previewUrl) {
|
|
4078
|
+
url = previewUrl;
|
|
4079
|
+
} else {
|
|
4080
|
+
url = `/${currentSlug}`;
|
|
4081
|
+
}
|
|
4082
|
+
window.open(url, "_blank");
|
|
4083
|
+
}, [pageSlug, previewUrl]);
|
|
4084
|
+
const handleOpenPreview = useCallback(() => {
|
|
4085
|
+
setIsPreviewOpen(true);
|
|
4086
|
+
}, []);
|
|
4087
|
+
const handleSaveFromPreview = useCallback(async () => {
|
|
4088
|
+
const data = latestDataRef.current;
|
|
4089
|
+
setIsSaving(true);
|
|
4090
|
+
try {
|
|
4091
|
+
const response = await fetch(`${apiEndpoint}/${pageId}`, {
|
|
4092
|
+
method: "PATCH",
|
|
4093
|
+
headers: { "Content-Type": "application/json" },
|
|
4094
|
+
body: JSON.stringify({
|
|
4095
|
+
puckData: data,
|
|
4096
|
+
title: data?.root?.props?.title || pageTitle,
|
|
4097
|
+
slug: data?.root?.props?.slug || pageSlug,
|
|
4098
|
+
draft: true
|
|
4099
|
+
})
|
|
4100
|
+
});
|
|
4101
|
+
if (!response.ok) {
|
|
4102
|
+
const errorData = await response.json();
|
|
4103
|
+
const errorMessage = errorData.error || errorData.message || "Failed to save page";
|
|
4104
|
+
throw new Error(errorMessage);
|
|
4105
|
+
}
|
|
4106
|
+
setLastSaved(/* @__PURE__ */ new Date());
|
|
4107
|
+
setSaveError(null);
|
|
4108
|
+
setDocumentStatus("draft");
|
|
4109
|
+
markClean();
|
|
4110
|
+
onSaveSuccess?.(data);
|
|
4111
|
+
} catch (error) {
|
|
4112
|
+
console.error("Error saving page:", error);
|
|
4113
|
+
setSaveError(error instanceof Error ? error.message : "Unknown error");
|
|
4114
|
+
onSaveError?.(error instanceof Error ? error : new Error("Unknown error"));
|
|
4115
|
+
throw error;
|
|
4116
|
+
} finally {
|
|
4117
|
+
setIsSaving(false);
|
|
4118
|
+
}
|
|
4119
|
+
}, [apiEndpoint, pageId, pageTitle, pageSlug, markClean, onSaveSuccess, onSaveError]);
|
|
4120
|
+
const overrides = useMemo(
|
|
4121
|
+
() => ({
|
|
4122
|
+
headerActions: ({ children }) => /* @__PURE__ */ jsx(
|
|
4123
|
+
HeaderActions,
|
|
4124
|
+
{
|
|
4125
|
+
onBack: handleBack,
|
|
4126
|
+
onPreview: handlePreview,
|
|
4127
|
+
onSave: handleSave,
|
|
4128
|
+
onPublish: handlePublish,
|
|
4129
|
+
onOpenPreview: handleOpenPreview,
|
|
4130
|
+
isSaving,
|
|
4131
|
+
hasUnsavedChanges,
|
|
4132
|
+
lastSaved,
|
|
4133
|
+
documentStatus,
|
|
4134
|
+
wasPublished,
|
|
4135
|
+
actionsStart: headerActionsStart,
|
|
4136
|
+
actionsEnd: headerActionsEnd,
|
|
4137
|
+
pageId,
|
|
4138
|
+
apiEndpoint,
|
|
4139
|
+
saveError,
|
|
4140
|
+
onDismissError: () => setSaveError(null),
|
|
4141
|
+
children
|
|
4142
|
+
}
|
|
4143
|
+
),
|
|
4144
|
+
// Always wrap iframe for richtext styles injection and theme-aware background
|
|
4145
|
+
iframe: ({ children, document: document2 }) => /* @__PURE__ */ jsx(IframeWrapper, { document: document2, layouts, layoutStyles, layoutKey, children }),
|
|
4146
|
+
// Merge custom overrides
|
|
4147
|
+
...customOverrides
|
|
4148
|
+
}),
|
|
4149
|
+
[
|
|
4150
|
+
handleBack,
|
|
4151
|
+
handlePreview,
|
|
4152
|
+
handleSave,
|
|
4153
|
+
handlePublish,
|
|
4154
|
+
handleOpenPreview,
|
|
4155
|
+
isSaving,
|
|
4156
|
+
hasUnsavedChanges,
|
|
4157
|
+
lastSaved,
|
|
4158
|
+
saveError,
|
|
4159
|
+
documentStatus,
|
|
4160
|
+
wasPublished,
|
|
4161
|
+
headerActionsStart,
|
|
4162
|
+
headerActionsEnd,
|
|
4163
|
+
pageId,
|
|
4164
|
+
apiEndpoint,
|
|
4165
|
+
layouts,
|
|
4166
|
+
layoutStyles,
|
|
4167
|
+
layoutKey,
|
|
4168
|
+
customOverrides
|
|
4169
|
+
]
|
|
4170
|
+
);
|
|
4171
|
+
const defaultPlugins = [headingAnalyzer];
|
|
4172
|
+
const resolvedPlugins = useMemo(() => {
|
|
4173
|
+
if (plugins === false) return void 0;
|
|
4174
|
+
if (!plugins || plugins.length === 0) return defaultPlugins;
|
|
4175
|
+
return [...defaultPlugins, ...plugins];
|
|
4176
|
+
}, [plugins]);
|
|
4177
|
+
const editorContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4178
|
+
/* @__PURE__ */ jsx("div", { className: "h-screen", children: /* @__PURE__ */ jsx(
|
|
4179
|
+
Puck,
|
|
4180
|
+
{
|
|
4181
|
+
config,
|
|
4182
|
+
data: dataWithSlug,
|
|
4183
|
+
onChange: handleChange,
|
|
4184
|
+
onPublish: handlePublish,
|
|
4185
|
+
headerTitle: `${pageTitle} /${pageSlug}`,
|
|
4186
|
+
plugins: resolvedPlugins,
|
|
4187
|
+
viewports: enableViewports ? DEFAULT_VIEWPORTS : void 0,
|
|
4188
|
+
overrides
|
|
4189
|
+
}
|
|
4190
|
+
) }),
|
|
4191
|
+
/* @__PURE__ */ jsx(
|
|
4192
|
+
PreviewModal,
|
|
4193
|
+
{
|
|
4194
|
+
isOpen: isPreviewOpen,
|
|
4195
|
+
onClose: () => setIsPreviewOpen(false),
|
|
4196
|
+
data: latestDataRef.current,
|
|
4197
|
+
pageTitle,
|
|
4198
|
+
onOpenInNewTab: handlePreview,
|
|
4199
|
+
layouts,
|
|
4200
|
+
hasUnsavedChanges,
|
|
4201
|
+
onSave: handleSaveFromPreview,
|
|
4202
|
+
isSaving
|
|
4203
|
+
}
|
|
4204
|
+
)
|
|
4205
|
+
] });
|
|
4206
|
+
if (theme) {
|
|
4207
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme, children: editorContent });
|
|
4208
|
+
}
|
|
4209
|
+
return editorContent;
|
|
4210
|
+
}
|
|
4211
|
+
var DEFAULT_VIEWPORTS;
|
|
4212
|
+
var init_PuckEditorCore_client = __esm({
|
|
4213
|
+
"src/editor/PuckEditorCore.client.tsx"() {
|
|
4214
|
+
"use client";
|
|
4215
|
+
init_HeaderActions();
|
|
4216
|
+
init_IframeWrapper();
|
|
4217
|
+
init_PreviewModal();
|
|
4218
|
+
init_useUnsavedChanges();
|
|
4219
|
+
init_theme();
|
|
4220
|
+
DEFAULT_VIEWPORTS = [
|
|
4221
|
+
{
|
|
4222
|
+
width: 360,
|
|
4223
|
+
height: "auto",
|
|
4224
|
+
label: "Mobile",
|
|
4225
|
+
icon: "Smartphone"
|
|
4226
|
+
},
|
|
4227
|
+
{
|
|
4228
|
+
width: 768,
|
|
4229
|
+
height: "auto",
|
|
4230
|
+
label: "Tablet",
|
|
4231
|
+
icon: "Tablet"
|
|
4232
|
+
},
|
|
4233
|
+
{
|
|
4234
|
+
width: 1280,
|
|
4235
|
+
height: "auto",
|
|
4236
|
+
label: "Desktop",
|
|
4237
|
+
icon: "Monitor"
|
|
4238
|
+
}
|
|
4239
|
+
];
|
|
4240
|
+
}
|
|
4241
|
+
});
|
|
4242
|
+
|
|
4243
|
+
// src/editor/PuckEditor.client.tsx
|
|
4244
|
+
var PuckEditor_client_exports = {};
|
|
4245
|
+
__export(PuckEditor_client_exports, {
|
|
4246
|
+
PuckEditor: () => PuckEditor
|
|
4247
|
+
});
|
|
4248
|
+
function PuckEditor({
|
|
4249
|
+
pageId,
|
|
4250
|
+
initialData,
|
|
4251
|
+
config,
|
|
4252
|
+
pageTitle,
|
|
4253
|
+
pageSlug,
|
|
4254
|
+
apiEndpoint,
|
|
4255
|
+
backUrl,
|
|
4256
|
+
previewUrl,
|
|
4257
|
+
enableViewports,
|
|
4258
|
+
plugins,
|
|
4259
|
+
layouts,
|
|
4260
|
+
layoutStyles,
|
|
4261
|
+
layoutKey,
|
|
4262
|
+
headerActionsStart,
|
|
4263
|
+
headerActionsEnd,
|
|
4264
|
+
overrides,
|
|
4265
|
+
onSaveSuccess,
|
|
4266
|
+
onSaveError,
|
|
4267
|
+
onChange,
|
|
4268
|
+
initialStatus,
|
|
4269
|
+
theme
|
|
4270
|
+
}) {
|
|
4271
|
+
return /* @__PURE__ */ jsx(
|
|
4272
|
+
PuckEditorCore2,
|
|
4273
|
+
{
|
|
4274
|
+
pageId,
|
|
4275
|
+
initialData,
|
|
4276
|
+
config,
|
|
4277
|
+
pageTitle,
|
|
4278
|
+
pageSlug,
|
|
4279
|
+
apiEndpoint,
|
|
4280
|
+
backUrl,
|
|
4281
|
+
previewUrl,
|
|
4282
|
+
enableViewports,
|
|
4283
|
+
plugins,
|
|
4284
|
+
layouts,
|
|
4285
|
+
layoutStyles,
|
|
4286
|
+
layoutKey,
|
|
4287
|
+
headerActionsStart,
|
|
4288
|
+
headerActionsEnd,
|
|
4289
|
+
overrides,
|
|
4290
|
+
onSaveSuccess,
|
|
4291
|
+
onSaveError,
|
|
4292
|
+
onChange,
|
|
4293
|
+
initialStatus,
|
|
4294
|
+
theme
|
|
4295
|
+
}
|
|
4296
|
+
);
|
|
4297
|
+
}
|
|
4298
|
+
var PuckEditorCore2;
|
|
4299
|
+
var init_PuckEditor_client = __esm({
|
|
4300
|
+
"src/editor/PuckEditor.client.tsx"() {
|
|
4301
|
+
"use client";
|
|
4302
|
+
init_LoadingState();
|
|
4303
|
+
PuckEditorCore2 = dynamic(
|
|
4304
|
+
() => Promise.resolve().then(() => (init_PuckEditorCore_client(), PuckEditorCore_client_exports)).then((mod) => mod.PuckEditorCore),
|
|
4305
|
+
{
|
|
4306
|
+
ssr: false,
|
|
4307
|
+
loading: () => /* @__PURE__ */ jsx(LoadingState, {})
|
|
4308
|
+
}
|
|
4309
|
+
);
|
|
4310
|
+
}
|
|
4311
|
+
});
|
|
4312
|
+
|
|
4313
|
+
// src/editor/index.ts
|
|
4314
|
+
init_PuckEditor_client();
|
|
4315
|
+
init_PuckEditorCore_client();
|
|
4316
|
+
function PuckEditorView({
|
|
4317
|
+
config,
|
|
4318
|
+
collectionSlug = "pages",
|
|
4319
|
+
apiBasePath = "/api/puck",
|
|
4320
|
+
backUrl,
|
|
4321
|
+
previewUrl,
|
|
4322
|
+
layoutStyles,
|
|
4323
|
+
layoutKey = "pageLayout",
|
|
4324
|
+
plugins,
|
|
4325
|
+
onSaveSuccess,
|
|
4326
|
+
onSaveError
|
|
4327
|
+
}) {
|
|
4328
|
+
const params = useParams();
|
|
4329
|
+
const searchParams = useSearchParams();
|
|
4330
|
+
const pageId = params?.id || searchParams?.get("id") || "";
|
|
4331
|
+
const [page, setPage] = useState(null);
|
|
4332
|
+
const [loading, setLoading] = useState(true);
|
|
4333
|
+
const [error, setError] = useState(null);
|
|
4334
|
+
const [PuckEditor2, setPuckEditor] = useState(null);
|
|
4335
|
+
useEffect(() => {
|
|
4336
|
+
Promise.resolve().then(() => (init_PuckEditor_client(), PuckEditor_client_exports)).then((mod) => {
|
|
4337
|
+
setPuckEditor(() => mod.PuckEditor);
|
|
4338
|
+
});
|
|
4339
|
+
}, []);
|
|
4340
|
+
useEffect(() => {
|
|
4341
|
+
async function fetchPage() {
|
|
4342
|
+
if (!pageId) {
|
|
4343
|
+
setError("No page ID provided");
|
|
4344
|
+
setLoading(false);
|
|
4345
|
+
return;
|
|
4346
|
+
}
|
|
4347
|
+
try {
|
|
4348
|
+
setLoading(true);
|
|
4349
|
+
const response = await fetch(`${apiBasePath}/${collectionSlug}/${pageId}`);
|
|
4350
|
+
if (!response.ok) {
|
|
4351
|
+
const data2 = await response.json().catch(() => ({}));
|
|
4352
|
+
throw new Error(data2.error || `Failed to fetch page: ${response.status}`);
|
|
4353
|
+
}
|
|
4354
|
+
const data = await response.json();
|
|
4355
|
+
setPage(data.doc);
|
|
4356
|
+
} catch (err) {
|
|
4357
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
4358
|
+
} finally {
|
|
4359
|
+
setLoading(false);
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4362
|
+
fetchPage();
|
|
4363
|
+
}, [pageId, apiBasePath, collectionSlug]);
|
|
4364
|
+
const computedBackUrl = backUrl || `/admin/collections/${collectionSlug}`;
|
|
4365
|
+
if (loading || !PuckEditor2) {
|
|
4366
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
4367
|
+
display: "flex",
|
|
4368
|
+
height: "100vh",
|
|
4369
|
+
alignItems: "center",
|
|
4370
|
+
justifyContent: "center",
|
|
4371
|
+
backgroundColor: "#0f0f0f",
|
|
4372
|
+
color: "#fff"
|
|
4373
|
+
}, children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
|
|
4374
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
4375
|
+
width: "32px",
|
|
4376
|
+
height: "32px",
|
|
4377
|
+
border: "3px solid #333",
|
|
4378
|
+
borderTopColor: "#fff",
|
|
4379
|
+
borderRadius: "50%",
|
|
4380
|
+
animation: "spin 1s linear infinite",
|
|
4381
|
+
margin: "0 auto 16px"
|
|
4382
|
+
} }),
|
|
4383
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#888" }, children: "Loading editor..." }),
|
|
4384
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
4385
|
+
@keyframes spin {
|
|
4386
|
+
to { transform: rotate(360deg); }
|
|
4387
|
+
}
|
|
4388
|
+
` })
|
|
4389
|
+
] }) });
|
|
4390
|
+
}
|
|
4391
|
+
if (error) {
|
|
4392
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
4393
|
+
display: "flex",
|
|
4394
|
+
height: "100vh",
|
|
4395
|
+
alignItems: "center",
|
|
4396
|
+
justifyContent: "center",
|
|
4397
|
+
backgroundColor: "#0f0f0f",
|
|
4398
|
+
color: "#fff"
|
|
4399
|
+
}, children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
|
|
4400
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#f87171", marginBottom: "16px" }, children: error }),
|
|
4401
|
+
/* @__PURE__ */ jsxs(
|
|
4402
|
+
"a",
|
|
4403
|
+
{
|
|
4404
|
+
href: computedBackUrl,
|
|
4405
|
+
style: {
|
|
4406
|
+
color: "#60a5fa",
|
|
4407
|
+
textDecoration: "underline"
|
|
4408
|
+
},
|
|
4409
|
+
children: [
|
|
4410
|
+
"Back to ",
|
|
4411
|
+
collectionSlug
|
|
4412
|
+
]
|
|
4413
|
+
}
|
|
4414
|
+
)
|
|
4415
|
+
] }) });
|
|
4416
|
+
}
|
|
4417
|
+
if (!page) {
|
|
4418
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
4419
|
+
display: "flex",
|
|
4420
|
+
height: "100vh",
|
|
4421
|
+
alignItems: "center",
|
|
4422
|
+
justifyContent: "center",
|
|
4423
|
+
backgroundColor: "#0f0f0f",
|
|
4424
|
+
color: "#fff"
|
|
4425
|
+
}, children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
|
|
4426
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#888", marginBottom: "16px" }, children: "Page not found" }),
|
|
4427
|
+
/* @__PURE__ */ jsxs(
|
|
4428
|
+
"a",
|
|
4429
|
+
{
|
|
4430
|
+
href: computedBackUrl,
|
|
4431
|
+
style: {
|
|
4432
|
+
color: "#60a5fa",
|
|
4433
|
+
textDecoration: "underline"
|
|
4434
|
+
},
|
|
4435
|
+
children: [
|
|
4436
|
+
"Back to ",
|
|
4437
|
+
collectionSlug
|
|
4438
|
+
]
|
|
4439
|
+
}
|
|
4440
|
+
)
|
|
4441
|
+
] }) });
|
|
4442
|
+
}
|
|
4443
|
+
const initialData = page.puckData || {
|
|
4444
|
+
root: {
|
|
4445
|
+
props: {
|
|
4446
|
+
title: page.title || "New Page"
|
|
4447
|
+
}
|
|
4448
|
+
},
|
|
4449
|
+
content: [],
|
|
4450
|
+
zones: {}
|
|
4451
|
+
};
|
|
4452
|
+
return /* @__PURE__ */ jsx(
|
|
4453
|
+
PuckEditor2,
|
|
4454
|
+
{
|
|
4455
|
+
pageId: page.id,
|
|
4456
|
+
initialData,
|
|
4457
|
+
config,
|
|
4458
|
+
pageTitle: page.title,
|
|
4459
|
+
pageSlug: page.slug,
|
|
4460
|
+
apiEndpoint: `${apiBasePath}/${collectionSlug}`,
|
|
4461
|
+
backUrl: computedBackUrl,
|
|
4462
|
+
previewUrl,
|
|
4463
|
+
layoutStyles,
|
|
4464
|
+
layoutKey,
|
|
4465
|
+
plugins,
|
|
4466
|
+
onSaveSuccess,
|
|
4467
|
+
onSaveError,
|
|
4468
|
+
initialStatus: page._status
|
|
4469
|
+
}
|
|
4470
|
+
);
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
// src/editor/index.ts
|
|
4474
|
+
init_HeaderActions();
|
|
4475
|
+
init_IframeWrapper();
|
|
4476
|
+
init_LoadingState();
|
|
4477
|
+
init_PreviewModal();
|
|
4478
|
+
init_VersionHistory();
|
|
4479
|
+
init_useUnsavedChanges();
|
|
4480
|
+
|
|
4481
|
+
export { HeaderActions, IframeWrapper, LoadingState, PreviewModal, PuckEditor, PuckEditorCore, PuckEditorView, VersionHistory, useUnsavedChanges };
|
|
4482
|
+
//# sourceMappingURL=index.mjs.map
|
|
4483
|
+
//# sourceMappingURL=index.mjs.map
|