Skip to content

Commit 246602a

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

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

packages/react-native-ficus-ui/src/components/input/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
isStyleProp,
1616
omitThemingProps,
1717
} from '../../style-system';
18+
import { SystemStyleObject } from '../../style-system';
1819
import { getColor, useTheme } from '../../theme';
1920
import { ButtonSpinner } from '../button/button-spinner';
2021
import {
@@ -30,7 +31,13 @@ export interface InputProps
3031
extends NativeFicusProps<'TextInput'>,
3132
PrefixSuffixProps,
3233
InputOptions,
33-
ThemingProps<'Input'> {}
34+
ThemingProps<'Input'> {
35+
_focused?: SystemStyleObject;
36+
_disabled?: SystemStyleObject;
37+
_checked?: SystemStyleObject;
38+
_dark?: SystemStyleObject;
39+
__styles?: SystemStyleObject;
40+
}
3441

3542
export const Input = forwardRef<InputProps, 'TextInput'>((props, ref) => {
3643
const [isFocused, setIsFocused] = useState(false);

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/system.types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ 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 & {
68+
_focused?: SystemStyleObject;
69+
_disabled?: SystemStyleObject;
70+
_checked?: SystemStyleObject;
71+
_dark?: SystemStyleObject;
72+
}
73+
>;
6874

6975
type PseudoProps = {
7076
// eslint-disable-next-line no-unused-vars

0 commit comments

Comments
 (0)