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.
- package/dist/cjs/components/area/Area.js +4 -10
- package/dist/cjs/components/avatar/Avatar.js +3 -3
- package/dist/cjs/components/avatar/tokens.js +2 -1
- package/dist/cjs/components/badge/Badge.js +30 -38
- package/dist/cjs/components/button/Button.js +13 -13
- package/dist/cjs/components/button/ButtonGroup.js +8 -8
- package/dist/cjs/components/calendar/Calendar.js +10 -10
- package/dist/cjs/components/cascader/Cascader.js +4 -4
- package/dist/cjs/components/cascader/useCascaderExtend.js +5 -15
- package/dist/cjs/components/checkbox/CheckboxGroup.js +2 -2
- package/dist/cjs/components/circle/Circle.js +2 -2
- package/dist/cjs/components/collapse/Collapse.js +13 -16
- package/dist/cjs/components/config-provider/ConfigProvider.js +1 -1
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +7 -7
- package/dist/cjs/components/dialog/Dialog.js +4 -6
- package/dist/cjs/components/dialog/tokens.js +2 -1
- package/dist/cjs/components/dropdown-menu/DropdownItem.js +53 -52
- package/dist/cjs/components/dropdown-menu/DropdownMenu.js +19 -23
- package/dist/cjs/components/dropdown-menu/tokens.js +20 -3
- package/dist/cjs/components/field/Field.js +6 -6
- package/dist/cjs/components/form/Form.js +5 -9
- package/dist/cjs/components/grid/Grid.js +4 -4
- package/dist/cjs/components/image/Image.js +19 -15
- package/dist/cjs/components/image-preview/ImagePreview.js +62 -60
- package/dist/cjs/components/image-preview/tokens.js +21 -2
- package/dist/cjs/components/index-bar/IndexAnchor.js +7 -6
- package/dist/cjs/components/index-bar/IndexBar.js +38 -44
- package/dist/cjs/components/index-bar/tokens.js +22 -13
- package/dist/cjs/components/index.js +343 -0
- package/dist/cjs/components/input/Input.js +7 -10
- package/dist/cjs/components/notice-bar/NoticeBar.js +69 -95
- package/dist/cjs/components/notify/Notify.js +46 -22
- package/dist/cjs/components/notify/defaults.js +2 -2
- package/dist/cjs/components/notify/imperative.js +1 -1
- package/dist/cjs/components/notify/tokens.js +5 -4
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +12 -12
- package/dist/cjs/components/number-keyboard/tokens.js +4 -2
- package/dist/cjs/components/overlay/useOverlayStack.js +5 -1
- package/dist/cjs/components/pagination/Pagination.js +2 -2
- package/dist/cjs/components/password-input/PasswordInput.js +35 -27
- package/dist/cjs/components/picker/Picker.js +11 -12
- package/dist/cjs/components/picker/WheelPicker.js +9 -9
- package/dist/cjs/components/picker/tokens.js +4 -2
- package/dist/cjs/components/popup/Popup.js +39 -54
- package/dist/cjs/components/popup/tokens.js +2 -1
- package/dist/cjs/components/portal/Portal.js +5 -0
- package/dist/cjs/components/portal/PortalHost.js +1 -13
- package/dist/cjs/components/pull-refresh/PullRefresh.js +46 -27
- package/dist/cjs/components/radio/RadioGroup.js +2 -2
- package/dist/cjs/components/search/Search.js +52 -67
- package/dist/cjs/components/search/tokens.js +2 -1
- package/dist/cjs/components/selector/Selector.js +3 -3
- package/dist/cjs/components/share-sheet/ShareSheet.js +64 -62
- package/dist/cjs/components/share-sheet/tokens.js +15 -2
- package/dist/cjs/components/sidebar/Sidebar.js +15 -19
- package/dist/cjs/components/sidebar/SidebarItem.js +0 -3
- package/dist/cjs/components/skeleton/Skeleton.js +44 -56
- package/dist/cjs/components/slider/Slider.js +55 -61
- package/dist/cjs/components/stepper/Stepper.js +13 -16
- package/dist/cjs/components/stepper/tokens.js +4 -2
- package/dist/cjs/components/swiper/Swiper.js +21 -42
- package/dist/cjs/components/swiper/useSwiperWeb.js +15 -18
- package/dist/cjs/components/tabbar/Tabbar.js +8 -11
- package/dist/cjs/components/tabbar/TabbarItem.js +0 -3
- package/dist/cjs/components/tabs/Tabs.js +33 -54
- package/dist/cjs/components/tabs/tokens.js +9 -1
- package/dist/cjs/components/tabs/useTabsScroll.js +4 -0
- package/dist/cjs/components/toast/Toast.js +10 -8
- package/dist/cjs/components/toast/tokens.js +5 -1
- package/dist/cjs/components/typography/Typography.js +17 -30
- package/dist/cjs/components/uploader/Uploader.js +49 -46
- package/dist/cjs/components/uploader/tokens.js +27 -1
- package/dist/cjs/components/water-mark/WaterMark.js +16 -16
- package/dist/cjs/hooks/usePresenceAnimation.js +12 -2
- package/dist/es/components/area/Area.js +5 -11
- package/dist/es/components/avatar/Avatar.js +3 -3
- package/dist/es/components/avatar/tokens.js +2 -1
- package/dist/es/components/badge/Badge.js +31 -39
- package/dist/es/components/button/Button.js +14 -14
- package/dist/es/components/button/ButtonGroup.js +7 -7
- package/dist/es/components/calendar/Calendar.js +11 -11
- package/dist/es/components/cascader/Cascader.js +5 -5
- package/dist/es/components/cascader/useCascaderExtend.js +5 -9
- package/dist/es/components/checkbox/CheckboxGroup.js +3 -3
- package/dist/es/components/circle/Circle.js +3 -3
- package/dist/es/components/collapse/Collapse.js +14 -17
- package/dist/es/components/config-provider/ConfigProvider.js +2 -2
- package/dist/es/components/datetime-picker/DatetimePicker.js +8 -8
- package/dist/es/components/dialog/Dialog.js +4 -6
- package/dist/es/components/dialog/tokens.js +2 -1
- package/dist/es/components/dropdown-menu/DropdownItem.js +53 -52
- package/dist/es/components/dropdown-menu/DropdownMenu.js +20 -24
- package/dist/es/components/dropdown-menu/tokens.js +20 -3
- package/dist/es/components/field/Field.js +7 -7
- package/dist/es/components/field/index.js +1 -1
- package/dist/es/components/form/Form.js +6 -10
- package/dist/es/components/grid/Grid.js +3 -3
- package/dist/es/components/image/Image.js +20 -16
- package/dist/es/components/image-preview/ImagePreview.js +63 -61
- package/dist/es/components/image-preview/tokens.js +21 -2
- package/dist/es/components/index-bar/IndexAnchor.js +7 -6
- package/dist/es/components/index-bar/IndexBar.js +39 -45
- package/dist/es/components/index-bar/tokens.js +22 -13
- package/dist/es/components/index.js +50 -1
- package/dist/es/components/input/Input.js +8 -11
- package/dist/es/components/notice-bar/NoticeBar.js +70 -96
- package/dist/es/components/notify/Notify.js +46 -23
- package/dist/es/components/notify/defaults.js +2 -2
- package/dist/es/components/notify/imperative.js +1 -1
- package/dist/es/components/notify/tokens.js +5 -4
- package/dist/es/components/number-keyboard/NumberKeyboard.js +13 -13
- package/dist/es/components/number-keyboard/tokens.js +4 -2
- package/dist/es/components/overlay/useOverlayStack.js +6 -2
- package/dist/es/components/pagination/Pagination.js +3 -3
- package/dist/es/components/password-input/PasswordInput.js +36 -28
- package/dist/es/components/picker/Picker.js +12 -13
- package/dist/es/components/picker/WheelPicker.js +10 -10
- package/dist/es/components/picker/tokens.js +4 -2
- package/dist/es/components/popup/Popup.js +41 -56
- package/dist/es/components/popup/tokens.js +2 -1
- package/dist/es/components/portal/Portal.js +5 -0
- package/dist/es/components/portal/PortalHost.js +1 -13
- package/dist/es/components/pull-refresh/PullRefresh.js +47 -28
- package/dist/es/components/radio/RadioGroup.js +3 -3
- package/dist/es/components/search/Search.js +53 -68
- package/dist/es/components/search/tokens.js +2 -1
- package/dist/es/components/selector/Selector.js +4 -4
- package/dist/es/components/share-sheet/ShareSheet.js +65 -63
- package/dist/es/components/share-sheet/tokens.js +15 -2
- package/dist/es/components/sidebar/Sidebar.js +14 -18
- package/dist/es/components/sidebar/SidebarItem.js +0 -3
- package/dist/es/components/skeleton/Skeleton.js +45 -57
- package/dist/es/components/slider/Slider.js +56 -62
- package/dist/es/components/stepper/Stepper.js +14 -17
- package/dist/es/components/stepper/tokens.js +4 -2
- package/dist/es/components/swiper/Swiper.js +22 -43
- package/dist/es/components/swiper/useSwiperWeb.js +16 -19
- package/dist/es/components/tabbar/Tabbar.js +9 -12
- package/dist/es/components/tabbar/TabbarItem.js +0 -3
- package/dist/es/components/tabs/Tabs.js +34 -55
- package/dist/es/components/tabs/tokens.js +9 -1
- package/dist/es/components/tabs/useTabsScroll.js +4 -0
- package/dist/es/components/toast/Toast.js +10 -8
- package/dist/es/components/toast/tokens.js +5 -1
- package/dist/es/components/typography/Typography.js +18 -31
- package/dist/es/components/uploader/Uploader.js +49 -46
- package/dist/es/components/uploader/tokens.js +27 -1
- package/dist/es/components/water-mark/WaterMark.js +17 -17
- package/dist/es/hooks/usePresenceAnimation.js +12 -2
- package/dist/types/components/dialog/tokens.d.ts +1 -0
- package/dist/types/components/dropdown-menu/tokens.d.ts +17 -0
- package/dist/types/components/field/index.d.ts +1 -1
- package/dist/types/components/image-preview/tokens.d.ts +16 -0
- package/dist/types/components/index-bar/tokens.d.ts +13 -4
- package/dist/types/components/index.d.ts +102 -0
- package/dist/types/components/notify/defaults.d.ts +2 -2
- package/dist/types/components/number-keyboard/tokens.d.ts +1 -0
- package/dist/types/components/password-input/PasswordInput.d.ts +4 -0
- package/dist/types/components/picker/tokens.d.ts +2 -0
- package/dist/types/components/popup/tokens.d.ts +1 -0
- package/dist/types/components/search/tokens.d.ts +1 -0
- package/dist/types/components/share-sheet/tokens.d.ts +13 -0
- package/dist/types/components/stepper/tokens.d.ts +2 -0
- package/dist/types/components/tabs/tokens.d.ts +8 -0
- package/dist/types/components/toast/tokens.d.ts +4 -0
- package/dist/types/components/uploader/tokens.d.ts +25 -0
- package/dist/types/hooks/usePresenceAnimation.d.ts +6 -1
- package/package.json +135 -135
|
@@ -75,7 +75,11 @@ const ImagePreview = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
75
75
|
beforeClose
|
|
76
76
|
} = props;
|
|
77
77
|
const {
|
|
78
|
-
colors
|
|
78
|
+
colors,
|
|
79
|
+
layout,
|
|
80
|
+
radii,
|
|
81
|
+
typography,
|
|
82
|
+
spacing
|
|
79
83
|
} = (0, _tokens.useImagePreviewTokens)(tokensOverride);
|
|
80
84
|
const swiperRef = (0, _react().useRef)(null);
|
|
81
85
|
const popupCloseReason = (0, _react().useRef)('close');
|
|
@@ -96,9 +100,9 @@ const ImagePreview = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
96
100
|
beforeClose,
|
|
97
101
|
onClose
|
|
98
102
|
};
|
|
99
|
-
const resolvedImages =
|
|
103
|
+
const resolvedImages = images.map(img => (0, _validate.isString)(img) ? {
|
|
100
104
|
uri: img
|
|
101
|
-
} : img)
|
|
105
|
+
} : img);
|
|
102
106
|
(0, _react().useEffect)(() => {
|
|
103
107
|
setActive(current => clampIndex(current, imagesLen));
|
|
104
108
|
}, [imagesLen]);
|
|
@@ -196,67 +200,70 @@ const ImagePreview = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
196
200
|
if (dx * dx + dy * dy >= TAP_MOVE_THRESHOLD_SQ) return;
|
|
197
201
|
handleImagePress();
|
|
198
202
|
}, [handleImagePress, resetTap]);
|
|
199
|
-
const pressableHandlers =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
203
|
+
const pressableHandlers = {
|
|
204
|
+
onTouchStart: e => {
|
|
205
|
+
const {
|
|
206
|
+
pageX,
|
|
207
|
+
pageY
|
|
208
|
+
} = e.nativeEvent;
|
|
209
|
+
if (pageX != null && pageY != null) markTapStart(pageX, pageY);
|
|
210
|
+
},
|
|
211
|
+
onTouchMove: e => {
|
|
212
|
+
const {
|
|
213
|
+
pageX,
|
|
214
|
+
pageY
|
|
215
|
+
} = e.nativeEvent;
|
|
216
|
+
if (pageX != null && pageY != null) markTapMove(pageX, pageY);
|
|
217
|
+
},
|
|
218
|
+
onTouchEnd: e => {
|
|
219
|
+
const {
|
|
220
|
+
pageX,
|
|
221
|
+
pageY
|
|
222
|
+
} = e.nativeEvent;
|
|
223
|
+
if (pageX != null && pageY != null) tryTapEnd(pageX, pageY);
|
|
224
|
+
},
|
|
225
|
+
onTouchCancel: resetTap
|
|
226
|
+
};
|
|
227
|
+
if (IS_WEB) {
|
|
228
|
+
pressableHandlers.onMouseDown = e => {
|
|
229
|
+
const ne = e.nativeEvent;
|
|
230
|
+
if (ne?.pageX != null && ne?.pageY != null) markTapStart(ne.pageX, ne.pageY);
|
|
223
231
|
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
handlers.onMouseUp = e => {
|
|
235
|
-
const ne = e.nativeEvent;
|
|
236
|
-
if (ne?.pageX != null && ne?.pageY != null) tryTapEnd(ne.pageX, ne.pageY);
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
return handlers;
|
|
240
|
-
}, [markTapMove, markTapStart, resetTap, tryTapEnd]);
|
|
232
|
+
pressableHandlers.onMouseMove = e => {
|
|
233
|
+
const ne = e.nativeEvent;
|
|
234
|
+
if (ne?.buttons !== 1) return;
|
|
235
|
+
if (ne?.pageX != null && ne?.pageY != null) markTapMove(ne.pageX, ne.pageY);
|
|
236
|
+
};
|
|
237
|
+
pressableHandlers.onMouseUp = e => {
|
|
238
|
+
const ne = e.nativeEvent;
|
|
239
|
+
if (ne?.pageX != null && ne?.pageY != null) tryTapEnd(ne.pageX, ne.pageY);
|
|
240
|
+
};
|
|
241
|
+
}
|
|
241
242
|
const renderIndex = (0, _react().useCallback)((current, total) => {
|
|
242
243
|
if (!showIndex || total === 0) return null;
|
|
243
244
|
const indexText = `${current + 1} / ${total}`;
|
|
244
245
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
245
|
-
style: styles.index,
|
|
246
|
+
style: [styles.index, {
|
|
247
|
+
top: spacing.indexTop
|
|
248
|
+
}],
|
|
246
249
|
testID: "rv-image-preview-index"
|
|
247
250
|
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
248
251
|
style: [styles.indexBadge, {
|
|
249
|
-
backgroundColor: colors.indexBackground
|
|
252
|
+
backgroundColor: colors.indexBackground,
|
|
253
|
+
borderRadius: radii.indexBadge,
|
|
254
|
+
paddingHorizontal: spacing.indexPaddingHorizontal,
|
|
255
|
+
paddingVertical: spacing.indexPaddingVertical
|
|
250
256
|
}]
|
|
251
257
|
}, indexRender ? indexRender({
|
|
252
258
|
index: current,
|
|
253
259
|
len: total
|
|
254
260
|
}) : /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
255
261
|
style: [styles.indexText, {
|
|
256
|
-
color: colors.indexText
|
|
262
|
+
color: colors.indexText,
|
|
263
|
+
fontSize: typography.indexTextSize
|
|
257
264
|
}]
|
|
258
265
|
}, indexText)));
|
|
259
|
-
}, [colors.indexBackground, colors.indexText, indexRender, showIndex]);
|
|
266
|
+
}, [colors.indexBackground, colors.indexText, indexRender, radii.indexBadge, showIndex, spacing.indexPaddingHorizontal, spacing.indexPaddingVertical, spacing.indexTop, typography.indexTextSize]);
|
|
260
267
|
const lazyBuffer = lazyRender ? Math.max(0, lazyRenderBuffer | 0) : 0;
|
|
261
268
|
return /*#__PURE__*/_react().default.createElement(_popup.default, {
|
|
262
269
|
visible: visible,
|
|
@@ -275,7 +282,11 @@ const ImagePreview = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
275
282
|
safeAreaInsetTop: safeAreaInsetTop,
|
|
276
283
|
safeAreaInsetBottom: safeAreaInsetBottom,
|
|
277
284
|
overlayTestID: "rv-image-preview-overlay",
|
|
278
|
-
style: styles.popup,
|
|
285
|
+
style: [styles.popup, {
|
|
286
|
+
backgroundColor: colors.transparent,
|
|
287
|
+
padding: layout.popupPadding,
|
|
288
|
+
borderRadius: layout.popupRadius
|
|
289
|
+
}],
|
|
279
290
|
beforeClose: handlePopupBeforeClose,
|
|
280
291
|
onClose: handlePopupClose,
|
|
281
292
|
onClosed: onClosed
|
|
@@ -320,8 +331,6 @@ ImagePreview.displayName = 'ImagePreview';
|
|
|
320
331
|
var _default = exports.default = ImagePreview;
|
|
321
332
|
const styles = _reactNative().StyleSheet.create({
|
|
322
333
|
popup: {
|
|
323
|
-
padding: 0,
|
|
324
|
-
borderRadius: 0,
|
|
325
334
|
position: 'absolute',
|
|
326
335
|
top: 0,
|
|
327
336
|
left: 0,
|
|
@@ -330,8 +339,7 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
330
339
|
width: '100%',
|
|
331
340
|
height: '100%',
|
|
332
341
|
maxWidth: '100%',
|
|
333
|
-
maxHeight: '100%'
|
|
334
|
-
backgroundColor: 'transparent'
|
|
342
|
+
maxHeight: '100%'
|
|
335
343
|
},
|
|
336
344
|
content: {
|
|
337
345
|
flex: 1
|
|
@@ -364,19 +372,13 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
364
372
|
},
|
|
365
373
|
index: {
|
|
366
374
|
position: 'absolute',
|
|
367
|
-
top: 24,
|
|
368
375
|
left: 0,
|
|
369
376
|
right: 0,
|
|
370
377
|
alignItems: 'center',
|
|
371
378
|
zIndex: 1
|
|
372
379
|
},
|
|
373
|
-
indexBadge: {
|
|
374
|
-
borderRadius: 999,
|
|
375
|
-
paddingHorizontal: 12,
|
|
376
|
-
paddingVertical: 4
|
|
377
|
-
},
|
|
380
|
+
indexBadge: {},
|
|
378
381
|
indexText: {
|
|
379
|
-
fontSize: 14,
|
|
380
382
|
fontWeight: '500'
|
|
381
383
|
}
|
|
382
384
|
});
|
|
@@ -7,7 +7,10 @@ exports.useImagePreviewTokens = void 0;
|
|
|
7
7
|
var _designSystem = require("../../design-system");
|
|
8
8
|
const createTokens = foundations => {
|
|
9
9
|
const {
|
|
10
|
-
palette
|
|
10
|
+
palette,
|
|
11
|
+
radii,
|
|
12
|
+
fontSize,
|
|
13
|
+
spacing
|
|
11
14
|
} = foundations;
|
|
12
15
|
return {
|
|
13
16
|
colors: {
|
|
@@ -15,7 +18,23 @@ const createTokens = foundations => {
|
|
|
15
18
|
indexBackground: 'rgba(0,0,0,0.35)',
|
|
16
19
|
indexText: '#fff',
|
|
17
20
|
indicatorActive: palette.primary?.[500] ?? '#1989fa',
|
|
18
|
-
indicatorInactive: 'rgba(255,255,255,0.4)'
|
|
21
|
+
indicatorInactive: 'rgba(255,255,255,0.4)',
|
|
22
|
+
transparent: 'transparent'
|
|
23
|
+
},
|
|
24
|
+
spacing: {
|
|
25
|
+
indexTop: 24,
|
|
26
|
+
indexPaddingHorizontal: spacing.lg,
|
|
27
|
+
indexPaddingVertical: spacing.xs
|
|
28
|
+
},
|
|
29
|
+
layout: {
|
|
30
|
+
popupPadding: 0,
|
|
31
|
+
popupRadius: 0
|
|
32
|
+
},
|
|
33
|
+
radii: {
|
|
34
|
+
indexBadge: radii.pill
|
|
35
|
+
},
|
|
36
|
+
typography: {
|
|
37
|
+
indexTextSize: fontSize.sm
|
|
19
38
|
}
|
|
20
39
|
};
|
|
21
40
|
};
|
|
@@ -36,7 +36,8 @@ const IndexAnchor = props => {
|
|
|
36
36
|
} = props;
|
|
37
37
|
const {
|
|
38
38
|
colors,
|
|
39
|
-
layout
|
|
39
|
+
layout,
|
|
40
|
+
typography
|
|
40
41
|
} = (0, _tokens.useIndexBarTokens)(tokensOverride);
|
|
41
42
|
const textColor = active && highlightColor ? highlightColor : colors.anchorText;
|
|
42
43
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({}, rest, {
|
|
@@ -48,11 +49,13 @@ const IndexAnchor = props => {
|
|
|
48
49
|
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
49
50
|
style: [styles.header, {
|
|
50
51
|
height: layout.anchorHeight,
|
|
51
|
-
backgroundColor: colors.anchorBackground
|
|
52
|
+
backgroundColor: colors.anchorBackground,
|
|
53
|
+
paddingHorizontal: layout.anchorPaddingHorizontal
|
|
52
54
|
}]
|
|
53
55
|
}, /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
54
56
|
style: [styles.title, {
|
|
55
|
-
color: textColor
|
|
57
|
+
color: textColor,
|
|
58
|
+
fontSize: typography.anchorTitleSize
|
|
56
59
|
}]
|
|
57
60
|
}, title ?? index)), children);
|
|
58
61
|
};
|
|
@@ -61,11 +64,9 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
61
64
|
width: '100%'
|
|
62
65
|
},
|
|
63
66
|
header: {
|
|
64
|
-
justifyContent: 'center'
|
|
65
|
-
paddingHorizontal: 16
|
|
67
|
+
justifyContent: 'center'
|
|
66
68
|
},
|
|
67
69
|
title: {
|
|
68
|
-
fontSize: 14,
|
|
69
70
|
fontWeight: '600'
|
|
70
71
|
}
|
|
71
72
|
});
|
|
@@ -47,7 +47,8 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
47
47
|
} = props;
|
|
48
48
|
const {
|
|
49
49
|
colors,
|
|
50
|
-
layout
|
|
50
|
+
layout,
|
|
51
|
+
typography
|
|
51
52
|
} = (0, _tokens.useIndexBarTokens)(tokensOverride);
|
|
52
53
|
const scrollRef = (0, _react().useRef)(null);
|
|
53
54
|
const scrollYRef = (0, _react().useRef)(0);
|
|
@@ -63,12 +64,8 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
63
64
|
const [indicator, setIndicator] = (0, _react().useState)({
|
|
64
65
|
visible: false
|
|
65
66
|
});
|
|
66
|
-
const anchors =
|
|
67
|
-
|
|
68
|
-
}, [children]);
|
|
69
|
-
const navItems = (0, _react().useMemo)(() => {
|
|
70
|
-
return indexList?.length ? indexList : anchors.map(anchor => anchor.props.index);
|
|
71
|
-
}, [anchors, indexList]);
|
|
67
|
+
const anchors = _react().default.Children.toArray(children).filter(_react().default.isValidElement);
|
|
68
|
+
const navItems = indexList?.length ? indexList : anchors.map(anchor => anchor.props.index);
|
|
72
69
|
const firstIndex = navItems[0];
|
|
73
70
|
const [activeIndex, setActiveIndex] = (0, _hooks.useControllableValue)(props, {
|
|
74
71
|
defaultValue: (0, _validate.isUndefined)(firstIndex) ? anchors[0]?.props.index : firstIndex,
|
|
@@ -240,35 +237,35 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
240
237
|
const stickyNode = sticky && stickyVisible && activeAnchor ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
241
238
|
style: [styles.sticky, {
|
|
242
239
|
backgroundColor: colors.stickyBackground,
|
|
243
|
-
height: layout.stickyHeight
|
|
240
|
+
height: layout.stickyHeight,
|
|
241
|
+
paddingHorizontal: layout.stickyPaddingHorizontal
|
|
244
242
|
}]
|
|
245
243
|
}, /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
246
244
|
style: [styles.stickyText, {
|
|
247
|
-
color: highlight
|
|
245
|
+
color: highlight,
|
|
246
|
+
fontSize: typography.stickyTextSize
|
|
248
247
|
}]
|
|
249
248
|
}, activeAnchor.props.title ?? activeAnchor.props.index)) : null;
|
|
250
249
|
const indicatorSize = layout.indicatorSize;
|
|
251
|
-
const indicatorNode =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}, {
|
|
263
|
-
translateY: -indicatorSize / 2
|
|
264
|
-
}]
|
|
265
|
-
}, indicatorStyle]
|
|
266
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
267
|
-
style: [styles.indicatorText, {
|
|
268
|
-
color: colors.indicatorText
|
|
250
|
+
const indicatorNode = !showIndicator || !indicator.visible ? null : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
251
|
+
style: [styles.indicator, {
|
|
252
|
+
width: indicatorSize,
|
|
253
|
+
height: indicatorSize,
|
|
254
|
+
borderRadius: indicatorSize / 2,
|
|
255
|
+
backgroundColor: colors.indicatorBackground,
|
|
256
|
+
zIndex,
|
|
257
|
+
transform: [{
|
|
258
|
+
translateX: -indicatorSize / 2
|
|
259
|
+
}, {
|
|
260
|
+
translateY: -indicatorSize / 2
|
|
269
261
|
}]
|
|
270
|
-
},
|
|
271
|
-
},
|
|
262
|
+
}, indicatorStyle]
|
|
263
|
+
}, /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
264
|
+
style: [styles.indicatorText, {
|
|
265
|
+
color: colors.indicatorText,
|
|
266
|
+
fontSize: typography.indicatorTextSize
|
|
267
|
+
}]
|
|
268
|
+
}, indicator.label));
|
|
272
269
|
const pickIndexFromEvent = (0, _react().useCallback)(evt => {
|
|
273
270
|
if (!navItems.length) return null;
|
|
274
271
|
const locationY = evt?.nativeEvent?.locationY;
|
|
@@ -337,12 +334,12 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
337
334
|
} = e.nativeEvent.layout;
|
|
338
335
|
indexListHeightRef.current = height;
|
|
339
336
|
}, []);
|
|
340
|
-
const anchorNodes =
|
|
337
|
+
const anchorNodes = anchors.map(anchor => /*#__PURE__*/_react().default.cloneElement(anchor, {
|
|
341
338
|
key: anchor.key ?? anchor.props.index,
|
|
342
339
|
active: anchor.props.index === displayIndex,
|
|
343
340
|
highlightColor: highlight,
|
|
344
341
|
onLayoutCapture: handleAnchorLayout
|
|
345
|
-
}))
|
|
342
|
+
}));
|
|
346
343
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({}, rest, {
|
|
347
344
|
style: [styles.container, style]
|
|
348
345
|
}), /*#__PURE__*/_react().default.createElement(_reactNative().ScrollView, {
|
|
@@ -357,6 +354,7 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
357
354
|
style: [styles.indexList, {
|
|
358
355
|
width: layout.indexWidth,
|
|
359
356
|
paddingVertical: layout.paddingVertical,
|
|
357
|
+
paddingHorizontal: layout.indexListPaddingHorizontal,
|
|
360
358
|
zIndex
|
|
361
359
|
}],
|
|
362
360
|
onLayout: handleIndexListLayout,
|
|
@@ -375,7 +373,10 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
375
373
|
return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
|
|
376
374
|
key: String(item),
|
|
377
375
|
testID: `rv-indexbar-nav-${String(item)}`,
|
|
378
|
-
style: styles.indexItem,
|
|
376
|
+
style: [styles.indexItem, {
|
|
377
|
+
paddingVertical: layout.indexItemPaddingVertical,
|
|
378
|
+
paddingHorizontal: layout.indexItemPaddingHorizontal
|
|
379
|
+
}],
|
|
379
380
|
hitSlop: layout.spacing,
|
|
380
381
|
onLayout: event => handleIndexItemLayout(item, event),
|
|
381
382
|
onPress: () => handlePressIn(item),
|
|
@@ -383,7 +384,8 @@ const IndexBarBase = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
|
383
384
|
onPressOut: handlePressOut
|
|
384
385
|
}, node ?? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
385
386
|
style: [styles.indexText, {
|
|
386
|
-
color: isActive ? highlight : colors.text
|
|
387
|
+
color: isActive ? highlight : colors.text,
|
|
388
|
+
fontSize: typography.indexTextSize
|
|
387
389
|
}, indexTextStyle]
|
|
388
390
|
}, String(item)));
|
|
389
391
|
})), indicatorNode);
|
|
@@ -398,19 +400,14 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
398
400
|
top: 0,
|
|
399
401
|
bottom: 0,
|
|
400
402
|
justifyContent: 'center',
|
|
401
|
-
alignItems: 'center'
|
|
402
|
-
paddingHorizontal: 2
|
|
403
|
+
alignItems: 'center'
|
|
403
404
|
},
|
|
404
405
|
indexItem: {
|
|
405
|
-
paddingVertical: 1,
|
|
406
|
-
paddingHorizontal: 0,
|
|
407
406
|
width: '100%',
|
|
408
407
|
alignItems: 'center',
|
|
409
408
|
justifyContent: 'center'
|
|
410
409
|
},
|
|
411
|
-
indexText: {
|
|
412
|
-
fontSize: 12
|
|
413
|
-
},
|
|
410
|
+
indexText: {},
|
|
414
411
|
indicator: {
|
|
415
412
|
position: 'absolute',
|
|
416
413
|
left: '50%',
|
|
@@ -420,7 +417,6 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
420
417
|
pointerEvents: 'none'
|
|
421
418
|
},
|
|
422
419
|
indicatorText: {
|
|
423
|
-
fontSize: 18,
|
|
424
420
|
fontWeight: '600'
|
|
425
421
|
},
|
|
426
422
|
stickyWrapper: {
|
|
@@ -430,11 +426,9 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
430
426
|
right: 0
|
|
431
427
|
},
|
|
432
428
|
sticky: {
|
|
433
|
-
justifyContent: 'center'
|
|
434
|
-
paddingHorizontal: 16
|
|
429
|
+
justifyContent: 'center'
|
|
435
430
|
},
|
|
436
431
|
stickyText: {
|
|
437
|
-
fontSize: 14,
|
|
438
432
|
fontWeight: '600'
|
|
439
433
|
}
|
|
440
434
|
});
|
|
@@ -8,28 +8,37 @@ var _designSystem = require("../../design-system");
|
|
|
8
8
|
const createTokens = foundations => {
|
|
9
9
|
const {
|
|
10
10
|
palette,
|
|
11
|
+
fontSize,
|
|
11
12
|
spacing
|
|
12
13
|
} = foundations;
|
|
13
|
-
const onPrimary = palette.primary.foreground ?? '#ffffff';
|
|
14
14
|
return {
|
|
15
15
|
colors: {
|
|
16
16
|
text: palette.default[600],
|
|
17
17
|
activeText: palette.primary[600],
|
|
18
|
-
indicatorBackground:
|
|
19
|
-
indicatorText:
|
|
20
|
-
stickyBackground:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
anchorText: palette.default[900],
|
|
24
|
-
border: palette.default[200]
|
|
18
|
+
indicatorBackground: palette.primary[500],
|
|
19
|
+
indicatorText: palette.primary.foreground ?? '#ffffff',
|
|
20
|
+
stickyBackground: palette.default[50],
|
|
21
|
+
anchorBackground: palette.default[50],
|
|
22
|
+
anchorText: palette.default[800]
|
|
25
23
|
},
|
|
26
24
|
layout: {
|
|
27
|
-
indexWidth:
|
|
28
|
-
indicatorSize: 60,
|
|
29
|
-
stickyHeight: 32,
|
|
25
|
+
indexWidth: 28,
|
|
30
26
|
paddingVertical: spacing.sm,
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
indexListPaddingHorizontal: spacing.xxs,
|
|
28
|
+
indexItemPaddingVertical: spacing.xxs,
|
|
29
|
+
indexItemPaddingHorizontal: spacing.xxs,
|
|
30
|
+
spacing: spacing.xs,
|
|
31
|
+
indicatorSize: 48,
|
|
32
|
+
stickyHeight: 32,
|
|
33
|
+
stickyPaddingHorizontal: spacing.md,
|
|
34
|
+
anchorHeight: 32,
|
|
35
|
+
anchorPaddingHorizontal: spacing.md
|
|
36
|
+
},
|
|
37
|
+
typography: {
|
|
38
|
+
indexTextSize: fontSize.xs,
|
|
39
|
+
indicatorTextSize: fontSize.lg,
|
|
40
|
+
stickyTextSize: fontSize.md,
|
|
41
|
+
anchorTitleSize: fontSize.sm
|
|
33
42
|
}
|
|
34
43
|
};
|
|
35
44
|
};
|