FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(webpack): mark the CSS type for stylable views explicitly by PanayotCankov · Pull Request #5257 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (36) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 3 additions & 2 deletions tns-core-modules/ui/action-bar/action-bar-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
ActionBar as ActionBarDefinition,
ActionItems as ActionItemsDefinition,
ActionItem as ActionItemDefinition,
NavigationButton, IOSActionItemSettings, AndroidActionItemSettings, AndroidActionBarSettings
NavigationButton, IOSActionItemSettings, AndroidActionItemSettings, AndroidActionBarSettings,
} from ".";

import { profile } from "../../profiling";

export * from "../core/view";

import { View, ViewBase, Property, unsetValue, booleanConverter, horizontalAlignmentProperty, verticalAlignmentProperty } from "../core/view";
import { View, ViewBase, Property, unsetValue, booleanConverter, horizontalAlignmentProperty, verticalAlignmentProperty, CSSType } from "../core/view";

export module knownCollections {
export var actionItems = "actionItems";
}

@CSSType("ActionBar")
export class ActionBarBase extends View implements ActionBarDefinition {
private _actionItems: ActionItems;
private _navigationButton: NavigationButton;
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ActivityIndicator as ActivityIndicatorDefinition } from ".";
import { View, Property, booleanConverter } from "../core/view";
import { View, Property, booleanConverter, CSSType } from "../core/view";

export * from "../core/view";

@CSSType("ActivityIndicator")
export class ActivityIndicatorBase extends View implements ActivityIndicatorDefinition {
public busy: boolean;
}
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/border/border.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Border as BorderDefinition } from ".";
import { ContentView, View, layout } from "../content-view";
import { ContentView, View, layout, CSSType } from "../content-view";

