UNPKG

5.93 kBTypeScriptView Raw
1import { PropertyChangeData } from '../../data/observable';
2import { ViewBase } from '../core/view-base';
3import { FontStyleType, FontWeightType } from '../styling/font-interfaces';
4import { FormattedString } from './formatted-string';
5import { Span } from './span';
6import { View } from '../core/view';
7import { Property, CssProperty, InheritedCssProperty } from '../core/properties';
8import { Style } from '../styling/style';
9import { CoreTypes } from '../../core-types';
10import { TextBase as TextBaseDefinition } from '.';
11import { ShadowCSSValues } from '../styling/css-shadow';
12import { StrokeCSSValues } from '../styling/css-stroke';
13export declare abstract class TextBaseCommon extends View implements TextBaseDefinition {
14 _isSingleLine: boolean;
15 text: string;
16 formattedText: FormattedString;
17 iosTextAnimation: 'inherit' | boolean;
18 static iosTextAnimationFallback: boolean;
19 /***
20 * In the NativeScript Core; by default the nativeTextViewProtected points to the same value as nativeViewProtected.
21 * At this point no internal NS components need this indirection functionality.
22 * This indirection is used to allow support usage by third party components so they don't have to duplicate functionality.
23 *
24 * A third party component can just override the `nativeTextViewProtected` getter and return a different internal view and that view would be
25 * what all TextView/TextInput class features would be applied to.
26 *
27 * A example is the Android MaterialDesign TextInput class, it has a wrapper view of a TextInputLayout
28 * https://developer.android.com/reference/com/google/android/material/textfield/TextInputLayout
29 * which wraps the actual TextInput. This wrapper layout (TextInputLayout) must be assigned to the nativeViewProtected as the entire
30 * NS Core uses nativeViewProtected for everything related to layout, so that it can be measured, added to the parent view as a child, ect.
31 *
32 * However, its internal view would be the actual TextView/TextInput and to allow that sub-view to have the normal TextView/TextInput
33 * class features, which we expose and to allow them to work on it, the internal TextView/TextInput is what the needs to have the class values applied to it.
34 *
35 * So all code that works on what is expected to be a TextView/TextInput should use `nativeTextViewProtected` so that any third party
36 * components that need to have two separate components can work properly without them having to duplicate all the TextBase (and decendants) functionality
37 * by just overriding the nativeTextViewProtected getter.
38 **/
39 get nativeTextViewProtected(): any;
40 get fontFamily(): string;
41 set fontFamily(value: string);
42 get fontSize(): number;
43 set fontSize(value: number);
44 get fontStyle(): FontStyleType;
45 set fontStyle(value: FontStyleType);
46 get fontWeight(): FontWeightType;
47 set fontWeight(value: FontWeightType);
48 get letterSpacing(): number;
49 set letterSpacing(value: number);
50 get lineHeight(): number;
51 set lineHeight(value: number);
52 get maxLines(): CoreTypes.MaxLinesType;
53 set maxLines(value: CoreTypes.MaxLinesType);
54 get textAlignment(): CoreTypes.TextAlignmentType;
55 set textAlignment(value: CoreTypes.TextAlignmentType);
56 get textDecoration(): CoreTypes.TextDecorationType;
57 set textDecoration(value: CoreTypes.TextDecorationType);
58 get textTransform(): CoreTypes.TextTransformType;
59 set textTransform(value: CoreTypes.TextTransformType);
60 get textShadow(): ShadowCSSValues;
61 set textShadow(value: ShadowCSSValues);
62 get whiteSpace(): CoreTypes.WhiteSpaceType;
63 set whiteSpace(value: CoreTypes.WhiteSpaceType);
64 get textOverflow(): CoreTypes.TextOverflowType;
65 set textOverflow(value: CoreTypes.TextOverflowType);
66 get padding(): string | CoreTypes.LengthType;
67 set padding(value: string | CoreTypes.LengthType);
68 get paddingTop(): CoreTypes.LengthType;
69 set paddingTop(value: CoreTypes.LengthType);
70 get paddingRight(): CoreTypes.LengthType;
71 set paddingRight(value: CoreTypes.LengthType);
72 get paddingBottom(): CoreTypes.LengthType;
73 set paddingBottom(value: CoreTypes.LengthType);
74 get paddingLeft(): CoreTypes.LengthType;
75 set paddingLeft(value: CoreTypes.LengthType);
76 _onFormattedTextContentsChanged(data: PropertyChangeData): void;
77 _addChildFromBuilder(name: string, value: any): void;
78 _requestLayoutOnTextChanged(): void;
79 eachChild(callback: (child: ViewBase) => boolean): void;
80 _setNativeText(reset?: boolean): void;
81}
82export declare function isBold(fontWeight: FontWeightType): boolean;
83export declare const textProperty: Property<TextBaseCommon, string>;
84export declare const formattedTextProperty: Property<TextBaseCommon, FormattedString>;
85export declare const iosTextAnimationProperty: Property<TextBaseCommon, boolean | "inherit">;
86export declare function getClosestPropertyValue<T>(property: CssProperty<any, T>, span: Span): T;
87export declare const textAlignmentProperty: InheritedCssProperty<Style, CoreTypes.TextAlignmentType>;
88export declare const textTransformProperty: CssProperty<Style, CoreTypes.TextTransformType>;
89export declare const textShadowProperty: CssProperty<Style, string | ShadowCSSValues>;
90export declare const textStrokeProperty: CssProperty<Style, string | StrokeCSSValues>;
91export declare const whiteSpaceProperty: CssProperty<Style, CoreTypes.WhiteSpaceType>;
92export declare const textOverflowProperty: CssProperty<Style, CoreTypes.TextOverflowType>;
93export declare const textDecorationProperty: CssProperty<Style, CoreTypes.TextDecorationType>;
94export declare const letterSpacingProperty: InheritedCssProperty<Style, number>;
95export declare const lineHeightProperty: InheritedCssProperty<Style, number>;
96export declare const maxLinesProperty: CssProperty<Style, number>;
97export declare const resetSymbol: unique symbol;