Skip to content
Snippets Groups Projects
Radio.js.map 8.25 KiB
Newer Older
Glenn Vorhes's avatar
Glenn Vorhes committed
{"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,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YAC5F,QAAQ,EAAE,CAAC,GAAkC,EAAE,EAAE;gBAC7C,IAAI,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,CAAC,KAAK,CAAC,OAAO;SACtC,CAAC;QAEF,IAAI,IAAI,CAAC,KAAK,CAAC,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C,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}"]}