UNPKG

stencil-quantum

Version:

Experience the quantum realm of stencil.

157 lines (156 loc) 3.93 kB
import { Component, h, Prop, Watch, Element, Event } from '@stencil/core'; import { Provider } from '../../libs/provider'; import { throwQuantum } from '../../libs'; export class QuantumProvider { componentWillLoad() { var _a, _b, _c, _d, _e, _f; try { this.name = (_c = (_b = (_a = this.bind) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : this.name) !== null && _c !== void 0 ? _c : ""; this.namespace = (_e = (_d = this.bind) === null || _d === void 0 ? void 0 : _d.namespace) !== null && _e !== void 0 ? _e : this.namespace; this.debug = ((_f = this.bind) === null || _f === void 0 ? void 0 : _f.debug) || this.debug; this.provider = Provider.create(this.el, this.name, this.value, this.namespace, this.debug); this.provider.listen(val => { try { this.update.emit({ value: val, provider: this.provider }); } catch (err) { throwQuantum(this.el, err); } }, true); } catch (err) { throwQuantum(this.el, err); } } onValue(val) { try { this.provider.provide(val); } catch (err) { throwQuantum(this.el, err); } } render() { return h("slot", null); } static get is() { return "quantum-provider"; } static get properties() { return { "bind": { "type": "unknown", "mutable": false, "complexType": { "original": "QuantumKey<any, any>", "resolved": "QuantumKey<any, any> | undefined", "references": { "QuantumKey": { "location": "import", "path": "../../libs" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "" } }, "name": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "" }, "attribute": "name", "reflect": true }, "namespace": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "" }, "attribute": "namespace", "reflect": true }, "debug": { "type": "boolean", "mutable": true, "complexType": { "original": "boolean", "resolved": "boolean | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "" }, "attribute": "debug", "reflect": true }, "value": { "type": "any", "mutable": false, "complexType": { "original": "any", "resolved": "any", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "value", "reflect": false } }; } static get events() { return [{ "method": "update", "name": "update", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "{value: any, provider: Provider<any>}", "resolved": "{ value: any; provider: Provider<any>; }", "references": { "Provider": { "location": "import", "path": "../../libs/provider" } } } }]; } static get elementRef() { return "el"; } static get watchers() { return [{ "propName": "value", "methodName": "onValue" }]; } }