react-native-boxes 1.0.9 → 1.0.10

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/dist/I18n.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export type I18n = {
2
+ t: (id?: string) => string | undefined;
3
+ };
4
+ export declare const _i18n: I18n;
package/dist/I18n.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._i18n = void 0;
4
+ exports._i18n = {
5
+ t: (id) => id
6
+ };
7
+ //# sourceMappingURL=I18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"I18n.js","sourceRoot":"","sources":["../src/I18n.ts"],"names":[],"mappings":";;;AAIa,QAAA,KAAK,GAAS;IACvB,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE;CAChB,CAAA"}
package/dist/Text.js CHANGED
@@ -6,11 +6,19 @@ const react_native_1 = require("react-native");
6
6
  const ThemeContext_1 = require("./ThemeContext");
7
7
  function TextView(props) {
8
8
  const theme = (0, react_1.useContext)(ThemeContext_1.ThemeContext);
9
+ let children = props.children;
10
+ if (theme.i18n) {
11
+ if (children && typeof children == 'string') {
12
+ children = theme.i18n.t(children);
13
+ }
14
+ }
9
15
  return (<react_native_1.Text {...props} style={[{
10
16
  flexWrap: 'wrap',
11
17
  color: theme.colors.text,
12
18
  padding: theme.dimens.space.sm
13
- }, theme.styles.text, props.style]}/>);
19
+ }, theme.styles.text, props.style]}>
20
+ {children}
21
+ </react_native_1.Text>);
14
22
  }
15
23
  exports.TextView = TextView;
16
24
  function Subtitle(props) {
package/dist/Text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,+CAA+C;AAC/C,iDAA8C;AAE9C,SAAgB,QAAQ,CAAC,KAAgB;IACrC,MAAM,KAAK,GAAG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AO,CACH,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB;gBACI,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBAC9B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;aAC3B;YACD,KAAK,CAAC,KAAK;SACd,CAAC,EAAG,CACR,CAAA;AACL,CAAC;AAXD,4BAWC;AAGD,SAAgB,KAAK,CAAC,KAAgB;IAClC,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,2BAAY,CAAC,CAAA;IACtC,OAAO,CACH,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB;gBACI,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBAC9B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;aAC9B;YACD,KAAK,CAAC,KAAK;SACd,CAAC,EAAG,CACR,CAAA;AACL,CAAC;AAXD,sBAWC;AAED,SAAgB,OAAO,CAAC,KAAgB;IACpC,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,2BAAY,CAAC,CAAA;IACtC,OAAO,CACH,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB;gBACI,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBAC9B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;aAC9B;YACD,KAAK,CAAC,KAAK;SACd,CAAC,EAAG,CACR,CAAA;AACL,CAAC;AAXD,0BAWC"}
@@ -1,5 +1,6 @@
1
1
  import { Colors, Dimens, Fonts } from "./Styles";
2
2
  import { randomColor } from "./utils";
3
+ import { I18n } from "./I18n";
3
4
  declare const DEFAULT_STYLE: {
4
5
  container: {
5
6
  marginTop: number;
@@ -24,6 +25,7 @@ export declare class Theme {
24
25
  dimens: typeof Dimens;
25
26
  colors: typeof Colors;
26
27
  fonts: typeof Fonts;
28
+ i18n: I18n;
27
29
  randomColor: typeof randomColor;
28
30
  constructor(appname?: string, colors?: {
29
31
  accent: string;
@@ -87,7 +89,7 @@ export declare class Theme {
87
89
  fontFamily: string;
88
90
  fontSize: number;
89
91
  };
90
- });
92
+ }, i18n?: I18n);
91
93
  }
92
94
  export declare const ThemeContext: import("react").Context<Theme>;
93
95
  export {};
@@ -4,6 +4,7 @@ exports.ThemeContext = exports.Theme = void 0;
4
4
  const react_1 = require("react");
5
5
  const Styles_1 = require("./Styles");
6
6
  const utils_1 = require("./utils");
7
+ const I18n_1 = require("./I18n");
7
8
  const DEFAULT_STYLE = (0, Styles_1.createStyle)(Styles_1.Dimens, Styles_1.Colors, Styles_1.Fonts);
8
9
  class Theme {
9
10
  appname = '';
@@ -11,14 +12,16 @@ class Theme {
11
12
  dimens;
12
13
  colors;
13
14
  fonts;
15
+ i18n;
14
16
  randomColor = utils_1.randomColor;
15
- constructor(appname = '', colors = Styles_1.Colors, dimens = Styles_1.Dimens, fonts = Styles_1.Fonts, styles = DEFAULT_STYLE) {
17
+ constructor(appname = '', colors = Styles_1.Colors, dimens = Styles_1.Dimens, fonts = Styles_1.Fonts, styles = DEFAULT_STYLE, i18n = I18n_1._i18n) {
16
18
  this.appname = appname;
17
19
  this.fonts = fonts ?? Styles_1.Fonts;
18
20
  this.colors = colors ?? Styles_1.Colors;
19
21
  this.dimens = dimens ?? Styles_1.Dimens;
20
22
  this.fonts = fonts ?? Styles_1.Fonts;
21
23
  this.styles = styles ?? (0, Styles_1.createStyle)(this.dimens, this.colors, this.fonts);
24
+ this.i18n = i18n;
22
25
  }
23
26
  }
24
27
  exports.Theme = Theme;
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeContext.js","sourceRoot":"","sources":["../src/ThemeContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AACrC,qCAAsF;AACtF,mCAAqC;AACrC,MAAM,aAAa,GAAG,IAAA,oBAAW,EAAC,eA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O,GAAG,EAAE,EACpB,MAAM,GAAG,eAAM,EACf,MAAM,GAAG,eAAM,EACf,KAAK,GAAG,cAAK,EACb,MAAM,GAAG,aAAa,EACtB,IAAI,GAAG,YAAK;QACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,cAAK,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,eAAM,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,eAAM,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,cAAK,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QACzE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;CACJ;AAtBD,sBAsBC;AACY,QAAA,YAAY,GAAG,IAAA,qBAAa,EAAC,IAAI,KAAK,EAAE,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './utils';
9
9
  export * from './Styles';
10
10
  export * from './demo';
11
11
  export * from './ThemeContext';
12
+ export * from './I18n';
package/dist/index.js CHANGED
@@ -25,4 +25,5 @@ __exportStar(require("./utils"), exports);
25
25
  __exportStar(require("./Styles"), exports);
26
26
  __exportStar(require("./demo"), exports);
27
27
  __exportStar(require("./ThemeContext"), exports);
28
+ __exportStar(require("./I18n"), exports);
28
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,0CAAwB;AACxB,wCAAsB;AACtB,0CAAwB;AACxB,2CAAyB;AACzB,yCAAuB;AACvB,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,0CAAwB;AACxB,wCAAsB;AACtB,0CAAwB;AACxB,2CAAyB;AACzB,yCAAuB;AACvB,iDAA+B;AAC/B,yCAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-boxes",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "A react native library for rapid development of UI using boxes",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/I18n.ts ADDED
@@ -0,0 +1,7 @@
1
+ export type I18n = {
2
+ t: (id?: string) => string | undefined
3
+ }
4
+
5
+ export const _i18n: I18n = {
6
+ t: (id) => id
7
+ }
package/src/Text.tsx CHANGED
@@ -4,13 +4,21 @@ import { ThemeContext } from "./ThemeContext";
4
4
 
5
5
  export function TextView(props: TextProps) {
6
6
  const theme = useContext(ThemeContext)
7
+ let children = props.children
8
+ if (theme.i18n) {
9
+ if (children && typeof children == 'string') {
10
+ children = theme.i18n.t(children)
11
+ }
12
+ }
7
13
  return (
8
14
  <Text {...props}
9
15
  style={[{
10
16
  flexWrap: 'wrap',
11
17
  color: theme.colors.text,
12
18
  padding: theme.dimens.space.sm
13
- }, theme.styles.text, props.style]} />
19
+ }, theme.styles.text, props.style]} >
20
+ {children}
21
+ </Text>
14
22
  )
15
23
  }
