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
|
@@ -15,7 +15,7 @@ const SearchComponent = (props, ref) => {
|
|
|
15
15
|
action,
|
|
16
16
|
actionText,
|
|
17
17
|
showAction = false,
|
|
18
|
-
shape:
|
|
18
|
+
shape: shapeP,
|
|
19
19
|
background,
|
|
20
20
|
style: containerStyle,
|
|
21
21
|
fieldStyle,
|
|
@@ -36,12 +36,12 @@ const SearchComponent = (props, ref) => {
|
|
|
36
36
|
...restFieldProps
|
|
37
37
|
} = props;
|
|
38
38
|
const tokens = useSearchTokens(tokensOverride);
|
|
39
|
-
const shape =
|
|
39
|
+
const shape = shapeP ?? tokens.defaults.shape;
|
|
40
40
|
const [value, triggerChange] = useControllableValue(props, {
|
|
41
41
|
defaultValue: ''
|
|
42
42
|
});
|
|
43
43
|
const inputValue = value ?? '';
|
|
44
|
-
const
|
|
44
|
+
const rInputAlign = align ?? inputAlign;
|
|
45
45
|
const onChangeTextRef = useRef(onChangeText),
|
|
46
46
|
onCancelRef = useRef(onCancel),
|
|
47
47
|
onSearchRef = useRef(onSearch),
|
|
@@ -64,17 +64,17 @@ const SearchComponent = (props, ref) => {
|
|
|
64
64
|
onSearchRef.current?.(inputValueRef.current);
|
|
65
65
|
onSubmitEditingRef.current?.(event);
|
|
66
66
|
}, []);
|
|
67
|
-
const
|
|
68
|
-
const
|
|
67
|
+
const rBg = background ?? tokens.colors.background;
|
|
68
|
+
const rLeftIcon = leftIcon ?? /*#__PURE__*/React.createElement(SearchIcon, {
|
|
69
69
|
size: tokens.icon.size,
|
|
70
70
|
fill: tokens.colors.icon,
|
|
71
71
|
color: tokens.colors.icon
|
|
72
72
|
});
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
73
|
+
const rClearTrigger = clearTrigger ?? tokens.defaults.clearTrigger;
|
|
74
|
+
const rReturnKey = returnKeyType ?? 'search';
|
|
75
|
+
const showAct = !!action || showAction;
|
|
76
|
+
const customActTxt = /*#__PURE__*/React.isValidElement(actionText);
|
|
77
|
+
const renderCancelAct = showAct && !action && !customActTxt;
|
|
78
78
|
const radius = shape === 'round' ? tokens.radius.round : tokens.radius.square;
|
|
79
79
|
const inputRef = useRef(null);
|
|
80
80
|
useImperativeHandle(ref, () => ({
|
|
@@ -82,26 +82,26 @@ const SearchComponent = (props, ref) => {
|
|
|
82
82
|
blur: () => inputRef.current?.blur(),
|
|
83
83
|
clear: () => handleChange('')
|
|
84
84
|
}), [handleChange]);
|
|
85
|
-
const
|
|
86
|
-
disabled: !
|
|
85
|
+
const cancelActPress = useAriaPress({
|
|
86
|
+
disabled: !renderCancelAct,
|
|
87
87
|
onPress: handleCancel,
|
|
88
88
|
extraProps: {
|
|
89
89
|
accessibilityRole: 'button',
|
|
90
90
|
testID: 'rnsu-search-action'
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
const
|
|
93
|
+
const ctrStyles = [S.ctr, {
|
|
94
94
|
paddingHorizontal: tokens.spacing.paddingHorizontal,
|
|
95
95
|
paddingVertical: tokens.spacing.paddingVertical,
|
|
96
|
-
backgroundColor:
|
|
96
|
+
backgroundColor: rBg
|
|
97
97
|
}, containerStyle];
|
|
98
|
-
const
|
|
98
|
+
const cntStyles = [S.cnt, {
|
|
99
99
|
borderRadius: radius,
|
|
100
100
|
paddingHorizontal: tokens.spacing.contentPaddingHorizontal,
|
|
101
101
|
paddingVertical: tokens.spacing.contentPaddingVertical,
|
|
102
102
|
backgroundColor: tokens.colors.contentBackground
|
|
103
103
|
}];
|
|
104
|
-
const
|
|
104
|
+
const labelEl = !label ? null : isText(label) ? /*#__PURE__*/React.createElement(Text, {
|
|
105
105
|
style: {
|
|
106
106
|
marginRight: tokens.spacing.labelGap,
|
|
107
107
|
color: tokens.colors.label,
|
|
@@ -113,20 +113,20 @@ const SearchComponent = (props, ref) => {
|
|
|
113
113
|
marginRight: tokens.spacing.labelGap
|
|
114
114
|
}
|
|
115
115
|
}, label);
|
|
116
|
-
const
|
|
116
|
+
const actEl = action ? /*#__PURE__*/React.createElement(View, {
|
|
117
117
|
style: [S.act, {
|
|
118
118
|
marginLeft: tokens.spacing.actionGap
|
|
119
119
|
}]
|
|
120
|
-
}, action) : !
|
|
120
|
+
}, action) : !showAct ? null : customActTxt ? /*#__PURE__*/React.createElement(View, {
|
|
121
121
|
style: [S.act, {
|
|
122
122
|
marginLeft: tokens.spacing.actionGap
|
|
123
123
|
}]
|
|
124
124
|
}, actionText) : /*#__PURE__*/React.createElement(Pressable, _extends({
|
|
125
125
|
style: [S.act, {
|
|
126
126
|
marginLeft: tokens.spacing.actionGap,
|
|
127
|
-
opacity:
|
|
127
|
+
opacity: cancelActPress.states.pressed ? tokens.opacity.actionPressed : 1
|
|
128
128
|
}]
|
|
129
|
-
},
|
|
129
|
+
}, cancelActPress.interactionProps), /*#__PURE__*/React.createElement(Text, {
|
|
130
130
|
style: {
|
|
131
131
|
color: tokens.colors.action,
|
|
132
132
|
fontSize: tokens.typography.action,
|
|
@@ -134,10 +134,10 @@ const SearchComponent = (props, ref) => {
|
|
|
134
134
|
}
|
|
135
135
|
}, actionText ?? locale.cancel));
|
|
136
136
|
return /*#__PURE__*/React.createElement(View, {
|
|
137
|
-
style:
|
|
137
|
+
style: ctrStyles
|
|
138
138
|
}, /*#__PURE__*/React.createElement(View, {
|
|
139
|
-
style:
|
|
140
|
-
},
|
|
139
|
+
style: cntStyles
|
|
140
|
+
}, labelEl, /*#__PURE__*/React.createElement(View, {
|
|
141
141
|
style: S.field
|
|
142
142
|
}, /*#__PURE__*/React.createElement(Field, _extends({
|
|
143
143
|
ref: inputRef,
|
|
@@ -145,12 +145,12 @@ const SearchComponent = (props, ref) => {
|
|
|
145
145
|
value: inputValue,
|
|
146
146
|
onChangeText: handleChange,
|
|
147
147
|
clearable: clearable,
|
|
148
|
-
clearTrigger:
|
|
149
|
-
leftIcon:
|
|
148
|
+
clearTrigger: rClearTrigger,
|
|
149
|
+
leftIcon: rLeftIcon,
|
|
150
150
|
rightIcon: rightIcon,
|
|
151
151
|
center: !errorMessage,
|
|
152
152
|
errorMessage: errorMessage,
|
|
153
|
-
inputAlign:
|
|
153
|
+
inputAlign: rInputAlign,
|
|
154
154
|
border: false,
|
|
155
155
|
style: [{
|
|
156
156
|
paddingHorizontal: tokens.spacing.none,
|
|
@@ -163,8 +163,8 @@ const SearchComponent = (props, ref) => {
|
|
|
163
163
|
paddingVertical: tokens.spacing.none
|
|
164
164
|
}, inputStyle],
|
|
165
165
|
onSubmitEditing: handleSubmit,
|
|
166
|
-
returnKeyType:
|
|
167
|
-
}, restFieldProps)))),
|
|
166
|
+
returnKeyType: rReturnKey
|
|
167
|
+
}, restFieldProps)))), actEl);
|
|
168
168
|
};
|
|
169
169
|
const SearchForwardRef = /*#__PURE__*/React.forwardRef(SearchComponent);
|
|
170
170
|
SearchForwardRef.displayName = 'Search';
|
|
@@ -103,10 +103,10 @@ const SelectorImpl = props => {
|
|
|
103
103
|
const {
|
|
104
104
|
tokensOverride,
|
|
105
105
|
options,
|
|
106
|
-
columns:
|
|
107
|
-
multiple:
|
|
108
|
-
showCheckMark:
|
|
109
|
-
disabled:
|
|
106
|
+
columns: colP,
|
|
107
|
+
multiple: multP,
|
|
108
|
+
showCheckMark: showChkP,
|
|
109
|
+
disabled: disP,
|
|
110
110
|
onChange,
|
|
111
111
|
itemStyle,
|
|
112
112
|
labelStyle,
|
|
@@ -115,37 +115,30 @@ const SelectorImpl = props => {
|
|
|
115
115
|
...rest
|
|
116
116
|
} = props;
|
|
117
117
|
const tokens = useSelectorTokens(tokensOverride);
|
|
118
|
-
const columns =
|
|
119
|
-
const multiple =
|
|
120
|
-
const showCheckMark =
|
|
121
|
-
const disabled = Boolean(
|
|
118
|
+
const columns = colP ?? tokens.defaults.columns ?? 1;
|
|
119
|
+
const multiple = multP ?? tokens.defaults.multiple;
|
|
120
|
+
const showCheckMark = showChkP ?? tokens.defaults.showCheckMark;
|
|
121
|
+
const disabled = Boolean(disP ?? tokens.defaults.disabled);
|
|
122
122
|
const [value = [], triggerChange] = useControllableValue(props, {
|
|
123
123
|
defaultValue: []
|
|
124
124
|
});
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
for (const
|
|
128
|
-
return
|
|
125
|
+
const optionsByVal = useMemo(() => {
|
|
126
|
+
const m = new Map();
|
|
127
|
+
for (const o of options) m.set(o.value, o);
|
|
128
|
+
return m;
|
|
129
129
|
}, [options]);
|
|
130
|
-
const
|
|
131
|
-
const basis = `${100 /
|
|
130
|
+
const rCols = Math.max(1, Math.floor(columns));
|
|
131
|
+
const basis = `${100 / rCols}%`;
|
|
132
132
|
const itemMargin = tokens.spacing.gap / 2;
|
|
133
133
|
const selectedSet = useMemo(() => new Set(value), [value]);
|
|
134
134
|
const toggleOption = useCallback(option => {
|
|
135
135
|
if (disabled || option.disabled) return;
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
} else {
|
|
141
|
-
nextValue = isActive ? [] : [option.value];
|
|
142
|
-
}
|
|
143
|
-
;
|
|
144
|
-
const items = nextValue.map(val => optionsByValue.get(val)).filter(Boolean);
|
|
145
|
-
triggerChange(nextValue, {
|
|
146
|
-
items
|
|
136
|
+
const active = selectedSet.has(option.value);
|
|
137
|
+
const nextVal = multiple ? active ? value.filter(item => item !== option.value) : [...value, option.value] : active ? [] : [option.value];
|
|
138
|
+
triggerChange(nextVal, {
|
|
139
|
+
items: nextVal.map(v => optionsByVal.get(v)).filter(Boolean)
|
|
147
140
|
});
|
|
148
|
-
}, [disabled, multiple,
|
|
141
|
+
}, [disabled, multiple, optionsByVal, selectedSet, triggerChange, value]);
|
|
149
142
|
return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
150
143
|
style: [tokens.layout.container, {
|
|
151
144
|
marginHorizontal: -itemMargin,
|
|
@@ -35,18 +35,21 @@ const ShareSheetOptionItem = /*#__PURE__*/React.memo(({
|
|
|
35
35
|
testID: `rv-share-sheet-item-${i}`
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
const iconNode = isText(o.icon) ? renderTextOrNode(o.icon, []) : o.icon;
|
|
38
39
|
return /*#__PURE__*/React.createElement(Pressable, _extends({
|
|
39
40
|
style: [S.o, ows]
|
|
40
41
|
}, p.interactionProps), /*#__PURE__*/React.createElement(View, {
|
|
41
42
|
style: [S.ic, is, {
|
|
42
43
|
marginHorizontal: t.spacing.iconMarginHorizontal
|
|
43
44
|
}]
|
|
44
|
-
},
|
|
45
|
+
}, iconNode), isValidNode(o.name) && renderTextOrNode(o.name, [S.ot, {
|
|
45
46
|
color: t.colors.option,
|
|
47
|
+
fontFamily: t.typography.fontFamily,
|
|
46
48
|
fontSize: t.typography.option,
|
|
47
49
|
paddingHorizontal: t.spacing.optionTextPaddingHorizontal
|
|
48
50
|
}]), isValidNode(o.description) && (isText(o.description) ? renderTextOrNode(o.description, [S.od, {
|
|
49
51
|
color: t.colors.optionDesc,
|
|
52
|
+
fontFamily: t.typography.fontFamily,
|
|
50
53
|
marginTop: t.spacing.gap,
|
|
51
54
|
fontSize: t.typography.optionDesc,
|
|
52
55
|
paddingHorizontal: t.spacing.optionDescPaddingHorizontal
|
|
@@ -81,6 +84,7 @@ const ShareSheetCancel = /*#__PURE__*/React.memo(({
|
|
|
81
84
|
}]
|
|
82
85
|
}, cp.interactionProps), renderTextOrNode(ct, [S.ct, {
|
|
83
86
|
color: t.colors.option,
|
|
87
|
+
fontFamily: t.typography.fontFamily,
|
|
84
88
|
fontSize: t.typography.cancel
|
|
85
89
|
}])));
|
|
86
90
|
});
|
|
@@ -173,6 +177,7 @@ const ShareSheetImpl = p => {
|
|
|
173
177
|
}]
|
|
174
178
|
}, ht && (isText(title) ? renderTextOrNode(title, [S.t, {
|
|
175
179
|
color: t.colors.title,
|
|
180
|
+
fontFamily: t.typography.fontFamily,
|
|
176
181
|
fontSize: t.typography.title,
|
|
177
182
|
marginTop: t.spacing.titleMarginTop
|
|
178
183
|
}]) : /*#__PURE__*/React.createElement(View, {
|
|
@@ -181,6 +186,7 @@ const ShareSheetImpl = p => {
|
|
|
181
186
|
}]
|
|
182
187
|
}, title)), hd && (isText(description) ? renderTextOrNode(description, [S.d, {
|
|
183
188
|
color: t.colors.description,
|
|
189
|
+
fontFamily: t.typography.fontFamily,
|
|
184
190
|
fontSize: t.typography.description,
|
|
185
191
|
marginTop: t.spacing.descriptionMarginTop
|
|
186
192
|
}]) : /*#__PURE__*/React.createElement(View, {
|
|
@@ -188,7 +194,7 @@ const ShareSheetImpl = p => {
|
|
|
188
194
|
marginTop: t.spacing.nodeMarginTop
|
|
189
195
|
}]
|
|
190
196
|
}, description)));
|
|
191
|
-
}, [description, hd, ht, title, t.colors.description, t.colors.title, t.spacing.descriptionMarginTop, t.spacing.headerPaddingBottom, t.spacing.headerPaddingHorizontal, t.spacing.headerPaddingTop, t.spacing.nodeMarginTop, t.spacing.titleMarginTop, t.typography.description, t.typography.title]);
|
|
197
|
+
}, [description, hd, ht, title, t.colors.description, t.colors.title, t.spacing.descriptionMarginTop, t.spacing.headerPaddingBottom, t.spacing.headerPaddingHorizontal, t.spacing.headerPaddingTop, t.spacing.nodeMarginTop, t.spacing.titleMarginTop, t.typography.description, t.typography.fontFamily, t.typography.title]);
|
|
192
198
|
const psm = [{
|
|
193
199
|
padding: t.spacing.popupPadding
|
|
194
200
|
}, ps];
|
|
@@ -3,7 +3,8 @@ const createTokens = foundations => {
|
|
|
3
3
|
const {
|
|
4
4
|
palette,
|
|
5
5
|
spacing,
|
|
6
|
-
fontSize
|
|
6
|
+
fontSize,
|
|
7
|
+
typography
|
|
7
8
|
} = foundations;
|
|
8
9
|
return {
|
|
9
10
|
colors: {
|
|
@@ -36,6 +37,7 @@ const createTokens = foundations => {
|
|
|
36
37
|
icon: 48
|
|
37
38
|
},
|
|
38
39
|
typography: {
|
|
40
|
+
fontFamily: typography.fontFamily,
|
|
39
41
|
title: fontSize.md,
|
|
40
42
|
description: fontSize.xs,
|
|
41
43
|
option: fontSize.xs,
|
|
@@ -20,38 +20,44 @@ const SidebarBaseImpl = props => {
|
|
|
20
20
|
const dir = useDirection();
|
|
21
21
|
const sidebarItems = useMemo(() => {
|
|
22
22
|
const items = [];
|
|
23
|
-
React.Children.toArray(children).forEach((child,
|
|
23
|
+
React.Children.toArray(children).forEach((child, i) => {
|
|
24
24
|
if (/*#__PURE__*/React.isValidElement(child)) items.push({
|
|
25
25
|
element: child,
|
|
26
|
-
index
|
|
26
|
+
index: i
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
return items;
|
|
30
30
|
}, [children]);
|
|
31
|
-
const
|
|
31
|
+
const firstIdx = sidebarItems[0]?.index ?? 0;
|
|
32
32
|
const [activeIndex, setActiveIndex] = useControllableValue(props, {
|
|
33
|
-
defaultValue:
|
|
33
|
+
defaultValue: firstIdx,
|
|
34
34
|
valuePropName: 'value',
|
|
35
35
|
defaultValuePropName: 'defaultValue',
|
|
36
36
|
trigger: 'onChange'
|
|
37
37
|
});
|
|
38
|
-
const
|
|
38
|
+
const curIdx = useMemo(() => {
|
|
39
39
|
for (const item of sidebarItems) {
|
|
40
40
|
if (item.index === activeIndex) return activeIndex;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
;
|
|
43
|
+
return firstIdx;
|
|
44
|
+
}, [activeIndex, firstIdx, sidebarItems]);
|
|
45
|
+
const ctxVal = useMemo(() => ({
|
|
46
|
+
activeIndex: curIdx,
|
|
46
47
|
onSelect: setActiveIndex
|
|
47
|
-
}), [
|
|
48
|
-
const
|
|
48
|
+
}), [curIdx, setActiveIndex]);
|
|
49
|
+
const cloned = useMemo(() => sidebarItems.map(item => /*#__PURE__*/React.cloneElement(item.element, {
|
|
49
50
|
key: item.element.key ?? item.index,
|
|
50
51
|
index: item.index,
|
|
51
52
|
tokensOverride: mergeTokensOverride(tokensOverride, item.element.props.tokensOverride)
|
|
52
53
|
})), [sidebarItems, tokensOverride]);
|
|
53
|
-
const activeItem = sidebarItems.find(item => item.index ===
|
|
54
|
-
const
|
|
54
|
+
const activeItem = sidebarItems.find(item => item.index === curIdx)?.element;
|
|
55
|
+
const contentTxtStyle = useMemo(() => ({
|
|
56
|
+
fontFamily: tokens.typography.fontFamily,
|
|
57
|
+
fontSize: tokens.typography.contentFontSize,
|
|
58
|
+
fontWeight: tokens.typography.fontWeight
|
|
59
|
+
}), [tokens.typography.fontFamily, tokens.typography.contentFontSize, tokens.typography.fontWeight]);
|
|
60
|
+
const activeContent = !isRenderable(activeItem?.props?.children) ? null : renderTextOrNode(activeItem.props.children, contentTxtStyle);
|
|
55
61
|
return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
56
62
|
style: [tokens.layout.container, {
|
|
57
63
|
backgroundColor: tokens.colors.background
|
|
@@ -62,8 +68,8 @@ const SidebarBaseImpl = props => {
|
|
|
62
68
|
}, sideStyle],
|
|
63
69
|
accessibilityRole: "tablist"
|
|
64
70
|
}, /*#__PURE__*/React.createElement(SidebarContext.Provider, {
|
|
65
|
-
value:
|
|
66
|
-
},
|
|
71
|
+
value: ctxVal
|
|
72
|
+
}, cloned), /*#__PURE__*/React.createElement(View, {
|
|
67
73
|
style: createHairlineView({
|
|
68
74
|
position: dir === 'rtl' ? 'left' : 'right',
|
|
69
75
|
color: tokens.colors.border,
|
|
@@ -72,7 +78,7 @@ const SidebarBaseImpl = props => {
|
|
|
72
78
|
})
|
|
73
79
|
})), /*#__PURE__*/React.createElement(View, {
|
|
74
80
|
style: [tokens.layout.content, activeItem?.props?.contentStyle]
|
|
75
|
-
},
|
|
81
|
+
}, activeContent));
|
|
76
82
|
};
|
|
77
83
|
const SidebarBase = /*#__PURE__*/React.memo(SidebarBaseImpl);
|
|
78
84
|
export default SidebarBase;
|
|
@@ -23,16 +23,16 @@ const SidebarItemImpl = props => {
|
|
|
23
23
|
...rest
|
|
24
24
|
} = props;
|
|
25
25
|
const tokens = useSidebarTokens(tokensOverride);
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
26
|
+
const ctx = useSidebarContext();
|
|
27
|
+
if (!ctx) return null;
|
|
28
28
|
const disabled = disabledProp ?? tokens.defaults.disabled;
|
|
29
|
-
const isActive =
|
|
30
|
-
const
|
|
29
|
+
const isActive = ctx.activeIndex === index;
|
|
30
|
+
const titleClr = disabled ? tokens.colors.disabled : isActive ? tokens.colors.titleActive : tokens.colors.title;
|
|
31
31
|
const press = useAriaPress({
|
|
32
32
|
disabled,
|
|
33
33
|
onPress: () => {
|
|
34
34
|
onClick?.(index);
|
|
35
|
-
|
|
35
|
+
ctx.onSelect(index);
|
|
36
36
|
},
|
|
37
37
|
extraProps: {
|
|
38
38
|
accessibilityRole: 'tab',
|
|
@@ -43,14 +43,15 @@ const SidebarItemImpl = props => {
|
|
|
43
43
|
testID: `rv-sidebar-item-${index}`
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
const
|
|
46
|
+
const indStyle = [tokens.layout.indicator, {
|
|
47
47
|
width: tokens.sizing.indicatorWidth,
|
|
48
48
|
borderRadius: tokens.sizing.indicatorWidth,
|
|
49
49
|
backgroundColor: tokens.colors.indicator
|
|
50
50
|
}];
|
|
51
51
|
const titleNode = isRenderable(title) ? isText(title) ? /*#__PURE__*/React.createElement(Text, {
|
|
52
52
|
style: [tokens.layout.title, {
|
|
53
|
-
color:
|
|
53
|
+
color: titleClr,
|
|
54
|
+
fontFamily: tokens.typography.fontFamily,
|
|
54
55
|
fontSize: tokens.typography.fontSize,
|
|
55
56
|
fontWeight: tokens.typography.fontWeight
|
|
56
57
|
}, textStyle]
|
|
@@ -72,7 +73,7 @@ const SidebarItemImpl = props => {
|
|
|
72
73
|
}), /*#__PURE__*/React.createElement(View, {
|
|
73
74
|
style: tokens.layout.indicatorWrapper
|
|
74
75
|
}, isActive && /*#__PURE__*/React.createElement(View, {
|
|
75
|
-
style:
|
|
76
|
+
style: indStyle
|
|
76
77
|
})), /*#__PURE__*/React.createElement(View, {
|
|
77
78
|
style: tokens.layout.itemContent
|
|
78
79
|
}, /*#__PURE__*/React.createElement(View, {
|
|
@@ -62,8 +62,10 @@ export const createSidebarTokens = foundations => {
|
|
|
62
62
|
indicator: palette.primary[600]
|
|
63
63
|
},
|
|
64
64
|
typography: {
|
|
65
|
+
fontFamily: typography.fontFamily,
|
|
65
66
|
fontSize: fontSize.sm,
|
|
66
|
-
fontWeight: typography.weight.medium
|
|
67
|
+
fontWeight: typography.weight.medium,
|
|
68
|
+
contentFontSize: fontSize.sm
|
|
67
69
|
},
|
|
68
70
|
sizing: {
|
|
69
71
|
width: 120,
|
|
@@ -13,36 +13,36 @@ const SkeletonImpl = (props, ref) => {
|
|
|
13
13
|
const {
|
|
14
14
|
tokensOverride,
|
|
15
15
|
isLoaded,
|
|
16
|
-
loading:
|
|
17
|
-
animate:
|
|
16
|
+
loading: loadP,
|
|
17
|
+
animate: animP,
|
|
18
18
|
startColor,
|
|
19
|
-
speed:
|
|
20
|
-
avatar:
|
|
21
|
-
avatarSize:
|
|
22
|
-
avatarShape:
|
|
23
|
-
title:
|
|
24
|
-
titleWidth:
|
|
25
|
-
row:
|
|
26
|
-
rowWidth:
|
|
19
|
+
speed: speedP,
|
|
20
|
+
avatar: avP,
|
|
21
|
+
avatarSize: avSzP,
|
|
22
|
+
avatarShape: avShapeP,
|
|
23
|
+
title: titleP,
|
|
24
|
+
titleWidth: titleWP,
|
|
25
|
+
row: rowP,
|
|
26
|
+
rowWidth: rowWP,
|
|
27
27
|
rowHeight,
|
|
28
|
-
round:
|
|
28
|
+
round: roundP,
|
|
29
29
|
style,
|
|
30
30
|
children,
|
|
31
31
|
...rest
|
|
32
32
|
} = props;
|
|
33
33
|
const tokens = useSkeletonTokens(tokensOverride);
|
|
34
34
|
const reducedMotion = useReducedMotion();
|
|
35
|
-
const loading =
|
|
36
|
-
const animate =
|
|
37
|
-
const avatar =
|
|
38
|
-
const avatarSize =
|
|
39
|
-
const avatarShape =
|
|
40
|
-
const title =
|
|
41
|
-
const titleWidth =
|
|
42
|
-
const row =
|
|
43
|
-
const rowWidth =
|
|
44
|
-
const round =
|
|
45
|
-
const speed = isFiniteNumber(
|
|
35
|
+
const loading = loadP ?? (isLoaded != null ? !isLoaded : true);
|
|
36
|
+
const animate = animP ?? true;
|
|
37
|
+
const avatar = avP ?? false;
|
|
38
|
+
const avatarSize = avSzP ?? tokens.defaults.avatarSize;
|
|
39
|
+
const avatarShape = avShapeP ?? 'round';
|
|
40
|
+
const title = titleP ?? false;
|
|
41
|
+
const titleWidth = titleWP ?? tokens.defaults.titleWidth;
|
|
42
|
+
const row = rowP ?? tokens.defaults.rowCount;
|
|
43
|
+
const rowWidth = rowWP ?? tokens.defaults.rowWidth;
|
|
44
|
+
const round = roundP ?? false;
|
|
45
|
+
const speed = isFiniteNumber(speedP) ? Math.max(0.01, speedP) : isString(speedP) && Number.isFinite(Number(speedP)) && Number(speedP) > 0 ? Number(speedP) : 1;
|
|
46
46
|
const duration = Math.max(0, tokens.animation.duration / speed);
|
|
47
47
|
const blockColor = startColor ?? tokens.colors.block;
|
|
48
48
|
const rows = isFiniteNumber(row) ? Math.max(0, Math.floor(row)) : 0;
|
|
@@ -53,14 +53,15 @@ const SkeletonImpl = (props, ref) => {
|
|
|
53
53
|
}, [props.rowWidth, rowWidth, rows, tokens.defaults.lastRowWidth, tokens.defaults.rowWidth]);
|
|
54
54
|
const rowHeights = useMemo(() => resolveSeries(rows, rowHeight, tokens.defaults.rowHeight), [rowHeight, rows, tokens.defaults.rowHeight]);
|
|
55
55
|
const titleHeight = rowHeights[0] ?? tokens.defaults.rowHeight;
|
|
56
|
-
const
|
|
57
|
-
const
|
|
56
|
+
const rAvSz = normalize(avatarSize, tokens.defaults.avatarSize);
|
|
57
|
+
const rTitleW = normalize(titleWidth, tokens.defaults.titleWidth);
|
|
58
58
|
const animated = useRef(new Animated.Value(0)).current;
|
|
59
59
|
useEffect(() => {
|
|
60
60
|
if (!loading || !animate || duration <= 0 || reducedMotion) {
|
|
61
61
|
animated.setValue(0);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
+
;
|
|
64
65
|
const loop = Animated.loop(Animated.sequence([Animated.timing(animated, {
|
|
65
66
|
toValue: 1,
|
|
66
67
|
duration: duration / 2,
|
|
@@ -75,51 +76,51 @@ const SkeletonImpl = (props, ref) => {
|
|
|
75
76
|
loop.start();
|
|
76
77
|
return () => loop.stop();
|
|
77
78
|
}, [animate, animated, duration, loading, reducedMotion]);
|
|
78
|
-
const
|
|
79
|
+
const animStyle = useMemo(() => !loading || !animate ? undefined : {
|
|
79
80
|
opacity: animated.interpolate({
|
|
80
81
|
inputRange: [0, 1],
|
|
81
82
|
outputRange: [tokens.animation.minOpacity, tokens.animation.maxOpacity]
|
|
82
83
|
})
|
|
83
84
|
}, [animate, animated, loading, tokens.animation.maxOpacity, tokens.animation.minOpacity]);
|
|
84
|
-
const
|
|
85
|
+
const ctrStyles = [S.ctr, {
|
|
85
86
|
gap: tokens.spacing.containerGap
|
|
86
87
|
}, style];
|
|
87
88
|
const avatarNode = useMemo(() => !avatar ? null : /*#__PURE__*/React.createElement(Animated.View, {
|
|
88
89
|
style: [{
|
|
89
|
-
width:
|
|
90
|
-
height:
|
|
90
|
+
width: rAvSz,
|
|
91
|
+
height: rAvSz,
|
|
91
92
|
borderRadius: avatarShape === 'round' ? 999 : tokens.radius,
|
|
92
93
|
backgroundColor: blockColor
|
|
93
|
-
},
|
|
94
|
-
}), [
|
|
94
|
+
}, animStyle]
|
|
95
|
+
}), [animStyle, avatar, avatarShape, blockColor, rAvSz, tokens.radius]);
|
|
95
96
|
const titleNode = useMemo(() => !title ? null : /*#__PURE__*/React.createElement(Animated.View, {
|
|
96
97
|
style: [{
|
|
97
|
-
width:
|
|
98
|
+
width: rTitleW,
|
|
98
99
|
height: titleHeight,
|
|
99
100
|
backgroundColor: blockColor,
|
|
100
101
|
borderRadius: round ? tokens.radius : 0
|
|
101
|
-
},
|
|
102
|
-
}), [
|
|
102
|
+
}, animStyle]
|
|
103
|
+
}), [animStyle, blockColor, rTitleW, round, title, titleHeight, tokens.radius]);
|
|
103
104
|
const rowNodes = useMemo(() => rows <= 0 ? null : /*#__PURE__*/React.createElement(View, {
|
|
104
105
|
style: S.rows
|
|
105
|
-
}, rowWidths.map((
|
|
106
|
-
key:
|
|
107
|
-
testID: `rv-skeleton-row-${
|
|
106
|
+
}, rowWidths.map((w, i) => /*#__PURE__*/React.createElement(Animated.View, {
|
|
107
|
+
key: i,
|
|
108
|
+
testID: `rv-skeleton-row-${i}`,
|
|
108
109
|
style: [{
|
|
109
|
-
width:
|
|
110
|
-
height: rowHeights[
|
|
111
|
-
marginTop:
|
|
110
|
+
width: w,
|
|
111
|
+
height: rowHeights[i],
|
|
112
|
+
marginTop: i === 0 && !title ? 0 : tokens.spacing.rowGap,
|
|
112
113
|
backgroundColor: blockColor,
|
|
113
114
|
borderRadius: round ? tokens.radius : 0
|
|
114
|
-
},
|
|
115
|
-
}))), [
|
|
115
|
+
}, animStyle]
|
|
116
|
+
}))), [animStyle, blockColor, rowHeights, rowWidths, rows, round, title, tokens.radius, tokens.spacing.rowGap]);
|
|
116
117
|
if (!loading) return /*#__PURE__*/React.createElement(View, _extends({
|
|
117
118
|
ref: ref,
|
|
118
119
|
style: style
|
|
119
120
|
}, rest), children);
|
|
120
121
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
121
122
|
ref: ref,
|
|
122
|
-
style:
|
|
123
|
+
style: ctrStyles
|
|
123
124
|
}, rest), avatarNode, /*#__PURE__*/React.createElement(View, {
|
|
124
125
|
style: S.cnt
|
|
125
126
|
}, titleNode, rowNodes));
|
|
@@ -7,8 +7,8 @@ import { Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
|
7
7
|
import { useSliderTokens } from './tokens';
|
|
8
8
|
import { parseNumber } from '../../utils/number';
|
|
9
9
|
import { createHairlineView } from '../../utils/hairline';
|
|
10
|
-
import { clamp } from '../../utils';
|
|
11
|
-
import { isFunction, isFiniteNumber } from '../../utils/validate';
|
|
10
|
+
import { clamp, renderTextOrNode } from '../../utils';
|
|
11
|
+
import { isFunction, isFiniteNumber, isText } from '../../utils/validate';
|
|
12
12
|
import { useAriaPress } from '../../hooks';
|
|
13
13
|
const isSameLayout = (a, b) => a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;
|
|
14
14
|
const normalizeValue = (value, range, min, max) => {
|
|
@@ -168,7 +168,7 @@ const ThumbNode = /*#__PURE__*/React.memo(({
|
|
|
168
168
|
return /*#__PURE__*/React.createElement(View, _extends({}, handlers, accessibilityProps, {
|
|
169
169
|
pointerEvents: isDisabled ? 'none' : 'auto',
|
|
170
170
|
style: [content ? S.thw : S.t, webGestureStyle, thumbStyle]
|
|
171
|
-
}), content
|
|
171
|
+
}), content != null ? isText(content) ? renderTextOrNode(content, []) : content : /*#__PURE__*/React.createElement(View, {
|
|
172
172
|
style: indicatorStyle
|
|
173
173
|
}), !content && /*#__PURE__*/React.createElement(View, {
|
|
174
174
|
style: createHairlineView({
|