@chaibuilder/sdk 4.0.0-beta.4 → 4.0.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -50
- package/dist/{2SSKDMRQ-Difo_1pg.js → 2SSKDMRQ-CdpXONNF.js} +3 -3
- package/dist/{2SSKDMRQ-CopJgtZb.cjs → 2SSKDMRQ-Dq_oq6gn.cjs} +1 -1
- package/dist/{AP7HFJJL-BPuPBqj4.js → AP7HFJJL-CZb0rAxI.js} +1 -1
- package/dist/{AP7HFJJL-DYxDgaOs.cjs → AP7HFJJL-Do14BULM.cjs} +1 -1
- package/dist/{IconPicker-B2-oriq2.js → IconPicker-CvZSjXc6.js} +2 -2
- package/dist/{IconPicker-C0oycHbs.cjs → IconPicker-DUN9bxmQ.cjs} +1 -1
- package/dist/STRINGS-BExFecZW.js +8 -0
- package/dist/STRINGS-FNnfjF5H.cjs +1 -0
- package/dist/{WDYDFRGG-DbejaRPK.cjs → WDYDFRGG-DfczfcZ8.cjs} +1 -1
- package/dist/{WDYDFRGG-KK8pkcW1.js → WDYDFRGG-Dxa2zFdt.js} +4 -4
- package/dist/{actions-registery-y_ENc8zj.js → actions-registery-CMKfEXxX.js} +3397 -3202
- package/dist/actions-registery-CqhNZFV3.cjs +481 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +0 -158
- package/dist/actions.js +3 -3
- package/dist/{active-in-another-tab-DkR2HWI4.js → active-in-another-tab-BREv3Xj8.js} +5 -5
- package/dist/{active-in-another-tab-Cu_ASKtx.cjs → active-in-another-tab-C9o276yY.cjs} +1 -1
- package/dist/{add-new-language-page-CBY0RR6q.js → add-new-language-page-C4PSVDV5.js} +4 -4
- package/dist/{add-new-language-page-BXuwluuU.cjs → add-new-language-page-jHLJjrl1.cjs} +1 -1
- package/dist/{add-new-page-C_PzKby8.cjs → add-new-page-BPPMxBYi.cjs} +1 -1
- package/dist/add-new-page-DomZuT16.js +31 -0
- package/dist/{ai-panel-content--YM01Aly.js → ai-panel-content-CsmUoTCg.js} +6 -6
- package/dist/{ai-panel-content-rRmJdH7L.cjs → ai-panel-content-DlS51Qef.cjs} +1 -1
- package/dist/ai-panel-default-lang-BRVlAMMU.js +317 -0
- package/dist/ai-panel-default-lang-DVKDEnbe.cjs +3 -0
- package/dist/ai-panel-other-lang-B-2xJz2W.cjs +1 -0
- package/dist/ai-panel-other-lang-BPVS6lO_.js +132 -0
- package/dist/{ai-prompt-input-DueQYNf-.js → ai-prompt-input-B0FMhaLB.js} +30 -34
- package/dist/{ai-prompt-input-N9PcYCFa.cjs → ai-prompt-input-CY2pBPzO.cjs} +1 -1
- package/dist/{ai-translation-prompt-B36F3d7K.js → ai-translation-prompt-6LlaU9LO.js} +2 -2
- package/dist/{ai-translation-prompt-IAdWMNZb.cjs → ai-translation-prompt-BwhKmgC3.cjs} +1 -1
- package/dist/apply-binding-BuwI_Uf5.cjs +41 -0
- package/dist/apply-binding-RQRSIe56.js +942 -0
- package/dist/change-password-modal-BlSTfit6.js +137 -0
- package/dist/change-password-modal-wbCcGfDM.cjs +1 -0
- package/dist/{code-display-DloSPyPr.cjs → code-display-BR-gij5j.cjs} +1 -1
- package/dist/{code-display-Ck81Id9K.js → code-display-DdWcOQ_i.js} +1 -1
- package/dist/code-editor-BC_saYAw.cjs +1 -0
- package/dist/code-editor-Be5VT6om.js +57 -0
- package/dist/{continue-editing-in-this-client-DmGFLHXw.cjs → continue-editing-in-this-client-Bs_3q1hH.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-Dm9cCj7K.js → continue-editing-in-this-client-Z1rBUPU8.js} +3 -3
- package/dist/core-czmLeR0h.cjs +1 -0
- package/dist/core-nSRy3D7z.js +54 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +285 -103
- package/dist/core.js +71 -42
- package/dist/{css-import-modal-9P_0uNa4.js → css-import-modal-DMZRgpy0.js} +8 -8
- package/dist/{css-import-modal-Rh1QAVxo.cjs → css-import-modal-QaTHJ7CT.cjs} +1 -1
- package/dist/delete-page-BoP3I06P.js +84 -0
- package/dist/delete-page-CjXYHAsS.cjs +1 -0
- package/dist/{design-token-usage-MNYsFlPG.js → design-token-usage-DFanW2r-.js} +26 -26
- package/dist/{design-token-usage-CXglXgcJ.cjs → design-token-usage-kEPgi-3C.cjs} +1 -1
- package/dist/{digital-asset-manager-CqCWBO0s.js → digital-asset-manager-BbI7Ye34.js} +6 -6
- package/dist/digital-asset-manager-N8tcW28y.cjs +1 -0
- package/dist/{duplicate-page-DzZByALW.cjs → duplicate-page-B-4nFU4j.cjs} +1 -1
- package/dist/{duplicate-page-BknLfqr0.js → duplicate-page-C6y7FdRQ.js} +7 -7
- package/dist/{dynamic-page-selector-WA007Sni.cjs → dynamic-page-selector-Cq4U-49i.cjs} +1 -1
- package/dist/{dynamic-page-selector-DoW7OyUB.js → dynamic-page-selector-DQCWphi0.js} +16 -16
- package/dist/fonts/bungee/Bungee-Regular.woff2 +0 -0
- package/dist/fonts/dm_sans/dm-sans-variable.woff2 +0 -0
- package/dist/fonts/geist/Geist-VariableFont_wght.ttf +0 -0
- package/dist/fonts/geist/Geist-VariableFont_wght.woff2 +0 -0
- package/dist/fonts/geist/geist-variable.woff2 +0 -0
- package/dist/fonts/geist-mono/GeistMono-VariableFont_wght.woff2 +0 -0
- package/dist/fonts/inter/inter-latin.woff2 +0 -0
- package/dist/fonts/inter/inter-variable.woff2 +1449 -0
- package/dist/fonts/lato/lato-variable.woff2 +0 -0
- package/dist/fonts/lavishly_yours/lavishly-yours.woff2 +11 -0
- package/dist/fonts/merriweather/merriweather-variable.woff2 +11 -0
- package/dist/fonts/montserrat/montserrat-variable.woff2 +0 -0
- package/dist/fonts/nunito_sans/nunito-sans-variable.woff2 +11 -0
- package/dist/fonts/open_sans/open-sans-variable.woff2 +0 -0
- package/dist/fonts/oswald/oswald-variable.woff2 +0 -0
- package/dist/fonts/playfair_display/playfair-display-variable.woff2 +11 -0
- package/dist/fonts/poppins/poppins-variable.woff2 +0 -0
- package/dist/fonts/raleway/raleway-variable.woff2 +0 -0
- package/dist/fonts/roboto/roboto-variable.woff2 +11 -0
- package/dist/fonts/source_sans_3/source-sans-3-variable.woff2 +11 -0
- package/dist/fonts/ubuntu/ubuntu-variable.woff2 +0 -0
- package/dist/fonts-B3UYxuJI.js +25 -0
- package/dist/fonts-D5fTqvSS.cjs +1 -0
- package/dist/{get-chai-builder-tailwind-config-BFePCEIS.cjs → get-chai-builder-tailwind-config-7CxFxEYL.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BXf_xLHk.js → get-chai-builder-tailwind-config-DC4sDOYK.js} +5 -5
- package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-B5RkBTsB.cjs} +1 -1
- package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-BpuwSLeS.js} +1 -1
- package/dist/{image-compression-DsZ1oqpb.js → image-compression-DPFITwOL.js} +2 -2
- package/dist/image-compression-UaU7Bwqe.cjs +1 -0
- package/dist/{image-editor-CqwaVxO2.cjs → image-editor-565A0NpE.cjs} +1 -1
- package/dist/{image-editor-CQnNtak2.js → image-editor-Dz_HQ0I8.js} +1 -1
- package/dist/index-3pEi7VzS.cjs +5 -0
- package/dist/index-C3CV1lXL.cjs +160 -0
- package/dist/index-CDVuf3C1.js +5118 -0
- package/dist/{index-rAcNbjk_.js → index-wBr2Ml98.js} +6152 -6102
- package/dist/{json-diff-viewer-CLuUHiPU.cjs → json-diff-viewer-CMYFM6D6.cjs} +7 -7
- package/dist/{json-diff-viewer-CMvGUvJ2.js → json-diff-viewer-DG7a5-2B.js} +87 -85
- package/dist/{lang-panel-CnwTb05j.js → lang-panel-BvGiJJ8s.js} +26 -26
- package/dist/lang-panel-D97iJH-l.cjs +1 -0
- package/dist/library-blocks/bento/agency-showcase/agency-showcase.html +175 -0
- package/dist/library-blocks/bento/agency-showcase/agency-showcase.webp +0 -0
- package/dist/library-blocks/bento/creative-portfolio/creative-portfolio.html +116 -0
- package/dist/library-blocks/bento/creative-portfolio/creative-portfolio.webp +0 -0
- package/dist/library-blocks/bento/product-features/product-features.html +159 -0
- package/dist/library-blocks/bento/product-features/product-features.webp +0 -0
- package/dist/library-blocks/bento/saas-dashboard/saas-dashboard.html +182 -0
- package/dist/library-blocks/bento/saas-dashboard/saas-dashboard.webp +0 -0
- package/dist/library-blocks/bento/startup-metrics/startup-metrics.html +170 -0
- package/dist/library-blocks/bento/startup-metrics/startup-metrics.webp +0 -0
- package/dist/library-blocks/blocks-list.json +149 -0
- package/dist/library-blocks/feature/agency-services/agency-services.html +194 -0
- package/dist/library-blocks/feature/agency-services/agency-services.webp +0 -0
- package/dist/library-blocks/feature/consulting-firm/consulting-firm.html +219 -0
- package/dist/library-blocks/feature/consulting-firm/consulting-firm.webp +0 -0
- package/dist/library-blocks/feature/design-studio/design-studio.html +190 -0
- package/dist/library-blocks/feature/design-studio/design-studio.webp +0 -0
- package/dist/library-blocks/feature/freelancer-toolkit/freelancer-toolkit.html +195 -0
- package/dist/library-blocks/feature/freelancer-toolkit/freelancer-toolkit.webp +0 -0
- package/dist/library-blocks/feature/marketing-agency/marketing-agency.html +212 -0
- package/dist/library-blocks/feature/marketing-agency/marketing-agency.webp +0 -0
- package/dist/library-blocks/footer/creative-agency/creative-agency.html +64 -0
- package/dist/library-blocks/footer/creative-agency/creative-agency.webp +0 -0
- package/dist/library-blocks/footer/minimal-portfolio/minimal-portfolio.html +106 -0
- package/dist/library-blocks/footer/minimal-portfolio/minimal-portfolio.webp +0 -0
- package/dist/library-blocks/footer/saas-startup/saas-startup.html +117 -0
- package/dist/library-blocks/footer/saas-startup/saas-startup.webp +0 -0
- package/dist/library-blocks/hero/creative-agency/creative-agency.html +117 -0
- package/dist/library-blocks/hero/creative-agency/creative-agency.webp +0 -0
- package/dist/library-blocks/hero/developer-focused/developer-focused.html +124 -0
- package/dist/library-blocks/hero/developer-focused/developer-focused.webp +0 -0
- package/dist/library-blocks/hero/minimal-saas/minimal-saas.html +98 -0
- package/dist/library-blocks/hero/minimal-saas/minimal-saas.webp +0 -0
- package/dist/library-blocks/hero/portfolio-showcase/portfolio-showcase.html +148 -0
- package/dist/library-blocks/hero/portfolio-showcase/portfolio-showcase.webp +0 -0
- package/dist/library-blocks/hero/startup-landing/startup-landing.html +130 -0
- package/dist/library-blocks/hero/startup-landing/startup-landing.webp +0 -0
- package/dist/library-blocks/navbar/creative-agency/creative-agency.html +139 -0
- package/dist/library-blocks/navbar/creative-agency/creative-agency.webp +0 -0
- package/dist/library-blocks/navbar/minimal-portfolio/minimal-portfolio.html +164 -0
- package/dist/library-blocks/navbar/minimal-portfolio/minimal-portfolio.webp +0 -0
- package/dist/library-blocks/navbar/saas-startup/saas-startup.html +129 -0
- package/dist/library-blocks/navbar/saas-startup/saas-startup.webp +0 -0
- package/dist/manage-design-tokens-4Gu6TMKZ.js +446 -0
- package/dist/manage-design-tokens-Do9Kptp3.cjs +1 -0
- package/dist/manage-design-tokens-modal-Btbdgoun.cjs +1 -0
- package/dist/manage-design-tokens-modal-CkyFE8NW.js +161 -0
- package/dist/{mark-as-template-DBLshWb5.js → mark-as-template-Djhnj93U.js} +11 -11
- package/dist/{mark-as-template-CpWEBJGd.cjs → mark-as-template-QPJ0DqxL.cjs} +1 -1
- package/dist/{nested-path-selector-content-C2sD9dkq.cjs → nested-path-selector-content-BcmSxXxL.cjs} +1 -1
- package/dist/{nested-path-selector-content-6OBJ8LG8.js → nested-path-selector-content-DkPIHcVj.js} +2 -2
- package/dist/{no-language-page-content-CzENgtnu.js → no-language-page-content-DTq-5StU.js} +9 -9
- package/dist/{no-language-page-content-BvPDdccK.cjs → no-language-page-content-ZQz4Kr0-.cjs} +1 -1
- package/dist/{no-language-page-dialog-CbYI2cVg.js → no-language-page-dialog-2rA-YBbC.js} +2 -2
- package/dist/{no-language-page-dialog-CgW4yJBC.cjs → no-language-page-dialog-BsLkwJID.cjs} +1 -1
- package/dist/{page-creator-Cc83uQqw.js → page-creator-Dzpc0_dN.js} +143 -143
- package/dist/page-creator-lcDUpPjh.cjs +1 -0
- package/dist/{page-lock-CT7SmQqp.cjs → page-lock-B2GU-1YM.cjs} +1 -1
- package/dist/{page-lock-BJUkyxdh.js → page-lock-ulFtdOkt.js} +2 -2
- package/dist/{page-locked-dialog-DsEbWRed.js → page-locked-dialog-B9VpkvhN.js} +22 -22
- package/dist/page-locked-dialog-CJ53Z6sQ.cjs +1 -0
- package/dist/page-manager-new-CkoS0B1i.cjs +1 -0
- package/dist/page-manager-new-OoC8W7Yn.js +408 -0
- package/dist/{page-manager-search-and-filter-Bfm0j1gg.cjs → page-manager-search-and-filter-BosoN3wg.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-zq-LfhQ1.js → page-manager-search-and-filter-JfSTGlvp.js} +30 -29
- package/dist/{page-revisions-content-D38G2tJM.js → page-revisions-content-DsFh5itr.js} +133 -122
- package/dist/page-revisions-content-Dtd-t1N3.cjs +1 -0
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +330 -96
- package/dist/pages.js +23 -19
- package/dist/plugin-BSjgGgwo.js +248 -0
- package/dist/plugin-DHpuZZXz.cjs +22 -0
- package/dist/publish-pages-content-C7oS7pkz.cjs +1 -0
- package/dist/{publish-pages-content-CS7f41Ac.js → publish-pages-content-DJc7iu8d.js} +39 -39
- package/dist/{register-chai-top-bar-ESJHs5s-.js → register-chai-top-bar-D6GjnauV.js} +87 -87
- package/dist/register-chai-top-bar-DyW9GPzV.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +20 -18
- package/dist/render.js +133 -132
- package/dist/{rte-widget-modal-BKNx2wln.cjs → rte-widget-modal-BKQaoxh9.cjs} +1 -1
- package/dist/{rte-widget-modal-D6Zik0Ta.js → rte-widget-modal-BdBYmqgs.js} +10 -10
- package/dist/runtime-client.cjs +1 -0
- package/dist/runtime-client.d.ts +158 -0
- package/dist/runtime-client.js +32 -0
- package/dist/runtime.cjs +11 -1
- package/dist/runtime.d.ts +153 -270
- package/dist/runtime.js +107 -71
- package/dist/{save-to-lib-WwOzbgiF.js → save-to-lib-5nwSdZ9R.js} +153 -147
- package/dist/save-to-lib-D0WdH4lq.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-B1SG_UXw.js → selected-block-display-D8ROZHHv.js} +12 -12
- package/dist/{selected-block-display-BOgnQRLF.cjs → selected-block-display-DjYeUPdU.cjs} +1 -1
- package/dist/{seo-panel-BkOgRoWd.js → seo-panel-BbyRNAEo.js} +27 -27
- package/dist/seo-panel-DRjSxmk5.cjs +2 -0
- package/dist/shared-json-ld-BbNLdzCO.cjs +1 -0
- package/dist/{shared-json-ld-uka9TOgA.js → shared-json-ld-EPbpTI9V.js} +88 -88
- package/dist/{slug-input-Cyd6NR6J.cjs → slug-input-CIzxXknM.cjs} +1 -1
- package/dist/{slug-input-DHLmUNrH.js → slug-input-DSbJecNr.js} +8 -8
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +45 -0
- package/dist/supabase-actions.js +380 -275
- package/dist/{take-over-request-Ca0X-qyf.js → take-over-request-BOGDk0H4.js} +13 -13
- package/dist/take-over-request-BXntCMdj.cjs +1 -0
- package/dist/{translation-warning-modal-pSZVKcNW.cjs → translation-warning-modal-DhJaOyLo.cjs} +1 -1
- package/dist/{translation-warning-modal-DrpFeI83.js → translation-warning-modal-reVr0L9e.js} +9 -9
- package/dist/types.cjs +1 -0
- package/dist/types.d.ts +756 -0
- package/dist/types.js +1 -0
- package/dist/{unmark-as-template-BMqgelv-.js → unmark-as-template-BM85Y7WK.js} +11 -11
- package/dist/{unmark-as-template-DF1Ms4VN.cjs → unmark-as-template-DOPyeU7R.cjs} +1 -1
- package/dist/unpublish-page-DHfds-1-.js +28 -0
- package/dist/{unpublish-page-Bsq2yEqQ.cjs → unpublish-page-Dz028Bzp.cjs} +1 -1
- package/dist/unpublished-partials-modal-BO5ZZdTw.js +52 -0
- package/dist/unpublished-partials-modal-CMqQa9-m.cjs +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +2 -2
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +360 -351
- package/dist/{web-preview-kres0aG7.cjs → web-preview-5MzixBt5.cjs} +1 -1
- package/dist/{web-preview-D6h1L2nV.js → web-preview-BNjG8s8A.js} +2 -2
- package/package.json +34 -35
- package/dist/actions-registery-JdxhXhT6.cjs +0 -418
- package/dist/add-new-page-DJLJFLAd.js +0 -31
- package/dist/ai-panel-default-lang-BZl0tPYo.js +0 -341
- package/dist/ai-panel-default-lang-D2zhXvKP.cjs +0 -3
- package/dist/ai-panel-other-lang-Bfjk2CYZ.js +0 -162
- package/dist/ai-panel-other-lang-Y4bEKHoG.cjs +0 -1
- package/dist/apply-binding-BvWfJCSZ.js +0 -841
- package/dist/apply-binding-IsUf6UWJ.cjs +0 -1
- package/dist/code-editor-Bb7JumZy.js +0 -51
- package/dist/code-editor-DQB8lAOk.cjs +0 -1
- package/dist/core-Dr7QYemB.js +0 -56
- package/dist/core-Y0lXLwkq.cjs +0 -1
- package/dist/delete-design-token-BG8yHcS5.cjs +0 -1
- package/dist/delete-design-token-COvR4G1S.js +0 -40
- package/dist/delete-page-CNucxe4P.js +0 -71
- package/dist/delete-page-DAvEjHwF.cjs +0 -1
- package/dist/digital-asset-manager-CB5MRBcW.cjs +0 -1
- package/dist/fonts/GeistMonoVF.woff +0 -0
- package/dist/fonts/GeistVF.woff +0 -0
- package/dist/fonts-B-Xt29pe.cjs +0 -1
- package/dist/fonts-DRly3Wzd.js +0 -78
- package/dist/image-compression-DZ9WMmyn.cjs +0 -1
- package/dist/index-B-rSiAp_.cjs +0 -1
- package/dist/index-C0-pgg_p.cjs +0 -5
- package/dist/index-C99FhuF1.cjs +0 -160
- package/dist/index-Dno42B0a.js +0 -4734
- package/dist/index-Dxfyt4d4.js +0 -39
- package/dist/lang-panel-fDCYm5Jm.cjs +0 -1
- package/dist/manage-design-tokens-BsSZE9Vs.js +0 -241
- package/dist/manage-design-tokens-BvH5KTJX.cjs +0 -1
- package/dist/page-creator-g8GqgcKH.cjs +0 -1
- package/dist/page-locked-dialog-Co5b9XIZ.cjs +0 -1
- package/dist/page-manager-new-5rFP5DyQ.js +0 -395
- package/dist/page-manager-new-BOkJImo2.cjs +0 -1
- package/dist/page-revisions-content-ag-MHBGr.cjs +0 -1
- package/dist/plugin-BGlQf0iy.cjs +0 -22
- package/dist/plugin-C-ht41UZ.js +0 -245
- package/dist/publish-pages-content-BiX-GMLw.cjs +0 -1
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +0 -1
- package/dist/save-to-lib-ffjCZYJ5.cjs +0 -1
- package/dist/seo-panel-FjS1UF_y.cjs +0 -2
- package/dist/shared-json-ld-yJkXjENy.cjs +0 -1
- package/dist/take-over-request-CmpJVe9T.cjs +0 -1
- package/dist/theme-panel-footer-BUXIu252.js +0 -26
- package/dist/theme-panel-footer-CKO9YYwZ.cjs +0 -1
- package/dist/unpublish-page-BJ0Bsvt2.js +0 -28
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { B as b, z as L } from "./register-chai-top-bar-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useQuery as K, useMutation as
|
|
2
|
+
import { B as b, z as L } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
+
import { aF as ne, c as M, X as ie, Y as oe, P as le, aG as ce, ax as de, aH as ue, p as P } from "./index-wBr2Ml98.js";
|
|
4
|
+
import { ap as D, aq as G, A as _, aw as me } from "./index-CDVuf3C1.js";
|
|
5
|
+
import { useQuery as K, useMutation as A, useQueryClient as pe } from "@tanstack/react-query";
|
|
6
|
+
import { useSetAtom as fe } from "jotai";
|
|
6
7
|
import { toast as N } from "sonner";
|
|
7
|
-
import { Trash2 as Y, Plus as
|
|
8
|
-
import { useState as h, useRef as V, useMemo as S, useEffect as
|
|
9
|
-
import { c as ve } from "./image-compression-
|
|
10
|
-
import { isEmpty as
|
|
11
|
-
const
|
|
8
|
+
import { Trash2 as Y, Plus as he, ImageIcon as ge, X as be, AlertCircle as ye } from "lucide-react";
|
|
9
|
+
import { useState as h, useRef as V, useMemo as S, useEffect as I, useCallback as ke } from "react";
|
|
10
|
+
import { c as ve } from "./image-compression-DPFITwOL.js";
|
|
11
|
+
import { isEmpty as Ne, set as Be, has as Ce } from "lodash-es";
|
|
12
|
+
const we = (r) => {
|
|
12
13
|
const a = D(), o = G();
|
|
13
|
-
return
|
|
14
|
+
return A({
|
|
14
15
|
mutationFn: async (t) => o(a, {
|
|
15
16
|
action: _.UPSERT_LIBRARY_ITEM,
|
|
16
17
|
data: t
|
|
@@ -24,7 +25,7 @@ const Be = (r) => {
|
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
|
-
},
|
|
28
|
+
}, Ie = (r) => {
|
|
28
29
|
const a = D(), o = G();
|
|
29
30
|
return K({
|
|
30
31
|
staleTime: "static",
|
|
@@ -44,40 +45,45 @@ const Be = (r) => {
|
|
|
44
45
|
},
|
|
45
46
|
retry: !1
|
|
46
47
|
});
|
|
47
|
-
},
|
|
48
|
-
const a = D(), o = G();
|
|
49
|
-
return
|
|
50
|
-
mutationFn: async (
|
|
48
|
+
}, Ee = (r) => {
|
|
49
|
+
const a = D(), o = G(), t = fe(ne);
|
|
50
|
+
return A({
|
|
51
|
+
mutationFn: async (l) => o(a, {
|
|
51
52
|
action: _.DELETE_LIBRARY_ITEM,
|
|
52
|
-
data: { id:
|
|
53
|
+
data: { id: l }
|
|
53
54
|
}),
|
|
54
55
|
onSuccess: () => {
|
|
55
|
-
|
|
56
|
+
t((l) => {
|
|
57
|
+
const m = { ...l };
|
|
58
|
+
return Object.keys(m).forEach((u) => {
|
|
59
|
+
m[u] = { loading: "idle", blocks: [], error: !1 };
|
|
60
|
+
}), m;
|
|
61
|
+
}), r ? r() : N.success("Block deleted successfully");
|
|
56
62
|
},
|
|
57
|
-
onError: (
|
|
58
|
-
console.error("Error deleting block:",
|
|
59
|
-
description:
|
|
63
|
+
onError: (l) => {
|
|
64
|
+
console.error("Error deleting block:", l), N.error("Failed to delete block", {
|
|
65
|
+
description: l instanceof Error ? l.message : "Unknown error"
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
});
|
|
63
|
-
},
|
|
69
|
+
}, xe = ({
|
|
64
70
|
blockId: r,
|
|
65
71
|
libBlockId: a,
|
|
66
72
|
isOpen: o,
|
|
67
73
|
onClose: t,
|
|
68
|
-
blockName:
|
|
69
|
-
trigger:
|
|
74
|
+
blockName: l,
|
|
75
|
+
trigger: m
|
|
70
76
|
}) => {
|
|
71
|
-
const [
|
|
72
|
-
|
|
77
|
+
const [u, c] = h(!1), d = M(), y = Ee(() => {
|
|
78
|
+
d([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), c(!1), t();
|
|
73
79
|
});
|
|
74
|
-
return /* @__PURE__ */ i(
|
|
75
|
-
/* @__PURE__ */ e(
|
|
80
|
+
return /* @__PURE__ */ i(ie, { open: o, onOpenChange: (p) => !p && t(), children: [
|
|
81
|
+
/* @__PURE__ */ e(oe, { asChild: !0, children: m || /* @__PURE__ */ i(b, { type: "button", variant: "destructive", size: "sm", onClick: (p) => p.preventDefault(), disabled: u, children: [
|
|
76
82
|
/* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
|
|
77
83
|
"Delete"
|
|
78
84
|
] }) }),
|
|
79
85
|
/* @__PURE__ */ e(
|
|
80
|
-
|
|
86
|
+
le,
|
|
81
87
|
{
|
|
82
88
|
className: "z-[9999] w-72 p-4",
|
|
83
89
|
sideOffset: 5,
|
|
@@ -88,39 +94,39 @@ const Be = (r) => {
|
|
|
88
94
|
"Are you sure you want to delete the block",
|
|
89
95
|
/* @__PURE__ */ i("span", { className: "font-medium", children: [
|
|
90
96
|
' "',
|
|
91
|
-
|
|
97
|
+
l,
|
|
92
98
|
'"'
|
|
93
99
|
] }),
|
|
94
100
|
"?"
|
|
95
101
|
] }),
|
|
96
102
|
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "This block will be permanently removed from the library. This action cannot be undone." }),
|
|
97
103
|
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
98
|
-
/* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled:
|
|
104
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled: u, children: "Cancel" }),
|
|
99
105
|
/* @__PURE__ */ e(b, { type: "button", variant: "destructive", size: "sm", onClick: () => {
|
|
100
|
-
|
|
101
|
-
}, disabled:
|
|
106
|
+
c(!0), y.mutate(a);
|
|
107
|
+
}, disabled: u, children: u ? "Deleting..." : "Delete" })
|
|
102
108
|
] })
|
|
103
109
|
] })
|
|
104
110
|
}
|
|
105
111
|
)
|
|
106
112
|
] });
|
|
107
|
-
},
|
|
113
|
+
}, Pe = ({
|
|
108
114
|
blockId: r,
|
|
109
115
|
libBlockId: a,
|
|
110
116
|
blockName: o,
|
|
111
117
|
size: t = "sm",
|
|
112
|
-
className:
|
|
113
|
-
close:
|
|
118
|
+
className: l = "",
|
|
119
|
+
close: m
|
|
114
120
|
}) => {
|
|
115
|
-
const [
|
|
121
|
+
const [u, c] = h(!1);
|
|
116
122
|
return /* @__PURE__ */ e(
|
|
117
|
-
|
|
123
|
+
xe,
|
|
118
124
|
{
|
|
119
125
|
blockId: r,
|
|
120
126
|
libBlockId: a,
|
|
121
|
-
isOpen:
|
|
127
|
+
isOpen: u,
|
|
122
128
|
onClose: () => {
|
|
123
|
-
|
|
129
|
+
c(!1), m();
|
|
124
130
|
},
|
|
125
131
|
blockName: o,
|
|
126
132
|
trigger: /* @__PURE__ */ i(
|
|
@@ -129,8 +135,8 @@ const Be = (r) => {
|
|
|
129
135
|
type: "button",
|
|
130
136
|
variant: "destructive",
|
|
131
137
|
size: t,
|
|
132
|
-
className:
|
|
133
|
-
onClick: () =>
|
|
138
|
+
className: l,
|
|
139
|
+
onClick: () => c(!0),
|
|
134
140
|
children: [
|
|
135
141
|
/* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
|
|
136
142
|
"Delete"
|
|
@@ -139,11 +145,11 @@ const Be = (r) => {
|
|
|
139
145
|
)
|
|
140
146
|
}
|
|
141
147
|
);
|
|
142
|
-
},
|
|
143
|
-
const r = D(), a = G(), o =
|
|
148
|
+
}, Le = () => {
|
|
149
|
+
const r = D(), a = G(), o = pe(), {
|
|
144
150
|
data: t = [],
|
|
145
|
-
isLoading:
|
|
146
|
-
error:
|
|
151
|
+
isLoading: l,
|
|
152
|
+
error: m
|
|
147
153
|
} = K({
|
|
148
154
|
queryKey: ["library-groups"],
|
|
149
155
|
staleTime: "static",
|
|
@@ -153,17 +159,17 @@ const Be = (r) => {
|
|
|
153
159
|
return await a(r, {
|
|
154
160
|
action: "GET_LIBRARY_GROUPS"
|
|
155
161
|
}) || [];
|
|
156
|
-
} catch (
|
|
157
|
-
return console.error("Error fetching library groups:",
|
|
162
|
+
} catch (d) {
|
|
163
|
+
return console.error("Error fetching library groups:", d), [];
|
|
158
164
|
}
|
|
159
165
|
}
|
|
160
|
-
}), { mutateAsync:
|
|
161
|
-
mutationFn: async (
|
|
162
|
-
if (!
|
|
166
|
+
}), { mutateAsync: u, isPending: c } = A({
|
|
167
|
+
mutationFn: async (d) => {
|
|
168
|
+
if (!d.trim())
|
|
163
169
|
throw new Error("Group name is required");
|
|
164
170
|
return a(r, {
|
|
165
171
|
action: "CREATE_BLOCK_GROUP",
|
|
166
|
-
data: { name:
|
|
172
|
+
data: { name: d }
|
|
167
173
|
});
|
|
168
174
|
},
|
|
169
175
|
onSuccess: () => {
|
|
@@ -171,21 +177,21 @@ const Be = (r) => {
|
|
|
171
177
|
queryKey: ["library-groups"]
|
|
172
178
|
}), N.success("Group created successfully");
|
|
173
179
|
},
|
|
174
|
-
onError: (
|
|
175
|
-
console.error("Error creating group:",
|
|
176
|
-
description:
|
|
180
|
+
onError: (d) => {
|
|
181
|
+
console.error("Error creating group:", d), N.error("Failed to create group", {
|
|
182
|
+
description: d instanceof Error ? d.message : "Unknown error"
|
|
177
183
|
});
|
|
178
184
|
}
|
|
179
185
|
});
|
|
180
186
|
return {
|
|
181
187
|
groups: t,
|
|
182
|
-
isLoading:
|
|
183
|
-
error:
|
|
184
|
-
createGroup:
|
|
185
|
-
isCreating:
|
|
188
|
+
isLoading: l,
|
|
189
|
+
error: m,
|
|
190
|
+
createGroup: u,
|
|
191
|
+
isCreating: c
|
|
186
192
|
};
|
|
187
|
-
},
|
|
188
|
-
const [o, t] = h(!1), [
|
|
193
|
+
}, _e = ({ value: r, onChange: a }) => {
|
|
194
|
+
const [o, t] = h(!1), [l, m] = h(""), u = V(null), { groups: c } = Le(), [d, y] = h([
|
|
189
195
|
{ id: "hero", name: "Hero" },
|
|
190
196
|
{ id: "feature", name: "Feature" },
|
|
191
197
|
{ id: "footer", name: "Footer" },
|
|
@@ -215,33 +221,33 @@ const Be = (r) => {
|
|
|
215
221
|
{ id: "timeline", name: "Timeline" }
|
|
216
222
|
]), f = S(
|
|
217
223
|
() => [
|
|
218
|
-
...
|
|
219
|
-
...
|
|
224
|
+
...c,
|
|
225
|
+
...d.filter((s) => !c.some((B) => B.id === s.id))
|
|
220
226
|
],
|
|
221
|
-
[
|
|
227
|
+
[c, d]
|
|
222
228
|
), g = () => {
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
225
|
-
const B = { id:
|
|
226
|
-
|
|
229
|
+
const s = l.trim();
|
|
230
|
+
if (!s) return;
|
|
231
|
+
const B = { id: s, name: s };
|
|
232
|
+
y((E) => [...E, B]), a(B.id), m(""), t(!1);
|
|
227
233
|
};
|
|
228
|
-
|
|
229
|
-
o &&
|
|
234
|
+
I(() => {
|
|
235
|
+
o && u.current && u.current.focus();
|
|
230
236
|
}, [o]);
|
|
231
|
-
const
|
|
232
|
-
|
|
237
|
+
const p = (s) => {
|
|
238
|
+
s.key === "Enter" && (s.preventDefault(), g());
|
|
233
239
|
};
|
|
234
|
-
return
|
|
235
|
-
r && !f.some((
|
|
240
|
+
return I(() => {
|
|
241
|
+
r && !f.some((s) => s.id === r) && a("");
|
|
236
242
|
}, [r, f, a]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
237
243
|
/* @__PURE__ */ e(
|
|
238
244
|
L,
|
|
239
245
|
{
|
|
240
|
-
ref:
|
|
246
|
+
ref: u,
|
|
241
247
|
placeholder: "Enter new group name",
|
|
242
|
-
value:
|
|
243
|
-
onChange: (
|
|
244
|
-
onKeyDown:
|
|
248
|
+
value: l,
|
|
249
|
+
onChange: (s) => m(s.target.value),
|
|
250
|
+
onKeyDown: p
|
|
245
251
|
}
|
|
246
252
|
),
|
|
247
253
|
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -254,30 +260,30 @@ const Be = (r) => {
|
|
|
254
260
|
{
|
|
255
261
|
className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
256
262
|
value: r,
|
|
257
|
-
onChange: (
|
|
263
|
+
onChange: (s) => a(s.target.value),
|
|
258
264
|
children: [
|
|
259
265
|
/* @__PURE__ */ e("option", { value: "", children: "Select a group" }),
|
|
260
|
-
|
|
261
|
-
|
|
266
|
+
c.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Library Groups", children: c.map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, `lib-${s.id}`)) }),
|
|
267
|
+
d.length > 0 && /* @__PURE__ */ e("optgroup", { label: "Predefined Groups", children: d.filter((s) => !c.some((B) => B.id === s.id)).map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, `local-${s.id}`)) })
|
|
262
268
|
]
|
|
263
269
|
}
|
|
264
270
|
),
|
|
265
|
-
/* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(
|
|
271
|
+
/* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) })
|
|
266
272
|
] });
|
|
267
|
-
},
|
|
268
|
-
const [o, t] = h(!1),
|
|
269
|
-
async (
|
|
273
|
+
}, De = ({ value: r, onChange: a }) => {
|
|
274
|
+
const [o, t] = h(!1), l = V(null), m = ke(
|
|
275
|
+
async (d) => {
|
|
270
276
|
var f;
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
277
|
+
const y = (f = d.target.files) == null ? void 0 : f[0];
|
|
278
|
+
if (y)
|
|
273
279
|
try {
|
|
274
280
|
t(!0);
|
|
275
|
-
let g =
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
a(
|
|
280
|
-
},
|
|
281
|
+
let g = y;
|
|
282
|
+
y.type.startsWith("image/") && (g = await ve(y));
|
|
283
|
+
const p = new FileReader();
|
|
284
|
+
p.onloadend = () => {
|
|
285
|
+
a(p.result), t(!1);
|
|
286
|
+
}, p.readAsDataURL(g);
|
|
281
287
|
} catch (g) {
|
|
282
288
|
console.error("Error reading file:", g), t(!1), N.error("Failed to process image", {
|
|
283
289
|
description: g instanceof Error ? g.message : "Unknown error"
|
|
@@ -288,68 +294,68 @@ const Be = (r) => {
|
|
|
288
294
|
);
|
|
289
295
|
return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
290
296
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
291
|
-
/* @__PURE__ */ e(L, { type: "file", ref:
|
|
297
|
+
/* @__PURE__ */ e(L, { type: "file", ref: l, onChange: m, accept: "image/*", className: "hidden" }),
|
|
292
298
|
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: () => {
|
|
293
|
-
var
|
|
294
|
-
(
|
|
299
|
+
var d;
|
|
300
|
+
(d = l.current) == null || d.click();
|
|
295
301
|
}, disabled: o, className: "w-full", children: o ? /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
|
|
296
302
|
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
297
303
|
"Uploading..."
|
|
298
304
|
] }) : /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
|
|
299
|
-
/* @__PURE__ */ e(
|
|
305
|
+
/* @__PURE__ */ e(ge, { className: "h-4 w-4" }),
|
|
300
306
|
"Select image"
|
|
301
307
|
] }) }),
|
|
302
308
|
r && /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "icon", onClick: () => {
|
|
303
|
-
a(""),
|
|
304
|
-
}, children: /* @__PURE__ */ e(
|
|
309
|
+
a(""), l.current && (l.current.value = "");
|
|
310
|
+
}, children: /* @__PURE__ */ e(be, { className: "h-4 w-4" }) })
|
|
305
311
|
] }),
|
|
306
312
|
r && /* @__PURE__ */ e("div", { className: "aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: r, alt: "Preview", className: "h-full w-full object-contain" }) })
|
|
307
313
|
] });
|
|
308
|
-
},
|
|
309
|
-
const { blocks: a, close: o, blockId: t } = r, {
|
|
310
|
-
let
|
|
311
|
-
for (const
|
|
312
|
-
if (
|
|
313
|
-
let
|
|
314
|
-
|
|
314
|
+
}, Me = (r) => {
|
|
315
|
+
const { blocks: a, close: o, blockId: t } = r, { getPartialBlocks: l } = ce(), m = a.find((n) => n._id === t), u = m == null ? void 0 : m._libBlockId, c = !!u, d = S(() => a.some((n) => n._type === "PartialBlock" || n._type === "GlobalBlock"), [a]), y = S(() => {
|
|
316
|
+
let n = [];
|
|
317
|
+
for (const k of a)
|
|
318
|
+
if (k._type === "PartialBlock" || k._type === "GlobalBlock") {
|
|
319
|
+
let v = l(k.partialBlockId);
|
|
320
|
+
k._parent && (v == null ? void 0 : v.length) > 0 && (v = v.map((R) => (Ne(R._parent) && Be(R, "_parent", k._parent), R))), n = [...n, ...v];
|
|
315
321
|
} else
|
|
316
|
-
|
|
317
|
-
return
|
|
318
|
-
}, [a,
|
|
319
|
-
|
|
322
|
+
n.push(k);
|
|
323
|
+
return n;
|
|
324
|
+
}, [a, l]), [f, g] = h(""), [p, s] = h(""), [B, E] = h(""), [x, U] = h(""), [C, W] = h({}), [Q, $] = h(!1), [H, q] = h(c), [X, J] = h(!1), { hasPermission: Z } = de(), ee = Z(me.DELETE_LIBRARY_BLOCK), O = M(), te = () => {
|
|
325
|
+
O([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), o();
|
|
320
326
|
}, {
|
|
321
|
-
data:
|
|
322
|
-
isLoading:
|
|
323
|
-
isError:
|
|
324
|
-
} =
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}, [
|
|
328
|
-
|
|
329
|
-
}, [
|
|
330
|
-
const
|
|
331
|
-
$(
|
|
332
|
-
}, [f,
|
|
327
|
+
data: w,
|
|
328
|
+
isLoading: F,
|
|
329
|
+
isError: j
|
|
330
|
+
} = Ie(u);
|
|
331
|
+
I(() => {
|
|
332
|
+
j && c && (J(!0), q(!1));
|
|
333
|
+
}, [j, c]), I(() => {
|
|
334
|
+
w && !F && (g(w.name || ""), s(w.group || ""), E(w.description || ""), U(w.preview || ""), q(!1));
|
|
335
|
+
}, [w, F]), I(() => {
|
|
336
|
+
const n = f.trim().length >= 2, k = p.trim() !== "";
|
|
337
|
+
$(n && k);
|
|
338
|
+
}, [f, p]);
|
|
333
339
|
const re = () => {
|
|
334
|
-
const
|
|
335
|
-
return f.trim() ? f.length < 2 && (
|
|
336
|
-
}, { resetLibrary: ae } =
|
|
337
|
-
|
|
338
|
-
}),
|
|
339
|
-
if (
|
|
340
|
-
const
|
|
341
|
-
|
|
340
|
+
const n = {};
|
|
341
|
+
return f.trim() ? f.length < 2 && (n.name = "Name must be at least 2 characters") : n.name = "Name is required", p || (n.group = "Group is required"), W(n), Object.keys(n).length === 0;
|
|
342
|
+
}, { resetLibrary: ae } = ue({ id: "" }), z = we((n) => {
|
|
343
|
+
c || O([t], { _libBlockId: n.id }), N.success(`Block ${c ? "updated" : "saved"} successfully`), ae(n.library), o();
|
|
344
|
+
}), se = async (n) => {
|
|
345
|
+
if (n.preventDefault(), !re()) return;
|
|
346
|
+
const k = y.map((v) => (Ce(v, "_libBlockId") && delete v._libBlockId, v));
|
|
347
|
+
z.mutate({
|
|
342
348
|
name: f.trim(),
|
|
343
|
-
group:
|
|
344
|
-
blocks:
|
|
349
|
+
group: p,
|
|
350
|
+
blocks: k,
|
|
345
351
|
description: B.trim(),
|
|
346
352
|
// Only include previewImage if it exists and is a base64 image
|
|
347
353
|
...x && x.startsWith("data:") ? { previewImage: x } : {},
|
|
348
354
|
// Include id if in edit mode
|
|
349
|
-
...
|
|
355
|
+
...c ? { id: u } : {}
|
|
350
356
|
});
|
|
351
|
-
},
|
|
352
|
-
return H ||
|
|
357
|
+
}, T = z.isPending;
|
|
358
|
+
return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ i("div", { className: "space-y-4 p-6", children: [
|
|
353
359
|
/* @__PURE__ */ e("div", { className: "font-medium text-destructive", children: "Block Not Found" }),
|
|
354
360
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This block could not be found on the server. It may have been deleted." }),
|
|
355
361
|
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-4", children: [
|
|
@@ -357,14 +363,14 @@ const Be = (r) => {
|
|
|
357
363
|
/* @__PURE__ */ e(b, { onClick: te, variant: "destructive", children: "Delink Block" })
|
|
358
364
|
] })
|
|
359
365
|
] }) : /* @__PURE__ */ i("div", { children: [
|
|
360
|
-
|
|
361
|
-
/* @__PURE__ */ e(
|
|
366
|
+
d && /* @__PURE__ */ i("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
|
|
367
|
+
/* @__PURE__ */ e(ye, { className: "mt-0.5 h-5 w-5 flex-shrink-0" }),
|
|
362
368
|
/* @__PURE__ */ i("div", { children: [
|
|
363
369
|
/* @__PURE__ */ e("p", { className: "font-medium", children: "Partial Blocks Detected" }),
|
|
364
370
|
/* @__PURE__ */ e("p", { className: "mt-1 text-xs", children: "This block contains one or more Partial Blocks. Partial blocks will be merged into the library block" })
|
|
365
371
|
] })
|
|
366
372
|
] }),
|
|
367
|
-
/* @__PURE__ */ i("form", { onSubmit:
|
|
373
|
+
/* @__PURE__ */ i("form", { onSubmit: se, className: "space-y-4", children: [
|
|
368
374
|
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
369
375
|
/* @__PURE__ */ e(P, { htmlFor: "name", className: C.name ? "text-destructive" : "", children: "Name" }),
|
|
370
376
|
/* @__PURE__ */ e(
|
|
@@ -373,7 +379,7 @@ const Be = (r) => {
|
|
|
373
379
|
id: "name",
|
|
374
380
|
placeholder: "Enter block name",
|
|
375
381
|
value: f,
|
|
376
|
-
onChange: (
|
|
382
|
+
onChange: (n) => g(n.target.value),
|
|
377
383
|
className: C.name ? "border-destructive" : ""
|
|
378
384
|
}
|
|
379
385
|
),
|
|
@@ -381,7 +387,7 @@ const Be = (r) => {
|
|
|
381
387
|
] }),
|
|
382
388
|
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
383
389
|
/* @__PURE__ */ e(P, { htmlFor: "group", className: C.group ? "text-destructive" : "", children: "Group" }),
|
|
384
|
-
/* @__PURE__ */ e(
|
|
390
|
+
/* @__PURE__ */ e(_e, { value: p, onChange: s }),
|
|
385
391
|
C.group && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.group })
|
|
386
392
|
] }),
|
|
387
393
|
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
@@ -393,31 +399,31 @@ const Be = (r) => {
|
|
|
393
399
|
placeholder: "Enter a brief description",
|
|
394
400
|
className: "resize-none",
|
|
395
401
|
value: B,
|
|
396
|
-
onChange: (
|
|
402
|
+
onChange: (n) => E(n.target.value)
|
|
397
403
|
}
|
|
398
404
|
)
|
|
399
405
|
] }),
|
|
400
406
|
/* @__PURE__ */ i("div", { className: "space-y-2", children: [
|
|
401
407
|
/* @__PURE__ */ e(P, { htmlFor: "previewImage", children: "Preview Image (optional)" }),
|
|
402
|
-
/* @__PURE__ */ e(
|
|
408
|
+
/* @__PURE__ */ e(De, { value: x, onChange: U })
|
|
403
409
|
] }),
|
|
404
410
|
/* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
405
|
-
|
|
406
|
-
|
|
411
|
+
c && ee && /* @__PURE__ */ e(
|
|
412
|
+
Pe,
|
|
407
413
|
{
|
|
408
414
|
blockId: t,
|
|
409
|
-
libBlockId:
|
|
415
|
+
libBlockId: u,
|
|
410
416
|
blockName: f,
|
|
411
417
|
className: "mr-auto",
|
|
412
418
|
close: o
|
|
413
419
|
}
|
|
414
420
|
),
|
|
415
|
-
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled:
|
|
416
|
-
/* @__PURE__ */ e(b, { type: "submit", disabled:
|
|
421
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled: T, children: "Cancel" }),
|
|
422
|
+
/* @__PURE__ */ e(b, { type: "submit", disabled: T || !Q, children: T ? "Saving..." : c ? "Update Block" : "Save Block" })
|
|
417
423
|
] })
|
|
418
424
|
] })
|
|
419
425
|
] });
|
|
420
426
|
};
|
|
421
427
|
export {
|
|
422
|
-
|
|
428
|
+
Me as default
|
|
423
429
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-C3CV1lXL.cjs"),b=require("./index-3pEi7VzS.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
|