@zhenryx/react-native-components 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,37 @@
1
- # @zhenryx/react-native-ui
2
- 一个 React Native UI 组件库
3
- 该组件库以避免以下情况出现:
4
- - 部分安卓机型吞字
1
+ # @zhenryx/react-native-components
2
+
3
+ 一个 React Native UI 组件库。
4
+
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- npm install @zhenryx/react-native-ui
8
+ npm install @zhenryx/react-native-components
9
9
  ```
10
10
 
11
11
  ## 要求
12
- - React >= 18.1.0
13
- - React Native >= 0.70.0
14
12
 
15
- ## 许可证
16
- ISC
13
+ - React >= 16.8.0
14
+ - React Native >= 0.60.0
15
+ - react-native-safe-area-context >= 3.0.0
16
+
17
+ ## 快速开始
18
+
19
+ ```bash
20
+ npm install react-native-safe-area-context
21
+ ```
22
+
23
+ ```tsx
24
+ import { ThemeProvider } from '@zhenryx/react-native-components';
25
+
26
+ function App() {
27
+ return (
28
+ <ThemeProvider>
29
+ <YourApp />
30
+ </ThemeProvider>
31
+ );
32
+ }
33
+ ```
34
+
35
+ ## 文档
36
+
37
+ 详细的组件文档请查看 [src/docs](./src/docs) 目录。
@@ -1 +1 @@
1
- {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAW,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAE,SAAS,EAAgC,MAAM,cAAc,CAAA;AAKlG,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwDxC,CAAA"}
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAW,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAE,SAAS,EAAgC,MAAM,cAAc,CAAA;AAIlG,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAsDxC,CAAA"}
@@ -26,21 +26,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Header = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
- const react_native_safe_area_context_1 = require("react-native-safe-area-context");
30
29
  const Text_1 = require("../Text/Text");
31
30
  const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
32
31
  const Header = ({ title = '自定义头部导航', backGroundColor, leftComponent, centerComponent, rightComponent, containerStyle, titleStyle: customTitleStyle, showBack = true, onBack }) => {
33
32
  const { theme } = (0, ThemeConfig_1.useTheme)();
34
- const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
35
33
  const headerStyle = (0, react_1.useMemo)(() => ({
36
- height: (theme['$header-height'] || 44) + insets.top,
37
- paddingTop: insets.top,
34
+ minHeight: theme['$header-height'] || 44,
38
35
  backgroundColor: backGroundColor || theme['$header-background'] || 'transparent',
39
36
  flexDirection: 'row',
40
37
  justifyContent: 'space-between',
41
38
  alignItems: 'center',
42
39
  paddingHorizontal: theme['$header-spacing'] || 15,
43
- }), [theme, backGroundColor, insets.top]);
40
+ }), [theme, backGroundColor]);
44
41
  const defaultTitleStyle = (0, react_1.useMemo)(() => ({
45
42
  fontSize: theme['$header-title-fontsize'] || 18,
46
43
  fontWeight: theme['$header-title-fontweight'] || '500'
@@ -0,0 +1,14 @@
1
+ import React, { ReactNode } from 'react';
2
+ export interface Tab {
3
+ id: string;
4
+ label: string;
5
+ content?: ReactNode;
6
+ }
7
+ export interface TabViewProps {
8
+ tabs: Tab[];
9
+ defaultTab?: string;
10
+ onTabChange?: (tabId: string) => void;
11
+ renderContent?: (tab: Tab) => ReactNode;
12
+ }
13
+ export declare const TabView: React.FC<TabViewProps>;
14
+ //# sourceMappingURL=TabView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../src/components/TabView/TabView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuB,SAAS,EAAE,MAAM,OAAO,CAAC;AAG9D,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC;CACzC;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAoE1C,CAAC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.TabView = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const react_native_1 = require("react-native");
29
+ const TabView = ({ tabs, defaultTab, onTabChange, renderContent, }) => {
30
+ const [activeTab, setActiveTab] = (0, react_1.useState)(defaultTab || tabs[0]?.id || '');
31
+ // 当 defaultTab 或 tabs 变化时,更新 activeTab
32
+ (0, react_1.useEffect)(() => {
33
+ if (defaultTab && tabs.some((tab) => tab.id === defaultTab)) {
34
+ setActiveTab(defaultTab);
35
+ }
36
+ else if (tabs.length > 0) {
37
+ setActiveTab((currentTab) => {
38
+ // 如果当前 tab 不在 tabs 中,回退到第一个 tab
39
+ if (!tabs.some((tab) => tab.id === currentTab)) {
40
+ return tabs[0].id;
41
+ }
42
+ return currentTab;
43
+ });
44
+ }
45
+ }, [defaultTab, tabs]);
46
+ const handleTabPress = (tabId) => {
47
+ setActiveTab(tabId);
48
+ onTabChange?.(tabId);
49
+ };
50
+ const activeTabData = tabs.find((tab) => tab.id === activeTab) || tabs[0];
51
+ return (<react_native_1.View style={styles.container}>
52
+ <react_native_1.View style={styles.tabContainer}>
53
+ <react_native_1.ScrollView horizontal showsHorizontalScrollIndicator={false}>
54
+ {tabs.map((tab) => (<react_native_1.Pressable key={tab.id} style={styles.tab} onPress={() => handleTabPress(tab.id)}>
55
+ <react_native_1.Text style={[
56
+ styles.tabText,
57
+ activeTab === tab.id && styles.tabTextActive,
58
+ ]}>
59
+ {tab.label}
60
+ </react_native_1.Text>
61
+ {activeTab === tab.id && <react_native_1.View style={styles.tabIndicator}/>}
62
+ </react_native_1.Pressable>))}
63
+ </react_native_1.ScrollView>
64
+ </react_native_1.View>
65
+
66
+ <react_native_1.View style={styles.contentContainer}>
67
+ {activeTabData
68
+ ? renderContent
69
+ ? renderContent(activeTabData)
70
+ : activeTabData.content || null
71
+ : null}
72
+ </react_native_1.View>
73
+ </react_native_1.View>);
74
+ };
75
+ exports.TabView = TabView;
76
+ exports.TabView.displayName = 'TabView';
77
+ const styles = react_native_1.StyleSheet.create({
78
+ container: {
79
+ flex: 1,
80
+ backgroundColor: '#FFFFFF',
81
+ },
82
+ tabContainer: {
83
+ borderBottomWidth: react_native_1.StyleSheet.hairlineWidth,
84
+ borderBottomColor: '#E5E7EB',
85
+ backgroundColor: '#FFFFFF',
86
+ },
87
+ tab: {
88
+ justifyContent: 'center',
89
+ alignItems: 'center',
90
+ paddingVertical: 12,
91
+ paddingHorizontal: 20,
92
+ position: 'relative',
93
+ minWidth: 70,
94
+ },
95
+ tabText: {
96
+ fontSize: 15,
97
+ color: '#9CA3AF',
98
+ fontWeight: '500',
99
+ textAlign: 'center',
100
+ },
101
+ tabTextActive: {
102
+ color: '#111827',
103
+ fontWeight: '700',
104
+ fontSize: 16,
105
+ transform: [{ scale: 1.1 }],
106
+ },
107
+ tabIndicator: {
108
+ position: 'absolute',
109
+ bottom: 0,
110
+ alignSelf: 'center',
111
+ width: 25,
112
+ height: 3,
113
+ backgroundColor: '#EF4444',
114
+ borderRadius: 2,
115
+ },
116
+ contentContainer: {
117
+ flex: 1,
118
+ padding: 20,
119
+ },
120
+ });
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export type { OverLayProps } from './Overlay/Overlay';
11
11
  export { Popup } from './Popup/Popup';
12
12
  export type { PopupProps } from './Popup/Popup';
13
13
  export { Text } from './Text/Text';
14
+ export { TabView } from './TabView/TabView';
15
+ export type { TabViewProps, Tab } from './TabView/TabView';
14
16
  export { ThemeProvider, useTheme } from './ThemeConfig/ThemeConfig';
15
17
  export type { Theme } from './ThemeConfig/ThemeConfig';
16
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,MAA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C"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTheme = exports.ThemeProvider = exports.Text = exports.Popup = exports.OverLay = exports.Header = exports.Empty = exports.Dialog = exports.Button = void 0;
3
+ exports.useTheme = exports.ThemeProvider = exports.TabView = exports.Text = exports.Popup = exports.OverLay = exports.Header = exports.Empty = exports.Dialog = exports.Button = void 0;
4
4
  var Button_1 = require("./Button/Button");
5
5
  Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
6
6
  var Dialog_1 = require("./Dialog/Dialog");
@@ -15,6 +15,8 @@ var Popup_1 = require("./Popup/Popup");
15
15
  Object.defineProperty(exports, "Popup", { enumerable: true, get: function () { return Popup_1.Popup; } });
16
16
  var Text_1 = require("./Text/Text");
17
17
  Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return Text_1.Text; } });
18
+ var TabView_1 = require("./TabView/TabView");
19
+ Object.defineProperty(exports, "TabView", { enumerable: true, get: function () { return TabView_1.TabView; } });
18
20
  var ThemeConfig_1 = require("./ThemeConfig/ThemeConfig");
19
21
  Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return ThemeConfig_1.ThemeProvider; } });
20
22
  Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return ThemeConfig_1.useTheme; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenryx/react-native-components",
3
- "version": "0.0.3",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -25,14 +25,12 @@
25
25
  "access": "public"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/react": "18.2.0",
29
- "@types/react-native": "0.70.0",
30
- "typescript": "5.0.4",
31
- "react-native-safe-area-context": "^4.8.0"
28
+ "@types/react": "^18.0.0",
29
+ "@types/react-native": "^0.60.0",
30
+ "typescript": "^4.0.0"
32
31
  },
33
32
  "peerDependencies": {
34
- "react": ">=18.1.0",
35
- "react-native": ">=0.70.0",
36
- "react-native-safe-area-context": ">=4.0.0"
33
+ "react": ">=16.8.0",
34
+ "react-native": ">=0.60.0"
37
35
  }
38
36
  }