@deweb.id/ui-kit 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -2
  3. package/css/ui-kit.css +901 -0
  4. package/dist/chunk-028rzptn.js +253 -0
  5. package/dist/chunk-028rzptn.js.map +10 -0
  6. package/dist/chunk-0x0et52k.js +82 -0
  7. package/dist/chunk-0x0et52k.js.map +10 -0
  8. package/dist/chunk-17gmkyd1.js +195 -0
  9. package/dist/chunk-17gmkyd1.js.map +10 -0
  10. package/dist/chunk-19jsevr8.js +17 -0
  11. package/dist/chunk-19jsevr8.js.map +10 -0
  12. package/dist/chunk-1t1fbbme.js +171 -0
  13. package/dist/chunk-1t1fbbme.js.map +10 -0
  14. package/dist/chunk-26ban96z.js +151 -0
  15. package/dist/chunk-26ban96z.js.map +10 -0
  16. package/dist/chunk-39hey5ns.js +2034 -0
  17. package/dist/chunk-39hey5ns.js.map +19 -0
  18. package/dist/chunk-3f0bjycv.js +481 -0
  19. package/dist/chunk-3f0bjycv.js.map +10 -0
  20. package/dist/chunk-3zpf64v4.js +108 -0
  21. package/dist/chunk-3zpf64v4.js.map +10 -0
  22. package/dist/chunk-4jrq15v9.js +919 -0
  23. package/dist/chunk-4jrq15v9.js.map +10 -0
  24. package/dist/chunk-8dacesjp.js +289 -0
  25. package/dist/chunk-8dacesjp.js.map +10 -0
  26. package/dist/chunk-8een770x.js +2546 -0
  27. package/dist/chunk-8een770x.js.map +29 -0
  28. package/dist/chunk-8jv2g2ne.js +371 -0
  29. package/dist/chunk-8jv2g2ne.js.map +10 -0
  30. package/dist/chunk-abdqb4e5.js +156 -0
  31. package/dist/chunk-abdqb4e5.js.map +10 -0
  32. package/dist/chunk-af27xdf2.js +891 -0
  33. package/dist/chunk-af27xdf2.js.map +11 -0
  34. package/dist/chunk-amsyqyh9.js +23 -0
  35. package/dist/chunk-amsyqyh9.js.map +9 -0
  36. package/dist/chunk-czbcw9e1.js +503 -0
  37. package/dist/chunk-czbcw9e1.js.map +11 -0
  38. package/dist/chunk-dar8mz91.js +73 -0
  39. package/dist/chunk-dar8mz91.js.map +10 -0
  40. package/dist/chunk-dsddmmdk.js +136 -0
  41. package/dist/chunk-dsddmmdk.js.map +10 -0
  42. package/dist/chunk-edx7tas6.js +89 -0
  43. package/dist/chunk-edx7tas6.js.map +10 -0
  44. package/dist/chunk-es4tgmvr.js +1686 -0
  45. package/dist/chunk-es4tgmvr.js.map +12 -0
  46. package/dist/chunk-f2aqj672.js +240 -0
  47. package/dist/chunk-f2aqj672.js.map +11 -0
  48. package/dist/chunk-h6k57hyd.js +146 -0
  49. package/dist/chunk-h6k57hyd.js.map +10 -0
  50. package/dist/chunk-hkx78qgj.js +1548 -0
  51. package/dist/chunk-hkx78qgj.js.map +12 -0
  52. package/dist/chunk-hq57r97c.js +770 -0
  53. package/dist/chunk-hq57r97c.js.map +11 -0
  54. package/dist/chunk-jct2e2h1.js +139 -0
  55. package/dist/chunk-jct2e2h1.js.map +10 -0
  56. package/dist/chunk-je0j5sn4.js +246 -0
  57. package/dist/chunk-je0j5sn4.js.map +10 -0
  58. package/dist/chunk-k2b698v5.js +754 -0
  59. package/dist/chunk-k2b698v5.js.map +12 -0
  60. package/dist/chunk-kv58555q.js +267 -0
  61. package/dist/chunk-kv58555q.js.map +11 -0
  62. package/dist/chunk-m0msvrte.js +15 -0
  63. package/dist/chunk-m0msvrte.js.map +10 -0
  64. package/dist/chunk-m3t14v77.js +30 -0
  65. package/dist/chunk-m3t14v77.js.map +10 -0
  66. package/dist/chunk-mctp30cp.js +1466 -0
  67. package/dist/chunk-mctp30cp.js.map +10 -0
  68. package/dist/chunk-n37qb5m5.js +1408 -0
  69. package/dist/chunk-n37qb5m5.js.map +10 -0
  70. package/dist/chunk-nhhgsdt3.js +570 -0
  71. package/dist/chunk-nhhgsdt3.js.map +11 -0
  72. package/dist/chunk-pxydj130.js +28 -0
  73. package/dist/chunk-pxydj130.js.map +10 -0
  74. package/dist/chunk-qmbwp4k7.js +3275 -0
  75. package/dist/chunk-qmbwp4k7.js.map +13 -0
  76. package/dist/chunk-qzxf0aa2.js +149 -0
  77. package/dist/chunk-qzxf0aa2.js.map +10 -0
  78. package/dist/chunk-rbjyp9ff.js +47 -0
  79. package/dist/chunk-rbjyp9ff.js.map +10 -0
  80. package/dist/chunk-rbkc50xg.js +103 -0
  81. package/dist/chunk-rbkc50xg.js.map +10 -0
  82. package/dist/chunk-rn6f0s6x.js +66 -0
  83. package/dist/chunk-rn6f0s6x.js.map +9 -0
  84. package/dist/chunk-rswzbfa2.js +422 -0
  85. package/dist/chunk-rswzbfa2.js.map +10 -0
  86. package/dist/chunk-rzns0reg.js +157 -0
  87. package/dist/chunk-rzns0reg.js.map +10 -0
  88. package/dist/chunk-s851vtje.js +90 -0
  89. package/dist/chunk-s851vtje.js.map +10 -0
  90. package/dist/chunk-vak164kx.js +15 -0
  91. package/dist/chunk-vak164kx.js.map +9 -0
  92. package/dist/chunk-vpvnvegz.js +480 -0
  93. package/dist/chunk-vpvnvegz.js.map +10 -0
  94. package/dist/chunk-x4pk7vxm.js +10 -0
  95. package/dist/chunk-x4pk7vxm.js.map +10 -0
  96. package/dist/chunk-xd2fwgek.js +53 -0
  97. package/dist/chunk-xd2fwgek.js.map +10 -0
  98. package/dist/chunk-y71rd8qf.js +499 -0
  99. package/dist/chunk-y71rd8qf.js.map +10 -0
  100. package/dist/chunk-zjmt193s.js +34 -0
  101. package/dist/chunk-zjmt193s.js.map +9 -0
  102. package/dist/components/blocks/CustomHtmlBlock.d.ts +14 -0
  103. package/dist/components/blocks/LoginFormBlock.d.ts +16 -0
  104. package/dist/components/blocks/SidebarMenuBlock.d.ts +11 -0
  105. package/dist/components/blocks/SliderBlock.d.ts +13 -0
  106. package/dist/components/code/code-editor.d.ts +58 -0
  107. package/dist/components/code/code-preview.d.ts +18 -0
  108. package/dist/components/code/index.d.ts +4 -0
  109. package/dist/components/code/validator.d.ts +10 -0
  110. package/dist/components/code/vsc-themes.d.ts +6 -0
  111. package/dist/components/dashboard/compound/context.d.ts +14 -0
  112. package/dist/components/dashboard/compound/dashboard.d.ts +14 -0
  113. package/dist/components/dashboard/compound/index.d.ts +18 -0
  114. package/dist/components/dashboard/compound/main.d.ts +25 -0
  115. package/dist/components/dashboard/compound/sidebar.d.ts +5 -0
  116. package/dist/components/dashboard/dashboard-head-info.d.ts +38 -0
  117. package/dist/components/dashboard/dashboard-head.d.ts +19 -0
  118. package/dist/components/dashboard/dataview.d.ts +19 -0
  119. package/dist/components/dashboard/detailview.d.ts +1 -0
  120. package/dist/components/dashboard/formview.d.ts +265 -0
  121. package/dist/components/dashboard/pageformview.d.ts +79 -0
  122. package/dist/components/dashboard/styling/background-color-control.d.ts +34 -0
  123. package/dist/components/dashboard/styling/background-control.d.ts +45 -0
  124. package/dist/components/dashboard/styling/border-control.d.ts +14 -0
  125. package/dist/components/dashboard/styling/color-control.d.ts +22 -0
  126. package/dist/components/dashboard/styling/index.d.ts +7 -0
  127. package/dist/components/dashboard/styling/radius-control.d.ts +15 -0
  128. package/dist/components/dashboard/styling/spacing-control.d.ts +17 -0
  129. package/dist/components/dashboard/styling/types.d.ts +50 -0
  130. package/dist/components/document/index.d.ts +25 -0
  131. package/dist/components/ecommerce/commerce-cards.d.ts +37 -0
  132. package/dist/components/effect/action-animation.d.ts +14 -0
  133. package/dist/components/effect/element-animation.d.ts +41 -0
  134. package/dist/components/effect/page-transition.d.ts +10 -0
  135. package/dist/components/layout/BlockPalette.d.ts +14 -0
  136. package/dist/components/layout/DynamicLayout.d.ts +56 -0
  137. package/dist/components/layout/GridRow.d.ts +37 -0
  138. package/dist/components/layout/LayoutBuilder.d.ts +52 -0
  139. package/dist/components/layout/WidgetFieldsForm.d.ts +15 -0
  140. package/dist/components/ui/accordion.d.ts +36 -0
  141. package/dist/components/ui/action-bar.d.ts +46 -0
  142. package/dist/components/ui/alert.d.ts +25 -0
  143. package/dist/components/ui/animated.d.ts +41 -0
  144. package/dist/components/ui/app-shell.d.ts +53 -0
  145. package/dist/components/ui/avatar.d.ts +18 -0
  146. package/dist/components/ui/badge.d.ts +15 -0
  147. package/dist/components/ui/breadcrumb.d.ts +20 -0
  148. package/dist/components/ui/button-icon.d.ts +9 -0
  149. package/dist/components/ui/button.d.ts +37 -0
  150. package/dist/components/ui/calendar.d.ts +14 -0
  151. package/dist/components/ui/card-skeleton-aware.d.ts +2 -0
  152. package/dist/components/ui/card.d.ts +36 -0
  153. package/dist/components/ui/chart.d.ts +75 -0
  154. package/dist/components/ui/chat-bubble.d.ts +74 -0
  155. package/dist/components/ui/code.d.ts +85 -0
  156. package/dist/components/ui/code.js +21 -0
  157. package/dist/components/ui/code.js.map +9 -0
  158. package/dist/components/ui/collapsible.d.ts +25 -0
  159. package/dist/components/ui/control-group.d.ts +39 -0
  160. package/dist/components/ui/dashboard-grid/DashboardDropSlot.d.ts +10 -0
  161. package/dist/components/ui/dashboard-grid/DashboardGrid.d.ts +5 -0
  162. package/dist/components/ui/dashboard-grid/DashboardWidgetCard.d.ts +43 -0
  163. package/dist/components/ui/dashboard-grid/useDashboardDnd.d.ts +36 -0
  164. package/dist/components/ui/data-empty.d.ts +24 -0
  165. package/dist/components/ui/data-list.d.ts +16 -0
  166. package/dist/components/ui/data-table.d.ts +48 -0
  167. package/dist/components/ui/data-view/DataView.d.ts +46 -0
  168. package/dist/components/ui/data-view/DataViewCalendar.d.ts +18 -0
  169. package/dist/components/ui/data-view/DataViewContent.d.ts +5 -0
  170. package/dist/components/ui/data-view/DataViewFilter.d.ts +8 -0
  171. package/dist/components/ui/data-view/DataViewGrid.d.ts +32 -0
  172. package/dist/components/ui/data-view/DataViewHeader.d.ts +22 -0
  173. package/dist/components/ui/data-view/DataViewKanban.d.ts +16 -0
  174. package/dist/components/ui/data-view/DataViewPivot.d.ts +15 -0
  175. package/dist/components/ui/data-view/DataViewTable.d.ts +33 -0
  176. package/dist/components/ui/data-view/index.d.ts +9 -0
  177. package/dist/components/ui/date-time-picker.d.ts +205 -0
  178. package/dist/components/ui/drawer.d.ts +71 -0
  179. package/dist/components/ui/dropdown-animation.d.ts +7 -0
  180. package/dist/components/ui/dropdown.d.ts +71 -0
  181. package/dist/components/ui/error-state.d.ts +15 -0
  182. package/dist/components/ui/filter-bar.d.ts +50 -0
  183. package/dist/components/ui/filter-bar.js +19 -0
  184. package/dist/components/ui/filter-bar.js.map +9 -0
  185. package/dist/components/ui/font.d.ts +24 -0
  186. package/dist/components/ui/form-advanced.d.ts +198 -0
  187. package/dist/components/ui/form-compound.d.ts +58 -0
  188. package/dist/components/ui/form-context.d.ts +19 -0
  189. package/dist/components/ui/form.d.ts +451 -0
  190. package/dist/components/ui/format-currency.d.ts +10 -0
  191. package/dist/components/ui/format-date.d.ts +28 -0
  192. package/dist/components/ui/format-number.d.ts +22 -0
  193. package/dist/components/ui/format-time.d.ts +5 -0
  194. package/dist/components/ui/grid.d.ts +30 -0
  195. package/dist/components/ui/heading.d.ts +9 -0
  196. package/dist/components/ui/indicator.d.ts +17 -0
  197. package/dist/components/ui/initial-icon.d.ts +11 -0
  198. package/dist/components/ui/input-code.d.ts +27 -0
  199. package/dist/components/ui/input-grid.d.ts +54 -0
  200. package/dist/components/ui/input.d.ts +37 -0
  201. package/dist/components/ui/invoice-blocks.d.ts +124 -0
  202. package/dist/components/ui/invoice-document.d.ts +63 -0
  203. package/dist/components/ui/kanban.d.ts +16 -0
  204. package/dist/components/ui/label.d.ts +4 -0
  205. package/dist/components/ui/lazy-load.d.ts +13 -0
  206. package/dist/components/ui/lightbox.d.ts +15 -0
  207. package/dist/components/ui/list.d.ts +33 -0
  208. package/dist/components/ui/loading.d.ts +79 -0
  209. package/dist/components/ui/media-card.d.ts +50 -0
  210. package/dist/components/ui/media-player.d.ts +47 -0
  211. package/dist/components/ui/menu.d.ts +24 -0
  212. package/dist/components/ui/modal.d.ts +233 -0
  213. package/dist/components/ui/page.d.ts +51 -0
  214. package/dist/components/ui/pagination.d.ts +16 -0
  215. package/dist/components/ui/print.d.ts +173 -0
  216. package/dist/components/ui/project-card.d.ts +43 -0
  217. package/dist/components/ui/radius-control.d.ts +36 -0
  218. package/dist/components/ui/rich-text-editor.d.ts +32 -0
  219. package/dist/components/ui/select-card.d.ts +56 -0
  220. package/dist/components/ui/sidebar-logo.d.ts +11 -0
  221. package/dist/components/ui/sidebar-menu.d.ts +82 -0
  222. package/dist/components/ui/sidebar-search.d.ts +7 -0
  223. package/dist/components/ui/skeletons.d.ts +46 -0
  224. package/dist/components/ui/surface.d.ts +13 -0
  225. package/dist/components/ui/table-pivot.d.ts +10 -0
  226. package/dist/components/ui/table.d.ts +258 -0
  227. package/dist/components/ui/tabs.d.ts +79 -0
  228. package/dist/components/ui/task-board.d.ts +29 -0
  229. package/dist/components/ui/terminal.d.ts +51 -0
  230. package/dist/components/ui/text-sensor.d.ts +9 -0
  231. package/dist/components/ui/theme-styler.d.ts +3 -0
  232. package/dist/components/ui/theme-toggle.d.ts +23 -0
  233. package/dist/components/ui/tooltip.d.ts +11 -0
  234. package/dist/components/website/account-banner.d.ts +11 -0
  235. package/dist/components/website/account-layout.d.ts +20 -0
  236. package/dist/components/website/account.d.ts +46 -0
  237. package/dist/components/website/ambient.d.ts +19 -0
  238. package/dist/components/website/auth.d.ts +35 -0
  239. package/dist/components/website/blog/blog-list-custom.d.ts +3 -0
  240. package/dist/components/website/blog/blog-list-gallery.d.ts +2 -0
  241. package/dist/components/website/blog/blog-list-grid.d.ts +2 -0
  242. package/dist/components/website/blog/blog-list-list.d.ts +2 -0
  243. package/dist/components/website/blog.d.ts +50 -0
  244. package/dist/components/website/carousel.d.ts +58 -0
  245. package/dist/components/website/cart.d.ts +31 -0
  246. package/dist/components/website/catalogue-view.d.ts +81 -0
  247. package/dist/components/website/catalogue.d.ts +96 -0
  248. package/dist/components/website/comment.d.ts +52 -0
  249. package/dist/components/website/eclipse.d.ts +15 -0
  250. package/dist/components/website/feature-grid.d.ts +58 -0
  251. package/dist/components/website/filter.d.ts +109 -0
  252. package/dist/components/website/hero.d.ts +89 -0
  253. package/dist/components/website/localize.d.ts +36 -0
  254. package/dist/components/website/logo.d.ts +24 -0
  255. package/dist/components/website/megamenu.d.ts +10 -0
  256. package/dist/components/website/navbar.d.ts +42 -0
  257. package/dist/components/website/notification.d.ts +58 -0
  258. package/dist/components/website/price.d.ts +26 -0
  259. package/dist/components/website/pricing.d.ts +21 -0
  260. package/dist/components/website/product.d.ts +32 -0
  261. package/dist/components/website/rating.d.ts +36 -0
  262. package/dist/components/website/review-form.d.ts +54 -0
  263. package/dist/components/website/reviews.d.ts +119 -0
  264. package/dist/components/website/search.d.ts +30 -0
  265. package/dist/entries/accordion.d.ts +1 -0
  266. package/dist/entries/accordion.js +9 -0
  267. package/dist/entries/accordion.js.map +9 -0
  268. package/dist/entries/alert.d.ts +1 -0
  269. package/dist/entries/alert.js +10 -0
  270. package/dist/entries/alert.js.map +9 -0
  271. package/dist/entries/badge.d.ts +1 -0
  272. package/dist/entries/badge.js +11 -0
  273. package/dist/entries/badge.js.map +9 -0
  274. package/dist/entries/breadcrumb.d.ts +1 -0
  275. package/dist/entries/breadcrumb.js +10 -0
  276. package/dist/entries/breadcrumb.js.map +9 -0
  277. package/dist/entries/button.d.ts +1 -0
  278. package/dist/entries/button.js +12 -0
  279. package/dist/entries/button.js.map +9 -0
  280. package/dist/entries/card.d.ts +1 -0
  281. package/dist/entries/card.js +25 -0
  282. package/dist/entries/card.js.map +9 -0
  283. package/dist/entries/chart.d.ts +1 -0
  284. package/dist/entries/chart.js +130 -0
  285. package/dist/entries/chart.js.map +10 -0
  286. package/dist/entries/components.d.ts +53 -0
  287. package/dist/entries/components.js +643 -0
  288. package/dist/entries/components.js.map +9 -0
  289. package/dist/entries/dashboard/dataview.d.ts +1 -0
  290. package/dist/entries/dashboard/dataview.js +82 -0
  291. package/dist/entries/dashboard/dataview.js.map +10 -0
  292. package/dist/entries/dashboard/pageformview.d.ts +1 -0
  293. package/dist/entries/dashboard/pageformview.js +34 -0
  294. package/dist/entries/dashboard/pageformview.js.map +9 -0
  295. package/dist/entries/data-table.d.ts +1 -0
  296. package/dist/entries/data-table.js +22 -0
  297. package/dist/entries/data-table.js.map +9 -0
  298. package/dist/entries/date-time-picker.d.ts +1 -0
  299. package/dist/entries/date-time-picker.js +28 -0
  300. package/dist/entries/date-time-picker.js.map +9 -0
  301. package/dist/entries/document.d.ts +1 -0
  302. package/dist/entries/document.js +69 -0
  303. package/dist/entries/document.js.map +10 -0
  304. package/dist/entries/drawer.d.ts +1 -0
  305. package/dist/entries/drawer.js +20 -0
  306. package/dist/entries/drawer.js.map +9 -0
  307. package/dist/entries/dropdown.d.ts +1 -0
  308. package/dist/entries/dropdown.js +29 -0
  309. package/dist/entries/dropdown.js.map +9 -0
  310. package/dist/entries/error-state.d.ts +1 -0
  311. package/dist/entries/error-state.js +14 -0
  312. package/dist/entries/error-state.js.map +9 -0
  313. package/dist/entries/favorite-button.d.ts +1 -0
  314. package/dist/entries/favorite-button.js +7 -0
  315. package/dist/entries/favorite-button.js.map +10 -0
  316. package/dist/entries/font.d.ts +1 -0
  317. package/dist/entries/font.js +10 -0
  318. package/dist/entries/font.js.map +9 -0
  319. package/dist/entries/form-advanced.d.ts +1 -0
  320. package/dist/entries/form-advanced.js +39 -0
  321. package/dist/entries/form-advanced.js.map +9 -0
  322. package/dist/entries/form.d.ts +1 -0
  323. package/dist/entries/form.js +74 -0
  324. package/dist/entries/form.js.map +9 -0
  325. package/dist/entries/heading.d.ts +1 -0
  326. package/dist/entries/heading.js +8 -0
  327. package/dist/entries/heading.js.map +9 -0
  328. package/dist/entries/input.d.ts +1 -0
  329. package/dist/entries/input.js +11 -0
  330. package/dist/entries/input.js.map +9 -0
  331. package/dist/entries/layout.d.ts +4 -0
  332. package/dist/entries/layout.js +101 -0
  333. package/dist/entries/layout.js.map +9 -0
  334. package/dist/entries/lazy-load.d.ts +1 -0
  335. package/dist/entries/lazy-load.js +9 -0
  336. package/dist/entries/lazy-load.js.map +9 -0
  337. package/dist/entries/list.d.ts +1 -0
  338. package/dist/entries/list.js +13 -0
  339. package/dist/entries/list.js.map +9 -0
  340. package/dist/entries/loading.d.ts +1 -0
  341. package/dist/entries/loading.js +18 -0
  342. package/dist/entries/loading.js.map +9 -0
  343. package/dist/entries/menu.d.ts +1 -0
  344. package/dist/entries/menu.js +17 -0
  345. package/dist/entries/menu.js.map +9 -0
  346. package/dist/entries/modal.d.ts +1 -0
  347. package/dist/entries/modal.js +33 -0
  348. package/dist/entries/modal.js.map +9 -0
  349. package/dist/entries/product.d.ts +2 -0
  350. package/dist/entries/product.js +10 -0
  351. package/dist/entries/product.js.map +9 -0
  352. package/dist/entries/select-card.d.ts +1 -0
  353. package/dist/entries/select-card.js +13 -0
  354. package/dist/entries/select-card.js.map +9 -0
  355. package/dist/entries/skeletons.d.ts +1 -0
  356. package/dist/entries/skeletons.js +35 -0
  357. package/dist/entries/skeletons.js.map +9 -0
  358. package/dist/entries/surface.d.ts +1 -0
  359. package/dist/entries/surface.js +10 -0
  360. package/dist/entries/surface.js.map +9 -0
  361. package/dist/entries/table.d.ts +1 -0
  362. package/dist/entries/table.js +65 -0
  363. package/dist/entries/table.js.map +9 -0
  364. package/dist/entries/tabs.d.ts +1 -0
  365. package/dist/entries/tabs.js +20 -0
  366. package/dist/entries/tabs.js.map +9 -0
  367. package/dist/entries/theme-styler.d.ts +1 -0
  368. package/dist/entries/theme-styler.js +26 -0
  369. package/dist/entries/theme-styler.js.map +9 -0
  370. package/dist/entries/toast.d.ts +1 -0
  371. package/dist/entries/toast.js +13 -0
  372. package/dist/entries/toast.js.map +9 -0
  373. package/dist/index.d.ts +163 -0
  374. package/dist/index.js +19864 -0
  375. package/dist/index.js.map +92 -0
  376. package/dist/lib/color/className.d.ts +14 -0
  377. package/dist/lib/color/config.d.ts +82 -0
  378. package/dist/lib/color/engine.d.ts +221 -0
  379. package/dist/lib/color/generator.d.ts +45 -0
  380. package/dist/lib/color/index.d.ts +5 -0
  381. package/dist/lib/color/safelist.d.ts +1 -0
  382. package/dist/lib/color/types.d.ts +12 -0
  383. package/dist/lib/font/config.d.ts +13 -0
  384. package/dist/lib/font/engine.d.ts +77 -0
  385. package/dist/lib/font/index.d.ts +3 -0
  386. package/dist/lib/font/types.d.ts +27 -0
  387. package/dist/lib/icon/config.d.ts +37 -0
  388. package/dist/lib/icon/engine.d.ts +84 -0
  389. package/dist/lib/icon/index.d.ts +3 -0
  390. package/dist/lib/icon/presets.d.ts +71 -0
  391. package/dist/lib/layout/config.d.ts +7 -0
  392. package/dist/lib/layout/engine.d.ts +224 -0
  393. package/dist/lib/layout/types.d.ts +151 -0
  394. package/dist/lib/layout/useActiveBreakpoint.d.ts +14 -0
  395. package/dist/lib/layout/useBlockDrag.d.ts +47 -0
  396. package/dist/lib/layout/useSectionDrag.d.ts +30 -0
  397. package/dist/lib/layout/useSpanResize.d.ts +31 -0
  398. package/dist/lib/localize/data.d.ts +9 -0
  399. package/dist/lib/product-utils.d.ts +7 -0
  400. package/dist/lib/sanitize/sanitizeHtml.d.ts +52 -0
  401. package/dist/lib/theme/motion.d.ts +27 -0
  402. package/dist/lib/theme/motion.js +12 -0
  403. package/dist/lib/theme/motion.js.map +9 -0
  404. package/dist/lib/theme/types.d.ts +133 -0
  405. package/dist/lib/useUndoRedo.d.ts +21 -0
  406. package/dist/lib/utils.d.ts +2 -0
  407. package/dist/types/product.d.ts +27 -0
  408. package/package.json +442 -4
