react-native-system-ui 1.0.0 → 1.0.1
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/action-sheet/ActionSheet.js +45 -51
- package/dist/cjs/components/area/Area.js +22 -22
- package/dist/cjs/components/avatar/Avatar.js +23 -23
- package/dist/cjs/components/badge/Badge.js +56 -61
- package/dist/cjs/components/button/Button.js +87 -92
- package/dist/cjs/components/button/ButtonGroup.js +4 -4
- package/dist/cjs/components/calendar/Calendar.js +28 -28
- package/dist/cjs/components/cascader/Cascader.js +205 -212
- package/dist/cjs/components/cell/Cell.js +54 -51
- package/dist/cjs/components/cell/CellGroup.js +26 -25
- package/dist/cjs/components/checkbox/Checkbox.js +1 -0
- package/dist/cjs/components/checkbox/CheckboxGroup.js +20 -19
- package/dist/cjs/components/circle/Circle.js +66 -54
- package/dist/cjs/components/collapse/Collapse.js +18 -18
- package/dist/cjs/components/config-provider/ConfigProvider.js +5 -5
- package/dist/cjs/components/count-down/CountDown.js +17 -17
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +34 -35
- package/dist/cjs/components/dialog/Dialog.js +16 -10
- package/dist/cjs/components/dialog/imperative.js +8 -14
- package/dist/cjs/components/dialog/tokens.js +1 -0
- package/dist/cjs/components/divider/Divider.js +48 -51
- package/dist/cjs/components/empty/Empty.js +30 -25
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +3 -2
- package/dist/cjs/components/flex/Flex.js +27 -27
- package/dist/cjs/components/flex/FlexItem.js +1 -0
- package/dist/cjs/components/form/Form.js +93 -92
- package/dist/cjs/components/form/FormItem.js +60 -54
- package/dist/cjs/components/form/FormList.js +35 -35
- package/dist/cjs/components/grid/Grid.js +48 -48
- package/dist/cjs/components/grid/GridItem.js +9 -2
- package/dist/cjs/components/image/Image.js +25 -24
- package/dist/cjs/components/image/tokens.js +3 -1
- package/dist/cjs/components/image-preview/ImagePreview.js +19 -19
- package/dist/cjs/components/image-preview/tokens.js +3 -1
- package/dist/cjs/components/input/Input.js +16 -19
- package/dist/cjs/components/loading/Loading.js +27 -27
- package/dist/cjs/components/nav-bar/NavBar.js +21 -18
- package/dist/cjs/components/nav-bar/tokens.js +3 -1
- package/dist/cjs/components/notice-bar/NoticeBar.js +7 -3
- package/dist/cjs/components/notice-bar/tokens.js +3 -1
- package/dist/cjs/components/notify/Notify.js +2 -1
- package/dist/cjs/components/notify/imperative.js +17 -17
- package/dist/cjs/components/notify/tokens.js +1 -0
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +217 -201
- package/dist/cjs/components/number-keyboard/tokens.js +7 -1
- package/dist/cjs/components/overlay/Overlay.js +15 -15
- package/dist/cjs/components/password-input/PasswordInput.js +49 -49
- package/dist/cjs/components/picker/Picker.js +50 -58
- package/dist/cjs/components/popup/Popup.js +10 -10
- package/dist/cjs/components/popup/tokens.js +1 -0
- package/dist/cjs/components/portal/Portal.js +3 -4
- package/dist/cjs/components/progress/Progress.js +94 -95
- package/dist/cjs/components/progress/tokens.js +1 -0
- package/dist/cjs/components/radio/Radio.js +67 -63
- package/dist/cjs/components/radio/RadioGroup.js +6 -6
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +7 -7
- package/dist/cjs/components/search/Search.js +28 -28
- package/dist/cjs/components/selector/Selector.js +19 -26
- package/dist/cjs/components/share-sheet/ShareSheet.js +6 -1
- package/dist/cjs/components/share-sheet/tokens.js +3 -1
- package/dist/cjs/components/sidebar/Sidebar.js +22 -16
- package/dist/cjs/components/sidebar/SidebarItem.js +9 -8
- package/dist/cjs/components/sidebar/tokens.js +3 -1
- package/dist/cjs/components/skeleton/Skeleton.js +43 -42
- package/dist/cjs/components/space/Space.js +45 -41
- package/dist/cjs/components/space/tokens.js +7 -1
- package/dist/cjs/components/stepper/Stepper.js +17 -15
- package/dist/cjs/components/stepper/tokens.js +1 -0
- package/dist/cjs/components/swiper/Swiper.js +10 -7
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +3 -2
- package/dist/cjs/components/switch/Switch.js +23 -23
- package/dist/cjs/components/tabbar/Tabbar.js +26 -26
- package/dist/cjs/components/tabs/Tabs.js +143 -153
- package/dist/cjs/components/tabs/tokens.js +3 -1
- package/dist/cjs/components/tag/Tag.js +38 -38
- package/dist/cjs/components/toast/Toast.js +3 -2
- package/dist/cjs/components/toast/tokens.js +1 -0
- package/dist/cjs/components/typography/Typography.js +23 -21
- package/dist/cjs/components/water-mark/WaterMark.js +65 -65
- package/dist/cjs/design-system/Text.js +38 -0
- package/dist/cjs/design-system/createComponentTokensHook.js +2 -2
- package/dist/cjs/design-system/index.js +7 -0
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
- package/dist/cjs/hooks/useControllableValue.js +11 -11
- package/dist/cjs/hooks/useCountDown.js +18 -18
- package/dist/cjs/platform/measure.js +4 -2
- package/dist/cjs/utils/color.js +2 -7
- package/dist/cjs/utils/compare.js +3 -3
- package/dist/cjs/utils/date.js +2 -2
- package/dist/cjs/utils/deepMerge.js +5 -5
- package/dist/cjs/utils/hairline.js +1 -0
- package/dist/cjs/utils/render.js +2 -8
- package/dist/cjs/utils/validate.js +2 -4
- package/dist/es/components/action-sheet/ActionSheet.js +45 -51
- package/dist/es/components/area/Area.js +22 -22
- package/dist/es/components/avatar/Avatar.js +23 -23
- package/dist/es/components/badge/Badge.js +56 -61
- package/dist/es/components/button/Button.js +87 -92
- package/dist/es/components/button/ButtonGroup.js +4 -4
- package/dist/es/components/calendar/Calendar.js +28 -28
- package/dist/es/components/cascader/Cascader.js +205 -212
- package/dist/es/components/cell/Cell.js +55 -52
- package/dist/es/components/cell/CellGroup.js +26 -25
- package/dist/es/components/checkbox/Checkbox.js +1 -0
- package/dist/es/components/checkbox/CheckboxGroup.js +20 -19
- package/dist/es/components/circle/Circle.js +66 -54
- package/dist/es/components/collapse/Collapse.js +18 -18
- package/dist/es/components/config-provider/ConfigProvider.js +5 -5
- package/dist/es/components/count-down/CountDown.js +17 -17
- package/dist/es/components/datetime-picker/DatetimePicker.js +34 -35
- package/dist/es/components/dialog/Dialog.js +16 -10
- package/dist/es/components/dialog/imperative.js +8 -14
- package/dist/es/components/dialog/tokens.js +1 -0
- package/dist/es/components/divider/Divider.js +48 -51
- package/dist/es/components/empty/Empty.js +30 -25
- package/dist/es/components/error-boundary/ErrorBoundary.js +3 -2
- package/dist/es/components/flex/Flex.js +27 -27
- package/dist/es/components/flex/FlexItem.js +1 -0
- package/dist/es/components/form/Form.js +93 -92
- package/dist/es/components/form/FormItem.js +60 -54
- package/dist/es/components/form/FormList.js +35 -35
- package/dist/es/components/grid/Grid.js +48 -48
- package/dist/es/components/grid/GridItem.js +10 -3
- package/dist/es/components/image/Image.js +25 -24
- package/dist/es/components/image/tokens.js +3 -1
- package/dist/es/components/image-preview/ImagePreview.js +19 -19
- package/dist/es/components/image-preview/tokens.js +3 -1
- package/dist/es/components/input/Input.js +16 -19
- package/dist/es/components/loading/Loading.js +27 -27
- package/dist/es/components/nav-bar/NavBar.js +21 -18
- package/dist/es/components/nav-bar/tokens.js +3 -1
- package/dist/es/components/notice-bar/NoticeBar.js +7 -3
- package/dist/es/components/notice-bar/tokens.js +3 -1
- package/dist/es/components/notify/Notify.js +2 -1
- package/dist/es/components/notify/imperative.js +17 -17
- package/dist/es/components/notify/tokens.js +1 -0
- package/dist/es/components/number-keyboard/NumberKeyboard.js +217 -201
- package/dist/es/components/number-keyboard/tokens.js +7 -1
- package/dist/es/components/overlay/Overlay.js +15 -15
- package/dist/es/components/password-input/PasswordInput.js +49 -49
- package/dist/es/components/picker/Picker.js +50 -58
- package/dist/es/components/popup/Popup.js +10 -10
- package/dist/es/components/popup/tokens.js +1 -0
- package/dist/es/components/portal/Portal.js +3 -4
- package/dist/es/components/progress/Progress.js +94 -95
- package/dist/es/components/progress/tokens.js +1 -0
- package/dist/es/components/radio/Radio.js +67 -63
- package/dist/es/components/radio/RadioGroup.js +6 -6
- package/dist/es/components/safe-area-view/SafeAreaView.js +7 -7
- package/dist/es/components/search/Search.js +28 -28
- package/dist/es/components/selector/Selector.js +19 -26
- package/dist/es/components/share-sheet/ShareSheet.js +6 -1
- package/dist/es/components/share-sheet/tokens.js +3 -1
- package/dist/es/components/sidebar/Sidebar.js +22 -16
- package/dist/es/components/sidebar/SidebarItem.js +9 -8
- package/dist/es/components/sidebar/tokens.js +3 -1
- package/dist/es/components/skeleton/Skeleton.js +43 -42
- package/dist/es/components/space/Space.js +45 -41
- package/dist/es/components/space/tokens.js +7 -1
- package/dist/es/components/stepper/Stepper.js +17 -15
- package/dist/es/components/stepper/tokens.js +1 -0
- package/dist/es/components/swiper/Swiper.js +11 -8
- package/dist/es/components/swiper/SwiperPagIndicator.js +3 -2
- package/dist/es/components/switch/Switch.js +23 -23
- package/dist/es/components/tabbar/Tabbar.js +26 -26
- package/dist/es/components/tabs/Tabs.js +144 -154
- package/dist/es/components/tabs/tokens.js +3 -1
- package/dist/es/components/tag/Tag.js +38 -38
- package/dist/es/components/toast/Toast.js +3 -2
- package/dist/es/components/toast/tokens.js +1 -0
- package/dist/es/components/typography/Typography.js +23 -21
- package/dist/es/components/water-mark/WaterMark.js +65 -65
- package/dist/es/design-system/Text.js +19 -0
- package/dist/es/design-system/createComponentTokensHook.js +2 -2
- package/dist/es/design-system/index.js +1 -0
- package/dist/es/design-system/mergeTokensOverride.js +1 -4
- package/dist/es/hooks/useControllableValue.js +11 -11
- package/dist/es/hooks/useCountDown.js +18 -18
- package/dist/es/platform/measure.js +4 -2
- package/dist/es/utils/color.js +1 -4
- package/dist/es/utils/compare.js +3 -3
- package/dist/es/utils/date.js +2 -2
- package/dist/es/utils/deepMerge.js +5 -5
- package/dist/es/utils/hairline.js +1 -0
- package/dist/es/utils/render.js +1 -1
- package/dist/es/utils/validate.js +1 -2
- package/dist/types/components/dialog/tokens.d.ts +1 -0
- package/dist/types/components/image-preview/tokens.d.ts +1 -0
- package/dist/types/components/nav-bar/tokens.d.ts +1 -1
- package/dist/types/components/notice-bar/tokens.d.ts +1 -0
- package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
- package/dist/types/components/picker/Picker.d.ts +1 -1
- package/dist/types/components/popup/tokens.d.ts +1 -0
- package/dist/types/components/share-sheet/tokens.d.ts +1 -0
- package/dist/types/components/stepper/tokens.d.ts +1 -0
- package/dist/types/components/tabs/tokens.d.ts +1 -0
- package/dist/types/components/toast/tokens.d.ts +1 -0
- package/dist/types/design-system/Text.d.ts +3 -0
- package/dist/types/design-system/index.d.ts +1 -0
- package/dist/types/hooks/useCountDown.d.ts +1 -1
- package/dist/types/utils/color.d.ts +0 -2
- package/dist/types/utils/date.d.ts +1 -1
- package/dist/types/utils/render.d.ts +1 -1
- package/dist/types/utils/validate.d.ts +0 -1
- package/package.json +17 -3
|
@@ -39,7 +39,6 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
39
39
|
visible,
|
|
40
40
|
images = [],
|
|
41
41
|
startPosition = 0,
|
|
42
|
-
swipeDuration = 300,
|
|
43
42
|
tokensOverride,
|
|
44
43
|
lazyRender = false,
|
|
45
44
|
lazyRenderBuffer = 1,
|
|
@@ -74,18 +73,18 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
74
73
|
const pendingCloseReason = useRef('close');
|
|
75
74
|
const touchStartRef = useRef(null);
|
|
76
75
|
const touchMovedRef = useRef(false);
|
|
77
|
-
const
|
|
78
|
-
const [activeIndex, setActiveIndex] = useState(() => clampIndex(startPosition,
|
|
79
|
-
const
|
|
76
|
+
const imgLen = images.length;
|
|
77
|
+
const [activeIndex, setActiveIndex] = useState(() => clampIndex(startPosition, imgLen));
|
|
78
|
+
const safeIdx = clampIndex(activeIndex, imgLen);
|
|
80
79
|
const latestRef = useRef({
|
|
81
80
|
images,
|
|
82
|
-
index:
|
|
81
|
+
index: safeIdx,
|
|
83
82
|
beforeClose,
|
|
84
83
|
onClose
|
|
85
84
|
});
|
|
86
85
|
latestRef.current = {
|
|
87
86
|
images,
|
|
88
|
-
index:
|
|
87
|
+
index: safeIdx,
|
|
89
88
|
beforeClose,
|
|
90
89
|
onClose
|
|
91
90
|
};
|
|
@@ -93,11 +92,11 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
93
92
|
uri: img
|
|
94
93
|
} : img), [images]);
|
|
95
94
|
useEffect(() => {
|
|
96
|
-
setActiveIndex(
|
|
97
|
-
}, [
|
|
95
|
+
setActiveIndex(cur => clampIndex(cur, imgLen));
|
|
96
|
+
}, [imgLen]);
|
|
98
97
|
useEffect(() => {
|
|
99
98
|
if (!visible) return;
|
|
100
|
-
const next = clampIndex(startPosition,
|
|
99
|
+
const next = clampIndex(startPosition, imgLen);
|
|
101
100
|
setActiveIndex(next);
|
|
102
101
|
if (typeof requestAnimationFrame !== 'undefined') {
|
|
103
102
|
const raf = requestAnimationFrame(() => {
|
|
@@ -105,7 +104,7 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
105
104
|
});
|
|
106
105
|
return () => cancelAnimationFrame(raf);
|
|
107
106
|
}
|
|
108
|
-
}, [
|
|
107
|
+
}, [imgLen, startPosition, visible]);
|
|
109
108
|
const runBeforeClose = useCallback(async reason => {
|
|
110
109
|
const {
|
|
111
110
|
beforeClose: bc,
|
|
@@ -144,17 +143,17 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
144
143
|
}, [executeClose]);
|
|
145
144
|
useImperativeHandle(ref, () => ({
|
|
146
145
|
swipeTo: (index, anim = true) => {
|
|
147
|
-
const next = clampIndex(index,
|
|
146
|
+
const next = clampIndex(index, imgLen);
|
|
148
147
|
setActiveIndex(next);
|
|
149
148
|
swiperRef.current?.swipeTo(next, anim);
|
|
150
149
|
}
|
|
151
|
-
}), [
|
|
150
|
+
}), [imgLen]);
|
|
152
151
|
const onChangeRef = useRef(onChange);
|
|
153
152
|
onChangeRef.current = onChange;
|
|
154
|
-
const
|
|
155
|
-
|
|
153
|
+
const safeIdxRef = useRef(safeIdx);
|
|
154
|
+
safeIdxRef.current = safeIdx;
|
|
156
155
|
const handleSwiperChange = useCallback(index => {
|
|
157
|
-
if (
|
|
156
|
+
if (safeIdxRef.current === index) return;
|
|
158
157
|
setActiveIndex(index);
|
|
159
158
|
onChangeRef.current?.(index);
|
|
160
159
|
}, []);
|
|
@@ -253,6 +252,7 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
253
252
|
}) : /*#__PURE__*/React.createElement(Text, {
|
|
254
253
|
style: [S.indexText, {
|
|
255
254
|
color: colors.indexText,
|
|
255
|
+
fontFamily: typography.fontFamily,
|
|
256
256
|
fontSize: typography.indexTextSize
|
|
257
257
|
}]
|
|
258
258
|
}, indexText)));
|
|
@@ -295,16 +295,16 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
295
295
|
style: [S.content, {
|
|
296
296
|
backgroundColor: colors.background
|
|
297
297
|
}]
|
|
298
|
-
},
|
|
298
|
+
}, imgLen === 1 && renderIndex(0, 1), imgLen === 0 ? /*#__PURE__*/React.createElement(View, {
|
|
299
299
|
style: S.empty,
|
|
300
300
|
testID: "rv-image-preview-empty"
|
|
301
301
|
}) : /*#__PURE__*/React.createElement(Swiper, {
|
|
302
302
|
ref: swiperRef,
|
|
303
303
|
style: S.swiper,
|
|
304
|
-
initialSwipe: clampIndex(startPosition,
|
|
304
|
+
initialSwipe: clampIndex(startPosition, imgLen),
|
|
305
305
|
loop: false,
|
|
306
306
|
autoplay: false,
|
|
307
|
-
touchable:
|
|
307
|
+
touchable: imgLen > 1,
|
|
308
308
|
indicator: renderIndicator,
|
|
309
309
|
onChange: handleSwiperChange,
|
|
310
310
|
testID: "rv-image-preview-swiper"
|
|
@@ -314,7 +314,7 @@ const ImagePreviewImpl = (props, ref) => {
|
|
|
314
314
|
testID: `rv-image-preview-slide-${index}`
|
|
315
315
|
}, /*#__PURE__*/React.createElement(ImageSlide, {
|
|
316
316
|
source: source,
|
|
317
|
-
rendered: !lazyRender || Math.abs(index -
|
|
317
|
+
rendered: !lazyRender || Math.abs(index - safeIdx) <= lazyBuffer,
|
|
318
318
|
pressableHandlers: pressableHandlers,
|
|
319
319
|
index: index,
|
|
320
320
|
total: resolvedImages.length
|
|
@@ -4,7 +4,8 @@ const createTokens = foundations => {
|
|
|
4
4
|
palette,
|
|
5
5
|
radii,
|
|
6
6
|
fontSize,
|
|
7
|
-
spacing
|
|
7
|
+
spacing,
|
|
8
|
+
typography
|
|
8
9
|
} = foundations;
|
|
9
10
|
return {
|
|
10
11
|
colors: {
|
|
@@ -28,6 +29,7 @@ const createTokens = foundations => {
|
|
|
28
29
|
indexBadge: radii.pill
|
|
29
30
|
},
|
|
30
31
|
typography: {
|
|
32
|
+
fontFamily: typography.fontFamily,
|
|
31
33
|
indexTextSize: fontSize.sm
|
|
32
34
|
}
|
|
33
35
|
};
|
|
@@ -35,8 +35,8 @@ const InputImpl = (props, ref) => {
|
|
|
35
35
|
const tokens = useInputTokens(tokensOverride);
|
|
36
36
|
const inputRef = useRef(null);
|
|
37
37
|
const onChangeRef = useRef(onChange);
|
|
38
|
-
onChangeRef.current = onChange;
|
|
39
38
|
const onChangeTextRef = useRef(onChangeText);
|
|
39
|
+
onChangeRef.current = onChange;
|
|
40
40
|
onChangeTextRef.current = onChangeText;
|
|
41
41
|
const handleChangeText = useCallback(value => {
|
|
42
42
|
onChangeRef.current?.(value);
|
|
@@ -50,9 +50,9 @@ const InputImpl = (props, ref) => {
|
|
|
50
50
|
return inputRef.current?.nativeElement ?? null;
|
|
51
51
|
}
|
|
52
52
|
}), []);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
53
|
+
const rAlign = alignProp ?? inputAlignProp ?? tokens.defaults.inputAlign;
|
|
54
|
+
const rClearTrigger = clearTriggerProp ?? tokens.defaults.clearTrigger;
|
|
55
|
+
const rKeyboardType = keyboardTypeProp ?? mapKeyboardType(type);
|
|
56
56
|
const fieldStyle = [{
|
|
57
57
|
paddingHorizontal: tokens.spacing.paddingHorizontal,
|
|
58
58
|
paddingVertical: tokens.spacing.paddingVertical,
|
|
@@ -62,11 +62,11 @@ const InputImpl = (props, ref) => {
|
|
|
62
62
|
ref: inputRef
|
|
63
63
|
}, rest, {
|
|
64
64
|
type: type,
|
|
65
|
-
keyboardType:
|
|
65
|
+
keyboardType: rKeyboardType,
|
|
66
66
|
tokensOverride: fieldTokensOverride,
|
|
67
67
|
border: tokens.defaults.border,
|
|
68
|
-
inputAlign:
|
|
69
|
-
clearTrigger:
|
|
68
|
+
inputAlign: rAlign,
|
|
69
|
+
clearTrigger: rClearTrigger,
|
|
70
70
|
style: fieldStyle,
|
|
71
71
|
inputStyle: inputStyle,
|
|
72
72
|
showWordLimit: showWordLimit,
|
|
@@ -82,24 +82,21 @@ const TextAreaImpl = (props, ref) => {
|
|
|
82
82
|
...rest
|
|
83
83
|
} = props;
|
|
84
84
|
const fieldTokens = useFieldTokens(rest.fieldTokensOverride);
|
|
85
|
-
const
|
|
86
|
-
const toRows = useCallback(height =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return minRows || maxRows ? {
|
|
94
|
-
minRows,
|
|
95
|
-
maxRows
|
|
85
|
+
const lh = fieldTokens.defaults.textareaLineHeight;
|
|
86
|
+
const toRows = useCallback(height => !isFiniteNumber(height) || height <= 0 ? undefined : Math.max(1, Math.round(height / lh)), [lh]);
|
|
87
|
+
const rAutoSize = useMemo(() => !autoSizeProp || isBoolean(autoSizeProp) ? autoSizeProp : (() => {
|
|
88
|
+
const minR = toRows(autoSizeProp.minHeight);
|
|
89
|
+
const maxR = toRows(autoSizeProp.maxHeight);
|
|
90
|
+
return minR || maxR ? {
|
|
91
|
+
minRows: minR,
|
|
92
|
+
maxRows: maxR
|
|
96
93
|
} : undefined;
|
|
97
94
|
})(), [autoSizeProp, toRows]);
|
|
98
95
|
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
99
96
|
ref: ref
|
|
100
97
|
}, rest, {
|
|
101
98
|
type: "textarea",
|
|
102
|
-
autoSize:
|
|
99
|
+
autoSize: rAutoSize
|
|
103
100
|
}));
|
|
104
101
|
};
|
|
105
102
|
const TextAreaForwardRef = /*#__PURE__*/React.forwardRef(TextAreaImpl);
|
|
@@ -7,13 +7,13 @@ import { useLoadingTokens } from './tokens';
|
|
|
7
7
|
const LoadingImpl = props => {
|
|
8
8
|
const {
|
|
9
9
|
tokensOverride,
|
|
10
|
-
color:
|
|
11
|
-
size:
|
|
12
|
-
textSize:
|
|
13
|
-
textColor:
|
|
14
|
-
vertical:
|
|
15
|
-
accessibilityLabel:
|
|
16
|
-
['aria-label']:
|
|
10
|
+
color: clrP,
|
|
11
|
+
size: sizeP,
|
|
12
|
+
textSize: tsP,
|
|
13
|
+
textColor: tcP,
|
|
14
|
+
vertical: vertP,
|
|
15
|
+
accessibilityLabel: accP,
|
|
16
|
+
['aria-label']: ariaP,
|
|
17
17
|
style,
|
|
18
18
|
textStyle,
|
|
19
19
|
contentStyle,
|
|
@@ -21,37 +21,37 @@ const LoadingImpl = props => {
|
|
|
21
21
|
...rest
|
|
22
22
|
} = props;
|
|
23
23
|
const tokens = useLoadingTokens(tokensOverride);
|
|
24
|
-
const
|
|
25
|
-
const size =
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
24
|
+
const clr = clrP ?? tokens.colors.indicator;
|
|
25
|
+
const size = sizeP ?? tokens.defaults.size;
|
|
26
|
+
const ts = tsP ?? tokens.defaults.textSize;
|
|
27
|
+
const tc = tcP ?? tokens.colors.text;
|
|
28
|
+
const vert = vertP ?? tokens.defaults.vertical;
|
|
29
|
+
const acc = ariaP ?? accP ?? 'loading';
|
|
30
|
+
const ind = /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
31
31
|
testID: "rv-loading-spinner",
|
|
32
32
|
size: size,
|
|
33
|
-
color:
|
|
34
|
-
accessibilityLabel:
|
|
33
|
+
color: clr,
|
|
34
|
+
accessibilityLabel: acc
|
|
35
35
|
});
|
|
36
|
-
const
|
|
37
|
-
marginLeft:
|
|
38
|
-
marginTop:
|
|
36
|
+
const txtSp = {
|
|
37
|
+
marginLeft: vert ? 0 : tokens.spacing.gap,
|
|
38
|
+
marginTop: vert ? tokens.spacing.gap : 0
|
|
39
39
|
};
|
|
40
|
-
const
|
|
41
|
-
style: isText(children) ? undefined :
|
|
42
|
-
}, renderTextOrNode(children, [tokens.layout.text,
|
|
43
|
-
fontSize:
|
|
44
|
-
color:
|
|
40
|
+
const txtNode = isRenderable(children) && /*#__PURE__*/React.createElement(View, {
|
|
41
|
+
style: isText(children) ? undefined : txtSp
|
|
42
|
+
}, renderTextOrNode(children, [tokens.layout.text, txtSp, {
|
|
43
|
+
fontSize: ts,
|
|
44
|
+
color: tc
|
|
45
45
|
}, textStyle].filter(Boolean)));
|
|
46
46
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
47
47
|
accessibilityRole: "progressbar",
|
|
48
48
|
style: [tokens.layout.container, {
|
|
49
|
-
flexDirection:
|
|
50
|
-
justifyContent:
|
|
49
|
+
flexDirection: vert ? 'column' : 'row',
|
|
50
|
+
justifyContent: vert ? 'center' : 'flex-start'
|
|
51
51
|
}, style]
|
|
52
52
|
}, rest), /*#__PURE__*/React.createElement(View, {
|
|
53
53
|
style: contentStyle
|
|
54
|
-
},
|
|
54
|
+
}, ind), txtNode);
|
|
55
55
|
};
|
|
56
56
|
export const Loading = /*#__PURE__*/React.memo(LoadingImpl);
|
|
57
57
|
Loading.displayName = 'Loading';
|
|
@@ -19,13 +19,13 @@ const NavBarBaseImpl = props => {
|
|
|
19
19
|
rightText,
|
|
20
20
|
leftIcon,
|
|
21
21
|
rightIcon,
|
|
22
|
-
leftArrow:
|
|
23
|
-
fixed:
|
|
24
|
-
placeholder:
|
|
25
|
-
zIndex:
|
|
26
|
-
border:
|
|
27
|
-
safeAreaInsetTop:
|
|
28
|
-
background:
|
|
22
|
+
leftArrow: leftArrP,
|
|
23
|
+
fixed: fixedP,
|
|
24
|
+
placeholder: placeP,
|
|
25
|
+
zIndex: zIdxP,
|
|
26
|
+
border: borderP,
|
|
27
|
+
safeAreaInsetTop: safeTopP,
|
|
28
|
+
background: bgP,
|
|
29
29
|
tintColor,
|
|
30
30
|
titleStyle,
|
|
31
31
|
descriptionStyle,
|
|
@@ -40,21 +40,21 @@ const NavBarBaseImpl = props => {
|
|
|
40
40
|
const locale = useLocale();
|
|
41
41
|
const dir = useDirection();
|
|
42
42
|
const tokens = useNavBarTokens(tokensOverride);
|
|
43
|
-
const leftArrow =
|
|
44
|
-
const fixed =
|
|
45
|
-
const placeholder =
|
|
46
|
-
const zIndex =
|
|
47
|
-
const border =
|
|
48
|
-
const safeAreaInsetTop =
|
|
49
|
-
const background =
|
|
43
|
+
const leftArrow = leftArrP ?? tokens.defaults.leftArrow;
|
|
44
|
+
const fixed = fixedP ?? tokens.defaults.fixed;
|
|
45
|
+
const placeholder = placeP ?? tokens.defaults.placeholder;
|
|
46
|
+
const zIndex = zIdxP ?? tokens.defaults.zIndex;
|
|
47
|
+
const border = borderP ?? tokens.defaults.border;
|
|
48
|
+
const safeAreaInsetTop = safeTopP ?? fixed;
|
|
49
|
+
const background = bgP ?? tokens.colors.background;
|
|
50
50
|
const handlePressLeft = onPressLeft ?? onClickLeft;
|
|
51
51
|
const handlePressRight = onPressRight ?? onClickRight;
|
|
52
52
|
const [height, setHeight] = useState(tokens.sizing.height);
|
|
53
53
|
const enablePlaceholder = fixed && placeholder;
|
|
54
54
|
const handleLayout = useCallback(event => {
|
|
55
55
|
if (!enablePlaceholder) return;
|
|
56
|
-
const
|
|
57
|
-
setHeight(prev => Math.abs(prev -
|
|
56
|
+
const nextH = event.nativeEvent.layout.height;
|
|
57
|
+
setHeight(prev => Math.abs(prev - nextH) < 0.5 ? prev : nextH);
|
|
58
58
|
}, [enablePlaceholder]);
|
|
59
59
|
const resolvedColor = tintColor ?? tokens.colors.text;
|
|
60
60
|
const sideColor = tintColor ?? tokens.colors.icon;
|
|
@@ -94,10 +94,11 @@ const NavBarBaseImpl = props => {
|
|
|
94
94
|
if (!hasAction) return /*#__PURE__*/React.createElement(View, {
|
|
95
95
|
style: tokens.layout.sidePlaceholder
|
|
96
96
|
});
|
|
97
|
-
const content = /*#__PURE__*/React.createElement(React.Fragment, null, arrowNode, sideIcon, isRenderable(sideText) ? isText(sideText) ? /*#__PURE__*/React.createElement(Text, {
|
|
97
|
+
const content = /*#__PURE__*/React.createElement(React.Fragment, null, arrowNode, isRenderable(sideIcon) ? sideIcon : null, isRenderable(sideText) ? isText(sideText) ? /*#__PURE__*/React.createElement(Text, {
|
|
98
98
|
numberOfLines: 1,
|
|
99
99
|
style: [tokens.layout.sideText, {
|
|
100
|
-
color: sideColor
|
|
100
|
+
color: sideColor,
|
|
101
|
+
fontFamily: tokens.typography.fontFamily
|
|
101
102
|
}]
|
|
102
103
|
}, sideText) : sideText : null);
|
|
103
104
|
const sideStyles = [tokens.layout.side, !isLeft && tokens.layout.rightAlign, sideStyle];
|
|
@@ -120,12 +121,14 @@ const NavBarBaseImpl = props => {
|
|
|
120
121
|
style: tokens.layout.titleWrapper
|
|
121
122
|
}, isRenderable(title) && renderTextOrNode(title, [tokens.layout.title, {
|
|
122
123
|
color: resolvedColor,
|
|
124
|
+
fontFamily: tokens.typography.fontFamily,
|
|
123
125
|
fontSize: tokens.typography.titleSize,
|
|
124
126
|
fontWeight: tokens.typography.titleWeight
|
|
125
127
|
}, titleStyle], {
|
|
126
128
|
numberOfLines: 1
|
|
127
129
|
}), isRenderable(description) && renderTextOrNode(description, [tokens.layout.description, {
|
|
128
130
|
color: tintColor ?? tokens.colors.description,
|
|
131
|
+
fontFamily: tokens.typography.fontFamily,
|
|
129
132
|
fontSize: tokens.typography.descriptionSize
|
|
130
133
|
}, descriptionStyle], {
|
|
131
134
|
numberOfLines: 1
|
|
@@ -2,7 +2,8 @@ import { createComponentTokensHook } from '../../design-system';
|
|
|
2
2
|
export const createNavBarTokens = ({
|
|
3
3
|
palette,
|
|
4
4
|
spacing,
|
|
5
|
-
fontSize
|
|
5
|
+
fontSize,
|
|
6
|
+
typography
|
|
6
7
|
}) => {
|
|
7
8
|
return {
|
|
8
9
|
defaults: {
|
|
@@ -69,6 +70,7 @@ export const createNavBarTokens = ({
|
|
|
69
70
|
icon: palette.default[700]
|
|
70
71
|
},
|
|
71
72
|
typography: {
|
|
73
|
+
fontFamily: typography.fontFamily,
|
|
72
74
|
titleSize: fontSize.lg,
|
|
73
75
|
titleWeight: '600',
|
|
74
76
|
descriptionSize: fontSize.sm
|
|
@@ -66,8 +66,8 @@ const NoticeBarImpl = props => {
|
|
|
66
66
|
const verticalItems = useMemo(() => {
|
|
67
67
|
if (!isVertical) return [];
|
|
68
68
|
if (items && items.length) return items;
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
69
|
+
const arr = React.Children.toArray(children);
|
|
70
|
+
if (arr.length) return arr;
|
|
71
71
|
return text !== undefined ? [text] : [];
|
|
72
72
|
}, [children, isVertical, items, text]);
|
|
73
73
|
const hasVerticalLoop = !reducedMotion && isVertical && verticalItems.length > 1;
|
|
@@ -194,6 +194,7 @@ const NoticeBarImpl = props => {
|
|
|
194
194
|
if (!isVertical || verticalTrackItems.length === 0) return null;
|
|
195
195
|
if (!hasVerticalLoop) return renderTextOrNode(verticalTrackItems[0], [S.text, {
|
|
196
196
|
color: resolvedColor,
|
|
197
|
+
fontFamily: tokens.typography.fontFamily,
|
|
197
198
|
fontSize: tokens.typography.fontSize
|
|
198
199
|
}], {
|
|
199
200
|
numberOfLines: 1,
|
|
@@ -218,12 +219,13 @@ const NoticeBarImpl = props => {
|
|
|
218
219
|
style: S.vItem
|
|
219
220
|
}, renderTextOrNode(item, [S.text, {
|
|
220
221
|
color: resolvedColor,
|
|
222
|
+
fontFamily: tokens.typography.fontFamily,
|
|
221
223
|
fontSize: tokens.typography.fontSize
|
|
222
224
|
}], {
|
|
223
225
|
numberOfLines: 1,
|
|
224
226
|
...restTextProps
|
|
225
227
|
})))));
|
|
226
|
-
}, [handleItemLayout, hasVerticalLoop, isVertical, itemHeight, resolvedColor, restTextProps, textOnLayout, tokens.typography.fontSize, verticalTrackItems, verticalTranslateY]);
|
|
228
|
+
}, [handleItemLayout, hasVerticalLoop, isVertical, itemHeight, resolvedColor, restTextProps, textOnLayout, tokens.typography.fontFamily, tokens.typography.fontSize, verticalTrackItems, verticalTranslateY]);
|
|
227
229
|
const handleContainerLayout = useCallback(event => {
|
|
228
230
|
setContainerWidthSafe(event.nativeEvent.layout.width);
|
|
229
231
|
}, [setContainerWidthSafe]);
|
|
@@ -258,6 +260,7 @@ const NoticeBarImpl = props => {
|
|
|
258
260
|
onLayout: handleTextLayout,
|
|
259
261
|
style: [S.text, S.scrollText, {
|
|
260
262
|
color: resolvedColor,
|
|
263
|
+
fontFamily: tokens.typography.fontFamily,
|
|
261
264
|
fontSize: tokens.typography.fontSize,
|
|
262
265
|
transform: [{
|
|
263
266
|
translateX
|
|
@@ -279,6 +282,7 @@ const NoticeBarImpl = props => {
|
|
|
279
282
|
onLayout: handleTextLayout,
|
|
280
283
|
style: [S.text, {
|
|
281
284
|
color: resolvedColor,
|
|
285
|
+
fontFamily: tokens.typography.fontFamily,
|
|
282
286
|
fontSize: tokens.typography.fontSize
|
|
283
287
|
}, wrapable && S.wrapText],
|
|
284
288
|
numberOfLines: wrapable ? undefined : 1,
|
|
@@ -4,7 +4,8 @@ export const createNoticeBarTokens = foundations => {
|
|
|
4
4
|
palette,
|
|
5
5
|
fontSize,
|
|
6
6
|
spacing,
|
|
7
|
-
radii
|
|
7
|
+
radii,
|
|
8
|
+
typography
|
|
8
9
|
} = foundations;
|
|
9
10
|
return {
|
|
10
11
|
colors: {
|
|
@@ -12,6 +13,7 @@ export const createNoticeBarTokens = foundations => {
|
|
|
12
13
|
background: palette.warning[50]
|
|
13
14
|
},
|
|
14
15
|
typography: {
|
|
16
|
+
fontFamily: typography.fontFamily,
|
|
15
17
|
fontSize: fontSize.sm
|
|
16
18
|
},
|
|
17
19
|
layout: {
|
|
@@ -213,13 +213,14 @@ const NotifyContentImpl = props => {
|
|
|
213
213
|
}]
|
|
214
214
|
}, hasMessage && (isText(message) ? renderTextOrNode(message, [tokens.layout.text, {
|
|
215
215
|
color: resolvedTextColor,
|
|
216
|
+
fontFamily: tokens.typography.fontFamily,
|
|
216
217
|
fontSize: tokens.typography.fontSize,
|
|
217
218
|
lineHeight: tokens.typography.lineHeight
|
|
218
219
|
}, textStyle]) : message))))), position === 'bottom' && /*#__PURE__*/React.createElement(View, {
|
|
219
220
|
style: {
|
|
220
221
|
height: safeAreaBottomInset
|
|
221
222
|
}
|
|
222
|
-
})), [accessibilityRole, animatedValue, contentHeight, handleLayout, hasMessage, interactive, message, offset, resolvedBackground, resolvedTextColor, safeAreaBottomInset, safeAreaTopValue, style, textStyle, tokens.layout.container, tokens.layout.content, tokens.layout.text, tokens.sizing.minHeight, tokens.spacing.paddingHorizontal, tokens.spacing.paddingVertical, tokens.typography.fontSize, tokens.typography.lineHeight, translateY, webBottomPadding, webTopPadding, position]);
|
|
223
|
+
})), [accessibilityRole, animatedValue, contentHeight, handleLayout, hasMessage, interactive, message, offset, resolvedBackground, resolvedTextColor, safeAreaBottomInset, safeAreaTopValue, style, textStyle, tokens.layout.container, tokens.layout.content, tokens.layout.text, tokens.sizing.minHeight, tokens.spacing.paddingHorizontal, tokens.spacing.paddingVertical, tokens.typography.fontFamily, tokens.typography.fontSize, tokens.typography.lineHeight, translateY, webBottomPadding, webTopPadding, position]);
|
|
223
224
|
if (!mounted) return null;
|
|
224
225
|
return /*#__PURE__*/React.createElement(View, {
|
|
225
226
|
testID: "rv-notify",
|
|
@@ -21,16 +21,16 @@ const typeDefaults = new Map();
|
|
|
21
21
|
const parseOptions = input => /*#__PURE__*/React.isValidElement(input) || isText(input) ? {
|
|
22
22
|
message: input
|
|
23
23
|
} : input ?? {};
|
|
24
|
-
const mergeOptions = (input,
|
|
25
|
-
const
|
|
26
|
-
const
|
|
24
|
+
const mergeOptions = (input, fallbackT) => {
|
|
25
|
+
const t = input.type ?? fallbackT;
|
|
26
|
+
const m = {
|
|
27
27
|
...currentOptions,
|
|
28
|
-
...typeDefaults.get(
|
|
28
|
+
...typeDefaults.get(t),
|
|
29
29
|
...input,
|
|
30
|
-
type
|
|
30
|
+
type: t
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
return
|
|
32
|
+
m.duration = m.duration ?? 3000;
|
|
33
|
+
return m;
|
|
34
34
|
};
|
|
35
35
|
const removeNotify = key => {
|
|
36
36
|
Portal.remove(key);
|
|
@@ -69,9 +69,9 @@ const NotifyPortal = ({
|
|
|
69
69
|
onClosed: handleClosed
|
|
70
70
|
}));
|
|
71
71
|
};
|
|
72
|
-
const showNotify = (input,
|
|
73
|
-
const opts = mergeOptions(parseOptions(input),
|
|
74
|
-
if (!allowMultiple) activeKeys.forEach(
|
|
72
|
+
const showNotify = (input, fallbackT = 'primary') => {
|
|
73
|
+
const opts = mergeOptions(parseOptions(input), fallbackT);
|
|
74
|
+
if (!allowMultiple) activeKeys.forEach(k => closeNotify(k));
|
|
75
75
|
const key = Portal.add(null);
|
|
76
76
|
notifyOptions.set(key, opts);
|
|
77
77
|
Portal.update(key, /*#__PURE__*/React.createElement(NotifyPortal, {
|
|
@@ -83,22 +83,22 @@ const showNotify = (input, fallbackType = 'primary') => {
|
|
|
83
83
|
const prev = notifyOptions.get(key);
|
|
84
84
|
if (!prev) return;
|
|
85
85
|
const parsed = parseOptions(isFunction(next) ? next(prev) : next);
|
|
86
|
-
const
|
|
87
|
-
const
|
|
86
|
+
const nextT = parsed.type ?? prev.type ?? fallbackT;
|
|
87
|
+
const m = {
|
|
88
88
|
...prev,
|
|
89
89
|
...parsed,
|
|
90
|
-
type:
|
|
90
|
+
type: nextT
|
|
91
91
|
};
|
|
92
|
-
if ('duration' in parsed && parsed.duration == null)
|
|
93
|
-
notifyOptions.set(key,
|
|
92
|
+
if ('duration' in parsed && parsed.duration == null) m.duration = baseOptions.duration ?? 3000;
|
|
93
|
+
notifyOptions.set(key, m);
|
|
94
94
|
Portal.update(key, /*#__PURE__*/React.createElement(NotifyPortal, {
|
|
95
95
|
id: key,
|
|
96
|
-
options:
|
|
96
|
+
options: m
|
|
97
97
|
}));
|
|
98
98
|
};
|
|
99
99
|
return {
|
|
100
100
|
clear: () => closeNotify(key),
|
|
101
|
-
update:
|
|
101
|
+
update: n => config(n),
|
|
102
102
|
config
|
|
103
103
|
};
|
|
104
104
|
};
|
|
@@ -51,6 +51,7 @@ export const createNotifyTokens = foundations => ({
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
typography: {
|
|
54
|
+
fontFamily: foundations.typography.fontFamily,
|
|
54
55
|
fontSize: foundations.fontSize.sm,
|
|
55
56
|
lineHeight: Math.round(foundations.fontSize.sm * foundations.typography.lineHeightMultiplier)
|
|
56
57
|
},
|