UNPKG

@stories-js/core

Version:

Stories web components to build stories

49 lines (45 loc) 1.49 kB
/*! * (C) StoriesJS https://storiesjs.org - GPL-2.0 License */ import { r as registerInstance, h, c as Host, g as getElement } from './index-49238f69.js'; import { a as api } from './index-aaa78d22.js'; import { m as messages } from './messages-1b750fe6.js'; import { A as ACTION_EVENT } from './action-1e3f583f.js'; import './index-f706f0f6.js'; const addonActionsCss = ":host{display:block;height:100%}"; const AddonActions = class { constructor(hostRef) { registerInstance(this, hostRef); this.id = "ADDON_ACTIONS"; this.actions = []; this.onActions = (actionDisplay) => { this.actions = [...this.actions, actionDisplay]; }; } title() { return "Actions"; } async storyContextChanged(story, context) { console.log('AddonActions.storyContextChanged', story, context); this.actions = []; } async componentDidLoad() { // Register addon api.registerAddon(this); // Register event listeners messages.on(ACTION_EVENT, this.onActions); } async disconnectedCallback() { // Unregister event listener messages.off(ACTION_EVENT, this.onActions); // Unregster addon api.unregisterAddon(this); } render() { return (h(Host, null, h("ul", null, this.actions.map(action => h("li", null, action.data.name))))); } get el() { return getElement(this); } }; AddonActions.style = addonActionsCss; export { AddonActions as stories_addon_actions }; //# sourceMappingURL=stories-addon-actions.entry.js.map