react-native-system-ui 0.0.3 → 0.0.4

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 (168) hide show
  1. package/dist/cjs/components/area/Area.js +4 -10
  2. package/dist/cjs/components/avatar/Avatar.js +3 -3
  3. package/dist/cjs/components/avatar/tokens.js +2 -1
  4. package/dist/cjs/components/badge/Badge.js +30 -38
  5. package/dist/cjs/components/button/Button.js +13 -13
  6. package/dist/cjs/components/button/ButtonGroup.js +8 -8
  7. package/dist/cjs/components/calendar/Calendar.js +10 -10
  8. package/dist/cjs/components/cascader/Cascader.js +4 -4
  9. package/dist/cjs/components/cascader/useCascaderExtend.js +5 -15
  10. package/dist/cjs/components/checkbox/CheckboxGroup.js +2 -2
  11. package/dist/cjs/components/circle/Circle.js +2 -2
  12. package/dist/cjs/components/collapse/Collapse.js +13 -16
  13. package/dist/cjs/components/config-provider/ConfigProvider.js +1 -1
  14. package/dist/cjs/components/datetime-picker/DatetimePicker.js +7 -7
  15. package/dist/cjs/components/dialog/Dialog.js +4 -6
  16. package/dist/cjs/components/dialog/tokens.js +2 -1
  17. package/dist/cjs/components/dropdown-menu/DropdownItem.js +53 -52
  18. package/dist/cjs/components/dropdown-menu/DropdownMenu.js +19 -23
  19. package/dist/cjs/components/dropdown-menu/tokens.js +20 -3
  20. package/dist/cjs/components/field/Field.js +6 -6
  21. package/dist/cjs/components/form/Form.js +5 -9
  22. package/dist/cjs/components/grid/Grid.js +4 -4
  23. package/dist/cjs/components/image/Image.js +19 -15
  24. package/dist/cjs/components/image-preview/ImagePreview.js +62 -60
  25. package/dist/cjs/components/image-preview/tokens.js +21 -2
  26. package/dist/cjs/components/index-bar/IndexAnchor.js +7 -6
  27. package/dist/cjs/components/index-bar/IndexBar.js +38 -44
  28. package/dist/cjs/components/index-bar/tokens.js +22 -13
  29. package/dist/cjs/components/index.js +343 -0
  30. package/dist/cjs/components/input/Input.js +7 -10
  31. package/dist/cjs/components/notice-bar/NoticeBar.js +69 -95
  32. package/dist/cjs/components/notify/Notify.js +46 -22
  33. package/dist/cjs/components/notify/defaults.js +2 -2
  34. package/dist/cjs/components/notify/imperative.js +1 -1
  35. package/dist/cjs/components/notify/tokens.js +5 -4
  36. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +12 -12
  37. package/dist/cjs/components/number-keyboard/tokens.js +4 -2
  38. package/dist/cjs/components/overlay/useOverlayStack.js +5 -1
  39. package/dist/cjs/components/pagination/Pagination.js +2 -2
  40. package/dist/cjs/components/password-input/PasswordInput.js +35 -27
  41. package/dist/cjs/components/picker/Picker.js +11 -12
  42. package/dist/cjs/components/picker/WheelPicker.js +9 -9
  43. package/dist/cjs/components/picker/tokens.js +4 -2
  44. package/dist/cjs/components/popup/Popup.js +39 -54
  45. package/dist/cjs/components/popup/tokens.js +2 -1
  46. package/dist/cjs/components/portal/Portal.js +5 -0
  47. package/dist/cjs/components/portal/PortalHost.js +1 -13
  48. package/dist/cjs/components/pull-refresh/PullRefresh.js +46 -27
  49. package/dist/cjs/components/radio/RadioGroup.js +2 -2
  50. package/dist/cjs/components/search/Search.js +52 -67
  51. package/dist/cjs/components/search/tokens.js +2 -1
  52. package/dist/cjs/components/selector/Selector.js +3 -3
  53. package/dist/cjs/components/share-sheet/ShareSheet.js +64 -62
  54. package/dist/cjs/components/share-sheet/tokens.js +15 -2
  55. package/dist/cjs/components/sidebar/Sidebar.js +15 -19
  56. package/dist/cjs/components/sidebar/SidebarItem.js +0 -3
  57. package/dist/cjs/components/skeleton/Skeleton.js +44 -56
  58. package/dist/cjs/components/slider/Slider.js +55 -61
  59. package/dist/cjs/components/stepper/Stepper.js +13 -16
  60. package/dist/cjs/components/stepper/tokens.js +4 -2
  61. package/dist/cjs/components/swiper/Swiper.js +21 -42
  62. package/dist/cjs/components/swiper/useSwiperWeb.js +15 -18
  63. package/dist/cjs/components/tabbar/Tabbar.js +8 -11
  64. package/dist/cjs/components/tabbar/TabbarItem.js +0 -3
  65. package/dist/cjs/components/tabs/Tabs.js +33 -54
  66. package/dist/cjs/components/tabs/tokens.js +9 -1
  67. package/dist/cjs/components/tabs/useTabsScroll.js +4 -0
  68. package/dist/cjs/components/toast/Toast.js +10 -8
  69. package/dist/cjs/components/toast/tokens.js +5 -1
  70. package/dist/cjs/components/typography/Typography.js +17 -30
  71. package/dist/cjs/components/uploader/Uploader.js +49 -46
  72. package/dist/cjs/components/uploader/tokens.js +27 -1
  73. package/dist/cjs/components/water-mark/WaterMark.js +16 -16
  74. package/dist/cjs/hooks/usePresenceAnimation.js +12 -2
  75. package/dist/es/components/area/Area.js +5 -11
  76. package/dist/es/components/avatar/Avatar.js +3 -3
  77. package/dist/es/components/avatar/tokens.js +2 -1
  78. package/dist/es/components/badge/Badge.js +31 -39
  79. package/dist/es/components/button/Button.js +14 -14
  80. package/dist/es/components/button/ButtonGroup.js +7 -7
  81. package/dist/es/components/calendar/Calendar.js +11 -11
  82. package/dist/es/components/cascader/Cascader.js +5 -5
  83. package/dist/es/components/cascader/useCascaderExtend.js +5 -9
  84. package/dist/es/components/checkbox/CheckboxGroup.js +3 -3
  85. package/dist/es/components/circle/Circle.js +3 -3
  86. package/dist/es/components/collapse/Collapse.js +14 -17
  87. package/dist/es/components/config-provider/ConfigProvider.js +2 -2
  88. package/dist/es/components/datetime-picker/DatetimePicker.js +8 -8
  89. package/dist/es/components/dialog/Dialog.js +4 -6
  90. package/dist/es/components/dialog/tokens.js +2 -1
  91. package/dist/es/components/dropdown-menu/DropdownItem.js +53 -52
  92. package/dist/es/components/dropdown-menu/DropdownMenu.js +20 -24
  93. package/dist/es/components/dropdown-menu/tokens.js +20 -3
  94. package/dist/es/components/field/Field.js +7 -7
  95. package/dist/es/components/field/index.js +1 -1
  96. package/dist/es/components/form/Form.js +6 -10
  97. package/dist/es/components/grid/Grid.js +3 -3
  98. package/dist/es/components/image/Image.js +20 -16
  99. package/dist/es/components/image-preview/ImagePreview.js +63 -61
  100. package/dist/es/components/image-preview/tokens.js +21 -2
  101. package/dist/es/components/index-bar/IndexAnchor.js +7 -6
  102. package/dist/es/components/index-bar/IndexBar.js +39 -45
  103. package/dist/es/components/index-bar/tokens.js +22 -13
  104. package/dist/es/components/index.js +50 -1
  105. package/dist/es/components/input/Input.js +8 -11
  106. package/dist/es/components/notice-bar/NoticeBar.js +70 -96
  107. package/dist/es/components/notify/Notify.js +46 -23
  108. package/dist/es/components/notify/defaults.js +2 -2
  109. package/dist/es/components/notify/imperative.js +1 -1
  110. package/dist/es/components/notify/tokens.js +5 -4
  111. package/dist/es/components/number-keyboard/NumberKeyboard.js +13 -13
  112. package/dist/es/components/number-keyboard/tokens.js +4 -2
  113. package/dist/es/components/overlay/useOverlayStack.js +6 -2
  114. package/dist/es/components/pagination/Pagination.js +3 -3
  115. package/dist/es/components/password-input/PasswordInput.js +36 -28
  116. package/dist/es/components/picker/Picker.js +12 -13
  117. package/dist/es/components/picker/WheelPicker.js +10 -10
  118. package/dist/es/components/picker/tokens.js +4 -2
  119. package/dist/es/components/popup/Popup.js +41 -56
  120. package/dist/es/components/popup/tokens.js +2 -1
  121. package/dist/es/components/portal/Portal.js +5 -0
  122. package/dist/es/components/portal/PortalHost.js +1 -13
  123. package/dist/es/components/pull-refresh/PullRefresh.js +47 -28
  124. package/dist/es/components/radio/RadioGroup.js +3 -3
  125. package/dist/es/components/search/Search.js +53 -68
  126. package/dist/es/components/search/tokens.js +2 -1
  127. package/dist/es/components/selector/Selector.js +4 -4
  128. package/dist/es/components/share-sheet/ShareSheet.js +65 -63
  129. package/dist/es/components/share-sheet/tokens.js +15 -2
  130. package/dist/es/components/sidebar/Sidebar.js +14 -18
  131. package/dist/es/components/sidebar/SidebarItem.js +0 -3
  132. package/dist/es/components/skeleton/Skeleton.js +45 -57
  133. package/dist/es/components/slider/Slider.js +56 -62
  134. package/dist/es/components/stepper/Stepper.js +14 -17
  135. package/dist/es/components/stepper/tokens.js +4 -2
  136. package/dist/es/components/swiper/Swiper.js +22 -43
  137. package/dist/es/components/swiper/useSwiperWeb.js +16 -19
  138. package/dist/es/components/tabbar/Tabbar.js +9 -12
  139. package/dist/es/components/tabbar/TabbarItem.js +0 -3
  140. package/dist/es/components/tabs/Tabs.js +34 -55
  141. package/dist/es/components/tabs/tokens.js +9 -1
  142. package/dist/es/components/tabs/useTabsScroll.js +4 -0
  143. package/dist/es/components/toast/Toast.js +10 -8
  144. package/dist/es/components/toast/tokens.js +5 -1
  145. package/dist/es/components/typography/Typography.js +18 -31
  146. package/dist/es/components/uploader/Uploader.js +49 -46
  147. package/dist/es/components/uploader/tokens.js +27 -1
  148. package/dist/es/components/water-mark/WaterMark.js +17 -17
  149. package/dist/es/hooks/usePresenceAnimation.js +12 -2
  150. package/dist/types/components/dialog/tokens.d.ts +1 -0
  151. package/dist/types/components/dropdown-menu/tokens.d.ts +17 -0
  152. package/dist/types/components/field/index.d.ts +1 -1
  153. package/dist/types/components/image-preview/tokens.d.ts +16 -0
  154. package/dist/types/components/index-bar/tokens.d.ts +13 -4
  155. package/dist/types/components/index.d.ts +102 -0
  156. package/dist/types/components/notify/defaults.d.ts +2 -2
  157. package/dist/types/components/number-keyboard/tokens.d.ts +1 -0
  158. package/dist/types/components/password-input/PasswordInput.d.ts +4 -0
  159. package/dist/types/components/picker/tokens.d.ts +2 -0
  160. package/dist/types/components/popup/tokens.d.ts +1 -0
  161. package/dist/types/components/search/tokens.d.ts +1 -0
  162. package/dist/types/components/share-sheet/tokens.d.ts +13 -0
  163. package/dist/types/components/stepper/tokens.d.ts +2 -0
  164. package/dist/types/components/tabs/tokens.d.ts +8 -0
  165. package/dist/types/components/toast/tokens.d.ts +4 -0
  166. package/dist/types/components/uploader/tokens.d.ts +25 -0
  167. package/dist/types/hooks/usePresenceAnimation.d.ts +6 -1
  168. package/package.json +135 -135
