@stories-js/core
Version:
Stories web components to build stories
53 lines (47 loc) • 1.59 kB
JavaScript
/*!
* (C) StoriesJS https://storiesjs.org - GPL-2.0 License
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
const index = require('./index-c25eada5.js');
const index$1 = require('./index-92599979.js');
const messages = require('./messages-666e577a.js');
const action = require('./action-f8c6de6b.js');
require('./index-ad63dbd0.js');
const addonActionsCss = ":host{display:block;height:100%}";
const AddonActions = class {
constructor(hostRef) {
index.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
index$1.api.registerAddon(this);
// Register event listeners
messages.messages.on(action.ACTION_EVENT, this.onActions);
}
async disconnectedCallback() {
// Unregister event listener
messages.messages.off(action.ACTION_EVENT, this.onActions);
// Unregster addon
index$1.api.unregisterAddon(this);
}
render() {
return (index.h(index.Host, null, index.h("ul", null, this.actions.map(action => index.h("li", null, action.data.name)))));
}
get el() { return index.getElement(this); }
};
AddonActions.style = addonActionsCss;
exports.stories_addon_actions = AddonActions;
//# sourceMappingURL=stories-addon-actions.cjs.entry.js.map