react-cosmos-ui 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/BaseSvg.d.ts +9 -0
  3. package/dist/components/BaseSvg.js +8 -0
  4. package/dist/components/Icon.d.ts +7 -0
  5. package/dist/components/Icon.js +5 -0
  6. package/dist/components/Illustration.d.ts +8 -0
  7. package/dist/components/Illustration.js +5 -0
  8. package/dist/components/KeyBox.d.ts +9 -0
  9. package/dist/components/KeyBox.js +28 -0
  10. package/dist/components/SidePanel.d.ts +10 -0
  11. package/dist/components/SidePanel.js +52 -0
  12. package/dist/components/Space.d.ts +7 -0
  13. package/dist/components/Space.js +8 -0
  14. package/dist/components/TreeView.d.ts +19 -0
  15. package/dist/components/TreeView.js +26 -0
  16. package/dist/components/ValueInputTree/ExpandCollapseValues.d.ts +9 -0
  17. package/dist/components/ValueInputTree/ExpandCollapseValues.js +11 -0
  18. package/dist/components/ValueInputTree/ValueInput/BooleanValueInput.d.ts +8 -0
  19. package/dist/components/ValueInputTree/ValueInput/BooleanValueInput.js +32 -0
  20. package/dist/components/ValueInputTree/ValueInput/NullValueInput.d.ts +5 -0
  21. package/dist/components/ValueInputTree/ValueInput/NullValueInput.js +9 -0
  22. package/dist/components/ValueInputTree/ValueInput/NumberValueInput.d.ts +8 -0
  23. package/dist/components/ValueInputTree/ValueInput/NumberValueInput.js +14 -0
  24. package/dist/components/ValueInputTree/ValueInput/StringValueInput.d.ts +8 -0
  25. package/dist/components/ValueInputTree/ValueInput/StringValueInput.js +18 -0
  26. package/dist/components/ValueInputTree/ValueInput/UndefinedValueInput.d.ts +5 -0
  27. package/dist/components/ValueInputTree/ValueInput/UndefinedValueInput.js +9 -0
  28. package/dist/components/ValueInputTree/ValueInput/UnserializableValueInput.d.ts +6 -0
  29. package/dist/components/ValueInputTree/ValueInput/UnserializableValueInput.js +11 -0
  30. package/dist/components/ValueInputTree/ValueInput/ValueInput.d.ts +11 -0
  31. package/dist/components/ValueInputTree/ValueInput/ValueInput.js +30 -0
  32. package/dist/components/ValueInputTree/ValueInput/shared.d.ts +6 -0
  33. package/dist/components/ValueInputTree/ValueInput/shared.js +41 -0
  34. package/dist/components/ValueInputTree/ValueInputDir.d.ts +9 -0
  35. package/dist/components/ValueInputTree/ValueInputDir.js +68 -0
  36. package/dist/components/ValueInputTree/ValueInputTree.d.ts +12 -0
  37. package/dist/components/ValueInputTree/ValueInputTree.js +32 -0
  38. package/dist/components/ValueInputTree/index.d.ts +4 -0
  39. package/dist/components/ValueInputTree/index.js +4 -0
  40. package/dist/components/ValueInputTree/shared.d.ts +16 -0
  41. package/dist/components/ValueInputTree/shared.js +15 -0
  42. package/dist/components/ValueInputTree/valueGroups.d.ts +8 -0
  43. package/dist/components/ValueInputTree/valueGroups.js +10 -0
  44. package/dist/components/ValueInputTree/valueTree.d.ts +3 -0
  45. package/dist/components/ValueInputTree/valueTree.js +20 -0
  46. package/dist/components/ValueInputTree/valueTreeExpansion.d.ts +7 -0
  47. package/dist/components/ValueInputTree/valueTreeExpansion.js +16 -0
  48. package/dist/components/buttons/Button32.d.ts +11 -0
  49. package/dist/components/buttons/Button32.js +8 -0
  50. package/dist/components/buttons/Button8.d.ts +11 -0
  51. package/dist/components/buttons/Button8.js +8 -0
  52. package/dist/components/buttons/IconButton32.d.ts +10 -0
  53. package/dist/components/buttons/IconButton32.js +7 -0
  54. package/dist/components/buttons/IconButton8.d.ts +10 -0
  55. package/dist/components/buttons/IconButton8.js +7 -0
  56. package/dist/components/buttons/index.d.ts +4 -0
  57. package/dist/components/buttons/index.js +4 -0
  58. package/dist/components/buttons/shared.d.ts +15 -0
  59. package/dist/components/buttons/shared.js +52 -0
  60. package/dist/components/icons/index.d.ts +33 -0
  61. package/dist/components/icons/index.js +107 -0
  62. package/dist/components/illustrations/ArtificialIntelligence.d.ts +3 -0
  63. package/dist/components/illustrations/ArtificialIntelligence.js +123 -0
  64. package/dist/components/illustrations/Astronaut.d.ts +3 -0
  65. package/dist/components/illustrations/Astronaut.js +72 -0
  66. package/dist/components/illustrations/BlankCanvas.d.ts +3 -0
  67. package/dist/components/illustrations/BlankCanvas.js +75 -0
  68. package/dist/components/inputs/NumberInput.d.ts +15 -0
  69. package/dist/components/inputs/NumberInput.js +79 -0
  70. package/dist/components/inputs/Select.d.ts +16 -0
  71. package/dist/components/inputs/Select.js +69 -0
  72. package/dist/components/inputs/shared.d.ts +14 -0
  73. package/dist/components/inputs/shared.js +43 -0
  74. package/dist/cosmos.decorator.d.ts +5 -0
  75. package/dist/cosmos.decorator.js +6 -0
  76. package/dist/cosmos.loadPlugins.d.ts +1 -0
  77. package/dist/cosmos.loadPlugins.js +17 -0
  78. package/dist/hooks/useDrag.d.ts +14 -0
  79. package/dist/hooks/useDrag.js +58 -0
  80. package/dist/hooks/useFocus.d.ts +5 -0
  81. package/dist/hooks/useFocus.js +7 -0
  82. package/dist/index.d.ts +36 -0
  83. package/dist/index.js +36 -0
  84. package/dist/playground.bundle.js +1358 -0
  85. package/dist/playground.bundle.js.LICENSE.txt +64 -0
  86. package/dist/playground.bundle.js.map +1 -0
  87. package/dist/playground.d.ts +11 -0
  88. package/dist/playground.js +36 -0
  89. package/dist/playgroundConfig.d.ts +10 -0
  90. package/dist/playgroundConfig.js +1 -0
  91. package/dist/plugins/BuildNotifications/index.d.ts +2 -0
  92. package/dist/plugins/BuildNotifications/index.js +35 -0
  93. package/dist/plugins/BuildNotifications/spec.d.ts +3 -0
  94. package/dist/plugins/BuildNotifications/spec.js +1 -0
  95. package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.d.ts +10 -0
  96. package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.js +36 -0
  97. package/dist/plugins/ClassStatePanel/ClassStatePanel/index.d.ts +11 -0
  98. package/dist/plugins/ClassStatePanel/ClassStatePanel/index.js +13 -0
  99. package/dist/plugins/ClassStatePanel/ClassStatePanel/shared.d.ts +2 -0
  100. package/dist/plugins/ClassStatePanel/ClassStatePanel/shared.js +16 -0
  101. package/dist/plugins/ClassStatePanel/index.d.ts +2 -0
  102. package/dist/plugins/ClassStatePanel/index.js +30 -0
  103. package/dist/plugins/ClassStatePanel/shared.d.ts +1 -0
  104. package/dist/plugins/ClassStatePanel/shared.js +1 -0
  105. package/dist/plugins/ClassStatePanel/spec.d.ts +3 -0
  106. package/dist/plugins/ClassStatePanel/spec.js +1 -0
  107. package/dist/plugins/ContentOverlay/ContentOverlay.d.ts +13 -0
  108. package/dist/plugins/ContentOverlay/ContentOverlay.js +34 -0
  109. package/dist/plugins/ContentOverlay/KeyShortcut.d.ts +6 -0
  110. package/dist/plugins/ContentOverlay/KeyShortcut.js +30 -0
  111. package/dist/plugins/ContentOverlay/NoFixtureSelected.d.ts +5 -0
  112. package/dist/plugins/ContentOverlay/NoFixtureSelected.js +34 -0
  113. package/dist/plugins/ContentOverlay/RendererNotResponding.d.ts +1 -0
  114. package/dist/plugins/ContentOverlay/RendererNotResponding.js +109 -0
  115. package/dist/plugins/ContentOverlay/WelcomeCosmos.d.ts +5 -0
  116. package/dist/plugins/ContentOverlay/WelcomeCosmos.js +158 -0
  117. package/dist/plugins/ContentOverlay/cosmos.decorator.d.ts +5 -0
  118. package/dist/plugins/ContentOverlay/cosmos.decorator.js +13 -0
  119. package/dist/plugins/ContentOverlay/index.d.ts +2 -0
  120. package/dist/plugins/ContentOverlay/index.js +19 -0
  121. package/dist/plugins/ContentOverlay/shared.d.ts +9 -0
  122. package/dist/plugins/ContentOverlay/shared.js +75 -0
  123. package/dist/plugins/ContentOverlay/spec.d.ts +3 -0
  124. package/dist/plugins/ContentOverlay/spec.js +1 -0
  125. package/dist/plugins/ContentOverlay/welcomeDismiss.d.ts +7 -0
  126. package/dist/plugins/ContentOverlay/welcomeDismiss.js +17 -0
  127. package/dist/plugins/ControlPanel/ControlPanel.d.ts +8 -0
  128. package/dist/plugins/ControlPanel/ControlPanel.js +37 -0
  129. package/dist/plugins/ControlPanel/index.d.ts +2 -0
  130. package/dist/plugins/ControlPanel/index.js +17 -0
  131. package/dist/plugins/ControlPanel/spec.d.ts +6 -0
  132. package/dist/plugins/ControlPanel/spec.js +1 -0
  133. package/dist/plugins/ControlSelect/SelectValueInput.d.ts +8 -0
  134. package/dist/plugins/ControlSelect/SelectValueInput.js +15 -0
  135. package/dist/plugins/ControlSelect/index.d.ts +2 -0
  136. package/dist/plugins/ControlSelect/index.js +22 -0
  137. package/dist/plugins/ControlSelect/spec.d.ts +3 -0
  138. package/dist/plugins/ControlSelect/spec.js +1 -0
  139. package/dist/plugins/Core/index.d.ts +2 -0
  140. package/dist/plugins/Core/index.js +68 -0
  141. package/dist/plugins/Core/spec.d.ts +25 -0
  142. package/dist/plugins/Core/spec.js +1 -0
  143. package/dist/plugins/FixtureBookmark/BookmarkFixtureButton.d.ts +6 -0
  144. package/dist/plugins/FixtureBookmark/BookmarkFixtureButton.js +6 -0
  145. package/dist/plugins/FixtureBookmark/FixtureBookmarks.d.ts +10 -0
  146. package/dist/plugins/FixtureBookmark/FixtureBookmarks.js +123 -0
  147. package/dist/plugins/FixtureBookmark/index.d.ts +2 -0
  148. package/dist/plugins/FixtureBookmark/index.js +46 -0
  149. package/dist/plugins/FixtureBookmark/spec.d.ts +3 -0
  150. package/dist/plugins/FixtureBookmark/spec.js +1 -0
  151. package/dist/plugins/FixtureSearch/FixtureSearchHeader.d.ts +7 -0
  152. package/dist/plugins/FixtureSearch/FixtureSearchHeader.js +66 -0
  153. package/dist/plugins/FixtureSearch/FixtureSearchOverlay.d.ts +13 -0
  154. package/dist/plugins/FixtureSearch/FixtureSearchOverlay.js +312 -0
  155. package/dist/plugins/FixtureSearch/FixtureSearchResult.d.ts +9 -0
  156. package/dist/plugins/FixtureSearch/FixtureSearchResult.js +48 -0
  157. package/dist/plugins/FixtureSearch/FixtureSearchShortcuts.d.ts +1 -0
  158. package/dist/plugins/FixtureSearch/FixtureSearchShortcuts.js +60 -0
  159. package/dist/plugins/FixtureSearch/index.d.ts +2 -0
  160. package/dist/plugins/FixtureSearch/index.js +72 -0
  161. package/dist/plugins/FixtureSearch/spec.d.ts +7 -0
  162. package/dist/plugins/FixtureSearch/spec.js +1 -0
  163. package/dist/plugins/FixtureTree/BlankState.d.ts +8 -0
  164. package/dist/plugins/FixtureTree/BlankState.js +75 -0
  165. package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.d.ts +12 -0
  166. package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.js +16 -0
  167. package/dist/plugins/FixtureTree/FixtureTree/FixtureDir.d.ts +9 -0
  168. package/dist/plugins/FixtureTree/FixtureTree/FixtureDir.js +46 -0
  169. package/dist/plugins/FixtureTree/FixtureTree/FixtureLink.d.ts +9 -0
  170. package/dist/plugins/FixtureTree/FixtureTree/FixtureLink.js +34 -0
  171. package/dist/plugins/FixtureTree/FixtureTree/FixtureTree.d.ts +13 -0
  172. package/dist/plugins/FixtureTree/FixtureTree/FixtureTree.js +37 -0
  173. package/dist/plugins/FixtureTree/FixtureTree/FixtureTreeItem.d.ts +6 -0
  174. package/dist/plugins/FixtureTree/FixtureTree/FixtureTreeItem.js +24 -0
  175. package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.d.ts +13 -0
  176. package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.js +46 -0
  177. package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureChildButton.d.ts +12 -0
  178. package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureChildButton.js +26 -0
  179. package/dist/plugins/FixtureTree/FixtureTreeContainer.d.ts +14 -0
  180. package/dist/plugins/FixtureTree/FixtureTreeContainer.js +28 -0
  181. package/dist/plugins/FixtureTree/FixtureTreeHeader.d.ts +11 -0
  182. package/dist/plugins/FixtureTree/FixtureTreeHeader.js +33 -0
  183. package/dist/plugins/FixtureTree/index.d.ts +2 -0
  184. package/dist/plugins/FixtureTree/index.js +25 -0
  185. package/dist/plugins/FixtureTree/revealFixture.d.ts +3 -0
  186. package/dist/plugins/FixtureTree/revealFixture.js +48 -0
  187. package/dist/plugins/FixtureTree/shared.d.ts +7 -0
  188. package/dist/plugins/FixtureTree/shared.js +8 -0
  189. package/dist/plugins/FixtureTree/spec.d.ts +7 -0
  190. package/dist/plugins/FixtureTree/spec.js +1 -0
  191. package/dist/plugins/FixtureTree/useScrollToSelected.d.ts +6 -0
  192. package/dist/plugins/FixtureTree/useScrollToSelected.js +18 -0
  193. package/dist/plugins/FullScreenButton/FullScreenButton.d.ts +5 -0
  194. package/dist/plugins/FullScreenButton/FullScreenButton.js +6 -0
  195. package/dist/plugins/FullScreenButton/index.d.ts +2 -0
  196. package/dist/plugins/FullScreenButton/index.js +25 -0
  197. package/dist/plugins/FullScreenButton/spec.d.ts +3 -0
  198. package/dist/plugins/FullScreenButton/spec.js +1 -0
  199. package/dist/plugins/MessageHandler/index.d.ts +2 -0
  200. package/dist/plugins/MessageHandler/index.js +12 -0
  201. package/dist/plugins/MessageHandler/shared.d.ts +3 -0
  202. package/dist/plugins/MessageHandler/shared.js +1 -0
  203. package/dist/plugins/MessageHandler/socket.d.ts +4 -0
  204. package/dist/plugins/MessageHandler/socket.js +45 -0
  205. package/dist/plugins/MessageHandler/spec.d.ts +11 -0
  206. package/dist/plugins/MessageHandler/spec.js +1 -0
  207. package/dist/plugins/Notifications/Notifications.d.ts +6 -0
  208. package/dist/plugins/Notifications/Notifications.js +75 -0
  209. package/dist/plugins/Notifications/index.d.ts +2 -0
  210. package/dist/plugins/Notifications/index.js +36 -0
  211. package/dist/plugins/Notifications/pushNotification.d.ts +6 -0
  212. package/dist/plugins/Notifications/pushNotification.js +40 -0
  213. package/dist/plugins/Notifications/shared.d.ts +3 -0
  214. package/dist/plugins/Notifications/shared.js +1 -0
  215. package/dist/plugins/Notifications/spec.d.ts +22 -0
  216. package/dist/plugins/Notifications/spec.js +1 -0
  217. package/dist/plugins/PluginList/PluginList.d.ts +10 -0
  218. package/dist/plugins/PluginList/PluginList.js +38 -0
  219. package/dist/plugins/PluginList/index.d.ts +2 -0
  220. package/dist/plugins/PluginList/index.js +12 -0
  221. package/dist/plugins/PluginList/spec.d.ts +3 -0
  222. package/dist/plugins/PluginList/spec.js +1 -0
  223. package/dist/plugins/PropsPanel/BlankState.d.ts +3 -0
  224. package/dist/plugins/PropsPanel/BlankState.js +47 -0
  225. package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.d.ts +10 -0
  226. package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.js +40 -0
  227. package/dist/plugins/PropsPanel/PropsPanel/index.d.ts +11 -0
  228. package/dist/plugins/PropsPanel/PropsPanel/index.js +13 -0
  229. package/dist/plugins/PropsPanel/PropsPanel/shared.d.ts +2 -0
  230. package/dist/plugins/PropsPanel/PropsPanel/shared.js +16 -0
  231. package/dist/plugins/PropsPanel/index.d.ts +2 -0
  232. package/dist/plugins/PropsPanel/index.js +55 -0
  233. package/dist/plugins/PropsPanel/shared.d.ts +1 -0
  234. package/dist/plugins/PropsPanel/shared.js +1 -0
  235. package/dist/plugins/PropsPanel/spec.d.ts +3 -0
  236. package/dist/plugins/PropsPanel/spec.js +1 -0
  237. package/dist/plugins/RemoteRenderer/RemoteButton/copyToClipboard.d.ts +1 -0
  238. package/dist/plugins/RemoteRenderer/RemoteButton/copyToClipboard.js +24 -0
  239. package/dist/plugins/RemoteRenderer/RemoteButton/index.d.ts +8 -0
  240. package/dist/plugins/RemoteRenderer/RemoteButton/index.js +37 -0
  241. package/dist/plugins/RemoteRenderer/index.d.ts +2 -0
  242. package/dist/plugins/RemoteRenderer/index.js +36 -0
  243. package/dist/plugins/RemoteRenderer/shared.d.ts +3 -0
  244. package/dist/plugins/RemoteRenderer/shared.js +1 -0
  245. package/dist/plugins/RemoteRenderer/spec.d.ts +3 -0
  246. package/dist/plugins/RemoteRenderer/spec.js +1 -0
  247. package/dist/plugins/RendererCore/index.d.ts +2 -0
  248. package/dist/plugins/RendererCore/index.js +47 -0
  249. package/dist/plugins/RendererCore/isValidFixtureSelected.d.ts +2 -0
  250. package/dist/plugins/RendererCore/isValidFixtureSelected.js +16 -0
  251. package/dist/plugins/RendererCore/onRouterFixtureChange.d.ts +3 -0
  252. package/dist/plugins/RendererCore/onRouterFixtureChange.js +18 -0
  253. package/dist/plugins/RendererCore/receiveResponse/fixtureListUpdate.d.ts +3 -0
  254. package/dist/plugins/RendererCore/receiveResponse/fixtureListUpdate.js +11 -0
  255. package/dist/plugins/RendererCore/receiveResponse/fixtureStateChange.d.ts +3 -0
  256. package/dist/plugins/RendererCore/receiveResponse/fixtureStateChange.js +30 -0
  257. package/dist/plugins/RendererCore/receiveResponse/index.d.ts +3 -0
  258. package/dist/plugins/RendererCore/receiveResponse/index.js +20 -0
  259. package/dist/plugins/RendererCore/receiveResponse/playgroundCommand.d.ts +3 -0
  260. package/dist/plugins/RendererCore/receiveResponse/playgroundCommand.js +5 -0
  261. package/dist/plugins/RendererCore/receiveResponse/rendererReady.d.ts +3 -0
  262. package/dist/plugins/RendererCore/receiveResponse/rendererReady.js +49 -0
  263. package/dist/plugins/RendererCore/setFixtureState.d.ts +3 -0
  264. package/dist/plugins/RendererCore/setFixtureState.js +22 -0
  265. package/dist/plugins/RendererCore/shared/index.d.ts +4 -0
  266. package/dist/plugins/RendererCore/shared/index.js +1 -0
  267. package/dist/plugins/RendererCore/shared/postRequest.d.ts +5 -0
  268. package/dist/plugins/RendererCore/shared/postRequest.js +31 -0
  269. package/dist/plugins/RendererCore/shared/router.d.ts +2 -0
  270. package/dist/plugins/RendererCore/shared/router.js +3 -0
  271. package/dist/plugins/RendererCore/spec.d.ts +25 -0
  272. package/dist/plugins/RendererCore/spec.js +1 -0
  273. package/dist/plugins/RendererPreview/RendererPreview.d.ts +8 -0
  274. package/dist/plugins/RendererPreview/RendererPreview.js +25 -0
  275. package/dist/plugins/RendererPreview/checkRendererStatus.d.ts +2 -0
  276. package/dist/plugins/RendererPreview/checkRendererStatus.js +31 -0
  277. package/dist/plugins/RendererPreview/handleRendererRequests.d.ts +6 -0
  278. package/dist/plugins/RendererPreview/handleRendererRequests.js +76 -0
  279. package/dist/plugins/RendererPreview/handleWindowMessages.d.ts +2 -0
  280. package/dist/plugins/RendererPreview/handleWindowMessages.js +56 -0
  281. package/dist/plugins/RendererPreview/index.d.ts +2 -0
  282. package/dist/plugins/RendererPreview/index.js +49 -0
  283. package/dist/plugins/RendererPreview/shared.d.ts +9 -0
  284. package/dist/plugins/RendererPreview/shared.js +1 -0
  285. package/dist/plugins/RendererPreview/spec.d.ts +13 -0
  286. package/dist/plugins/RendererPreview/spec.js +1 -0
  287. package/dist/plugins/RendererSelect/index.d.ts +2 -0
  288. package/dist/plugins/RendererSelect/index.js +27 -0
  289. package/dist/plugins/RendererSelect/spec.d.ts +3 -0
  290. package/dist/plugins/RendererSelect/spec.js +1 -0
  291. package/dist/plugins/ResponsivePreview/ResponsivePreview/Header.d.ts +13 -0
  292. package/dist/plugins/ResponsivePreview/ResponsivePreview/Header.js +97 -0
  293. package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.d.ts +14 -0
  294. package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.js +152 -0
  295. package/dist/plugins/ResponsivePreview/ResponsivePreview/style.d.ts +45 -0
  296. package/dist/plugins/ResponsivePreview/ResponsivePreview/style.js +79 -0
  297. package/dist/plugins/ResponsivePreview/ToggleButton/index.d.ts +6 -0
  298. package/dist/plugins/ResponsivePreview/ToggleButton/index.js +6 -0
  299. package/dist/plugins/ResponsivePreview/index.d.ts +2 -0
  300. package/dist/plugins/ResponsivePreview/index.js +79 -0
  301. package/dist/plugins/ResponsivePreview/shared.d.ts +21 -0
  302. package/dist/plugins/ResponsivePreview/shared.js +19 -0
  303. package/dist/plugins/ResponsivePreview/spec.d.ts +13 -0
  304. package/dist/plugins/ResponsivePreview/spec.js +1 -0
  305. package/dist/plugins/Root/GlobalHeader.d.ts +9 -0
  306. package/dist/plugins/Root/GlobalHeader.js +59 -0
  307. package/dist/plugins/Root/RendererHeader.d.ts +16 -0
  308. package/dist/plugins/Root/RendererHeader.js +79 -0
  309. package/dist/plugins/Root/Root.d.ts +28 -0
  310. package/dist/plugins/Root/Root.js +120 -0
  311. package/dist/plugins/Root/SidePanel.d.ts +10 -0
  312. package/dist/plugins/Root/SidePanel.js +26 -0
  313. package/dist/plugins/Root/ToggleNavButton.d.ts +7 -0
  314. package/dist/plugins/Root/ToggleNavButton.js +6 -0
  315. package/dist/plugins/Root/index.d.ts +2 -0
  316. package/dist/plugins/Root/index.js +73 -0
  317. package/dist/plugins/Root/navOpen.d.ts +4 -0
  318. package/dist/plugins/Root/navOpen.js +11 -0
  319. package/dist/plugins/Root/navWidth.d.ts +5 -0
  320. package/dist/plugins/Root/navWidth.js +14 -0
  321. package/dist/plugins/Root/panelOpen.d.ts +4 -0
  322. package/dist/plugins/Root/panelOpen.js +16 -0
  323. package/dist/plugins/Root/panelWidth.d.ts +5 -0
  324. package/dist/plugins/Root/panelWidth.js +14 -0
  325. package/dist/plugins/Root/shared.d.ts +3 -0
  326. package/dist/plugins/Root/shared.js +1 -0
  327. package/dist/plugins/Root/spec.d.ts +14 -0
  328. package/dist/plugins/Root/spec.js +1 -0
  329. package/dist/plugins/Router/index.d.ts +2 -0
  330. package/dist/plugins/Router/index.js +56 -0
  331. package/dist/plugins/Router/spec.d.ts +15 -0
  332. package/dist/plugins/Router/spec.js +1 -0
  333. package/dist/plugins/StandardControl/index.d.ts +2 -0
  334. package/dist/plugins/StandardControl/index.js +43 -0
  335. package/dist/plugins/StandardControl/spec.d.ts +3 -0
  336. package/dist/plugins/StandardControl/spec.js +1 -0
  337. package/dist/plugins/StandardControl/storage.d.ts +7 -0
  338. package/dist/plugins/StandardControl/storage.js +10 -0
  339. package/dist/plugins/Storage/index.d.ts +2 -0
  340. package/dist/plugins/Storage/index.js +40 -0
  341. package/dist/plugins/Storage/spec.d.ts +18 -0
  342. package/dist/plugins/Storage/spec.js +1 -0
  343. package/dist/plugins/pluginEntry.d.ts +23 -0
  344. package/dist/plugins/pluginEntry.js +29 -0
  345. package/dist/shared/defaultPluginConfig.d.ts +13 -0
  346. package/dist/shared/defaultPluginConfig.js +13 -0
  347. package/dist/shared/fixtureTree.d.ts +3 -0
  348. package/dist/shared/fixtureTree.js +12 -0
  349. package/dist/shared/treeExpansion.d.ts +7 -0
  350. package/dist/shared/treeExpansion.js +24 -0
  351. package/dist/shared/url.d.ts +5 -0
  352. package/dist/shared/url.js +33 -0
  353. package/dist/slots/ControlActionSlot.d.ts +10 -0
  354. package/dist/slots/ControlActionSlot.js +5 -0
  355. package/dist/slots/ControlSlot.d.ts +11 -0
  356. package/dist/slots/ControlSlot.js +5 -0
  357. package/dist/slots/FixtureActionSlot.d.ts +10 -0
  358. package/dist/slots/FixtureActionSlot.js +5 -0
  359. package/dist/slots/NavRowSlot.d.ts +9 -0
  360. package/dist/slots/NavRowSlot.js +5 -0
  361. package/dist/slots/RendererActionSlot.d.ts +10 -0
  362. package/dist/slots/RendererActionSlot.js +5 -0
  363. package/dist/slots/SidePanelRowSlot.d.ts +12 -0
  364. package/dist/slots/SidePanelRowSlot.js +5 -0
  365. package/dist/slots/ValueInputSlot.d.ts +16 -0
  366. package/dist/slots/ValueInputSlot.js +5 -0
  367. package/dist/style/colors.d.ts +37 -0
  368. package/dist/style/colors.js +43 -0
  369. package/dist/style/globalStyle.d.ts +2 -0
  370. package/dist/style/globalStyle.js +49 -0
  371. package/dist/style/vars.d.ts +2 -0
  372. package/dist/style/vars.js +2 -0
  373. package/dist/testHelpers/pluginHelpers.d.ts +5 -0
  374. package/dist/testHelpers/pluginHelpers.js +25 -0
  375. package/dist/testHelpers/pluginMocks.d.ts +116 -0
  376. package/dist/testHelpers/pluginMocks.js +139 -0
  377. package/package.json +24 -0