16
24
 
@@ -1,6 +1,7 @@
1
1
  import { createContext } from "react"
2
2
  import { Colors, Dimens, createStyle, DarkColors, LightColors, Fonts } from "./Styles"
3
3
  import { randomColor } from "./utils"
4
+ import { I18n, _i18n } from "./I18n"
4
5
  const DEFAULT_STYLE = createStyle(Dimens, Colors, Fonts)
5
6
  export class Theme {
6
7
  appname: string = ''
@@ -8,18 +9,21 @@ export class Theme {
8
9
  dimens: typeof Dimens
9
10
  colors: typeof Colors
10
11
  fonts: typeof Fonts
12
+ i18n: I18n
11
13
  randomColor = randomColor
12
14
  constructor(appname = '',
13
15
  colors = Colors,
14
16
  dimens = Dimens,
15
17
  fonts = Fonts,
16
- styles = DEFAULT_STYLE) {
18
+ styles = DEFAULT_STYLE,
19
+ i18n = _i18n) {
17
20
  this.appname = appname
18
21
  this.fonts = fonts ?? Fonts
19
22
  this.colors = colors ?? Colors
20
23
  this.dimens = dimens ?? Dimens
21
24
  this.fonts = fonts ?? Fonts
22
25
  this.styles = styles ?? createStyle(this.dimens, this.colors, this.fonts)
26
+ this.i18n = i18n
23
27
  }
24
28
  }
25
29
  export const ThemeContext = createContext(new Theme())
package/src/index.tsx CHANGED
@@ -9,3 +9,4 @@ export * from './utils';
9
9
  export * from './Styles';
10
10
  export * from './demo';
11
11
  export * from './ThemeContext';
12
+ export * from './I18n'