@@ -1,5 +1,5 @@
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, { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import React, { useCallback, useEffect, useState } from 'react';
3
3
  import { ActivityIndicator, Image as RNImage, Platform, Pressable, StyleSheet, Text, View } from 'react-native';
4
4
  import { SvgUri } from 'react-native-svg';
5
5
  import { isNumber, isString, isText } from '../../utils';
@@ -100,24 +100,30 @@ const Image = /*#__PURE__*/React.forwardRef((props, ref) => {
100
100
  const fit = fitProp ?? tokens.defaults.fit;
101
101
  const showLoading = showLoadingProp ?? tokens.defaults.showLoading;
102
102
  const showError = showErrorProp ?? tokens.defaults.showError;
103
- const loadingText = loadingTextProp ?? tokens.defaults.loadingText;
104
- const errorText = errorTextProp ?? tokens.defaults.errorText;
103
+ const loadingText = loadingTextProp !== undefined ? loadingTextProp : tokens.defaults.loadingText;
104
+ const errorText = errorTextProp !== undefined ? errorTextProp : tokens.defaults.errorText;
105
105
  const {
106
106
  container: containerLayoutStyle,
107
107
  image: imageStyleWithoutLayout
108
- } = useMemo(() => splitImageStyle(style), [style]);
109
- const actualSource = useMemo(() => {
110
- if (source) return source;
111
- if (src) return {
112
- uri: src
113
- };
114
- return undefined;
115
- }, [source, src]);
108
+ } = splitImageStyle(style);
109
+ const actualSource = source ? source : src ? {
110
+ uri: src
111
+ } : undefined;
112
+ const sourceKey = (() => {
113
+ if (source) {
114
+ if (typeof source === 'number') return `res:${source}`;
115
+ const uri = resolveSourceUri(source);
116
+ if (uri) return `uri:${uri}`;
117
+ return 'source:unknown';
118
+ }
119
+ if (src) return `src:${src}`;
120
+ return 'none';
121
+ })();
116
122
  const resolvedAccessibilityLabel = alt ?? accessibilityLabel ?? ariaLabel;
117
123
  const [status, setStatus] = useState(() => actualSource ? 'loading' : 'idle');
118
124
  useEffect(() => {
119
125
  setStatus(actualSource ? 'loading' : 'idle');
120
- }, [actualSource]);
126
+ }, [sourceKey]);
121
127
  const handleLoad = useCallback(event => {
122
128
  setStatus('loaded');
123
129
  onLoad?.(event);
@@ -139,10 +145,8 @@ const Image = /*#__PURE__*/React.forwardRef((props, ref) => {
139
145
  });
140
146
  }, [handleError]);
