@v-miniapp/ui-react 1.0.41 → 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.
Files changed (137) hide show
  1. package/README.md +1 -1
  2. package/dist/external/index.js +1993 -2004
  3. package/dist/index.js +1011 -1022
  4. package/dist-storybook/assets/ANIMATION-CUdn1GTK.js +99 -0
  5. package/dist-storybook/assets/APP_FRAMEWORK-ljbIOHYd.js +197 -0
  6. package/dist-storybook/assets/BOTTOM_TAB_BAR-DxCwCfBK.js +175 -0
  7. package/dist-storybook/assets/CUSTOM_ERROR_BOUNDARY-B4wTQNZc.js +250 -0
  8. package/dist-storybook/assets/Color-AVL7NMMY-1_8XTICv.js +1 -0
  9. package/dist-storybook/assets/DARK_MODE-CoHseCDO.js +57 -0
  10. package/dist-storybook/assets/DocsRenderer-PQXLIZUC-BO86igwd.js +2 -0
  11. package/dist-storybook/assets/GETTING_STARTED-H_vVi5cv.js +77 -0
  12. package/dist-storybook/assets/INFINITE_SCROLL-BtM3uoX0.js +111 -0
  13. package/dist-storybook/assets/KEEP_ALIVE-CL2au0al.js +126 -0
  14. package/dist-storybook/assets/LOCALE-XTCey55y.js +465 -0
  15. package/dist-storybook/assets/MIGRATION_GUIDE-2LONslE4.js +449 -0
  16. package/dist-storybook/assets/MOBILE_BEHAVIOURS-DZ6alKTX.js +177 -0
  17. package/dist-storybook/assets/PAGE_LAYOUT-BuOpN-1Y.js +192 -0
  18. package/dist-storybook/assets/ROUTING_NAVIGATION-BCPHXNto.js +335 -0
  19. package/dist-storybook/assets/TAILWIND_INTEGRATION-_T-VfvkM.js +87 -0
  20. package/dist-storybook/assets/_setToString-CbM921C9.js +1 -0
  21. package/dist-storybook/assets/alert-DLW8CoyB.js +1 -0
  22. package/dist-storybook/assets/alert.stories-B-vuojPh.js +110 -0
  23. package/dist-storybook/assets/avatar-GxcYPA1p.js +1 -0
  24. package/dist-storybook/assets/avatar.stories-KYFztAc8.js +136 -0
  25. package/dist-storybook/assets/axe-CmvD4WV5.js +20 -0
  26. package/dist-storybook/assets/badge-D_LzMVtw.js +1 -0
  27. package/dist-storybook/assets/badge.stories-Be2ItCmQ.js +262 -0
  28. package/dist-storybook/assets/blocks-BuaOUtiH.js +1243 -0
  29. package/dist-storybook/assets/bottom-tab-bar-CtcTAxuI.js +115 -0
  30. package/dist-storybook/assets/bottom-tab-bar.stories-CDmEve6z.js +186 -0
  31. package/dist-storybook/assets/button-CL7GeC23.js +1 -0
  32. package/dist-storybook/assets/button.stories-CaqLWQiY.js +287 -0
  33. package/dist-storybook/assets/calendar-dOCsjhVU.js +1 -0
  34. package/dist-storybook/assets/calendar.stories-DLWZldet.js +189 -0
  35. package/dist-storybook/assets/carousel-1Kww3hIz.js +37 -0
  36. package/dist-storybook/assets/carousel.stories-B8YbGOOr.js +217 -0
  37. package/dist-storybook/assets/checkbox-MGytNNRt.js +1 -0
  38. package/dist-storybook/assets/checkbox.stories-CLvfZPiw.js +201 -0
  39. package/dist-storybook/assets/chip-kG4p82WT.js +247 -0
  40. package/dist-storybook/assets/chip.stories-BbwJb5eD.js +442 -0
  41. package/dist-storybook/assets/classname-CUR_zgkh.js +1 -0
  42. package/dist-storybook/assets/colors-_6nFGM3e.js +1 -0
  43. package/dist-storybook/assets/date-Cg-Uk_pp.js +1 -0
  44. package/dist-storybook/assets/date-field.stories-Diptwqfv.js +129 -0
  45. package/dist-storybook/assets/date-picker-Dnq_-0Md.js +1 -0
  46. package/dist-storybook/assets/date-picker.stories-BuGWvzFL.js +123 -0
  47. package/dist-storybook/assets/default-error-BcnD8fFO.png +0 -0
  48. package/dist-storybook/assets/dialog.stories-DJ0WsSkA.js +212 -0
  49. package/dist-storybook/assets/dropdown.stories-D6JUYP73.js +200 -0
  50. package/dist-storybook/assets/embla-carousel-react.esm-BYjpaHZ9.js +1 -0
  51. package/dist-storybook/assets/en-Cs9O0XWn.js +15 -0
  52. package/dist-storybook/assets/icon-DdQsMyRa.js +1 -0
  53. package/dist-storybook/assets/icon.stories-B-ZvRzFf.js +365 -0
  54. package/dist-storybook/assets/iframe-CQAwSt4E.js +1071 -0
  55. package/dist-storybook/assets/iframe-yMKl6hJA.css +1 -0
  56. package/dist-storybook/assets/image-C3EsNRhz.js +9 -0
  57. package/dist-storybook/assets/image.stories-C4l8D3ju.js +255 -0
  58. package/dist-storybook/assets/index-B-Ksafg0.js +1 -0
  59. package/dist-storybook/assets/index-BV0AJWP6.js +1 -0
  60. package/dist-storybook/assets/index-CgMRTj-o.js +1 -0
  61. package/dist-storybook/assets/index-DHiZ-gXR.js +1 -0
  62. package/dist-storybook/assets/input-wrapper-BKHgnPy6.js +1 -0
  63. package/dist-storybook/assets/label-DV2iCDmN.js +27 -0
  64. package/dist-storybook/assets/label.stories-BwTIPFXX.js +138 -0
  65. package/dist-storybook/assets/matchers-7Z3WT2CE-Dw4MQV_s.js +14 -0
  66. package/dist-storybook/assets/navigation-bar-vI-FPasP.js +79 -0
  67. package/dist-storybook/assets/navigation-bar.stories-DYuFaJFD.js +73 -0
  68. package/dist-storybook/assets/number-field-CXKmnfKe.js +1 -0
  69. package/dist-storybook/assets/number-field.stories--fn26TJu.js +167 -0
  70. package/dist-storybook/assets/omit-Bsx5nTI0.js +1 -0
  71. package/dist-storybook/assets/option-item-LRh_OyV4.js +1 -0
  72. package/dist-storybook/assets/option-item.stories-snjAvgay.js +66 -0
  73. package/dist-storybook/assets/pagination-DZHoBs_4.js +1 -0
  74. package/dist-storybook/assets/pagination.stories-BoEs0jzS.js +91 -0
  75. package/dist-storybook/assets/pick-BhmhLmLe.js +1 -0
  76. package/dist-storybook/assets/preload-helper-PPVm8Dsz.js +1 -0
  77. package/dist-storybook/assets/radio-B5NJxG_l.js +1 -0
  78. package/dist-storybook/assets/radio.stories-DuN-Awi_.js +183 -0
  79. package/dist-storybook/assets/rating-BdXViYBv.js +1 -0
  80. package/dist-storybook/assets/rating.stories-BCcQjMEx.js +117 -0
  81. package/dist-storybook/assets/react-18-CNyWQ7je.js +9 -0
  82. package/dist-storybook/assets/react-hufnxGVs.js +1 -0
  83. package/dist-storybook/assets/search-field-CQqgFbfg.js +1 -0
  84. package/dist-storybook/assets/search-field.stories-DiCZbhng.js +79 -0
  85. package/dist-storybook/assets/section-content-DGNB4eLN.js +1 -0
  86. package/dist-storybook/assets/section.stories-C2I_kKhu.js +69 -0
  87. package/dist-storybook/assets/sheet.stories-wk1JaKU5.js +152 -0
  88. package/dist-storybook/assets/skeleton-C91JgehG.js +1 -0
  89. package/dist-storybook/assets/skeleton.stories-BCmX-VNr.js +139 -0
  90. package/dist-storybook/assets/store-CPumdfcU.js +1 -0
  91. package/dist-storybook/assets/store-D2RudmNr.js +18 -0
  92. package/dist-storybook/assets/switch-p-aXI-ev.js +1 -0
  93. package/dist-storybook/assets/switch.stories-BqPLNKB9.js +250 -0
  94. package/dist-storybook/assets/tab-bar-CSeCmtIZ.js +31 -0
  95. package/dist-storybook/assets/tab-bar.stories-Cb6v8H2w.js +136 -0
  96. package/dist-storybook/assets/text-area-DwSXyqOe.js +1 -0
  97. package/dist-storybook/assets/text-area.stories-By8bCfgc.js +87 -0
  98. package/dist-storybook/assets/text-field-jK6rpOo2.js +1 -0
  99. package/dist-storybook/assets/text-field.stories-CrWBAhvI.js +92 -0
  100. package/dist-storybook/assets/toast-provider-DurnMJhd.js +9 -0
  101. package/dist-storybook/assets/toast.stories-iWAToAZA.js +201 -0
  102. package/dist-storybook/assets/tooltip-QDdel5My.js +1 -0
  103. package/dist-storybook/assets/tooltip.stories-RC6SuPPD.js +153 -0
  104. package/dist-storybook/assets/typography-DEpAJl_i.js +1 -0
  105. package/dist-storybook/assets/typography.stories-Bu8qFugR.js +202 -0
  106. package/dist-storybook/assets/uploader.stories-B2wW9qVy.js +65 -0
  107. package/dist-storybook/assets/use-app-pause-B_tWHKJK.js +29 -0
  108. package/dist-storybook/assets/use-app-resume--900G-dV.js +29 -0
  109. package/dist-storybook/assets/use-custom-icon-event-3VExRzvC.js +29 -0
  110. package/dist-storybook/assets/use-did-hide-BUsL73ab.js +48 -0
  111. package/dist-storybook/assets/use-did-show-C1-VLDxi.js +49 -0
  112. package/dist-storybook/assets/use-histories-E4E2jJEY.js +50 -0
  113. package/dist-storybook/assets/use-history-o1im8IDj.js +67 -0
  114. package/dist-storybook/assets/use-location-CUEaBO4P.js +56 -0
  115. package/dist-storybook/assets/use-navigate-C4CTuFSZ.js +84 -0
  116. package/dist-storybook/assets/use-navigation-type-Dcz4hgKo.js +44 -0
  117. package/dist-storybook/assets/use-page-config-DSJBVQbq.js +48 -0
  118. package/dist-storybook/assets/use-page-scroll-dY-U1Vv4.js +69 -0
  119. package/dist-storybook/assets/use-page-state-CtNpwGPN.js +79 -0
  120. package/dist-storybook/assets/use-settings-changed-BBJwIHTE.js +29 -0
  121. package/dist-storybook/assets/v-mini-icon-Dn1BmJzb.woff2 +0 -0
  122. package/dist-storybook/assets/visibility-sensor-CwrzJO06.js +1 -0
  123. package/dist-storybook/iframe.html +670 -0
  124. package/dist-storybook/index.html +132 -0
  125. package/dist-storybook/index.json +1 -0
  126. package/dist-storybook/project.json +1 -0
  127. package/dist-storybook/sb-addons/a11y-2/manager-bundle.js +5 -0
  128. package/dist-storybook/sb-addons/docs-1/manager-bundle.js +151 -0
  129. package/dist-storybook/sb-addons/storybook-build-3/manager-bundle.js +3 -0
  130. package/dist-storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +971 -0
  131. package/dist-storybook/sb-manager/globals-module-info.js +799 -0
  132. package/dist-storybook/sb-manager/globals-runtime.js +69791 -0
  133. package/dist-storybook/sb-manager/globals.js +34 -0
  134. package/dist-storybook/sb-manager/runtime.js +13198 -0
  135. package/dist-storybook/stories-data.json +374 -0
  136. package/dist-storybook/vite-inject-mocker-entry.js +2 -0
  137. package/package.json +1 -1
