@v-miniapp/ui-react 1.0.41 → 1.0.47
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/app/types/app.d.ts +10 -0
- package/dist/components/app/utils/data-theme.d.ts +1 -2
- package/dist/components/carousel/index.d.ts +1 -0
- package/dist/external/index.js +2530 -2519
- package/dist/index.js +2308 -2297
- package/dist-storybook/assets/ANIMATION-DLCDVwPI.js +99 -0
- package/dist-storybook/assets/APP_FRAMEWORK-B9Mrudgl.js +197 -0
- package/dist-storybook/assets/BOTTOM_TAB_BAR-Bgfy-nnv.js +175 -0
- package/dist-storybook/assets/CUSTOM_ERROR_BOUNDARY-G_i_6aho.js +250 -0
- package/dist-storybook/assets/Color-AVL7NMMY-OD8SQvXt.js +1 -0
- package/dist-storybook/assets/DocsRenderer-PQXLIZUC-D8kbgtPd.js +2 -0
- package/dist-storybook/assets/GETTING_STARTED-Bf6ENjZo.js +77 -0
- package/dist-storybook/assets/INFINITE_SCROLL-O36i5W8i.js +111 -0
- package/dist-storybook/assets/KEEP_ALIVE-CicDtVw6.js +126 -0
- package/dist-storybook/assets/LOCALE-D_43J3RD.js +465 -0
- package/dist-storybook/assets/MIGRATION_GUIDE-Dn2gFk5v.js +449 -0
- package/dist-storybook/assets/MOBILE_BEHAVIOURS-D5jOxNiz.js +177 -0
- package/dist-storybook/assets/PAGE_LAYOUT-C0sW9iZo.js +192 -0
- package/dist-storybook/assets/ROUTING_NAVIGATION-Bpj_mu5r.js +335 -0
- package/dist-storybook/assets/TAILWIND_INTEGRATION-CVrohRXO.js +87 -0
- package/dist-storybook/assets/THEME_MODE-Sc8cgznR.js +111 -0
- package/dist-storybook/assets/_setToString-CjYxL0rS.js +1 -0
- package/dist-storybook/assets/alert-abKmNYys.js +1 -0
- package/dist-storybook/assets/alert.stories-XyvS4WTm.js +110 -0
- package/dist-storybook/assets/avatar-B-jvPnzm.js +1 -0
- package/dist-storybook/assets/avatar.stories-glTjw5Kd.js +136 -0
- package/dist-storybook/assets/axe-B8nlqekz.js +20 -0
- package/dist-storybook/assets/badge-Cc9u7jBX.js +1 -0
- package/dist-storybook/assets/badge.stories-CeNmmdtv.js +262 -0
- package/dist-storybook/assets/blocks-CpOj9FQ_.js +1243 -0
- package/dist-storybook/assets/bottom-tab-bar-BsPd0FD7.js +115 -0
- package/dist-storybook/assets/bottom-tab-bar.stories-BG1ee2eN.js +186 -0
- package/dist-storybook/assets/button-GtWXUngt.js +1 -0
- package/dist-storybook/assets/button.stories-3d_T0h_Z.js +287 -0
- package/dist-storybook/assets/calendar-CJ5_NxYx.js +1 -0
- package/dist-storybook/assets/calendar.stories-DEleEKoa.js +189 -0
- package/dist-storybook/assets/carousel-sbzGq2WF.js +37 -0
- package/dist-storybook/assets/carousel.stories-DY9nDa3M.js +217 -0
- package/dist-storybook/assets/checkbox-CMpJJxvm.js +1 -0
- package/dist-storybook/assets/checkbox.stories-BY8W9TRC.js +201 -0
- package/dist-storybook/assets/chip-zY6gJxDk.js +247 -0
- package/dist-storybook/assets/chip.stories-CXh30Tdq.js +442 -0
- package/dist-storybook/assets/classname-DoNrELT0.js +1 -0
- package/dist-storybook/assets/colors-_6nFGM3e.js +1 -0
- package/dist-storybook/assets/date-Ci5dIit0.js +1 -0
- package/dist-storybook/assets/date-field.stories-CerGwXZy.js +129 -0
- package/dist-storybook/assets/date-picker-BCIW_1-h.js +1 -0
- package/dist-storybook/assets/date-picker.stories-DUaL7sft.js +123 -0
- package/dist-storybook/assets/default-error-BcnD8fFO.png +0 -0
- package/dist-storybook/assets/dialog.stories-BtQMDA-1.js +212 -0
- package/dist-storybook/assets/dropdown.stories-DF69os0J.js +200 -0
- package/dist-storybook/assets/embla-carousel-react.esm-CCQjHA-d.js +1 -0
- package/dist-storybook/assets/en-Cs9O0XWn.js +15 -0
- package/dist-storybook/assets/icon-TJ3FHxUI.js +1 -0
- package/dist-storybook/assets/icon.stories-Ch36FMIn.js +365 -0
- package/dist-storybook/assets/iframe-CLEfhyJc.js +1071 -0
- package/dist-storybook/assets/iframe-yMKl6hJA.css +1 -0
- package/dist-storybook/assets/image-D6Yo4ht9.js +9 -0
- package/dist-storybook/assets/image.stories-CJPB43ys.js +255 -0
- package/dist-storybook/assets/index-7xlKHfV2.js +1 -0
- package/dist-storybook/assets/index-B-Ksafg0.js +1 -0
- package/dist-storybook/assets/index-CaMbLGUB.js +1 -0
- package/dist-storybook/assets/index-DRIh_SUo.js +1 -0
- package/dist-storybook/assets/input-wrapper-D_9hAdHZ.js +1 -0
- package/dist-storybook/assets/label-fI1oWVKU.js +27 -0
- package/dist-storybook/assets/label.stories-C3xDUHd-.js +138 -0
- package/dist-storybook/assets/matchers-7Z3WT2CE-Dw4MQV_s.js +14 -0
- package/dist-storybook/assets/navigation-bar-CiGSH7u8.js +79 -0
- package/dist-storybook/assets/navigation-bar.stories-BvGp7uJf.js +73 -0
- package/dist-storybook/assets/number-field-DNj4myBV.js +1 -0
- package/dist-storybook/assets/number-field.stories-B_Bj8RqE.js +167 -0
- package/dist-storybook/assets/omit-CStFhbPt.js +1 -0
- package/dist-storybook/assets/option-item-BloohEvW.js +1 -0
- package/dist-storybook/assets/option-item.stories-BjtolfPz.js +66 -0
- package/dist-storybook/assets/pagination-Dcazh6R_.js +1 -0
- package/dist-storybook/assets/pagination.stories-CrGsYeRw.js +91 -0
- package/dist-storybook/assets/pick-DbIUGM9R.js +1 -0
- package/dist-storybook/assets/preload-helper-PPVm8Dsz.js +1 -0
- package/dist-storybook/assets/radio-t2E8E0Oc.js +1 -0
- package/dist-storybook/assets/radio.stories-BEG-zTwI.js +183 -0
- package/dist-storybook/assets/rating-DsULci27.js +1 -0
- package/dist-storybook/assets/rating.stories-Dwk8Ov3Q.js +117 -0
- package/dist-storybook/assets/react-18-4mLDkQmf.js +9 -0
- package/dist-storybook/assets/react-mAVd1wAc.js +1 -0
- package/dist-storybook/assets/search-field-CuiHMy7j.js +1 -0
- package/dist-storybook/assets/search-field.stories-BnsT36yY.js +79 -0
- package/dist-storybook/assets/section-content-pkGNuEs6.js +1 -0
- package/dist-storybook/assets/section.stories-B5IhLkbG.js +69 -0
- package/dist-storybook/assets/sheet.stories-COzxyiqj.js +152 -0
- package/dist-storybook/assets/skeleton-Dn8rwbgX.js +1 -0
- package/dist-storybook/assets/skeleton.stories-B71MlMyi.js +139 -0
- package/dist-storybook/assets/store-D2RudmNr.js +18 -0
- package/dist-storybook/assets/store-DxAqU1JB.js +1 -0
- package/dist-storybook/assets/switch-BziC1t_8.js +1 -0
- package/dist-storybook/assets/switch.stories-DMBBwZef.js +250 -0
- package/dist-storybook/assets/tab-bar-DZ3oOU50.js +31 -0
- package/dist-storybook/assets/tab-bar.stories-Bp9w6nc3.js +136 -0
- package/dist-storybook/assets/text-area-CAmJ2yms.js +1 -0
- package/dist-storybook/assets/text-area.stories-BZ3HXtij.js +87 -0
- package/dist-storybook/assets/text-field-CjrgfYOZ.js +1 -0
- package/dist-storybook/assets/text-field.stories-vSXYvs0U.js +92 -0
- package/dist-storybook/assets/toast-provider-B9k1NBG6.js +9 -0
- package/dist-storybook/assets/toast.stories-DQKbk7dO.js +201 -0
- package/dist-storybook/assets/tooltip-VnA8Hy0S.js +1 -0
- package/dist-storybook/assets/tooltip.stories-wuthZ3Sv.js +153 -0
- package/dist-storybook/assets/typography-DoV67nnS.js +1 -0
- package/dist-storybook/assets/typography.stories-DD9HLY16.js +202 -0
- package/dist-storybook/assets/uploader.stories-sModULvT.js +65 -0
- package/dist-storybook/assets/use-app-pause-BQYQ2_kc.js +29 -0
- package/dist-storybook/assets/use-app-resume-BHDCAORn.js +29 -0
- package/dist-storybook/assets/use-custom-icon-event-BCGSFwaE.js +29 -0
- package/dist-storybook/assets/use-did-hide-Cosc0Bts.js +48 -0
- package/dist-storybook/assets/use-did-show-CTWe5NYk.js +49 -0
- package/dist-storybook/assets/use-histories-CAcE6nVz.js +50 -0
- package/dist-storybook/assets/use-history-FuEbPpap.js +67 -0
- package/dist-storybook/assets/use-location-CdUC1tic.js +56 -0
- package/dist-storybook/assets/use-navigate-DP9paY1K.js +84 -0
- package/dist-storybook/assets/use-navigation-type-BWVxMUtZ.js +44 -0
- package/dist-storybook/assets/use-page-config-5u8OF-8L.js +48 -0
- package/dist-storybook/assets/use-page-scroll-nPQcBn5B.js +69 -0
- package/dist-storybook/assets/use-page-state-CULl52gw.js +79 -0
- package/dist-storybook/assets/use-settings-changed-2GP5ZsJS.js +29 -0
- package/dist-storybook/assets/v-mini-icon-Dn1BmJzb.woff2 +0 -0
- package/dist-storybook/assets/visibility-sensor-huP-8j4n.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-CLEfhyJc.js";import{U as d}from"./chip-zY6gJxDk.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-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./classname-DoNrELT0.js";import"./icon-TJ3FHxUI.js";import"./colors-_6nFGM3e.js";import"./navigation-bar-CiGSH7u8.js";import"./visibility-sensor-huP-8j4n.js";import"./index-B-Ksafg0.js";import"./store-DxAqU1JB.js";import"./_setToString-CjYxL0rS.js";import"./react-mAVd1wAc.js";import"./omit-CStFhbPt.js";import"./pick-DbIUGM9R.js";import"./button-GtWXUngt.js";import"./typography-DoV67nnS.js";import"./image-D6Yo4ht9.js";import"./bottom-tab-bar-BsPd0FD7.js";import"./toast-provider-B9k1NBG6.js";import"./carousel-sbzGq2WF.js";import"./embla-carousel-react.esm-CCQjHA-d.js";import"./pagination-Dcazh6R_.js";import"./section-content-pkGNuEs6.js";import"./option-item-BloohEvW.js";import"./index-DRIh_SUo.js";import"./alert-abKmNYys.js";import"./skeleton-Dn8rwbgX.js";import"./label-fI1oWVKU.js";import"./input-wrapper-D_9hAdHZ.js";import"./text-field-CjrgfYOZ.js";import"./number-field-DNj4myBV.js";import"./checkbox-CMpJJxvm.js";import"./radio-t2E8E0Oc.js";import"./date-Ci5dIit0.js";import"./date-picker-BCIW_1-h.js";import"./calendar-CJ5_NxYx.js";import"./search-field-CuiHMy7j.js";import"./text-area-CAmJ2yms.js";import"./avatar-B-jvPnzm.js";import"./badge-Cc9u7jBX.js";import"./switch-BziC1t_8.js";import"./tab-bar-DZ3oOU50.js";import"./rating-DsULci27.js";import"./tooltip-VnA8Hy0S.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as t}from"./index-7xlKHfV2.js";import{b as i,M as p}from"./blocks-CpOj9FQ_.js";import{t as o}from"./store-D2RudmNr.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as t}from"./index-7xlKHfV2.js";import{b as i,M as r}from"./blocks-CpOj9FQ_.js";import{t as o}from"./store-D2RudmNr.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as r}from"./index-7xlKHfV2.js";import{b as c,M as s}from"./blocks-CpOj9FQ_.js";import{t}from"./store-D2RudmNr.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as s}from"./index-7xlKHfV2.js";import{b as c}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as c}from"./index-7xlKHfV2.js";import{b as o}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as t}from"./index-7xlKHfV2.js";import{b as o}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as t}from"./index-7xlKHfV2.js";import{b as s}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as s}from"./index-7xlKHfV2.js";import{b as c}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as o}from"./index-7xlKHfV2.js";import{b as s,M as t}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as s}from"./index-7xlKHfV2.js";import{b as r}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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-CLEfhyJc.js";import{useMDXComponents as a}from"./index-7xlKHfV2.js";import{b as t}from"./blocks-CpOj9FQ_.js";import"./preload-helper-PPVm8Dsz.js";import"./index-CaMbLGUB.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};
|