executable-stories-react 0.1.15 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { ReportDocCustom, ReportDocMermaid, ReportDocCode, ReportDocSection, StoryReport } from 'executable-stories-formatters';
3
+ import { ReportDocCustom, ReportDocMermaid, ReportDocCode, ReportDocSection, StoryReport } from 'executable-stories-core';
4
4
 
5
5
  /**
6
6
  * Result<T> — explicit success/error type matching the cookbook convention.
@@ -8,6 +8,7 @@ import { ReportDocCustom, ReportDocMermaid, ReportDocCode, ReportDocSection, Sto
8
8
  * Used at the boundary where a StoryReport is parsed: the consumer hands us
9
9
  * an unknown value (file contents, fetch body, prop) and we return a Result.
10
10
  */
11
+
11
12
  type Result<T, E = ReportParseError> = {
12
13
  ok: true;
13
14
  data: T;
@@ -52,9 +53,50 @@ interface ReportInteractiveProps {
52
53
  className?: string;
53
54
  title?: string;
54
55
  dataTheme?: "light" | "dark";
56
+ /**
57
+ * Drop the report's own title block (`<h1>` + summary + meta) while keeping
58
+ * the search and filter controls. Use when the surrounding page already shows
59
+ * the report title as its heading — e.g. the Astro stories index embedded in
60
+ * Starlight, where Starlight renders the page `<h1>`.
61
+ */
62
+ hideHeader?: boolean;
55
63
  }
56
64
  declare function ReportInteractive(props: ReportInteractiveProps): react.JSX.Element;
57
65
 
66
+ interface ReportInteractiveIslandProps {
67
+ report: StoryReport | Result<StoryReport>;
68
+ title?: string;
69
+ className?: string;
70
+ hideHeader?: boolean;
71
+ /** Render code blocks with CDN highlight.js (default true). */
72
+ syntaxHighlighting?: boolean;
73
+ /** Render `story.mermaid(...)` blocks as CDN-loaded SVG diagrams (default true). */
74
+ mermaid?: boolean;
75
+ }
76
+ /**
77
+ * Self-contained interactive island for host frameworks that hydrate this as a
78
+ * client island (e.g. Astro `<ReportInteractiveIsland client:load/>`).
79
+ *
80
+ * Frameworks like Astro serialize island props as JSON, so they CANNOT pass the
81
+ * `renderers` functions to <ReportInteractive> directly — which is why a host
82
+ * would otherwise fall back to a separate post-hydration script that mutates the
83
+ * island's DOM (and gets clobbered when the island re-renders). This wrapper
84
+ * builds the React-OWNED highlighting + mermaid renderers internally, so the
85
+ * enhancements live inside the React tree and survive every re-render. The
86
+ * heavy libraries load from a CDN at runtime, so the host bundle stays lean.
87
+ */
88
+ declare function ReportInteractiveIsland({ report, title, className, hideHeader, syntaxHighlighting, mermaid, }: ReportInteractiveIslandProps): react.JSX.Element;
89
+
90
+ interface IslandRendererOptions {
91
+ syntaxHighlighting: boolean;
92
+ mermaid: boolean;
93
+ }
94
+ /**
95
+ * Build the BuiltinRenderers map the island passes to <ReportInteractive>.
96
+ * Created once at mount so the renderer functions stay referentially stable.
97
+ */
98
+ declare function buildIslandRenderers(opts: IslandRendererOptions): BuiltinRenderers;
99
+
58
100
  interface ReportSearchProps {
59
101
  value: string;
60
102
  onChange: (next: string) => void;
@@ -70,8 +112,15 @@ declare const ReportSearch: react.ForwardRefExoticComponent<ReportSearchProps &
70
112
  * Used by <ReportInteractive>. Kept side-effect-free so it can be unit-tested.
71
113
  */
72
114
 
115
+ type StatusFilter = "all" | "passed" | "failed" | "skipped" | "pending";
116
+ interface FilterCriteria {
117
+ query?: string;
118
+ status?: StatusFilter;
119
+ /** Scenario matches if it carries ANY of these tags (empty = no tag filter). */
120
+ tags?: string[];
121
+ }
73
122
  declare function normalizeQuery(query: string): string;
74
- declare function filterReport(report: StoryReport, query: string): StoryReport;
123
+ declare function filterReport(report: StoryReport, criteria: string | FilterCriteria): StoryReport;
75
124
  interface FailureRef {
76
125
  featureId: string;
77
126
  scenarioId: string;
@@ -97,6 +146,8 @@ interface KeyboardShortcutHandlers {
97
146
  onPrevFailure?: () => void;
98
147
  onToggleHelp?: () => void;
99
148
  onEscape?: () => void;
149
+ onExpandAll?: () => void;
150
+ onCollapseAll?: () => void;
100
151
  }
101
152
  /**
102
153
  * Attaches one keydown listener for the lifetime of the component, regardless
@@ -108,8 +159,8 @@ declare function useKeyboardShortcuts(handlers: KeyboardShortcutHandlers): void;
108
159
 
109
160
  /**
110
161
  * Scrolls to a scenario by URL hash on mount and whenever the hash changes.
111
- * No-op in SSR (only runs in useEffect).
162
+ * No-op in SSR (only runs in useEffect). Honours `prefers-reduced-motion`.
112
163
  */
113
164
  declare function useDeepLinkScroll(): void;
114
165
 
115
- export { type FailureRef, type KeyboardShortcutHandlers, ReportFailureBanner, type ReportFailureBannerProps, ReportInteractive, type ReportInteractiveProps, ReportSearch, type ReportSearchProps, ReportShortcutsHelp, type ReportShortcutsHelpProps, filterReport, listFailures, normalizeQuery, useDeepLinkScroll, useKeyboardShortcuts };
166
+ export { type FailureRef, type IslandRendererOptions, type KeyboardShortcutHandlers, ReportFailureBanner, type ReportFailureBannerProps, ReportInteractive, ReportInteractiveIsland, type ReportInteractiveIslandProps, type ReportInteractiveProps, ReportSearch, type ReportSearchProps, ReportShortcutsHelp, type ReportShortcutsHelpProps, buildIslandRenderers, filterReport, listFailures, normalizeQuery, useDeepLinkScroll, useKeyboardShortcuts };
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { ReportDocCustom, ReportDocMermaid, ReportDocCode, ReportDocSection, StoryReport } from 'executable-stories-formatters';
3
+ import { ReportDocCustom, ReportDocMermaid, ReportDocCode, ReportDocSection, StoryReport } from 'executable-stories-core';
4
4
 
5
5
  /**
6
6
  * Result<T> — explicit success/error type matching the cookbook convention.
@@ -8,6 +8,7 @@ import { ReportDocCustom, ReportDocMermaid, ReportDocCode, ReportDocSection, Sto
8
8
  * Used at the boundary where a StoryReport is parsed: the consumer hands us
9
9
  * an unknown value (file contents, fetch body, prop) and we return a Result.
10
10
  */
11
+
11
12
  type Result<T, E = ReportParseError> = {
12
13
  ok: true;
13
14
  data: T;
@@ -52,9 +53,50 @@ interface ReportInteractiveProps {
52
53
  className?: string;
53
54
  title?: string;
54
55
  dataTheme?: "light" | "dark";
56
+ /**
57
+ * Drop the report's own title block (`<h1>` + summary + meta) while keeping
58
+ * the search and filter controls. Use when the surrounding page already shows
59
+ * the report title as its heading — e.g. the Astro stories index embedded in
60
+ * Starlight, where Starlight renders the page `<h1>`.
61
+ */
62
+ hideHeader?: boolean;
55
63
  }
56
64
  declare function ReportInteractive(props: ReportInteractiveProps): react.JSX.Element;
57
65
 
66
+ interface ReportInteractiveIslandProps {
67
+ report: StoryReport | Result<StoryReport>;
68
+ title?: string;
69
+ className?: string;
70
+ hideHeader?: boolean;
71
+ /** Render code blocks with CDN highlight.js (default true). */
72
+ syntaxHighlighting?: boolean;
73
+ /** Render `story.mermaid(...)` blocks as CDN-loaded SVG diagrams (default true). */
74
+ mermaid?: boolean;
75
+ }
76
+ /**
77
+ * Self-contained interactive island for host frameworks that hydrate this as a
78
+ * client island (e.g. Astro `<ReportInteractiveIsland client:load/>`).
79
+ *
80
+ * Frameworks like Astro serialize island props as JSON, so they CANNOT pass the
81
+ * `renderers` functions to <ReportInteractive> directly — which is why a host
82
+ * would otherwise fall back to a separate post-hydration script that mutates the
83
+ * island's DOM (and gets clobbered when the island re-renders). This wrapper
84
+ * builds the React-OWNED highlighting + mermaid renderers internally, so the
85
+ * enhancements live inside the React tree and survive every re-render. The
86
+ * heavy libraries load from a CDN at runtime, so the host bundle stays lean.
87
+ */
88
+ declare function ReportInteractiveIsland({ report, title, className, hideHeader, syntaxHighlighting, mermaid, }: ReportInteractiveIslandProps): react.JSX.Element;
89
+
90
+ interface IslandRendererOptions {
91
+ syntaxHighlighting: boolean;
92
+ mermaid: boolean;
93
+ }
94
+ /**
95
+ * Build the BuiltinRenderers map the island passes to <ReportInteractive>.
96
+ * Created once at mount so the renderer functions stay referentially stable.
97
+ */
98
+ declare function buildIslandRenderers(opts: IslandRendererOptions): BuiltinRenderers;
99
+
58
100
  interface ReportSearchProps {
59
101
  value: string;
60
102
  onChange: (next: string) => void;
@@ -70,8 +112,15 @@ declare const ReportSearch: react.ForwardRefExoticComponent<ReportSearchProps &
70
112
  * Used by <ReportInteractive>. Kept side-effect-free so it can be unit-tested.
71
113
  */
72
114
 
115
+ type StatusFilter = "all" | "passed" | "failed" | "skipped" | "pending";
116
+ interface FilterCriteria {
117
+ query?: string;
118
+ status?: StatusFilter;
119
+ /** Scenario matches if it carries ANY of these tags (empty = no tag filter). */
120
+ tags?: string[];
121
+ }
73
122
  declare function normalizeQuery(query: string): string;
74
- declare function filterReport(report: StoryReport, query: string): StoryReport;
123
+ declare function filterReport(report: StoryReport, criteria: string | FilterCriteria): StoryReport;
75
124
  interface FailureRef {
76
125
  featureId: string;
77
126
  scenarioId: string;
@@ -97,6 +146,8 @@ interface KeyboardShortcutHandlers {
97
146
  onPrevFailure?: () => void;
98
147
  onToggleHelp?: () => void;
99
148
  onEscape?: () => void;
149
+ onExpandAll?: () => void;
150
+ onCollapseAll?: () => void;
100
151
  }
101
152
  /**
102
153
  * Attaches one keydown listener for the lifetime of the component, regardless
@@ -108,8 +159,8 @@ declare function useKeyboardShortcuts(handlers: KeyboardShortcutHandlers): void;
108
159
 
109
160
  /**
110
161
  * Scrolls to a scenario by URL hash on mount and whenever the hash changes.
111
- * No-op in SSR (only runs in useEffect).
162
+ * No-op in SSR (only runs in useEffect). Honours `prefers-reduced-motion`.
112
163
  */
113
164
  declare function useDeepLinkScroll(): void;
114
165
 
115
- export { type FailureRef, type KeyboardShortcutHandlers, ReportFailureBanner, type ReportFailureBannerProps, ReportInteractive, type ReportInteractiveProps, ReportSearch, type ReportSearchProps, ReportShortcutsHelp, type ReportShortcutsHelpProps, filterReport, listFailures, normalizeQuery, useDeepLinkScroll, useKeyboardShortcuts };
166
+ export { type FailureRef, type IslandRendererOptions, type KeyboardShortcutHandlers, ReportFailureBanner, type ReportFailureBannerProps, ReportInteractive, ReportInteractiveIsland, type ReportInteractiveIslandProps, type ReportInteractiveProps, ReportSearch, type ReportSearchProps, ReportShortcutsHelp, type ReportShortcutsHelpProps, buildIslandRenderers, filterReport, listFailures, normalizeQuery, useDeepLinkScroll, useKeyboardShortcuts };