executable-stories-react 0.8.0 → 0.10.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.
@@ -372,12 +372,29 @@ interface ReportSearchProps {
372
372
  }
373
373
  declare const ReportSearch: react.ForwardRefExoticComponent<ReportSearchProps & react.RefAttributes<HTMLInputElement>>;
374
374
 
375
+ /**
376
+ * View state in the URL, so a filtered report survives a refresh and can be
377
+ * shared as a link.
378
+ *
379
+ * It lives in the HASH, not the query string, because the flagship surface is a
380
+ * single HTML file opened from disk. A `file://` document has an opaque origin,
381
+ * and Chrome refuses `history.pushState`/`replaceState` when the URL argument
382
+ * changes anything but the fragment there. The fragment is the one part every
383
+ * browser lets us rewrite in place.
384
+ *
385
+ * Format: `#<anchor>?<params>` — the anchor half stays exactly what it has
386
+ * always been, a scenario id deep link, so existing permalinks keep working and
387
+ * a link with no filters is unchanged.
388
+ */
389
+ type UrlStatusFilter = "all" | "passed" | "failed" | "skipped" | "pending";
390
+
375
391
  /**
376
392
  * Pure functions for filtering a StoryReport by a search query.
377
393
  * Used by <ReportInteractive>. Kept side-effect-free so it can be unit-tested.
378
394
  */
379
395
 
380
- type StatusFilter = "all" | "passed" | "failed" | "skipped" | "pending";
396
+ /** Defined with the URL codec that has to validate it, so the two can't drift. */
397
+ type StatusFilter = UrlStatusFilter;
381
398
  interface FilterCriteria {
382
399
  query?: string;
383
400
  status?: StatusFilter;
@@ -443,8 +460,13 @@ interface KeyboardShortcutHandlers {
443
460
  declare function useKeyboardShortcuts(handlers: KeyboardShortcutHandlers): void;
444
461
 
445
462
  /**
446
- * Scrolls to a scenario by URL hash on mount and whenever the hash changes.
447
- * No-op in SSR (only runs in useEffect). Honours `prefers-reduced-motion`.
463
+ * Scrolls to a scenario by URL hash on mount and whenever the deep link
464
+ * changes. No-op in SSR (only runs in useEffect). Honours
465
+ * `prefers-reduced-motion`.
466
+ *
467
+ * The fragment also carries filter state (`#<anchor>?q=...`), so only the
468
+ * anchor half is read — and a hashchange that merely rewrote the filters must
469
+ * not yank the page back to the last anchor, hence the last-anchor guard.
448
470
  */
449
471
  declare function useDeepLinkScroll(): void;
450
472
 
@@ -372,12 +372,29 @@ interface ReportSearchProps {
372
372
  }
373
373
  declare const ReportSearch: react.ForwardRefExoticComponent<ReportSearchProps & react.RefAttributes<HTMLInputElement>>;
374
374
 
375
+ /**
376
+ * View state in the URL, so a filtered report survives a refresh and can be
377
+ * shared as a link.
378
+ *
379
+ * It lives in the HASH, not the query string, because the flagship surface is a
380
+ * single HTML file opened from disk. A `file://` document has an opaque origin,
381
+ * and Chrome refuses `history.pushState`/`replaceState` when the URL argument
382
+ * changes anything but the fragment there. The fragment is the one part every
383
+ * browser lets us rewrite in place.
384
+ *
385
+ * Format: `#<anchor>?<params>` — the anchor half stays exactly what it has
386
+ * always been, a scenario id deep link, so existing permalinks keep working and
387
+ * a link with no filters is unchanged.
388
+ */
389
+ type UrlStatusFilter = "all" | "passed" | "failed" | "skipped" | "pending";
390
+
375
391
  /**
376
392
  * Pure functions for filtering a StoryReport by a search query.
377
393
  * Used by <ReportInteractive>. Kept side-effect-free so it can be unit-tested.
378
394
  */
379
395
 
380
- type StatusFilter = "all" | "passed" | "failed" | "skipped" | "pending";
396
+ /** Defined with the URL codec that has to validate it, so the two can't drift. */
397
+ type StatusFilter = UrlStatusFilter;
381
398
  interface FilterCriteria {
382
399
  query?: string;
383
400
  status?: StatusFilter;
@@ -443,8 +460,13 @@ interface KeyboardShortcutHandlers {
443
460
  declare function useKeyboardShortcuts(handlers: KeyboardShortcutHandlers): void;
444
461
 
445
462
  /**
446
- * Scrolls to a scenario by URL hash on mount and whenever the hash changes.
447
- * No-op in SSR (only runs in useEffect). Honours `prefers-reduced-motion`.
463
+ * Scrolls to a scenario by URL hash on mount and whenever the deep link
464
+ * changes. No-op in SSR (only runs in useEffect). Honours
465
+ * `prefers-reduced-motion`.
466
+ *
467
+ * The fragment also carries filter state (`#<anchor>?q=...`), so only the
468
+ * anchor half is read — and a hashchange that merely rewrote the filters must
469
+ * not yank the page back to the last anchor, hence the last-anchor guard.
448
470
  */
449
471
  declare function useDeepLinkScroll(): void;
450
472