rn-floating-input 0.1.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.
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
4
+ import { Pressable, TextInput as RNTextInput, View } from "react-native";
5
+ import Animated, { interpolate, LinearTransition, useAnimatedStyle, useSharedValue, withSequence, withTiming } from "react-native-reanimated";
6
+ import { baseStyles, DEFAULT_ANIMATION, DEFAULT_THEME } from "./defaults";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ export const FloatingInput = /*#__PURE__*/React.forwardRef(({
9
+ value,
10
+ onChangeText,
11
+ onBlur,
12
+ onFocus,
13
+ onPress,
14
+ label,
15
+ placeholder,
16
+ error,
17
+ touched,
18
+ maxLength,
19
+ keyboardType = "default",
20
+ autoFocus = false,
21
+ editable = true,
22
+ autoCapitalize,
23
+ secureTextEntry = false,
24
+ right,
25
+ renderInput,
26
+ theme: themeProp,
27
+ styles: stylesProp,
28
+ style,
29
+ animationConfig: animationProp,
30
+ textInputProps
31
+ }, ref) => {
32
+ const inputRef = useRef(null);
33
+ const [isFocused, setIsFocused] = useState(false);
34
+ const hasError = !!touched && !!error;
35
+ const theme = {
36
+ ...DEFAULT_THEME,
37
+ ...themeProp
38
+ };
39
+ const anim = {
40
+ ...DEFAULT_ANIMATION,
41
+ ...animationProp
42
+ };
43
+ const shouldBeActive = isFocused || !!value;
44
+ const focusAnim = useSharedValue(value ? 1 : 0);
45
+ const shakeAnim = useSharedValue(0);
46
+ useImperativeHandle(ref, () => ({
47
+ focus: () => inputRef.current?.focus(),
48
+ blur: () => inputRef.current?.blur(),
49
+ clear: () => inputRef.current?.clear(),
50
+ isFocused: () => inputRef.current?.isFocused() ?? false
51
+ }));
52
+ useEffect(() => {
53
+ focusAnim.value = withTiming(shouldBeActive ? 1 : 0, {
54
+ duration: anim.labelDuration
55
+ });
56
+ }, [shouldBeActive]);
57
+ useEffect(() => {
58
+ if (!hasError) return;
59
+ const mag = anim.shakeMagnitude;
60
+ const dur = anim.shakeDuration;
61
+ shakeAnim.value = withSequence(withTiming(-mag, {
62
+ duration: dur
63
+ }), withTiming(mag, {
64
+ duration: dur
65
+ }), withTiming(-mag, {
66
+ duration: dur
67
+ }), withTiming(0, {
68
+ duration: dur
69
+ }));
70
+ }, [hasError]);
71
+ const labelAnimatedStyle = useAnimatedStyle(() => ({
72
+ transform: [{
73
+ translateX: shakeAnim.value
74
+ }, {
75
+ translateY: interpolate(focusAnim.value, [0, 1], [0, -anim.labelTranslateY])
76
+ }],
77
+ fontSize: interpolate(focusAnim.value, [0, 1], [theme.fontSize, theme.labelActiveFontSize])
78
+ }));
79
+ function handleFocus() {
80
+ setIsFocused(true);
81
+ onFocus?.();
82
+ }
83
+ function handleBlur() {
84
+ setIsFocused(false);
85
+ onBlur?.();
86
+ }
87
+ function renderTextInput() {
88
+ const inputProps = {
89
+ ref: inputRef,
90
+ editable,
91
+ autoFocus,
92
+ maxLength,
93
+ value,
94
+ placeholder: shouldBeActive ? placeholder : undefined,
95
+ placeholderTextColor: theme.placeholderColor,
96
+ onChangeText,
97
+ onBlur: handleBlur,
98
+ onFocus: handleFocus,
99
+ keyboardType,
100
+ autoCapitalize,
101
+ secureTextEntry,
102
+ selectionColor: theme.selectionColor,
103
+ cursorColor: theme.selectionColor,
104
+ selectionHandleColor: theme.selectionColor,
105
+ underlineColorAndroid: "transparent",
106
+ style: [baseStyles.input, {
107
+ color: theme.inputColor,
108
+ fontFamily: theme.fontFamily,
109
+ fontSize: theme.fontSize
110
+ }, right ? baseStyles.inputWithRight : undefined, stylesProp?.input],
111
+ ...textInputProps
112
+ };
113
+ const inputElement = renderInput ? renderInput(inputProps) : /*#__PURE__*/_jsx(RNTextInput, {
114
+ ...inputProps
115
+ });
116
+ return /*#__PURE__*/_jsxs(View, {
117
+ style: [baseStyles.inputContainer, {
118
+ backgroundColor: theme.backgroundColor,
119
+ borderRadius: theme.borderRadius,
120
+ minHeight: theme.minHeight
121
+ }, style, stylesProp?.inputContainer],
122
+ children: [/*#__PURE__*/_jsxs(View, {
123
+ style: [baseStyles.labelAndInputArea, stylesProp?.labelAndInputArea],
124
+ children: [/*#__PURE__*/_jsx(Animated.Text, {
125
+ style: [baseStyles.label, {
126
+ color: hasError ? theme.errorColor : theme.labelColor,
127
+ fontFamily: theme.fontFamily
128
+ }, labelAnimatedStyle, stylesProp?.label],
129
+ children: label
130
+ }), inputElement]
131
+ }), right && /*#__PURE__*/_jsx(View, {
132
+ style: [baseStyles.rightContainer, stylesProp?.right],
133
+ children: right
134
+ })]
135
+ });
136
+ }
137
+ function renderContent() {
138
+ if (onPress) {
139
+ return /*#__PURE__*/_jsx(Pressable, {
140
+ onPress: onPress,
141
+ children: /*#__PURE__*/_jsx(View, {
142
+ pointerEvents: "none",
143
+ children: renderTextInput()
144
+ })
145
+ });
146
+ }
147
+ return renderTextInput();
148
+ }
149
+ return /*#__PURE__*/_jsxs(Animated.View, {
150
+ layout: LinearTransition.springify(),
151
+ style: [baseStyles.container, stylesProp?.container],
152
+ children: [renderContent(), hasError && /*#__PURE__*/_jsx(Animated.Text, {
153
+ style: [baseStyles.errorText, {
154
+ fontSize: theme.labelActiveFontSize,
155
+ color: theme.errorColor,
156
+ fontFamily: theme.fontFamily
157
+ }, stylesProp?.error],
158
+ children: error
159
+ })]
160
+ });
161
+ });
162
+ FloatingInput.displayName = "FloatingInput";
163
+ //# sourceMappingURL=FloatingInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useImperativeHandle","useRef","useState","Pressable","TextInput","RNTextInput","View","Animated","interpolate","LinearTransition","useAnimatedStyle","useSharedValue","withSequence","withTiming","baseStyles","DEFAULT_ANIMATION","DEFAULT_THEME","jsx","_jsx","jsxs","_jsxs","FloatingInput","forwardRef","value","onChangeText","onBlur","onFocus","onPress","label","placeholder","error","touched","maxLength","keyboardType","autoFocus","editable","autoCapitalize","secureTextEntry","right","renderInput","theme","themeProp","styles","stylesProp","style","animationConfig","animationProp","textInputProps","ref","inputRef","isFocused","setIsFocused","hasError","anim","shouldBeActive","focusAnim","shakeAnim","focus","current","blur","clear","duration","labelDuration","mag","shakeMagnitude","dur","shakeDuration","labelAnimatedStyle","transform","translateX","translateY","labelTranslateY","fontSize","labelActiveFontSize","handleFocus","handleBlur","renderTextInput","inputProps","undefined","placeholderTextColor","placeholderColor","selectionColor","cursorColor","selectionHandleColor","underlineColorAndroid","input","color","inputColor","fontFamily","inputWithRight","inputElement","inputContainer","backgroundColor","borderRadius","minHeight","children","labelAndInputArea","Text","errorColor","labelColor","rightContainer","renderContent","pointerEvents","layout","springify","container","errorText","displayName"],"sourceRoot":"../../src","sources":["FloatingInput.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/E,SAASC,SAAS,EAAEC,SAAS,IAAIC,WAAW,EAAEC,IAAI,QAAQ,cAAc;AACxE,OAAOC,QAAQ,IACbC,WAAW,EACXC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,UAAU,QACL,yBAAyB;AAEhC,SAASC,UAAU,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG1E,OAAO,MAAMC,aAAa,gBAAGvB,KAAK,CAACwB,UAAU,CAI3C,CACE;EACEC,KAAK;EACLC,YAAY;EACZC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,KAAK;EACLC,WAAW;EACXC,KAAK;EACLC,OAAO;EACPC,SAAS;EACTC,YAAY,GAAG,SAAS;EACxBC,SAAS,GAAG,KAAK;EACjBC,QAAQ,GAAG,IAAI;EACfC,cAAc;EACdC,eAAe,GAAG,KAAK;EACvBC,KAAK;EACLC,WAAW;EACXC,KAAK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CAAC4F,SAAS,EACpB;QACElC,QAAQ,EAAEhC,KAAK,CAACiC,mBAAmB;QACnCa,KAAK,EAAE9C,KAAK,CAAC0D,UAAU;QACvBV,UAAU,EAAEhD,KAAK,CAACgD;MACpB,CAAC,EACD7C,UAAU,EAAEb,KAAK,CACjB;MAAAiE,QAAA,EAEDjE;IAAK,CACO,CAChB;EAAA,CACY,CAAC;AAEpB,CACF,CAAC;AAEDT,aAAa,CAACsF,WAAW,GAAG,eAAe","ignoreList":[]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ import { StyleSheet } from 'react-native';
4
+ export const DEFAULT_THEME = {
5
+ backgroundColor: '#EDEFF2',
6
+ labelColor: '#878A99',
7
+ inputColor: '#36373D',
8
+ errorColor: '#E3152E',
9
+ selectionColor: '#31BE30',
10
+ placeholderColor: '#878A99',
11
+ borderRadius: 14,
12
+ minHeight: 56,
13
+ fontSize: 16,
14
+ labelActiveFontSize: 12,
15
+ fontFamily: 'System'
16
+ };
17
+ export const DEFAULT_ANIMATION = {
18
+ labelDuration: 200,
19
+ shakeMagnitude: 2,
20
+ shakeDuration: 50,
21
+ labelTranslateY: 10
22
+ };
23
+ export const baseStyles = StyleSheet.create({
24
+ container: {},
25
+ inputContainer: {
26
+ flexDirection: 'row',
27
+ alignItems: 'center'
28
+ },
29
+ labelAndInputArea: {
30
+ flex: 1,
31
+ justifyContent: 'center'
32
+ },
33
+ label: {
34
+ position: 'absolute',
35
+ left: 16
36
+ },
37
+ input: {
38
+ paddingTop: 24,
39
+ paddingBottom: 8,
40
+ paddingLeft: 16,
41
+ paddingRight: 16
42
+ },
43
+ inputWithRight: {
44
+ paddingRight: 48
45
+ },
46
+ rightContainer: {
47
+ position: 'absolute',
48
+ right: 12,
49
+ alignSelf: 'center'
50
+ },
51
+ errorText: {
52
+ marginLeft: 8,
53
+ marginTop: 6
54
+ }
55
+ });
56
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StyleSheet","DEFAULT_THEME","backgroundColor","labelColor","inputColor","errorColor","selectionColor","placeholderColor","borderRadius","minHeight","fontSize","labelActiveFontSize","fontFamily","DEFAULT_ANIMATION","labelDuration","shakeMagnitude","shakeDuration","labelTranslateY","baseStyles","create","container","inputContainer","flexDirection","alignItems","labelAndInputArea","flex","justifyContent","label","position","left","input","paddingTop","paddingBottom","paddingLeft","paddingRight","inputWithRight","rightContainer","right","alignSelf","errorText","marginLeft","marginTop"],"sourceRoot":"../../src","sources":["defaults.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAIzC,OAAO,MAAMC,aAA2C,GAAG;EACzDC,eAAe,EAAE,SAAS;EAC1BC,UAAU,EAAE,SAAS;EACrBC,UAAU,EAAE,SAAS;EACrBC,UAAU,EAAE,SAAS;EACrBC,cAAc,EAAE,SAAS;EACzBC,gBAAgB,EAAE,SAAS;EAC3BC,YAAY,EAAE,EAAE;EAChBC,SAAS,EAAE,EAAE;EACbC,QAAQ,EAAE,EAAE;EACZC,mBAAmB,EAAE,EAAE;EACvBC,UAAU,EAAE;AACd,CAAC;AAED,OAAO,MAAMC,iBAAyD,GAAG;EACvEC,aAAa,EAAE,GAAG;EAClBC,cAAc,EAAE,CAAC;EACjBC,aAAa,EAAE,EAAE;EACjBC,eAAe,EAAE;AACnB,CAAC;AAED,OAAO,MAAMC,UAAU,GAAGlB,UAAU,CAACmB,MAAM,CAAC;EAC1CC,SAAS,EAAE,CAAC,CAAC;EACbC,cAAc,EAAE;IACdC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd,CAAC;EACDC,iBAAiB,EAAE;IACjBC,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE;EAClB,CAAC;EACDC,KAAK,EAAE;IACLC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE;EACR,CAAC;EACDC,KAAK,EAAE;IACLC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE,CAAC;IAChBC,WAAW,EAAE,EAAE;IACfC,YAAY,EAAE;EAChB,CAAC;EACDC,cAAc,EAAE;IACdD,YAAY,EAAE;EAChB,CAAC;EACDE,cAAc,EAAE;IACdR,QAAQ,EAAE,UAAU;IACpBS,KAAK,EAAE,EAAE;IACTC,SAAS,EAAE;EACb,CAAC;EACDC,SAAS,EAAE;IACTC,UAAU,EAAE,CAAC;IACbC,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { FloatingInput } from './FloatingInput';
4
+ export { DEFAULT_ANIMATION, DEFAULT_THEME } from './defaults';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FloatingInput","DEFAULT_ANIMATION","DEFAULT_THEME"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,YAAY","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { FloatingInputProps, FloatingInputRef } from "./types";
3
+ export declare const FloatingInput: React.ForwardRefExoticComponent<FloatingInputProps & React.RefAttributes<FloatingInputRef>>;
4
+ //# sourceMappingURL=FloatingInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FloatingInput.d.ts","sourceRoot":"","sources":["../../src/FloatingInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAYhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEpE,eAAO,MAAM,aAAa,6FAoNzB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { FloatingInputAnimationConfig, FloatingInputTheme } from './types';
2
+ export declare const DEFAULT_THEME: Required<FloatingInputTheme>;
3
+ export declare const DEFAULT_ANIMATION: Required<FloatingInputAnimationConfig>;
4
+ export declare const baseStyles: {
5
+ container: {};
6
+ inputContainer: {
7
+ flexDirection: "row";
8
+ alignItems: "center";
9
+ };
10
+ labelAndInputArea: {
11
+ flex: number;
12
+ justifyContent: "center";
13
+ };
14
+ label: {
15
+ position: "absolute";
16
+ left: number;
17
+ };
18
+ input: {
19
+ paddingTop: number;
20
+ paddingBottom: number;
21
+ paddingLeft: number;
22
+ paddingRight: number;
23
+ };
24
+ inputWithRight: {
25
+ paddingRight: number;
26
+ };
27
+ rightContainer: {
28
+ position: "absolute";
29
+ right: number;
30
+ alignSelf: "center";
31
+ };
32
+ errorText: {
33
+ marginLeft: number;
34
+ marginTop: number;
35
+ };
36
+ };
37
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE/E,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,kBAAkB,CAYtD,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,4BAA4B,CAKpE,CAAA;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCrB,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { FloatingInput } from './FloatingInput';
2
+ export { DEFAULT_ANIMATION, DEFAULT_THEME } from './defaults';
3
+ export type { FloatingInputAnimationConfig, FloatingInputProps, FloatingInputRef, FloatingInputStyles, FloatingInputTheme, } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC7D,YAAY,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAA"}
@@ -0,0 +1,60 @@
1
+ import type { KeyboardTypeOptions, StyleProp, TextInputProps, TextStyle, ViewStyle } from 'react-native';
2
+ export interface FloatingInputTheme {
3
+ backgroundColor?: string;
4
+ labelColor?: string;
5
+ inputColor?: string;
6
+ errorColor?: string;
7
+ selectionColor?: string;
8
+ placeholderColor?: string;
9
+ borderRadius?: number;
10
+ minHeight?: number;
11
+ fontSize?: number;
12
+ labelActiveFontSize?: number;
13
+ fontFamily?: string;
14
+ }
15
+ export interface FloatingInputStyles {
16
+ container?: StyleProp<ViewStyle>;
17
+ inputContainer?: StyleProp<ViewStyle>;
18
+ labelAndInputArea?: StyleProp<ViewStyle>;
19
+ label?: StyleProp<TextStyle>;
20
+ input?: StyleProp<TextStyle>;
21
+ error?: StyleProp<TextStyle>;
22
+ right?: StyleProp<ViewStyle>;
23
+ }
24
+ export interface FloatingInputAnimationConfig {
25
+ labelDuration?: number;
26
+ shakeMagnitude?: number;
27
+ shakeDuration?: number;
28
+ labelTranslateY?: number;
29
+ }
30
+ export interface FloatingInputRef {
31
+ focus: () => void;
32
+ blur: () => void;
33
+ clear: () => void;
34
+ isFocused: () => boolean;
35
+ }
36
+ export interface FloatingInputProps {
37
+ value?: string;
38
+ onChangeText?: (text: string) => void;
39
+ onBlur?: () => void;
40
+ onFocus?: () => void;
41
+ onPress?: () => void;
42
+ label?: string;
43
+ placeholder?: string;
44
+ error?: string;
45
+ touched?: boolean;
46
+ maxLength?: number;
47
+ keyboardType?: KeyboardTypeOptions;
48
+ autoFocus?: boolean;
49
+ editable?: boolean;
50
+ autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
51
+ secureTextEntry?: boolean;
52
+ right?: React.ReactNode;
53
+ renderInput?: (props: TextInputProps) => React.ReactNode;
54
+ theme?: FloatingInputTheme;
55
+ styles?: FloatingInputStyles;
56
+ style?: StyleProp<ViewStyle>;
57
+ animationConfig?: FloatingInputAnimationConfig;
58
+ textInputProps?: Omit<TextInputProps, 'value' | 'onChangeText' | 'onBlur' | 'onFocus'>;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAA;AAErB,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAChC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,CAAC,EA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IAGxD,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,eAAe,CAAC,EAAE,4BAA4B,CAAA;IAG9C,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAA;CACvF"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "rn-floating-input",
3
+ "version": "0.1.0",
4
+ "description": "A performant floating label TextInput for React Native with animated label, error shake, and full customization",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "!**/__tests__",
14
+ "!**/__fixtures__",
15
+ "!**/__mocks__"
16
+ ],
17
+ "scripts": {
18
+ "build": "bob build",
19
+ "typescript": "tsc --noEmit",
20
+ "prepare": "bob build"
21
+ },
22
+ "keywords": [
23
+ "react-native",
24
+ "floating-label",
25
+ "text-input",
26
+ "animated",
27
+ "reanimated",
28
+ "form"
29
+ ],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/ilhambabayev/react-native-floating-input.git"
33
+ },
34
+ "author": "Ilham Babayev",
35
+ "license": "MIT",
36
+ "peerDependencies": {
37
+ "react": ">=18.0.0",
38
+ "react-native": ">=0.70.0",
39
+ "react-native-reanimated": ">=3.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/react": "~19.1.0",
43
+ "react": "19.1.0",
44
+ "react-native": "0.81.5",
45
+ "react-native-builder-bob": "^0.35.0",
46
+ "react-native-reanimated": "~4.1.1",
47
+ "typescript": "~5.9.2"
48
+ },
49
+ "react-native-builder-bob": {
50
+ "source": "src",
51
+ "output": "lib",
52
+ "targets": [
53
+ "commonjs",
54
+ "module",
55
+ [
56
+ "typescript",
57
+ {
58
+ "project": "tsconfig.build.json"
59
+ }
60
+ ]
61
+ ]
62
+ },
63
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
64
+ }