UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

71 lines (70 loc) 2.49 kB
/*! * KoliBri - The accessible HTML-Standard */ import { Log } from "../../../schema"; import { nameProp } from "../../props"; import { BaseController } from "../base-controller"; import { BaseWebComponent } from "../base-web-component"; import { ClickButtonController } from "../click-button/controller"; import { skeletonPropsConfig } from "./api"; export class SkeletonController extends BaseController { constructor(stateAccess) { super(stateAccess, skeletonPropsConfig); this.onKeydown = (event) => { if (event.key === 'Escape') { console.log('Show should be toggled'); void this.toggle(); } }; this.handleClick = () => { var _a, _b; Log.debug('Button clicked, count should be increased'); this.setState('count', ((_b = (_a = this.getState) === null || _a === void 0 ? void 0 : _a.call(this, 'count')) !== null && _b !== void 0 ? _b : 0) + 1); }; this.setButtonRef = (element) => { this.clickButtonCtrl.setButtonRef(element); }; this.clickButtonCtrl = new ClickButtonController(BaseWebComponent.stateLess); this.startLoadedEventInterval(); } componentWillLoad(props) { const { name } = props; this.watchName(name); this.clickButtonCtrl.componentWillLoad({ label: 'Click me', }); } watchName(value) { nameProp.apply(value, (v) => { this.setRenderProp('name', v); }); } toggle() { var _a, _b; this.setState('show', !((_b = (_a = this.getState) === null || _a === void 0 ? void 0 : _a.call(this, 'show')) !== null && _b !== void 0 ? _b : false)); } focus() { return this.clickButtonCtrl.focus(); } startLoadedEventInterval() { this.intervalId = setInterval(() => { var _a, _b; this.emitLoaded((_b = (_a = this.getState) === null || _a === void 0 ? void 0 : _a.call(this, 'count')) !== null && _b !== void 0 ? _b : 0); }, 2000); } emitLoaded(count) { if (this.onLoadedCallback) { this.onLoadedCallback(count); } } setOnLoadedCallback(callback) { this.onLoadedCallback = callback; } destroy() { if (this.intervalId) { clearInterval(this.intervalId); this.intervalId = undefined; } } } //# sourceMappingURL=controller.js.map