tanstack_start_ts 1.0.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.
- package/.wrangler/deploy/config.json +1 -0
- package/bunfig.toml +6 -0
- package/components.json +22 -0
- package/config.json +0 -0
- package/dist/client/.assetsignore +2 -0
- package/dist/client/assets/ProductCard-DbIkJAE-.js +1 -0
- package/dist/client/assets/about-AskxOruL.js +1 -0
- package/dist/client/assets/admin-BZVcAQM3.js +1 -0
- package/dist/client/assets/admin.functions--RdVcuBx.js +1 -0
- package/dist/client/assets/admin.login-QgrF_9Fp.js +1 -0
- package/dist/client/assets/affiliate-disclosure-BIAsA-HO.js +1 -0
- package/dist/client/assets/categories-D0N418mK.js +1 -0
- package/dist/client/assets/category._slug-aCaQm14E.js +1 -0
- package/dist/client/assets/contact-PhvO-V15.js +1 -0
- package/dist/client/assets/faq-BsiHWPM8.js +1 -0
- package/dist/client/assets/hero-bg-BP2eVUIX.jpg +0 -0
- package/dist/client/assets/index-BU9rnkF3.js +1 -0
- package/dist/client/assets/index-BpJWZkva.js +1 -0
- package/dist/client/assets/index-vRX-zAyq.js +1 -0
- package/dist/client/assets/login-DteE0ZGp.js +1 -0
- package/dist/client/assets/logo-pSNfLJQk.png +0 -0
- package/dist/client/assets/privacy-B_Pu7040.js +1 -0
- package/dist/client/assets/product-links-BkZ41Gv3.js +1 -0
- package/dist/client/assets/product._id-BVUysCW-.js +1 -0
- package/dist/client/assets/products.functions-cGzRziKO.js +1 -0
- package/dist/client/assets/profile-CveRcKq2.js +1 -0
- package/dist/client/assets/reset-password-ySEjItX_.js +1 -0
- package/dist/client/assets/saved-CHtdQDJF.js +1 -0
- package/dist/client/assets/search-CXWfET1y.js +1 -0
- package/dist/client/assets/signup-CEx90iuV.js +1 -0
- package/dist/client/assets/styles-DrNJG0BO.css +1 -0
- package/dist/client/assets/terms-VqJ9kX9b.js +1 -0
- package/dist/client/assets/update-password-C-d0ix5e.js +1 -0
- package/dist/client/assets/vendor-aria-hidden-DvXkyWUv.js +1 -0
- package/dist/client/assets/vendor-class-variance-authority-5VPnzWs2.js +1 -0
- package/dist/client/assets/vendor-clsx-B-dksMZM.js +1 -0
- package/dist/client/assets/vendor-cookie-es-CS0aJGDi.js +1 -0
- package/dist/client/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
- package/dist/client/assets/vendor-floating-ui-core-BlUy28sp.js +1 -0
- package/dist/client/assets/vendor-floating-ui-dom-BxK0hn2R.js +1 -0
- package/dist/client/assets/vendor-floating-ui-react-dom-Bas3975S.js +1 -0
- package/dist/client/assets/vendor-floating-ui-utils-BfYUAVcw.js +1 -0
- package/dist/client/assets/vendor-framer-motion-BMdL-cuX.js +9 -0
- package/dist/client/assets/vendor-get-nonce-C-Z93AgS.js +1 -0
- package/dist/client/assets/vendor-iceberg-js-tWD4K6Lg.js +1 -0
- package/dist/client/assets/vendor-lovable.dev-cloud-auth-js-VuzqtJVg.js +1 -0
- package/dist/client/assets/vendor-lucide-react-b5K2fehp.js +1 -0
- package/dist/client/assets/vendor-motion-dom-BETJamZt.js +1 -0
- package/dist/client/assets/vendor-motion-utils-BuWewJbj.js +1 -0
- package/dist/client/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-accordion-C22Rgxe9.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-arrow-DMHj2mKI.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-avatar-CVPBkFXg.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-collapsible-BvM-4sKX.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-collection-D9KtqmHm.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-compose-refs-Cvq0AS8Z.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-context-CAqqn5Nx.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-dialog-DZ01vOLq.js +5 -0
- package/dist/client/assets/vendor-radix-ui-react-direction-DxZwNuei.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-dismissable-layer-Dqgrs55Y.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-dropdown-menu-0uzvrqkn.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-focus-guards-DgWoZ-fP.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-focus-scope-BLIu5QaL.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-id-bpga_rLa.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-menu-D0qf2r6_.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-popper-BafIylxU.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-portal-BnAsfNCS.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-presence-C-f3UKQ2.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-primitive-zTHwXNoz.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-roving-focus-jyJB8K2E.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-slot-6LXHJrHl.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-callback-ref-E91aPc6s.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-controllable-state-Ca3eMtxa.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-effect-event-CPeX4A3c.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-escape-keydown-7n3YsXFo.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-is-hydrated-C1PY1qNv.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-layout-effect-B3AcGWPy.js +1 -0
- package/dist/client/assets/vendor-radix-ui-react-use-size-CXS04sct.js +1 -0
- package/dist/client/assets/vendor-react-dom-BnNs-kzm.js +9 -0
- package/dist/client/assets/vendor-react-gJPiVnX5.js +1 -0
- package/dist/client/assets/vendor-react-remove-scroll-DHKl-IMP.js +4 -0
- package/dist/client/assets/vendor-react-remove-scroll-bar-CSjdInc2.js +38 -0
- package/dist/client/assets/vendor-react-style-singleton-BqHpkgXn.js +1 -0
- package/dist/client/assets/vendor-scheduler-7OC5HNn7.js +1 -0
- package/dist/client/assets/vendor-seroval-B_Fur-nl.js +3 -0
- package/dist/client/assets/vendor-seroval-plugins-CBHnPkZJ.js +1 -0
- package/dist/client/assets/vendor-sonner-71-LdGG1.js +1 -0
- package/dist/client/assets/vendor-supabase-auth-js-DWrN-bIx.js +18 -0
- package/dist/client/assets/vendor-supabase-functions-js-uY_V-TxC.js +1 -0
- package/dist/client/assets/vendor-supabase-phoenix-BzEf37Ve.js +2 -0
- package/dist/client/assets/vendor-supabase-postgrest-js-C4rBWbCx.js +4 -0
- package/dist/client/assets/vendor-supabase-realtime-js-D6BlOYKE.js +23 -0
- package/dist/client/assets/vendor-supabase-storage-js-BG98L3Zz.js +1 -0
- package/dist/client/assets/vendor-supabase-supabase-js-DCCzdwBJ.js +1 -0
- package/dist/client/assets/vendor-tailwind-merge-Ct12j0u0.js +1 -0
- package/dist/client/assets/vendor-tanstack-history-C617CaxG.js +1 -0
- package/dist/client/assets/vendor-tanstack-query-core-7wuJJ5ZL.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-query-HImzo8sX.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-router-sIZLK-LU.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-start-client-GiYCfWmf.js +1 -0
- package/dist/client/assets/vendor-tanstack-react-store-EvTi3ahh.js +1 -0
- package/dist/client/assets/vendor-tanstack-router-core-Cr7bYUZv.js +1 -0
- package/dist/client/assets/vendor-tanstack-start-client-core-C-00BBOu.js +2 -0
- package/dist/client/assets/vendor-tanstack-start-fn-stubs-l0sNRNKZ.js +1 -0
- package/dist/client/assets/vendor-tanstack-store-BC7mA7pq.js +1 -0
- package/dist/client/assets/vendor-tslib-Du-meQkk.js +1 -0
- package/dist/client/assets/vendor-use-callback-ref-C_fIAtot.js +1 -0
- package/dist/client/assets/vendor-use-sidecar-Bh0DDN6h.js +1 -0
- package/dist/client/assets/vendor-use-sync-external-store-ZvKHXaIn.js +1 -0
- package/dist/client/assets/vendor-vercel-analytics-DwPM5BWs.js +1 -0
- package/dist/client/assets/vendor-zod-By9teAtI.js +1 -0
- package/dist/client/robots.txt +2 -0
- package/dist/server/.dev.vars +5 -0
- package/dist/server/.vite/manifest.json +2528 -0
- package/dist/server/assets/ProductCard-CUPXy5Eo.js +149 -0
- package/dist/server/assets/_tanstack-start-manifest_v-do7vTWFD.js +4 -0
- package/dist/server/assets/about-TfKQw0Ga.js +28 -0
- package/dist/server/assets/admin-DspfJOJk.js +578 -0
- package/dist/server/assets/admin.functions-B78ppWLR.js +645 -0
- package/dist/server/assets/admin.functions-BWlKBoTL.js +93 -0
- package/dist/server/assets/admin.login-CV7QfeA6.js +139 -0
- package/dist/server/assets/affiliate-disclosure-B1wI1cDb.js +86 -0
- package/dist/server/assets/auth-middleware-Cn49MidW.js +62 -0
- package/dist/server/assets/categories-Z7jnAYZP.js +108 -0
- package/dist/server/assets/category._slug-D0XY3FGK.js +112 -0
- package/dist/server/assets/contact-IzyONsXs.js +104 -0
- package/dist/server/assets/faq-aRhB_CR3.js +133 -0
- package/dist/server/assets/hero-bg-BP2eVUIX.jpg +0 -0
- package/dist/server/assets/index-BTPHbXw9.js +221 -0
- package/dist/server/assets/index-ByJkHkrU.js +30 -0
- package/dist/server/assets/login-Dvy5Dm0f.js +175 -0
- package/dist/server/assets/logo-pSNfLJQk.png +0 -0
- package/dist/server/assets/privacy-B6Wiez1P.js +93 -0
- package/dist/server/assets/product-links-CGYEPP56.js +16 -0
- package/dist/server/assets/product._id-BpRa-1z0.js +231 -0
- package/dist/server/assets/products.functions-DSlmibYN.js +209 -0
- package/dist/server/assets/products.functions-DlHkRiqi.js +24 -0
- package/dist/server/assets/profile-B0NWzVAZ.js +314 -0
- package/dist/server/assets/reset-password-CY-rmqMr.js +115 -0
- package/dist/server/assets/saved-7FA6Dbom.js +126 -0
- package/dist/server/assets/search-Yw5c_fZa.js +329 -0
- package/dist/server/assets/signup-UPzgZo4i.js +143 -0
- package/dist/server/assets/styles-DrNJG0BO.css +1 -0
- package/dist/server/assets/terms-CMnX95bP.js +89 -0
- package/dist/server/assets/update-password-Cr94ea8n.js +131 -0
- package/dist/server/assets/vendor-aria-hidden-DPa16MWu.js +122 -0
- package/dist/server/assets/vendor-class-variance-authority-0YxJPB9Y.js +44 -0
- package/dist/server/assets/vendor-cloudflare-unenv-preset-ya0VEFBz.js +250 -0
- package/dist/server/assets/vendor-clsx-DgYk2OaC.js +16 -0
- package/dist/server/assets/vendor-cookie-es-DAoofYiI.js +44 -0
- package/dist/server/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
- package/dist/server/assets/vendor-floating-ui-core-3tkK0THV.js +726 -0
- package/dist/server/assets/vendor-floating-ui-dom-C-cPtgJv.js +626 -0
- package/dist/server/assets/vendor-floating-ui-react-dom-CRG6gBpH.js +319 -0
- package/dist/server/assets/vendor-floating-ui-utils-DmXANH-E.js +320 -0
- package/dist/server/assets/vendor-framer-motion-X4zAkX3J.js +1979 -0
- package/dist/server/assets/vendor-get-nonce-DiSj3EHl.js +9 -0
- package/dist/server/assets/vendor-h3-v2-CCobnLY5.js +287 -0
- package/dist/server/assets/vendor-iceberg-js-bHCkXyJn.js +534 -0
- package/dist/server/assets/vendor-isbot-CZ7WjwVs.js +21 -0
- package/dist/server/assets/vendor-lovable.dev-cloud-auth-js-BE03njZw.js +180 -0
- package/dist/server/assets/vendor-lucide-react-Ddew6HYb.js +458 -0
- package/dist/server/assets/vendor-motion-dom-D2MTwGIG.js +5983 -0
- package/dist/server/assets/vendor-motion-utils-LJlIFN6m.js +161 -0
- package/dist/server/assets/vendor-radix-ui-primitive-B-mNdDrH.js +11 -0
- package/dist/server/assets/vendor-radix-ui-react-accordion-1Izf6x00.js +308 -0
- package/dist/server/assets/vendor-radix-ui-react-arrow-B882lnFK.js +23 -0
- package/dist/server/assets/vendor-radix-ui-react-avatar-BVgZt2Ab.js +209 -0
- package/dist/server/assets/vendor-radix-ui-react-collapsible-DCBbMZiS.js +147 -0
- package/dist/server/assets/vendor-radix-ui-react-collection-BZ2srfgU.js +150 -0
- package/dist/server/assets/vendor-radix-ui-react-compose-refs-D3qsKVk1.js +39 -0
- package/dist/server/assets/vendor-radix-ui-react-context-BVoNDLue.js +78 -0
- package/dist/server/assets/vendor-radix-ui-react-dialog-DlxMaNYK.js +406 -0
- package/dist/server/assets/vendor-radix-ui-react-direction-Dt_WDL1t.js +9 -0
- package/dist/server/assets/vendor-radix-ui-react-dismissable-layer-CjsuPohV.js +210 -0
- package/dist/server/assets/vendor-radix-ui-react-dropdown-menu-DVxKumY8.js +263 -0
- package/dist/server/assets/vendor-radix-ui-react-focus-guards-D_6NoePE.js +29 -0
- package/dist/server/assets/vendor-radix-ui-react-focus-scope-DEIhTJJH.js +206 -0
- package/dist/server/assets/vendor-radix-ui-react-id-DFFpgh6m.js +14 -0
- package/dist/server/assets/vendor-radix-ui-react-menu-CiTMLwjT.js +893 -0
- package/dist/server/assets/vendor-radix-ui-react-popper-23Ye2Vyc.js +286 -0
- package/dist/server/assets/vendor-radix-ui-react-portal-CZCH5uPk.js +16 -0
- package/dist/server/assets/vendor-radix-ui-react-presence-CaAULlDU.js +128 -0
- package/dist/server/assets/vendor-radix-ui-react-primitive-BeOk3UYa.js +124 -0
- package/dist/server/assets/vendor-radix-ui-react-roving-focus-DES9GR8l.js +224 -0
- package/dist/server/assets/vendor-radix-ui-react-slot-DUhZbzoH.js +103 -0
- package/dist/server/assets/vendor-radix-ui-react-use-callback-ref-BynBgohw.js +11 -0
- package/dist/server/assets/vendor-radix-ui-react-use-controllable-state-C9KpT6DG.js +69 -0
- package/dist/server/assets/vendor-radix-ui-react-use-effect-event-gpNY2xjS.js +1 -0
- package/dist/server/assets/vendor-radix-ui-react-use-escape-keydown-CcYRQ2pp.js +17 -0
- package/dist/server/assets/vendor-radix-ui-react-use-is-hydrated-D_LcBPXY.js +15 -0
- package/dist/server/assets/vendor-radix-ui-react-use-layout-effect-1LNLXAjr.js +6 -0
- package/dist/server/assets/vendor-radix-ui-react-use-size-D6fiKJQo.js +39 -0
- package/dist/server/assets/vendor-react-DvBrY0qp.js +511 -0
- package/dist/server/assets/vendor-react-dom-yvMLPM0j.js +10484 -0
- package/dist/server/assets/vendor-react-remove-scroll-BNtiEvVN.js +328 -0
- package/dist/server/assets/vendor-react-remove-scroll-bar-hLqRASRk.js +82 -0
- package/dist/server/assets/vendor-react-style-singleton-BXjcXskB.js +69 -0
- package/dist/server/assets/vendor-rou3-3NaGPdI8.js +8 -0
- package/dist/server/assets/vendor-seroval-dJyC-Zhz.js +1775 -0
- package/dist/server/assets/vendor-seroval-plugins-Pq_U2meB.js +58 -0
- package/dist/server/assets/vendor-sonner-CqbjhsRh.js +1086 -0
- package/dist/server/assets/vendor-srvx-BA-baEX9.js +6 -0
- package/dist/server/assets/vendor-supabase-auth-js-D4xjVprw.js +7602 -0
- package/dist/server/assets/vendor-supabase-functions-js-sWy4UYn1.js +322 -0
- package/dist/server/assets/vendor-supabase-phoenix-Bw3Uh2Nn.js +1777 -0
- package/dist/server/assets/vendor-supabase-postgrest-js-AO-BXa7I.js +4938 -0
- package/dist/server/assets/vendor-supabase-realtime-js-BtdNgJbm.js +2111 -0
- package/dist/server/assets/vendor-supabase-storage-js-Dk_MrPYO.js +2679 -0
- package/dist/server/assets/vendor-supabase-supabase-js-D1EEtG3j.js +697 -0
- package/dist/server/assets/vendor-tailwind-merge-BHb_obmC.js +3255 -0
- package/dist/server/assets/vendor-tanstack-history-C4pKJmkt.js +204 -0
- package/dist/server/assets/vendor-tanstack-query-core-PwwTR5ld.js +2552 -0
- package/dist/server/assets/vendor-tanstack-react-query-hhHzXAK1.js +190 -0
- package/dist/server/assets/vendor-tanstack-react-router-XzqpA65A.js +1120 -0
- package/dist/server/assets/vendor-tanstack-react-start-RvWUpvat.js +37 -0
- package/dist/server/assets/vendor-tanstack-react-start-client-gpNY2xjS.js +1 -0
- package/dist/server/assets/vendor-tanstack-react-start-server-uj_Y9pEN.js +15 -0
- package/dist/server/assets/vendor-tanstack-react-store-gpNY2xjS.js +1 -0
- package/dist/server/assets/vendor-tanstack-router-core-6wywV3KN.js +4252 -0
- package/dist/server/assets/vendor-tanstack-start-client-core-DoOKV2pA.js +1741 -0
- package/dist/server/assets/vendor-tanstack-start-fn-stubs-l0sNRNKZ.js +1 -0
- package/dist/server/assets/vendor-tanstack-start-server-core-CsAstXv7.js +1421 -0
- package/dist/server/assets/vendor-tanstack-start-storage-context-DgH9hIJT.js +17 -0
- package/dist/server/assets/vendor-tanstack-store-l0sNRNKZ.js +1 -0
- package/dist/server/assets/vendor-tslib-_8ICaZ64.js +67 -0
- package/dist/server/assets/vendor-unenv-DUvF4YIF.js +544 -0
- package/dist/server/assets/vendor-use-callback-ref-DMFDRvmi.js +66 -0
- package/dist/server/assets/vendor-use-sidecar-DG1tHua4.js +106 -0
- package/dist/server/assets/vendor-use-sync-external-store-rZ8vi0It.js +64 -0
- package/dist/server/assets/vendor-vercel-analytics-oP8BDp0L.js +168 -0
- package/dist/server/assets/vendor-zod-BRyQdbC-.js +3580 -0
- package/dist/server/index.js +158 -0
- package/dist/server/wrangler.json +1 -0
- package/enable-powershell.ps1 +7 -0
- package/eslint.config.js +41 -0
- package/lint.bat +4 -0
- package/package.json +95 -0
- package/public/robots.txt +2 -0
- package/run-npm-build.cjs +20 -0
- package/run-npm-build.js +20 -0
- package/src/assets/hero-bg.jpg +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/scrollsy/Footer.tsx +68 -0
- package/src/components/scrollsy/LiveTicker.tsx +31 -0
- package/src/components/scrollsy/Logo.tsx +28 -0
- package/src/components/scrollsy/Nav.tsx +255 -0
- package/src/components/scrollsy/ProductCard.tsx +190 -0
- package/src/components/scrollsy/ProductFilters.tsx +226 -0
- package/src/components/scrollsy/SupportWidget.tsx +197 -0
- package/src/components/ui/accordion.tsx +51 -0
- package/src/components/ui/alert-dialog.tsx +115 -0
- package/src/components/ui/alert.tsx +49 -0
- package/src/components/ui/aspect-ratio.tsx +5 -0
- package/src/components/ui/avatar.tsx +47 -0
- package/src/components/ui/badge.tsx +32 -0
- package/src/components/ui/breadcrumb.tsx +101 -0
- package/src/components/ui/button.tsx +49 -0
- package/src/components/ui/calendar.tsx +177 -0
- package/src/components/ui/card.tsx +55 -0
- package/src/components/ui/carousel.tsx +240 -0
- package/src/components/ui/chart.tsx +331 -0
- package/src/components/ui/checkbox.tsx +26 -0
- package/src/components/ui/collapsible.tsx +11 -0
- package/src/components/ui/command.tsx +143 -0
- package/src/components/ui/context-menu.tsx +187 -0
- package/src/components/ui/dialog.tsx +104 -0
- package/src/components/ui/drawer.tsx +98 -0
- package/src/components/ui/dropdown-menu.tsx +188 -0
- package/src/components/ui/form.tsx +171 -0
- package/src/components/ui/hover-card.tsx +27 -0
- package/src/components/ui/input-otp.tsx +69 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +21 -0
- package/src/components/ui/menubar.tsx +229 -0
- package/src/components/ui/navigation-menu.tsx +120 -0
- package/src/components/ui/pagination.tsx +98 -0
- package/src/components/ui/popover.tsx +31 -0
- package/src/components/ui/progress.tsx +25 -0
- package/src/components/ui/radio-group.tsx +36 -0
- package/src/components/ui/resizable.tsx +37 -0
- package/src/components/ui/scroll-area.tsx +44 -0
- package/src/components/ui/select.tsx +152 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +122 -0
- package/src/components/ui/sidebar.tsx +744 -0
- package/src/components/ui/skeleton.tsx +7 -0
- package/src/components/ui/slider.tsx +23 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +94 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/textarea.tsx +21 -0
- package/src/components/ui/toggle-group.tsx +57 -0
- package/src/components/ui/toggle.tsx +42 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/hooks/use-auth.ts +26 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/integrations/lovable/index.ts +41 -0
- package/src/lib/admin.functions.ts +564 -0
- package/src/lib/error-capture.ts +27 -0
- package/src/lib/error-page.ts +30 -0
- package/src/lib/product-links.ts +39 -0
- package/src/lib/products.functions.ts +101 -0
- package/src/lib/utils.ts +6 -0
- package/src/routeTree.gen.ts +480 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +177 -0
- package/src/routes/about.tsx +66 -0
- package/src/routes/admin.login.tsx +95 -0
- package/src/routes/admin.tsx +811 -0
- package/src/routes/affiliate-disclosure.tsx +35 -0
- package/src/routes/categories.tsx +57 -0
- package/src/routes/category.$slug.tsx +51 -0
- package/src/routes/contact.tsx +69 -0
- package/src/routes/faq.tsx +63 -0
- package/src/routes/index.tsx +269 -0
- package/src/routes/login.tsx +160 -0
- package/src/routes/privacy.tsx +39 -0
- package/src/routes/product.$id.tsx +212 -0
- package/src/routes/profile.tsx +393 -0
- package/src/routes/reset-password.tsx +71 -0
- package/src/routes/saved.tsx +83 -0
- package/src/routes/search.tsx +136 -0
- package/src/routes/signup.tsx +108 -0
- package/src/routes/sitemap[.]xml.ts +34 -0
- package/src/routes/terms.tsx +40 -0
- package/src/routes/update-password.tsx +91 -0
- package/src/server.ts +80 -0
- package/src/start.ts +24 -0
- package/src/styles.css +333 -0
- package/terminal-test-output.txt +1 -0
- package/tsconfig.json +27 -0
- package/vercel.json +26 -0
- package/vite.config.ts +38 -0
- package/wrangler.jsonc +7 -0
|
@@ -0,0 +1,1979 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DvBrY0qp.js";
|
|
2
|
+
import { w as isHTMLElement, p as getFeatureDefinitions, R as setFeatureDefinitions, x as isMotionValue, t as isControllingVariants, A as isVariantLabel, v as isForcedMotionValue, e as buildHTMLStyles, f as buildSVGAttrs, z as isSVGTag, L as resolveMotionValue, B as isVariantNode, s as isAnimationControls, N as resolveVariantFromProps, O as scrapeMotionValuesFromProps, P as scrapeMotionValuesFromProps$1, G as optimizedAppearDataAttribute, S as SVGVisualElement, a as HTMLVisualElement, F as Feature, k as createAnimationState, M as resolveVariant, y as isPrimaryPointer, b as addDomEvent, o as frameData, n as frame, h as cancelFrame, E as mixNumber, g as calcLength, l as createBox, m as eachAxis, C as measurePageBox, j as convertBoxToBoundingBox, i as convertBoundingBoxToBox, c as addValueToWillChange, d as animateMotionValue, Q as setDragLock, K as resize, I as percent, u as isElementTextInput, D as microtask, q as globalProjectionState, H as HTMLProjectionNode, r as hover, J as press } from "./vendor-motion-dom-D2MTwGIG.js";
|
|
3
|
+
import { r as pipe, u as secondsToMilliseconds, p as millisecondsToSeconds, s as progress, f as clamp, q as noop } from "./vendor-motion-utils-LJlIFN6m.js";
|
|
4
|
+
const LayoutGroupContext = reactExports.createContext({});
|
|
5
|
+
function useConstant(init) {
|
|
6
|
+
const ref = reactExports.useRef(null);
|
|
7
|
+
if (ref.current === null) {
|
|
8
|
+
ref.current = init();
|
|
9
|
+
}
|
|
10
|
+
return ref.current;
|
|
11
|
+
}
|
|
12
|
+
const isBrowser = typeof window !== "undefined";
|
|
13
|
+
const useIsomorphicLayoutEffect = isBrowser ? reactExports.useLayoutEffect : reactExports.useEffect;
|
|
14
|
+
const PresenceContext = /* @__PURE__ */ reactExports.createContext(null);
|
|
15
|
+
const MotionConfigContext = reactExports.createContext({
|
|
16
|
+
transformPagePoint: (p) => p,
|
|
17
|
+
isStatic: false,
|
|
18
|
+
reducedMotion: "never"
|
|
19
|
+
});
|
|
20
|
+
function setRef(ref, value) {
|
|
21
|
+
if (typeof ref === "function") {
|
|
22
|
+
return ref(value);
|
|
23
|
+
} else if (ref !== null && ref !== void 0) {
|
|
24
|
+
ref.current = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function composeRefs(...refs) {
|
|
28
|
+
return (node) => {
|
|
29
|
+
let hasCleanup = false;
|
|
30
|
+
const cleanups = refs.map((ref) => {
|
|
31
|
+
const cleanup = setRef(ref, node);
|
|
32
|
+
if (!hasCleanup && typeof cleanup === "function") {
|
|
33
|
+
hasCleanup = true;
|
|
34
|
+
}
|
|
35
|
+
return cleanup;
|
|
36
|
+
});
|
|
37
|
+
if (hasCleanup) {
|
|
38
|
+
return () => {
|
|
39
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
40
|
+
const cleanup = cleanups[i];
|
|
41
|
+
if (typeof cleanup === "function") {
|
|
42
|
+
cleanup();
|
|
43
|
+
} else {
|
|
44
|
+
setRef(refs[i], null);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function useComposedRefs(...refs) {
|
|
52
|
+
return reactExports.useCallback(composeRefs(...refs), refs);
|
|
53
|
+
}
|
|
54
|
+
class PopChildMeasure extends reactExports.Component {
|
|
55
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
56
|
+
const element = this.props.childRef.current;
|
|
57
|
+
if (isHTMLElement(element) && prevProps.isPresent && !this.props.isPresent && this.props.pop !== false) {
|
|
58
|
+
const parent = element.offsetParent;
|
|
59
|
+
const parentWidth = isHTMLElement(parent) ? parent.offsetWidth || 0 : 0;
|
|
60
|
+
const parentHeight = isHTMLElement(parent) ? parent.offsetHeight || 0 : 0;
|
|
61
|
+
const computedStyle = getComputedStyle(element);
|
|
62
|
+
const size = this.props.sizeRef.current;
|
|
63
|
+
size.height = parseFloat(computedStyle.height);
|
|
64
|
+
size.width = parseFloat(computedStyle.width);
|
|
65
|
+
size.top = element.offsetTop;
|
|
66
|
+
size.left = element.offsetLeft;
|
|
67
|
+
size.right = parentWidth - size.width - size.left;
|
|
68
|
+
size.bottom = parentHeight - size.height - size.top;
|
|
69
|
+
size.direction = computedStyle.direction;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Required with getSnapshotBeforeUpdate to stop React complaining.
|
|
75
|
+
*/
|
|
76
|
+
componentDidUpdate() {
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return this.props.children;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function PopChild({ children, isPresent, anchorX, anchorY, root, pop }) {
|
|
83
|
+
const id2 = reactExports.useId();
|
|
84
|
+
const ref = reactExports.useRef(null);
|
|
85
|
+
const size = reactExports.useRef({
|
|
86
|
+
width: 0,
|
|
87
|
+
height: 0,
|
|
88
|
+
top: 0,
|
|
89
|
+
left: 0,
|
|
90
|
+
right: 0,
|
|
91
|
+
bottom: 0,
|
|
92
|
+
direction: "ltr"
|
|
93
|
+
});
|
|
94
|
+
const { nonce } = reactExports.useContext(MotionConfigContext);
|
|
95
|
+
const childRef = children.props?.ref ?? children?.ref;
|
|
96
|
+
const composedRef = useComposedRefs(ref, childRef);
|
|
97
|
+
reactExports.useInsertionEffect(() => {
|
|
98
|
+
const { width, height, top, left, right, bottom, direction } = size.current;
|
|
99
|
+
if (isPresent || pop === false || !ref.current || !width || !height)
|
|
100
|
+
return;
|
|
101
|
+
const isRTL = direction === "rtl";
|
|
102
|
+
const x = anchorX === "left" ? isRTL ? `right: ${right}` : `left: ${left}` : isRTL ? `left: ${left}` : `right: ${right}`;
|
|
103
|
+
const y = anchorY === "bottom" ? `bottom: ${bottom}` : `top: ${top}`;
|
|
104
|
+
ref.current.dataset.motionPopId = id2;
|
|
105
|
+
const style = document.createElement("style");
|
|
106
|
+
if (nonce)
|
|
107
|
+
style.nonce = nonce;
|
|
108
|
+
const parent = root ?? document.head;
|
|
109
|
+
parent.appendChild(style);
|
|
110
|
+
if (style.sheet) {
|
|
111
|
+
style.sheet.insertRule(`
|
|
112
|
+
[data-motion-pop-id="${id2}"] {
|
|
113
|
+
position: absolute !important;
|
|
114
|
+
width: ${width}px !important;
|
|
115
|
+
height: ${height}px !important;
|
|
116
|
+
${x}px !important;
|
|
117
|
+
${y}px !important;
|
|
118
|
+
}
|
|
119
|
+
`);
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
ref.current?.removeAttribute("data-motion-pop-id");
|
|
123
|
+
if (parent.contains(style)) {
|
|
124
|
+
parent.removeChild(style);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}, [isPresent]);
|
|
128
|
+
return jsxRuntimeExports.jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, pop, children: pop === false ? children : reactExports.cloneElement(children, { ref: composedRef }) });
|
|
129
|
+
}
|
|
130
|
+
const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, anchorY, root }) => {
|
|
131
|
+
const presenceChildren = useConstant(newChildrenMap);
|
|
132
|
+
const id2 = reactExports.useId();
|
|
133
|
+
let isReusedContext = true;
|
|
134
|
+
let context = reactExports.useMemo(() => {
|
|
135
|
+
isReusedContext = false;
|
|
136
|
+
return {
|
|
137
|
+
id: id2,
|
|
138
|
+
initial,
|
|
139
|
+
isPresent,
|
|
140
|
+
custom,
|
|
141
|
+
onExitComplete: (childId) => {
|
|
142
|
+
presenceChildren.set(childId, true);
|
|
143
|
+
for (const isComplete of presenceChildren.values()) {
|
|
144
|
+
if (!isComplete)
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
onExitComplete && onExitComplete();
|
|
148
|
+
},
|
|
149
|
+
register: (childId) => {
|
|
150
|
+
presenceChildren.set(childId, false);
|
|
151
|
+
return () => presenceChildren.delete(childId);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}, [isPresent, presenceChildren, onExitComplete]);
|
|
155
|
+
if (presenceAffectsLayout && isReusedContext) {
|
|
156
|
+
context = { ...context };
|
|
157
|
+
}
|
|
158
|
+
reactExports.useMemo(() => {
|
|
159
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
160
|
+
}, [isPresent]);
|
|
161
|
+
reactExports.useEffect(() => {
|
|
162
|
+
!isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
|
|
163
|
+
}, [isPresent]);
|
|
164
|
+
children = jsxRuntimeExports.jsx(PopChild, { pop: mode === "popLayout", isPresent, anchorX, anchorY, root, children });
|
|
165
|
+
return jsxRuntimeExports.jsx(PresenceContext.Provider, { value: context, children });
|
|
166
|
+
};
|
|
167
|
+
function newChildrenMap() {
|
|
168
|
+
return /* @__PURE__ */ new Map();
|
|
169
|
+
}
|
|
170
|
+
function usePresence(subscribe = true) {
|
|
171
|
+
const context = reactExports.useContext(PresenceContext);
|
|
172
|
+
if (context === null)
|
|
173
|
+
return [true, null];
|
|
174
|
+
const { isPresent, onExitComplete, register } = context;
|
|
175
|
+
const id2 = reactExports.useId();
|
|
176
|
+
reactExports.useEffect(() => {
|
|
177
|
+
if (subscribe) {
|
|
178
|
+
return register(id2);
|
|
179
|
+
}
|
|
180
|
+
}, [subscribe]);
|
|
181
|
+
const safeToRemove = reactExports.useCallback(() => subscribe && onExitComplete && onExitComplete(id2), [id2, onExitComplete, subscribe]);
|
|
182
|
+
return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
|
|
183
|
+
}
|
|
184
|
+
const getChildKey = (child) => child.key || "";
|
|
185
|
+
function onlyElements(children) {
|
|
186
|
+
const filtered = [];
|
|
187
|
+
reactExports.Children.forEach(children, (child) => {
|
|
188
|
+
if (reactExports.isValidElement(child))
|
|
189
|
+
filtered.push(child);
|
|
190
|
+
});
|
|
191
|
+
return filtered;
|
|
192
|
+
}
|
|
193
|
+
const AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false, anchorX = "left", anchorY = "top", root }) => {
|
|
194
|
+
const [isParentPresent, safeToRemove] = usePresence(propagate);
|
|
195
|
+
const presentChildren = reactExports.useMemo(() => onlyElements(children), [children]);
|
|
196
|
+
const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);
|
|
197
|
+
const isInitialRender = reactExports.useRef(true);
|
|
198
|
+
const pendingPresentChildren = reactExports.useRef(presentChildren);
|
|
199
|
+
const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
|
|
200
|
+
const exitingComponents = reactExports.useRef(/* @__PURE__ */ new Set());
|
|
201
|
+
const [diffedChildren, setDiffedChildren] = reactExports.useState(presentChildren);
|
|
202
|
+
const [renderedChildren, setRenderedChildren] = reactExports.useState(presentChildren);
|
|
203
|
+
useIsomorphicLayoutEffect(() => {
|
|
204
|
+
isInitialRender.current = false;
|
|
205
|
+
pendingPresentChildren.current = presentChildren;
|
|
206
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
207
|
+
const key = getChildKey(renderedChildren[i]);
|
|
208
|
+
if (!presentKeys.includes(key)) {
|
|
209
|
+
if (exitComplete.get(key) !== true) {
|
|
210
|
+
exitComplete.set(key, false);
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
exitComplete.delete(key);
|
|
214
|
+
exitingComponents.current.delete(key);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
218
|
+
const exitingChildren = [];
|
|
219
|
+
if (presentChildren !== diffedChildren) {
|
|
220
|
+
let nextChildren = [...presentChildren];
|
|
221
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
222
|
+
const child = renderedChildren[i];
|
|
223
|
+
const key = getChildKey(child);
|
|
224
|
+
if (!presentKeys.includes(key)) {
|
|
225
|
+
nextChildren.splice(i, 0, child);
|
|
226
|
+
exitingChildren.push(child);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (mode === "wait" && exitingChildren.length) {
|
|
230
|
+
nextChildren = exitingChildren;
|
|
231
|
+
}
|
|
232
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
233
|
+
setDiffedChildren(presentChildren);
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const { forceRender } = reactExports.useContext(LayoutGroupContext);
|
|
237
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: renderedChildren.map((child) => {
|
|
238
|
+
const key = getChildKey(child);
|
|
239
|
+
const isPresent = propagate && !isParentPresent ? false : presentChildren === renderedChildren || presentKeys.includes(key);
|
|
240
|
+
const onExit = () => {
|
|
241
|
+
if (exitingComponents.current.has(key)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (exitComplete.has(key)) {
|
|
245
|
+
exitingComponents.current.add(key);
|
|
246
|
+
exitComplete.set(key, true);
|
|
247
|
+
} else {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
let isEveryExitComplete = true;
|
|
251
|
+
exitComplete.forEach((isExitComplete) => {
|
|
252
|
+
if (!isExitComplete)
|
|
253
|
+
isEveryExitComplete = false;
|
|
254
|
+
});
|
|
255
|
+
if (isEveryExitComplete) {
|
|
256
|
+
forceRender?.();
|
|
257
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
258
|
+
propagate && safeToRemove?.();
|
|
259
|
+
onExitComplete && onExitComplete();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return jsxRuntimeExports.jsx(PresenceChild, { isPresent, initial: !isInitialRender.current || initial ? void 0 : false, custom, presenceAffectsLayout, mode, root, onExitComplete: isPresent ? void 0 : onExit, anchorX, anchorY, children: child }, key);
|
|
263
|
+
}) });
|
|
264
|
+
};
|
|
265
|
+
const LazyContext = reactExports.createContext({ strict: false });
|
|
266
|
+
const featureProps = {
|
|
267
|
+
animation: [
|
|
268
|
+
"animate",
|
|
269
|
+
"variants",
|
|
270
|
+
"whileHover",
|
|
271
|
+
"whileTap",
|
|
272
|
+
"exit",
|
|
273
|
+
"whileInView",
|
|
274
|
+
"whileFocus",
|
|
275
|
+
"whileDrag"
|
|
276
|
+
],
|
|
277
|
+
exit: ["exit"],
|
|
278
|
+
drag: ["drag", "dragControls"],
|
|
279
|
+
focus: ["whileFocus"],
|
|
280
|
+
hover: ["whileHover", "onHoverStart", "onHoverEnd"],
|
|
281
|
+
tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
|
|
282
|
+
pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
|
|
283
|
+
inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
|
|
284
|
+
layout: ["layout", "layoutId"]
|
|
285
|
+
};
|
|
286
|
+
let isInitialized = false;
|
|
287
|
+
function initFeatureDefinitions() {
|
|
288
|
+
if (isInitialized)
|
|
289
|
+
return;
|
|
290
|
+
const initialFeatureDefinitions = {};
|
|
291
|
+
for (const key in featureProps) {
|
|
292
|
+
initialFeatureDefinitions[key] = {
|
|
293
|
+
isEnabled: (props) => featureProps[key].some((name) => !!props[name])
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
setFeatureDefinitions(initialFeatureDefinitions);
|
|
297
|
+
isInitialized = true;
|
|
298
|
+
}
|
|
299
|
+
function getInitializedFeatureDefinitions() {
|
|
300
|
+
initFeatureDefinitions();
|
|
301
|
+
return getFeatureDefinitions();
|
|
302
|
+
}
|
|
303
|
+
function loadFeatures(features) {
|
|
304
|
+
const featureDefinitions = getInitializedFeatureDefinitions();
|
|
305
|
+
for (const key in features) {
|
|
306
|
+
featureDefinitions[key] = {
|
|
307
|
+
...featureDefinitions[key],
|
|
308
|
+
...features[key]
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
setFeatureDefinitions(featureDefinitions);
|
|
312
|
+
}
|
|
313
|
+
const validMotionProps = /* @__PURE__ */ new Set([
|
|
314
|
+
"animate",
|
|
315
|
+
"exit",
|
|
316
|
+
"variants",
|
|
317
|
+
"initial",
|
|
318
|
+
"style",
|
|
319
|
+
"values",
|
|
320
|
+
"variants",
|
|
321
|
+
"transition",
|
|
322
|
+
"transformTemplate",
|
|
323
|
+
"custom",
|
|
324
|
+
"inherit",
|
|
325
|
+
"onBeforeLayoutMeasure",
|
|
326
|
+
"onAnimationStart",
|
|
327
|
+
"onAnimationComplete",
|
|
328
|
+
"onUpdate",
|
|
329
|
+
"onDragStart",
|
|
330
|
+
"onDrag",
|
|
331
|
+
"onDragEnd",
|
|
332
|
+
"onMeasureDragConstraints",
|
|
333
|
+
"onDirectionLock",
|
|
334
|
+
"onDragTransitionEnd",
|
|
335
|
+
"_dragX",
|
|
336
|
+
"_dragY",
|
|
337
|
+
"onHoverStart",
|
|
338
|
+
"onHoverEnd",
|
|
339
|
+
"onViewportEnter",
|
|
340
|
+
"onViewportLeave",
|
|
341
|
+
"globalTapTarget",
|
|
342
|
+
"propagate",
|
|
343
|
+
"ignoreStrict",
|
|
344
|
+
"viewport"
|
|
345
|
+
]);
|
|
346
|
+
function isValidMotionProp(key) {
|
|
347
|
+
return key.startsWith("while") || key.startsWith("drag") && key !== "draggable" || key.startsWith("layout") || key.startsWith("onTap") || key.startsWith("onPan") || key.startsWith("onLayout") || validMotionProps.has(key);
|
|
348
|
+
}
|
|
349
|
+
let shouldForward = (key) => !isValidMotionProp(key);
|
|
350
|
+
function loadExternalIsValidProp(isValidProp) {
|
|
351
|
+
if (typeof isValidProp !== "function")
|
|
352
|
+
return;
|
|
353
|
+
shouldForward = (key) => key.startsWith("on") ? !isValidMotionProp(key) : isValidProp(key);
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
const emotionPkg = "@emotion/is-prop-valid";
|
|
357
|
+
loadExternalIsValidProp(require(emotionPkg).default);
|
|
358
|
+
} catch {
|
|
359
|
+
}
|
|
360
|
+
function filterProps(props, isDom, forwardMotionProps) {
|
|
361
|
+
const filteredProps = {};
|
|
362
|
+
for (const key in props) {
|
|
363
|
+
if (key === "values" && typeof props.values === "object")
|
|
364
|
+
continue;
|
|
365
|
+
if (isMotionValue(props[key]))
|
|
366
|
+
continue;
|
|
367
|
+
if (shouldForward(key) || forwardMotionProps === true && isValidMotionProp(key) || !isDom && !isValidMotionProp(key) || // If trying to use native HTML drag events, forward drag listeners
|
|
368
|
+
props["draggable"] && key.startsWith("onDrag")) {
|
|
369
|
+
filteredProps[key] = props[key];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return filteredProps;
|
|
373
|
+
}
|
|
374
|
+
const MotionContext = /* @__PURE__ */ reactExports.createContext({});
|
|
375
|
+
function getCurrentTreeVariants(props, context) {
|
|
376
|
+
if (isControllingVariants(props)) {
|
|
377
|
+
const { initial, animate } = props;
|
|
378
|
+
return {
|
|
379
|
+
initial: initial === false || isVariantLabel(initial) ? initial : void 0,
|
|
380
|
+
animate: isVariantLabel(animate) ? animate : void 0
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
return props.inherit !== false ? context : {};
|
|
384
|
+
}
|
|
385
|
+
function useCreateMotionContext(props) {
|
|
386
|
+
const { initial, animate } = getCurrentTreeVariants(props, reactExports.useContext(MotionContext));
|
|
387
|
+
return reactExports.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
|
|
388
|
+
}
|
|
389
|
+
function variantLabelsAsDependency(prop) {
|
|
390
|
+
return Array.isArray(prop) ? prop.join(" ") : prop;
|
|
391
|
+
}
|
|
392
|
+
const createHtmlRenderState = () => ({
|
|
393
|
+
style: {},
|
|
394
|
+
transform: {},
|
|
395
|
+
transformOrigin: {},
|
|
396
|
+
vars: {}
|
|
397
|
+
});
|
|
398
|
+
function copyRawValuesOnly(target, source, props) {
|
|
399
|
+
for (const key in source) {
|
|
400
|
+
if (!isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
|
|
401
|
+
target[key] = source[key];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function useInitialMotionValues({ transformTemplate }, visualState) {
|
|
406
|
+
return reactExports.useMemo(() => {
|
|
407
|
+
const state = createHtmlRenderState();
|
|
408
|
+
buildHTMLStyles(state, visualState, transformTemplate);
|
|
409
|
+
return Object.assign({}, state.vars, state.style);
|
|
410
|
+
}, [visualState]);
|
|
411
|
+
}
|
|
412
|
+
function useStyle(props, visualState) {
|
|
413
|
+
const styleProp = props.style || {};
|
|
414
|
+
const style = {};
|
|
415
|
+
copyRawValuesOnly(style, styleProp, props);
|
|
416
|
+
Object.assign(style, useInitialMotionValues(props, visualState));
|
|
417
|
+
return style;
|
|
418
|
+
}
|
|
419
|
+
function useHTMLProps(props, visualState) {
|
|
420
|
+
const htmlProps = {};
|
|
421
|
+
const style = useStyle(props, visualState);
|
|
422
|
+
if (props.drag && props.dragListener !== false) {
|
|
423
|
+
htmlProps.draggable = false;
|
|
424
|
+
style.userSelect = style.WebkitUserSelect = style.WebkitTouchCallout = "none";
|
|
425
|
+
style.touchAction = props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`;
|
|
426
|
+
}
|
|
427
|
+
if (props.tabIndex === void 0 && (props.onTap || props.onTapStart || props.whileTap)) {
|
|
428
|
+
htmlProps.tabIndex = 0;
|
|
429
|
+
}
|
|
430
|
+
htmlProps.style = style;
|
|
431
|
+
return htmlProps;
|
|
432
|
+
}
|
|
433
|
+
const createSvgRenderState = () => ({
|
|
434
|
+
...createHtmlRenderState(),
|
|
435
|
+
attrs: {}
|
|
436
|
+
});
|
|
437
|
+
function useSVGProps(props, visualState, _isStatic, Component) {
|
|
438
|
+
const visualProps = reactExports.useMemo(() => {
|
|
439
|
+
const state = createSvgRenderState();
|
|
440
|
+
buildSVGAttrs(state, visualState, isSVGTag(Component), props.transformTemplate, props.style);
|
|
441
|
+
return {
|
|
442
|
+
...state.attrs,
|
|
443
|
+
style: { ...state.style }
|
|
444
|
+
};
|
|
445
|
+
}, [visualState]);
|
|
446
|
+
if (props.style) {
|
|
447
|
+
const rawStyles = {};
|
|
448
|
+
copyRawValuesOnly(rawStyles, props.style, props);
|
|
449
|
+
visualProps.style = { ...rawStyles, ...visualProps.style };
|
|
450
|
+
}
|
|
451
|
+
return visualProps;
|
|
452
|
+
}
|
|
453
|
+
const lowercaseSVGElements = [
|
|
454
|
+
"animate",
|
|
455
|
+
"circle",
|
|
456
|
+
"defs",
|
|
457
|
+
"desc",
|
|
458
|
+
"ellipse",
|
|
459
|
+
"g",
|
|
460
|
+
"image",
|
|
461
|
+
"line",
|
|
462
|
+
"filter",
|
|
463
|
+
"marker",
|
|
464
|
+
"mask",
|
|
465
|
+
"metadata",
|
|
466
|
+
"path",
|
|
467
|
+
"pattern",
|
|
468
|
+
"polygon",
|
|
469
|
+
"polyline",
|
|
470
|
+
"rect",
|
|
471
|
+
"stop",
|
|
472
|
+
"switch",
|
|
473
|
+
"symbol",
|
|
474
|
+
"svg",
|
|
475
|
+
"text",
|
|
476
|
+
"tspan",
|
|
477
|
+
"use",
|
|
478
|
+
"view"
|
|
479
|
+
];
|
|
480
|
+
function isSVGComponent(Component) {
|
|
481
|
+
if (
|
|
482
|
+
/**
|
|
483
|
+
* If it's not a string, it's a custom React component. Currently we only support
|
|
484
|
+
* HTML custom React components.
|
|
485
|
+
*/
|
|
486
|
+
typeof Component !== "string" || /**
|
|
487
|
+
* If it contains a dash, the element is a custom HTML webcomponent.
|
|
488
|
+
*/
|
|
489
|
+
Component.includes("-")
|
|
490
|
+
) {
|
|
491
|
+
return false;
|
|
492
|
+
} else if (
|
|
493
|
+
/**
|
|
494
|
+
* If it's in our list of lowercase SVG tags, it's an SVG component
|
|
495
|
+
*/
|
|
496
|
+
lowercaseSVGElements.indexOf(Component) > -1 || /**
|
|
497
|
+
* If it contains a capital letter, it's an SVG component
|
|
498
|
+
*/
|
|
499
|
+
/[A-Z]/u.test(Component)
|
|
500
|
+
) {
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
function useRender(Component, props, ref, { latestValues }, isStatic, forwardMotionProps = false, isSVG) {
|
|
506
|
+
const useVisualProps = isSVG ?? isSVGComponent(Component) ? useSVGProps : useHTMLProps;
|
|
507
|
+
const visualProps = useVisualProps(props, latestValues, isStatic, Component);
|
|
508
|
+
const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
|
|
509
|
+
const elementProps = Component !== reactExports.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
|
|
510
|
+
const { children } = props;
|
|
511
|
+
const renderedChildren = reactExports.useMemo(() => isMotionValue(children) ? children.get() : children, [children]);
|
|
512
|
+
return reactExports.createElement(Component, {
|
|
513
|
+
...elementProps,
|
|
514
|
+
children: renderedChildren
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function makeState({ scrapeMotionValuesFromProps: scrapeMotionValuesFromProps2, createRenderState }, props, context, presenceContext) {
|
|
518
|
+
const state = {
|
|
519
|
+
latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps2),
|
|
520
|
+
renderState: createRenderState()
|
|
521
|
+
};
|
|
522
|
+
return state;
|
|
523
|
+
}
|
|
524
|
+
function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
|
|
525
|
+
const values = {};
|
|
526
|
+
const motionValues = scrapeMotionValues(props, {});
|
|
527
|
+
for (const key in motionValues) {
|
|
528
|
+
values[key] = resolveMotionValue(motionValues[key]);
|
|
529
|
+
}
|
|
530
|
+
let { initial, animate } = props;
|
|
531
|
+
const isControllingVariants$1 = isControllingVariants(props);
|
|
532
|
+
const isVariantNode$1 = isVariantNode(props);
|
|
533
|
+
if (context && isVariantNode$1 && !isControllingVariants$1 && props.inherit !== false) {
|
|
534
|
+
if (initial === void 0)
|
|
535
|
+
initial = context.initial;
|
|
536
|
+
if (animate === void 0)
|
|
537
|
+
animate = context.animate;
|
|
538
|
+
}
|
|
539
|
+
let isInitialAnimationBlocked = presenceContext ? presenceContext.initial === false : false;
|
|
540
|
+
isInitialAnimationBlocked = isInitialAnimationBlocked || initial === false;
|
|
541
|
+
const variantToSet = isInitialAnimationBlocked ? animate : initial;
|
|
542
|
+
if (variantToSet && typeof variantToSet !== "boolean" && !isAnimationControls(variantToSet)) {
|
|
543
|
+
const list = Array.isArray(variantToSet) ? variantToSet : [variantToSet];
|
|
544
|
+
for (let i = 0; i < list.length; i++) {
|
|
545
|
+
const resolved = resolveVariantFromProps(props, list[i]);
|
|
546
|
+
if (resolved) {
|
|
547
|
+
const { transitionEnd, transition, ...target } = resolved;
|
|
548
|
+
for (const key in target) {
|
|
549
|
+
let valueTarget = target[key];
|
|
550
|
+
if (Array.isArray(valueTarget)) {
|
|
551
|
+
const index = isInitialAnimationBlocked ? valueTarget.length - 1 : 0;
|
|
552
|
+
valueTarget = valueTarget[index];
|
|
553
|
+
}
|
|
554
|
+
if (valueTarget !== null) {
|
|
555
|
+
values[key] = valueTarget;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
for (const key in transitionEnd) {
|
|
559
|
+
values[key] = transitionEnd[key];
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return values;
|
|
565
|
+
}
|
|
566
|
+
const makeUseVisualState = (config) => (props, isStatic) => {
|
|
567
|
+
const context = reactExports.useContext(MotionContext);
|
|
568
|
+
const presenceContext = reactExports.useContext(PresenceContext);
|
|
569
|
+
const make = () => makeState(config, props, context, presenceContext);
|
|
570
|
+
return isStatic ? make() : useConstant(make);
|
|
571
|
+
};
|
|
572
|
+
const useHTMLVisualState = /* @__PURE__ */ makeUseVisualState({
|
|
573
|
+
scrapeMotionValuesFromProps,
|
|
574
|
+
createRenderState: createHtmlRenderState
|
|
575
|
+
});
|
|
576
|
+
const useSVGVisualState = /* @__PURE__ */ makeUseVisualState({
|
|
577
|
+
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps$1,
|
|
578
|
+
createRenderState: createSvgRenderState
|
|
579
|
+
});
|
|
580
|
+
const motionComponentSymbol = /* @__PURE__ */ Symbol.for("motionComponentSymbol");
|
|
581
|
+
function useMotionRef(visualState, visualElement, externalRef) {
|
|
582
|
+
const externalRefContainer = reactExports.useRef(externalRef);
|
|
583
|
+
reactExports.useInsertionEffect(() => {
|
|
584
|
+
externalRefContainer.current = externalRef;
|
|
585
|
+
});
|
|
586
|
+
const refCleanup = reactExports.useRef(null);
|
|
587
|
+
return reactExports.useCallback((instance) => {
|
|
588
|
+
if (instance) {
|
|
589
|
+
visualState.onMount?.(instance);
|
|
590
|
+
}
|
|
591
|
+
if (visualElement) {
|
|
592
|
+
instance ? visualElement.mount(instance) : visualElement.unmount();
|
|
593
|
+
}
|
|
594
|
+
const ref = externalRefContainer.current;
|
|
595
|
+
if (typeof ref === "function") {
|
|
596
|
+
if (instance) {
|
|
597
|
+
const cleanup = ref(instance);
|
|
598
|
+
if (typeof cleanup === "function") {
|
|
599
|
+
refCleanup.current = cleanup;
|
|
600
|
+
}
|
|
601
|
+
} else if (refCleanup.current) {
|
|
602
|
+
refCleanup.current();
|
|
603
|
+
refCleanup.current = null;
|
|
604
|
+
} else {
|
|
605
|
+
ref(instance);
|
|
606
|
+
}
|
|
607
|
+
} else if (ref) {
|
|
608
|
+
ref.current = instance;
|
|
609
|
+
}
|
|
610
|
+
}, [visualElement]);
|
|
611
|
+
}
|
|
612
|
+
const SwitchLayoutGroupContext = reactExports.createContext({});
|
|
613
|
+
function isRefObject(ref) {
|
|
614
|
+
return ref && typeof ref === "object" && Object.prototype.hasOwnProperty.call(ref, "current");
|
|
615
|
+
}
|
|
616
|
+
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
|
|
617
|
+
const { visualElement: parent } = reactExports.useContext(MotionContext);
|
|
618
|
+
const lazyContext = reactExports.useContext(LazyContext);
|
|
619
|
+
const presenceContext = reactExports.useContext(PresenceContext);
|
|
620
|
+
const motionConfig = reactExports.useContext(MotionConfigContext);
|
|
621
|
+
const reducedMotionConfig = motionConfig.reducedMotion;
|
|
622
|
+
const skipAnimations = motionConfig.skipAnimations;
|
|
623
|
+
const visualElementRef = reactExports.useRef(null);
|
|
624
|
+
const hasMountedOnce = reactExports.useRef(false);
|
|
625
|
+
createVisualElement = createVisualElement || lazyContext.renderer;
|
|
626
|
+
if (!visualElementRef.current && createVisualElement) {
|
|
627
|
+
visualElementRef.current = createVisualElement(Component, {
|
|
628
|
+
visualState,
|
|
629
|
+
parent,
|
|
630
|
+
props,
|
|
631
|
+
presenceContext,
|
|
632
|
+
blockInitialAnimation: presenceContext ? presenceContext.initial === false : false,
|
|
633
|
+
reducedMotionConfig,
|
|
634
|
+
skipAnimations,
|
|
635
|
+
isSVG
|
|
636
|
+
});
|
|
637
|
+
if (hasMountedOnce.current && visualElementRef.current) {
|
|
638
|
+
visualElementRef.current.manuallyAnimateOnMount = true;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const visualElement = visualElementRef.current;
|
|
642
|
+
const initialLayoutGroupConfig = reactExports.useContext(SwitchLayoutGroupContext);
|
|
643
|
+
if (visualElement && !visualElement.projection && ProjectionNodeConstructor && (visualElement.type === "html" || visualElement.type === "svg")) {
|
|
644
|
+
createProjectionNode(visualElementRef.current, props, ProjectionNodeConstructor, initialLayoutGroupConfig);
|
|
645
|
+
}
|
|
646
|
+
const isMounted = reactExports.useRef(false);
|
|
647
|
+
reactExports.useInsertionEffect(() => {
|
|
648
|
+
if (visualElement && isMounted.current) {
|
|
649
|
+
visualElement.update(props, presenceContext);
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
const optimisedAppearId = props[optimizedAppearDataAttribute];
|
|
653
|
+
const wantsHandoff = reactExports.useRef(Boolean(optimisedAppearId) && typeof window !== "undefined" && !window.MotionHandoffIsComplete?.(optimisedAppearId) && window.MotionHasOptimisedAnimation?.(optimisedAppearId));
|
|
654
|
+
useIsomorphicLayoutEffect(() => {
|
|
655
|
+
hasMountedOnce.current = true;
|
|
656
|
+
if (!visualElement)
|
|
657
|
+
return;
|
|
658
|
+
isMounted.current = true;
|
|
659
|
+
window.MotionIsMounted = true;
|
|
660
|
+
visualElement.updateFeatures();
|
|
661
|
+
visualElement.scheduleRenderMicrotask();
|
|
662
|
+
if (wantsHandoff.current && visualElement.animationState) {
|
|
663
|
+
visualElement.animationState.animateChanges();
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
reactExports.useEffect(() => {
|
|
667
|
+
if (!visualElement)
|
|
668
|
+
return;
|
|
669
|
+
if (!wantsHandoff.current && visualElement.animationState) {
|
|
670
|
+
visualElement.animationState.animateChanges();
|
|
671
|
+
}
|
|
672
|
+
if (wantsHandoff.current) {
|
|
673
|
+
queueMicrotask(() => {
|
|
674
|
+
window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
|
|
675
|
+
});
|
|
676
|
+
wantsHandoff.current = false;
|
|
677
|
+
}
|
|
678
|
+
visualElement.enteringChildren = void 0;
|
|
679
|
+
});
|
|
680
|
+
return visualElement;
|
|
681
|
+
}
|
|
682
|
+
function createProjectionNode(visualElement, props, ProjectionNodeConstructor, initialPromotionConfig) {
|
|
683
|
+
const { layoutId, layout: layout2, drag: drag2, dragConstraints, layoutScroll, layoutRoot, layoutAnchor, layoutCrossfade } = props;
|
|
684
|
+
visualElement.projection = new ProjectionNodeConstructor(visualElement.latestValues, props["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(visualElement.parent));
|
|
685
|
+
visualElement.projection.setOptions({
|
|
686
|
+
layoutId,
|
|
687
|
+
layout: layout2,
|
|
688
|
+
alwaysMeasureLayout: Boolean(drag2) || dragConstraints && isRefObject(dragConstraints),
|
|
689
|
+
visualElement,
|
|
690
|
+
/**
|
|
691
|
+
* TODO: Update options in an effect. This could be tricky as it'll be too late
|
|
692
|
+
* to update by the time layout animations run.
|
|
693
|
+
* We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
|
|
694
|
+
* ensuring it gets called if there's no potential layout animations.
|
|
695
|
+
*
|
|
696
|
+
*/
|
|
697
|
+
animationType: typeof layout2 === "string" ? layout2 : "both",
|
|
698
|
+
initialPromotionConfig,
|
|
699
|
+
crossfade: layoutCrossfade,
|
|
700
|
+
layoutScroll,
|
|
701
|
+
layoutRoot,
|
|
702
|
+
layoutAnchor
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
function getClosestProjectingNode(visualElement) {
|
|
706
|
+
if (!visualElement)
|
|
707
|
+
return void 0;
|
|
708
|
+
return visualElement.options.allowProjection !== false ? visualElement.projection : getClosestProjectingNode(visualElement.parent);
|
|
709
|
+
}
|
|
710
|
+
function createMotionComponent(Component, { forwardMotionProps = false, type } = {}, preloadedFeatures, createVisualElement) {
|
|
711
|
+
preloadedFeatures && loadFeatures(preloadedFeatures);
|
|
712
|
+
const isSVG = type ? type === "svg" : isSVGComponent(Component);
|
|
713
|
+
const useVisualState = isSVG ? useSVGVisualState : useHTMLVisualState;
|
|
714
|
+
function MotionDOMComponent(props, externalRef) {
|
|
715
|
+
let MeasureLayout2;
|
|
716
|
+
const configAndProps = {
|
|
717
|
+
...reactExports.useContext(MotionConfigContext),
|
|
718
|
+
...props,
|
|
719
|
+
layoutId: useLayoutId(props)
|
|
720
|
+
};
|
|
721
|
+
const { isStatic } = configAndProps;
|
|
722
|
+
const context = useCreateMotionContext(props);
|
|
723
|
+
const visualState = useVisualState(props, isStatic);
|
|
724
|
+
if (!isStatic && typeof window !== "undefined") {
|
|
725
|
+
useStrictMode();
|
|
726
|
+
const layoutProjection = getProjectionFunctionality(configAndProps);
|
|
727
|
+
MeasureLayout2 = layoutProjection.MeasureLayout;
|
|
728
|
+
context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode, isSVG);
|
|
729
|
+
}
|
|
730
|
+
return jsxRuntimeExports.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout2 && context.visualElement ? jsxRuntimeExports.jsx(MeasureLayout2, { visualElement: context.visualElement, ...configAndProps }) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps, isSVG)] });
|
|
731
|
+
}
|
|
732
|
+
MotionDOMComponent.displayName = `motion.${typeof Component === "string" ? Component : `create(${Component.displayName ?? Component.name ?? ""})`}`;
|
|
733
|
+
const ForwardRefMotionComponent = reactExports.forwardRef(MotionDOMComponent);
|
|
734
|
+
ForwardRefMotionComponent[motionComponentSymbol] = Component;
|
|
735
|
+
return ForwardRefMotionComponent;
|
|
736
|
+
}
|
|
737
|
+
function useLayoutId({ layoutId }) {
|
|
738
|
+
const layoutGroupId = reactExports.useContext(LayoutGroupContext).id;
|
|
739
|
+
return layoutGroupId && layoutId !== void 0 ? layoutGroupId + "-" + layoutId : layoutId;
|
|
740
|
+
}
|
|
741
|
+
function useStrictMode(configAndProps, preloadedFeatures) {
|
|
742
|
+
reactExports.useContext(LazyContext).strict;
|
|
743
|
+
}
|
|
744
|
+
function getProjectionFunctionality(props) {
|
|
745
|
+
const featureDefinitions = getInitializedFeatureDefinitions();
|
|
746
|
+
const { drag: drag2, layout: layout2 } = featureDefinitions;
|
|
747
|
+
if (!drag2 && !layout2)
|
|
748
|
+
return {};
|
|
749
|
+
const combined = { ...drag2, ...layout2 };
|
|
750
|
+
return {
|
|
751
|
+
MeasureLayout: drag2?.isEnabled(props) || layout2?.isEnabled(props) ? combined.MeasureLayout : void 0,
|
|
752
|
+
ProjectionNode: combined.ProjectionNode
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
function createMotionProxy(preloadedFeatures, createVisualElement) {
|
|
756
|
+
if (typeof Proxy === "undefined") {
|
|
757
|
+
return createMotionComponent;
|
|
758
|
+
}
|
|
759
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
760
|
+
const factory = (Component, options) => {
|
|
761
|
+
return createMotionComponent(Component, options, preloadedFeatures, createVisualElement);
|
|
762
|
+
};
|
|
763
|
+
const deprecatedFactoryFunction = (Component, options) => {
|
|
764
|
+
return factory(Component, options);
|
|
765
|
+
};
|
|
766
|
+
return new Proxy(deprecatedFactoryFunction, {
|
|
767
|
+
/**
|
|
768
|
+
* Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc.
|
|
769
|
+
* The prop name is passed through as `key` and we can use that to generate a `motion`
|
|
770
|
+
* DOM component with that name.
|
|
771
|
+
*/
|
|
772
|
+
get: (_target, key) => {
|
|
773
|
+
if (key === "create")
|
|
774
|
+
return factory;
|
|
775
|
+
if (!componentCache.has(key)) {
|
|
776
|
+
componentCache.set(key, createMotionComponent(key, void 0, preloadedFeatures, createVisualElement));
|
|
777
|
+
}
|
|
778
|
+
return componentCache.get(key);
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
const createDomVisualElement = (Component, options) => {
|
|
783
|
+
const isSVG = options.isSVG ?? isSVGComponent(Component);
|
|
784
|
+
return isSVG ? new SVGVisualElement(options) : new HTMLVisualElement(options, {
|
|
785
|
+
allowProjection: Component !== reactExports.Fragment
|
|
786
|
+
});
|
|
787
|
+
};
|
|
788
|
+
class AnimationFeature extends Feature {
|
|
789
|
+
/**
|
|
790
|
+
* We dynamically generate the AnimationState manager as it contains a reference
|
|
791
|
+
* to the underlying animation library. We only want to load that if we load this,
|
|
792
|
+
* so people can optionally code split it out using the `m` component.
|
|
793
|
+
*/
|
|
794
|
+
constructor(node) {
|
|
795
|
+
super(node);
|
|
796
|
+
node.animationState || (node.animationState = createAnimationState(node));
|
|
797
|
+
}
|
|
798
|
+
updateAnimationControlsSubscription() {
|
|
799
|
+
const { animate } = this.node.getProps();
|
|
800
|
+
if (isAnimationControls(animate)) {
|
|
801
|
+
this.unmountControls = animate.subscribe(this.node);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Subscribe any provided AnimationControls to the component's VisualElement
|
|
806
|
+
*/
|
|
807
|
+
mount() {
|
|
808
|
+
this.updateAnimationControlsSubscription();
|
|
809
|
+
}
|
|
810
|
+
update() {
|
|
811
|
+
const { animate } = this.node.getProps();
|
|
812
|
+
const { animate: prevAnimate } = this.node.prevProps || {};
|
|
813
|
+
if (animate !== prevAnimate) {
|
|
814
|
+
this.updateAnimationControlsSubscription();
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
unmount() {
|
|
818
|
+
this.node.animationState.reset();
|
|
819
|
+
this.unmountControls?.();
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
let id = 0;
|
|
823
|
+
class ExitAnimationFeature extends Feature {
|
|
824
|
+
constructor() {
|
|
825
|
+
super(...arguments);
|
|
826
|
+
this.id = id++;
|
|
827
|
+
this.isExitComplete = false;
|
|
828
|
+
}
|
|
829
|
+
update() {
|
|
830
|
+
if (!this.node.presenceContext)
|
|
831
|
+
return;
|
|
832
|
+
const { isPresent, onExitComplete } = this.node.presenceContext;
|
|
833
|
+
const { isPresent: prevIsPresent } = this.node.prevPresenceContext || {};
|
|
834
|
+
if (!this.node.animationState || isPresent === prevIsPresent) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if (isPresent && prevIsPresent === false) {
|
|
838
|
+
if (this.isExitComplete) {
|
|
839
|
+
const { initial, custom } = this.node.getProps();
|
|
840
|
+
if (typeof initial === "string" || typeof initial === "object" && initial !== null && !Array.isArray(initial)) {
|
|
841
|
+
const resolved = resolveVariant(this.node, initial, custom);
|
|
842
|
+
if (resolved) {
|
|
843
|
+
const { transition, transitionEnd, ...target } = resolved;
|
|
844
|
+
for (const key in target) {
|
|
845
|
+
this.node.getValue(key)?.jump(target[key]);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
this.node.animationState.reset();
|
|
850
|
+
this.node.animationState.animateChanges();
|
|
851
|
+
} else {
|
|
852
|
+
this.node.animationState.setActive("exit", false);
|
|
853
|
+
}
|
|
854
|
+
this.isExitComplete = false;
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
const exitAnimation = this.node.animationState.setActive("exit", !isPresent);
|
|
858
|
+
if (onExitComplete && !isPresent) {
|
|
859
|
+
exitAnimation.then(() => {
|
|
860
|
+
this.isExitComplete = true;
|
|
861
|
+
onExitComplete(this.id);
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
mount() {
|
|
866
|
+
const { register, onExitComplete } = this.node.presenceContext || {};
|
|
867
|
+
if (onExitComplete) {
|
|
868
|
+
onExitComplete(this.id);
|
|
869
|
+
}
|
|
870
|
+
if (register) {
|
|
871
|
+
this.unmount = register(this.id);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
unmount() {
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
const animations = {
|
|
878
|
+
animation: {
|
|
879
|
+
Feature: AnimationFeature
|
|
880
|
+
},
|
|
881
|
+
exit: {
|
|
882
|
+
Feature: ExitAnimationFeature
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
function extractEventInfo(event) {
|
|
886
|
+
return {
|
|
887
|
+
point: {
|
|
888
|
+
x: event.pageX,
|
|
889
|
+
y: event.pageY
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
const addPointerInfo = (handler) => (event) => isPrimaryPointer(event) && handler(event, extractEventInfo(event));
|
|
894
|
+
function addPointerEvent(target, eventName, handler, options) {
|
|
895
|
+
return addDomEvent(target, eventName, addPointerInfo(handler), options);
|
|
896
|
+
}
|
|
897
|
+
const getContextWindow = ({ current }) => {
|
|
898
|
+
return current ? current.ownerDocument.defaultView : null;
|
|
899
|
+
};
|
|
900
|
+
const distance = (a, b) => Math.abs(a - b);
|
|
901
|
+
function distance2D(a, b) {
|
|
902
|
+
const xDelta = distance(a.x, b.x);
|
|
903
|
+
const yDelta = distance(a.y, b.y);
|
|
904
|
+
return Math.sqrt(xDelta ** 2 + yDelta ** 2);
|
|
905
|
+
}
|
|
906
|
+
const overflowStyles = /* @__PURE__ */ new Set(["auto", "scroll"]);
|
|
907
|
+
class PanSession {
|
|
908
|
+
constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3, element } = {}) {
|
|
909
|
+
this.startEvent = null;
|
|
910
|
+
this.lastMoveEvent = null;
|
|
911
|
+
this.lastMoveEventInfo = null;
|
|
912
|
+
this.lastRawMoveEventInfo = null;
|
|
913
|
+
this.handlers = {};
|
|
914
|
+
this.contextWindow = window;
|
|
915
|
+
this.scrollPositions = /* @__PURE__ */ new Map();
|
|
916
|
+
this.removeScrollListeners = null;
|
|
917
|
+
this.onElementScroll = (event2) => {
|
|
918
|
+
this.handleScroll(event2.target);
|
|
919
|
+
};
|
|
920
|
+
this.onWindowScroll = () => {
|
|
921
|
+
this.handleScroll(window);
|
|
922
|
+
};
|
|
923
|
+
this.updatePoint = () => {
|
|
924
|
+
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
925
|
+
return;
|
|
926
|
+
if (this.lastRawMoveEventInfo) {
|
|
927
|
+
this.lastMoveEventInfo = transformPoint(this.lastRawMoveEventInfo, this.transformPagePoint);
|
|
928
|
+
}
|
|
929
|
+
const info2 = getPanInfo(this.lastMoveEventInfo, this.history);
|
|
930
|
+
const isPanStarted = this.startEvent !== null;
|
|
931
|
+
const isDistancePastThreshold = distance2D(info2.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
|
|
932
|
+
if (!isPanStarted && !isDistancePastThreshold)
|
|
933
|
+
return;
|
|
934
|
+
const { point: point2 } = info2;
|
|
935
|
+
const { timestamp: timestamp2 } = frameData;
|
|
936
|
+
this.history.push({ ...point2, timestamp: timestamp2 });
|
|
937
|
+
const { onStart, onMove } = this.handlers;
|
|
938
|
+
if (!isPanStarted) {
|
|
939
|
+
onStart && onStart(this.lastMoveEvent, info2);
|
|
940
|
+
this.startEvent = this.lastMoveEvent;
|
|
941
|
+
}
|
|
942
|
+
onMove && onMove(this.lastMoveEvent, info2);
|
|
943
|
+
};
|
|
944
|
+
this.handlePointerMove = (event2, info2) => {
|
|
945
|
+
this.lastMoveEvent = event2;
|
|
946
|
+
this.lastRawMoveEventInfo = info2;
|
|
947
|
+
this.lastMoveEventInfo = transformPoint(info2, this.transformPagePoint);
|
|
948
|
+
frame.update(this.updatePoint, true);
|
|
949
|
+
};
|
|
950
|
+
this.handlePointerUp = (event2, info2) => {
|
|
951
|
+
this.end();
|
|
952
|
+
const { onEnd, onSessionEnd, resumeAnimation } = this.handlers;
|
|
953
|
+
if (this.dragSnapToOrigin || !this.startEvent) {
|
|
954
|
+
resumeAnimation && resumeAnimation();
|
|
955
|
+
}
|
|
956
|
+
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
957
|
+
return;
|
|
958
|
+
const panInfo = getPanInfo(event2.type === "pointercancel" ? this.lastMoveEventInfo : transformPoint(info2, this.transformPagePoint), this.history);
|
|
959
|
+
if (this.startEvent && onEnd) {
|
|
960
|
+
onEnd(event2, panInfo);
|
|
961
|
+
}
|
|
962
|
+
onSessionEnd && onSessionEnd(event2, panInfo);
|
|
963
|
+
};
|
|
964
|
+
if (!isPrimaryPointer(event))
|
|
965
|
+
return;
|
|
966
|
+
this.dragSnapToOrigin = dragSnapToOrigin;
|
|
967
|
+
this.handlers = handlers;
|
|
968
|
+
this.transformPagePoint = transformPagePoint;
|
|
969
|
+
this.distanceThreshold = distanceThreshold;
|
|
970
|
+
this.contextWindow = contextWindow || window;
|
|
971
|
+
const info = extractEventInfo(event);
|
|
972
|
+
const initialInfo = transformPoint(info, this.transformPagePoint);
|
|
973
|
+
const { point } = initialInfo;
|
|
974
|
+
const { timestamp } = frameData;
|
|
975
|
+
this.history = [{ ...point, timestamp }];
|
|
976
|
+
const { onSessionStart } = handlers;
|
|
977
|
+
onSessionStart && onSessionStart(event, getPanInfo(initialInfo, this.history));
|
|
978
|
+
this.removeListeners = pipe(addPointerEvent(this.contextWindow, "pointermove", this.handlePointerMove), addPointerEvent(this.contextWindow, "pointerup", this.handlePointerUp), addPointerEvent(this.contextWindow, "pointercancel", this.handlePointerUp));
|
|
979
|
+
if (element) {
|
|
980
|
+
this.startScrollTracking(element);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Start tracking scroll on ancestors and window.
|
|
985
|
+
*/
|
|
986
|
+
startScrollTracking(element) {
|
|
987
|
+
let current = element.parentElement;
|
|
988
|
+
while (current) {
|
|
989
|
+
const style = getComputedStyle(current);
|
|
990
|
+
if (overflowStyles.has(style.overflowX) || overflowStyles.has(style.overflowY)) {
|
|
991
|
+
this.scrollPositions.set(current, {
|
|
992
|
+
x: current.scrollLeft,
|
|
993
|
+
y: current.scrollTop
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
current = current.parentElement;
|
|
997
|
+
}
|
|
998
|
+
this.scrollPositions.set(window, {
|
|
999
|
+
x: window.scrollX,
|
|
1000
|
+
y: window.scrollY
|
|
1001
|
+
});
|
|
1002
|
+
window.addEventListener("scroll", this.onElementScroll, {
|
|
1003
|
+
capture: true
|
|
1004
|
+
});
|
|
1005
|
+
window.addEventListener("scroll", this.onWindowScroll);
|
|
1006
|
+
this.removeScrollListeners = () => {
|
|
1007
|
+
window.removeEventListener("scroll", this.onElementScroll, {
|
|
1008
|
+
capture: true
|
|
1009
|
+
});
|
|
1010
|
+
window.removeEventListener("scroll", this.onWindowScroll);
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Handle scroll compensation during drag.
|
|
1015
|
+
*
|
|
1016
|
+
* For element scroll: adjusts history origin since pageX/pageY doesn't change.
|
|
1017
|
+
* For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.
|
|
1018
|
+
*/
|
|
1019
|
+
handleScroll(target) {
|
|
1020
|
+
const initial = this.scrollPositions.get(target);
|
|
1021
|
+
if (!initial)
|
|
1022
|
+
return;
|
|
1023
|
+
const isWindow = target === window;
|
|
1024
|
+
const current = isWindow ? { x: window.scrollX, y: window.scrollY } : {
|
|
1025
|
+
x: target.scrollLeft,
|
|
1026
|
+
y: target.scrollTop
|
|
1027
|
+
};
|
|
1028
|
+
const delta = { x: current.x - initial.x, y: current.y - initial.y };
|
|
1029
|
+
if (delta.x === 0 && delta.y === 0)
|
|
1030
|
+
return;
|
|
1031
|
+
if (isWindow) {
|
|
1032
|
+
if (this.lastMoveEventInfo) {
|
|
1033
|
+
this.lastMoveEventInfo.point.x += delta.x;
|
|
1034
|
+
this.lastMoveEventInfo.point.y += delta.y;
|
|
1035
|
+
}
|
|
1036
|
+
} else {
|
|
1037
|
+
if (this.history.length > 0) {
|
|
1038
|
+
this.history[0].x -= delta.x;
|
|
1039
|
+
this.history[0].y -= delta.y;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
this.scrollPositions.set(target, current);
|
|
1043
|
+
frame.update(this.updatePoint, true);
|
|
1044
|
+
}
|
|
1045
|
+
updateHandlers(handlers) {
|
|
1046
|
+
this.handlers = handlers;
|
|
1047
|
+
}
|
|
1048
|
+
end() {
|
|
1049
|
+
this.removeListeners && this.removeListeners();
|
|
1050
|
+
this.removeScrollListeners && this.removeScrollListeners();
|
|
1051
|
+
this.scrollPositions.clear();
|
|
1052
|
+
cancelFrame(this.updatePoint);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function transformPoint(info, transformPagePoint) {
|
|
1056
|
+
return transformPagePoint ? { point: transformPagePoint(info.point) } : info;
|
|
1057
|
+
}
|
|
1058
|
+
function subtractPoint(a, b) {
|
|
1059
|
+
return { x: a.x - b.x, y: a.y - b.y };
|
|
1060
|
+
}
|
|
1061
|
+
function getPanInfo({ point }, history) {
|
|
1062
|
+
return {
|
|
1063
|
+
point,
|
|
1064
|
+
delta: subtractPoint(point, lastDevicePoint(history)),
|
|
1065
|
+
offset: subtractPoint(point, startDevicePoint(history)),
|
|
1066
|
+
velocity: getVelocity(history, 0.1)
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
function startDevicePoint(history) {
|
|
1070
|
+
return history[0];
|
|
1071
|
+
}
|
|
1072
|
+
function lastDevicePoint(history) {
|
|
1073
|
+
return history[history.length - 1];
|
|
1074
|
+
}
|
|
1075
|
+
function getVelocity(history, timeDelta) {
|
|
1076
|
+
if (history.length < 2) {
|
|
1077
|
+
return { x: 0, y: 0 };
|
|
1078
|
+
}
|
|
1079
|
+
let i = history.length - 1;
|
|
1080
|
+
let timestampedPoint = null;
|
|
1081
|
+
const lastPoint = lastDevicePoint(history);
|
|
1082
|
+
while (i >= 0) {
|
|
1083
|
+
timestampedPoint = history[i];
|
|
1084
|
+
if (lastPoint.timestamp - timestampedPoint.timestamp > secondsToMilliseconds(timeDelta)) {
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
i--;
|
|
1088
|
+
}
|
|
1089
|
+
if (!timestampedPoint) {
|
|
1090
|
+
return { x: 0, y: 0 };
|
|
1091
|
+
}
|
|
1092
|
+
if (timestampedPoint === history[0] && history.length > 2 && lastPoint.timestamp - timestampedPoint.timestamp > secondsToMilliseconds(timeDelta) * 2) {
|
|
1093
|
+
timestampedPoint = history[1];
|
|
1094
|
+
}
|
|
1095
|
+
const time = millisecondsToSeconds(lastPoint.timestamp - timestampedPoint.timestamp);
|
|
1096
|
+
if (time === 0) {
|
|
1097
|
+
return { x: 0, y: 0 };
|
|
1098
|
+
}
|
|
1099
|
+
const currentVelocity = {
|
|
1100
|
+
x: (lastPoint.x - timestampedPoint.x) / time,
|
|
1101
|
+
y: (lastPoint.y - timestampedPoint.y) / time
|
|
1102
|
+
};
|
|
1103
|
+
if (currentVelocity.x === Infinity) {
|
|
1104
|
+
currentVelocity.x = 0;
|
|
1105
|
+
}
|
|
1106
|
+
if (currentVelocity.y === Infinity) {
|
|
1107
|
+
currentVelocity.y = 0;
|
|
1108
|
+
}
|
|
1109
|
+
return currentVelocity;
|
|
1110
|
+
}
|
|
1111
|
+
function applyConstraints(point, { min, max }, elastic) {
|
|
1112
|
+
if (min !== void 0 && point < min) {
|
|
1113
|
+
point = elastic ? mixNumber(min, point, elastic.min) : Math.max(point, min);
|
|
1114
|
+
} else if (max !== void 0 && point > max) {
|
|
1115
|
+
point = elastic ? mixNumber(max, point, elastic.max) : Math.min(point, max);
|
|
1116
|
+
}
|
|
1117
|
+
return point;
|
|
1118
|
+
}
|
|
1119
|
+
function calcRelativeAxisConstraints(axis, min, max) {
|
|
1120
|
+
return {
|
|
1121
|
+
min: min !== void 0 ? axis.min + min : void 0,
|
|
1122
|
+
max: max !== void 0 ? axis.max + max - (axis.max - axis.min) : void 0
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
function calcRelativeConstraints(layoutBox, { top, left, bottom, right }) {
|
|
1126
|
+
return {
|
|
1127
|
+
x: calcRelativeAxisConstraints(layoutBox.x, left, right),
|
|
1128
|
+
y: calcRelativeAxisConstraints(layoutBox.y, top, bottom)
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
function calcViewportAxisConstraints(layoutAxis, constraintsAxis) {
|
|
1132
|
+
let min = constraintsAxis.min - layoutAxis.min;
|
|
1133
|
+
let max = constraintsAxis.max - layoutAxis.max;
|
|
1134
|
+
if (constraintsAxis.max - constraintsAxis.min < layoutAxis.max - layoutAxis.min) {
|
|
1135
|
+
[min, max] = [max, min];
|
|
1136
|
+
}
|
|
1137
|
+
return { min, max };
|
|
1138
|
+
}
|
|
1139
|
+
function calcViewportConstraints(layoutBox, constraintsBox) {
|
|
1140
|
+
return {
|
|
1141
|
+
x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),
|
|
1142
|
+
y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y)
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
function calcOrigin(source, target) {
|
|
1146
|
+
let origin = 0.5;
|
|
1147
|
+
const sourceLength = calcLength(source);
|
|
1148
|
+
const targetLength = calcLength(target);
|
|
1149
|
+
if (targetLength > sourceLength) {
|
|
1150
|
+
origin = progress(target.min, target.max - sourceLength, source.min);
|
|
1151
|
+
} else if (sourceLength > targetLength) {
|
|
1152
|
+
origin = progress(source.min, source.max - targetLength, target.min);
|
|
1153
|
+
}
|
|
1154
|
+
return clamp(0, 1, origin);
|
|
1155
|
+
}
|
|
1156
|
+
function rebaseAxisConstraints(layout2, constraints) {
|
|
1157
|
+
const relativeConstraints = {};
|
|
1158
|
+
if (constraints.min !== void 0) {
|
|
1159
|
+
relativeConstraints.min = constraints.min - layout2.min;
|
|
1160
|
+
}
|
|
1161
|
+
if (constraints.max !== void 0) {
|
|
1162
|
+
relativeConstraints.max = constraints.max - layout2.min;
|
|
1163
|
+
}
|
|
1164
|
+
return relativeConstraints;
|
|
1165
|
+
}
|
|
1166
|
+
const defaultElastic = 0.35;
|
|
1167
|
+
function resolveDragElastic(dragElastic = defaultElastic) {
|
|
1168
|
+
if (dragElastic === false) {
|
|
1169
|
+
dragElastic = 0;
|
|
1170
|
+
} else if (dragElastic === true) {
|
|
1171
|
+
dragElastic = defaultElastic;
|
|
1172
|
+
}
|
|
1173
|
+
return {
|
|
1174
|
+
x: resolveAxisElastic(dragElastic, "left", "right"),
|
|
1175
|
+
y: resolveAxisElastic(dragElastic, "top", "bottom")
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function resolveAxisElastic(dragElastic, minLabel, maxLabel) {
|
|
1179
|
+
return {
|
|
1180
|
+
min: resolvePointElastic(dragElastic, minLabel),
|
|
1181
|
+
max: resolvePointElastic(dragElastic, maxLabel)
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function resolvePointElastic(dragElastic, label) {
|
|
1185
|
+
return typeof dragElastic === "number" ? dragElastic : dragElastic[label] || 0;
|
|
1186
|
+
}
|
|
1187
|
+
const elementDragControls = /* @__PURE__ */ new WeakMap();
|
|
1188
|
+
class VisualElementDragControls {
|
|
1189
|
+
constructor(visualElement) {
|
|
1190
|
+
this.openDragLock = null;
|
|
1191
|
+
this.isDragging = false;
|
|
1192
|
+
this.currentDirection = null;
|
|
1193
|
+
this.originPoint = { x: 0, y: 0 };
|
|
1194
|
+
this.constraints = false;
|
|
1195
|
+
this.hasMutatedConstraints = false;
|
|
1196
|
+
this.elastic = createBox();
|
|
1197
|
+
this.latestPointerEvent = null;
|
|
1198
|
+
this.latestPanInfo = null;
|
|
1199
|
+
this.visualElement = visualElement;
|
|
1200
|
+
}
|
|
1201
|
+
start(originEvent, { snapToCursor = false, distanceThreshold } = {}) {
|
|
1202
|
+
const { presenceContext } = this.visualElement;
|
|
1203
|
+
if (presenceContext && presenceContext.isPresent === false)
|
|
1204
|
+
return;
|
|
1205
|
+
const onSessionStart = (event) => {
|
|
1206
|
+
if (snapToCursor) {
|
|
1207
|
+
this.snapToCursor(extractEventInfo(event).point);
|
|
1208
|
+
}
|
|
1209
|
+
this.stopAnimation();
|
|
1210
|
+
};
|
|
1211
|
+
const onStart = (event, info) => {
|
|
1212
|
+
const { drag: drag2, dragPropagation, onDragStart } = this.getProps();
|
|
1213
|
+
if (drag2 && !dragPropagation) {
|
|
1214
|
+
if (this.openDragLock)
|
|
1215
|
+
this.openDragLock();
|
|
1216
|
+
this.openDragLock = setDragLock(drag2);
|
|
1217
|
+
if (!this.openDragLock)
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
this.latestPointerEvent = event;
|
|
1221
|
+
this.latestPanInfo = info;
|
|
1222
|
+
this.isDragging = true;
|
|
1223
|
+
this.currentDirection = null;
|
|
1224
|
+
this.resolveConstraints();
|
|
1225
|
+
if (this.visualElement.projection) {
|
|
1226
|
+
this.visualElement.projection.isAnimationBlocked = true;
|
|
1227
|
+
this.visualElement.projection.target = void 0;
|
|
1228
|
+
}
|
|
1229
|
+
eachAxis((axis) => {
|
|
1230
|
+
let current = this.getAxisMotionValue(axis).get() || 0;
|
|
1231
|
+
if (percent.test(current)) {
|
|
1232
|
+
const { projection } = this.visualElement;
|
|
1233
|
+
if (projection && projection.layout) {
|
|
1234
|
+
const measuredAxis = projection.layout.layoutBox[axis];
|
|
1235
|
+
if (measuredAxis) {
|
|
1236
|
+
const length = calcLength(measuredAxis);
|
|
1237
|
+
current = length * (parseFloat(current) / 100);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
this.originPoint[axis] = current;
|
|
1242
|
+
});
|
|
1243
|
+
if (onDragStart) {
|
|
1244
|
+
frame.update(() => onDragStart(event, info), false, true);
|
|
1245
|
+
}
|
|
1246
|
+
addValueToWillChange(this.visualElement, "transform");
|
|
1247
|
+
const { animationState } = this.visualElement;
|
|
1248
|
+
animationState && animationState.setActive("whileDrag", true);
|
|
1249
|
+
};
|
|
1250
|
+
const onMove = (event, info) => {
|
|
1251
|
+
this.latestPointerEvent = event;
|
|
1252
|
+
this.latestPanInfo = info;
|
|
1253
|
+
const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag } = this.getProps();
|
|
1254
|
+
if (!dragPropagation && !this.openDragLock)
|
|
1255
|
+
return;
|
|
1256
|
+
const { offset } = info;
|
|
1257
|
+
if (dragDirectionLock && this.currentDirection === null) {
|
|
1258
|
+
this.currentDirection = getCurrentDirection(offset);
|
|
1259
|
+
if (this.currentDirection !== null) {
|
|
1260
|
+
onDirectionLock && onDirectionLock(this.currentDirection);
|
|
1261
|
+
}
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
this.updateAxis("x", info.point, offset);
|
|
1265
|
+
this.updateAxis("y", info.point, offset);
|
|
1266
|
+
this.visualElement.render();
|
|
1267
|
+
if (onDrag) {
|
|
1268
|
+
frame.update(() => onDrag(event, info), false, true);
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
const onSessionEnd = (event, info) => {
|
|
1272
|
+
this.latestPointerEvent = event;
|
|
1273
|
+
this.latestPanInfo = info;
|
|
1274
|
+
this.stop(event, info);
|
|
1275
|
+
this.latestPointerEvent = null;
|
|
1276
|
+
this.latestPanInfo = null;
|
|
1277
|
+
};
|
|
1278
|
+
const resumeAnimation = () => {
|
|
1279
|
+
const { dragSnapToOrigin: snap } = this.getProps();
|
|
1280
|
+
if (snap || this.constraints) {
|
|
1281
|
+
this.startAnimation({ x: 0, y: 0 });
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
const { dragSnapToOrigin } = this.getProps();
|
|
1285
|
+
this.panSession = new PanSession(originEvent, {
|
|
1286
|
+
onSessionStart,
|
|
1287
|
+
onStart,
|
|
1288
|
+
onMove,
|
|
1289
|
+
onSessionEnd,
|
|
1290
|
+
resumeAnimation
|
|
1291
|
+
}, {
|
|
1292
|
+
transformPagePoint: this.visualElement.getTransformPagePoint(),
|
|
1293
|
+
dragSnapToOrigin,
|
|
1294
|
+
distanceThreshold,
|
|
1295
|
+
contextWindow: getContextWindow(this.visualElement),
|
|
1296
|
+
element: this.visualElement.current
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* @internal
|
|
1301
|
+
*/
|
|
1302
|
+
stop(event, panInfo) {
|
|
1303
|
+
const finalEvent = event || this.latestPointerEvent;
|
|
1304
|
+
const finalPanInfo = panInfo || this.latestPanInfo;
|
|
1305
|
+
const isDragging = this.isDragging;
|
|
1306
|
+
this.cancel();
|
|
1307
|
+
if (!isDragging || !finalPanInfo || !finalEvent)
|
|
1308
|
+
return;
|
|
1309
|
+
const { velocity } = finalPanInfo;
|
|
1310
|
+
this.startAnimation(velocity);
|
|
1311
|
+
const { onDragEnd } = this.getProps();
|
|
1312
|
+
if (onDragEnd) {
|
|
1313
|
+
frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* @internal
|
|
1318
|
+
*/
|
|
1319
|
+
cancel() {
|
|
1320
|
+
this.isDragging = false;
|
|
1321
|
+
const { projection, animationState } = this.visualElement;
|
|
1322
|
+
if (projection) {
|
|
1323
|
+
projection.isAnimationBlocked = false;
|
|
1324
|
+
}
|
|
1325
|
+
this.endPanSession();
|
|
1326
|
+
const { dragPropagation } = this.getProps();
|
|
1327
|
+
if (!dragPropagation && this.openDragLock) {
|
|
1328
|
+
this.openDragLock();
|
|
1329
|
+
this.openDragLock = null;
|
|
1330
|
+
}
|
|
1331
|
+
animationState && animationState.setActive("whileDrag", false);
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Clean up the pan session without modifying other drag state.
|
|
1335
|
+
* This is used during unmount to ensure event listeners are removed
|
|
1336
|
+
* without affecting projection animations or drag locks.
|
|
1337
|
+
* @internal
|
|
1338
|
+
*/
|
|
1339
|
+
endPanSession() {
|
|
1340
|
+
this.panSession && this.panSession.end();
|
|
1341
|
+
this.panSession = void 0;
|
|
1342
|
+
}
|
|
1343
|
+
updateAxis(axis, _point, offset) {
|
|
1344
|
+
const { drag: drag2 } = this.getProps();
|
|
1345
|
+
if (!offset || !shouldDrag(axis, drag2, this.currentDirection))
|
|
1346
|
+
return;
|
|
1347
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
1348
|
+
let next = this.originPoint[axis] + offset[axis];
|
|
1349
|
+
if (this.constraints && this.constraints[axis]) {
|
|
1350
|
+
next = applyConstraints(next, this.constraints[axis], this.elastic[axis]);
|
|
1351
|
+
}
|
|
1352
|
+
axisValue.set(next);
|
|
1353
|
+
}
|
|
1354
|
+
resolveConstraints() {
|
|
1355
|
+
const { dragConstraints, dragElastic } = this.getProps();
|
|
1356
|
+
const layout2 = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(false) : this.visualElement.projection?.layout;
|
|
1357
|
+
const prevConstraints = this.constraints;
|
|
1358
|
+
if (dragConstraints && isRefObject(dragConstraints)) {
|
|
1359
|
+
if (!this.constraints) {
|
|
1360
|
+
this.constraints = this.resolveRefConstraints();
|
|
1361
|
+
}
|
|
1362
|
+
} else {
|
|
1363
|
+
if (dragConstraints && layout2) {
|
|
1364
|
+
this.constraints = calcRelativeConstraints(layout2.layoutBox, dragConstraints);
|
|
1365
|
+
} else {
|
|
1366
|
+
this.constraints = false;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
this.elastic = resolveDragElastic(dragElastic);
|
|
1370
|
+
if (prevConstraints !== this.constraints && !isRefObject(dragConstraints) && layout2 && this.constraints && !this.hasMutatedConstraints) {
|
|
1371
|
+
eachAxis((axis) => {
|
|
1372
|
+
if (this.constraints !== false && this.getAxisMotionValue(axis)) {
|
|
1373
|
+
this.constraints[axis] = rebaseAxisConstraints(layout2.layoutBox[axis], this.constraints[axis]);
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
resolveRefConstraints() {
|
|
1379
|
+
const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();
|
|
1380
|
+
if (!constraints || !isRefObject(constraints))
|
|
1381
|
+
return false;
|
|
1382
|
+
const constraintsElement = constraints.current;
|
|
1383
|
+
const { projection } = this.visualElement;
|
|
1384
|
+
if (!projection || !projection.layout)
|
|
1385
|
+
return false;
|
|
1386
|
+
if (projection.root) {
|
|
1387
|
+
projection.root.scroll = void 0;
|
|
1388
|
+
projection.root.updateScroll();
|
|
1389
|
+
}
|
|
1390
|
+
const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
|
|
1391
|
+
let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
|
|
1392
|
+
if (onMeasureDragConstraints) {
|
|
1393
|
+
const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));
|
|
1394
|
+
this.hasMutatedConstraints = !!userConstraints;
|
|
1395
|
+
if (userConstraints) {
|
|
1396
|
+
measuredConstraints = convertBoundingBoxToBox(userConstraints);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return measuredConstraints;
|
|
1400
|
+
}
|
|
1401
|
+
startAnimation(velocity) {
|
|
1402
|
+
const { drag: drag2, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd } = this.getProps();
|
|
1403
|
+
const constraints = this.constraints || {};
|
|
1404
|
+
const momentumAnimations = eachAxis((axis) => {
|
|
1405
|
+
if (!shouldDrag(axis, drag2, this.currentDirection)) {
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
let transition = constraints && constraints[axis] || {};
|
|
1409
|
+
if (dragSnapToOrigin === true || dragSnapToOrigin === axis)
|
|
1410
|
+
transition = { min: 0, max: 0 };
|
|
1411
|
+
const bounceStiffness = dragElastic ? 200 : 1e6;
|
|
1412
|
+
const bounceDamping = dragElastic ? 40 : 1e7;
|
|
1413
|
+
const inertia = {
|
|
1414
|
+
type: "inertia",
|
|
1415
|
+
velocity: dragMomentum ? velocity[axis] : 0,
|
|
1416
|
+
bounceStiffness,
|
|
1417
|
+
bounceDamping,
|
|
1418
|
+
timeConstant: 750,
|
|
1419
|
+
restDelta: 1,
|
|
1420
|
+
restSpeed: 10,
|
|
1421
|
+
...dragTransition,
|
|
1422
|
+
...transition
|
|
1423
|
+
};
|
|
1424
|
+
return this.startAxisValueAnimation(axis, inertia);
|
|
1425
|
+
});
|
|
1426
|
+
return Promise.all(momentumAnimations).then(onDragTransitionEnd);
|
|
1427
|
+
}
|
|
1428
|
+
startAxisValueAnimation(axis, transition) {
|
|
1429
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
1430
|
+
addValueToWillChange(this.visualElement, axis);
|
|
1431
|
+
return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false));
|
|
1432
|
+
}
|
|
1433
|
+
stopAnimation() {
|
|
1434
|
+
eachAxis((axis) => this.getAxisMotionValue(axis).stop());
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Drag works differently depending on which props are provided.
|
|
1438
|
+
*
|
|
1439
|
+
* - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
|
|
1440
|
+
* - Otherwise, we apply the delta to the x/y motion values.
|
|
1441
|
+
*/
|
|
1442
|
+
getAxisMotionValue(axis) {
|
|
1443
|
+
const dragKey = `_drag${axis.toUpperCase()}`;
|
|
1444
|
+
const props = this.visualElement.getProps();
|
|
1445
|
+
const externalMotionValue = props[dragKey];
|
|
1446
|
+
return externalMotionValue ? externalMotionValue : this.visualElement.getValue(axis, this.visualElement.latestValues[axis] ?? 0);
|
|
1447
|
+
}
|
|
1448
|
+
snapToCursor(point) {
|
|
1449
|
+
eachAxis((axis) => {
|
|
1450
|
+
const { drag: drag2 } = this.getProps();
|
|
1451
|
+
if (!shouldDrag(axis, drag2, this.currentDirection))
|
|
1452
|
+
return;
|
|
1453
|
+
const { projection } = this.visualElement;
|
|
1454
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
1455
|
+
if (projection && projection.layout) {
|
|
1456
|
+
const { min, max } = projection.layout.layoutBox[axis];
|
|
1457
|
+
const current = axisValue.get() || 0;
|
|
1458
|
+
axisValue.set(point[axis] - mixNumber(min, max, 0.5) + current);
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* When the viewport resizes we want to check if the measured constraints
|
|
1464
|
+
* have changed and, if so, reposition the element within those new constraints
|
|
1465
|
+
* relative to where it was before the resize.
|
|
1466
|
+
*/
|
|
1467
|
+
scalePositionWithinConstraints() {
|
|
1468
|
+
if (!this.visualElement.current)
|
|
1469
|
+
return;
|
|
1470
|
+
const { drag: drag2, dragConstraints } = this.getProps();
|
|
1471
|
+
const { projection } = this.visualElement;
|
|
1472
|
+
if (!isRefObject(dragConstraints) || !projection || !this.constraints)
|
|
1473
|
+
return;
|
|
1474
|
+
this.stopAnimation();
|
|
1475
|
+
const boxProgress = { x: 0, y: 0 };
|
|
1476
|
+
eachAxis((axis) => {
|
|
1477
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
1478
|
+
if (axisValue && this.constraints !== false) {
|
|
1479
|
+
const latest = axisValue.get();
|
|
1480
|
+
boxProgress[axis] = calcOrigin({ min: latest, max: latest }, this.constraints[axis]);
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
const { transformTemplate } = this.visualElement.getProps();
|
|
1484
|
+
this.visualElement.current.style.transform = transformTemplate ? transformTemplate({}, "") : "none";
|
|
1485
|
+
projection.root && projection.root.updateScroll();
|
|
1486
|
+
projection.updateLayout();
|
|
1487
|
+
this.constraints = false;
|
|
1488
|
+
this.resolveConstraints();
|
|
1489
|
+
eachAxis((axis) => {
|
|
1490
|
+
if (!shouldDrag(axis, drag2, null))
|
|
1491
|
+
return;
|
|
1492
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
1493
|
+
const { min, max } = this.constraints[axis];
|
|
1494
|
+
axisValue.set(mixNumber(min, max, boxProgress[axis]));
|
|
1495
|
+
});
|
|
1496
|
+
this.visualElement.render();
|
|
1497
|
+
}
|
|
1498
|
+
addListeners() {
|
|
1499
|
+
if (!this.visualElement.current)
|
|
1500
|
+
return;
|
|
1501
|
+
elementDragControls.set(this.visualElement, this);
|
|
1502
|
+
const element = this.visualElement.current;
|
|
1503
|
+
const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
|
|
1504
|
+
const { drag: drag2, dragListener = true } = this.getProps();
|
|
1505
|
+
const target = event.target;
|
|
1506
|
+
const isClickingTextInputChild = target !== element && isElementTextInput(target);
|
|
1507
|
+
if (drag2 && dragListener && !isClickingTextInputChild) {
|
|
1508
|
+
this.start(event);
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
let stopResizeObservers;
|
|
1512
|
+
const measureDragConstraints = () => {
|
|
1513
|
+
const { dragConstraints } = this.getProps();
|
|
1514
|
+
if (isRefObject(dragConstraints) && dragConstraints.current) {
|
|
1515
|
+
this.constraints = this.resolveRefConstraints();
|
|
1516
|
+
if (!stopResizeObservers) {
|
|
1517
|
+
stopResizeObservers = startResizeObservers(element, dragConstraints.current, () => this.scalePositionWithinConstraints());
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
const { projection } = this.visualElement;
|
|
1522
|
+
const stopMeasureLayoutListener = projection.addEventListener("measure", measureDragConstraints);
|
|
1523
|
+
if (projection && !projection.layout) {
|
|
1524
|
+
projection.root && projection.root.updateScroll();
|
|
1525
|
+
projection.updateLayout();
|
|
1526
|
+
}
|
|
1527
|
+
frame.read(measureDragConstraints);
|
|
1528
|
+
const stopResizeListener = addDomEvent(window, "resize", () => this.scalePositionWithinConstraints());
|
|
1529
|
+
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
1530
|
+
if (this.isDragging && hasLayoutChanged) {
|
|
1531
|
+
eachAxis((axis) => {
|
|
1532
|
+
const motionValue = this.getAxisMotionValue(axis);
|
|
1533
|
+
if (!motionValue)
|
|
1534
|
+
return;
|
|
1535
|
+
this.originPoint[axis] += delta[axis].translate;
|
|
1536
|
+
motionValue.set(motionValue.get() + delta[axis].translate);
|
|
1537
|
+
});
|
|
1538
|
+
this.visualElement.render();
|
|
1539
|
+
}
|
|
1540
|
+
}));
|
|
1541
|
+
return () => {
|
|
1542
|
+
stopResizeListener();
|
|
1543
|
+
stopPointerListener();
|
|
1544
|
+
stopMeasureLayoutListener();
|
|
1545
|
+
stopLayoutUpdateListener && stopLayoutUpdateListener();
|
|
1546
|
+
stopResizeObservers && stopResizeObservers();
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
getProps() {
|
|
1550
|
+
const props = this.visualElement.getProps();
|
|
1551
|
+
const { drag: drag2 = false, dragDirectionLock = false, dragPropagation = false, dragConstraints = false, dragElastic = defaultElastic, dragMomentum = true } = props;
|
|
1552
|
+
return {
|
|
1553
|
+
...props,
|
|
1554
|
+
drag: drag2,
|
|
1555
|
+
dragDirectionLock,
|
|
1556
|
+
dragPropagation,
|
|
1557
|
+
dragConstraints,
|
|
1558
|
+
dragElastic,
|
|
1559
|
+
dragMomentum
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
function skipFirstCall(callback) {
|
|
1564
|
+
let isFirst = true;
|
|
1565
|
+
return () => {
|
|
1566
|
+
if (isFirst) {
|
|
1567
|
+
isFirst = false;
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
callback();
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
function startResizeObservers(element, constraintsElement, onResize) {
|
|
1574
|
+
const stopElement = resize(element, skipFirstCall(onResize));
|
|
1575
|
+
const stopContainer = resize(constraintsElement, skipFirstCall(onResize));
|
|
1576
|
+
return () => {
|
|
1577
|
+
stopElement();
|
|
1578
|
+
stopContainer();
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
function shouldDrag(direction, drag2, currentDirection) {
|
|
1582
|
+
return (drag2 === true || drag2 === direction) && (currentDirection === null || currentDirection === direction);
|
|
1583
|
+
}
|
|
1584
|
+
function getCurrentDirection(offset, lockThreshold = 10) {
|
|
1585
|
+
let direction = null;
|
|
1586
|
+
if (Math.abs(offset.y) > lockThreshold) {
|
|
1587
|
+
direction = "y";
|
|
1588
|
+
} else if (Math.abs(offset.x) > lockThreshold) {
|
|
1589
|
+
direction = "x";
|
|
1590
|
+
}
|
|
1591
|
+
return direction;
|
|
1592
|
+
}
|
|
1593
|
+
class DragGesture extends Feature {
|
|
1594
|
+
constructor(node) {
|
|
1595
|
+
super(node);
|
|
1596
|
+
this.removeGroupControls = noop;
|
|
1597
|
+
this.removeListeners = noop;
|
|
1598
|
+
this.controls = new VisualElementDragControls(node);
|
|
1599
|
+
}
|
|
1600
|
+
mount() {
|
|
1601
|
+
const { dragControls } = this.node.getProps();
|
|
1602
|
+
if (dragControls) {
|
|
1603
|
+
this.removeGroupControls = dragControls.subscribe(this.controls);
|
|
1604
|
+
}
|
|
1605
|
+
this.removeListeners = this.controls.addListeners() || noop;
|
|
1606
|
+
}
|
|
1607
|
+
update() {
|
|
1608
|
+
const { dragControls } = this.node.getProps();
|
|
1609
|
+
const { dragControls: prevDragControls } = this.node.prevProps || {};
|
|
1610
|
+
if (dragControls !== prevDragControls) {
|
|
1611
|
+
this.removeGroupControls();
|
|
1612
|
+
if (dragControls) {
|
|
1613
|
+
this.removeGroupControls = dragControls.subscribe(this.controls);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
unmount() {
|
|
1618
|
+
this.removeGroupControls();
|
|
1619
|
+
this.removeListeners();
|
|
1620
|
+
if (!this.controls.isDragging) {
|
|
1621
|
+
this.controls.endPanSession();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
const asyncHandler = (handler) => (event, info) => {
|
|
1626
|
+
if (handler) {
|
|
1627
|
+
frame.update(() => handler(event, info), false, true);
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
class PanGesture extends Feature {
|
|
1631
|
+
constructor() {
|
|
1632
|
+
super(...arguments);
|
|
1633
|
+
this.removePointerDownListener = noop;
|
|
1634
|
+
}
|
|
1635
|
+
onPointerDown(pointerDownEvent) {
|
|
1636
|
+
this.session = new PanSession(pointerDownEvent, this.createPanHandlers(), {
|
|
1637
|
+
transformPagePoint: this.node.getTransformPagePoint(),
|
|
1638
|
+
contextWindow: getContextWindow(this.node)
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
createPanHandlers() {
|
|
1642
|
+
const { onPanSessionStart, onPanStart, onPan, onPanEnd } = this.node.getProps();
|
|
1643
|
+
return {
|
|
1644
|
+
onSessionStart: asyncHandler(onPanSessionStart),
|
|
1645
|
+
onStart: asyncHandler(onPanStart),
|
|
1646
|
+
onMove: asyncHandler(onPan),
|
|
1647
|
+
onEnd: (event, info) => {
|
|
1648
|
+
delete this.session;
|
|
1649
|
+
if (onPanEnd) {
|
|
1650
|
+
frame.postRender(() => onPanEnd(event, info));
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
mount() {
|
|
1656
|
+
this.removePointerDownListener = addPointerEvent(this.node.current, "pointerdown", (event) => this.onPointerDown(event));
|
|
1657
|
+
}
|
|
1658
|
+
update() {
|
|
1659
|
+
this.session && this.session.updateHandlers(this.createPanHandlers());
|
|
1660
|
+
}
|
|
1661
|
+
unmount() {
|
|
1662
|
+
this.removePointerDownListener();
|
|
1663
|
+
this.session && this.session.end();
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
let hasTakenAnySnapshot = false;
|
|
1667
|
+
class MeasureLayoutWithContext extends reactExports.Component {
|
|
1668
|
+
/**
|
|
1669
|
+
* This only mounts projection nodes for components that
|
|
1670
|
+
* need measuring, we might want to do it for all components
|
|
1671
|
+
* in order to incorporate transforms
|
|
1672
|
+
*/
|
|
1673
|
+
componentDidMount() {
|
|
1674
|
+
const { visualElement, layoutGroup, switchLayoutGroup, layoutId } = this.props;
|
|
1675
|
+
const { projection } = visualElement;
|
|
1676
|
+
if (projection) {
|
|
1677
|
+
if (layoutGroup.group)
|
|
1678
|
+
layoutGroup.group.add(projection);
|
|
1679
|
+
if (switchLayoutGroup && switchLayoutGroup.register && layoutId) {
|
|
1680
|
+
switchLayoutGroup.register(projection);
|
|
1681
|
+
}
|
|
1682
|
+
if (hasTakenAnySnapshot) {
|
|
1683
|
+
projection.root.didUpdate();
|
|
1684
|
+
}
|
|
1685
|
+
projection.addEventListener("animationComplete", () => {
|
|
1686
|
+
this.safeToRemove();
|
|
1687
|
+
});
|
|
1688
|
+
projection.setOptions({
|
|
1689
|
+
...projection.options,
|
|
1690
|
+
layoutDependency: this.props.layoutDependency,
|
|
1691
|
+
onExitComplete: () => this.safeToRemove()
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
globalProjectionState.hasEverUpdated = true;
|
|
1695
|
+
}
|
|
1696
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
1697
|
+
const { layoutDependency, visualElement, drag: drag2, isPresent } = this.props;
|
|
1698
|
+
const { projection } = visualElement;
|
|
1699
|
+
if (!projection)
|
|
1700
|
+
return null;
|
|
1701
|
+
projection.isPresent = isPresent;
|
|
1702
|
+
if (prevProps.layoutDependency !== layoutDependency) {
|
|
1703
|
+
projection.setOptions({
|
|
1704
|
+
...projection.options,
|
|
1705
|
+
layoutDependency
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
hasTakenAnySnapshot = true;
|
|
1709
|
+
if (drag2 || prevProps.layoutDependency !== layoutDependency || layoutDependency === void 0 || prevProps.isPresent !== isPresent) {
|
|
1710
|
+
projection.willUpdate();
|
|
1711
|
+
} else {
|
|
1712
|
+
this.safeToRemove();
|
|
1713
|
+
}
|
|
1714
|
+
if (prevProps.isPresent !== isPresent) {
|
|
1715
|
+
if (isPresent) {
|
|
1716
|
+
projection.promote();
|
|
1717
|
+
} else if (!projection.relegate()) {
|
|
1718
|
+
frame.postRender(() => {
|
|
1719
|
+
const stack = projection.getStack();
|
|
1720
|
+
if (!stack || !stack.members.length) {
|
|
1721
|
+
this.safeToRemove();
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return null;
|
|
1727
|
+
}
|
|
1728
|
+
componentDidUpdate() {
|
|
1729
|
+
const { visualElement, layoutAnchor } = this.props;
|
|
1730
|
+
const { projection } = visualElement;
|
|
1731
|
+
if (projection) {
|
|
1732
|
+
projection.options.layoutAnchor = layoutAnchor;
|
|
1733
|
+
projection.root.didUpdate();
|
|
1734
|
+
microtask.postRender(() => {
|
|
1735
|
+
if (!projection.currentAnimation && projection.isLead()) {
|
|
1736
|
+
this.safeToRemove();
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
componentWillUnmount() {
|
|
1742
|
+
const { visualElement, layoutGroup, switchLayoutGroup: promoteContext } = this.props;
|
|
1743
|
+
const { projection } = visualElement;
|
|
1744
|
+
hasTakenAnySnapshot = true;
|
|
1745
|
+
if (projection) {
|
|
1746
|
+
projection.scheduleCheckAfterUnmount();
|
|
1747
|
+
if (layoutGroup && layoutGroup.group)
|
|
1748
|
+
layoutGroup.group.remove(projection);
|
|
1749
|
+
if (promoteContext && promoteContext.deregister)
|
|
1750
|
+
promoteContext.deregister(projection);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
safeToRemove() {
|
|
1754
|
+
const { safeToRemove } = this.props;
|
|
1755
|
+
safeToRemove && safeToRemove();
|
|
1756
|
+
}
|
|
1757
|
+
render() {
|
|
1758
|
+
return null;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
function MeasureLayout(props) {
|
|
1762
|
+
const [isPresent, safeToRemove] = usePresence();
|
|
1763
|
+
const layoutGroup = reactExports.useContext(LayoutGroupContext);
|
|
1764
|
+
return jsxRuntimeExports.jsx(MeasureLayoutWithContext, { ...props, layoutGroup, switchLayoutGroup: reactExports.useContext(SwitchLayoutGroupContext), isPresent, safeToRemove });
|
|
1765
|
+
}
|
|
1766
|
+
const drag = {
|
|
1767
|
+
pan: {
|
|
1768
|
+
Feature: PanGesture
|
|
1769
|
+
},
|
|
1770
|
+
drag: {
|
|
1771
|
+
Feature: DragGesture,
|
|
1772
|
+
ProjectionNode: HTMLProjectionNode,
|
|
1773
|
+
MeasureLayout
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
function handleHoverEvent(node, event, lifecycle) {
|
|
1777
|
+
const { props } = node;
|
|
1778
|
+
if (node.animationState && props.whileHover) {
|
|
1779
|
+
node.animationState.setActive("whileHover", lifecycle === "Start");
|
|
1780
|
+
}
|
|
1781
|
+
const eventName = "onHover" + lifecycle;
|
|
1782
|
+
const callback = props[eventName];
|
|
1783
|
+
if (callback) {
|
|
1784
|
+
frame.postRender(() => callback(event, extractEventInfo(event)));
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
class HoverGesture extends Feature {
|
|
1788
|
+
mount() {
|
|
1789
|
+
const { current } = this.node;
|
|
1790
|
+
if (!current)
|
|
1791
|
+
return;
|
|
1792
|
+
this.unmount = hover(current, (_element, startEvent) => {
|
|
1793
|
+
handleHoverEvent(this.node, startEvent, "Start");
|
|
1794
|
+
return (endEvent) => handleHoverEvent(this.node, endEvent, "End");
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
unmount() {
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
class FocusGesture extends Feature {
|
|
1801
|
+
constructor() {
|
|
1802
|
+
super(...arguments);
|
|
1803
|
+
this.isActive = false;
|
|
1804
|
+
}
|
|
1805
|
+
onFocus() {
|
|
1806
|
+
let isFocusVisible = false;
|
|
1807
|
+
try {
|
|
1808
|
+
isFocusVisible = this.node.current.matches(":focus-visible");
|
|
1809
|
+
} catch (e) {
|
|
1810
|
+
isFocusVisible = true;
|
|
1811
|
+
}
|
|
1812
|
+
if (!isFocusVisible || !this.node.animationState)
|
|
1813
|
+
return;
|
|
1814
|
+
this.node.animationState.setActive("whileFocus", true);
|
|
1815
|
+
this.isActive = true;
|
|
1816
|
+
}
|
|
1817
|
+
onBlur() {
|
|
1818
|
+
if (!this.isActive || !this.node.animationState)
|
|
1819
|
+
return;
|
|
1820
|
+
this.node.animationState.setActive("whileFocus", false);
|
|
1821
|
+
this.isActive = false;
|
|
1822
|
+
}
|
|
1823
|
+
mount() {
|
|
1824
|
+
this.unmount = pipe(addDomEvent(this.node.current, "focus", () => this.onFocus()), addDomEvent(this.node.current, "blur", () => this.onBlur()));
|
|
1825
|
+
}
|
|
1826
|
+
unmount() {
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function handlePressEvent(node, event, lifecycle) {
|
|
1830
|
+
const { props } = node;
|
|
1831
|
+
if (node.current instanceof HTMLButtonElement && node.current.disabled) {
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
if (node.animationState && props.whileTap) {
|
|
1835
|
+
node.animationState.setActive("whileTap", lifecycle === "Start");
|
|
1836
|
+
}
|
|
1837
|
+
const eventName = "onTap" + (lifecycle === "End" ? "" : lifecycle);
|
|
1838
|
+
const callback = props[eventName];
|
|
1839
|
+
if (callback) {
|
|
1840
|
+
frame.postRender(() => callback(event, extractEventInfo(event)));
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
class PressGesture extends Feature {
|
|
1844
|
+
mount() {
|
|
1845
|
+
const { current } = this.node;
|
|
1846
|
+
if (!current)
|
|
1847
|
+
return;
|
|
1848
|
+
const { globalTapTarget, propagate } = this.node.props;
|
|
1849
|
+
this.unmount = press(current, (_element, startEvent) => {
|
|
1850
|
+
handlePressEvent(this.node, startEvent, "Start");
|
|
1851
|
+
return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
|
|
1852
|
+
}, {
|
|
1853
|
+
useGlobalTarget: globalTapTarget,
|
|
1854
|
+
stopPropagation: propagate?.tap === false
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
unmount() {
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
const observerCallbacks = /* @__PURE__ */ new WeakMap();
|
|
1861
|
+
const observers = /* @__PURE__ */ new WeakMap();
|
|
1862
|
+
const fireObserverCallback = (entry) => {
|
|
1863
|
+
const callback = observerCallbacks.get(entry.target);
|
|
1864
|
+
callback && callback(entry);
|
|
1865
|
+
};
|
|
1866
|
+
const fireAllObserverCallbacks = (entries) => {
|
|
1867
|
+
entries.forEach(fireObserverCallback);
|
|
1868
|
+
};
|
|
1869
|
+
function initIntersectionObserver({ root, ...options }) {
|
|
1870
|
+
const lookupRoot = root || document;
|
|
1871
|
+
if (!observers.has(lookupRoot)) {
|
|
1872
|
+
observers.set(lookupRoot, {});
|
|
1873
|
+
}
|
|
1874
|
+
const rootObservers = observers.get(lookupRoot);
|
|
1875
|
+
const key = JSON.stringify(options);
|
|
1876
|
+
if (!rootObservers[key]) {
|
|
1877
|
+
rootObservers[key] = new IntersectionObserver(fireAllObserverCallbacks, { root, ...options });
|
|
1878
|
+
}
|
|
1879
|
+
return rootObservers[key];
|
|
1880
|
+
}
|
|
1881
|
+
function observeIntersection(element, options, callback) {
|
|
1882
|
+
const rootInteresectionObserver = initIntersectionObserver(options);
|
|
1883
|
+
observerCallbacks.set(element, callback);
|
|
1884
|
+
rootInteresectionObserver.observe(element);
|
|
1885
|
+
return () => {
|
|
1886
|
+
observerCallbacks.delete(element);
|
|
1887
|
+
rootInteresectionObserver.unobserve(element);
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
const thresholdNames = {
|
|
1891
|
+
some: 0,
|
|
1892
|
+
all: 1
|
|
1893
|
+
};
|
|
1894
|
+
class InViewFeature extends Feature {
|
|
1895
|
+
constructor() {
|
|
1896
|
+
super(...arguments);
|
|
1897
|
+
this.hasEnteredView = false;
|
|
1898
|
+
this.isInView = false;
|
|
1899
|
+
}
|
|
1900
|
+
startObserver() {
|
|
1901
|
+
this.stopObserver?.();
|
|
1902
|
+
const { viewport = {} } = this.node.getProps();
|
|
1903
|
+
const { root, margin: rootMargin, amount = "some", once } = viewport;
|
|
1904
|
+
const options = {
|
|
1905
|
+
root: root ? root.current : void 0,
|
|
1906
|
+
rootMargin,
|
|
1907
|
+
threshold: typeof amount === "number" ? amount : thresholdNames[amount]
|
|
1908
|
+
};
|
|
1909
|
+
const onIntersectionUpdate = (entry) => {
|
|
1910
|
+
const { isIntersecting } = entry;
|
|
1911
|
+
if (this.isInView === isIntersecting)
|
|
1912
|
+
return;
|
|
1913
|
+
this.isInView = isIntersecting;
|
|
1914
|
+
if (once && !isIntersecting && this.hasEnteredView) {
|
|
1915
|
+
return;
|
|
1916
|
+
} else if (isIntersecting) {
|
|
1917
|
+
this.hasEnteredView = true;
|
|
1918
|
+
}
|
|
1919
|
+
if (this.node.animationState) {
|
|
1920
|
+
this.node.animationState.setActive("whileInView", isIntersecting);
|
|
1921
|
+
}
|
|
1922
|
+
const { onViewportEnter, onViewportLeave } = this.node.getProps();
|
|
1923
|
+
const callback = isIntersecting ? onViewportEnter : onViewportLeave;
|
|
1924
|
+
callback && callback(entry);
|
|
1925
|
+
};
|
|
1926
|
+
this.stopObserver = observeIntersection(this.node.current, options, onIntersectionUpdate);
|
|
1927
|
+
}
|
|
1928
|
+
mount() {
|
|
1929
|
+
this.startObserver();
|
|
1930
|
+
}
|
|
1931
|
+
update() {
|
|
1932
|
+
if (typeof IntersectionObserver === "undefined")
|
|
1933
|
+
return;
|
|
1934
|
+
const { props, prevProps } = this.node;
|
|
1935
|
+
const hasOptionsChanged = ["amount", "margin", "root"].some(hasViewportOptionChanged(props, prevProps));
|
|
1936
|
+
if (hasOptionsChanged) {
|
|
1937
|
+
this.startObserver();
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
unmount() {
|
|
1941
|
+
this.stopObserver?.();
|
|
1942
|
+
this.hasEnteredView = false;
|
|
1943
|
+
this.isInView = false;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function hasViewportOptionChanged({ viewport = {} }, { viewport: prevViewport = {} } = {}) {
|
|
1947
|
+
return (name) => viewport[name] !== prevViewport[name];
|
|
1948
|
+
}
|
|
1949
|
+
const gestureAnimations = {
|
|
1950
|
+
inView: {
|
|
1951
|
+
Feature: InViewFeature
|
|
1952
|
+
},
|
|
1953
|
+
tap: {
|
|
1954
|
+
Feature: PressGesture
|
|
1955
|
+
},
|
|
1956
|
+
focus: {
|
|
1957
|
+
Feature: FocusGesture
|
|
1958
|
+
},
|
|
1959
|
+
hover: {
|
|
1960
|
+
Feature: HoverGesture
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
const layout = {
|
|
1964
|
+
layout: {
|
|
1965
|
+
ProjectionNode: HTMLProjectionNode,
|
|
1966
|
+
MeasureLayout
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
const featureBundle = {
|
|
1970
|
+
...animations,
|
|
1971
|
+
...gestureAnimations,
|
|
1972
|
+
...drag,
|
|
1973
|
+
...layout
|
|
1974
|
+
};
|
|
1975
|
+
const motion = /* @__PURE__ */ createMotionProxy(featureBundle, createDomVisualElement);
|
|
1976
|
+
export {
|
|
1977
|
+
AnimatePresence as A,
|
|
1978
|
+
motion as m
|
|
1979
|
+
};
|