| 1 | import { codegenNativeComponent, type CodegenTypes } from "react-native"; |
| 2 | import type { ViewProps } from "react-native"; |
| 3 | |
| 4 | interface TargetedEvent { |
| 5 | target: CodegenTypes.Int32; |
| 6 | } |
| 7 | |
| 8 | /** |
| 9 | * Event fired when text selection changes in the SourceText. |
| 10 | * @property target - The view tag identifier |
| 11 | * @property start - The start index of the selected range (0-based) |
| 12 | * @property end - The end index of the selected range (0-based, exclusive) |
| 13 | */ |
| 14 | interface SelectionChangeEvent extends TargetedEvent { |
| 15 | start: CodegenTypes.Int32; |
| 16 | end: CodegenTypes.Int32; |
| 17 | } |
| 18 | |
| 19 | type EllipsizeMode = "head" | "middle" | "tail" | "clip"; |
| 20 | |
| 21 | interface NativeProps extends ViewProps { |
| 22 | numberOfLines?: CodegenTypes.Int32; |
| 23 | allowFontScaling?: CodegenTypes.WithDefault<boolean, true>; |
| 24 | ellipsizeMode?: CodegenTypes.WithDefault<EllipsizeMode, "tail">; |
| 25 | selectable?: boolean; |
| 26 | /** |
| 27 | * Callback fired when the text selection changes. |
| 28 | * |
| 29 | * @example |
| 30 | * ```tsx |
| 31 | * <SourceText |
| 32 | * onSelectionChange={(event) => { |
| 33 | * console.log('Selection:', event.nativeEvent.start, event.nativeEvent.end); |
| 34 | * }} |
| 35 | * > |
| 36 | * Selectable text |
| 37 | * </SourceText> |
| 38 | * ``` |
| 39 | */ |
| 40 | onSelectionChange?: CodegenTypes.BubblingEventHandler<SelectionChangeEvent>; |
| 41 | } |
| 42 | |
| 43 | export default codegenNativeComponent<NativeProps>("T3SourceText", { |
| 44 | excludedPlatforms: ["android"], |
| 45 | }); |