Skip to content

Commit 1d38bba

Browse files
committed
feat: input uses accepts focused props from theme and type
1 parent 189fe57 commit 1d38bba

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

packages/react-native-ficus-ui/src/components/input/input.service.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,27 @@ export function useInput(
3636
[isDisabled, isLoading, isFocused, styles, colorMode]
3737
);
3838

39-
const inputContainerStyles = useMemo(
40-
() => ({
39+
const themeFocused = styles?._focused;
40+
const propFocused = props._focused;
41+
42+
const inputContainerStyles = useMemo(() => {
43+
let base = {
4144
flexDirection: 'row',
4245
alignItems: 'center',
4346
justifyContent: 'space-between',
4447
...stateStyles,
45-
}),
46-
[stateStyles]
47-
);
48+
};
49+
50+
if (isFocused) {
51+
base = {
52+
...base,
53+
...(themeFocused || {}),
54+
...(propFocused || {}),
55+
};
56+
}
57+
58+
return base;
59+
}, [stateStyles, isFocused, themeFocused, propFocused]);
4860

4961
const inputStyles = useMemo(
5062
() => ({

packages/react-native-ficus-ui/src/style-system/pseudos.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ export const pseudoStylesMap = {
1414
* Represents the valid pseudo-class keys derived from `pseudoStylesMap`.
1515
*/
1616
export type PseudoStyleKey = keyof typeof pseudoStylesMap;
17+
18+
export type StateStyles<T = any> = Partial<Record<PseudoStyleKey, T>>;

packages/react-native-ficus-ui/src/style-system/system.types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
SpaceProps,
1212
} from './config';
1313
import { CommonProps } from './config/common';
14-
import { PseudoStyleKey } from './pseudos';
14+
import { PseudoStyleKey, StateStyles } from './pseudos';
1515
import { RNStyleSheet, RNStyleSheetProperties } from './utils/prop-config';
1616
import { Dict, ResponsiveValue } from './utils/types';
1717

@@ -63,8 +63,9 @@ export interface RecursiveStyleSheetSelector<D> {
6363
export type RecursiveStyleSheetObject<D> = D &
6464
(D | RecursivePseudo<D> | RecursiveStyleSheetSelector<D>);
6565

66-
export type SystemStyleObject =
67-
RecursiveStyleSheetObject<StyleSheetWithMultiValues>;
66+
export type SystemStyleObject = RecursiveStyleSheetObject<
67+
StyleSheetWithMultiValues & StateStyles<any>
68+
>;
6869

6970
type PseudoProps = {
7071
// eslint-disable-next-line no-unused-vars

0 commit comments

Comments
 (0)