@bifrostui/react 2.0.0-alpha.2 → 2.0.0-alpha.20

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 (484) hide show
  1. package/dist/ActionSheet/ActionSheet.d.ts +1 -1
  2. package/dist/ActionSheet/ActionSheet.js +8 -8
  3. package/dist/ActionSheet/ActionSheet.types.d.ts +1 -1
  4. package/dist/ActionSheet/ActionSheetContext.d.ts +1 -1
  5. package/dist/ActionSheet/ActionSheetContext.js +2 -2
  6. package/dist/ActionSheet/ActionSheetItem.types.d.ts +1 -1
  7. package/dist/Alert/Alert.d.ts +1 -1
  8. package/dist/Alert/Alert.js +16 -16
  9. package/dist/Alert/__tests__/fixtures/A11yDemos.d.ts +1 -1
  10. package/dist/Alert/__tests__/fixtures/A11yDemos.js +12 -12
  11. package/dist/Avatar/Avatar.d.ts +1 -1
  12. package/dist/Avatar/Avatar.js +5 -5
  13. package/dist/Avatar/Avatar.types.d.ts +1 -1
  14. package/dist/Avatar/AvatarGroup.types.d.ts +1 -1
  15. package/dist/Backdrop/Backdrop.d.ts +1 -1
  16. package/dist/Backdrop/Backdrop.js +3 -3
  17. package/dist/Backdrop/Backdrop.types.d.ts +1 -1
  18. package/dist/Backdrop/__tests__/fixtures/A11yDemos.d.ts +1 -1
  19. package/dist/Backdrop/__tests__/fixtures/A11yDemos.js +3 -3
  20. package/dist/Badge/Badge.d.ts +1 -1
  21. package/dist/Badge/Badge.js +4 -4
  22. package/dist/Badge/__tests__/fixtures/A11yDemos.d.ts +1 -1
  23. package/dist/Badge/__tests__/fixtures/A11yDemos.js +13 -13
  24. package/dist/Breadcrumb/Breadcrumb.d.ts +1 -1
  25. package/dist/Breadcrumb/Breadcrumb.js +9 -9
  26. package/dist/Breadcrumb/Breadcrumb.types.d.ts +1 -1
  27. package/dist/Breadcrumb/BreadcrumbItem.d.ts +1 -1
  28. package/dist/Breadcrumb/BreadcrumbItem.js +4 -4
  29. package/dist/Button/Button.d.ts +1 -1
  30. package/dist/Button/Button.js +6 -6
  31. package/dist/Button/Button.types.d.ts +1 -1
  32. package/dist/Button/__tests__/fixtures/A11yDemos.d.ts +1 -1
  33. package/dist/Button/__tests__/fixtures/A11yDemos.js +8 -8
  34. package/dist/Button/index.css +2 -3
  35. package/dist/Calendar/Calendar.types.d.ts +1 -1
  36. package/dist/Calendar/__tests__/fixtures/A11yDemos.d.ts +1 -1
  37. package/dist/Calendar/__tests__/fixtures/A11yDemos.js +2 -2
  38. package/dist/Card/Card.d.ts +1 -1
  39. package/dist/Card/Card.js +3 -3
  40. package/dist/Card/Card.types.d.ts +1 -1
  41. package/dist/Card/CardContent.d.ts +1 -1
  42. package/dist/Card/CardContent.js +3 -3
  43. package/dist/Card/CardContent.types.d.ts +1 -1
  44. package/dist/Card/CardFooter.d.ts +1 -1
  45. package/dist/Card/CardFooter.js +3 -3
  46. package/dist/Card/CardFooter.types.d.ts +1 -1
  47. package/dist/Card/CardHeader.d.ts +1 -1
  48. package/dist/Card/CardHeader.js +10 -10
  49. package/dist/Checkbox/CheckboxContext.d.ts +1 -1
  50. package/dist/Checkbox/CheckboxContext.js +2 -2
  51. package/dist/Checkbox/__tests__/fixtures/A11yDemos.d.ts +1 -1
  52. package/dist/Checkbox/__tests__/fixtures/A11yDemos.js +4 -4
  53. package/dist/CitySelector/CitySelector.types.d.ts +1 -0
  54. package/dist/CitySelector/Selector/index.d.ts +1 -1
  55. package/dist/CitySelector/Selector/index.js +2 -2
  56. package/dist/Collapse/Collapse.types.d.ts +1 -1
  57. package/dist/CollapsePanel/CollapsePanel.d.ts +1 -1
  58. package/dist/CollapsePanel/CollapsePanel.js +9 -9
  59. package/dist/CollapsePanel/CollapsePanel.types.d.ts +1 -1
  60. package/dist/CollapsePanel/CollapsePanelItem.d.ts +1 -1
  61. package/dist/CollapsePanel/CollapsePanelItem.js +5 -5
  62. package/dist/Countdown/Countdown.types.d.ts +2 -2
  63. package/dist/Countdown/__tests__/fixtures/A11yDemos.d.ts +1 -1
  64. package/dist/Countdown/__tests__/fixtures/A11yDemos.js +10 -10
  65. package/dist/Countdown/utils.d.ts +2 -2
  66. package/dist/Countdown/utils.js +4 -4
  67. package/dist/DatePicker/DatePicker.types.d.ts +1 -1
  68. package/dist/DesktopPicker/DesktopPicker.types.d.ts +1 -1
  69. package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +11 -11
  70. package/dist/DesktopTimePicker/useGetTimePickerContent.js +2 -2
  71. package/dist/DesktopTimePicker/utils/utils.d.ts +1 -1
  72. package/dist/DesktopTimePicker/utils/utils.js +3 -3
  73. package/dist/Dialog/__tests__/fixtures/A11yDemos.d.ts +1 -1
  74. package/dist/Dialog/__tests__/fixtures/A11yDemos.js +4 -4
  75. package/dist/Divider/Divider.types.d.ts +1 -1
  76. package/dist/Drawer/Drawer.d.ts +1 -1
  77. package/dist/Drawer/Drawer.js +5 -5
  78. package/dist/Drawer/Drawer.types.d.ts +1 -1
  79. package/dist/Fade/Fade.d.ts +1 -1
  80. package/dist/Fade/Fade.js +4 -4
  81. package/dist/Fade/Fade.miniapp.js +13 -10
  82. package/dist/Fade/Fade.types.d.ts +1 -1
  83. package/dist/IconButton/IconButton.d.ts +1 -1
  84. package/dist/IconButton/IconButton.js +6 -6
  85. package/dist/IconButton/IconButton.types.d.ts +1 -1
  86. package/dist/Input/Input.types.d.ts +1 -1
  87. package/dist/Input/__tests__/fixtures/A11yDemos.d.ts +1 -1
  88. package/dist/Input/__tests__/fixtures/A11yDemos.js +7 -7
  89. package/dist/ItemSelector/ItemSelector.miniapp.js +7 -5
  90. package/dist/ItemSelector/ItemSelector.types.d.ts +1 -0
  91. package/dist/ItemSelector/Selector/index.d.ts +1 -1
  92. package/dist/ItemSelector/Selector/index.js +2 -2
  93. package/dist/List/List.d.ts +1 -1
  94. package/dist/List/List.js +4 -4
  95. package/dist/List/ListContext.d.ts +1 -1
  96. package/dist/List/ListContext.js +2 -2
  97. package/dist/List/ListItem.d.ts +1 -1
  98. package/dist/List/ListItem.js +8 -8
  99. package/dist/List/ListItem.types.d.ts +1 -1
  100. package/dist/List/ListItemContent.d.ts +1 -1
  101. package/dist/List/ListItemContent.js +3 -3
  102. package/dist/List/ListItemContent.types.d.ts +1 -1
  103. package/dist/List/ListItemExtra.d.ts +1 -1
  104. package/dist/List/ListItemExtra.js +3 -3
  105. package/dist/List/ListItemExtra.types.d.ts +1 -1
  106. package/dist/List/ListItemFooter.d.ts +1 -1
  107. package/dist/List/ListItemFooter.js +3 -3
  108. package/dist/List/ListItemFooter.types.d.ts +1 -1
  109. package/dist/List/ListItemHeader.d.ts +1 -1
  110. package/dist/List/ListItemHeader.js +3 -3
  111. package/dist/List/ListItemHeader.types.d.ts +1 -1
  112. package/dist/Loading/Loading.d.ts +1 -1
  113. package/dist/Loading/Loading.js +5 -5
  114. package/dist/Loading/Loading.types.d.ts +1 -1
  115. package/dist/Modal/Modal.d.ts +1 -1
  116. package/dist/Modal/Modal.js +6 -6
  117. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  118. package/dist/Modal/Modal.miniapp.js +7 -7
  119. package/dist/Modal/__tests__/fixtures/A11yDemos.d.ts +1 -1
  120. package/dist/Modal/__tests__/fixtures/A11yDemos.js +3 -3
  121. package/dist/Modal/useModal.js +26 -29
  122. package/dist/NavBar/NavBar.d.ts +1 -1
  123. package/dist/NavBar/NavBar.js +10 -10
  124. package/dist/Picker/Picker.js +0 -1
  125. package/dist/Picker/Picker.types.d.ts +1 -1
  126. package/dist/Picker/__tests__/fixtures/A11yDemos.d.ts +1 -1
  127. package/dist/Picker/__tests__/fixtures/A11yDemos.js +2 -2
  128. package/dist/Popover/Popover.d.ts +1 -1
  129. package/dist/Popover/Popover.js +8 -8
  130. package/dist/Popover/Popover.types.d.ts +1 -1
  131. package/dist/Popover/__tests__/fixtures/A11yDemos.d.ts +1 -1
  132. package/dist/Popover/__tests__/fixtures/A11yDemos.js +21 -21
  133. package/dist/Portal/Portal.d.ts +1 -1
  134. package/dist/Portal/Portal.js +3 -3
  135. package/dist/Portal/Portal.miniapp.js +14 -8
  136. package/dist/Portal/Portal.types.d.ts +1 -1
  137. package/dist/Progress/Progress.d.ts +1 -1
  138. package/dist/Progress/Progress.js +4 -4
  139. package/dist/Progress/Progress.types.d.ts +1 -1
  140. package/dist/Progress/__tests__/fixtures/A11yDemos.d.ts +1 -1
  141. package/dist/Progress/__tests__/fixtures/A11yDemos.js +9 -9
  142. package/dist/Radio/RadioButtonIcon.d.ts +1 -1
  143. package/dist/Radio/RadioButtonIcon.js +4 -4
  144. package/dist/Radio/RadioContext.d.ts +1 -1
  145. package/dist/Radio/RadioContext.js +2 -2
  146. package/dist/Radio/__tests__/fixtures/A11yDemos.d.ts +1 -1
  147. package/dist/Radio/__tests__/fixtures/A11yDemos.js +4 -4
  148. package/dist/Rating/Rating.types.d.ts +1 -1
  149. package/dist/ScrollView/ScrollView.types.d.ts +210 -1
  150. package/dist/ScrollView/__tests__/fixtures/A11yDemos.d.ts +1 -1
  151. package/dist/ScrollView/__tests__/fixtures/A11yDemos.js +30 -30
  152. package/dist/ScrollView/useScrollView.js +16 -4
  153. package/dist/Skeleton/Skeleton.d.ts +1 -1
  154. package/dist/Skeleton/Skeleton.js +3 -3
  155. package/dist/Skeleton/Skeleton.types.d.ts +1 -1
  156. package/dist/Slide/Slide.d.ts +1 -1
  157. package/dist/Slide/Slide.js +4 -4
  158. package/dist/Slide/Slide.miniapp.js +13 -10
  159. package/dist/Slider/Slider.types.d.ts +1 -1
  160. package/dist/Steps/Step.types.d.ts +1 -1
  161. package/dist/Steps/StepsContext.d.ts +1 -1
  162. package/dist/Steps/StepsContext.js +2 -2
  163. package/dist/SwipeAction/SwipeAction.js +7 -8
  164. package/dist/SwipeAction/SwipeAction.types.d.ts +1 -1
  165. package/dist/Swiper/Swiper.types.d.ts +1 -1
  166. package/dist/Swiper/SwiperItem.d.ts +1 -1
  167. package/dist/Swiper/SwiperItem.js +2 -2
  168. package/dist/Switch/__tests__/fixtures/A11yDemos.d.ts +1 -1
  169. package/dist/Switch/__tests__/fixtures/A11yDemos.js +4 -4
  170. package/dist/TabBar/TabBar.d.ts +1 -1
  171. package/dist/TabBar/TabBar.js +5 -5
  172. package/dist/Tabs/Tab.css +1 -23
  173. package/dist/Tabs/Tab.d.ts +2 -2
  174. package/dist/Tabs/Tab.js +42 -34
  175. package/dist/Tabs/Tab.types.d.ts +1 -1
  176. package/dist/Tabs/TabIndicator.d.ts +11 -0
  177. package/dist/Tabs/TabIndicator.js +185 -0
  178. package/dist/Tabs/TabMask.d.ts +7 -0
  179. package/dist/Tabs/TabMask.js +47 -0
  180. package/dist/Tabs/TabPanel.js +4 -4
  181. package/dist/Tabs/TabPanel.types.d.ts +1 -1
  182. package/dist/Tabs/Tabs.css +15 -6
  183. package/dist/Tabs/Tabs.js +99 -157
  184. package/dist/Tabs/Tabs.types.d.ts +5 -6
  185. package/dist/Tabs/TabsContext.d.ts +15 -6
  186. package/dist/Tabs/TabsContext.js +6 -14
  187. package/dist/Tabs/classes.d.ts +13 -0
  188. package/dist/Tabs/classes.js +63 -0
  189. package/dist/Tabs/index.css +16 -29
  190. package/dist/Tabs/index.d.ts +2 -2
  191. package/dist/Tabs/index.js +4 -4
  192. package/dist/Tabs/index.miniapp.d.ts +5 -0
  193. package/dist/Tabs/index.miniapp.js +50 -0
  194. package/dist/Tabs/miniapp/Tab.d.ts +5 -0
  195. package/dist/Tabs/miniapp/Tab.js +106 -0
  196. package/dist/Tabs/miniapp/TabIndicator.d.ts +15 -0
  197. package/dist/Tabs/miniapp/TabIndicator.js +301 -0
  198. package/dist/Tabs/miniapp/Tabs.d.ts +5 -0
  199. package/dist/Tabs/miniapp/Tabs.js +251 -0
  200. package/dist/Tabs/miniapp/TabsContext.d.ts +17 -0
  201. package/dist/Tabs/miniapp/TabsContext.js +39 -0
  202. package/dist/Tabs/miniapp/index.d.ts +2 -0
  203. package/dist/Tabs/miniapp/index.js +41 -0
  204. package/dist/Tabs/miniapp/scroll.d.ts +21 -0
  205. package/dist/Tabs/miniapp/scroll.js +52 -0
  206. package/dist/Tabs/miniapp/utils/queryBatch.d.ts +68 -0
  207. package/dist/Tabs/miniapp/utils/queryBatch.js +100 -0
  208. package/dist/Tabs/utils/scroll.js +10 -4
  209. package/dist/Tag/Tag.css +0 -1
  210. package/dist/Tag/Tag.d.ts +1 -1
  211. package/dist/Tag/Tag.js +6 -6
  212. package/dist/Tag/Tag.types.d.ts +1 -1
  213. package/dist/Tag/TagGroup.d.ts +1 -1
  214. package/dist/Tag/TagGroup.js +3 -3
  215. package/dist/Tag/TagGroup.types.d.ts +1 -1
  216. package/dist/Tag/__tests__/fixtures/A11yDemos.js +3 -3
  217. package/dist/Tag/index.css +0 -1
  218. package/dist/TextArea/__tests__/fixtures/A11yDemos.d.ts +1 -1
  219. package/dist/TextArea/__tests__/fixtures/A11yDemos.js +6 -6
  220. package/dist/ThemeProvider/hooks/ThemeContext.d.ts +1 -1
  221. package/dist/ThemeProvider/hooks/ThemeContext.js +2 -2
  222. package/dist/ThemeProvider/hooks/useTheme.js +2 -2
  223. package/dist/ThemeProvider/utils/mountTokens.js +2 -2
  224. package/dist/Toast/Toast.d.ts +1 -1
  225. package/dist/Toast/Toast.js +8 -8
  226. package/dist/Toast/__tests__/fixtures/A11yDemos.d.ts +1 -1
  227. package/dist/Toast/__tests__/fixtures/A11yDemos.js +2 -2
  228. package/dist/Tooltip/Tooltip.d.ts +1 -1
  229. package/dist/Tooltip/Tooltip.js +5 -5
  230. package/dist/Tooltip/Tooltip.types.d.ts +1 -1
  231. package/dist/Tooltip/__tests__/fixtures/A11yDemos.d.ts +1 -1
  232. package/dist/Tooltip/__tests__/fixtures/A11yDemos.js +14 -14
  233. package/dist/Transition/Transition.d.ts +1 -1
  234. package/dist/Transition/Transition.js +3 -3
  235. package/dist/Transition/Transition.miniapp.d.ts +1 -1
  236. package/dist/Transition/Transition.miniapp.js +3 -3
  237. package/dist/Transition/TransitionCore.js +8 -2
  238. package/dist/_.._/benchmarks/components/Button.d.js +15 -0
  239. package/dist/_.._/benchmarks/components/Button.js +2 -2
  240. package/dist/_.._/benchmarks/components/Input.d.js +15 -0
  241. package/dist/_.._/benchmarks/components/Tabs.d.js +15 -0
  242. package/es/ActionSheet/ActionSheet.d.ts +1 -1
  243. package/es/ActionSheet/ActionSheet.js +1 -1
  244. package/es/ActionSheet/ActionSheet.types.d.ts +1 -1
  245. package/es/ActionSheet/ActionSheetContext.d.ts +1 -1
  246. package/es/ActionSheet/ActionSheetContext.js +1 -1
  247. package/es/ActionSheet/ActionSheetItem.types.d.ts +1 -1
  248. package/es/Alert/Alert.d.ts +1 -1
  249. package/es/Alert/Alert.js +1 -1
  250. package/es/Alert/__tests__/fixtures/A11yDemos.d.ts +1 -1
  251. package/es/Alert/__tests__/fixtures/A11yDemos.js +1 -1
  252. package/es/Avatar/Avatar.d.ts +1 -1
  253. package/es/Avatar/Avatar.js +1 -1
  254. package/es/Avatar/Avatar.types.d.ts +1 -1
  255. package/es/Avatar/AvatarGroup.types.d.ts +1 -1
  256. package/es/Backdrop/Backdrop.d.ts +1 -1
  257. package/es/Backdrop/Backdrop.js +1 -1
  258. package/es/Backdrop/Backdrop.types.d.ts +1 -1
  259. package/es/Backdrop/__tests__/fixtures/A11yDemos.d.ts +1 -1
  260. package/es/Backdrop/__tests__/fixtures/A11yDemos.js +1 -1
  261. package/es/Badge/Badge.d.ts +1 -1
  262. package/es/Badge/Badge.js +1 -1
  263. package/es/Badge/__tests__/fixtures/A11yDemos.d.ts +1 -1
  264. package/es/Badge/__tests__/fixtures/A11yDemos.js +1 -1
  265. package/es/Breadcrumb/Breadcrumb.d.ts +1 -1
  266. package/es/Breadcrumb/Breadcrumb.js +1 -1
  267. package/es/Breadcrumb/Breadcrumb.types.d.ts +1 -1
  268. package/es/Breadcrumb/BreadcrumbItem.d.ts +1 -1
  269. package/es/Breadcrumb/BreadcrumbItem.js +1 -1
  270. package/es/Button/Button.d.ts +1 -1
  271. package/es/Button/Button.js +1 -1
  272. package/es/Button/Button.types.d.ts +1 -1
  273. package/es/Button/__tests__/fixtures/A11yDemos.d.ts +1 -1
  274. package/es/Button/__tests__/fixtures/A11yDemos.js +1 -1
  275. package/es/Button/index.css +2 -3
  276. package/es/Calendar/Calendar.types.d.ts +1 -1
  277. package/es/Calendar/__tests__/fixtures/A11yDemos.d.ts +1 -1
  278. package/es/Calendar/__tests__/fixtures/A11yDemos.js +1 -1
  279. package/es/Card/Card.d.ts +1 -1
  280. package/es/Card/Card.js +1 -1
  281. package/es/Card/Card.types.d.ts +1 -1
  282. package/es/Card/CardContent.d.ts +1 -1
  283. package/es/Card/CardContent.js +1 -1
  284. package/es/Card/CardContent.types.d.ts +1 -1
  285. package/es/Card/CardFooter.d.ts +1 -1
  286. package/es/Card/CardFooter.js +1 -1
  287. package/es/Card/CardFooter.types.d.ts +1 -1
  288. package/es/Card/CardHeader.d.ts +1 -1
  289. package/es/Card/CardHeader.js +1 -1
  290. package/es/Checkbox/CheckboxContext.d.ts +1 -1
  291. package/es/Checkbox/CheckboxContext.js +1 -1
  292. package/es/Checkbox/__tests__/fixtures/A11yDemos.d.ts +1 -1
  293. package/es/Checkbox/__tests__/fixtures/A11yDemos.js +1 -1
  294. package/es/CitySelector/CitySelector.types.d.ts +1 -0
  295. package/es/CitySelector/Selector/index.d.ts +1 -1
  296. package/es/CitySelector/Selector/index.js +1 -1
  297. package/es/Collapse/Collapse.types.d.ts +1 -1
  298. package/es/CollapsePanel/CollapsePanel.d.ts +1 -1
  299. package/es/CollapsePanel/CollapsePanel.js +1 -1
  300. package/es/CollapsePanel/CollapsePanel.types.d.ts +1 -1
  301. package/es/CollapsePanel/CollapsePanelItem.d.ts +1 -1
  302. package/es/CollapsePanel/CollapsePanelItem.js +1 -1
  303. package/es/Countdown/Countdown.types.d.ts +2 -2
  304. package/es/Countdown/__tests__/fixtures/A11yDemos.d.ts +1 -1
  305. package/es/Countdown/__tests__/fixtures/A11yDemos.js +1 -1
  306. package/es/Countdown/utils.d.ts +2 -2
  307. package/es/Countdown/utils.js +4 -4
  308. package/es/DatePicker/DatePicker.types.d.ts +1 -1
  309. package/es/DesktopPicker/DesktopPicker.types.d.ts +1 -1
  310. package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +11 -11
  311. package/es/DesktopTimePicker/useGetTimePickerContent.js +3 -3
  312. package/es/DesktopTimePicker/utils/utils.d.ts +1 -1
  313. package/es/DesktopTimePicker/utils/utils.js +2 -2
  314. package/es/Dialog/__tests__/fixtures/A11yDemos.d.ts +1 -1
  315. package/es/Dialog/__tests__/fixtures/A11yDemos.js +1 -1
  316. package/es/Divider/Divider.types.d.ts +1 -1
  317. package/es/Drawer/Drawer.d.ts +1 -1
  318. package/es/Drawer/Drawer.js +1 -1
  319. package/es/Drawer/Drawer.types.d.ts +1 -1
  320. package/es/Fade/Fade.d.ts +1 -1
  321. package/es/Fade/Fade.js +1 -1
  322. package/es/Fade/Fade.miniapp.js +14 -11
  323. package/es/Fade/Fade.types.d.ts +1 -1
  324. package/es/IconButton/IconButton.d.ts +1 -1
  325. package/es/IconButton/IconButton.js +1 -1
  326. package/es/IconButton/IconButton.types.d.ts +1 -1
  327. package/es/Input/Input.types.d.ts +1 -1
  328. package/es/Input/__tests__/fixtures/A11yDemos.d.ts +1 -1
  329. package/es/Input/__tests__/fixtures/A11yDemos.js +1 -1
  330. package/es/ItemSelector/ItemSelector.miniapp.js +7 -5
  331. package/es/ItemSelector/ItemSelector.types.d.ts +1 -0
  332. package/es/ItemSelector/Selector/index.d.ts +1 -1
  333. package/es/ItemSelector/Selector/index.js +1 -1
  334. package/es/List/List.d.ts +1 -1
  335. package/es/List/List.js +1 -1
  336. package/es/List/ListContext.d.ts +1 -1
  337. package/es/List/ListContext.js +1 -1
  338. package/es/List/ListItem.d.ts +1 -1
  339. package/es/List/ListItem.js +1 -1
  340. package/es/List/ListItem.types.d.ts +1 -1
  341. package/es/List/ListItemContent.d.ts +1 -1
  342. package/es/List/ListItemContent.js +1 -1
  343. package/es/List/ListItemContent.types.d.ts +1 -1
  344. package/es/List/ListItemExtra.d.ts +1 -1
  345. package/es/List/ListItemExtra.js +1 -1
  346. package/es/List/ListItemExtra.types.d.ts +1 -1
  347. package/es/List/ListItemFooter.d.ts +1 -1
  348. package/es/List/ListItemFooter.js +1 -1
  349. package/es/List/ListItemFooter.types.d.ts +1 -1
  350. package/es/List/ListItemHeader.d.ts +1 -1
  351. package/es/List/ListItemHeader.js +1 -1
  352. package/es/List/ListItemHeader.types.d.ts +1 -1
  353. package/es/Loading/Loading.d.ts +1 -1
  354. package/es/Loading/Loading.js +1 -1
  355. package/es/Loading/Loading.types.d.ts +1 -1
  356. package/es/Modal/Modal.d.ts +1 -1
  357. package/es/Modal/Modal.js +1 -1
  358. package/es/Modal/Modal.miniapp.d.ts +2 -2
  359. package/es/Modal/Modal.miniapp.js +1 -1
  360. package/es/Modal/__tests__/fixtures/A11yDemos.d.ts +1 -1
  361. package/es/Modal/__tests__/fixtures/A11yDemos.js +1 -1
  362. package/es/Modal/useModal.js +26 -29
  363. package/es/NavBar/NavBar.d.ts +1 -1
  364. package/es/NavBar/NavBar.js +1 -1
  365. package/es/Picker/Picker.js +0 -1
  366. package/es/Picker/Picker.types.d.ts +1 -1
  367. package/es/Picker/__tests__/fixtures/A11yDemos.d.ts +1 -1
  368. package/es/Picker/__tests__/fixtures/A11yDemos.js +1 -1
  369. package/es/Popover/Popover.d.ts +1 -1
  370. package/es/Popover/Popover.js +1 -1
  371. package/es/Popover/Popover.types.d.ts +1 -1
  372. package/es/Popover/__tests__/fixtures/A11yDemos.d.ts +1 -1
  373. package/es/Popover/__tests__/fixtures/A11yDemos.js +1 -1
  374. package/es/Portal/Portal.d.ts +1 -1
  375. package/es/Portal/Portal.js +1 -1
  376. package/es/Portal/Portal.miniapp.js +15 -9
  377. package/es/Portal/Portal.types.d.ts +1 -1
  378. package/es/Progress/Progress.d.ts +1 -1
  379. package/es/Progress/Progress.js +1 -1
  380. package/es/Progress/Progress.types.d.ts +1 -1
  381. package/es/Progress/__tests__/fixtures/A11yDemos.d.ts +1 -1
  382. package/es/Progress/__tests__/fixtures/A11yDemos.js +1 -1
  383. package/es/Radio/RadioButtonIcon.d.ts +1 -1
  384. package/es/Radio/RadioButtonIcon.js +1 -1
  385. package/es/Radio/RadioContext.d.ts +1 -1
  386. package/es/Radio/RadioContext.js +1 -1
  387. package/es/Radio/__tests__/fixtures/A11yDemos.d.ts +1 -1
  388. package/es/Radio/__tests__/fixtures/A11yDemos.js +1 -1
  389. package/es/Rating/Rating.types.d.ts +1 -1
  390. package/es/ScrollView/ScrollView.types.d.ts +210 -1
  391. package/es/ScrollView/__tests__/fixtures/A11yDemos.d.ts +1 -1
  392. package/es/ScrollView/__tests__/fixtures/A11yDemos.js +1 -1
  393. package/es/ScrollView/useScrollView.js +16 -4
  394. package/es/Skeleton/Skeleton.d.ts +1 -1
  395. package/es/Skeleton/Skeleton.js +1 -1
  396. package/es/Skeleton/Skeleton.types.d.ts +1 -1
  397. package/es/Slide/Slide.d.ts +1 -1
  398. package/es/Slide/Slide.js +1 -1
  399. package/es/Slide/Slide.miniapp.js +14 -11
  400. package/es/Slider/Slider.types.d.ts +1 -1
  401. package/es/Steps/Step.types.d.ts +1 -1
  402. package/es/Steps/StepsContext.d.ts +1 -1
  403. package/es/Steps/StepsContext.js +1 -1
  404. package/es/SwipeAction/SwipeAction.js +7 -8
  405. package/es/SwipeAction/SwipeAction.types.d.ts +1 -1
  406. package/es/Swiper/Swiper.js +5 -1
  407. package/es/Swiper/Swiper.types.d.ts +1 -1
  408. package/es/Swiper/SwiperItem.d.ts +1 -1
  409. package/es/Swiper/SwiperItem.js +1 -1
  410. package/es/Switch/__tests__/fixtures/A11yDemos.d.ts +1 -1
  411. package/es/Switch/__tests__/fixtures/A11yDemos.js +1 -1
  412. package/es/TabBar/TabBar.d.ts +1 -1
  413. package/es/TabBar/TabBar.js +1 -1
  414. package/es/Tabs/Tab.css +1 -23
  415. package/es/Tabs/Tab.d.ts +2 -2
  416. package/es/Tabs/Tab.js +44 -36
  417. package/es/Tabs/Tab.types.d.ts +1 -1
  418. package/es/Tabs/TabIndicator.d.ts +11 -0
  419. package/es/Tabs/TabIndicator.js +156 -0
  420. package/es/Tabs/TabMask.d.ts +7 -0
  421. package/es/Tabs/TabMask.js +18 -0
  422. package/es/Tabs/TabPanel.js +8 -4
  423. package/es/Tabs/TabPanel.types.d.ts +1 -1
  424. package/es/Tabs/Tabs.css +15 -6
  425. package/es/Tabs/Tabs.js +100 -158
  426. package/es/Tabs/Tabs.types.d.ts +5 -6
  427. package/es/Tabs/TabsContext.d.ts +15 -6
  428. package/es/Tabs/TabsContext.js +6 -4
  429. package/es/Tabs/classes.d.ts +13 -0
  430. package/es/Tabs/classes.js +28 -0
  431. package/es/Tabs/index.css +16 -29
  432. package/es/Tabs/index.d.ts +2 -2
  433. package/es/Tabs/index.js +2 -2
  434. package/es/Tabs/index.miniapp.d.ts +5 -0
  435. package/es/Tabs/index.miniapp.js +11 -0
  436. package/es/Tabs/miniapp/Tab.d.ts +5 -0
  437. package/es/Tabs/miniapp/Tab.js +77 -0
  438. package/es/Tabs/miniapp/TabIndicator.d.ts +15 -0
  439. package/es/Tabs/miniapp/TabIndicator.js +272 -0
  440. package/es/Tabs/miniapp/Tabs.d.ts +5 -0
  441. package/es/Tabs/miniapp/Tabs.js +229 -0
  442. package/es/Tabs/miniapp/TabsContext.d.ts +17 -0
  443. package/es/Tabs/miniapp/TabsContext.js +16 -0
  444. package/es/Tabs/miniapp/index.d.ts +2 -0
  445. package/es/Tabs/miniapp/index.js +7 -0
  446. package/es/Tabs/miniapp/scroll.d.ts +21 -0
  447. package/es/Tabs/miniapp/scroll.js +29 -0
  448. package/es/Tabs/miniapp/utils/queryBatch.d.ts +68 -0
  449. package/es/Tabs/miniapp/utils/queryBatch.js +65 -0
  450. package/es/Tabs/utils/scroll.js +10 -4
  451. package/es/Tag/Tag.css +0 -1
  452. package/es/Tag/Tag.d.ts +1 -1
  453. package/es/Tag/Tag.js +4 -4
  454. package/es/Tag/Tag.types.d.ts +1 -1
  455. package/es/Tag/TagGroup.d.ts +1 -1
  456. package/es/Tag/TagGroup.js +1 -1
  457. package/es/Tag/TagGroup.types.d.ts +1 -1
  458. package/es/Tag/__tests__/fixtures/A11yDemos.js +3 -3
  459. package/es/Tag/index.css +0 -1
  460. package/es/TextArea/__tests__/fixtures/A11yDemos.d.ts +1 -1
  461. package/es/TextArea/__tests__/fixtures/A11yDemos.js +1 -1
  462. package/es/ThemeProvider/hooks/ThemeContext.d.ts +1 -1
  463. package/es/ThemeProvider/hooks/ThemeContext.js +1 -1
  464. package/es/ThemeProvider/hooks/useTheme.js +1 -1
  465. package/es/ThemeProvider/utils/mountTokens.js +1 -1
  466. package/es/Toast/Toast.d.ts +1 -1
  467. package/es/Toast/Toast.js +1 -1
  468. package/es/Toast/__tests__/fixtures/A11yDemos.d.ts +1 -1
  469. package/es/Toast/__tests__/fixtures/A11yDemos.js +1 -1
  470. package/es/Tooltip/Tooltip.d.ts +1 -1
  471. package/es/Tooltip/Tooltip.js +1 -1
  472. package/es/Tooltip/Tooltip.types.d.ts +1 -1
  473. package/es/Tooltip/__tests__/fixtures/A11yDemos.d.ts +1 -1
  474. package/es/Tooltip/__tests__/fixtures/A11yDemos.js +1 -1
  475. package/es/Transition/Transition.d.ts +1 -1
  476. package/es/Transition/Transition.js +1 -1
  477. package/es/Transition/Transition.miniapp.d.ts +1 -1
  478. package/es/Transition/Transition.miniapp.js +1 -1
  479. package/es/Transition/TransitionCore.js +8 -2
  480. package/es/_.._/benchmarks/components/Button.d.js +0 -0
  481. package/es/_.._/benchmarks/components/Button.js +1 -1
  482. package/es/_.._/benchmarks/components/Input.d.js +0 -0
  483. package/es/_.._/benchmarks/components/Tabs.d.js +0 -0
  484. package/package.json +7 -6
