UNPKG

@wikimedia/wvui

Version:

Wikimedia Vue UI (WVUI) – Wikimedia Foundation's Vue.js shared user-interface components for Wikipedia, MediaWiki, and beyond.

57 lines (56 loc) 1.85 kB
import { Args, ArgTypes } from '@storybook/addons'; export declare function filterKeys(obj: Record<string, unknown>, keysToRemove: string[]): Record<string, unknown>; /** * Map event names to action listeners. * * Finds entries in argTypes that have the 'action' property set, and returns an object mapping * those event names to the listeners for those actions. * * To use this for e.g. the 'click' and 'mouseover' events, add the following to argTypes in either * the file's export default or to an individual story: * argTypes: { * // other stuff * ...makeActionArgTypes( [ 'click', 'mouseover' ] ) * } * * Then in your story component, add a computed property: * computed: { * actionListeners() { * return makeActionListeners( args, argTypes ); * } * } * * and pass this computed property to the component's v-on in the template: * * template: ` * <wvui-button * v-bind="$props" * v-on="actionListeners" * /> * ` * * @param args The args parameter passed to the story * @param argTypes The argTypes parameter passed to the story * @return Object for use in v-on="" */ export declare function makeActionListeners(args: Args, argTypes: ArgTypes): Record<string, () => void>; /** * Transform an array like [ 'click', 'focus' ] to an object for use in argTypes. * For usage see makeActionListeners(). * * Returns an object that looks like: * { * click: { * action: 'click', * table: { category: 'Events' } * }, * focus: { * action: 'focus', * table: { category: 'Events' } * } * } * * @param eventNames Array of event names * @return An object describing event args */ export declare function makeActionArgTypes(eventNames: string[]): ArgTypes;