From a246c5145b56a568d9b66f8e16f647a2d5fd0ecf Mon Sep 17 00:00:00 2001 From: glennvorhes <gavorhes@wisc.edu> Date: Fri, 28 Jun 2019 14:37:34 -0500 Subject: [PATCH] use default react imports --- dist/reactComponents/Radio.d.ts | 4 ++++ dist/reactComponents/Radio.js | 4 ++++ dist/reactComponents/Radio.js.map | 2 +- src/reactComponents/Radio.tsx | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dist/reactComponents/Radio.d.ts b/dist/reactComponents/Radio.d.ts index 63ee0ee..2631698 100644 --- a/dist/reactComponents/Radio.d.ts +++ b/dist/reactComponents/Radio.d.ts @@ -35,6 +35,10 @@ interface iRadioConnected extends iRadioConnectedOpt { selectedIndex: number; } export declare class RadioConnected extends React.Component<iRadioConnected, {}> { + static defaultProps: { + inline: boolean; + classes: any[]; + }; render(): JSX.Element; } export {}; diff --git a/dist/reactComponents/Radio.js b/dist/reactComponents/Radio.js index 9b880dd..2a4a801 100644 --- a/dist/reactComponents/Radio.js +++ b/dist/reactComponents/Radio.js @@ -113,5 +113,9 @@ class RadioConnected extends React.Component { return React.createElement(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 }); } } +RadioConnected.defaultProps = { + inline: false, + classes: [] +}; exports.RadioConnected = RadioConnected; //# sourceMappingURL=Radio.js.map \ No newline at end of file diff --git a/dist/reactComponents/Radio.js.map b/dist/reactComponents/Radio.js.map index 6084bd3..a5b8a2f 100644 --- a/dist/reactComponents/Radio.js.map +++ b/dist/reactComponents/Radio.js.map @@ -1 +1 @@ -{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,+BAAgC;AAGhC,qBAAmB;AACnB,+CAAwC;AAiBxC,MAAM,SAAU,SAAQ,KAAK,CAAC,SAAyB;IAGnD,YAAY,KAAiB,EAAE,OAAe;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,KAAK,EAChB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AApBD,sBAoBC;AAcD,MAAa,cAAe,SAAQ,KAAK,CAAC,SAA8B;IAEpE,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;AAbD,wCAaC","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 iRadioItemOpt {\r\n index?: number\r\n}\r\n\r\nexport interface iRadioItem extends iRadioItemOpt{\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\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 _iRadioBaseOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface _iRadioBase extends _iRadioBaseOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n connected: boolean;\r\n}\r\n\r\ninterface iRadioBase extends _iRadioBase{\r\n selectedValueOrIndex: string|number;\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\n// interface _iRadioBaseOpt {\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n//\r\n// interface _iRadioBase extends _iRadioBaseOpt{\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// connected: boolean;\r\n// }\r\n//\r\n// interface iRadioBase extends _iRadioBase{\r\n// selectedValueOrIndex: string|number;\r\n// }\r\n\r\n// interface iRadio {\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n\r\n\r\nexport class Radio extends React.Component<{\r\n title: string,\r\n items: string[],\r\n callback: (val: string) => any,\r\n defaultValue: string,\r\n inline?: boolean,\r\n 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\ninterface iRadioConnectedOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface iRadioConnected extends iRadioConnectedOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n selectedIndex: number;\r\n}\r\n\r\nexport class RadioConnected extends React.Component<iRadioConnected, {}> {\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}\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;AAiBxC,MAAM,SAAU,SAAQ,KAAK,CAAC,SAAyB;IAGnD,YAAY,KAAiB,E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SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AApBD,sBAoBC;AAcD,MAAa,cAAe,SAAQ,KAAK,CAAC,SAA8B;IAMpE,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;;AAfM,2BAAY,GAAG;IAClB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,EAAE;CACd,CAAA;AAJL,wCAiBC","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 iRadioItemOpt {\r\n index?: number\r\n}\r\n\r\nexport interface iRadioItem extends iRadioItemOpt{\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\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 _iRadioBaseOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface _iRadioBase extends _iRadioBaseOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n connected: boolean;\r\n}\r\n\r\ninterface iRadioBase extends _iRadioBase{\r\n selectedValueOrIndex: string|number;\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\n// interface _iRadioBaseOpt {\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n//\r\n// interface _iRadioBase extends _iRadioBaseOpt{\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// connected: boolean;\r\n// }\r\n//\r\n// interface iRadioBase extends _iRadioBase{\r\n// selectedValueOrIndex: string|number;\r\n// }\r\n\r\n// interface iRadio {\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n\r\n\r\nexport class Radio extends React.Component<{\r\n title: string,\r\n items: string[],\r\n callback: (val: string) => any,\r\n defaultValue: string,\r\n inline?: boolean,\r\n 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\ninterface iRadioConnectedOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface iRadioConnected extends iRadioConnectedOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n selectedIndex: number;\r\n}\r\n\r\nexport class RadioConnected extends React.Component<iRadioConnected, {}> {\r\n static defaultProps = {\r\n inline: false,\r\n classes: []\r\n }\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}\r\n\r\n"]} \ No newline at end of file diff --git a/src/reactComponents/Radio.tsx b/src/reactComponents/Radio.tsx index e309de8..fb01c49 100644 --- a/src/reactComponents/Radio.tsx +++ b/src/reactComponents/Radio.tsx @@ -197,6 +197,10 @@ interface iRadioConnected extends iRadioConnectedOpt{ } export class RadioConnected extends React.Component<iRadioConnected, {}> { + static defaultProps = { + inline: false, + classes: [] + } render() { return <RadioBase -- GitLab