Skip to content
Snippets Groups Projects
Commit da3310dc authored by Glenn Vorhes's avatar Glenn Vorhes
Browse files

use default react imports

parent 145b53e9
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,8 @@ export interface iRadioItem {
checked: boolean;
inline: boolean;
change: (s: string) => any;
connected?: boolean;
index?: number;
connected: boolean;
index: number;
}
export declare class Radio extends React.Component<{
title: string;
......
......@@ -42,6 +42,10 @@ class RadioItem extends React.Component {
React.createElement("label", { htmlFor: this.guid }, this.props.text));
}
}
RadioItem.defaultProps = {
connected: false,
index: null
};
class RadioBase extends React.Component {
constructor(props, context) {
super(props, context);
......@@ -79,6 +83,9 @@ class RadioBase extends React.Component {
React.createElement("ul", { style: { listStyle: 'none' } }, arr));
}
}
RadioBase.defaultProps = {
inline: false
};
class Radio extends React.Component {
render() {
return React.createElement(RadioBase, { title: this.props.title, items: this.props.items, callback: this.props.callback, inline: this.props.inline, selectedValueOrIndex: this.props.defaultValue, connected: false, classes: this.props.classes });
......
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,+BAAgC;AAGhC,qBAAmB;AACnB,+CAAwC;AAaxC,MAAM,SAAU,SAAQ,KAAK,CAAC,SAAyB;IAGnD,YAAY,KAAiB,EAAE,OAAe;QAC1C,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,kBAAQ,EAAE,CAAA;IAC1B,CAAC;IAGD,MAAM;QACF,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACnB,KAAK,GAAG;gBACJ,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE,OAAO;aACnB,CAAC;SACL;QAED,IAAI,KAAK,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAA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C;YACpC,gCAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM;YAC3B,4BAAI,KAAK,EAAE,EAAC,SAAS,EAAE,MAAM,EAAC,IACzB,GAAG,CACH,CACH,CAAA;IACV,CAAC;CACJ;AAGD,MAAa,KAAM,SAAQ,KAAK,CAAC,SAEkB;IAE/C,MAAM;QAEF,OAAO,oBAAC,SAAS,IACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC7C,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AAhBD,sBAgBC;AAED,MAAa,cAAe,SAAQ,KAAK,CAAC,SAEU;IAEhD,MAAM;QACF,OAAO,oBAAC,SAAS,IACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAC9C,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AAfD,wCAeC","sourcesContent":["/**\r\n * Created by glenn on 6/12/2017.\r\n */\r\n\r\n\r\nimport React = require(\"react\");\r\n\r\nimport $ = require('jquery');\r\nimport 'jquery-ui';\r\nimport makeGuid from '../util/makeGuid';\r\nimport {ChangeEvent} from \"react\";\r\n\r\nexport interface iRadioItem{\r\n groupId: string;\r\n text: string;\r\n checked: boolean;\r\n inline: boolean;\r\n change: (s: string) => any;\r\n connected?: boolean;\r\n index?: number\r\n}\r\n\r\nclass RadioItem extends React.Component<iRadioItem, {}> {\r\n guid: string;\r\n\r\n constructor(props: iRadioItem, context: Object){\r\n super(props, context);\r\n this.guid = makeGuid()\r\n }\r\n\r\n\r\n render() {\r\n let style = {};\r\n if (this.props.inline) {\r\n style = {\r\n display: 'inline-block',\r\n padding: '0 5px'\r\n };\r\n }\r\n\r\n let props = {\r\n id: this.guid,\r\n type: \"radio\",\r\n name: this.props.groupId,\r\n value: typeof this.props.index == 'undefined' ? this.props.text : this.props.index.toFixed(),\r\n onChange: (evt: ChangeEvent<HTMLInputElement>) => {\r\n this.props.change(evt.target.value);\r\n evt.target.checked = true;\r\n },\r\n checked: this.props.checked,\r\n defaultChecked: this.props.checked\r\n };\r\n\r\n if (this.props.connected) {\r\n delete props.defaultChecked;\r\n } else {\r\n delete props.checked\r\n }\r\n\r\n return <li style={style}>\r\n <input {...props}/>\r\n <label htmlFor={this.guid}>{this.props.text}</label>\r\n </li>;\r\n }\r\n}\r\n\r\ninterface iRadioBase {\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n inline?: boolean;\r\n selectedValueOrIndex: string|number;\r\n connected: boolean;\r\n classes?: string[]\r\n}\r\n\r\nclass RadioBase extends React.Component<iRadioBase, {}> {\r\n inline: boolean;\r\n groupId: string;\r\n\r\n constructor(props: iRadioBase, context: Object) {\r\n super(props, context);\r\n this.inline = this.props.inline || false;\r\n this.groupId = this.props.title.toLowerCase().replace(/ /g, '');\r\n }\r\n\r\n render() {\r\n\r\n let arr = [];\r\n\r\n for (let i = 0; i < this.props.items.length; i++) {\r\n\r\n let itemProps = {\r\n groupId: this.groupId,\r\n text: this.props.items[i],\r\n inline: this.props.inline,\r\n change: (s: string) => (this.props.callback(s)),\r\n key: this.props.items[i],\r\n connected: this.props.connected || false,\r\n checked: false,\r\n index: i\r\n };\r\n\r\n if (typeof this.props.selectedValueOrIndex == 'number'){\r\n itemProps.checked = i == this.props.selectedValueOrIndex;\r\n } else {\r\n itemProps.checked = this.props.items[i] == this.props.selectedValueOrIndex;\r\n delete itemProps.index\r\n }\r\n\r\n arr.push(<RadioItem {...itemProps}/>)\r\n }\r\n\r\n let classes = ['radio-list'];\r\n\r\n if (this.props.classes){\r\n classes = classes.concat(this.props.classes);\r\n }\r\n\r\n return <div className={classes.join(' ')}>\r\n <h4>{this.props.title}</h4>\r\n <ul style={{listStyle: 'none'}}>\r\n {arr}\r\n </ul>\r\n </div>\r\n }\r\n}\r\n\r\n\r\nexport class Radio extends React.Component<{\r\n title: string, items: string[], callback: (val: string) => any, inline?: boolean,\r\n defaultValue: string, classes?: string[] }, {}> {\r\n\r\n render() {\r\n\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.defaultValue}\r\n connected={false}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}\r\n\r\nexport class RadioConnected extends React.Component<{\r\n title: string, items: string[], callback: (val: string) => any, inline?: boolean,\r\n selectedIndex: number, classes?: string[] }, {}> {\r\n\r\n render() {\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.selectedIndex}\r\n connected={true}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}"]}
\ No newline at end of file
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,+BAAgC;AAGhC,qBAAmB;AACnB,+CAAwC;AAaxC,MAAM,SAAU,SAAQ,KAAK,CAAC,SAAyB;IAQnD,YAAY,KAAiB,EAAE,OAAe;QAC1C,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,kBAAQ,EAAE,CAAA;I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,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAC9C,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AAfD,wCAeC","sourcesContent":["/**\r\n * Created by glenn on 6/12/2017.\r\n */\r\n\r\n\r\nimport React = require(\"react\");\r\n\r\nimport $ = require('jquery');\r\nimport 'jquery-ui';\r\nimport makeGuid from '../util/makeGuid';\r\nimport {ChangeEvent} from \"react\";\r\n\r\nexport interface iRadioItem{\r\n groupId: string;\r\n text: string;\r\n checked: boolean;\r\n inline: boolean;\r\n change: (s: string) => any;\r\n connected: boolean;\r\n index: number\r\n}\r\n\r\nclass RadioItem extends React.Component<iRadioItem, {}> {\r\n static defaultProps = {\r\n connected: false,\r\n index: null\r\n }\r\n\r\n guid: string;\r\n\r\n constructor(props: iRadioItem, context: Object){\r\n super(props, context);\r\n this.guid = makeGuid()\r\n }\r\n\r\n\r\n render() {\r\n let style = {};\r\n if (this.props.inline) {\r\n style = {\r\n display: 'inline-block',\r\n padding: '0 5px'\r\n };\r\n }\r\n\r\n let props = {\r\n id: this.guid,\r\n type: \"radio\",\r\n name: this.props.groupId,\r\n value: typeof this.props.index == 'undefined' ? this.props.text : this.props.index.toFixed(),\r\n onChange: (evt: ChangeEvent<HTMLInputElement>) => {\r\n this.props.change(evt.target.value);\r\n evt.target.checked = true;\r\n },\r\n checked: this.props.checked,\r\n defaultChecked: this.props.checked\r\n };\r\n\r\n if (this.props.connected) {\r\n delete props.defaultChecked;\r\n } else {\r\n delete props.checked\r\n }\r\n\r\n return <li style={style}>\r\n <input {...props}/>\r\n <label htmlFor={this.guid}>{this.props.text}</label>\r\n </li>;\r\n }\r\n}\r\n\r\ninterface iRadioBase {\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n inline: boolean;\r\n selectedValueOrIndex: string|number;\r\n connected: boolean;\r\n classes?: string[]\r\n}\r\n\r\nclass RadioBase extends React.Component<iRadioBase, {}> {\r\n static defaultProps = {\r\n inline: false\r\n };\r\n\r\n inline: boolean;\r\n groupId: string;\r\n\r\n constructor(props: iRadioBase, context: Object) {\r\n super(props, context);\r\n this.inline = this.props.inline || false;\r\n this.groupId = this.props.title.toLowerCase().replace(/ /g, '');\r\n }\r\n\r\n render() {\r\n\r\n let arr = [];\r\n\r\n for (let i = 0; i < this.props.items.length; i++) {\r\n\r\n let itemProps = {\r\n groupId: this.groupId,\r\n text: this.props.items[i],\r\n inline: this.props.inline,\r\n change: (s: string) => (this.props.callback(s)),\r\n key: this.props.items[i],\r\n connected: this.props.connected || false,\r\n checked: false,\r\n index: i\r\n };\r\n\r\n if (typeof this.props.selectedValueOrIndex == 'number'){\r\n itemProps.checked = i == this.props.selectedValueOrIndex;\r\n } else {\r\n itemProps.checked = this.props.items[i] == this.props.selectedValueOrIndex;\r\n delete itemProps.index\r\n }\r\n\r\n arr.push(<RadioItem {...itemProps}/>)\r\n }\r\n\r\n let classes = ['radio-list'];\r\n\r\n if (this.props.classes){\r\n classes = classes.concat(this.props.classes);\r\n }\r\n\r\n return <div className={classes.join(' ')}>\r\n <h4>{this.props.title}</h4>\r\n <ul style={{listStyle: 'none'}}>\r\n {arr}\r\n </ul>\r\n </div>\r\n }\r\n}\r\n\r\n\r\nexport class Radio extends React.Component<{\r\n title: string, items: string[], callback: (val: string) => any, inline?: boolean,\r\n defaultValue: string, classes?: string[] }, {}> {\r\n\r\n render() {\r\n\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.defaultValue}\r\n connected={false}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}\r\n\r\nexport class RadioConnected extends React.Component<{\r\n title: string, items: string[], callback: (val: string) => any, inline?: boolean,\r\n selectedIndex: number, classes?: string[] }, {}> {\r\n\r\n render() {\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.selectedIndex}\r\n connected={true}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}"]}
\ No newline at end of file
......@@ -2,12 +2,14 @@
* Created by glenn on 7/6/2017.
*/
import React = require("react");
export interface iSlider {
export interface iSliderOpt {
steps?: number;
animate?: boolean;
defaultAnimationInterval?: number;
value?: number;
}
export interface iSlider extends iSliderOpt {
change: (d: number) => any;
steps: number;
animate: boolean;
defaultAnimationInterval: number;
value: number;
}
export declare class Slider extends React.Component<iSlider, {}> {
static defaultProps: {
......
This diff is collapsed.
......@@ -16,11 +16,16 @@ export interface iRadioItem{
checked: boolean;
inline: boolean;
change: (s: string) => any;
connected?: boolean;
index?: number
connected: boolean;
index: number
}
class RadioItem extends React.Component<iRadioItem, {}> {
static defaultProps = {
connected: false,
index: null
}
guid: string;
constructor(props: iRadioItem, context: Object){
......@@ -68,13 +73,17 @@ interface iRadioBase {
title: string;
items: string[];
callback: (val: string) => any;
inline?: boolean;
inline: boolean;
selectedValueOrIndex: string|number;
connected: boolean;
classes?: string[]
}
class RadioBase extends React.Component<iRadioBase, {}> {
static defaultProps = {
inline: false
};
inline: boolean;
groupId: string;
......
......@@ -8,12 +8,15 @@ import makeGuid from '../util/makeGuid';
import {ChangeEvent} from "react";
import {get_browser} from '../util/get_browser';
export interface iSlider {
export interface iSliderOpt {
steps?: number;
animate?: boolean;
defaultAnimationInterval?: number;
value?: number;
}
export interface iSlider extends iSliderOpt{
change: (d: number) => any;
steps: number;
animate: boolean;
defaultAnimationInterval: number;
value: number;
}
export class Slider extends React.Component<iSlider, {}> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment