Repository URL to install this package:
|
Version:
2.0.2 ▾
|
"use strict";
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {
value: true
});
const react_1 = __importDefault(require("react"));
const mobx_react_1 = require("xmobx/mobx-react");
/**
* @todo - this should be able to be a PureComponent
*
* @todo use more `id` for perf & ada
* => aria-labelledby
*
* @tutorial https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/radiogroup
* @api @ada https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/examples/radio/radio.html
*/
let RadioGroupMolecule = class RadioGroupMolecule extends react_1.default.Component {
constructor(props) {
super(props);
/**
* === @render ===
*/
this.renderItem = (item, index) => {
// console.log({ item })
const {
onChange,
renderItem
} = this.props;
return renderItem(Object.assign({}, item, {
onChange
}), index, this.state);
};
this.state = props.state;
}
get attributes() {
const {
identifier
} = this.props;
const attributes = {
id: identifier
};
return attributes;
}
get list() {
return this.state.inputsList.map(this.renderItem);
}
render() {
// @todo styled section?
return react_1.default.createElement("section", Object.assign({}, this.attributes, {
role: "radiogroup"
}), this.list);
}
};
RadioGroupMolecule = __decorate([mobx_react_1.observer], RadioGroupMolecule);
exports.RadioGroupMolecule = RadioGroupMolecule;
exports.default = RadioGroupMolecule; //# sourceMappingURL=RadioGroupStateless.js.map