UNPKG

2.44 kBTypeScriptView Raw
1import { Subject } from 'rxjs';
2import { ICollection, StoryFnAngularReturnType } from '../types';
3type StoryRenderInfo = {
4 storyFnAngular: StoryFnAngularReturnType;
5 moduleMetadataSnapshot: string;
6};
7export declare abstract class AbstractRenderer {
8 /**
9 * Wait and destroy the platform
10 */
11 static resetApplications(domNode?: HTMLElement): void;
12 /**
13 * Reset compiled components because we often want to compile the same component with
14 * more than one NgModule.
15 */
16 protected static resetCompiledComponents: () => Promise<void>;
17 protected previousStoryRenderInfo: Map<HTMLElement, StoryRenderInfo>;
18 protected storyProps$: Subject<ICollection | undefined>;
19 constructor();
20 protected abstract beforeFullRender(domNode?: HTMLElement): Promise<void>;
21 protected abstract afterFullRender(): Promise<void>;
22 /**
23 * Bootstrap main angular module with main component or send only new `props` with storyProps$
24 *
25 * @param storyFnAngular {StoryFnAngularReturnType}
26 * @param forced {boolean} If :
27 * - true render will only use the StoryFn `props' in storyProps observable that will update sotry's component/template properties. Improves performance without reloading the whole module&component if props changes
28 * - false fully recharges or initializes angular module & component
29 * @param component {Component}
30 */
31 render({ storyFnAngular, forced, component, targetDOMNode, }: {
32 storyFnAngular: StoryFnAngularReturnType;
33 forced: boolean;
34 component?: any;
35 targetDOMNode: HTMLElement;
36 }): Promise<void>;
37 /**
38 * Only ASCII alphanumerics can be used as HTML tag name.
39 * https://html.spec.whatwg.org/#elements-2
40 *
41 * Therefore, stories break when non-ASCII alphanumerics are included in target selector.
42 * https://github.com/storybookjs/storybook/issues/15147
43 *
44 * This method returns storyId when it doesn't contain any non-ASCII alphanumerics.
45 * Otherwise, it generates a valid HTML tag name from storyId by removing non-ASCII alphanumerics from storyId, prefixing "sb-", and suffixing "-component"
46 * @protected
47 * @memberof AbstractRenderer
48 */
49 protected generateTargetSelectorFromStoryId(id: string): string;
50 protected initAngularRootElement(targetDOMNode: HTMLElement, targetSelector: string): void;
51 private fullRendererRequired;
52}
53export {};
54
\No newline at end of file