react-native-system-ui 0.0.7 → 1.0.0

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 (366) hide show
  1. package/README.md +46 -31
  2. package/dist/cjs/components/action-sheet/ActionSheet.js +97 -105
  3. package/dist/cjs/components/action-sheet/tokens.js +16 -27
  4. package/dist/cjs/components/area/Area.js +54 -67
  5. package/dist/cjs/components/area/tokens.js +6 -3
  6. package/dist/cjs/components/avatar/Avatar.js +25 -23
  7. package/dist/cjs/components/badge/Badge.js +31 -31
  8. package/dist/cjs/components/badge/tokens.js +6 -8
  9. package/dist/cjs/components/button/Button.js +115 -151
  10. package/dist/cjs/components/button/ButtonGroup.js +8 -42
  11. package/dist/cjs/components/button/tokens.js +1 -8
  12. package/dist/cjs/components/calendar/Calendar.js +212 -223
  13. package/dist/cjs/components/calendar/tokens.js +3 -3
  14. package/dist/cjs/components/cascader/Cascader.js +177 -180
  15. package/dist/cjs/components/cascader/tokens.js +2 -2
  16. package/dist/cjs/components/cascader/useCascaderExtend.js +25 -29
  17. package/dist/cjs/components/cell/Cell.js +70 -83
  18. package/dist/cjs/components/cell/CellGroup.js +16 -29
  19. package/dist/cjs/components/checkbox/Checkbox.js +139 -132
  20. package/dist/cjs/components/checkbox/CheckboxGroup.js +4 -35
  21. package/dist/cjs/components/checkbox/tokens.js +7 -10
  22. package/dist/cjs/components/circle/Circle.js +25 -24
  23. package/dist/cjs/components/collapse/Collapse.js +75 -91
  24. package/dist/cjs/components/config-provider/ConfigProvider.js +16 -3
  25. package/dist/cjs/components/config-provider/DirectionContext.js +15 -0
  26. package/dist/cjs/components/config-provider/index.js +7 -0
  27. package/dist/cjs/components/config-provider/locale/en-US.js +32 -0
  28. package/dist/cjs/components/config-provider/locale/zh-CN.js +32 -0
  29. package/dist/cjs/components/config-provider/useDirection.js +16 -0
  30. package/dist/cjs/components/count-down/CountDown.js +20 -15
  31. package/dist/cjs/components/datetime-picker/DatetimePicker.js +61 -84
  32. package/dist/cjs/components/datetime-picker/tokens.js +14 -3
  33. package/dist/cjs/components/dialog/Dialog.js +153 -121
  34. package/dist/cjs/components/dialog/imperative.js +17 -30
  35. package/dist/cjs/components/divider/Divider.js +26 -28
  36. package/dist/cjs/components/empty/Empty.js +35 -39
  37. package/dist/cjs/components/error-boundary/ErrorBoundary.js +73 -0
  38. package/dist/cjs/components/error-boundary/index.js +19 -0
  39. package/dist/cjs/components/field/Field.js +109 -106
  40. package/dist/cjs/components/flex/Flex.js +18 -18
  41. package/dist/cjs/components/flex/FlexItem.js +26 -27
  42. package/dist/cjs/components/form/Form.js +142 -161
  43. package/dist/cjs/components/form/FormItem.js +69 -97
  44. package/dist/cjs/components/form/FormList.js +49 -37
  45. package/dist/cjs/components/form/tokens.js +6 -3
  46. package/dist/cjs/components/form/utils.js +15 -34
  47. package/dist/cjs/components/grid/Grid.js +30 -29
  48. package/dist/cjs/components/grid/GridItem.js +84 -85
  49. package/dist/cjs/components/image/Image.js +55 -59
  50. package/dist/cjs/components/image/tokens.js +2 -2
  51. package/dist/cjs/components/image-preview/ImagePreview.js +124 -112
  52. package/dist/cjs/components/image-preview/imperative.js +4 -13
  53. package/dist/cjs/components/index.js +13 -0
  54. package/dist/cjs/components/input/Input.js +30 -22
  55. package/dist/cjs/components/loading/Loading.js +14 -15
  56. package/dist/cjs/components/nav-bar/NavBar.js +68 -83
  57. package/dist/cjs/components/nav-bar/tokens.js +1 -9
  58. package/dist/cjs/components/notice-bar/NoticeBar.js +74 -77
  59. package/dist/cjs/components/notify/Notify.js +88 -84
  60. package/dist/cjs/components/notify/imperative.js +20 -43
  61. package/dist/cjs/components/notify/tokens.js +1 -11
  62. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +187 -209
  63. package/dist/cjs/components/overlay/Overlay.js +37 -52
  64. package/dist/cjs/components/overlay/tokens.js +5 -3
  65. package/dist/cjs/components/password-input/PasswordInput.js +98 -79
  66. package/dist/cjs/components/picker/Picker.js +440 -421
  67. package/dist/cjs/components/picker/tokens.js +1 -1
  68. package/dist/cjs/components/popup/Popup.js +263 -293
  69. package/dist/cjs/components/portal/Portal.js +12 -29
  70. package/dist/cjs/components/portal/PortalHost.js +151 -234
  71. package/dist/cjs/components/progress/Progress.js +51 -48
  72. package/dist/cjs/components/radio/Radio.js +45 -42
  73. package/dist/cjs/components/radio/RadioGroup.js +8 -40
  74. package/dist/cjs/components/radio/tokens.js +7 -10
  75. package/dist/cjs/components/safe-area-view/SafeAreaView.js +22 -26
  76. package/dist/cjs/components/search/Search.js +51 -43
  77. package/dist/cjs/components/selector/Selector.js +14 -13
  78. package/dist/cjs/components/share-sheet/ShareSheet.js +160 -161
  79. package/dist/cjs/components/sidebar/Sidebar.js +39 -45
  80. package/dist/cjs/components/sidebar/SidebarContext.js +1 -2
  81. package/dist/cjs/components/sidebar/SidebarItem.js +13 -16
  82. package/dist/cjs/components/sidebar/tokens.js +1 -3
  83. package/dist/cjs/components/skeleton/Skeleton.js +30 -37
  84. package/dist/cjs/components/skeleton/tokens.js +1 -2
  85. package/dist/cjs/components/slider/Slider.js +156 -135
  86. package/dist/cjs/components/space/Space.js +46 -69
  87. package/dist/cjs/components/stepper/Stepper.js +177 -155
  88. package/dist/cjs/components/swiper/Swiper.js +251 -253
  89. package/dist/cjs/components/swiper/SwiperPagIndicator.js +25 -27
  90. package/dist/cjs/components/swiper/tokens.js +10 -3
  91. package/dist/cjs/components/switch/Switch.js +13 -15
  92. package/dist/cjs/components/tabbar/Tabbar.js +35 -27
  93. package/dist/cjs/components/tabbar/TabbarContext.js +1 -2
  94. package/dist/cjs/components/tabbar/TabbarItem.js +65 -68
  95. package/dist/cjs/components/tabs/Tabs.js +286 -313
  96. package/dist/cjs/components/tag/Tag.js +46 -37
  97. package/dist/cjs/components/toast/Toast.js +90 -90
  98. package/dist/cjs/components/toast/imperative.js +16 -41
  99. package/dist/cjs/components/typography/Typography.js +3 -5
  100. package/dist/cjs/components/water-mark/WaterMark.js +31 -29
  101. package/dist/cjs/design-system/ThemeProvider.js +5 -11
  102. package/dist/cjs/design-system/createComponentTokensHook.js +11 -13
  103. package/dist/cjs/design-system/presets.js +2 -3
  104. package/dist/cjs/design-system/tokens.js +2 -11
  105. package/dist/cjs/hooks/animation/index.js +25 -0
  106. package/dist/cjs/hooks/animation/useAnimatedTransition.js +72 -0
  107. package/dist/cjs/hooks/animation/useReducedMotion.js +75 -0
  108. package/dist/cjs/hooks/aria/useAriaListBox.js +8 -16
  109. package/dist/cjs/hooks/aria/useAriaOverlay.js +3 -3
  110. package/dist/cjs/hooks/aria/useAriaPress.js +8 -21
  111. package/dist/cjs/hooks/aria/useAriaToggle.js +3 -3
  112. package/dist/cjs/hooks/gesture/useGestureScroll.js +60 -61
  113. package/dist/cjs/hooks/index.js +12 -0
  114. package/dist/cjs/hooks/overlay/OverlayStackStore.js +49 -69
  115. package/dist/cjs/hooks/overlay/useOverlayStack.js +13 -19
  116. package/dist/cjs/hooks/useControllableValue.js +10 -21
  117. package/dist/cjs/hooks/useCountDown.js +14 -22
  118. package/dist/cjs/hooks/useHairline.js +17 -29
  119. package/dist/cjs/hooks/useSafeAreaPadding.js +1 -4
  120. package/dist/cjs/index.js +67 -1
  121. package/dist/cjs/platform/animation.js +10 -2
  122. package/dist/cjs/platform/measure.js +18 -36
  123. package/dist/cjs/utils/color.js +21 -35
  124. package/dist/cjs/utils/compare.js +7 -12
  125. package/dist/cjs/utils/createPlatformShadow.js +28 -39
  126. package/dist/cjs/utils/date.js +20 -50
  127. package/dist/cjs/utils/deepMerge.js +16 -26
  128. package/dist/cjs/utils/hairline.js +74 -71
  129. package/dist/cjs/utils/index.js +22 -0
  130. package/dist/cjs/utils/number.js +21 -29
  131. package/dist/cjs/utils/render.js +27 -0
  132. package/dist/cjs/utils/rtl.js +25 -0
  133. package/dist/cjs/utils/string.js +8 -25
  134. package/dist/es/components/action-sheet/ActionSheet.js +99 -107
  135. package/dist/es/components/action-sheet/tokens.js +16 -27
  136. package/dist/es/components/area/Area.js +55 -68
  137. package/dist/es/components/area/tokens.js +6 -3
  138. package/dist/es/components/avatar/Avatar.js +25 -23
  139. package/dist/es/components/avatar/index.js +1 -2
  140. package/dist/es/components/badge/Badge.js +33 -33
  141. package/dist/es/components/badge/tokens.js +6 -8
  142. package/dist/es/components/button/Button.js +116 -152
  143. package/dist/es/components/button/ButtonGroup.js +9 -43
  144. package/dist/es/components/button/tokens.js +2 -3
  145. package/dist/es/components/calendar/Calendar.js +214 -225
  146. package/dist/es/components/calendar/tokens.js +3 -3
  147. package/dist/es/components/cascader/Cascader.js +180 -183
  148. package/dist/es/components/cascader/tokens.js +2 -2
  149. package/dist/es/components/cascader/useCascaderExtend.js +25 -29
  150. package/dist/es/components/cell/Cell.js +71 -84
  151. package/dist/es/components/cell/CellGroup.js +16 -28
  152. package/dist/es/components/checkbox/Checkbox.js +140 -133
  153. package/dist/es/components/checkbox/CheckboxGroup.js +5 -36
  154. package/dist/es/components/checkbox/tokens.js +7 -10
  155. package/dist/es/components/circle/Circle.js +25 -23
  156. package/dist/es/components/collapse/Collapse.js +77 -92
  157. package/dist/es/components/config-provider/ConfigProvider.js +10 -3
  158. package/dist/es/components/config-provider/DirectionContext.js +2 -0
  159. package/dist/es/components/config-provider/index.js +1 -0
  160. package/dist/es/components/config-provider/locale/en-US.js +32 -0
  161. package/dist/es/components/config-provider/locale/zh-CN.js +32 -0
  162. package/dist/es/components/config-provider/useDirection.js +3 -0
  163. package/dist/es/components/count-down/CountDown.js +23 -18
  164. package/dist/es/components/datetime-picker/DatetimePicker.js +61 -84
  165. package/dist/es/components/datetime-picker/tokens.js +14 -3
  166. package/dist/es/components/dialog/Dialog.js +154 -121
  167. package/dist/es/components/dialog/imperative.js +17 -30
  168. package/dist/es/components/divider/Divider.js +28 -29
  169. package/dist/es/components/empty/Empty.js +36 -39
  170. package/dist/es/components/error-boundary/ErrorBoundary.js +61 -0
  171. package/dist/es/components/error-boundary/index.js +1 -0
  172. package/dist/es/components/field/Field.js +109 -106
  173. package/dist/es/components/flex/Flex.js +18 -17
  174. package/dist/es/components/flex/FlexItem.js +27 -27
  175. package/dist/es/components/form/Form.js +143 -162
  176. package/dist/es/components/form/FormItem.js +68 -95
  177. package/dist/es/components/form/FormList.js +49 -37
  178. package/dist/es/components/form/tokens.js +6 -3
  179. package/dist/es/components/form/utils.js +15 -34
  180. package/dist/es/components/grid/Grid.js +30 -28
  181. package/dist/es/components/grid/GridItem.js +84 -84
  182. package/dist/es/components/image/Image.js +58 -62
  183. package/dist/es/components/image/tokens.js +2 -2
  184. package/dist/es/components/image-preview/ImagePreview.js +124 -112
  185. package/dist/es/components/image-preview/imperative.js +4 -13
  186. package/dist/es/components/index.js +3 -1
  187. package/dist/es/components/input/Input.js +31 -23
  188. package/dist/es/components/loading/Loading.js +16 -16
  189. package/dist/es/components/nav-bar/NavBar.js +68 -83
  190. package/dist/es/components/nav-bar/tokens.js +1 -3
  191. package/dist/es/components/notice-bar/NoticeBar.js +74 -76
  192. package/dist/es/components/notify/Notify.js +92 -87
  193. package/dist/es/components/notify/imperative.js +21 -44
  194. package/dist/es/components/notify/tokens.js +1 -5
  195. package/dist/es/components/number-keyboard/NumberKeyboard.js +187 -209
  196. package/dist/es/components/overlay/Overlay.js +36 -51
  197. package/dist/es/components/overlay/tokens.js +5 -3
  198. package/dist/es/components/password-input/PasswordInput.js +98 -79
  199. package/dist/es/components/picker/Picker.js +440 -421
  200. package/dist/es/components/picker/tokens.js +1 -1
  201. package/dist/es/components/popup/Popup.js +263 -292
  202. package/dist/es/components/portal/Portal.js +13 -29
  203. package/dist/es/components/portal/PortalHost.js +152 -234
  204. package/dist/es/components/progress/Progress.js +51 -48
  205. package/dist/es/components/radio/Radio.js +47 -44
  206. package/dist/es/components/radio/RadioGroup.js +10 -41
  207. package/dist/es/components/radio/tokens.js +7 -10
  208. package/dist/es/components/safe-area-view/SafeAreaView.js +22 -25
  209. package/dist/es/components/search/Search.js +52 -44
  210. package/dist/es/components/selector/Selector.js +14 -13
  211. package/dist/es/components/share-sheet/ShareSheet.js +162 -163
  212. package/dist/es/components/sidebar/Sidebar.js +41 -47
  213. package/dist/es/components/sidebar/SidebarContext.js +1 -2
  214. package/dist/es/components/sidebar/SidebarItem.js +13 -15
  215. package/dist/es/components/sidebar/tokens.js +1 -3
  216. package/dist/es/components/skeleton/Skeleton.js +30 -37
  217. package/dist/es/components/skeleton/tokens.js +1 -2
  218. package/dist/es/components/slider/Slider.js +156 -134
  219. package/dist/es/components/space/Space.js +48 -71
  220. package/dist/es/components/stepper/Stepper.js +178 -156
  221. package/dist/es/components/swiper/Swiper.js +252 -254
  222. package/dist/es/components/swiper/SwiperPagIndicator.js +25 -27
  223. package/dist/es/components/swiper/tokens.js +10 -3
  224. package/dist/es/components/switch/Switch.js +13 -15
  225. package/dist/es/components/tabbar/Tabbar.js +36 -28
  226. package/dist/es/components/tabbar/TabbarContext.js +1 -2
  227. package/dist/es/components/tabbar/TabbarItem.js +66 -69
  228. package/dist/es/components/tabs/Tabs.js +286 -313
  229. package/dist/es/components/tag/Tag.js +49 -39
  230. package/dist/es/components/toast/Toast.js +93 -91
  231. package/dist/es/components/toast/imperative.js +16 -41
  232. package/dist/es/components/typography/Typography.js +3 -5
  233. package/dist/es/components/water-mark/WaterMark.js +32 -30
  234. package/dist/es/design-system/ThemeProvider.js +5 -11
  235. package/dist/es/design-system/createComponentTokensHook.js +11 -13
  236. package/dist/es/design-system/presets.js +2 -3
  237. package/dist/es/design-system/tokens.js +1 -9
  238. package/dist/es/hooks/animation/index.js +2 -0
  239. package/dist/es/hooks/animation/useAnimatedTransition.js +53 -0
  240. package/dist/es/hooks/animation/useReducedMotion.js +54 -0
  241. package/dist/es/hooks/aria/useAriaListBox.js +8 -16
  242. package/dist/es/hooks/aria/useAriaOverlay.js +3 -3
  243. package/dist/es/hooks/aria/useAriaPress.js +8 -21
  244. package/dist/es/hooks/aria/useAriaToggle.js +3 -3
  245. package/dist/es/hooks/gesture/useGestureScroll.js +60 -61
  246. package/dist/es/hooks/index.js +1 -0
  247. package/dist/es/hooks/overlay/OverlayStackStore.js +49 -69
  248. package/dist/es/hooks/overlay/useOverlayStack.js +13 -19
  249. package/dist/es/hooks/useControllableValue.js +10 -21
  250. package/dist/es/hooks/useCountDown.js +14 -22
  251. package/dist/es/hooks/useHairline.js +16 -28
  252. package/dist/es/hooks/useSafeAreaPadding.js +1 -4
  253. package/dist/es/index.js +8 -1
  254. package/dist/es/platform/animation.js +9 -1
  255. package/dist/es/platform/measure.js +18 -36
  256. package/dist/es/utils/color.js +21 -35
  257. package/dist/es/utils/compare.js +7 -12
  258. package/dist/es/utils/createPlatformShadow.js +28 -39
  259. package/dist/es/utils/date.js +20 -50
  260. package/dist/es/utils/deepMerge.js +16 -26
  261. package/dist/es/utils/hairline.js +73 -65
  262. package/dist/es/utils/index.js +2 -0
  263. package/dist/es/utils/number.js +21 -29
  264. package/dist/es/utils/render.js +7 -0
  265. package/dist/es/utils/rtl.js +17 -0
  266. package/dist/es/utils/string.js +8 -25
  267. package/dist/types/components/action-sheet/ActionSheet.d.ts +1 -1
  268. package/dist/types/components/area/Area.d.ts +1 -1
  269. package/dist/types/components/area/tokens.d.ts +4 -0
  270. package/dist/types/components/avatar/Avatar.d.ts +1 -1
  271. package/dist/types/components/avatar/index.d.ts +1 -2
  272. package/dist/types/components/badge/Badge.d.ts +1 -1
  273. package/dist/types/components/button/Button.d.ts +1 -1
  274. package/dist/types/components/button/index.d.ts +1 -1
  275. package/dist/types/components/calendar/Calendar.d.ts +1 -1
  276. package/dist/types/components/cascader/Cascader.d.ts +1 -1
  277. package/dist/types/components/cell/Cell.d.ts +1 -1
  278. package/dist/types/components/cell/CellGroup.d.ts +1 -1
  279. package/dist/types/components/cell/index.d.ts +2 -2
  280. package/dist/types/components/checkbox/Checkbox.d.ts +1 -1
  281. package/dist/types/components/circle/Circle.d.ts +1 -1
  282. package/dist/types/components/collapse/Collapse.d.ts +1 -2
  283. package/dist/types/components/config-provider/DirectionContext.d.ts +3 -0
  284. package/dist/types/components/config-provider/index.d.ts +2 -1
  285. package/dist/types/components/config-provider/locale/en-US.d.ts +32 -0
  286. package/dist/types/components/config-provider/locale/zh-CN.d.ts +32 -0
  287. package/dist/types/components/config-provider/useDirection.d.ts +1 -0
  288. package/dist/types/components/count-down/CountDown.d.ts +1 -1
  289. package/dist/types/components/datetime-picker/DatetimePicker.d.ts +1 -1
  290. package/dist/types/components/datetime-picker/tokens.d.ts +12 -0
  291. package/dist/types/components/dialog/Dialog.d.ts +1 -1
  292. package/dist/types/components/divider/Divider.d.ts +1 -1
  293. package/dist/types/components/empty/Empty.d.ts +1 -1
  294. package/dist/types/components/error-boundary/ErrorBoundary.d.ts +6 -0
  295. package/dist/types/components/error-boundary/index.d.ts +2 -0
  296. package/dist/types/components/field/Field.d.ts +1 -1
  297. package/dist/types/components/flex/Flex.d.ts +1 -1
  298. package/dist/types/components/flex/FlexItem.d.ts +1 -1
  299. package/dist/types/components/flex/index.d.ts +2 -2
  300. package/dist/types/components/form/Form.d.ts +1 -1
  301. package/dist/types/components/form/FormItem.d.ts +2 -1
  302. package/dist/types/components/form/index.d.ts +2 -2
  303. package/dist/types/components/form/tokens.d.ts +4 -0
  304. package/dist/types/components/grid/Grid.d.ts +1 -1
  305. package/dist/types/components/grid/GridItem.d.ts +1 -1
  306. package/dist/types/components/grid/index.d.ts +2 -2
  307. package/dist/types/components/image/Image.d.ts +1 -1
  308. package/dist/types/components/image-preview/ImagePreview.d.ts +1 -1
  309. package/dist/types/components/index.d.ts +4 -1
  310. package/dist/types/components/input/Input.d.ts +3 -3
  311. package/dist/types/components/loading/Loading.d.ts +1 -1
  312. package/dist/types/components/nav-bar/NavBar.d.ts +1 -1
  313. package/dist/types/components/notice-bar/NoticeBar.d.ts +1 -1
  314. package/dist/types/components/notify/Notify.d.ts +2 -2
  315. package/dist/types/components/notify/index.d.ts +1 -1
  316. package/dist/types/components/overlay/Overlay.d.ts +1 -5
  317. package/dist/types/components/overlay/tokens.d.ts +3 -0
  318. package/dist/types/components/password-input/PasswordInput.d.ts +1 -1
  319. package/dist/types/components/picker/Picker.d.ts +5 -5
  320. package/dist/types/components/popup/Popup.d.ts +3 -42
  321. package/dist/types/components/portal/Portal.d.ts +9 -6
  322. package/dist/types/components/portal/PortalHost.d.ts +1 -1
  323. package/dist/types/components/radio/RadioGroup.d.ts +1 -1
  324. package/dist/types/components/safe-area-view/SafeAreaView.d.ts +1 -1
  325. package/dist/types/components/search/Search.d.ts +1 -1
  326. package/dist/types/components/share-sheet/ShareSheet.d.ts +1 -1
  327. package/dist/types/components/sidebar/Sidebar.d.ts +1 -1
  328. package/dist/types/components/sidebar/SidebarContext.d.ts +1 -1
  329. package/dist/types/components/sidebar/SidebarItem.d.ts +1 -1
  330. package/dist/types/components/sidebar/index.d.ts +2 -2
  331. package/dist/types/components/skeleton/Skeleton.d.ts +1 -1
  332. package/dist/types/components/slider/Slider.d.ts +1 -1
  333. package/dist/types/components/stepper/Stepper.d.ts +1 -1
  334. package/dist/types/components/swiper/Swiper.d.ts +1 -1
  335. package/dist/types/components/swiper/index.d.ts +1 -1
  336. package/dist/types/components/swiper/tokens.d.ts +8 -0
  337. package/dist/types/components/tabbar/Tabbar.d.ts +2 -2
  338. package/dist/types/components/tabbar/TabbarContext.d.ts +1 -1
  339. package/dist/types/components/tabbar/TabbarItem.d.ts +2 -2
  340. package/dist/types/components/tabs/Tabs.d.ts +1 -1
  341. package/dist/types/components/tabs/index.d.ts +1 -1
  342. package/dist/types/components/tag/Tag.d.ts +1 -1
  343. package/dist/types/components/toast/Toast.d.ts +2 -2
  344. package/dist/types/components/toast/index.d.ts +1 -1
  345. package/dist/types/components/water-mark/WaterMark.d.ts +1 -1
  346. package/dist/types/design-system/tokens.d.ts +0 -1
  347. package/dist/types/hooks/animation/index.d.ts +3 -0
  348. package/dist/types/hooks/animation/useAnimatedTransition.d.ts +13 -0
  349. package/dist/types/hooks/animation/useReducedMotion.d.ts +3 -0
  350. package/dist/types/hooks/aria/useAriaOverlay.d.ts +1 -1
  351. package/dist/types/hooks/gesture/useGestureScroll.d.ts +11 -10
  352. package/dist/types/hooks/index.d.ts +1 -0
  353. package/dist/types/hooks/overlay/OverlayStackStore.d.ts +8 -8
  354. package/dist/types/hooks/useHairline.d.ts +1 -1
  355. package/dist/types/index.d.ts +5 -0
  356. package/dist/types/platform/animation.d.ts +8 -0
  357. package/dist/types/platform/measure.d.ts +1 -1
  358. package/dist/types/utils/compare.d.ts +1 -1
  359. package/dist/types/utils/createPlatformShadow.d.ts +2 -2
  360. package/dist/types/utils/date.d.ts +2 -2
  361. package/dist/types/utils/hairline.d.ts +5 -10
  362. package/dist/types/utils/index.d.ts +2 -0
  363. package/dist/types/utils/number.d.ts +2 -2
  364. package/dist/types/utils/render.d.ts +5 -0
  365. package/dist/types/utils/rtl.d.ts +5 -0
  366. package/package.json +9 -2
