diff --git a/dist/reactComponents/Radio.d.ts b/dist/reactComponents/Radio.d.ts index 54011fec219fb9c27f31da0aae2dedda8bb41461..43692f31adf44f59f7598a729f49f74c261cbbc6 100644 --- a/dist/reactComponents/Radio.d.ts +++ b/dist/reactComponents/Radio.d.ts @@ -19,6 +19,7 @@ export declare class Radio extends React.Component<{ callback: (val: string) => any; inline?: boolean; defaultValue: string; + classes?: string[]; }, null> { render(): JSX.Element; } @@ -28,6 +29,7 @@ export declare class RadioConnected extends React.Component<{ callback: (val: string) => any; inline?: boolean; selectedIndex: number; + classes?: string[]; }, null> { render(): JSX.Element; } diff --git a/dist/reactComponents/Radio.jsx b/dist/reactComponents/Radio.jsx index 710ba696e503c5ab780db971d745dd6186370c1f..733a62007d3d13f1cce265f129d25f440994e916 100644 --- a/dist/reactComponents/Radio.jsx +++ b/dist/reactComponents/Radio.jsx @@ -67,13 +67,6 @@ var RadioBase = (function (_super) { } RadioBase.prototype.render = function () { var _this = this; - var style = {}; - if (this.inline) { - style = { - display: 'inline-block', - padding: '0 5px' - }; - } var arr = []; for (var i = 0; i < this.props.items.length; i++) { var itemProps = { @@ -95,7 +88,11 @@ var RadioBase = (function (_super) { } arr.push(<RadioItem {...itemProps}/>); } - return <div className="radio-list"> + var classes = ['radio-list']; + if (this.props.classes) { + classes = classes.concat(this.props.classes); + } + return <div className={classes.join(' ')}> <h4>{this.props.title}</h4> <ul style={{ listStyle: 'none' }}> {arr} @@ -110,7 +107,7 @@ var Radio = (function (_super) { return _super !== null && _super.apply(this, arguments) || this; } Radio.prototype.render = function () { - return <RadioBase title={this.props.title} items={this.props.items} callback={this.props.callback} inline={this.props.inline} selectedValueOrIndex={this.props.defaultValue} connected={false}/>; + return <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}/>; }; return Radio; }(reactAndRedux_1.React.Component)); @@ -121,7 +118,7 @@ var RadioConnected = (function (_super) { return _super !== null && _super.apply(this, arguments) || this; } RadioConnected.prototype.render = function () { - return <RadioBase title={this.props.title} items={this.props.items} callback={this.props.callback} inline={this.props.inline} selectedValueOrIndex={this.props.selectedIndex} connected={true}/>; + return <RadioBase title={this.props.title} items={this.props.items} callback={this.props.callback} inline={this.props.inline} selectedValueOrIndex={this.props.selectedIndex} connected={true} classes={this.props.classes}/>; }; return RadioConnected; }(reactAndRedux_1.React.Component)); diff --git a/dist/reactComponents/Radio.jsx.map b/dist/reactComponents/Radio.jsx.map index 9cf2b9c8875de453c347b3cb262b69c64444139f..6fa1290d9ad4bf1bc82c8afd061678e98b58aba9 100644 --- a/dist/reactComponents/Radio.jsx.map +++ b/dist/reactComponents/Radio.jsx.map @@ -1 +1 @@ -{"version":3,"file":"Radio.jsx","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;AAGH,iDAAsC;AAEtC,qBAAmB;AACnB,6CAAwC;AAaxC;IAAwB,6BAAiC;IAGrD,mBAAY,KAAiB,EAAE,OAAe;QAA9C,YACI,kBAAM,KAAK,EAAE,OAAO,CAAC,SAExB;QADG,KAAI,CAAC,IAAI,GAAG,kBAAQ,EAAE,CAAA;;IAC1B,CAAC;IAGD,0BAAM,GAAN;QAAA,iBAgCC;QA/BG,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACpB,KAAK,GAAG;gBACJ,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE,OAAO;aACnB,CAAC;QACN,CAAC;QAED,IAAI,KAAK,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,I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,KAAK,CAAC,KAAK,CAAC,CACxB,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC9B,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAC1B,oBAAoB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAC/C,SAAS,CAAC,CAAC,IAAI,CAAC,EAClB,CAAA;IACN,CAAC;IACL,qBAAC;AAAD,CAAC,AAZD,CAAoC,qBAAK,CAAC,SAAS,GAYlD;AAZY,wCAAc","sourcesContent":["/**\r\n * Created by glenn on 6/12/2017.\r\n */\r\n\r\n\r\nimport {React} from './reactAndRedux';\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, null> {\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}\r\n\r\nclass RadioBase extends React.Component<iRadioBase, null> {\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 let style = {};\r\n if (this.inline) {\r\n style = {\r\n display: 'inline-block',\r\n padding: '0 5px'\r\n }\r\n }\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 return <div className=\"radio-list\">\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<{ title: string, items: string[], callback: (val: string) => any, inline?: boolean, defaultValue: string }, null> {\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.defaultValue}\r\n connected={false}\r\n />\r\n }\r\n}\r\n\r\nexport class RadioConnected extends React.Component<{ title: string, items: string[], callback: (val: string) => any, inline?: boolean, selectedIndex: number }, null> {\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 />\r\n }\r\n}"]} \ No newline at end of file +{"version":3,"file":"Radio.jsx","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;AAGH,iDAAsC;AAEtC,qBAAmB;AACnB,6CAAwC;AAaxC;IAAwB,6BAAiC;IAGrD,mBAAY,KAAiB,EAAE,OAAe;QAA9C,YACI,kBAAM,KAAK,EAAE,OAAO,CAAC,SAExB;QADG,KAAI,CAAC,IAAI,GAAG,kBAAQ,EAAE,CAAA;;IAC1B,CAAC;IAGD,0BAAM,GAAN;QAAA,iBAgCC;QA/BG,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACpB,KAAK,GAAG;gBACJ,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE,OAAO;aACnB,CAAC;QACN,CAAC;QAED,IAAI,KAAK,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YAC5F,QAAQ,EAAE,UAAC,GAAkC;gBACzC,KAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACpC,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;YAC9B,CAAC;YACD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YAC3B,cAAc,EAAG,IAAI,C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AAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAC/C,SAAS,CAAC,CAAC,IAAI,CAAC,CAChB,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAC9B,CAAA;IACN,CAAC;IACL,qBAAC;AAAD,CAAC,AAfD,CAAoC,qBAAK,CAAC,SAAS,GAelD;AAfY,wCAAc","sourcesContent":["/**\r\n * Created by glenn on 6/12/2017.\r\n */\r\n\r\n\r\nimport {React} from './reactAndRedux';\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, null> {\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, null> {\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[] }, null> {\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[] }, null> {\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 diff --git a/src/reactComponents/Radio.tsx b/src/reactComponents/Radio.tsx index 13526f3043ea1c6fe83937619797ed0d9bb27a44..1ff39c0f8246b86f29e884dbbfe5cdff806bf628 100644 --- a/src/reactComponents/Radio.tsx +++ b/src/reactComponents/Radio.tsx @@ -70,6 +70,7 @@ interface iRadioBase { inline?: boolean; selectedValueOrIndex: string|number; connected: boolean; + classes?: string[] } class RadioBase extends React.Component<iRadioBase, null> { @@ -83,13 +84,6 @@ class RadioBase extends React.Component<iRadioBase, null> { } render() { - let style = {}; - if (this.inline) { - style = { - display: 'inline-block', - padding: '0 5px' - } - } let arr = []; @@ -116,7 +110,13 @@ class RadioBase extends React.Component<iRadioBase, null> { arr.push(<RadioItem {...itemProps}/>) } - return <div className="radio-list"> + let classes = ['radio-list']; + + if (this.props.classes){ + classes = classes.concat(this.props.classes); + } + + return <div className={classes.join(' ')}> <h4>{this.props.title}</h4> <ul style={{listStyle: 'none'}}> {arr} @@ -126,9 +126,12 @@ class RadioBase extends React.Component<iRadioBase, null> { } -export class Radio extends React.Component<{ title: string, items: string[], callback: (val: string) => any, inline?: boolean, defaultValue: string }, null> { +export class Radio extends React.Component<{ + title: string, items: string[], callback: (val: string) => any, inline?: boolean, + defaultValue: string, classes?: string[] }, null> { render() { + return <RadioBase title={this.props.title} items={this.props.items} @@ -136,11 +139,14 @@ export class Radio extends React.Component<{ title: string, items: string[], cal inline={this.props.inline} selectedValueOrIndex={this.props.defaultValue} connected={false} + classes={this.props.classes} /> } } -export class RadioConnected extends React.Component<{ title: string, items: string[], callback: (val: string) => any, inline?: boolean, selectedIndex: number }, null> { +export class RadioConnected extends React.Component<{ + title: string, items: string[], callback: (val: string) => any, inline?: boolean, + selectedIndex: number, classes?: string[] }, null> { render() { return <RadioBase @@ -150,6 +156,7 @@ export class RadioConnected extends React.Component<{ title: string, items: stri inline={this.props.inline} selectedValueOrIndex={this.props.selectedIndex} connected={true} + classes={this.props.classes} /> } } \ No newline at end of file