1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 4× 9× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 2× 1× 1× 1× 1× 1× 1× 1× | 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { Eif (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _uxcoreCellField = require('uxcore-cell-field'); var _uxcoreCellField2 = _interopRequireDefault(_uxcoreCellField); var _objectAssign = require('object-assign'); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _uxcoreRadiogroup = require('uxcore-radiogroup'); var _uxcoreRadiogroup2 = _interopRequireDefault(_uxcoreRadiogroup); var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { Iif (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { Iif (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } var Item = _uxcoreRadiogroup2['default'].Item; var RadioField = function (_CellField) { _inherits(RadioField, _CellField); function RadioField() { _classCallCheck(this, RadioField); return _possibleConstructorReturn(this, _CellField.apply(this, arguments)); } RadioField.prototype.getTextMap = function getTextMap() { var me = this; var obj = {}; var _me$props = me.props, column = _me$props.column, rowData = _me$props.rowData; var config = column.config, renderChildren = column.renderChildren; Iif (column.renderChildren) { renderChildren().forEach(function (item) { obj[item.props.value] = item.props.text; }); } else Eif (config && config.data) { var configData = []; Iif (typeof config.data === 'function') { configData = config.data(rowData); } Eif (config.data instanceof Array) { configData = config.data; } configData.forEach(function (item) { obj[item.value] = item.text; }); } return obj; }; RadioField.prototype.renderChildren = function renderChildren() { var me = this; var _me$props2 = me.props, column = _me$props2.column, rowData = _me$props2.rowData; var renderChildren = column.renderChildren, config = column.config; Iif (renderChildren) { return renderChildren(rowData); } Eif (config) { var configData = []; Iif (typeof config.data === 'function') { configData = config.data(rowData); } Eif (config.data instanceof Array) { configData = config.data; } return configData.map(function (item, index) { return _react2['default'].createElement(Item, { key: index, value: item.value, text: item.text, disabled: item.disabled }); }); } return []; }; RadioField.prototype.renderContent = function renderContent() { var me = this; var textMap = me.getTextMap(); var fieldProps = { onChange: function onChange(value) { me.handleDataChange({ text: textMap[value], value: value }); }, value: me.props.value }; Eif (me.props.column.config) { var customProps = _extends({}, me.props.column.config); Object.keys(fieldProps).forEach(function (item) { delete customProps[item]; }); (0, _objectAssign2['default'])(fieldProps, customProps); } return _react2['default'].createElement( _uxcoreRadiogroup2['default'], fieldProps, me.renderChildren() ); }; return RadioField; }(_uxcoreCellField2['default']); RadioField.propTypes = (0, _objectAssign2['default'])({}, _uxcoreCellField2['default'].propTypes); RadioField.defaultProps = (0, _objectAssign2['default'])({}, _uxcoreCellField2['default'].defaultProps); exports['default'] = RadioField; module.exports = exports['default']; |