141
147
  const uri = resolveSourceUri(actualSource);
142
- const isSvg = useMemo(() => {
143
- const normalizedUri = isString(uri) ? uri.toLowerCase() : undefined;
144
- return isString(normalizedUri) && (normalizedUri.endsWith('.svg') || normalizedUri.includes('.svg?') || normalizedUri.includes('/svg?'));
145
- }, [uri]);
148
+ const normalizedUri = isString(uri) ? uri.toLowerCase() : undefined;
149
+ const isSvg = !!normalizedUri && (normalizedUri.endsWith('.svg') || normalizedUri.includes('.svg?') || normalizedUri.includes('/svg?'));
146
150
  const resolvedLoadingSize = isNumber(loadingSize) ? loadingSize : tokens.defaults.loadingIndicatorBaseSize;
147
151
  const resolvedErrorIconSize = iconSizeProp ?? tokens.defaults.iconSize;
148
152
  const containerRole = onPress ? 'button' : undefined;
@@ -1,5 +1,5 @@
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, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { Image as RNImage, Platform, Pressable, StyleSheet, Text, View } from 'react-native';
4
4
  import Popup from '../popup';
5
5
  import Swiper from '../swiper';
@@ -55,7 +55,11 @@ const ImagePreview = /*#__PURE__*/React.forwardRef((props, ref) => {
55
55
  beforeClose
56
56
  } = props;
57
57
  const {
58
- colors
58
+ colors,
59
+ layout,
60
+ radii,
61
+ typography,
62
+ spacing
59
63
  } = useImagePreviewTokens(tokensOverride);
60
64
  const swiperRef = useRef(null);
61
65
  const popupCloseReason = useRef('close');
@@ -76,9 +80,9 @@ const ImagePreview = /*#__PURE__*/React.forwardRef((props, ref) => {
76
80
  beforeClose,
77
81
  onClose
78
82
  };
79
- const resolvedImages = useMemo(() => images.map(img => isString(img) ? {
83
+ const resolvedImages = images.map(img => isString(img) ? {
80
84
  uri: img
81
- } : img), [images]);
85
+ } : img);
82
86
  useEffect(() => {
83
87
  setActive(current => clampIndex(current, imagesLen));
84
88
  }, [imagesLen]);
@@ -176,67 +180,70 @@ const ImagePreview = /*#__PURE__*/React.forwardRef((props, ref) => {
176
180
  if (dx * dx + dy * dy >= TAP_MOVE_THRESHOLD_SQ) return;
177
181
  handleImagePress();
178
182
  }, [handleImagePress, resetTap]);
179
- const pressableHandlers = useMemo(() => {
180
- const handlers = {
181
- onTouchStart: e => {
182
- const {
183
- pageX,
184
- pageY
185
- } = e.nativeEvent;
186
- if (pageX != null && pageY != null) markTapStart(pageX, pageY);
187
- },
188
- onTouchMove: e => {
189
- const {
190
- pageX,
191
- pageY
192
- } = e.nativeEvent;
193
- if (pageX != null && pageY != null) markTapMove(pageX, pageY);
194
- },
195
- onTouchEnd: e => {
196
- const {
197
- pageX,
198
- pageY
199
- } = e.nativeEvent;
200
- if (pageX != null && pageY != null) tryTapEnd(pageX, pageY);
201
- },
202
- onTouchCancel: resetTap
183
+ const pressableHandlers = {
184
+ onTouchStart: e => {
185
+ const {
186
+ pageX,
187
+ pageY
188
+ } = e.nativeEvent;
189
+ if (pageX != null && pageY != null) markTapStart(pageX, pageY);
190
+ },
191
+ onTouchMove: e => {
192
+ const {
193
+ pageX,
194
+ pageY
195
+ } = e.nativeEvent;
196
+ if (pageX != null && pageY != null) markTapMove(pageX, pageY);
197
+ },
198
+ onTouchEnd: e => {
199
+ const {
200
+ pageX,
201
+ pageY
202
+ } = e.nativeEvent;
203
+ if (pageX != null && pageY != null) tryTapEnd(pageX, pageY);
204
+ },
205
+ onTouchCancel: resetTap
206
+ };
207
+ if (IS_WEB) {
208
+ pressableHandlers.onMouseDown = e => {
209
+ const ne = e.nativeEvent;
210
+ if (ne?.pageX != null && ne?.pageY != null) markTapStart(ne.pageX, ne.pageY);
203
211
  };
204
- if (IS_WEB) {
205
- handlers.onMouseDown = e => {
206
- const ne = e.nativeEvent;
207
- if (ne?.pageX != null && ne?.pageY != null) markTapStart(ne.pageX, ne.pageY);
208
- };
209
- handlers.onMouseMove = e => {
210
- const ne = e.nativeEvent;
211
- if (ne?.buttons !== 1) return;
212
- if (ne?.pageX != null && ne?.pageY != null) markTapMove(ne.pageX, ne.pageY);
213
- };
214
- handlers.onMouseUp = e => {
215
- const ne = e.nativeEvent;
216
- if (ne?.pageX != null && ne?.pageY != null) tryTapEnd(ne.pageX, ne.pageY);
217
- };
218
- }
219
- return handlers;
220
- }, [markTapMove, markTapStart, resetTap, tryTapEnd]);
212
+ pressableHandlers.onMouseMove = e => {
213
+ const ne = e.nativeEvent;
214
+ if (ne?.buttons !== 1) return;
215
+ if (ne?.pageX != null && ne?.pageY != null) markTapMove(ne.pageX, ne.pageY);
216
+ };
217
+ pressableHandlers.onMouseUp = e => {
218
+ const ne = e.nativeEvent;
219
+ if (ne?.pageX != null && ne?.pageY != null) tryTapEnd(ne.pageX, ne.pageY);
220
+ };
221
+ }
221
222
  const renderIndex = useCallback((current, total) => {
222
223
  if (!showIndex || total === 0) return null;
223
224
  const indexText = `${current + 1} / ${total}`;
224
225
  return /*#__PURE__*/React.createElement(View, {
225
- style: styles.index,
226
+ style: [styles.index, {
227
+ top: spacing.indexTop
228
+ }],
226
229
  testID: "rv-image-preview-index"
227
230
  }, /*#__PURE__*/React.createElement(View, {
228
231
  style: [styles.indexBadge, {
229
- backgroundColor: colors.indexBackground
232
+ backgroundColor: colors.indexBackground,
233
+ borderRadius: radii.indexBadge,
234
+ paddingHorizontal: spacing.indexPaddingHorizontal,
235
+ paddingVertical: spacing.indexPaddingVertical
230
236
  }]
231
237
  }, indexRender ? indexRender({
232
238
  index: current,
233
239
  len: total
234
240
  }) : /*#__PURE__*/React.createElement(Text, {
235
241
  style: [styles.indexText, {
236
- color: colors.indexText
242
+ color: colors.indexText,
243
+ fontSize: typography.indexTextSize
237
244
  }]
238
245
  }, indexText)));
239
- }, [colors.indexBackground, colors.indexText, indexRender, showIndex]);
246
+ }, [colors.indexBackground, colors.indexText, indexRender, radii.indexBadge, showIndex, spacing.indexPaddingHorizontal, spacing.indexPaddingVertical, spacing.indexTop, typography.indexTextSize]);
240
247
  const lazyBuffer = lazyRender ? Math.max(0, lazyRenderBuffer | 0) : 0;
241
248
  return /*#__PURE__*/React.createElement(Popup, {
242
249
  visible: visible,
@@ -255,7 +262,11 @@ const ImagePreview = /*#__PURE__*/React.forwardRef((props, ref) => {
255
262
  safeAreaInsetTop: safeAreaInsetTop,
256
263
  safeAreaInsetBottom: safeAreaInsetBottom,
257
264
  overlayTestID: "rv-image-preview-overlay",
258
- style: styles.popup,
265
+ style: [styles.popup, {
266
+ backgroundColor: colors.transparent,
267
+ padding: layout.popupPadding,
268
+ borderRadius: layout.popupRadius
269
+ }],
259
270
  beforeClose: handlePopupBeforeClose,
260
271
  onClose: handlePopupClose,
261
272
  onClosed: onClosed
@@ -300,8 +311,6 @@ ImagePreview.displayName = 'ImagePreview';
300
311
  export default ImagePreview;
301
312
  const styles = StyleSheet.create({
302
313
  popup: {
303
- padding: 0,
304
- borderRadius: 0,
305
314
  position: 'absolute',
306
315
  top: 0,
307
316
  left: 0,
@@ -310,8 +319,7 @@ const styles = StyleSheet.create({
310
319
  width: '100%',
311
320
  height: '100%',
312
321
  maxWidth: '100%',
313
- maxHeight: '100%',
314
- backgroundColor: 'transparent'
322
+ maxHeight: '100%'
315
323
  },
316
324
  content: {
317
325
  flex: 1
@@ -344,19 +352,13 @@ const styles = StyleSheet.create({
344
352
  },
345
353
  index: {
346
354
  position: 'absolute',
347
- top: 24,
348
355
  left: 0,
349
356
  right: 0,
350
357
  alignItems: 'center',
351
358
  zIndex: 1
352
359
  },
353
- indexBadge: {
354
- borderRadius: 999,
355
- paddingHorizontal: 12,
356
- paddingVertical: 4
357
- },
360
+ indexBadge: {},
358
361
  indexText: {
359
- fontSize: 14,
360
362
  fontWeight: '500'
361
363
  }
362
364
  });
@@ -1,7 +1,10 @@
1
1
  import { createComponentTokensHook } from '../../design-system';
2
2
  const createTokens = foundations => {
3
3
  const {
4
- palette
4
+ palette,
5
+ radii,
6
+ fontSize,
7
+ spacing
5
8
  } = foundations;
6
9
  return {
7
10
  colors: {
@@ -9,7 +12,23 @@ const createTokens = foundations => {
9
12
  indexBackground: 'rgba(0,0,0,0.35)',
10
13
  indexText: '#fff',
11
14
  indicatorActive: palette.primary?.[500] ?? '#1989fa',
12
- indicatorInactive: 'rgba(255,255,255,0.4)'
15
+ indicatorInactive: 'rgba(255,255,255,0.4)',
16
+ transparent: 'transparent'
17
+ },
18
+ spacing: {
19
+ indexTop: 24,
20
+ indexPaddingHorizontal: spacing.lg,
21
+ indexPaddingVertical: spacing.xs
22
+ },
23
+ layout: {
24
+ popupPadding: 0,
25
+ popupRadius: 0
26
+ },
27
+ radii: {
28
+ indexBadge: radii.pill
29
+ },
30
+ typography: {
31
+ indexTextSize: fontSize.sm
13
32
  }
14
33
  };
15
34
  };
@@ -17,7 +17,8 @@ const IndexAnchor = props => {
17
17
  } = props;
18
18
  const {
19
19
  colors,
20
- layout
20
+ layout,
21
+ typography
21
22
  } = useIndexBarTokens(tokensOverride);
22
23
  const textColor = active && highlightColor ? highlightColor : colors.anchorText;
23
24
  return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
@@ -29,11 +30,13 @@ const IndexAnchor = props => {
29
30
  }), /*#__PURE__*/React.createElement(View, {
30
31
  style: [styles.header, {
31
32
  height: layout.anchorHeight,
32
- backgroundColor: colors.anchorBackground
33
+ backgroundColor: colors.anchorBackground,
34
+ paddingHorizontal: layout.anchorPaddingHorizontal
33
35
  }]
34
36
  }, /*#__PURE__*/React.createElement(Text, {
35
37
  style: [styles.title, {
36
- color: textColor
38
+ color: textColor,
39
+ fontSize: typography.anchorTitleSize
37
40
  }]
38
41
  }, title ?? index)), children);
39
42
  };
@@ -42,11 +45,9 @@ const styles = StyleSheet.create({
42
45
  width: '100%'
43
46
  },
44
47
  header: {
45
- justifyContent: 'center',
46
- paddingHorizontal: 16
48
+ justifyContent: 'center'
47
49
  },
48
50
  title: {
49
- fontSize: 14,
50
51
  fontWeight: '600'
51
52
  }
52
53
  });
@@ -1,5 +1,5 @@
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, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
4
4
  import { useControllableValue } from '../../hooks';
5
5
  import { isFiniteNumber, isUndefined } from '../../utils/validate';
@@ -28,7 +28,8 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
28
28
  } = props;
29
29
  const {
30
30
  colors,
31
- layout
31
+ layout,
32
+ typography
32
33
  } = useIndexBarTokens(tokensOverride);
33
34
  const scrollRef = useRef(null);
34
35
  const scrollYRef = useRef(0);
@@ -44,12 +45,8 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
44
45
  const [indicator, setIndicator] = useState({
45
46
  visible: false
46
47
  });
47
- const anchors = useMemo(() => {
48
- return React.Children.toArray(children).filter(React.isValidElement);
49
- }, [children]);
50
- const navItems = useMemo(() => {
51
- return indexList?.length ? indexList : anchors.map(anchor => anchor.props.index);
52
- }, [anchors, indexList]);
48
+ const anchors = React.Children.toArray(children).filter(React.isValidElement);
49
+ const navItems = indexList?.length ? indexList : anchors.map(anchor => anchor.props.index);
53
50
  const firstIndex = navItems[0];
54
51
  const [activeIndex, setActiveIndex] = useControllableValue(props, {
55
52
  defaultValue: isUndefined(firstIndex) ? anchors[0]?.props.index : firstIndex,
@@ -221,35 +218,35 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
221
218
  const stickyNode = sticky && stickyVisible && activeAnchor ? /*#__PURE__*/React.createElement(View, {
222
219
  style: [styles.sticky, {
223
220
  backgroundColor: colors.stickyBackground,
224
- height: layout.stickyHeight
221
+ height: layout.stickyHeight,
222
+ paddingHorizontal: layout.stickyPaddingHorizontal
225
223
  }]
226
224
  }, /*#__PURE__*/React.createElement(Text, {
227
225
  style: [styles.stickyText, {
228
- color: highlight
226
+ color: highlight,
227
+ fontSize: typography.stickyTextSize
229
228
  }]
230
229
  }, activeAnchor.props.title ?? activeAnchor.props.index)) : null;
231
230
  const indicatorSize = layout.indicatorSize;
232
- const indicatorNode = useMemo(() => {
233
- if (!showIndicator || !indicator.visible) return null;
234
- return /*#__PURE__*/React.createElement(View, {
235
- style: [styles.indicator, {
236
- width: indicatorSize,
237
- height: indicatorSize,
238
- borderRadius: indicatorSize / 2,
239
- backgroundColor: colors.indicatorBackground,
240
- zIndex,
241
- transform: [{
242
- translateX: -indicatorSize / 2
243
- }, {
244
- translateY: -indicatorSize / 2
245
- }]
246
- }, indicatorStyle]
247
- }, /*#__PURE__*/React.createElement(Text, {
248
- style: [styles.indicatorText, {
249
- color: colors.indicatorText
231
+ const indicatorNode = !showIndicator || !indicator.visible ? null : /*#__PURE__*/React.createElement(View, {
232
+ style: [styles.indicator, {
233
+ width: indicatorSize,
234
+ height: indicatorSize,
235
+ borderRadius: indicatorSize / 2,
236
+ backgroundColor: colors.indicatorBackground,
237
+ zIndex,
238
+ transform: [{
239
+ translateX: -indicatorSize / 2
240
+ }, {
241
+ translateY: -indicatorSize / 2
250
242
  }]
251
- }, indicator.label));
252
- }, [colors.indicatorBackground, colors.indicatorText, indicator.label, indicator.visible, indicatorSize, indicatorStyle, showIndicator, zIndex]);
243
+ }, indicatorStyle]
244
+ }, /*#__PURE__*/React.createElement(Text, {
245
+ style: [styles.indicatorText, {
246
+ color: colors.indicatorText,
247
+ fontSize: typography.indicatorTextSize
248
+ }]
249
+ }, indicator.label));
253
250
  const pickIndexFromEvent = useCallback(evt => {
254
251
  if (!navItems.length) return null;
255
252
  const locationY = evt?.nativeEvent?.locationY;
@@ -318,12 +315,12 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
318
315
  } = e.nativeEvent.layout;
319
316
  indexListHeightRef.current = height;
320
317
  }, []);
321
- const anchorNodes = useMemo(() => anchors.map(anchor => /*#__PURE__*/React.cloneElement(anchor, {
318
+ const anchorNodes = anchors.map(anchor => /*#__PURE__*/React.cloneElement(anchor, {
322
319
  key: anchor.key ?? anchor.props.index,
323
320
  active: anchor.props.index === displayIndex,
324
321
  highlightColor: highlight,
325
322
  onLayoutCapture: handleAnchorLayout
326
- })), [anchors, displayIndex, handleAnchorLayout, highlight]);
323
+ }));
327
324
  return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
328
325
  style: [styles.container, style]
329
326
  }), /*#__PURE__*/React.createElement(ScrollView, {
@@ -338,6 +335,7 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
338
335
  style: [styles.indexList, {
339
336
  width: layout.indexWidth,
340
337
  paddingVertical: layout.paddingVertical,
338
+ paddingHorizontal: layout.indexListPaddingHorizontal,
341
339
  zIndex
342
340
  }],
343
341
  onLayout: handleIndexListLayout,
@@ -356,7 +354,10 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
356
354
  return /*#__PURE__*/React.createElement(Pressable, {
357
355
  key: String(item),
358
356
  testID: `rv-indexbar-nav-${String(item)}`,
359
- style: styles.indexItem,
357
+ style: [styles.indexItem, {
358
+ paddingVertical: layout.indexItemPaddingVertical,
359
+ paddingHorizontal: layout.indexItemPaddingHorizontal
360
+ }],
360
361
  hitSlop: layout.spacing,
361
362
  onLayout: event => handleIndexItemLayout(item, event),
362
363
  onPress: () => handlePressIn(item),
@@ -364,7 +365,8 @@ const IndexBarBase = /*#__PURE__*/React.forwardRef((props, ref) => {
364
365
  onPressOut: handlePressOut
365
366
  }, node ?? /*#__PURE__*/React.createElement(Text, {
366
367
  style: [styles.indexText, {
367
- color: isActive ? highlight : colors.text
368
+ color: isActive ? highlight : colors.text,
369
+ fontSize: typography.indexTextSize
368
370
  }, indexTextStyle]
369
371
  }, String(item)));
370
372
  })), indicatorNode);
@@ -379,19 +381,14 @@ const styles = StyleSheet.create({
379
381
  top: 0,
380
382
  bottom: 0,
381
383
  justifyContent: 'center',
382
- alignItems: 'center',
383
- paddingHorizontal: 2
384
+ alignItems: 'center'
384
385
  },
385
386
  indexItem: {
386
- paddingVertical: 1,
387
- paddingHorizontal: 0,
388
387
  width: '100%',
389
388
  alignItems: 'center',
390
389
  justifyContent: 'center'
391
390
  },
392
- indexText: {
393
- fontSize: 12
394
- },
391
+ indexText: {},
395
392
  indicator: {
396
393
  position: 'absolute',
397
394
  left: '50%',
@@ -401,7 +398,6 @@ const styles = StyleSheet.create({
401
398
  pointerEvents: 'none'
402
399
  },
403
400
  indicatorText: {
404
- fontSize: 18,
405
401
  fontWeight: '600'
406
402
  },
407
403
  stickyWrapper: {
@@ -411,11 +407,9 @@ const styles = StyleSheet.create({
411
407
  right: 0
412
408
  },
413
409
  sticky: {
414
- justifyContent: 'center',
415
- paddingHorizontal: 16
410
+ justifyContent: 'center'
416
411
  },
417
412
  stickyText: {
418
- fontSize: 14,
419
413
  fontWeight: '600'
420
414
  }
421
415
  });
@@ -2,28 +2,37 @@ import { createComponentTokensHook } from '../../design-system';
2
2
  const createTokens = foundations => {
3
3
  const {
4
4
  palette,
5
+ fontSize,
5
6
  spacing
6
7
  } = foundations;
7
- const onPrimary = palette.primary.foreground ?? '#ffffff';
8
8
  return {
9
9
  colors: {
10
10
  text: palette.default[600],
11
11
  activeText: palette.primary[600],
12
- indicatorBackground: 'rgba(0,0,0,0.6)',
13
- indicatorText: onPrimary,
14
- stickyBackground: '#ffffff',
15
- stickyText: palette.default[900],
16
- anchorBackground: '#ffffff',
17
- anchorText: palette.default[900],
18
- border: palette.default[200]
12
+ indicatorBackground: palette.primary[500],
13
+ indicatorText: palette.primary.foreground ?? '#ffffff',
14
+ stickyBackground: palette.default[50],
15
+ anchorBackground: palette.default[50],
16
+ anchorText: palette.default[800]
19
17
  },
20
18
  layout: {
21
- indexWidth: 24,
22
- indicatorSize: 60,
23
- stickyHeight: 32,
19
+ indexWidth: 28,
24
20
  paddingVertical: spacing.sm,
25
- spacing: 4,
26
- anchorHeight: 32
21
+ indexListPaddingHorizontal: spacing.xxs,
22
+ indexItemPaddingVertical: spacing.xxs,
23
+ indexItemPaddingHorizontal: spacing.xxs,
24
+ spacing: spacing.xs,
25
+ indicatorSize: 48,
26
+ stickyHeight: 32,
27
+ stickyPaddingHorizontal: spacing.md,
28
+ anchorHeight: 32,
29
+ anchorPaddingHorizontal: spacing.md
30
+ },
31
+ typography: {
32
+ indexTextSize: fontSize.xs,
33
+ indicatorTextSize: fontSize.lg,
34
+ stickyTextSize: fontSize.md,
35
+ anchorTitleSize: fontSize.sm
27
36
  }
28
37
  };
29
38
  };