@v-miniapp/ui-react 1.0.40 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/icon/icon-mapping.d.ts +4 -0
- package/dist/components/navigation-bar/navigation-bar.d.ts +3 -1
- package/dist/external/index.js +2009 -2012
- package/dist/external/styles.css +1 -1
- package/dist/index.js +1029 -1032
- package/dist/styles.css +1 -1
- package/dist-storybook/assets/ANIMATION-CUdn1GTK.js +99 -0
- package/dist-storybook/assets/APP_FRAMEWORK-ljbIOHYd.js +197 -0
- package/dist-storybook/assets/BOTTOM_TAB_BAR-DxCwCfBK.js +175 -0
- package/dist-storybook/assets/CUSTOM_ERROR_BOUNDARY-B4wTQNZc.js +250 -0
- package/dist-storybook/assets/Color-AVL7NMMY-1_8XTICv.js +1 -0
- package/dist-storybook/assets/DARK_MODE-CoHseCDO.js +57 -0
- package/dist-storybook/assets/DocsRenderer-PQXLIZUC-BO86igwd.js +2 -0
- package/dist-storybook/assets/GETTING_STARTED-H_vVi5cv.js +77 -0
- package/dist-storybook/assets/INFINITE_SCROLL-BtM3uoX0.js +111 -0
- package/dist-storybook/assets/KEEP_ALIVE-CL2au0al.js +126 -0
- package/dist-storybook/assets/LOCALE-XTCey55y.js +465 -0
- package/dist-storybook/assets/MIGRATION_GUIDE-2LONslE4.js +449 -0
- package/dist-storybook/assets/MOBILE_BEHAVIOURS-DZ6alKTX.js +177 -0
- package/dist-storybook/assets/PAGE_LAYOUT-BuOpN-1Y.js +192 -0
- package/dist-storybook/assets/ROUTING_NAVIGATION-BCPHXNto.js +335 -0
- package/dist-storybook/assets/TAILWIND_INTEGRATION-_T-VfvkM.js +87 -0
- package/dist-storybook/assets/_setToString-CbM921C9.js +1 -0
- package/dist-storybook/assets/alert-DLW8CoyB.js +1 -0
- package/dist-storybook/assets/alert.stories-B-vuojPh.js +110 -0
- package/dist-storybook/assets/avatar-GxcYPA1p.js +1 -0
- package/dist-storybook/assets/avatar.stories-KYFztAc8.js +136 -0
- package/dist-storybook/assets/axe-CmvD4WV5.js +20 -0
- package/dist-storybook/assets/badge-D_LzMVtw.js +1 -0
- package/dist-storybook/assets/badge.stories-Be2ItCmQ.js +262 -0
- package/dist-storybook/assets/blocks-BuaOUtiH.js +1243 -0
- package/dist-storybook/assets/bottom-tab-bar-CtcTAxuI.js +115 -0
- package/dist-storybook/assets/bottom-tab-bar.stories-CDmEve6z.js +186 -0
- package/dist-storybook/assets/button-CL7GeC23.js +1 -0
- package/dist-storybook/assets/button.stories-CaqLWQiY.js +287 -0
- package/dist-storybook/assets/calendar-dOCsjhVU.js +1 -0
- package/dist-storybook/assets/calendar.stories-DLWZldet.js +189 -0
- package/dist-storybook/assets/carousel-1Kww3hIz.js +37 -0
- package/dist-storybook/assets/carousel.stories-B8YbGOOr.js +217 -0
- package/dist-storybook/assets/checkbox-MGytNNRt.js +1 -0
- package/dist-storybook/assets/checkbox.stories-CLvfZPiw.js +201 -0
- package/dist-storybook/assets/chip-kG4p82WT.js +247 -0
- package/dist-storybook/assets/chip.stories-BbwJb5eD.js +442 -0
- package/dist-storybook/assets/classname-CUR_zgkh.js +1 -0
- package/dist-storybook/assets/colors-_6nFGM3e.js +1 -0
- package/dist-storybook/assets/date-Cg-Uk_pp.js +1 -0
- package/dist-storybook/assets/date-field.stories-Diptwqfv.js +129 -0
- package/dist-storybook/assets/date-picker-Dnq_-0Md.js +1 -0
- package/dist-storybook/assets/date-picker.stories-BuGWvzFL.js +123 -0
- package/dist-storybook/assets/default-error-BcnD8fFO.png +0 -0
- package/dist-storybook/assets/dialog.stories-DJ0WsSkA.js +212 -0
- package/dist-storybook/assets/dropdown.stories-D6JUYP73.js +200 -0
- package/dist-storybook/assets/embla-carousel-react.esm-BYjpaHZ9.js +1 -0
- package/dist-storybook/assets/en-Cs9O0XWn.js +15 -0
- package/dist-storybook/assets/icon-DdQsMyRa.js +1 -0
- package/dist-storybook/assets/icon.stories-B-ZvRzFf.js +365 -0
- package/dist-storybook/assets/iframe-CQAwSt4E.js +1071 -0
- package/dist-storybook/assets/iframe-yMKl6hJA.css +1 -0
- package/dist-storybook/assets/image-C3EsNRhz.js +9 -0
- package/dist-storybook/assets/image.stories-C4l8D3ju.js +255 -0
- package/dist-storybook/assets/index-B-Ksafg0.js +1 -0
- package/dist-storybook/assets/index-BV0AJWP6.js +1 -0
- package/dist-storybook/assets/index-CgMRTj-o.js +1 -0
- package/dist-storybook/assets/index-DHiZ-gXR.js +1 -0
- package/dist-storybook/assets/input-wrapper-BKHgnPy6.js +1 -0
- package/dist-storybook/assets/label-DV2iCDmN.js +27 -0
- package/dist-storybook/assets/label.stories-BwTIPFXX.js +138 -0
- package/dist-storybook/assets/matchers-7Z3WT2CE-Dw4MQV_s.js +14 -0
- package/dist-storybook/assets/navigation-bar-vI-FPasP.js +79 -0
- package/dist-storybook/assets/navigation-bar.stories-DYuFaJFD.js +73 -0
- package/dist-storybook/assets/number-field-CXKmnfKe.js +1 -0
- package/dist-storybook/assets/number-field.stories--fn26TJu.js +167 -0
- package/dist-storybook/assets/omit-Bsx5nTI0.js +1 -0
- package/dist-storybook/assets/option-item-LRh_OyV4.js +1 -0
- package/dist-storybook/assets/option-item.stories-snjAvgay.js +66 -0
- package/dist-storybook/assets/pagination-DZHoBs_4.js +1 -0
- package/dist-storybook/assets/pagination.stories-BoEs0jzS.js +91 -0
- package/dist-storybook/assets/pick-BhmhLmLe.js +1 -0
- package/dist-storybook/assets/preload-helper-PPVm8Dsz.js +1 -0
- package/dist-storybook/assets/radio-B5NJxG_l.js +1 -0
- package/dist-storybook/assets/radio.stories-DuN-Awi_.js +183 -0
- package/dist-storybook/assets/rating-BdXViYBv.js +1 -0
- package/dist-storybook/assets/rating.stories-BCcQjMEx.js +117 -0
- package/dist-storybook/assets/react-18-CNyWQ7je.js +9 -0
- package/dist-storybook/assets/react-hufnxGVs.js +1 -0
- package/dist-storybook/assets/search-field-CQqgFbfg.js +1 -0
- package/dist-storybook/assets/search-field.stories-DiCZbhng.js +79 -0
- package/dist-storybook/assets/section-content-DGNB4eLN.js +1 -0
- package/dist-storybook/assets/section.stories-C2I_kKhu.js +69 -0
- package/dist-storybook/assets/sheet.stories-wk1JaKU5.js +152 -0
- package/dist-storybook/assets/skeleton-C91JgehG.js +1 -0
- package/dist-storybook/assets/skeleton.stories-BCmX-VNr.js +139 -0
- package/dist-storybook/assets/store-CPumdfcU.js +1 -0
- package/dist-storybook/assets/store-D2RudmNr.js +18 -0
- package/dist-storybook/assets/switch-p-aXI-ev.js +1 -0
- package/dist-storybook/assets/switch.stories-BqPLNKB9.js +250 -0
- package/dist-storybook/assets/tab-bar-CSeCmtIZ.js +31 -0
- package/dist-storybook/assets/tab-bar.stories-Cb6v8H2w.js +136 -0
- package/dist-storybook/assets/text-area-DwSXyqOe.js +1 -0
- package/dist-storybook/assets/text-area.stories-By8bCfgc.js +87 -0
- package/dist-storybook/assets/text-field-jK6rpOo2.js +1 -0
- package/dist-storybook/assets/text-field.stories-CrWBAhvI.js +92 -0
- package/dist-storybook/assets/toast-provider-DurnMJhd.js +9 -0
- package/dist-storybook/assets/toast.stories-iWAToAZA.js +201 -0
- package/dist-storybook/assets/tooltip-QDdel5My.js +1 -0
- package/dist-storybook/assets/tooltip.stories-RC6SuPPD.js +153 -0
- package/dist-storybook/assets/typography-DEpAJl_i.js +1 -0
- package/dist-storybook/assets/typography.stories-Bu8qFugR.js +202 -0
- package/dist-storybook/assets/uploader.stories-B2wW9qVy.js +65 -0
- package/dist-storybook/assets/use-app-pause-B_tWHKJK.js +29 -0
- package/dist-storybook/assets/use-app-resume--900G-dV.js +29 -0
- package/dist-storybook/assets/use-custom-icon-event-3VExRzvC.js +29 -0
- package/dist-storybook/assets/use-did-hide-BUsL73ab.js +48 -0
- package/dist-storybook/assets/use-did-show-C1-VLDxi.js +49 -0
- package/dist-storybook/assets/use-histories-E4E2jJEY.js +50 -0
- package/dist-storybook/assets/use-history-o1im8IDj.js +67 -0
- package/dist-storybook/assets/use-location-CUEaBO4P.js +56 -0
- package/dist-storybook/assets/use-navigate-C4CTuFSZ.js +84 -0
- package/dist-storybook/assets/use-navigation-type-Dcz4hgKo.js +44 -0
- package/dist-storybook/assets/use-page-config-DSJBVQbq.js +48 -0
- package/dist-storybook/assets/use-page-scroll-dY-U1Vv4.js +69 -0
- package/dist-storybook/assets/use-page-state-CtNpwGPN.js +79 -0
- package/dist-storybook/assets/use-settings-changed-BBJwIHTE.js +29 -0
- package/dist-storybook/assets/v-mini-icon-Dn1BmJzb.woff2 +0 -0
- package/dist-storybook/assets/visibility-sensor-CwrzJO06.js +1 -0
- package/dist-storybook/iframe.html +670 -0
- package/dist-storybook/index.html +132 -0
- package/dist-storybook/index.json +1 -0
- package/dist-storybook/project.json +1 -0
- package/dist-storybook/sb-addons/a11y-2/manager-bundle.js +5 -0
- package/dist-storybook/sb-addons/docs-1/manager-bundle.js +151 -0
- package/dist-storybook/sb-addons/storybook-build-3/manager-bundle.js +3 -0
- package/dist-storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +971 -0
- package/dist-storybook/sb-manager/globals-module-info.js +799 -0
- package/dist-storybook/sb-manager/globals-runtime.js +69791 -0
- package/dist-storybook/sb-manager/globals.js +34 -0
- package/dist-storybook/sb-manager/runtime.js +13198 -0
- package/dist-storybook/stories-data.json +374 -0
- package/dist-storybook/vite-inject-mocker-entry.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import{j as o,r as g}from"./iframe-CQAwSt4E.js";import{U as d}from"./chip-kG4p82WT.js";import{t as e}from"./store-D2RudmNr.js";import{T as b,S as h,M as u,P as v,a as y}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./classname-CUR_zgkh.js";import"./icon-DdQsMyRa.js";import"./colors-_6nFGM3e.js";import"./navigation-bar-vI-FPasP.js";import"./visibility-sensor-CwrzJO06.js";import"./index-B-Ksafg0.js";import"./store-CPumdfcU.js";import"./_setToString-CbM921C9.js";import"./react-hufnxGVs.js";import"./omit-Bsx5nTI0.js";import"./pick-BhmhLmLe.js";import"./button-CL7GeC23.js";import"./typography-DEpAJl_i.js";import"./image-C3EsNRhz.js";import"./bottom-tab-bar-CtcTAxuI.js";import"./toast-provider-DurnMJhd.js";import"./carousel-1Kww3hIz.js";import"./embla-carousel-react.esm-BYjpaHZ9.js";import"./pagination-DZHoBs_4.js";import"./section-content-DGNB4eLN.js";import"./option-item-LRh_OyV4.js";import"./index-BV0AJWP6.js";import"./alert-DLW8CoyB.js";import"./skeleton-C91JgehG.js";import"./label-DV2iCDmN.js";import"./input-wrapper-BKHgnPy6.js";import"./text-field-jK6rpOo2.js";import"./number-field-CXKmnfKe.js";import"./checkbox-MGytNNRt.js";import"./radio-B5NJxG_l.js";import"./date-Cg-Uk_pp.js";import"./date-picker-Dnq_-0Md.js";import"./calendar-dOCsjhVU.js";import"./search-field-CQqgFbfg.js";import"./text-area-DwSXyqOe.js";import"./avatar-GxcYPA1p.js";import"./badge-D_LzMVtw.js";import"./switch-p-aXI-ev.js";import"./tab-bar-CSeCmtIZ.js";import"./rating-BdXViYBv.js";import"./tooltip-QDdel5My.js";import"./index-DHiZ-gXR.js";const w=()=>{const r=`
|
|
2
|
+
## ${e("common.table.title")}
|
|
3
|
+
| ${e("common.table.name")} | ${e("common.table.type")} | ${e("common.table.required")} | ${e("common.table.description")} |
|
|
4
|
+
| :--- | :--- | :---: | :--- |
|
|
5
|
+
| \`value\` | \`IFileUpload[]\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.valueDescription")} |
|
|
6
|
+
| \`onChange\` | \`(files: IFileUpload[]) => void\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.onChangeDescription")} |
|
|
7
|
+
| \`limit\` | \`number\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.limitDescription")} |
|
|
8
|
+
| \`disabled\` | \`boolean\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.disabledDescription")} |
|
|
9
|
+
| \`showPreview\` | \`boolean\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.showPreviewDescription")} |
|
|
10
|
+
| \`includeBase64\` | \`boolean\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.includeBase64Description")} |
|
|
11
|
+
| \`className\` | \`string\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.classNameDescription")} |
|
|
12
|
+
| \`...props\` | \`ComponentPropsWithRef<'div'>\` | ${e("common.table.no")} | ${e("components.uploader.argTypes.propsDescription")} |
|
|
13
|
+
`;return o.jsxs(o.Fragment,{children:[o.jsx(b,{}),o.jsx(h,{}),o.jsx(u,{children:e("components.uploader.description")}),o.jsx(v,{}),o.jsx(u,{children:r}),o.jsx(y,{})]})},ue={title:"Components/Uploader",component:d,parameters:{layout:"padded",docs:{page:w}},tags:["autodocs"],argTypes:{value:{control:!1,description:e("components.uploader.argTypes.valueDescription"),table:{type:{summary:"IFileUpload[]"}}},onChange:{action:"changed",description:e("components.uploader.argTypes.onChangeDescription"),table:{type:{summary:"(files: IFileUpload[]) => void"}}},limit:{control:{type:"number",min:1,max:10,step:1},description:e("components.uploader.argTypes.limitDescription"),table:{type:{summary:"number"}}},disabled:{control:"boolean",description:e("components.uploader.argTypes.disabledDescription"),table:{type:{summary:"boolean"}}},showPreview:{control:"boolean",description:e("components.uploader.argTypes.showPreviewDescription"),table:{type:{summary:"boolean"}}},includeBase64:{control:"boolean",description:e("components.uploader.argTypes.includeBase64Description"),table:{type:{summary:"boolean"}}},className:{control:"text",description:e("components.uploader.argTypes.classNameDescription"),table:{type:{summary:"string"}}}}},t={name:e("components.uploader.stories.default.name"),args:{}},s={name:e("components.uploader.stories.controlled.name"),render:()=>{const[r,c]=g.useState([]);return o.jsx(d,{value:r,onChange:c})}},n={name:e("components.uploader.stories.withLimit.name"),args:{limit:3}},a={name:e("components.uploader.stories.withPreview.name"),args:{showPreview:!0}},i={name:e("components.uploader.stories.disabled.name"),args:{disabled:!0}},p={name:e("components.uploader.stories.singleFile.name"),args:{limit:1,showPreview:!0}},m={name:e("components.uploader.stories.multipleFiles.name"),args:{limit:5,showPreview:!0}},l={name:e("components.uploader.stories.interactive.name"),render:()=>{const[r,c]=g.useState([]);return o.jsxs("div",{children:[o.jsx(d,{value:r,onChange:c,showPreview:!0,limit:3}),o.jsx("p",{style:{marginTop:"16px",fontSize:"14px"},children:e("components.uploader.stories.interactive.filesUploaded",{count:r.length})})]})}};t.parameters={...t.parameters,docs:{...t.parameters?.docs,source:{originalSource:`{
|
|
14
|
+
name: t('components.uploader.stories.default.name'),
|
|
15
|
+
args: {}
|
|
16
|
+
}`,...t.parameters?.docs?.source}}};s.parameters={...s.parameters,docs:{...s.parameters?.docs,source:{originalSource:`{
|
|
17
|
+
name: t('components.uploader.stories.controlled.name'),
|
|
18
|
+
render: () => {
|
|
19
|
+
const [files, setFiles] = useState<IFileUpload[]>([]);
|
|
20
|
+
return <Uploader value={files} onChange={setFiles} />;
|
|
21
|
+
}
|
|
22
|
+
}`,...s.parameters?.docs?.source}}};n.parameters={...n.parameters,docs:{...n.parameters?.docs,source:{originalSource:`{
|
|
23
|
+
name: t('components.uploader.stories.withLimit.name'),
|
|
24
|
+
args: {
|
|
25
|
+
limit: 3
|
|
26
|
+
}
|
|
27
|
+
}`,...n.parameters?.docs?.source}}};a.parameters={...a.parameters,docs:{...a.parameters?.docs,source:{originalSource:`{
|
|
28
|
+
name: t('components.uploader.stories.withPreview.name'),
|
|
29
|
+
args: {
|
|
30
|
+
showPreview: true
|
|
31
|
+
}
|
|
32
|
+
}`,...a.parameters?.docs?.source}}};i.parameters={...i.parameters,docs:{...i.parameters?.docs,source:{originalSource:`{
|
|
33
|
+
name: t('components.uploader.stories.disabled.name'),
|
|
34
|
+
args: {
|
|
35
|
+
disabled: true
|
|
36
|
+
}
|
|
37
|
+
}`,...i.parameters?.docs?.source}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
|
|
38
|
+
name: t('components.uploader.stories.singleFile.name'),
|
|
39
|
+
args: {
|
|
40
|
+
limit: 1,
|
|
41
|
+
showPreview: true
|
|
42
|
+
}
|
|
43
|
+
}`,...p.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
|
|
44
|
+
name: t('components.uploader.stories.multipleFiles.name'),
|
|
45
|
+
args: {
|
|
46
|
+
limit: 5,
|
|
47
|
+
showPreview: true
|
|
48
|
+
}
|
|
49
|
+
}`,...m.parameters?.docs?.source}}};l.parameters={...l.parameters,docs:{...l.parameters?.docs,source:{originalSource:`{
|
|
50
|
+
name: t('components.uploader.stories.interactive.name'),
|
|
51
|
+
render: () => {
|
|
52
|
+
const [files, setFiles] = useState<IFileUpload[]>([]);
|
|
53
|
+
return <div>
|
|
54
|
+
<Uploader value={files} onChange={setFiles} showPreview limit={3} />
|
|
55
|
+
<p style={{
|
|
56
|
+
marginTop: '16px',
|
|
57
|
+
fontSize: '14px'
|
|
58
|
+
}}>
|
|
59
|
+
{t('components.uploader.stories.interactive.filesUploaded', {
|
|
60
|
+
count: files.length
|
|
61
|
+
})}
|
|
62
|
+
</p>
|
|
63
|
+
</div>;
|
|
64
|
+
}
|
|
65
|
+
}`,...l.parameters?.docs?.source}}};const ge=["Default","Controlled","WithLimit","WithPreview","Disabled","SingleFile","MultipleFiles","Interactive"];export{s as Controlled,t as Default,i as Disabled,l as Interactive,m as MultipleFiles,p as SingleFile,n as WithLimit,a as WithPreview,ge as __namedExportsOrder,ue as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{j as e}from"./iframe-CQAwSt4E.js";import{useMDXComponents as t}from"./index-CgMRTj-o.js";import{b as i,M as p}from"./blocks-BuaOUtiH.js";import{t as o}from"./store-D2RudmNr.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function r(s){const n={code:"code",h1:"h1",h2:"h2",pre:"pre",...t(),...s.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(i,{title:"Hooks/useAppPause"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"useapppause",children:"useAppPause"}),`
|
|
5
|
+
`,e.jsx(p,{children:o("hooks.useAppPause.description")}),`
|
|
6
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useAppPause } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"props",children:"Props"}),`
|
|
10
|
+
`,e.jsx(p,{children:`
|
|
11
|
+
| Name | Type | Required | Default | Description |
|
|
12
|
+
| --------- | ------------ | -------- | ------- | ----------------------------------------------------------------------- |
|
|
13
|
+
| onPause | () => void | Yes | - | ${o("hooks.useAppPause.onPauseDescription")} |
|
|
14
|
+
`}),`
|
|
15
|
+
`,e.jsx(n.h2,{id:"",children:o("hooks.usageExample")}),`
|
|
16
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useAppPause } from '@v-miniapp/ui-react';
|
|
17
|
+
|
|
18
|
+
function MyComponent() {
|
|
19
|
+
useAppPause(() => {
|
|
20
|
+
console.log('App paused!');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<h1>My Component</h1>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
`})})]})}function l(s={}){const{wrapper:n}={...t(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(r,{...s})}):r(s)}export{l as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{j as e}from"./iframe-CQAwSt4E.js";import{useMDXComponents as t}from"./index-CgMRTj-o.js";import{b as i,M as r}from"./blocks-BuaOUtiH.js";import{t as o}from"./store-D2RudmNr.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function p(s){const n={code:"code",h1:"h1",h2:"h2",pre:"pre",...t(),...s.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(i,{title:"Hooks/useAppResume"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"useappresume",children:"useAppResume"}),`
|
|
5
|
+
`,e.jsx(r,{children:o("hooks.useAppResume.description")}),`
|
|
6
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useAppResume } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"props",children:"Props"}),`
|
|
10
|
+
`,e.jsx(r,{children:`
|
|
11
|
+
| Name | Type | Required | Default | Description |
|
|
12
|
+
| --------- | ------------ | -------- | ------- | ----------------------------------------------------------------------- |
|
|
13
|
+
| onResume | () => void | Yes | - | ${o("hooks.useAppResume.onResumeDescription")} |
|
|
14
|
+
`}),`
|
|
15
|
+
`,e.jsx(n.h2,{id:"",children:o("hooks.usageExample")}),`
|
|
16
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useAppResume } from '@v-miniapp/ui-react';
|
|
17
|
+
|
|
18
|
+
function MyComponent() {
|
|
19
|
+
useAppResume(() => {
|
|
20
|
+
console.log('App resumed!');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<h1>My Component</h1>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
`})})]})}function l(s={}){const{wrapper:n}={...t(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(p,{...s})}):p(s)}export{l as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as r}from"./index-CgMRTj-o.js";import{b as c,M as s}from"./blocks-BuaOUtiH.js";import{t}from"./store-D2RudmNr.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function i(o){const e={code:"code",h1:"h1",h2:"h2",pre:"pre",...r(),...o.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(c,{title:"Hooks/useCustomIconEvent"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usecustomiconevent",children:"useCustomIconEvent"}),`
|
|
5
|
+
`,n.jsx(s,{children:t("hooks.useCustomIconEvent.description")}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useCustomIconEvent } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"props",children:"Props"}),`
|
|
10
|
+
`,n.jsx(s,{children:`
|
|
11
|
+
| Name | Type | Required | Default | Description |
|
|
12
|
+
| ----------------- | ------------------------ | -------- | ------- | ----------- |
|
|
13
|
+
| onCustomIconEvent | (index: number) => void | Yes | - | ${t("hooks.useCustomIconEvent.onCustomIconEventDescription")} |
|
|
14
|
+
`}),`
|
|
15
|
+
`,n.jsx(e.h2,{id:"",children:t("hooks.usageExample")}),`
|
|
16
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useCustomIconEvent } from '@v-miniapp/ui-react';
|
|
17
|
+
|
|
18
|
+
function MyComponent() {
|
|
19
|
+
useCustomIconEvent((index) => {
|
|
20
|
+
console.log(\`Custom icon at index \${index} was clicked\`);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<h1>My Component</h1>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
`})})]})}function l(o={}){const{wrapper:e}={...r(),...o.components};return e?n.jsx(e,{...o,children:n.jsx(i,{...o})}):i(o)}export{l as default};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{j as e}from"./iframe-CQAwSt4E.js";import{useMDXComponents as s}from"./index-CgMRTj-o.js";import{b as c}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function d(i){const n={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...s(),...i.components};return e.jsxs(e.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,e.jsx(c,{title:"Hooks/useDidHide"}),`
|
|
4
|
+
`,e.jsx(n.h1,{id:"usedidhide",children:"useDidHide"}),`
|
|
5
|
+
`,e.jsx(n.p,{children:"Hook để xử lý khi page bị ẩn (hide)."}),`
|
|
6
|
+
`,e.jsx(n.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-typescript",children:`import { useDidHide } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,e.jsx(n.h2,{id:"parameters",children:"Parameters"}),`
|
|
10
|
+
`,e.jsxs(n.ul,{children:[`
|
|
11
|
+
`,e.jsxs(n.li,{children:[e.jsx(n.code,{children:"func?: () => void"}),": Callback function được gọi khi page hide"]}),`
|
|
12
|
+
`]}),`
|
|
13
|
+
`,e.jsx(n.h2,{id:"returns",children:"Returns"}),`
|
|
14
|
+
`,e.jsxs(n.ul,{children:[`
|
|
15
|
+
`,e.jsxs(n.li,{children:[e.jsx(n.code,{children:"didHide"}),": ",e.jsx(n.code,{children:"boolean"})," - Cho biết page có đang bị ẩn không"]}),`
|
|
16
|
+
`]}),`
|
|
17
|
+
`,e.jsx(n.h2,{id:"usage",children:"Usage"}),`
|
|
18
|
+
`,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { useDidHide } from '@v-miniapp/ui-react'
|
|
19
|
+
import { useEffect } from 'react'
|
|
20
|
+
|
|
21
|
+
const MyPage = () => {
|
|
22
|
+
const didHide = useDidHide(() => {
|
|
23
|
+
console.log('Page is hidden')
|
|
24
|
+
// Cleanup, pause timers, etc.
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (didHide) {
|
|
29
|
+
// Page is hidden, cleanup
|
|
30
|
+
pauseTimers()
|
|
31
|
+
}
|
|
32
|
+
}, [didHide])
|
|
33
|
+
|
|
34
|
+
return <div>Page is {didHide ? 'hidden' : 'visible'}</div>
|
|
35
|
+
}
|
|
36
|
+
`})}),`
|
|
37
|
+
`,e.jsx(n.h2,{id:"lifecycle",children:"Lifecycle"}),`
|
|
38
|
+
`,e.jsx(n.p,{children:"Hook này trigger callback khi:"}),`
|
|
39
|
+
`,e.jsxs(n.ul,{children:[`
|
|
40
|
+
`,e.jsx(n.li,{children:"Page bị navigate đi (navigate đến page khác)"}),`
|
|
41
|
+
`,e.jsx(n.li,{children:"Page bị ẩn do keep-alive (page khác được show)"}),`
|
|
42
|
+
`]}),`
|
|
43
|
+
`,e.jsx(n.h2,{id:"notes",children:"Notes"}),`
|
|
44
|
+
`,e.jsxs(n.ul,{children:[`
|
|
45
|
+
`,e.jsxs(n.li,{children:[e.jsx(n.code,{children:"didHide"})," sẽ là ",e.jsx(n.code,{children:"true"})," khi page bị ẩn, ",e.jsx(n.code,{children:"false"})," khi được hiển thị"]}),`
|
|
46
|
+
`,e.jsxs(n.li,{children:["Sử dụng ",e.jsx(n.code,{children:"navigationEventEmitter"})," với event ",e.jsx(n.code,{children:"beforeLocationChangeP1"})," để detect page hide"]}),`
|
|
47
|
+
`,e.jsx(n.li,{children:"Hữu ích cho cleanup, pause timers, hoặc save state"}),`
|
|
48
|
+
`]})]})}function a(i={}){const{wrapper:n}={...s(),...i.components};return n?e.jsx(n,{...i,children:e.jsx(d,{...i})}):d(i)}export{a as default};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as c}from"./index-CgMRTj-o.js";import{b as o}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function s(i){const e={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...c(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(o,{title:"Hooks/useDidShow"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usedidshow",children:"useDidShow"}),`
|
|
5
|
+
`,n.jsx(e.p,{children:"Hook để xử lý khi page được hiển thị (show)."}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useDidShow } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(e.h2,{id:"parameters",children:"Parameters"}),`
|
|
10
|
+
`,n.jsxs(e.ul,{children:[`
|
|
11
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"func?: () => void"}),": Callback function được gọi khi page show"]}),`
|
|
12
|
+
`]}),`
|
|
13
|
+
`,n.jsx(e.h2,{id:"returns",children:"Returns"}),`
|
|
14
|
+
`,n.jsxs(e.ul,{children:[`
|
|
15
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"didShow"}),": ",n.jsx(e.code,{children:"boolean"})," - Cho biết page có đang được hiển thị không"]}),`
|
|
16
|
+
`]}),`
|
|
17
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
18
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useDidShow } from '@v-miniapp/ui-react'
|
|
19
|
+
import { useEffect } from 'react'
|
|
20
|
+
|
|
21
|
+
const MyPage = () => {
|
|
22
|
+
const didShow = useDidShow(() => {
|
|
23
|
+
console.log('Page is shown')
|
|
24
|
+
// Fetch data, track analytics, etc.
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (didShow) {
|
|
29
|
+
// Page is visible, do something
|
|
30
|
+
fetchData()
|
|
31
|
+
}
|
|
32
|
+
}, [didShow])
|
|
33
|
+
|
|
34
|
+
return <div>Page is {didShow ? 'visible' : 'hidden'}</div>
|
|
35
|
+
}
|
|
36
|
+
`})}),`
|
|
37
|
+
`,n.jsx(e.h2,{id:"lifecycle",children:"Lifecycle"}),`
|
|
38
|
+
`,n.jsx(e.p,{children:"Hook này trigger callback khi:"}),`
|
|
39
|
+
`,n.jsxs(e.ul,{children:[`
|
|
40
|
+
`,n.jsx(e.li,{children:"Page được mount lần đầu"}),`
|
|
41
|
+
`,n.jsx(e.li,{children:"Page được navigate đến (từ page khác)"}),`
|
|
42
|
+
`,n.jsx(e.li,{children:"Page được show lại sau khi bị ẩn (navigate back)"}),`
|
|
43
|
+
`]}),`
|
|
44
|
+
`,n.jsx(e.h2,{id:"notes",children:"Notes"}),`
|
|
45
|
+
`,n.jsxs(e.ul,{children:[`
|
|
46
|
+
`,n.jsx(e.li,{children:"Callback được gọi ngay khi component mount"}),`
|
|
47
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"didShow"})," sẽ là ",n.jsx(e.code,{children:"true"})," khi page được hiển thị, ",n.jsx(e.code,{children:"false"})," khi bị ẩn"]}),`
|
|
48
|
+
`,n.jsxs(e.li,{children:["Sử dụng ",n.jsx(e.code,{children:"navigationEventEmitter"})," với event ",n.jsx(e.code,{children:"beforeLocationChangeP2"})," để detect page show"]}),`
|
|
49
|
+
`]})]})}function a(i={}){const{wrapper:e}={...c(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(s,{...i})}):s(i)}export{a as default};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as t}from"./index-CgMRTj-o.js";import{b as o}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function s(e){const i={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...t(),...e.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(o,{title:"Hooks/useHistories"}),`
|
|
4
|
+
`,n.jsx(i.h1,{id:"usehistories",children:"useHistories"}),`
|
|
5
|
+
`,n.jsx(i.p,{children:"Hook để lấy toàn bộ history stack."}),`
|
|
6
|
+
`,n.jsx(i.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-typescript",children:`import { useHistories } from '@v-miniapp/ui-react'
|
|
8
|
+
`})}),`
|
|
9
|
+
`,n.jsx(i.h2,{id:"returns",children:"Returns"}),`
|
|
10
|
+
`,n.jsxs(i.ul,{children:[`
|
|
11
|
+
`,n.jsxs(i.li,{children:[n.jsx(i.code,{children:"histories"}),": ",n.jsx(i.code,{children:"IHistory[]"})," - Mảng các history entries trong navigation stack"]}),`
|
|
12
|
+
`]}),`
|
|
13
|
+
`,n.jsx(i.h2,{id:"type-definitions",children:"Type Definitions"}),`
|
|
14
|
+
`,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-typescript",children:`type IHistory = {
|
|
15
|
+
action: IHistoryAction
|
|
16
|
+
location: ILocation
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type IHistory[] = IHistory[]
|
|
20
|
+
`})}),`
|
|
21
|
+
`,n.jsx(i.h2,{id:"usage",children:"Usage"}),`
|
|
22
|
+
`,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-tsx",children:`import { useHistories } from '@v-miniapp/ui-react'
|
|
23
|
+
|
|
24
|
+
const MyPage = () => {
|
|
25
|
+
const histories = useHistories()
|
|
26
|
+
|
|
27
|
+
console.log(histories.length) // Số lượng pages trong stack
|
|
28
|
+
console.log(histories[0]) // First history entry
|
|
29
|
+
console.log(histories[histories.length - 1]) // Last history entry (current)
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<p>History stack length: {histories.length}</p>
|
|
34
|
+
<ul>
|
|
35
|
+
{histories.map((history, index) => (
|
|
36
|
+
<li key={history.location.key}>
|
|
37
|
+
{index + 1}. {history.location.pathname} ({history.action})
|
|
38
|
+
</li>
|
|
39
|
+
))}
|
|
40
|
+
</ul>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
`})}),`
|
|
45
|
+
`,n.jsx(i.h2,{id:"notes",children:"Notes"}),`
|
|
46
|
+
`,n.jsxs(i.ul,{children:[`
|
|
47
|
+
`,n.jsx(i.li,{children:"History stack được quản lý bởi browser history API"}),`
|
|
48
|
+
`,n.jsxs(i.li,{children:["Mỗi history entry có unique ",n.jsx(i.code,{children:"location.key"})]}),`
|
|
49
|
+
`,n.jsx(i.li,{children:"Stack được update khi navigate (push/replace/pop)"}),`
|
|
50
|
+
`]})]})}function d(e={}){const{wrapper:i}={...t(),...e.components};return i?n.jsx(i,{...e,children:n.jsx(s,{...e})}):s(e)}const p=[];export{p as __namedExportsOrder,d as default};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as t}from"./index-CgMRTj-o.js";import{b as s}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function o(i){const e={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...t(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(s,{title:"Hooks/useHistory"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usehistory",children:"useHistory"}),`
|
|
5
|
+
`,n.jsx(e.p,{children:"Hook để lấy history entry hiện tại của page."}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useHistory } 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.code,{children:"history"}),": ",n.jsx(e.code,{children:"IHistory"})," object hoặc ",n.jsx(e.code,{children:"undefined"})," chứa:",`
|
|
12
|
+
`,n.jsxs(e.ul,{children:[`
|
|
13
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"action"}),": ",n.jsx(e.code,{children:"'PUSH' | 'REPLACE' | 'POP'"})," - Navigation action type"]}),`
|
|
14
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"location"}),": ",n.jsx(e.code,{children:"ILocation"})," object chứa:",`
|
|
15
|
+
`,n.jsxs(e.ul,{children:[`
|
|
16
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"key"}),": ",n.jsx(e.code,{children:"string"})," - Unique key cho location này"]}),`
|
|
17
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"pathname"}),": ",n.jsx(e.code,{children:"string"})," - Pathname của page"]}),`
|
|
18
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"params?"}),": ",n.jsx(e.code,{children:"Record<string, string>"})," - Query parameters"]}),`
|
|
19
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"state?"}),": ",n.jsx(e.code,{children:"any"})," - State object"]}),`
|
|
20
|
+
`]}),`
|
|
21
|
+
`]}),`
|
|
22
|
+
`]}),`
|
|
23
|
+
`]}),`
|
|
24
|
+
`]}),`
|
|
25
|
+
`,n.jsx(e.h2,{id:"type-definitions",children:"Type Definitions"}),`
|
|
26
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type IHistory = {
|
|
27
|
+
action: IHistoryAction
|
|
28
|
+
location: ILocation
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type IHistoryAction = 'POP' | 'REPLACE' | 'PUSH'
|
|
32
|
+
|
|
33
|
+
type ILocation = {
|
|
34
|
+
key: string
|
|
35
|
+
pathname: string
|
|
36
|
+
params?: Record<string, string>
|
|
37
|
+
state?: any
|
|
38
|
+
}
|
|
39
|
+
`})}),`
|
|
40
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
41
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useHistory } from '@v-miniapp/ui-react'
|
|
42
|
+
|
|
43
|
+
const MyPage = () => {
|
|
44
|
+
const history = useHistory()
|
|
45
|
+
|
|
46
|
+
if (!history) return null
|
|
47
|
+
|
|
48
|
+
console.log(history.location.pathname) // '/home'
|
|
49
|
+
console.log(history.location.params) // { id: '123' }
|
|
50
|
+
console.log(history.location.state) // { from: 'home' }
|
|
51
|
+
console.log(history.location.key) // Unique key
|
|
52
|
+
console.log(history.action) // 'PUSH' | 'REPLACE' | 'POP'
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<p>Current path: {history.location.pathname}</p>
|
|
57
|
+
<p>Action: {history.action}</p>
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
`})}),`
|
|
62
|
+
`,n.jsx(e.h2,{id:"notes",children:"Notes"}),`
|
|
63
|
+
`,n.jsxs(e.ul,{children:[`
|
|
64
|
+
`,n.jsxs(e.li,{children:["Hook này sử dụng ",n.jsx(e.code,{children:"LocationKeyContext"})," để lấy history entry tương ứng với page hiện tại"]}),`
|
|
65
|
+
`,n.jsxs(e.li,{children:["Nếu không có ",n.jsx(e.code,{children:"locationKey"})," trong context, sẽ trả về last history entry"]}),`
|
|
66
|
+
`,n.jsx(e.li,{children:"History entry được tạo mới mỗi khi navigate (với unique key)"}),`
|
|
67
|
+
`]})]})}function a(i={}){const{wrapper:e}={...t(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(o,{...i})}):o(i)}const x=[];export{x as __namedExportsOrder,a as default};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as s}from"./index-CgMRTj-o.js";import{b as c}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function o(i){const e={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...s(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(c,{title:"Hooks/useLocation"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"uselocation",children:"useLocation"}),`
|
|
5
|
+
`,n.jsx(e.p,{children:"Hook để lấy location object hiện tại (pathname, params, state, key)."}),`
|
|
6
|
+
`,n.jsx(e.h2,{id:"import",children:"Import"}),`
|
|
7
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useLocation } 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.code,{children:"location"}),": ",n.jsx(e.code,{children:"ILocation"})," object hoặc ",n.jsx(e.code,{children:"undefined"})," chứa:",`
|
|
12
|
+
`,n.jsxs(e.ul,{children:[`
|
|
13
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"key"}),": ",n.jsx(e.code,{children:"string"})," - Unique key cho location này"]}),`
|
|
14
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"pathname"}),": ",n.jsx(e.code,{children:"string"})," - Pathname của page"]}),`
|
|
15
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"params?"}),": ",n.jsx(e.code,{children:"Record<string, string>"})," - Query parameters"]}),`
|
|
16
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"state?"}),": ",n.jsx(e.code,{children:"any"})," - State object"]}),`
|
|
17
|
+
`]}),`
|
|
18
|
+
`]}),`
|
|
19
|
+
`]}),`
|
|
20
|
+
`,n.jsx(e.h2,{id:"type-definitions",children:"Type Definitions"}),`
|
|
21
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type ILocation = {
|
|
22
|
+
key: string
|
|
23
|
+
pathname: string
|
|
24
|
+
params?: Record<string, string>
|
|
25
|
+
state?: any
|
|
26
|
+
}
|
|
27
|
+
`})}),`
|
|
28
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
29
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useLocation } from '@v-miniapp/ui-react'
|
|
30
|
+
|
|
31
|
+
const MyPage = () => {
|
|
32
|
+
const location = useLocation()
|
|
33
|
+
|
|
34
|
+
if (!location) return null
|
|
35
|
+
|
|
36
|
+
console.log(location.pathname) // '/home'
|
|
37
|
+
console.log(location.params) // { id: '123' }
|
|
38
|
+
console.log(location.state) // { from: 'home' }
|
|
39
|
+
console.log(location.key) // Unique key
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<p>Path: {location.pathname}</p>
|
|
44
|
+
{location.params && (
|
|
45
|
+
<p>Params: {JSON.stringify(location.params)}</p>
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
`})}),`
|
|
51
|
+
`,n.jsx(e.h2,{id:"notes",children:"Notes"}),`
|
|
52
|
+
`,n.jsxs(e.ul,{children:[`
|
|
53
|
+
`,n.jsxs(e.li,{children:["Hook này là wrapper của ",n.jsx(e.code,{children:"useHistory().location"})]}),`
|
|
54
|
+
`,n.jsxs(e.li,{children:["Có thể trả về ",n.jsx(e.code,{children:"undefined"})," nếu không có history entry"]}),`
|
|
55
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"location.key"})," là unique identifier cho mỗi navigation instance"]}),`
|
|
56
|
+
`]})]})}function h(i={}){const{wrapper:e}={...s(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(o,{...i})}):o(i)}export{h as default};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as o}from"./index-CgMRTj-o.js";import{b as s,M as t}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function i(a){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...o(),...a.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(s,{title:"Hooks/useNavigate"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usenavigate",children:"useNavigate"}),`
|
|
5
|
+
`,n.jsxs(e.p,{children:["Hook để lấy function ",n.jsx(e.code,{children:"navigate"})," để điều hướng giữa các pages."]}),`
|
|
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/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.code,{children:"navigate"}),": Function để điều hướng với type ",n.jsx(e.code,{children:"INavigate"}),":",`
|
|
12
|
+
`,n.jsxs(e.ul,{children:[`
|
|
13
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"navigate(pathname: string, options?: INavigatePathnameOptions): void"})," - Navigate bằng pathname"]}),`
|
|
14
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"navigate(delta: number, options?: INavigateDeltaOptions): void"})," - Navigate bằng delta (back/forward)"]}),`
|
|
15
|
+
`]}),`
|
|
16
|
+
`]}),`
|
|
17
|
+
`]}),`
|
|
18
|
+
`,n.jsx(e.h2,{id:"type-definitions",children:"Type Definitions"}),`
|
|
19
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type INavigate = {
|
|
20
|
+
(to: string, options?: INavigatePathnameOptions): void
|
|
21
|
+
(to: number, options?: INavigateDeltaOptions): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type INavigatePathnameOptions = {
|
|
25
|
+
replace?: boolean
|
|
26
|
+
params?: Record<string, string>
|
|
27
|
+
state?: any
|
|
28
|
+
} & IPageState
|
|
29
|
+
|
|
30
|
+
type INavigateDeltaOptions = {
|
|
31
|
+
animation?: IAppAnimationState
|
|
32
|
+
}
|
|
33
|
+
`})}),`
|
|
34
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
35
|
+
`,n.jsx(e.h3,{id:"navigate-bằng-pathname",children:"Navigate bằng pathname"}),`
|
|
36
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useNavigate } from '@v-miniapp/ui-react'
|
|
37
|
+
|
|
38
|
+
const MyPage = () => {
|
|
39
|
+
const navigate = useNavigate()
|
|
40
|
+
|
|
41
|
+
const handleClick = () => {
|
|
42
|
+
navigate('/settings', {
|
|
43
|
+
params: { id: '123' },
|
|
44
|
+
state: { from: 'home' },
|
|
45
|
+
replace: false,
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return <button onClick={handleClick}>Go to Settings</button>
|
|
50
|
+
}
|
|
51
|
+
`})}),`
|
|
52
|
+
`,n.jsx(e.h3,{id:"navigate-với-page-level-config",children:"Navigate với page-level config"}),`
|
|
53
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const navigate = useNavigate()
|
|
54
|
+
|
|
55
|
+
navigate('/detail', {
|
|
56
|
+
params: { id: '123' },
|
|
57
|
+
navigationBar: {
|
|
58
|
+
title: 'Detail Page',
|
|
59
|
+
},
|
|
60
|
+
animation: {
|
|
61
|
+
type: 'fade_in',
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
`})}),`
|
|
65
|
+
`,n.jsx(e.h3,{id:"navigate-backforward",children:"Navigate back/forward"}),`
|
|
66
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const navigate = useNavigate()
|
|
67
|
+
|
|
68
|
+
// Navigate back 1 page
|
|
69
|
+
navigate(-1)
|
|
70
|
+
|
|
71
|
+
// Navigate forward 1 page
|
|
72
|
+
navigate(1)
|
|
73
|
+
|
|
74
|
+
// Navigate back với custom animation
|
|
75
|
+
navigate(-1, {
|
|
76
|
+
animation: { type: 'none' },
|
|
77
|
+
})
|
|
78
|
+
`})}),`
|
|
79
|
+
`,n.jsx(e.h2,{id:"options",children:"Options"}),`
|
|
80
|
+
`,n.jsx(e.h3,{id:"inavigatepathnameoptions",children:"INavigatePathnameOptions"}),`
|
|
81
|
+
`,n.jsx(t,{children:"\n| Option | Type | Mô tả |\n| :--- | :--- | :--- |\n| `replace` | `boolean` | Nếu `true`, replace history entry thay vì push mới |\n| `params` | `Record<string, string>` | Query parameters (sẽ được thêm vào URL) |\n| `state` | `any` | State object (không hiển thị trong URL, lưu trong history) |\n| `animation` | `IAppAnimationState` | Override animation cho navigation này |\n| `navigationBar` | `IAppNavigationBarState` | Override navigation bar cho page này |\n| `bottomTabBar` | `IAppBottomTabBarState` | Override bottom tab bar cho page này |\n| `keepAlive` | `boolean | IAppKeepAliveState` | Override keep-alive cho page này |\n| `pageLayout` | `IAppPageLayoutState` | Override page layout cho page này |\n"}),`
|
|
82
|
+
`,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Lưu ý:"})," `INavigatePathnameOptions` extends `IPageState`, nên bạn có thể truyền các page-level config trong navigate options để override config cho page mới."]}),`
|
|
83
|
+
`,n.jsx(e.h3,{id:"inavigatedeltaoptions",children:"INavigateDeltaOptions"}),`
|
|
84
|
+
`,n.jsx(t,{children:"\n| Option | Type | Mô tả |\n| :--- | :--- | :--- |\n| `animation` | `IAppAnimationState` | Override animation cho navigation này |\n"})]})}function d(a={}){const{wrapper:e}={...o(),...a.components};return e?n.jsx(e,{...a,children:n.jsx(i,{...a})}):i(a)}export{d as default};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as s}from"./index-CgMRTj-o.js";import{b as r}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function t(i){const e={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...s(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(r,{title:"Hooks/useNavigationType"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usenavigationtype",children:"useNavigationType"}),`
|
|
5
|
+
`,n.jsx(e.p,{children:"Hook để lấy navigation action type (PUSH, REPLACE, POP)."}),`
|
|
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/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.code,{children:"action"}),": ",n.jsx(e.code,{children:"'PUSH' | 'REPLACE' | 'POP'"})," hoặc ",n.jsx(e.code,{children:"undefined"})]}),`
|
|
12
|
+
`]}),`
|
|
13
|
+
`,n.jsx(e.h2,{id:"type-definitions",children:"Type Definitions"}),`
|
|
14
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type IHistoryAction = 'POP' | 'REPLACE' | 'PUSH'
|
|
15
|
+
`})}),`
|
|
16
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
17
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useNavigationType } from '@v-miniapp/ui-react'
|
|
18
|
+
|
|
19
|
+
const MyPage = () => {
|
|
20
|
+
const action = useNavigationType()
|
|
21
|
+
|
|
22
|
+
console.log(action) // 'PUSH' | 'REPLACE' | 'POP'
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<p>Navigation type: {action}</p>
|
|
27
|
+
{action === 'PUSH' && <p>New page pushed to stack</p>}
|
|
28
|
+
{action === 'REPLACE' && <p>Current page replaced</p>}
|
|
29
|
+
{action === 'POP' && <p>Navigated back/forward</p>}
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
`})}),`
|
|
34
|
+
`,n.jsx(e.h2,{id:"action-types",children:"Action Types"}),`
|
|
35
|
+
`,n.jsxs(e.ul,{children:[`
|
|
36
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"PUSH"}),": Navigate đến page mới (push vào history stack)"]}),`
|
|
37
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"REPLACE"}),": Replace current page (thay thế history entry hiện tại)"]}),`
|
|
38
|
+
`,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"POP"}),": Navigate back/forward trong history stack (browser back/forward button)"]}),`
|
|
39
|
+
`]}),`
|
|
40
|
+
`,n.jsx(e.h2,{id:"notes",children:"Notes"}),`
|
|
41
|
+
`,n.jsxs(e.ul,{children:[`
|
|
42
|
+
`,n.jsxs(e.li,{children:["Hook này là wrapper của ",n.jsx(e.code,{children:"useHistory().action"})]}),`
|
|
43
|
+
`,n.jsxs(e.li,{children:["Có thể trả về ",n.jsx(e.code,{children:"undefined"})," nếu không có history entry"]}),`
|
|
44
|
+
`]})]})}function p(i={}){const{wrapper:e}={...s(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(t,{...i})}):t(i)}export{p as default};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as a}from"./index-CgMRTj-o.js";import{b as t}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function o(i){const e={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...a(),...i.components};return n.jsxs(n.Fragment,{children:[`
|
|
2
|
+
`,`
|
|
3
|
+
`,n.jsx(t,{title:"Hooks/usePageConfig"}),`
|
|
4
|
+
`,n.jsx(e.h1,{id:"usepageconfig",children:"usePageConfig"}),`
|
|
5
|
+
`,n.jsx(e.p,{children:"Hook để lấy config của page hiện tạ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 { usePageConfig } 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.code,{children:"pageConfig"}),": ",n.jsx(e.code,{children:"IPageConfig"})," của page hiện tại hoặc ",n.jsx(e.code,{children:"undefined"})]}),`
|
|
12
|
+
`]}),`
|
|
13
|
+
`,n.jsx(e.h2,{id:"type-definitions",children:"Type Definitions"}),`
|
|
14
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type IPageConfig = {
|
|
15
|
+
pathname: string
|
|
16
|
+
Component: ComponentType
|
|
17
|
+
Layouts?: IPageLayout[]
|
|
18
|
+
bottomTabBarId?: string
|
|
19
|
+
} & IPageState
|
|
20
|
+
`})}),`
|
|
21
|
+
`,n.jsx(e.h2,{id:"usage",children:"Usage"}),`
|
|
22
|
+
`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { usePageConfig } from '@v-miniapp/ui-react'
|
|
23
|
+
|
|
24
|
+
const MyPage = () => {
|
|
25
|
+
const pageConfig = usePageConfig()
|
|
26
|
+
|
|
27
|
+
if (!pageConfig) return null
|
|
28
|
+
|
|
29
|
+
console.log(pageConfig.pathname) // '/home'
|
|
30
|
+
console.log(pageConfig.Component) // Component của page
|
|
31
|
+
console.log(pageConfig.navigationBar) // Navigation bar config
|
|
32
|
+
console.log(pageConfig.animation) // Animation config
|
|
33
|
+
console.log(pageConfig.Layouts) // Layouts array
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<p>Page: {pageConfig.pathname}</p>
|
|
38
|
+
<p>Title: {pageConfig.navigationBar?.title}</p>
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
`})}),`
|
|
43
|
+
`,n.jsx(e.h2,{id:"notes",children:"Notes"}),`
|
|
44
|
+
`,n.jsxs(e.ul,{children:[`
|
|
45
|
+
`,n.jsxs(e.li,{children:["Hook này tìm page config dựa trên ",n.jsx(e.code,{children:"pathname"})," hiện tại"]}),`
|
|
46
|
+
`,n.jsxs(e.li,{children:["Trả về ",n.jsx(e.code,{children:"undefined"})," nếu không tìm thấy page config"]}),`
|
|
47
|
+
`,n.jsxs(e.li,{children:["Page config chứa tất cả thông tin được định nghĩa trong ",n.jsx(e.code,{children:"IAppConfig.pages"})]}),`
|
|
48
|
+
`]})]})}function l(i={}){const{wrapper:e}={...a(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(o,{...i})}):o(i)}export{l as default};
|