UNPKG

@public-ui/components

Version:

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

62 lines (61 loc) 1.93 kB
/*! * KoliBri - The accessible HTML-Standard */ import { clampedNumberValueProp, labelProp, maxProp, unitProp, variantProgressProp } from "../../props"; import { BaseController } from "../base-controller"; import { progressPropsConfig } from "./api"; export class ProgressController extends BaseController { constructor(stateAccess) { super(stateAccess, progressPropsConfig); } componentWillLoad(props) { const { label, max, unit, value, variant } = props; this.watchLabel(label); this.watchMax(max); this.watchUnit(unit); this.watchValue(value); this.watchVariant(variant); this.setState('liveValue', this.getRenderProp('value')); this.startLiveValueInterval(); } watchLabel(value) { labelProp.apply(value, (v) => { this.setRenderProp('label', v); }); } watchMax(value) { maxProp.apply(value, (v) => { this.setRenderProp('max', v); this.watchValue(this.getRawProp('value')); }); } watchUnit(value) { unitProp.apply(value, (v) => { this.setRenderProp('unit', v); }); } watchValue(value) { this.setRawProp('value', value); clampedNumberValueProp.apply(value, (v) => { this.setRenderProp('value', v); }, { min: 0, max: this.getRenderProp('max') }); } watchVariant(value) { variantProgressProp.apply(value, (v) => { this.setRenderProp('variant', v); }); } startLiveValueInterval() { this.interval = setInterval(() => { const value = this.getRenderProp('value'); this.setState('liveValue', value); }, 5000); } destroy() { if (this.interval) { clearInterval(this.interval); this.interval = undefined; } } } //# sourceMappingURL=controller.js.map