react-native-controlled-input 0.2.0 → 0.6.0

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.
@@ -46,6 +46,7 @@ class ControlledInputViewManager : SimpleViewManager<ControlledInputView>(),
46
46
  InputStyle(
47
47
  color = if (inputStyle.hasKey("color")) inputStyle.getString("color") else null,
48
48
  fontSize = if (inputStyle.hasKey("fontSize")) inputStyle.getDouble("fontSize") else null,
49
+ fontFamily = if (inputStyle.hasKey("fontFamily")) inputStyle.getString("fontFamily") else null,
49
50
  height = if (inputStyle.hasKey("height")) inputStyle.getDouble("height") else null,
50
51
  paddingTop = if (inputStyle.hasKey("paddingTop")) inputStyle.getDouble("paddingTop") else null,
51
52
  paddingBottom = if (inputStyle.hasKey("paddingBottom")) inputStyle.getDouble("paddingBottom") else null,
@@ -24,8 +24,11 @@ import androidx.compose.runtime.remember
24
24
  import androidx.compose.ui.Modifier
25
25
  import androidx.compose.ui.focus.FocusRequester
26
26
  import androidx.compose.ui.focus.focusRequester
27
+ import android.graphics.Typeface
27
28
  import androidx.compose.ui.graphics.Color
29
+ import androidx.compose.ui.platform.LocalContext
28
30
  import androidx.compose.ui.text.TextStyle
31
+ import androidx.compose.ui.text.font.FontFamily
29
32
  import androidx.compose.ui.unit.dp
30
33
  import androidx.compose.ui.unit.sp
31
34
  import androidx.lifecycle.ViewModel
@@ -38,6 +41,7 @@ import kotlinx.coroutines.flow.StateFlow
38
41
  data class InputStyle(
39
42
  val color: String? = null,
40
43
  val fontSize: Double? = null,
44
+ val fontFamily: String? = null,
41
45
  val height: Double? = null,
42
46
  val paddingTop: Double? = null,
43
47
  val paddingBottom: Double? = null,
@@ -78,8 +82,20 @@ fun JetpackComposeView(
78
82
  }
79
83
  }
80
84
 
85
+ val context = LocalContext.current
81
86
  val textColor = style?.color?.let { Color(android.graphics.Color.parseColor(it)) } ?: Color.White
82
87
  val fontSize = style?.fontSize?.let { it.sp } ?: 24.sp
88
+ val fontFamily = remember(style?.fontFamily) {
89
+ style?.fontFamily?.let { name ->
90
+ try {
91
+ val typeface = com.facebook.react.views.text.ReactFontManager.getInstance()
92
+ .getTypeface(name, Typeface.NORMAL, context.assets)
93
+ typeface?.let { FontFamily(it) }
94
+ } catch (_: Exception) {
95
+ null
96
+ }
97
+ }
98
+ }
83
99
  val height = style?.height?.let { it.dp }
84
100
  val paddingValues = PaddingValues(
85
101
  start = style?.paddingLeft?.dp ?: 0.dp,
@@ -111,6 +127,7 @@ fun JetpackComposeView(
111
127
  textStyle = TextStyle(
112
128
  color = textColor,
113
129
  fontSize = fontSize,
130
+ fontFamily = fontFamily,
114
131
  ),
115
132
  interactionSource = interactionSource,
116
133
  )
@@ -62,6 +62,10 @@ using namespace facebook::react;
62
62
  _inputView.fontSize = style.fontSize;
63
63
  }
64
64
 
65
+ if (oldStyle.fontFamily != style.fontFamily) {
66
+ _inputView.fontFamily = style.fontFamily.empty() ? nil : [NSString stringWithUTF8String:style.fontFamily.c_str()];
67
+ }
68
+
65
69
  if (oldStyle.height != style.height) {
66
70
  _inputView.inputHeight = style.height;
67
71
  }
@@ -11,6 +11,7 @@ public class RNControlledInput: UIView {
11
11
 
12
12
  @objc public var textColor: UIColor?
13
13
  @objc public var fontSize: CGFloat = 16
14
+ @objc public var fontFamily: String?
14
15
  @objc public var inputHeight: CGFloat = 0
15
16
  @objc public var padding: UIEdgeInsets = .zero
16
17
  @objc public var borderWidth: CGFloat = 0
@@ -25,6 +25,7 @@ interface BlurEvent {
25
25
  interface InputStyle {
26
26
  color?: ColorValue;
27
27
  fontSize?: Double;
28
+ fontFamily?: string;
28
29
  height?: Double;
29
30
  paddingTop?: Double;
30
31
  paddingBottom?: Double;
@@ -1 +1 @@
1
- {"version":3,"names":["forwardRef","useImperativeHandle","useRef","Platform","ControlledInputViewNativeComponent","Commands","jsx","_jsx","ControlledInputView","props","ref","nativeRef","blur","current","OS","console","log","focus"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,mBAAmB,EACnBC,MAAM,QAGD,OAAO;AACd,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,kCAAkC,IACvCC,QAAQ,QACH,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS9C,OAAO,MAAMC,mBAAmB,gBAAGR,UAAU,CAG3C,CAACS,KAAK,EAAEC,GAAG,KAAK;EAChB,MAAMC,SAAS,GACbT,MAAM,CAAwD,IAAI,CAAC;EAErED,mBAAmB,CAACS,GAAG,EAAE,OAAO;IAC9BE,IAAI,EAAEA,CAAA,KAAM;MACV,IAAI,CAACD,SAAS,CAACE,OAAO,EAAE;QACtB;MACF;MAEA,IAAIV,QAAQ,CAACW,EAAE,KAAK,KAAK,IAAIX,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;QACtDC,OAAO,CAACC,GAAG,CACT,yBAAyBb,QAAQ,CAACW,EAAE,yBACtC,CAAC;QACDT,QAAQ,CAACO,IAAI,CAACD,SAAS,CAACE,OAAO,CAAC;MAClC;IACF,CAAC;IACDI,KAAK,EAAEA,CAAA,KAAM;MACX,IAAI,CAACN,SAAS,CAACE,OAAO,EAAE;QACtB;MACF;MAEA,IAAIV,QAAQ,CAACW,EAAE,KAAK,KAAK,IAAIX,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;QACtDC,OAAO,CAACC,GAAG,CACT,yBAAyBb,QAAQ,CAACW,EAAE,0BACtC,CAAC;QACDT,QAAQ,CAACY,KAAK,CAACN,SAAS,CAACE,OAAO,CAAC;MACnC;IACF;EACF,CAAC,CAAC,CAAC;EAEH,oBACEN,IAAA,CAACH,kCAAkC;IAAA,GAAKK,KAAK;IAAEC,GAAG,EAAEC;EAAiB,CAAE,CAAC;AAE5E,CAAC,CAAC;AAEF,cAAc,sCAAsC","ignoreList":[]}
1
+ {"version":3,"names":["forwardRef","useImperativeHandle","useRef","Platform","ControlledInputViewNativeComponent","Commands","jsx","_jsx","ControlledInputView","props","ref","nativeRef","blur","current","OS","console","log","focus"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,mBAAmB,EACnBC,MAAM,QAED,OAAO;AACd,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,kCAAkC,IACvCC,QAAQ,QAEH,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO9C,OAAO,MAAMC,mBAAmB,gBAAGR,UAAU,CAG3C,CAACS,KAAK,EAAEC,GAAG,KAAK;EAChB,MAAMC,SAAS,GACbT,MAAM,CAAwD,IAAI,CAAC;EAErED,mBAAmB,CAACS,GAAG,EAAE,OAAO;IAC9BE,IAAI,EAAEA,CAAA,KAAM;MACV,IAAI,CAACD,SAAS,CAACE,OAAO,EAAE;QACtB;MACF;MAEA,IAAIV,QAAQ,CAACW,EAAE,KAAK,KAAK,IAAIX,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;QACtDC,OAAO,CAACC,GAAG,CACT,yBAAyBb,QAAQ,CAACW,EAAE,yBACtC,CAAC;QACDT,QAAQ,CAACO,IAAI,CAACD,SAAS,CAACE,OAAO,CAAC;MAClC;IACF,CAAC;IACDI,KAAK,EAAEA,CAAA,KAAM;MACX,IAAI,CAACN,SAAS,CAACE,OAAO,EAAE;QACtB;MACF;MAEA,IAAIV,QAAQ,CAACW,EAAE,KAAK,KAAK,IAAIX,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;QACtDC,OAAO,CAACC,GAAG,CACT,yBAAyBb,QAAQ,CAACW,EAAE,0BACtC,CAAC;QACDT,QAAQ,CAACY,KAAK,CAACN,SAAS,CAACE,OAAO,CAAC;MACnC;IACF;EACF,CAAC,CAAC,CAAC;EAEH,oBACEN,IAAA,CAACH,kCAAkC;IAAA,GAAKK,KAAK;IAAEC,GAAG,EAAEC;EAAiB,CAAE,CAAC;AAE5E,CAAC,CAAC;AAEF,cAAc,sCAAsC","ignoreList":[]}
@@ -10,6 +10,7 @@ interface BlurEvent {
10
10
  interface InputStyle {
11
11
  color?: ColorValue;
12
12
  fontSize?: Double;
13
+ fontFamily?: string;
13
14
  height?: Double;
14
15
  paddingTop?: Double;
15
16
  paddingBottom?: Double;
@@ -1 +1 @@
1
- {"version":3,"file":"ControlledInputViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ControlledInputViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,oBAAoB,EACpB,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,UAAU;CAEnB;AAED,UAAU,SAAS;CAElB;AAED,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,CAAC;IACvE,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,CAAC;CACvE;AAED,eAAO,MAAM,QAAQ,EAAE,cAErB,CAAC;;AAEH,wBAA0E"}
1
+ {"version":3,"file":"ControlledInputViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ControlledInputViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,oBAAoB,EACpB,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,UAAU;CAEnB;AAED,UAAU,SAAS;CAElB;AAED,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,CAAC;IACvE,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,CAAC;CACvE;AAED,eAAO,MAAM,QAAQ,EAAE,cAErB,CAAC;;AAEH,wBAA0E"}
@@ -1,9 +1,8 @@
1
+ import { type NativeProps } from './ControlledInputViewNativeComponent';
1
2
  export interface ControlledInputViewRef {
2
3
  blur: () => void;
3
4
  focus: () => void;
4
5
  }
5
- export declare const ControlledInputView: import("react").ForwardRefExoticComponent<Omit<Omit<import("./ControlledInputViewNativeComponent").NativeProps, "ref"> & {
6
- ref?: React.Ref<import("react-native").HostInstance>;
7
- }, "ref"> & import("react").RefAttributes<ControlledInputViewRef>>;
6
+ export declare const ControlledInputView: import("react").ForwardRefExoticComponent<NativeProps & import("react").RefAttributes<ControlledInputViewRef>>;
8
7
  export * from './ControlledInputViewNativeComponent';
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAcA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB;;kEAqC9B,CAAC;AAEH,cAAc,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAOA,OAA2C,EAEzC,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAE9C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,gHAqC9B,CAAC;AAEH,cAAc,sCAAsC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-controlled-input",
3
- "version": "0.2.0",
3
+ "version": "0.6.0",
4
4
  "description": "React Native Controlled Inputative Controlled Input",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -25,6 +25,7 @@ interface BlurEvent {
25
25
  interface InputStyle {
26
26
  color?: ColorValue;
27
27
  fontSize?: Double;
28
+ fontFamily?: string;
28
29
  height?: Double;
29
30
  paddingTop?: Double;
30
31
  paddingBottom?: Double;
package/src/index.tsx CHANGED
@@ -2,16 +2,14 @@ import {
2
2
  forwardRef,
3
3
  useImperativeHandle,
4
4
  useRef,
5
- type ComponentProps,
6
5
  type ElementRef,
7
6
  } from 'react';
8
7
  import { Platform } from 'react-native';
9
8
  import ControlledInputViewNativeComponent, {
10
9
  Commands,
10
+ type NativeProps,
11
11
  } from './ControlledInputViewNativeComponent';
12
12
 
13
- type NativeProps = ComponentProps<typeof ControlledInputViewNativeComponent>;
14
-
15
13
  export interface ControlledInputViewRef {
16
14
  blur: () => void;
17
15
  focus: () => void;