@winged/core
Version:
Morden webapp framekwork made only for ts developers. (UNDER DEVELOPMENT, PLEASE DO NOT USE)
138 lines (120 loc) • 3.12 kB
text/typescript
import { VDomStruct, View, vState } from '../src/index'
/* tslint:disable:max-line-length */
export abstract class BoxView<V extends BoxView<any>> extends View<V> {
() public highlighted: boolean
() public content: boolean | string | number
public abstract readonly _subviewMap: {}
protected readonly _contents: VDomStruct = ['E', 'section', { id: 'box-view' }, [
['L', 'Slot', { name: 'header' }],
['E', 'p', { class: ['content ', ['D', 'highlighted ? "highlighted"']] }, [
'this is the content part of box:',
['D', 'content']
]],
['E', 'button', { onclick: 'handleConfirm' }, 'Confirm']
]]
public abstract handleConfirm(event: Event): void
protected _linkSubviewProps() {
return {}
}
}
interface Inside {
someKey: string
}
interface Another {
age: string
}
interface BoxData extends Another {
name: string
inside: Inside
// map2: DeepMap;
}
class Dog {
public dogName: string
}
type Int = number
// tslint:disable-next-line:interface-over-type-literal
type ShallowMap = {
[index: number]: string;
test: number;
}
interface TestGeneric<T> {
name: string
child: T
}
interface DeepMap {
[index: string]: string
}
// tslint:disable-next-line:interface-over-type-literal
type Mixing<T> = {
name: string;
child: T;
}
function test(): void {
// do nothing
}
interface SomeFn {
(a: string): string
b: string
}
export class BoxViewImpl extends BoxView<BoxViewImpl> {
public _propsType: {
boxData: BoxData & { added1: string } & { added2: string };
list: Array<{ name: string, box: BoxData }>;
list2: BoxData[] | undefined;
list3: string[];
list4: Array<BoxData & { added1?: string }>;
boxData2: BoxData | null;
str: string;
int: Int;
bool: Boolean;
highlighted: boolean;
union: string | boolean | number;
content: string | Boolean;
intTest?: Int;
boolTest: Boolean;
tValue: true;
fValue: false;
generic: TestGeneric<{ value: string }>
generic2: Mixing<BoxData>
correctLiteral: {
key: string;
}
// /* incorrect types */
nullTest1: BoxData | void;
nullTest2: undefined | string;
nullTest3: BoxData | void;
mixUp: string[] | string;
mixUp2: { name: string } | string;
mixUp3: string | number | ({ name: string } & { value: string });
mixUp4: Array<{ name: string }> | { value: string };
fn: () => string;
fn2: typeof test;
fn3: BoxViewImpl['onPropsChange'];
fn4: SomeFn;
shallowMap: ShallowMap;
deepMap: DeepMap;
pet: Dog;
map: {
[name: string]: string;
}
indexMap: {
[index: number]: string;
}
}
public _events: {
confirm: (data: { myKey: string }) => void;
}
public test: string
public _subviewMap: {}
public handleConfirm(event: Event): void {
console.log('handle confirm')
}
public onMount() {
console.log('box view impl mounted')
}
public onPropsChange(props: this['_propsType']) {
console.log('props change')
this.content = props.content as string
this.highlighted = props.highlighted
}
}