react-native-system-ui 0.0.4 → 0.0.5

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.
@@ -51,20 +51,21 @@ const Notify = props => {
51
51
  const tokens = (0, _tokens.useNotifyTokens)(tokensOverride);
52
52
  const paddingVertical = tokens.spacing.paddingVertical;
53
53
  const safeAreaPadding = (0, _hooks.useSafeAreaPadding)({
54
- top: paddingVertical,
55
- bottom: paddingVertical
54
+ top: 0,
55
+ bottom: 0
56
56
  });
57
57
  const type = typeProp ?? tokens.defaults.type;
58
58
  const position = positionProp ?? tokens.defaults.position;
59
59
  const closeOnClick = closeOnClickProp ?? tokens.defaults.closeOnClick;
60
60
  const safeAreaInsetTop = props.safeAreaInsetTop ?? (position === 'top' ? tokens.defaults.safeAreaInsetTop : false);
61
61
  const safeAreaInsetBottom = props.safeAreaInsetBottom ?? (position === 'bottom' ? tokens.defaults.safeAreaInsetBottom : false);
62
- const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop : paddingVertical;
63
- const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom : paddingVertical;
62
+ const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop : 0;
63
+ const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom : 0;
64
64
  const offset = typeof offsetProp === 'number' && Number.isFinite(offsetProp) ? Math.max(0, offsetProp) : 0;
65
- const safeBottomInset = safeAreaInsetBottom && position === 'bottom' && typeof safeBottom === 'number' ? Math.max(0, safeBottom - paddingVertical) + offset : offset;
66
- const webTopPadding = _reactNative().Platform.OS === 'web' && position === 'top' ? typeof safeTop === 'string' ? `calc(${safeTop} + ${offset}px)` : safeTop + offset : undefined;
67
- const webBottomPadding = _reactNative().Platform.OS === 'web' && safeAreaInsetBottom && position === 'bottom' ? typeof safeBottom === 'string' ? `calc(${safeBottom} + ${offset}px)` : safeBottom + offset : undefined;
65
+ const addOffset = (value, delta) => typeof value === 'string' ? `calc(${value} + ${delta}px)` : value + delta;
66
+ const safeBottomInset = safeAreaInsetBottom && position === 'bottom' && typeof safeBottom === 'number' ? safeBottom + offset : offset;
67
+ const webTopPadding = _reactNative().Platform.OS === 'web' && position === 'top' ? addOffset(safeTop, offset) : undefined;
68
+ const webBottomPadding = _reactNative().Platform.OS === 'web' && safeAreaInsetBottom && position === 'bottom' ? addOffset(safeBottom, offset) : undefined;
68
69
  const variant = tokens.colors.variants[type];
69
70
  const resolvedBackground = background ?? variant.background;
70
71
  const resolvedTextColor = color ?? variant.text;
@@ -155,7 +156,7 @@ const Notify = props => {
155
156
  if (!mounted) return null;
156
157
  const bar = /*#__PURE__*/_react().default.createElement(_reactNative().View, {
157
158
  style: [tokens.layout.container, position === 'top' ? {
158
- paddingTop: webTopPadding ?? (typeof safeTop === 'number' ? safeTop + offset : safeTop)
159
+ paddingTop: webTopPadding ?? addOffset(safeTop, offset)
159
160
  } : null, webBottomPadding !== undefined ? {
160
161
  paddingBottom: webBottomPadding
161
162
  } : null]
@@ -31,20 +31,21 @@ export const Notify = props => {
31
31
  const tokens = useNotifyTokens(tokensOverride);
32
32
  const paddingVertical = tokens.spacing.paddingVertical;
33
33
  const safeAreaPadding = useSafeAreaPadding({
34
- top: paddingVertical,
35
- bottom: paddingVertical
34
+ top: 0,
35
+ bottom: 0
36
36
  });
37
37
  const type = typeProp ?? tokens.defaults.type;
38
38
  const position = positionProp ?? tokens.defaults.position;
39
39
  const closeOnClick = closeOnClickProp ?? tokens.defaults.closeOnClick;
40
40
  const safeAreaInsetTop = props.safeAreaInsetTop ?? (position === 'top' ? tokens.defaults.safeAreaInsetTop : false);
41
41
  const safeAreaInsetBottom = props.safeAreaInsetBottom ?? (position === 'bottom' ? tokens.defaults.safeAreaInsetBottom : false);
42
- const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop : paddingVertical;
43
- const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom : paddingVertical;
42
+ const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop : 0;
43
+ const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom : 0;
44
44
  const offset = typeof offsetProp === 'number' && Number.isFinite(offsetProp) ? Math.max(0, offsetProp) : 0;
45
- const safeBottomInset = safeAreaInsetBottom && position === 'bottom' && typeof safeBottom === 'number' ? Math.max(0, safeBottom - paddingVertical) + offset : offset;
46
- const webTopPadding = Platform.OS === 'web' && position === 'top' ? typeof safeTop === 'string' ? `calc(${safeTop} + ${offset}px)` : safeTop + offset : undefined;
47
- const webBottomPadding = Platform.OS === 'web' && safeAreaInsetBottom && position === 'bottom' ? typeof safeBottom === 'string' ? `calc(${safeBottom} + ${offset}px)` : safeBottom + offset : undefined;
45
+ const addOffset = (value, delta) => typeof value === 'string' ? `calc(${value} + ${delta}px)` : value + delta;
46
+ const safeBottomInset = safeAreaInsetBottom && position === 'bottom' && typeof safeBottom === 'number' ? safeBottom + offset : offset;
47
+ const webTopPadding = Platform.OS === 'web' && position === 'top' ? addOffset(safeTop, offset) : undefined;
48
+ const webBottomPadding = Platform.OS === 'web' && safeAreaInsetBottom && position === 'bottom' ? addOffset(safeBottom, offset) : undefined;
48
49
  const variant = tokens.colors.variants[type];
49
50
  const resolvedBackground = background ?? variant.background;
50
51
  const resolvedTextColor = color ?? variant.text;
@@ -135,7 +136,7 @@ export const Notify = props => {
135
136
  if (!mounted) return null;
136
137
  const bar = /*#__PURE__*/React.createElement(View, {
137
138
  style: [tokens.layout.container, position === 'top' ? {
138
- paddingTop: webTopPadding ?? (typeof safeTop === 'number' ? safeTop + offset : safeTop)
139
+ paddingTop: webTopPadding ?? addOffset(safeTop, offset)
139
140
  } : null, webBottomPadding !== undefined ? {
140
141
  paddingBottom: webBottomPadding
141
142
  } : null]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-system-ui",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "面向 React Native 的设计系统级组件库,Tokens + ThemeProvider 主题体系,按需引入、体积小;API 统一可组合、高效可靠,支持可访问性与多端一致。",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/es/index.js",