react-native-system-ui 1.0.0 → 1.0.2
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/README.md +3 -3
- package/dist/cjs/components/action-sheet/ActionSheet.js +51 -53
- 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 +206 -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 +94 -93
- 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 +38 -28
- 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 +8 -2
- 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/slider/Slider.js +1 -1
- 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/tabbar/TabbarItem.js +6 -0
- 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 +7 -3
- 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 +51 -53
- 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 +206 -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 +95 -94
- 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 +39 -29
- 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 +8 -2
- 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/slider/Slider.js +3 -3
- 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/tabbar/TabbarItem.js +6 -0
- 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 +7 -3
- 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
|
@@ -43,154 +43,153 @@ export const ProgressFilledTrack = ({
|
|
|
43
43
|
export const Progress = /*#__PURE__*/memo(props => {
|
|
44
44
|
const {
|
|
45
45
|
tokensOverride,
|
|
46
|
-
percentage:
|
|
46
|
+
percentage: pctP,
|
|
47
47
|
strokeWidth,
|
|
48
48
|
color,
|
|
49
49
|
trackColor,
|
|
50
50
|
pivotText,
|
|
51
51
|
pivotColor,
|
|
52
52
|
textColor,
|
|
53
|
-
inactive:
|
|
54
|
-
showPivot:
|
|
53
|
+
inactive: inactP,
|
|
54
|
+
showPivot: showPivotP,
|
|
55
55
|
animated,
|
|
56
|
-
transition:
|
|
57
|
-
animationDuration:
|
|
56
|
+
transition: transP,
|
|
57
|
+
animationDuration: durP,
|
|
58
58
|
style,
|
|
59
59
|
pivotStyle,
|
|
60
60
|
indicatorStyle,
|
|
61
|
-
orientation:
|
|
61
|
+
orientation: oriP,
|
|
62
62
|
children,
|
|
63
63
|
...rest
|
|
64
64
|
} = props;
|
|
65
65
|
const tokens = useProgressTokens(tokensOverride);
|
|
66
66
|
const reducedMotion = useReducedMotion();
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
67
|
+
const pct = clamp(parsePercentage(pctP ?? tokens.defaults.percentage), 0, 100);
|
|
68
|
+
const h = parseNumberLike(strokeWidth, tokens.sizing.height) ?? tokens.sizing.height;
|
|
69
|
+
const inact = inactP ?? tokens.defaults.inactive;
|
|
70
|
+
const ori = oriP ?? 'horizontal';
|
|
71
|
+
const showPivot = ori === 'vertical' ? false : showPivotP ?? tokens.defaults.showPivot;
|
|
72
|
+
const doAnim = (animated ?? transP ?? tokens.defaults.transition) && !inact;
|
|
73
|
+
const dur = Math.max(0, durP ?? tokens.defaults.animationDuration);
|
|
74
|
+
const isGrad = Platform.OS === 'web' && isString(color) && GRADIENT_REGEX.test(color);
|
|
75
|
+
const trackClr = trackColor ?? tokens.colors.track;
|
|
76
|
+
const indClr = inact ? tokens.colors.track : !isGrad ? color ?? tokens.colors.indicator : undefined;
|
|
77
|
+
const pivotBg = pivotColor ?? (isGrad ? inact ? tokens.colors.track : tokens.colors.indicator : indClr);
|
|
78
|
+
const pivotTxtClr = textColor ?? tokens.colors.pivotText;
|
|
79
|
+
const pivotCnt = pivotText ?? `${pct}%`;
|
|
80
|
+
const hasPiv = showPivot && pivotCnt !== null && pivotCnt !== false;
|
|
81
|
+
const animVal = useRef(new Animated.Value(pct)).current;
|
|
82
82
|
useEffect(() => {
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
toValue:
|
|
86
|
-
duration,
|
|
83
|
+
if (doAnim && dur > 0 && !reducedMotion) {
|
|
84
|
+
const anim = Animated.timing(animVal, {
|
|
85
|
+
toValue: pct,
|
|
86
|
+
duration: dur,
|
|
87
87
|
useNativeDriver: false,
|
|
88
88
|
isInteraction: false
|
|
89
89
|
});
|
|
90
|
-
|
|
91
|
-
return () =>
|
|
92
|
-
} else
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, [percentageClamped, shouldAnimate, duration, animatedValue, reducedMotion]);
|
|
96
|
-
const [layout, setLayout] = useState({
|
|
90
|
+
anim.start();
|
|
91
|
+
return () => anim.stop();
|
|
92
|
+
} else animVal.setValue(pct);
|
|
93
|
+
}, [pct, doAnim, dur, animVal, reducedMotion]);
|
|
94
|
+
const [lay, setLay] = useState({
|
|
97
95
|
track: 0,
|
|
98
96
|
pivot: 0
|
|
99
97
|
});
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
98
|
+
const onTrackLay = useCallback(e => {
|
|
99
|
+
const w = e.nativeEvent.layout.width;
|
|
100
|
+
setLay(prev => prev.track === w ? prev : {
|
|
103
101
|
...prev,
|
|
104
|
-
track:
|
|
102
|
+
track: w
|
|
105
103
|
});
|
|
106
104
|
}, []);
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
105
|
+
const onPivotLay = useCallback(e => {
|
|
106
|
+
const w = e.nativeEvent.layout.width;
|
|
107
|
+
setLay(prev => prev.pivot === w ? prev : {
|
|
110
108
|
...prev,
|
|
111
|
-
pivot:
|
|
109
|
+
pivot: w
|
|
112
110
|
});
|
|
113
111
|
}, []);
|
|
114
|
-
const trackStyle = [tokens.layout.track,
|
|
115
|
-
width:
|
|
112
|
+
const trackStyle = [tokens.layout.track, ori === 'vertical' ? {
|
|
113
|
+
width: h,
|
|
116
114
|
height: '100%',
|
|
117
|
-
backgroundColor:
|
|
118
|
-
borderRadius:
|
|
115
|
+
backgroundColor: trackClr,
|
|
116
|
+
borderRadius: h / 2
|
|
119
117
|
} : {
|
|
120
|
-
height:
|
|
121
|
-
backgroundColor:
|
|
122
|
-
borderRadius:
|
|
118
|
+
height: h,
|
|
119
|
+
backgroundColor: trackClr,
|
|
120
|
+
borderRadius: h / 2
|
|
123
121
|
}];
|
|
124
122
|
const pivotNode = useMemo(() => {
|
|
125
|
-
if (!
|
|
123
|
+
if (!hasPiv) return null;
|
|
126
124
|
const {
|
|
127
|
-
track:
|
|
128
|
-
pivot:
|
|
129
|
-
} =
|
|
130
|
-
const
|
|
131
|
-
bottom:
|
|
132
|
-
backgroundColor:
|
|
125
|
+
track: tw,
|
|
126
|
+
pivot: pw
|
|
127
|
+
} = lay;
|
|
128
|
+
const ctrStyle = [tokens.layout.pivot, {
|
|
129
|
+
bottom: h + tokens.sizing.pivotPaddingVertical * 2,
|
|
130
|
+
backgroundColor: pivotBg,
|
|
133
131
|
paddingHorizontal: tokens.sizing.pivotPaddingHorizontal,
|
|
134
132
|
paddingVertical: tokens.sizing.pivotPaddingVertical,
|
|
135
|
-
borderRadius:
|
|
136
|
-
opacity:
|
|
133
|
+
borderRadius: h,
|
|
134
|
+
opacity: tw > 0 ? 1 : 0
|
|
137
135
|
}];
|
|
138
|
-
let
|
|
139
|
-
if (
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
}
|
|
136
|
+
let transStyle = null;
|
|
137
|
+
if (tw > 0 && pw > 0) {
|
|
138
|
+
const p1 = pw / 2 / tw * 100;
|
|
139
|
+
const p2 = (tw - pw / 2) / tw * 100;
|
|
140
|
+
transStyle = p1 < p2 ? {
|
|
141
|
+
transform: [{
|
|
142
|
+
translateX: animVal.interpolate({
|
|
143
|
+
inputRange: [0, p1, p2, 100],
|
|
144
|
+
outputRange: [0, 0, tw - pw, tw - pw],
|
|
145
|
+
extrapolate: 'clamp'
|
|
146
|
+
})
|
|
147
|
+
}]
|
|
148
|
+
} : {
|
|
149
|
+
transform: [{
|
|
150
|
+
translateX: (tw - pw) / 2
|
|
151
|
+
}]
|
|
152
|
+
};
|
|
153
|
+
} else transStyle = {
|
|
154
|
+
transform: [{
|
|
155
|
+
translateX: (tw - pw) / 2
|
|
156
|
+
}]
|
|
157
|
+
};
|
|
160
158
|
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
161
|
-
style: [
|
|
159
|
+
style: [ctrStyle, transStyle],
|
|
162
160
|
pointerEvents: "none",
|
|
163
|
-
onLayout:
|
|
164
|
-
}, isText(
|
|
161
|
+
onLayout: onPivotLay
|
|
162
|
+
}, isText(pivotCnt) ? /*#__PURE__*/React.createElement(Text, {
|
|
165
163
|
style: [tokens.layout.pivotText, {
|
|
166
|
-
color:
|
|
164
|
+
color: pivotTxtClr,
|
|
165
|
+
fontFamily: tokens.typography.fontFamily,
|
|
167
166
|
fontSize: tokens.typography.pivotFontSize
|
|
168
167
|
}, pivotStyle]
|
|
169
|
-
},
|
|
170
|
-
}, [
|
|
171
|
-
const
|
|
172
|
-
animatedValue:
|
|
173
|
-
orientation:
|
|
174
|
-
height:
|
|
175
|
-
indicatorColor:
|
|
168
|
+
}, pivotCnt) : pivotCnt);
|
|
169
|
+
}, [animVal, hasPiv, h, lay, onPivotLay, pivotCnt, pivotStyle, pivotBg, pivotTxtClr, tokens.layout.pivot, tokens.layout.pivotText, tokens.sizing.pivotPaddingHorizontal, tokens.sizing.pivotPaddingVertical, tokens.typography.fontFamily, tokens.typography.pivotFontSize]);
|
|
170
|
+
const ctxVal = useMemo(() => ({
|
|
171
|
+
animatedValue: animVal,
|
|
172
|
+
orientation: ori,
|
|
173
|
+
height: h,
|
|
174
|
+
indicatorColor: indClr,
|
|
176
175
|
indicatorStyle: indicatorStyle,
|
|
177
|
-
isGradient:
|
|
178
|
-
gradientColor:
|
|
176
|
+
isGradient: isGrad,
|
|
177
|
+
gradientColor: isGrad ? color : undefined,
|
|
179
178
|
layoutIndicator: tokens.layout.indicator
|
|
180
|
-
}), [
|
|
179
|
+
}), [animVal, color, h, indicatorStyle, isGrad, ori, indClr, tokens.layout.indicator]);
|
|
181
180
|
return /*#__PURE__*/React.createElement(ProgressContext.Provider, {
|
|
182
|
-
value:
|
|
181
|
+
value: ctxVal
|
|
183
182
|
}, /*#__PURE__*/React.createElement(View, _extends({
|
|
184
183
|
style: style,
|
|
185
184
|
accessibilityRole: "progressbar",
|
|
186
185
|
accessibilityValue: {
|
|
187
186
|
min: 0,
|
|
188
187
|
max: 100,
|
|
189
|
-
now:
|
|
188
|
+
now: pct
|
|
190
189
|
}
|
|
191
190
|
}, rest), /*#__PURE__*/React.createElement(View, {
|
|
192
191
|
style: trackStyle,
|
|
193
|
-
onLayout:
|
|
192
|
+
onLayout: hasPiv ? onTrackLay : undefined
|
|
194
193
|
}, children ?? /*#__PURE__*/React.createElement(ProgressFilledTrack, null)), pivotNode));
|
|
195
194
|
});
|
|
196
195
|
Progress.displayName = 'Progress';
|
|
@@ -17,7 +17,7 @@ export const Radio = /*#__PURE__*/React.memo(props => {
|
|
|
17
17
|
iconSize,
|
|
18
18
|
checkedColor,
|
|
19
19
|
iconRender,
|
|
20
|
-
shape:
|
|
20
|
+
shape: shapeP,
|
|
21
21
|
labelPosition,
|
|
22
22
|
labelDisabled,
|
|
23
23
|
disabled,
|
|
@@ -32,129 +32,133 @@ export const Radio = /*#__PURE__*/React.memo(props => {
|
|
|
32
32
|
} = props;
|
|
33
33
|
const tokens = useRadioTokens(tokensOverride);
|
|
34
34
|
const group = useContext(RadioGroupContext);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const isGroup = !!group &&
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const shape =
|
|
44
|
-
const
|
|
35
|
+
const optVal = value ?? name;
|
|
36
|
+
const sv = optVal == null ? undefined : String(optVal);
|
|
37
|
+
const isGroup = !!group && sv !== undefined;
|
|
38
|
+
const rIconSz = parseNumber(iconSize ?? group?.iconSize, tokens.defaults.iconSize);
|
|
39
|
+
const rCheckedClr = checkedColor ?? group?.checkedColor ?? tokens.colors.checkedBackground;
|
|
40
|
+
const rLabelPos = labelPosition ?? tokens.defaults.labelPosition;
|
|
41
|
+
const rLabelDis = labelDisabled ?? group?.labelDisabled ?? tokens.defaults.labelDisabled;
|
|
42
|
+
const rDis = Boolean(disabled || group?.state.isDisabled);
|
|
43
|
+
const shape = shapeP ?? tokens.defaults.shape;
|
|
44
|
+
const standKey = sv ?? 'standalone';
|
|
45
45
|
const inputRef = useRef(null);
|
|
46
|
-
const
|
|
46
|
+
const inputElRef = useRef(null);
|
|
47
47
|
const onChangeRef = useRef(onChange);
|
|
48
48
|
onChangeRef.current = onChange;
|
|
49
49
|
const onClickRef = useRef(onClick);
|
|
50
50
|
onClickRef.current = onClick;
|
|
51
|
-
const
|
|
51
|
+
const rAccLabel = accessibilityLabel ?? ariaLabel ?? (isText(children) ? String(children) : undefined) ?? sv ?? 'radio';
|
|
52
52
|
const {
|
|
53
|
-
isSelected:
|
|
54
|
-
setSelected:
|
|
53
|
+
isSelected: standSel,
|
|
54
|
+
setSelected: setStandSel
|
|
55
55
|
} = useToggleState({
|
|
56
56
|
isSelected: checked,
|
|
57
57
|
defaultSelected: defaultChecked,
|
|
58
58
|
onChange: next => onChange?.(next)
|
|
59
59
|
});
|
|
60
60
|
const pseudoState = {
|
|
61
|
-
selectedValue:
|
|
61
|
+
selectedValue: standSel ? standKey : null,
|
|
62
62
|
setSelectedValue: next => {
|
|
63
|
-
|
|
63
|
+
setStandSel(next === standKey);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
useEffect(() => {
|
|
67
|
-
if (isGroup && group &&
|
|
68
|
-
group.registerValue(
|
|
69
|
-
return () => group.unregisterValue(
|
|
67
|
+
if (isGroup && group && sv !== undefined) {
|
|
68
|
+
group.registerValue(sv, optVal ?? sv);
|
|
69
|
+
return () => group.unregisterValue(sv);
|
|
70
70
|
}
|
|
71
|
+
;
|
|
71
72
|
return undefined;
|
|
72
|
-
}, [group, isGroup,
|
|
73
|
+
}, [group, isGroup, optVal, sv]);
|
|
73
74
|
const state = isGroup && group ? group.state : pseudoState;
|
|
74
|
-
const
|
|
75
|
+
const radioVal = isGroup ? sv : standKey;
|
|
75
76
|
const {
|
|
76
77
|
onBlur,
|
|
77
78
|
onFocus,
|
|
78
|
-
...
|
|
79
|
+
...compRest
|
|
79
80
|
} = rest;
|
|
80
|
-
const ariaRef = Platform.OS === 'web' ?
|
|
81
|
+
const ariaRef = Platform.OS === 'web' ? inputElRef : inputRef;
|
|
81
82
|
const {
|
|
82
83
|
inputProps
|
|
83
84
|
} = useRadio({
|
|
84
|
-
value:
|
|
85
|
-
isDisabled:
|
|
86
|
-
'aria-label':
|
|
87
|
-
accessibilityLabel:
|
|
88
|
-
...
|
|
85
|
+
value: radioVal,
|
|
86
|
+
isDisabled: rDis,
|
|
87
|
+
'aria-label': rAccLabel,
|
|
88
|
+
accessibilityLabel: rAccLabel,
|
|
89
|
+
...compRest
|
|
89
90
|
}, state, ariaRef);
|
|
90
|
-
const isChecked = isGroup && group &&
|
|
91
|
+
const isChecked = isGroup && group && sv !== undefined ? group.state.selectedValue === sv : checked !== undefined ? checked : standSel;
|
|
91
92
|
const inputOnPress = inputProps?.onPress;
|
|
92
93
|
const handlePress = useCallback(e => {
|
|
93
94
|
onClickRef.current?.(e);
|
|
94
|
-
if (
|
|
95
|
-
if (isGroup && group &&
|
|
96
|
-
if (!isChecked) group.state.setSelectedValue(
|
|
95
|
+
if (rDis) return;
|
|
96
|
+
if (isGroup && group && sv !== undefined) {
|
|
97
|
+
if (!isChecked) group.state.setSelectedValue(sv);
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
100
|
+
;
|
|
99
101
|
if (checked !== undefined) {
|
|
100
102
|
onChangeRef.current?.(!checked);
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
105
|
+
;
|
|
103
106
|
if (onChangeRef.current) {
|
|
104
|
-
|
|
107
|
+
setStandSel(!standSel);
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
110
|
+
;
|
|
107
111
|
inputOnPress?.(e);
|
|
108
|
-
}, [checked, group, inputOnPress, isChecked, isGroup,
|
|
112
|
+
}, [checked, group, inputOnPress, isChecked, isGroup, rDis, sv, setStandSel, standSel]);
|
|
109
113
|
const mergedInputProps = inputProps ? {
|
|
110
114
|
...inputProps,
|
|
111
115
|
onPress: handlePress
|
|
112
116
|
} : {};
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const spacingStyle =
|
|
117
|
+
const borderClr = rDis ? tokens.colors.disabledBorder : isChecked ? rCheckedClr : tokens.colors.border;
|
|
118
|
+
const bgClr = rDis ? tokens.colors.disabledBackground : tokens.colors.background;
|
|
119
|
+
const spacingStyle = rLabelPos === 'left' ? {
|
|
116
120
|
marginRight: tokens.spacing.gap
|
|
117
121
|
} : {
|
|
118
122
|
marginLeft: tokens.spacing.gap
|
|
119
123
|
};
|
|
120
|
-
const
|
|
121
|
-
const
|
|
124
|
+
const labelClr = rDis ? tokens.colors.labelDisabled : tokens.colors.label;
|
|
125
|
+
const radius = shape === 'square' ? tokens.radii.square : tokens.radii.round;
|
|
122
126
|
const labelNode = useMemo(() => !isRenderable(children) ? null : /*#__PURE__*/React.createElement(View, {
|
|
123
127
|
style: [tokens.layout.labelWrapper, spacingStyle],
|
|
124
128
|
pointerEvents: "none",
|
|
125
129
|
accessible: false
|
|
126
130
|
}, renderTextOrNode(children, [tokens.layout.label, {
|
|
127
|
-
color:
|
|
131
|
+
color: labelClr,
|
|
128
132
|
fontSize: tokens.typography.fontSize,
|
|
129
133
|
lineHeight: tokens.typography.fontSize * tokens.typography.lineHeightMultiplier,
|
|
130
134
|
fontFamily: tokens.typography.fontFamily,
|
|
131
135
|
fontWeight: tokens.typography.fontWeight
|
|
132
|
-
}, labelStyle].filter(Boolean))), [children,
|
|
133
|
-
const interactive = !
|
|
136
|
+
}, labelStyle].filter(Boolean))), [children, labelClr, labelStyle, spacingStyle, tokens.layout.label, tokens.layout.labelWrapper, tokens.typography.fontFamily, tokens.typography.fontSize, tokens.typography.fontWeight, tokens.typography.lineHeightMultiplier]);
|
|
137
|
+
const interactive = !rDis && !rLabelDis;
|
|
134
138
|
const defaultIcon = useMemo(() => /*#__PURE__*/React.createElement(View, {
|
|
135
139
|
style: [tokens.layout.icon, {
|
|
136
|
-
width:
|
|
137
|
-
height:
|
|
138
|
-
borderRadius,
|
|
139
|
-
backgroundColor
|
|
140
|
+
width: rIconSz,
|
|
141
|
+
height: rIconSz,
|
|
142
|
+
borderRadius: radius,
|
|
143
|
+
backgroundColor: bgClr
|
|
140
144
|
}]
|
|
141
145
|
}, isChecked && /*#__PURE__*/React.createElement(View, {
|
|
142
146
|
style: {
|
|
143
|
-
width:
|
|
144
|
-
height:
|
|
145
|
-
borderRadius,
|
|
146
|
-
backgroundColor:
|
|
147
|
+
width: rIconSz * tokens.sizing.dotScale,
|
|
148
|
+
height: rIconSz * tokens.sizing.dotScale,
|
|
149
|
+
borderRadius: radius,
|
|
150
|
+
backgroundColor: rCheckedClr
|
|
147
151
|
}
|
|
148
152
|
}), /*#__PURE__*/React.createElement(View, {
|
|
149
153
|
style: createHairlineView({
|
|
150
154
|
position: 'all',
|
|
151
|
-
color:
|
|
152
|
-
borderRadius
|
|
155
|
+
color: borderClr,
|
|
156
|
+
borderRadius: radius
|
|
153
157
|
})
|
|
154
|
-
})), [
|
|
158
|
+
})), [bgClr, borderClr, radius, isChecked, rCheckedClr, rIconSz, tokens.layout.icon, tokens.sizing.dotScale]);
|
|
155
159
|
const iconVisual = iconRender ? iconRender({
|
|
156
160
|
checked: Boolean(isChecked),
|
|
157
|
-
disabled: Boolean(
|
|
161
|
+
disabled: Boolean(rDis)
|
|
158
162
|
}) ?? null : defaultIcon;
|
|
159
163
|
const webInputStyle = {
|
|
160
164
|
position: 'absolute',
|
|
@@ -173,7 +177,7 @@ export const Radio = /*#__PURE__*/React.memo(props => {
|
|
|
173
177
|
...webInputProps
|
|
174
178
|
} = inputProps ?? {};
|
|
175
179
|
const webInputNode = Platform.OS === 'web' ? /*#__PURE__*/React.createElement("input", _extends({
|
|
176
|
-
ref:
|
|
180
|
+
ref: inputElRef
|
|
177
181
|
}, webInputProps, {
|
|
178
182
|
style: webInputStyle
|
|
179
183
|
})) : null;
|
|
@@ -181,26 +185,26 @@ export const Radio = /*#__PURE__*/React.memo(props => {
|
|
|
181
185
|
style: tokens.layout.iconWrapper
|
|
182
186
|
}, iconVisual, webInputNode) : /*#__PURE__*/React.createElement(Pressable, _extends({}, mergedInputProps, {
|
|
183
187
|
ref: inputRef,
|
|
184
|
-
testID:
|
|
185
|
-
disabled:
|
|
188
|
+
testID: sv !== undefined ? `radio-icon-${sv}` : undefined,
|
|
189
|
+
disabled: rDis,
|
|
186
190
|
accessibilityRole: "radio",
|
|
187
191
|
accessibilityState: {
|
|
188
192
|
selected: isChecked,
|
|
189
|
-
disabled:
|
|
193
|
+
disabled: rDis
|
|
190
194
|
},
|
|
191
195
|
style: tokens.layout.iconWrapper
|
|
192
196
|
}), iconVisual, webInputNode);
|
|
193
|
-
const isLeft =
|
|
197
|
+
const isLeft = rLabelPos === 'left';
|
|
194
198
|
const first = isLeft ? labelNode : iconNode;
|
|
195
199
|
const second = isLeft ? iconNode : labelNode;
|
|
196
200
|
if (interactive) return /*#__PURE__*/React.createElement(Pressable, _extends({}, mergedInputProps, {
|
|
197
201
|
ref: inputRef,
|
|
198
|
-
testID:
|
|
199
|
-
disabled:
|
|
202
|
+
testID: sv !== undefined ? `radio-icon-${sv}` : undefined,
|
|
203
|
+
disabled: rDis,
|
|
200
204
|
accessibilityRole: "radio",
|
|
201
205
|
accessibilityState: {
|
|
202
206
|
selected: isChecked,
|
|
203
|
-
disabled:
|
|
207
|
+
disabled: rDis
|
|
204
208
|
},
|
|
205
209
|
style: [tokens.layout.container, style]
|
|
206
210
|
}), first, second);
|
|
@@ -51,14 +51,14 @@ const RadioGroupImpl = props => {
|
|
|
51
51
|
'aria-label': accessibilityLabel,
|
|
52
52
|
name
|
|
53
53
|
}, state);
|
|
54
|
-
const
|
|
54
|
+
const rProps = useMemo(() => ({
|
|
55
55
|
...(radioGroupProps ?? {}),
|
|
56
56
|
...(accessibilityHint && {
|
|
57
57
|
'aria-describedby': accessibilityHint
|
|
58
58
|
}),
|
|
59
59
|
'aria-disabled': disabled
|
|
60
60
|
}), [accessibilityHint, disabled, radioGroupProps]);
|
|
61
|
-
const
|
|
61
|
+
const ctxVal = useMemo(() => ({
|
|
62
62
|
state,
|
|
63
63
|
direction,
|
|
64
64
|
iconSize,
|
|
@@ -67,16 +67,16 @@ const RadioGroupImpl = props => {
|
|
|
67
67
|
registerValue,
|
|
68
68
|
unregisterValue
|
|
69
69
|
}), [checkedColor, direction, iconSize, labelDisabled, registerValue, state, unregisterValue]);
|
|
70
|
-
const
|
|
70
|
+
const ctrStyle = [direction === 'horizontal' ? tokens.layout.groupHorizontal : tokens.layout.groupVertical, {
|
|
71
71
|
columnGap: direction === 'horizontal' ? gap : undefined,
|
|
72
72
|
rowGap: gap
|
|
73
73
|
}, style];
|
|
74
74
|
return /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
75
|
-
value:
|
|
76
|
-
}, /*#__PURE__*/React.createElement(View, _extends({},
|
|
75
|
+
value: ctxVal
|
|
76
|
+
}, /*#__PURE__*/React.createElement(View, _extends({}, rProps, viewProps, {
|
|
77
77
|
accessibilityLabel: accessibilityLabel,
|
|
78
78
|
accessibilityHint: accessibilityHint,
|
|
79
|
-
style:
|
|
79
|
+
style: ctrStyle
|
|
80
80
|
}), children));
|
|
81
81
|
};
|
|
82
82
|
export const RadioGroup = /*#__PURE__*/React.memo(RadioGroupImpl);
|
|
@@ -8,11 +8,11 @@ const SafeAreaViewImpl = ({
|
|
|
8
8
|
onLayout,
|
|
9
9
|
pointerEvents
|
|
10
10
|
}) => {
|
|
11
|
-
const
|
|
11
|
+
const pad = useSafeAreaPadding({});
|
|
12
12
|
if (edge === 'top') return /*#__PURE__*/React.createElement(View, {
|
|
13
13
|
style: [{
|
|
14
14
|
width: '100%',
|
|
15
|
-
minHeight:
|
|
15
|
+
minHeight: pad.paddingTop
|
|
16
16
|
}, style],
|
|
17
17
|
onLayout: onLayout,
|
|
18
18
|
pointerEvents: pointerEvents ?? 'none'
|
|
@@ -20,17 +20,17 @@ const SafeAreaViewImpl = ({
|
|
|
20
20
|
if (edge === 'bottom') return /*#__PURE__*/React.createElement(View, {
|
|
21
21
|
style: [{
|
|
22
22
|
width: '100%',
|
|
23
|
-
minHeight:
|
|
23
|
+
minHeight: pad.paddingBottom
|
|
24
24
|
}, style],
|
|
25
25
|
pointerEvents: pointerEvents ?? 'none'
|
|
26
26
|
});
|
|
27
27
|
return /*#__PURE__*/React.createElement(View, {
|
|
28
28
|
style: [{
|
|
29
29
|
width: '100%',
|
|
30
|
-
paddingTop:
|
|
31
|
-
paddingBottom:
|
|
32
|
-
paddingLeft:
|
|
33
|
-
paddingRight:
|
|
30
|
+
paddingTop: pad.paddingTop,
|
|
31
|
+
paddingBottom: pad.paddingBottom,
|
|
32
|
+
paddingLeft: pad.paddingLeft,
|
|
33
|
+
paddingRight: pad.paddingRight
|
|
34
34
|
}, style],
|
|
35
35
|
onLayout: onLayout,
|
|
36
36
|
pointerEvents: pointerEvents
|