@@ -1,23 +1,18 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useRef, useState, useCallback, useEffect, useImperativeHandle, forwardRef, useMemo, Children, isValidElement } from 'react';
2
+ import React, { useRef, useState, useCallback, useEffect, useImperativeHandle, forwardRef, memo, useMemo, Children, isValidElement } from 'react';
3
3
  import { FlatList, View, StyleSheet, useWindowDimensions, Platform } from 'react-native';
4
4
  import { clamp } from '../../utils/number';
5
5
  import SwiperPagIndicator from './SwiperPagIndicator';
6
- export const SwiperItem = /*#__PURE__*/forwardRef((props, ref) => {
7
- const {
8
- style,
9
- children,
10
- testID
11
- } = props;
12
- return /*#__PURE__*/React.createElement(View, {
13
- ref: ref,
14
- style: [styles.item, style],
15
- testID: testID
16
- }, children);
17
- });
18
- SwiperItem.displayName = 'SwiperItem';
19
- const DEFAULT_AUTOPLAY_INTERVAL = 3000;
20
- const LOOP_RENDER_ALL_THRESHOLD = 10;
6
+ import { useSwiperTokens } from './tokens';
7
+ const SwiperItemImpl = (props, ref) => /*#__PURE__*/React.createElement(View, {
8
+ ref: ref,
9
+ style: [S.item, props.style],
10
+ testID: props.testID
11
+ }, props.children);
12
+ const SwiperItemFR = /*#__PURE__*/forwardRef(SwiperItemImpl);
13
+ SwiperItemFR.displayName = 'SwiperItem';
14
+ export const SwiperItem = /*#__PURE__*/memo(SwiperItemFR);
15
+ const LOOP_THRESHOLD = 10;
21
16
  const SwiperImpl = (props, ref) => {
22
17
  const {
23
18
  data,
@@ -34,310 +29,313 @@ const SwiperImpl = (props, ref) => {
34
29
  style,
35
30
  testID
36
31
  } = props;
37
- const flatListRef = useRef(null);
38
- const autoplayTimerRef = useRef(null);
39
- const isInteractingRef = useRef(false);
40
- const isAnimatingRef = useRef(false);
41
- const queuedIndexRef = useRef(null);
42
- const isMomentumRef = useRef(false);
32
+ const tokens = useSwiperTokens();
33
+ const listRef = useRef(null);
34
+ const autoRef = useRef(null);
35
+ const interRef = useRef(false);
36
+ const animRef = useRef(false);
37
+ const queueRef = useRef(null);
38
+ const momRef = useRef(false);
39
+ const dragRef = useRef(null);
43
40
  const isWeb = Platform.OS === 'web';
44
41
  const {
45
- width: windowWidth,
46
- height: windowHeight
42
+ width: wW,
43
+ height: wH
47
44
  } = useWindowDimensions();
48
45
  const [layout, setLayout] = useState({
49
46
  width: 0,
50
47
  height: 0
51
48
  });
52
- const handleLayout = useCallback(event => {
49
+ const onLayout = useCallback(e => {
53
50
  const {
54
- width,
55
- height
56
- } = event.nativeEvent.layout;
57
- setLayout(prev => prev.width === width && prev.height === height ? prev : {
58
- width,
59
- height
51
+ width: w,
52
+ height: h
53
+ } = e.nativeEvent.layout;
54
+ setLayout(p => p.width === w && p.height === h ? p : {
55
+ width: w,
56
+ height: h
60
57
  });
61
58
  }, []);
62
- const childItems = useMemo(() => {
63
- if (!children) return [];
64
- return Children.toArray(children).filter(child => /*#__PURE__*/isValidElement(child));
65
- }, [children]);
59
+ const items = useMemo(() => !children ? [] : Children.toArray(children).filter(c => /*#__PURE__*/isValidElement(c)), [children]);
66
60
  const usingData = Array.isArray(data);
67
- const baseItems = useMemo(() => usingData ? data : childItems, [usingData, data, childItems]);
68
- const count = baseItems.length;
61
+ const base = usingData ? data : items;
62
+ const count = base.length;
69
63
  const shouldLoop = loop && count > 1;
70
- const displayData = useMemo(() => {
71
- if (!shouldLoop) return baseItems;
72
- const head = baseItems[count - 1];
73
- const tail = baseItems[0];
74
- return [head, ...baseItems, tail];
75
- }, [baseItems, shouldLoop, count]);
76
- const displayCount = displayData.length;
77
- const loopRenderAll = shouldLoop && displayCount <= LOOP_RENDER_ALL_THRESHOLD;
78
- const getRealIndex = useCallback(displayIndex => {
79
- if (!shouldLoop) return clamp(displayIndex, 0, count - 1);
80
- if (displayIndex === 0) return count - 1;
81
- if (displayIndex === displayCount - 1) return 0;
82
- return displayIndex - 1;
83
- }, [shouldLoop, count, displayCount]);
84
- const getDisplayIndex = useCallback(realIndex => {
85
- if (!shouldLoop) return clamp(realIndex, 0, count - 1);
86
- return clamp(realIndex, 0, count - 1) + 1;
87
- }, [shouldLoop, count]);
88
- const initialRealIndex = clamp(initialSwipe, 0, Math.max(0, count - 1));
89
- const initialDisplayIndex = getDisplayIndex(initialRealIndex);
90
- const currentIndexRef = useRef(initialRealIndex);
91
- const [currentIndex, setCurrentIndex] = useState(initialRealIndex);
92
- const layoutReady = layout.width > 0 && layout.height > 0;
93
- const mainSize = vertical ? layout.height || windowHeight || 1 : layout.width || windowWidth || 1;
94
- const crossSize = vertical ? layout.width || windowWidth || 1 : layout.height || windowHeight || 1;
95
- const itemStyle = useMemo(() => ({
96
- width: vertical ? crossSize : mainSize,
97
- height: vertical ? mainSize : crossSize
98
- }), [vertical, mainSize, crossSize]);
99
- const clearAutoplay = useCallback(() => {
100
- if (autoplayTimerRef.current) {
101
- clearTimeout(autoplayTimerRef.current);
102
- autoplayTimerRef.current = null;
64
+ const display = useMemo(() => shouldLoop ? [base[count - 1], ...base, base[0]] : base, [base, shouldLoop, count]);
65
+ const dCount = display.length;
66
+ const loopAll = shouldLoop && dCount <= LOOP_THRESHOLD;
67
+ const realIdx = useCallback(di => !shouldLoop ? clamp(di, 0, count - 1) : di === 0 ? count - 1 : di === dCount - 1 ? 0 : di - 1, [shouldLoop, count, dCount]);
68
+ const dispIdx = useCallback(ri => shouldLoop ? clamp(ri, 0, count - 1) + 1 : clamp(ri, 0, count - 1), [shouldLoop, count]);
69
+ const initReal = clamp(initialSwipe, 0, Math.max(0, count - 1));
70
+ const initDisp = dispIdx(initReal);
71
+ const curRef = useRef(initReal);
72
+ const [curIdx, setCurIdx] = useState(initReal);
73
+ const ready = layout.width > 0 && layout.height > 0;
74
+ const mainSz = vertical ? layout.height || wH || 1 : layout.width || wW || 1;
75
+ const crossSz = vertical ? layout.width || wW || 1 : layout.height || wH || 1;
76
+ const itemSz = useMemo(() => ({
77
+ width: vertical ? crossSz : mainSz,
78
+ height: vertical ? mainSz : crossSz
79
+ }), [vertical, mainSz, crossSz]);
80
+ const clearAuto = useCallback(() => {
81
+ if (autoRef.current) {
82
+ clearTimeout(autoRef.current);
83
+ autoRef.current = null;
103
84
  }
104
85
  }, []);
105
- const updateIndex = useCallback(next => {
106
- const clamped = clamp(next, 0, Math.max(0, count - 1));
107
- if (currentIndexRef.current === clamped) return;
108
- currentIndexRef.current = clamped;
109
- setCurrentIndex(clamped);
110
- onChange?.(clamped);
111
- }, [count, onChange]);
112
- const scrollToDisplayIndex = useCallback((displayIndex, animated) => {
86
+ const onChangeRef = useRef(onChange);
87
+ onChangeRef.current = onChange;
88
+ const update = useCallback(n => {
89
+ const c = clamp(n, 0, Math.max(0, count - 1));
90
+ if (curRef.current === c) return;
91
+ curRef.current = c;
92
+ setCurIdx(c);
93
+ onChangeRef.current?.(c);
94
+ }, [count]);
95
+ const scrollTo = useCallback((i, anim) => {
113
96
  try {
114
- flatListRef.current?.scrollToIndex({
115
- index: displayIndex,
116
- animated
97
+ listRef.current?.scrollToIndex({
98
+ index: i,
99
+ animated: anim
117
100
  });
118
101
  } catch {}
119
102
  }, []);
120
103
  const swipeTo = useCallback((index, animated = true) => {
121
104
  if (count === 0) return;
122
- if (animated && isAnimatingRef.current) {
123
- queuedIndexRef.current = index;
105
+ if (animated && animRef.current) {
106
+ queueRef.current = index;
124
107
  return;
125
108
  }
126
- const targetRealIndex = clamp(index, 0, count - 1);
127
- let targetDisplayIndex = getDisplayIndex(targetRealIndex);
128
- let resolvedAnimated = animated;
129
- if (isWeb && shouldLoop && animated) {
130
- const currentRealIndex = currentIndexRef.current;
131
- if (currentRealIndex === count - 1 && targetRealIndex === 0 || currentRealIndex === 0 && targetRealIndex === count - 1) {
132
- resolvedAnimated = false;
133
- }
134
- }
135
- if (shouldLoop && resolvedAnimated) {
136
- const currentDisplayIndex = getDisplayIndex(currentIndexRef.current);
137
- if (currentDisplayIndex === count && targetRealIndex === 0) {
138
- targetDisplayIndex = displayCount - 1;
139
- } else if (currentDisplayIndex === 1 && targetRealIndex === count - 1) {
140
- targetDisplayIndex = 0;
141
- }
109
+ const tReal = clamp(index, 0, count - 1);
110
+ let tDisp = dispIdx(tReal);
111
+ if (shouldLoop && animated) {
112
+ const cDisp = dispIdx(curRef.current);
113
+ if (cDisp === count && tReal === 0) tDisp = dCount - 1;else if (cDisp === 1 && tReal === count - 1) tDisp = 0;
142
114
  }
143
- const currentRealIndex = currentIndexRef.current;
144
- const currentDisplayIndex = getDisplayIndex(currentRealIndex);
145
- if (targetRealIndex === currentRealIndex && targetDisplayIndex === currentDisplayIndex) {
146
- if (queuedIndexRef.current != null) {
147
- const next = queuedIndexRef.current;
148
- queuedIndexRef.current = null;
149
- swipeTo(next, true);
115
+ const cReal = curRef.current,
116
+ cDisp = dispIdx(cReal);
117
+ if (tReal === cReal && tDisp === cDisp) {
118
+ if (queueRef.current != null) {
119
+ const q = queueRef.current;
120
+ queueRef.current = null;
121
+ swipeTo(q, true);
150
122
  }
123
+ ;
151
124
  return;
152
125
  }
153
- if (resolvedAnimated) {
154
- isAnimatingRef.current = true;
155
- }
156
- scrollToDisplayIndex(targetDisplayIndex, resolvedAnimated);
157
- if (!resolvedAnimated) {
158
- updateIndex(targetRealIndex);
159
- if (queuedIndexRef.current != null) {
160
- const next = queuedIndexRef.current;
161
- queuedIndexRef.current = null;
162
- swipeTo(next, true);
126
+ if (animated) animRef.current = true;
127
+ scrollTo(tDisp, animated);
128
+ if (!animated) {
129
+ update(tReal);
130
+ if (queueRef.current != null) {
131
+ const q = queueRef.current;
132
+ queueRef.current = null;
133
+ swipeTo(q, true);
163
134
  }
164
135
  }
165
- }, [count, getDisplayIndex, scrollToDisplayIndex, shouldLoop, displayCount, updateIndex, isWeb]);
166
- const resolveAutoplayInterval = useCallback(() => {
167
- if (typeof autoplay === 'number') return Math.max(0, autoplay);
168
- if (autoplay) return DEFAULT_AUTOPLAY_INTERVAL;
169
- return 0;
170
- }, [autoplay]);
171
- const scheduleAutoplay = useCallback(() => {
172
- const interval = resolveAutoplayInterval();
173
- if (!interval || count <= 1) return;
174
- if (isInteractingRef.current && !isWeb) return;
175
- clearAutoplay();
176
- autoplayTimerRef.current = setTimeout(() => {
177
- if (isInteractingRef.current && !isWeb) return;
178
- const nextIndex = shouldLoop ? (currentIndexRef.current + 1) % count : clamp(currentIndexRef.current + 1, 0, count - 1);
179
- swipeTo(nextIndex, true);
180
- }, interval);
181
- }, [resolveAutoplayInterval, count, clearAutoplay, shouldLoop, swipeTo]);
182
- const swipeNext = useCallback(() => {
136
+ }, [count, dispIdx, scrollTo, shouldLoop, dCount, update]);
137
+ const schedule = useCallback(() => {
138
+ const iv = typeof autoplay === 'number' ? Math.max(0, autoplay) : autoplay ? tokens.defaults.autoplayInterval : 0;
139
+ if (!iv || count <= 1) return;
140
+ if (interRef.current && !isWeb) return;
141
+ clearAuto();
142
+ autoRef.current = setTimeout(() => {
143
+ if (interRef.current && !isWeb) return;
144
+ swipeTo(shouldLoop ? (curRef.current + 1) % count : clamp(curRef.current + 1, 0, count - 1), true);
145
+ }, iv);
146
+ }, [autoplay, count, clearAuto, shouldLoop, swipeTo, isWeb, tokens.defaults.autoplayInterval]);
147
+ const next = useCallback(() => {
183
148
  if (count === 0) return;
184
- const next = shouldLoop ? (currentIndexRef.current + 1) % count : clamp(currentIndexRef.current + 1, 0, count - 1);
185
- swipeTo(next, true);
149
+ swipeTo(shouldLoop ? (curRef.current + 1) % count : clamp(curRef.current + 1, 0, count - 1), true);
186
150
  }, [count, shouldLoop, swipeTo]);
187
- const swipePrev = useCallback(() => {
151
+ const prev = useCallback(() => {
188
152
  if (count === 0) return;
189
- const next = shouldLoop ? (currentIndexRef.current - 1 + count) % count : clamp(currentIndexRef.current - 1, 0, count - 1);
190
- swipeTo(next, true);
153
+ swipeTo(shouldLoop ? (curRef.current - 1 + count) % count : clamp(curRef.current - 1, 0, count - 1), true);
191
154
  }, [count, shouldLoop, swipeTo]);
192
- const flushQueuedSwipe = () => {
193
- if (queuedIndexRef.current == null) return;
194
- const next = queuedIndexRef.current;
195
- queuedIndexRef.current = null;
196
- swipeTo(next, true);
155
+ const flush = () => {
156
+ if (queueRef.current == null) return;
157
+ const q = queueRef.current;
158
+ queueRef.current = null;
159
+ swipeTo(q, true);
197
160
  };
198
161
  useImperativeHandle(ref, () => ({
199
162
  swipeTo,
200
- swipeNext,
201
- swipePrev,
202
- getCurrentIndex: () => currentIndexRef.current
203
- }), [swipeTo, swipeNext, swipePrev]);
163
+ swipeNext: next,
164
+ swipePrev: prev,
165
+ getCurrentIndex: () => curRef.current
166
+ }), [swipeTo, next, prev]);
204
167
  useEffect(() => {
205
- if (!layoutReady || count === 0) return;
206
- scrollToDisplayIndex(initialDisplayIndex, false);
207
- }, [layoutReady, count, initialDisplayIndex, scrollToDisplayIndex]);
168
+ if (!ready || count === 0) return;
169
+ scrollTo(initDisp, false);
170
+ }, [ready, count, initDisp, scrollTo]);
208
171
  useEffect(() => {
209
- scheduleAutoplay();
210
- return clearAutoplay;
211
- }, [scheduleAutoplay, clearAutoplay, currentIndex]);
212
- const handleScrollBeginDrag = () => {
213
- isInteractingRef.current = true;
214
- clearAutoplay();
215
- };
216
- const handleScroll = event => {
217
- if (!isWeb || count <= 1) return;
218
- const offset = vertical ? event.nativeEvent.contentOffset.y : event.nativeEvent.contentOffset.x;
219
- const displayIndex = Math.round(offset / mainSize);
220
- const nextDisplayIndex = shouldLoop ? clamp(displayIndex, 0, displayCount - 1) : clamp(displayIndex, 0, count - 1);
221
- updateIndex(getRealIndex(nextDisplayIndex));
222
- const alignedOffset = Math.round(offset / mainSize) * mainSize;
223
- if (Math.abs(offset - alignedOffset) < 0.5) {
224
- isAnimatingRef.current = false;
225
- isInteractingRef.current = false;
226
- isMomentumRef.current = false;
227
- scheduleAutoplay();
228
- flushQueuedSwipe();
172
+ schedule();
173
+ return clearAuto;
174
+ }, [schedule, clearAuto, curIdx]);
175
+ const reset = useCallback(() => {
176
+ animRef.current = false;
177
+ interRef.current = false;
178
+ momRef.current = false;
179
+ schedule();
180
+ flush();
181
+ }, [schedule]);
182
+ const onScroll = useCallback(e => {
183
+ if (count <= 1) return;
184
+ const off = vertical ? e.nativeEvent.contentOffset.y : e.nativeEvent.contentOffset.x;
185
+ const di = Math.round(off / mainSz);
186
+ const cdi = shouldLoop ? clamp(di, 0, dCount - 1) : clamp(di, 0, count - 1);
187
+ update(realIdx(cdi));
188
+ if (isWeb) {
189
+ const aligned = di * mainSz;
190
+ if (Math.abs(off - aligned) < 0.5) {
191
+ if (shouldLoop && (di <= 0 || di >= dCount - 1)) scrollTo(di <= 0 ? count : 1, false);
192
+ reset();
193
+ }
229
194
  }
230
- };
231
- const handleMomentumScrollBegin = () => {
232
- isMomentumRef.current = true;
233
- };
234
- const handleScrollEndDrag = event => {
235
- if (isMomentumRef.current) return;
236
- handleScrollEnd(event);
237
- };
238
- const handleScrollEnd = event => {
239
- if (count === 0) return;
240
- const offset = vertical ? event.nativeEvent.contentOffset.y : event.nativeEvent.contentOffset.x;
241
- const displayIndex = Math.round(offset / mainSize);
242
- let nextDisplayIndex = displayIndex;
195
+ }, [count, vertical, mainSz, shouldLoop, dCount, update, realIdx, scrollTo, reset, isWeb]);
196
+ const onEnd = useCallback(e => {
197
+ if (isWeb || count === 0) return;
198
+ const off = vertical ? e.nativeEvent.contentOffset.y : e.nativeEvent.contentOffset.x;
199
+ const di = Math.round(off / mainSz);
200
+ let ndi = di;
243
201
  if (shouldLoop) {
244
- if (displayIndex === 0) nextDisplayIndex = count;
245
- if (displayIndex === displayCount - 1) nextDisplayIndex = 1;
202
+ if (di === 0) ndi = count;
203
+ if (di === dCount - 1) ndi = 1;
246
204
  }
247
- if (nextDisplayIndex !== displayIndex) {
248
- scrollToDisplayIndex(nextDisplayIndex, false);
249
- }
250
- updateIndex(getRealIndex(nextDisplayIndex));
251
- isInteractingRef.current = false;
252
- isAnimatingRef.current = false;
253
- isMomentumRef.current = false;
254
- scheduleAutoplay();
255
- flushQueuedSwipe();
256
- };
257
- const renderIndicator = () => {
258
- if (indicator === false || count <= 1) return null;
259
- if (typeof indicator === 'function') return indicator(count, currentIndex);
260
- return /*#__PURE__*/React.createElement(SwiperPagIndicator, _extends({}, indicatorProps, {
261
- total: count,
262
- current: currentIndex,
263
- vertical: vertical
264
- }));
265
- };
205
+ if (ndi !== di) scrollTo(ndi, false);
206
+ update(realIdx(ndi));
207
+ reset();
208
+ }, [vertical, count, mainSz, shouldLoop, dCount, scrollTo, update, realIdx, reset, isWeb]);
209
+ const onDragBegin = useCallback(() => {
210
+ interRef.current = true;
211
+ clearAuto();
212
+ }, [clearAuto]);
213
+ const onDragEnd = useCallback(e => {
214
+ if (!momRef.current) onEnd(e);
215
+ }, [onEnd]);
216
+ const onMomBegin = useCallback(() => {
217
+ momRef.current = true;
218
+ }, []);
219
+ const onFail = useCallback(info => {
220
+ scrollTo(info.index, false);
221
+ update(realIdx(info.index));
222
+ reset();
223
+ }, [scrollTo, update, realIdx, reset]);
224
+ const renderItemRef = useRef(renderItem);
225
+ renderItemRef.current = renderItem;
266
226
  const renderSlide = useCallback(info => {
267
- const content = usingData ? renderItem?.(info) ?? null : info.item;
268
- if (!content) return null;
269
- return /*#__PURE__*/React.createElement(View, {
270
- style: [styles.slide, itemStyle]
271
- }, content);
272
- }, [usingData, renderItem, itemStyle]);
227
+ const c = usingData ? renderItemRef.current?.(info) ?? null : info.item;
228
+ return c ? /*#__PURE__*/React.createElement(View, {
229
+ style: [S.slide, itemSz]
230
+ }, c) : null;
231
+ }, [usingData, itemSz]);
232
+ const getLayout = useCallback((_, i) => ({
233
+ length: mainSz,
234
+ offset: mainSz * i,
235
+ index: i
236
+ }), [mainSz]);
237
+ const keyEx = useCallback((_, i) => `s-${i}`, []);
273
238
  if (count === 0) return null;
274
- return /*#__PURE__*/React.createElement(View, {
275
- style: [styles.container, style],
276
- onLayout: handleLayout,
239
+ const indNode = indicator === false || count <= 1 ? null : typeof indicator === 'function' ? indicator(count, curIdx) : /*#__PURE__*/React.createElement(SwiperPagIndicator, _extends({}, indicatorProps, {
240
+ total: count,
241
+ current: curIdx,
242
+ vertical: vertical
243
+ }));
244
+ const webMouse = isWeb && touchable && count > 1 ? {
245
+ onPointerDown: e => {
246
+ if (e.nativeEvent.pointerType !== 'mouse' || e.nativeEvent.button !== 0) return;
247
+ dragRef.current = vertical ? e.nativeEvent.pageY : e.nativeEvent.pageX;
248
+ interRef.current = true;
249
+ clearAuto();
250
+ },
251
+ onPointerUp: e => {
252
+ const s = dragRef.current;
253
+ dragRef.current = null;
254
+ if (s == null || e.nativeEvent.pointerType !== 'mouse') return;
255
+ const d = (vertical ? e.nativeEvent.pageY : e.nativeEvent.pageX) - s;
256
+ if (Math.abs(d) >= mainSz * 0.15) {
257
+ d < 0 ? next() : prev();
258
+ }
259
+ ;
260
+ interRef.current = false;
261
+ schedule();
262
+ },
263
+ onPointerLeave: () => {
264
+ if (dragRef.current != null) {
265
+ dragRef.current = null;
266
+ interRef.current = false;
267
+ schedule();
268
+ }
269
+ }
270
+ } : undefined;
271
+ return /*#__PURE__*/React.createElement(View, _extends({
272
+ accessibilityRole: "adjustable",
273
+ accessibilityLabel: `swiper, ${curIdx + 1} of ${count}`,
274
+ accessibilityValue: {
275
+ min: 0,
276
+ max: count - 1,
277
+ now: curIdx
278
+ },
279
+ style: [S.ctr, webMouse && S.web, style],
280
+ onLayout: onLayout,
277
281
  testID: testID
278
- }, /*#__PURE__*/React.createElement(FlatList, {
279
- ref: flatListRef,
280
- data: displayData,
282
+ }, webMouse), /*#__PURE__*/React.createElement(FlatList, {
283
+ ref: listRef,
284
+ data: display,
281
285
  renderItem: renderSlide,
282
- keyExtractor: (_item, index) => `swiper-${index}`,
286
+ keyExtractor: keyEx,
283
287
  horizontal: !vertical,
284
- getItemLayout: (_, index) => ({
285
- length: mainSize,
286
- offset: mainSize * index,
287
- index
288
- }),
289
- initialScrollIndex: layoutReady ? initialDisplayIndex : undefined,
288
+ getItemLayout: getLayout,
289
+ initialScrollIndex: ready ? initDisp : undefined,
290
290
  scrollEnabled: touchable && count > 1,
291
- removeClippedSubviews: !shouldLoop || !loopRenderAll,
292
- disableVirtualization: shouldLoop && loopRenderAll,
293
- initialNumToRender: shouldLoop ? loopRenderAll ? displayCount : 3 : 3,
294
- maxToRenderPerBatch: shouldLoop ? loopRenderAll ? displayCount : 3 : 3,
295
- windowSize: shouldLoop ? loopRenderAll ? displayCount : 7 : 5,
291
+ removeClippedSubviews: !shouldLoop || !loopAll,
292
+ disableVirtualization: shouldLoop && loopAll,
293
+ initialNumToRender: shouldLoop ? loopAll ? dCount : 3 : 3,
294
+ maxToRenderPerBatch: shouldLoop ? loopAll ? dCount : 3 : 3,
295
+ windowSize: shouldLoop ? loopAll ? dCount : 7 : 5,
296
296
  pagingEnabled: true,
297
- snapToInterval: mainSize,
297
+ snapToInterval: mainSz,
298
298
  decelerationRate: "fast",
299
299
  showsHorizontalScrollIndicator: false,
300
300
  showsVerticalScrollIndicator: false,
301
- onScrollBeginDrag: handleScrollBeginDrag,
302
- onScroll: handleScroll,
303
- scrollEventThrottle: 16,
304
- onScrollEndDrag: handleScrollEndDrag,
305
- onMomentumScrollBegin: handleMomentumScrollBegin,
306
- onMomentumScrollEnd: handleScrollEnd,
307
- onScrollToIndexFailed: info => {
308
- scrollToDisplayIndex(info.index, false);
309
- isAnimatingRef.current = false;
310
- isInteractingRef.current = false;
311
- updateIndex(getRealIndex(info.index));
312
- scheduleAutoplay();
313
- flushQueuedSwipe();
314
- }
301
+ onScrollBeginDrag: onDragBegin,
302
+ onScroll: onScroll,
303
+ scrollEventThrottle: tokens.defaults.scrollEventThrottle,
304
+ onScrollEndDrag: onDragEnd,
305
+ onMomentumScrollBegin: onMomBegin,
306
+ onMomentumScrollEnd: onEnd,
307
+ onScrollToIndexFailed: onFail
315
308
  }), /*#__PURE__*/React.createElement(View, {
316
309
  pointerEvents: "none",
317
- style: styles.indicatorOverlay
318
- }, renderIndicator()));
310
+ style: [S.ind, {
311
+ zIndex: tokens.layer.zIndex,
312
+ elevation: tokens.layer.elevation
313
+ }]
314
+ }, indNode));
319
315
  };
320
- const Swiper = /*#__PURE__*/forwardRef(SwiperImpl);
321
- Swiper.displayName = 'Swiper';
322
- const styles = StyleSheet.create({
323
- container: {
316
+ const SwiperFR = /*#__PURE__*/forwardRef(SwiperImpl);
317
+ const Swiper = /*#__PURE__*/memo(SwiperFR);
318
+ const S = StyleSheet.create({
319
+ ctr: {
324
320
  position: 'relative',
325
321
  overflow: 'hidden'
326
322
  },
323
+ web: {
324
+ cursor: 'grab',
325
+ userSelect: 'none'
326
+ },
327
327
  slide: {
328
328
  flex: 1
329
329
  },
330
330
  item: {
331
331
  flex: 1
332
332
  },
333
- indicatorOverlay: {
333
+ ind: {
334
334
  position: 'absolute',
335
335
  left: 0,
336
336
  right: 0,
337
337
  top: 0,
338
- bottom: 0,
339
- zIndex: 10,
340
- elevation: 10
338
+ bottom: 0
341
339
  }
342
340
  });
343
341
  export default Swiper;