@astryxdesign/core 0.7.2-canary.caec7ca → 0.7.2-canary.cbb7fa3

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 (125) hide show
  1. package/dist/AspectRatio/AspectRatio.d.ts +6 -8
  2. package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
  3. package/dist/AspectRatio/AspectRatio.js +44 -3
  4. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  5. package/dist/Breadcrumbs/BreadcrumbItem.js +5 -2
  6. package/dist/CheckboxInput/CheckboxInput.d.ts +1 -1
  7. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  8. package/dist/CheckboxInput/CheckboxInput.js +3 -1
  9. package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
  10. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  11. package/dist/CommandPalette/CommandPaletteInput.js +37 -5
  12. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  13. package/dist/ContextMenu/ContextMenu.js +5 -2
  14. package/dist/Dialog/Dialog.d.ts.map +1 -1
  15. package/dist/Dialog/Dialog.js +20 -8
  16. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  17. package/dist/DropdownMenu/DropdownMenu.js +46 -3
  18. package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -0
  19. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  20. package/dist/DropdownMenu/DropdownMenuContext.js +21 -0
  21. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  22. package/dist/DropdownMenu/DropdownMenuSubMenu.js +15 -4
  23. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  24. package/dist/EmptyState/EmptyState.js +4 -10
  25. package/dist/Field/Field.d.ts +1 -1
  26. package/dist/Field/Field.d.ts.map +1 -1
  27. package/dist/Field/Field.js +8 -4
  28. package/dist/Grid/GridSpan.d.ts.map +1 -1
  29. package/dist/Grid/GridSpan.js +1 -0
  30. package/dist/List/List.d.ts +46 -19
  31. package/dist/List/List.d.ts.map +1 -1
  32. package/dist/List/List.js +28 -10
  33. package/dist/List/ListContext.d.ts +8 -3
  34. package/dist/List/ListContext.d.ts.map +1 -1
  35. package/dist/List/ListContext.js +7 -2
  36. package/dist/List/ListItem.d.ts +4 -3
  37. package/dist/List/ListItem.d.ts.map +1 -1
  38. package/dist/List/ListItem.js +19 -8
  39. package/dist/List/index.d.ts +1 -1
  40. package/dist/List/index.d.ts.map +1 -1
  41. package/dist/Markdown/Markdown.d.ts.map +1 -1
  42. package/dist/Markdown/Markdown.js +8 -1
  43. package/dist/MetadataList/MetadataList.d.ts.map +1 -1
  44. package/dist/MetadataList/MetadataList.js +5 -1
  45. package/dist/MetadataList/MetadataListContext.d.ts +1 -1
  46. package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
  47. package/dist/RadioList/RadioList.d.ts +1 -1
  48. package/dist/RadioList/RadioList.d.ts.map +1 -1
  49. package/dist/RadioList/RadioList.js +6 -2
  50. package/dist/ToggleButton/ToggleButton.d.ts +3 -2
  51. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  52. package/dist/ToggleButton/ToggleButton.js +12 -1
  53. package/dist/TreeList/TreeList.d.ts.map +1 -1
  54. package/dist/TreeList/TreeList.js +1 -0
  55. package/dist/TreeList/TreeListBranches.d.ts.map +1 -1
  56. package/dist/TreeList/TreeListBranches.js +2 -2
  57. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  58. package/dist/TreeList/TreeListItem.js +57 -9
  59. package/dist/astryx.css +16 -3
  60. package/dist/hooks/useMenuHover.d.ts.map +1 -1
  61. package/dist/hooks/useMenuHover.js +18 -13
  62. package/dist/utils/plainDate.d.ts.map +1 -1
  63. package/dist/utils/plainDate.js +15 -9
  64. package/package.json +3 -3
  65. package/src/AspectRatio/AspectRatio.test.tsx +44 -43
  66. package/src/AspectRatio/AspectRatio.tsx +38 -18
  67. package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +157 -0
  68. package/src/Avatar/Avatar.doc.mjs +5 -3
  69. package/src/AvatarGroup/AvatarGroup.doc.mjs +3 -2
  70. package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
  71. package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +3 -1
  72. package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
  73. package/src/CheckboxInput/CheckboxInput.tsx +3 -1
  74. package/src/CommandPalette/CommandPaletteInput.test.tsx +53 -4
  75. package/src/CommandPalette/CommandPaletteInput.tsx +33 -3
  76. package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +335 -0
  77. package/src/ContextMenu/ContextMenu.tsx +4 -1
  78. package/src/Dialog/Dialog.test.tsx +46 -0
  79. package/src/Dialog/Dialog.tsx +20 -7
  80. package/src/Dialog/__tests__/Dialog.a11y.known-failures.ts +0 -14
  81. package/src/DropdownMenu/DropdownMenu.tsx +45 -2
  82. package/src/DropdownMenu/DropdownMenuContext.tsx +24 -0
  83. package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +185 -0
  84. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +17 -3
  85. package/src/EmptyState/EmptyState.doc.mjs +3 -2
  86. package/src/EmptyState/EmptyState.spec.md +189 -0
  87. package/src/EmptyState/EmptyState.test.tsx +74 -3
  88. package/src/EmptyState/EmptyState.tsx +4 -8
  89. package/src/Field/Field.doc.mjs +14 -8
  90. package/src/Field/Field.spec.md +217 -0
  91. package/src/Field/Field.test.tsx +60 -2
  92. package/src/Field/Field.tsx +17 -8
  93. package/src/Grid/GridSpan.tsx +3 -0
  94. package/src/Item/Item.doc.mjs +1 -1
  95. package/src/Item/Item.tsx +1 -1
  96. package/src/List/List.doc.mjs +14 -1
  97. package/src/List/List.spec.md +129 -77
  98. package/src/List/List.test.tsx +144 -94
  99. package/src/List/List.tsx +74 -18
  100. package/src/List/ListContext.tsx +9 -3
  101. package/src/List/ListItem.tsx +46 -26
  102. package/src/List/index.ts +1 -1
  103. package/src/Markdown/Markdown.tsx +14 -1
  104. package/src/MetadataList/MetadataList.doc.mjs +2 -2
  105. package/src/MetadataList/MetadataList.test.tsx +38 -0
  106. package/src/MetadataList/MetadataList.tsx +8 -1
  107. package/src/MetadataList/MetadataListContext.tsx +1 -1
  108. package/src/RadioList/RadioList.fr10.test.tsx +45 -2
  109. package/src/RadioList/RadioList.tsx +4 -1
  110. package/src/Slider/Slider.spec.md +39 -18
  111. package/src/TabList/TabList.spec.md +57 -44
  112. package/src/TimeInput/TimeInput.fr10.test.tsx +15 -0
  113. package/src/ToggleButton/ToggleButton.test.tsx +95 -0
  114. package/src/ToggleButton/ToggleButton.tsx +12 -1
  115. package/src/TreeList/TreeList.doc.mjs +1 -0
  116. package/src/TreeList/TreeList.test.tsx +327 -6
  117. package/src/TreeList/TreeList.tsx +5 -1
  118. package/src/TreeList/TreeListBranches.tsx +6 -0
  119. package/src/TreeList/TreeListItem.tsx +88 -13
  120. package/src/docPropLiterals.test.ts +36 -10
  121. package/src/hooks/useMenuHover.ts +18 -13
  122. package/src/reset.css +0 -29
  123. package/src/theme/derivedVarRegistry.test.ts +7 -0
  124. package/src/utils/plainDate.test.ts +37 -1
  125. package/src/utils/plainDate.ts +15 -5
