UNPKG

@stories-js/core

Version:

Stories web components to build stories

91 lines 2.66 kB
/*! * (C) StoriesJS https://storiesjs.org - GPL-2.0 License */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/consistent-type-definitions */ // eslint-disable-next-line @typescript-eslint/no-unused-vars import { Component, Host, h, Element, State, Method } from '@stencil/core'; // import type { ObservableMap } from '@stencil/store'; // import { createStore } from '@stencil/store'; import { api } from '../../api'; import { messages } from '../../types'; import { CONTROL_EVENT } from './Control'; export class AddonControls { constructor() { this.controls = []; this.onControl = (event) => { // this.store.state.actions.push(actionDisplay) console.log('onControl.event', event); }; } title() { return "Controls"; } async storyContextChanged(story, context) { console.log('AddonControls.storyContextChanged', story, context); } async componentDidLoad() { // Register addon api.registerAddon(this); // Register event listeners messages.on(CONTROL_EVENT, this.onControl); // Create store // this.store = createStore({controls: []}) } async disconnectedCallback() { // Unregister event listener messages.off(CONTROL_EVENT, this.onControl); // Unregster addon api.unregisterAddon(this); } render() { return (h(Host, null, h("div", null, "Addon Controls"))); } static get is() { return "stories-addon-controls"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["addon-controls.scss"] }; } static get styleUrls() { return { "$": ["addon-controls.css"] }; } static get states() { return { "controls": {} }; } static get methods() { return { "storyContextChanged": { "complexType": { "signature": "(story: StoryComponent, context: StoryContext) => Promise<void>", "parameters": [{ "tags": [], "text": "" }, { "tags": [], "text": "" }], "references": { "Promise": { "location": "global" }, "StoryComponent": { "location": "import", "path": "../../types" }, "StoryContext": { "location": "import", "path": "../../types" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } } }; } static get elementRef() { return "el"; } } //# sourceMappingURL=addon-controls.js.map