@@ -0,0 +1,2034 @@
1
+ import {
2
+ Button2
3
+ } from "./chunk-kv58555q.js";
4
+ import {
5
+ Icon2
6
+ } from "./chunk-k2b698v5.js";
7
+ import {
8
+ Input2
9
+ } from "./chunk-nhhgsdt3.js";
10
+ import {
11
+ ButtonIcon2
12
+ } from "./chunk-m3t14v77.js";
13
+ import {
14
+ Tooltip2
15
+ } from "./chunk-4jrq15v9.js";
16
+ import {
17
+ Select2,
18
+ Checkbox2,
19
+ SelectGroup2,
20
+ InputColor2
21
+ } from "./chunk-qmbwp4k7.js";
22
+ import {
23
+ Badge2
24
+ } from "./chunk-dsddmmdk.js";
25
+ import {
26
+ getLayoutSettings2,
27
+ getBlockComponent2,
28
+ getBlockDefaultProps2,
29
+ getBlockFields2,
30
+ getBlocks2,
31
+ resolveResponsive2,
32
+ resolveSectionZone2,
33
+ BREAKPOINT_PX2,
34
+ getColSpanClass2,
35
+ gridClassNames2,
36
+ sectionVisibilityClass2,
37
+ setLayout2,
38
+ getLayout2,
39
+ createSection2,
40
+ sectionHtmlId2,
41
+ registerLayoutPreset2,
42
+ getLayoutPresets2,
43
+ exportLayoutConfig2,
44
+ saveLayoutToLocalStorage2,
45
+ restoreLayoutFromLocalStorage2
46
+ } from "./chunk-hq57r97c.js";
47
+
48
+ // src/components/layout/DynamicLayout.tsx
49
+ import { createContext, useContext, useMemo, useState } from "react";
50
+ import { Menu } from "lucide-react";
51
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
52
+ var LayoutContext2 = createContext(null);
53
+ function useLayoutContext2() {
54
+ return useContext(LayoutContext2);
55
+ }
56
+ function DefaultOffCanvasTrigger({ targetId }) {
57
+ const ctx = useLayoutContext2();
58
+ const effectiveTargetId = targetId || "default-drawer";
59
+ return /* @__PURE__ */ jsxDEV("button", {
60
+ onClick: () => ctx?.toggleOffCanvas(effectiveTargetId),
61
+ title: "Toggle Off-Canvas",
62
+ className: "bg-card border border-border text-foreground hover:bg-muted rounded-md shadow-xs transition-colors flex items-center justify-center w-full h-full min-h-[36px] overflow-hidden",
63
+ children: /* @__PURE__ */ jsxDEV(Menu, {
64
+ className: "w-4 h-4 shrink-0"
65
+ }, undefined, false, undefined, this)
66
+ }, undefined, false, undefined, this);
67
+ }
68
+ var warnedBlocks = new Set;
69
+ function renderItem(item, blockDef) {
70
+ if (!blockDef) {
71
+ return /* @__PURE__ */ jsxDEV("div", {
72
+ className: "p-4 bg-destructive/10 border border-destructive/20 rounded-xl shadow-xs text-center text-sm font-medium text-destructive w-full",
73
+ children: "Block Not Found"
74
+ }, undefined, false, undefined, this);
75
+ }
76
+ if (blockDef.type === "component") {
77
+ if (blockDef.componentKey === "OffCanvasTriggerBlock") {
78
+ return /* @__PURE__ */ jsxDEV(DefaultOffCanvasTrigger, {
79
+ targetId: item.settings?.targetSectionId
80
+ }, undefined, false, undefined, this);
81
+ }
82
+ const Component = blockDef.componentKey ? getBlockComponent2(blockDef.componentKey) : undefined;
83
+ if (Component) {
84
+ const defaultProps = blockDef.componentKey ? getBlockDefaultProps2(blockDef.componentKey) : undefined;
85
+ return /* @__PURE__ */ jsxDEV(Component, {
86
+ ...defaultProps,
87
+ ...item.settings
88
+ }, undefined, false, undefined, this);
89
+ }
90
+ if (typeof console !== "undefined" && blockDef.componentKey && !warnedBlocks.has(blockDef.componentKey)) {
91
+ console.warn(`[Deweb UI] Block "${blockDef.name}" (componentKey: "${blockDef.componentKey}") tidak ditemukan di block registry -- panggil setBlockComponents() untuk mendaftarkannya.`);
92
+ warnedBlocks.add(blockDef.componentKey);
93
+ }
94
+ return /* @__PURE__ */ jsxDEV("div", {
95
+ className: "p-4 bg-card border border-border rounded-xl shadow-xs text-center flex flex-col gap-2.5 w-full h-full justify-center items-center",
96
+ children: [
97
+ /* @__PURE__ */ jsxDEV("span", {
98
+ className: "text-sm font-semibold text-foreground tracking-tight",
99
+ children: blockDef.name
100
+ }, undefined, false, undefined, this),
101
+ blockDef.components && blockDef.components.length > 0 && /* @__PURE__ */ jsxDEV("div", {
102
+ className: "flex flex-wrap gap-1.5 justify-center",
103
+ children: blockDef.components.map((comp, idx) => /* @__PURE__ */ jsxDEV(Badge2, {
104
+ variant: "soft",
105
+ color: "primary",
106
+ size: "xs",
107
+ children: comp
108
+ }, idx, false, undefined, this))
109
+ }, undefined, false, undefined, this)
110
+ ]
111
+ }, undefined, true, undefined, this);
112
+ }
113
+ return /* @__PURE__ */ jsxDEV("div", {
114
+ className: "w-full h-full",
115
+ dangerouslySetInnerHTML: { __html: blockDef.html ?? "" }
116
+ }, undefined, false, undefined, this);
117
+ }
118
+ function ItemGrid({ items, blocks, resolveBp }) {
119
+ return /* @__PURE__ */ jsxDEV("div", {
120
+ className: "grid grid-cols-12 gap-4 min-h-[60px]",
121
+ children: items.map((item) => {
122
+ const blockDef = blocks[item.blockId];
123
+ return /* @__PURE__ */ jsxDEV("div", {
124
+ className: `${gridClassNames2(item.grid, resolveBp)} flex`,
125
+ children: renderItem(item, blockDef)
126
+ }, item.id, false, undefined, this);
127
+ })
128
+ }, undefined, false, undefined, this);
129
+ }
130
+ function ContainerBox2({ container, backgroundColor, id, resolveBp = "base", visibilityClassName, children }) {
131
+ const settings = getLayoutSettings2();
132
+ const setting = resolveResponsive2(container, resolveBp);
133
+ const capStyle = (widthPx) => ({
134
+ maxWidth: widthPx,
135
+ marginLeft: "auto",
136
+ marginRight: "auto",
137
+ paddingLeft: `${settings.contentEdgeSpacing}%`,
138
+ paddingRight: `${settings.contentEdgeSpacing}%`
139
+ });
140
+ const outerStyle = { backgroundColor };
141
+ const outerClassName = `w-full py-4 relative ${visibilityClassName ?? ""}`.trim();
142
+ if (setting.type === "wrapper") {
143
+ return /* @__PURE__ */ jsxDEV("div", {
144
+ id,
145
+ className: outerClassName,
146
+ style: { ...capStyle(settings.maxSiteWidth), ...outerStyle },
147
+ children
148
+ }, undefined, false, undefined, this);
149
+ }
150
+ if (setting.type === "full-width-wrapper") {
151
+ return /* @__PURE__ */ jsxDEV("div", {
152
+ id,
153
+ className: outerClassName,
154
+ style: outerStyle,
155
+ children: /* @__PURE__ */ jsxDEV("div", {
156
+ style: capStyle(settings.maxSiteWidth),
157
+ children
158
+ }, undefined, false, undefined, this)
159
+ }, undefined, false, undefined, this);
160
+ }
161
+ if (setting.type === "custom") {
162
+ return /* @__PURE__ */ jsxDEV("div", {
163
+ id,
164
+ className: outerClassName,
165
+ style: outerStyle,
166
+ children: /* @__PURE__ */ jsxDEV("div", {
167
+ style: capStyle(setting.customWidthPx ?? settings.maxSiteWidth),
168
+ children
169
+ }, undefined, false, undefined, this)
170
+ }, undefined, false, undefined, this);
171
+ }
172
+ return /* @__PURE__ */ jsxDEV("div", {
173
+ id,
174
+ className: outerClassName,
175
+ style: outerStyle,
176
+ children
177
+ }, undefined, false, undefined, this);
178
+ }
179
+ function ZoneRenderer({ sections, zoneName, blocks, resolveBp }) {
180
+ const isEmpty = sections.length === 0;
181
+ return /* @__PURE__ */ jsxDEV("div", {
182
+ className: "relative",
183
+ children: [
184
+ sections.map((section) => renderSection2(section, blocks, resolveBp)),
185
+ isEmpty && /* @__PURE__ */ jsxDEV("div", {
186
+ className: "w-full py-4",
187
+ children: /* @__PURE__ */ jsxDEV("div", {
188
+ className: "col-span-12 flex items-center justify-center p-6 border-2 border-dashed border-border/60 rounded-xs bg-muted/20",
189
+ children: /* @__PURE__ */ jsxDEV("span", {
190
+ className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground",
191
+ children: [
192
+ "Empty ",
193
+ zoneName,
194
+ " Zone"
195
+ ]
196
+ }, undefined, true, undefined, this)
197
+ }, undefined, false, undefined, this)
198
+ }, undefined, false, undefined, this)
199
+ ]
200
+ }, undefined, true, undefined, this);
201
+ }
202
+ function renderSection2(section, blocks, resolveBp) {
203
+ return /* @__PURE__ */ jsxDEV(ContainerBox2, {
204
+ container: section.container,
205
+ backgroundColor: section.backgroundColor,
206
+ id: sectionHtmlId2(section),
207
+ resolveBp,
208
+ visibilityClassName: sectionVisibilityClass2(section.visible, resolveBp),
209
+ children: /* @__PURE__ */ jsxDEV(ItemGrid, {
210
+ items: section.items,
211
+ blocks,
212
+ resolveBp
213
+ }, undefined, false, undefined, this)
214
+ }, section.id, false, undefined, this);
215
+ }
216
+ var ZONE_KEYS = ["top", "main", "bottom", "offcanvas"];
217
+ function DynamicLayout2({ blocks, schema, forceBreakpoint }) {
218
+ const detectedBp = useActiveBreakpoint2();
219
+ const activeBp = forceBreakpoint ?? detectedBp;
220
+ const [openOffCanvasIds, setOpenOffCanvasIds] = useState(new Set);
221
+ const ctxValue = useMemo(() => ({
222
+ openOffCanvasIds,
223
+ toggleOffCanvas: (targetId) => setOpenOffCanvasIds((prev) => {
224
+ const next = new Set(prev);
225
+ if (next.has(targetId))
226
+ next.delete(targetId);
227
+ else
228
+ next.add(targetId);
229
+ return next;
230
+ }),
231
+ closeOffCanvas: () => setOpenOffCanvasIds(new Set)
232
+ }), [openOffCanvasIds]);
233
+ const resolvedByZone = { top: [], main: [], bottom: [], offcanvas: [] };
234
+ for (const homeZoneKey of ZONE_KEYS) {
235
+ const zone = schema[homeZoneKey];
236
+ if (!zone)
237
+ continue;
238
+ for (const section of zone.sections) {
239
+ const targetZone = resolveSectionZone2(section, homeZoneKey, activeBp);
240
+ resolvedByZone[targetZone].push(section);
241
+ }
242
+ }
243
+ return /* @__PURE__ */ jsxDEV(LayoutContext2.Provider, {
244
+ value: ctxValue,
245
+ children: /* @__PURE__ */ jsxDEV("div", {
246
+ className: "w-full h-full min-h-[100%] bg-background flex flex-col overflow-hidden relative",
247
+ children: [
248
+ schema.top && /* @__PURE__ */ jsxDEV("header", {
249
+ className: "w-full border-b border-border bg-background",
250
+ children: /* @__PURE__ */ jsxDEV(ZoneRenderer, {
251
+ sections: resolvedByZone.top,
252
+ zoneName: "Top",
253
+ blocks,
254
+ resolveBp: activeBp
255
+ }, undefined, false, undefined, this)
256
+ }, undefined, false, undefined, this),
257
+ /* @__PURE__ */ jsxDEV("main", {
258
+ className: "w-full",
259
+ children: /* @__PURE__ */ jsxDEV(ZoneRenderer, {
260
+ sections: resolvedByZone.main,
261
+ zoneName: "Main",
262
+ blocks,
263
+ resolveBp: activeBp
264
+ }, undefined, false, undefined, this)
265
+ }, undefined, false, undefined, this),
266
+ schema.bottom && /* @__PURE__ */ jsxDEV("footer", {
267
+ className: "w-full border-t border-border bg-muted/30",
268
+ children: /* @__PURE__ */ jsxDEV(ZoneRenderer, {
269
+ sections: resolvedByZone.bottom,
270
+ zoneName: "Bottom",
271
+ blocks,
272
+ resolveBp: activeBp
273
+ }, undefined, false, undefined, this)
274
+ }, undefined, false, undefined, this),
275
+ resolvedByZone.offcanvas.map((section, index) => /* @__PURE__ */ jsxDEV(OffCanvasDrawer, {
276
+ section,
277
+ isFirst: index === 0,
278
+ blocks,
279
+ resolveBp: activeBp
280
+ }, section.id, false, undefined, this))
281
+ ]
282
+ }, undefined, true, undefined, this)
283
+ }, undefined, false, undefined, this);
284
+ }
285
+ var OFFCANVAS_POSITION_CLASS = {
286
+ left: "left-0 top-0 bottom-0 w-64 -translate-x-full border-r",
287
+ right: "right-0 top-0 bottom-0 w-64 translate-x-full border-l",
288
+ top: "left-0 right-0 top-0 h-64 -translate-y-full border-b",
289
+ bottom: "left-0 right-0 bottom-0 h-64 translate-y-full border-t"
290
+ };
291
+ function OffCanvasDrawer({ section, isFirst, blocks, resolveBp }) {
292
+ const position = section.offcanvasPosition ?? "left";
293
+ const ctx = useLayoutContext2();
294
+ const isOpen = ctx?.openOffCanvasIds.has(section.id) || isFirst && ctx?.openOffCanvasIds.has("default-drawer") || ctx?.openOffCanvasIds.has(`${position}-drawer`) || false;
295
+ let transformClass = OFFCANVAS_POSITION_CLASS[position];
296
+ if (isOpen) {
297
+ if (position === "left" || position === "right")
298
+ transformClass = transformClass.replace(/-?translate-x-full/, "translate-x-0");
299
+ if (position === "top" || position === "bottom")
300
+ transformClass = transformClass.replace(/-?translate-y-full/, "translate-y-0");
301
+ }
302
+ return /* @__PURE__ */ jsxDEV(Fragment, {
303
+ children: [
304
+ isOpen && /* @__PURE__ */ jsxDEV("div", {
305
+ className: "absolute inset-0 bg-black/50 z-40 transition-opacity",
306
+ onClick: () => ctx?.closeOffCanvas()
307
+ }, undefined, false, undefined, this),
308
+ /* @__PURE__ */ jsxDEV("div", {
309
+ id: sectionHtmlId2(section),
310
+ className: `absolute bg-card border-border z-50 transform transition-transform overflow-y-auto ${isOpen ? "shadow-2xl opacity-100 visible" : "shadow-none opacity-0 invisible pointer-events-none"} ${transformClass}`,
311
+ style: { backgroundColor: section.backgroundColor },
312
+ children: [
313
+ /* @__PURE__ */ jsxDEV("div", {
314
+ className: "p-4 flex justify-between items-center border-b border-border",
315
+ children: [
316
+ /* @__PURE__ */ jsxDEV("span", {
317
+ className: "font-semibold text-foreground",
318
+ children: section.name || "Off-Canvas Menu"
319
+ }, undefined, false, undefined, this),
320
+ /* @__PURE__ */ jsxDEV("button", {
321
+ onClick: () => ctx?.closeOffCanvas(),
322
+ className: "p-1.5 rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",
323
+ children: /* @__PURE__ */ jsxDEV("svg", {
324
+ width: "16",
325
+ height: "16",
326
+ viewBox: "0 0 24 24",
327
+ fill: "none",
328
+ stroke: "currentColor",
329
+ strokeWidth: "2",
330
+ strokeLinecap: "round",
331
+ strokeLinejoin: "round",
332
+ children: [
333
+ /* @__PURE__ */ jsxDEV("path", {
334
+ d: "M18 6 6 18"
335
+ }, undefined, false, undefined, this),
336
+ /* @__PURE__ */ jsxDEV("path", {
337
+ d: "m6 6 12 12"
338
+ }, undefined, false, undefined, this)
339
+ ]
340
+ }, undefined, true, undefined, this)
341
+ }, undefined, false, undefined, this)
342
+ ]
343
+ }, undefined, true, undefined, this),
344
+ /* @__PURE__ */ jsxDEV("div", {
345
+ className: "p-4",
346
+ children: /* @__PURE__ */ jsxDEV(ItemGrid, {
347
+ items: section.items,
348
+ blocks,
349
+ resolveBp
350
+ }, undefined, false, undefined, this)
351
+ }, undefined, false, undefined, this)
352
+ ]
353
+ }, undefined, true, undefined, this)
354
+ ]
355
+ }, undefined, true, undefined, this);
356
+ }
357
+
358
+ // src/components/layout/BlockPalette.tsx
359
+ import { GripVertical, Search } from "lucide-react";
360
+ import { useState as useState2 } from "react";
361
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
362
+ function BlockPalette2({ blocks, onStartPlaceDrag, placingBlockId }) {
363
+ const [searchQuery, setSearchQuery] = useState2("");
364
+ const blockKeys = Object.keys(blocks).filter((key) => blocks[key].name.toLowerCase().includes(searchQuery.toLowerCase()));
365
+ return /* @__PURE__ */ jsxDEV2("div", {
366
+ className: "space-y-3",
367
+ children: [
368
+ /* @__PURE__ */ jsxDEV2("div", {
369
+ className: "flex flex-col gap-2",
370
+ children: [
371
+ /* @__PURE__ */ jsxDEV2("span", {
372
+ className: "font-semibold text-[color:var(--color-text-color)] uppercase tracking-wider text-sm",
373
+ children: "Blocks Palette"
374
+ }, undefined, false, undefined, this),
375
+ /* @__PURE__ */ jsxDEV2("div", {
376
+ className: "relative",
377
+ children: [
378
+ /* @__PURE__ */ jsxDEV2(Search, {
379
+ className: "absolute left-2.5 top-1/2 -translate-y-1/2 text-[color:var(--color-text-color)]",
380
+ size: 14
381
+ }, undefined, false, undefined, this),
382
+ /* @__PURE__ */ jsxDEV2(Input2, {
383
+ value: searchQuery,
384
+ onChange: (e) => setSearchQuery(e.target.value),
385
+ placeholder: "Cari block...",
386
+ className: "pl-8 h-8 text-sm"
387
+ }, undefined, false, undefined, this)
388
+ ]
389
+ }, undefined, true, undefined, this)
390
+ ]
391
+ }, undefined, true, undefined, this),
392
+ /* @__PURE__ */ jsxDEV2("div", {
393
+ className: "flex lg:flex-col gap-2 overflow-x-auto lg:overflow-x-visible lg:overflow-y-auto lg:max-h-[calc(100vh-120px)] pb-2 pr-2 custom-scrollbar",
394
+ children: [
395
+ blockKeys.map((key) => {
396
+ const block = blocks[key];
397
+ const isPlacing = placingBlockId === key;
398
+ return /* @__PURE__ */ jsxDEV2("div", {
399
+ "data-palette-card": true,
400
+ className: `relative shrink-0 w-36 lg:w-full rounded-lg border border-[color:var(--color-border)] bg-[var(--color-background)] p-2 flex items-center justify-between gap-1.5 shadow-sm group transition-all duration-200 hover:border-indigo-400 ${isPlacing ? "opacity-30 scale-95 z-10" : "opacity-100 scale-100 z-0"}`,
401
+ children: [
402
+ /* @__PURE__ */ jsxDEV2("div", {
403
+ onPointerDown: onStartPlaceDrag(key),
404
+ className: "absolute inset-0 cursor-grab active:cursor-grabbing touch-none select-none z-10"
405
+ }, undefined, false, undefined, this),
406
+ /* @__PURE__ */ jsxDEV2("div", {
407
+ className: "flex items-center gap-1.5 overflow-hidden",
408
+ children: [
409
+ /* @__PURE__ */ jsxDEV2(GripVertical, {
410
+ size: 14,
411
+ className: "text-[color:var(--color-text-color)] group-hover:text-[color:var(--color-foreground)] shrink-0"
412
+ }, undefined, false, undefined, this),
413
+ /* @__PURE__ */ jsxDEV2("span", {
414
+ className: "text-xs font-semibold text-[color:var(--color-foreground)] truncate",
415
+ children: block.name
416
+ }, undefined, false, undefined, this)
417
+ ]
418
+ }, undefined, true, undefined, this),
419
+ /* @__PURE__ */ jsxDEV2("span", {
420
+ className: "text-[9px] font-semibold uppercase text-[color:var(--color-text-color)] shrink-0",
421
+ children: block.type === "component" ? "Cmp" : "HTML"
422
+ }, undefined, false, undefined, this)
423
+ ]
424
+ }, key, true, undefined, this);
425
+ }),
426
+ blockKeys.length === 0 && /* @__PURE__ */ jsxDEV2("p", {
427
+ className: "text-xs text-[color:var(--color-text-color)]",
428
+ children: [
429
+ "Belum ada block -- buat di ",
430
+ /* @__PURE__ */ jsxDEV2("a", {
431
+ href: "/blocks",
432
+ className: "text-[color:var(--color-primary)] hover:underline",
433
+ children: "Block Manager"
434
+ }, undefined, false, undefined, this),
435
+ "."
436
+ ]
437
+ }, undefined, true, undefined, this)
438
+ ]
439
+ }, undefined, true, undefined, this)
440
+ ]
441
+ }, undefined, true, undefined, this);
442
+ }
443
+
444
+ // src/components/layout/GridRow.tsx
445
+ import { useState as useState3 } from "react";
446
+ import { GripVertical as GripVertical2 } from "lucide-react";
447
+
448
+ // src/components/layout/WidgetFieldsForm.tsx
449
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
450
+ function isEmptyValue(value) {
451
+ if (value === null || value === undefined)
452
+ return true;
453
+ if (typeof value === "string")
454
+ return value.trim() === "";
455
+ return false;
456
+ }
457
+ function WidgetFieldsForm2({ fields, values, onChange }) {
458
+ const entries = Object.entries(fields);
459
+ if (entries.length === 0)
460
+ return null;
461
+ return /* @__PURE__ */ jsxDEV3("div", {
462
+ className: "flex flex-col gap-3",
463
+ children: entries.map(([key, field]) => {
464
+ const currentValue = values[key] ?? field.default;
465
+ const showRequiredError = field.required && isEmptyValue(currentValue);
466
+ if (field.type === "checkbox") {
467
+ return /* @__PURE__ */ jsxDEV3("label", {
468
+ className: "flex items-center gap-2 text-xs text-foreground cursor-pointer select-none",
469
+ children: [
470
+ /* @__PURE__ */ jsxDEV3(Checkbox2, {
471
+ checked: Boolean(currentValue),
472
+ onChange: (e) => onChange(key, e.target.checked)
473
+ }, undefined, false, undefined, this),
474
+ /* @__PURE__ */ jsxDEV3("span", {
475
+ className: "font-medium",
476
+ children: field.label
477
+ }, undefined, false, undefined, this)
478
+ ]
479
+ }, key, true, undefined, this);
480
+ }
481
+ if (field.type === "select") {
482
+ return /* @__PURE__ */ jsxDEV3("div", {
483
+ className: "flex flex-col gap-1.5 text-xs text-foreground",
484
+ children: [
485
+ /* @__PURE__ */ jsxDEV3("span", {
486
+ className: "font-medium text-muted-foreground",
487
+ children: field.label
488
+ }, undefined, false, undefined, this),
489
+ /* @__PURE__ */ jsxDEV3(Select2, {
490
+ size: "sm",
491
+ className: "w-full",
492
+ value: String(currentValue ?? ""),
493
+ onChange: (val) => onChange(key, val),
494
+ options: (field.options ?? []).map((opt) => ({
495
+ value: opt.value,
496
+ name: opt.label
497
+ }))
498
+ }, undefined, false, undefined, this)
499
+ ]
500
+ }, key, true, undefined, this);
501
+ }
502
+ if (field.type === "color") {
503
+ return /* @__PURE__ */ jsxDEV3("div", {
504
+ className: "flex flex-col gap-1.5 text-xs text-foreground",
505
+ children: [
506
+ /* @__PURE__ */ jsxDEV3("span", {
507
+ className: "font-medium text-muted-foreground",
508
+ children: field.label
509
+ }, undefined, false, undefined, this),
510
+ /* @__PURE__ */ jsxDEV3(InputColor2, {
511
+ value: String(currentValue ?? "#000000"),
512
+ onChange: (hex) => onChange(key, hex),
513
+ size: "sm"
514
+ }, undefined, false, undefined, this),
515
+ showRequiredError && /* @__PURE__ */ jsxDEV3(FieldRequiredError, {}, undefined, false, undefined, this)
516
+ ]
517
+ }, key, true, undefined, this);
518
+ }
519
+ if (field.type === "image") {
520
+ const urlValue = String(currentValue ?? "");
521
+ return /* @__PURE__ */ jsxDEV3("div", {
522
+ className: "flex flex-col gap-1.5 text-xs text-foreground",
523
+ children: [
524
+ /* @__PURE__ */ jsxDEV3("span", {
525
+ className: "font-medium text-muted-foreground",
526
+ children: field.label
527
+ }, undefined, false, undefined, this),
528
+ /* @__PURE__ */ jsxDEV3(Input2, {
529
+ inputSize: "sm",
530
+ type: "text",
531
+ placeholder: "https://... URL gambar",
532
+ value: urlValue,
533
+ onChange: (e) => onChange(key, e.target.value)
534
+ }, undefined, false, undefined, this),
535
+ urlValue && /* @__PURE__ */ jsxDEV3("img", {
536
+ src: urlValue,
537
+ alt: "",
538
+ className: "h-16 w-full rounded-lg border border-border object-cover",
539
+ onError: (e) => {
540
+ e.currentTarget.style.display = "none";
541
+ },
542
+ onLoad: (e) => {
543
+ e.currentTarget.style.display = "block";
544
+ }
545
+ }, undefined, false, undefined, this),
546
+ showRequiredError && /* @__PURE__ */ jsxDEV3(FieldRequiredError, {}, undefined, false, undefined, this)
547
+ ]
548
+ }, key, true, undefined, this);
549
+ }
550
+ return /* @__PURE__ */ jsxDEV3("div", {
551
+ className: "flex flex-col gap-1.5 text-xs text-foreground",
552
+ children: [
553
+ /* @__PURE__ */ jsxDEV3("span", {
554
+ className: "font-medium text-muted-foreground",
555
+ children: field.label
556
+ }, undefined, false, undefined, this),
557
+ /* @__PURE__ */ jsxDEV3(Input2, {
558
+ inputSize: "sm",
559
+ type: field.type === "number" ? "number" : "text",
560
+ value: String(currentValue ?? ""),
561
+ onChange: (e) => onChange(key, field.type === "number" ? Number(e.target.value) : e.target.value),
562
+ className: showRequiredError ? "border-destructive" : ""
563
+ }, undefined, false, undefined, this),
564
+ showRequiredError && /* @__PURE__ */ jsxDEV3(FieldRequiredError, {}, undefined, false, undefined, this)
565
+ ]
566
+ }, key, true, undefined, this);
567
+ })
568
+ }, undefined, false, undefined, this);
569
+ }
570
+ function FieldRequiredError() {
571
+ return /* @__PURE__ */ jsxDEV3("p", {
572
+ className: "text-[11px] font-medium text-destructive",
573
+ children: "Wajib diisi."
574
+ }, undefined, false, undefined, this);
575
+ }
576
+
577
+ // src/components/layout/GridRow.tsx
578
+ import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
579
+ function GridRow2({ dropTargetKey, items, blocks, activeBp, onChange, onRemoveItem, onReassignBlock, onToggleVisible, blockDrag, onStartBlockDrag, bare, suppressHighlight }) {
580
+ const { rowRef, drag, startResize } = useSpanResize2({ items }, activeBp, (zone) => onChange(zone.items));
581
+ const blockKeys = Object.keys(blocks);
582
+ const [openFieldsFor, setOpenFieldsFor] = useState3(null);
583
+ function updateItemSetting(index, key, value) {
584
+ const newItems = [...items];
585
+ newItems[index] = { ...newItems[index], settings: { ...newItems[index].settings, [key]: value } };
586
+ onChange(newItems);
587
+ }
588
+ const totalSpan = items.reduce((sum, item) => {
589
+ const span = item.id === drag.draggingItemId ? drag.liveSpan : resolveResponsive2({ ...item.grid.span, base: item.grid.span.base ?? 12 }, activeBp);
590
+ return sum + span;
591
+ }, 0);
592
+ const isDropTarget = !suppressHighlight && blockDrag.dropTargetKey === dropTargetKey;
593
+ return /* @__PURE__ */ jsxDEV4("div", {
594
+ className: "space-y-2",
595
+ children: [
596
+ /* @__PURE__ */ jsxDEV4("div", {
597
+ ref: rowRef,
598
+ "data-zone-key": dropTargetKey,
599
+ className: `relative grid grid-cols-12 gap-2 p-3.5 rounded-xs min-h-[105px] transition-colors ${bare ? "" : "bg-muted/40 border-2 border-dashed border-border"} ${isDropTarget ? "border-primary bg-primary/10 ring-2 ring-primary/20" : ""}`,
600
+ children: [
601
+ /* @__PURE__ */ jsxDEV4("div", {
602
+ className: "absolute inset-3.5 grid grid-cols-12 gap-2 pointer-events-none z-0",
603
+ children: Array.from({ length: 12 }, (_, i) => /* @__PURE__ */ jsxDEV4("div", {
604
+ className: "h-full rounded-xs border-2 border-dashed border-primary/20 bg-primary/[0.04] flex items-center justify-center transition-colors",
605
+ children: /* @__PURE__ */ jsxDEV4("span", {
606
+ className: "text-[10px] font-mono font-bold text-primary/40 select-none",
607
+ children: i + 1
608
+ }, undefined, false, undefined, this)
609
+ }, i, false, undefined, this))
610
+ }, undefined, false, undefined, this),
611
+ items.map((item, i) => {
612
+ const isResizing = item.id === drag.draggingItemId;
613
+ const isMoveDragging = blockDrag.dragMode === "move" && item.id === blockDrag.draggingId;
614
+ const span = isResizing ? drag.liveSpan : resolveResponsive2({ ...item.grid.span, base: item.grid.span.base ?? 12 }, activeBp);
615
+ const block = blocks[item.blockId];
616
+ const showInsertionBefore = isDropTarget && blockDrag.dropBeforeId === item.id;
617
+ const isHiddenHere = item.grid.visible ? resolveResponsive2({ ...item.grid.visible, base: item.grid.visible.base ?? true }, activeBp) === false : false;
618
+ return /* @__PURE__ */ jsxDEV4("div", {
619
+ className: `${getColSpanClass2(span)} relative flex min-w-0`,
620
+ children: [
621
+ showInsertionBefore && /* @__PURE__ */ jsxDEV4("div", {
622
+ className: "absolute -left-1 top-0 bottom-0 w-0.5 rounded-full bg-primary z-20"
623
+ }, undefined, false, undefined, this),
624
+ /* @__PURE__ */ jsxDEV4("div", {
625
+ "data-item-id": item.id,
626
+ className: `w-full relative z-10 bg-card border-2 border-border/80 rounded-xs flex flex-col group overflow-visible transition-all min-w-0 p-3 shadow-xs hover:border-primary hover:shadow-sm ${isMoveDragging ? "opacity-30" : ""} ${isHiddenHere ? "bg-amber-500/5 border-dashed border-amber-400" : isResizing ? "border-primary ring-2 ring-primary/20 shadow-md z-20" : ""}`,
627
+ children: [
628
+ /* @__PURE__ */ jsxDEV4("div", {
629
+ className: "absolute bottom-[calc(100%+6px)] left-0 z-30 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",
630
+ children: [
631
+ /* @__PURE__ */ jsxDEV4("div", {
632
+ className: "h-[36px] flex items-center gap-1.5 px-2 bg-card rounded-md min-w-max border border-border shadow-md z-30",
633
+ children: [
634
+ /* @__PURE__ */ jsxDEV4("div", {
635
+ onPointerDown: onStartBlockDrag(item.id),
636
+ className: "cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground touch-none flex items-center p-1",
637
+ children: /* @__PURE__ */ jsxDEV4(GripVertical2, {
638
+ size: 13
639
+ }, undefined, false, undefined, this)
640
+ }, undefined, false, undefined, this),
641
+ /* @__PURE__ */ jsxDEV4(Select2, {
642
+ size: "xs",
643
+ className: "w-[160px]",
644
+ value: item.blockId,
645
+ onChange: (val) => onReassignBlock(i, val),
646
+ options: blockKeys.map((key) => ({ value: key, name: blocks[key].name }))
647
+ }, undefined, false, undefined, this),
648
+ /* @__PURE__ */ jsxDEV4(ButtonIcon2, {
649
+ size: "xs",
650
+ variant: "ghost",
651
+ icon: isHiddenHere ? "eyeOff" : "eye",
652
+ onClick: () => onToggleVisible(i),
653
+ title: isHiddenHere ? `Sembunyi di ${activeBp} -- klik utk tampilkan` : `Tampil di ${activeBp} -- klik utk sembunyikan`,
654
+ className: `shrink-0 ${isHiddenHere ? "text-amber-500" : "text-muted-foreground hover:text-foreground"}`
655
+ }, undefined, false, undefined, this),
656
+ Object.keys(getBlockFields2(item.blockId)).length > 0 && /* @__PURE__ */ jsxDEV4(ButtonIcon2, {
657
+ size: "xs",
658
+ variant: "ghost",
659
+ icon: "settings",
660
+ onClick: () => setOpenFieldsFor(openFieldsFor === item.id ? null : item.id),
661
+ title: "Edit Props",
662
+ className: `shrink-0 ${openFieldsFor === item.id ? "text-primary" : "text-muted-foreground hover:text-foreground"}`
663
+ }, undefined, false, undefined, this),
664
+ /* @__PURE__ */ jsxDEV4(ButtonIcon2, {
665
+ size: "xs",
666
+ variant: "ghost",
667
+ icon: "trash",
668
+ onClick: () => onRemoveItem(i),
669
+ title: "Hapus Block",
670
+ className: "text-destructive hover:bg-destructive/10 shrink-0"
671
+ }, undefined, false, undefined, this)
672
+ ]
673
+ }, undefined, true, undefined, this),
674
+ openFieldsFor === item.id && /* @__PURE__ */ jsxDEV4("div", {
675
+ className: "mt-1 w-64 p-3 bg-card rounded-xl border border-border shadow-xl",
676
+ children: /* @__PURE__ */ jsxDEV4(WidgetFieldsForm2, {
677
+ fields: getBlockFields2(item.blockId),
678
+ values: item.settings ?? {},
679
+ onChange: (key, value) => updateItemSetting(i, key, value)
680
+ }, undefined, false, undefined, this)
681
+ }, undefined, false, undefined, this)
682
+ ]
683
+ }, undefined, true, undefined, this),
684
+ /* @__PURE__ */ jsxDEV4("div", {
685
+ className: isHiddenHere ? "opacity-40" : "",
686
+ children: [
687
+ block && (block.components?.length ?? 0) > 0 && span > 1 && /* @__PURE__ */ jsxDEV4("div", {
688
+ className: "flex flex-wrap gap-1 overflow-hidden h-[22px]",
689
+ children: block.components.slice(0, 3).map((comp, idx) => /* @__PURE__ */ jsxDEV4(Badge2, {
690
+ variant: "soft",
691
+ color: "primary",
692
+ size: "xs",
693
+ children: comp
694
+ }, idx, false, undefined, this))
695
+ }, undefined, false, undefined, this),
696
+ span <= 1 && block?.componentKey !== "OffCanvasTriggerBlock" && /* @__PURE__ */ jsxDEV4("div", {
697
+ className: "text-[10px] text-muted-foreground truncate w-full text-center mt-1",
698
+ children: "..."
699
+ }, undefined, false, undefined, this)
700
+ ]
701
+ }, undefined, true, undefined, this),
702
+ block?.componentKey === "OffCanvasTriggerBlock" && /* @__PURE__ */ jsxDEV4("div", {
703
+ className: "mt-1.5",
704
+ children: /* @__PURE__ */ jsxDEV4(Select2, {
705
+ size: "xs",
706
+ className: "w-full",
707
+ placeholder: "-- Pilih Laci --",
708
+ value: item.settings?.targetSectionId || "",
709
+ onChange: (val) => {
710
+ const newItems = [...items];
711
+ newItems[i] = { ...newItems[i], settings: { ...newItems[i].settings, targetSectionId: val } };
712
+ onChange(newItems);
713
+ },
714
+ options: [
715
+ { value: "left-drawer", name: "Left Drawer" },
716
+ { value: "right-drawer", name: "Right Drawer" },
717
+ { value: "top-drawer", name: "Top Drawer" },
718
+ { value: "bottom-drawer", name: "Bottom Drawer" }
719
+ ]
720
+ }, undefined, false, undefined, this)
721
+ }, undefined, false, undefined, this),
722
+ span <= 1 && block?.componentKey !== "OffCanvasTriggerBlock" && /* @__PURE__ */ jsxDEV4("div", {
723
+ className: "text-[10px] text-muted-foreground truncate w-full text-center mt-1",
724
+ children: "..."
725
+ }, undefined, false, undefined, this),
726
+ /* @__PURE__ */ jsxDEV4("div", {
727
+ onPointerDown: startResize(item.id),
728
+ className: "absolute top-0 right-[-4px] bottom-0 w-3 flex items-center justify-center cursor-col-resize touch-none group/handle z-20",
729
+ children: /* @__PURE__ */ jsxDEV4("div", {
730
+ className: "w-1 h-6 rounded-full bg-border group-hover/handle:bg-primary transition-colors shadow-xs"
731
+ }, undefined, false, undefined, this)
732
+ }, undefined, false, undefined, this),
733
+ isResizing && /* @__PURE__ */ jsxDEV4("div", {
734
+ className: "absolute -top-7 right-0 bg-foreground text-background text-[10px] font-bold px-2 py-0.5 rounded-md shadow-lg whitespace-nowrap",
735
+ children: [
736
+ "Span ",
737
+ span
738
+ ]
739
+ }, undefined, true, undefined, this)
740
+ ]
741
+ }, undefined, true, undefined, this)
742
+ ]
743
+ }, item.id, true, undefined, this);
744
+ }),
745
+ isDropTarget && blockDrag.dropBeforeId === null && items.length > 0 && /* @__PURE__ */ jsxDEV4("div", {
746
+ className: "absolute right-3 top-3 bottom-3 w-0.5 rounded-full bg-primary z-20"
747
+ }, undefined, false, undefined, this),
748
+ items.length === 0 && /* @__PURE__ */ jsxDEV4("div", {
749
+ className: "col-span-12 flex items-center justify-center text-xs text-muted-foreground",
750
+ children: isDropTarget ? "Lepas di sini" : "Kosong -- drag block dari palette"
751
+ }, undefined, false, undefined, this)
752
+ ]
753
+ }, undefined, true, undefined, this),
754
+ totalSpan > 12 && /* @__PURE__ */ jsxDEV4("p", {
755
+ className: "text-[11px] text-amber-600 font-medium",
756
+ children: [
757
+ "Total span ",
758
+ totalSpan,
759
+ "/12 -- kelebihan akan turun ke baris baru."
760
+ ]
761
+ }, undefined, true, undefined, this)
762
+ ]
763
+ }, undefined, true, undefined, this);
764
+ }
765
+
766
+ // src/components/layout/LayoutBuilder.tsx
767
+ import { Fragment as Fragment2, useEffect, useState as useState4 } from "react";
768
+ import { ChevronDown, ChevronUp, GripVertical as GripVertical3, Maximize2, Minimize2, Pencil, Redo2, Undo2 } from "lucide-react";
769
+ import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
770
+ var BREAKPOINTS = [
771
+ { key: "base", label: "Base" },
772
+ { key: "sm", label: "SM" },
773
+ { key: "md", label: "MD" },
774
+ { key: "lg", label: "LG" },
775
+ { key: "xl", label: "XL" }
776
+ ];
777
+ var DEVICE_PRESETS = [
778
+ { key: "lg", label: "Desktop", icon: "monitor", group: ["lg", "xl"] },
779
+ { key: "md", label: "Tablet", icon: "tablet", group: ["md"] },
780
+ { key: "base", label: "Mobile", icon: "smartphone", group: ["base", "sm"] }
781
+ ];
782
+ function BreakpointSwitcher({ active, onChange }) {
783
+ const currentDevice = DEVICE_PRESETS.find((d) => d.group.includes(active))?.key || "lg";
784
+ return /* @__PURE__ */ jsxDEV5("div", {
785
+ className: "flex flex-row items-center gap-2",
786
+ children: [
787
+ /* @__PURE__ */ jsxDEV5(SelectGroup2, {
788
+ size: "md",
789
+ options: DEVICE_PRESETS.map((d) => ({
790
+ value: d.key,
791
+ label: /* @__PURE__ */ jsxDEV5("span", {
792
+ className: "flex items-center gap-1.5 font-medium",
793
+ children: [
794
+ /* @__PURE__ */ jsxDEV5(Icon2, {
795
+ name: d.icon,
796
+ size: 15
797
+ }, undefined, false, undefined, this),
798
+ /* @__PURE__ */ jsxDEV5("span", {
799
+ children: d.label
800
+ }, undefined, false, undefined, this)
801
+ ]
802
+ }, undefined, true, undefined, this)
803
+ })),
804
+ value: currentDevice,
805
+ onChange: (val) => onChange(val)
806
+ }, undefined, false, undefined, this),
807
+ /* @__PURE__ */ jsxDEV5(SelectGroup2, {
808
+ size: "md",
809
+ options: BREAKPOINTS.map((bp) => ({
810
+ value: bp.key,
811
+ label: /* @__PURE__ */ jsxDEV5("span", {
812
+ className: "flex flex-col items-center justify-center leading-none py-0.5",
813
+ children: [
814
+ /* @__PURE__ */ jsxDEV5("span", {
815
+ className: "text-[11px] font-bold tracking-tight",
816
+ children: bp.label
817
+ }, undefined, false, undefined, this),
818
+ /* @__PURE__ */ jsxDEV5("span", {
819
+ className: "text-[9px] opacity-70 mt-0.5 font-mono",
820
+ children: [
821
+ BREAKPOINT_PX2[bp.key],
822
+ "px"
823
+ ]
824
+ }, undefined, true, undefined, this)
825
+ ]
826
+ }, undefined, true, undefined, this)
827
+ })),
828
+ value: active,
829
+ onChange: (val) => onChange(val)
830
+ }, undefined, false, undefined, this)
831
+ ]
832
+ }, undefined, true, undefined, this);
833
+ }
834
+ function ContainerControls({
835
+ setting,
836
+ backgroundColor,
837
+ onChangeSetting,
838
+ onChangeBackgroundColor
839
+ }) {
840
+ return /* @__PURE__ */ jsxDEV5("div", {
841
+ className: "flex items-center gap-3",
842
+ children: [
843
+ /* @__PURE__ */ jsxDEV5("label", {
844
+ className: "flex items-center gap-1.5 shrink-0",
845
+ children: [
846
+ /* @__PURE__ */ jsxDEV5("span", {
847
+ className: "text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",
848
+ children: "Style"
849
+ }, undefined, false, undefined, this),
850
+ /* @__PURE__ */ jsxDEV5(Select2, {
851
+ size: "sm",
852
+ className: "w-[160px]",
853
+ options: [
854
+ { value: "wrapper", name: "Wrapper" },
855
+ { value: "full-width-wrapper", name: "Full Width Wrapper" },
856
+ { value: "full-width", name: "Full Width" },
857
+ { value: "custom", name: "Custom" }
858
+ ],
859
+ value: setting.type,
860
+ onChange: (val) => onChangeSetting({ ...setting, type: val })
861
+ }, undefined, false, undefined, this),
862
+ setting.type === "custom" && /* @__PURE__ */ jsxDEV5(Input2, {
863
+ type: "number",
864
+ min: 0,
865
+ placeholder: "px",
866
+ inputSize: "sm",
867
+ inputClassName: "w-16",
868
+ value: setting.customWidthPx ?? "",
869
+ onChange: (e) => onChangeSetting({ ...setting, customWidthPx: e.target.value ? Number(e.target.value) : undefined })
870
+ }, undefined, false, undefined, this)
871
+ ]
872
+ }, undefined, true, undefined, this),
873
+ /* @__PURE__ */ jsxDEV5("label", {
874
+ className: "flex items-center gap-1.5 shrink-0",
875
+ children: [
876
+ /* @__PURE__ */ jsxDEV5("span", {
877
+ className: "text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",
878
+ children: "Bg"
879
+ }, undefined, false, undefined, this),
880
+ /* @__PURE__ */ jsxDEV5(InputColor2, {
881
+ size: "sm",
882
+ hideInput: true,
883
+ value: backgroundColor ?? "transparent",
884
+ onChange: (val) => onChangeBackgroundColor(val === "transparent" ? undefined : val),
885
+ allowTransparent: true,
886
+ alpha: true
887
+ }, undefined, false, undefined, this)
888
+ ]
889
+ }, undefined, true, undefined, this)
890
+ ]
891
+ }, undefined, true, undefined, this);
892
+ }
893
+ function SectionRow({
894
+ zoneKey,
895
+ section,
896
+ blocks,
897
+ activeBp,
898
+ simulatedMaxWidth,
899
+ onChange,
900
+ onRemove,
901
+ blockDrag,
902
+ onStartBlockDrag,
903
+ sectionDrag,
904
+ onStartSectionDrag
905
+ }) {
906
+ const dropTargetKey = `${zoneKey}:${section.id}`;
907
+ const isDropTarget = !sectionDrag.draggingId && blockDrag.dropTargetKey === dropTargetKey;
908
+ const setItems = (items) => onChange({ ...section, items });
909
+ const removeItem = (index) => setItems(section.items.filter((_, i) => i !== index));
910
+ const reassignBlock = (index, blockId) => {
911
+ const newItems = [...section.items];
912
+ newItems[index] = { ...newItems[index], blockId, settings: undefined };
913
+ setItems(newItems);
914
+ };
915
+ const toggleVisible = (index) => {
916
+ const newItems = [...section.items];
917
+ const item = newItems[index];
918
+ const currentlyVisible = item.grid.visible ? resolveResponsive2({ ...item.grid.visible, base: item.grid.visible.base ?? true }, activeBp) : true;
919
+ newItems[index] = { ...item, grid: { ...item.grid, visible: { ...item.grid.visible, base: item.grid.visible?.base ?? true, [activeBp]: !currentlyVisible } } };
920
+ setItems(newItems);
921
+ };
922
+ const setContainerSetting = (setting) => onChange({ ...section, container: { ...section.container, [activeBp]: setting } });
923
+ const setBackgroundColor = (color) => onChange({ ...section, backgroundColor: color });
924
+ const setName = (name) => onChange({ ...section, name });
925
+ const setOffCanvasPosition = (position) => onChange({ ...section, offcanvasPosition: position });
926
+ const resolvedZone = resolveSectionZone2(section, zoneKey, activeBp);
927
+ const setOffCanvasOnMobile = (checked) => onChange({ ...section, offcanvasOnMobile: checked });
928
+ const setOffCanvasOnTablet = (checked) => onChange({ ...section, offcanvasOnTablet: checked });
929
+ const isSectionHiddenHere = section.visible ? resolveResponsive2({ ...section.visible, base: section.visible.base ?? true }, activeBp) === false : false;
930
+ const toggleSectionVisible = () => {
931
+ const currentlyVisible = !isSectionHiddenHere;
932
+ onChange({ ...section, visible: { ...section.visible, base: section.visible?.base ?? true, [activeBp]: !currentlyVisible } });
933
+ };
934
+ const isMoveDragging = sectionDrag.draggingId === section.id;
935
+ const showInsertionBefore = sectionDrag.dropZoneKey === zoneKey && sectionDrag.dropBeforeId === section.id;
936
+ return /* @__PURE__ */ jsxDEV5("div", {
937
+ className: "relative",
938
+ children: [
939
+ showInsertionBefore && /* @__PURE__ */ jsxDEV5("div", {
940
+ className: "absolute -top-2 left-0 right-0 h-0.5 rounded-full bg-indigo-500 z-20"
941
+ }, undefined, false, undefined, this),
942
+ /* @__PURE__ */ jsxDEV5("div", {
943
+ "data-section-id": section.id,
944
+ "data-zone-key": dropTargetKey,
945
+ className: `group/section space-y-2 p-2.5 rounded-xs border-2 border-dashed transition-all ${isSectionHiddenHere ? "border-amber-400/50 bg-amber-500/5 opacity-60 blur-[1.5px] hover:blur-none" : isDropTarget ? "border-primary bg-primary/10 ring-4 ring-primary/20" : "border-border bg-card shadow-xs"} ${isMoveDragging ? "opacity-30" : ""}`,
946
+ children: [
947
+ /* @__PURE__ */ jsxDEV5("div", {
948
+ className: "flex flex-wrap items-center gap-2",
949
+ children: [
950
+ /* @__PURE__ */ jsxDEV5("div", {
951
+ className: "flex items-center gap-1.5 mr-auto shrink-0",
952
+ children: [
953
+ /* @__PURE__ */ jsxDEV5("div", {
954
+ onPointerDown: onStartSectionDrag(section.id),
955
+ className: "cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground touch-none shrink-0 p-1",
956
+ children: /* @__PURE__ */ jsxDEV5(GripVertical3, {
957
+ size: 14
958
+ }, undefined, false, undefined, this)
959
+ }, undefined, false, undefined, this),
960
+ /* @__PURE__ */ jsxDEV5("span", {
961
+ className: "text-[11px] font-semibold text-primary uppercase tracking-wider shrink-0",
962
+ children: "Section"
963
+ }, undefined, false, undefined, this),
964
+ /* @__PURE__ */ jsxDEV5(Input2, {
965
+ inputSize: "sm",
966
+ value: section.name ?? "",
967
+ onChange: (e) => setName(e.target.value),
968
+ placeholder: "Nama section (mis. slider, footer)",
969
+ inputClassName: "w-48 text-xs font-medium"
970
+ }, undefined, false, undefined, this),
971
+ /* @__PURE__ */ jsxDEV5(ButtonIcon2, {
972
+ size: "xs",
973
+ variant: "ghost",
974
+ icon: isSectionHiddenHere ? "eyeOff" : "eye",
975
+ onClick: toggleSectionVisible,
976
+ title: isSectionHiddenHere ? `Sembunyi di ${activeBp} -- klik utk tampilkan` : `Tampil di ${activeBp} -- klik utk sembunyikan`,
977
+ className: `shrink-0 ${isSectionHiddenHere ? "text-amber-500" : "text-muted-foreground opacity-0 group-hover/section:opacity-100 hover:text-foreground"}`
978
+ }, undefined, false, undefined, this),
979
+ /* @__PURE__ */ jsxDEV5(ButtonIcon2, {
980
+ size: "xs",
981
+ variant: "ghost",
982
+ icon: "trash",
983
+ onClick: onRemove,
984
+ title: "Hapus Section",
985
+ className: "text-destructive hover:bg-destructive/10 opacity-0 group-hover/section:opacity-100 shrink-0"
986
+ }, undefined, false, undefined, this)
987
+ ]
988
+ }, undefined, true, undefined, this),
989
+ zoneKey !== "offcanvas" && /* @__PURE__ */ jsxDEV5("label", {
990
+ className: `flex items-center gap-2 border rounded-lg px-2.5 h-[32px] text-xs shrink-0 cursor-pointer transition-colors ${section.offcanvasOnMobile ? "bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-400 font-semibold" : "bg-background border-border text-muted-foreground hover:text-foreground"}`,
991
+ title: "Kalau dicentang, Section ini pindah render ke Off Canvas KHUSUS saat breakpoint Mobile -- Desktop/Tablet TETAP di Zone rumahnya, tidak terpengaruh sama sekali.",
992
+ children: [
993
+ /* @__PURE__ */ jsxDEV5(Checkbox2, {
994
+ checked: section.offcanvasOnMobile ?? false,
995
+ onChange: (e) => setOffCanvasOnMobile(e.target.checked)
996
+ }, undefined, false, undefined, this),
997
+ /* @__PURE__ */ jsxDEV5("span", {
998
+ className: "flex items-center gap-1.5 font-medium",
999
+ children: [
1000
+ /* @__PURE__ */ jsxDEV5(Icon2, {
1001
+ name: "smartphone",
1002
+ size: 13
1003
+ }, undefined, false, undefined, this),
1004
+ " Off Canvas di Mobile"
1005
+ ]
1006
+ }, undefined, true, undefined, this)
1007
+ ]
1008
+ }, undefined, true, undefined, this),
1009
+ zoneKey !== "offcanvas" && /* @__PURE__ */ jsxDEV5("label", {
1010
+ className: `flex items-center gap-2 border rounded-lg px-2.5 h-[32px] text-xs shrink-0 cursor-pointer transition-colors ${section.offcanvasOnTablet ? "bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-400 font-semibold" : "bg-background border-border text-muted-foreground hover:text-foreground"}`,
1011
+ title: "Kalau dicentang, Section ini pindah render ke Off Canvas KHUSUS saat breakpoint Tablet (md) -- Desktop/Mobile TETAP di Zone rumahnya, tidak terpengaruh sama sekali. Independen dari checkbox Mobile.",
1012
+ children: [
1013
+ /* @__PURE__ */ jsxDEV5(Checkbox2, {
1014
+ checked: section.offcanvasOnTablet ?? false,
1015
+ onChange: (e) => setOffCanvasOnTablet(e.target.checked)
1016
+ }, undefined, false, undefined, this),
1017
+ /* @__PURE__ */ jsxDEV5("span", {
1018
+ className: "flex items-center gap-1.5 font-medium",
1019
+ children: [
1020
+ /* @__PURE__ */ jsxDEV5(Icon2, {
1021
+ name: "tablet",
1022
+ size: 13
1023
+ }, undefined, false, undefined, this),
1024
+ " Off Canvas di Tablet"
1025
+ ]
1026
+ }, undefined, true, undefined, this)
1027
+ ]
1028
+ }, undefined, true, undefined, this),
1029
+ resolvedZone === "offcanvas" && /* @__PURE__ */ jsxDEV5("div", {
1030
+ className: "flex items-center gap-1.5 shrink-0",
1031
+ children: [
1032
+ /* @__PURE__ */ jsxDEV5(Select2, {
1033
+ size: "sm",
1034
+ className: "w-[110px]",
1035
+ options: [
1036
+ { value: "left", name: "Left" },
1037
+ { value: "right", name: "Right" },
1038
+ { value: "top", name: "Top" },
1039
+ { value: "bottom", name: "Bottom" }
1040
+ ],
1041
+ value: section.offcanvasPosition ?? "left",
1042
+ onChange: (val) => setOffCanvasPosition(val)
1043
+ }, undefined, false, undefined, this),
1044
+ /* @__PURE__ */ jsxDEV5(Tooltip2, {
1045
+ content: `Off Canvas akan muncul dari: ${section.offcanvasPosition ?? "left"}. Di sini dirender inline untuk editing, aslinya tersembunyi.`,
1046
+ position: "top",
1047
+ children: /* @__PURE__ */ jsxDEV5(Icon2, {
1048
+ name: "info",
1049
+ className: "w-3.5 h-3.5 text-[color:var(--color-text-color)] hover:text-[color:var(--color-primary)] transition-colors"
1050
+ }, undefined, false, undefined, this)
1051
+ }, undefined, false, undefined, this)
1052
+ ]
1053
+ }, undefined, true, undefined, this),
1054
+ /* @__PURE__ */ jsxDEV5(ContainerControls, {
1055
+ setting: resolveResponsive2(section.container, activeBp),
1056
+ backgroundColor: section.backgroundColor,
1057
+ onChangeSetting: setContainerSetting,
1058
+ onChangeBackgroundColor: setBackgroundColor
1059
+ }, undefined, false, undefined, this)
1060
+ ]
1061
+ }, undefined, true, undefined, this),
1062
+ /* @__PURE__ */ jsxDEV5("p", {
1063
+ className: "text-[10px] text-indigo-400 font-mono px-0.5 hidden",
1064
+ children: [
1065
+ "id: ",
1066
+ sectionHtmlId2(section)
1067
+ ]
1068
+ }, undefined, true, undefined, this),
1069
+ /* @__PURE__ */ jsxDEV5("div", {
1070
+ style: { maxWidth: simulatedMaxWidth, marginLeft: simulatedMaxWidth ? "auto" : undefined, marginRight: simulatedMaxWidth ? "auto" : undefined },
1071
+ className: "pt-2 rounded-lg transition-[max-width] duration-200",
1072
+ children: /* @__PURE__ */ jsxDEV5(ContainerBox2, {
1073
+ container: section.container,
1074
+ backgroundColor: section.backgroundColor,
1075
+ resolveBp: activeBp,
1076
+ children: /* @__PURE__ */ jsxDEV5(GridRow2, {
1077
+ dropTargetKey,
1078
+ items: section.items,
1079
+ blocks,
1080
+ activeBp,
1081
+ onChange: setItems,
1082
+ onRemoveItem: removeItem,
1083
+ onReassignBlock: reassignBlock,
1084
+ onToggleVisible: toggleVisible,
1085
+ blockDrag,
1086
+ onStartBlockDrag,
1087
+ bare: true,
1088
+ suppressHighlight: !!sectionDrag.draggingId
1089
+ }, undefined, false, undefined, this)
1090
+ }, undefined, false, undefined, this)
1091
+ }, undefined, false, undefined, this)
1092
+ ]
1093
+ }, undefined, true, undefined, this)
1094
+ ]
1095
+ }, undefined, true, undefined, this);
1096
+ }
1097
+ function ZoneEditor({
1098
+ title,
1099
+ zoneKey,
1100
+ zone,
1101
+ blocks,
1102
+ activeBp,
1103
+ simulatedMaxWidth,
1104
+ onChange,
1105
+ blockDrag,
1106
+ onStartBlockDrag,
1107
+ sectionDrag,
1108
+ onStartSectionDrag
1109
+ }) {
1110
+ const sections = zone?.sections ?? [];
1111
+ const addSection = () => onChange({ sections: [...sections, createSection2()] });
1112
+ const updateSection = (index, next) => {
1113
+ const newSections = [...sections];
1114
+ newSections[index] = next;
1115
+ onChange({ sections: newSections });
1116
+ };
1117
+ const removeSection = (index) => onChange({ sections: sections.filter((_, i) => i !== index) });
1118
+ const isDropTarget = sectionDrag.dropZoneKey === zoneKey || blockDrag.dragMode && blockDrag.dropTargetKey === zoneKey;
1119
+ return /* @__PURE__ */ jsxDEV5("div", {
1120
+ className: "space-y-1.5 pt-6",
1121
+ children: [
1122
+ /* @__PURE__ */ jsxDEV5("span", {
1123
+ className: "font-semibold text-muted-foreground uppercase tracking-wider text-xs",
1124
+ children: title
1125
+ }, undefined, false, undefined, this),
1126
+ /* @__PURE__ */ jsxDEV5("div", {
1127
+ "data-section-zone": zoneKey,
1128
+ "data-zone-key": zoneKey,
1129
+ className: `space-y-3 p-3.5 bg-muted/20 border rounded-xs transition-colors ${isDropTarget ? "border-primary bg-primary/5 ring-2 ring-primary/20" : "border-border"}`,
1130
+ children: [
1131
+ sections.map((section, i) => /* @__PURE__ */ jsxDEV5(SectionRow, {
1132
+ zoneKey,
1133
+ section,
1134
+ blocks,
1135
+ activeBp,
1136
+ simulatedMaxWidth,
1137
+ onChange: (next) => updateSection(i, next),
1138
+ onRemove: () => removeSection(i),
1139
+ blockDrag,
1140
+ sectionDrag,
1141
+ onStartSectionDrag,
1142
+ onStartBlockDrag
1143
+ }, section.id, false, undefined, this)),
1144
+ sections.length === 0 && /* @__PURE__ */ jsxDEV5("div", {
1145
+ className: "flex items-center justify-center text-xs text-muted-foreground py-6",
1146
+ children: isDropTarget ? "Lepas di sini -- Section baru akan dibuat otomatis" : 'Zone kosong -- klik "+ New Section" atau drag block dari palette'
1147
+ }, undefined, false, undefined, this),
1148
+ /* @__PURE__ */ jsxDEV5("div", {
1149
+ className: "flex justify-center",
1150
+ children: /* @__PURE__ */ jsxDEV5(Button2, {
1151
+ variant: "outline",
1152
+ size: "sm",
1153
+ onClick: addSection,
1154
+ children: [
1155
+ /* @__PURE__ */ jsxDEV5(Icon2, {
1156
+ name: "plus",
1157
+ className: "w-3.5 h-3.5"
1158
+ }, undefined, false, undefined, this),
1159
+ "New Section"
1160
+ ]
1161
+ }, undefined, true, undefined, this)
1162
+ }, undefined, false, undefined, this)
1163
+ ]
1164
+ }, undefined, true, undefined, this)
1165
+ ]
1166
+ }, undefined, true, undefined, this);
1167
+ }
1168
+ function LayoutBuilder2({ presetName, schema: controlledSchema, onSchemaChange, compact, activeBp: controlledActiveBp, onActiveBpChange, onNavigateToPreset } = {}) {
1169
+ const isControlled = controlledSchema !== undefined && onSchemaChange !== undefined;
1170
+ const isActiveBpControlled = controlledActiveBp !== undefined && onActiveBpChange !== undefined;
1171
+ const [layout, setLayoutState] = useState4(() => {
1172
+ if (isControlled)
1173
+ return controlledSchema;
1174
+ if (presetName)
1175
+ return getLayoutPresets2()[presetName] ?? getLayoutPresets2().default;
1176
+ restoreLayoutFromLocalStorage2();
1177
+ return getLayout2();
1178
+ });
1179
+ const [blocks] = useState4(() => getBlocks2());
1180
+ const [uncontrolledActiveBp, setUncontrolledActiveBp] = useState4("base");
1181
+ const activeBp = isActiveBpControlled ? controlledActiveBp : uncontrolledActiveBp;
1182
+ const setActiveBp = isActiveBpControlled ? onActiveBpChange : setUncontrolledActiveBp;
1183
+ const [presets, setPresets] = useState4(getLayoutPresets2());
1184
+ const [isFullscreen, setIsFullscreen] = useState4(false);
1185
+ const [isCompactExpanded, setIsCompactExpanded] = useState4(false);
1186
+ const [compactHeightVh, setCompactHeightVh] = useState4(70);
1187
+ useEffect(() => {
1188
+ if (isControlled)
1189
+ setLayoutState(controlledSchema);
1190
+ }, [controlledSchema]);
1191
+ const layoutHistory = useUndoRedo2(layout);
1192
+ const applyLayout = (schema, opts = {}) => {
1193
+ setLayoutState(schema);
1194
+ if (!opts.skipHistory)
1195
+ layoutHistory.push(schema);
1196
+ if (isControlled) {
1197
+ onSchemaChange(schema);
1198
+ if (presetName) {
1199
+ registerLayoutPreset2(presetName, schema);
1200
+ }
1201
+ } else if (presetName) {
1202
+ registerLayoutPreset2(presetName, schema);
1203
+ } else {
1204
+ setLayout2(schema);
1205
+ saveLayoutToLocalStorage2();
1206
+ }
1207
+ };
1208
+ const handleUndo = () => {
1209
+ const prev = layoutHistory.undo();
1210
+ if (prev)
1211
+ applyLayout(prev, { skipHistory: true });
1212
+ };
1213
+ const handleRedo = () => {
1214
+ const next = layoutHistory.redo();
1215
+ if (next)
1216
+ applyLayout(next, { skipHistory: true });
1217
+ };
1218
+ const { drag: blockDrag, startDrag: onStartBlockDrag, startDragFromPalette } = useBlockDrag2(layout, applyLayout);
1219
+ const { drag: sectionDrag, startSectionDrag: onStartSectionDrag } = useSectionDrag2(layout, applyLayout);
1220
+ const startCompactResize = (e) => {
1221
+ e.preventDefault();
1222
+ const startY = e.clientY;
1223
+ const startVh = compactHeightVh;
1224
+ const viewportH = window.innerHeight;
1225
+ function handleMove(ev) {
1226
+ const deltaY = ev.clientY - startY;
1227
+ const deltaVh = deltaY / viewportH * 100;
1228
+ const nextVh = Math.min(90, Math.max(20, startVh - deltaVh));
1229
+ setCompactHeightVh(nextVh);
1230
+ }
1231
+ function handleUp() {
1232
+ window.removeEventListener("pointermove", handleMove);
1233
+ window.removeEventListener("pointerup", handleUp);
1234
+ document.body.style.cursor = "";
1235
+ document.body.style.userSelect = "";
1236
+ }
1237
+ document.body.style.cursor = "ns-resize";
1238
+ document.body.style.userSelect = "none";
1239
+ window.addEventListener("pointermove", handleMove);
1240
+ window.addEventListener("pointerup", handleUp);
1241
+ };
1242
+ const draggingSection = sectionDrag.draggingId ? ["top", "main", "bottom", "offcanvas"].flatMap((key) => layout[key]?.sections ?? []).find((s) => s.id === sectionDrag.draggingId) : undefined;
1243
+ const draggingBlockId = blockDrag.dragMode === "place" ? blockDrag.placingBlockId : blockDrag.dragMode === "move" ? ["top", "main", "bottom", "offcanvas"].flatMap((key) => (layout[key]?.sections ?? []).flatMap((s) => s.items)).find((i) => i.id === blockDrag.draggingId)?.blockId : undefined;
1244
+ const draggingBlock = draggingBlockId ? blocks[draggingBlockId] : undefined;
1245
+ const savePreset = () => {
1246
+ const name = typeof window !== "undefined" ? window.prompt("Nama preset:") : null;
1247
+ if (!name)
1248
+ return;
1249
+ const schema = { ...layout, preset: name };
1250
+ registerLayoutPreset2(name, schema);
1251
+ setPresets(getLayoutPresets2());
1252
+ applyLayout(schema);
1253
+ };
1254
+ const exportJson = () => {
1255
+ if (typeof window === "undefined" || typeof document === "undefined")
1256
+ return;
1257
+ const config = exportLayoutConfig2();
1258
+ const blob = new Blob([JSON.stringify(config, null, 2)], { type: "application/json" });
1259
+ const url = URL.createObjectURL(blob);
1260
+ const a = document.createElement("a");
1261
+ a.href = url;
1262
+ a.download = "deweb-ui-layout-export.json";
1263
+ a.click();
1264
+ URL.revokeObjectURL(url);
1265
+ };
1266
+ const simulatedMaxWidth = activeBp === "xl" ? undefined : activeBp === "base" ? 600 : Math.max(600, BREAKPOINT_PX2[activeBp]);
1267
+ if (compact && !isCompactExpanded) {
1268
+ return /* @__PURE__ */ jsxDEV5("button", {
1269
+ type: "button",
1270
+ onClick: () => setIsCompactExpanded(true),
1271
+ className: "fixed bottom-0 left-0 right-0 z-40 flex items-center justify-center gap-2 border-t border-[color:var(--color-border)] bg-[var(--color-background)] py-2.5 text-sm font-semibold text-[color:var(--color-foreground)] shadow-[0_-2px_8px_rgba(0,0,0,0.06)] hover:bg-[var(--color-secondary)] transition-colors",
1272
+ children: [
1273
+ /* @__PURE__ */ jsxDEV5(Pencil, {
1274
+ size: 14
1275
+ }, undefined, false, undefined, this),
1276
+ "Edit Layout ",
1277
+ presetName ? `(${presetName})` : "",
1278
+ /* @__PURE__ */ jsxDEV5(ChevronUp, {
1279
+ size: 14
1280
+ }, undefined, false, undefined, this)
1281
+ ]
1282
+ }, undefined, true, undefined, this);
1283
+ }
1284
+ const bodyContent = /* @__PURE__ */ jsxDEV5(Fragment2, {
1285
+ children: [
1286
+ /* @__PURE__ */ jsxDEV5("div", {
1287
+ className: "sticky top-0 z-50 flex flex-wrap items-center justify-between gap-3 mb-4 p-3 -mx-4 -mt-4 bg-card/95 backdrop-blur-sm border-b border-border shadow-xs",
1288
+ children: [
1289
+ /* @__PURE__ */ jsxDEV5("div", {
1290
+ className: "flex items-center gap-3",
1291
+ children: [
1292
+ /* @__PURE__ */ jsxDEV5("h4", {
1293
+ className: "text-sm font-semibold text-foreground tracking-tight",
1294
+ children: "Layout Editor:"
1295
+ }, undefined, false, undefined, this),
1296
+ /* @__PURE__ */ jsxDEV5(Select2, {
1297
+ size: "sm",
1298
+ className: "w-[180px]",
1299
+ options: Object.keys(presets).map((key) => ({
1300
+ value: key,
1301
+ name: key.charAt(0).toUpperCase() + key.slice(1)
1302
+ })),
1303
+ value: layout.preset || "default",
1304
+ onChange: (val) => {
1305
+ if (presetName) {
1306
+ onNavigateToPreset?.(val);
1307
+ return;
1308
+ }
1309
+ const preset = presets[val];
1310
+ if (!preset)
1311
+ return;
1312
+ applyLayout(preset, { skipHistory: true });
1313
+ layoutHistory.reset(preset);
1314
+ }
1315
+ }, undefined, false, undefined, this),
1316
+ /* @__PURE__ */ jsxDEV5(Button2, {
1317
+ variant: "primary",
1318
+ size: "sm",
1319
+ onClick: savePreset,
1320
+ children: "Simpan Preset"
1321
+ }, undefined, false, undefined, this),
1322
+ /* @__PURE__ */ jsxDEV5(Button2, {
1323
+ variant: "outline",
1324
+ size: "sm",
1325
+ onClick: exportJson,
1326
+ children: "Export JSON"
1327
+ }, undefined, false, undefined, this),
1328
+ /* @__PURE__ */ jsxDEV5("div", {
1329
+ className: "flex items-center gap-1 border-l border-border pl-2 ml-1",
1330
+ children: [
1331
+ /* @__PURE__ */ jsxDEV5(Button2, {
1332
+ variant: "outline",
1333
+ size: "sm",
1334
+ onClick: handleUndo,
1335
+ disabled: !layoutHistory.canUndo,
1336
+ title: "Undo (sesi ini saja, tidak persist ke JSON)",
1337
+ children: /* @__PURE__ */ jsxDEV5(Undo2, {
1338
+ size: 14
1339
+ }, undefined, false, undefined, this)
1340
+ }, undefined, false, undefined, this),
1341
+ /* @__PURE__ */ jsxDEV5(Button2, {
1342
+ variant: "outline",
1343
+ size: "sm",
1344
+ onClick: handleRedo,
1345
+ disabled: !layoutHistory.canRedo,
1346
+ title: "Redo (sesi ini saja, tidak persist ke JSON)",
1347
+ children: /* @__PURE__ */ jsxDEV5(Redo2, {
1348
+ size: 14
1349
+ }, undefined, false, undefined, this)
1350
+ }, undefined, false, undefined, this)
1351
+ ]
1352
+ }, undefined, true, undefined, this)
1353
+ ]
1354
+ }, undefined, true, undefined, this),
1355
+ /* @__PURE__ */ jsxDEV5("div", {
1356
+ className: "flex flex-wrap items-center gap-2",
1357
+ children: [
1358
+ /* @__PURE__ */ jsxDEV5(BreakpointSwitcher, {
1359
+ active: activeBp,
1360
+ onChange: setActiveBp
1361
+ }, undefined, false, undefined, this),
1362
+ !compact && /* @__PURE__ */ jsxDEV5(Button2, {
1363
+ variant: "outline",
1364
+ size: "sm",
1365
+ onClick: () => setIsFullscreen((f) => !f),
1366
+ title: isFullscreen ? "Keluar dari fullscreen" : "Fullscreen",
1367
+ children: isFullscreen ? /* @__PURE__ */ jsxDEV5(Minimize2, {
1368
+ size: 14
1369
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV5(Maximize2, {
1370
+ size: 14
1371
+ }, undefined, false, undefined, this)
1372
+ }, undefined, false, undefined, this),
1373
+ compact && /* @__PURE__ */ jsxDEV5(Button2, {
1374
+ variant: "outline",
1375
+ size: "sm",
1376
+ onClick: () => setIsCompactExpanded(false),
1377
+ title: "Tutup panel edit",
1378
+ children: /* @__PURE__ */ jsxDEV5(ChevronDown, {
1379
+ size: 14
1380
+ }, undefined, false, undefined, this)
1381
+ }, undefined, false, undefined, this)
1382
+ ]
1383
+ }, undefined, true, undefined, this)
1384
+ ]
1385
+ }, undefined, true, undefined, this),
1386
+ /* @__PURE__ */ jsxDEV5("div", {
1387
+ className: "flex flex-col lg:flex-row gap-6 items-start",
1388
+ children: [
1389
+ /* @__PURE__ */ jsxDEV5("div", {
1390
+ className: "w-full lg:w-48 shrink-0 lg:sticky lg:top-24",
1391
+ children: /* @__PURE__ */ jsxDEV5(BlockPalette2, {
1392
+ blocks,
1393
+ onStartPlaceDrag: startDragFromPalette,
1394
+ placingBlockId: blockDrag.placingBlockId
1395
+ }, undefined, false, undefined, this)
1396
+ }, undefined, false, undefined, this),
1397
+ /* @__PURE__ */ jsxDEV5("div", {
1398
+ className: "flex-1 flex flex-col gap-6 min-w-0",
1399
+ children: [
1400
+ /* @__PURE__ */ jsxDEV5(ZoneEditor, {
1401
+ title: "Top Zone",
1402
+ zoneKey: "top",
1403
+ zone: layout.top,
1404
+ blocks,
1405
+ activeBp,
1406
+ simulatedMaxWidth,
1407
+ onChange: (zone) => applyLayout({ ...layout, top: zone }),
1408
+ blockDrag,
1409
+ onStartBlockDrag,
1410
+ sectionDrag,
1411
+ onStartSectionDrag
1412
+ }, undefined, false, undefined, this),
1413
+ /* @__PURE__ */ jsxDEV5(ZoneEditor, {
1414
+ title: "Main Zone",
1415
+ zoneKey: "main",
1416
+ zone: layout.main,
1417
+ blocks,
1418
+ activeBp,
1419
+ simulatedMaxWidth,
1420
+ onChange: (zone) => applyLayout({ ...layout, main: zone }),
1421
+ blockDrag,
1422
+ onStartBlockDrag,
1423
+ sectionDrag,
1424
+ onStartSectionDrag
1425
+ }, undefined, false, undefined, this),
1426
+ /* @__PURE__ */ jsxDEV5(ZoneEditor, {
1427
+ title: "Bottom Zone",
1428
+ zoneKey: "bottom",
1429
+ zone: layout.bottom,
1430
+ blocks,
1431
+ activeBp,
1432
+ simulatedMaxWidth,
1433
+ onChange: (zone) => applyLayout({ ...layout, bottom: zone }),
1434
+ blockDrag,
1435
+ onStartBlockDrag,
1436
+ sectionDrag,
1437
+ onStartSectionDrag
1438
+ }, undefined, false, undefined, this),
1439
+ /* @__PURE__ */ jsxDEV5(ZoneEditor, {
1440
+ title: "Off Canvas",
1441
+ zoneKey: "offcanvas",
1442
+ zone: layout.offcanvas,
1443
+ blocks,
1444
+ activeBp,
1445
+ simulatedMaxWidth,
1446
+ onChange: (zone) => applyLayout({ ...layout, offcanvas: zone }),
1447
+ blockDrag,
1448
+ onStartBlockDrag,
1449
+ sectionDrag,
1450
+ onStartSectionDrag
1451
+ }, undefined, false, undefined, this),
1452
+ !compact && /* @__PURE__ */ jsxDEV5("div", {
1453
+ className: "rounded-lg border border-dashed border-[color:var(--color-border)] p-4 text-sm text-[color:var(--color-text-color)]",
1454
+ children: [
1455
+ "Butuh block baru? Kelola di halaman ",
1456
+ /* @__PURE__ */ jsxDEV5("a", {
1457
+ href: "/blocks",
1458
+ className: "font-semibold text-[color:var(--color-primary)] hover:underline",
1459
+ children: "Block Manager"
1460
+ }, undefined, false, undefined, this),
1461
+ "."
1462
+ ]
1463
+ }, undefined, true, undefined, this)
1464
+ ]
1465
+ }, undefined, true, undefined, this)
1466
+ ]
1467
+ }, undefined, true, undefined, this)
1468
+ ]
1469
+ }, undefined, true, undefined, this);
1470
+ const dragOverlays = /* @__PURE__ */ jsxDEV5(Fragment2, {
1471
+ children: [
1472
+ blockDrag.dragMode && draggingBlock && /* @__PURE__ */ jsxDEV5("div", {
1473
+ className: "fixed z-[100] pointer-events-none rounded-lg border border-dashed border-indigo-400 bg-[var(--color-background)] shadow-lg p-2.5 flex items-center gap-1.5",
1474
+ style: {
1475
+ left: blockDrag.dragX - blockDrag.offsetX,
1476
+ top: blockDrag.dragY - blockDrag.offsetY,
1477
+ width: blockDrag.width
1478
+ },
1479
+ children: [
1480
+ /* @__PURE__ */ jsxDEV5(GripVertical3, {
1481
+ size: 13,
1482
+ className: "text-[color:var(--color-text-color)] shrink-0"
1483
+ }, undefined, false, undefined, this),
1484
+ /* @__PURE__ */ jsxDEV5("span", {
1485
+ className: "text-xs font-semibold text-[color:var(--color-foreground)]",
1486
+ children: draggingBlock.name
1487
+ }, undefined, false, undefined, this)
1488
+ ]
1489
+ }, undefined, true, undefined, this),
1490
+ sectionDrag.draggingId && draggingSection && /* @__PURE__ */ jsxDEV5("div", {
1491
+ className: "fixed z-[100] pointer-events-none rounded-lg border-2 border-dashed border-indigo-300 bg-indigo-50/40 shadow-lg p-2.5",
1492
+ style: {
1493
+ left: sectionDrag.dragX - sectionDrag.offsetX,
1494
+ top: sectionDrag.dragY - sectionDrag.offsetY,
1495
+ width: sectionDrag.width * 0.9
1496
+ },
1497
+ children: /* @__PURE__ */ jsxDEV5("span", {
1498
+ className: "text-xs font-semibold text-indigo-500",
1499
+ children: [
1500
+ "Section: ",
1501
+ draggingSection.name || sectionHtmlId2(draggingSection)
1502
+ ]
1503
+ }, undefined, true, undefined, this)
1504
+ }, undefined, false, undefined, this)
1505
+ ]
1506
+ }, undefined, true, undefined, this);
1507
+ if (compact) {
1508
+ return /* @__PURE__ */ jsxDEV5(Fragment2, {
1509
+ children: [
1510
+ /* @__PURE__ */ jsxDEV5("div", {
1511
+ style: { height: `${compactHeightVh}vh` },
1512
+ className: "w-full shrink-0 pointer-events-none"
1513
+ }, undefined, false, undefined, this),
1514
+ /* @__PURE__ */ jsxDEV5("div", {
1515
+ className: "fixed bottom-0 left-0 right-0 z-[60] flex flex-col border-t border-border bg-card shadow-xl",
1516
+ style: { height: `${compactHeightVh}vh` },
1517
+ children: [
1518
+ /* @__PURE__ */ jsxDEV5("div", {
1519
+ onPointerDown: startCompactResize,
1520
+ className: "flex shrink-0 cursor-ns-resize items-center justify-center py-1.5 touch-none group",
1521
+ title: "Drag utk atur tinggi panel",
1522
+ children: /* @__PURE__ */ jsxDEV5("div", {
1523
+ className: "h-1 w-10 rounded-full bg-border group-hover:bg-primary transition-colors"
1524
+ }, undefined, false, undefined, this)
1525
+ }, undefined, false, undefined, this),
1526
+ /* @__PURE__ */ jsxDEV5("div", {
1527
+ className: "flex-1 overflow-y-auto p-4 pt-0",
1528
+ children: bodyContent
1529
+ }, undefined, false, undefined, this)
1530
+ ]
1531
+ }, undefined, true, undefined, this),
1532
+ dragOverlays
1533
+ ]
1534
+ }, undefined, true, undefined, this);
1535
+ }
1536
+ return /* @__PURE__ */ jsxDEV5(Fragment2, {
1537
+ children: [
1538
+ /* @__PURE__ */ jsxDEV5("div", {
1539
+ className: isFullscreen ? "fixed inset-0 z-40 bg-background overflow-y-auto p-6" : "",
1540
+ children: /* @__PURE__ */ jsxDEV5("div", {
1541
+ className: "space-y-6 py-2 bg-card p-6 rounded-2xl border border-border mx-auto shadow-xs transition-[max-width] duration-200",
1542
+ style: { maxWidth: isFullscreen ? undefined : "48rem" },
1543
+ children: bodyContent
1544
+ }, undefined, false, undefined, this)
1545
+ }, undefined, false, undefined, this),
1546
+ dragOverlays
1547
+ ]
1548
+ }, undefined, true, undefined, this);
1549
+ }
1550
+
1551
+ // src/lib/layout/useActiveBreakpoint.ts
1552
+ import * as React from "react";
1553
+ var BREAKPOINT_ORDER = ["base", "sm", "md", "lg", "xl"];
1554
+ function computeActiveBreakpoint() {
1555
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function")
1556
+ return "base";
1557
+ let resolved = "base";
1558
+ for (const bp of BREAKPOINT_ORDER) {
1559
+ if (bp === "base")
1560
+ continue;
1561
+ if (window.matchMedia(`(min-width: ${BREAKPOINT_PX2[bp]}px)`).matches)
1562
+ resolved = bp;
1563
+ }
1564
+ return resolved;
1565
+ }
1566
+ function useActiveBreakpoint2() {
1567
+ const [bp, setBp] = React.useState(() => computeActiveBreakpoint());
1568
+ React.useEffect(() => {
1569
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function")
1570
+ return;
1571
+ const queries = BREAKPOINT_ORDER.filter((b) => b !== "base").map((b) => window.matchMedia(`(min-width: ${BREAKPOINT_PX2[b]}px)`));
1572
+ const handleChange = () => setBp(computeActiveBreakpoint());
1573
+ queries.forEach((mq) => mq.addEventListener("change", handleChange));
1574
+ return () => queries.forEach((mq) => mq.removeEventListener("change", handleChange));
1575
+ }, []);
1576
+ return bp;
1577
+ }
1578
+
1579
+ // src/lib/layout/useBlockDrag.ts
1580
+ import * as React2 from "react";
1581
+ var INITIAL_DRAG = {
1582
+ dragMode: null,
1583
+ draggingId: null,
1584
+ placingBlockId: null,
1585
+ dragX: 0,
1586
+ dragY: 0,
1587
+ offsetX: 0,
1588
+ offsetY: 0,
1589
+ width: 0,
1590
+ height: 0,
1591
+ dropTargetKey: null,
1592
+ dropBeforeId: null
1593
+ };
1594
+ var ZONE_NAMES = ["top", "main", "bottom", "offcanvas"];
1595
+ function parseDropTargetKey(key) {
1596
+ const [zoneName, sectionId] = key.split(":");
1597
+ if (!ZONE_NAMES.includes(zoneName))
1598
+ return null;
1599
+ return { zoneName, sectionId: sectionId ?? null };
1600
+ }
1601
+ function getItemsAt(layout, zoneName, sectionId) {
1602
+ const zone = layout[zoneName];
1603
+ if (!zone)
1604
+ return null;
1605
+ return zone.sections.find((s) => s.id === sectionId)?.items ?? null;
1606
+ }
1607
+ function setItemsAt(layout, zoneName, sectionId, items) {
1608
+ const zone = layout[zoneName];
1609
+ const sections = zone.sections.map((s) => s.id === sectionId ? { ...s, items } : s);
1610
+ return { ...layout, [zoneName]: { ...zone, sections } };
1611
+ }
1612
+ function findItemLocation(layout, itemId) {
1613
+ for (const zoneName of ZONE_NAMES) {
1614
+ const zone = layout[zoneName];
1615
+ if (!zone)
1616
+ continue;
1617
+ for (const section of zone.sections) {
1618
+ if (section.items.some((i) => i.id === itemId))
1619
+ return { zoneName, sectionId: section.id };
1620
+ }
1621
+ }
1622
+ return null;
1623
+ }
1624
+ function useBlockDrag2(layout, onChange) {
1625
+ const [drag, setDragState] = React2.useState(INITIAL_DRAG);
1626
+ const dragRef = React2.useRef(drag);
1627
+ const layoutRef = React2.useRef(layout);
1628
+ dragRef.current = drag;
1629
+ layoutRef.current = layout;
1630
+ function setDrag(next) {
1631
+ setDragState((s) => {
1632
+ const value = typeof next === "function" ? next(s) : next;
1633
+ dragRef.current = value;
1634
+ return value;
1635
+ });
1636
+ }
1637
+ const startDrag = (itemId) => (e) => {
1638
+ e.preventDefault();
1639
+ e.stopPropagation();
1640
+ const itemEl = e.currentTarget.closest("[data-item-id]");
1641
+ const rect = itemEl ? itemEl.getBoundingClientRect() : { left: e.clientX, top: e.clientY, width: 160, height: 60 };
1642
+ document.body.style.cursor = "grabbing";
1643
+ document.body.style.userSelect = "none";
1644
+ setDrag({
1645
+ ...INITIAL_DRAG,
1646
+ dragMode: "move",
1647
+ draggingId: itemId,
1648
+ dragX: e.clientX,
1649
+ dragY: e.clientY,
1650
+ offsetX: e.clientX - rect.left,
1651
+ offsetY: e.clientY - rect.top,
1652
+ width: rect.width,
1653
+ height: rect.height
1654
+ });
1655
+ };
1656
+ const startDragFromPalette = (blockId) => (e) => {
1657
+ e.preventDefault();
1658
+ e.stopPropagation();
1659
+ const cardEl = e.currentTarget.closest("[data-palette-card]");
1660
+ const rect = cardEl ? cardEl.getBoundingClientRect() : { left: e.clientX, top: e.clientY, width: 140, height: 50 };
1661
+ document.body.style.cursor = "grabbing";
1662
+ document.body.style.userSelect = "none";
1663
+ setDrag({
1664
+ ...INITIAL_DRAG,
1665
+ dragMode: "place",
1666
+ placingBlockId: blockId,
1667
+ dragX: e.clientX,
1668
+ dragY: e.clientY,
1669
+ offsetX: e.clientX - rect.left,
1670
+ offsetY: e.clientY - rect.top,
1671
+ width: rect.width,
1672
+ height: rect.height
1673
+ });
1674
+ };
1675
+ React2.useEffect(() => {
1676
+ function handleMove(e) {
1677
+ const current = dragRef.current;
1678
+ if (!current.dragMode)
1679
+ return;
1680
+ setDrag((s) => ({ ...s, dragX: e.clientX, dragY: e.clientY }));
1681
+ const el = document.elementFromPoint(e.clientX, e.clientY);
1682
+ const targetEl = el && el.closest("[data-zone-key]");
1683
+ const dropTargetKey = targetEl ? targetEl.getAttribute("data-zone-key") : null;
1684
+ if (!dropTargetKey) {
1685
+ if (current.dropTargetKey !== null || current.dropBeforeId !== null) {
1686
+ setDrag((s) => ({ ...s, dropTargetKey: null, dropBeforeId: null }));
1687
+ }
1688
+ return;
1689
+ }
1690
+ const itemEl = el && el.closest("[data-item-id]");
1691
+ let beforeId = null;
1692
+ if (itemEl) {
1693
+ const overId = itemEl.getAttribute("data-item-id");
1694
+ const overRect = itemEl.getBoundingClientRect();
1695
+ const isBefore = e.clientX < overRect.left + overRect.width / 2;
1696
+ if (overId && overId !== current.draggingId) {
1697
+ beforeId = isBefore ? overId : null;
1698
+ if (!isBefore) {
1699
+ const siblings = Array.from(targetEl.querySelectorAll("[data-item-id]"));
1700
+ const idx = siblings.findIndex((s) => s.getAttribute("data-item-id") === overId);
1701
+ const next = siblings[idx + 1];
1702
+ beforeId = next ? next.getAttribute("data-item-id") : null;
1703
+ }
1704
+ }
1705
+ }
1706
+ if (current.dropTargetKey !== dropTargetKey || current.dropBeforeId !== beforeId) {
1707
+ setDrag((s) => ({ ...s, dropTargetKey, dropBeforeId: beforeId }));
1708
+ }
1709
+ }
1710
+ function handleUp() {
1711
+ document.body.style.cursor = "";
1712
+ document.body.style.userSelect = "";
1713
+ const current = dragRef.current;
1714
+ if (!current.dragMode)
1715
+ return;
1716
+ const targetKey = current.dropTargetKey;
1717
+ const beforeId = current.dropBeforeId;
1718
+ if (targetKey) {
1719
+ const target = parseDropTargetKey(targetKey);
1720
+ if (target) {
1721
+ let layoutNow = layoutRef.current;
1722
+ let targetSectionId = target.sectionId;
1723
+ if (!targetSectionId) {
1724
+ const newSection = createSection2();
1725
+ const zone = layoutNow[target.zoneName] ?? { sections: [] };
1726
+ layoutNow = { ...layoutNow, [target.zoneName]: { ...zone, sections: [...zone.sections, newSection] } };
1727
+ targetSectionId = newSection.id;
1728
+ }
1729
+ if (current.dragMode === "move" && current.draggingId) {
1730
+ const draggingId = current.draggingId;
1731
+ const source = findItemLocation(layoutNow, draggingId);
1732
+ if (source) {
1733
+ const sourceItems = getItemsAt(layoutNow, source.zoneName, source.sectionId);
1734
+ const draggedItem = sourceItems.find((i) => i.id === draggingId);
1735
+ const sourceItemsWithout = sourceItems.filter((i) => i.id !== draggingId);
1736
+ const isSameTarget = source.zoneName === target.zoneName && source.sectionId === targetSectionId;
1737
+ const targetItems = isSameTarget ? sourceItemsWithout : [...getItemsAt(layoutNow, target.zoneName, targetSectionId) ?? []];
1738
+ const insertIdx = beforeId ? targetItems.findIndex((i) => i.id === beforeId) : -1;
1739
+ if (insertIdx !== -1)
1740
+ targetItems.splice(insertIdx, 0, draggedItem);
1741
+ else
1742
+ targetItems.push(draggedItem);
1743
+ let nextLayout = setItemsAt(layoutNow, source.zoneName, source.sectionId, sourceItemsWithout);
1744
+ nextLayout = setItemsAt(nextLayout, target.zoneName, targetSectionId, targetItems);
1745
+ onChange(nextLayout);
1746
+ } else {
1747
+ onChange(layoutNow);
1748
+ }
1749
+ } else if (current.dragMode === "place" && current.placingBlockId) {
1750
+ const targetItems = [...getItemsAt(layoutNow, target.zoneName, targetSectionId) ?? []];
1751
+ const newItem = {
1752
+ id: `item-${crypto.randomUUID()}`,
1753
+ blockId: current.placingBlockId,
1754
+ grid: { span: { base: 12 } }
1755
+ };
1756
+ const insertIdx = beforeId ? targetItems.findIndex((i) => i.id === beforeId) : -1;
1757
+ if (insertIdx !== -1)
1758
+ targetItems.splice(insertIdx, 0, newItem);
1759
+ else
1760
+ targetItems.push(newItem);
1761
+ const nextLayout = setItemsAt(layoutNow, target.zoneName, targetSectionId, targetItems);
1762
+ onChange(nextLayout);
1763
+ }
1764
+ }
1765
+ }
1766
+ setDrag(INITIAL_DRAG);
1767
+ }
1768
+ window.addEventListener("pointermove", handleMove);
1769
+ window.addEventListener("pointerup", handleUp);
1770
+ return () => {
1771
+ window.removeEventListener("pointermove", handleMove);
1772
+ window.removeEventListener("pointerup", handleUp);
1773
+ };
1774
+ }, [onChange]);
1775
+ return { drag, startDrag, startDragFromPalette };
1776
+ }
1777
+
1778
+ // src/lib/layout/useSectionDrag.ts
1779
+ import * as React3 from "react";
1780
+ var INITIAL_DRAG2 = {
1781
+ draggingId: null,
1782
+ dragX: 0,
1783
+ dragY: 0,
1784
+ offsetX: 0,
1785
+ offsetY: 0,
1786
+ width: 0,
1787
+ height: 0,
1788
+ dropZoneKey: null,
1789
+ dropBeforeId: null
1790
+ };
1791
+ var ZONE_NAMES2 = ["top", "main", "bottom", "offcanvas"];
1792
+ function findSectionZone(layout, sectionId) {
1793
+ for (const zoneName of ZONE_NAMES2) {
1794
+ if (layout[zoneName]?.sections.some((s) => s.id === sectionId))
1795
+ return zoneName;
1796
+ }
1797
+ return null;
1798
+ }
1799
+ function useSectionDrag2(layout, onChange) {
1800
+ const [drag, setDragState] = React3.useState(INITIAL_DRAG2);
1801
+ const dragRef = React3.useRef(drag);
1802
+ const layoutRef = React3.useRef(layout);
1803
+ dragRef.current = drag;
1804
+ layoutRef.current = layout;
1805
+ function setDrag(next) {
1806
+ setDragState((s) => {
1807
+ const value = typeof next === "function" ? next(s) : next;
1808
+ dragRef.current = value;
1809
+ return value;
1810
+ });
1811
+ }
1812
+ const startSectionDrag = (sectionId) => (e) => {
1813
+ e.preventDefault();
1814
+ e.stopPropagation();
1815
+ const sectionEl = e.currentTarget.closest("[data-section-id]");
1816
+ const rect = sectionEl ? sectionEl.getBoundingClientRect() : { left: e.clientX, top: e.clientY, width: 300, height: 80 };
1817
+ document.body.style.cursor = "grabbing";
1818
+ document.body.style.userSelect = "none";
1819
+ setDrag({
1820
+ draggingId: sectionId,
1821
+ dragX: e.clientX,
1822
+ dragY: e.clientY,
1823
+ offsetX: e.clientX - rect.left,
1824
+ offsetY: e.clientY - rect.top,
1825
+ width: rect.width,
1826
+ height: rect.height,
1827
+ dropZoneKey: null,
1828
+ dropBeforeId: null
1829
+ });
1830
+ };
1831
+ React3.useEffect(() => {
1832
+ function handleMove(e) {
1833
+ const current = dragRef.current;
1834
+ if (!current.draggingId)
1835
+ return;
1836
+ setDrag((s) => ({ ...s, dragX: e.clientX, dragY: e.clientY }));
1837
+ const el = document.elementFromPoint(e.clientX, e.clientY);
1838
+ const zoneEl = el && el.closest("[data-section-zone]");
1839
+ const zoneKey = zoneEl ? zoneEl.getAttribute("data-section-zone") : null;
1840
+ if (!zoneKey) {
1841
+ if (current.dropZoneKey !== null || current.dropBeforeId !== null) {
1842
+ setDrag((s) => ({ ...s, dropZoneKey: null, dropBeforeId: null }));
1843
+ }
1844
+ return;
1845
+ }
1846
+ const sectionEl = el && el.closest("[data-section-id]");
1847
+ let beforeId = null;
1848
+ if (sectionEl) {
1849
+ const overId = sectionEl.getAttribute("data-section-id");
1850
+ const overRect = sectionEl.getBoundingClientRect();
1851
+ const isBefore = e.clientY < overRect.top + overRect.height / 2;
1852
+ if (overId && overId !== current.draggingId) {
1853
+ beforeId = isBefore ? overId : null;
1854
+ if (!isBefore) {
1855
+ const siblings = Array.from(zoneEl.querySelectorAll("[data-section-id]"));
1856
+ const idx = siblings.findIndex((s) => s.getAttribute("data-section-id") === overId);
1857
+ const next = siblings[idx + 1];
1858
+ beforeId = next ? next.getAttribute("data-section-id") : null;
1859
+ }
1860
+ }
1861
+ }
1862
+ if (current.dropZoneKey !== zoneKey || current.dropBeforeId !== beforeId) {
1863
+ setDrag((s) => ({ ...s, dropZoneKey: zoneKey, dropBeforeId: beforeId }));
1864
+ }
1865
+ }
1866
+ function handleUp() {
1867
+ document.body.style.cursor = "";
1868
+ document.body.style.userSelect = "";
1869
+ const current = dragRef.current;
1870
+ if (!current.draggingId)
1871
+ return;
1872
+ const draggingId = current.draggingId;
1873
+ const targetZoneKey = current.dropZoneKey;
1874
+ const beforeId = current.dropBeforeId;
1875
+ if (targetZoneKey) {
1876
+ const layoutNow = layoutRef.current;
1877
+ const sourceZoneKey = findSectionZone(layoutNow, draggingId);
1878
+ if (sourceZoneKey) {
1879
+ const sourceZone = layoutNow[sourceZoneKey];
1880
+ const draggedSection = sourceZone.sections.find((s) => s.id === draggingId);
1881
+ const sourceSections = sourceZone.sections.filter((s) => s.id !== draggingId);
1882
+ const isSameZone = sourceZoneKey === targetZoneKey;
1883
+ const targetZone = isSameZone ? { ...sourceZone, sections: sourceSections } : layoutNow[targetZoneKey] ?? { sections: [] };
1884
+ const targetSections = isSameZone ? sourceSections : [...targetZone.sections];
1885
+ const insertIdx = beforeId ? targetSections.findIndex((s) => s.id === beforeId) : -1;
1886
+ if (insertIdx !== -1)
1887
+ targetSections.splice(insertIdx, 0, draggedSection);
1888
+ else
1889
+ targetSections.push(draggedSection);
1890
+ const nextLayout = { ...layoutNow };
1891
+ if (isSameZone) {
1892
+ nextLayout[targetZoneKey] = { ...targetZone, sections: targetSections };
1893
+ } else {
1894
+ nextLayout[sourceZoneKey] = { ...sourceZone, sections: sourceSections };
1895
+ nextLayout[targetZoneKey] = { ...targetZone, sections: targetSections };
1896
+ }
1897
+ onChange(nextLayout);
1898
+ }
1899
+ }
1900
+ setDrag(INITIAL_DRAG2);
1901
+ }
1902
+ window.addEventListener("pointermove", handleMove);
1903
+ window.addEventListener("pointerup", handleUp);
1904
+ return () => {
1905
+ window.removeEventListener("pointermove", handleMove);
1906
+ window.removeEventListener("pointerup", handleUp);
1907
+ };
1908
+ }, [onChange]);
1909
+ return { drag, startSectionDrag };
1910
+ }
1911
+
1912
+ // src/lib/layout/useSpanResize.ts
1913
+ import * as React4 from "react";
1914
+ var INITIAL_DRAG3 = {
1915
+ draggingItemId: null,
1916
+ startX: 0,
1917
+ startSpan: 0,
1918
+ columnWidthPx: 0,
1919
+ liveSpan: 0
1920
+ };
1921
+ function useSpanResize2(zone, activeBp, onChange) {
1922
+ const rowRef = React4.useRef(null);
1923
+ const [drag, setDragState] = React4.useState(INITIAL_DRAG3);
1924
+ const dragRef = React4.useRef(drag);
1925
+ const zoneRef = React4.useRef(zone);
1926
+ dragRef.current = drag;
1927
+ zoneRef.current = zone;
1928
+ function setDrag(next) {
1929
+ setDragState((s) => {
1930
+ const value = typeof next === "function" ? next(s) : next;
1931
+ dragRef.current = value;
1932
+ return value;
1933
+ });
1934
+ }
1935
+ const startResize = (itemId) => (e) => {
1936
+ e.preventDefault();
1937
+ e.stopPropagation();
1938
+ const rowEl = rowRef.current;
1939
+ if (!rowEl)
1940
+ return;
1941
+ const rowWidth = rowEl.getBoundingClientRect().width;
1942
+ const columnWidthPx = rowWidth / 12;
1943
+ const item = zoneRef.current.items.find((i) => i.id === itemId);
1944
+ if (!item)
1945
+ return;
1946
+ const startSpan = item.grid.span[activeBp] ?? item.grid.span.base;
1947
+ document.body.style.cursor = "col-resize";
1948
+ document.body.style.userSelect = "none";
1949
+ setDrag({
1950
+ draggingItemId: itemId,
1951
+ startX: e.clientX,
1952
+ startSpan,
1953
+ columnWidthPx,
1954
+ liveSpan: startSpan
1955
+ });
1956
+ };
1957
+ React4.useEffect(() => {
1958
+ function handleMove(e) {
1959
+ const current = dragRef.current;
1960
+ if (!current.draggingItemId || !current.columnWidthPx)
1961
+ return;
1962
+ const deltaX = e.clientX - current.startX;
1963
+ const deltaSpan = Math.round(deltaX / current.columnWidthPx);
1964
+ const nextSpan = Math.min(12, Math.max(1, current.startSpan + deltaSpan));
1965
+ if (nextSpan !== current.liveSpan) {
1966
+ setDrag((s) => ({ ...s, liveSpan: nextSpan }));
1967
+ }
1968
+ }
1969
+ function handleUp() {
1970
+ document.body.style.cursor = "";
1971
+ document.body.style.userSelect = "";
1972
+ const current = dragRef.current;
1973
+ if (!current.draggingItemId)
1974
+ return;
1975
+ const items = zoneRef.current.items.map((item) => item.id === current.draggingItemId ? { ...item, grid: { ...item.grid, span: { ...item.grid.span, [activeBp]: current.liveSpan } } } : item);
1976
+ onChange({ ...zoneRef.current, items });
1977
+ setDrag(INITIAL_DRAG3);
1978
+ }
1979
+ window.addEventListener("pointermove", handleMove);
1980
+ window.addEventListener("pointerup", handleUp);
1981
+ return () => {
1982
+ window.removeEventListener("pointermove", handleMove);
1983
+ window.removeEventListener("pointerup", handleUp);
1984
+ };
1985
+ }, [activeBp, onChange]);
1986
+ return { rowRef, drag, startResize };
1987
+ }
1988
+
1989
+ // src/lib/useUndoRedo.ts
1990
+ import { useCallback, useRef as useRef4, useState as useState9 } from "react";
1991
+ function useUndoRedo2(initial) {
1992
+ const [history, setHistory] = useState9([initial]);
1993
+ const [pointer, setPointer] = useState9(0);
1994
+ const historyRef = useRef4(history);
1995
+ const pointerRef = useRef4(pointer);
1996
+ historyRef.current = history;
1997
+ pointerRef.current = pointer;
1998
+ const push = useCallback((next) => {
1999
+ const trimmed = historyRef.current.slice(0, pointerRef.current + 1);
2000
+ const nextHistory = [...trimmed, next];
2001
+ setHistory(nextHistory);
2002
+ setPointer(nextHistory.length - 1);
2003
+ }, []);
2004
+ const undo = useCallback(() => {
2005
+ if (pointerRef.current <= 0)
2006
+ return;
2007
+ const nextPointer = pointerRef.current - 1;
2008
+ setPointer(nextPointer);
2009
+ return historyRef.current[nextPointer];
2010
+ }, []);
2011
+ const redo = useCallback(() => {
2012
+ if (pointerRef.current >= historyRef.current.length - 1)
2013
+ return;
2014
+ const nextPointer = pointerRef.current + 1;
2015
+ setPointer(nextPointer);
2016
+ return historyRef.current[nextPointer];
2017
+ }, []);
2018
+ const reset = useCallback((value) => {
2019
+ setHistory([value]);
2020
+ setPointer(0);
2021
+ }, []);
2022
+ return {
2023
+ push,
2024
+ undo,
2025
+ redo,
2026
+ reset,
2027
+ canUndo: pointer > 0,
2028
+ canRedo: pointer < history.length - 1
2029
+ };
2030
+ }
2031
+
2032
+ export { LayoutContext2, useLayoutContext2, ContainerBox2, renderSection2, DynamicLayout2, BlockPalette2, WidgetFieldsForm2, GridRow2, LayoutBuilder2, useActiveBreakpoint2, useBlockDrag2, useSectionDrag2, useSpanResize2, useUndoRedo2 };
2033
+
2034
+ //# debugId=CBF52138AEDA894A64756E2164756E21