@delmaredigital/payload-puck 0.2.0 → 0.3.0

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