UNPKG

uicore-ts

Version:

UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework tha

159 lines (158 loc) 6.03 kB
import { UIColor } from "./UIColor"; import { UILocalizedTextObject } from "./UIInterfaces"; import { UIObject, ValueOf } from "./UIObject"; import { UIRectangle } from "./UIRectangle"; import { UIView, UIViewBroadcastEvent } from "./UIView"; export declare class UITextView extends UIView { static defaultTextColor: UIColor; static notificationTextColor: UIColor; static attentionRequiredColor: UIColor; /** * Override this to customise the attention indicator HTML that is appended * to a label's text when `attentionRequired` is `YES`. * * The default renders an amber `●` dot: * ``` * UITextView.renderAttentionIndicator = () => * `<span style="color: #f59e0b; margin-left: 4px;">●</span>` * ``` * Call sites never need to change — only this one function needs to be * replaced at app startup to restyle every attention indicator globally. */ static attentionIndicatorHTMLString: () => string; attentionIndicatorHTMLString: () => string; static _intrinsicHeightCache: { [x: string]: { [x: string]: number; }; } & UIObject; static _intrinsicWidthCache: { [x: string]: { [x: string]: number; }; } & UIObject; static _ptToPx: number; static _pxToPt: number; static type: { readonly paragraph: "p"; readonly header1: "h1"; readonly header2: "h2"; readonly header3: "h3"; readonly header4: "h4"; readonly header5: "h5"; readonly header6: "h6"; readonly textArea: "textarea"; readonly textField: "input"; readonly span: "span"; readonly label: "label"; }; static textAlignment: { readonly left: "left"; readonly center: "center"; readonly right: "right"; readonly justify: "justify"; }; constructor(elementID?: string, textViewType?: string | ValueOf<typeof UITextView.type>, viewHTMLElement?: null); private _textElementView; /** * The inner text element that holds the actual text content */ get textElementView(): UIView; /** * Override style to apply to the text element instead of the container */ /** * Access the outer container's style (for positioning, layout, etc.) */ get containerStyle(): CSSStyleDeclaration; /** * Override styleClasses to apply to the text element */ get styleClasses(): string[]; set styleClasses(styleClasses: string[]); didReceiveBroadcastEvent(event: UIViewBroadcastEvent): void; willMoveToSuperview(superview: UIView): void; documentFontsDidLoad(): void; layoutSubviews(): void; private _invalidateMeasurementStyles; private _getMeasurementStyles; private _parseLineHeight; private _shouldUseFastMeasurement; setUseFastMeasurement(useFast: boolean): void; invalidateMeasurementStrategy(): void; get textAlignment(): ValueOf<typeof UITextView.textAlignment>; set textAlignment(textAlignment: ValueOf<typeof UITextView.textAlignment>); get textColor(): UIColor; set textColor(color: UIColor); get isSingleLine(): boolean; set isSingleLine(isSingleLine: boolean); get notificationAmount(): number; set notificationAmount(notificationAmount: number); notificationAmountDidChange(notificationAmount: number): void; get attentionRequired(): boolean; set attentionRequired(attentionRequired: boolean); get text(): string; set text(text: string); /** * Formats a raw number string by inserting `separator` every three digits * in the integer part. Handles negative numbers and decimals (machine locale * "." as decimal point). Non-numeric strings are returned unchanged. */ static applyThousandsSeparatorToNumericalString(value: string, separator: string): string; set innerHTML(innerHTML: string); get innerHTML(): string; setText(key: string, defaultString: string, parameters?: { [x: string]: string | UILocalizedTextObject; }): void; get fontSize(): number; set fontSize(fontSize: number); useAutomaticFontSize(minFontSize?: number, maxFontSize?: number): void; /** * Get a stable cache key for the font without triggering reflow. * Only computes font on first access or when font properties change. */ private _getFontCacheKey; /** * Invalidate font cache when font properties change */ private _invalidateFontCache; static _determinePXAndPTRatios(): void; static automaticallyCalculatedFontSize(bounds: UIRectangle, currentSize: UIRectangle, currentFontSize: number, minFontSize?: number, maxFontSize?: number): number; _text?: string; textPrefix: string; textSuffix: string; _notificationAmount: number; _attentionRequired: boolean; _thousandsSeparator: string | null; get thousandsSeparator(): string | null; set thousandsSeparator(value: string | null); _textColor: UIColor; _textAlignment?: ValueOf<typeof UITextView.textAlignment>; _isSingleLine: boolean; _minFontSize?: number; _maxFontSize?: number; _automaticFontSizeSelection: boolean; private _cachedFontKey?; private _fontInvalidationTriggers; changesOften: boolean; _intrinsicHeightCache: { [x: string]: { [x: string]: number; }; } & UIObject; _intrinsicWidthCache: { [x: string]: { [x: string]: number; }; } & UIObject; private _useFastMeasurement; private _cachedMeasurementStyles; usesVirtualLayoutingForIntrinsicSizing: boolean; addStyleClass(styleClass: string): void; removeStyleClass(styleClass: string): void; focus(): void; blur(): void; intrinsicContentHeight(constrainingWidth?: number): any; intrinsicContentWidth(constrainingHeight?: number): any; intrinsicContentSizeWithConstraints(constrainingHeight?: number, constrainingWidth?: number): UIRectangle; }