@@ -0,0 +1,156 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import clsx from "clsx";
3
+ import { debounce, isMini, useEventCallback } from "@bifrostui/utils";
4
+ import scrollLeftTo from "./utils/scroll";
5
+ import { tabIndicatorClass } from "./classes";
6
+ const duration = 300;
7
+ const DEFAULT_INDICATOR_WIDTH = 24;
8
+ const TabIndicator = ({
9
+ currentValue,
10
+ registeredTabs,
11
+ tabsContainerRef
12
+ }) => {
13
+ const indicatorRef = useRef(null);
14
+ const hasRenderedOnce = useRef(false);
15
+ const [indicatorStyle, setIndicatorStyle] = useState(
16
+ null
17
+ );
18
+ const getActiveTabElement = useEventCallback(
19
+ (activeValue) => {
20
+ const tabRef = registeredTabs.current[activeValue];
21
+ return tabRef == null ? void 0 : tabRef.current;
22
+ }
23
+ );
24
+ const scrollIntoView = useEventCallback(
25
+ (activeTab, animate = true) => {
26
+ const tabsEl = tabsContainerRef.current;
27
+ if (!tabsEl || !activeTab) {
28
+ return;
29
+ }
30
+ scrollLeftTo(
31
+ tabsEl,
32
+ activeTab.offsetLeft - (tabsEl.offsetWidth - activeTab.offsetWidth) / 2,
33
+ animate ? duration : 0
34
+ );
35
+ }
36
+ );
37
+ const getIndicatorWidth = useEventCallback(() => {
38
+ const indicator = indicatorRef.current;
39
+ if (!indicator)
40
+ return DEFAULT_INDICATOR_WIDTH;
41
+ const rect = indicator.getBoundingClientRect();
42
+ return rect.width > 0 ? rect.width : DEFAULT_INDICATOR_WIDTH;
43
+ });
44
+ const getTabsMeta = useEventCallback(() => {
45
+ const tabsNode = tabsContainerRef.current;
46
+ let tabsMeta = null;
47
+ if (tabsNode) {
48
+ const rect = tabsNode.getBoundingClientRect();
49
+ tabsMeta = {
50
+ clientWidth: tabsNode.clientWidth,
51
+ scrollLeft: tabsNode.scrollLeft,
52
+ scrollWidth: tabsNode.scrollWidth,
53
+ left: rect.left
54
+ };
55
+ }
56
+ let tabMeta = null;
57
+ const activeTab = getActiveTabElement(currentValue);
58
+ if (activeTab) {
59
+ tabMeta = activeTab.getBoundingClientRect();
60
+ }
61
+ return { tabsMeta, tabMeta };
62
+ });
63
+ const updateIndicatorState = useEventCallback(() => {
64
+ const { tabsMeta, tabMeta } = getTabsMeta();
65
+ if (!tabMeta || !tabsMeta) {
66
+ setIndicatorStyle(null);
67
+ return;
68
+ }
69
+ const tabLeft = tabMeta.left - tabsMeta.left + tabsMeta.scrollLeft;
70
+ const tabWidth = tabMeta.width;
71
+ const indicatorWidth = getIndicatorWidth();
72
+ const leftPosition = tabLeft + (tabWidth - indicatorWidth) / 2;
73
+ const newIndicatorStyle = {
74
+ left: leftPosition
75
+ };
76
+ if (indicatorStyle === null) {
77
+ setIndicatorStyle(newIndicatorStyle);
78
+ } else {
79
+ const dLeft = Math.abs(indicatorStyle.left - newIndicatorStyle.left);
80
+ if (dLeft >= 1) {
81
+ setIndicatorStyle(newIndicatorStyle);
82
+ }
83
+ }
84
+ const activeTab = getActiveTabElement(currentValue);
85
+ if (activeTab) {
86
+ const maxScrollDistance = tabsMeta.scrollWidth - tabsMeta.clientWidth;
87
+ if (maxScrollDistance > 0 && !isMini) {
88
+ scrollIntoView(activeTab, hasRenderedOnce.current);
89
+ }
90
+ hasRenderedOnce.current = true;
91
+ }
92
+ });
93
+ useEffect(() => {
94
+ updateIndicatorState();
95
+ });
96
+ useEffect(() => {
97
+ const tabsContainer = tabsContainerRef.current;
98
+ if (!tabsContainer)
99
+ return void 0;
100
+ const handleResize = debounce(() => {
101
+ if (tabsContainerRef.current) {
102
+ updateIndicatorState();
103
+ }
104
+ }, 100);
105
+ window.addEventListener("resize", handleResize);
106
+ let resizeObserver;
107
+ let mutationObserver;
108
+ if (typeof ResizeObserver !== "undefined") {
109
+ resizeObserver = new ResizeObserver(handleResize);
110
+ Array.from(tabsContainer.children).forEach((child) => {
111
+ resizeObserver == null ? void 0 : resizeObserver.observe(child);
112
+ });
113
+ }
114
+ if (typeof MutationObserver !== "undefined") {
115
+ const handleMutation = (records) => {
116
+ records.forEach((record) => {
117
+ record.removedNodes.forEach((item) => {
118
+ if (item instanceof Element) {
119
+ resizeObserver == null ? void 0 : resizeObserver.unobserve(item);
120
+ }
121
+ });
122
+ record.addedNodes.forEach((item) => {
123
+ if (item instanceof Element) {
124
+ resizeObserver == null ? void 0 : resizeObserver.observe(item);
125
+ }
126
+ });
127
+ });
128
+ handleResize();
129
+ };
130
+ mutationObserver = new MutationObserver(handleMutation);
131
+ mutationObserver.observe(tabsContainer, { childList: true });
132
+ }
133
+ return () => {
134
+ window.removeEventListener("resize", handleResize);
135
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
136
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
137
+ };
138
+ }, [updateIndicatorState, tabsContainerRef]);
139
+ if (!indicatorStyle) {
140
+ return null;
141
+ }
142
+ return /* @__PURE__ */ React.createElement(
143
+ "div",
144
+ {
145
+ ref: indicatorRef,
146
+ className: clsx(tabIndicatorClass),
147
+ style: indicatorStyle,
148
+ "aria-hidden": "true"
149
+ }
150
+ );
151
+ };
152
+ TabIndicator.displayName = "BuiTabsIndicator";
153
+ var TabIndicator_default = TabIndicator;
154
+ export {
155
+ TabIndicator_default as default
156
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export interface TabMaskProps {
3
+ /** 位置:左侧或右侧 */
4
+ position: 'left' | 'right';
5
+ }
6
+ declare const _default: React.NamedExoticComponent<TabMaskProps>;
7
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import clsx from "clsx";
3
+ import { tabMaskClass, tabMaskLeftClass, tabMaskRightClass } from "./classes";
4
+ const TabMask = ({ position }) => /* @__PURE__ */ React.createElement(
5
+ "div",
6
+ {
7
+ className: clsx(
8
+ tabMaskClass,
9
+ position === "left" ? tabMaskLeftClass : tabMaskRightClass
10
+ ),
11
+ "aria-hidden": "true"
12
+ }
13
+ );
14
+ TabMask.displayName = "BuiTabsMask";
15
+ var TabMask_default = /* @__PURE__ */ React.memo(TabMask);
16
+ export {
17
+ TabMask_default as default
18
+ };
@@ -28,8 +28,12 @@ var __objRest = (source, exclude) => {
28
28
  };
29
29
  import React, { forwardRef } from "react";
30
30
  import clsx from "clsx";
31
+ import {
32
+ tabPanelRootClass,
33
+ tabPanelActiveClass,
34
+ tabPanelInactiveClass
35
+ } from "./classes";
31
36
  import "./TabPanel.css";
32
- const prefixCls = "bui-tabpanel";
33
37
  const TabPanel = forwardRef((props, ref) => {
34
38
  const _a = props, {
35
39
  className,
@@ -53,9 +57,9 @@ const TabPanel = forwardRef((props, ref) => {
53
57
  "aria-hidden": !isActive,
54
58
  tabIndex: 0,
55
59
  ref,
56
- className: clsx(prefixCls, className, {
57
- [`${prefixCls}-active`]: isActive,
58
- [`${prefixCls}-inactive`]: !isActive
60
+ className: clsx(tabPanelRootClass, className, {
61
+ [tabPanelActiveClass]: isActive,
62
+ [tabPanelInactiveClass]: !isActive
59
63
  })
60
64
  }, others),
61
65
  isActive ? children : keepActiveDom
@@ -1,5 +1,5 @@
1
1
  import { OverrideProps } from '@bifrostui/types';
2
- import React from 'react';
2
+ import * as React from 'react';
3
3
  export type TabPanelProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
4
4
  props: P & {
5
5
  /**
package/es/Tabs/Tabs.css CHANGED
@@ -16,7 +16,6 @@ xhs-page {
16
16
  --bui-tab-height: 100%;
17
17
  --bui-tab-padding: var(--bui-spacing-lg) var(--bui-spacing-lg) 10px;
18
18
  --bui-tab-active-color: var(--bui-color-fg-default);
19
- --bui-tab-active-font-family: var(--bui-font-family-accent, inherit);
20
19
  }
21
20
  .bui-tabs {
22
21
  position: relative;
@@ -29,6 +28,7 @@ xhs-page {
29
28
  flex-wrap: nowrap;
30
29
  justify-content: flex-start;
31
30
  align-items: center;
31
+ white-space: nowrap;
32
32
  position: relative;
33
33
  overflow-x: scroll;
34
34
  scrollbar-width: none;
@@ -36,15 +36,28 @@ xhs-page {
36
36
  .bui-tabs-tabs::-webkit-scrollbar {
37
37
  display: none;
38
38
  }
39
+ .bui-tabs-scroll-wrapper {
40
+ height: 100%;
41
+ display: flex;
42
+ flex-wrap: nowrap;
43
+ justify-content: flex-start;
44
+ align-items: center;
45
+ position: relative;
46
+ min-width: 100%;
47
+ }
39
48
  .bui-tabs-indicator {
40
49
  position: absolute;
50
+ top: unset;
51
+ bottom: var(--bui-tabs-indicator-bottom, 0);
41
52
  width: var(--bui-tabs-indicator-width);
42
- bottom: var(--bui-tabs-indicator-bottom);
43
53
  height: var(--bui-tabs-indicator-height);
44
54
  color: var(--bui-color-primary);
45
55
  background: var(--bui-tabs-indicator-bg);
46
56
  border-radius: var(--bui-tabs-indicator-border-radius);
47
57
  box-shadow: var(--bui-tabs-indicator-box-shadow);
58
+ z-index: 1;
59
+ pointer-events: none;
60
+ transition: left 0.3s ease-in-out;
48
61
  }
49
62
  .bui-tabs-content {
50
63
  padding: var(--bui-spacing-lg);
@@ -74,7 +87,3 @@ xhs-page {
74
87
  var(--bui-color-bg-view),
75
88
  rgba(255, 255, 255, 0));
76
89
  }
77
- .bui-indicator-invisible {
78
- visibility: hidden;
79
- background-color: transparent;
80
- }
package/es/Tabs/Tabs.js CHANGED
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __objRest = (source, exclude) => {
18
21
  var target = {};
19
22
  for (var prop in source)
@@ -28,188 +31,127 @@ var __objRest = (source, exclude) => {
28
31
  };
29
32
  import React, { useEffect, useMemo, useRef, useState } from "react";
30
33
  import clsx from "clsx";
31
- import { debounce, isMini, throttle, useEventCallback } from "@bifrostui/utils";
32
- import scrollLeftTo from "./utils/scroll";
34
+ import { useValue, useEventCallback } from "@bifrostui/utils";
33
35
  import Tab from "./Tab";
36
+ import TabIndicator from "./TabIndicator";
37
+ import TabMask from "./TabMask";
34
38
  import { TabsContextProvider } from "./TabsContext";
39
+ import { tabsRootClass, tabsScrollClass } from "./classes";
35
40
  import "./Tabs.css";
36
- const prefixCls = "bui-tabs";
37
- const duration = 300;
38
41
  const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
39
- const _a = props, { children, className, value, tabs = [], onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "onChange"]);
40
- const tabsRef = useRef(null);
41
- const activeLineRef = useRef(null);
42
- const [indicatorData, setIndicatorData] = useState({
43
- x: 0,
44
- hasActiveTab: false
45
- });
46
- const [maskData, setMaskData] = useState({
47
- leftMaskOpacity: 0,
48
- rightMaskOpacity: 0
49
- });
50
- const getActiveTabElement = () => {
51
- const tabsEl = tabsRef.current;
52
- if (!tabsEl)
53
- return;
54
- const activeIndex = tabs.findIndex((item) => item.index === value);
55
- if (tabs.length) {
56
- return activeIndex > -1 ? tabsEl.childNodes[activeIndex + 1] : void 0;
42
+ const _a = props, {
43
+ children,
44
+ className,
45
+ defaultValue,
46
+ value,
47
+ tabs = [],
48
+ onChange
49
+ } = _a, others = __objRest(_a, [
50
+ "children",
51
+ "className",
52
+ "defaultValue",
53
+ "value",
54
+ "tabs",
55
+ "onChange"
56
+ ]);
57
+ const handleOnChange = useEventCallback(
58
+ (e, data) => {
59
+ onChange == null ? void 0 : onChange(e, { index: data.value });
57
60
  }
58
- return [...tabsEl.childNodes].find((child) => {
59
- var _a2, _b;
60
- if (isMini) {
61
- return [...(_b = (_a2 = child == null ? void 0 : child.classList) == null ? void 0 : _a2.tokenList) != null ? _b : []].includes(
62
- "bui-tab-miniapp-active"
63
- );
64
- }
65
- return [...child.classList].includes("bui-tab-active");
66
- });
67
- };
68
- const scrollIntoView = () => {
69
- const tabsEl = tabsRef.current;
70
- const activeTab = getActiveTabElement();
71
- if (!tabsEl || !activeTab) {
72
- return;
61
+ );
62
+ const [currentValue, triggerValueChange] = useValue({
63
+ value,
64
+ defaultValue: defaultValue != null ? defaultValue : "",
65
+ onChange: handleOnChange,
66
+ config: {
67
+ name: "Tabs",
68
+ state: "value"
73
69
  }
74
- const to = activeTab.offsetLeft - (tabsEl.offsetWidth - activeTab.offsetWidth) / 2;
75
- scrollLeftTo(tabsEl, to, duration);
76
- };
77
- const animate = useEventCallback(() => {
78
- const tabsEl = tabsRef.current;
79
- if (!tabsEl)
80
- return;
81
- const activeLine = activeLineRef.current;
82
- if (!activeLine)
83
- return;
84
- const activeTab = getActiveTabElement();
85
- let activeTabLeft = 0;
86
- let activeTabWidth = 0;
87
- let containerWidth = 0;
88
- let containerScrollWidth = 0;
89
- let activeLineWidth = 0;
90
- let x = 0;
91
- if (activeTab) {
92
- activeTabLeft = activeTab.offsetLeft;
93
- activeTabWidth = activeTab.offsetWidth;
94
- containerWidth = tabsEl.offsetWidth;
95
- containerScrollWidth = tabsEl.scrollWidth;
96
- activeLineWidth = activeLine.offsetWidth;
97
- x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
70
+ });
71
+ const tabsRef = useRef(null);
72
+ const registeredTabs = useRef(
73
+ {}
74
+ );
75
+ const [registrationVersion, setRegistrationVersion] = useState(0);
76
+ const [isScrollable, setIsScrollable] = useState(false);
77
+ if (process.env.NODE_ENV !== "production") {
78
+ if (tabs.length > 0 && React.Children.count(children) > 0) {
79
+ console.warn(
80
+ "BUI Warning: Tabs \u7EC4\u4EF6\u4E0D\u5E94\u8BE5\u540C\u65F6\u4F7F\u7528 tabs \u5C5E\u6027\u548C children\u3002\u8BF7\u53EA\u4F7F\u7528\u5176\u4E2D\u4E00\u79CD\u65B9\u5F0F\u3002\u5F53\u524D\u5C06\u4F18\u5148\u4F7F\u7528 tabs \u5C5E\u6027\uFF0Cchildren \u5C06\u88AB\u5FFD\u7565\u3002"
81
+ );
98
82
  }
99
- setIndicatorData({
100
- x,
101
- hasActiveTab: !!activeTab
102
- });
103
- const maxScrollDistance = containerScrollWidth - containerWidth;
104
- if (maxScrollDistance <= 0 || !activeTab)
105
- return;
106
- if (!isMini) {
107
- scrollIntoView();
83
+ }
84
+ const onRegister = useEventCallback(
85
+ (data) => {
86
+ if (data.value !== void 0 && data.value !== null) {
87
+ registeredTabs.current[data.value] = data.ref;
88
+ setRegistrationVersion((v) => v + 1);
89
+ }
108
90
  }
91
+ );
92
+ const onUnregister = useEventCallback((data) => {
93
+ delete registeredTabs.current[data.value];
94
+ setRegistrationVersion((v) => v + 1);
109
95
  });
110
- const updateMask = useMemo(
111
- () => throttle(
112
- () => {
113
- const tabsEl = tabsRef.current;
114
- if (!tabsEl)
115
- return;
116
- const scrollLeft = tabsEl == null ? void 0 : tabsEl.scrollLeft;
117
- const showLeftMask = scrollLeft > 0;
118
- const rightRange = Math.abs(
119
- tabsEl.scrollWidth - (scrollLeft + tabsEl.offsetWidth)
120
- );
121
- const showRightMask = rightRange > 1;
122
- setMaskData({
123
- leftMaskOpacity: showLeftMask ? 1 : 0,
124
- rightMaskOpacity: showRightMask ? 1 : 0
125
- });
126
- },
127
- 100,
128
- {
129
- trailing: true,
130
- leading: true
96
+ const handleClick = useEventCallback(
97
+ (e, item) => {
98
+ const { index, disabled = false } = item;
99
+ if (disabled || [void 0, null].includes(index))
100
+ return;
101
+ if (index !== currentValue) {
102
+ triggerValueChange(e, index);
131
103
  }
132
- ),
133
- []
104
+ }
134
105
  );
106
+ const contextValue = useMemo(
107
+ () => ({
108
+ value: currentValue,
109
+ triggerChange: handleClick,
110
+ onRegister,
111
+ onUnregister
112
+ }),
113
+ [currentValue, handleClick, onRegister, onUnregister]
114
+ );
115
+ const renderedTabs = useMemo(() => {
116
+ if (tabs.length > 0) {
117
+ return tabs.map((item) => /* @__PURE__ */ React.createElement(Tab, { key: item.index, index: item == null ? void 0 : item.index, disabled: item == null ? void 0 : item.disabled }, item.title));
118
+ }
119
+ return children;
120
+ }, [tabs, children]);
135
121
  useEffect(() => {
136
- animate();
137
- }, [value, tabs.length, React.Children.toArray(children).length]);
138
- useEffect(() => {
139
- updateMask();
140
- const handleResize = debounce(() => {
141
- animate();
142
- updateMask();
143
- }, 100);
144
- window.addEventListener("resize", handleResize);
145
- return () => {
146
- window.removeEventListener("resize", handleResize);
122
+ const tabsEl = tabsRef.current;
123
+ if (!tabsEl)
124
+ return void 0;
125
+ const checkScrollable = () => {
126
+ setIsScrollable(tabsEl.scrollWidth > tabsEl.offsetWidth);
147
127
  };
148
- }, []);
149
- const handleClick = (e, item) => {
150
- const { index, disabled = false } = item;
151
- if (disabled || [void 0, null].includes(index))
152
- return;
153
- if (index !== value) {
154
- onChange == null ? void 0 : onChange(e, { index });
128
+ checkScrollable();
129
+ if (typeof ResizeObserver === "undefined") {
130
+ return void 0;
155
131
  }
156
- };
157
- return /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), /* @__PURE__ */ React.createElement(
158
- "div",
159
- {
160
- className: clsx(`${prefixCls}-mask`, `${prefixCls}-mask-left`),
161
- style: {
162
- opacity: maskData.leftMaskOpacity
163
- },
164
- "aria-hidden": "true"
165
- }
166
- ), /* @__PURE__ */ React.createElement(
167
- "div",
168
- {
169
- className: clsx(`${prefixCls}-mask`, `${prefixCls}-mask-right`),
170
- style: {
171
- opacity: maskData.rightMaskOpacity
172
- },
173
- "aria-hidden": "true"
174
- }
175
- ), /* @__PURE__ */ React.createElement(
132
+ const resizeObserver = new ResizeObserver(checkScrollable);
133
+ resizeObserver.observe(tabsEl);
134
+ return () => {
135
+ resizeObserver.disconnect();
136
+ };
137
+ }, [registrationVersion]);
138
+ return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({ className: clsx(tabsRootClass, className) }, others), { ref }), isScrollable && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TabMask, { position: "left" }), /* @__PURE__ */ React.createElement(TabMask, { position: "right" })), /* @__PURE__ */ React.createElement(
176
139
  "div",
177
140
  {
178
- className: `${prefixCls}-tabs`,
141
+ className: tabsScrollClass,
179
142
  ref: tabsRef,
180
- onScroll: updateMask,
181
143
  role: "tablist",
182
144
  "aria-orientation": "horizontal"
183
145
  },
184
146
  /* @__PURE__ */ React.createElement(
185
- "div",
147
+ TabIndicator,
186
148
  {
187
- ref: activeLineRef,
188
- className: clsx(`${prefixCls}-indicator`, {
189
- "bui-indicator-invisible": isMini || !indicatorData.hasActiveTab
190
- }),
191
- style: {
192
- transition: "transform 0.3s ease-in-out",
193
- transform: `translate(${indicatorData.x}px, 0px)`
194
- },
195
- "aria-hidden": "true"
149
+ currentValue,
150
+ registeredTabs,
151
+ tabsContainerRef: tabsRef
196
152
  }
197
153
  ),
198
- /* @__PURE__ */ React.createElement(TabsContextProvider, { value: { value, triggerChange: handleClick } }, !!tabs.length && tabs.map((item) => {
199
- return /* @__PURE__ */ React.createElement(
200
- Tab,
201
- {
202
- key: item.index,
203
- index: item == null ? void 0 : item.index,
204
- disabled: item == null ? void 0 : item.disabled,
205
- role: "tab",
206
- "aria-selected": value === item.index,
207
- "aria-disabled": item == null ? void 0 : item.disabled,
208
- tabIndex: (item == null ? void 0 : item.disabled) ? -1 : 0
209
- },
210
- item.title
211
- );
212
- }), children)
154
+ /* @__PURE__ */ React.createElement(TabsContextProvider, { value: contextValue }, renderedTabs)
213
155
  ));
