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