Commit 727e5804 by Иван Кубота

wip

parent 78d40225
{"version":3,"file":"Button.jsx","sourceRoot":"","sources":["../../src/cmp/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gCAA2D;AAE3D;IAAqB,0BAAS;IAA9B;QAAA,qEAeC;QAdG,YAAM,GAAc,IAAI,CAAC;QACzB,SAAG,GAAG;YACF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,aAAO,GAAiC;YACpC,KAAK,EAAE,UAAC,CAAC,EAAC,GAAU,IAAG,OAAA,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,GAAG,GAAG,EAA3B,CAA2B;YAClD,QAAQ,EAAE,UAAC,CAAC,EAAC,GAAW,IAAG,OAAA,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAC,QAAQ,EAAE,GAAG,EAAC,CAAC,EAA7B,CAA6B;SAC3D,CAAC;;IAMN,CAAC;IALG,uBAAM,GAAN;QACI,YAAY;QACZ,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,CAAA,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACL,aAAC;AAAD,CAAC,AAfD,CAAqB,gBAAS,GAe7B;AAEO,wBAAM"} {"version":3,"file":"Button.jsx","sourceRoot":"","sources":["../../src/cmp/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gCAAyE;AAIzE;IAAqB,0BAAsB;IAA3C;QAAA,qEAeC;QAdG,YAAM,GAAc,IAAI,CAAC;QACzB,SAAG,GAAG;YACF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,aAAO,GAAiC;YACpC,KAAK,EAAE,UAAC,CAAC,EAAC,GAAU,IAAG,OAAA,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,GAAG,GAAG,EAA3B,CAA2B;YAClD,QAAQ,EAAE,UAAC,CAAC,EAAC,GAAW,IAAG,OAAA,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAC,QAAQ,EAAE,GAAG,EAAC,CAAC,EAA7B,CAA6B;SAC3D,CAAC;;IAMN,CAAC;IALG,uBAAM,GAAN;QACI,YAAY;QACZ,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,CAAA,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACL,aAAC;AAAD,CAAC,AAfD,CAAqB,gBAAS,GAe7B;AAEO,wBAAM"}
\ No newline at end of file \ No newline at end of file
...@@ -36,10 +36,33 @@ var Item = /** @class */ (function (_super) { ...@@ -36,10 +36,33 @@ var Item = /** @class */ (function (_super) {
}; };
return Item; return Item;
}(Rjsx_1.Component)); }(Rjsx_1.Component));
var UIComponent = /** @class */ (function (_super) {
__extends(UIComponent, _super);
function UIComponent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.def = {
disabled: false,
hidden: false,
label: {
position: 'top',
text: 'Label'
},
selected: false,
active: false,
empty: false,
placeholder: '',
style: {
size: 'normal',
margin: { top: '16px' }
}
};
return _this;
}
return UIComponent;
}(Rjsx_1.Component));
<div className='wrapper'> <div className='wrapper'>
{item = <Item />} {item = <Item />}
{btn = <Button_1.Button onClick={function (a, b, c) { {btn = <Button_1.Button onClick={function (e, b, c) {
item.checkbox.set({ checked: !item.checkbox.state.checked }); item.checkbox.set({ checked: !item.checkbox.state.checked });
}}>text1<b>text2</b>{i = <i x="2">text3</i>}text4</Button_1.Button>} }}>text1<b>text2</b>{i = <i x="2">text3</i>}text4</Button_1.Button>}
<Item /> <Item />
......
{"version":3,"file":"index.jsx","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,+BAAuC;AACvC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC;AAKjB;IAA8B,wBAAS;IAAvC;QAAA,qEAmBC;QAlBG,cAAQ,GAAc,IAAI,CAA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AA,CAAC,IAAI,CAAC,AAAD,EACT;AAAA,EAAE,GAAG,CAAC,CAAA;AAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE/B,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,WAAW,CAAC;IACR,CAAC,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,EAAC,CAAC,CAAC;IACzB,GAAG,CAAC,GAAG,CAAC,EAAC,QAAQ,EAAE,OAAO,GAAC,CAAC,KAAG,CAAC,EAAC,CAAC,CAAC;IACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC,OAAO,EAAE,OAAO,GAAC,CAAC,KAAG,CAAC,EAAC,CAAC,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAC,OAAO,EAAE,OAAO,GAAC,CAAC,GAAC,CAAC,EAAC,CAAC,CAAC;AAC/C,CAAC,EAAE,IAAI,CAAC,CAAC;AAET,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
\ No newline at end of file \ No newline at end of file
import {Reactivity} from "./Rjsx"; import {Component, Reactivity} from "./Rjsx";
export = Rjsx; export = Rjsx;
export as namespace Rjsx; export as namespace Rjsx;
...@@ -52,7 +52,7 @@ declare namespace Rjsx { ...@@ -52,7 +52,7 @@ declare namespace Rjsx {
attributes: P; attributes: P;
children: Array<VNode<any> | string>; children: Array<VNode<any> | string>;
key?: Key | null; key?: Key | null;
renderTo: Function renderTo(el:HTMLElement):void;
} }
type RenderableProps<P, RefType = any> = Readonly< type RenderableProps<P, RefType = any> = Readonly<
...@@ -103,7 +103,7 @@ declare namespace Rjsx { ...@@ -103,7 +103,7 @@ declare namespace Rjsx {
forceUpdate(callback?: () => void): void; forceUpdate(callback?: () => void): void;
abstract render(props?: RenderableProps<P>, state?: Readonly<S>, context?: any): ComponentChild; abstract render(props?: RenderableProps<P>, state?: Readonly<S>, context?: any): ComponentChild;
renderTo?(HTMLElement): void; abstract renderTo(el: HTMLElement): void;
} }
function h( function h(
...@@ -129,7 +129,7 @@ declare namespace Rjsx { ...@@ -129,7 +129,7 @@ declare namespace Rjsx {
}; };
} }
/*
type Defaultize<Props, Defaults> = type Defaultize<Props, Defaults> =
// Distribute over unions // Distribute over unions
Props extends any Props extends any
...@@ -138,15 +138,18 @@ type Defaultize<Props, Defaults> = ...@@ -138,15 +138,18 @@ type Defaultize<Props, Defaults> =
// Include the remaining properties from Props // Include the remaining properties from Props
& Pick<Props, Exclude<keyof Props, keyof Defaults>> & Pick<Props, Exclude<keyof Props, keyof Defaults>>
: never; : never;
*/
declare global { declare global {
namespace JSX { namespace JSX {
/*interface Element extends Rjsx.VNode<any> { interface Element extends Component<any> {
props: any;
} }
interface ElementClass extends Rjsx.Component<any, any> { interface ElementClass extends Rjsx.Component<any, any> {
}*/ props: any;
}
interface ElementAttributesProperty { interface ElementAttributesProperty {
props: any; props: any;
...@@ -154,12 +157,14 @@ declare global { ...@@ -154,12 +157,14 @@ declare global {
interface ElementChildrenAttribute { interface ElementChildrenAttribute {
children: any; children: any;
props: any;
} }
/*type LibraryManagedAttributes<Component, Props> = type LibraryManagedAttributes<Component, Props> =
Component extends { defaultProps: infer Defaults } Component extends { defaultProps: infer Defaults }
? Defaultize<Props, Defaults> ? Defaultize<Props, Defaults>
: Props;*/ : Props;
interface SVGAttributes extends HTMLAttributes { interface SVGAttributes extends HTMLAttributes {
accentHeight?: number | string; accentHeight?: number | string;
......
...@@ -183,18 +183,18 @@ const Predefined: {[key: string]: any} = { ...@@ -183,18 +183,18 @@ const Predefined: {[key: string]: any} = {
} }
} }
}; };
class Component extends Reactive { class Component<T> extends Reactive {
nodeName: string = null; nodeName: string = null;
el: HTMLElement|Text|any = null; el: HTMLElement|Text|any = null;
def = {}; def = {};
children: Component[] = null; children: Component<any>[] = null;
tree: TreeType = null; tree: Component<any> = null;
setters: PropSettersInterface<Component> = { setters: PropSettersInterface<Component<T>> = {
dangerouslySetInnerHTML: (_, htmlText) => _.el.innerHTML = htmlText, dangerouslySetInnerHTML: (_, htmlText) => _.el.innerHTML = htmlText,
text: (_, val) => _.el.innerText = val text: (_, val) => _.el.innerText = val
}; };
render(): TreeType{ render(): Component<any>{
this.el = document.createElement(this.nodeName); this.el = document.createElement(this.nodeName);
return this; return this;
} }
...@@ -214,7 +214,7 @@ class Component extends Reactive { ...@@ -214,7 +214,7 @@ class Component extends Reactive {
renderTo(where: HTMLElement) { renderTo(where: HTMLElement) {
where.appendChild(this.el); where.appendChild(this.el);
} }
addChild(child: Component) { addChild(child: Component<any>) {
child.renderTo(this.el); child.renderTo(this.el);
this.children.push(child); this.children.push(child);
} }
...@@ -249,8 +249,11 @@ class Component extends Reactive { ...@@ -249,8 +249,11 @@ class Component extends Reactive {
} }
} }
interface TextNodeProps {
value: string
}
class TextNode extends Component { class TextNode extends Component<TextNodeProps> {
constructor(){ constructor(){
super('TextNode'); super('TextNode');
} }
......
import {Component, h, PropSettersInterface} from '../Rjsx'; import {Component, h, PropSettersInterface, EventHandler} from '../Rjsx';
interface ButtonProps {
class Button extends Component { onClick: EventHandler<MouseEvent>
}
class Button extends Component<ButtonProps> {
button: Component = null; button: Component = null;
def = { def = {
type: 'Button', type: 'Button',
......
...@@ -5,12 +5,12 @@ let i, btn, item; ...@@ -5,12 +5,12 @@ let i, btn, item;
interface ItemProps { interface ItemProps {
onClick: Function onClick: Function
} }
class Item<ItemProps> extends Component { class Item extends Component<ItemProps> {
checkbox: Component = null; checkbox: Component<any> = null;
checkbox2: Component = null; checkbox2: Component<any> = null;
render(){ render(){
let checkbox3: Component; let checkbox3: Component<any>;
return <div> return <div>
{this.checkbox = <input disabled={false} type="checkbox"/>}<br/> {this.checkbox = <input disabled={false} type="checkbox"/>}<br/>
...@@ -26,10 +26,70 @@ class Item<ItemProps> extends Component { ...@@ -26,10 +26,70 @@ class Item<ItemProps> extends Component {
} }
} }
<div className='wrapper'> type positionType = 'left'|'top'|'right'|'bottom';
type sizeType = 'tiny'|'small'|'normal'|'big'|'large'|'enormous';
interface UIComponentProps {
disabled?: boolean;
hidden?: boolean;
selected?: boolean;
active?: boolean;
empty?: boolean;
placeholder?: string;
label?: {
position?: positionType,
text?: string | (Component<any>|string)[],
hidden?: boolean
};
description?: {
position?: positionType,
text?: string | (Component<any>|string)[]
};
error?: {
position?: positionType,
text?: string | (Component<any>|string)[]
};
validation?: null | Function | RegExp;
type: Readonly<string>;
style?: {
font?: {
size?: sizeType | number;
family?: string;
color?: string
},
size?: sizeType,
margin?: {
top?: number | string,
left?: number | string,
right?: number | string,
bottom?: number | string,
}
}
}
class UIComponent extends Component<UIComponentProps> {
def: UIComponentProps = {
disabled: false,
hidden: false,
label: {
position: 'top',
text: 'Label'
},
selected: false,
active: false,
empty: false,
placeholder: '',
style: {
size: 'normal',
margin: {top: '16px'}
}
};
}
<div className='wrapper'>
{item = <Item/>} {item = <Item/>}
{btn = <Button onClick={function(a,b,c){ {btn = <Button onClick={function(e,b,c){
item.checkbox.set({checked: !item.checkbox.state.checked}) item.checkbox.set({checked: !item.checkbox.state.checked})
}}>text1<b>text2</b>{i = <i x="2">text3</i>}text4</Button>} }}>text1<b>text2</b>{i = <i x="2">text3</i>}text4</Button>}
<Item/> <Item/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment