@codeleap/mobile 4.2.14 → 4.2.16
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/components/SearchInput/index.d.ts +5 -3
- package/dist/components/SearchInput/index.js +7 -6
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/TextInput/types.d.ts +3 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +5 -5
- package/package.json.bak +1 -1
- package/src/components/SearchInput/index.tsx +11 -6
- package/src/components/TextInput/types.ts +2 -1
- package/src/types/index.ts +1 -1
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { AppIcon } from '@codeleap/styles';
|
|
2
|
-
import {
|
|
2
|
+
import { ForwardRefComponentWithDefaultProps } from '../../types';
|
|
3
3
|
import { TextInputProps } from '../TextInput';
|
|
4
|
+
import { TextInput as RNTextInput } from 'react-native';
|
|
4
5
|
export type SearchInputProps = {
|
|
5
6
|
onTypingChange: (isTyping: boolean) => void;
|
|
6
7
|
onSearchChange: (search: string) => void;
|
|
7
8
|
onValueChange?: (search: string) => void;
|
|
8
9
|
onClear?: () => void;
|
|
10
|
+
showClear?: (search: string) => boolean;
|
|
9
11
|
debugName: string;
|
|
10
12
|
debounce?: number;
|
|
11
13
|
clearIcon?: AppIcon;
|
|
12
14
|
searchIcon?: AppIcon;
|
|
13
|
-
placeholder
|
|
15
|
+
placeholder?: string;
|
|
14
16
|
} & Partial<TextInputProps>;
|
|
15
|
-
export declare const SearchInput:
|
|
17
|
+
export declare const SearchInput: ForwardRefComponentWithDefaultProps<SearchInputProps, RNTextInput>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useState } from 'react';
|
|
2
2
|
import { TextInput } from '../TextInput';
|
|
3
3
|
import { TypeGuards } from '@codeleap/common';
|
|
4
|
-
export const SearchInput = (props) => {
|
|
5
|
-
const { debugName, onClear, onSearchChange, onTypingChange, clearIcon, searchIcon, debounce, placeholder, value, onValueChange, ...others } = {
|
|
4
|
+
export const SearchInput = forwardRef((props, ref) => {
|
|
5
|
+
const { debugName, onClear, onSearchChange, onTypingChange, clearIcon, searchIcon, debounce, placeholder, value, onValueChange, showClear, ...others } = {
|
|
6
6
|
...SearchInput.defaultProps,
|
|
7
7
|
...props,
|
|
8
8
|
};
|
|
@@ -31,16 +31,17 @@ export const SearchInput = (props) => {
|
|
|
31
31
|
return (<TextInput value={search} onChangeText={(value) => {
|
|
32
32
|
onTypingChange?.(true);
|
|
33
33
|
handleChangeSearch(value);
|
|
34
|
-
}} placeholder={placeholder} debugName={`Search ${debugName}`} rightIcon={
|
|
34
|
+
}} placeholder={placeholder} debugName={`Search ${debugName}`} rightIcon={(showClear?.(search) ?? true) && {
|
|
35
35
|
name: clearIcon,
|
|
36
36
|
onPress: handleClear,
|
|
37
37
|
}} leftIcon={{
|
|
38
38
|
name: searchIcon,
|
|
39
|
-
}} {...others}/>);
|
|
40
|
-
};
|
|
39
|
+
}} ref={ref} {...others}/>);
|
|
40
|
+
});
|
|
41
41
|
SearchInput.defaultProps = {
|
|
42
42
|
debounce: null,
|
|
43
43
|
clearIcon: 'x',
|
|
44
44
|
searchIcon: 'search',
|
|
45
|
+
showClear: (s) => !!s?.trim?.()
|
|
45
46
|
};
|
|
46
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SearchInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SearchInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGnD,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EA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AAC,CAAA;QACpB,OAAO,EAAE,EAAE,CAAA;IACb,CAAC,CAAA;IAED,OAAO,CACL,CAAC,SAAS,CACR,KAAK,CAAC,CAAC,MAAM,CAAC,CACd,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACtB,cAAc,EAAE,CAAC,IAAI,CAAC,CAAA;YACtB,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,SAAS,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC,CACjC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI;YAC1C,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,WAAW;SACrB,CAAC,CACF,QAAQ,CAAC,CAAC;YACR,IAAI,EAAE,UAAU;SACjB,CAAC,CACF,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,IAAI,MAAM,CAAC,EACX,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,WAAW,CAAC,YAAY,GAAG;IACzB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,GAAc;IACzB,UAAU,EAAE,QAAmB;IAC/B,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;CACH,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { InputBaseProps } from '../InputBase';
|
|
2
|
-
import { TextInputProps as RNTextInputProps } from 'react-native';
|
|
3
|
+
import { TextInputProps as RNTextInputProps, TextInput as RNTextInput } from 'react-native';
|
|
3
4
|
import { AnyFunction, FormTypes, yup } from '@codeleap/common';
|
|
4
5
|
import { AppIcon, StyledProp } from '@codeleap/styles';
|
|
5
6
|
import { TextInputMaskProps } from '../../modules/textInputMask';
|
|
@@ -18,4 +19,5 @@ export type TextInputProps = Omit<InputBaseProps, 'style'> & Omit<RNTextInputPro
|
|
|
18
19
|
_error?: string;
|
|
19
20
|
onPress?: AnyFunction;
|
|
20
21
|
style?: StyledProp<TextInputComposition>;
|
|
22
|
+
ref?: React.Ref<RNTextInput>;
|
|
21
23
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export type ComponentWithDefaultProps<P = any> = ((props: P) => JSX.Element) & {
|
|
|
4
4
|
defaultProps: Partial<P>;
|
|
5
5
|
};
|
|
6
6
|
export type ForwardRefComponentWithDefaultProps<P = any, R = any> = ((props: P, ref: R) => JSX.Element) & {
|
|
7
|
-
defaultProps
|
|
7
|
+
defaultProps?: Partial<P>;
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/mobile",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.16",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"directory": "packages/mobile"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@codeleap/common": "4.2.
|
|
13
|
-
"@codeleap/config": "4.2.
|
|
12
|
+
"@codeleap/common": "4.2.16",
|
|
13
|
+
"@codeleap/config": "4.2.16"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsc --build",
|
|
17
17
|
"lint": "eslint -c .eslintrc.js --fix \"./src/**/*.{ts,tsx,js,jsx}\""
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@codeleap/common": "4.2.
|
|
21
|
-
"@codeleap/styles": "4.2.
|
|
20
|
+
"@codeleap/common": "4.2.16",
|
|
21
|
+
"@codeleap/styles": "4.2.16",
|
|
22
22
|
"@d11/react-native-fast-image": "8.8.0",
|
|
23
23
|
"@react-native-firebase/messaging": "21.4.0",
|
|
24
24
|
"@react-navigation/bottom-tabs": "6.5.3",
|
package/package.json.bak
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { forwardRef, useState } from 'react'
|
|
2
2
|
import { AppIcon } from '@codeleap/styles'
|
|
3
|
-
import { ComponentWithDefaultProps } from '../../types'
|
|
3
|
+
import { ComponentWithDefaultProps, ForwardRefComponentWithDefaultProps } from '../../types'
|
|
4
4
|
import { TextInputProps, TextInput } from '../TextInput'
|
|
5
5
|
import { TypeGuards } from '@codeleap/common'
|
|
6
|
+
import { TextInput as RNTextInput } from 'react-native'
|
|
6
7
|
|
|
7
8
|
export type SearchInputProps = {
|
|
8
9
|
onTypingChange: (isTyping: boolean) => void
|
|
9
10
|
onSearchChange: (search: string) => void
|
|
10
11
|
onValueChange?: (search: string) => void
|
|
11
12
|
onClear?: () => void
|
|
13
|
+
showClear?: (search: string) => boolean
|
|
12
14
|
debugName: string
|
|
13
15
|
debounce?: number
|
|
14
16
|
clearIcon?: AppIcon
|
|
15
17
|
searchIcon?: AppIcon
|
|
16
|
-
placeholder
|
|
18
|
+
placeholder?: string
|
|
17
19
|
} & Partial<TextInputProps>
|
|
18
20
|
|
|
19
|
-
export const SearchInput:
|
|
21
|
+
export const SearchInput: ForwardRefComponentWithDefaultProps<SearchInputProps, RNTextInput> = forwardRef((props, ref) => {
|
|
20
22
|
const {
|
|
21
23
|
debugName,
|
|
22
24
|
onClear,
|
|
@@ -28,6 +30,7 @@ export const SearchInput: ComponentWithDefaultProps<SearchInputProps> = (props)
|
|
|
28
30
|
placeholder,
|
|
29
31
|
value,
|
|
30
32
|
onValueChange,
|
|
33
|
+
showClear,
|
|
31
34
|
...others
|
|
32
35
|
} = {
|
|
33
36
|
...SearchInput.defaultProps,
|
|
@@ -71,20 +74,22 @@ export const SearchInput: ComponentWithDefaultProps<SearchInputProps> = (props)
|
|
|
71
74
|
}}
|
|
72
75
|
placeholder={placeholder}
|
|
73
76
|
debugName={`Search ${debugName}`}
|
|
74
|
-
rightIcon={
|
|
77
|
+
rightIcon={(showClear?.(search) ?? true) && {
|
|
75
78
|
name: clearIcon,
|
|
76
79
|
onPress: handleClear,
|
|
77
80
|
}}
|
|
78
81
|
leftIcon={{
|
|
79
82
|
name: searchIcon,
|
|
80
83
|
}}
|
|
84
|
+
ref={ref}
|
|
81
85
|
{...others}
|
|
82
86
|
/>
|
|
83
87
|
)
|
|
84
|
-
}
|
|
88
|
+
})
|
|
85
89
|
|
|
86
90
|
SearchInput.defaultProps = {
|
|
87
91
|
debounce: null,
|
|
88
92
|
clearIcon: 'x' as AppIcon,
|
|
89
93
|
searchIcon: 'search' as AppIcon,
|
|
94
|
+
showClear: (s) => !!s?.trim?.()
|
|
90
95
|
} as Partial<SearchInputProps>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InputBaseProps } from '../InputBase'
|
|
2
|
-
import { TextInputProps as RNTextInputProps } from 'react-native'
|
|
2
|
+
import { TextInputProps as RNTextInputProps, TextInput as RNTextInput } from 'react-native'
|
|
3
3
|
import { AnyFunction, FormTypes, yup } from '@codeleap/common'
|
|
4
4
|
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
5
5
|
import { TextInputMaskProps } from '../../modules/textInputMask'
|
|
@@ -22,4 +22,5 @@ export type TextInputProps =
|
|
|
22
22
|
_error?: string
|
|
23
23
|
onPress?: AnyFunction
|
|
24
24
|
style?: StyledProp<TextInputComposition>
|
|
25
|
+
ref?: React.Ref<RNTextInput>
|
|
25
26
|
}
|
package/src/types/index.ts
CHANGED