@histoire/vue 0.0.0-stage → 1.0.0-beta.2

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.
Files changed (204) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/controls/GenericControls.d.ts +30 -0
  3. package/dist/components/controls/GenericControls.d.ts.map +1 -0
  4. package/dist/components/controls/GenericControls.js +34 -0
  5. package/dist/components/controls/HistoireControls.d.ts +30 -0
  6. package/dist/components/controls/HistoireControls.d.ts.map +1 -0
  7. package/dist/components/controls/HistoireControls.js +176 -0
  8. package/dist/components/controls/PresetMenu.d.ts +63 -0
  9. package/dist/components/controls/PresetMenu.d.ts.map +1 -0
  10. package/dist/components/controls/PresetMenu.js +180 -0
  11. package/dist/components/controls/PropControl.d.ts +40 -0
  12. package/dist/components/controls/PropControl.d.ts.map +1 -0
  13. package/dist/components/controls/PropControl.js +66 -0
  14. package/dist/components/controls/StateControl.d.ts +15 -0
  15. package/dist/components/controls/StateControl.d.ts.map +1 -0
  16. package/dist/components/controls/StateControl.js +30 -0
  17. package/dist/components/controls/StatePresets.d.ts +37 -0
  18. package/dist/components/controls/StatePresets.d.ts.map +1 -0
  19. package/dist/components/controls/StatePresets.js +105 -0
  20. package/dist/components/controls/edit.d.ts +10 -0
  21. package/dist/components/controls/edit.d.ts.map +1 -0
  22. package/dist/components/controls/edit.js +82 -0
  23. package/dist/components/controls/editor.d.ts +9 -0
  24. package/dist/components/controls/editor.d.ts.map +1 -0
  25. package/dist/components/controls/editor.js +28 -0
  26. package/dist/components/docs/HistoireDocs.d.ts +44 -0
  27. package/dist/components/docs/HistoireDocs.d.ts.map +1 -0
  28. package/dist/components/docs/HistoireDocs.js +124 -0
  29. package/dist/components/docs/anchors.d.ts +3 -0
  30. package/dist/components/docs/anchors.d.ts.map +1 -0
  31. package/dist/components/docs/anchors.js +26 -0
  32. package/dist/components/docs/content.d.ts +11 -0
  33. package/dist/components/docs/content.d.ts.map +1 -0
  34. package/dist/components/docs/content.js +7 -0
  35. package/dist/components/docs/links.d.ts +20 -0
  36. package/dist/components/docs/links.d.ts.map +1 -0
  37. package/dist/components/docs/links.js +85 -0
  38. package/dist/components/docs/sanitize.d.ts +3 -0
  39. package/dist/components/docs/sanitize.d.ts.map +1 -0
  40. package/dist/components/docs/sanitize.js +16 -0
  41. package/dist/components/embed/EmbedPanels.d.ts +21 -0
  42. package/dist/components/embed/EmbedPanels.d.ts.map +1 -0
  43. package/dist/components/embed/EmbedPanels.js +49 -0
  44. package/dist/components/embed/HistoireEmbed.d.ts +36 -0
  45. package/dist/components/embed/HistoireEmbed.d.ts.map +1 -0
  46. package/dist/components/embed/HistoireEmbed.js +81 -0
  47. package/dist/components/embed/geometry.d.ts +5 -0
  48. package/dist/components/embed/geometry.d.ts.map +1 -0
  49. package/dist/components/embed/geometry.js +38 -0
  50. package/dist/components/events/HistoireEvents.d.ts +30 -0
  51. package/dist/components/events/HistoireEvents.d.ts.map +1 -0
  52. package/dist/components/events/HistoireEvents.js +88 -0
  53. package/dist/components/explorer/ExplorerNavigation.d.ts +20 -0
  54. package/dist/components/explorer/ExplorerNavigation.d.ts.map +1 -0
  55. package/dist/components/explorer/ExplorerNavigation.js +15 -0
  56. package/dist/components/explorer/ExplorerPanels.d.ts +42 -0
  57. package/dist/components/explorer/ExplorerPanels.d.ts.map +1 -0
  58. package/dist/components/explorer/ExplorerPanels.js +87 -0
  59. package/dist/components/explorer/ExplorerPreview.d.ts +29 -0
  60. package/dist/components/explorer/ExplorerPreview.d.ts.map +1 -0
  61. package/dist/components/explorer/ExplorerPreview.js +93 -0
  62. package/dist/components/explorer/HistoireExplorer.d.ts +47 -0
  63. package/dist/components/explorer/HistoireExplorer.d.ts.map +1 -0
  64. package/dist/components/explorer/HistoireExplorer.js +41 -0
  65. package/dist/components/explorer/panel-tabs.d.ts +48 -0
  66. package/dist/components/explorer/panel-tabs.d.ts.map +1 -0
  67. package/dist/components/explorer/panel-tabs.js +58 -0
  68. package/dist/components/extensions/HistoireExtensionOutlet.d.ts +47 -0
  69. package/dist/components/extensions/HistoireExtensionOutlet.d.ts.map +1 -0
  70. package/dist/components/extensions/HistoireExtensionOutlet.js +35 -0
  71. package/dist/components/extensions/HistoireExtensionView.d.ts +59 -0
  72. package/dist/components/extensions/HistoireExtensionView.d.ts.map +1 -0
  73. package/dist/components/extensions/HistoireExtensionView.js +58 -0
  74. package/dist/components/extensions/panel-action.d.ts +38 -0
  75. package/dist/components/extensions/panel-action.d.ts.map +1 -0
  76. package/dist/components/extensions/panel-action.js +19 -0
  77. package/dist/components/extensions/state-renderer.d.ts +17 -0
  78. package/dist/components/extensions/state-renderer.d.ts.map +1 -0
  79. package/dist/components/extensions/state-renderer.js +72 -0
  80. package/dist/components/extensions/view-lifecycle.d.ts +47 -0
  81. package/dist/components/extensions/view-lifecycle.d.ts.map +1 -0
  82. package/dist/components/extensions/view-lifecycle.js +108 -0
  83. package/dist/components/extensions/workbench-components.d.ts +9 -0
  84. package/dist/components/extensions/workbench-components.d.ts.map +1 -0
  85. package/dist/components/extensions/workbench-components.js +82 -0
  86. package/dist/components/preview/HistoirePreview.d.ts +11 -0
  87. package/dist/components/preview/HistoirePreview.d.ts.map +1 -0
  88. package/dist/components/preview/HistoirePreview.js +3 -0
  89. package/dist/components/preview/surface.d.ts +13 -0
  90. package/dist/components/preview/surface.d.ts.map +1 -0
  91. package/dist/components/preview/surface.js +129 -0
  92. package/dist/components/search/HistoireSearch.d.ts +9 -0
  93. package/dist/components/search/HistoireSearch.d.ts.map +1 -0
  94. package/dist/components/search/HistoireSearch.js +66 -0
  95. package/dist/components/source/HistoireSource.d.ts +58 -0
  96. package/dist/components/source/HistoireSource.d.ts.map +1 -0
  97. package/dist/components/source/HistoireSource.js +85 -0
  98. package/dist/components/source/content.d.ts +11 -0
  99. package/dist/components/source/content.d.ts.map +1 -0
  100. package/dist/components/source/content.js +7 -0
  101. package/dist/components/source/highlight.d.ts +3 -0
  102. package/dist/components/source/highlight.d.ts.map +1 -0
  103. package/dist/components/source/highlight.js +15 -0
  104. package/dist/components/source/render.d.ts +6 -0
  105. package/dist/components/source/render.d.ts.map +1 -0
  106. package/dist/components/source/render.js +11 -0
  107. package/dist/components/tests/HistoireTests.d.ts +66 -0
  108. package/dist/components/tests/HistoireTests.d.ts.map +1 -0
  109. package/dist/components/tests/HistoireTests.js +109 -0
  110. package/dist/components/tests/TestsRunActions.d.ts +54 -0
  111. package/dist/components/tests/TestsRunActions.d.ts.map +1 -0
  112. package/dist/components/tests/TestsRunActions.js +138 -0
  113. package/dist/components/tests/render.d.ts +33 -0
  114. package/dist/components/tests/render.d.ts.map +1 -0
  115. package/dist/components/tests/render.js +103 -0
  116. package/dist/components/toolbar/HistoireToolbar.d.ts +7 -0
  117. package/dist/components/toolbar/HistoireToolbar.d.ts.map +1 -0
  118. package/dist/components/toolbar/HistoireToolbar.js +66 -0
  119. package/dist/components/toolbar/ToolbarExtensions.d.ts +27 -0
  120. package/dist/components/toolbar/ToolbarExtensions.d.ts.map +1 -0
  121. package/dist/components/toolbar/ToolbarExtensions.js +79 -0
  122. package/dist/components/toolbar/groups.d.ts +19 -0
  123. package/dist/components/toolbar/groups.d.ts.map +1 -0
  124. package/dist/components/toolbar/groups.js +18 -0
  125. package/dist/components/tree/HistoireStoryTree.d.ts +40 -0
  126. package/dist/components/tree/HistoireStoryTree.d.ts.map +1 -0
  127. package/dist/components/tree/HistoireStoryTree.js +57 -0
  128. package/dist/composables/session.d.ts +4 -0
  129. package/dist/composables/session.d.ts.map +1 -0
  130. package/dist/composables/session.js +5 -0
  131. package/dist/composables/snapshot.d.ts +5 -0
  132. package/dist/composables/snapshot.d.ts.map +1 -0
  133. package/dist/composables/snapshot.js +9 -0
  134. package/dist/content/controller.d.ts +20 -0
  135. package/dist/content/controller.d.ts.map +1 -0
  136. package/dist/content/controller.js +54 -0
  137. package/dist/content.css +22 -0
  138. package/dist/controls.css +26 -0
  139. package/dist/embed.css +15 -0
  140. package/dist/explorer.css +67 -0
  141. package/dist/extensions.css +20 -0
  142. package/dist/foundation/VirtualList.d.ts +114 -0
  143. package/dist/foundation/VirtualList.d.ts.map +1 -0
  144. package/dist/foundation/VirtualList.js +126 -0
  145. package/dist/foundation/floating.d.ts +9 -0
  146. package/dist/foundation/floating.d.ts.map +1 -0
  147. package/dist/foundation/floating.js +90 -0
  148. package/dist/foundation/parts.d.ts +13 -0
  149. package/dist/foundation/parts.d.ts.map +1 -0
  150. package/dist/foundation/parts.js +13 -0
  151. package/dist/index.d.ts +18 -0
  152. package/dist/index.d.ts.map +1 -0
  153. package/dist/index.js +15 -0
  154. package/dist/internal.d.ts +31 -0
  155. package/dist/internal.d.ts.map +1 -0
  156. package/dist/internal.js +26 -0
  157. package/dist/navigation.css +51 -0
  158. package/dist/overlays/OverlayHost.d.ts +21 -0
  159. package/dist/overlays/OverlayHost.d.ts.map +1 -0
  160. package/dist/overlays/OverlayHost.js +118 -0
  161. package/dist/overlays/geometry.d.ts +4 -0
  162. package/dist/overlays/geometry.d.ts.map +1 -0
  163. package/dist/overlays/geometry.js +7 -0
  164. package/dist/overlays/menu-bounds.d.ts +10 -0
  165. package/dist/overlays/menu-bounds.d.ts.map +1 -0
  166. package/dist/overlays/menu-bounds.js +52 -0
  167. package/dist/provider/HistoireProvider.d.ts +43 -0
  168. package/dist/provider/HistoireProvider.d.ts.map +1 -0
  169. package/dist/provider/HistoireProvider.js +183 -0
  170. package/dist/provider/context.d.ts +37 -0
  171. package/dist/provider/context.d.ts.map +1 -0
  172. package/dist/provider/context.js +16 -0
  173. package/dist/provider/extensions.d.ts +61 -0
  174. package/dist/provider/extensions.d.ts.map +1 -0
  175. package/dist/provider/extensions.js +139 -0
  176. package/dist/provider/panels.d.ts +33 -0
  177. package/dist/provider/panels.d.ts.map +1 -0
  178. package/dist/provider/panels.js +53 -0
  179. package/dist/provider/plugin-shortcuts.d.ts +22 -0
  180. package/dist/provider/plugin-shortcuts.d.ts.map +1 -0
  181. package/dist/provider/plugin-shortcuts.js +73 -0
  182. package/dist/provider/shortcuts.d.ts +16 -0
  183. package/dist/provider/shortcuts.d.ts.map +1 -0
  184. package/dist/provider/shortcuts.js +62 -0
  185. package/dist/provider/theme.d.ts +4 -0
  186. package/dist/provider/theme.d.ts.map +1 -0
  187. package/dist/provider/theme.js +25 -0
  188. package/dist/search/navigation.d.ts +27 -0
  189. package/dist/search/navigation.d.ts.map +1 -0
  190. package/dist/search/navigation.js +61 -0
  191. package/dist/style.css +88 -0
  192. package/dist/tests/collector.d.ts +16 -0
  193. package/dist/tests/collector.d.ts.map +1 -0
  194. package/dist/tests/collector.js +51 -0
  195. package/dist/tests/controller.d.ts +28 -0
  196. package/dist/tests/controller.d.ts.map +1 -0
  197. package/dist/tests/controller.js +79 -0
  198. package/dist/tests/model.d.ts +20 -0
  199. package/dist/tests/model.d.ts.map +1 -0
  200. package/dist/tests/model.js +18 -0
  201. package/dist/tests.css +59 -0
  202. package/dist/virtual-list.css +6 -0
  203. package/package.json +58 -3
  204. package/README.md +0 -3
