forgebook 0.0.0-stage → 0.1.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 (493) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -2
  3. package/dist/bin/forgebook/catalogueVite.d.ts +16 -0
  4. package/dist/bin/forgebook/catalogueVite.d.ts.map +1 -0
  5. package/dist/bin/forgebook/catalogueVite.js +15 -0
  6. package/dist/bin/forgebook/catalogueVite.js.map +1 -0
  7. package/dist/bin/forgebook/forgebook.d.mts +3 -0
  8. package/dist/bin/forgebook/forgebook.d.mts.map +1 -0
  9. package/dist/bin/forgebook/forgebook.mjs +93 -0
  10. package/dist/bin/forgebook/forgebook.mjs.map +1 -0
  11. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +90 -0
  12. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -0
  13. package/dist/bin/forgebook-docs/catalogueDocs.types.js +1 -0
  14. package/dist/bin/forgebook-docs/catalogueDocs.types.js.map +1 -0
  15. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +9 -0
  16. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -0
  17. package/dist/bin/forgebook-docs/catalogueMarkdown.js +132 -0
  18. package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -0
  19. package/dist/bin/forgebook-docs/collectDocs.d.ts +17 -0
  20. package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -0
  21. package/dist/bin/forgebook-docs/collectDocs.js +115 -0
  22. package/dist/bin/forgebook-docs/collectDocs.js.map +1 -0
  23. package/dist/bin/forgebook-docs/forgebook-docs.d.mts +3 -0
  24. package/dist/bin/forgebook-docs/forgebook-docs.d.mts.map +1 -0
  25. package/dist/bin/forgebook-docs/forgebook-docs.mjs +114 -0
  26. package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -0
  27. package/dist/bin/forgebook-docs/moduleDocs.d.ts +9 -0
  28. package/dist/bin/forgebook-docs/moduleDocs.d.ts.map +1 -0
  29. package/dist/bin/forgebook-docs/moduleDocs.js +62 -0
  30. package/dist/bin/forgebook-docs/moduleDocs.js.map +1 -0
  31. package/dist/bin/forgebook-docs/sassDocs.d.ts +20 -0
  32. package/dist/bin/forgebook-docs/sassDocs.d.ts.map +1 -0
  33. package/dist/bin/forgebook-docs/sassDocs.js +77 -0
  34. package/dist/bin/forgebook-docs/sassDocs.js.map +1 -0
  35. package/dist/bin/forgebook-texts/forgebook-texts.d.mts +3 -0
  36. package/dist/bin/forgebook-texts/forgebook-texts.d.mts.map +1 -0
  37. package/dist/bin/forgebook-texts/forgebook-texts.mjs +94 -0
  38. package/dist/bin/forgebook-texts/forgebook-texts.mjs.map +1 -0
  39. package/dist/bin/forgebook-texts/storyTextsReport.d.ts +26 -0
  40. package/dist/bin/forgebook-texts/storyTextsReport.d.ts.map +1 -0
  41. package/dist/bin/forgebook-texts/storyTextsReport.js +35 -0
  42. package/dist/bin/forgebook-texts/storyTextsReport.js.map +1 -0
  43. package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts +25 -0
  44. package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts.map +1 -0
  45. package/dist/bin/forgebook-texts/storyTextsReport.types.js +7 -0
  46. package/dist/bin/forgebook-texts/storyTextsReport.types.js.map +1 -0
  47. package/dist/src/a11y.d.ts +28 -0
  48. package/dist/src/a11y.d.ts.map +1 -0
  49. package/dist/src/a11y.js +29 -0
  50. package/dist/src/a11y.js.map +1 -0
  51. package/dist/src/argTypes.d.ts +114 -0
  52. package/dist/src/argTypes.d.ts.map +1 -0
  53. package/dist/src/argTypes.js +254 -0
  54. package/dist/src/argTypes.js.map +1 -0
  55. package/dist/src/backdrops.d.ts +88 -0
  56. package/dist/src/backdrops.d.ts.map +1 -0
  57. package/dist/src/backdrops.js +202 -0
  58. package/dist/src/backdrops.js.map +1 -0
  59. package/dist/src/catalogue.d.ts +120 -0
  60. package/dist/src/catalogue.d.ts.map +1 -0
  61. package/dist/src/catalogue.js +80 -0
  62. package/dist/src/catalogue.js.map +1 -0
  63. package/dist/src/componentDocs.d.ts +98 -0
  64. package/dist/src/componentDocs.d.ts.map +1 -0
  65. package/dist/src/componentDocs.js +47 -0
  66. package/dist/src/componentDocs.js.map +1 -0
  67. package/dist/src/frame/checkStory.d.ts +20 -0
  68. package/dist/src/frame/checkStory.d.ts.map +1 -0
  69. package/dist/src/frame/checkStory.js +31 -0
  70. package/dist/src/frame/checkStory.js.map +1 -0
  71. package/dist/src/frame/frame.css +51 -0
  72. package/dist/src/frame/frameClock.d.ts +53 -0
  73. package/dist/src/frame/frameClock.d.ts.map +1 -0
  74. package/dist/src/frame/frameClock.js +80 -0
  75. package/dist/src/frame/frameClock.js.map +1 -0
  76. package/dist/src/frame/frameStatus.d.ts +8 -0
  77. package/dist/src/frame/frameStatus.d.ts.map +1 -0
  78. package/dist/src/frame/frameStatus.js +8 -0
  79. package/dist/src/frame/frameStatus.js.map +1 -0
  80. package/dist/src/frame/frameView.d.ts +33 -0
  81. package/dist/src/frame/frameView.d.ts.map +1 -0
  82. package/dist/src/frame/frameView.js +134 -0
  83. package/dist/src/frame/frameView.js.map +1 -0
  84. package/dist/src/frame/matrixLayout.d.ts +36 -0
  85. package/dist/src/frame/matrixLayout.d.ts.map +1 -0
  86. package/dist/src/frame/matrixLayout.js +87 -0
  87. package/dist/src/frame/matrixLayout.js.map +1 -0
  88. package/dist/src/frame/measureTools.d.ts +24 -0
  89. package/dist/src/frame/measureTools.d.ts.map +1 -0
  90. package/dist/src/frame/measureTools.js +141 -0
  91. package/dist/src/frame/measureTools.js.map +1 -0
  92. package/dist/src/frame/mountFrame.d.ts +47 -0
  93. package/dist/src/frame/mountFrame.d.ts.map +1 -0
  94. package/dist/src/frame/mountFrame.js +229 -0
  95. package/dist/src/frame/mountFrame.js.map +1 -0
  96. package/dist/src/frame/playStory.d.ts +40 -0
  97. package/dist/src/frame/playStory.d.ts.map +1 -0
  98. package/dist/src/frame/playStory.js +55 -0
  99. package/dist/src/frame/playStory.js.map +1 -0
  100. package/dist/src/frame/renderer.d.ts +85 -0
  101. package/dist/src/frame/renderer.d.ts.map +1 -0
  102. package/dist/src/frame/renderer.js +18 -0
  103. package/dist/src/frame/renderer.js.map +1 -0
  104. package/dist/src/frame/settle.d.ts +24 -0
  105. package/dist/src/frame/settle.d.ts.map +1 -0
  106. package/dist/src/frame/settle.js +25 -0
  107. package/dist/src/frame/settle.js.map +1 -0
  108. package/dist/src/frame/staleModule.d.ts +40 -0
  109. package/dist/src/frame/staleModule.d.ts.map +1 -0
  110. package/dist/src/frame/staleModule.js +74 -0
  111. package/dist/src/frame/staleModule.js.map +1 -0
  112. package/dist/src/frame/storyCanvas.d.ts +21 -0
  113. package/dist/src/frame/storyCanvas.d.ts.map +1 -0
  114. package/dist/src/frame/storyCanvas.js +30 -0
  115. package/dist/src/frame/storyCanvas.js.map +1 -0
  116. package/dist/src/frame/storyHooks.d.ts +31 -0
  117. package/dist/src/frame/storyHooks.d.ts.map +1 -0
  118. package/dist/src/frame/storyHooks.js +59 -0
  119. package/dist/src/frame/storyHooks.js.map +1 -0
  120. package/dist/src/frame/storyModule.d.ts +104 -0
  121. package/dist/src/frame/storyModule.d.ts.map +1 -0
  122. package/dist/src/frame/storyModule.js +205 -0
  123. package/dist/src/frame/storyModule.js.map +1 -0
  124. package/dist/src/frame/storyRun.d.ts +96 -0
  125. package/dist/src/frame/storyRun.d.ts.map +1 -0
  126. package/dist/src/frame/storyRun.js +318 -0
  127. package/dist/src/frame/storyRun.js.map +1 -0
  128. package/dist/src/languages.d.ts +15 -0
  129. package/dist/src/languages.d.ts.map +1 -0
  130. package/dist/src/languages.js +8 -0
  131. package/dist/src/languages.js.map +1 -0
  132. package/dist/src/matrix.d.ts +56 -0
  133. package/dist/src/matrix.d.ts.map +1 -0
  134. package/dist/src/matrix.js +61 -0
  135. package/dist/src/matrix.js.map +1 -0
  136. package/dist/src/messages.d.ts +203 -0
  137. package/dist/src/messages.d.ts.map +1 -0
  138. package/dist/src/messages.js +193 -0
  139. package/dist/src/messages.js.map +1 -0
  140. package/dist/src/namedValues.d.ts +38 -0
  141. package/dist/src/namedValues.d.ts.map +1 -0
  142. package/dist/src/namedValues.js +48 -0
  143. package/dist/src/namedValues.js.map +1 -0
  144. package/dist/src/pageConfig.d.ts +23 -0
  145. package/dist/src/pageConfig.d.ts.map +1 -0
  146. package/dist/src/pageConfig.js +1 -0
  147. package/dist/src/pageConfig.js.map +1 -0
  148. package/dist/src/playTrace.d.ts +41 -0
  149. package/dist/src/playTrace.d.ts.map +1 -0
  150. package/dist/src/playTrace.js +35 -0
  151. package/dist/src/playTrace.js.map +1 -0
  152. package/dist/src/shell/A11yTab.d.ts +44 -0
  153. package/dist/src/shell/A11yTab.d.ts.map +1 -0
  154. package/dist/src/shell/A11yTab.js +30 -0
  155. package/dist/src/shell/A11yTab.js.map +1 -0
  156. package/dist/src/shell/ApiReference.d.ts +18 -0
  157. package/dist/src/shell/ApiReference.d.ts.map +1 -0
  158. package/dist/src/shell/ApiReference.js +41 -0
  159. package/dist/src/shell/ApiReference.js.map +1 -0
  160. package/dist/src/shell/ClockControls.d.ts +43 -0
  161. package/dist/src/shell/ClockControls.d.ts.map +1 -0
  162. package/dist/src/shell/ClockControls.js +53 -0
  163. package/dist/src/shell/ClockControls.js.map +1 -0
  164. package/dist/src/shell/Code.d.ts +16 -0
  165. package/dist/src/shell/Code.d.ts.map +1 -0
  166. package/dist/src/shell/Code.js +9 -0
  167. package/dist/src/shell/Code.js.map +1 -0
  168. package/dist/src/shell/CodeTab.d.ts +17 -0
  169. package/dist/src/shell/CodeTab.d.ts.map +1 -0
  170. package/dist/src/shell/CodeTab.js +17 -0
  171. package/dist/src/shell/CodeTab.js.map +1 -0
  172. package/dist/src/shell/CodeText.d.ts +16 -0
  173. package/dist/src/shell/CodeText.d.ts.map +1 -0
  174. package/dist/src/shell/CodeText.js +10 -0
  175. package/dist/src/shell/CodeText.js.map +1 -0
  176. package/dist/src/shell/ComponentPage.d.ts +38 -0
  177. package/dist/src/shell/ComponentPage.d.ts.map +1 -0
  178. package/dist/src/shell/ComponentPage.js +146 -0
  179. package/dist/src/shell/ComponentPage.js.map +1 -0
  180. package/dist/src/shell/Dock.d.ts +42 -0
  181. package/dist/src/shell/Dock.d.ts.map +1 -0
  182. package/dist/src/shell/Dock.js +90 -0
  183. package/dist/src/shell/Dock.js.map +1 -0
  184. package/dist/src/shell/EventsTab.d.ts +25 -0
  185. package/dist/src/shell/EventsTab.d.ts.map +1 -0
  186. package/dist/src/shell/EventsTab.js +26 -0
  187. package/dist/src/shell/EventsTab.js.map +1 -0
  188. package/dist/src/shell/FrameView.d.ts +49 -0
  189. package/dist/src/shell/FrameView.d.ts.map +1 -0
  190. package/dist/src/shell/FrameView.js +29 -0
  191. package/dist/src/shell/FrameView.js.map +1 -0
  192. package/dist/src/shell/HomePage.d.ts +39 -0
  193. package/dist/src/shell/HomePage.d.ts.map +1 -0
  194. package/dist/src/shell/HomePage.js +85 -0
  195. package/dist/src/shell/HomePage.js.map +1 -0
  196. package/dist/src/shell/InteractionsTab.d.ts +28 -0
  197. package/dist/src/shell/InteractionsTab.d.ts.map +1 -0
  198. package/dist/src/shell/InteractionsTab.js +17 -0
  199. package/dist/src/shell/InteractionsTab.js.map +1 -0
  200. package/dist/src/shell/MatrixPicker.d.ts +24 -0
  201. package/dist/src/shell/MatrixPicker.d.ts.map +1 -0
  202. package/dist/src/shell/MatrixPicker.js +29 -0
  203. package/dist/src/shell/MatrixPicker.js.map +1 -0
  204. package/dist/src/shell/PackageHtml.d.ts +17 -0
  205. package/dist/src/shell/PackageHtml.d.ts.map +1 -0
  206. package/dist/src/shell/PackageHtml.js +13 -0
  207. package/dist/src/shell/PackageHtml.js.map +1 -0
  208. package/dist/src/shell/PartsTab.d.ts +23 -0
  209. package/dist/src/shell/PartsTab.d.ts.map +1 -0
  210. package/dist/src/shell/PartsTab.js +23 -0
  211. package/dist/src/shell/PartsTab.js.map +1 -0
  212. package/dist/src/shell/PropFields.d.ts +31 -0
  213. package/dist/src/shell/PropFields.d.ts.map +1 -0
  214. package/dist/src/shell/PropFields.js +81 -0
  215. package/dist/src/shell/PropFields.js.map +1 -0
  216. package/dist/src/shell/PropsTab.d.ts +45 -0
  217. package/dist/src/shell/PropsTab.d.ts.map +1 -0
  218. package/dist/src/shell/PropsTab.js +81 -0
  219. package/dist/src/shell/PropsTab.js.map +1 -0
  220. package/dist/src/shell/SchemeSwitches.d.ts +24 -0
  221. package/dist/src/shell/SchemeSwitches.d.ts.map +1 -0
  222. package/dist/src/shell/SchemeSwitches.js +36 -0
  223. package/dist/src/shell/SchemeSwitches.js.map +1 -0
  224. package/dist/src/shell/Segmented.d.ts +41 -0
  225. package/dist/src/shell/Segmented.d.ts.map +1 -0
  226. package/dist/src/shell/Segmented.js +19 -0
  227. package/dist/src/shell/Segmented.js.map +1 -0
  228. package/dist/src/shell/Shell.d.ts +49 -0
  229. package/dist/src/shell/Shell.d.ts.map +1 -0
  230. package/dist/src/shell/Shell.js +279 -0
  231. package/dist/src/shell/Shell.js.map +1 -0
  232. package/dist/src/shell/Sidebar.d.ts +52 -0
  233. package/dist/src/shell/Sidebar.d.ts.map +1 -0
  234. package/dist/src/shell/Sidebar.js +132 -0
  235. package/dist/src/shell/Sidebar.js.map +1 -0
  236. package/dist/src/shell/SidebarHandle.d.ts +29 -0
  237. package/dist/src/shell/SidebarHandle.d.ts.map +1 -0
  238. package/dist/src/shell/SidebarHandle.js +46 -0
  239. package/dist/src/shell/SidebarHandle.js.map +1 -0
  240. package/dist/src/shell/Stage.d.ts +68 -0
  241. package/dist/src/shell/Stage.d.ts.map +1 -0
  242. package/dist/src/shell/Stage.js +218 -0
  243. package/dist/src/shell/Stage.js.map +1 -0
  244. package/dist/src/shell/StageTools.d.ts +27 -0
  245. package/dist/src/shell/StageTools.d.ts.map +1 -0
  246. package/dist/src/shell/StageTools.js +34 -0
  247. package/dist/src/shell/StageTools.js.map +1 -0
  248. package/dist/src/shell/StageViewport.d.ts +46 -0
  249. package/dist/src/shell/StageViewport.d.ts.map +1 -0
  250. package/dist/src/shell/StageViewport.js +173 -0
  251. package/dist/src/shell/StageViewport.js.map +1 -0
  252. package/dist/src/shell/StoryCodeBlock.d.ts +35 -0
  253. package/dist/src/shell/StoryCodeBlock.d.ts.map +1 -0
  254. package/dist/src/shell/StoryCodeBlock.js +27 -0
  255. package/dist/src/shell/StoryCodeBlock.js.map +1 -0
  256. package/dist/src/shell/StoryPicker.d.ts +26 -0
  257. package/dist/src/shell/StoryPicker.d.ts.map +1 -0
  258. package/dist/src/shell/StoryPicker.js +32 -0
  259. package/dist/src/shell/StoryPicker.js.map +1 -0
  260. package/dist/src/shell/Toolbar.d.ts +40 -0
  261. package/dist/src/shell/Toolbar.d.ts.map +1 -0
  262. package/dist/src/shell/Toolbar.js +125 -0
  263. package/dist/src/shell/Toolbar.js.map +1 -0
  264. package/dist/src/shell/WidthField.d.ts +24 -0
  265. package/dist/src/shell/WidthField.d.ts.map +1 -0
  266. package/dist/src/shell/WidthField.js +40 -0
  267. package/dist/src/shell/WidthField.js.map +1 -0
  268. package/dist/src/shell/catalogueContext.d.ts +6 -0
  269. package/dist/src/shell/catalogueContext.d.ts.map +1 -0
  270. package/dist/src/shell/catalogueContext.js +14 -0
  271. package/dist/src/shell/catalogueContext.js.map +1 -0
  272. package/dist/src/shell/codeTokens.d.ts +23 -0
  273. package/dist/src/shell/codeTokens.d.ts.map +1 -0
  274. package/dist/src/shell/codeTokens.js +48 -0
  275. package/dist/src/shell/codeTokens.js.map +1 -0
  276. package/dist/src/shell/codeWriter.d.ts +6 -0
  277. package/dist/src/shell/codeWriter.d.ts.map +1 -0
  278. package/dist/src/shell/codeWriter.js +14 -0
  279. package/dist/src/shell/codeWriter.js.map +1 -0
  280. package/dist/src/shell/compareVariants.d.ts +35 -0
  281. package/dist/src/shell/compareVariants.d.ts.map +1 -0
  282. package/dist/src/shell/compareVariants.js +68 -0
  283. package/dist/src/shell/compareVariants.js.map +1 -0
  284. package/dist/src/shell/dockTabs.d.ts +63 -0
  285. package/dist/src/shell/dockTabs.d.ts.map +1 -0
  286. package/dist/src/shell/dockTabs.js +140 -0
  287. package/dist/src/shell/dockTabs.js.map +1 -0
  288. package/dist/src/shell/icons.d.ts +47 -0
  289. package/dist/src/shell/icons.d.ts.map +1 -0
  290. package/dist/src/shell/icons.js +36 -0
  291. package/dist/src/shell/icons.js.map +1 -0
  292. package/dist/src/shell/keyboard.d.ts +35 -0
  293. package/dist/src/shell/keyboard.d.ts.map +1 -0
  294. package/dist/src/shell/keyboard.js +51 -0
  295. package/dist/src/shell/keyboard.js.map +1 -0
  296. package/dist/src/shell/mountShell.d.ts +22 -0
  297. package/dist/src/shell/mountShell.d.ts.map +1 -0
  298. package/dist/src/shell/mountShell.js +39 -0
  299. package/dist/src/shell/mountShell.js.map +1 -0
  300. package/dist/src/shell/shell.css +1831 -0
  301. package/dist/src/shell/strings.d.ts +184 -0
  302. package/dist/src/shell/strings.d.ts.map +1 -0
  303. package/dist/src/shell/strings.js +188 -0
  304. package/dist/src/shell/strings.js.map +1 -0
  305. package/dist/src/shell/switchView.d.ts +23 -0
  306. package/dist/src/shell/switchView.d.ts.map +1 -0
  307. package/dist/src/shell/switchView.js +19 -0
  308. package/dist/src/shell/switchView.js.map +1 -0
  309. package/dist/src/shell/treeSearch.d.ts +35 -0
  310. package/dist/src/shell/treeSearch.d.ts.map +1 -0
  311. package/dist/src/shell/treeSearch.js +60 -0
  312. package/dist/src/shell/treeSearch.js.map +1 -0
  313. package/dist/src/shell/useComponentDocs.d.ts +16 -0
  314. package/dist/src/shell/useComponentDocs.d.ts.map +1 -0
  315. package/dist/src/shell/useComponentDocs.js +25 -0
  316. package/dist/src/shell/useComponentDocs.js.map +1 -0
  317. package/dist/src/shell/useCopy.d.ts +10 -0
  318. package/dist/src/shell/useCopy.d.ts.map +1 -0
  319. package/dist/src/shell/useCopy.js +23 -0
  320. package/dist/src/shell/useCopy.js.map +1 -0
  321. package/dist/src/shell/useFrameMessages.d.ts +54 -0
  322. package/dist/src/shell/useFrameMessages.d.ts.map +1 -0
  323. package/dist/src/shell/useFrameMessages.js +90 -0
  324. package/dist/src/shell/useFrameMessages.js.map +1 -0
  325. package/dist/src/shell/useFrameQueue.d.ts +29 -0
  326. package/dist/src/shell/useFrameQueue.d.ts.map +1 -0
  327. package/dist/src/shell/useFrameQueue.js +72 -0
  328. package/dist/src/shell/useFrameQueue.js.map +1 -0
  329. package/dist/src/shell/useLiveView.d.ts +29 -0
  330. package/dist/src/shell/useLiveView.d.ts.map +1 -0
  331. package/dist/src/shell/useLiveView.js +51 -0
  332. package/dist/src/shell/useLiveView.js.map +1 -0
  333. package/dist/src/shell/useLoaded.d.ts +20 -0
  334. package/dist/src/shell/useLoaded.d.ts.map +1 -0
  335. package/dist/src/shell/useLoaded.js +40 -0
  336. package/dist/src/shell/useLoaded.js.map +1 -0
  337. package/dist/src/shell/usePageDoc.d.ts +20 -0
  338. package/dist/src/shell/usePageDoc.d.ts.map +1 -0
  339. package/dist/src/shell/usePageDoc.js +21 -0
  340. package/dist/src/shell/usePageDoc.js.map +1 -0
  341. package/dist/src/shell/usePopover.d.ts +23 -0
  342. package/dist/src/shell/usePopover.d.ts.map +1 -0
  343. package/dist/src/shell/usePopover.js +39 -0
  344. package/dist/src/shell/usePopover.js.map +1 -0
  345. package/dist/src/shell/useRecentPages.d.ts +21 -0
  346. package/dist/src/shell/useRecentPages.d.ts.map +1 -0
  347. package/dist/src/shell/useRecentPages.js +62 -0
  348. package/dist/src/shell/useRecentPages.js.map +1 -0
  349. package/dist/src/shell/useScrollMemory.d.ts +40 -0
  350. package/dist/src/shell/useScrollMemory.d.ts.map +1 -0
  351. package/dist/src/shell/useScrollMemory.js +69 -0
  352. package/dist/src/shell/useScrollMemory.js.map +1 -0
  353. package/dist/src/shell/useSidebarLayout.d.ts +14 -0
  354. package/dist/src/shell/useSidebarLayout.d.ts.map +1 -0
  355. package/dist/src/shell/useSidebarLayout.js +19 -0
  356. package/dist/src/shell/useSidebarLayout.js.map +1 -0
  357. package/dist/src/shell/useStored.d.ts +11 -0
  358. package/dist/src/shell/useStored.d.ts.map +1 -0
  359. package/dist/src/shell/useStored.js +68 -0
  360. package/dist/src/shell/useStored.js.map +1 -0
  361. package/dist/src/shell/useStoryCode.d.ts +14 -0
  362. package/dist/src/shell/useStoryCode.d.ts.map +1 -0
  363. package/dist/src/shell/useStoryCode.js +29 -0
  364. package/dist/src/shell/useStoryCode.js.map +1 -0
  365. package/dist/src/shell/useStoryHeights.d.ts +9 -0
  366. package/dist/src/shell/useStoryHeights.d.ts.map +1 -0
  367. package/dist/src/shell/useStoryHeights.js +31 -0
  368. package/dist/src/shell/useStoryHeights.js.map +1 -0
  369. package/dist/src/shell/useStoryIdsElement.d.ts +7 -0
  370. package/dist/src/shell/useStoryIdsElement.d.ts.map +1 -0
  371. package/dist/src/shell/useStoryIdsElement.js +29 -0
  372. package/dist/src/shell/useStoryIdsElement.js.map +1 -0
  373. package/dist/src/shell/useStoryKeys.d.ts +11 -0
  374. package/dist/src/shell/useStoryKeys.d.ts.map +1 -0
  375. package/dist/src/shell/useStoryKeys.js +40 -0
  376. package/dist/src/shell/useStoryKeys.js.map +1 -0
  377. package/dist/src/shell/useSystemDark.d.ts +3 -0
  378. package/dist/src/shell/useSystemDark.d.ts.map +1 -0
  379. package/dist/src/shell/useSystemDark.js +19 -0
  380. package/dist/src/shell/useSystemDark.js.map +1 -0
  381. package/dist/src/sourceFiles.d.ts +18 -0
  382. package/dist/src/sourceFiles.d.ts.map +1 -0
  383. package/dist/src/sourceFiles.js +22 -0
  384. package/dist/src/sourceFiles.js.map +1 -0
  385. package/dist/src/storyBackground.d.ts +21 -0
  386. package/dist/src/storyBackground.d.ts.map +1 -0
  387. package/dist/src/storyBackground.js +27 -0
  388. package/dist/src/storyBackground.js.map +1 -0
  389. package/dist/src/storyClock.d.ts +62 -0
  390. package/dist/src/storyClock.d.ts.map +1 -0
  391. package/dist/src/storyClock.js +51 -0
  392. package/dist/src/storyClock.js.map +1 -0
  393. package/dist/src/storyGlobals.d.ts +60 -0
  394. package/dist/src/storyGlobals.d.ts.map +1 -0
  395. package/dist/src/storyGlobals.js +117 -0
  396. package/dist/src/storyGlobals.js.map +1 -0
  397. package/dist/src/storyHeights.d.ts +37 -0
  398. package/dist/src/storyHeights.d.ts.map +1 -0
  399. package/dist/src/storyHeights.js +53 -0
  400. package/dist/src/storyHeights.js.map +1 -0
  401. package/dist/src/storyIdsElement.d.ts +9 -0
  402. package/dist/src/storyIdsElement.d.ts.map +1 -0
  403. package/dist/src/storyIdsElement.js +9 -0
  404. package/dist/src/storyIdsElement.js.map +1 -0
  405. package/dist/src/storyTexts.d.ts +43 -0
  406. package/dist/src/storyTexts.d.ts.map +1 -0
  407. package/dist/src/storyTexts.js +71 -0
  408. package/dist/src/storyTexts.js.map +1 -0
  409. package/dist/src/storyTree.d.ts +215 -0
  410. package/dist/src/storyTree.d.ts.map +1 -0
  411. package/dist/src/storyTree.js +308 -0
  412. package/dist/src/storyTree.js.map +1 -0
  413. package/dist/src/switches.d.ts +156 -0
  414. package/dist/src/switches.d.ts.map +1 -0
  415. package/dist/src/switches.js +193 -0
  416. package/dist/src/switches.js.map +1 -0
  417. package/dist/src/viewState.d.ts +194 -0
  418. package/dist/src/viewState.d.ts.map +1 -0
  419. package/dist/src/viewState.js +303 -0
  420. package/dist/src/viewState.js.map +1 -0
  421. package/dist/src/vite/adapter.d.ts +70 -0
  422. package/dist/src/vite/adapter.d.ts.map +1 -0
  423. package/dist/src/vite/adapter.js +22 -0
  424. package/dist/src/vite/adapter.js.map +1 -0
  425. package/dist/src/vite/autoTitle.d.ts +28 -0
  426. package/dist/src/vite/autoTitle.d.ts.map +1 -0
  427. package/dist/src/vite/autoTitle.js +44 -0
  428. package/dist/src/vite/autoTitle.js.map +1 -0
  429. package/dist/src/vite/componentPage.d.ts +34 -0
  430. package/dist/src/vite/componentPage.d.ts.map +1 -0
  431. package/dist/src/vite/componentPage.js +94 -0
  432. package/dist/src/vite/componentPage.js.map +1 -0
  433. package/dist/src/vite/config.d.ts +72 -0
  434. package/dist/src/vite/config.d.ts.map +1 -0
  435. package/dist/src/vite/config.js +25 -0
  436. package/dist/src/vite/config.js.map +1 -0
  437. package/dist/src/vite/configFile.d.ts +76 -0
  438. package/dist/src/vite/configFile.d.ts.map +1 -0
  439. package/dist/src/vite/configFile.js +190 -0
  440. package/dist/src/vite/configFile.js.map +1 -0
  441. package/dist/src/vite/docsExtractor.d.ts +46 -0
  442. package/dist/src/vite/docsExtractor.d.ts.map +1 -0
  443. package/dist/src/vite/docsExtractor.js +88 -0
  444. package/dist/src/vite/docsExtractor.js.map +1 -0
  445. package/dist/src/vite/docsProgram.d.ts +42 -0
  446. package/dist/src/vite/docsProgram.d.ts.map +1 -0
  447. package/dist/src/vite/docsProgram.js +144 -0
  448. package/dist/src/vite/docsProgram.js.map +1 -0
  449. package/dist/src/vite/docsWorker.d.ts +2 -0
  450. package/dist/src/vite/docsWorker.d.ts.map +1 -0
  451. package/dist/src/vite/docsWorker.js +68 -0
  452. package/dist/src/vite/docsWorker.js.map +1 -0
  453. package/dist/src/vite/forcedStates.d.ts +27 -0
  454. package/dist/src/vite/forcedStates.d.ts.map +1 -0
  455. package/dist/src/vite/forcedStates.js +60 -0
  456. package/dist/src/vite/forcedStates.js.map +1 -0
  457. package/dist/src/vite/forgebookPlugin.d.ts +28 -0
  458. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -0
  459. package/dist/src/vite/forgebookPlugin.js +375 -0
  460. package/dist/src/vite/forgebookPlugin.js.map +1 -0
  461. package/dist/src/vite/highlightCode.d.ts +16 -0
  462. package/dist/src/vite/highlightCode.d.ts.map +1 -0
  463. package/dist/src/vite/highlightCode.js +82 -0
  464. package/dist/src/vite/highlightCode.js.map +1 -0
  465. package/dist/src/vite/indexStoryFile.d.ts +35 -0
  466. package/dist/src/vite/indexStoryFile.d.ts.map +1 -0
  467. package/dist/src/vite/indexStoryFile.js +458 -0
  468. package/dist/src/vite/indexStoryFile.js.map +1 -0
  469. package/dist/src/vite/pages.d.ts +49 -0
  470. package/dist/src/vite/pages.d.ts.map +1 -0
  471. package/dist/src/vite/pages.js +171 -0
  472. package/dist/src/vite/pages.js.map +1 -0
  473. package/dist/src/vite/prebundled.d.ts +30 -0
  474. package/dist/src/vite/prebundled.d.ts.map +1 -0
  475. package/dist/src/vite/prebundled.js +81 -0
  476. package/dist/src/vite/prebundled.js.map +1 -0
  477. package/dist/src/vite/storyCode.d.ts +28 -0
  478. package/dist/src/vite/storyCode.d.ts.map +1 -0
  479. package/dist/src/vite/storyCode.js +80 -0
  480. package/dist/src/vite/storyCode.js.map +1 -0
  481. package/dist/src/vite/storyFilesModule.d.ts +17 -0
  482. package/dist/src/vite/storyFilesModule.d.ts.map +1 -0
  483. package/dist/src/vite/storyFilesModule.js +64 -0
  484. package/dist/src/vite/storyFilesModule.js.map +1 -0
  485. package/dist/src/vite/storyMeta.d.ts +34 -0
  486. package/dist/src/vite/storyMeta.d.ts.map +1 -0
  487. package/dist/src/vite/storyMeta.js +74 -0
  488. package/dist/src/vite/storyMeta.js.map +1 -0
  489. package/dist/src/vite/typeScriptPieces.d.ts +23 -0
  490. package/dist/src/vite/typeScriptPieces.d.ts.map +1 -0
  491. package/dist/src/vite/typeScriptPieces.js +236 -0
  492. package/dist/src/vite/typeScriptPieces.js.map +1 -0
  493. package/package.json +202 -3
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { MEASURE_TOOLS } from "../viewState.js";
3
+ import { useCatalogue } from "./catalogueContext.js";
4
+ import { Icon } from "./icons.js";
5
+ import { STRINGS } from "./strings.js";
6
+ /** Each tool's icon. */
7
+ const TOOL_ICONS = {
8
+ outline: "outline",
9
+ grid: "grid",
10
+ measure: "ruler"
11
+ };
12
+ /**
13
+ * The zoom and the tools, floating at the stage's lower end corner: they change how the story is looked at, not what
14
+ * it gets, so they sit on the stage rather than in the toolbar.
15
+ *
16
+ * @param props - the zoom, the tools and their setters.
17
+ */
18
+ export const StageTools = ({ zoom, onZoomChange, tools, onToolsChange }) => {
19
+ const { zooms } = useCatalogue();
20
+ const step = zooms.indexOf(zoom);
21
+ const zoomOut = zooms[step - 1];
22
+ const zoomIn = zooms[step + 1];
23
+ return (_jsxs("div", { className: "forgebook-stage-tools", role: "toolbar", "aria-label": STRINGS.stageTools, children: [_jsxs("div", { className: "forgebook-stage-tools__group", children: [_jsx("button", { type: "button", className: "forgebook-stage-tools__button", "aria-label": STRINGS.zoomOut, title: STRINGS.zoomOut, disabled: zoomOut === undefined, onClick: () => {
24
+ if (zoomOut !== undefined)
25
+ onZoomChange(zoomOut);
26
+ }, children: _jsx(Icon, { name: "minus", size: 14 }) }), _jsx("button", { type: "button", className: "forgebook-stage-tools__zoom", "aria-label": `${STRINGS.zoom} ${zoom}%: ${STRINGS.zoomReset}`, title: STRINGS.zoomReset, disabled: zoom === 100, onClick: () => onZoomChange(100), children: `${zoom}%` }), _jsx("button", { type: "button", className: "forgebook-stage-tools__button", "aria-label": STRINGS.zoomIn, title: STRINGS.zoomIn, disabled: zoomIn === undefined, onClick: () => {
27
+ if (zoomIn !== undefined)
28
+ onZoomChange(zoomIn);
29
+ }, children: _jsx(Icon, { name: "plus", size: 14 }) })] }), _jsx("span", { className: "forgebook-stage-tools__divider" }), _jsx("div", { className: "forgebook-stage-tools__group", children: MEASURE_TOOLS.map((tool) => {
30
+ const isOn = tools.includes(tool);
31
+ return (_jsx("button", { type: "button", className: "forgebook-stage-tools__button", "aria-pressed": isOn, title: STRINGS.tools[tool], "aria-label": STRINGS.tools[tool], onClick: () => onToolsChange(MEASURE_TOOLS.filter((known) => (known === tool ? !isOn : tools.includes(known)))), children: _jsx(Icon, { name: TOOL_ICONS[tool], size: 14 }) }, tool));
32
+ }) })] }));
33
+ };
34
+ //# sourceMappingURL=StageTools.js.map
@@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,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAClF,YAGH,KAAC,IAAI,IAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,GAAI,IAZrC,IAAI,CAaF,CACV,CAAC;gBACJ,CAAC,CAAC,GACE,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The room a story's frame gets on the stage, as a browser's device mode: the stage's whole width or a fixed one,
3
+ * centred, with a handle on each side; the width it has is reported to the toolbar's field. On a story's page a
4
+ * handle at its foot sets its height too (note 142): the story's own (its content, at least the height it declares) or a dragged one, which is the window the story's overlays are placed in.
5
+ *
6
+ * @remarks
7
+ * Dragging either handle widens or narrows the story on both sides at once, so it stays centred; a double click on a
8
+ * handle gives the story the whole stage again. A handle keeps the pointer while it drags, so the frame under it
9
+ * cannot take the moves; the arrow keys move it too (10 px, 50 px with Shift). The width reaches the address only when
10
+ * a drag ends or the toolbar's field is committed, so a drag is one entry in the address, not hundreds. A story wider than the
11
+ * stage scrolls sideways. The foot handle works the same way downwards (one side, so the height follows the pointer
12
+ * one for one), its arrow keys are up and down, and a double click gives the story its own height back.
13
+ *
14
+ * @module
15
+ */
16
+ import { type ReactNode } from "react";
17
+ import { type StageHeight, type StageWidth, type Zoom } from "../viewState.ts";
18
+ /** The viewport's props. */
19
+ export type StageViewportProps = {
20
+ /** The story's width. */
21
+ readonly width: StageWidth;
22
+ /** Called with the width a handle, the keyboard or the field set; none shows no handles (the component's page). */
23
+ readonly onWidthChange?: ((width: StageWidth) => void) | undefined;
24
+ /** The story's zoom, in percent: it scales the drawing, the story keeps its width. */
25
+ readonly zoom?: Zoom;
26
+ /** Called with the width the story really has (a drag's, or the stage's while it fills it), for the toolbar. */
27
+ readonly onShownWidthChange?: ((width: number | undefined) => void) | undefined;
28
+ /** The colour the story's page has (its source's, for the view), which the room waits on; the surface's otherwise. */
29
+ readonly background?: string | undefined;
30
+ /** The story's height: its own by default. */
31
+ readonly height?: StageHeight;
32
+ /** Called with the height the foot handle or its keys set; none shows no foot handle (the component's page). */
33
+ readonly onHeightChange?: ((height: StageHeight) => void) | undefined;
34
+ /**
35
+ * The frame, or a function that draws it at the height set by the foot handle (a drag's while it lasts), in the
36
+ * story's own CSS px; `undefined` lets the frame take the story's own.
37
+ */
38
+ readonly children: ReactNode | ((height: number | undefined) => ReactNode);
39
+ };
40
+ /**
41
+ * The room of a story's frame.
42
+ *
43
+ * @param props - the width, its setter and the frame.
44
+ */
45
+ export declare const StageViewport: ({ width, onWidthChange, zoom, onShownWidthChange, background, height, onHeightChange, children }: StageViewportProps) => ReactNode;
46
+ //# sourceMappingURL=StageViewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StageViewport.d.ts","sourceRoot":"","sources":["../../../src/shell/StageViewport.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAIL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,IAAI,EACV,MAAM,iBAAiB,CAAC;AAIzB,4BAA4B;AAC5B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,mHAAmH;IACnH,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACnE,sFAAsF;IACtF,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,gHAAgH;IAChH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAChF,sHAAsH;IACtH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,gHAAgH;IAChH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC;CAC5E,CAAC;AA8GF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,kGAS3B,kBAAkB,KAAG,SAkJvB,CAAC"}
@@ -0,0 +1,173 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The room a story's frame gets on the stage, as a browser's device mode: the stage's whole width or a fixed one,
4
+ * centred, with a handle on each side; the width it has is reported to the toolbar's field. On a story's page a
5
+ * handle at its foot sets its height too (note 142): the story's own (its content, at least the height it declares) or a dragged one, which is the window the story's overlays are placed in.
6
+ *
7
+ * @remarks
8
+ * Dragging either handle widens or narrows the story on both sides at once, so it stays centred; a double click on a
9
+ * handle gives the story the whole stage again. A handle keeps the pointer while it drags, so the frame under it
10
+ * cannot take the moves; the arrow keys move it too (10 px, 50 px with Shift). The width reaches the address only when
11
+ * a drag ends or the toolbar's field is committed, so a drag is one entry in the address, not hundreds. A story wider than the
12
+ * stage scrolls sideways. The foot handle works the same way downwards (one side, so the height follows the pointer
13
+ * one for one), its arrow keys are up and down, and a double click gives the story its own height back.
14
+ *
15
+ * @module
16
+ */
17
+ import { useEffect, useRef, useState } from "react";
18
+ import { clampedHeight, clampedWidth, STAGE_HEIGHT_RANGE } from "../viewState.js";
19
+ import { useCatalogue } from "./catalogueContext.js";
20
+ import { STRINGS } from "./strings.js";
21
+ /** A handle's width, in CSS px: the stage's `$space-4`. */
22
+ const HANDLE_WIDTH = 16;
23
+ /** How much one arrow key changes the width, in CSS px: without and with Shift. */
24
+ const KEY_STEP = { normal: 10, large: 50 };
25
+ /** A height, as the foot handle's readout writes it. */
26
+ const heightLabel = (height) => `${height} px`;
27
+ /** The height set on the stage, in CSS px; none at the story's own. */
28
+ const chosenHeightOf = (height) => (height === "auto" ? undefined : height);
29
+ /** The column of the story and its foot handle: the canvas's room for Fill, its content's otherwise. */
30
+ const columnStyle = (layoutWidth) => layoutWidth === undefined ? { flex: 1, minWidth: 0 } : undefined;
31
+ /** The frame, drawn at the height set on the stage when it is drawn by a function. */
32
+ const drawnFrame = (children, height) => typeof children === "function" ? children(height) : children;
33
+ /**
34
+ * The handle at the story's foot (note 142): a drag or the up and down keys set the story's height from the one it
35
+ * has, a double click gives it its own back; it shows the height set.
36
+ *
37
+ * @param props - the zoom, the heights and their setters.
38
+ */
39
+ const FootHandle = ({ scale, roomHeight, fixedHeight, currentHeight, onDrag, onHeightChange }) => {
40
+ if (onHeightChange === undefined)
41
+ return null;
42
+ const startDrag = (event) => {
43
+ if (event.button !== 0)
44
+ return;
45
+ event.preventDefault();
46
+ const handle = event.currentTarget;
47
+ handle.setPointerCapture(event.pointerId);
48
+ const startY = event.clientY;
49
+ // from the height the story has now: its own (at least the declared one) or the one set before
50
+ const startHeight = currentHeight();
51
+ const heightAt = (clientY) => clampedHeight(startHeight + (clientY - startY) / scale);
52
+ const move = (moveEvent) => onDrag(heightAt(moveEvent.clientY));
53
+ const end = (endEvent) => {
54
+ handle.removeEventListener("pointermove", move);
55
+ handle.removeEventListener("pointerup", end);
56
+ handle.removeEventListener("pointercancel", end);
57
+ onDrag(undefined);
58
+ if (endEvent.clientY !== startY)
59
+ onHeightChange(heightAt(endEvent.clientY));
60
+ };
61
+ handle.addEventListener("pointermove", move);
62
+ handle.addEventListener("pointerup", end);
63
+ handle.addEventListener("pointercancel", end);
64
+ };
65
+ const resizeWithKeys = (event) => {
66
+ const step = event.shiftKey ? KEY_STEP.large : KEY_STEP.normal;
67
+ if (event.key === "ArrowDown")
68
+ onHeightChange(clampedHeight(currentHeight() + step));
69
+ else if (event.key === "ArrowUp")
70
+ onHeightChange(clampedHeight(currentHeight() - step));
71
+ else
72
+ return;
73
+ event.preventDefault();
74
+ };
75
+ return (_jsx("div", { className: "forgebook-viewport__foot", role: "separator", "aria-orientation": "horizontal", "aria-label": STRINGS.heightHandle, "aria-valuemin": STAGE_HEIGHT_RANGE.min, "aria-valuemax": STAGE_HEIGHT_RANGE.max, "aria-valuenow": fixedHeight ?? roomHeight, title: STRINGS.heightHandleHint, tabIndex: 0, onPointerDown: startDrag, onKeyDown: resizeWithKeys, onDoubleClick: () => onHeightChange("auto"), children: fixedHeight === undefined ? null : (_jsx("span", { className: "forgebook-viewport__foot-label", children: heightLabel(fixedHeight) })) }));
76
+ };
77
+ /**
78
+ * The room of a story's frame.
79
+ *
80
+ * @param props - the width, its setter and the frame.
81
+ */
82
+ export const StageViewport = ({ width, onWidthChange, zoom = 100, onShownWidthChange, background, height = "auto", onHeightChange, children }) => {
83
+ const { widthRange } = useCatalogue();
84
+ const roomRef = useRef(null);
85
+ const canvasRef = useRef(null);
86
+ const scale = zoom / 100;
87
+ // the room the story gets for "fill", in the story's own px: the canvas's width, unzoomed
88
+ const [canvasWidth, setCanvasWidth] = useState(undefined);
89
+ // the story's height in its own px, for the zoomed box around it
90
+ const [roomHeight, setRoomHeight] = useState(undefined);
91
+ // the width while a drag is under way; the address gets it when the drag ends
92
+ const [dragWidth, setDragWidth] = useState(undefined);
93
+ // the width the story really has: the stage's own for "fill"
94
+ const [shownWidth, setShownWidth] = useState(undefined);
95
+ // the height while the foot handle drags; the address gets it when the drag ends
96
+ const [dragHeight, setDragHeight] = useState(undefined);
97
+ // offsetWidth and offsetHeight are the story's own px: a zoom's transform does not change them
98
+ useEffect(() => {
99
+ const room = roomRef.current;
100
+ const canvas = canvasRef.current;
101
+ if (room === null || canvas === null)
102
+ return;
103
+ const observer = new ResizeObserver(() => {
104
+ setShownWidth(room.offsetWidth);
105
+ setRoomHeight(room.offsetHeight);
106
+ setCanvasWidth(canvas.clientWidth);
107
+ });
108
+ observer.observe(room);
109
+ observer.observe(canvas);
110
+ return () => observer.disconnect();
111
+ }, []);
112
+ // the toolbar's width field shows the width the story has, a drag's included; none once the stage goes
113
+ const reportedWidth = dragWidth ?? shownWidth;
114
+ useEffect(() => onShownWidthChange?.(reportedWidth), [onShownWidthChange, reportedWidth]);
115
+ useEffect(() => () => onShownWidthChange?.(undefined), [onShownWidthChange]);
116
+ const currentWidth = () => roomRef.current?.offsetWidth ?? widthRange.min;
117
+ const startDrag = (side, event) => {
118
+ if (onWidthChange === undefined || event.button !== 0)
119
+ return;
120
+ event.preventDefault();
121
+ const handle = event.currentTarget;
122
+ handle.setPointerCapture(event.pointerId);
123
+ const startX = event.clientX;
124
+ const startWidth = currentWidth();
125
+ // centred: a handle moved by x changes the width by twice x, in the story's own px
126
+ const widthAt = (clientX) => clampedWidth(startWidth + (2 * (side === "end" ? clientX - startX : startX - clientX)) / scale, widthRange);
127
+ const move = (moveEvent) => setDragWidth(widthAt(moveEvent.clientX));
128
+ const end = (endEvent) => {
129
+ handle.removeEventListener("pointermove", move);
130
+ handle.removeEventListener("pointerup", end);
131
+ handle.removeEventListener("pointercancel", end);
132
+ setDragWidth(undefined);
133
+ if (endEvent.clientX !== startX)
134
+ onWidthChange(widthAt(endEvent.clientX));
135
+ };
136
+ handle.addEventListener("pointermove", move);
137
+ handle.addEventListener("pointerup", end);
138
+ handle.addEventListener("pointercancel", end);
139
+ };
140
+ const resizeWithKeys = (side, event) => {
141
+ if (onWidthChange === undefined)
142
+ return;
143
+ const step = event.shiftKey ? KEY_STEP.large : KEY_STEP.normal;
144
+ const outward = side === "end" ? "ArrowRight" : "ArrowLeft";
145
+ const inward = side === "end" ? "ArrowLeft" : "ArrowRight";
146
+ if (event.key === outward)
147
+ onWidthChange(clampedWidth(currentWidth() + step, widthRange));
148
+ else if (event.key === inward)
149
+ onWidthChange(clampedWidth(currentWidth() - step, widthRange));
150
+ else
151
+ return;
152
+ event.preventDefault();
153
+ };
154
+ const fixedHeight = dragHeight ?? chosenHeightOf(height);
155
+ const fixedWidth = dragWidth ?? (width === "fill" ? undefined : width);
156
+ // "fill" takes the canvas, less the two handles, in the story's own px
157
+ const handlesWidth = onWidthChange === undefined ? 0 : 2 * HANDLE_WIDTH;
158
+ const layoutWidth = fixedWidth ?? (canvasWidth === undefined ? undefined : Math.max(0, canvasWidth - handlesWidth) / scale);
159
+ const handle = (side) => onWidthChange === undefined ? null : (_jsx("div", { className: "forgebook-viewport__handle", "data-side": side, role: "separator", "aria-orientation": "vertical", "aria-label": STRINGS.widthHandle, "aria-valuemin": widthRange.min, "aria-valuemax": widthRange.max, "aria-valuenow": dragWidth ?? shownWidth, title: STRINGS.widthHandleHint, tabIndex: 0, onPointerDown: (event) => startDrag(side, event), onKeyDown: (event) => resizeWithKeys(side, event), onDoubleClick: () => onWidthChange("fill") }));
160
+ const currentHeight = () => roomRef.current?.offsetHeight ?? STAGE_HEIGHT_RANGE.min;
161
+ const isDragging = [dragWidth, dragHeight].some((dragged) => dragged !== undefined);
162
+ return (_jsx("div", { className: "forgebook-viewport", children: _jsxs("div", { ref: canvasRef, className: "forgebook-viewport__canvas", children: [handle("start"), _jsxs("div", { className: "forgebook-viewport__column", style: columnStyle(layoutWidth), children: [_jsx("div", { className: "forgebook-viewport__zoom", style: layoutWidth === undefined
163
+ ? undefined
164
+ : {
165
+ width: layoutWidth * scale,
166
+ height: roomHeight === undefined ? undefined : roomHeight * scale
167
+ }, children: _jsx("div", { ref: roomRef, className: "forgebook-viewport__room", "data-dragging": isDragging ? "" : undefined, style: {
168
+ width: layoutWidth,
169
+ transform: scale === 1 ? undefined : `scale(${scale})`,
170
+ backgroundColor: background
171
+ }, children: drawnFrame(children, fixedHeight) }) }), _jsx(FootHandle, { scale: scale, roomHeight: roomHeight, fixedHeight: fixedHeight, currentHeight: currentHeight, onDrag: setDragHeight, onHeightChange: onHeightChange })] }), handle("end")] }) }));
172
+ };
173
+ //# sourceMapping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AAW,EACxB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,cAAc,GAC9B,IACE,EACL,MAAM,CAAC,KAAK,CAAC,IACV,GACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * A story's code, as the panel's Code tab and the component page show it: its `render` as written, coloured by the
3
+ * plugin, or, for a story drawn from its args, the component in the framework's code with the values of the moment.
4
+ *
5
+ * @module
6
+ */
7
+ import type { StoryFileCode } from "@forgebook/story-format/source";
8
+ import type { ReactNode } from "react";
9
+ import type { StoryCodeWriter } from "../frame/renderer.ts";
10
+ import type { PanelArgs } from "../messages.ts";
11
+ /** Which story's code, and the values its JSX is drawn from when it has no `render`. */
12
+ export type StoryCodeSource = {
13
+ /** The story file's code. */
14
+ readonly code: StoryFileCode;
15
+ /** The story's export name. */
16
+ readonly exportName: string;
17
+ /** The component's name, for the code of a story drawn from its args. */
18
+ readonly componentName: string;
19
+ /** The values of the moment: the story's args, with the panel's over them on the story page. */
20
+ readonly args: PanelArgs;
21
+ };
22
+ /**
23
+ * The story's code as text, as copied.
24
+ *
25
+ * @param source - the file's code, the story, the component's name and the args.
26
+ * @param write - the framework's code writer, for a story drawn from its args.
27
+ */
28
+ export declare const storyCodeText: ({ code, exportName, componentName, args }: StoryCodeSource, write: StoryCodeWriter) => string;
29
+ /**
30
+ * The story's code, coloured.
31
+ *
32
+ * @param props - the file's code, the story, the component's name and the args.
33
+ */
34
+ export declare const StoryCodeBlock: (source: StoryCodeSource) => ReactNode;
35
+ //# sourceMappingURL=StoryCodeBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoryCodeBlock.d.ts","sourceRoot":"","sources":["../../../src/shell/StoryCodeBlock.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,wFAAwF;AACxF,MAAM,MAAM,eAAe,GAAG;IAC5B,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,+BAA+B;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,gGAAgG;IAChG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,2CAA2C,eAAe,EAC1D,OAAO,eAAe,KACrB,MAA8D,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,eAAe,KAAG,SAmBxD,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Code } from "./Code.js";
3
+ import { useCodeWriter } from "./codeWriter.js";
4
+ /**
5
+ * The story's code as text, as copied.
6
+ *
7
+ * @param source - the file's code, the story, the component's name and the args.
8
+ * @param write - the framework's code writer, for a story drawn from its args.
9
+ */
10
+ export const storyCodeText = ({ code, exportName, componentName, args }, write) => code[exportName]?.text ?? write(componentName, args);
11
+ /**
12
+ * The story's code, coloured.
13
+ *
14
+ * @param props - the file's code, the story, the component's name and the args.
15
+ */
16
+ export const StoryCodeBlock = (source) => {
17
+ const write = useCodeWriter();
18
+ const render = source.code[source.exportName];
19
+ if (render !== undefined) {
20
+ // biome-ignore lint/style/useNamingConvention: React's own name for markup set as HTML
21
+ const markup = { __html: render.html };
22
+ return (_jsx("pre", { className: "forgebook-code-block", children: _jsx("code", { className: "forgebook-code", dangerouslySetInnerHTML: markup }) }));
23
+ }
24
+ // the attributes' names are names, not types: only the component's name is coloured as one
25
+ return (_jsx("pre", { className: "forgebook-code-block", children: _jsx(Code, { text: storyCodeText(source, write), names: Object.keys(source.args) }) }));
26
+ };
27
+ //# sourceMappingURL=StoryCodeBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoryCodeBlock.js","sourceRoot":"","sources":["../../../src/shell/StoryCodeBlock.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAY,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAchD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAmB,EAC1D,KAAsB,EACd,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,IAAI,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAa,EAAE;IACnE,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,uFAAuF;QACvF,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QACvC,OAAO,CACL,cAAK,SAAS,EAAC,sBAAsB,YAEnC,eAAM,SAAS,EAAC,gBAAgB,EAAC,uBAAuB,EAAE,MAAM,GAAI,GAChE,CACP,CAAC;IACJ,CAAC;IACD,2FAA2F;IAC3F,OAAO,CACL,cAAK,SAAS,EAAC,sBAAsB,YACnC,KAAC,IAAI,IAAC,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAI,GACzE,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The picker of a component's stories in its pages' header: All (the component's page), then every story, under its
3
+ * group, in one select, so the header keeps one line however many stories the component has.
4
+ *
5
+ * @module
6
+ */
7
+ import { type ReactNode } from "react";
8
+ import { type TreeComponent, type TreeStory } from "../storyTree.ts";
9
+ /** The picker's props. */
10
+ export type StoryPickerProps = {
11
+ /** The component. */
12
+ readonly component: TreeComponent;
13
+ /** The shown story's id; none on the component's page. */
14
+ readonly currentStoryId: string | undefined;
15
+ /** Opens the component's page. */
16
+ readonly onOpenComponent: () => void;
17
+ /** Opens a story's page. */
18
+ readonly onOpenStory: (story: TreeStory) => void;
19
+ };
20
+ /**
21
+ * The picker of a component's stories.
22
+ *
23
+ * @param props - the component, the shown story and how to open a page.
24
+ */
25
+ export declare const StoryPicker: ({ component, currentStoryId, onOpenComponent, onOpenStory }: StoryPickerProps) => ReactNode;
26
+ //# sourceMappingURL=StoryPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoryPicker.d.ts","sourceRoot":"","sources":["../../../src/shell/StoryPicker.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAoB,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAkB,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIrF,0BAA0B;AAC1B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qBAAqB;IACrB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,kCAAkC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,IAAI,CAAC;IACrC,4BAA4B;IAC5B,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CAClD,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,6DAKzB,gBAAgB,KAAG,SA2CrB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The picker of a component's stories in its pages' header: All (the component's page), then every story, under its
4
+ * group, in one select, so the header keeps one line however many stories the component has.
5
+ *
6
+ * @module
7
+ */
8
+ import { useId } from "react";
9
+ import { groupLabel } from "../catalogue.js";
10
+ import { groupedStories } from "../storyTree.js";
11
+ import { useCatalogue } from "./catalogueContext.js";
12
+ import { STRINGS } from "./strings.js";
13
+ /** The value of the option that opens the component's page: no story id is empty. */
14
+ const ALL = "";
15
+ /**
16
+ * The picker of a component's stories.
17
+ *
18
+ * @param props - the component, the shown story and how to open a page.
19
+ */
20
+ export const StoryPicker = ({ component, currentStoryId, onOpenComponent, onOpenStory }) => {
21
+ const id = useId();
22
+ const { storyGroups } = useCatalogue();
23
+ const sections = groupedStories(component.stories, storyGroups.map((group) => group.id));
24
+ return (_jsxs("div", { className: "forgebook-picker", children: [_jsx("label", { className: "forgebook-popover__label", htmlFor: id, children: STRINGS.storiesNav }), _jsxs("select", { id: id, className: "forgebook-select forgebook-picker__select", value: currentStoryId ?? ALL, onChange: (event) => {
25
+ const chosen = component.stories.find((story) => story.id === event.currentTarget.value);
26
+ if (chosen === undefined)
27
+ onOpenComponent();
28
+ else
29
+ onOpenStory(chosen);
30
+ }, children: [_jsx("option", { value: ALL, children: STRINGS.allStories(component.stories.length) }), sections.map((section) => section.group === undefined ? (section.stories.map((story) => (_jsx("option", { value: story.id, children: story.name }, story.id)))) : (_jsx("optgroup", { label: groupLabel(storyGroups, section.group), children: section.stories.map((story) => (_jsx("option", { value: story.id, children: story.name }, story.id))) }, section.group)))] })] }));
31
+ };
32
+ //# sourceMappingURL=StoryPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoryPicker.js","sourceRoot":"","sources":["../../../src/shell/StoryPicker.tsx"],"names":[],"mappings":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AQ,KAAK,EAAE,GAAG,YAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAU,EAC1E,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACxB,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAC5B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC7B,iBAAuB,KAAK,EAAE,KAAK,CAAC,EAAE,YACnC,KAAK,CAAC,IAAI,IADA,KAAK,CAAC,EAAE,CAEZ,CACV,CAAC,CACH,CAAC,CAAC,CAAC,CACF,mBAA8B,KAAK,EAAE,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,YACxE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC9B,iBAAuB,KAAK,EAAE,KAAK,CAAC,EAAE,YACnC,KAAK,CAAC,IAAI,IADA,KAAK,CAAC,EAAE,CAEZ,CACV,CAAC,IALW,OAAO,CAAC,KAAK,CAMjB,CACZ,CACF,IACM,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The catalogue's toolbar: the colour scheme and the contrast switches, the View menu (every other declared switch,
3
+ * the background, the style sheets, the text size), the stage's width, the panel, and Compare; every value kept in the
4
+ * address.
5
+ *
6
+ * @module
7
+ */
8
+ import { type ReactNode } from "react";
9
+ import { type FixedView } from "../storyGlobals.ts";
10
+ import { type ViewState } from "../viewState.ts";
11
+ /** The toolbar's props. */
12
+ export type ToolbarProps = {
13
+ /** The view. */
14
+ readonly view: ViewState;
15
+ /** Called with the changed view. */
16
+ readonly onViewChange: (view: ViewState) => void;
17
+ /** Whether a story's page is shown: the props panel and Compare belong to it, not to a component's page. */
18
+ readonly isStoryPage?: boolean;
19
+ /** Shows the hidden sidebar; none while it is shown. */
20
+ readonly onShowSidebar?: (() => void) | undefined;
21
+ /** The width the shown story really has, in CSS px, for the width field; none on a component's page. */
22
+ readonly shownWidth?: number | undefined;
23
+ /** What the shown story fixes of the view: shown, and not changeable here; nothing by default. */
24
+ readonly fixed?: FixedView;
25
+ };
26
+ /**
27
+ * The button that shows the hidden sidebar, at the toolbar's start; the home's bar holds only it.
28
+ *
29
+ * @param props - what showing the sidebar does.
30
+ */
31
+ export declare const ShowSidebarButton: ({ onShowSidebar }: {
32
+ readonly onShowSidebar: () => void;
33
+ }) => ReactNode;
34
+ /**
35
+ * The toolbar.
36
+ *
37
+ * @param props - the view, its setter, the page shown and the story's width.
38
+ */
39
+ export declare const Toolbar: ({ view: ownView, onViewChange: onOwnViewChange, isStoryPage, onShowSidebar, shownWidth, fixed }: ToolbarProps) => ReactNode;
40
+ //# sourceMappingURL=Toolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../src/shell/Toolbar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAoB,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,KAAK,SAAS,EAAsC,MAAM,oBAAoB,CAAC;AAExF,OAAO,EASL,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AAUzB,2BAA2B;AAC3B,MAAM,MAAM,YAAY,GAAG;IACzB,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,oCAAoC;IACpC,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACjD,4GAA4G;IAC5G,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,wDAAwD;IACxD,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,wGAAwG;IACxG,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,kGAAkG;IAClG,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC5B,CAAC;AA+RF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,mBAAmB;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAA;CAAE,KAAG,SAU7F,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,iGAOrB,YAAY,KAAG,SA0DjB,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The catalogue's toolbar: the colour scheme and the contrast switches, the View menu (every other declared switch,
4
+ * the background, the style sheets, the text size), the stage's width, the panel, and Compare; every value kept in the
5
+ * address.
6
+ *
7
+ * @module
8
+ */
9
+ import { useId } from "react";
10
+ import { NOT_FIXED, withFixed, withOwnFixed } from "../storyGlobals.js";
11
+ import { switchControl, switchWithRole } from "../switches.js";
12
+ import { DEFAULT_VIEW, hasViewChanges, isComparing, isMenuSwitch, PLAIN_BACKDROP, SHEETS_CHOICES } from "../viewState.js";
13
+ import { useCatalogue } from "./catalogueContext.js";
14
+ import { Icon } from "./icons.js";
15
+ import { SchemeSwitches } from "./SchemeSwitches.js";
16
+ import { Segmented } from "./Segmented.js";
17
+ import { STRINGS } from "./strings.js";
18
+ import { switchValueIn, withSwitch } from "./switchView.js";
19
+ import { usePopover } from "./usePopover.js";
20
+ import { WidthField } from "./WidthField.js";
21
+ /**
22
+ * One switch's row in the View menu: segments, or a list for many values.
23
+ *
24
+ * @param props - the switch, the view and its setter.
25
+ */
26
+ const SwitchRow = ({ each, view, onViewChange, isFixed }) => {
27
+ const listId = useId();
28
+ const isCompared = view.compare.includes(each.id) || isFixed;
29
+ if (switchControl(each) === "list") {
30
+ return (_jsxs("div", { className: "forgebook-popover__row", children: [_jsx("label", { className: "forgebook-popover__label", htmlFor: listId, children: each.label }), _jsx("select", { id: listId, className: "forgebook-select", value: switchValueIn(view, each), disabled: isCompared, title: isFixed ? STRINGS.setByStory : undefined, onChange: (event) => onViewChange(withSwitch(view, each, event.currentTarget.value)), children: each.values.map((value) => (_jsx("option", { value: value.value, children: value.label }, value.value))) })] }));
31
+ }
32
+ return (_jsxs("div", { className: "forgebook-popover__row", children: [_jsx("span", { className: "forgebook-popover__label", children: each.label }), _jsx(Segmented, { label: each.label, options: each.values.map((value) => ({ value: value.value, label: value.label })), value: switchValueIn(view, each), isDisabled: isCompared, disabledNote: isFixed ? STRINGS.setByStory : undefined, onValueChange: (value) => onViewChange(withSwitch(view, each, value)) })] }));
33
+ };
34
+ /**
35
+ * The View menu: every declared switch the toolbar does not show itself, the background, the style sheets and the
36
+ * text size, with a dot on its button when one is changed. The background is a list: its six names are too long for
37
+ * a row of segments.
38
+ *
39
+ * @param props - the view and its setter.
40
+ */
41
+ const ViewMenu = ({ view, onViewChange, fixed = NOT_FIXED, hasOwnChanges }) => {
42
+ const { isOpen, setIsOpen, buttonRef, panelRef, panelId } = usePopover();
43
+ const catalogue = useCatalogue();
44
+ const { switches } = catalogue;
45
+ const backdropId = useId();
46
+ const menuSwitches = switches.filter(isMenuSwitch);
47
+ return (_jsxs("div", { className: "forgebook-view-menu", children: [_jsxs("button", { ref: buttonRef, type: "button", className: "forgebook-button", "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => setIsOpen(!isOpen), children: [_jsx(Icon, { name: "sliders", size: 14 }), STRINGS.view, hasOwnChanges ? (_jsx("span", { className: "forgebook-dot", role: "img", "aria-label": STRINGS.viewChanged })) : null, _jsx(Icon, { name: "chevronDown", size: 12 })] }), isOpen ? (_jsxs("div", { ref: panelRef, id: panelId, className: "forgebook-popover", role: "dialog", "aria-label": STRINGS.view, children: [menuSwitches.map((each) => (_jsx(SwitchRow, { each: each, view: view, onViewChange: onViewChange, isFixed: fixed.switches[each.id] !== undefined }, each.id))), _jsxs("div", { className: "forgebook-popover__row", children: [_jsx("label", { className: "forgebook-popover__label", htmlFor: backdropId, children: STRINGS.backdrop }), _jsxs("select", { id: backdropId, className: "forgebook-select", value: view.backdrop, disabled: fixed.backdrop !== undefined, title: fixed.backdrop === undefined ? undefined : STRINGS.setByStory, onChange: (event) => onViewChange({ ...view, backdrop: event.currentTarget.value }), children: [_jsx("option", { value: PLAIN_BACKDROP, children: STRINGS.backdropPlain }), catalogue.backdrops.map((backdrop) => (_jsx("option", { value: backdrop.id, children: backdrop.label }, backdrop.id)))] })] }), _jsxs("div", { className: "forgebook-popover__row", children: [_jsx("span", { className: "forgebook-popover__label", children: STRINGS.sheets }), _jsx(Segmented, { label: STRINGS.sheets, options: SHEETS_CHOICES.map((sheets) => ({
48
+ value: sheets,
49
+ label: STRINGS.sheetChoices[sheets]
50
+ })), value: view.sheets, isDisabled: view.compare.includes("sheets"), onValueChange: (sheets) => onViewChange({ ...view, sheets }) })] }), _jsxs("div", { className: "forgebook-popover__row", children: [_jsx("span", { className: "forgebook-popover__label", children: STRINGS.text }), _jsx(Segmented, { label: STRINGS.text, options: catalogue.textSizes.map((text) => ({ value: text, label: STRINGS.textScale(text) })), value: view.text, isDisabled: view.compare.includes("text"), onValueChange: (text) => onViewChange({ ...view, text }) })] }), _jsxs("div", { className: "forgebook-popover__foot", children: [_jsx("button", { type: "button", className: "forgebook-text-button", onClick: () => onViewChange({
51
+ ...view,
52
+ switches: {
53
+ ...view.switches,
54
+ ...Object.fromEntries(menuSwitches.map((each) => [each.id, each.default]))
55
+ },
56
+ backdrop: DEFAULT_VIEW.backdrop,
57
+ sheets: DEFAULT_VIEW.sheets,
58
+ text: DEFAULT_VIEW.text
59
+ }), children: STRINGS.resetView }), _jsx("span", { className: "forgebook-popover__note", children: STRINGS.viewInAddress })] })] })) : null] }));
60
+ };
61
+ /**
62
+ * The Compare menu's choices: Off, the colour scheme at both contrasts when the catalogue has both, each switch of
63
+ * the View menu, the text sizes and the style sheets.
64
+ *
65
+ * @param switches - the catalogue's switches.
66
+ */
67
+ const compareChoices = (switches) => {
68
+ const scheme = switchWithRole(switches, "colorScheme");
69
+ const contrast = switchWithRole(switches, "contrast");
70
+ const schemes = scheme === undefined
71
+ ? []
72
+ : [
73
+ contrast === undefined
74
+ ? { axes: [scheme.id], label: scheme.label }
75
+ : { axes: [scheme.id, contrast.id], label: STRINGS.compareOf([scheme.label, contrast.label]) }
76
+ ];
77
+ return [
78
+ { axes: [], label: STRINGS.compareOff },
79
+ ...schemes,
80
+ ...switches.filter(isMenuSwitch).map((each) => ({ axes: [each.id], label: each.label })),
81
+ { axes: ["text"], label: STRINGS.compareText },
82
+ { axes: ["sheets"], label: STRINGS.compareSheets }
83
+ ];
84
+ };
85
+ /**
86
+ * The Compare menu: what the stage sets side by side, or nothing; its button is pressed while the stage compares.
87
+ *
88
+ * @param props - the view, its setter, and whether the page compares at all.
89
+ */
90
+ const CompareMenu = ({ view, onViewChange, isDisabled, fixed = NOT_FIXED }) => {
91
+ const { isOpen, setIsOpen, buttonRef, panelRef, panelId } = usePopover();
92
+ const switches = useCatalogue().switches;
93
+ const name = useId();
94
+ return (_jsxs("div", { className: "forgebook-view-menu", children: [_jsxs("button", { ref: buttonRef, type: "button", className: "forgebook-button", title: STRINGS.compare, "aria-pressed": isComparing(view), "aria-expanded": isOpen, "aria-controls": panelId, disabled: isDisabled, onClick: () => setIsOpen(!isOpen), children: [_jsx(Icon, { name: "compare", size: 14 }), _jsx("span", { className: "forgebook-button__label", children: STRINGS.compare }), _jsx(Icon, { name: "chevronDown", size: 12 })] }), isOpen ? (_jsx("div", { ref: panelRef, id: panelId, className: "forgebook-popover forgebook-popover--end", role: "dialog", "aria-label": STRINGS.compare, children: _jsxs("fieldset", { className: "forgebook-choices", children: [_jsx("legend", { className: "forgebook-visually-hidden", children: STRINGS.compare }), compareChoices(switches).map((choice) => (_jsxs("label", { className: "forgebook-choice", children: [_jsx("input", { type: "radio", name: name,
95
+ // a switch the story fixes would draw the same story in every cell
96
+ disabled: choice.axes.some((axis) => fixed.switches[axis] !== undefined), checked: view.compare.join(",") === choice.axes.join(","), onChange: () => {
97
+ onViewChange({ ...view, compare: choice.axes });
98
+ setIsOpen(false);
99
+ } }), choice.label] }, choice.axes.join(","))))] }) })) : null] }));
100
+ };
101
+ /**
102
+ * The button that shows the hidden sidebar, at the toolbar's start; the home's bar holds only it.
103
+ *
104
+ * @param props - what showing the sidebar does.
105
+ */
106
+ export const ShowSidebarButton = ({ onShowSidebar }) => (_jsx("button", { type: "button", className: "forgebook-icon-button", title: STRINGS.showSidebar, "aria-label": STRINGS.showSidebar, onClick: onShowSidebar, children: _jsx(Icon, { name: "sidebar", size: 14 }) }));
107
+ /**
108
+ * The toolbar.
109
+ *
110
+ * @param props - the view, its setter, the page shown and the story's width.
111
+ */
112
+ export const Toolbar = ({ view: ownView, onViewChange: onOwnViewChange, isStoryPage = true, onShowSidebar, shownWidth, fixed = NOT_FIXED }) => {
113
+ const { widths, switches } = useCatalogue();
114
+ // the story's fixed values are shown, and a change of anything else keeps the user's own in the address
115
+ const view = withFixed(ownView, fixed);
116
+ const onViewChange = (changed) => onOwnViewChange(withOwnFixed(changed, ownView, fixed));
117
+ return (_jsxs("div", { className: "forgebook-toolbar", children: [onShowSidebar === undefined ? null : _jsx(ShowSidebarButton, { onShowSidebar: onShowSidebar }), _jsx(SchemeSwitches, { view: view, onViewChange: onViewChange, isStoryPage: isStoryPage, fixed: fixed }), _jsx("span", { className: "forgebook-toolbar__divider" }), _jsx(ViewMenu, { view: view, onViewChange: onViewChange, fixed: fixed, hasOwnChanges: hasViewChanges(ownView, switches) }), _jsx("span", { className: "forgebook-toolbar__divider" }), _jsxs("div", { className: "forgebook-toolbar__width", children: [_jsx("span", { className: "forgebook-toolbar__icon", title: STRINGS.width, children: _jsx(Icon, { name: "width", size: 14 }) }), _jsx(Segmented, { label: STRINGS.width, isDisabled: (isStoryPage && isComparing(view)) || fixed.width !== undefined, disabledNote: fixed.width === undefined ? undefined : STRINGS.setByStory, options: [
118
+ { value: "fill", label: STRINGS.widthFill },
119
+ ...widths.map((preset) => ({
120
+ value: preset.width,
121
+ label: preset.label ?? STRINGS.widthPx(preset.width)
122
+ }))
123
+ ], value: view.width, onValueChange: (width) => onViewChange({ ...view, width }), after: _jsx(WidthField, { width: view.width, shownWidth: shownWidth, onWidthChange: (width) => onViewChange({ ...view, width }) }) })] }), _jsx("span", { className: "forgebook-toolbar__spacer" }), _jsxs("button", { type: "button", className: "forgebook-button", title: STRINGS.panel, "aria-pressed": view.isPanelOpen, disabled: !isStoryPage, onClick: () => onViewChange({ ...view, isPanelOpen: !view.isPanelOpen }), children: [_jsx(Icon, { name: "panel", size: 14 }), _jsx("span", { className: "forgebook-button__label", children: STRINGS.panel })] }), _jsx(CompareMenu, { view: view, onViewChange: onViewChange, isDisabled: !isStoryPage, fixed: fixed })] }));
124
+ };
125
+ //# sourceMappingURL=Toolbar.js.map