@v-miniapp/ui-react 1.0.45 → 1.0.59
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/dist/components/app/app.d.ts +17 -0
- package/dist/components/app/bottom-tab-bar-layout/hook.d.ts +21 -0
- package/dist/components/app/bottom-tab-bar-layout/store.d.ts +13 -0
- package/dist/components/app/bottom-tab-bar-layout/type.d.ts +13 -0
- package/dist/components/app/data-theme.d.ts +8 -0
- package/dist/components/app/index.d.ts +9 -18
- package/dist/components/app/navigation-bar-layout/hook.d.ts +17 -0
- package/dist/components/app/navigation-bar-layout/store.d.ts +13 -0
- package/dist/components/app/navigation-bar-layout/type.d.ts +7 -0
- package/dist/components/app/page-layout/hook.d.ts +21 -0
- package/dist/components/app/page-layout/store.d.ts +13 -0
- package/dist/components/app/page-layout/type.d.ts +8 -0
- package/dist/components/app/type.d.ts +27 -0
- package/dist/components/calendar/default-render.d.ts +1 -1
- package/dist/components/calendar/utils.d.ts +1 -1
- package/dist/components/carousel/index.d.ts +1 -0
- package/dist/components/input-wrapper/input-wrapper.d.ts +2 -2
- package/dist/components/layout/page.d.ts +8 -1
- package/dist/external/index.js +11344 -7959
- package/dist/external/styles.css +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4194 -4376
- package/dist/styles.css +1 -1
- package/dist/utils/event-emitter.d.ts +4 -0
- package/dist-storybook/assets/App-Dp1UG-xp.js +93 -0
- package/dist-storybook/assets/{Color-AVL7NMMY-1_8XTICv.js → Color-AVL7NMMY-XA8cFKdV.js} +1 -1
- package/dist-storybook/assets/DEEPLINK-cjgFMuRJ.js +33 -0
- package/dist-storybook/assets/{DocsRenderer-PQXLIZUC-BO86igwd.js → DocsRenderer-PQXLIZUC-D10-0Yfb.js} +2 -2
- package/dist-storybook/assets/EVENTS-BY66PjI7.js +65 -0
- package/dist-storybook/assets/GETTING_STARTED-580o-9Mx.js +64 -0
- package/dist-storybook/assets/GETTING_STARTED-BiQMvjvo.js +62 -0
- package/dist-storybook/assets/GETTING_STARTED-CIVMqKZW.js +80 -0
- package/dist-storybook/assets/{INFINITE_SCROLL-BtM3uoX0.js → INFINITE_SCROLL-BbeR5HeP.js} +1 -1
- package/dist-storybook/assets/LocalesProvider-CMlmwAyY.js +53 -0
- package/dist-storybook/assets/MIGRATE_DARKMODE_TO_THEME-CBDyZyg2.js +107 -0
- package/dist-storybook/assets/{MIGRATION_GUIDE-2LONslE4.js → MIGRATION_GUIDE-FZyRWI-B.js} +3 -3
- package/dist-storybook/assets/OVERVIEW-C9_6gX5Q.js +51 -0
- package/dist-storybook/assets/Router-B5U8bubH.js +71 -0
- package/dist-storybook/assets/{TAILWIND_INTEGRATION-_T-VfvkM.js → TAILWIND_INTEGRATION-BJdy5DAv.js} +1 -1
- package/dist-storybook/assets/THEME-CRbvH7KT.js +103 -0
- package/dist-storybook/assets/_baseClone-DQVxEhny.js +1 -0
- package/dist-storybook/assets/alert-CKwsuaPI.js +1 -0
- package/dist-storybook/assets/{alert.stories-B-vuojPh.js → alert.stories-D0X5wUHk.js} +3 -3
- package/dist-storybook/assets/app-CTv8lFU3.js +1 -0
- package/dist-storybook/assets/avatar-rWcYGe6j.js +1 -0
- package/dist-storybook/assets/{avatar.stories-KYFztAc8.js → avatar.stories-8lrbhMma.js} +6 -6
- package/dist-storybook/assets/{axe-CmvD4WV5.js → axe-BHGdSCoA.js} +1 -1
- package/dist-storybook/assets/badge-VcjGVEum.js +1 -0
- package/dist-storybook/assets/{badge.stories-Be2ItCmQ.js → badge.stories-BEFNaUA1.js} +3 -3
- package/dist-storybook/assets/{blocks-BuaOUtiH.js → blocks-DKR3P4qW.js} +3 -3
- package/dist-storybook/assets/{bottom-tab-bar-CtcTAxuI.js → bottom-tab-bar-B6IAoRwz.js} +1 -1
- package/dist-storybook/assets/{bottom-tab-bar.stories-CDmEve6z.js → bottom-tab-bar.stories-DXzLlO5o.js} +3 -3
- package/dist-storybook/assets/button-DJH3RlJl.js +1 -0
- package/dist-storybook/assets/{button.stories-CaqLWQiY.js → button.stories-DgYDJ6x7.js} +3 -3
- package/dist-storybook/assets/calendar-C4Xe_TW2.js +1 -0
- package/dist-storybook/assets/{calendar.stories-DLWZldet.js → calendar.stories-IVvRAjWN.js} +3 -3
- package/dist-storybook/assets/carousel-DJlgMyS5.js +37 -0
- package/dist-storybook/assets/{carousel.stories-B8YbGOOr.js → carousel.stories-3rA3nxdL.js} +3 -3
- package/dist-storybook/assets/checkbox-JOxcmyCZ.js +1 -0
- package/dist-storybook/assets/{checkbox.stories-CLvfZPiw.js → checkbox.stories-ge3pgfBb.js} +3 -3
- package/dist-storybook/assets/chip-Crt60rph.js +1 -0
- package/dist-storybook/assets/{chip.stories-BbwJb5eD.js → chip.stories-D7E6fdiV.js} +3 -3
- package/dist-storybook/assets/{date-Cg-Uk_pp.js → date-B3PFMb6s.js} +1 -1
- package/dist-storybook/assets/date-field-range-B-sv9nbW.js +1 -0
- package/dist-storybook/assets/date-field.stories-B9G2heHt.js +129 -0
- package/dist-storybook/assets/date-picker-BPzKPdhO.js +1 -0
- package/dist-storybook/assets/{date-picker.stories-BuGWvzFL.js → date-picker.stories-CIFgk4q_.js} +3 -3
- package/dist-storybook/assets/dialog-BAfGQzk5.js +1 -0
- package/dist-storybook/assets/{dialog.stories-DJ0WsSkA.js → dialog.stories-vDMKz9Tw.js} +3 -3
- package/dist-storybook/assets/{chip-kG4p82WT.js → dropdown-Dtomaqpw.js} +2 -2
- package/dist-storybook/assets/{dropdown.stories-D6JUYP73.js → dropdown.stories-Cj0HM0VI.js} +3 -3
- package/dist-storybook/assets/{embla-carousel-react.esm-BYjpaHZ9.js → embla-carousel-react.esm-5D5fs7OQ.js} +1 -1
- package/dist-storybook/assets/icon-CdiFzFyf.js +1 -0
- package/dist-storybook/assets/{icon.stories-B-ZvRzFf.js → icon.stories-DWwbUUY-.js} +3 -3
- package/dist-storybook/assets/iframe-BHaCv4dM.css +1 -0
- package/dist-storybook/assets/{iframe-CQAwSt4E.js → iframe-DfPay7Zl.js} +42 -42
- package/dist-storybook/assets/image-CMKb-R3x.js +9 -0
- package/dist-storybook/assets/{image.stories-C4l8D3ju.js → image.stories-BhZU057W.js} +3 -3
- package/dist-storybook/assets/index-BWpuenI4.js +1 -0
- package/dist-storybook/assets/{index-CgMRTj-o.js → index-DqZh6B0b.js} +1 -1
- package/dist-storybook/assets/{index-BV0AJWP6.js → index-EGt7xBnA.js} +1 -1
- package/dist-storybook/assets/{index-DHiZ-gXR.js → index-cMNObl2z.js} +1 -1
- package/dist-storybook/assets/input-wrapper-CgaUwbbE.js +1 -0
- package/dist-storybook/assets/{label-DV2iCDmN.js → label-D44azUgi.js} +1 -1
- package/dist-storybook/assets/{label.stories-BwTIPFXX.js → label.stories-CXJjdYf_.js} +3 -3
- package/dist-storybook/assets/{navigation-bar-vI-FPasP.js → navigation-bar-DK3TxcTu.js} +2 -2
- package/dist-storybook/assets/{navigation-bar.stories-DYuFaJFD.js → navigation-bar.stories-CB3Kg-sH.js} +3 -3
- package/dist-storybook/assets/number-field-Bz7su9S1.js +1 -0
- package/dist-storybook/assets/{number-field.stories--fn26TJu.js → number-field.stories-DSxPSzLv.js} +3 -3
- package/dist-storybook/assets/omit-BWHsnDSR.js +1 -0
- package/dist-storybook/assets/option-item-CpeNcb5w.js +1 -0
- package/dist-storybook/assets/{option-item.stories-snjAvgay.js → option-item.stories-BvXoc8WX.js} +3 -3
- package/dist-storybook/assets/pagination-Cp-DHO4Q.js +1 -0
- package/dist-storybook/assets/{pagination.stories-BoEs0jzS.js → pagination.stories-_5qj2nTS.js} +4 -4
- package/dist-storybook/assets/proxy-B4G9nIBd.js +1 -0
- package/dist-storybook/assets/radio-D0aV0RIg.js +1 -0
- package/dist-storybook/assets/{radio.stories-DuN-Awi_.js → radio.stories-BNR-wwuw.js} +3 -3
- package/dist-storybook/assets/rating-D2e8RTGl.js +1 -0
- package/dist-storybook/assets/{rating.stories-BCcQjMEx.js → rating.stories-CI0LG0Qq.js} +3 -3
- package/dist-storybook/assets/{react-18-CNyWQ7je.js → react-18-C7pDmBBf.js} +1 -1
- package/dist-storybook/assets/{react-hufnxGVs.js → react-I9jCW2VV.js} +1 -1
- package/dist-storybook/assets/search-field-DINESW8Y.js +1 -0
- package/dist-storybook/assets/{search-field.stories-DiCZbhng.js → search-field.stories-CKXC6-Za.js} +3 -3
- package/dist-storybook/assets/section-content-D49PabBW.js +1 -0
- package/dist-storybook/assets/{section.stories-C2I_kKhu.js → section.stories-9vd48AgB.js} +3 -3
- package/dist-storybook/assets/sheet-footer-nEdxsYan.js +1 -0
- package/dist-storybook/assets/{sheet.stories-wk1JaKU5.js → sheet.stories-C3gLIQsn.js} +3 -3
- package/dist-storybook/assets/skeleton-B12XbNAJ.js +1 -0
- package/dist-storybook/assets/{skeleton.stories-BCmX-VNr.js → skeleton.stories-C0y1o1Y_.js} +3 -3
- package/dist-storybook/assets/{store-D2RudmNr.js → store-Ce3Ikv5g.js} +5 -5
- package/dist-storybook/assets/switch-D0Z9tWin.js +1 -0
- package/dist-storybook/assets/{switch.stories-BqPLNKB9.js → switch.stories-BdWFln-M.js} +3 -3
- package/dist-storybook/assets/{tab-bar-CSeCmtIZ.js → tab-bar-kExoGg5P.js} +1 -1
- package/dist-storybook/assets/{tab-bar.stories-Cb6v8H2w.js → tab-bar.stories-BgDXX0of.js} +3 -3
- package/dist-storybook/assets/text-area-GKy5HL12.js +1 -0
- package/dist-storybook/assets/{text-area.stories-By8bCfgc.js → text-area.stories-DCt3RB3A.js} +3 -3
- package/dist-storybook/assets/text-field-CGWNqitB.js +1 -0
- package/dist-storybook/assets/{text-field.stories-CrWBAhvI.js → text-field.stories-Bqv7f948.js} +3 -3
- package/dist-storybook/assets/toast-provider-DKSrfhJD.js +9 -0
- package/dist-storybook/assets/{toast.stories-iWAToAZA.js → toast.stories-CcFzS6QI.js} +1 -1
- package/dist-storybook/assets/tooltip-B9rDI6z9.js +1 -0
- package/dist-storybook/assets/{tooltip.stories-RC6SuPPD.js → tooltip.stories-DDdsuU3U.js} +3 -3
- package/dist-storybook/assets/typography-CB8hPDyK.js +1 -0
- package/dist-storybook/assets/{typography.stories-Bu8qFugR.js → typography.stories-BzCxaZQU.js} +3 -3
- package/dist-storybook/assets/{uploader.stories-B2wW9qVy.js → uploader.stories-izVumFqZ.js} +3 -3
- package/dist-storybook/assets/use-app-pause-ClsUnndr.js +21 -0
- package/dist-storybook/assets/use-app-resume-D_EcIvMd.js +21 -0
- package/dist-storybook/assets/use-bottom-tab-bar-BC1cz2uE.js +49 -0
- package/dist-storybook/assets/use-custom-icon-event-cUk4Md0Y.js +26 -0
- package/dist-storybook/assets/use-did-hide-BmABiaUE.js +30 -0
- package/dist-storybook/assets/use-did-show-CQuySkkT.js +30 -0
- package/dist-storybook/assets/use-histories-CBm09Lno.js +30 -0
- package/dist-storybook/assets/use-history-7yguNz6O.js +33 -0
- package/dist-storybook/assets/use-language-DPyWMce2.js +46 -0
- package/dist-storybook/assets/use-load-more-KlDJZhj2.js +42 -0
- package/dist-storybook/assets/use-location-C7kE1yla.js +39 -0
- package/dist-storybook/assets/use-navigate-BpIyvtwc.js +36 -0
- package/dist-storybook/assets/use-navigation-bar-guzwhM_u.js +42 -0
- package/dist-storybook/assets/use-navigation-type-DOndDqQH.js +27 -0
- package/dist-storybook/assets/use-page-layout-dO6ylI1b.js +37 -0
- package/dist-storybook/assets/use-page-scroll-CCG2d2Gb.js +42 -0
- package/dist-storybook/assets/use-pull-to-refresh-lhumDu1H.js +38 -0
- package/dist-storybook/assets/use-settings-changed-Bt58DJ-c.js +30 -0
- package/dist-storybook/assets/use-translate-Jhz6jTXo.js +59 -0
- package/dist-storybook/assets/{visibility-sensor-CwrzJO06.js → visibility-sensor-Jf-Nmil6.js} +1 -1
- package/dist-storybook/iframe.html +2 -2
- package/dist-storybook/index.json +1 -1
- package/dist-storybook/project.json +1 -1
- package/dist-storybook/sb-addons/a11y-2/manager-bundle.js +2 -2
- package/dist-storybook/sb-addons/docs-1/manager-bundle.js +2 -2
- package/dist-storybook/sb-addons/storybook-build-3/manager-bundle.js +1 -1
- package/dist-storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +4 -4
- package/dist-storybook/stories-data.json +152 -122
- package/package.json +3 -1
- package/dist/components/app/components/app.d.ts +0 -13
- package/dist/components/app/components/link.d.ts +0 -8
- package/dist/components/app/components/navigation-analytic.d.ts +0 -2
- package/dist/components/app/components/pages-render.d.ts +0 -2
- package/dist/components/app/context/location-key.d.ts +0 -4
- package/dist/components/app/hooks/use-app-pause.d.ts +0 -1
- package/dist/components/app/hooks/use-app-resume.d.ts +0 -1
- package/dist/components/app/hooks/use-app-state.d.ts +0 -7
- package/dist/components/app/hooks/use-bottom-tab-bar.d.ts +0 -13
- package/dist/components/app/hooks/use-did-hide.d.ts +0 -1
- package/dist/components/app/hooks/use-did-show.d.ts +0 -1
- package/dist/components/app/hooks/use-history.d.ts +0 -2
- package/dist/components/app/hooks/use-location.d.ts +0 -1
- package/dist/components/app/hooks/use-navigate.d.ts +0 -1
- package/dist/components/app/hooks/use-navigation-bar.d.ts +0 -12
- package/dist/components/app/hooks/use-navigation-type.d.ts +0 -1
- package/dist/components/app/hooks/use-page-config.d.ts +0 -1
- package/dist/components/app/hooks/use-page-layout.d.ts +0 -14
- package/dist/components/app/hooks/use-page-scroll.d.ts +0 -5
- package/dist/components/app/hooks/use-page-state.d.ts +0 -6
- package/dist/components/app/stores/app.d.ts +0 -24
- package/dist/components/app/stores/app.selector.d.ts +0 -11
- package/dist/components/app/types/app.d.ts +0 -55
- package/dist/components/app/types/navigation.d.ts +0 -30
- package/dist/components/app/utils/animation.d.ts +0 -2
- package/dist/components/app/utils/data-theme.d.ts +0 -5
- package/dist/components/app/utils/history.d.ts +0 -7
- package/dist/hooks/use-analytic.d.ts +0 -1
- package/dist/hooks/use-is-using-app.d.ts +0 -1
- package/dist/hooks/use-is-using-locales.d.ts +0 -1
- package/dist/locales/defaultResources/en.d.ts +0 -27
- package/dist/locales/defaultResources/vi.d.ts +0 -27
- package/dist/locales/fns.d.ts +0 -6
- package/dist/locales/hooks.d.ts +0 -9
- package/dist/locales/index.d.ts +0 -4
- package/dist/locales/provider.d.ts +0 -6
- package/dist/locales/store.d.ts +0 -13
- package/dist/locales/types.d.ts +0 -37
- package/dist/locales/utils.d.ts +0 -2
- package/dist-storybook/assets/ANIMATION-CUdn1GTK.js +0 -99
- package/dist-storybook/assets/APP_FRAMEWORK-ljbIOHYd.js +0 -197
- package/dist-storybook/assets/BOTTOM_TAB_BAR-DxCwCfBK.js +0 -175
- package/dist-storybook/assets/CUSTOM_ERROR_BOUNDARY-B4wTQNZc.js +0 -250
- package/dist-storybook/assets/DARK_MODE-CoHseCDO.js +0 -57
- package/dist-storybook/assets/GETTING_STARTED-H_vVi5cv.js +0 -77
- package/dist-storybook/assets/KEEP_ALIVE-CL2au0al.js +0 -126
- package/dist-storybook/assets/LOCALE-XTCey55y.js +0 -465
- package/dist-storybook/assets/MOBILE_BEHAVIOURS-DZ6alKTX.js +0 -177
- package/dist-storybook/assets/PAGE_LAYOUT-BuOpN-1Y.js +0 -192
- package/dist-storybook/assets/ROUTING_NAVIGATION-BCPHXNto.js +0 -335
- package/dist-storybook/assets/_setToString-CbM921C9.js +0 -1
- package/dist-storybook/assets/alert-DLW8CoyB.js +0 -1
- package/dist-storybook/assets/avatar-GxcYPA1p.js +0 -1
- package/dist-storybook/assets/badge-D_LzMVtw.js +0 -1
- package/dist-storybook/assets/button-CL7GeC23.js +0 -1
- package/dist-storybook/assets/calendar-dOCsjhVU.js +0 -1
- package/dist-storybook/assets/carousel-1Kww3hIz.js +0 -37
- package/dist-storybook/assets/checkbox-MGytNNRt.js +0 -1
- package/dist-storybook/assets/classname-CUR_zgkh.js +0 -1
- package/dist-storybook/assets/date-field.stories-Diptwqfv.js +0 -129
- package/dist-storybook/assets/date-picker-Dnq_-0Md.js +0 -1
- package/dist-storybook/assets/icon-DdQsMyRa.js +0 -1
- package/dist-storybook/assets/iframe-yMKl6hJA.css +0 -1
- package/dist-storybook/assets/image-C3EsNRhz.js +0 -9
- package/dist-storybook/assets/input-wrapper-BKHgnPy6.js +0 -1
- package/dist-storybook/assets/number-field-CXKmnfKe.js +0 -1
- package/dist-storybook/assets/omit-Bsx5nTI0.js +0 -1
- package/dist-storybook/assets/option-item-LRh_OyV4.js +0 -1
- package/dist-storybook/assets/pagination-DZHoBs_4.js +0 -1
- package/dist-storybook/assets/pick-BhmhLmLe.js +0 -1
- package/dist-storybook/assets/radio-B5NJxG_l.js +0 -1
- package/dist-storybook/assets/rating-BdXViYBv.js +0 -1
- package/dist-storybook/assets/search-field-CQqgFbfg.js +0 -1
- package/dist-storybook/assets/section-content-DGNB4eLN.js +0 -1
- package/dist-storybook/assets/skeleton-C91JgehG.js +0 -1
- package/dist-storybook/assets/store-CPumdfcU.js +0 -1
- package/dist-storybook/assets/switch-p-aXI-ev.js +0 -1
- package/dist-storybook/assets/text-area-DwSXyqOe.js +0 -1
- package/dist-storybook/assets/text-field-jK6rpOo2.js +0 -1
- package/dist-storybook/assets/toast-provider-DurnMJhd.js +0 -9
- package/dist-storybook/assets/tooltip-QDdel5My.js +0 -1
- package/dist-storybook/assets/typography-DEpAJl_i.js +0 -1
- package/dist-storybook/assets/use-app-pause-B_tWHKJK.js +0 -29
- package/dist-storybook/assets/use-app-resume--900G-dV.js +0 -29
- package/dist-storybook/assets/use-custom-icon-event-3VExRzvC.js +0 -29
- package/dist-storybook/assets/use-did-hide-BUsL73ab.js +0 -48
- package/dist-storybook/assets/use-did-show-C1-VLDxi.js +0 -49
- package/dist-storybook/assets/use-histories-E4E2jJEY.js +0 -50
- package/dist-storybook/assets/use-history-o1im8IDj.js +0 -67
- package/dist-storybook/assets/use-location-CUEaBO4P.js +0 -56
- package/dist-storybook/assets/use-navigate-C4CTuFSZ.js +0 -84
- package/dist-storybook/assets/use-navigation-type-Dcz4hgKo.js +0 -44
- package/dist-storybook/assets/use-page-config-DSJBVQbq.js +0 -48
- package/dist-storybook/assets/use-page-scroll-dY-U1Vv4.js +0 -69
- package/dist-storybook/assets/use-page-state-CtNpwGPN.js +0 -79
- package/dist-storybook/assets/use-settings-changed-BBJwIHTE.js +0 -29
- /package/dist/components/app/{components/bottom-tab-bar.d.ts → bottom-tab-bar-layout/index.d.ts} +0 -0
- /package/dist/components/app/{components/navigation-bar.d.ts → navigation-bar-layout/index.d.ts} +0 -0
- /package/dist/components/app/{components/page-layout.d.ts → page-layout/index.d.ts} +0 -0
- /package/dist/{components/app/hooks → hooks}/use-custom-icon-event.d.ts +0 -0
- /package/dist/{components/app/hooks → hooks}/use-settings-changed.d.ts +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{j as e}from"./iframe-DfPay7Zl.js";import{useMDXComponents as s}from"./index-DqZh6B0b.js";import{b as o,M as d}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function r(i){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...s(),...i.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(o,{title:"Router/useDidHide"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"usedidhide",children:"useDidHide"}),`
|
|
5
|
+
`,e.jsxs(n.p,{children:["Hook cho ",e.jsx(n.strong,{children:"lifecycle khi page bị ẩn"}),": gọi callback (nếu truyền) khi navigation rời khỏi page này, và trả về boolean ",e.jsx(n.strong,{children:"didHide"})," cho biết page có đang bị ẩn hay không."]}),`
|
|
6
|
+
`,e.jsxs(n.blockquote,{children:[`
|
|
7
|
+
`,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Ghi chú"}),": useDidHide được dùng khi cấu hình ",e.jsx(n.code,{children:"keepAlive"}),". Xem chi tiết tại ",e.jsx(n.a,{href:"?path=/docs/router-router--docs#irouterconfig",children:"IRouterConfig"})]}),`
|
|
8
|
+
`]}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
10
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useDidHide } from '@v-miniapp/router'
|
|
11
|
+
`})}),`
|
|
12
|
+
`,e.jsx(n.h2,{id:"usage",children:"Usage"}),`
|
|
13
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { useDidHide } from '@v-miniapp/router'
|
|
14
|
+
|
|
15
|
+
const MyPage = () => {
|
|
16
|
+
const didHide = useDidHide(() => {
|
|
17
|
+
console.log('Page is hidden')
|
|
18
|
+
// Pause timers, cleanup subscriptions, v.v.
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return <div>Page is {didHide ? 'hidden' : 'visible'}</div>
|
|
22
|
+
}
|
|
23
|
+
`})}),`
|
|
24
|
+
`,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Lưu ý:"})," Callback được gọi khi sự kiện ",e.jsx(n.code,{children:"beforeHistoryChange"})," xảy ra và ",e.jsx(n.code,{children:"nextHistory.location.key"})," khác với location key của page hiện tại (tức user đã navigate sang page khác)."]}),`
|
|
25
|
+
`,e.jsx(n.h2,{id:"parameters",children:"Parameters"}),`
|
|
26
|
+
`,e.jsx(d,{children:"\n| Tham số | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `func` | `() => void` | Callback được gọi khi page bị hide (navigation sang page khác). Optional. |\n"}),`
|
|
27
|
+
`,e.jsx(n.h2,{id:"returns",children:"Returns"}),`
|
|
28
|
+
`,e.jsxs(n.ul,{children:[`
|
|
29
|
+
`,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"didHide"}),": ",e.jsx(n.code,{children:"boolean"})," — ",e.jsx(n.code,{children:"true"})," khi page vừa bị ẩn; ",e.jsx(n.code,{children:"false"})," khi page đang hiển thị."]}),`
|
|
30
|
+
`]})]})}function u(i={}){const{wrapper:n}={...s(),...i.components};return n?e.jsx(n,{...i,children:e.jsx(r,{...i})}):r(i)}export{u as default};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as r}from"./index-DqZh6B0b.js";import{b as s,M as t}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function o(i){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(s,{title:"Router/useDidShow"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usedidshow",children:"useDidShow"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook cho ",n.jsx(e.strong,{children:"lifecycle khi page được hiển thị"}),": gọi callback (nếu truyền) khi navigation khiến page này trở thành page hiện tại, và trả về boolean ",n.jsx(e.strong,{children:"didShow"})," cho biết page có đang hiển thị hay không."]}),`
|
|
6
|
+
`,n.jsxs(e.blockquote,{children:[`
|
|
7
|
+
`,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Ghi chú"}),": useDidShow được dùng khi cấu hình ",n.jsx(e.code,{children:"keepAlive"}),". Xem chi tiết tại ",n.jsx(e.a,{href:"?path=/docs/router-router--docs#irouterconfig",children:"IRouterConfig"})]}),`
|
|
8
|
+
`]}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
10
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useDidShow } from '@v-miniapp/router'
|
|
11
|
+
`})}),`
|
|
12
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
13
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useDidShow } from '@v-miniapp/router'
|
|
14
|
+
|
|
15
|
+
const MyPage = () => {
|
|
16
|
+
const didShow = useDidShow(() => {
|
|
17
|
+
console.log('Page is shown')
|
|
18
|
+
// Fetch data, track analytics, v.v.
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return <div>Page is {didShow ? 'visible' : 'hidden'}</div>
|
|
22
|
+
}
|
|
23
|
+
`})}),`
|
|
24
|
+
`,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Lưu ý:"})," Callback được gọi khi mount và mỗi khi navigation dẫn tới page này được show (sự kiện ",n.jsx(e.code,{children:"beforeHistoryChangeP2"})," với ",n.jsx(e.code,{children:"nextHistory.location.key"})," trùng với location key của page)."]}),`
|
|
25
|
+
`,n.jsx(e.h2,{id:"parameters",children:"Parameters"}),`
|
|
26
|
+
`,n.jsx(t,{children:"\n| Tham số | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `func` | `() => void` | Callback được gọi khi page show (và gọi một lần khi mount). Optional. |\n"}),`
|
|
27
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
28
|
+
`,n.jsxs(e.ul,{children:[`
|
|
29
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"didShow"}),": ",n.jsx(e.code,{children:"boolean"})," — ",n.jsx(e.code,{children:"true"})," khi page đang là page hiển thị; ",n.jsx(e.code,{children:"false"})," khi đã bị navigate ra."]}),`
|
|
30
|
+
`]})]})}function u(i={}){const{wrapper:e}={...r(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(o,{...i})}):o(i)}export{u as default};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as r}from"./index-DqZh6B0b.js";import{b as i}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function t(s){const e={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...s.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(i,{title:"Router/useHistories"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usehistories",children:"useHistories"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook trả về ",n.jsx(e.strong,{children:"toàn bộ history stack"})," dưới dạng mảng các ",n.jsx(e.code,{children:"IHistory"})," (mỗi entry gồm ",n.jsx(e.code,{children:"action"})," và ",n.jsx(e.code,{children:"location"}),"). Dùng khi cần biết độ sâu stack, kiểm tra có thể back hay không, hoặc hiển thị breadcrumb."]}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useHistories } from '@v-miniapp/router'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useHistories, useNavigate } from '@v-miniapp/router'
|
|
11
|
+
|
|
12
|
+
const NavigationBar = () => {
|
|
13
|
+
const histories = useHistories()
|
|
14
|
+
const navigate = useNavigate()
|
|
15
|
+
const canGoBack = histories.length > 1
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<header>
|
|
19
|
+
{canGoBack && (
|
|
20
|
+
<button onClick={() => navigate(-1)}>Back</button>
|
|
21
|
+
)}
|
|
22
|
+
<span>Stack: {histories.length} pages</span>
|
|
23
|
+
</header>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
`})}),`
|
|
27
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
28
|
+
`,n.jsxs(e.ul,{children:[`
|
|
29
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"histories"}),": ",n.jsx(e.code,{children:"IHistory[]"})," — Mảng các history entry theo thứ tự từ gốc đến hiện tại. Xem thêm ",n.jsx(e.a,{href:"?path=/docs/router-usehistory--docs#returns",children:"usage với useHistory"}),"."]}),`
|
|
30
|
+
`]})]})}function u(s={}){const{wrapper:e}={...r(),...s.components};return e?n.jsx(e,{...s,children:n.jsx(t,{...s})}):t(s)}const l=[];export{l as __namedExportsOrder,u as default};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as o}from"./index-DqZh6B0b.js";import{b as i,M as s}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function e(r){const t={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...o(),...r.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(i,{title:"Router/useHistory"}),`
|
|
4
|
+
`,n.jsx(t.h1,{id:"usehistory",children:"useHistory"}),`
|
|
5
|
+
`,n.jsxs(t.p,{children:["Hook trả về ",n.jsx(t.strong,{children:"history entry"})," hiện tại: ",n.jsx(t.code,{children:"action"})," (PUSH / REPLACE / POP) và ",n.jsx(t.code,{children:"location"}),". Trong cây render của router, giá trị tương ứng với page/component theo ",n.jsx(t.strong,{children:"LocationKeyContext"})," (entry của page đang hiển thị hoặc entry được context chỉ định)."]}),`
|
|
6
|
+
`,n.jsx(t.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-typescript",children:`import { useHistory } from '@v-miniapp/router'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(t.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-tsx",children:`import { useHistory } from '@v-miniapp/router'
|
|
11
|
+
|
|
12
|
+
const MyPage = () => {
|
|
13
|
+
const history = useHistory()
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
<p>Path: {history.location.pathname}</p>
|
|
18
|
+
<p>Action: {history.action}</p>
|
|
19
|
+
<p>Params: {JSON.stringify(history.location.params)}</p>
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
`})}),`
|
|
24
|
+
`,n.jsx(t.h2,{id:"returns",children:"Returns"}),`
|
|
25
|
+
`,n.jsxs(t.ul,{children:[`
|
|
26
|
+
`,n.jsxs(t.li,{children:[n.jsx(t.strong,{children:"history"}),": ",n.jsx(t.code,{children:"IHistory"})]}),`
|
|
27
|
+
`]}),`
|
|
28
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-typescript",children:`type IHistory = {
|
|
29
|
+
action: IHistoryAction // 'POP' | 'REPLACE' | 'PUSH'
|
|
30
|
+
location: ILocation // { key, pathname, params?, state? }
|
|
31
|
+
}
|
|
32
|
+
`})}),`
|
|
33
|
+
`,n.jsx(s,{children:"\n| Thuộc tính | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `action` | `'PUSH' \\| 'REPLACE' \\| 'POP'` | Cách đi tới entry này: push mới, replace, hay back/forward |\n| `location` | `ILocation` | Pathname, params, state, key của entry |\n"})]})}function l(r={}){const{wrapper:t}={...o(),...r.components};return t?n.jsx(t,{...r,children:n.jsx(e,{...r})}):e(r)}const m=[];export{m as __namedExportsOrder,l as default};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as s}from"./index-DqZh6B0b.js";import{b as t,M as i}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function a(g){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...s(),...g.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(t,{title:"Locale/useLanguage"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"uselanguage",children:"useLanguage"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook trả về ",n.jsx(e.strong,{children:"ngôn ngữ hiện tại"}),", ",n.jsx(e.strong,{children:"ngôn ngữ system"})," và function ",n.jsx(e.strong,{children:"setLanguage"})," để đổi ngôn ngữ. Component dùng hook này sẽ ",n.jsx(e.strong,{children:"re-render"})," khi ngôn ngữ thay đổi."]}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useLanguage } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
10
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type IUseLanguageResult = {
|
|
11
|
+
language: IAppLanguage // Ngôn ngữ đang dùng ('vi' | 'en' | 'system' | custom)
|
|
12
|
+
systemLanguage: ILang // Ngôn ngữ từ system/URL (khi language === 'system')
|
|
13
|
+
setLanguage: (language: ILang) => void
|
|
14
|
+
}
|
|
15
|
+
`})}),`
|
|
16
|
+
`,n.jsx(i,{children:"\n| Thuộc tính | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `language` | `IAppLanguage` | Ngôn ngữ hiện tại; `'system'` nghĩa là đang dùng `systemLanguage` |\n| `systemLanguage` | `ILang` | Ngôn ngữ từ URL (`langCode`) hoặc system |\n| `setLanguage` | `(language: ILang) => void` | Đặt ngôn ngữ hiện tại (type-safe nếu đã declare `ICustomLocales`) |\n"}),`
|
|
17
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
18
|
+
`,n.jsx(e.h3,{id:"hiển-thị-và-đổi-ngôn-ngữ",children:"Hiển thị và đổi ngôn ngữ"}),`
|
|
19
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useLanguage } from '@v-miniapp/ui-react'
|
|
20
|
+
|
|
21
|
+
function LanguageSwitcher() {
|
|
22
|
+
const { language, setLanguage } = useLanguage()
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<p>Current: {language}</p>
|
|
27
|
+
<button onClick={() => setLanguage('vi')}>Tiếng Việt</button>
|
|
28
|
+
<button onClick={() => setLanguage('en')}>English</button>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
`})}),`
|
|
33
|
+
`,n.jsx(e.h3,{id:"dùng-systemlanguage-khi-language--system",children:"Dùng systemLanguage khi language === 'system'"}),`
|
|
34
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`function DebugLanguage() {
|
|
35
|
+
const { language, systemLanguage } = useLanguage()
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<p>
|
|
39
|
+
App language: {language}
|
|
40
|
+
{language === 'system' && \` (resolved: \${systemLanguage})\`}
|
|
41
|
+
</p>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
`})}),`
|
|
45
|
+
`,n.jsx(e.h2,{id:"type-safety",children:"Type safety"}),`
|
|
46
|
+
`,n.jsxs(e.p,{children:["Sau khi khai báo ",n.jsx(e.code,{children:"ICustomLocales.language"})," (ví dụ ",n.jsx(e.code,{children:"'vi' | 'en' | 'jp'"}),"), ",n.jsx(e.code,{children:"setLanguage()"})," chỉ chấp nhận các giá trị đó; TypeScript báo lỗi nếu truyền language khác."]})]})}function h(g={}){const{wrapper:e}={...s(),...g.components};return e?n.jsx(e,{...g,children:n.jsx(a,{...g})}):a(g)}export{h as default};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import{j as e}from"./iframe-DfPay7Zl.js";import{useMDXComponents as r}from"./index-DqZh6B0b.js";import{b as s,M as o}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function t(i){const n={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...i.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(s,{title:"UI React/useLoadMore"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"useloadmore",children:"useLoadMore"}),`
|
|
5
|
+
`,e.jsxs(n.p,{children:["Hook đăng ký ",e.jsx(n.strong,{children:"handler load more"})," (onEndReached) cho ",e.jsx(n.strong,{children:"page hiện tại"}),". Khi user scroll tới cuối vùng scroll (hoặc trigger tương đương từ page layout), handler được gọi. Dùng cho infinite list."]}),`
|
|
6
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useLoadMore } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { useLoadMore } from '@v-miniapp/ui-react'
|
|
11
|
+
|
|
12
|
+
const InfiniteListPage = () => {
|
|
13
|
+
const [page, setPage] = useState(1)
|
|
14
|
+
const [items, setItems] = useState([])
|
|
15
|
+
|
|
16
|
+
useLoadMore(() => {
|
|
17
|
+
setPage((p) => p + 1)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
fetchPage(page).then((data) => setItems((prev) => [...prev, ...data]))
|
|
22
|
+
}, [page])
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ul>
|
|
26
|
+
{items.map((item) => (
|
|
27
|
+
<li key={item.id}>{item.name}</li>
|
|
28
|
+
))}
|
|
29
|
+
</ul>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
`})}),`
|
|
33
|
+
`,e.jsx(n.h2,{id:"signature",children:"Signature"}),`
|
|
34
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`function useLoadMore(onEndReached: () => void): void
|
|
35
|
+
`})}),`
|
|
36
|
+
`,e.jsx(n.h2,{id:"parameters",children:"Parameters"}),`
|
|
37
|
+
`,e.jsx(o,{children:"\n| Tham số | Kiểu | Bắt buộc | Mô tả |\n| :--- | :--- | :--- | :--- |\n| `onEndReached` | `() => void` | ✓ | Function gọi khi scroll tới cuối (load thêm dữ liệu). |\n"}),`
|
|
38
|
+
`,e.jsx(n.h2,{id:"lưu-ý",children:"Lưu ý"}),`
|
|
39
|
+
`,e.jsxs(n.ul,{children:[`
|
|
40
|
+
`,e.jsxs(n.li,{children:["Chỉ áp dụng cho ",e.jsx(n.strong,{children:"page hiện tại"}),". Mỗi page cần gọi ",e.jsx(n.code,{children:"useLoadMore"})," riêng nếu muốn load more."]}),`
|
|
41
|
+
`,e.jsxs(n.li,{children:["Kết hợp với ",e.jsx(n.strong,{children:"onEndReachedThreshold"})," để xác định khi nào “tới cuối”."]}),`
|
|
42
|
+
`]})]})}function u(i={}){const{wrapper:n}={...r(),...i.components};return n?e.jsx(n,{...i,children:e.jsx(t,{...i})}):t(i)}export{u as default};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as i}from"./index-DqZh6B0b.js";import{b as r,M as s}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function o(e){const t={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...i(),...e.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(r,{title:"Router/useLocation"}),`
|
|
4
|
+
`,n.jsx(t.h1,{id:"uselocation",children:"useLocation"}),`
|
|
5
|
+
`,n.jsxs(t.p,{children:["Hook trả về ",n.jsx(t.strong,{children:"location"})," hiện tại của page (pathname, params, state, key). Giá trị lấy từ ",n.jsx(t.code,{children:"useHistory().location"}),"; phụ thuộc context (location key) nên đúng với page/component đang render."]}),`
|
|
6
|
+
`,n.jsx(t.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-typescript",children:`import { useLocation } from '@v-miniapp/router'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(t.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-tsx",children:`import { useLocation } from '@v-miniapp/router'
|
|
11
|
+
|
|
12
|
+
const DetailPage = () => {
|
|
13
|
+
const location = useLocation()
|
|
14
|
+
|
|
15
|
+
if (!location) return null
|
|
16
|
+
|
|
17
|
+
const id = location.params?.id
|
|
18
|
+
const from = location.state?.from
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div>
|
|
22
|
+
Path: {location.pathname}
|
|
23
|
+
{id && <p>ID: {id}</p>}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
`})}),`
|
|
28
|
+
`,n.jsx(t.h2,{id:"returns",children:"Returns"}),`
|
|
29
|
+
`,n.jsxs(t.ul,{children:[`
|
|
30
|
+
`,n.jsxs(t.li,{children:[n.jsx(t.strong,{children:"location"}),": ",n.jsx(t.code,{children:"ILocation"})]}),`
|
|
31
|
+
`]}),`
|
|
32
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-typescript",children:`type ILocation = {
|
|
33
|
+
key: string
|
|
34
|
+
pathname: string
|
|
35
|
+
params?: Record<string, string>
|
|
36
|
+
state?: any
|
|
37
|
+
}
|
|
38
|
+
`})}),`
|
|
39
|
+
`,n.jsx(s,{children:"\n| Thuộc tính | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `key` | `string` | Key duy nhất cho entry trong history |\n| `pathname` | `string` | Đường dẫn hiện tại |\n| `params` | `Record<string, string>` | Query params từ navigate options |\n| `state` | `any` | State từ navigate options |\n"})]})}function h(e={}){const{wrapper:t}={...i(),...e.components};return t?n.jsx(t,{...e,children:n.jsx(o,{...e})}):o(e)}export{h as default};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as r}from"./index-DqZh6B0b.js";import{b as s,M as a}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function i(t){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...t.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(s,{title:"Router/useNavigate"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usenavigate",children:"useNavigate"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook trả về function ",n.jsx(e.strong,{children:"navigate"})," để điều hướng giữa các pages: bằng ",n.jsx(e.strong,{children:"pathname"})," hoặc bằng ",n.jsx(e.strong,{children:"delta"})," (back/forward)."]}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useNavigate } from '@v-miniapp/router'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"sử-dụng",children:"Sử dụng"}),`
|
|
10
|
+
`,n.jsx(e.h3,{id:"navigate-bằng-pathname",children:"Navigate bằng pathname"}),`
|
|
11
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const navigate = useNavigate()
|
|
12
|
+
|
|
13
|
+
navigate('/settings')
|
|
14
|
+
navigate('/detail', { params: { id: '123' }, state: { from: 'home' } })
|
|
15
|
+
navigate('/home', { replace: true })
|
|
16
|
+
`})}),`
|
|
17
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
18
|
+
`,n.jsxs(e.ul,{children:[`
|
|
19
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"navigate"}),": Function với type ",n.jsx(e.code,{children:"INavigate"}),":",`
|
|
20
|
+
`,n.jsxs(e.ul,{children:[`
|
|
21
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"navigate(pathname: string, options?: INavigatePathnameOptions): void"})," — đi tới pathname"]}),`
|
|
22
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"navigate(delta: number, options?: INavigateDeltaOptions): void"})," — back/forward trong history stack"]}),`
|
|
23
|
+
`]}),`
|
|
24
|
+
`]}),`
|
|
25
|
+
`]}),`
|
|
26
|
+
`,n.jsx(e.h3,{id:"navigate-back--forward",children:"Navigate back / forward"}),`
|
|
27
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const navigate = useNavigate()
|
|
28
|
+
|
|
29
|
+
navigate(-1) // Back 1 page
|
|
30
|
+
navigate(1) // Forward 1 page
|
|
31
|
+
navigate(-1, { animation: { type: 'none' } })
|
|
32
|
+
`})}),`
|
|
33
|
+
`,n.jsx(e.h2,{id:"inavigatepathnameoptions",children:"INavigatePathnameOptions"}),`
|
|
34
|
+
`,n.jsx(a,{children:"\n| Option | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `replace` | `boolean` | `true`: thay thế entry hiện tại thay vì push mới |\n| `params` | `Record<string, string>` | Query params (xuất hiện trên URL) |\n| `state` | `any` | State gửi kèm (không lên URL), lưu trong history |\n| Các thuộc tính `IRouterPageState` | - | Override animation, keepAlive, Layouts, v.v. cho page đích |\n"}),`
|
|
35
|
+
`,n.jsx(e.h2,{id:"inavigatedeltaoptions",children:"INavigateDeltaOptions"}),`
|
|
36
|
+
`,n.jsx(a,{children:"\n| Option | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `animation` | `IAnimationState` | Override animation cho lần navigate này. `type` (`'none'`, `'slide_up'`, `'slide_left'`, `'fade_in'`) |\n"})]})}function l(t={}){const{wrapper:e}={...r(),...t.components};return e?n.jsx(e,{...t,children:n.jsx(i,{...t})}):i(t)}export{l as default};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as i}from"./index-DqZh6B0b.js";import{b as r,M as o}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function e(t){const a={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...i(),...t.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(r,{title:"UI React/useNavigationBar"}),`
|
|
4
|
+
`,n.jsx(a.h1,{id:"usenavigationbar",children:"useNavigationBar"}),`
|
|
5
|
+
`,n.jsxs(a.p,{children:["Hook trả về ",n.jsx(a.strong,{children:"state"})," navigation bar đã merge (app + page hiện tại) và các function để ",n.jsx(a.strong,{children:"cập nhật"})," / ",n.jsx(a.strong,{children:"ẩn"})," / ",n.jsx(a.strong,{children:"reset"})," cho page hoặc cho app. Dùng khi cần đọc hoặc thay đổi title, backIcon, hidden, … của navigation bar từ trong component."]}),`
|
|
6
|
+
`,n.jsx(a.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(a.pre,{children:n.jsx(a.code,{className:"language-typescript",children:`import { useNavigationBar } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(a.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,n.jsx(a.h3,{id:"đổi-title-cho-page-hiện-tại",children:"Đổi title cho page hiện tại"}),`
|
|
11
|
+
`,n.jsx(a.pre,{children:n.jsx(a.code,{className:"language-tsx",children:`import { useNavigationBar } from '@v-miniapp/ui-react'
|
|
12
|
+
|
|
13
|
+
const DetailPage = () => {
|
|
14
|
+
const { setPageNavigationBar } = useNavigationBar()
|
|
15
|
+
|
|
16
|
+
const handleSelect = (item) => {
|
|
17
|
+
setPageNavigationBar({ title: item.name })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return <div>...</div>
|
|
21
|
+
}
|
|
22
|
+
`})}),`
|
|
23
|
+
`,n.jsx(a.h3,{id:"ẩn-navigation-bar-trên-một-page",children:"Ẩn navigation bar trên một page"}),`
|
|
24
|
+
`,n.jsx(a.pre,{children:n.jsx(a.code,{className:"language-tsx",children:`const { removePageNavigationBar } = useNavigationBar()
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
removePageNavigationBar()
|
|
28
|
+
return () => resetPageNavigationBar()
|
|
29
|
+
}, [])
|
|
30
|
+
`})}),`
|
|
31
|
+
`,n.jsx(a.h3,{id:"đọc-state-để-render-tùy-biến",children:"Đọc state để render tùy biến"}),`
|
|
32
|
+
`,n.jsx(a.pre,{children:n.jsx(a.code,{className:"language-tsx",children:`const { state } = useNavigationBar()
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div>
|
|
36
|
+
<p>Title: {state.title}</p>
|
|
37
|
+
<p>Hidden: {state.hidden ? 'Yes' : 'No'}</p>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
`})}),`
|
|
41
|
+
`,n.jsx(a.h2,{id:"returns",children:"Returns"}),`
|
|
42
|
+
`,n.jsx(o,{children:"\n| Thuộc tính | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `state` | `IPageNavigationBarState` (merged) | State đã merge: default (divider, transparent) + app + page. Dùng để render NavigationBar. |\n| `pageState` | `object` | State navigation bar riêng của page hiện tại (theo `location.key`). |\n| `appState` | `object` | State navigation bar mặc định của app. |\n| `setPageNavigationBar` | `(state: Partial<IPageNavigationBarState>) => void` | Cập nhật navigation bar cho **page hiện tại**. |\n| `setAppNavigationBar` | `(state: Partial<IAppNavigationBarState>) => void` | Cập nhật navigation bar **mặc định** cho toàn app. |\n| `removePageNavigationBar` | `() => void` | Ẩn navigation bar cho page hiện tại (`hidden: true`). |\n| `removeAppNavigationBar` | `() => void` | Ẩn navigation bar mặc định của app. |\n| `resetPageNavigationBar` | `() => void` | Reset navigation bar của page hiện tại về config từ `IPageConfig`. |\n| `resetAppNavigationBar` | `() => void` | Reset navigation bar app về config từ `IAppConfig`. |\n"})]})}function d(t={}){const{wrapper:a}={...i(),...t.components};return a?n.jsx(a,{...t,children:n.jsx(e,{...t})}):e(t)}export{d as default};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as t}from"./index-DqZh6B0b.js";import{b as o,M as s}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function r(i){const e={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...t(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(o,{title:"Router/useNavigationType"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usenavigationtype",children:"useNavigationType"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook trả về ",n.jsx(e.strong,{children:"action"})," của history entry hiện tại: cách user đã tới page này — ",n.jsx(e.strong,{children:"PUSH"})," (navigate mới), ",n.jsx(e.strong,{children:"REPLACE"})," (thay thế), hay ",n.jsx(e.strong,{children:"POP"})," (back/forward). Tương đương ",n.jsx(e.code,{children:"useHistory().action"}),"."]}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useNavigationType } from '@v-miniapp/router'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useNavigationType } from '@v-miniapp/router'
|
|
11
|
+
|
|
12
|
+
const MyPage = () => {
|
|
13
|
+
const action = useNavigationType()
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
<p>You arrived via: {action}</p>
|
|
18
|
+
{action === 'POP' && <p>You used back/forward</p>}
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
`})}),`
|
|
23
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
24
|
+
`,n.jsxs(e.ul,{children:[`
|
|
25
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"action"}),": ",n.jsx(e.code,{children:"IHistoryAction"})," — ",n.jsx(e.code,{children:"'PUSH' | 'REPLACE' | 'POP'"})]}),`
|
|
26
|
+
`]}),`
|
|
27
|
+
`,n.jsx(s,{children:"\n| Giá trị | Ý nghĩa |\n| :--- | :--- |\n| `'PUSH'` | Đi tới page mới (push vào stack) |\n| `'REPLACE'` | Thay thế entry hiện tại (navigate với `replace: true`) |\n| `'POP'` | Back hoặc forward trong stack |\n"})]})}function l(i={}){const{wrapper:e}={...t(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(r,{...i})}):r(i)}export{l as default};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{j as e}from"./iframe-DfPay7Zl.js";import{useMDXComponents as o}from"./index-DqZh6B0b.js";import{b as s,M as r}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function n(t){const a={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...o(),...t.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(s,{title:"UI React/usePageLayout"}),`
|
|
4
|
+
`,e.jsx(a.h1,{id:"usepagelayout",children:"usePageLayout"}),`
|
|
5
|
+
`,e.jsxs(a.p,{children:["Hook trả về ",e.jsx(a.strong,{children:"state"})," page layout đã merge (app + page hiện tại) và các function để ",e.jsx(a.strong,{children:"cập nhật"})," / ",e.jsx(a.strong,{children:"ẩn"})," / ",e.jsx(a.strong,{children:"reset"})," cho page hoặc app. State gồm scrollRestoration, pullToRefresh, onEndReached, contentClassName, hidden. Dùng khi cần đọc hoặc thay đổi layout (pull-to-refresh, load more, class) từ trong component."]}),`
|
|
6
|
+
`,e.jsx(a.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(a.pre,{children:e.jsx(a.code,{className:"language-typescript",children:`import { usePageLayout } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(a.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,e.jsx(a.h3,{id:"cập-nhật-pull-to-refresh--load-more-cho-page",children:"Cập nhật pull-to-refresh / load more cho page"}),`
|
|
11
|
+
`,e.jsx(a.pre,{children:e.jsx(a.code,{className:"language-tsx",children:`import { usePageLayout } from '@v-miniapp/ui-react'
|
|
12
|
+
|
|
13
|
+
const MyPage = () => {
|
|
14
|
+
const { setPagePageLayout } = usePageLayout()
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setPagePageLayout({
|
|
18
|
+
pullToRefresh: { onRefresh: async () => await fetchData() },
|
|
19
|
+
onEndReached: () => loadMore(),
|
|
20
|
+
})
|
|
21
|
+
}, [])
|
|
22
|
+
|
|
23
|
+
return <div>...</div>
|
|
24
|
+
}
|
|
25
|
+
`})}),`
|
|
26
|
+
`,e.jsx(a.h3,{id:"đổi-contentclassname-cho-page",children:"Đổi contentClassName cho page"}),`
|
|
27
|
+
`,e.jsx(a.pre,{children:e.jsx(a.code,{className:"language-tsx",children:`const { setPagePageLayout } = usePageLayout()
|
|
28
|
+
|
|
29
|
+
setPagePageLayout({ contentClassName: 'p-4 bg-gray-100' })
|
|
30
|
+
`})}),`
|
|
31
|
+
`,e.jsx(a.h3,{id:"reset-về-config-ban-đầu",children:"Reset về config ban đầu"}),`
|
|
32
|
+
`,e.jsx(a.pre,{children:e.jsx(a.code,{className:"language-tsx",children:`const { resetPagePageLayout } = usePageLayout()
|
|
33
|
+
|
|
34
|
+
resetPagePageLayout()
|
|
35
|
+
`})}),`
|
|
36
|
+
`,e.jsx(a.h2,{id:"returns",children:"Returns"}),`
|
|
37
|
+
`,e.jsx(r,{children:"\n| Thuộc tính | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `state` | merged | State đã merge: default (scrollRestoration: true) + app + page. |\n| `pageState` | `object` | State page layout riêng của page hiện tại. |\n| `appState` | `object` | State page layout mặc định của app. |\n| `setPagePageLayout` | `(state: Partial<IPagePageState>) => void` | Cập nhật page layout cho **page hiện tại** (pullToRefresh, onEndReached, contentClassName, …). |\n| `setAppPageLayout` | `(state: Partial<IAppPageState>) => void` | Cập nhật page layout **mặc định** cho app. |\n| `removePagePageLayout` | `() => void` | Ẩn page layout cho page hiện tại (`hidden: true`). |\n| `removeAppPageLayout` | `() => void` | Ẩn page layout mặc định của app. |\n| `resetPagePageLayout` | `() => void` | Reset page layout của page về config từ `IPageConfig`. |\n| `resetAppPageLayout` | `() => void` | Reset page layout app về config từ `IAppConfig`. |\n"})]})}function l(t={}){const{wrapper:a}={...o(),...t.components};return a?e.jsx(a,{...t,children:e.jsx(n,{...t})}):n(t)}export{l as default};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import{j as e}from"./iframe-DfPay7Zl.js";import{useMDXComponents as l}from"./index-DqZh6B0b.js";import{b as o,M as s}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function r(t){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...l(),...t.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(o,{title:"UI React/usePageScroll"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"usepagescroll",children:"usePageScroll"}),`
|
|
5
|
+
`,e.jsxs(n.p,{children:["Hook đăng ký ",e.jsx(n.strong,{children:"callback"})," khi page scroll. Callback nhận element đang scroll và event; có thể dùng options ",e.jsx(n.strong,{children:"throttle"})," để giảm tần suất gọi."]}),`
|
|
6
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { usePageScroll } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"signature",children:"Signature"}),`
|
|
10
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`function usePageScroll(
|
|
11
|
+
callback: (target: HTMLDivElement, event: Event) => void,
|
|
12
|
+
options?: IPageScrollOptions
|
|
13
|
+
): void
|
|
14
|
+
`})}),`
|
|
15
|
+
`,e.jsx(n.h2,{id:"parameters",children:"Parameters"}),`
|
|
16
|
+
`,e.jsx(s,{children:"\n| Tham số | Kiểu | Mô tả |\n| :--- | :--- | :--- |\n| `callback` | `(target, event) => void` | Gọi khi scroll. `target`: element scroll, `event`: scroll event. |\n| `options` | `IPageScrollOptions` | `{ wait? (ms), leading?, trailing? }`. |\n"}),`
|
|
17
|
+
`,e.jsx(n.h2,{id:"usage",children:"Usage"}),`
|
|
18
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { usePageScroll } from '@v-miniapp/ui-react'
|
|
19
|
+
|
|
20
|
+
const MyPage = () => {
|
|
21
|
+
usePageScroll((target, event) => {
|
|
22
|
+
console.log('Scroll:', target.scrollTop)
|
|
23
|
+
}, {
|
|
24
|
+
wait: 200,
|
|
25
|
+
trailing: true,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return <div>Nội dung scroll</div>
|
|
29
|
+
}
|
|
30
|
+
`})}),`
|
|
31
|
+
`,e.jsx(n.h3,{id:"scroll-đến-cuối-để-load-thêm",children:"Scroll đến cuối để load thêm"}),`
|
|
32
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`usePageScroll(
|
|
33
|
+
(target) => {
|
|
34
|
+
const { scrollTop, scrollHeight, clientHeight } = target
|
|
35
|
+
if (scrollTop + clientHeight >= scrollHeight - 10) loadMore()
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
wait: 100,
|
|
39
|
+
trailing: true
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
`})})]})}function h(t={}){const{wrapper:n}={...l(),...t.components};return n?e.jsx(n,{...t,children:e.jsx(r,{...t})}):r(t)}export{h as default};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{j as e}from"./iframe-DfPay7Zl.js";import{useMDXComponents as t}from"./index-DqZh6B0b.js";import{b as i,M as o}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function s(r){const n={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...t(),...r.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(i,{title:"UI React/usePullToRefresh"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"usepulltorefresh",children:"usePullToRefresh"}),`
|
|
5
|
+
`,e.jsxs(n.p,{children:["Hook đăng ký ",e.jsx(n.strong,{children:"handler pull-to-refresh"})," cho ",e.jsx(n.strong,{children:"page hiện tại"}),". Khi user kéo xuống để refresh, handler được gọi. Handler có thể trả về Promise (async) hoặc void."]}),`
|
|
6
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { usePullToRefresh } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { usePullToRefresh } from '@v-miniapp/ui-react'
|
|
11
|
+
|
|
12
|
+
const ListPage = () => {
|
|
13
|
+
const [items, setItems] = useState([])
|
|
14
|
+
|
|
15
|
+
usePullToRefresh(async () => {
|
|
16
|
+
const data = await fetchList()
|
|
17
|
+
setItems(data)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<ul>
|
|
22
|
+
{items.map((item) => (
|
|
23
|
+
<li key={item.id}>{item.name}</li>
|
|
24
|
+
))}
|
|
25
|
+
</ul>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
`})}),`
|
|
29
|
+
`,e.jsx(n.h2,{id:"signature",children:"Signature"}),`
|
|
30
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`function usePullToRefresh(onRefresh: () => Promise<unknown> | unknown): void
|
|
31
|
+
`})}),`
|
|
32
|
+
`,e.jsx(n.h2,{id:"parameters",children:"Parameters"}),`
|
|
33
|
+
`,e.jsx(o,{children:"\n| Tham số | Kiểu | Bắt buộc | Mô tả |\n| :--- | :--- | :--- | :--- |\n| `onRefresh` | `() => Promise ` | ✓ | Function gọi khi user pull-to-refresh. Có thể async (trả về Promise) hoặc sync. |\n"}),`
|
|
34
|
+
`,e.jsx(n.h2,{id:"lưu-ý",children:"Lưu ý"}),`
|
|
35
|
+
`,e.jsxs(n.ul,{children:[`
|
|
36
|
+
`,e.jsxs(n.li,{children:["Chỉ áp dụng cho ",e.jsx(n.strong,{children:"page hiện tại"})," (theo location). Khi navigate sang page khác, page đó cần gọi ",e.jsx(n.code,{children:"usePullToRefresh"})," riêng nếu muốn pull-to-refresh."]}),`
|
|
37
|
+
`,e.jsx(n.li,{children:"Handler được lưu trong ref nên có thể truyền function mới mỗi render mà không cần dependency array phức tạp."}),`
|
|
38
|
+
`]})]})}function d(r={}){const{wrapper:n}={...t(),...r.components};return n?e.jsx(n,{...r,children:e.jsx(s,{...r})}):s(r)}export{d as default};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as s}from"./index-DqZh6B0b.js";import{b as r,M as h}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function i(e){const t={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...s(),...e.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(r,{title:"UI React/useSettingsChanged"}),`
|
|
4
|
+
`,n.jsx(t.h1,{id:"usesettingschanged",children:"useSettingsChanged"}),`
|
|
5
|
+
`,n.jsxs(t.p,{children:["Hook đăng ký ",n.jsx(t.strong,{children:"callback"})," khi ",n.jsx(t.strong,{children:"settings"})," của app thay đổi (từ native hoặc môi trường V-MiniApp). Callback nhận object ",n.jsx(t.strong,{children:"settings"})," (theme, language, v.v.). Dùng để đồng bộ UI với cài đặt người dùng hoặc native."]}),`
|
|
6
|
+
`,n.jsx(t.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-typescript",children:`import { useSettingsChanged } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(t.h2,{id:"usage",children:"Usage"}),`
|
|
10
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-tsx",children:`import { useSettingsChanged } from '@v-miniapp/ui-react'
|
|
11
|
+
|
|
12
|
+
const MyPage = () => {
|
|
13
|
+
useSettingsChanged((settings) => {
|
|
14
|
+
console.log('Settings changed:', settings)
|
|
15
|
+
// Cập nhật theme, language, v.v. theo settings
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return <div>...</div>
|
|
19
|
+
}
|
|
20
|
+
`})}),`
|
|
21
|
+
`,n.jsx(t.h2,{id:"signature",children:"Signature"}),`
|
|
22
|
+
`,n.jsx(t.pre,{children:n.jsx(t.code,{className:"language-typescript",children:`function useSettingsChanged(onSettingsChanged: (settings: ISettings) => void): void
|
|
23
|
+
`})}),`
|
|
24
|
+
`,n.jsx(t.h2,{id:"parameters",children:"Parameters"}),`
|
|
25
|
+
`,n.jsx(h,{children:"\n| Tham số | Kiểu | Bắt buộc | Mô tả |\n| :--- | :--- | :--- | :--- |\n| `onSettingsChanged` | `(settings: ISettings) => void` | ✓ | Gọi khi settings thay đổi. `settings`: object chứa cài đặt (cấu trúc tùy môi trường). |\n"}),`
|
|
26
|
+
`,n.jsx(t.h2,{id:"lưu-ý",children:"Lưu ý"}),`
|
|
27
|
+
`,n.jsxs(t.ul,{children:[`
|
|
28
|
+
`,n.jsxs(t.li,{children:["Thời điểm và nội dung ",n.jsx(t.strong,{children:"settings"})," phụ thuộc vào môi trường V-MiniApp / native (event hoặc API từ host)."]}),`
|
|
29
|
+
`,n.jsx(t.li,{children:"Dùng khi cần phản ứng với thay đổi theme (dark/light), ngôn ngữ, hoặc cài đặt khác từ phía app host."}),`
|
|
30
|
+
`]})]})}function l(e={}){const{wrapper:t}={...s(),...e.components};return t?n.jsx(t,{...e,children:n.jsx(i,{...e})}):i(e)}export{l as default};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{j as n}from"./iframe-DfPay7Zl.js";import{useMDXComponents as s}from"./index-DqZh6B0b.js";import{b as i}from"./blocks-DKR3P4qW.js";import"./preload-helper-PPVm8Dsz.js";import"./index-cMNObl2z.js";function r(t){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...s(),...t.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(i,{title:"Locale/useTranslate"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usetranslate",children:"useTranslate"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook trả về function ",n.jsx(e.strong,{children:"translate"})," để lấy bản dịch theo key. Component dùng hook này sẽ ",n.jsx(e.strong,{children:"re-render"})," khi ngôn ngữ thay đổi (reactive)."]}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useTranslate } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
10
|
+
`,n.jsxs(e.ul,{children:[`
|
|
11
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"translate"}),": Function với signature:",`
|
|
12
|
+
`,n.jsxs(e.ul,{children:[`
|
|
13
|
+
`,n.jsx(e.li,{children:n.jsx(e.code,{children:"(key: IResourceKey, params?: ITemplateParams, lang?: ILang) => string"})}),`
|
|
14
|
+
`,n.jsx(e.li,{children:"Trả về chuỗi bản dịch; nếu thiếu key hoặc locale thì fallback về key."}),`
|
|
15
|
+
`]}),`
|
|
16
|
+
`]}),`
|
|
17
|
+
`]}),`
|
|
18
|
+
`,n.jsx(e.h2,{id:"reactivity",children:"Reactivity"}),`
|
|
19
|
+
`,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"useTranslate"})," có reactivity. Khi gọi ",n.jsx(e.code,{children:"setLanguage()"})," (hoặc ",n.jsx(e.code,{children:"useLanguage().setLanguage"}),"), mọi component đang dùng ",n.jsx(e.code,{children:"useTranslate()"})," sẽ re-render và hiển thị đúng ngôn ngữ mới."]}),`
|
|
20
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`// ✅ Đúng: dùng hook trong component → re-render khi đổi ngôn ngữ
|
|
21
|
+
function Title() {
|
|
22
|
+
const t = useTranslate()
|
|
23
|
+
return <h1>{t('app.title')}</h1>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ❌ Sai: dùng t() trong component → không re-render khi đổi ngôn ngữ
|
|
27
|
+
function Title() {
|
|
28
|
+
const title = t('app.title')
|
|
29
|
+
return <h1>{title}</h1>
|
|
30
|
+
}
|
|
31
|
+
`})}),`
|
|
32
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
33
|
+
`,n.jsx(e.h3,{id:"cơ-bản",children:"Cơ bản"}),`
|
|
34
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useTranslate } from '@v-miniapp/ui-react'
|
|
35
|
+
|
|
36
|
+
function Welcome() {
|
|
37
|
+
const t = useTranslate()
|
|
38
|
+
return <h1>{t('app.title')}</h1>
|
|
39
|
+
}
|
|
40
|
+
`})}),`
|
|
41
|
+
`,n.jsx(e.h3,{id:"với-template-params",children:"Với template params"}),`
|
|
42
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`function Greeting({ name }: { name: string }) {
|
|
43
|
+
const t = useTranslate()
|
|
44
|
+
return <p>{t('user.greeting', { name })}</p>
|
|
45
|
+
}
|
|
46
|
+
`})}),`
|
|
47
|
+
`,n.jsx(e.h3,{id:"dịch-theo-ngôn-ngữ-chỉ-định-không-đổi-ngôn-ngữ-app",children:"Dịch theo ngôn ngữ chỉ định (không đổi ngôn ngữ app)"}),`
|
|
48
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`function Compare() {
|
|
49
|
+
const t = useTranslate()
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
<span>{t('app.title', undefined, 'vi')}</span>
|
|
53
|
+
<span>{t('app.title', undefined, 'en')}</span>
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
`})}),`
|
|
58
|
+
`,n.jsx(e.h2,{id:"type-safety",children:"Type safety"}),`
|
|
59
|
+
`,n.jsxs(e.p,{children:["Khi đã khai báo ",n.jsx(e.code,{children:"ICustomLocales"})," (module augmentation), ",n.jsx(e.code,{children:"key"})," sẽ được gợi ý và kiểm tra theo các key trong resource."]})]})}function d(t={}){const{wrapper:e}={...s(),...t.components};return e?n.jsx(e,{...t,children:n.jsx(r,{...t})}):r(t)}export{d as default};
|