@delmaredigital/payload-puck 0.2.0 → 0.3.0

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