@grackle-ai/web-components 0.107.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 (279) hide show
  1. package/.rush/temp/3ae72563f781afd72723475938136f113846603e.untar.log +10 -0
  2. package/.rush/temp/bc1d5bf9201ce71abeaeaddd096deb9b0805d703.untar.log +10 -0
  3. package/.rush/temp/operation/_phase_build/all.log +18 -0
  4. package/.rush/temp/operation/_phase_build/log-chunks.jsonl +18 -0
  5. package/.rush/temp/operation/_phase_build/state.json +3 -0
  6. package/.rush/temp/operation/_phase_test/all.log +121 -0
  7. package/.rush/temp/operation/_phase_test/log-chunks.jsonl +121 -0
  8. package/.rush/temp/operation/_phase_test/state.json +3 -0
  9. package/.rush/temp/shrinkwrap-deps.json +938 -0
  10. package/.storybook/main.ts +22 -0
  11. package/.storybook/preview.tsx +30 -0
  12. package/config/rig.json +4 -0
  13. package/config/rush-project.json +12 -0
  14. package/dist/index.css +1 -0
  15. package/dist/index.js +39221 -0
  16. package/eslint.config.cjs +5 -0
  17. package/package.json +83 -0
  18. package/rush-logs/web-components._phase_build.cache.log +4 -0
  19. package/rush-logs/web-components._phase_test.cache.log +4 -0
  20. package/src/components/chat/ChatInput.module.scss +81 -0
  21. package/src/components/chat/ChatInput.stories.tsx +91 -0
  22. package/src/components/chat/ChatInput.tsx +168 -0
  23. package/src/components/chat/index.ts +6 -0
  24. package/src/components/dag/DagView.module.scss +149 -0
  25. package/src/components/dag/DagView.stories.tsx +125 -0
  26. package/src/components/dag/DagView.tsx +109 -0
  27. package/src/components/dag/TaskNode.stories.tsx +133 -0
  28. package/src/components/dag/TaskNode.tsx +40 -0
  29. package/src/components/dag/useDagLayout.ts +139 -0
  30. package/src/components/display/Breadcrumbs.module.scss +71 -0
  31. package/src/components/display/Breadcrumbs.stories.tsx +80 -0
  32. package/src/components/display/Breadcrumbs.tsx +46 -0
  33. package/src/components/display/Button.module.scss +110 -0
  34. package/src/components/display/Button.stories.tsx +88 -0
  35. package/src/components/display/Button.tsx +40 -0
  36. package/src/components/display/ConfirmDialog.module.scss +67 -0
  37. package/src/components/display/ConfirmDialog.stories.tsx +81 -0
  38. package/src/components/display/ConfirmDialog.tsx +88 -0
  39. package/src/components/display/CopyButton.module.scss +41 -0
  40. package/src/components/display/CopyButton.stories.tsx +78 -0
  41. package/src/components/display/CopyButton.tsx +64 -0
  42. package/src/components/display/DemoBanner.module.scss +37 -0
  43. package/src/components/display/DemoBanner.stories.tsx +40 -0
  44. package/src/components/display/DemoBanner.tsx +23 -0
  45. package/src/components/display/EventHoverRow.module.scss +102 -0
  46. package/src/components/display/EventHoverRow.stories.tsx +99 -0
  47. package/src/components/display/EventHoverRow.tsx +154 -0
  48. package/src/components/display/EventRenderer.module.scss +272 -0
  49. package/src/components/display/EventRenderer.stories.tsx +186 -0
  50. package/src/components/display/EventRenderer.tsx +271 -0
  51. package/src/components/display/EventStream.module.scss +93 -0
  52. package/src/components/display/EventStream.stories.tsx +249 -0
  53. package/src/components/display/EventStream.tsx +369 -0
  54. package/src/components/display/FloatingActionBar.module.scss +107 -0
  55. package/src/components/display/FloatingActionBar.stories.tsx +122 -0
  56. package/src/components/display/FloatingActionBar.tsx +119 -0
  57. package/src/components/display/SessionAttemptSelector.module.scss +50 -0
  58. package/src/components/display/SessionAttemptSelector.stories.tsx +78 -0
  59. package/src/components/display/SessionAttemptSelector.tsx +49 -0
  60. package/src/components/display/SessionPicker.module.scss +200 -0
  61. package/src/components/display/SessionPicker.stories.tsx +169 -0
  62. package/src/components/display/SessionPicker.tsx +214 -0
  63. package/src/components/display/Skeleton.module.scss +58 -0
  64. package/src/components/display/Skeleton.stories.tsx +94 -0
  65. package/src/components/display/Skeleton.tsx +127 -0
  66. package/src/components/display/Spinner.module.scss +41 -0
  67. package/src/components/display/Spinner.stories.tsx +66 -0
  68. package/src/components/display/Spinner.tsx +32 -0
  69. package/src/components/display/SplashScreen.module.scss +20 -0
  70. package/src/components/display/SplashScreen.stories.tsx +26 -0
  71. package/src/components/display/SplashScreen.tsx +16 -0
  72. package/src/components/display/SplitButton.module.scss +166 -0
  73. package/src/components/display/SplitButton.stories.tsx +95 -0
  74. package/src/components/display/SplitButton.tsx +128 -0
  75. package/src/components/display/Tooltip.module.scss +84 -0
  76. package/src/components/display/Tooltip.stories.tsx +240 -0
  77. package/src/components/display/Tooltip.tsx +184 -0
  78. package/src/components/display/extractText.test.tsx +48 -0
  79. package/src/components/display/index.ts +20 -0
  80. package/src/components/editable/EditableCheckbox.stories.tsx +54 -0
  81. package/src/components/editable/EditableCheckbox.tsx +39 -0
  82. package/src/components/editable/EditableField.module.scss +135 -0
  83. package/src/components/editable/EditableSelect.tsx +164 -0
  84. package/src/components/editable/EditableTextArea.stories.tsx +50 -0
  85. package/src/components/editable/EditableTextArea.tsx +148 -0
  86. package/src/components/editable/EditableTextField.stories.tsx +62 -0
  87. package/src/components/editable/EditableTextField.tsx +153 -0
  88. package/src/components/editable/EnvironmentSelect.module.scss +17 -0
  89. package/src/components/editable/EnvironmentSelect.stories.tsx +61 -0
  90. package/src/components/editable/EnvironmentSelect.tsx +87 -0
  91. package/src/components/editable/index.ts +13 -0
  92. package/src/components/editable/useEditableField.test.tsx +233 -0
  93. package/src/components/editable/useEditableField.ts +173 -0
  94. package/src/components/index.ts +20 -0
  95. package/src/components/knowledge/KnowledgeDetailPanel.module.scss +162 -0
  96. package/src/components/knowledge/KnowledgeDetailPanel.stories.tsx +208 -0
  97. package/src/components/knowledge/KnowledgeDetailPanel.tsx +122 -0
  98. package/src/components/knowledge/KnowledgeGraph.module.scss +110 -0
  99. package/src/components/knowledge/KnowledgeGraph.stories.tsx +180 -0
  100. package/src/components/knowledge/KnowledgeGraph.tsx +455 -0
  101. package/src/components/knowledge/KnowledgeNav.module.scss +130 -0
  102. package/src/components/knowledge/KnowledgeNav.stories.tsx +108 -0
  103. package/src/components/knowledge/KnowledgeNav.tsx +138 -0
  104. package/src/components/knowledge/index.ts +3 -0
  105. package/src/components/layout/AppNav.module.scss +82 -0
  106. package/src/components/layout/AppNav.stories.tsx +115 -0
  107. package/src/components/layout/AppNav.tsx +133 -0
  108. package/src/components/layout/BottomStatusBar.module.scss +58 -0
  109. package/src/components/layout/BottomStatusBar.stories.tsx +35 -0
  110. package/src/components/layout/BottomStatusBar.tsx +206 -0
  111. package/src/components/layout/Sidebar.module.scss +60 -0
  112. package/src/components/layout/Sidebar.stories.tsx +46 -0
  113. package/src/components/layout/Sidebar.tsx +84 -0
  114. package/src/components/layout/StatusBar.module.scss +108 -0
  115. package/src/components/layout/StatusBar.stories.tsx +119 -0
  116. package/src/components/layout/StatusBar.tsx +70 -0
  117. package/src/components/layout/index.ts +9 -0
  118. package/src/components/lists/EnvironmentNav.module.scss +118 -0
  119. package/src/components/lists/EnvironmentNav.stories.tsx +121 -0
  120. package/src/components/lists/EnvironmentNav.tsx +133 -0
  121. package/src/components/lists/FindingsNav.module.scss +126 -0
  122. package/src/components/lists/FindingsNav.tsx +146 -0
  123. package/src/components/lists/TaskList.module.scss +206 -0
  124. package/src/components/lists/TaskList.stories.tsx +401 -0
  125. package/src/components/lists/TaskList.tsx +509 -0
  126. package/src/components/lists/index.ts +6 -0
  127. package/src/components/lists/listHelpers.tsx +130 -0
  128. package/src/components/notifications/Callout.module.scss +83 -0
  129. package/src/components/notifications/Callout.stories.tsx +81 -0
  130. package/src/components/notifications/Callout.tsx +64 -0
  131. package/src/components/notifications/Toast.module.scss +86 -0
  132. package/src/components/notifications/Toast.stories.tsx +71 -0
  133. package/src/components/notifications/Toast.tsx +51 -0
  134. package/src/components/notifications/ToastContainer.module.scss +23 -0
  135. package/src/components/notifications/ToastContainer.stories.tsx +66 -0
  136. package/src/components/notifications/ToastContainer.tsx +29 -0
  137. package/src/components/notifications/UpdateBanner.stories.tsx +77 -0
  138. package/src/components/notifications/UpdateBanner.test.tsx +64 -0
  139. package/src/components/notifications/UpdateBanner.tsx +44 -0
  140. package/src/components/notifications/index.ts +8 -0
  141. package/src/components/panels/AboutPanel.stories.tsx +70 -0
  142. package/src/components/panels/AboutPanel.tsx +66 -0
  143. package/src/components/panels/AppearancePanel.stories.tsx +45 -0
  144. package/src/components/panels/AppearancePanel.tsx +97 -0
  145. package/src/components/panels/CredentialProvidersPanel.stories.tsx +62 -0
  146. package/src/components/panels/CredentialProvidersPanel.tsx +111 -0
  147. package/src/components/panels/EnvironmentEditPanel.module.scss +170 -0
  148. package/src/components/panels/EnvironmentEditPanel.stories.tsx +206 -0
  149. package/src/components/panels/EnvironmentEditPanel.tsx +785 -0
  150. package/src/components/panels/FindingsPanel.module.scss +94 -0
  151. package/src/components/panels/FindingsPanel.stories.tsx +109 -0
  152. package/src/components/panels/FindingsPanel.tsx +76 -0
  153. package/src/components/panels/KeyboardShortcutsPanel.module.scss +65 -0
  154. package/src/components/panels/KeyboardShortcutsPanel.stories.tsx +40 -0
  155. package/src/components/panels/KeyboardShortcutsPanel.tsx +104 -0
  156. package/src/components/panels/PluginsPanel.tsx +77 -0
  157. package/src/components/panels/SettingsPanel.module.scss +336 -0
  158. package/src/components/panels/TaskActionButtons.module.scss +22 -0
  159. package/src/components/panels/TaskActionButtons.stories.tsx +125 -0
  160. package/src/components/panels/TaskActionButtons.tsx +87 -0
  161. package/src/components/panels/TaskEditPanel.module.scss +202 -0
  162. package/src/components/panels/TaskEditPanel.stories.tsx +75 -0
  163. package/src/components/panels/TaskEditPanel.tsx +328 -0
  164. package/src/components/panels/TaskOverviewPanel.module.scss +236 -0
  165. package/src/components/panels/TaskOverviewPanel.stories.tsx +219 -0
  166. package/src/components/panels/TaskOverviewPanel.tsx +270 -0
  167. package/src/components/panels/TokensPanel.stories.tsx +131 -0
  168. package/src/components/panels/TokensPanel.tsx +143 -0
  169. package/src/components/panels/WorkpadPanel.module.scss +39 -0
  170. package/src/components/panels/WorkpadPanel.stories.tsx +56 -0
  171. package/src/components/panels/WorkpadPanel.tsx +63 -0
  172. package/src/components/panels/index.ts +13 -0
  173. package/src/components/personas/McpToolSelector.module.scss +109 -0
  174. package/src/components/personas/McpToolSelector.stories.tsx +129 -0
  175. package/src/components/personas/McpToolSelector.tsx +180 -0
  176. package/src/components/personas/PersonaManager.module.scss +233 -0
  177. package/src/components/personas/PersonaManager.stories.tsx +139 -0
  178. package/src/components/personas/PersonaManager.tsx +122 -0
  179. package/src/components/schedules/ScheduleManager.module.scss +98 -0
  180. package/src/components/schedules/ScheduleManager.stories.tsx +78 -0
  181. package/src/components/schedules/ScheduleManager.tsx +160 -0
  182. package/src/components/settings/SettingsNav.module.scss +82 -0
  183. package/src/components/settings/SettingsNav.stories.tsx +83 -0
  184. package/src/components/settings/SettingsNav.tsx +104 -0
  185. package/src/components/streams/StreamDetailPanel.module.scss +206 -0
  186. package/src/components/streams/StreamDetailPanel.stories.tsx +132 -0
  187. package/src/components/streams/StreamDetailPanel.tsx +119 -0
  188. package/src/components/streams/StreamList.module.scss +92 -0
  189. package/src/components/streams/StreamList.stories.tsx +99 -0
  190. package/src/components/streams/StreamList.tsx +114 -0
  191. package/src/components/streams/index.ts +10 -0
  192. package/src/components/tools/AgentToolCard.module.scss +118 -0
  193. package/src/components/tools/AgentToolCard.stories.tsx +304 -0
  194. package/src/components/tools/AgentToolCard.tsx +247 -0
  195. package/src/components/tools/FileEditCard.stories.tsx +138 -0
  196. package/src/components/tools/FileEditCard.tsx +160 -0
  197. package/src/components/tools/FileReadCard.stories.tsx +120 -0
  198. package/src/components/tools/FileReadCard.tsx +106 -0
  199. package/src/components/tools/FindingCard.stories.tsx +124 -0
  200. package/src/components/tools/FindingCard.tsx +178 -0
  201. package/src/components/tools/GenericToolCard.stories.tsx +80 -0
  202. package/src/components/tools/GenericToolCard.tsx +111 -0
  203. package/src/components/tools/IpcCard.stories.tsx +129 -0
  204. package/src/components/tools/IpcCard.tsx +178 -0
  205. package/src/components/tools/KnowledgeCard.stories.tsx +112 -0
  206. package/src/components/tools/KnowledgeCard.tsx +165 -0
  207. package/src/components/tools/MetadataCard.stories.tsx +32 -0
  208. package/src/components/tools/MetadataCard.tsx +39 -0
  209. package/src/components/tools/SearchCard.stories.tsx +74 -0
  210. package/src/components/tools/SearchCard.tsx +86 -0
  211. package/src/components/tools/ShellCard.stories.tsx +112 -0
  212. package/src/components/tools/ShellCard.tsx +106 -0
  213. package/src/components/tools/TaskCard.stories.tsx +123 -0
  214. package/src/components/tools/TaskCard.tsx +203 -0
  215. package/src/components/tools/TodoCard.module.scss +131 -0
  216. package/src/components/tools/TodoCard.stories.tsx +202 -0
  217. package/src/components/tools/TodoCard.tsx +200 -0
  218. package/src/components/tools/ToolCard.stories.tsx +177 -0
  219. package/src/components/tools/ToolCard.tsx +60 -0
  220. package/src/components/tools/ToolCardProps.ts +20 -0
  221. package/src/components/tools/ToolSearchCard.stories.tsx +81 -0
  222. package/src/components/tools/ToolSearchCard.tsx +86 -0
  223. package/src/components/tools/WorkpadCard.stories.tsx +106 -0
  224. package/src/components/tools/WorkpadCard.tsx +125 -0
  225. package/src/components/tools/classifyTool.test.ts +44 -0
  226. package/src/components/tools/classifyTool.ts +134 -0
  227. package/src/components/tools/parseDiff.ts +95 -0
  228. package/src/components/tools/parseShellOutput.ts +28 -0
  229. package/src/components/tools/toolCardHelpers.test.ts +53 -0
  230. package/src/components/tools/toolCards.module.scss +234 -0
  231. package/src/components/workspace/WorkspaceBoard.module.scss +238 -0
  232. package/src/components/workspace/WorkspaceBoard.stories.tsx +240 -0
  233. package/src/components/workspace/WorkspaceBoard.tsx +232 -0
  234. package/src/components/workspace/WorkspaceFormFields.module.scss +79 -0
  235. package/src/components/workspace/WorkspaceFormFields.stories.tsx +133 -0
  236. package/src/components/workspace/WorkspaceFormFields.tsx +185 -0
  237. package/src/context/GrackleContext.ts +28 -0
  238. package/src/context/GrackleContextTypes.ts +64 -0
  239. package/src/context/SidebarContext.tsx +53 -0
  240. package/src/context/ThemeContext.tsx +21 -0
  241. package/src/context/ToastContext.tsx +56 -0
  242. package/src/hooks/types.ts +864 -0
  243. package/src/hooks/useEventSelection.test.ts +204 -0
  244. package/src/hooks/useEventSelection.ts +158 -0
  245. package/src/hooks/useSmartScroll.ts +151 -0
  246. package/src/hooks/useTheme.ts +228 -0
  247. package/src/index.ts +210 -0
  248. package/src/mocks/MockGrackleProvider.tsx +1397 -0
  249. package/src/mocks/mockData.ts +1966 -0
  250. package/src/mocks/mockKnowledgeData.ts +294 -0
  251. package/src/scss.d.ts +12 -0
  252. package/src/styles/global.scss +244 -0
  253. package/src/styles/mixins.scss +278 -0
  254. package/src/styles/prism-theme.scss +148 -0
  255. package/src/styles/theme.scss +1102 -0
  256. package/src/test-utils/storybook-decorators.tsx +50 -0
  257. package/src/test-utils/storybook-helpers.ts +262 -0
  258. package/src/themes.ts +142 -0
  259. package/src/utils/boardColumns.ts +141 -0
  260. package/src/utils/breadcrumbs.test.ts +285 -0
  261. package/src/utils/breadcrumbs.ts +222 -0
  262. package/src/utils/dashboard.test.ts +156 -0
  263. package/src/utils/dashboard.ts +195 -0
  264. package/src/utils/eventContent.test.ts +353 -0
  265. package/src/utils/eventContent.ts +209 -0
  266. package/src/utils/findingCategory.ts +33 -0
  267. package/src/utils/format.ts +27 -0
  268. package/src/utils/iconSize.ts +18 -0
  269. package/src/utils/navigation.ts +205 -0
  270. package/src/utils/route-config.test.ts +128 -0
  271. package/src/utils/scrollUtils.test.ts +65 -0
  272. package/src/utils/scrollUtils.ts +49 -0
  273. package/src/utils/sessionEvents.test.ts +302 -0
  274. package/src/utils/sessionEvents.ts +233 -0
  275. package/src/utils/taskStatus.tsx +137 -0
  276. package/src/utils/time.ts +92 -0
  277. package/tsconfig.json +8 -0
  278. package/vite.config.ts +20 -0
  279. package/vitest.config.ts +10 -0
