Skip to content

Commit 959e349

Browse files
pkaramonclaude
andcommitted
refactor: merge componentTypes.ts into types.ts
componentTypes.ts only contained type-only imports from react-native, so there's no reason to keep it separate. All native component types (EnrichedTextInputProps, EnrichedTextInputInstance, FocusEvent, BlurEvent) are now in types.ts alongside the shared event/style types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 616eb66 commit 959e349

File tree

4 files changed

+68
-81
lines changed

4 files changed

+68
-81
lines changed

src/componentTypes.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type {
44
BlurEvent,
55
EnrichedTextInputInstance,
66
EnrichedTextInputProps,
7-
} from './componentTypes';
7+
} from './types';
88
export type {
99
OnChangeTextEvent,
1010
OnChangeHtmlEvent,

src/native/EnrichedTextInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { normalizeHtmlStyle } from '../utils/normalizeHtmlStyle';
2626
import { toNativeRegexConfig } from '../utils/regexParser';
2727
import { nullthrows } from '../utils/nullthrows';
2828
import type { OnLinkDetected, OnMentionDetected } from '../types';
29-
import type { EnrichedTextInputProps } from '../componentTypes';
29+
import type { EnrichedTextInputProps } from '../types';
3030

3131
const warnMentionIndicators = (indicator: string) => {
3232
console.warn(

src/types.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import type { ColorValue, TextStyle } from 'react-native';
1+
import type { RefObject } from 'react';
2+
import type {
3+
ColorValue,
4+
NativeMethods,
5+
NativeSyntheticEvent,
6+
TargetedEvent,
7+
TextStyle,
8+
ViewProps,
9+
ViewStyle,
10+
} from 'react-native';
211

312
// Event data interfaces
413

@@ -173,6 +182,62 @@ export interface HtmlStyle {
173182
};
174183
}
175184

185+
// Native component types
186+
187+
export type FocusEvent = NativeSyntheticEvent<TargetedEvent>;
188+
export type BlurEvent = NativeSyntheticEvent<TargetedEvent>;
189+
190+
export interface EnrichedTextInputInstance
191+
extends EnrichedTextInputBaseInstance,
192+
NativeMethods {}
193+
194+
export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
195+
ref?: RefObject<EnrichedTextInputInstance | null>;
196+
autoFocus?: boolean;
197+
editable?: boolean;
198+
mentionIndicators?: string[];
199+
defaultValue?: string;
200+
placeholder?: string;
201+
placeholderTextColor?: ColorValue;
202+
cursorColor?: ColorValue;
203+
selectionColor?: ColorValue;
204+
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
205+
htmlStyle?: HtmlStyle;
206+
style?: ViewStyle | TextStyle;
207+
scrollEnabled?: boolean;
208+
linkRegex?: RegExp | null;
209+
onFocus?: (e: FocusEvent) => void;
210+
onBlur?: (e: BlurEvent) => void;
211+
onChangeText?: (e: NativeSyntheticEvent<OnChangeTextEvent>) => void;
212+
onChangeHtml?: (e: NativeSyntheticEvent<OnChangeHtmlEvent>) => void;
213+
onChangeState?: (e: NativeSyntheticEvent<OnChangeStateEvent>) => void;
214+
onLinkDetected?: (e: OnLinkDetected) => void;
215+
onMentionDetected?: (e: OnMentionDetected) => void;
216+
onStartMention?: (indicator: string) => void;
217+
onChangeMention?: (e: OnChangeMentionEvent) => void;
218+
onEndMention?: (indicator: string) => void;
219+
onChangeSelection?: (e: NativeSyntheticEvent<OnChangeSelectionEvent>) => void;
220+
onKeyPress?: (e: NativeSyntheticEvent<OnKeyPressEvent>) => void;
221+
onPasteImages?: (e: NativeSyntheticEvent<OnPasteImagesEvent>) => void;
222+
contextMenuItems?: ContextMenuItem[];
223+
/**
224+
* If true, Android will use experimental synchronous events.
225+
* This will prevent from input flickering when updating component size.
226+
* However, this is an experimental feature, which has not been thoroughly tested.
227+
* We may decide to enable it by default in a future release.
228+
* Disabled by default.
229+
*/
230+
androidExperimentalSynchronousEvents?: boolean;
231+
/**
232+
* If true, external HTML (e.g. from Google Docs, Word, web pages) will be
233+
* normalized through the HTML normalizer before being applied.
234+
* This converts arbitrary HTML into the canonical tag subset that the enriched
235+
* parser understands.
236+
* Disabled by default.
237+
*/
238+
useHtmlNormalizer?: boolean;
239+
}
240+
176241
// Base instance interface shared between platforms
177242

178243
export interface EnrichedTextInputBaseInstance {

0 commit comments

Comments
 (0)