@@ -9,7 +9,7 @@
9
9
  * SYNC: When AspectRatio.tsx changes, update tests to match new behavior
10
10
  */
11
11
 
12
- import {describe, it, expect, vi, beforeAll} from 'vitest';
12
+ import {describe, it, expect, vi} from 'vitest';
13
13
  import {render, screen} from '@testing-library/react';
14
14
  import {AspectRatio} from './AspectRatio';
15
15
 
@@ -230,9 +230,8 @@ describe('AspectRatio', () => {
230
230
  <img src="test.jpg" alt="Test" data-testid="image" />
231
231
  </AspectRatio>,
232
232
  );
233
- // The marker sits on the child's actual parent, so the reset.css
234
- // sizing rules are direct-child selectors with no dependence on
235
- // AspectRatio's internal structure.
233
+ // Earlier releases documented the marker, so it stays on the child's
234
+ // direct parent for product CSS that targets it.
236
235
  const wrapper = screen.getByTestId('image').parentElement;
237
236
  expect(wrapper).toHaveAttribute(
238
237
  'data-astryx-aspect-ratio-override',
@@ -274,8 +273,11 @@ describe('AspectRatio', () => {
274
273
  );
275
274
  const wrapper = screen.getByTestId('image').parentElement;
276
275
  expect(wrapper).not.toHaveAttribute('data-astryx-aspect-ratio-override');
277
- // Without the marker, none of the reset.css fit rules can match, so
278
- // existing self-styled children render exactly as before.
276
+ // Without fit the wrapper carries no child-sizing styles, so existing
277
+ // self-styled children render exactly as before.
278
+ expect(wrapper?.className).not.toContain('childFill');
279
+ expect(wrapper?.className).not.toContain('childCover');
280
+ expect(wrapper?.className).not.toContain('childContain');
279
281
  expect(screen.getByTestId('image')).not.toHaveAttribute('class');
280
282
  });
281
283
 
@@ -292,13 +294,37 @@ describe('AspectRatio', () => {
292
294
  </AspectRatio>,
293
295
  );
294
296
  const image = screen.getByTestId('image');
295
- // Fit styling is pure CSS (zero-specificity reset rules); the child's
296
- // own className/style pass through untouched and always win, so
297
- // children that already size themselves keep their behavior.
297
+ // Fit styling is a direct-child rule on the wrapper; the child's own
298
+ // className/style pass through untouched, and an inline style still
299
+ // wins over it.
298
300
  expect(image.className).toBe('consumer-class');
299
301
  expect(image.style.objectFit).toBe('contain');
300
302
  });
