react-native-system-ui 1.0.1 → 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 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
- 当前为 v0.0.7,欢迎 issue / PR。
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), loading ? /*#__PURE__*/_react().default.createElement(_loading.default, {
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
@@ -396,10 +396,11 @@ const CascaderOptionItem = /*#__PURE__*/_react().default.memo(({
396
396
  }, selected ? {
397
397
  fontWeight: tokens.typography.optionTextActiveWeight
398
398
  } : null];
399
- const cnt = optionRender ? optionRender({
399
+ const rawCnt = optionRender ? optionRender({
400
400
  option,
401
401
  selected
402
402
  }) : (0, _utils.renderTextOrNode)(lbl, txtStyle);
403
+ const cnt = (0, _validate.isText)(rawCnt) ? (0, _utils.renderTextOrNode)(rawCnt, txtStyle) : rawCnt;
403
404
  return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
404
405
  testID: `cascader-option-${tabIndex}-${String(ov)}`,
405
406
  style: ({
@@ -288,7 +288,7 @@ const InternalFormImpl = (props, ref) => {
288
288
  value: ctxVal
289
289
  }, /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({
290
290
  style: style
291
- }, rest), children, footer));
291
+ }, rest), children, (0, _validate.isText)(footer) ? (0, _utils.renderTextOrNode)(footer, []) : footer));
292
292
  };
293
293
  const InternalFormRef = /*#__PURE__*/_react().default.forwardRef(InternalFormImpl);
294
294
  const InternalForm = /*#__PURE__*/_react().default.memo(InternalFormRef);
@@ -266,16 +266,26 @@ const ImagePreviewImpl = (props, ref) => {
266
266
  paddingHorizontal: spacing.indexPaddingHorizontal,
267
267
  paddingVertical: spacing.indexPaddingVertical
268
268
  }]
269
- }, indexRender ? indexRender({
270
- index: current,
271
- len: total
272
- }) : /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
273
- style: [S.indexText, {
274
- color: colors.indexText,
275
- fontFamily: typography.fontFamily,
276
- fontSize: typography.indexTextSize
277
- }]
278
- }, indexText)));
269
+ }, (() => {
270
+ if (!indexRender) return /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
271
+ style: [S.indexText, {
272
+ color: colors.indexText,
273
+ fontFamily: typography.fontFamily,
274
+ fontSize: typography.indexTextSize
275
+ }]
276
+ }, indexText);
277
+ const node = indexRender({
278
+ index: current,
279
+ len: total
280
+ });
281
+ return (0, _validate.isText)(node) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
282
+ style: [S.indexText, {
283
+ color: colors.indexText,
284
+ fontFamily: typography.fontFamily,
285
+ fontSize: typography.indexTextSize
286
+ }]
287
+ }, node) : node;
288
+ })()));
279
289
  }, [colors.indexBackground, colors.indexText, indexRender, radii.indexBadge, showIndex, spacing.indexPaddingHorizontal, spacing.indexPaddingVertical, spacing.indexTop, typography.indexTextSize]);
280
290
  const lazyBuffer = lazyRender ? Math.max(0, lazyRenderBuffer | 0) : 0;
281
291
  const renderIndicator = (0, _react().useCallback)((total, current) => /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, renderIndex(current, total), showIndicators && total > 1 && /*#__PURE__*/_react().default.createElement(_swiper.default.PagIndicator, {
@@ -55,13 +55,14 @@ const ShareSheetOptionItem = /*#__PURE__*/_react().default.memo(({
55
55
  testID: `rv-share-sheet-item-${i}`
56
56
  }
57
57
  });
58
+ const iconNode = (0, _validate.isText)(o.icon) ? (0, _utils.renderTextOrNode)(o.icon, []) : o.icon;
58
59
  return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
59
60
  style: [S.o, ows]
60
61
  }, p.interactionProps), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
61
62
  style: [S.ic, is, {
62
63
  marginHorizontal: t.spacing.iconMarginHorizontal
63
64
  }]
64
- }, o.icon), (0, _validate.isValidNode)(o.name) && (0, _utils.renderTextOrNode)(o.name, [S.ot, {
65
+ }, iconNode), (0, _validate.isValidNode)(o.name) && (0, _utils.renderTextOrNode)(o.name, [S.ot, {
65
66
  color: t.colors.option,
66
67
  fontFamily: t.typography.fontFamily,
67
68
  fontSize: t.typography.option,
@@ -205,7 +205,7 @@ const ThumbNode = /*#__PURE__*/_react().default.memo(({
205
205
  return /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({}, handlers, accessibilityProps, {
206
206
  pointerEvents: isDisabled ? 'none' : 'auto',
207
207
  style: [content ? S.thw : S.t, webGestureStyle, thumbStyle]
208
- }), content ?? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
208
+ }), content != null ? (0, _validate.isText)(content) ? (0, _utils2.renderTextOrNode)(content, []) : content : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
209
209
  style: indicatorStyle
210
210
  }), !content && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
211
211
  style: (0, _hairline.createHairlineView)({
@@ -52,6 +52,12 @@ const TabbarItemImpl = p => {
52
52
  const c = ia ? ctx.activeColor : ctx.inactiveColor;
53
53
  const ris = iconSize ?? t.icon.size;
54
54
  const ait = (0, _react().useCallback)(n => {
55
+ if ((0, _validate.isText)(n)) return /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
56
+ style: {
57
+ color: c,
58
+ fontSize: ris
59
+ }
60
+ }, n);
55
61
  if (! /*#__PURE__*/_react().default.isValidElement(n)) return n;
56
62
  const e = n;
57
63
  const np = {};
@@ -271,7 +271,10 @@ const ToastContentImpl = props => {
271
271
  style: [S.t, toastStyle, style]
272
272
  }, iconNode && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
273
273
  style: iconWrapperStyle
274
- }, iconNode), hasMessage && ((0, _validate.isText)(message) ? (0, _utils.renderTextOrNode)(message, [S.m, messageStyle, textStyle]) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
274
+ }, (0, _validate.isText)(iconNode) ? (0, _utils.renderTextOrNode)(iconNode, [{
275
+ color: colors.text,
276
+ fontSize: tokens.iconSize
277
+ }]) : iconNode), hasMessage && ((0, _validate.isText)(message) ? (0, _utils.renderTextOrNode)(message, [S.m, messageStyle, textStyle]) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
275
278
  style: S.mw
276
279
  }, message)))), needsSafeAreaBottom && /*#__PURE__*/_react().default.createElement(_safeAreaView.SafeAreaView, {
277
280
  edge: "bottom",
@@ -40,7 +40,9 @@ const ActionSheetHeader = /*#__PURE__*/React.memo(({
40
40
  }, closePress.interactionProps), /*#__PURE__*/React.isValidElement(closeIcon) ? /*#__PURE__*/React.cloneElement(closeIcon, {
41
41
  fill: colors.description,
42
42
  color: colors.description
43
- }) : closeIcon));
43
+ }) : renderTextOrNode(closeIcon, [{
44
+ color: colors.description
45
+ }])));
44
46
  });
45
47
  const ActionSheetItem = /*#__PURE__*/React.memo(({
46
48
  action,
@@ -83,7 +85,9 @@ const ActionSheetItem = /*#__PURE__*/React.memo(({
83
85
  }, action.style]
84
86
  }, actionPress.interactionProps), !!icon && /*#__PURE__*/React.createElement(View, {
85
87
  style: tokens.layout.icon
86
- }, icon), loading ? /*#__PURE__*/React.createElement(Loading, {
88
+ }, isText(icon) ? renderTextOrNode(icon, [{
89
+ color: colors.item
90
+ }]) : icon), loading ? /*#__PURE__*/React.createElement(Loading, {
87
91
  size: 20
88
92
  }) : isRenderable(name) ? /*#__PURE__*/React.createElement(View, {
89
93
  style: tokens.layout.itemTextWrapper
@@ -370,10 +370,11 @@ const CascaderOptionItem = /*#__PURE__*/React.memo(({
370
370
  }, selected ? {
371
371
  fontWeight: tokens.typography.optionTextActiveWeight
372
372
  } : null];
373
- const cnt = optionRender ? optionRender({
373
+ const rawCnt = optionRender ? optionRender({
374
374
  option,
375
375
  selected
376
376
  }) : renderTextOrNode(lbl, txtStyle);
377
+ const cnt = isText(rawCnt) ? renderTextOrNode(rawCnt, txtStyle) : rawCnt;
377
378
  return /*#__PURE__*/React.createElement(Pressable, {
378
379
  testID: `cascader-option-${tabIndex}-${String(ov)}`,
379
380
  style: ({
@@ -1,7 +1,7 @@
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, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
3
  import { View } from 'react-native';
4
- import { shallowEqualObject } from '../../utils';
4
+ import { shallowEqualObject, renderTextOrNode } from '../../utils';
5
5
  import { isPromiseLike } from '../../utils/promise';
6
6
  import { isNumber, isString, isText } from '../../utils/validate';
7
7
  import { FORM_ALL_FIELDS_KEY, getValueByName, normalizeTrigger, serializeNamePath, setValueByName } from './utils';
@@ -269,7 +269,7 @@ const InternalFormImpl = (props, ref) => {
269
269
  value: ctxVal
270
270
  }, /*#__PURE__*/React.createElement(View, _extends({
271
271
  style: style
272
- }, rest), children, footer));
272
+ }, rest), children, isText(footer) ? renderTextOrNode(footer, []) : footer));
273
273
  };
274
274
  const InternalFormRef = /*#__PURE__*/React.forwardRef(InternalFormImpl);
275
275
  const InternalForm = /*#__PURE__*/React.memo(InternalFormRef);
@@ -4,7 +4,7 @@ import { Image as RNImage, Platform, Pressable, StyleSheet, Text, View } from 'r
4
4
  import Popup from '../popup';
5
5
  import Swiper from '../swiper';
6
6
  import { useImagePreviewTokens } from './tokens';
7
- import { isString } from '../../utils/validate';
7
+ import { isString, isText } from '../../utils/validate';
8
8
  const clampIndex = (index, total) => total <= 0 ? 0 : Math.max(0, Math.min(total - 1, index));
9
9
  const indicatorSpacing = {
10
10
  bottom: 32
@@ -246,16 +246,26 @@ const ImagePreviewImpl = (props, ref) => {
246
246
  paddingHorizontal: spacing.indexPaddingHorizontal,
247
247
  paddingVertical: spacing.indexPaddingVertical
248
248
  }]
249
- }, indexRender ? indexRender({
250
- index: current,
251
- len: total
252
- }) : /*#__PURE__*/React.createElement(Text, {
253
- style: [S.indexText, {
254
- color: colors.indexText,
255
- fontFamily: typography.fontFamily,
256
- fontSize: typography.indexTextSize
257
- }]
258
- }, indexText)));
249
+ }, (() => {
250
+ if (!indexRender) return /*#__PURE__*/React.createElement(Text, {
251
+ style: [S.indexText, {
252
+ color: colors.indexText,
253
+ fontFamily: typography.fontFamily,
254
+ fontSize: typography.indexTextSize
255
+ }]
256
+ }, indexText);
257
+ const node = indexRender({
258
+ index: current,
259
+ len: total
260
+ });
261
+ return isText(node) ? /*#__PURE__*/React.createElement(Text, {
262
+ style: [S.indexText, {
263
+ color: colors.indexText,
264
+ fontFamily: typography.fontFamily,
265
+ fontSize: typography.indexTextSize
266
+ }]
267
+ }, node) : node;
268
+ })()));
259
269
  }, [colors.indexBackground, colors.indexText, indexRender, radii.indexBadge, showIndex, spacing.indexPaddingHorizontal, spacing.indexPaddingVertical, spacing.indexTop, typography.indexTextSize]);
