preact-material-components
Version:
preact wrapper for "Material Components for the web"
45 lines • 1.75 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { MDCRadio } from '@material/radio/';
import { h } from 'preact';
import MaterialComponent from '../Base/MaterialComponent';
export class Radio extends MaterialComponent {
constructor() {
super(...arguments);
this.componentName = 'radio';
this.mdcProps = ['disabled'];
this.mdcNotifyProps = ['checked'];
}
componentDidMount() {
super.componentDidMount();
if (this.control) {
this.MDComponent = new MDCRadio(this.control);
}
this.afterComponentDidMount();
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.MDComponent) {
this.MDComponent.destroy();
}
}
materialDom(allprops) {
const { className } = allprops, props = __rest(allprops, ["className"]);
return (h("div", { className: className, ref: this.setControlRef },
h("input", Object.assign({ className: "mdc-radio__native-control", type: "radio" }, props)),
h("div", { className: "mdc-radio__background" },
h("div", { className: "mdc-radio__outer-circle" }),
h("div", { className: "mdc-radio__inner-circle" }))));
}
}
export default Radio;
//# sourceMappingURL=index.js.map