@astryxdesign/core 0.7.2-canary.fe2c655 → 0.7.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 (297) hide show
  1. package/CHANGELOG.md +156 -2
  2. package/README.md +4 -4
  3. package/dist/AppShell/AppShell.d.ts.map +1 -1
  4. package/dist/AppShell/AppShell.js +40 -1
  5. package/dist/AspectRatio/AspectRatio.d.ts +6 -8
  6. package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
  7. package/dist/AspectRatio/AspectRatio.js +44 -3
  8. package/dist/Avatar/Avatar.d.ts.map +1 -1
  9. package/dist/Avatar/Avatar.js +8 -1
  10. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
  11. package/dist/AvatarGroup/AvatarGroupOverflow.js +4 -1
  12. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  13. package/dist/Breadcrumbs/BreadcrumbItem.js +5 -2
  14. package/dist/Chat/ChatLayoutScrollButton.d.ts.map +1 -1
  15. package/dist/Chat/ChatLayoutScrollButton.js +1 -0
  16. package/dist/CheckboxInput/CheckboxInput.d.ts +1 -1
  17. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  18. package/dist/CheckboxInput/CheckboxInput.js +3 -1
  19. package/dist/CheckboxList/CheckboxList.d.ts +1 -1
  20. package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
  21. package/dist/CheckboxList/CheckboxList.js +6 -2
  22. package/dist/CheckboxList/CheckboxListItem.d.ts +9 -1
  23. package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
  24. package/dist/CheckboxList/CheckboxListItem.js +4 -2
  25. package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
  26. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  27. package/dist/CommandPalette/CommandPaletteInput.js +37 -5
  28. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  29. package/dist/ContextMenu/ContextMenu.js +5 -2
  30. package/dist/Dialog/Dialog.d.ts.map +1 -1
  31. package/dist/Dialog/Dialog.js +20 -8
  32. package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
  33. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  34. package/dist/DropdownMenu/DropdownMenu.js +84 -113
  35. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts +1 -1
  36. package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -0
  37. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  38. package/dist/DropdownMenu/DropdownMenuContext.js +21 -0
  39. package/dist/DropdownMenu/DropdownMenuDivider.d.ts +5 -3
  40. package/dist/DropdownMenu/DropdownMenuDivider.d.ts.map +1 -1
  41. package/dist/DropdownMenu/DropdownMenuDivider.js +7 -3
  42. package/dist/DropdownMenu/DropdownMenuGroup.d.ts +6 -4
  43. package/dist/DropdownMenu/DropdownMenuGroup.d.ts.map +1 -1
  44. package/dist/DropdownMenu/DropdownMenuGroup.js +4 -3
  45. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts +1 -1
  46. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  47. package/dist/DropdownMenu/DropdownMenuSubMenu.js +15 -4
  48. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +24 -0
  49. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -0
  50. package/dist/DropdownMenu/lazyMenuBottomSheet.js +46 -0
  51. package/dist/DropdownMenu/menuRegionStops.d.ts +38 -0
  52. package/dist/DropdownMenu/menuRegionStops.d.ts.map +1 -0
  53. package/dist/DropdownMenu/menuRegionStops.js +131 -0
  54. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  55. package/dist/EmptyState/EmptyState.js +4 -10
  56. package/dist/Field/Field.d.ts +1 -1
  57. package/dist/Field/Field.d.ts.map +1 -1
  58. package/dist/Field/Field.js +8 -4
  59. package/dist/FormLayout/FormLayout.d.ts +5 -4
  60. package/dist/FormLayout/FormLayout.d.ts.map +1 -1
  61. package/dist/FormLayout/FormLayout.js +1 -1
  62. package/dist/FormLayout/FormLayoutContext.d.ts +3 -3
  63. package/dist/FormLayout/FormLayoutContext.js +3 -3
  64. package/dist/Grid/Grid.d.ts +8 -7
  65. package/dist/Grid/Grid.d.ts.map +1 -1
  66. package/dist/Grid/Grid.js +5 -4
  67. package/dist/Grid/GridSpan.d.ts +1 -1
  68. package/dist/Grid/GridSpan.d.ts.map +1 -1
  69. package/dist/Grid/GridSpan.js +1 -0
  70. package/dist/Heading/Heading.d.ts.map +1 -1
  71. package/dist/Heading/Heading.js +4 -2
  72. package/dist/Item/Item.d.ts +6 -2
  73. package/dist/Item/Item.d.ts.map +1 -1
  74. package/dist/Item/Item.js +19 -4
  75. package/dist/List/List.d.ts +46 -19
  76. package/dist/List/List.d.ts.map +1 -1
  77. package/dist/List/List.js +28 -10
  78. package/dist/List/ListContext.d.ts +8 -3
  79. package/dist/List/ListContext.d.ts.map +1 -1
  80. package/dist/List/ListContext.js +7 -2
  81. package/dist/List/ListItem.d.ts +13 -5
  82. package/dist/List/ListItem.d.ts.map +1 -1
  83. package/dist/List/ListItem.js +21 -8
  84. package/dist/List/index.d.ts +1 -1
  85. package/dist/List/index.d.ts.map +1 -1
  86. package/dist/Markdown/Markdown.d.ts.map +1 -1
  87. package/dist/Markdown/Markdown.js +8 -1
  88. package/dist/Markdown/parser.d.ts.map +1 -1
  89. package/dist/Markdown/parser.js +8 -2
  90. package/dist/Markdown/plugins/headingLinks.d.ts.map +1 -1
  91. package/dist/Markdown/plugins/headingLinks.js +9 -1
  92. package/dist/MetadataList/MetadataList.d.ts.map +1 -1
  93. package/dist/MetadataList/MetadataList.js +5 -1
  94. package/dist/MetadataList/MetadataListContext.d.ts +1 -1
  95. package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
  96. package/dist/MobileNav/MobileNav.d.ts +9 -0
  97. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  98. package/dist/MobileNav/MobileNav.js +30 -3
  99. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  100. package/dist/PowerSearch/PowerSearch.js +5 -0
  101. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  102. package/dist/PowerSearch/PowerSearchValueEditor.js +45 -11
  103. package/dist/RadioList/RadioList.d.ts +1 -1
  104. package/dist/RadioList/RadioList.d.ts.map +1 -1
  105. package/dist/RadioList/RadioList.js +6 -2
  106. package/dist/RadioList/RadioListItem.d.ts +9 -1
  107. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  108. package/dist/RadioList/RadioListItem.js +2 -0
  109. package/dist/SideNav/SideNavItem.d.ts +8 -1
  110. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  111. package/dist/SideNav/SideNavItem.js +76 -10
  112. package/dist/Text/Text.d.ts.map +1 -1
  113. package/dist/Text/Text.js +4 -2
  114. package/dist/ToggleButton/ToggleButton.d.ts +3 -2
  115. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  116. package/dist/ToggleButton/ToggleButton.js +12 -1
  117. package/dist/Token/Token.js +1 -1
  118. package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
  119. package/dist/TopNav/TopNavMegaMenu.js +5 -3
  120. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  121. package/dist/TopNav/TopNavMenu.js +5 -3
  122. package/dist/TreeList/TreeList.d.ts.map +1 -1
  123. package/dist/TreeList/TreeList.js +1 -0
  124. package/dist/TreeList/TreeListBranches.d.ts.map +1 -1
  125. package/dist/TreeList/TreeListBranches.js +2 -2
  126. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  127. package/dist/TreeList/TreeListItem.js +57 -9
  128. package/dist/astryx.css +27 -4
  129. package/dist/hooks/useMenuHover.d.ts.map +1 -1
  130. package/dist/hooks/useMenuHover.js +18 -13
  131. package/dist/reset.a11y.chromium.spec.js +50 -1
  132. package/dist/utils/plainDate.d.ts.map +1 -1
  133. package/dist/utils/plainDate.js +15 -9
  134. package/docs.mjs +4 -4
  135. package/package.json +4 -4
  136. package/scripts/agent-doc-state.mjs +66 -6
  137. package/scripts/postinstall.mjs +44 -3
  138. package/src/AppShell/AppShell.tsx +45 -1
  139. package/src/AspectRatio/AspectRatio.test.tsx +44 -43
  140. package/src/AspectRatio/AspectRatio.tsx +38 -18
  141. package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +157 -0
  142. package/src/Avatar/Avatar.doc.mjs +5 -3
  143. package/src/Avatar/Avatar.tsx +11 -2
  144. package/src/AvatarGroup/AvatarGroup.doc.mjs +3 -2
  145. package/src/AvatarGroup/AvatarGroupOverflow.test.tsx +24 -1
  146. package/src/AvatarGroup/AvatarGroupOverflow.tsx +2 -0
  147. package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
  148. package/src/Breadcrumbs/Breadcrumbs.test.tsx +30 -1
  149. package/src/Card/Card.doc.mjs +1 -1
  150. package/src/Chat/ChatLayoutScrollButton.test.tsx +13 -0
  151. package/src/Chat/ChatLayoutScrollButton.tsx +4 -2
  152. package/src/Chat/__tests__/ChatLayoutScrollButton.a11y.chromium.spec.ts +64 -19
  153. package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +3 -1
  154. package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
  155. package/src/CheckboxInput/CheckboxInput.tsx +3 -1
  156. package/src/CheckboxList/CheckboxList.fr10.test.tsx +29 -2
  157. package/src/CheckboxList/CheckboxList.test.tsx +22 -0
  158. package/src/CheckboxList/CheckboxList.tsx +4 -1
  159. package/src/CheckboxList/CheckboxListItem.doc.mjs +16 -0
  160. package/src/CheckboxList/CheckboxListItem.tsx +10 -0
  161. package/src/Code/Code.doc.mjs +1 -0
  162. package/src/CommandPalette/CommandPalette.doc.mjs +2 -0
  163. package/src/CommandPalette/CommandPaletteInput.test.tsx +53 -4
  164. package/src/CommandPalette/CommandPaletteInput.tsx +33 -3
  165. package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +335 -0
  166. package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +292 -0
  167. package/src/ContextMenu/ContextMenu.doc.mjs +2 -3
  168. package/src/ContextMenu/ContextMenu.test.tsx +12 -2
  169. package/src/ContextMenu/ContextMenu.tsx +4 -1
  170. package/src/ContextMenu/__tests__/ContextMenuAudit.a11y.chromium.spec.ts +438 -0
  171. package/src/Dialog/Dialog.test.tsx +46 -0
  172. package/src/Dialog/Dialog.tsx +20 -7
  173. package/src/Dialog/__tests__/Dialog.a11y.known-failures.ts +0 -14
  174. package/src/Drawer/Drawer.doc.mjs +1 -0
  175. package/src/DropdownMenu/DropdownMenu.ssr.test.tsx +57 -0
  176. package/src/DropdownMenu/DropdownMenu.test.tsx +79 -6
  177. package/src/DropdownMenu/DropdownMenu.tsx +88 -144
  178. package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +1 -1
  179. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +1 -1
  180. package/src/DropdownMenu/DropdownMenuContext.tsx +24 -0
  181. package/src/DropdownMenu/DropdownMenuDivider.doc.mjs +2 -2
  182. package/src/DropdownMenu/DropdownMenuDivider.spec.md +192 -0
  183. package/src/DropdownMenu/DropdownMenuDivider.tsx +9 -5
  184. package/src/DropdownMenu/DropdownMenuGroup.doc.mjs +169 -10
  185. package/src/DropdownMenu/DropdownMenuGroup.tsx +6 -4
  186. package/src/DropdownMenu/DropdownMenuLazySheet.test.tsx +126 -0
  187. package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +1 -1
  188. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +1 -1
  189. package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +185 -0
  190. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +17 -3
  191. package/src/DropdownMenu/__tests__/DropdownMenuDividerAudit.a11y.chromium.spec.ts +280 -0
  192. package/src/DropdownMenu/__tests__/DropdownMenuGroupAudit.a11y.chromium.spec.ts +334 -0
  193. package/src/DropdownMenu/__tests__/warmMenuBottomSheet.tsx +43 -0
  194. package/src/DropdownMenu/lazyMenuBottomSheet.ts +71 -0
  195. package/src/DropdownMenu/menuRegionStops.ts +167 -0
  196. package/src/EmptyState/EmptyState.doc.mjs +3 -2
  197. package/src/EmptyState/EmptyState.spec.md +189 -0
  198. package/src/EmptyState/EmptyState.test.tsx +74 -3
  199. package/src/EmptyState/EmptyState.tsx +4 -8
  200. package/src/Field/Field.doc.mjs +14 -8
  201. package/src/Field/Field.spec.md +217 -0
  202. package/src/Field/Field.test.tsx +60 -2
  203. package/src/Field/Field.tsx +17 -8
  204. package/src/Field/FieldLabel.doc.mjs +133 -26
  205. package/src/Field/FieldLabel.spec.md +172 -0
  206. package/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts +296 -0
  207. package/src/FormLayout/FormLayout.doc.mjs +6 -3
  208. package/src/FormLayout/FormLayout.spec.md +192 -0
  209. package/src/FormLayout/FormLayout.test.tsx +15 -0
  210. package/src/FormLayout/FormLayout.tsx +7 -6
  211. package/src/FormLayout/FormLayoutContext.ts +3 -3
  212. package/src/Grid/Grid.doc.mjs +7 -1
  213. package/src/Grid/Grid.spec.md +93 -113
  214. package/src/Grid/Grid.test.tsx +22 -0
  215. package/src/Grid/Grid.tsx +10 -9
  216. package/src/Grid/GridSpan.doc.mjs +3 -3
  217. package/src/Grid/GridSpan.tsx +4 -1
  218. package/src/Heading/Heading.test.tsx +57 -0
  219. package/src/Heading/Heading.tsx +6 -2
  220. package/src/Icon/Icon.doc.mjs +36 -0
  221. package/src/Indicator/Indicator.doc.mjs +3 -3
  222. package/src/Item/Item.doc.mjs +12 -8
  223. package/src/Item/Item.test.tsx +61 -0
  224. package/src/Item/Item.tsx +40 -4
  225. package/src/Layout/LayoutHeader.doc.mjs +5 -0
  226. package/src/List/List.doc.mjs +14 -1
  227. package/src/List/List.spec.md +129 -77
  228. package/src/List/List.test.tsx +163 -94
  229. package/src/List/List.tsx +74 -18
  230. package/src/List/ListContext.tsx +9 -3
  231. package/src/List/ListItem.doc.mjs +16 -0
  232. package/src/List/ListItem.tsx +56 -27
  233. package/src/List/index.ts +1 -1
  234. package/src/Markdown/Markdown.tsx +14 -1
  235. package/src/Markdown/parser.ts +8 -2
  236. package/src/Markdown/plugins/headingLinks.ts +9 -1
  237. package/src/MetadataList/MetadataList.doc.mjs +3 -3
  238. package/src/MetadataList/MetadataList.test.tsx +38 -0
  239. package/src/MetadataList/MetadataList.tsx +8 -1
  240. package/src/MetadataList/MetadataListContext.tsx +1 -1
  241. package/src/MobileNav/MobileNav.tsx +30 -3
  242. package/src/MobileNav/MobileNavCloseEdgeCases.test.tsx +173 -15
  243. package/src/MoreMenu/MoreMenu.test.tsx +5 -1
  244. package/src/PowerSearch/PowerSearch.test.tsx +62 -0
  245. package/src/PowerSearch/PowerSearch.tsx +9 -0
  246. package/src/PowerSearch/PowerSearchValueEditor.test.tsx +71 -0
  247. package/src/PowerSearch/PowerSearchValueEditor.tsx +45 -0
  248. package/src/ProgressBar/ProgressBar.doc.mjs +1 -0
  249. package/src/RadioList/RadioList.fr10.test.tsx +45 -2
  250. package/src/RadioList/RadioList.test.tsx +22 -0
  251. package/src/RadioList/RadioList.tsx +4 -1
  252. package/src/RadioList/RadioListItem.doc.mjs +16 -0
  253. package/src/RadioList/RadioListItem.tsx +10 -1
  254. package/src/Resizable/useResizable.doc.mjs +2 -0
  255. package/src/ScrollableArea/ScrollableArea.doc.mjs +1 -1
  256. package/src/SideNav/SideNav.spec.md +227 -0
  257. package/src/SideNav/SideNav.test.tsx +220 -0
  258. package/src/SideNav/SideNavItem.doc.mjs +2 -2
  259. package/src/SideNav/SideNavItem.tsx +99 -17
  260. package/src/Slider/Slider.spec.md +39 -18
  261. package/src/Spinner/Spinner.doc.mjs +1 -1
  262. package/src/TabList/TabList.spec.md +57 -44
  263. package/src/Table/Table.spec.md +6 -1
  264. package/src/Table/plugins/activation/useTableActivation.spec.md +254 -0
  265. package/src/Text/Text.test.tsx +57 -0
  266. package/src/Text/Text.tsx +6 -2
  267. package/src/TimeInput/TimeInput.fr10.test.tsx +15 -0
  268. package/src/Timestamp/Timestamp.doc.mjs +1 -1
  269. package/src/ToggleButton/ToggleButton.test.tsx +95 -0
  270. package/src/ToggleButton/ToggleButton.tsx +12 -1
  271. package/src/ToggleButton/ToggleButtonGroup.doc.mjs +4 -0
  272. package/src/Token/Token.tsx +1 -1
  273. package/src/Token/__tests__/TokenRemoveTarget.a11y.chromium.spec.ts +86 -0
  274. package/src/Toolbar/Toolbar.test.tsx +0 -8
  275. package/src/Toolbar/__tests__/Toolbar.a11y.chromium.spec.ts +163 -0
  276. package/src/Toolbar/__tests__/Toolbar.a11y.renders.tsx +63 -0
  277. package/src/Toolbar/__tests__/Toolbar.a11y.states.ts +142 -0
  278. package/src/Toolbar/__tests__/Toolbar.a11y.test.tsx +126 -0
  279. package/src/TopNav/TopNavMegaMenu.test.tsx +47 -0
  280. package/src/TopNav/TopNavMegaMenu.tsx +9 -3
  281. package/src/TopNav/TopNavMenu.test.tsx +46 -1
  282. package/src/TopNav/TopNavMenu.tsx +13 -3
  283. package/src/TreeList/TreeList.doc.mjs +1 -0
  284. package/src/TreeList/TreeList.test.tsx +327 -6
  285. package/src/TreeList/TreeList.tsx +5 -1
  286. package/src/TreeList/TreeListBranches.tsx +6 -0
  287. package/src/TreeList/TreeListItem.tsx +88 -13
  288. package/src/docPropLiterals.test.ts +36 -10
  289. package/src/hooks/useMenuHover.ts +18 -13
  290. package/src/postinstall.test.mjs +79 -0
  291. package/src/reset.a11y.chromium.spec.ts +52 -1
  292. package/src/reset.css +9 -29
  293. package/src/reset.test.ts +11 -0
  294. package/src/theme/derivedVarRegistry.test.ts +7 -0
  295. package/src/unicodePropertyEscapes.source-build.test.mjs +69 -0
  296. package/src/utils/plainDate.test.ts +37 -1
  297. package/src/utils/plainDate.ts +15 -5
