react-native-sj-ui 0.1.1 → 0.1.3

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.
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ import { ActivityIndicator, TouchableOpacity } from 'react-native';
4
+ import ViewCard from "./ViewCard.js";
5
+ import TextView from "./TextView.js";
6
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const COLORS = {
8
+ primary: '#2563EB',
9
+ secondary: '#6B7280',
10
+ success: '#16A34A',
11
+ danger: '#DC2626',
12
+ warning: '#D97706',
13
+ info: '#0891B2'
14
+ };
15
+ const Button = ({
16
+ title,
17
+ children,
18
+ variant = 'solid',
19
+ colorScheme = 'primary',
20
+ size = 'md',
21
+ loading = false,
22
+ disabled = false,
23
+ leftIcon,
24
+ rightIcon,
25
+ fullWidth = false,
26
+ borderRadius = 8,
27
+ onPress,
28
+ ...props
29
+ }) => {
30
+ const color = COLORS[colorScheme];
31
+ const sizeStyle = {
32
+ sm: {
33
+ paddingVertical: 8,
34
+ paddingHorizontal: 12,
35
+ fontSize: 14
36
+ },
37
+ md: {
38
+ paddingVertical: 12,
39
+ paddingHorizontal: 16,
40
+ fontSize: 16
41
+ },
42
+ lg: {
43
+ paddingVertical: 16,
44
+ paddingHorizontal: 20,
45
+ fontSize: 18
46
+ }
47
+ }[size];
48
+ let backgroundColor = color;
49
+ let borderColor = color;
50
+ let borderWidth = 0;
51
+ let textColor = '#fff';
52
+ switch (variant) {
53
+ case 'outline':
54
+ backgroundColor = 'transparent';
55
+ borderColor = color;
56
+ borderWidth = 1;
57
+ textColor = color;
58
+ break;
59
+ case 'ghost':
60
+ backgroundColor = 'transparent';
61
+ borderColor = 'transparent';
62
+ borderWidth = 0;
63
+ textColor = color;
64
+ break;
65
+ }
66
+ if (disabled) {
67
+ backgroundColor = '#D1D5DB';
68
+ borderColor = '#D1D5DB';
69
+ textColor = '#6B7280';
70
+ }
71
+ return /*#__PURE__*/_jsx(TouchableOpacity, {
72
+ ...props,
73
+ activeOpacity: 0.8,
74
+ disabled: disabled || loading,
75
+ onPress: onPress,
76
+ children: /*#__PURE__*/_jsx(ViewCard, {
77
+ flexDirection: "row",
78
+ alignItems: "center",
79
+ justifyContent: "center",
80
+ gap: 8,
81
+ width: fullWidth ? '100%' : undefined,
82
+ paddingVertical: sizeStyle.paddingVertical,
83
+ paddingHorizontal: sizeStyle.paddingHorizontal,
84
+ borderRadius: borderRadius,
85
+ backgroundColor: backgroundColor,
86
+ borderColor: borderColor,
87
+ borderWidth: borderWidth,
88
+ opacity: disabled ? 0.6 : 1,
89
+ children: loading ? /*#__PURE__*/_jsx(ActivityIndicator, {
90
+ color: variant === 'solid' ? '#fff' : color,
91
+ size: "small"
92
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
93
+ children: [leftIcon, title && /*#__PURE__*/_jsx(TextView, {
94
+ textColor: textColor,
95
+ fontWeight: "600",
96
+ fontSize: sizeStyle.fontSize,
97
+ children: title
98
+ }), children, rightIcon]
99
+ })
100
+ })
101
+ });
102
+ };
103
+ export default Button;
104
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ActivityIndicator","TouchableOpacity","ViewCard","TextView","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","COLORS","primary","secondary","success","danger","warning","info","Button","title","children","variant","colorScheme","size","loading","disabled","leftIcon","rightIcon","fullWidth","borderRadius","onPress","props","color","sizeStyle","sm","paddingVertical","paddingHorizontal","fontSize","md","lg","backgroundColor","borderColor","borderWidth","textColor","activeOpacity","flexDirection","alignItems","justifyContent","gap","width","undefined","opacity","fontWeight"],"sourceRoot":"../../../src","sources":["components/Button.tsx"],"mappings":";;AAAA,SACEA,iBAAiB,EACjBC,gBAAgB,QAEX,cAAc;AACrB,OAAOC,QAAQ,MAAM,eAAY;AACjC,OAAOC,QAAQ,MAAM,eAAY;AAAC,SAAAC,GAAA,I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Q,EAERO,SAAS;MAAA,CACV;IACH,CACO;EAAC,CACK,CAAC;AAEvB,CAAC;AAED,eAAeT,MAAM","ignoreList":[]}
@@ -5,5 +5,6 @@ import Flex from "./Flex.js";
5
5
  import Row from "./Row.js";