@@ -0,0 +1,16 @@
1
+ import type { JSX } from "react";
2
+ import { Spinner } from "./Spinner.js";
3
+ import styles from "./SplashScreen.module.scss";
4
+
5
+ /**
6
+ * Full-viewport splash screen displayed while waiting for the server's initial
7
+ * state (e.g. onboarding status). Shows the Grackle logo and a spinner.
8
+ */
9
+ export function SplashScreen(): JSX.Element {
10
+ return (
11
+ <div className={styles.splash} data-testid="splash-screen">
12
+ <img src="/grackle-logo.png" alt="Grackle" className={styles.logo} />
13
+ <Spinner size="xl" label="Loading Grackle" liveRegion />
14
+ </div>
15
+ );
16
+ }
@@ -0,0 +1,166 @@
1
+ @use '../../styles/mixins' as *;
2
+
3
+ // =============================================================================
4
+ // SplitButton — compound button with main action + chevron dropdown
5
+ // =============================================================================
6
+
7
+ .container {
8
+ position: relative;
9
+ display: inline-flex;
10
+ }
11
+
12
+ // --- Shared button base (main + chevron) ------------------------------------
13
+
14
+ %splitBase {
15
+ display: inline-flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ cursor: pointer;
19
+ font-family: var(--font-ui);
20
+ border: none;
21
+ transition: background var(--transition-fast),
22
+ box-shadow var(--transition-fast);
23
+
24
+ &:focus-visible {
25
+ outline: 2px solid var(--ring);
26
+ outline-offset: 2px;
27
+ }
28
+
29
+ &:disabled {
30
+ opacity: 0.64;
31
+ cursor: not-allowed;
32
+ pointer-events: none;
33
+ }
34
+ }
35
+
36
+ .mainButton {
37
+ @extend %splitBase;
38
+ border-radius: var(--radius-md) 0 0 var(--radius-md);
39
+ }
40
+
41
+ .chevronButton {
42
+ @extend %splitBase;
43
+ border-radius: 0 var(--radius-md) var(--radius-md) 0;
44
+ border-left: 1px solid rgba(255, 255, 255, 0.25);
45
+ font-size: 0.6em;
46
+
47
+ // Override size-class padding to keep chevron compact
48
+ &.sm, &.md, &.lg {
49
+ padding-left: var(--space-xs);
50
+ padding-right: var(--space-xs);
51
+ }
52
+ }
53
+
54
+ // --- Sizes ------------------------------------------------------------------
55
+
56
+ .sm {
57
+ font-size: var(--font-size-xs);
58
+ padding: 2px var(--space-sm);
59
+ font-weight: var(--font-weight-medium);
60
+ }
61
+
62
+ .md {
63
+ font-size: var(--font-size-sm);
64
+ padding: var(--space-xs) var(--space-md);
65
+ font-weight: var(--font-weight-bold);
66
+ }
67
+
68
+ .lg {
69
+ font-size: var(--font-size-sm);
70
+ padding: var(--space-sm) var(--space-lg);
71
+ font-weight: var(--font-weight-bold);
72
+ }
73
+
74
+ // --- Variants ---------------------------------------------------------------
75
+
76
+ .primary {
77
+ background: var(--accent-green);
78
+ border: 1px solid var(--accent-green);
79
+ color: #ffffff;
80
+ box-shadow: var(--shadow-xs);
81
+
82
+ &:hover {
83
+ box-shadow: var(--shadow-glow-green);
84
+ }
85
+
86
+ &:active {
87
+ box-shadow: none;
88
+ }
89
+ }
90
+
91
+ .danger {
92
+ background: var(--accent-red);
93
+ border: 1px solid var(--accent-red);
94
+ color: #ffffff;
95
+ box-shadow: var(--shadow-xs);
96
+
97
+ &:hover {
98
+ box-shadow: var(--shadow-glow-red);
99
+ }
100
+
101
+ &:active {
102
+ box-shadow: none;
103
+ }
104
+ }
105
+
106
+ .outline {
107
+ background: var(--bg-surface);
108
+ color: var(--accent-green);
109
+ box-shadow: var(--shadow-xs);
110
+
111
+ &:hover {
112
+ background: var(--bg-overlay);
113
+ }
114
+ }
115
+
116
+ .ghost {
117
+ background: none;
118
+ color: var(--text-secondary);
119
+
120
+ &:hover {
121
+ background: var(--bg-overlay);
122
+ }
123
+ }
124
+
125
+ // --- Dropdown menu ----------------------------------------------------------
126
+
127
+ .dropdown {
128
+ position: absolute;
129
+ top: calc(100% + var(--space-xs));
130
+ right: 0;
131
+ z-index: 1000;
132
+ min-width: 160px;
133
+ background: var(--bg-surface);
134
+ border: 1px solid var(--border-input);
135
+ border-radius: var(--radius-md);
136
+ box-shadow: var(--shadow-md);
137
+ padding: var(--space-xs) 0;
138
+ }
139
+
140
+ .option {
141
+ display: flex;
142
+ flex-direction: column;
143
+ align-items: flex-start;
144
+ width: 100%;
145
+ padding: var(--space-xs) var(--space-md);
146
+ background: none;
147
+ border: none;
148
+ cursor: pointer;
149
+ font-family: var(--font-ui);
150
+ color: var(--text-primary);
151
+ text-align: left;
152
+
153
+ &:hover {
154
+ background: var(--bg-overlay);
155
+ }
156
+ }
157
+
158
+ .optionLabel {
159
+ font-size: var(--font-size-sm);
160
+ font-weight: var(--font-weight-medium);
161
+ }
162
+
163
+ .optionDesc {
164
+ font-size: var(--font-size-xs);
165
+ color: var(--text-secondary);
166
+ }
@@ -0,0 +1,95 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { expect, fn, userEvent, within } from "@storybook/test";
3
+ import { SplitButton } from "./SplitButton.js";
4
+
5
+ const meta: Meta<typeof SplitButton> = {
6
+ component: SplitButton,
7
+ title: "Primitives/Display/SplitButton",
8
+ tags: ["autodocs"],
9
+ args: {
10
+ label: "Stop",
11
+ onClick: fn(),
12
+ options: [
13
+ { label: "Stop", description: "Graceful shutdown", onClick: fn() },
14
+ { label: "Kill", description: "Force kill", onClick: fn() },
15
+ ],
16
+ variant: "danger",
17
+ size: "sm",
18
+ "data-testid": "split-btn",
19
+ },
20
+ };
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ /** Default rendering — main label and chevron visible. */
25
+ export const Default: Story = {
26
+ play: async ({ canvasElement }) => {
27
+ const canvas = within(canvasElement);
28
+ await expect(canvas.getByTestId("split-btn-main")).toBeInTheDocument();
29
+ await expect(canvas.getByTestId("split-btn-main")).toHaveTextContent("Stop");
30
+ await expect(canvas.getByTestId("split-btn-chevron")).toBeInTheDocument();
31
+ // Dropdown should NOT be visible
32
+ await expect(canvas.queryByTestId("split-btn-menu")).not.toBeInTheDocument();
33
+ },
34
+ };
35
+
36
+ /** Clicking the main area fires onClick without opening the dropdown. */
37
+ export const ClickMainAction: Story = {
38
+ play: async ({ canvasElement, args }) => {
39
+ const canvas = within(canvasElement);
40
+ await userEvent.click(canvas.getByTestId("split-btn-main"));
41
+ await expect(args.onClick).toHaveBeenCalledOnce();
42
+ // Dropdown should remain closed
43
+ await expect(canvas.queryByTestId("split-btn-menu")).not.toBeInTheDocument();
44
+ },
45
+ };
46
+
47
+ /** Clicking the chevron opens the dropdown; selecting an option fires callback and closes it. */
48
+ export const OpenAndSelectOption: Story = {
49
+ play: async ({ canvasElement, args }) => {
50
+ const canvas = within(canvasElement);
51
+
52
+ // Open the dropdown
53
+ await userEvent.click(canvas.getByTestId("split-btn-chevron"));
54
+ await expect(canvas.getByTestId("split-btn-menu")).toBeInTheDocument();
55
+
56
+ // Both options visible in the menu
57
+ const menu = within(canvas.getByTestId("split-btn-menu"));
58
+ const options = menu.getAllByRole("button");
59
+ await expect(options).toHaveLength(2);
60
+
61
+ // Click the second option ("Kill")
62
+ await userEvent.click(options[1]);
63
+ await expect(args.options[1].onClick).toHaveBeenCalledOnce();
64
+
65
+ // Dropdown should close
66
+ await expect(canvas.queryByTestId("split-btn-menu")).not.toBeInTheDocument();
67
+ },
68
+ };
69
+
70
+ /** Clicking outside the dropdown closes it. */
71
+ export const CloseOnClickOutside: Story = {
72
+ play: async ({ canvasElement }) => {
73
+ const canvas = within(canvasElement);
74
+
75
+ // Open dropdown
76
+ await userEvent.click(canvas.getByTestId("split-btn-chevron"));
77
+ await expect(canvas.getByTestId("split-btn-menu")).toBeInTheDocument();
78
+
79
+ // Click outside (the canvas root, outside the container)
80
+ await userEvent.click(canvasElement);
81
+ await expect(canvas.queryByTestId("split-btn-menu")).not.toBeInTheDocument();
82
+ },
83
+ };
84
+
85
+ /** Danger variant with primary variant for comparison. */
86
+ export const PrimaryVariant: Story = {
87
+ args: {
88
+ label: "Deploy",
89
+ variant: "primary",
90
+ options: [
91
+ { label: "Deploy", description: "Deploy to staging", onClick: fn() },
92
+ { label: "Deploy prod", description: "Deploy to production", onClick: fn() },
93
+ ],
94
+ },
95
+ };
@@ -0,0 +1,128 @@
1
+ import { useState, useRef, useEffect, type JSX } from "react";
2
+ import { ChevronDown } from "lucide-react";
3
+ import type { ButtonVariant, ButtonSize } from "./Button.js";
4
+ import { ICON_MD } from "../../utils/iconSize.js";
5
+ import styles from "./SplitButton.module.scss";
6
+
7
+ /** A single option in the split button dropdown. */
8
+ export interface SplitButtonOption {
9
+ /** Display label. */
10
+ label: string;
11
+ /** Short description shown below the label. */
12
+ description?: string;
13
+ /** Callback fired when this option is selected. */
14
+ onClick: () => void;
15
+ }
16
+
17
+ /** Props for the {@link SplitButton} component. */
18
+ export interface SplitButtonProps {
19
+ /** Label for the main (default) action. */
20
+ label: string;
21
+ /** Callback for the main action (clicking the label area). */
22
+ onClick: () => void;
23
+ /** Menu options shown when the chevron is clicked. */
24
+ options: SplitButtonOption[];
25
+ /** Visual variant. Defaults to `"primary"`. */
26
+ variant?: ButtonVariant;
27
+ /** Size. Defaults to `"md"`. */
28
+ size?: ButtonSize;
29
+ /** data-testid for the root element. */
30
+ "data-testid"?: string;
31
+ }
32
+
33
+ /**
34
+ * Compound split button with a main action and a chevron dropdown for
35
+ * additional options. The main area fires the default action; the chevron
36
+ * opens a dropdown menu with all available options.
37
+ */
38
+ export function SplitButton({
39
+ label,
40
+ onClick,
41
+ options,
42
+ variant = "primary",
43
+ size = "md",
44
+ "data-testid": testId,
45
+ }: SplitButtonProps): JSX.Element {
46
+ const [open, setOpen] = useState(false);
47
+ const containerRef = useRef<HTMLDivElement>(null);
48
+
49
+ // Close on click outside
50
+ useEffect(() => {
51
+ if (!open) {
52
+ return;
53
+ }
54
+ function handleClickOutside(e: MouseEvent): void {
55
+ if (containerRef.current && e.target instanceof Node && !containerRef.current.contains(e.target)) {
56
+ setOpen(false);
57
+ }
58
+ }
59
+ document.addEventListener("mousedown", handleClickOutside);
60
+ return () => document.removeEventListener("mousedown", handleClickOutside);
61
+ }, [open]);
62
+
63
+ // Close on Escape
64
+ useEffect(() => {
65
+ if (!open) {
66
+ return;
67
+ }
68
+ function handleKeyDown(e: KeyboardEvent): void {
69
+ if (e.key === "Escape") {
70
+ setOpen(false);
71
+ }
72
+ }
73
+ document.addEventListener("keydown", handleKeyDown);
74
+ return () => document.removeEventListener("keydown", handleKeyDown);
75
+ }, [open]);
76
+
77
+ const variantClass = styles[variant] || "";
78
+ const sizeClass = styles[size] || "";
79
+
80
+ const handleMainClick = (): void => {
81
+ if (open) {
82
+ setOpen(false);
83
+ }
84
+ onClick();
85
+ };
86
+
87
+ return (
88
+ <div ref={containerRef} className={styles.container} data-testid={testId}>
89
+ <button
90
+ type="button"
91
+ className={`${styles.mainButton} ${variantClass} ${sizeClass}`}
92
+ onClick={handleMainClick}
93
+ data-testid={testId ? `${testId}-main` : undefined}
94
+ >
95
+ {label}
96
+ </button>
97
+ <button
98
+ type="button"
99
+ className={`${styles.chevronButton} ${variantClass} ${sizeClass}`}
100
+ onClick={() => setOpen((prev) => !prev)}
101
+ aria-label={`More options for ${label}`}
102
+ aria-haspopup="menu"
103
+ aria-expanded={open}
104
+ data-testid={testId ? `${testId}-chevron` : undefined}
105
+ >
106
+ <ChevronDown size={ICON_MD} aria-hidden="true" />
107
+ </button>
108
+ {open && (
109
+ <div className={styles.dropdown} data-testid={testId ? `${testId}-menu` : undefined}>
110
+ {options.map((opt, idx) => (
111
+ <button
112
+ key={idx}
113
+ type="button"
114
+ className={styles.option}
115
+ onClick={() => {
116
+ opt.onClick();
117
+ setOpen(false);
118
+ }}
119
+ >
120
+ <span className={styles.optionLabel}>{opt.label}</span>
121
+ {opt.description && <span className={styles.optionDesc}>{opt.description}</span>}
122
+ </button>
123
+ ))}
124
+ </div>
125
+ )}
126
+ </div>
127
+ );
128
+ }
@@ -0,0 +1,84 @@
1
+ @use '../../styles/mixins' as *;
2
+
3
+ // =============================================================================
4
+ // Tooltip — lightweight hover/focus tooltip
5
+ // =============================================================================
6
+
7
+ $arrow-size: 5px;
8
+ $tooltip-gap: 6px;
9
+
10
+ // Wrapper — inline by default, provides relative context
11
+ .wrapper {
12
+ display: inline-flex;
13
+ position: relative;
14
+ }
15
+
16
+ .wrapperBlock {
17
+ display: flex;
18
+ position: relative;
19
+ }
20
+
21
+ // Tooltip bubble — fixed positioning escapes overflow:hidden ancestors
22
+ .tooltip {
23
+ position: fixed;
24
+ z-index: 500;
25
+
26
+ max-width: 240px;
27
+ padding: var(--space-xs) var(--space-sm);
28
+
29
+ background: var(--bg-elevated);
30
+ border: 1px solid var(--glass-border);
31
+ border-radius: var(--radius-sm);
32
+ box-shadow: var(--shadow-sm);
33
+ backdrop-filter: blur(var(--glass-blur-card));
34
+ -webkit-backdrop-filter: blur(var(--glass-blur-card));
35
+
36
+ color: var(--text-primary);
37
+ font-size: var(--font-size-xs);
38
+ line-height: 1.4;
39
+ white-space: normal;
40
+ overflow-wrap: anywhere;
41
+ pointer-events: none;
42
+
43
+ opacity: 0;
44
+ transition: opacity var(--transition-fast);
45
+
46
+ &.visible {
47
+ opacity: 1;
48
+ }
49
+ }
50
+
51
+ // Arrow — CSS triangle via ::after pseudo-element
52
+ .tooltip::after {
53
+ content: '';
54
+ position: absolute;
55
+ border: $arrow-size solid transparent;
56
+ }
57
+
58
+ .top::after {
59
+ top: 100%;
60
+ left: 50%;
61
+ transform: translateX(-50%);
62
+ border-top-color: var(--bg-elevated);
63
+ }
64
+
65
+ .bottom::after {
66
+ bottom: 100%;
67
+ left: 50%;
68
+ transform: translateX(-50%);
69
+ border-bottom-color: var(--bg-elevated);
70
+ }
71
+
72
+ .left::after {
73
+ left: 100%;
74
+ top: 50%;
75
+ transform: translateY(-50%);
76
+ border-left-color: var(--bg-elevated);
77
+ }
78
+
79
+ .right::after {
80
+ right: 100%;
81
+ top: 50%;
82
+ transform: translateY(-50%);
83
+ border-right-color: var(--bg-elevated);
84
+ }