@@ -13,7 +13,7 @@
13
13
  * - /packages/cli/assets/templates/blocks/components/CommandPalette/ (showcase blocks)
14
14
  */
15
15
 
16
- import {useCallback, useEffect, useRef, type ReactNode} from 'react';
16
+ import {useCallback, useEffect, useRef, useState, type ReactNode} from 'react';
17
17
  import * as stylex from '@stylexjs/stylex';
18
18
  import {Icon} from '../Icon';
19
19
  import {Spinner} from '../Spinner';
@@ -28,6 +28,11 @@ import {useCommandPaletteContext} from './CommandPaletteContext';
28
28
  import {useDialogContext} from '../Dialog/DialogContext';
29
29
  import type {BaseProps} from '../BaseProps';
30
30
  import {themeProps} from '../utils/themeProps';
31
+ import {focusOutlineProps} from '../utils/focusOutline.stylex';
32
+ import {
33
+ getInteractionModality,
34
+ useInteractionModalityTracking,
35
+ } from '../utils/interactionModality';
31
36
  import {useTranslator} from '../i18n';
32
37
 
33
38
  import {useMergedRefs} from '../hooks/useMergedRefs';
@@ -71,7 +76,6 @@ const styles = stylex.create({
71
76
  minWidth: 0,
72
77
  borderWidth: 0,
73
78
  borderStyle: 'none',
74
- outline: 'none',
75
79
  backgroundColor: 'transparent',
76
80
  color: colorVars['--color-text-primary'],
77
81
  fontFamily: typographyVars['--font-family-body'],
@@ -169,6 +173,8 @@ export function CommandPaletteInput({
169
173
  endContent,
170
174
  onChange,
171
175
  onKeyDown,
176
+ onFocus,
177
+ onBlur,
172
178
  ref,
173
179
  xstyle,
174
180
  className,
@@ -184,6 +190,26 @@ export function CommandPaletteInput({
184
190
  const hasListbox = ctx ? ctx.selectableItems.length > 0 : true;
185
191
  const dialogContext = useDialogContext();
186
192
  const inputRef = useRef<HTMLInputElement>(null);
193
+ const [isKeyboardFocus, setIsKeyboardFocus] = useState(false);
194
+
195
+ // Text-entry controls match :focus-visible after pointer focus in Chromium.
196
+ // Keep the shared selector, but narrow its ring to focus acquired through
197
+ // keyboard navigation so a click or pointer-opened palette stays unringed.
198
+ useInteractionModalityTracking();
199
+ const handleFocus = useCallback(
200
+ (event: React.FocusEvent<HTMLInputElement>) => {
201
+ setIsKeyboardFocus(getInteractionModality() === 'keyboard');
202
+ onFocus?.(event);
203
+ },
204
+ [onFocus],
205
+ );
206
+ const handleBlur = useCallback(
207
+ (event: React.FocusEvent<HTMLInputElement>) => {
208
+ setIsKeyboardFocus(false);
209
+ onBlur?.(event);
210
+ },
211
+ [onBlur],
212
+ );
187
213
 
188
214
  // Use context values as fallback
189
215
  const value = controlledValue ?? ctx?.search;
@@ -259,7 +285,9 @@ export function CommandPaletteInput({
259
285
  <input
260
286
  {...props}
261
287
  ref={useMergedRefs(ref, inputRef)}
262
- {...stylex.props(styles.input)}
288
+ {...(isKeyboardFocus
289
+ ? focusOutlineProps.focusVisible(styles.input)
290
+ : focusOutlineProps.suppressed(styles.input))}
263
291
  type="text"
264
292
  role={ctx ? 'combobox' : standaloneRole}
265
293
  aria-expanded={
@@ -300,6 +328,8 @@ export function CommandPaletteInput({
300
328
  onChange?.(e);
301
329
  }}
302
330
  onKeyDown={handleKeyDown}
331
+ onFocus={handleFocus}
332
+ onBlur={handleBlur}
303
333
  />
304
334
  {(ctx?.isBusy || hasEndContent) && (
305
335
  <span {...stylex.props(styles.end)}>
@@ -0,0 +1,335 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file CommandPaletteInputAudit.a11y.chromium.spec.ts
5
+ * @input Exact-head CommandPaletteInput stories across semantic, theme, direction, viewport, and focus states
6
+ * @output Screenshots and fail-closed sensor receipts for the CommandPaletteInput whole-component audit
7
+ * @position Component-owned Night Watch browser evidence; CI runs it only for a CommandPaletteInput audit pull request
8
+ */
9
+
10
+ import {createHash} from 'node:crypto';
11
+ import {execFileSync} from 'node:child_process';
12
+ import * as fs from 'node:fs';
13
+ import * as path from 'node:path';
14
+ import {expect, test, type Locator, type Page} from '@playwright/test';
15
+ import {holdMotionStill} from '@astryxdesign/a11y-spec/chromium';
16
+ import {
17
+ DEFAULT_STORYBOOK_DIR,
18
+ serveStorybook,
19
+ type StaticServer,
20
+ } from '@astryxdesign/a11y-spec/storybook';
21
+
22
+ const OUTPUT = path.resolve('command-palette-input-audit-evidence');
23
+ const WIDE = {width: 1024, height: 768};
24
+ const NARROW = {width: 320, height: 720};
25
+
26
+ type Mode = 'light' | 'dark';
27
+ type Direction = 'ltr' | 'rtl';
28
+ type Theme = 'neutral' | 'butter';
29
+ type Story = 'standalone' | 'popup-context' | 'aggregate-matrix';
30
+ type State = 'rest' | 'keyboard-focus' | 'pointer-focus' | 'context-matrix';
31
+
32
+ type AuditReceipt = {
33
+ passed: boolean;
34
+ expected: Record<string, unknown>;
35
+ };
36
+
37
+ type AuditCase = {
38
+ key: string;
39
+ story: Story;
40
+ mode: Mode;
41
+ direction: Direction;
42
+ theme: Theme;
43
+ state: State;
44
+ viewport: {width: number; height: number};
45
+ };
46
+
47
+ const cases: AuditCase[] = [];
48
+ function addPair(
49
+ key: string,
50
+ options: Partial<Omit<AuditCase, 'key' | 'mode'>> = {},
51
+ ) {
52
+ for (const mode of ['light', 'dark'] as const) {
53
+ cases.push({
54
+ key: `${key}-${mode}`,
55
+ story: options.story ?? 'standalone',
56
+ mode,
57
+ direction: options.direction ?? 'ltr',
58
+ theme: options.theme ?? 'neutral',
59
+ state: options.state ?? 'rest',
60
+ viewport: options.viewport ?? WIDE,
61
+ });
62
+ }
63
+ }
64
+
65
+ addPair('standalone-rest');
66
+ addPair('standalone-keyboard-focus', {state: 'keyboard-focus'});
67
+ addPair('standalone-pointer-focus', {state: 'pointer-focus'});
68
+ addPair('standalone-keyboard-focus-custom-theme', {
69
+ state: 'keyboard-focus',
70
+ theme: 'butter',
71
+ });
72
+ addPair('standalone-keyboard-focus-rtl', {
73
+ state: 'keyboard-focus',
74
+ direction: 'rtl',
75
+ });
76
+ addPair('standalone-keyboard-focus-narrow', {
77
+ state: 'keyboard-focus',
78
+ viewport: NARROW,
79
+ });
80
+ addPair('popup-rest', {story: 'popup-context'});
81
+ addPair('popup-keyboard-focus', {
82
+ story: 'popup-context',
83
+ state: 'keyboard-focus',
84
+ });
85
+ addPair('popup-pointer-focus', {
86
+ story: 'popup-context',
87
+ state: 'pointer-focus',
88
+ });
89
+ addPair('context-matrix', {
90
+ story: 'aggregate-matrix',
91
+ state: 'context-matrix',
92
+ });
93
+
94
+ test.describe.configure({mode: 'serial', retries: 0});
95
+ let server: StaticServer;
96
+ let checkoutSha: string;
97
+ let storybookSha: string;
98
+
99
+ function storyId(item: AuditCase) {
100
+ return item.story === 'aggregate-matrix'
101
+ ? 'core-commandpalette--audit-matrix'
102
+ : `core-commandpaletteinput--${item.story}`;
103
+ }
104
+
105
+ function storyUrl(item: AuditCase) {
106
+ return `${server.origin}/iframe.html?id=${storyId(item)}&viewMode=story&globals=colorMode:${item.mode};astryxTheme:${item.theme};direction:${item.direction}`;
107
+ }
108
+
109
+ async function settle(page: Page) {
110
+ await holdMotionStill(page);
111
+ await page.evaluate(async () => document.fonts.ready);
112
+ await page.waitForTimeout(40);
113
+ }
114
+
115
+ async function focusFromKeyboard(page: Page, input: Locator) {
116
+ await page.keyboard.press('Tab');
117
+ if (!(await input.evaluate(element => element === document.activeElement))) {
118
+ await input.focus();
119
+ }
120
+ await expect(input).toBeFocused();
121
+ expect(
122
+ await input.evaluate(element => element.matches(':focus-visible')),
123
+ ).toBe(true);
124
+ }
125
+
126
+ async function focusFromPointer(input: Locator) {
127
+ // PopupContext is already focused by Dialog's open-time focus management.
128
+ // Move focus away first so the click acquires focus and runs the component's
129
+ // pointer-modality gate rather than merely clicking an existing keyboard focus.
130
+ await input.blur();
131
+ await expect(input).not.toBeFocused();
132
+ await input.click();
133
+ await expect(input).toBeFocused();
134
+ // CSS Selectors 4 deliberately keeps text-entry controls focus-visible after
135
+ // a pointer click. The component's shared modality gate must still withhold
136
+ // its keyboard-only ring.
137
+ expect(
138
+ await input.evaluate(element => element.matches(':focus-visible')),
139
+ ).toBe(true);
140
+ }
141
+
142
+ test.beforeAll(async () => {
143
+ fs.rmSync(OUTPUT, {recursive: true, force: true});
144
+ fs.mkdirSync(OUTPUT, {recursive: true});
145
+ checkoutSha = execFileSync('git', ['rev-parse', 'HEAD'], {
146
+ encoding: 'utf8',
147
+ }).trim();
148
+ const expected = process.env.ASTRYX_HEAD_SHA;
149
+ if (expected && expected !== checkoutSha) {
150
+ throw new Error(
151
+ `checkout ${checkoutSha} does not match expected head ${expected}`,
152
+ );
153
+ }
154
+ server = await serveStorybook(
155
+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
156
+ );
157
+ const response = await fetch(`${server.origin}/astryx-build-sha.txt`);
158
+ if (!response.ok) {
159
+ throw new Error(`Storybook build has no SHA stamp (${response.status})`);
160
+ }
161
+ storybookSha = (await response.text()).trim();
162
+ if (storybookSha !== checkoutSha) {
163
+ throw new Error(
164
+ `Storybook ${storybookSha} does not match checkout ${checkoutSha}`,
165
+ );
166
+ }
167
+ });
168
+
169
+ test.afterAll(async () => {
170
+ await server?.close();
171
+ });
172
+
173
+ for (const item of cases) {
174
+ test(item.key, async ({browser}) => {
175
+ const context = await browser.newContext({
176
+ viewport: item.viewport,
177
+ colorScheme: item.mode,
178
+ reducedMotion: 'reduce',
179
+ });
180
+ const page = await context.newPage();
181
+ const pageErrors: string[] = [];
182
+ page.on('pageerror', error => pageErrors.push(String(error)));
183
+ await page.goto(storyUrl(item), {waitUntil: 'load'});
184
+ await page.locator('#storybook-root').waitFor();
185
+
186
+ let input: Locator;
187
+ if (item.story === 'aggregate-matrix') {
188
+ const matrix = page.locator('[data-command-palette-audit-matrix]');
189
+ await expect(matrix).toBeVisible();
190
+ await expect(matrix.getByRole('combobox')).toHaveCount(3);
191
+ await expect(matrix.locator('.astryx-spinner')).toHaveCount(1);
192
+ await expect(matrix.getByRole('option')).not.toHaveCount(0);
193
+ input = matrix
194
+ .getByRole('region', {name: 'Grouped command palette'})
195
+ .getByRole('combobox');
196
+ } else if (item.story === 'popup-context') {
197
+ input = page.getByRole('combobox', {name: 'Search commands'});
198
+ await expect(input).toHaveAttribute('aria-expanded', 'true');
199
+ await expect(input).toHaveAttribute('aria-controls', /.+/);
200
+ } else {
201
+ input = page.getByRole('searchbox', {name: 'Search documentation'});
202
+ await expect(input).not.toHaveAttribute('aria-expanded');
203
+ await expect(input).not.toHaveAttribute('aria-controls');
204
+ await expect(page.getByTestId('input-end-content')).toBeVisible();
205
+ }
206
+
207
+ await expect(input).toBeVisible();
208
+ if (item.state === 'keyboard-focus') {
209
+ await focusFromKeyboard(page, input);
210
+ } else if (item.state === 'pointer-focus') {
211
+ await focusFromPointer(input);
212
+ }
213
+ await settle(page);
214
+
215
+ const inputBox = await input.boundingBox();
216
+ if (inputBox == null) {
217
+ throw new Error(`${item.key}: the visible input has no geometry`);
218
+ }
219
+ const observed = await page.evaluate(() => ({
220
+ theme: document
221
+ .querySelector('[data-astryx-theme]')
222
+ ?.getAttribute('data-astryx-theme'),
223
+ mode: document.documentElement.getAttribute('data-theme'),
224
+ direction: getComputedStyle(
225
+ document.querySelector('.astryx-command-palette-input') as HTMLElement,
226
+ ).direction,
227
+ viewport: {width: innerWidth, height: innerHeight},
228
+ reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,
229
+ horizontalOverflow: document.documentElement.scrollWidth > innerWidth + 1,
230
+ fonts: document.fonts.status,
231
+ }));
232
+ const focus = await input.evaluate(element => {
233
+ const style = getComputedStyle(element);
234
+ return {
235
+ focused: element === document.activeElement,
236
+ focusVisible: element.matches(':focus-visible'),
237
+ outlineWidth: style.outlineWidth,
238
+ outlineStyle: style.outlineStyle,
239
+ outlineColor: style.outlineColor,
240
+ outlineOffset: style.outlineOffset,
241
+ };
242
+ });
243
+ const ringVisible =
244
+ focus.outlineStyle !== 'none' &&
245
+ Number.parseFloat(focus.outlineWidth) >= 2;
246
+ const focusIndicatorPass =
247
+ item.state === 'keyboard-focus'
248
+ ? focus.focused && focus.focusVisible && ringVisible
249
+ : item.state === 'pointer-focus'
250
+ ? focus.focused && focus.focusVisible && !ringVisible
251
+ : true;
252
+
253
+ const png = await page.screenshot({animations: 'disabled', fullPage: true});
254
+ const image = `${item.key}.png`;
255
+ const receipt = {
256
+ schemaVersion: 1,
257
+ expected: {
258
+ build: checkoutSha,
259
+ storyId: storyId(item),
260
+ mode: item.mode,
261
+ direction: item.direction,
262
+ theme: item.theme,
263
+ state: item.state,
264
+ viewport: item.viewport,
265
+ },
266
+ observed: {
267
+ build: storybookSha,
268
+ ...observed,
269
+ role: await input.getAttribute('role'),
270
+ name: await input.getAttribute('aria-label'),
271
+ geometry: inputBox,
272
+ focus,
273
+ pageErrors,
274
+ },
275
+ image: {
276
+ file: image,
277
+ sha256: createHash('sha256').update(png).digest('hex'),
278
+ width: png.readUInt32BE(16),
279
+ height: png.readUInt32BE(20),
280
+ },
281
+ checks: {focusIndicatorPass},
282
+ passed:
283
+ storybookSha === checkoutSha &&
284
+ pageErrors.length === 0 &&
285
+ observed.theme === item.theme &&
286
+ observed.mode === item.mode &&
287
+ observed.direction === item.direction &&
288
+ observed.viewport.width === item.viewport.width &&
289
+ observed.viewport.height === item.viewport.height &&
290
+ observed.reducedMotion &&
291
+ !observed.horizontalOverflow &&
292
+ observed.fonts === 'loaded' &&
293
+ focusIndicatorPass,
294
+ };
295
+ fs.writeFileSync(path.join(OUTPUT, image), png);
296
+ fs.writeFileSync(
297
+ path.join(OUTPUT, `${item.key}.sensors.json`),
298
+ `${JSON.stringify(receipt, null, 2)}\n`,
299
+ );
300
+
301
+ await context.close();
302
+ });
303
+ }
304
+
305
+ test('manifest is complete', async () => {
306
+ const receiptFiles = fs
307
+ .readdirSync(OUTPUT)
308
+ .filter(file => file.endsWith('.sensors.json'));
309
+ const receipts = receiptFiles.map(
310
+ (file): AuditReceipt =>
311
+ JSON.parse(
312
+ fs.readFileSync(path.join(OUTPUT, file), 'utf8'),
313
+ ) as AuditReceipt,
314
+ );
315
+ const manifest = {
316
+ schemaVersion: 1,
317
+ component: 'core/CommandPaletteInput',
318
+ build: checkoutSha,
319
+ frames: cases.map(item => ({
320
+ key: item.key,
321
+ image: `${item.key}.png`,
322
+ receipt: `${item.key}.sensors.json`,
323
+ })),
324
+ };
325
+ fs.writeFileSync(
326
+ path.join(OUTPUT, 'manifest.json'),
327
+ `${JSON.stringify(manifest, null, 2)}\n`,
328
+ );
329
+ expect(receiptFiles).toHaveLength(cases.length);
330
+ expect(
331
+ receipts
332
+ .filter(receipt => !receipt.passed)
333
+ .map(receipt => receipt.expected),
334
+ ).toEqual([]);
335
+ });
@@ -0,0 +1,292 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file CommandPaletteItemAudit.a11y.chromium.spec.ts
5
+ * @input Exact-head CommandPaletteItem stories across semantics, states, themes, direction, and viewport sizes
6
+ * @output Screenshots and fail-closed sensor receipts for the CommandPaletteItem whole-component audit
7
+ * @position Component-owned Night Watch browser evidence; CI runs it only for a CommandPaletteItem audit pull request
8
+ */
9
+
10
+ import {createHash} from 'node:crypto';
11
+ import {execFileSync} from 'node:child_process';
12
+ import * as fs from 'node:fs';
13
+ import * as path from 'node:path';
14
+ import {expect, test, type Page} from '@playwright/test';
15
+ import {holdMotionStill} from '@astryxdesign/a11y-spec/chromium';
16
+ import {
17
+ DEFAULT_STORYBOOK_DIR,
18
+ serveStorybook,
19
+ type StaticServer,
20
+ } from '@astryxdesign/a11y-spec/storybook';
21
+
22
+ const OUTPUT = path.resolve('command-palette-item-audit-evidence');
23
+ const WIDE = {width: 1024, height: 768};
24
+ const NARROW = {width: 320, height: 720};
25
+
26
+ type Mode = 'light' | 'dark';
27
+ type Direction = 'ltr' | 'rtl';
28
+ type Theme = 'neutral' | 'butter';
29
+ type Story = 'states' | 'combined-and-long';
30
+ type State = 'rest' | 'hover';
31
+
32
+ type AuditCase = {
33
+ key: string;
34
+ story: Story;
35
+ mode: Mode;
36
+ direction: Direction;
37
+ theme: Theme;
38
+ state: State;
39
+ viewport: {width: number; height: number};
40
+ };
41
+
42
+ type AuditReceipt = {
43
+ passed: boolean;
44
+ expected: Record<string, unknown>;
45
+ };
46
+
47
+ const cases: AuditCase[] = [];
48
+ function addPair(
49
+ key: string,
50
+ options: Partial<Omit<AuditCase, 'key' | 'mode'>> = {},
51
+ ) {
52
+ for (const mode of ['light', 'dark'] as const) {
53
+ cases.push({
54
+ key: `${key}-${mode}`,
55
+ story: options.story ?? 'states',
56
+ mode,
57
+ direction: options.direction ?? 'ltr',
58
+ theme: options.theme ?? 'neutral',
59
+ state: options.state ?? 'rest',
60
+ viewport: options.viewport ?? WIDE,
61
+ });
62
+ }
63
+ }
64
+
65
+ addPair('states-rest');
66
+ addPair('states-hover', {state: 'hover'});
67
+ addPair('states-custom-theme', {theme: 'butter'});
68
+ addPair('states-rtl', {direction: 'rtl'});
69
+ addPair('states-narrow', {viewport: NARROW});
70
+ addPair('combined-rest', {story: 'combined-and-long'});
71
+ addPair('combined-custom-theme', {
72
+ story: 'combined-and-long',
73
+ theme: 'butter',
74
+ });
75
+ addPair('combined-narrow', {
76
+ story: 'combined-and-long',
77
+ viewport: NARROW,
78
+ });
79
+
80
+ test.describe.configure({mode: 'serial', retries: 0});
81
+ let server: StaticServer;
82
+ let checkoutSha: string;
83
+ let storybookSha: string;
84
+
85
+ function storyId(item: AuditCase) {
86
+ return `core-commandpaletteitem--${item.story}`;
87
+ }
88
+
89
+ function storyUrl(item: AuditCase) {
90
+ return `${server.origin}/iframe.html?id=${storyId(item)}&viewMode=story&globals=colorMode:${item.mode};astryxTheme:${item.theme};direction:${item.direction}`;
91
+ }
92
+
93
+ async function settle(page: Page) {
94
+ await holdMotionStill(page);
95
+ await page.evaluate(async () => document.fonts.ready);
96
+ await page.waitForTimeout(40);
97
+ }
98
+
99
+ test.beforeAll(async () => {
100
+ fs.rmSync(OUTPUT, {recursive: true, force: true});
101
+ fs.mkdirSync(OUTPUT, {recursive: true});
102
+ checkoutSha = execFileSync('git', ['rev-parse', 'HEAD'], {
103
+ encoding: 'utf8',
104
+ }).trim();
105
+ const expected = process.env.ASTRYX_HEAD_SHA;
106
+ if (expected && expected !== checkoutSha) {
107
+ throw new Error(
108
+ `checkout ${checkoutSha} does not match expected head ${expected}`,
109
+ );
110
+ }
111
+ server = await serveStorybook(
112
+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
113
+ );
114
+ const response = await fetch(`${server.origin}/astryx-build-sha.txt`);
115
+ if (!response.ok) {
116
+ throw new Error(`Storybook build has no SHA stamp (${response.status})`);
117
+ }
118
+ storybookSha = (await response.text()).trim();
119
+ if (storybookSha !== checkoutSha) {
120
+ throw new Error(
121
+ `Storybook ${storybookSha} does not match checkout ${checkoutSha}`,
122
+ );
123
+ }
124
+ });
125
+
126
+ test.afterAll(async () => {
127
+ await server?.close();
128
+ });
129
+
130
+ for (const item of cases) {
131
+ test(item.key, async ({browser}) => {
132
+ const context = await browser.newContext({
133
+ viewport: item.viewport,
134
+ colorScheme: item.mode,
135
+ reducedMotion: 'reduce',
136
+ });
137
+ const page = await context.newPage();
138
+ const pageErrors: string[] = [];
139
+ page.on('pageerror', error => pageErrors.push(String(error)));
140
+ await page.goto(storyUrl(item), {waitUntil: 'load'});
141
+ await page.locator('#storybook-root').waitFor();
142
+
143
+ const listName =
144
+ item.story === 'states'
145
+ ? 'Command item states'
146
+ : 'Combined and long command item states';
147
+ const list = page.getByRole('listbox', {name: listName});
148
+ const options = list.getByRole('option');
149
+ const expectedCount = item.story === 'states' ? 4 : 2;
150
+ const expectedDisabled = item.story === 'states' ? 1 : 0;
151
+ await expect(list).toBeVisible();
152
+ await expect(options).toHaveCount(expectedCount);
153
+ await expect(
154
+ list.locator('[role="option"][aria-selected="true"]'),
155
+ ).toHaveCount(1);
156
+ await expect(
157
+ list.locator('[role="option"][aria-disabled="true"]'),
158
+ ).toHaveCount(expectedDisabled);
159
+ await expect(list.locator('button, a, [tabindex]')).toHaveCount(0);
160
+
161
+ if (item.state === 'hover') {
162
+ await options.first().hover();
163
+ }
164
+ await settle(page);
165
+
166
+ const observed = await page.evaluate(() => ({
167
+ theme: document
168
+ .querySelector('[data-astryx-theme]')
169
+ ?.getAttribute('data-astryx-theme'),
170
+ mode: document.documentElement.getAttribute('data-theme'),
171
+ direction: getComputedStyle(
172
+ document.querySelector('.astryx-command-palette-item') as HTMLElement,
173
+ ).direction,
174
+ viewport: {width: innerWidth, height: innerHeight},
175
+ reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,
176
+ horizontalOverflow: document.documentElement.scrollWidth > innerWidth + 1,
177
+ fonts: document.fonts.status,
178
+ }));
179
+ const optionStates = await options.evaluateAll(nodes =>
180
+ nodes.map(node => {
181
+ const style = getComputedStyle(node);
182
+ const box = node.getBoundingClientRect();
183
+ return {
184
+ name: node.textContent?.replace(/\s+/g, ' ').trim(),
185
+ selected: node.getAttribute('aria-selected'),
186
+ disabled: node.getAttribute('aria-disabled'),
187
+ backgroundColor: style.backgroundColor,
188
+ color: style.color,
189
+ opacity: style.opacity,
190
+ geometry: {
191
+ x: box.x,
192
+ y: box.y,
193
+ width: box.width,
194
+ height: box.height,
195
+ },
196
+ };
197
+ }),
198
+ );
199
+ const semanticsPass =
200
+ optionStates.length === expectedCount &&
201
+ optionStates.filter(option => option.selected === 'true').length === 1 &&
202
+ optionStates.filter(option => option.disabled === 'true').length ===
203
+ expectedDisabled &&
204
+ optionStates.every(
205
+ option => option.geometry.width > 0 && option.geometry.height > 0,
206
+ );
207
+
208
+ const png = await page.screenshot({animations: 'disabled', fullPage: true});
209
+ const image = `${item.key}.png`;
210
+ const receipt = {
211
+ schemaVersion: 1,
212
+ expected: {
213
+ build: checkoutSha,
214
+ storyId: storyId(item),
215
+ mode: item.mode,
216
+ direction: item.direction,
217
+ theme: item.theme,
218
+ state: item.state,
219
+ viewport: item.viewport,
220
+ optionCount: expectedCount,
221
+ disabledCount: expectedDisabled,
222
+ selectedCount: 1,
223
+ },
224
+ observed: {
225
+ build: storybookSha,
226
+ ...observed,
227
+ listRole: await list.getAttribute('role'),
228
+ listName: await list.getAttribute('aria-label'),
229
+ optionStates,
230
+ pageErrors,
231
+ },
232
+ image: {
233
+ file: image,
234
+ sha256: createHash('sha256').update(png).digest('hex'),
235
+ width: png.readUInt32BE(16),
236
+ height: png.readUInt32BE(20),
237
+ },
238
+ checks: {semanticsPass},
239
+ passed:
240
+ storybookSha === checkoutSha &&
241
+ pageErrors.length === 0 &&
242
+ observed.theme === item.theme &&
243
+ observed.mode === item.mode &&
244
+ observed.direction === item.direction &&
245
+ observed.viewport.width === item.viewport.width &&
246
+ observed.viewport.height === item.viewport.height &&
247
+ observed.reducedMotion &&
248
+ !observed.horizontalOverflow &&
249
+ observed.fonts === 'loaded' &&
250
+ semanticsPass,
251
+ };
252
+ fs.writeFileSync(path.join(OUTPUT, image), png);
253
+ fs.writeFileSync(
254
+ path.join(OUTPUT, `${item.key}.sensors.json`),
255
+ `${JSON.stringify(receipt, null, 2)}\n`,
256
+ );
257
+
258
+ await context.close();
259
+ });
260
+ }
261
+
262
+ test('manifest is complete', async () => {
263
+ const receiptFiles = fs
264
+ .readdirSync(OUTPUT)
265
+ .filter(file => file.endsWith('.sensors.json'));
266
+ const receipts = receiptFiles.map(
267
+ (file): AuditReceipt =>
268
+ JSON.parse(
269
+ fs.readFileSync(path.join(OUTPUT, file), 'utf8'),
270
+ ) as AuditReceipt,
271
+ );
272
+ const manifest = {
273
+ schemaVersion: 1,
274
+ component: 'core/CommandPaletteItem',
275
+ build: checkoutSha,
276
+ frames: cases.map(item => ({
277
+ key: item.key,
278
+ image: `${item.key}.png`,
279
+ receipt: `${item.key}.sensors.json`,
280
+ })),
281
+ };
282
+ fs.writeFileSync(
283
+ path.join(OUTPUT, 'manifest.json'),
284
+ `${JSON.stringify(manifest, null, 2)}\n`,
285
+ );
286
+ expect(receiptFiles).toHaveLength(cases.length);
287
+ expect(
288
+ receipts
289
+ .filter(receipt => !receipt.passed)
290
+ .map(receipt => receipt.expected),
291
+ ).toEqual([]);
292
+ });