6
6
  import TextView from "./TextView.js";
7
7
  import ViewCard from "./ViewCard.js";
8
- export { Column, Flex, Row, TextView, ViewCard };
8
+ import Button from "./Button.js";
9
+ export { Column, Flex, Row, TextView, ViewCard, Button };
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Column","Flex","Row","TextView","ViewCard"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,OAAOA,MAAM,MAAM,aAAU;AAC7B,OAAOC,IAAI,MAAM,WAAQ;AACzB,OAAOC,GAAG,MAAM,UAAO;AACvB,OAAOC,QAAQ,MAAM,eAAY;AACjC,OAAOC,QAAQ,MAAM,eAAY;AAEjC,SAASJ,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["Column","Flex","Row","TextView","ViewCard","Button"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,OAAOA,MAAM,MAAM,aAAU;AAC7B,OAAOC,IAAI,MAAM,WAAQ;AACzB,OAAOC,GAAG,MAAM,UAAO;AACvB,OAAOC,QAAQ,MAAM,eAAY;AACjC,OAAOC,QAAQ,MAAM,eAAY;AACjC,OAAOC,MAAM,MAAM,aAAU;AAE7B,SAASL,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ import { type TouchableOpacityProps } from 'react-native';
2
+ type ButtonVariant = 'solid' | 'outline' | 'ghost';
3
+ type ButtonColorScheme = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
4
+ type ButtonSize = 'sm' | 'md' | 'lg';
5
+ interface ButtonProps extends TouchableOpacityProps {
6
+ title?: string;
7
+ children?: React.ReactNode;
8
+ variant?: ButtonVariant;
9
+ colorScheme?: ButtonColorScheme;
10
+ size?: ButtonSize;
11
+ loading?: boolean;
12
+ leftIcon?: React.ReactNode;
13
+ rightIcon?: React.ReactNode;
14
+ fullWidth?: boolean;
15
+ borderRadius?: number;
16
+ onPress?: () => void;
17
+ }
18
+ declare const Button: React.FC<ButtonProps>;
19
+ export default Button;
20
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAItB,KAAK,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAEnD,KAAK,iBAAiB,GAClB,SAAS,GACT,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,GACT,MAAM,CAAC;AAEX,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC,UAAU,WAAY,SAAQ,qBAAqB;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE5B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAWD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA8GjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -3,5 +3,6 @@ import Flex from './Flex.js';
3
3
  import Row from './Row.js';
4
4
  import TextView from './TextView.js';
5
5
  import ViewCard from './ViewCard.js';
