addons.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { Channel } from '@storybook/channels';
  2. export { E as EventMap, H as HooksContext, L as Listener, k as applyHooks, u as useArgs, a as useCallback, b as useChannel, c as useEffect, d as useGlobals, e as useMemo, f as useParameter, g as useReducer, h as useRef, i as useState, j as useStoryContext } from './hooks-655fa363.js';
  3. import { Addon_StoryWrapper } from '@storybook/types';
  4. declare class AddonStore {
  5. constructor();
  6. private channel;
  7. /**
  8. * @deprecated will be removed in 8.0, please use channel instead
  9. */
  10. private serverChannel;
  11. private promise;
  12. private resolve;
  13. getChannel: () => Channel;
  14. /**
  15. * @deprecated will be removed in 8.0, please use getChannel instead
  16. */
  17. getServerChannel: () => Channel;
  18. ready: () => Promise<Channel>;
  19. hasChannel: () => boolean;
  20. /**
  21. * @deprecated will be removed in 8.0, please use the normal channel instead
  22. */
  23. hasServerChannel: () => boolean;
  24. setChannel: (channel: Channel) => void;
  25. /**
  26. * @deprecated will be removed in 8.0, please use the normal channel instead
  27. */
  28. setServerChannel: (channel: Channel) => void;
  29. }
  30. declare const addons: AddonStore;
  31. type MakeDecoratorResult = (...args: any) => any;
  32. interface MakeDecoratorOptions {
  33. name: string;
  34. parameterName: string;
  35. skipIfNoParametersOrOptions?: boolean;
  36. wrapper: Addon_StoryWrapper;
  37. }
  38. /**
  39. * Creates a Storybook decorator function that can be used to wrap stories with additional functionality.
  40. *
  41. * @param {MakeDecoratorOptions} options - The options for the decorator.
  42. * @param {string} options.name - The name of the decorator.
  43. * @param {string} options.parameterName - The name of the parameter that will be used to pass options to the decorator.
  44. * @param {Addon_StoryWrapper} options.wrapper - The function that will be used to wrap the story.
  45. * @param {boolean} [options.skipIfNoParametersOrOptions=false] - Whether to skip the decorator if no options or parameters are provided.
  46. * @returns {MakeDecoratorResult} A function that can be used as a Storybook decorator.
  47. *
  48. * @example
  49. * const myDecorator = makeDecorator({
  50. * name: 'My Decorator',
  51. * parameterName: 'myDecorator',
  52. * wrapper: (storyFn, context, { options }) => {
  53. * const { myOption } = options;
  54. * return <div style={{ backgroundColor: myOption }}>{storyFn()}</div>;
  55. * },
  56. * });
  57. *
  58. * export const decorators = [myDecorator];
  59. */
  60. declare const makeDecorator: ({ name, parameterName, wrapper, skipIfNoParametersOrOptions, }: MakeDecoratorOptions) => MakeDecoratorResult;
  61. declare function mockChannel(): Channel;
  62. export { AddonStore, MakeDecoratorOptions, MakeDecoratorResult, addons, makeDecorator, mockChannel };