@@ -0,0 +1,192 @@
1
+ import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as t}from"./index-CgMRTj-o.js";import{b as s,M as r}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function o(a){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...t(),...a.components};return n.jsxs(n.Fragment,{children:[`
2
+ `,`
3
+ `,n.jsx(s,{title:"App Framework/Page Layout"}),`
4
+ `,n.jsx(e.h1,{id:"page-layout",children:"Page Layout"}),`
5
+ `,n.jsx(e.p,{children:"Page Layout config cho phép bạn cấu hình layout cho các pages với các thuộc tính như spacing, safe area offsets, pull-to-refresh, và scroll restoration."}),`
6
+ `,n.jsx(e.h2,{id:"cấu-trúc",children:"Cấu trúc"}),`
7
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`type IAppPageLayoutState = IPageBaseProps & {
8
+ hidden?: boolean
9
+ scrollRestoration?: boolean
10
+ }
11
+
12
+ type IPageBaseProps = {
13
+ hasSpacing?: boolean
14
+ headerOffset?: boolean
15
+ safeAreaTopOffset?: boolean
16
+ safeAreaBottomOffset?: boolean
17
+ contentClassName?: string
18
+ pullToRefresh?: IPullToRefreshBasProps
19
+ onEndReached?: () => void
20
+ onEndReachedThreshold?: number
21
+ id?: string
22
+ className?: string
23
+ style?: React.CSSProperties
24
+ }
25
+ `})}),`
26
+ `,n.jsx(e.h2,{id:"thuộc-tính",children:"Thuộc tính"}),`
27
+ `,n.jsx(r,{children:"\n| Thuộc tính | Kiểu dữ liệu | Mặc định | Mô tả |\n| :--- | :--- | :--- | :--- |\n| `hidden` | `boolean` | `false` | Không render page layout wrapper (chỉ render children trực tiếp) |\n| `scrollRestoration` | `boolean` | `true` | Giữ scroll position khi navigate (kết hợp với keep-alive) |\n| `hasSpacing` | `boolean` | `true` | Thêm padding cho content |\n| `headerOffset` | `boolean` | `false` | Thêm offset cho header |\n| `safeAreaTopOffset` | `boolean` | `true` | Thêm safe area top inset padding |\n| `safeAreaBottomOffset` | `boolean` | `true` | Thêm safe area bottom inset padding |\n| `contentClassName` | `string` | - | CSS class name cho content wrapper |\n| `pullToRefresh` | `IPullToRefreshBasProps` | - | Cấu hình pull-to-refresh |\n| `onEndReached` | `() => void` | - | Callback khi scroll đến cuối page |\n| `onEndReachedThreshold` | `number` | `50` | Khoảng cách (px) từ cuối để trigger `onEndReached` |\n| `className` | `string` | - | CSS class name cho page wrapper |\n| `style` | `React.CSSProperties` | - | Inline styles cho page wrapper |\n| `id` | `string` | - | HTML id cho page wrapper |\n"}),`
28
+ `,n.jsx(e.h2,{id:"cách-hoạt-động",children:"Cách hoạt động"}),`
29
+ `,n.jsxs(e.ol,{children:[`
30
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Page Layout Wrapper"}),": Mỗi page được wrap bởi ",n.jsx(e.code,{children:"PageLayout"})," component, cung cấp các tính năng như safe area, spacing, và scroll restoration"]}),`
31
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Scroll Restoration"}),": Khi ",n.jsx(e.code,{children:"scrollRestoration: true"})," và keep-alive enabled, scroll position sẽ được giữ khi navigate back/forward"]}),`
32
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Safe Area"}),": Tự động thêm padding cho safe area top/bottom (quan trọng trên iOS với notch)"]}),`
33
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Hidden"}),": Khi ",n.jsx(e.code,{children:"hidden: true"}),", page layout wrapper sẽ không render, chỉ render children trực tiếp"]}),`
34
+ `]}),`
35
+ `,n.jsx(e.h2,{id:"cấu-hình",children:"Cấu hình"}),`
36
+ `,n.jsx(e.h3,{id:"app-level-config",children:"App-level Config"}),`
37
+ `,n.jsx(e.p,{children:"Cấu hình page layout mặc định cho tất cả pages:"}),`
38
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
39
+ pageLayout: {
40
+ hasSpacing: true,
41
+ safeAreaTopOffset: true,
42
+ safeAreaBottomOffset: true,
43
+ scrollRestoration: true,
44
+ contentClassName: 'p-4',
45
+ },
46
+ pages: [
47
+ // Tất cả pages sẽ dùng config này
48
+ ],
49
+ }
50
+ `})}),`
51
+ `,n.jsx(e.h3,{id:"page-level-config",children:"Page-level Config"}),`
52
+ `,n.jsx(e.p,{children:"Override page layout cho từng page:"}),`
53
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
54
+ pageLayout: {
55
+ hasSpacing: true,
56
+ scrollRestoration: true,
57
+ },
58
+ pages: [
59
+ {
60
+ pathname: '/home',
61
+ Component: HomePage,
62
+ // Page này dùng app-level config
63
+ },
64
+ {
65
+ pathname: '/detail',
66
+ Component: DetailPage,
67
+ // Override page layout cho page này
68
+ pageLayout: {
69
+ hasSpacing: false, // Không có spacing
70
+ contentClassName: 'p-0', // Không có padding
71
+ scrollRestoration: false, // Reset scroll khi vào page này
72
+ },
73
+ },
74
+ {
75
+ pathname: '/fullscreen',
76
+ Component: FullscreenPage,
77
+ // Ẩn page layout wrapper
78
+ pageLayout: {
79
+ hidden: true, // Không wrap với PageLayout
80
+ },
81
+ },
82
+ ],
83
+ }
84
+ `})}),`
85
+ `,n.jsx(e.h2,{id:"ví-dụ-với-pull-to-refresh",children:"Ví dụ với Pull-to-Refresh"}),`
86
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
87
+ pageLayout: {
88
+ pullToRefresh: {
89
+ onRefresh: async () => {
90
+ // Refresh data
91
+ await fetchData()
92
+ },
93
+ pullingText: 'Kéo xuống để làm mới',
94
+ canReleaseText: 'Thả ra để làm mới',
95
+ refreshingText: 'Đang làm mới...',
96
+ completeText: 'Hoàn thành',
97
+ },
98
+ },
99
+ pages: [
100
+ {
101
+ pathname: '/home',
102
+ Component: HomePage,
103
+ },
104
+ ],
105
+ }
106
+ `})}),`
107
+ `,n.jsx(e.h2,{id:"ví-dụ-với-infinite-scroll",children:"Ví dụ với Infinite Scroll"}),`
108
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
109
+ pageLayout: {
110
+ onEndReached: () => {
111
+ // Load more data
112
+ loadMore()
113
+ },
114
+ onEndReachedThreshold: 100, // Trigger khi còn 100px từ cuối
115
+ },
116
+ pages: [
117
+ {
118
+ pathname: '/list',
119
+ Component: ListPage,
120
+ },
121
+ ],
122
+ }
123
+ `})}),`
124
+ `,n.jsx(e.h2,{id:"ví-dụ-với-custom-styling",children:"Ví dụ với Custom Styling"}),`
125
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
126
+ pageLayout: {
127
+ contentClassName: 'bg-gray-50 min-h-screen',
128
+ className: 'custom-page-wrapper',
129
+ style: {
130
+ backgroundColor: '#f5f5f5',
131
+ },
132
+ },
133
+ pages: [
134
+ {
135
+ pathname: '/home',
136
+ Component: HomePage,
137
+ // Override với custom styling
138
+ pageLayout: {
139
+ contentClassName: 'bg-white p-6',
140
+ },
141
+ },
142
+ ],
143
+ }
144
+ `})}),`
145
+ `,n.jsx(e.h2,{id:"scroll-restoration-với-keep-alive",children:"Scroll Restoration với Keep-Alive"}),`
146
+ `,n.jsx(e.p,{children:"Khi kết hợp với keep-alive, scroll restoration sẽ giữ scroll position:"}),`
147
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
148
+ keepAlive: {
149
+ enable: true,
150
+ },
151
+ pageLayout: {
152
+ scrollRestoration: true, // Giữ scroll position
153
+ },
154
+ pages: [
155
+ {
156
+ pathname: '/list',
157
+ Component: ListPage,
158
+ // Khi navigate back, scroll position sẽ được giữ
159
+ },
160
+ ],
161
+ }
162
+ `})}),`
163
+ `,n.jsx(e.h2,{id:"safe-area-offsets",children:"Safe Area Offsets"}),`
164
+ `,n.jsx(e.p,{children:"Safe area offsets tự động điều chỉnh dựa trên navigation bar và bottom tab bar:"}),`
165
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const appConfig: IAppConfig = {
166
+ navigationBar: {
167
+ hidden: false, // Navigation bar hiển thị
168
+ },
169
+ bottomTabBar: {
170
+ items: [{ id: 'home', name: 'Home', path: '/home' }],
171
+ },
172
+ pageLayout: {
173
+ // safeAreaTopOffset tự động = true khi navigationBar.hidden = false
174
+ // safeAreaBottomOffset tự động = false khi bottomTabBar hiển thị
175
+ },
176
+ pages: [
177
+ {
178
+ pathname: '/home',
179
+ Component: HomePage,
180
+ bottomTabBarId: 'home',
181
+ },
182
+ ],
183
+ }
184
+ `})}),`
185
+ `,n.jsx(e.h2,{id:"lưu-ý",children:"Lưu ý"}),`
186
+ `,n.jsxs(e.ul,{children:[`
187
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Scroll Restoration"}),": Chỉ hoạt động tốt khi kết hợp với keep-alive. Khi ",n.jsx(e.code,{children:"scrollRestoration: false"}),", scroll sẽ reset về top khi navigate"]}),`
188
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Safe Area"}),": Safe area offsets tự động điều chỉnh dựa trên navigation bar và bottom tab bar visibility"]}),`
189
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Hidden"}),": Khi ",n.jsx(e.code,{children:"hidden: true"}),", tất cả các tính năng của page layout (safe area, spacing, scroll restoration) sẽ không hoạt động"]}),`
190
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Content ClassName"}),": ",n.jsx(e.code,{children:"contentClassName"})," được áp dụng cho content wrapper bên trong page, không phải page wrapper"]}),`
191
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Pull-to-Refresh"}),": Pull-to-refresh chỉ hoạt động khi page có thể scroll"]}),`
192
+ `]})]})}function g(a={}){const{wrapper:e}={...t(),...a.components};return e?n.jsx(e,{...a,children:n.jsx(o,{...a})}):o(a)}export{g as default};
@@ -0,0 +1,335 @@
1
+ import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as c}from"./index-CgMRTj-o.js";import{b as r,M as o}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function s(i){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",hr:"hr",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...c(),...i.components};return n.jsxs(n.Fragment,{children:[`
2
+ `,`
3
+ `,n.jsx(r,{title:"App Framework/Routing & Navigation"}),`
4
+ `,n.jsx(e.h1,{id:"routing--navigation",children:"Routing & Navigation"}),`
5
+ `,n.jsxs(e.p,{children:["Hệ thống routing và navigation của ",n.jsx(e.code,{children:"App"})," framework cung cấp các hooks và utilities để quản lý navigation, truy cập thông tin page, và xử lý các lifecycle events."]}),`
6
+ `,n.jsx(e.h2,{id:"routing",children:"Routing"}),`
7
+ `,n.jsxs(e.p,{children:["Hệ thống routing sử dụng ",n.jsx(e.strong,{children:"exact path matching"})," - mỗi page được định nghĩa với một ",n.jsx(e.code,{children:"pathname"})," cụ thể và chỉ match khi pathname khớp chính xác."]}),`
8
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Lưu ý:"})}),`
9
+ `,n.jsxs(e.ul,{children:[`
10
+ `,n.jsxs(e.li,{children:["Không hỗ trợ dynamic pathname như ",n.jsx(e.code,{children:"/:id"})," hoặc nested routes"]}),`
11
+ `,n.jsxs(e.li,{children:["Hỗ trợ query parameters thông qua ",n.jsx(e.code,{children:"params"})," trong navigate options"]}),`
12
+ `,n.jsx(e.li,{children:"Sử dụng browser history API để quản lý navigation stack"}),`
13
+ `]}),`
14
+ `,n.jsx(e.h2,{id:"navigation",children:"Navigation"}),`
15
+ `,n.jsxs(e.p,{children:["Navigation được thực hiện thông qua function ",n.jsx(e.code,{children:"navigate"})," từ hook ",n.jsx(e.code,{children:"useNavigate()"}),". Có 2 cách navigate:"]}),`
16
+ `,n.jsxs(e.ol,{children:[`
17
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Navigate bằng pathname"}),": ",n.jsx(e.code,{children:"navigate('/pathname', options)"})]}),`
18
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"Navigate bằng delta"}),": ",n.jsx(e.code,{children:"navigate(delta)"})," - điều hướng trong history stack (back/forward)"]}),`
19
+ `]}),`
20
+ `,n.jsx(e.h2,{id:"hooks",children:"Hooks"}),`
21
+ `,n.jsx(e.h3,{id:"usenavigate",children:"useNavigate"}),`
22
+ `,n.jsxs(e.p,{children:["Hook để lấy function ",n.jsx(e.code,{children:"navigate"})," để điều hướng giữa các pages."]}),`
23
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
24
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useNavigate } from '@v-miniapp/ui-react'
25
+ `})}),`
26
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
27
+ `,n.jsxs(e.ul,{children:[`
28
+ `,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"}),":",`
29
+ `,n.jsxs(e.ul,{children:[`
30
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"navigate(pathname: string, options?: INavigatePathnameOptions): void"})," - Navigate bằng pathname"]}),`
31
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"navigate(delta: number, options?: INavigateDeltaOptions): void"})," - Navigate bằng delta (back/forward)"]}),`
32
+ `]}),`
33
+ `]}),`
34
+ `]}),`
35
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
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 đến page khác
43
+ navigate('/settings', {
44
+ params: { id: '123' },
45
+ state: { from: 'home' },
46
+ replace: false, // true để replace thay vì push
47
+ })
48
+ }
49
+
50
+ const handleBack = () => {
51
+ // Navigate back
52
+ navigate(-1)
53
+ }
54
+
55
+ return <button onClick={handleClick}>Go to Settings</button>
56
+ }
57
+ `})}),`
58
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usenavigate--docs",children:"useNavigate Hook"})]}),`
59
+ `,n.jsx(e.hr,{}),`
60
+ `,n.jsx(e.h3,{id:"usehistory",children:"useHistory"}),`
61
+ `,n.jsx(e.p,{children:"Hook để lấy history entry hiện tại của page."}),`
62
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
63
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useHistory } from '@v-miniapp/ui-react'
64
+ `})}),`
65
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
66
+ `,n.jsxs(e.ul,{children:[`
67
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"history"}),": ",n.jsx(e.code,{children:"IHistory"})," object chứa:",`
68
+ `,n.jsxs(e.ul,{children:[`
69
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"action"}),": ",n.jsx(e.code,{children:"'PUSH' | 'REPLACE' | 'POP'"})]}),`
70
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"location"}),": ",n.jsx(e.code,{children:"ILocation"})," object chứa ",n.jsx(e.code,{children:"key"}),", ",n.jsx(e.code,{children:"pathname"}),", ",n.jsx(e.code,{children:"params?"}),", ",n.jsx(e.code,{children:"state?"})]}),`
71
+ `]}),`
72
+ `]}),`
73
+ `]}),`
74
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
75
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useHistory } from '@v-miniapp/ui-react'
76
+
77
+ const MyPage = () => {
78
+ const history = useHistory()
79
+
80
+ console.log(history.location.pathname) // '/home'
81
+ console.log(history.location.params) // { id: '123' }
82
+ console.log(history.action) // 'PUSH' | 'REPLACE' | 'POP'
83
+
84
+ return <div>Current path: {history.location.pathname}</div>
85
+ }
86
+ `})}),`
87
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usehistory--docs",children:"useHistory Hook"})]}),`
88
+ `,n.jsx(e.hr,{}),`
89
+ `,n.jsx(e.h3,{id:"usehistories",children:"useHistories"}),`
90
+ `,n.jsx(e.p,{children:"Hook để lấy toàn bộ history stack."}),`
91
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
92
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useHistories } from '@v-miniapp/ui-react'
93
+ `})}),`
94
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
95
+ `,n.jsxs(e.ul,{children:[`
96
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"histories"}),": ",n.jsx(e.code,{children:"IHistory[]"})," - Mảng các history entries"]}),`
97
+ `]}),`
98
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
99
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useHistories } from '@v-miniapp/ui-react'
100
+
101
+ const MyPage = () => {
102
+ const histories = useHistories()
103
+
104
+ console.log(histories.length) // Số lượng pages trong stack
105
+
106
+ return <div>History stack length: {histories.length}</div>
107
+ }
108
+ `})}),`
109
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usehistories--docs",children:"useHistories Hook"})]}),`
110
+ `,n.jsx(e.hr,{}),`
111
+ `,n.jsx(e.h3,{id:"uselocation",children:"useLocation"}),`
112
+ `,n.jsx(e.p,{children:"Hook để lấy location object hiện tại (pathname, params, state, key)."}),`
113
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
114
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useLocation } from '@v-miniapp/ui-react'
115
+ `})}),`
116
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
117
+ `,n.jsxs(e.ul,{children:[`
118
+ `,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:",`
119
+ `,n.jsxs(e.ul,{children:[`
120
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"key"}),": ",n.jsx(e.code,{children:"string"})]}),`
121
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"pathname"}),": ",n.jsx(e.code,{children:"string"})]}),`
122
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"params?"}),": ",n.jsx(e.code,{children:"Record<string, string>"})]}),`
123
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"state?"}),": ",n.jsx(e.code,{children:"any"})]}),`
124
+ `]}),`
125
+ `]}),`
126
+ `]}),`
127
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
128
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useLocation } from '@v-miniapp/ui-react'
129
+
130
+ const MyPage = () => {
131
+ const location = useLocation()
132
+
133
+ console.log(location.pathname) // '/home'
134
+ console.log(location.params) // { id: '123' }
135
+ console.log(location.state) // { from: 'home' }
136
+ console.log(location.key) // Unique key cho location này
137
+
138
+ return <div>Path: {location.pathname}</div>
139
+ }
140
+ `})}),`
141
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-uselocation--docs",children:"useLocation Hook"})]}),`
142
+ `,n.jsx(e.hr,{}),`
143
+ `,n.jsx(e.h3,{id:"usepageconfig",children:"usePageConfig"}),`
144
+ `,n.jsx(e.p,{children:"Hook để lấy config của page hiện tại."}),`
145
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
146
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { usePageConfig } from '@v-miniapp/ui-react'
147
+ `})}),`
148
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
149
+ `,n.jsxs(e.ul,{children:[`
150
+ `,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"})]}),`
151
+ `]}),`
152
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
153
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { usePageConfig } from '@v-miniapp/ui-react'
154
+
155
+ const MyPage = () => {
156
+ const pageConfig = usePageConfig()
157
+
158
+ if (!pageConfig) return null
159
+
160
+ console.log(pageConfig.pathname) // '/home'
161
+ console.log(pageConfig.Component) // Component của page
162
+ console.log(pageConfig.navigationBar) // Navigation bar config
163
+
164
+ return <div>Page: {pageConfig.pathname}</div>
165
+ }
166
+ `})}),`
167
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usepageconfig--docs",children:"usePageConfig Hook"})]}),`
168
+ `,n.jsx(e.hr,{}),`
169
+ `,n.jsx(e.h3,{id:"usenavigationtype",children:"useNavigationType"}),`
170
+ `,n.jsx(e.p,{children:"Hook để lấy navigation action type (PUSH, REPLACE, POP)."}),`
171
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
172
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useNavigationType } from '@v-miniapp/ui-react'
173
+ `})}),`
174
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
175
+ `,n.jsxs(e.ul,{children:[`
176
+ `,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"})]}),`
177
+ `]}),`
178
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
179
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useNavigationType } from '@v-miniapp/ui-react'
180
+
181
+ const MyPage = () => {
182
+ const action = useNavigationType()
183
+
184
+ console.log(action) // 'PUSH' | 'REPLACE' | 'POP'
185
+
186
+ return <div>Navigation type: {action}</div>
187
+ }
188
+ `})}),`
189
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usenavigationtype--docs",children:"useNavigationType Hook"})]}),`
190
+ `,n.jsx(e.hr,{}),`
191
+ `,n.jsx(e.h3,{id:"usedidshow",children:"useDidShow"}),`
192
+ `,n.jsx(e.p,{children:"Hook để xử lý khi page được hiển thị (show)."}),`
193
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
194
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useDidShow } from '@v-miniapp/ui-react'
195
+ `})}),`
196
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Parameters:"})}),`
197
+ `,n.jsxs(e.ul,{children:[`
198
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"func?: () => void"}),": Callback function được gọi khi page show"]}),`
199
+ `]}),`
200
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
201
+ `,n.jsxs(e.ul,{children:[`
202
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"didShow"}),": Boolean cho biết page có đang được hiển thị không"]}),`
203
+ `]}),`
204
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
205
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useDidShow } from '@v-miniapp/ui-react'
206
+
207
+ const MyPage = () => {
208
+ const didShow = useDidShow(() => {
209
+ console.log('Page is shown')
210
+ // Fetch data, track analytics, etc.
211
+ })
212
+
213
+ return <div>Page is {didShow ? 'visible' : 'hidden'}</div>
214
+ }
215
+ `})}),`
216
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usedidshow--docs",children:"useDidShow Hook"})]}),`
217
+ `,n.jsx(e.hr,{}),`
218
+ `,n.jsx(e.h3,{id:"usedidhide",children:"useDidHide"}),`
219
+ `,n.jsx(e.p,{children:"Hook để xử lý khi page bị ẩn (hide)."}),`
220
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
221
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { useDidHide } from '@v-miniapp/ui-react'
222
+ `})}),`
223
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Parameters:"})}),`
224
+ `,n.jsxs(e.ul,{children:[`
225
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"func?: () => void"}),": Callback function được gọi khi page hide"]}),`
226
+ `]}),`
227
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
228
+ `,n.jsxs(e.ul,{children:[`
229
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"didHide"}),": Boolean cho biết page có đang bị ẩn không"]}),`
230
+ `]}),`
231
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
232
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { useDidHide } from '@v-miniapp/ui-react'
233
+
234
+ const MyPage = () => {
235
+ const didHide = useDidHide(() => {
236
+ console.log('Page is hidden')
237
+ // Cleanup, pause timers, etc.
238
+ })
239
+
240
+ return <div>Page is {didHide ? 'hidden' : 'visible'}</div>
241
+ }
242
+ `})}),`
243
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usedidhide--docs",children:"useDidHide Hook"})]}),`
244
+ `,n.jsx(e.hr,{}),`
245
+ `,n.jsx(e.h3,{id:"usepagescroll",children:"usePageScroll"}),`
246
+ `,n.jsx(e.p,{children:"Hook để lắng nghe sự kiện scroll của page."}),`
247
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
248
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { usePageScroll } from '@v-miniapp/ui-react'
249
+ `})}),`
250
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Parameters:"})}),`
251
+ `,n.jsxs(e.ul,{children:[`
252
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"callback: (target: HTMLDivElement, event: Event) => void"}),": Callback được gọi khi scroll"]}),`
253
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"options?: IUsePageScrollOptions"}),": Options cho throttle"]}),`
254
+ `]}),`
255
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
256
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { usePageScroll } from '@v-miniapp/ui-react'
257
+
258
+ const MyPage = () => {
259
+ usePageScroll((target, event) => {
260
+ console.log('Scroll position:', target.scrollTop)
261
+ // Handle scroll event
262
+ }, {
263
+ throttle: {
264
+ wait: 200, // Throttle 200ms
265
+ }
266
+ })
267
+
268
+ return <div>Scroll me</div>
269
+ }
270
+ `})}),`
271
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usepagescroll--docs",children:"usePageScroll Hook"})]}),`
272
+ `,n.jsx(e.hr,{}),`
273
+ `,n.jsx(e.h3,{id:"usepagestate",children:"usePageState"}),`
274
+ `,n.jsx(e.p,{children:"Hook để quản lý state của page hiện tại."}),`
275
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Import:"})}),`
276
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-typescript",children:`import { usePageState } from '@v-miniapp/ui-react'
277
+ `})}),`
278
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Returns:"})}),`
279
+ `,n.jsxs(e.ul,{children:[`
280
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"pageState"}),": ",n.jsx(e.code,{children:"IPageState"})," của page hiện tại hoặc ",n.jsx(e.code,{children:"undefined"})]}),`
281
+ `,n.jsxs(e.li,{children:[n.jsx(e.code,{children:"setPageState"}),": ",n.jsx(e.code,{children:"Dispatch<SetStateAction<IPageState | undefined>>"})," - Function để update page state"]}),`
282
+ `]}),`
283
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Cách sử dụng:"})}),`
284
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`import { usePageState } from '@v-miniapp/ui-react'
285
+
286
+ const MyPage = () => {
287
+ const { pageState, setPageState } = usePageState()
288
+
289
+ const updateNavigationBar = () => {
290
+ setPageState({
291
+ navigationBar: {
292
+ title: 'New Title',
293
+ },
294
+ })
295
+ }
296
+
297
+ return <button onClick={updateNavigationBar}>Update Title</button>
298
+ }
299
+ `})}),`
300
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Xem chi tiết:"})," ",n.jsx(e.a,{href:"?path=/docs/hooks-usepagestate--docs",children:"usePageState Hook"})]}),`
301
+ `,n.jsx(e.hr,{}),`
302
+ `,n.jsx(e.h2,{id:"navigate-options",children:"Navigate Options"}),`
303
+ `,n.jsxs(e.p,{children:["Khi sử dụng ",n.jsx(e.code,{children:"navigate(pathname, options)"}),", bạn có thể truyền các options sau:"]}),`
304
+ `,n.jsx(o,{children:"\n| Option | Type | Mô tả |\n| :--- | :--- | :--- |\n| `params` | `Record&lt;string, string&gt;` | 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| `replace` | `boolean` | Nếu `true`, replace history entry thay vì push mới |\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"}),`
305
+ `,n.jsxs(e.p,{children:[n.jsx(e.strong,{children:"Lưu ý:"})," ",n.jsx(e.code,{children:"INavigatePathnameOptions"})," extends ",n.jsx(e.code,{children:"IPageState"}),", nên bạn có thể truyền các page-level config trong navigate options để override config cho page mới."]}),`
306
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Ví dụ:"})}),`
307
+ `,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const navigate = useNavigate()
308
+
309
+ // Navigate với params và state
310
+ navigate('/detail', {
311
+ params: { id: '123' }, // ?id=123
312
+ state: { from: 'home' }, // Không hiển thị trong URL
313
+ replace: false, // Push vào history stack
314
+ })
315
+
316
+ // Navigate back
317
+ navigate(-1) // Quay lại 1 page
318
+
319
+ // Navigate forward
320
+ navigate(1) // Tiến tới 1 page
321
+ `})}),`
322
+ `,n.jsx(e.hr,{}),`
323
+ `,n.jsx(e.h2,{id:"lifecycle-events",children:"Lifecycle Events"}),`
324
+ `,n.jsx(e.p,{children:"Khi navigate giữa các pages, các lifecycle events được trigger:"}),`
325
+ `,n.jsxs(e.ol,{children:[`
326
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"beforeLocationChangeP1"}),": Trigger trước khi location thay đổi (phase 1)"]}),`
327
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"beforeLocationChangeP2"}),": Trigger trước khi location thay đổi (phase 2)"]}),`
328
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"useDidShow"}),": Trigger khi page được hiển thị"]}),`
329
+ `,n.jsxs(e.li,{children:[n.jsx(e.strong,{children:"useDidHide"}),": Trigger khi page bị ẩn"]}),`
330
+ `]}),`
331
+ `,n.jsx(e.p,{children:n.jsx(e.strong,{children:"Thứ tự:"})}),`
332
+ `,n.jsxs(e.ul,{children:[`
333
+ `,n.jsxs(e.li,{children:["Page A hide → ",n.jsx(e.code,{children:"useDidHide"})," của Page A"]}),`
334
+ `,n.jsxs(e.li,{children:["Page B show → ",n.jsx(e.code,{children:"useDidShow"})," của Page B"]}),`
335
+ `]})]})}function g(i={}){const{wrapper:e}={...c(),...i.components};return e?n.jsx(e,{...i,children:n.jsx(s,{...i})}):s(i)}export{g as default};
@@ -0,0 +1,87 @@
1
+ import{j as n}from"./iframe-CQAwSt4E.js";import{useMDXComponents as c}from"./index-CgMRTj-o.js";import{b as t}from"./blocks-BuaOUtiH.js";import"./preload-helper-PPVm8Dsz.js";import"./index-DHiZ-gXR.js";function e(s){const i={code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...c(),...s.components};return n.jsxs(n.Fragment,{children:[`
2
+ `,`
3
+ `,n.jsx(t,{title:"Use Cases/Tailwind Integration"}),`
4
+ `,n.jsx(i.h1,{id:"tích-hợp-với-tailwind-css",children:"Tích hợp với Tailwind CSS"}),`
5
+ `,n.jsxs(i.p,{children:["Khi sử dụng Tailwind CSS, bạn có thể tích hợp với ",n.jsx(i.code,{children:"@v-miniapp/ui-react"})," để tránh conflict và sử dụng chung design tokens."]}),`
6
+ `,n.jsx(i.h2,{id:"import-tailwind-integration",children:"Import Tailwind Integration"}),`
7
+ `,n.jsxs(i.p,{children:["Thêm import vào file CSS chính của bạn (thường là ",n.jsx(i.code,{children:"tailwind.css"})," hoặc ",n.jsx(i.code,{children:"index.css"}),"):"]}),`
8
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-css",children:`/* tailwind.css hoặc file CSS chính */
9
+ @import '@v-miniapp/ui-react/tailwind';
10
+ `})}),`
11
+ `,n.jsxs(i.p,{children:[n.jsx(i.strong,{children:"Lưu ý quan trọng:"})," Khi sử dụng Tailwind integration, bạn ",n.jsx(i.strong,{children:"không cần"})," import ",n.jsx(i.code,{children:"@v-miniapp/ui-react/styles.css"})," nữa."]}),`
12
+ `,n.jsx(i.h2,{id:"design-tokens",children:"Design Tokens"}),`
13
+ `,n.jsxs(i.p,{children:["Khi tích hợp với Tailwind, bạn có thể sử dụng các design tokens từ ",n.jsx(i.code,{children:"@v-miniapp/ui-react"}),":"]}),`
14
+ `,n.jsx(i.h3,{id:"colors",children:"Colors"}),`
15
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-tsx",children:`// Sử dụng color tokens trong Tailwind
16
+ <div className="bg-alias-layer-01 text-alias-text-primary">
17
+ Content
18
+ </div>
19
+ `})}),`
20
+ `,n.jsx(i.p,{children:"Các color tokens có sẵn:"}),`
21
+ `,n.jsxs(i.ul,{children:[`
22
+ `,n.jsxs(i.li,{children:[n.jsx(i.code,{children:"alias-layer-*"})," - Layer colors (background)"]}),`
23
+ `,n.jsxs(i.li,{children:[n.jsx(i.code,{children:"alias-text-*"})," - Text colors"]}),`
24
+ `,n.jsxs(i.li,{children:[n.jsx(i.code,{children:"alias-object-*"})," - Object colors (buttons, badges, etc.)"]}),`
25
+ `,n.jsxs(i.li,{children:[n.jsx(i.code,{children:"alias-border-*"})," - Border colors"]}),`
26
+ `]}),`
27
+ `,n.jsx(i.h3,{id:"spacing--sizing",children:"Spacing & Sizing"}),`
28
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-tsx",children:`// Sử dụng spacing tokens
29
+ <div className="p-4 m-2">
30
+ Content
31
+ </div>
32
+ `})}),`
33
+ `,n.jsx(i.h3,{id:"typography",children:"Typography"}),`
34
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-tsx",children:`// Sử dụng typography tokens
35
+ <h1 className="text-base font-medium">
36
+ Title
37
+ </h1>
38
+ `})}),`
39
+ `,n.jsx(i.h2,{id:"tránh-conflict",children:"Tránh Conflict"}),`
40
+ `,n.jsx(i.p,{children:"Khi tích hợp với Tailwind:"}),`
41
+ `,n.jsxs(i.ol,{children:[`
42
+ `,n.jsxs(i.li,{children:[n.jsx(i.strong,{children:"CSS Variables"}),": ",n.jsx(i.code,{children:"@v-miniapp/ui-react"})," sử dụng CSS variables để tránh conflict với Tailwind utilities"]}),`
43
+ `,n.jsxs(i.li,{children:[n.jsx(i.strong,{children:"Prefix"}),": Các class của ",n.jsx(i.code,{children:"@v-miniapp/ui-react"})," có prefix riêng (ví dụ: ",n.jsx(i.code,{children:"vsf-*"}),") để tránh conflict"]}),`
44
+ `,n.jsxs(i.li,{children:[n.jsx(i.strong,{children:"Tokens"}),": Sử dụng design tokens thay vì hardcode values để đảm bảo consistency"]}),`
45
+ `]}),`
46
+ `,n.jsx(i.h2,{id:"ví-dụ-hoàn-chỉnh",children:"Ví dụ hoàn chỉnh"}),`
47
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-tsx",children:`// tailwind.config.js
48
+ module.exports = {
49
+ content: [
50
+ './src/**/*.{js,jsx,ts,tsx}',
51
+ './node_modules/@v-miniapp/ui-react/dist/**/*.{js,jsx,ts,tsx}',
52
+ ],
53
+ theme: {
54
+ extend: {
55
+ // Extend với tokens từ @v-miniapp/ui-react nếu cần
56
+ },
57
+ },
58
+ plugins: [],
59
+ }
60
+ `})}),`
61
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-css",children:`/* tailwind.css */
62
+ @tailwind base;
63
+ @tailwind components;
64
+ @tailwind utilities;
65
+
66
+ /* Import Tailwind integration từ @v-miniapp/ui-react */
67
+ @import '@v-miniapp/ui-react/tailwind';
68
+ `})}),`
69
+ `,n.jsx(i.pre,{children:n.jsx(i.code,{className:"language-tsx",children:`// App.tsx
70
+ import { App } from '@v-miniapp/ui-react'
71
+ // KHÔNG import styles.css khi dùng Tailwind integration
72
+ // import '@v-miniapp/ui-react/styles.css' // ❌ Không cần
73
+
74
+ const appConfig: IAppConfig = {
75
+ // ...
76
+ }
77
+
78
+ export const MiniApp: FC = () => {
79
+ return <App config={appConfig} />
80
+ }
81
+ `})}),`
82
+ `,n.jsx(i.h2,{id:"lưu-ý",children:"Lưu ý"}),`
83
+ `,n.jsxs(i.ul,{children:[`
84
+ `,n.jsxs(i.li,{children:["Chỉ sử dụng ",n.jsx(i.strong,{children:"một trong hai"}),": ",n.jsx(i.code,{children:"styles.css"})," HOẶC ",n.jsx(i.code,{children:"tailwind"})," integration, không dùng cả hai"]}),`
85
+ `,n.jsxs(i.li,{children:["Đảm bảo import ",n.jsx(i.code,{children:"@v-miniapp/ui-react/tailwind"})," ",n.jsx(i.strong,{children:"sau"})," các Tailwind directives (",n.jsx(i.code,{children:"@tailwind base"}),", etc.)"]}),`
86
+ `,n.jsx(i.li,{children:"Các design tokens được expose qua CSS variables, có thể sử dụng trong Tailwind config nếu cần"}),`
87
+ `]})]})}function h(s={}){const{wrapper:i}={...c(),...s.components};return i?n.jsx(i,{...s,children:n.jsx(e,{...s})}):e(s)}export{h as default};