6
- export { Column, Flex, Row, TextView, ViewCard };
6
+ import Button from './Button.js';
7
+ export { Column, Flex, Row, TextView, ViewCard, Button };
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAU,CAAC;AAC9B,OAAO,IAAI,MAAM,WAAQ,CAAC;AAC1B,OAAO,GAAG,MAAM,UAAO,CAAC;AACxB,OAAO,QAAQ,MAAM,eAAY,CAAC;AAClC,OAAO,QAAQ,MAAM,eAAY,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAU,CAAC;AAC9B,OAAO,IAAI,MAAM,WAAQ,CAAC;AAC1B,OAAO,GAAG,MAAM,UAAO,CAAC;AACxB,OAAO,QAAQ,MAAM,eAAY,CAAC;AAClC,OAAO,QAAQ,MAAM,eAAY,CAAC;AAClC,OAAO,MAAM,MAAM,aAAU,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-sj-ui",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "The ui library for react native application.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -0,0 +1,162 @@
1
+ import {
2
+ ActivityIndicator,
3
+ TouchableOpacity,
4
+ type TouchableOpacityProps,
5
+ } from 'react-native';
6
+ import ViewCard from './ViewCard';
7
+ import TextView from './TextView';
8
+
9
+ type ButtonVariant = 'solid' | 'outline' | 'ghost';
10
+
11
+ type ButtonColorScheme =
12
+ | 'primary'
13
+ | 'secondary'
14
+ | 'success'
15
+ | 'danger'
16
+ | 'warning'
17
+ | 'info';
18
+
19
+ type ButtonSize = 'sm' | 'md' | 'lg';
20
+
21
+ interface ButtonProps extends TouchableOpacityProps {
22
+ title?: string;
23
+ children?: React.ReactNode;
24
+
25
+ variant?: ButtonVariant;
26
+ colorScheme?: ButtonColorScheme;
27
+ size?: ButtonSize;
28
+
29
+ loading?: boolean;
30
+
31
+ leftIcon?: React.ReactNode;
32
+ rightIcon?: React.ReactNode;
33
+
34
+ fullWidth?: boolean;
35
+
36
+ borderRadius?: number;
37
+
38
+ onPress?: () => void;
39
+ }
40
+
41
+ const COLORS = {
42
+ primary: '#2563EB',
43
+ secondary: '#6B7280',
44
+ success: '#16A34A',
45
+ danger: '#DC2626',
46
+ warning: '#D97706',
47
+ info: '#0891B2',
48
+ };
49
+
50
+ const Button: React.FC<ButtonProps> = ({
51
+ title,
52
+ children,
53
+ variant = 'solid',
54
+ colorScheme = 'primary',
55
+ size = 'md',
56
+ loading = false,
57
+ disabled = false,
58
+ leftIcon,
59
+ rightIcon,
60
+ fullWidth = false,
61
+ borderRadius = 8,
62
+ onPress,
63
+ ...props
64
+ }) => {
65
+ const color = COLORS[colorScheme];
66
+
67
+ const sizeStyle = {
68
+ sm: {
69
+ paddingVertical: 8,
70
+ paddingHorizontal: 12,
71
+ fontSize: 14,
72
+ },
73
+ md: {
74
+ paddingVertical: 12,
75
+ paddingHorizontal: 16,
76
+ fontSize: 16,
77
+ },
78
+ lg: {
79
+ paddingVertical: 16,
80
+ paddingHorizontal: 20,
81
+ fontSize: 18,
82
+ },
83
+ }[size];
84
+
85
+ let backgroundColor = color;
86
+ let borderColor = color;
87
+ let borderWidth = 0;
88
+ let textColor = '#fff';
89
+
90
+ switch (variant) {
91
+ case 'outline':
92
+ backgroundColor = 'transparent';
93
+ borderColor = color;
94
+ borderWidth = 1;
95
+ textColor = color;
96
+ break;
97
+
98
+ case 'ghost':
99
+ backgroundColor = 'transparent';
100
+ borderColor = 'transparent';
101
+ borderWidth = 0;
102
+ textColor = color;
103
+ break;
104
+ }
105
+
106
+ if (disabled) {
107
+ backgroundColor = '#D1D5DB';
108
+ borderColor = '#D1D5DB';
109
+ textColor = '#6B7280';
110
+ }
111
+
112
+ return (
113
+ <TouchableOpacity
114
+ {...props}
115
+ activeOpacity={0.8}
116
+ disabled={disabled || loading}
117
+ onPress={onPress}
118
+ >
119
+ <ViewCard
120
+ flexDirection="row"
121
+ alignItems="center"
122
+ justifyContent="center"
123
+ gap={8}
124
+ width={fullWidth ? '100%' : undefined}
125
+ paddingVertical={sizeStyle.paddingVertical}
126
+ paddingHorizontal={sizeStyle.paddingHorizontal}
127
+ borderRadius={borderRadius}
128
+ backgroundColor={backgroundColor}
129
+ borderColor={borderColor}
130
+ borderWidth={borderWidth}
131
+ opacity={disabled ? 0.6 : 1}
132
+ >
133
+ {loading ? (
134
+ <ActivityIndicator
135
+ color={variant === 'solid' ? '#fff' : color}
136
+ size="small"
137
+ />
138
+ ) : (
139
+ <>
140
+ {leftIcon}
141
+
142
+ {title && (
143
+ <TextView
144
+ textColor={textColor}
145
+ fontWeight="600"
146
+ fontSize={sizeStyle.fontSize}
147
+ >
148
+ {title}
149
+ </TextView>
150
+ )}
151
+
152
+ {children}
153
+
154
+ {rightIcon}
155
+ </>
156
+ )}
157
+ </ViewCard>
158
+ </TouchableOpacity>
159
+ );
160
+ };
161
+
162
+ export default Button;
@@ -3,5 +3,6 @@ import Flex from './Flex';
3
3
  import Row from './Row';
4
4
  import TextView from './TextView';
5
5
  import ViewCard from './ViewCard';
6
+ import Button from './Button';
6
7
 
7
- export { Column, Flex, Row, TextView, ViewCard };
8
+ export { Column, Flex, Row, TextView, ViewCard, Button };