301
303
 
304
+ it('sizes the child from the wrapper with fit="cover"', () => {
305
+ render(
306
+ <AspectRatio ratio={16 / 9} fit="cover">
307
+ <img src="test.jpg" alt="Test" data-testid="image" />
308
+ </AspectRatio>,
309
+ );
310
+ const wrapper = screen.getByTestId('image').parentElement;
311
+ expect(wrapper?.className).toContain('childFill');
312
+ expect(wrapper?.className).toContain('childCover');
313
+ expect(wrapper?.className).not.toContain('childContain');
314
+ });
315
+
316
+ it('sizes the child from the wrapper with fit="contain"', () => {
317
+ render(
318
+ <AspectRatio ratio={16 / 9} fit="contain">
319
+ <img src="test.jpg" alt="Test" data-testid="image" />
320
+ </AspectRatio>,
321
+ );
322
+ const wrapper = screen.getByTestId('image').parentElement;
323
+ expect(wrapper?.className).toContain('childFill');
324
+ expect(wrapper?.className).toContain('childContain');
325
+ expect(wrapper?.className).not.toContain('childCover');
326
+ });
327
+
302
328
  it('centers the child via the wrapper with fit="center"', () => {
303
329
  render(
304
330
  <AspectRatio ratio={16 / 9} fit="center">
@@ -309,6 +335,7 @@ describe('AspectRatio', () => {
309
335
  expect(image).not.toHaveAttribute('class');
310
336
  const wrapper = image.parentElement;
311
337
  expect(wrapper?.className).toContain('childCenter');
338
+ expect(wrapper?.className).not.toContain('childFill');
312
339
  });
313
340
 
314
341
  it('does not center the wrapper for other fit values', () => {
@@ -353,45 +380,19 @@ describe('AspectRatio', () => {
353
380
  });
354
381
  });
355
382
 
356
- describe('reset.css fit baseline rules', () => {
357
- // The cover/contain child sizing ships as zero-specificity baseline
358
- // rules in reset.css keyed on the data-astryx-aspect-ratio-override
359
- // marker the component sets on the child's direct parent. These
360
- // assertions keep the stylesheet in sync with the component contract.
361
- let resetCSS: string;
362
-
363
- beforeAll(async () => {
383
+ describe('reset.css', () => {
384
+ it('carries no AspectRatio rules', async () => {
385
+ // fit ships with the component's StyleX styles in `astryx-base`. A
386
+ // rule in reset.css sits below the layer the documented Tailwind
387
+ // setups give preflight, whose `img, video { height: auto }` would
388
+ // undo the fill.
364
389
  const fs = await import('fs');
365
390
  const path = await import('path');
366
- resetCSS = fs.readFileSync(
391
+ const resetCSS = fs.readFileSync(
367
392
  path.resolve(__dirname, '../reset.css'),
368
393
  'utf-8',
369
394
  );
370
- });
371
-
372
- it('sizes the child to fill the box for cover and contain', () => {
373
- const fillMatch = resetCSS.match(
374
- /:where\(\[data-astryx-aspect-ratio-override="cover"\], \[data-astryx-aspect-ratio-override="contain"\]\)\s*>\s*:where\(\*\)\s*\{([^}]+)\}/,
375
- );
376
- expect(fillMatch).not.toBeNull();
377
- expect(fillMatch![1]).toContain('width: 100%');
378
- expect(fillMatch![1]).toContain('height: 100%');
379
- });
380
-
381
- it('crops media with object-fit: cover for fit="cover"', () => {
382
- const coverMatch = resetCSS.match(
383
- /:where\(\[data-astryx-aspect-ratio-override="cover"\]\)\s*>\s*:where\(img, video\)\s*\{([^}]+)\}/,
384
- );
385
- expect(coverMatch).not.toBeNull();
386
- expect(coverMatch![1]).toContain('object-fit: cover');
387
- });
388
-
389
- it('letterboxes media with object-fit: contain for fit="contain"', () => {
390
- const containMatch = resetCSS.match(
391
- /:where\(\[data-astryx-aspect-ratio-override="contain"\]\)\s*>\s*:where\(img, video\)\s*\{([^}]+)\}/,
392
- );
393
- expect(containMatch).not.toBeNull();
394
- expect(containMatch![1]).toContain('object-fit: contain');
395
+ expect(resetCSS).not.toContain('aspect-ratio-override');
395
396
  });
396
397
  });
397
398
  });
@@ -9,7 +9,6 @@
9
9
  * SYNC: When modified, update these files to stay in sync:
10
10
  * - /packages/core/src/AspectRatio/AspectRatio.doc.mjs
11
11
  * - /packages/core/src/AspectRatio/AspectRatio.test.tsx
12
- * - /packages/core/src/reset.css (AspectRatio fit baseline rules)
13
12
  * - /apps/storybook/stories/AspectRatio.stories.tsx
14
13
  * - /packages/cli/assets/templates/blocks/components/AspectRatio/ (showcase blocks)
15
14
  */
@@ -91,13 +90,12 @@ export interface AspectRatioProps extends BaseProps<HTMLDivElement> {
91
90
  * (`object-fit: contain`).
92
91
  * - `center`: child keeps its natural size, centered in the box.
93
92
  *
94
- * `cover`/`contain` child sizing ships as zero-specificity baseline rules
95
- * in `reset.css`, keyed on the `data-astryx-aspect-ratio-override`
96
- * attribute the component sets on the child's direct parent. Any styles
97
- * the child sets itself still win, so children that already size
98
- * themselves keep their behavior. When omitted, the child is left
99
- * unstyled (the pre-existing contract). `fit` is structural, not visual,
100
- * so it is not exposed on the theming surface.
93
+ * `cover`/`contain` size the child from the component's own styles, in
94
+ * the `astryx-base` cascade layer. Styles in a later layer (Tailwind
95
+ * utilities, `astryx-theme`), unlayered CSS, and inline styles on the
96
+ * child still win. When omitted, the child is left unstyled (the
97
+ * pre-existing contract). `fit` is structural, not visual, so it is not
98
+ * exposed on the theming surface.
101
99
  *
102
100
  * @example
103
101
  * ```
@@ -140,15 +138,33 @@ const styles = stylex.create({
140
138
  height: '100%',
141
139
  },
142
140
  // fit="center" centers the child at its natural size from the wrapper —
143
- // no styles on the child itself. The `cover`/`contain` child sizing can't
144
- // live here (StyleX has no descendant selectors); it ships as baseline
145
- // rules in reset.css keyed on the `data-astryx-aspect-ratio-override`
146
- // attribute the wrapper carries (see below).
141
+ // no styles on the child itself.
147
142
  childCenter: {
148
143
  display: 'flex',
149
144
  alignItems: 'center',
150
145
  justifyContent: 'center',
151
146
  },
147
+ // `cover`/`contain` must style the child itself (`object-fit` only applies
148
+ // on the replaced element), and StyleX has no child selector. The
149
+ // `:not([stylex-hack])` pseudo-class always matches, so StyleX accepts the
150
+ // key and emits `.x:not([stylex-hack]) > *`, a direct-child rule in the
151
+ // `astryx-base` layer like every other component style.
152
+ childFill: {
153
+ ':not([stylex-hack]) > *': {
154
+ width: '100%',
155
+ height: '100%',
156
+ },
157
+ },
158
+ childCover: {
159
+ ':not([stylex-hack]) > :is(img, video)': {
160
+ objectFit: 'cover',
161
+ },
162
+ },
163
+ childContain: {
164
+ ':not([stylex-hack]) > :is(img, video)': {
165
+ objectFit: 'contain',
166
+ },
167
+ },
152
168
  });
153
169
 
154
170
  // The ratio compiles to a CSS variable + a class-level declaration
@@ -234,14 +250,18 @@ export function AspectRatio({
234
250
  style,
235
251
  )}
236
252
  {...props}>
237
- {/* The marker attribute carries the fit value so the reset.css child
238
- sizing can use direct-child selectors on this wrapper — the child's
239
- actual parent — without depending on AspectRatio's internal
240
- structure or on the theming surface (fit is structural, not
241
- themeable). The name is namespaced to avoid collisions. */}
253
+ {/* The marker attribute carries the fit value. No Astryx style keys on
254
+ it any more, but earlier releases documented it, so product CSS may
255
+ still target it. */}
242
256
  <div
243
257
  data-astryx-aspect-ratio-override={fit}
244
- {...stylex.props(styles.child, fit === 'center' && styles.childCenter)}>
258
+ {...stylex.props(
259
+ styles.child,
260
+ fit === 'center' && styles.childCenter,
261
+ (fit === 'cover' || fit === 'contain') && styles.childFill,
262
+ fit === 'cover' && styles.childCover,
263
+ fit === 'contain' && styles.childContain,
264
+ )}>
245
265
  {children}
246
266
  </div>
247
267
  </div>
@@ -0,0 +1,157 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file AspectRatioFitLayers.a11y.browser.spec.ts
5
+ * @input The built FitModes story (its rendered markup and compiled CSS) and
6
+ * Tailwind's preflight.css
7
+ * @output Browser evidence that `fit` fills the box on the documented setups
8
+ * @position AspectRatio integration proof. Which rule sizes the child is a
9
+ * cascade-layer question, and only a shipping engine resolves the cascade.
10
+ */
11
+
12
+ import * as fs from 'node:fs';
13
+ import {fileURLToPath} from 'node:url';
14
+ import {expect, test, type Page} from '@playwright/test';
15
+ import {
16
+ DEFAULT_STORYBOOK_DIR,
17
+ serveStorybook,
18
+ type StaticServer,
19
+ } from '@astryxdesign/a11y-spec/storybook';
20
+
21
+ const PREFLIGHT_CSS = fs.readFileSync(
22
+ fileURLToPath(import.meta.resolve('tailwindcss/preflight.css')),
23
+ 'utf8',
24
+ );
25
+
26
+ // The layer order each setup guide declares, and the layer preflight goes in.
27
+ const TAILWIND_SETUPS = [
28
+ {
29
+ name: 'Tailwind v4',
30
+ order:
31
+ '@layer reset, theme, base, astryx-base, astryx-theme, components, utilities;',
32
+ preflightLayer: 'base',
33
+ },
34
+ {
35
+ name: 'Tailwind v3',
36
+ order: '@layer reset, tw-preflight, astryx-base, astryx-theme;',
37
+ preflightLayer: 'tw-preflight',
38
+ },
39
+ ];
40
+
41
+ // A 100×100 image in a 320px-wide 16:9 box: filling the box makes it 320×180.
42
+ const IMAGE =
43
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'/%3E";
44
+
45
+ type Fit = 'cover' | 'contain';
46
+
47
+ let storybook: StaticServer;
48
+ test.beforeAll(async () => {
49
+ storybook = await serveStorybook(
50
+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
51
+ );
52
+ });
53
+ test.afterAll(async () => {
54
+ await storybook?.close();
55
+ });
56
+
57
+ /**
58
+ * The markup AspectRatio renders for `fit`, and every CSS rule the story
59
+ * page loaded, taken from the built story so the classes and rules are the
60
+ * component's real compiled output. The child image gets a fixed id, a
61
+ * local source and any extra class.
62
+ */
63
+ async function captureStory(page: Page, fit: Fit, mediaClass: string) {
64
+ await page.goto(
65
+ `${storybook.origin}/iframe.html?id=core-aspectratio--fit-modes&viewMode=story`,
66
+ );
67
+ const wrapper = page.locator(`[data-astryx-aspect-ratio-override="${fit}"]`);
68
+ await expect(wrapper).toHaveCount(1);
69
+ return wrapper.evaluate(
70
+ (element, {image, extraClass}) => {
71
+ const root = element.parentElement?.cloneNode(true);
72
+ const media =
73
+ root instanceof HTMLElement ? root.querySelector('img') : null;
74
+ if (!(root instanceof HTMLElement) || media == null) {
75
+ throw new Error('FitModes no longer renders an img inside AspectRatio');
76
+ }
77
+ media.id = 'media';
78
+ media.src = image;
79
+ if (extraClass) {
80
+ media.classList.add(extraClass);
81
+ }
82
+ const css = [...document.styleSheets]
83
+ .flatMap(sheet => [...sheet.cssRules].map(rule => rule.cssText))
84
+ .join('\n');
85
+ return {html: root.outerHTML, css};
86
+ },
87
+ {image: IMAGE, extraClass: mediaClass},
88
+ );
89
+ }
90
+
91
+ /** Re-host the captured story with `before` CSS ahead of it and `after` CSS behind it. */
92
+ async function measureMedia(
93
+ page: Page,
94
+ fit: Fit,
95
+ {
96
+ before = [],
97
+ after = [],
98
+ mediaClass = '',
99
+ }: {
100
+ before?: string[];
101
+ after?: string[];
102
+ mediaClass?: string;
103
+ },
104
+ ) {
105
+ const {html, css} = await captureStory(page, fit, mediaClass);
106
+ await page.setContent(
107
+ `<!doctype html><div style="width: 320px">${html}</div>`,
108
+ );
109
+ for (const content of [...before, css, ...after]) {
110
+ await page.addStyleTag({content});
111
+ }
112
+ await page.waitForFunction(
113
+ () => (document.getElementById('media') as HTMLImageElement).complete,
114
+ );
115
+ return page.evaluate(() => {
116
+ const media = document.getElementById('media');
117
+ if (!media) {
118
+ throw new Error('missing media');
119
+ }
120
+ const box = media.getBoundingClientRect();
121
+ return {
122
+ width: box.width,
123
+ height: box.height,
124
+ objectFit: getComputedStyle(media).objectFit,
125
+ };
126
+ });
127
+ }
128
+
129
+ for (const setup of TAILWIND_SETUPS) {
130
+ for (const fit of ['cover', 'contain'] as const) {
131
+ test(`fit="${fit}" fills the box on the ${setup.name} setup`, async ({
132
+ page,
133
+ }) => {
134
+ const media = await measureMedia(page, fit, {
135
+ before: [
136
+ setup.order,
137
+ `@layer ${setup.preflightLayer} { ${PREFLIGHT_CSS} }`,
138
+ ],
139
+ });
140
+ expect(media).toEqual({width: 320, height: 180, objectFit: fit});
141
+ });
142
+ }
143
+ }
144
+
145
+ test('fit fills the box with only Astryx CSS loaded', async ({page}) => {
146
+ const media = await measureMedia(page, 'cover', {});
147
+ expect(media).toEqual({width: 320, height: 180, objectFit: 'cover'});
148
+ });
149
+
150
+ test('a utility class on the child still wins over fit', async ({page}) => {
151
+ const media = await measureMedia(page, 'cover', {
152
+ before: [TAILWIND_SETUPS[0].order, `@layer base { ${PREFLIGHT_CSS} }`],
153
+ after: ['@layer utilities { .h-10 { height: 40px; } }'],
154
+ mediaClass: 'h-10',
155
+ });
156
+ expect(media).toEqual({width: 320, height: 40, objectFit: 'cover'});
157
+ });
@@ -67,8 +67,10 @@ export const docs = {
67
67
  },
68
68
  {
69
69
  name: 'size',
70
- type: "'xsm' | 'sm' | 'md' | 'lg' | 'xl' | number",
71
- description: "Avatar size. Use a named size ('xsm' 20px, 'sm' 24px, 'md' 36px, 'lg' 48px, 'xl' 128px) or a numeric pixel value. Avatar shares Icon's abbreviated scale, but its tiers are larger because avatars align with media rather than glyphs. Inside an AvatarGroup the group's size wins and this prop is ignored.",
70
+ type:
71
+ "'xsm' | 'sm' | 'md' | 'lg' | 'xl' | 16 | 20 | 24 | 32 | 36 | 40 | 48 | 60 | 64 | 72 | 96 | 128 | 144 | 180",
72
+ description:
73
+ "Avatar size: named sizes are 'xsm' (20px), 'sm' (24px), 'md' (36px), 'lg' (48px), and 'xl' (128px); numeric sizes must be one of the pixel values listed in the type. Inside an AvatarGroup, the group's size always overrides this prop, including when the group uses its default size.",
72
74
  default: "'md'",
73
75
  },
74
76
  {
@@ -169,7 +171,7 @@ export const docsDense = {
169
171
  fallbackSrc: 'fallback image when primary fails',
170
172
  name: 'user name for initials and alt text',
171
173
  alt: 'alt text; falls back to name',
172
- size: "avatar size. Named ('xsm' 20px, 'sm' 24px, 'md' 36px, 'lg' 48px, 'xl' 128px) or numeric px. An AvatarGroup's size overrides it.",
174
+ size: "named sizes: 'xsm' 20px, 'sm' 24px, 'md' 36px, 'lg' 48px, 'xl' 128px; numeric px restricted to values listed in the type. AvatarGroup's size always wins, default included.",
173
175
  status:
174
176
  'corner content for status indicators; AvatarStatusDot reports its `label`, composed into the avatar accessible name ("Jane Doe, Online"), at any nesting depth',
175
177
  tooltip:
@@ -48,9 +48,10 @@ export const docs = {
48
48
  },
49
49
  {
50
50
  name: 'size',
51
- type: 'AvatarSize',
51
+ type:
52
+ "'xsm' | 'sm' | 'md' | 'lg' | 'xl' | 16 | 20 | 24 | 32 | 36 | 40 | 48 | 60 | 64 | 72 | 96 | 128 | 144 | 180",
52
53
  description:
53
- "Size applied to all avatars via context. This wins over each child Avatar's own size prop, including when it is left at the default, so set the size here rather than on the children.",
54
+ "Size applied to all avatars: named sizes are 'xsm' (20px), 'sm' (24px), 'md' (36px), 'lg' (48px), and 'xl' (128px); numeric sizes must be one of the pixel values listed in the type. The group's size always overrides each child Avatar's size, including when the group uses its default size.",
54
55
  default: "'md'",
55
56
  },
56
57
  {
@@ -56,6 +56,7 @@ import {layerAnimations} from '../Layer/layerAnimations.stylex';
56
56
  import {renderDropdownItems} from '../DropdownMenu/renderDropdownItems';
57
57
  import {
58
58
  DropdownMenuContext,
59
+ DropdownMenuRootOpenContext,
59
60
  type DropdownMenuContextValue,
60
61
  type DropdownMenuSize,
61
62
  } from '../DropdownMenu/DropdownMenuContext';
@@ -673,7 +674,9 @@ function BreadcrumbMenuTrigger({
673
674
  stylex.props(menuStyles.menu),
674
675
  )}>
675
676
  <DropdownMenuContext value={contextValue}>
676
- {menuContent}
677
+ <DropdownMenuRootOpenContext value={popover.isOpen}>
678
+ {menuContent}
679
+ </DropdownMenuRootOpenContext>
677
680
  </DropdownMenuContext>
678
681
  </div>,
679
682
  {
@@ -395,7 +395,9 @@ test('captures narrow touch reflow in both modes', async ({browser}) => {
395
395
  try {
396
396
  const page = await context.newPage();
397
397
  const scenario = CASES.find(item => item.name === 'narrow-overflow');
398
- if (!scenario) {throw new Error('Narrow metadata fixture is missing');}
398
+ if (!scenario) {
399
+ throw new Error('Narrow metadata fixture is missing');
400
+ }
399
401
  const failures: string[] = [];
400
402
  for (const mode of ['light', 'dark'] as const) {
401
403
  failures.push(
@@ -209,6 +209,40 @@ describe('CheckboxInput', () => {
209
209
  );
210
210
  });
211
211
 
212
+ it('preserves a caller-provided id on the input and its label', () => {
213
+ render(
214
+ <CheckboxInput
215
+ id="accept-terms"
216
+ label="Accept terms"
217
+ value={false}
218
+ onChange={() => {}}
219
+ />,
220
+ );
221
+
222
+ const checkbox = screen.getByRole('checkbox');
223
+ expect(checkbox).toHaveAttribute('id', 'accept-terms');
224
+ expect(screen.getByText('Accept terms').closest('label')).toHaveAttribute(
225
+ 'for',
226
+ 'accept-terms',
227
+ );
228
+ expect(screen.getByLabelText('Accept terms')).toBe(checkbox);
229
+ });
230
+
231
+ it('generates an id the label resolves when the caller passes an empty id', () => {
232
+ render(
233
+ <CheckboxInput
234
+ id=""
235
+ label="Accept terms"
236
+ value={false}
237
+ onChange={() => {}}
238
+ />,
239
+ );
240
+
241
+ const checkbox = screen.getByRole('checkbox');
242
+ expect(checkbox.id).not.toBe('');
243
+ expect(screen.getByLabelText('Accept terms')).toBe(checkbox);
244
+ });
245
+
212
246
  it('forwards arbitrary data-* attributes to the input', () => {
213
247
  render(
214
248
  <CheckboxInput
@@ -311,6 +311,7 @@ const dynamicWidthStyles = stylex.create({
311
311
  * ```
312
312
  */
313
313
  export function CheckboxInput({
314
+ id: idProp,
314
315
  label,
315
316
  isLabelHidden = false,
316
317
  description,
@@ -340,7 +341,8 @@ export function CheckboxInput({
340
341
  // The row is the pressable: the overlay's pressed arm reads the row's
341
342
  // scope marker, the way the indicator's hover tint does.
342
343
  const pressable = usePressFeedback();
343
- const id = useId();
344
+ const generatedId = useId();
345
+ const id = idProp || generatedId;
344
346
  const descriptionID = useId();
345
347
  const statusMessageID = useId();
346
348
  // Announce the effective required state (form default included) while the
@@ -8,12 +8,19 @@
8
8
  */
9
9
 
10
10
  import {createRef} from 'react';
11
- import {describe, it, expect, vi} from 'vitest';
12
- import {render, screen, fireEvent} from '@testing-library/react';
11
+ import {describe, it, expect, vi, beforeEach} from 'vitest';
12
+ import {render, screen, fireEvent, act} from '@testing-library/react';
13
+ import * as stylex from '@stylexjs/stylex';
13
14
  import {CommandPaletteInput} from './CommandPaletteInput';
14
15
  import {CommandPaletteContext} from './CommandPaletteContext';
15
16
  import {Dialog} from '../Dialog';
16
17
  import type {CommandPaletteContextValue} from './CommandPaletteContext';
18
+ import {focusOutlineStyles} from '../utils/focusOutline.stylex';
19
+ import {__resetInteractionModalityForTest} from '../utils/interactionModality';
20
+
21
+ beforeEach(() => {
22
+ __resetInteractionModalityForTest();
23
+ });
17
24
 
18
25
  function makeContext(
19
26
  overrides: Partial<CommandPaletteContextValue> = {},
@@ -279,6 +286,45 @@ describe('CommandPaletteInput', () => {
279
286
  },
280
287
  );
281
288
 
289
+ it('draws the shared ring only when keyboard navigation acquired focus', () => {
290
+ render(<CommandPaletteInput hasAutoFocus={false} />);
291
+ const input = screen.getByRole('searchbox');
292
+ const ringClasses = stylex
293
+ .props(focusOutlineStyles.focusVisible)
294
+ .className!.split(' ');
295
+ const isRinged = () =>
296
+ ringClasses.every(className => input.classList.contains(className));
297
+
298
+ fireEvent.pointerDown(input);
299
+ fireEvent.focus(input);
300
+ expect(isRinged()).toBe(false);
301
+
302
+ fireEvent.blur(input);
303
+ fireEvent.keyDown(input, {key: 'Tab'});
304
+ fireEvent.focus(input);
305
+ expect(isRinged()).toBe(true);
306
+ });
307
+
308
+ it('preserves caller focus and blur handlers while tracking modality', () => {
309
+ const onFocus = vi.fn();
310
+ const onBlur = vi.fn();
311
+ render(
312
+ <CommandPaletteInput
313
+ hasAutoFocus={false}
314
+ onFocus={onFocus}
315
+ onBlur={onBlur}
316
+ />,
317
+ );
318
+ const input = screen.getByRole('searchbox');
319
+
320
+ fireEvent.keyDown(input, {key: 'Tab'});
321
+ fireEvent.focus(input);
322
+ fireEvent.blur(input);
323
+
324
+ expect(onFocus).toHaveBeenCalledTimes(1);
325
+ expect(onBlur).toHaveBeenCalledTimes(1);
326
+ });
327
+
282
328
  it('does not schedule focus when hasAutoFocus is false', async () => {
283
329
  const focusSpy = vi.spyOn(HTMLElement.prototype, 'focus');
284
330
  render(<CommandPaletteInput hasAutoFocus={false} />);
@@ -481,8 +527,11 @@ describe('CommandPaletteInput popup context', () => {
481
527
  </CommandPaletteContext>,
482
528
  );
483
529
 
484
- await vi.waitFor(() => {
485
- expect(screen.getByRole('combobox')).toHaveFocus();
530
+ await act(async () => {
531
+ await new Promise<void>(resolve =>
532
+ requestAnimationFrame(() => resolve()),
533
+ );
486
534
  });
535
+ expect(screen.getByRole('combobox')).toHaveFocus();
487
536
  });
488
537
  });