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
|
@@ -34,13 +34,13 @@ export const Space = /*#__PURE__*/React.memo(props => {
|
|
|
34
34
|
const {
|
|
35
35
|
children,
|
|
36
36
|
gap,
|
|
37
|
-
size:
|
|
38
|
-
direction:
|
|
39
|
-
align:
|
|
40
|
-
justify:
|
|
41
|
-
wrap:
|
|
42
|
-
block:
|
|
43
|
-
fill:
|
|
37
|
+
size: sizeP,
|
|
38
|
+
direction: dirP,
|
|
39
|
+
align: alignP,
|
|
40
|
+
justify: justP = 'start',
|
|
41
|
+
wrap: wrapP,
|
|
42
|
+
block: blockP,
|
|
43
|
+
fill: fillP,
|
|
44
44
|
divider,
|
|
45
45
|
tokensOverride,
|
|
46
46
|
style,
|
|
@@ -48,64 +48,68 @@ export const Space = /*#__PURE__*/React.memo(props => {
|
|
|
48
48
|
...rest
|
|
49
49
|
} = props;
|
|
50
50
|
const tokens = useSpaceTokens(tokensOverride);
|
|
51
|
-
const
|
|
52
|
-
const wrap =
|
|
53
|
-
const
|
|
54
|
-
const [
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
flexDirection:
|
|
64
|
-
flexWrap:
|
|
65
|
-
alignItems: alignMap[
|
|
66
|
-
justifyContent: justifyMap[
|
|
67
|
-
width:
|
|
68
|
-
columnGap:
|
|
69
|
-
rowGap:
|
|
51
|
+
const hor = (dirP ?? tokens.defaults.direction) === 'horizontal';
|
|
52
|
+
const wrap = wrapP ?? tokens.defaults.wrap;
|
|
53
|
+
const gapIn = resolveGapInput(gap, sizeP, tokens.defaults.gapPreset);
|
|
54
|
+
const [hG, vG] = parseGap(gapIn, tokens.sizing.presets);
|
|
55
|
+
const hGap = Math.max(0, hG);
|
|
56
|
+
const vGap = Math.max(0, vG);
|
|
57
|
+
const justStretch = justP === 'stretch';
|
|
58
|
+
const justStyle = justStretch ? 'start' : justP;
|
|
59
|
+
const block = blockP ?? !hor;
|
|
60
|
+
const align = alignP ?? (hor ? 'center' : 'stretch');
|
|
61
|
+
const fillOrJust = hor && ((fillP ?? false) || justStretch);
|
|
62
|
+
const boxStyle = {
|
|
63
|
+
flexDirection: hor ? 'row' : 'column',
|
|
64
|
+
flexWrap: hor && wrap ? 'wrap' : 'nowrap',
|
|
65
|
+
alignItems: alignMap[align],
|
|
66
|
+
justifyContent: justifyMap[justStyle],
|
|
67
|
+
width: block ? '100%' : undefined,
|
|
68
|
+
columnGap: hor ? hGap : undefined,
|
|
69
|
+
rowGap: vGap
|
|
70
70
|
};
|
|
71
|
-
const
|
|
71
|
+
const txtStyle = {
|
|
72
|
+
fontFamily: tokens.typography.fontFamily,
|
|
73
|
+
fontSize: tokens.typography.fontSize
|
|
74
|
+
};
|
|
75
|
+
const arr = React.Children.toArray(children).filter(isRenderable);
|
|
72
76
|
const content = [];
|
|
73
|
-
for (let i = 0; i <
|
|
74
|
-
const child =
|
|
77
|
+
for (let i = 0; i < arr.length; i++) {
|
|
78
|
+
const child = arr[i];
|
|
75
79
|
const key = /*#__PURE__*/React.isValidElement(child) && child.key != null ? child.key : i;
|
|
76
|
-
const
|
|
80
|
+
const flexS = fillOrJust ? {
|
|
77
81
|
flexGrow: 1,
|
|
78
82
|
flexBasis: 0,
|
|
79
83
|
minWidth: 0
|
|
80
|
-
} : !
|
|
84
|
+
} : !hor && (fillP || block) ? {
|
|
81
85
|
width: '100%'
|
|
82
86
|
} : undefined;
|
|
83
87
|
content.push(/*#__PURE__*/React.createElement(View, {
|
|
84
88
|
key: key,
|
|
85
|
-
style:
|
|
86
|
-
}, renderTextOrNode(child)));
|
|
87
|
-
if (divider && i <
|
|
89
|
+
style: flexS
|
|
90
|
+
}, renderTextOrNode(child, txtStyle)));
|
|
91
|
+
if (divider && i < arr.length - 1) content.push(/*#__PURE__*/React.createElement(View, {
|
|
88
92
|
key: `divider-${String(key)}`
|
|
89
|
-
}, renderTextOrNode(divider)));
|
|
93
|
+
}, renderTextOrNode(divider, txtStyle)));
|
|
90
94
|
}
|
|
91
|
-
const
|
|
95
|
+
const inter = isFunction(onClick);
|
|
92
96
|
const {
|
|
93
97
|
interactionProps,
|
|
94
98
|
states
|
|
95
99
|
} = useAriaPress({
|
|
96
|
-
disabled: !
|
|
100
|
+
disabled: !inter,
|
|
97
101
|
onPress: onClick,
|
|
98
|
-
extraProps:
|
|
102
|
+
extraProps: inter ? {
|
|
99
103
|
accessibilityRole: 'button'
|
|
100
104
|
} : undefined
|
|
101
105
|
});
|
|
102
|
-
if (
|
|
103
|
-
style: [tokens.layout.container,
|
|
106
|
+
if (inter) return /*#__PURE__*/React.createElement(Pressable, _extends({
|
|
107
|
+
style: [tokens.layout.container, boxStyle, style, states.pressed && {
|
|
104
108
|
opacity: 0.85
|
|
105
109
|
}]
|
|
106
110
|
}, interactionProps, rest), content);
|
|
107
111
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
108
|
-
style: [tokens.layout.container,
|
|
112
|
+
style: [tokens.layout.container, boxStyle, style]
|
|
109
113
|
}, rest), content);
|
|
110
114
|
});
|
|
111
115
|
Space.displayName = 'Space';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createComponentTokensHook } from '../../design-system';
|
|
2
2
|
const createSpaceTokens = foundations => {
|
|
3
3
|
const {
|
|
4
|
-
spacing
|
|
4
|
+
spacing,
|
|
5
|
+
fontSize,
|
|
6
|
+
typography
|
|
5
7
|
} = foundations;
|
|
6
8
|
return {
|
|
7
9
|
defaults: {
|
|
@@ -12,6 +14,10 @@ const createSpaceTokens = foundations => {
|
|
|
12
14
|
layout: {
|
|
13
15
|
container: {}
|
|
14
16
|
},
|
|
17
|
+
typography: {
|
|
18
|
+
fontFamily: typography.fontFamily,
|
|
19
|
+
fontSize: fontSize.sm
|
|
20
|
+
},
|
|
15
21
|
sizing: {
|
|
16
22
|
presets: {
|
|
17
23
|
mini: spacing.xxs ?? spacing.xs ?? 4,
|
|
@@ -70,14 +70,14 @@ const StepperImpl = (props, ref) => {
|
|
|
70
70
|
const decimalLen = parseDecimalLength(decimalLengthProp);
|
|
71
71
|
const stepRaw = Number(step ?? 1);
|
|
72
72
|
const stepSize = isFiniteNumber(stepRaw) && stepRaw > 0 ? stepRaw : 1;
|
|
73
|
-
const
|
|
74
|
-
const
|
|
73
|
+
const rBtnSize = Math.max(0, parseNumber(buttonSize, tokens.defaults.buttonSize));
|
|
74
|
+
const rInputW = Math.max(0, parseNumber(inputWidth, tokens.defaults.inputWidth));
|
|
75
75
|
const defaultVal = useMemo(() => {
|
|
76
76
|
const raw = props.defaultValue;
|
|
77
77
|
if (raw === null) return null;
|
|
78
78
|
const base = isFiniteNumber(raw) ? raw : 0;
|
|
79
|
-
const
|
|
80
|
-
return autoFixed ? clampValue(
|
|
79
|
+
const fmt = formatNumber(base, integer, decimalLen);
|
|
80
|
+
return autoFixed ? clampValue(fmt, min, max) : fmt;
|
|
81
81
|
}, [autoFixed, decimalLen, integer, max, min, props.defaultValue]);
|
|
82
82
|
const [value, triggerChange] = useControllableValue({
|
|
83
83
|
...props,
|
|
@@ -256,20 +256,20 @@ const StepperImpl = (props, ref) => {
|
|
|
256
256
|
const isPlusDisabled = isDisabledAll || disablePlus || maxNumber != null && currentForCompare >= maxNumber;
|
|
257
257
|
const radius = tokens.radii.default;
|
|
258
258
|
const btnSizeStyle = useMemo(() => ({
|
|
259
|
-
width:
|
|
260
|
-
height:
|
|
261
|
-
}), [
|
|
259
|
+
width: rBtnSize,
|
|
260
|
+
height: rBtnSize
|
|
261
|
+
}), [rBtnSize]);
|
|
262
262
|
const inputSizeStyle = useMemo(() => ({
|
|
263
|
-
width:
|
|
264
|
-
height:
|
|
263
|
+
width: rInputW,
|
|
264
|
+
height: rBtnSize,
|
|
265
265
|
marginHorizontal: tokens.spacing.gap
|
|
266
|
-
}), [
|
|
266
|
+
}), [rBtnSize, rInputW, tokens.spacing.gap]);
|
|
267
267
|
const getButtonStyle = useCallback((type, state) => {
|
|
268
268
|
const isPlus = type === 'plus';
|
|
269
269
|
const isDisabled = isPlus ? isPlusDisabled : isMinusDisabled;
|
|
270
270
|
if (theme === 'round') {
|
|
271
271
|
const base = [S.btn, btnSizeStyle, {
|
|
272
|
-
borderRadius:
|
|
272
|
+
borderRadius: rBtnSize / 2,
|
|
273
273
|
opacity: isDisabled ? tokens.opacity.roundDisabled : 1
|
|
274
274
|
}];
|
|
275
275
|
if (isPlus) {
|
|
@@ -301,7 +301,7 @@ const StepperImpl = (props, ref) => {
|
|
|
301
301
|
return [S.btn, btnSizeStyle, cornerStyle, {
|
|
302
302
|
backgroundColor: bgColor
|
|
303
303
|
}, buttonStyle];
|
|
304
|
-
}, [btnSizeStyle, buttonStyle, isMinusDisabled, isPlusDisabled, radius,
|
|
304
|
+
}, [btnSizeStyle, buttonStyle, isMinusDisabled, isPlusDisabled, radius, rBtnSize, theme, layoutDir, tokens.colors.active, tokens.colors.background, tokens.colors.buttonDisabledBackground, tokens.colors.roundTheme, tokens.colors.roundThemeBackground, tokens.opacity.pressed, tokens.opacity.roundDisabled]);
|
|
305
305
|
const getButtonTextStyle = useCallback(type => {
|
|
306
306
|
const isPlus = type === 'plus';
|
|
307
307
|
const isDisabled = isPlus ? isPlusDisabled : isMinusDisabled;
|
|
@@ -309,6 +309,7 @@ const StepperImpl = (props, ref) => {
|
|
|
309
309
|
const color = isPlus ? tokens.colors.roundThemeText : tokens.colors.roundTheme;
|
|
310
310
|
return [S.btnTxt, {
|
|
311
311
|
color,
|
|
312
|
+
fontFamily: tokens.typography.fontFamily,
|
|
312
313
|
fontSize: tokens.typography.fontSize,
|
|
313
314
|
fontWeight: tokens.typography.fontWeight
|
|
314
315
|
}];
|
|
@@ -316,10 +317,11 @@ const StepperImpl = (props, ref) => {
|
|
|
316
317
|
;
|
|
317
318
|
return [S.btnTxt, {
|
|
318
319
|
color: isDisabled ? tokens.colors.buttonDisabledIcon : tokens.colors.buttonIcon,
|
|
320
|
+
fontFamily: tokens.typography.fontFamily,
|
|
319
321
|
fontSize: tokens.typography.fontSize,
|
|
320
322
|
fontWeight: tokens.typography.fontWeight
|
|
321
323
|
}];
|
|
322
|
-
}, [isMinusDisabled, isPlusDisabled, theme, tokens.colors.buttonDisabledIcon, tokens.colors.buttonIcon, tokens.colors.roundTheme, tokens.colors.roundThemeText, tokens.typography.fontSize, tokens.typography.fontWeight]);
|
|
324
|
+
}, [isMinusDisabled, isPlusDisabled, theme, tokens.colors.buttonDisabledIcon, tokens.colors.buttonIcon, tokens.colors.roundTheme, tokens.colors.roundThemeText, tokens.typography.fontFamily, tokens.typography.fontSize, tokens.typography.fontWeight]);
|
|
323
325
|
const handleChangeText = useCallback(text => {
|
|
324
326
|
if (disableInput || disabled || changingRef.current) return;
|
|
325
327
|
updateInputText(text);
|
|
@@ -391,10 +393,10 @@ const StepperImpl = (props, ref) => {
|
|
|
391
393
|
style: createHairlineView({
|
|
392
394
|
position: 'all',
|
|
393
395
|
color: tokens.colors.roundTheme,
|
|
394
|
-
borderRadius:
|
|
396
|
+
borderRadius: rBtnSize / 2
|
|
395
397
|
})
|
|
396
398
|
}));
|
|
397
|
-
}, [getButtonTextStyle, getMinusBtnStyle, handleMinusPress, handleMinusPressIn, handlePressOut, isMinusDisabled, showMinus, theme, tokens.colors.roundTheme,
|
|
399
|
+
}, [getButtonTextStyle, getMinusBtnStyle, handleMinusPress, handleMinusPressIn, handlePressOut, isMinusDisabled, showMinus, theme, tokens.colors.roundTheme, rBtnSize]);
|
|
398
400
|
const renderPlusBtn = useCallback(() => {
|
|
399
401
|
if (!showPlus) return null;
|
|
400
402
|
return /*#__PURE__*/React.createElement(Pressable, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useRef, useState, useCallback, useEffect, useImperativeHandle, forwardRef, memo, useMemo, Children, isValidElement } from 'react';
|
|
3
|
-
import { FlatList, View, StyleSheet,
|
|
3
|
+
import { FlatList, View, StyleSheet, Platform } from 'react-native';
|
|
4
4
|
import { clamp } from '../../utils/number';
|
|
5
5
|
import SwiperPagIndicator from './SwiperPagIndicator';
|
|
6
6
|
import { useSwiperTokens } from './tokens';
|
|
@@ -38,10 +38,6 @@ const SwiperImpl = (props, ref) => {
|
|
|
38
38
|
const momRef = useRef(false);
|
|
39
39
|
const dragRef = useRef(null);
|
|
40
40
|
const isWeb = Platform.OS === 'web';
|
|
41
|
-
const {
|
|
42
|
-
width: wW,
|
|
43
|
-
height: wH
|
|
44
|
-
} = useWindowDimensions();
|
|
45
41
|
const [layout, setLayout] = useState({
|
|
46
42
|
width: 0,
|
|
47
43
|
height: 0
|
|
@@ -71,8 +67,8 @@ const SwiperImpl = (props, ref) => {
|
|
|
71
67
|
const curRef = useRef(initReal);
|
|
72
68
|
const [curIdx, setCurIdx] = useState(initReal);
|
|
73
69
|
const ready = layout.width > 0 && layout.height > 0;
|
|
74
|
-
const mainSz = vertical ? layout.height
|
|
75
|
-
const crossSz = vertical ? layout.width
|
|
70
|
+
const mainSz = vertical ? layout.height : layout.width;
|
|
71
|
+
const crossSz = vertical ? layout.width : layout.height;
|
|
76
72
|
const itemSz = useMemo(() => ({
|
|
77
73
|
width: vertical ? crossSz : mainSz,
|
|
78
74
|
height: vertical ? mainSz : crossSz
|
|
@@ -268,6 +264,13 @@ const SwiperImpl = (props, ref) => {
|
|
|
268
264
|
}
|
|
269
265
|
}
|
|
270
266
|
} : undefined;
|
|
267
|
+
if (!ready) {
|
|
268
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
269
|
+
style: [S.ctr, style],
|
|
270
|
+
onLayout: onLayout,
|
|
271
|
+
testID: testID
|
|
272
|
+
});
|
|
273
|
+
}
|
|
271
274
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
272
275
|
accessibilityRole: "adjustable",
|
|
273
276
|
accessibilityLabel: `swiper, ${curIdx + 1} of ${count}`,
|
|
@@ -286,7 +289,7 @@ const SwiperImpl = (props, ref) => {
|
|
|
286
289
|
keyExtractor: keyEx,
|
|
287
290
|
horizontal: !vertical,
|
|
288
291
|
getItemLayout: getLayout,
|
|
289
|
-
initialScrollIndex:
|
|
292
|
+
initialScrollIndex: initDisp,
|
|
290
293
|
scrollEnabled: touchable && count > 1,
|
|
291
294
|
removeClippedSubviews: !shouldLoop || !loopAll,
|
|
292
295
|
disableVirtualization: shouldLoop && loopAll,
|
|
@@ -36,8 +36,8 @@ const SwiperPagIndicator = /*#__PURE__*/memo(({
|
|
|
36
36
|
}) => {
|
|
37
37
|
const tokens = useSwiperPagIndicatorTokens(tokensOverride);
|
|
38
38
|
const dots = [];
|
|
39
|
-
const ac = activeColor || tokens.colors.active
|
|
40
|
-
|
|
39
|
+
const ac = activeColor || tokens.colors.active;
|
|
40
|
+
const ic = inactiveColor || tokens.colors.inactive;
|
|
41
41
|
const posStyle = vertical ? [S.cv, {
|
|
42
42
|
right: tokens.offset.verticalRight
|
|
43
43
|
}] : [S.ch, {
|
|
@@ -58,6 +58,7 @@ const SwiperPagIndicator = /*#__PURE__*/memo(({
|
|
|
58
58
|
}
|
|
59
59
|
}));
|
|
60
60
|
}
|
|
61
|
+
;
|
|
61
62
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
62
63
|
style: [S.c, {
|
|
63
64
|
zIndex: tokens.layer.zIndex,
|
|
@@ -5,33 +5,33 @@ import { parseNumber } from '../../utils';
|
|
|
5
5
|
import { useSwitchTokens } from './tokens';
|
|
6
6
|
const SwitchImpl = props => {
|
|
7
7
|
const {
|
|
8
|
-
disabled:
|
|
9
|
-
size:
|
|
10
|
-
activeColor:
|
|
11
|
-
inactiveColor:
|
|
12
|
-
activeValue:
|
|
13
|
-
inactiveValue:
|
|
8
|
+
disabled: disP,
|
|
9
|
+
size: szP,
|
|
10
|
+
activeColor: actClrP,
|
|
11
|
+
inactiveColor: inactClrP,
|
|
12
|
+
activeValue: actValP,
|
|
13
|
+
inactiveValue: inactValP,
|
|
14
14
|
tokensOverride,
|
|
15
15
|
onClick,
|
|
16
16
|
style
|
|
17
17
|
} = props;
|
|
18
18
|
const tokens = useSwitchTokens(tokensOverride);
|
|
19
|
-
const disabled =
|
|
20
|
-
const activeValue =
|
|
21
|
-
const inactiveValue =
|
|
19
|
+
const disabled = disP ?? tokens.defaults.disabled;
|
|
20
|
+
const activeValue = actValP ?? tokens.defaults.activeValue;
|
|
21
|
+
const inactiveValue = inactValP ?? tokens.defaults.inactiveValue;
|
|
22
22
|
const scale = useMemo(() => {
|
|
23
23
|
if (!tokens.defaults.size) return 1;
|
|
24
|
-
if (typeof
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
return Math.max(0, num / tokens.defaults.size);
|
|
24
|
+
if (typeof szP === 'string') {
|
|
25
|
+
const v = szP.toLowerCase();
|
|
26
|
+
if (v === 'sm') return 0.75;
|
|
27
|
+
if (v === 'md') return 1;
|
|
28
|
+
if (v === 'lg') return 1.25;
|
|
29
|
+
return Math.max(0, parseNumber(szP, tokens.defaults.size) / tokens.defaults.size);
|
|
31
30
|
}
|
|
32
|
-
|
|
31
|
+
;
|
|
32
|
+
if (typeof szP === 'number') return Math.max(0, szP / tokens.defaults.size);
|
|
33
33
|
return 1;
|
|
34
|
-
}, [
|
|
34
|
+
}, [szP, tokens.defaults.size]);
|
|
35
35
|
const [value, triggerChange] = useControllableValue(props, {
|
|
36
36
|
valuePropName: 'checked',
|
|
37
37
|
defaultValuePropName: 'defaultChecked',
|
|
@@ -39,8 +39,8 @@ const SwitchImpl = props => {
|
|
|
39
39
|
trigger: 'onChange'
|
|
40
40
|
});
|
|
41
41
|
const isChecked = Object.is(value, activeValue);
|
|
42
|
-
const
|
|
43
|
-
const
|
|
42
|
+
const actClr = actClrP ?? tokens.colors.activeTrack;
|
|
43
|
+
const inactClr = inactClrP ?? tokens.colors.inactiveTrack;
|
|
44
44
|
const handleTouchEnd = useCallback(event => {
|
|
45
45
|
if (disabled) return;
|
|
46
46
|
onClick?.(event);
|
|
@@ -55,11 +55,11 @@ const SwitchImpl = props => {
|
|
|
55
55
|
value: isChecked,
|
|
56
56
|
disabled: disabled,
|
|
57
57
|
trackColor: {
|
|
58
|
-
false:
|
|
59
|
-
true:
|
|
58
|
+
false: inactClr,
|
|
59
|
+
true: actClr
|
|
60
60
|
},
|
|
61
61
|
thumbColor: tokens.colors.handle,
|
|
62
|
-
ios_backgroundColor:
|
|
62
|
+
ios_backgroundColor: inactClr,
|
|
63
63
|
style: [{
|
|
64
64
|
transform: [{
|
|
65
65
|
scaleX: scale
|
|
@@ -12,15 +12,15 @@ const TabbarBaseImpl = props => {
|
|
|
12
12
|
children,
|
|
13
13
|
value,
|
|
14
14
|
defaultValue,
|
|
15
|
-
fixed:
|
|
16
|
-
border:
|
|
15
|
+
fixed: fixedP,
|
|
16
|
+
border: borderP,
|
|
17
17
|
zIndex = 1,
|
|
18
18
|
activeColor,
|
|
19
19
|
inactiveColor,
|
|
20
|
-
background:
|
|
21
|
-
placeholder:
|
|
20
|
+
background: bgP,
|
|
21
|
+
placeholder: placeP,
|
|
22
22
|
safeAreaInsetBottom,
|
|
23
|
-
iconSize:
|
|
23
|
+
iconSize: iconSzP,
|
|
24
24
|
tokensOverride,
|
|
25
25
|
style,
|
|
26
26
|
contentStyle,
|
|
@@ -28,31 +28,31 @@ const TabbarBaseImpl = props => {
|
|
|
28
28
|
...rest
|
|
29
29
|
} = props;
|
|
30
30
|
const tokens = useTabbarTokens(tokensOverride);
|
|
31
|
-
const fixed =
|
|
32
|
-
const border =
|
|
33
|
-
const background =
|
|
34
|
-
const placeholder =
|
|
35
|
-
const iconSize =
|
|
36
|
-
const
|
|
31
|
+
const fixed = fixedP ?? tokens.defaults.fixed;
|
|
32
|
+
const border = borderP ?? tokens.defaults.border;
|
|
33
|
+
const background = bgP ?? tokens.colors.background;
|
|
34
|
+
const placeholder = placeP ?? tokens.defaults.placeholder;
|
|
35
|
+
const iconSize = iconSzP ?? tokens.icon.size;
|
|
36
|
+
const enableSafeBottom = safeAreaInsetBottom ?? fixed;
|
|
37
37
|
const items = useMemo(() => React.Children.toArray(children).filter(React.isValidElement), [children]);
|
|
38
|
-
const
|
|
38
|
+
const firstName = items.length ? items[0].props.name ?? 0 : undefined;
|
|
39
39
|
const [activeValue, setActiveValue] = useControllableValue(props, {
|
|
40
|
-
defaultValue:
|
|
40
|
+
defaultValue: firstName,
|
|
41
41
|
valuePropName: 'value',
|
|
42
42
|
defaultValuePropName: 'defaultValue',
|
|
43
43
|
trigger: 'onChange'
|
|
44
44
|
});
|
|
45
45
|
const itemNames = items.map((item, i) => item.props.name ?? i);
|
|
46
|
-
const currentName = activeValue === undefined || activeValue === null ?
|
|
46
|
+
const currentName = activeValue === undefined || activeValue === null ? firstName : itemNames.some(n => n === activeValue) ? activeValue : firstName;
|
|
47
47
|
const [barHeight, setBarHeight] = useState(tokens.layout.height);
|
|
48
48
|
const enablePlaceholder = fixed && placeholder;
|
|
49
49
|
const handleLayout = useCallback(event => {
|
|
50
50
|
if (!enablePlaceholder) return;
|
|
51
|
-
const
|
|
52
|
-
setBarHeight(prev => Math.abs(prev -
|
|
51
|
+
const h = event.nativeEvent.layout.height;
|
|
52
|
+
setBarHeight(prev => Math.abs(prev - h) < 0.5 ? prev : h);
|
|
53
53
|
}, [enablePlaceholder]);
|
|
54
54
|
const onSelect = useCallback((name, index) => setActiveValue(name, index), [setActiveValue]);
|
|
55
|
-
const
|
|
55
|
+
const ctxVal = useMemo(() => ({
|
|
56
56
|
activeValue: currentName,
|
|
57
57
|
activeColor: activeColor ?? tokens.colors.active,
|
|
58
58
|
inactiveColor: inactiveColor ?? tokens.colors.inactive,
|
|
@@ -60,7 +60,7 @@ const TabbarBaseImpl = props => {
|
|
|
60
60
|
fontWeight: tokens.typography.fontWeight,
|
|
61
61
|
onSelect
|
|
62
62
|
}), [activeColor, currentName, inactiveColor, onSelect, tokens.colors.active, tokens.colors.inactive, tokens.typography.fontSize, tokens.typography.fontWeight]);
|
|
63
|
-
const
|
|
63
|
+
const cloned = useMemo(() => items.map((item, i) => {
|
|
64
64
|
const name = item.props.name ?? i;
|
|
65
65
|
return /*#__PURE__*/React.cloneElement(item, {
|
|
66
66
|
key: item.key ?? name,
|
|
@@ -71,11 +71,11 @@ const TabbarBaseImpl = props => {
|
|
|
71
71
|
});
|
|
72
72
|
}), [iconSize, items, tokensOverride]);
|
|
73
73
|
if (items.length === 0) return null;
|
|
74
|
-
const
|
|
75
|
-
const
|
|
74
|
+
const ContainerWrap = enableSafeBottom ? SafeAreaView : View;
|
|
75
|
+
const placeStyle = {
|
|
76
76
|
height: barHeight
|
|
77
77
|
};
|
|
78
|
-
const
|
|
78
|
+
const ctrStyle = [S.c, fixed && [S.f, {
|
|
79
79
|
zIndex
|
|
80
80
|
}], style];
|
|
81
81
|
const barStyle = [S.b, {
|
|
@@ -88,18 +88,18 @@ const TabbarBaseImpl = props => {
|
|
|
88
88
|
}];
|
|
89
89
|
return /*#__PURE__*/React.createElement(React.Fragment, null, enablePlaceholder && /*#__PURE__*/React.createElement(View, {
|
|
90
90
|
testID: "rv-tabbar-placeholder",
|
|
91
|
-
style:
|
|
91
|
+
style: placeStyle
|
|
92
92
|
}), /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
93
|
-
style:
|
|
93
|
+
style: ctrStyle,
|
|
94
94
|
onLayout: handleLayout
|
|
95
|
-
}), /*#__PURE__*/React.createElement(
|
|
95
|
+
}), /*#__PURE__*/React.createElement(ContainerWrap, {
|
|
96
96
|
style: barStyle
|
|
97
97
|
}, /*#__PURE__*/React.createElement(TabbarContext.Provider, {
|
|
98
|
-
value:
|
|
98
|
+
value: ctxVal
|
|
99
99
|
}, /*#__PURE__*/React.createElement(View, {
|
|
100
100
|
style: rowStyle,
|
|
101
101
|
accessibilityRole: "tablist"
|
|
102
|
-
},
|
|
102
|
+
}, cloned)), border && /*#__PURE__*/React.createElement(View, {
|
|
103
103
|
style: createHairlineView({
|
|
104
104
|
position: 'top',
|
|
105
105
|
color: tokens.colors.border,
|