260
270
  const lazyBuffer = lazyRender ? Math.max(0, lazyRenderBuffer | 0) : 0;
261
271
  const renderIndicator = useCallback((total, current) => /*#__PURE__*/React.createElement(React.Fragment, null, renderIndex(current, total), showIndicators && total > 1 && /*#__PURE__*/React.createElement(Swiper.PagIndicator, {
@@ -35,13 +35,14 @@ 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
- }, o.icon), isValidNode(o.name) && renderTextOrNode(o.name, [S.ot, {
45
+ }, iconNode), isValidNode(o.name) && renderTextOrNode(o.name, [S.ot, {
45
46
  color: t.colors.option,
46
47
  fontFamily: t.typography.fontFamily,
47
48
  fontSize: t.typography.option,
@@ -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 ?? /*#__PURE__*/React.createElement(View, {
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({
@@ -32,6 +32,12 @@ const TabbarItemImpl = p => {
32
32
  const c = ia ? ctx.activeColor : ctx.inactiveColor;
33
33
  const ris = iconSize ?? t.icon.size;
34
34
  const ait = useCallback(n => {
35
+ if (isText(n)) return /*#__PURE__*/React.createElement(Text, {
36
+ style: {
37
+ color: c,
38
+ fontSize: ris
39
+ }
40
+ }, n);
35
41
  if (! /*#__PURE__*/React.isValidElement(n)) return n;
36
42
  const e = n;
37
43
  const np = {};
@@ -245,7 +245,10 @@ const ToastContentImpl = props => {
245
245
  style: [S.t, toastStyle, style]
246
246
  }, iconNode && /*#__PURE__*/React.createElement(View, {
247
247
  style: iconWrapperStyle
248
- }, iconNode), hasMessage && (isText(message) ? renderTextOrNode(message, [S.m, messageStyle, textStyle]) : /*#__PURE__*/React.createElement(View, {
248
+ }, isText(iconNode) ? renderTextOrNode(iconNode, [{
249
+ color: colors.text,
250
+ fontSize: tokens.iconSize
251
+ }]) : iconNode), hasMessage && (isText(message) ? renderTextOrNode(message, [S.m, messageStyle, textStyle]) : /*#__PURE__*/React.createElement(View, {
249
252
  style: S.mw
250
253
  }, message)))), needsSafeAreaBottom && /*#__PURE__*/React.createElement(SafeAreaView, {
251
254
  edge: "bottom",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-system-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "面向 React Native 的设计系统级组件库,Tokens + ThemeProvider 主题体系,按需引入、体积小;API 统一可组合、高效可靠,支持可访问性与多端一致。",
5
5
  "homepage": "https://rn-system-ui.netlify.app/",
6
6
  "main": "./dist/cjs/index.js",