@@ -0,0 +1,123 @@
1
+ import { isEqual } from 'lodash-es';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { XIcon } from '../../components/icons/index.js';
5
+ import { stringifyFixtureId } from '../../components/ValueInputTree/index.js';
6
+ import { createRelativePlaygroundUrl } from '../../shared/url.js';
7
+ import { blue, grey128, grey224, grey24, grey248, grey32, grey8, selectedColors, white10, } from '../../style/colors.js';
8
+ import { quick } from '../../style/vars.js';
9
+ export function FixtureBookmarks({ fixtureItems, bookmarks, selectedFixtureId, onFixtureSelect, onBookmarkDelete, }) {
10
+ const bookmarkedItems = fixtureItems.filter(item => bookmarks.some(b => isEqual(b, item.fixtureId)));
11
+ if (!bookmarkedItems.length)
12
+ return null;
13
+ return (React.createElement(Container, null,
14
+ React.createElement(Header, null,
15
+ React.createElement(HeaderTitle, null, "Bookmarks")),
16
+ bookmarkedItems.map(fixtureItem => {
17
+ const { fixtureId } = fixtureItem;
18
+ const itemKey = stringifyFixtureId(fixtureId);
19
+ const selected = isEqual(fixtureId, selectedFixtureId);
20
+ function handleClick(e) {
21
+ e.preventDefault();
22
+ if (e.metaKey) {
23
+ openAnchorInNewTab(e.currentTarget);
24
+ }
25
+ else {
26
+ onFixtureSelect(fixtureId);
27
+ }
28
+ }
29
+ return (React.createElement(ListItem, { key: itemKey, selected: selected },
30
+ React.createElement(FixtureLink, { href: createRelativePlaygroundUrl({ fixtureId }), selected: selected, onClick: handleClick }, getFixtureName(fixtureItem)),
31
+ React.createElement(DeleteButton, { onClick: () => onBookmarkDelete(fixtureId) },
32
+ React.createElement(DeleteIconContainer, null,
33
+ React.createElement(XIcon, null)))));
34
+ })));
35
+ }
36
+ function openAnchorInNewTab(anchorEl) {
37
+ // Allow users to cmd+click to open fixtures in new tab
38
+ window.open(anchorEl.href, '_blank');
39
+ }
40
+ function getFixtureName({ name, fileName }) {
41
+ return name ? `${fileName} ${name}` : fileName;
42
+ }
43
+ const Container = styled.div `
44
+ padding: 0 0 8px 0;
45
+ background: ${grey32};
46
+ `;
47
+ const Header = styled.div `
48
+ flex-shrink: 0;
49
+ height: 40px;
50
+ padding: 0 4px;
51
+ border-top: 1px solid ${white10};
52
+ background: ${grey32};
53
+ display: flex;
54
+ flex-direction: row;
55
+ justify-content: space-between;
56
+ align-items: center;
57
+ `;
58
+ const HeaderTitle = styled.div `
59
+ padding: 0 4px 0 20px;
60
+ color: ${grey128};
61
+ line-height: 24px;
62
+ white-space: nowrap;
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ text-transform: uppercase;
66
+ `;
67
+ const FixtureLink = styled.a `
68
+ flex: 1;
69
+ padding: 0 0 0 24px;
70
+ font-size: 14px;
71
+ color: ${selectedColors(grey224, grey248)};
72
+ text-decoration: none;
73
+ white-space: nowrap;
74
+ overflow: hidden;
75
+ text-overflow: ellipsis;
76
+
77
+ :focus {
78
+ outline: none;
79
+ box-shadow: inset 2px 0px 0 0 ${blue};
80
+ }
81
+
82
+ ::-moz-focus-inner {
83
+ border: 0;
84
+ }
85
+ `;
86
+ const DeleteButton = styled.span `
87
+ flex-shrink: 0;
88
+ width: 32px;
89
+ height: 28px;
90
+ padding: 0 4px 0 0;
91
+ display: flex;
92
+ align-items: center;
93
+ justify-content: center;
94
+ opacity: 0;
95
+ transition: opacity ${quick}s;
96
+ `;
97
+ const DeleteIconContainer = styled.div `
98
+ width: 16px;
99
+ height: 16px;
100
+ color: ${grey128};
101
+ `;
102
+ const ListItem = styled.span `
103
+ display: flex;
104
+ flex-direction: row;
105
+ align-items: center;
106
+ height: 28px;
107
+ background: ${selectedColors(grey32, grey8)};
108
+ line-height: 28px;
109
+ user-select: none;
110
+ cursor: default;
111
+ transition: color ${quick}s;
112
+
113
+ :hover {
114
+ background: ${selectedColors(grey24, grey8)};
115
+ }
116
+
117
+ :hover ${DeleteButton} {
118
+ opacity: 0.6;
119
+ :hover {
120
+ opacity: 1;
121
+ }
122
+ }
123
+ `;
@@ -0,0 +1,2 @@
1
+ declare const register: () => void;
2
+ export { register };
@@ -0,0 +1,46 @@
1
+ import { isEqual } from 'lodash-es';
2
+ import React from 'react';
3
+ import { createFixtureTree, flattenFixtureTree, } from 'react-cosmos-core';
4
+ import { createPlugin } from 'react-plugin';
5
+ import { BookmarkFixtureButton } from './BookmarkFixtureButton.js';
6
+ import { FixtureBookmarks } from './FixtureBookmarks.js';
7
+ const { namedPlug, register } = createPlugin({
8
+ name: 'fixtureBookmark',
9
+ });
10
+ namedPlug('fixtureAction', 'bookmarkFixture', ({ pluginContext, slotProps }) => {
11
+ const { fixtureId } = slotProps;
12
+ const { getBookmarks, setBookmarks } = getStorageApi(pluginContext);
13
+ const bookmarks = getBookmarks();
14
+ const selected = bookmarks.some(b => isEqual(b, fixtureId));
15
+ return (React.createElement(BookmarkFixtureButton, { selected: selected, onClick: () => setBookmarks(selected
16
+ ? bookmarks.filter(b => !isEqual(b, fixtureId))
17
+ : [...bookmarks, fixtureId]) }));
18
+ });
19
+ namedPlug('navRow', 'fixtureBookmarks', ({ pluginContext }) => {
20
+ const router = pluginContext.getMethodsOf('router');
21
+ const { getBookmarks, setBookmarks } = getStorageApi(pluginContext);
22
+ const bookmarks = getBookmarks();
23
+ const fixtureItems = useFixtureItems(pluginContext);
24
+ return (React.createElement(FixtureBookmarks, { fixtureItems: fixtureItems, bookmarks: bookmarks, selectedFixtureId: router.getSelectedFixtureId(), onFixtureSelect: router.selectFixture, onBookmarkDelete: fixtureId => setBookmarks(bookmarks.filter(b => !isEqual(b, fixtureId))) }));
25
+ });
26
+ export { register };
27
+ if (process.env.NODE_ENV !== 'test')
28
+ register();
29
+ function getStorageApi(pluginContext) {
30
+ const storage = pluginContext.getMethodsOf('storage');
31
+ function getBookmarks() {
32
+ return storage.getItem('fixtureBookmarks') || [];
33
+ }
34
+ function setBookmarks(bookmarks) {
35
+ storage.setItem('fixtureBookmarks', bookmarks);
36
+ }
37
+ return { getBookmarks, setBookmarks };
38
+ }
39
+ function useFixtureItems(pluginContext) {
40
+ const { getMethodsOf } = pluginContext;
41
+ const core = getMethodsOf('core');
42
+ const { fixturesDir, fixtureFileSuffix } = core.getFixtureFileVars();
43
+ const rendererCore = getMethodsOf('rendererCore');
44
+ const fixtures = rendererCore.getFixtures();
45
+ return React.useMemo(() => flattenFixtureTree(createFixtureTree({ fixturesDir, fixtureFileSuffix, fixtures })), [fixtureFileSuffix, fixtures, fixturesDir]);
46
+ }
@@ -0,0 +1,3 @@
1
+ export type FixtureBookmarkSpec = {
2
+ name: 'fixtureBookmark';
3
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ type Props = {
2
+ validFixtureSelected: boolean;
3
+ onOpen: () => unknown;
4
+ onCloseNav: () => unknown;
5
+ };
6
+ export declare function FixtureSearchHeader({ validFixtureSelected, onOpen, onCloseNav, }: Props): JSX.Element;
7
+ export {};
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { IconButton32 } from '../../components/buttons/index.js';
4
+ import { ChevronLeftIcon, SearchIcon } from '../../components/icons/index.js';
5
+ import { KeyBox } from '../../components/KeyBox.js';
6
+ import { blue, grey160, grey32, white10 } from '../../style/colors.js';
7
+ export function FixtureSearchHeader({ validFixtureSelected, onOpen, onCloseNav, }) {
8
+ return (React.createElement(Container, null,
9
+ React.createElement(SearchButton, { onClick: onOpen },
10
+ React.createElement(SearchIconContainer, null,
11
+ React.createElement(SearchIcon, null)),
12
+ React.createElement(SearchLabel, null, "Search fixtures"),
13
+ React.createElement(KeyBox, { value: '⌘', bgColor: white10, textColor: grey160, size: 20 }),
14
+ React.createElement(KeyBox, { value: 'P', bgColor: white10, textColor: grey160, size: 20 })),
15
+ React.createElement(NavButtonContainer, null,
16
+ React.createElement(IconButton32, { icon: React.createElement(ChevronLeftIcon, null), title: "Hide fixture list", disabled: !validFixtureSelected, selected: false, onClick: onCloseNav }))));
17
+ }
18
+ const Container = styled.div `
19
+ display: flex;
20
+ flex-direction: row;
21
+ align-items: center;
22
+ height: 40px;
23
+ margin: 0 1px 0 0;
24
+ background: ${grey32};
25
+ `;
26
+ const SearchButton = styled.button `
27
+ flex: 1;
28
+ height: 32px;
29
+ display: flex;
30
+ flex-direction: row;
31
+ justify-content: flex-start;
32
+ align-items: center;
33
+ border: none;
34
+ background: transparent;
35
+ color: ${grey160};
36
+ padding: 0 0 0 16px;
37
+ overflow: hidden;
38
+ cursor: text;
39
+
40
+ :focus {
41
+ outline: none;
42
+ box-shadow: inset 2px 0px 0 0 ${blue};
43
+ }
44
+
45
+ ::-moz-focus-inner {
46
+ border: 0;
47
+ }
48
+ `;
49
+ const SearchIconContainer = styled.span `
50
+ flex-shrink: 0;
51
+ width: 16px;
52
+ height: 16px;
53
+ margin: 1px 8px 0 6px;
54
+ opacity: 0.64;
55
+ `;
56
+ const SearchLabel = styled.span `
57
+ padding: 0 3px 0 0;
58
+ line-height: 24px;
59
+ white-space: nowrap;
60
+ overflow: hidden;
61
+ text-overflow: ellipsis;
62
+ text-align: left;
63
+ `;
64
+ const NavButtonContainer = styled.div `
65
+ padding: 0 4px;
66
+ `;
@@ -0,0 +1,13 @@
1
+ import { FixtureId, FixtureList } from 'react-cosmos-core';
2
+ type Props = {
3
+ searchText: string;
4
+ fixturesDir: string;
5
+ fixtureFileSuffix: string;
6
+ fixtures: FixtureList;
7
+ selectedFixtureId: null | FixtureId;
8
+ onSetSearchText: (searchText: string) => unknown;
9
+ onClose: () => unknown;
10
+ onSelect: (fixtureId: FixtureId, revealFixture: boolean) => unknown;
11
+ };
12
+ export declare function FixtureSearchOverlay({ searchText, fixturesDir, fixtureFileSuffix, fixtures, selectedFixtureId, onSetSearchText, onClose, onSelect, }: Props): JSX.Element;
13
+ export {};
@@ -0,0 +1,312 @@
1
+ import { filter } from 'fuzzaldrin-plus';
2
+ import { isEqual } from 'lodash-es';
3
+ import React, { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
4
+ import { createFixtureTree, flattenFixtureTree, KEY_DOWN, KEY_ENTER, KEY_ESC, KEY_FWD_SLASH, KEY_TAB, KEY_UP, } from 'react-cosmos-core';
5
+ import styled from 'styled-components';
6
+ import { HelpCircleIcon, SearchIcon } from '../../components/icons/index.js';
7
+ import { black60, grey128, grey160, grey176, grey208, grey224, grey248, grey64, } from '../../style/colors.js';
8
+ import { quick } from '../../style/vars.js';
9
+ import { FixtureSearchResult } from './FixtureSearchResult.js';
10
+ import { FixtureSearchShortcuts } from './FixtureSearchShortcuts.js';
11
+ export function FixtureSearchOverlay({ searchText, fixturesDir, fixtureFileSuffix, fixtures, selectedFixtureId, onSetSearchText, onClose, onSelect, }) {
12
+ // Fixture items are memoized purely to minimize computation
13
+ const fixtureItems = useMemo(() => {
14
+ const fixtureTree = createFixtureTree({
15
+ fixtures,
16
+ fixturesDir,
17
+ fixtureFileSuffix,
18
+ });
19
+ const flatFixtureTree = flattenFixtureTree(fixtureTree);
20
+ return flatFixtureTree.reduce((acc, item) => {
21
+ const cleanPath = [...item.parents, item.fileName];
22
+ if (item.name)
23
+ cleanPath.push(item.name);
24
+ return { ...acc, [cleanPath.join(' ')]: item };
25
+ }, {});
26
+ }, [fixtures, fixturesDir, fixtureFileSuffix]);
27
+ const onInputChange = useCallback((e) => {
28
+ onSetSearchText(e.currentTarget.value);
29
+ }, [onSetSearchText]);
30
+ const [matchingFixturePaths, setMatchingFixturePaths] = useState(getMatchingFixturePaths(fixtureItems, searchText));
31
+ const [activeFixturePath, setActiveFixturePath] = useState(() => {
32
+ const selectedFixturePath = selectedFixtureId && findFixturePath(fixtureItems, selectedFixtureId);
33
+ return selectedFixturePath || getFirstFixturePath(matchingFixturePaths);
34
+ });
35
+ useEffect(() => {
36
+ const newMatchingFixturePaths = getMatchingFixturePaths(fixtureItems, searchText);
37
+ if (!isEqual(newMatchingFixturePaths, matchingFixturePaths)) {
38
+ setMatchingFixturePaths(newMatchingFixturePaths);
39
+ // Reset active fixture to first matching fixture when search changes
40
+ // WARNING: Putting this in a separate effect with only matchingFixturePaths
41
+ // as a dependency looks nicer, but creates a flicker between some renders.
42
+ // On searchText change, the component would first render a new list of
43
+ // matching fixture paths (which may or may not contain the activeFixturePath),
44
+ // and only in the (albeit almost instant) 2nd render would activeFixturePath
45
+ // be updated to equal the first of the new list of matching fixture paths.
46
+ setActiveFixturePath(getFirstFixturePath(newMatchingFixturePaths));
47
+ }
48
+ }, [fixtureItems, matchingFixturePaths, searchText]);
49
+ const onInputKeyDown = useMemo(() => {
50
+ function handleEscape() {
51
+ onClose();
52
+ }
53
+ function handleEnter() {
54
+ if (activeFixturePath !== null) {
55
+ const { fixtureId } = fixtureItems[activeFixturePath];
56
+ onSelect(fixtureId, true);
57
+ }
58
+ }
59
+ function handleUp() {
60
+ if (activeFixturePath) {
61
+ const fixtureIndex = matchingFixturePaths.indexOf(activeFixturePath);
62
+ if (fixtureIndex > 0) {
63
+ setActiveFixturePath(matchingFixturePaths[fixtureIndex - 1]);
64
+ }
65
+ }
66
+ }
67
+ function handleDown() {
68
+ if (activeFixturePath) {
69
+ const fixtureIndex = matchingFixturePaths.indexOf(activeFixturePath);
70
+ if (fixtureIndex < matchingFixturePaths.length - 1) {
71
+ setActiveFixturePath(matchingFixturePaths[fixtureIndex + 1]);
72
+ }
73
+ }
74
+ }
75
+ function handleTab() {
76
+ const matchingFixtureCount = matchingFixturePaths.length;
77
+ if (matchingFixtureCount > 0) {
78
+ if (!activeFixturePath) {
79
+ setActiveFixturePath(matchingFixturePaths[0]);
80
+ }
81
+ else {
82
+ const fixtureIndex = matchingFixturePaths.indexOf(activeFixturePath);
83
+ const lastMatch = fixtureIndex === matchingFixtureCount - 1;
84
+ if (lastMatch) {
85
+ setActiveFixturePath(matchingFixturePaths[0]);
86
+ }
87
+ else {
88
+ setActiveFixturePath(matchingFixturePaths[fixtureIndex + 1]);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ function handleTabReverse() {
94
+ const matchingFixtureCount = matchingFixturePaths.length;
95
+ if (matchingFixtureCount > 0) {
96
+ if (!activeFixturePath) {
97
+ setActiveFixturePath(matchingFixturePaths[matchingFixtureCount - 1]);
98
+ }
99
+ else {
100
+ const fixtureIndex = matchingFixturePaths.indexOf(activeFixturePath);
101
+ const lastMatch = fixtureIndex === 0;
102
+ if (lastMatch) {
103
+ setActiveFixturePath(matchingFixturePaths[matchingFixtureCount - 1]);
104
+ }
105
+ else {
106
+ setActiveFixturePath(matchingFixturePaths[fixtureIndex - 1]);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ function handleQuestionMark(e) {
112
+ if (e.shiftKey) {
113
+ e.preventDefault();
114
+ setShowShortcuts(prev => !prev);
115
+ }
116
+ }
117
+ return (e) => {
118
+ switch (e.keyCode) {
119
+ case KEY_ESC:
120
+ e.preventDefault();
121
+ return handleEscape();
122
+ case KEY_ENTER:
123
+ e.preventDefault();
124
+ return handleEnter();
125
+ case KEY_UP:
126
+ e.preventDefault();
127
+ return handleUp();
128
+ case KEY_DOWN:
129
+ e.preventDefault();
130
+ return handleDown();
131
+ case KEY_TAB:
132
+ e.preventDefault();
133
+ return e.shiftKey ? handleTabReverse() : handleTab();
134
+ case KEY_FWD_SLASH:
135
+ return handleQuestionMark(e);
136
+ default:
137
+ // Nada
138
+ }
139
+ };
140
+ }, [
141
+ onClose,
142
+ activeFixturePath,
143
+ fixtureItems,
144
+ onSelect,
145
+ matchingFixturePaths,
146
+ ]);
147
+ const inputRef = useRef(null);
148
+ // Auto focus when search input is created
149
+ useEffect(() => {
150
+ if (inputRef.current) {
151
+ inputRef.current.focus();
152
+ inputRef.current.select();
153
+ }
154
+ }, []);
155
+ // 1. Prevent click propagation to overlay element (which calls onClose)
156
+ // 2. Keep user focused on search input while search is open
157
+ const onContentClick = useCallback((e) => {
158
+ e.stopPropagation();
159
+ if (inputRef.current) {
160
+ inputRef.current.focus();
161
+ }
162
+ }, []);
163
+ const [showShortcuts, setShowShortcuts] = useState(false);
164
+ const handleToggleHelp = useCallback(() => {
165
+ setShowShortcuts(prev => !prev);
166
+ }, []);
167
+ return (React.createElement(OverlayIE11, { "data-testid": "fixtureSearchOverlay", onClick: onClose },
168
+ React.createElement(Content, { "data-testid": "fixtureSearchContent", onClick: onContentClick },
169
+ React.createElement(InputContainer, null,
170
+ React.createElement(SearchIconContainer, null,
171
+ React.createElement(SearchIcon, null)),
172
+ React.createElement(SearchInput, { ref: inputRef, type: "text", placeholder: "Fixture search", value: searchText, onChange: onInputChange, onKeyDown: onInputKeyDown }),
173
+ React.createElement(HelpButton, { selected: showShortcuts, onClick: handleToggleHelp },
174
+ React.createElement(HelpCircleIcon, null))),
175
+ React.createElement(ShortcutsContainer, { visible: showShortcuts },
176
+ React.createElement(FixtureSearchShortcuts, null)),
177
+ React.createElement(ResultsViewport, null,
178
+ React.createElement(ResultsContainer, null,
179
+ matchingFixturePaths.map(cleanFixturePath => (React.createElement(FixtureSearchResult, { key: cleanFixturePath, cleanFixturePath: cleanFixturePath, fixtureItem: fixtureItems[cleanFixturePath], active: cleanFixturePath === activeFixturePath, onSelect: onSelect }))),
180
+ matchingFixturePaths.length === 0 && (React.createElement(NoResults, null, "No results")))))));
181
+ }
182
+ function findFixturePath(fixtureItems, fixtureId) {
183
+ const fixturePaths = Object.keys(fixtureItems);
184
+ return fixturePaths.find(fixturePath => isEqual(fixtureItems[fixturePath].fixtureId, fixtureId));
185
+ }
186
+ function getFirstFixturePath(fixturePaths) {
187
+ return fixturePaths.length > 0 ? fixturePaths[0] : null;
188
+ }
189
+ function getMatchingFixturePaths(fixtureItems, searchText) {
190
+ const fixturePaths = Object.keys(fixtureItems);
191
+ if (searchText === '') {
192
+ return fixturePaths;
193
+ }
194
+ const fixtureSearchTexts = [];
195
+ fixturePaths.forEach(cleanFixturePath => {
196
+ const { fixtureId, parents } = fixtureItems[cleanFixturePath];
197
+ const { path, name } = fixtureId;
198
+ // Allow fixtures to be searched by their entire file path, suffixed by
199
+ // their name in the case of named fixtures, as well as by parent path,
200
+ // allowing users to query results in the format they are displayed
201
+ const searchPath = [path];
202
+ if (name)
203
+ searchPath.push(name);
204
+ searchPath.push(...parents);
205
+ fixtureSearchTexts.push(searchPath.join(' '));
206
+ });
207
+ const machingFixtureSearchTexts = filter(fixtureSearchTexts, searchText);
208
+ return machingFixtureSearchTexts.map(fixtureSearchText => {
209
+ const fixtureIndex = fixtureSearchTexts.indexOf(fixtureSearchText);
210
+ return fixturePaths[fixtureIndex];
211
+ });
212
+ }
213
+ const Overlay = styled.div `
214
+ position: fixed;
215
+ top: 0;
216
+ bottom: 0;
217
+ left: 0;
218
+ right: 0;
219
+ background: ${black60};
220
+ `;
221
+ const OverlayIE11 = styled(Overlay) `
222
+ z-index: 10;
223
+ `;
224
+ const Content = styled.div `
225
+ position: absolute;
226
+ top: 20%;
227
+ left: 50%;
228
+ transform: translate(-50%, 0);
229
+ width: 80%;
230
+ max-width: 640px;
231
+ border-radius: 3px;
232
+ background: ${grey248};
233
+ box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px,
234
+ rgba(15, 15, 15, 0.1) 0px 5px 10px, rgba(15, 15, 15, 0.2) 0px 15px 40px;
235
+ display: flex;
236
+ flex-direction: column;
237
+ overflow: hidden;
238
+ `;
239
+ const InputContainer = styled.div `
240
+ flex-shrink: 0;
241
+ display: flex;
242
+ flex-direction: row;
243
+ align-items: center;
244
+ height: 48px;
245
+ padding: 0 12px;
246
+ user-select: none;
247
+ cursor: text;
248
+ `;
249
+ const SearchIconContainer = styled.div `
250
+ flex-shrink: 0;
251
+ width: 20px;
252
+ height: 20px;
253
+ margin: 2px 0 0 0;
254
+ padding: 0 10px 0 6px;
255
+ color: ${grey176};
256
+ `;
257
+ const SearchInput = styled.input `
258
+ flex: 1;
259
+ border: none;
260
+ background: transparent;
261
+ color: ${grey64};
262
+ outline: none;
263
+ font-size: 16px;
264
+ line-height: 32px;
265
+
266
+ ::placeholder {
267
+ color: ${grey160};
268
+ }
269
+ `;
270
+ const HelpButton = styled.div `
271
+ flex-shrink: 0;
272
+ width: 20px;
273
+ height: 20px;
274
+ margin: 2px 0 0 0;
275
+ padding: 6px;
276
+ border-radius: 50%;
277
+ background: ${props => (props.selected ? grey224 : 'transparent')};
278
+ color: ${props => (props.selected ? grey128 : grey176)};
279
+ cursor: pointer;
280
+ transition: background ${quick}s, color ${quick}s;
281
+
282
+ :hover {
283
+ color: ${grey128};
284
+ }
285
+ `;
286
+ const ShortcutsContainer = styled.div `
287
+ height: ${props => (props.visible ? 72 : 0)}px;
288
+ overflow: hidden;
289
+ opacity: ${props => (props.visible ? 1 : 0)};
290
+ transition: height ${quick}s, opacity ${quick}s;
291
+ user-select: none;
292
+ `;
293
+ const ResultsViewport = styled.div `
294
+ max-height: 336px;
295
+ border-top: 1px solid ${grey208};
296
+ background: ${grey224};
297
+ overflow-x: hidden;
298
+ overflow-y: auto;
299
+ `;
300
+ const ResultsContainer = styled.div `
301
+ padding: 8px 0;
302
+ `;
303
+ const NoResults = styled.div `
304
+ padding: 0 24px 0 48px;
305
+ line-height: 32px;
306
+ font-size: 14px;
307
+ white-space: nowrap;
308
+ overflow: hidden;
309
+ text-overflow: ellipsis;
310
+ user-select: none;
311
+ color: ${grey128};
312
+ `;
@@ -0,0 +1,9 @@
1
+ import { FixtureId, FlatFixtureTreeItem } from 'react-cosmos-core';
2
+ type Props = {
3
+ active: boolean;
4
+ cleanFixturePath: string;
5
+ fixtureItem: FlatFixtureTreeItem;
6
+ onSelect: (fixtureId: FixtureId, revealFixture: boolean) => unknown;
7
+ };
8
+ export declare function FixtureSearchResult({ active, cleanFixturePath, fixtureItem, onSelect, }: Props): JSX.Element;
9
+ export {};
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { blue, createGreyColor, grey64, selectedColors, } from '../../style/colors.js';
4
+ export function FixtureSearchResult({ active, cleanFixturePath, fixtureItem, onSelect, }) {
5
+ const { fixtureId, fileName, name, parents } = fixtureItem;
6
+ const containerRef = useScrollToActive(cleanFixturePath, active);
7
+ const onClick = React.useCallback(() => onSelect(fixtureId, true), [fixtureId, onSelect]);
8
+ return (React.createElement(Container, { ref: containerRef, selected: active, onClick: onClick },
9
+ React.createElement(Text, null,
10
+ React.createElement(Name, { selected: active }, name ? `${fileName} ${name}` : fileName),
11
+ parents.length > 0 && React.createElement(Parents, null, parents.join('/')))));
12
+ }
13
+ function useScrollToActive(cleanFixturePath, active) {
14
+ const containerRef = React.useRef(null);
15
+ // Scroll to results when they become active
16
+ React.useLayoutEffect(() => {
17
+ const containerNode = containerRef.current;
18
+ if (active && containerNode) {
19
+ scrollIntoView(containerNode);
20
+ }
21
+ }, [cleanFixturePath, active]);
22
+ return containerRef;
23
+ }
24
+ function scrollIntoView(node) {
25
+ if (typeof node.scrollIntoView === 'function') {
26
+ node.scrollIntoView({ block: 'center' });
27
+ }
28
+ }
29
+ const Container = styled.div `
30
+ padding: 0 24px 0 48px;
31
+ background: ${selectedColors('transparent', blue)};
32
+ color: ${selectedColors(createGreyColor(64, 0.64), createGreyColor(255, 0.64))};
33
+ `;
34
+ const Text = styled.div `
35
+ font-size: 14px;
36
+ line-height: 32px;
37
+ white-space: nowrap;
38
+ overflow: hidden;
39
+ text-overflow: ellipsis;
40
+ user-select: none;
41
+ `;
42
+ const Name = styled.span `
43
+ color: ${selectedColors(grey64, 'white')};
44
+ font-weight: 500;
45
+ `;
46
+ const Parents = styled.span `
47
+ padding: 0 0 0 8px;
48
+ `;
@@ -0,0 +1 @@
1
+ export declare function FixtureSearchShortcuts(): JSX.Element;