ui-rn 2.0.3 → 2.0.4

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/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "ui-rn",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "repository": "https://github.com/package-dev/ui-rn",
5
5
  "description": "ui-rn",
6
6
  "author": "Phamha98",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
7
+ "main": "src/index.tsx",
9
8
  "peerDependencies": {
10
9
  "react": ">=18",
11
10
  "react-native": ">=0.70"
@@ -0,0 +1,15 @@
1
+ import { RNVectorIcon } from "./index";
2
+ import { FlexStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
3
+ import { MakeProp } from "./makeProps";
4
+ export interface Props extends MakeProp {
5
+ name: string;
6
+ size?: number;
7
+ type?: keyof typeof RNVectorIcon;
8
+ onPress?: () => void;
9
+ styleContainer?: StyleProp<ViewStyle>;
10
+ style?: StyleProp<TextStyle>;
11
+ alignSelf?: FlexStyle['alignSelf'];
12
+ disabled?: boolean;
13
+ activeOpacity?: number;
14
+ color?: string;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import Ionicons from "react-native-vector-icons/Ionicons";
3
+ import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
4
+ /**
5
+ * Collection of React Native Vector Icons
6
+ * Provides access to various icon sets from react-native-vector-icons
7
+ */
8
+ export declare const RNVectorIcon: {
9
+ Ionicons: typeof Ionicons;
10
+ AntDesign: typeof Ionicons;
11
+ Entypo: typeof Ionicons;
12
+ EvilIcons: typeof Ionicons;
13
+ MaterialIcons: typeof Ionicons;
14
+ MaterialCommunityIcons: typeof Ionicons;
15
+ FontAwesome: typeof Ionicons;
16
+ FontAwesome5: typeof FontAwesome5;
17
+ SimpleLineIcons: typeof Ionicons;
18
+ Feather: typeof Ionicons;
19
+ Octicons: typeof Ionicons;
20
+ Fontisto: typeof Ionicons;
21
+ };
22
+ export type IconType = keyof typeof RNVectorIcon;
23
+ import { Props } from "./PropsStyle";
24
+ export default class IconApp extends React.PureComponent<Props> {
25
+ static defaultProps: Props;
26
+ res: {
27
+ color: string;
28
+ style: any;
29
+ size: number;
30
+ };
31
+ constructor(props: Props);
32
+ render(): React.JSX.Element | null;
33
+ }
@@ -0,0 +1,72 @@
1
+ import React from "react";
2
+ import { StyleSheet, TouchableOpacity } from "react-native";
3
+ import Ionicons from "react-native-vector-icons/Ionicons";
4
+ import EvilIcons from "react-native-vector-icons/EvilIcons";
5
+ import FontAwesome from "react-native-vector-icons/FontAwesome";
6
+ import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
7
+ import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
8
+ import MaterialIcons from "react-native-vector-icons/MaterialIcons";
9
+ import Entypo from "react-native-vector-icons/Entypo";
10
+ import AntDesign from "react-native-vector-icons/AntDesign";
11
+ import SimpleLineIcons from "react-native-vector-icons/SimpleLineIcons";
12
+ import Feather from "react-native-vector-icons/Feather";
13
+ import Octicons from "react-native-vector-icons/Octicons";
14
+ import Fontisto from "react-native-vector-icons/Fontisto";
15
+ /**
16
+ * Collection of React Native Vector Icons
17
+ * Provides access to various icon sets from react-native-vector-icons
18
+ */
19
+ export const RNVectorIcon = {
20
+ Ionicons,
21
+ AntDesign,
22
+ Entypo,
23
+ EvilIcons,
24
+ MaterialIcons,
25
+ MaterialCommunityIcons,
26
+ FontAwesome,
27
+ FontAwesome5,
28
+ SimpleLineIcons,
29
+ Feather,
30
+ Octicons,
31
+ Fontisto,
32
+ };
33
+ import { makeProps } from "./makeProps";
34
+ export default class IconApp extends React.PureComponent {
35
+ static defaultProps = {
36
+ size: 23,
37
+ color: "gray",
38
+ name: "home",
39
+ };
40
+ res;
41
+ constructor(props) {
42
+ super(props);
43
+ this.res = makeProps(props);
44
+ }
45
+ render() {
46
+ const { size, color, style } = this.res;
47
+ if (this.props.name === "none")
48
+ return null;
49
+ const IconView = RNVectorIcon[this.props.type || "Ionicons"];
50
+ if (typeof this.props.onPress != "function") {
51
+ return (<IconView size={size} color={color} style={style} name={this.props.name} onPress={this.props.onPress}/>);
52
+ }
53
+ return (<TouchableOpacity activeOpacity={this.props.activeOpacity || 0.5} disabled={typeof this.props.onPress == "function" ? this.props.disabled : true} style={[
54
+ styles.container,
55
+ { ...(this.props.alignSelf && { alignSelf: this.props.alignSelf }) },
56
+ this.props.style,
57
+ this.props.styleContainer,
58
+ ]}>
59
+ <IconView size={size} color={color} style={style} name={this.props.name} onPress={this.props.onPress}/>
60
+ </TouchableOpacity>);
61
+ }
62
+ }
63
+ /**
64
+ * Default styles for the IconApp component
65
+ */
66
+ const styles = StyleSheet.create({
67
+ container: {
68
+ alignItems: "center",
69
+ justifyContent: "center",
70
+ alignSelf: "flex-start",
71
+ },
72
+ });
@@ -0,0 +1,37 @@
1
+ import { ViewStyle } from "react-native";
2
+ declare enum COLORS {
3
+ white = 1,
4
+ red = 2,
5
+ blue = 3,
6
+ black = 4,
7
+ green = 5,
8
+ yellow = 6,
9
+ pink = 7,
10
+ gray = 8,
11
+ primary = 9
12
+ }
13
+ type ColorKey = keyof typeof COLORS;
14
+ type ColorModifiers = Partial<Record<ColorKey, boolean>>;
15
+ declare const PROPS: {
16
+ readonly mar: "margin";
17
+ readonly marH: "marginHorizontal";
18
+ readonly marV: "marginVertical";
19
+ readonly marL: "marginLeft";
20
+ readonly marT: "marginTop";
21
+ readonly marR: "marginRight";
22
+ readonly marB: "marginBottom";
23
+ readonly zIndex: "zIndex";
24
+ readonly opacity: "opacity";
25
+ readonly size: "size";
26
+ };
27
+ export type ShortKey = keyof typeof PROPS;
28
+ export type Convert<T extends string> = Partial<Record<T, boolean | number | string>>;
29
+ export type MakeProp = Convert<ShortKey> & ColorModifiers;
30
+ type Result = {
31
+ size: number;
32
+ color: string;
33
+ name: string;
34
+ style: ViewStyle;
35
+ };
36
+ export declare const makeProps: (props: Record<string, any>) => Result;
37
+ export {};
@@ -1,20 +1,16 @@
1
- import { StyleSheet, ViewStyle } from "react-native";
2
-
3
- enum COLORS {
4
- white = 1,
5
- red,
6
- blue,
7
- black,
8
- green,
9
- yellow,
10
- pink,
11
- gray,
12
- primary,
13
- }
14
-
15
- type ColorKey = keyof typeof COLORS;
16
- type ColorModifiers = Partial<Record<ColorKey, boolean>>;
17
-
1
+ import { StyleSheet } from "react-native";
2
+ var COLORS;
3
+ (function (COLORS) {
4
+ COLORS[COLORS["white"] = 1] = "white";
5
+ COLORS[COLORS["red"] = 2] = "red";
6
+ COLORS[COLORS["blue"] = 3] = "blue";
7
+ COLORS[COLORS["black"] = 4] = "black";
8
+ COLORS[COLORS["green"] = 5] = "green";
9
+ COLORS[COLORS["yellow"] = 6] = "yellow";
10
+ COLORS[COLORS["pink"] = 7] = "pink";
11
+ COLORS[COLORS["gray"] = 8] = "gray";
12
+ COLORS[COLORS["primary"] = 9] = "primary";
13
+ })(COLORS || (COLORS = {}));
18
14
  const PROPS = {
19
15
  mar: "margin",
20
16
  marH: "marginHorizontal",
@@ -26,66 +22,43 @@ const PROPS = {
26
22
  zIndex: "zIndex",
27
23
  opacity: "opacity",
28
24
  size: "size",
29
- } as const;
30
-
31
- export type ShortKey = keyof typeof PROPS;
32
-
33
- export type Convert<T extends string> = Partial<
34
- Record<T, boolean | number | string>
35
- >;
36
-
37
- export type MakeProp = Convert<ShortKey> & ColorModifiers;
38
-
39
- /** type guards */
40
- const isColorKey = (key: string): key is ColorKey => key in COLORS;
41
- const isShortKey = (key: string): key is ShortKey =>
42
- key in PROPS;
43
-
44
- type Result = {
45
- size: number;
46
- color: string;
47
- name: string;
48
- style: ViewStyle;
49
25
  };
50
-
51
- export const makeProps = (props: Record<string, any>): Result => {
52
- const style: ViewStyle = {};
53
-
54
- const res: Omit<Result, "style"> = {
26
+ /** type guards */
27
+ const isColorKey = (key) => key in COLORS;
28
+ const isShortKey = (key) => key in PROPS;
29
+ export const makeProps = (props) => {
30
+ const style = {};
31
+ const res = {
55
32
  size: props.size ?? 23,
56
33
  color: props.color ?? "gray",
57
34
  name: props.name ?? "home",
58
35
  };
59
-
60
36
  Object.keys(props).forEach((key) => {
61
37
  const match = key.match(/^(\w+)-(\w+)$/);
62
-
63
38
  // color modifier
64
39
  if (isColorKey(key)) {
65
40
  res.color = key;
66
41
  return;
67
42
  }
68
-
69
43
  if (match) {
70
44
  const rawKey = match[1];
71
45
  const rawValue = match[2];
72
-
73
46
  const value = isNaN(Number(rawValue))
74
47
  ? rawValue
75
48
  : Number(rawValue);
76
-
77
49
  if (rawKey === "size") {
78
50
  res.size = Number(rawValue);
79
- } else if (rawKey === "color") {
51
+ }
52
+ else if (rawKey === "color") {
80
53
  res.color = rawValue;
81
- } else if (isShortKey(rawKey)) {
82
- (style as any)[PROPS[rawKey]] = value;
54
+ }
55
+ else if (isShortKey(rawKey)) {
56
+ style[PROPS[rawKey]] = value;
83
57
  }
84
58
  }
85
59
  });
86
-
87
60
  return {
88
61
  ...res,
89
62
  style: StyleSheet.create({ style }).style,
90
63
  };
91
- };
64
+ };
@@ -1,32 +0,0 @@
1
- import {
2
- RNVectorIcon,
3
- } from "./index"
4
- import React from 'react'
5
- import {
6
- FlexStyle,
7
- StyleProp,
8
- StyleSheet,
9
- TextProps,
10
- TextStyle,
11
- TouchableOpacity,
12
- ViewProps,
13
- ViewStyle,
14
- } from 'react-native'
15
-
16
- import { isArray, isEmpty, isNumber, isObject, isString } from "underscore";
17
- import { MakeProp } from "./makeProps";
18
- export interface Props extends MakeProp {
19
- name: string
20
- size?: number
21
- type?: keyof typeof RNVectorIcon
22
- onPress?: () => void
23
- styleContainer?: StyleProp<ViewStyle>
24
- style?: StyleProp<TextStyle>
25
- alignSelf?: FlexStyle['alignSelf']
26
- disabled?: boolean
27
- activeOpacity?: number
28
- color?: string
29
-
30
- }
31
-
32
-
@@ -1,102 +0,0 @@
1
- import React from "react";
2
- import { StyleSheet, TouchableOpacity } from "react-native";
3
- import Ionicons from "react-native-vector-icons/Ionicons";
4
- import EvilIcons from "react-native-vector-icons/EvilIcons";
5
- import FontAwesome from "react-native-vector-icons/FontAwesome";
6
- import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
7
- import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
8
- import MaterialIcons from "react-native-vector-icons/MaterialIcons";
9
- import Entypo from "react-native-vector-icons/Entypo";
10
- import AntDesign from "react-native-vector-icons/AntDesign";
11
- import SimpleLineIcons from "react-native-vector-icons/SimpleLineIcons";
12
- import Feather from "react-native-vector-icons/Feather";
13
- import Octicons from "react-native-vector-icons/Octicons";
14
- import Fontisto from "react-native-vector-icons/Fontisto";
15
-
16
- /**
17
- * Collection of React Native Vector Icons
18
- * Provides access to various icon sets from react-native-vector-icons
19
- */
20
- export const RNVectorIcon = {
21
- Ionicons,
22
- AntDesign,
23
- Entypo,
24
- EvilIcons,
25
- MaterialIcons,
26
- MaterialCommunityIcons,
27
- FontAwesome,
28
- FontAwesome5,
29
- SimpleLineIcons,
30
- Feather,
31
- Octicons,
32
- Fontisto,
33
- };
34
-
35
- export type IconType = keyof typeof RNVectorIcon;
36
-
37
- import { Props } from "./PropsStyle";
38
- import { makeProps } from "./makeProps";
39
-
40
- export default class IconApp extends React.PureComponent<Props> {
41
- static defaultProps: Props = {
42
- size: 23,
43
- color: "gray",
44
- name: "home",
45
- };
46
-
47
- res: { color: string; style: any; size: number };
48
-
49
- constructor(props: Props) {
50
- super(props);
51
- this.res = makeProps(props);
52
- }
53
- render() {
54
- const { size, color, style } = this.res;
55
- if (this.props.name === "none") return null;
56
- const IconView = RNVectorIcon[this.props.type || "Ionicons"];
57
- if (typeof this.props.onPress != "function") {
58
- return (
59
- <IconView
60
- size={size}
61
- color={color}
62
- style={style}
63
- name={this.props.name}
64
- onPress={this.props.onPress}
65
- />
66
- );
67
- }
68
- return (
69
- <TouchableOpacity
70
- activeOpacity={this.props.activeOpacity || 0.5}
71
- disabled={
72
- typeof this.props.onPress == "function" ? this.props.disabled : true
73
- }
74
- style={[
75
- styles.container,
76
- { ...(this.props.alignSelf && { alignSelf: this.props.alignSelf }) },
77
- this.props.style,
78
- this.props.styleContainer,
79
- ]}
80
- >
81
- <IconView
82
- size={size}
83
- color={color}
84
- style={style}
85
- name={this.props.name}
86
- onPress={this.props.onPress}
87
- />
88
- </TouchableOpacity>
89
- );
90
- }
91
- }
92
-
93
- /**
94
- * Default styles for the IconApp component
95
- */
96
- const styles = StyleSheet.create({
97
- container: {
98
- alignItems: "center",
99
- justifyContent: "center",
100
- alignSelf: "flex-start",
101
- },
102
- });