214
156
  });
215
157
  Tabs.displayName = "BuiTabs";
@@ -1,10 +1,5 @@
1
1
  import React, { SyntheticEvent } from 'react';
2
2
  import { OverrideProps } from '@bifrostui/types';
3
- export interface TabHeaderItem {
4
- title: React.ReactNode;
5
- index: string;
6
- disabled?: boolean;
7
- }
8
3
  export interface ITabsChangeData {
9
4
  /** 切换后的tab索引 */
10
5
  index: string;
@@ -19,9 +14,13 @@ export type ITabAlign = 'start' | 'center';
19
14
  export type TabsProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
20
15
  props: P & {
21
16
  /**
22
- * 当前选中面板的索引值,与tabs.index对应
17
+ * 当前选中面板的索引值,与 ITabItem.index 对应
23
18
  */
24
19
  value?: string;
20
+ /**
21
+ * 默认选中面板的索引值(非受控模式)
22
+ */
23
+ defaultValue?: string;
25
24
  /**
26
25
  * 切换面板的数据
27
26
  */
@@ -1,8 +1,17 @@
1
1
  import React from 'react';
2
- import { TabChangeEvent, TabsProps } from './Tabs.types';
3
- type TabsContextValueType = Omit<TabsProps, 'onChange'> & {
4
- triggerChange: TabChangeEvent;
5
- };
6
- declare const TabsContext: React.Context<TabsContextValueType>;
7
- export declare const TabsContextProvider: React.Provider<TabsContextValueType>;
2
+ import { TabChangeEvent } from './Tabs.types';
3
+ export interface TabRegisterData {
4
+ value: string;
5
+ ref: React.RefObject<HTMLElement>;
6
+ }
7
+ export interface TabsContextValueType {
8
+ value?: string;
9
+ triggerChange?: TabChangeEvent;
10
+ onRegister?: (data: TabRegisterData) => void;
11
+ onUnregister?: (data: {
12
+ value: string;
13
+ }) => void;
14
+ }
15
+ declare const TabsContext: import("@bifrostui/utils").Context<TabsContextValueType>;
16
+ export declare const TabsContextProvider: React.Provider<TabsContextValueType> & React.FC<React.ProviderProps<TabsContextValueType>>;
8
17
  export default TabsContext;
@@ -1,7 +1,9 @@
1
- import React from "react";
2
- const TabsContext = React.createContext(
3
- void 0
4
- );
1
+ import { createContext } from "@bifrostui/utils";
2
+ const TabsContext = createContext({
3
+ triggerChange: void 0,
4
+ onRegister: void 0,
5
+ onUnregister: void 0
6
+ });
5
7
  if (process.env.NODE_ENV !== "production") {
6
8
  TabsContext.displayName = "BuiTabsContext";
7
9
  }
@@ -0,0 +1,13 @@
1
+ export declare const tabsRootClass = "bui-tabs";
2
+ export declare const tabRootClass = "bui-tab";
3
+ export declare const tabPanelRootClass = "bui-tabpanel";
4
+ export declare const tabsScrollClass: string;
5
+ export declare const tabsScrollWrapperClass: string;
6
+ export declare const tabActiveClass: string;
7
+ export declare const tabDisabledClass: string;
8
+ export declare const tabIndicatorClass: string;
9
+ export declare const tabMaskClass: string;
10
+ export declare const tabMaskLeftClass: string;
11
+ export declare const tabMaskRightClass: string;
12
+ export declare const tabPanelActiveClass: string;
13
+ export declare const tabPanelInactiveClass: string;