preact-material-components
Version:
preact wrapper for "Material Components for the web"
34 lines • 1.44 kB
JavaScript
import { MDCCheckbox } from '@material/checkbox/';
import { h } from 'preact';
import MaterialComponent from '../Base/MaterialComponent';
export class Checkbox extends MaterialComponent {
constructor() {
super(...arguments);
this.componentName = 'checkbox';
this.mdcProps = ['disabled'];
this.mdcNotifyProps = ['checked', 'indeterminate', 'disabled'];
}
componentDidMount() {
super.componentDidMount();
if (this.control) {
this.MDComponent = new MDCCheckbox(this.control);
}
this.afterComponentDidMount();
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.MDComponent) {
this.MDComponent.destroy();
}
}
materialDom(allprops) {
return (h("div", { ref: this.setControlRef },
h("input", Object.assign({ type: "checkbox", className: "mdc-checkbox__native-control" }, allprops)),
h("div", { className: "mdc-checkbox__background" },
h("svg", { version: "1.1", className: "mdc-checkbox__checkmark", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
h("path", { className: "mdc-checkbox__checkmark-path", fill: "none", stroke: "white", d: "M1.73,12.91 8.1,19.28 22.79,4.59" })),
h("div", { className: "mdc-checkbox__mixedmark" }))));
}
}
export default Checkbox;
//# sourceMappingURL=index.js.map