@Deprecated
@CSSType("Border")
export class Border extends ContentView implements BorderDefinition {
get cornerRadius(): number {
if (typeof this.borderRadius === "number") {
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/button/button-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Button as ButtonDefinition } from ".";
import { TextBase, booleanConverter } from "../text-base";
import { TextBase, booleanConverter, CSSType } from "../text-base";

export * from "../text-base";

@CSSType("Button")
export abstract class ButtonBase extends TextBase implements ButtonDefinition {
public static tapEvent = "tap";

Expand Down
9 changes: 9 additions & 0 deletions tns-core-modules/ui/core/view/view-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ function ensureAnimationModule() {
}
}

export function CSSType(type: string): ClassDecorator {
return (cls) => {
cls.prototype.cssType = type;
};
}

export function PseudoClassHandler(...pseudoClasses: string[]): MethodDecorator {
const stateEventNames = pseudoClasses.map(s => ":" + s);
const listeners = Symbol("listeners");
Expand Down Expand Up @@ -580,6 +586,9 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}
return this._cssType;
}
set cssType(type: string) {
this._cssType = type.toLowerCase();
}

get isLayoutRequired(): boolean {
return true;
Expand Down
40 changes: 28 additions & 12 deletions tns-core-modules/ui/core/view/view.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ export * from "../../styling/style-properties";

export function PseudoClassHandler(...pseudoClasses: string[]): MethodDecorator;

/**
* Specifies the type name for the instances of this View class,
* that is used when matching CSS type selectors.
*
* Usage:
* ```
* @CSSType("Button")
* class Button extends View {
* }
* ```
*
* Internally the decorator set `Button.prototype.cssType = "Button"`.
* @param type The type name, e. g. "Button", "Label", etc.
*/
export function CSSType(type: string): ClassDecorator;

/**
* Denotes a length number that is in device independent pixel units.
*/
Expand Down Expand Up @@ -339,8 +355,8 @@ export abstract class View extends ViewBase {
/**
* This is called to find out how big a view should be. The parent supplies constraint information in the width and height parameters.
* The actual measurement work of a view is performed in onMeasure(int, int), called by this method. Therefore, only onMeasure(int, int) can and must be overridden by subclasses.
* @param widthMeasureSpec Horizontal space requirements as imposed by the parent
* @param heightMeasureSpec Vertical space requirements as imposed by the parent
* @param widthMeasureSpec Horizontal space requirements as imposed by the parent
* @param heightMeasureSpec Vertical space requirements as imposed by the parent
*/
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void;

Expand Down Expand Up @@ -370,8 +386,8 @@ export abstract class View extends ViewBase {
/**
* Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
* When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an exception, thrown by measure(int, int).
* @param widthMeasureSpec horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
* @param heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
* @param widthMeasureSpec horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
* @param heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
*/
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;

Expand All @@ -380,14 +396,14 @@ export abstract class View extends ViewBase {
* @param left Left position, relative to parent
* @param top Top position, relative to parent
* @param right Right position, relative to parent
* @param bottom Bottom position, relative to parent
* @param bottom Bottom position, relative to parent
*/
public onLayout(left: number, top: number, right: number, bottom: number): void;

/**
* This method must be called by onMeasure(int, int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time.
* @param measuredWidth The measured width of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
* @param measuredHeight The measured height of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
* @param measuredWidth The measured width of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
* @param measuredHeight The measured height of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
*/
public setMeasuredDimension(measuredWidth: number, measuredHeight: number): void;

Expand All @@ -397,16 +413,16 @@ export abstract class View extends ViewBase {
* @param left Left position, relative to parent
* @param top Top position, relative to parent
* @param right Right position, relative to parent
* @param bottom Bottom position, relative to parent
* @param bottom Bottom position, relative to parent
*/
public layoutNativeView(left: number, top: number, right: number, bottom: number): void;

/**
* Measure a child by taking into account its margins and a given measureSpecs.
* @param parent This parameter is not used. You can pass null.
* @param child The view to be measured.
* @param measuredWidth The measured width that the parent layout specifies for this view.
* @param measuredHeight The measured height that the parent layout specifies for this view.
* @param measuredWidth The measured width that the parent layout specifies for this view.
* @param measuredHeight The measured height that the parent layout specifies for this view.
*/
public static measureChild(parent: View, child: View, widthMeasureSpec: number, heightMeasureSpec: number): { measuredWidth: number; measuredHeight: number };

Expand All @@ -416,7 +432,7 @@ export abstract class View extends ViewBase {
* @param left Left position, relative to parent
* @param top Top position, relative to parent
* @param right Right position, relative to parent
* @param bottom Bottom position, relative to parent
* @param bottom Bottom position, relative to parent
*/
public static layoutChild(parent: View, child: View, left: number, top: number, right: number, bottom: number): void;

Expand Down Expand Up @@ -787,4 +803,4 @@ export namespace ios {
export class UILayoutViewController {
public static initWithOwner(owner: WeakRef<View>): UILayoutViewController;
}
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DatePicker as DatePickerDefinition } from ".";
import { View, Property } from "../core/view";
import { View, Property, CSSType } from "../core/view";

export * from "../core/view";

const defaultDate = new Date();
const dateComparer = (x: Date, y: Date): boolean => (x <= y && x >= y);

@CSSType("DatePicker")
export class DatePickerBase extends View implements DatePickerDefinition {
public year: number;
public month: number;
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/frame/frame-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Frame as FrameDefinition, NavigationEntry, BackstackEntry, NavigationTr
import { Page } from "../page";

// Types.
import { View, CustomLayoutView, isIOS, isAndroid, traceEnabled, traceWrite, traceCategories, EventData, Property } from "../core/view";
import { View, CustomLayoutView, isIOS, isAndroid, traceEnabled, traceWrite, traceCategories, EventData, Property, CSSType } from "../core/view";
import { resolveFileName } from "../../file-system/file-name-resolver";
import { knownFolders, path } from "../../file-system";
import { parse, createViewFromEntry } from "../builder";
Expand Down Expand Up @@ -35,6 +35,7 @@ export interface NavigationContext {
isBackNavigation: boolean;
}

@CSSType("Frame")
export class FrameBase extends CustomLayoutView implements FrameDefinition {
public static androidOptionSelectedEvent = "optionSelected";

Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/html-view/html-view-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HtmlView as HtmlViewDefinition } from ".";
import { View, Property } from "../core/view";
import { View, Property, CSSType } from "../core/view";

export * from "../core/view";

@CSSType("HtmlView")
export class HtmlViewBase extends View implements HtmlViewDefinition {
public html: string;
}
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/image/image-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Image as ImageDefinition, Stretch } from ".";
import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter } from "../core/view";
import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter, CSSType } from "../core/view";
import { ImageAsset } from "../../image-asset";
import { ImageSource, fromAsset, fromNativeSource, fromUrl } from "../../image-source";
import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils";

export * from "../core/view";
export { ImageSource, ImageAsset, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };

@CSSType("Image")
export abstract class ImageBase extends View implements ImageDefinition {
public imageSource: ImageSource;
public src: string | ImageSource;
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/label/label.android.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Label as LabelDefinition } from ".";
import { TextBase, WhiteSpace, whiteSpaceProperty, booleanConverter } from "../text-base";
import { TextBase, WhiteSpace, whiteSpaceProperty, booleanConverter, CSSType } from "../text-base";
import { profile } from "../../profiling";

export * from "../text-base";

let TextView: typeof android.widget.TextView;

@CSSType("Label")
export class Label extends TextBase implements LabelDefinition {
nativeViewProtected: android.widget.TextView;

Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/label/label.ios.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
TextBase, View, layout,
borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty,
paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, whiteSpaceProperty,
Length, WhiteSpace, booleanConverter
Length, WhiteSpace, booleanConverter, CSSType
} from "../text-base";

import { ios } from "../styling/background";
Expand All @@ -18,6 +18,7 @@ enum FixedSize {
BOTH = 3
}

@CSSType("Label")
export class Label extends TextBase implements LabelDefinition {
nativeViewProtected: TNSLabel;
private _fixedSize: FixedSize;
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbsoluteLayout as AbsoluteLayoutDefinition } from ".";
import { LayoutBase, View, Property, Length, zeroLength } from "../layout-base";
import { LayoutBase, View, Property, Length, zeroLength, CSSType } from "../layout-base";

export * from "../layout-base";

Expand All @@ -13,6 +13,7 @@ function validateArgs(element: View): View {
return element;
}

@CSSType("AbsoluteLayout")
export class AbsoluteLayoutBase extends LayoutBase implements AbsoluteLayoutDefinition {
// TODO: Do we still need this? it can be get like view.left
public static getLeft(element: View): Length {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DockLayout as DockLayoutDefinition, Dock } from ".";
import { LayoutBase, View, Property, isIOS, booleanConverter, makeValidator, makeParser } from "../layout-base";
import { LayoutBase, View, Property, isIOS, booleanConverter, makeValidator, makeParser, CSSType } from "../layout-base";

function validateArgs(element: View): View {
if (!element) {
Expand All @@ -10,6 +10,7 @@ function validateArgs(element: View): View {

export * from "../layout-base";

@CSSType("DockLayout")
export class DockLayoutBase extends LayoutBase implements DockLayoutDefinition {

public static getDock(element: View): Dock {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LayoutBase, View, Style, CssProperty, isIOS, ShorthandProperty, makeValidator, makeParser, unsetValue } from "../layout-base";
import { LayoutBase, View, Style, CssProperty, isIOS, ShorthandProperty, makeValidator, makeParser, unsetValue, CSSType } from "../layout-base";

export * from "../layout-base";

Expand Down Expand Up @@ -137,6 +137,7 @@ function validateArgs(element: View): View {
/**
* A common base class for all cross platform flexbox layout implementations.
*/
@CSSType("FlexboxLayout")
export abstract class FlexboxLayoutBase extends LayoutBase {
get flexDirection(): FlexDirection {
return this.style.flexDirection;
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GridLayout as GridLayoutDefinition, ItemSpec as ItemSpecDefinition } from ".";
import { LayoutBase, View, Observable, Property, makeParser, makeValidator } from "../layout-base";
import { LayoutBase, View, Observable, Property, makeParser, makeValidator, CSSType } from "../layout-base";

export * from "../layout-base";

Expand Down Expand Up @@ -125,6 +125,7 @@ export class ItemSpec extends Observable implements ItemSpecDefinition {
}
}

@CSSType("GridLayout")
export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition {
private _rows: Array<ItemSpec> = new Array<ItemSpec>();
private _cols: Array<ItemSpec> = new Array<ItemSpec>();
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { StackLayout as StackLayoutDefinition, Orientation } from ".";
import { LayoutBase, Property, isIOS, makeValidator, makeParser } from "../layout-base";
import { LayoutBase, Property, isIOS, makeValidator, makeParser, CSSType } from "../layout-base";

export * from "../layout-base";

@CSSType("StackLayout")
export class StackLayoutBase extends LayoutBase implements StackLayoutDefinition {
public orientation: Orientation;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { WrapLayout as WrapLayoutDefinition, Orientation } from ".";
import { LayoutBase, Property, isIOS, Length, makeValidator, makeParser } from "../layout-base";
import { LayoutBase, Property, isIOS, Length, makeValidator, makeParser, CSSType } from "../layout-base";

export * from "../layout-base";

@CSSType("WrapLayout")
export class WrapLayoutBase extends LayoutBase implements WrapLayoutDefinition {
public orientation: Orientation;
public itemWidth: Length;
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ListPicker as ListPickerDefinition, ItemsSource } from ".";
import { View, Property, CoercibleProperty } from "../core/view";
import { View, Property, CoercibleProperty, CSSType } from "../core/view";

export * from "../core/view";

@CSSType("ListPicker")
export class ListPickerBase extends View implements ListPickerDefinition {

public selectedIndex: number;
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/list-view/list-view-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ListView as ListViewDefinition, ItemsSource, ItemEventData } from ".";
import { CoercibleProperty, CssProperty, Style, View, Template, KeyedTemplate, Length, Property, Color, Observable, EventData } from "../core/view";
import { CoercibleProperty, CssProperty, Style, View, Template, KeyedTemplate, Length, Property, Color, Observable, EventData, CSSType } from "../core/view";
import { parse, parseMultipleTemplates } from "../builder";
import { Label } from "../label";
import { ObservableArray, ChangedData } from "../../data/observable-array";
Expand All @@ -18,6 +18,7 @@ export module knownMultiTemplates {

const autoEffectiveRowHeight = -1;

@CSSType("ListView")
export abstract class ListViewBase extends View implements ListViewDefinition {
public static itemLoadingEvent = "itemLoading";
public static itemTapEvent = "itemTap";
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/page/page-common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Page as PageDefinition, NavigatedData, ShownModallyData } from ".";
import {
ContentView, View, eachDescendant, Property, CssProperty, Color, isIOS,
booleanConverter, resetCSSProperties, Style, EventData
booleanConverter, resetCSSProperties, Style, EventData, CSSType
} from "../content-view";
import { Frame, topmost as topmostFrame } from "../frame";
import { ActionBar } from "../action-bar";
Expand All @@ -11,6 +11,7 @@ import { profile } from "../../profiling";

export * from "../content-view";

@CSSType("Page")
export class PageBase extends ContentView implements PageDefinition {

public static navigatingToEvent = "navigatingTo";
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Placeholder as PlaceholderDefinition, CreateViewEventData } from "."
import { View, EventData } from "../core/view"
import { View, EventData, CSSType } from "../core/view"

@CSSType("Placeholder")
export class Placeholder extends View implements PlaceholderDefinition {
public static creatingViewEvent = "creatingView";

Expand Down
Loading

Back | FazBrowse Home | New Git URL