@@ -0,0 +1,138 @@
1
+ import { BuiltinIcon, getControlElement, HstButton, restoreControlsFocus } from '@histoire/controls/vue';
2
+ import { defineComponent, h, nextTick, shallowRef } from 'vue';
3
+ import { HistoireDropdown } from '../../foundation/floating.js';
4
+ import { useHistoireResource } from '../../provider/context.js';
5
+ /** Split Run command with secondary actions menu and local cancellation. */
6
+ export const HistoireTestsRunActions = defineComponent({
7
+ name: 'HistoireTestsRunActions',
8
+ props: {
9
+ /** Any execution, local or host-owned, blocks new commands. */
10
+ busy: { type: Boolean, required: true },
11
+ /** Only a local operation can be cancelled from this panel. */
12
+ cancellable: { type: Boolean, required: true },
13
+ /** Ready runtime with in-canvas test capability. */
14
+ canvasAvailable: { type: Boolean, required: true },
15
+ /** Dev source with server test capability and selected variant. */
16
+ serverAvailable: { type: Boolean, required: true },
17
+ },
18
+ emits: {
19
+ /** Omitted mode refreshes definitions without running assertions. */
20
+ perform: (_mode) => true,
21
+ cancel: () => true,
22
+ },
23
+ setup(props, { emit }) {
24
+ const trigger = shallowRef(null);
25
+ const menu = shallowRef(null);
26
+ const open = shallowRef(false);
27
+ let active = true;
28
+ let focusVersion = 0;
29
+ let openLast = false;
30
+ useHistoireResource(() => {
31
+ active = false;
32
+ focusVersion++;
33
+ });
34
+ /** Enabled menu items in DOM order. */
35
+ function items() {
36
+ return Array.from(menu.value?.querySelectorAll('[role="menuitem"]:not(:disabled)') ?? []);
37
+ }
38
+ /** Focuses menu's requested edge only after provider-local dropdown mounts. */
39
+ async function focusItems(last = openLast) {
40
+ const version = ++focusVersion;
41
+ await nextTick();
42
+ if (!active || !open.value || version !== focusVersion)
43
+ return;
44
+ const list = items();
45
+ list[last ? list.length - 1 : 0]?.focus();
46
+ }
47
+ /** Closes menu; explicit keyboard dismissal returns focus to its trigger. */
48
+ function close(restore = false) {
49
+ const wasOpen = open.value;
50
+ open.value = false;
51
+ focusVersion++;
52
+ if (restore && wasOpen && trigger.value?.isConnected)
53
+ trigger.value.focus();
54
+ }
55
+ /** Opens menu and chooses first or last available command for arrow keys. */
56
+ function show(last = false) {
57
+ openLast = last;
58
+ open.value = true;
59
+ void focusItems(last);
60
+ }
61
+ /** Starts selected command after dismissing menu that contained it. */
62
+ function select(mode) {
63
+ close();
64
+ emit('perform', mode);
65
+ }
66
+ /** Implements expected menu traversal without leaking keys to host shortcuts. */
67
+ function onMenuKeydown(event) {
68
+ if (event.key === 'Tab') {
69
+ event.preventDefault();
70
+ event.stopPropagation();
71
+ close();
72
+ restoreControlsFocus(trigger.value, { restoreFocus: true, focusDirection: event.shiftKey ? 'previous' : 'next' });
73
+ return;
74
+ }
75
+ const list = items();
76
+ const index = list.indexOf(menu.value?.ownerDocument.activeElement);
77
+ const next = event.key === 'ArrowDown'
78
+ ? (index + 1) % list.length
79
+ : event.key === 'ArrowUp'
80
+ ? (index - 1 + list.length) % list.length
81
+ : event.key === 'Home' ? 0 : event.key === 'End' ? list.length - 1 : undefined;
82
+ if (next === undefined || !list.length)
83
+ return;
84
+ event.preventDefault();
85
+ event.stopPropagation();
86
+ list[next]?.focus();
87
+ }
88
+ /** Arrow keys on trigger open menu at matching edge. */
89
+ function onTriggerKeydown(event) {
90
+ if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
91
+ return;
92
+ event.preventDefault();
93
+ event.stopPropagation();
94
+ show(event.key === 'ArrowUp');
95
+ }
96
+ return () => h('div', { class: 'histoire-tests-actions' }, [
97
+ h('div', { 'class': 'histoire-tests-run-group', 'role': 'group', 'aria-label': 'Test actions' }, [
98
+ h(HstButton, { 'color': 'flat', 'type': 'button', 'class': 'histoire-tests-run', 'aria-label': 'Run tests', 'disabled': props.busy || !props.canvasAvailable, 'onClick': () => emit('perform', 'preview') }, {
99
+ default: () => [h(BuiltinIcon, { 'icon': 'play-filled-alt', 'size': 14, 'aria-hidden': 'true' }), 'Run'],
100
+ }),
101
+ h(HistoireDropdown, {
102
+ class: 'histoire-tests-run-dropdown',
103
+ placement: 'bottom-end',
104
+ distance: 6,
105
+ triggers: [],
106
+ shown: open.value,
107
+ noAutoFocus: true,
108
+ autoBoundaryMaxSize: true,
109
+ onApplyShow: () => { void focusItems(); },
110
+ onHide: () => close(),
111
+ }, {
112
+ default: () => h(HstButton, {
113
+ 'color': 'flat',
114
+ 'ref': (value) => { trigger.value = getControlElement(value); },
115
+ 'type': 'button',
116
+ 'class': 'histoire-tests-run-trigger',
117
+ 'iconOnly': true,
118
+ 'aria-label': 'More test actions',
119
+ 'aria-haspopup': 'menu',
120
+ 'aria-expanded': open.value,
121
+ 'disabled': props.busy,
122
+ 'onClick': () => open.value ? close(true) : show(),
123
+ 'onKeydown': onTriggerKeydown,
124
+ }, { default: () => h(BuiltinIcon, { 'icon': 'chevron-down', 'size': 14, 'aria-hidden': 'true' }) }),
125
+ popper: () => h('div', { 'ref': menu, 'class': 'histoire-tests-run-menu histoire-control-popover', 'role': 'menu', 'aria-label': 'Test actions', 'onKeydown': onMenuKeydown }, [
126
+ h(HstButton, { color: 'flat', type: 'button', role: 'menuitem', tabindex: -1, disabled: props.busy || !props.serverAvailable, onClick: () => select('server') }, { default: () => 'Run on server' }),
127
+ h(HstButton, { color: 'flat', type: 'button', role: 'menuitem', tabindex: -1, disabled: props.busy || !props.canvasAvailable, onClick: () => select() }, { default: () => 'Force refresh' }),
128
+ ]),
129
+ }),
130
+ ]),
131
+ props.cancellable
132
+ ? h(HstButton, { color: 'flat', type: 'button', class: 'histoire-tests-cancel', onClick: () => emit('cancel') }, {
133
+ default: () => [h(BuiltinIcon, { 'icon': 'stop-filled-alt', 'size': 14, 'aria-hidden': 'true' }), 'Cancel'],
134
+ })
135
+ : null,
136
+ ]);
137
+ },
138
+ });
@@ -0,0 +1,33 @@
1
+ import type { HistoireSerializedTestDefinition, HistoireTestCaseResult, HistoireTestError, HistoireTestRunSummary } from '@histoire/protocol';
2
+ import type { VNode } from 'vue';
3
+ /** Displayed test state; `running` marks definitions awaiting an active run. */
4
+ export type HistoireTestRowState = 'passed' | 'failed' | 'skipped' | 'idle' | 'running';
5
+ /** One virtual list entry projected from results or collected definitions. */
6
+ export interface HistoireTestRow {
7
+ /** Stable test identity. */
8
+ key: string;
9
+ /** Result or definition with its display names. */
10
+ test: HistoireTestCaseResult | HistoireSerializedTestDefinition;
11
+ /** Resolved display state. */
12
+ state: HistoireTestRowState;
13
+ }
14
+ /** Results take precedence; definitions fall back to skipped, running or not run. */
15
+ export declare function projectTestRows(summary: HistoireTestRunSummary | null | undefined, definitions: readonly HistoireSerializedTestDefinition[], busy: boolean): HistoireTestRow[];
16
+ /** Non-zero result counts, e.g. `2 passed · 1 failed`, each tinted by its state. */
17
+ export declare function renderTestCounts(summary: HistoireTestRunSummary): string | (VNode | string)[];
18
+ /**
19
+ * Status glyph exposed as an image with its state name; running uses the standard loader.
20
+ * Carbon has no filled skip glyph, so `disc` states draw the outline glyph inside a filled
21
+ * disc sized like Carbon's `*-filled` circles (14px within the 16px slot).
22
+ */
23
+ export declare function renderTestStateIcon(state: HistoireTestRowState): VNode;
24
+ /** Serialized assertion details remain text; source excerpts in stacks are never executed. */
25
+ export declare function renderTestError(error: HistoireTestError, index: number): VNode;
26
+ /** One test line with status, muted suite path and inline failure details. */
27
+ export declare function renderTestRow(row: HistoireTestRow): VNode;
28
+ /**
29
+ * Split result bar with one segment per non-empty state, sized by its count;
30
+ * indeterminate while running. Empty states render nothing so the bar shows no stray gaps.
31
+ */
32
+ export declare function renderTestProgress(summary: HistoireTestRunSummary | null | undefined, busy: boolean): VNode | null;
33
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/components/tests/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC7I,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAIhC,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AAEvF,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,mDAAmD;IACnD,IAAI,EAAE,sBAAsB,GAAG,gCAAgC,CAAA;IAC/D,8BAA8B;IAC9B,KAAK,EAAE,oBAAoB,CAAA;CAC5B;AAWD,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,GAAG,SAAS,EAAE,WAAW,EAAE,SAAS,gCAAgC,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,EAAE,CAO9K;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,CAO7F;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,KAAK,CAQtE;AAoBD,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAY9E;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,KAAK,CAczD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAKlH"}
@@ -0,0 +1,103 @@
1
+ import { BuiltinIcon, HstPulsatingDisc } from '@histoire/controls/vue';
2
+ import { h } from 'vue';
3
+ /** Icon and accessible label for each displayed state. */
4
+ const STATES = {
5
+ passed: { icon: 'checkmark-filled', label: 'Passed' },
6
+ failed: { icon: 'error-filled', label: 'Failed' },
7
+ skipped: { icon: 'skip-forward', label: 'Skipped', disc: true },
8
+ idle: { icon: 'circle-dash', label: 'Not run' },
9
+ running: { label: 'Running' },
10
+ };
11
+ /** Results take precedence; definitions fall back to skipped, running or not run. */
12
+ export function projectTestRows(summary, definitions, busy) {
13
+ if (summary?.tests.length)
14
+ return summary.tests.map(test => ({ key: test.id, test, state: test.state }));
15
+ return definitions.map(test => ({
16
+ key: test.id,
17
+ test,
18
+ state: test.mode === 'skip' || test.mode === 'todo' ? 'skipped' : busy ? 'running' : 'idle',
19
+ }));
20
+ }
21
+ /** Non-zero result counts, e.g. `2 passed · 1 failed`, each tinted by its state. */
22
+ export function renderTestCounts(summary) {
23
+ const parts = [['passed', summary.passed], ['failed', summary.failed], ['skipped', summary.skipped]].filter(([, count]) => count > 0);
24
+ if (!parts.length)
25
+ return 'No tests run';
26
+ return parts.flatMap(([state, count], index) => {
27
+ const label = h('span', { 'key': state, 'data-state': state }, `${count} ${state}`);
28
+ return index ? [' · ', label] : [label];
29
+ });
30
+ }
31
+ /**
32
+ * Status glyph exposed as an image with its state name; running uses the standard loader.
33
+ * Carbon has no filled skip glyph, so `disc` states draw the outline glyph inside a filled
34
+ * disc sized like Carbon's `*-filled` circles (14px within the 16px slot).
35
+ */
36
+ export function renderTestStateIcon(state) {
37
+ const { icon, label, disc } = STATES[state];
38
+ const glyph = !icon
39
+ ? h(HstPulsatingDisc, { size: 14 })
40
+ : disc
41
+ ? h('span', { class: 'histoire-test-state-disc' }, h(BuiltinIcon, { 'icon': icon, 'size': 10, 'aria-hidden': 'true' }))
42
+ : h(BuiltinIcon, { 'icon': icon, 'size': 16, 'aria-hidden': 'true' });
43
+ return h('span', { 'class': 'histoire-test-state', 'data-state': state, 'role': 'img', 'aria-label': label, 'title': label }, glyph);
44
+ }
45
+ /**
46
+ * Splits suite path from test's own name. Server results repeat the
47
+ * suite-qualified name in `name`, so `fullName` is the only reliable source.
48
+ */
49
+ function splitSuite(fullName) {
50
+ const parts = fullName.split(' > ');
51
+ return { suite: parts.slice(0, -1), name: parts.at(-1) ?? fullName };
52
+ }
53
+ /** Diff lines tinted by their `+`/`-` marker; text content stays identical. */
54
+ function renderDiff(diff) {
55
+ const lines = diff.split('\n');
56
+ return h('pre', { 'class': 'histoire-test-error-diff', 'aria-label': 'Assertion difference' }, lines.flatMap((line, index) => [
57
+ h('span', { 'data-diff': line.startsWith('+') ? 'added' : line.startsWith('-') ? 'removed' : undefined }, line),
58
+ index < lines.length - 1 ? '\n' : null,
59
+ ]));
60
+ }
61
+ /** Serialized assertion details remain text; source excerpts in stacks are never executed. */
62
+ export function renderTestError(error, index) {
63
+ if (typeof error === 'string')
64
+ return h('div', { key: index, class: 'histoire-test-error' }, h('p', { class: 'histoire-test-error-message' }, error));
65
+ return h('div', { key: index, class: 'histoire-test-error' }, [
66
+ h('p', { class: 'histoire-test-error-message' }, error.name && !error.message.startsWith(error.name) ? `${error.name}: ${error.message}` : error.message),
67
+ error.diff ? renderDiff(error.diff) : null,
68
+ error.stack
69
+ ? h('details', { class: 'histoire-test-error-stack' }, [
70
+ h('summary', 'Stack trace'),
71
+ h('pre', { 'aria-label': 'Error stack and source excerpt' }, error.stack),
72
+ ])
73
+ : null,
74
+ ]);
75
+ }
76
+ /** One test line with status, muted suite path and inline failure details. */
77
+ export function renderTestRow(row) {
78
+ const { test, state } = row;
79
+ const { suite, name } = splitSuite(test.fullName || test.name);
80
+ const errors = 'errors' in test ? test.errors : [];
81
+ return h('div', { 'class': 'histoire-test-row', 'data-state': state }, [
82
+ h('div', { class: 'histoire-test-row-main' }, [
83
+ renderTestStateIcon(state),
84
+ h('span', { class: 'histoire-test-name' }, [
85
+ suite.length ? h('span', { class: 'histoire-test-suite' }, `${suite.join(' › ')} › `) : null,
86
+ name,
87
+ ]),
88
+ ]),
89
+ errors.length ? h('div', { class: 'histoire-test-errors' }, errors.map(renderTestError)) : null,
90
+ ]);
91
+ }
92
+ /**
93
+ * Split result bar with one segment per non-empty state, sized by its count;
94
+ * indeterminate while running. Empty states render nothing so the bar shows no stray gaps.
95
+ */
96
+ export function renderTestProgress(summary, busy) {
97
+ if (busy)
98
+ return h('div', { 'class': 'histoire-tests-progress', 'data-running': '', 'aria-hidden': 'true' }, h('span'));
99
+ if (!summary?.total)
100
+ return null;
101
+ const segments = [['passed', summary.passed], ['failed', summary.failed], ['skipped', summary.skipped]].filter(([, count]) => count > 0);
102
+ return h('div', { 'class': 'histoire-tests-progress', 'aria-hidden': 'true' }, segments.map(([state, count]) => h('span', { 'key': state, 'data-state': state, 'style': { flexGrow: count } })));
103
+ }
@@ -0,0 +1,7 @@
1
+ /** Scoped preferences work without primary; runtime receives current settings when explicitly mounted. */
2
+ export declare const HistoireToolbar: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
+ [key: string]: any;
4
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "error"[], "error", import("vue").PublicProps, Readonly<{}> & Readonly<{
5
+ onError?: ((...args: any[]) => any) | undefined;
6
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
7
+ //# sourceMappingURL=HistoireToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistoireToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/toolbar/HistoireToolbar.ts"],"names":[],"mappings":"AAUA,0GAA0G;AAC1G,eAAO,MAAM,eAAe;;;;iFAuD1B,CAAA"}
@@ -0,0 +1,66 @@
1
+ import { HstButton, HstSelect, HstSwitch, HstText } from '@histoire/controls/vue';
2
+ import { isHistoireProjectFileOrigin } from '@histoire/protocol';
3
+ import { canOpenHistoireTargetInEditor, getHistoireSessionDescriptor, requestHistoireOpenInEditor } from '@histoire/sdk/internal';
4
+ import { defineComponent, h, ref, watch } from 'vue';
5
+ import { useHistoireSnapshot } from '../../composables/snapshot.js';
6
+ import { useHistoireContext } from '../../provider/context.js';
7
+ import { ToolbarExtensions } from './ToolbarExtensions.js';
8
+ /** Scoped preferences work without primary; runtime receives current settings when explicitly mounted. */
9
+ export const HistoireToolbar = defineComponent({
10
+ name: 'HistoireToolbar',
11
+ emits: ['error'],
12
+ setup(_props, { emit }) {
13
+ const { session } = useHistoireContext();
14
+ const snapshot = useHistoireSnapshot();
15
+ const width = ref(String(snapshot.value.settings.responsiveWidth));
16
+ const height = ref(snapshot.value.settings.responsiveHeight == null ? '' : String(snapshot.value.settings.responsiveHeight));
17
+ // String drafts retain native change/blur commit timing, including Auto height.
18
+ watch(() => snapshot.value.settings.responsiveWidth, value => width.value = String(value));
19
+ watch(() => snapshot.value.settings.responsiveHeight, value => height.value = value == null ? '' : String(value));
20
+ /** Every complete patch is validated atomically by session; failures remain visible to host. */
21
+ function update(patch) {
22
+ void session.settings.update(patch).catch(error => emit('error', error));
23
+ }
24
+ /** First-party finite editor action names only collected story target. */
25
+ function editor() {
26
+ const target = snapshot.value.selection;
27
+ if (target && canOpenHistoireTargetInEditor(snapshot.value, target))
28
+ void requestHistoireOpenInEditor(session, target).catch(error => emit('error', error));
29
+ }
30
+ /** Plugin items of one native group, after that group's built-ins. */
31
+ function plugins(group) {
32
+ return h(ToolbarExtensions, { group, onError: (error) => emit('error', error) });
33
+ }
34
+ return () => {
35
+ const settings = snapshot.value.settings;
36
+ let config;
37
+ try {
38
+ config = getHistoireSessionDescriptor(session).config;
39
+ }
40
+ catch { /* Disconnected/SSR provider still displays current local preferences. */ }
41
+ const selection = snapshot.value.selection;
42
+ const selectedStory = snapshot.value.catalog.stories.find(story => story.id === selection?.storyId);
43
+ const showEditor = !selection || (!!selectedStory && isHistoireProjectFileOrigin(selectedStory.fileOrigin));
44
+ return h('section', { 'class': 'histoire-toolbar', 'aria-label': 'Histoire toolbar' }, [
45
+ h(HstText, { 'layout': 'inline', 'aria-label': 'Viewport width', 'type': 'number', 'min': 1, 'modelValue': width.value, 'onUpdate:modelValue': (value) => width.value = value, 'onChange': () => update({ responsiveWidth: Number(width.value) }) }),
46
+ h(HstText, { 'layout': 'inline', 'aria-label': 'Viewport height', 'type': 'number', 'min': 1, 'modelValue': height.value, 'onUpdate:modelValue': (value) => height.value = value, 'onChange': () => update({ responsiveHeight: height.value ? Number(height.value) : null }) }),
47
+ h(HstButton, { 'color': 'flat', 'type': 'button', 'aria-pressed': settings.rotate, 'onClick': () => update({ rotate: !settings.rotate }) }, { default: () => 'Rotate' }),
48
+ h(HstSelect, { 'layout': 'inline', 'aria-label': 'Viewport preset', 'placeholder': 'Viewport', 'options': (config?.responsivePresets ?? []).map((preset, index) => ({ value: index, label: preset.label })), 'onUpdate:modelValue': (index) => {
49
+ const preset = config?.responsivePresets[index];
50
+ if (preset)
51
+ update({ responsiveWidth: preset.width, responsiveHeight: preset.height ?? null });
52
+ } }),
53
+ plugins('viewport'),
54
+ h(HstSelect, { 'layout': 'inline', 'aria-label': 'Background', 'modelValue': settings.backgroundColor, 'options': [...(config?.backgroundPresets.some(preset => preset.color === 'transparent') ? [] : [{ value: 'transparent', label: 'Transparent' }]), ...(config?.backgroundPresets ?? []).map(preset => ({ value: preset.color, label: preset.label }))], 'onUpdate:modelValue': (value) => update({ backgroundColor: value }) }),
55
+ h(HstSwitch, { 'title': 'Checkerboard', 'modelValue': settings.checkerboard, 'onUpdate:modelValue': (value) => update({ checkerboard: value }) }),
56
+ plugins('background'),
57
+ h(HstSelect, { 'layout': 'inline', 'aria-label': 'Direction', 'modelValue': settings.textDirection, 'options': [{ value: 'ltr', label: 'LTR' }, { value: 'rtl', label: 'RTL' }], 'onUpdate:modelValue': (value) => update({ textDirection: value }) }),
58
+ config?.theme.hideColorSchemeSwitch ? null : h(HstSelect, { 'layout': 'inline', 'aria-label': 'Appearance', 'modelValue': settings.colorScheme, 'options': ['auto', 'light', 'dark'], 'onUpdate:modelValue': (value) => update({ colorScheme: value }) }),
59
+ plugins('ui'),
60
+ showEditor ? h(HstButton, { color: 'flat', type: 'button', disabled: !canOpenHistoireTargetInEditor(snapshot.value, selection), onClick: editor }, { default: () => 'Open in editor' }) : null,
61
+ // Items of groups without a native counterpart trail the built-ins.
62
+ plugins('plugins'),
63
+ ]);
64
+ };
65
+ },
66
+ });
@@ -0,0 +1,27 @@
1
+ import type { PropType } from 'vue';
2
+ import type { NativeToolbarGroup } from './groups.js';
3
+ /**
4
+ * Plugin toolbar items of one native toolbar group (see `NATIVE_TOOLBAR_GROUPS`), in registry
5
+ * order, from the provider's extension host. Items naming a group without a native counterpart
6
+ * render in the trailing `plugins` group.
7
+ * Actions run once at a time against the root context; toggles re-read `pressed` after each run
8
+ * and on host notifications; popovers and custom items render their views.
9
+ */
10
+ export declare const ToolbarExtensions: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
11
+ /** Native group whose items render here. */
12
+ group: {
13
+ type: PropType<NativeToolbarGroup>;
14
+ required: true;
15
+ };
16
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
+ [key: string]: any;
18
+ }>[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "error"[], "error", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ /** Native group whose items render here. */
20
+ group: {
21
+ type: PropType<NativeToolbarGroup>;
22
+ required: true;
23
+ };
24
+ }>> & Readonly<{
25
+ onError?: ((...args: any[]) => any) | undefined;
26
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
27
+ //# sourceMappingURL=ToolbarExtensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarExtensions.d.ts","sourceRoot":"","sources":["../../../src/components/toolbar/ToolbarExtensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAYrD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;IAG1B,4CAA4C;;cACnB,QAAQ,CAAC,kBAAkB,CAAC;;;;;;IADrD,4CAA4C;;;;;;;iFA6D9C,CAAA"}
@@ -0,0 +1,79 @@
1
+ import { HstButton } from '@histoire/controls/vue';
2
+ import { createContributionKeys } from '@histoire/plugin-kit';
3
+ import { defineComponent, h, shallowReactive, shallowRef } from 'vue';
4
+ import { HistoireDropdown } from '../../foundation/floating.js';
5
+ import { useHistoireContext } from '../../provider/context.js';
6
+ import { HistoireExtensionView } from '../extensions/HistoireExtensionView.js';
7
+ import { nativeToolbarGroup } from './groups.js';
8
+ /**
9
+ * Plugin toolbar items of one native toolbar group (see `NATIVE_TOOLBAR_GROUPS`), in registry
10
+ * order, from the provider's extension host. Items naming a group without a native counterpart
11
+ * render in the trailing `plugins` group.
12
+ * Actions run once at a time against the root context; toggles re-read `pressed` after each run
13
+ * and on host notifications; popovers and custom items render their views.
14
+ */
15
+ export const ToolbarExtensions = defineComponent({
16
+ name: 'HistoireToolbarExtensions',
17
+ props: {
18
+ /** Native group whose items render here. */
19
+ group: { type: String, required: true },
20
+ },
21
+ emits: ['error'],
22
+ setup(props, { emit }) {
23
+ const { extensions } = useHistoireContext();
24
+ const running = shallowReactive(new Set());
25
+ const failedToggles = new WeakSet();
26
+ // Bumped after each run so toggles re-read `pressed` even without a host notification.
27
+ const runs = shallowRef(0);
28
+ const keyOf = createContributionKeys();
29
+ /** Runs one action item; failures reach the toolbar's error event. */
30
+ function run(item, context) {
31
+ if (running.has(item.id))
32
+ return;
33
+ running.add(item.id);
34
+ void extensions.run(item.id, context).catch(error => emit('error', error)).finally(() => {
35
+ running.delete(item.id);
36
+ runs.value++;
37
+ });
38
+ }
39
+ /** Toggle state; a throwing `pressed` is reported once and reads as unpressed. */
40
+ function pressed(item, context) {
41
+ if (item.type !== 'toggle' || failedToggles.has(item))
42
+ return false;
43
+ try {
44
+ return item.pressed(context);
45
+ }
46
+ catch (error) {
47
+ failedToggles.add(item);
48
+ extensions.host?.reportViewError(item.id, error, 'report');
49
+ return false;
50
+ }
51
+ }
52
+ /** Renders one item by type. */
53
+ function render(item, context) {
54
+ if (item.type === 'custom')
55
+ return h(HistoireExtensionView, { key: keyOf(item), contribution: item, context });
56
+ if (item.type === 'popover') {
57
+ return h(HistoireDropdown, { key: keyOf(item), placement: 'bottom' }, {
58
+ default: () => h(HstButton, { 'color': 'flat', 'type': 'button', 'aria-haspopup': 'dialog' }, { default: () => item.label }),
59
+ popper: () => h(HistoireExtensionView, { contribution: item, context }),
60
+ });
61
+ }
62
+ return h(HstButton, {
63
+ 'key': keyOf(item),
64
+ 'color': 'flat',
65
+ 'type': 'button',
66
+ 'disabled': running.has(item.id),
67
+ 'aria-pressed': item.type === 'toggle' ? pressed(item, context) : undefined,
68
+ 'onClick': () => run(item, context),
69
+ }, { default: () => item.label });
70
+ }
71
+ return () => {
72
+ void runs.value;
73
+ const context = extensions.context;
74
+ if (!context)
75
+ return null;
76
+ return extensions.available('toolbar.item', context).filter(item => nativeToolbarGroup(item.group) === props.group).map(item => render(item, context));
77
+ };
78
+ },
79
+ });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Native toolbar groups receiving plugin items, in toolbar order. Each has the same name as its
3
+ * standalone workbench counterpart:
4
+ * - `viewport`: after Viewport width, height, Rotate and Viewport preset.
5
+ * - `background`: after Background and Checkerboard.
6
+ * - `ui`: after Appearance (where it would be when the color scheme switch is hidden).
7
+ * - `plugins`: trailing group after Open in editor.
8
+ * Groups without a native counterpart (`search`, `tools`, `arrange`, `zoom`, `screenshot`,
9
+ * `embed`, `inspector`) and unknown names fall back to `plugins`.
10
+ */
11
+ export declare const NATIVE_TOOLBAR_GROUPS: readonly ["viewport", "background", "ui", "plugins"];
12
+ /** Native toolbar group. */
13
+ export type NativeToolbarGroup = typeof NATIVE_TOOLBAR_GROUPS[number];
14
+ /**
15
+ * Native group rendering items of `group`.
16
+ * @param group Contribution group.
17
+ */
18
+ export declare function nativeToolbarGroup(group: string): NativeToolbarGroup;
19
+ //# sourceMappingURL=groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../src/components/toolbar/groups.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,sDAAyF,CAAA;AAE3H,4BAA4B;AAC5B,MAAM,MAAM,kBAAkB,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAA;AAErE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAEpE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Native toolbar groups receiving plugin items, in toolbar order. Each has the same name as its
3
+ * standalone workbench counterpart:
4
+ * - `viewport`: after Viewport width, height, Rotate and Viewport preset.
5
+ * - `background`: after Background and Checkerboard.
6
+ * - `ui`: after Appearance (where it would be when the color scheme switch is hidden).
7
+ * - `plugins`: trailing group after Open in editor.
8
+ * Groups without a native counterpart (`search`, `tools`, `arrange`, `zoom`, `screenshot`,
9
+ * `embed`, `inspector`) and unknown names fall back to `plugins`.
10
+ */
11
+ export const NATIVE_TOOLBAR_GROUPS = ['viewport', 'background', 'ui', 'plugins'];
12
+ /**
13
+ * Native group rendering items of `group`.
14
+ * @param group Contribution group.
15
+ */
16
+ export function nativeToolbarGroup(group) {
17
+ return NATIVE_TOOLBAR_GROUPS.includes(group) ? group : 'plugins';
18
+ }
@@ -0,0 +1,40 @@
1
+ import type { PropType, VNode } from 'vue';
2
+ /** Catalog navigation consumes exact IDs and remembers variants through session selection. */
3
+ export declare const HistoireStoryTree: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ showVariants: {
5
+ type: BooleanConstructor;
6
+ default: boolean;
7
+ };
8
+ foldersInitiallyOpen: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
12
+ expandedPaths: {
13
+ type: PropType<readonly (readonly string[])[]>;
14
+ default: undefined;
15
+ };
16
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
+ [key: string]: any;
18
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "folder" | "select")[], "error" | "folder" | "select", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ showVariants: {
20
+ type: BooleanConstructor;
21
+ default: boolean;
22
+ };
23
+ foldersInitiallyOpen: {
24
+ type: BooleanConstructor;
25
+ default: boolean;
26
+ };
27
+ expandedPaths: {
28
+ type: PropType<readonly (readonly string[])[]>;
29
+ default: undefined;
30
+ };
31
+ }>> & Readonly<{
32
+ onError?: ((...args: any[]) => any) | undefined;
33
+ onFolder?: ((...args: any[]) => any) | undefined;
34
+ onSelect?: ((...args: any[]) => any) | undefined;
35
+ }>, {
36
+ showVariants: boolean;
37
+ foldersInitiallyOpen: boolean;
38
+ expandedPaths: readonly (readonly string[])[];
39
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
40
+ //# sourceMappingURL=HistoireStoryTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistoireStoryTree.d.ts","sourceRoot":"","sources":["../../../src/components/tree/HistoireStoryTree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAM1C,8FAA8F;AAC9F,eAAO,MAAM,iBAAiB;;QAGV,IAAI;QAAW,OAAO;;;QACd,IAAI;QAAW,OAAO;;;QAC7B,IAAI,EAAW,QAAQ,CAAC,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;QAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;4EA2CnF,CAAA"}
@@ -0,0 +1,57 @@
1
+ import { HstButton } from '@histoire/controls/vue';
2
+ import { defineComponent, h, shallowRef } from 'vue';
3
+ import { useHistoireSnapshot } from '../../composables/snapshot.js';
4
+ import { useHistoireContext } from '../../provider/context.js';
5
+ /** Catalog navigation consumes exact IDs and remembers variants through session selection. */
6
+ export const HistoireStoryTree = defineComponent({
7
+ name: 'HistoireStoryTree',
8
+ props: {
9
+ showVariants: { type: Boolean, default: true },
10
+ foldersInitiallyOpen: { type: Boolean, default: true },
11
+ expandedPaths: { type: Array, default: undefined },
12
+ },
13
+ emits: ['select', 'folder', 'error'],
14
+ setup(props, { emit }) {
15
+ const { session } = useHistoireContext();
16
+ const snapshot = useHistoireSnapshot();
17
+ const folders = shallowRef(new Map());
18
+ /** Caller owns routing; successful activation reports canonical resolved target. */
19
+ function select(target) {
20
+ void session.selection.select(target).then(() => emit('select', session.getSnapshot().selection)).catch(error => emit('error', error));
21
+ }
22
+ /** Recursive catalog tree keeps source group ordering, without array-offset story identities. */
23
+ function rows(nodes, path = []) {
24
+ return nodes.map((node) => {
25
+ if (node.kind === 'group')
26
+ return h('li', { key: node.id ?? node.title }, [h('div', node.title), h('ul', rows(node.children, path))]);
27
+ if (node.kind === 'folder') {
28
+ const full = [...path, node.title];
29
+ const key = JSON.stringify(full);
30
+ const open = props.expandedPaths ? props.expandedPaths.some(value => JSON.stringify(value) === key) : folders.value.get(key) ?? props.foldersInitiallyOpen;
31
+ return h('li', { 'key': key, 'data-test-id': 'story-list-folder' }, h('details', { open, onToggle: (event) => {
32
+ const value = event.currentTarget.open;
33
+ if (value === open)
34
+ return;
35
+ folders.value = new Map(folders.value).set(key, value);
36
+ emit('folder', { path: full, open: value });
37
+ } }, [h('summary', node.title), open ? h('ul', rows(node.children, full)) : null]));
38
+ }
39
+ if (node.kind !== 'story')
40
+ return h('li');
41
+ const matches = snapshot.value.catalog.stories.filter(story => story.id === node.storyId);
42
+ const story = matches.length === 1 ? matches[0] : undefined;
43
+ const active = snapshot.value.selection;
44
+ return h('li', { key: node.storyId }, [
45
+ h(HstButton, { 'color': 'flat', 'type': 'button', 'data-test-id': 'story-list-item', 'aria-label': story?.title ?? node.title, 'aria-current': active?.storyId === node.storyId ? 'true' : undefined, 'disabled': !story, 'onClick': () => select({ storyId: node.storyId }) }, { default: () => [node.title, story && !story.docsOnly ? h('span', { class: 'histoire-story-variant-count' }, ` ${story.variants.length}`) : null] }),
46
+ props.showVariants && story && !story.docsOnly
47
+ ? h('ul', story.variants.map(variant => h('li', { key: variant.id }, h(HstButton, { 'color': 'flat', 'type': 'button', 'aria-label': `${story.title} / ${variant.title}`, 'aria-current': active?.storyId === story.id && active.variantId === variant.id ? 'true' : undefined, 'onClick': () => select({ storyId: story.id, variantId: variant.id }) }, { default: () => variant.title }))))
48
+ : null,
49
+ ]);
50
+ });
51
+ }
52
+ return () => h('nav', { 'class': 'histoire-tree', 'aria-label': 'Histoire stories' }, [
53
+ snapshot.value.status === 'failed' || (snapshot.value.source && !snapshot.value.capabilities.catalog.available) ? h('p', { role: 'alert' }, 'Catalog unavailable') : null,
54
+ h('ul', rows(snapshot.value.catalog.tree)),
55
+ ]);
56
+ },
57
+ });
@@ -0,0 +1,4 @@
1
+ import type { HistoireSession } from '@histoire/sdk';
2
+ /** Read explicit caller session from nearest native provider. */
3
+ export declare function useHistoireSession(): HistoireSession;
4
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/composables/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAGpD,iEAAiE;AACjE,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD"}
@@ -0,0 +1,5 @@
1
+ import { useHistoireContext } from '../provider/context.js';
2
+ /** Read explicit caller session from nearest native provider. */
3
+ export function useHistoireSession() {
4
+ return useHistoireContext().session;
5
+ }