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
package/README.md
CHANGED
|
@@ -119,13 +119,13 @@ export const AuroraBranding = () => (
|
|
|
119
119
|
|
|
120
120
|
| 分类 | 组件 |
|
|
121
121
|
| --- | --- |
|
|
122
|
-
| **设计系统** | ConfigProvider、ThemeProvider、createTokens、themePresets(light / dark / aurora) |
|
|
122
|
+
| **设计系统** | ConfigProvider、ThemeProvider、Text、createTokens、themePresets(light / dark / aurora) |
|
|
123
123
|
| **基础展示** | Button、Badge、Cell、Collapse、Divider、Empty、Flex、Grid、Space、Tag、Typography、Loading、Avatar |
|
|
124
124
|
| **反馈交互** | Toast、Dialog、ActionSheet、Notify、Overlay、Popup、Portal、NoticeBar、ShareSheet |
|
|
125
125
|
| **表单输入** | Form、Field、Input、PasswordInput、Checkbox、Radio、Switch、Stepper、Rate、Picker、DatetimePicker、Calendar、Search、NumberKeyboard、Area、Cascader、Selector |
|
|
126
126
|
| **导航布局** | Tabs、NavBar、Tabbar、Sidebar、Swiper(三端手势 + 桌面鼠标拖拽) |
|
|
127
127
|
| **数据展示** | Image、ImagePreview、Skeleton、Progress、Circle、Slider、CountDown、WaterMark |
|
|
128
|
-
| **基础设施** | SafeAreaView、PortalHost、OverlayProvider、locale(zhCN / enUS) |
|
|
128
|
+
| **基础设施** | SafeAreaView、ErrorBoundary、PortalHost、OverlayProvider、locale(zhCN / enUS) |
|
|
129
129
|
|
|
130
130
|
详细组件列表与开发状态见 [路线图](./docs/guide/roadmap.md)。
|
|
131
131
|
|
|
@@ -156,4 +156,4 @@ export const AuroraBranding = () => (
|
|
|
156
156
|
|
|
157
157
|
## 版本与反馈
|
|
158
158
|
|
|
159
|
-
当前为
|
|
159
|
+
当前为 v1.0.2,欢迎 issue / PR。
|
|
@@ -66,7 +66,9 @@ const ActionSheetHeader = /*#__PURE__*/_react().default.memo(({
|
|
|
66
66
|
}, closePress.interactionProps), /*#__PURE__*/_react().default.isValidElement(closeIcon) ? /*#__PURE__*/_react().default.cloneElement(closeIcon, {
|
|
67
67
|
fill: colors.description,
|
|
68
68
|
color: colors.description
|
|
69
|
-
}) : closeIcon
|
|
69
|
+
}) : (0, _utils.renderTextOrNode)(closeIcon, [{
|
|
70
|
+
color: colors.description
|
|
71
|
+
}])));
|
|
70
72
|
});
|
|
71
73
|
const ActionSheetItem = /*#__PURE__*/_react().default.memo(({
|
|
72
74
|
action,
|
|
@@ -109,7 +111,9 @@ const ActionSheetItem = /*#__PURE__*/_react().default.memo(({
|
|
|
109
111
|
}, action.style]
|
|
110
112
|
}, actionPress.interactionProps), !!icon && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
111
113
|
style: tokens.layout.icon
|
|
112
|
-
}, icon)
|
|
114
|
+
}, (0, _utils.isText)(icon) ? (0, _utils.renderTextOrNode)(icon, [{
|
|
115
|
+
color: colors.item
|
|
116
|
+
}]) : icon), loading ? /*#__PURE__*/_react().default.createElement(_loading.default, {
|
|
113
117
|
size: 20
|
|
114
118
|
}) : (0, _utils.isRenderable)(name) ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
115
119
|
style: tokens.layout.itemTextWrapper
|
|
@@ -163,33 +167,33 @@ const ActionSheetImpl = props => {
|
|
|
163
167
|
description,
|
|
164
168
|
cancelText,
|
|
165
169
|
actions = [],
|
|
166
|
-
closeOnClickAction:
|
|
170
|
+
closeOnClickAction: closeOnActP,
|
|
167
171
|
closeOnSelect,
|
|
168
|
-
closeable:
|
|
172
|
+
closeable: closeableP,
|
|
169
173
|
closeIcon = defaultCloseIcon,
|
|
170
174
|
beforeClose,
|
|
171
175
|
onSelect,
|
|
172
176
|
onCancel,
|
|
173
177
|
onClose,
|
|
174
178
|
children,
|
|
175
|
-
round:
|
|
176
|
-
safeAreaInsetBottom:
|
|
177
|
-
overlay:
|
|
178
|
-
lockScroll:
|
|
179
|
-
style:
|
|
180
|
-
...
|
|
179
|
+
round: roundP,
|
|
180
|
+
safeAreaInsetBottom: safeP,
|
|
181
|
+
overlay: ovP,
|
|
182
|
+
lockScroll: lockP,
|
|
183
|
+
style: popStyle,
|
|
184
|
+
...popProps
|
|
181
185
|
} = props;
|
|
182
186
|
const tokens = (0, _tokens.useActionSheetTokens)(tokensOverride);
|
|
183
|
-
const closeable =
|
|
184
|
-
const round =
|
|
185
|
-
const
|
|
186
|
-
const overlay =
|
|
187
|
-
const lockScroll =
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
187
|
+
const closeable = closeableP ?? tokens.defaults.closeable;
|
|
188
|
+
const round = roundP ?? tokens.defaults.round;
|
|
189
|
+
const safeBottom = safeP ?? tokens.defaults.safeAreaInsetBottom;
|
|
190
|
+
const overlay = ovP ?? tokens.defaults.overlay;
|
|
191
|
+
const lockScroll = lockP ?? tokens.defaults.lockScroll;
|
|
192
|
+
const closeOnAct = closeOnActP ?? closeOnSelect ?? tokens.defaults.closeOnClickAction;
|
|
193
|
+
const hasT = (0, _utils.isRenderable)(title);
|
|
194
|
+
const hasD = (0, _utils.isRenderable)(description);
|
|
195
|
+
const hasC = (0, _utils.isRenderable)(cancelText);
|
|
196
|
+
const lastReasonRef = (0, _react().useRef)('close');
|
|
193
197
|
const closingRef = (0, _react().useRef)(false);
|
|
194
198
|
const beforeCloseRef = (0, _react().useRef)(beforeClose);
|
|
195
199
|
beforeCloseRef.current = beforeClose;
|
|
@@ -199,7 +203,7 @@ const ActionSheetImpl = props => {
|
|
|
199
203
|
onCancelRef.current = onCancel;
|
|
200
204
|
const onSelectRef = (0, _react().useRef)(onSelect);
|
|
201
205
|
onSelectRef.current = onSelect;
|
|
202
|
-
const
|
|
206
|
+
const runBefore = (0, _react().useCallback)(async action => {
|
|
203
207
|
if (!beforeCloseRef.current) return true;
|
|
204
208
|
try {
|
|
205
209
|
return (await beforeCloseRef.current(action)) !== false;
|
|
@@ -216,61 +220,55 @@ const ActionSheetImpl = props => {
|
|
|
216
220
|
;
|
|
217
221
|
onCancelRef.current?.();
|
|
218
222
|
}, []);
|
|
219
|
-
const
|
|
223
|
+
const reqClose = (0, _react().useCallback)(async action => {
|
|
220
224
|
if (closingRef.current) return;
|
|
221
225
|
closingRef.current = true;
|
|
222
226
|
try {
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
227
|
+
const ok = await runBefore(action);
|
|
228
|
+
if (!ok) return;
|
|
225
229
|
emitClose(action);
|
|
226
230
|
} finally {
|
|
227
231
|
closingRef.current = false;
|
|
228
232
|
}
|
|
229
|
-
}, [emitClose,
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
return
|
|
233
|
-
}, [
|
|
234
|
-
const
|
|
235
|
-
emitClose(
|
|
233
|
+
}, [emitClose, runBefore]);
|
|
234
|
+
const onPopupBefore = (0, _react().useCallback)(reason => {
|
|
235
|
+
lastReasonRef.current = reason;
|
|
236
|
+
return runBefore(reason);
|
|
237
|
+
}, [runBefore]);
|
|
238
|
+
const onPopupClose = (0, _react().useCallback)(() => {
|
|
239
|
+
emitClose(lastReasonRef.current);
|
|
236
240
|
}, [emitClose]);
|
|
237
|
-
const
|
|
238
|
-
void requestClose('cancel');
|
|
239
|
-
}, [requestClose]);
|
|
240
|
-
const handleCloseIcon = (0, _react().useCallback)(() => {
|
|
241
|
-
void requestClose('close-icon');
|
|
242
|
-
}, [requestClose]);
|
|
243
|
-
const handleActionPress = (0, _react().useCallback)((action, index) => {
|
|
241
|
+
const onActPress = (0, _react().useCallback)((action, index) => {
|
|
244
242
|
if (action.disabled || action.loading) return;
|
|
245
243
|
action.onPress?.(action);
|
|
246
244
|
action.callback?.(action);
|
|
247
245
|
onSelectRef.current?.(action, index);
|
|
248
|
-
if (
|
|
249
|
-
}, [
|
|
250
|
-
const
|
|
246
|
+
if (closeOnAct) void reqClose('action');
|
|
247
|
+
}, [reqClose, closeOnAct]);
|
|
248
|
+
const popStyleMemo = (0, _react().useMemo)(() => [tokens.layout.popup, popStyle], [tokens.layout.popup, popStyle]);
|
|
251
249
|
return /*#__PURE__*/_react().default.createElement(_popup.default, _extends({
|
|
252
250
|
visible: visible,
|
|
253
251
|
placement: "bottom",
|
|
254
252
|
round: round,
|
|
255
|
-
safeAreaInsetTop:
|
|
256
|
-
safeAreaInsetBottom:
|
|
253
|
+
safeAreaInsetTop: hasT && closeable,
|
|
254
|
+
safeAreaInsetBottom: safeBottom,
|
|
257
255
|
overlay: overlay,
|
|
258
256
|
lockScroll: lockScroll,
|
|
259
|
-
beforeClose:
|
|
260
|
-
onClose:
|
|
261
|
-
style:
|
|
262
|
-
},
|
|
257
|
+
beforeClose: onPopupBefore,
|
|
258
|
+
onClose: onPopupClose,
|
|
259
|
+
style: popStyleMemo
|
|
260
|
+
}, popProps), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
263
261
|
accessibilityRole: "menu",
|
|
264
262
|
style: [tokens.layout.panel, {
|
|
265
263
|
backgroundColor: tokens.colors.background
|
|
266
264
|
}]
|
|
267
|
-
},
|
|
265
|
+
}, hasT && /*#__PURE__*/_react().default.createElement(ActionSheetHeader, {
|
|
268
266
|
title: title,
|
|
269
267
|
closeable: closeable,
|
|
270
268
|
closeIcon: closeIcon,
|
|
271
269
|
tokens: tokens,
|
|
272
|
-
onClose:
|
|
273
|
-
}),
|
|
270
|
+
onClose: () => void reqClose('close-icon')
|
|
271
|
+
}), hasD && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
274
272
|
style: tokens.layout.descriptionContainer
|
|
275
273
|
}, (0, _utils.isText)(description) ? (0, _utils.renderTextOrNode)(description, [tokens.layout.description, {
|
|
276
274
|
color: tokens.colors.description,
|
|
@@ -291,11 +289,11 @@ const ActionSheetImpl = props => {
|
|
|
291
289
|
action: action,
|
|
292
290
|
index: index,
|
|
293
291
|
tokens: tokens,
|
|
294
|
-
onActionPress:
|
|
295
|
-
}))), children,
|
|
292
|
+
onActionPress: onActPress
|
|
293
|
+
}))), children, hasC && /*#__PURE__*/_react().default.createElement(ActionSheetCancel, {
|
|
296
294
|
cancelText: cancelText,
|
|
297
295
|
tokens: tokens,
|
|
298
|
-
onPress:
|
|
296
|
+
onPress: () => void reqClose('cancel')
|
|
299
297
|
})));
|
|
300
298
|
};
|
|
301
299
|
const ActionSheet = /*#__PURE__*/_react().default.memo(ActionSheetImpl);
|
|
@@ -20,19 +20,19 @@ const sortEntries = record => record ? Object.entries(record).sort(([a], [b]) =>
|
|
|
20
20
|
const getProvinceCode = code => code.slice(0, 2);
|
|
21
21
|
const getCityCode = code => code.slice(0, 4);
|
|
22
22
|
const groupBy = (list, getKey) => {
|
|
23
|
-
const
|
|
23
|
+
const m = new Map();
|
|
24
24
|
sortEntries(list).forEach(([code, name]) => {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
25
|
+
const k = getKey(code);
|
|
26
|
+
const arr = m.get(k);
|
|
27
|
+
if (arr) arr.push({
|
|
28
28
|
label: name,
|
|
29
29
|
value: code
|
|
30
|
-
});else
|
|
30
|
+
});else m.set(k, [{
|
|
31
31
|
label: name,
|
|
32
32
|
value: code
|
|
33
33
|
}]);
|
|
34
34
|
});
|
|
35
|
-
return
|
|
35
|
+
return m;
|
|
36
36
|
};
|
|
37
37
|
const buildAreaColumns = (areaList, columnsNum = 3) => {
|
|
38
38
|
const provinces = sortEntries(areaList.province_list);
|
|
@@ -81,15 +81,15 @@ const AreaImpl = props => {
|
|
|
81
81
|
const tokens = (0, _tokens.useAreaTokens)();
|
|
82
82
|
const {
|
|
83
83
|
areaList,
|
|
84
|
-
columnsNum:
|
|
84
|
+
columnsNum: colP = tokens.defaults.columnsNum,
|
|
85
85
|
value,
|
|
86
86
|
defaultValue,
|
|
87
87
|
onChange,
|
|
88
88
|
onConfirm,
|
|
89
|
-
interactionMode:
|
|
89
|
+
interactionMode: modeP = tokens.defaults.interactionMode,
|
|
90
90
|
...rest
|
|
91
91
|
} = props;
|
|
92
|
-
const
|
|
92
|
+
const cols = (0, _react().useMemo)(() => colP >= 1 && colP <= 3 ? colP : tokens.defaults.columnsNum, [colP]);
|
|
93
93
|
const {
|
|
94
94
|
province_list,
|
|
95
95
|
city_list,
|
|
@@ -99,27 +99,27 @@ const AreaImpl = props => {
|
|
|
99
99
|
province_list,
|
|
100
100
|
city_list,
|
|
101
101
|
county_list
|
|
102
|
-
},
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
102
|
+
}, cols), [city_list, county_list, province_list, cols]);
|
|
103
|
+
const norm = (0, _react().useCallback)(val => val === undefined ? undefined : normalizeCascadeValue(columns, val, cols), [columns, cols]);
|
|
104
|
+
const normVal = (0, _react().useMemo)(() => norm(value), [norm, value]);
|
|
105
|
+
const normDef = (0, _react().useMemo)(() => norm(defaultValue), [norm, defaultValue]);
|
|
106
106
|
const onChangeRef = (0, _react().useRef)(onChange);
|
|
107
107
|
onChangeRef.current = onChange;
|
|
108
108
|
const onConfirmRef = (0, _react().useRef)(onConfirm);
|
|
109
109
|
onConfirmRef.current = onConfirm;
|
|
110
|
-
const
|
|
111
|
-
onChangeRef.current?.(values.map(String),
|
|
110
|
+
const onCh = (0, _react().useCallback)((values, opts) => {
|
|
111
|
+
onChangeRef.current?.(values.map(String), opts);
|
|
112
112
|
}, []);
|
|
113
|
-
const
|
|
114
|
-
onConfirmRef.current?.(values.map(String),
|
|
113
|
+
const onConf = (0, _react().useCallback)((values, opts) => {
|
|
114
|
+
onConfirmRef.current?.(values.map(String), opts);
|
|
115
115
|
}, []);
|
|
116
116
|
return /*#__PURE__*/_react().default.createElement(_picker.default, _extends({}, rest, {
|
|
117
117
|
columns: columns,
|
|
118
|
-
interactionMode:
|
|
119
|
-
value:
|
|
120
|
-
defaultValue:
|
|
121
|
-
onChange: onChange ?
|
|
122
|
-
onConfirm: onConfirm ?
|
|
118
|
+
interactionMode: modeP,
|
|
119
|
+
value: normVal,
|
|
120
|
+
defaultValue: normDef,
|
|
121
|
+
onChange: onChange ? onCh : undefined,
|
|
122
|
+
onConfirm: onConfirm ? onConf : undefined
|
|
123
123
|
}));
|
|
124
124
|
};
|
|
125
125
|
const Area = /*#__PURE__*/_react().default.memo(AreaImpl);
|
|
@@ -61,11 +61,11 @@ const AvatarImpl = (props, ref) => {
|
|
|
61
61
|
source,
|
|
62
62
|
icon,
|
|
63
63
|
text,
|
|
64
|
-
size:
|
|
65
|
-
width:
|
|
66
|
-
height:
|
|
67
|
-
shape:
|
|
68
|
-
fit:
|
|
64
|
+
size: szP,
|
|
65
|
+
width: wP,
|
|
66
|
+
height: hP,
|
|
67
|
+
shape: shapeP,
|
|
68
|
+
fit: fitP,
|
|
69
69
|
color,
|
|
70
70
|
backgroundColor,
|
|
71
71
|
style,
|
|
@@ -76,45 +76,45 @@ const AvatarImpl = (props, ref) => {
|
|
|
76
76
|
...rest
|
|
77
77
|
} = props;
|
|
78
78
|
const tokens = (0, _tokens.useAvatarTokens)(tokensOverride);
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
79
|
+
const rSz = szP ?? tokens.defaults.size;
|
|
80
|
+
const rShape = shapeP ?? tokens.defaults.shape;
|
|
81
|
+
const base = (0, _utils.isNumber)(rSz) ? rSz : tokens.sizing.sizes[rSz];
|
|
82
|
+
const w = wP ?? base;
|
|
83
|
+
const h = hP ?? base;
|
|
84
|
+
const radius = rShape === 'circle' ? Math.min(w, h) / 2 : Math.max(tokens.radii.squareMin, Math.min(w, h) / tokens.radii.squareDivisor);
|
|
85
|
+
const transStyle = {
|
|
86
86
|
backgroundColor: tokens.colors.transparent
|
|
87
87
|
};
|
|
88
|
-
const
|
|
88
|
+
const fallback = icon ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
89
89
|
style: [tokens.layout.iconWrapper, {
|
|
90
|
-
width: Math.min(
|
|
91
|
-
height: Math.min(
|
|
90
|
+
width: Math.min(w, tokens.sizing.iconMaxSize),
|
|
91
|
+
height: Math.min(h, tokens.sizing.iconMaxSize)
|
|
92
92
|
}, contentStyle]
|
|
93
93
|
}, icon) : text && /*#__PURE__*/_react().default.createElement(AvatarFallbackText, {
|
|
94
94
|
color: color,
|
|
95
95
|
style: [{
|
|
96
|
-
fontSize: Math.min(
|
|
96
|
+
fontSize: Math.min(w, h) * tokens.typography.fallbackTextScale
|
|
97
97
|
}, textStyle]
|
|
98
98
|
}, text.trim().slice(0, 2).toUpperCase());
|
|
99
99
|
const content = children ?? (src || source ? /*#__PURE__*/_react().default.createElement(AvatarImage, {
|
|
100
100
|
src: src,
|
|
101
101
|
source: source,
|
|
102
|
-
containerStyle:
|
|
102
|
+
containerStyle: transStyle,
|
|
103
103
|
style: tokens.layout.image,
|
|
104
|
-
fit:
|
|
104
|
+
fit: fitP ?? 'cover',
|
|
105
105
|
loadingText: null,
|
|
106
106
|
loadingSize: tokens.sizing.loadingSize,
|
|
107
107
|
showError: true,
|
|
108
|
-
fallback:
|
|
109
|
-
}) :
|
|
108
|
+
fallback: fallback
|
|
109
|
+
}) : fallback);
|
|
110
110
|
return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
|
|
111
111
|
ref: ref,
|
|
112
112
|
accessibilityRole: "image",
|
|
113
113
|
accessibilityLabel: text ?? (src ? 'avatar' : undefined),
|
|
114
114
|
style: [tokens.layout.container, {
|
|
115
|
-
width:
|
|
116
|
-
height:
|
|
117
|
-
borderRadius,
|
|
115
|
+
width: w,
|
|
116
|
+
height: h,
|
|
117
|
+
borderRadius: radius,
|
|
118
118
|
backgroundColor: backgroundColor ?? tokens.colors.background
|
|
119
119
|
}, style]
|
|
120
120
|
}, rest), content);
|
|
@@ -28,10 +28,10 @@ const BadgeImpl = (props, ref) => {
|
|
|
28
28
|
content,
|
|
29
29
|
color,
|
|
30
30
|
textColor,
|
|
31
|
-
dot:
|
|
31
|
+
dot: dotP,
|
|
32
32
|
max,
|
|
33
33
|
offset,
|
|
34
|
-
showZero:
|
|
34
|
+
showZero: showZeroP,
|
|
35
35
|
badgeStyle,
|
|
36
36
|
textStyle,
|
|
37
37
|
onPress,
|
|
@@ -40,65 +40,66 @@ const BadgeImpl = (props, ref) => {
|
|
|
40
40
|
...rest
|
|
41
41
|
} = props;
|
|
42
42
|
const tokens = (0, _tokens.useBadgeTokens)(tokensOverride);
|
|
43
|
-
const dot =
|
|
44
|
-
const showZero =
|
|
45
|
-
const
|
|
43
|
+
const dot = dotP ?? tokens.defaults.dot;
|
|
44
|
+
const showZero = showZeroP ?? tokens.defaults.showZero;
|
|
45
|
+
const hasCh = _react().default.Children.count(children) > 0;
|
|
46
46
|
const {
|
|
47
47
|
visible,
|
|
48
48
|
formattedContent
|
|
49
49
|
} = (0, _react().useMemo)(() => {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
-
visible:
|
|
50
|
+
const num = (0, _utils.isNumericLike)(content) ? Number(content) : null;
|
|
51
|
+
const hide = num === 0 && !showZero;
|
|
52
|
+
const vis = dot || (0, _utils.isRenderable)(content) && !hide;
|
|
53
|
+
if (!vis || dot) return {
|
|
54
|
+
visible: vis,
|
|
55
55
|
formattedContent: null
|
|
56
56
|
};
|
|
57
|
-
const
|
|
58
|
-
const
|
|
57
|
+
const numMax = (0, _utils.isNumericLike)(max) ? Number(max) : null;
|
|
58
|
+
const fmt = num !== null && numMax !== null && num > numMax ? `${numMax}+` : content;
|
|
59
59
|
return {
|
|
60
60
|
visible: true,
|
|
61
|
-
formattedContent:
|
|
61
|
+
formattedContent: fmt
|
|
62
62
|
};
|
|
63
63
|
}, [content, dot, max, showZero]);
|
|
64
|
-
const [
|
|
64
|
+
const [sz, setSz] = (0, _react().useState)({
|
|
65
65
|
width: 0,
|
|
66
66
|
height: 0
|
|
67
67
|
});
|
|
68
|
-
const
|
|
68
|
+
const onLay = (0, _react().useCallback)(e => {
|
|
69
69
|
const {
|
|
70
70
|
width,
|
|
71
71
|
height
|
|
72
|
-
} =
|
|
73
|
-
|
|
72
|
+
} = e.nativeEvent.layout;
|
|
73
|
+
setSz(prev => prev.width === width && prev.height === height ? prev : {
|
|
74
74
|
width,
|
|
75
75
|
height
|
|
76
76
|
});
|
|
77
77
|
}, []);
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
78
|
+
const transStyle = (0, _react().useMemo)(() => {
|
|
79
|
+
if (!hasCh) return undefined;
|
|
80
80
|
if (dot) {
|
|
81
|
-
const
|
|
81
|
+
const h = tokens.sizing.dotSize / 2;
|
|
82
82
|
return {
|
|
83
83
|
transform: [{
|
|
84
|
-
translateX:
|
|
84
|
+
translateX: h
|
|
85
85
|
}, {
|
|
86
|
-
translateY: -
|
|
86
|
+
translateY: -h
|
|
87
87
|
}]
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
;
|
|
91
|
+
if (sz.width === 0) return {
|
|
91
92
|
opacity: 0
|
|
92
93
|
};
|
|
93
94
|
return {
|
|
94
95
|
transform: [{
|
|
95
|
-
translateX:
|
|
96
|
+
translateX: sz.width / 2
|
|
96
97
|
}, {
|
|
97
|
-
translateY: -
|
|
98
|
+
translateY: -sz.height / 2
|
|
98
99
|
}]
|
|
99
100
|
};
|
|
100
|
-
}, [dot,
|
|
101
|
-
const
|
|
101
|
+
}, [dot, hasCh, sz.height, sz.width, tokens.sizing.dotSize]);
|
|
102
|
+
const boxStyle = (0, _react().useMemo)(() => dot ? {
|
|
102
103
|
width: tokens.sizing.dotSize,
|
|
103
104
|
height: tokens.sizing.dotSize,
|
|
104
105
|
borderRadius: tokens.radii.dot,
|
|
@@ -113,45 +114,39 @@ const BadgeImpl = (props, ref) => {
|
|
|
113
114
|
borderColor: tokens.colors.border,
|
|
114
115
|
backgroundColor: color ?? tokens.colors.background
|
|
115
116
|
}, [color, dot, tokens.borders.width, tokens.colors.background, tokens.colors.border, tokens.colors.dot, tokens.radii.badge, tokens.radii.dot, tokens.sizing.dotSize, tokens.sizing.height, tokens.sizing.minWidth, tokens.sizing.paddingHorizontal, tokens.sizing.paddingVertical]);
|
|
116
|
-
const
|
|
117
|
+
const txtStyle = [tokens.layout.text, {
|
|
117
118
|
color: textColor ?? tokens.colors.text,
|
|
118
119
|
fontSize: tokens.typography.fontSize,
|
|
119
120
|
lineHeight: tokens.typography.lineHeight,
|
|
120
121
|
fontFamily: tokens.typography.fontFamily,
|
|
121
122
|
fontWeight: tokens.typography.fontWeight
|
|
122
123
|
}, textStyle];
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}]
|
|
150
|
-
}, rest), children, badgeElement) : /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({
|
|
151
|
-
ref: ref,
|
|
152
|
-
style: [tokens.layout.wrapper, style]
|
|
153
|
-
}, rest), children, badgeElement);
|
|
154
|
-
}
|
|
124
|
+
const offStyle = (0, _react().useMemo)(() => !offset ? undefined : hasCh ? {
|
|
125
|
+
right: offset[0],
|
|
126
|
+
top: offset[1]
|
|
127
|
+
} : {
|
|
128
|
+
marginLeft: offset[0],
|
|
129
|
+
marginTop: offset[1]
|
|
130
|
+
}, [hasCh, offset]);
|
|
131
|
+
const badgeEl = !visible ? null : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
132
|
+
pointerEvents: hasCh ? 'none' : 'auto',
|
|
133
|
+
onLayout: hasCh && !dot ? onLay : undefined,
|
|
134
|
+
style: [hasCh ? tokens.layout.badgeAbsolute : tokens.layout.badgeStandalone, boxStyle, transStyle, offStyle, badgeStyle, !hasCh ? style : undefined]
|
|
135
|
+
}, !dot && (0, _utils.renderTextOrNode)(formattedContent, txtStyle));
|
|
136
|
+
const accLabel = visible ? dot ? 'has new content' : `${formattedContent}` : undefined;
|
|
137
|
+
if (hasCh) return onPress ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
|
|
138
|
+
ref: ref,
|
|
139
|
+
onPress: onPress,
|
|
140
|
+
accessibilityLabel: accLabel,
|
|
141
|
+
style: ({
|
|
142
|
+
pressed
|
|
143
|
+
}) => [tokens.layout.wrapper, style, pressed && {
|
|
144
|
+
opacity: tokens.defaults.pressedOpacity
|
|
145
|
+
}]
|
|
146
|
+
}, rest), children, badgeEl) : /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({
|
|
147
|
+
ref: ref,
|
|
148
|
+
style: [tokens.layout.wrapper, style]
|
|
149
|
+
}, rest), children, badgeEl);
|
|
155
150
|
if (!visible) return null;
|
|
156
151
|
return onPress ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
|
|
157
152
|
ref: ref,
|
|
@@ -161,7 +156,7 @@ const BadgeImpl = (props, ref) => {
|
|
|
161
156
|
}) => [tokens.layout.pressableStandalone, pressed && {
|
|
162
157
|
opacity: tokens.defaults.pressedOpacity
|
|
163
158
|
}]
|
|
164
|
-
}, rest),
|
|
159
|
+
}, rest), badgeEl) : /*#__PURE__*/_react().default.cloneElement(badgeEl, {
|
|
165
160
|
ref,
|
|
166
161
|
...rest
|
|
167
162
|
});
|