Comparing version 0.0.12 to 0.0.13
/*! | ||
* Eyzy v0.0.10 | ||
* Eyzy v0.0.12 | ||
* (c) 2022 amsik | ||
@@ -469,16 +469,48 @@ * Released under the MIT License. | ||
getName._ = 0; | ||
function RadioGroup(props) { | ||
var options = props.options, name = props.name, value = props.value, onChange = props.onChange; | ||
var rName = getName(name); | ||
var selectedValue = value; | ||
if (selectedValue === undefined && options[0]) { | ||
selectedValue = options[0].value || options[0].label; | ||
var RadioGroup = /** @class */ (function (_super) { | ||
__extends(RadioGroup, _super); | ||
function RadioGroup() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.parentEl = React.createRef(); | ||
_this.handleChange = function (e) { | ||
var onChange = _this.props.onChange; | ||
var target = e.target; | ||
onChange && onChange(target.value); | ||
try { | ||
var bounds = target.parentNode.getBoundingClientRect(); | ||
var parentEl = _this.parentEl.current; | ||
var groupWrap = parentEl.parentNode; | ||
var groupWrapWidth = groupWrap.clientWidth; | ||
var groupWrapBounds = groupWrap.getBoundingClientRect(); | ||
var _a = [ | ||
bounds.left - groupWrapBounds.left, | ||
bounds.right - groupWrapBounds.left | ||
], labelLeft = _a[0], labelRight = _a[1]; | ||
if (labelRight > groupWrapWidth) { | ||
groupWrap.scrollLeft += labelRight - groupWrapWidth + 25; | ||
} | ||
else if (labelLeft < 0) { | ||
groupWrap.scrollLeft += (labelLeft - 25); | ||
} | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
}; | ||
return _this; | ||
} | ||
var handleChange = function (e) { | ||
onChange(e.target.value); | ||
RadioGroup.prototype.render = function () { | ||
var _this = this; | ||
var _a = this.props, options = _a.options, name = _a.name, value = _a.value; | ||
var rName = getName(name); | ||
var selectedValue = value; | ||
if (selectedValue === undefined && options[0]) { | ||
selectedValue = options[0].value || options[0].label; | ||
} | ||
return (React.createElement("div", { className: 'eyzy-radio-group', ref: this.parentEl }, options.map(function (o, i) { return (React.createElement("label", { key: i, className: cn({ active: isChecked(o, selectedValue) }) }, | ||
React.createElement("input", { type: "radio", name: rName, value: o.value || o.label, disabled: o.disabled, checked: isChecked(o, selectedValue), onChange: _this.handleChange }), | ||
o.label)); }))); | ||
}; | ||
return (React.createElement("div", { className: 'eyzy-radio-group' }, options.map(function (o, i) { return (React.createElement("label", { key: i, className: cn({ active: isChecked(o, selectedValue) }) }, | ||
React.createElement("input", { type: "radio", name: rName, value: o.value || o.label, disabled: o.disabled, checked: isChecked(o, selectedValue), onChange: handleChange }), | ||
o.label)); }))); | ||
} | ||
return RadioGroup; | ||
}(React.PureComponent)); | ||
//# sourceMappingURL=RadioGroup.js.map | ||
@@ -485,0 +517,0 @@ |
{ | ||
"name": "eyzy", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"author": "Kostiantyn", | ||
@@ -5,0 +5,0 @@ "description": "React UI Toolkit", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122185
1315