@astryxdesign/core 0.7.4-canary.f32572e → 0.7.4

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 (59) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/Chat/ChatMessageList.d.ts.map +1 -1
  3. package/dist/Chat/ChatMessageList.js +8 -1
  4. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  5. package/dist/CheckboxInput/CheckboxInput.js +6 -0
  6. package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
  7. package/dist/CommandPalette/CommandPalette.js +6 -11
  8. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  9. package/dist/CommandPalette/CommandPaletteInput.js +7 -1
  10. package/dist/CommandPalette/CommandPaletteItem.d.ts +1 -0
  11. package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
  12. package/dist/CommandPalette/CommandPaletteItem.js +5 -1
  13. package/dist/DateInput/DateInput.d.ts +6 -4
  14. package/dist/DateInput/DateInput.d.ts.map +1 -1
  15. package/dist/DateInput/DateInput.js +5 -1
  16. package/dist/DateInput/NativeDateField.d.ts.map +1 -1
  17. package/dist/DateInput/NativeDateField.js +5 -1
  18. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  19. package/dist/DateInput/TouchDateField.js +5 -1
  20. package/dist/DateInput/tokens.stylex.d.ts.map +1 -1
  21. package/dist/DateInput/tokens.stylex.js +3 -1
  22. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  23. package/dist/DropdownMenu/DropdownMenuSubMenu.js +7 -1
  24. package/dist/FileInput/FileInput.d.ts.map +1 -1
  25. package/dist/FileInput/FileInput.js +16 -2
  26. package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
  27. package/dist/Thumbnail/Thumbnail.js +9 -2
  28. package/package.json +4 -4
  29. package/src/BottomSheet/BottomSheet.spec.md +1 -0
  30. package/src/BottomSheet/BottomSheetEdgeTint.test.tsx +25 -2
  31. package/src/BottomSheet/BottomSheetSwitcher.spec.md +7 -6
  32. package/src/BottomSheet/BottomSheetSwitcher.test.tsx +221 -1
  33. package/src/BottomSheet/__tests__/BottomSheetNativeModal.a11y.browser.spec.ts +461 -0
  34. package/src/Chat/ChatMessageList.test.tsx +6 -2
  35. package/src/Chat/ChatMessageList.tsx +7 -1
  36. package/src/Chat/__tests__/ChatMessageList.a11y.chromium.spec.ts +20 -12
  37. package/src/CheckboxInput/CheckboxInput.tsx +6 -0
  38. package/src/CommandPalette/CommandPalette.doc.mjs +4 -1
  39. package/src/CommandPalette/CommandPalette.test.tsx +4 -2
  40. package/src/CommandPalette/CommandPalette.tsx +6 -11
  41. package/src/CommandPalette/CommandPaletteInput.test.tsx +3 -1
  42. package/src/CommandPalette/CommandPaletteInput.tsx +10 -1
  43. package/src/CommandPalette/CommandPaletteItem.doc.mjs +17 -5
  44. package/src/CommandPalette/CommandPaletteItem.test.tsx +65 -12
  45. package/src/CommandPalette/CommandPaletteItem.tsx +6 -1
  46. package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +250 -20
  47. package/src/DateInput/DateInput.doc.mjs +23 -5
  48. package/src/DateInput/DateInput.spec.md +52 -45
  49. package/src/DateInput/DateInput.tsx +13 -7
  50. package/src/DateInput/NativeDateField.tsx +6 -2
  51. package/src/DateInput/TouchDateField.tsx +6 -2
  52. package/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.ts +576 -0
  53. package/src/DateInput/tokens.stylex.ts +3 -1
  54. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +10 -1
  55. package/src/FileInput/FileInput.tsx +18 -2
  56. package/src/Overlay/Overlay.spec.md +304 -0
  57. package/src/Thumbnail/Thumbnail.test.tsx +6 -1
  58. package/src/Thumbnail/Thumbnail.tsx +12 -3
  59. package/src/__tests__/BusyOwnerAnnouncement.test.tsx +324 -2
@@ -13,6 +13,7 @@ review_triggers: [public-api, behavior, layout, theming, accessibility]
13
13
  verified_by:
14
14
  [
15
15
  packages/core/src/BottomSheet/BottomSheetSwitcher.test.tsx,
16
+ packages/core/src/BottomSheet/__tests__/BottomSheetNativeModal.a11y.browser.spec.ts,
16
17
  apps/storybook/stories/BottomSheetSwitcher.stories.tsx,
17
18
  scripts/check-knowledge.mjs,
18
19
  ]
@@ -192,12 +193,12 @@ Consumer migration instructions belong in consumer docs and release notes.
192
193
 
193
194
  ## Verification map
194
195
 
195
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
196
- | ---------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
197
- | FR1–FR4, FR8 | `BottomSheetSwitcher.test.tsx` | closed, first open, handoffs in either completion order, rapid replacement, unmount, close | A child becomes interactive at the wrong time, a retained child disappears early, a second backdrop paints, or a sheet dialog's lifecycle breaks. | `audit:BottomSheetSwitcher/behavior` |
198
- | FR5–FR7, AR1–AR3 | `BottomSheetSwitcher.test.tsx`; `BottomSheetNativeModal.a11y.browser.spec.ts` (implementation gap: not yet in the tree) | modal/non-modal, info/form/required, nested layer, IME, focus return, scroll lock in engines, non-modal local ordering | Modality, dismissal order, naming, inertness, scroll lock, or focus behavior diverges, or a sheet dialog takes a page-level z-index. | `audit:BottomSheetSwitcher/accessibility` |
199
- | FR9 | `BottomSheetSwitcher.test.tsx`; export checks | ref across open/handoff/close/unmount, callback-ref cleanup, `id` once, DOM/ARIA/data/events, class, style, xstyle | A supported input is dropped or duplicated, an object ref is null while a sheet is mounted or skips a cleanup, or an input overrides component-owned semantics accidentally. | `audit:BottomSheetSwitcher/api` |
200
- | Theming anatomy | `scripts/check-knowledge.mjs`; theming tests | dialog, delegated sheet panel, scrim | A non-painting host gains a target, a delegated panel loses its owner, or the scrim gap disappears without review. | `audit:BottomSheetSwitcher/theming` |
196
+ | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
197
+ | ---------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
198
+ | FR1–FR4, FR8 | `BottomSheetSwitcher.test.tsx` | closed, first open, handoffs in either completion order, rapid replacement, unmount, close | A child becomes interactive at the wrong time, a retained child disappears early, a second backdrop paints, or a sheet dialog's lifecycle breaks. | `audit:BottomSheetSwitcher/behavior` |
199
+ | FR5–FR7, AR1–AR3 | `BottomSheetSwitcher.test.tsx`; `BottomSheetNativeModal.a11y.browser.spec.ts` | modal/non-modal, info/form/required, nested layer, IME, focus return, scroll lock in engines, non-modal local ordering | Modality, dismissal order, naming, inertness, scroll lock, or focus behavior diverges, or a sheet dialog takes a page-level z-index. | `audit:BottomSheetSwitcher/accessibility` |
200
+ | FR9 | `BottomSheetSwitcher.test.tsx`; export checks | ref across open/handoff/close/unmount, callback-ref cleanup, `id` once, DOM/ARIA/data/events, class, style, xstyle | A supported input is dropped or duplicated, an object ref is null while a sheet is mounted or skips a cleanup, or an input overrides component-owned semantics accidentally. | `audit:BottomSheetSwitcher/api` |
201
+ | Theming anatomy | `scripts/check-knowledge.mjs`; theming tests | dialog, delegated sheet panel, scrim | A non-painting host gains a target, a delegated panel loses its owner, or the scrim gap disappears without review. | `audit:BottomSheetSwitcher/theming` |
201
202
 
202
203
  ## Decision log
203
204
 
@@ -10,7 +10,7 @@
10
10
  * update these tests to match the public behavior.
11
11
  */
12
12
 
13
- import {fireEvent, render, screen} from '@testing-library/react';
13
+ import {act, fireEvent, render, screen} from '@testing-library/react';
14
14
  import {
15
15
  StrictMode,
16
16
  createRef,
@@ -22,6 +22,9 @@ import {
22
22
  import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
23
23
  import {hasActiveFocusTrapEscape, useFocusTrap} from '../hooks';
24
24
  import {useLayerDismissal} from '../Layer/useLayerDismissal';
25
+ import {Dialog} from '../Dialog';
26
+ import {hydrateRoot} from 'react-dom/client';
27
+ import {renderToString} from 'react-dom/server';
25
28
  import {BottomSheet} from './BottomSheet';
26
29
  import {BottomSheetSwitcher} from './BottomSheetSwitcher';
27
30
 
@@ -260,6 +263,12 @@ function RequiredConfirmFlow() {
260
263
  );
261
264
  }
262
265
 
266
+ /**
267
+ * A three-step flow that mounts closed, for the host-dialog contract: the
268
+ * switcher's ref, `id`, and `data-testid`. `onMountLayout` and
269
+ * `onMountPassive` run in the consumer's own mount effects, where a parent
270
+ * would first read the ref.
271
+ */
263
272
  function HostFlow({
264
273
  dialogRef,
265
274
  dialogProps,
@@ -344,6 +353,50 @@ function isScrollLockEngaged(): boolean {
344
353
  return document.body.style.position === 'fixed';
345
354
  }
346
355
 
356
+ /** A two-step flow whose second step opens a Core Dialog above itself. */
357
+ function DialogInStepFlow() {
358
+ const [activeSheet, setActiveSheet] = useState<string | null>(null);
359
+ const [isDialogOpen, setIsDialogOpen] = useState(false);
360
+ return (
361
+ <>
362
+ <button type="button" onClick={() => setActiveSheet('details')}>
363
+ Start flow
364
+ </button>
365
+ <BottomSheetSwitcher
366
+ activeSheet={activeSheet}
367
+ onActiveSheetChange={setActiveSheet}>
368
+ <BottomSheet
369
+ sheetId="details"
370
+ label="Details"
371
+ data-testid="details-sheet">
372
+ <button type="button" onClick={() => setActiveSheet('confirm')}>
373
+ Continue
374
+ </button>
375
+ </BottomSheet>
376
+ <BottomSheet
377
+ sheetId="confirm"
378
+ label="Confirm"
379
+ data-testid="confirm-sheet">
380
+ <button type="button" onClick={() => setIsDialogOpen(true)}>
381
+ Open dialog
382
+ </button>
383
+ <Dialog
384
+ isOpen={isDialogOpen}
385
+ onOpenChange={setIsDialogOpen}
386
+ aria-label="Are you sure">
387
+ <button type="button" onClick={() => setIsDialogOpen(false)}>
388
+ Close dialog
389
+ </button>
390
+ </Dialog>
391
+ <button type="button" onClick={() => setActiveSheet(null)}>
392
+ Done
393
+ </button>
394
+ </BottomSheet>
395
+ </BottomSheetSwitcher>
396
+ </>
397
+ );
398
+ }
399
+
347
400
  /**
348
401
  * Records every native dialog call with the dialog's accessible label, and
349
402
  * returns focus the way Chromium and WebKit do: close() on a dialog presented
@@ -1352,6 +1405,42 @@ describe('BottomSheetSwitcher', () => {
1352
1405
  expect(window.scrollTo).toHaveBeenCalledWith(0, 120);
1353
1406
  });
1354
1407
 
1408
+ it('keeps the lock engaged under a Core Dialog opened from a step, and the Dialog paints above the step', () => {
1409
+ render(<DialogInStepFlow />);
1410
+ fireEvent.click(screen.getByRole('button', {name: 'Start flow'}));
1411
+ fireEvent.click(screen.getByRole('button', {name: 'Continue'}));
1412
+ finishSheetTransition(getSheetLayer('confirm-sheet'), 'transform');
1413
+ finishSheetTransition(getSheetLayer('details-sheet'), 'opacity');
1414
+ const confirmDialog = getSheetDialog('confirm-sheet');
1415
+
1416
+ fireEvent.click(screen.getByRole('button', {name: 'Open dialog'}));
1417
+ const dialog = screen.getByRole('dialog', {name: 'Are you sure'});
1418
+ expect(dialog).toHaveAttribute('open');
1419
+ // The Dialog was presented after the step's dialog, so the top layer
1420
+ // paints it above; the Dialog and the flow share the lock's counter,
1421
+ // so the step beneath keeps the pin when the Dialog gives its hold back.
1422
+ expect(HTMLDialogElement.prototype.showModal).toHaveBeenLastCalledWith();
1423
+ expect(
1424
+ vi.mocked(HTMLDialogElement.prototype.showModal).mock.contexts.at(-1),
1425
+ ).toBe(dialog);
1426
+ expect(confirmDialog).toHaveAttribute('open');
1427
+ expect(isScrollLockEngaged()).toBe(true);
1428
+
1429
+ expect(window.scrollTo).not.toHaveBeenCalled();
1430
+
1431
+ // Escape reaches the Dialog first, not the step beneath it.
1432
+ fireEvent.keyDown(dialog, {key: 'Escape'});
1433
+ expect(dialog).not.toHaveAttribute('open');
1434
+ expect(confirmDialog).toHaveAttribute('open');
1435
+ expect(isScrollLockEngaged()).toBe(true);
1436
+ expect(window.scrollTo).not.toHaveBeenCalled();
1437
+
1438
+ fireEvent.click(screen.getByRole('button', {name: 'Done'}));
1439
+ finishSheetTransition(getSheetLayer('confirm-sheet'), 'transform');
1440
+ expect(isScrollLockEngaged()).toBe(false);
1441
+ expect(window.scrollTo).toHaveBeenCalledTimes(1);
1442
+ });
1443
+
1355
1444
  it("resolves the switcher ref to the host sheet's dialog and never to null while a sheet is mounted, from the first commit on", () => {
1356
1445
  const dialogRef = createRef<HTMLDialogElement>();
1357
1446
  const seenAtMount: {layout?: Element | null; passive?: Element | null} =
@@ -1473,6 +1562,88 @@ describe('BottomSheetSwitcher', () => {
1473
1562
  expect(withId()).toEqual([dialogs[1]]);
1474
1563
  });
1475
1564
 
1565
+ it("renders the switcher id and data-testid once, on the active sheet's dialog, in the server markup of a flow that mounts open", () => {
1566
+ // The active sheet is known from props, so the host needs no commit:
1567
+ // server markup carries both attributes on that sheet's dialog, once.
1568
+ const markup = renderToString(
1569
+ <BottomSheetSwitcher
1570
+ id="checkout"
1571
+ data-testid="checkout-flow"
1572
+ activeSheet="confirm"
1573
+ onActiveSheetChange={() => {}}>
1574
+ <BottomSheet sheetId="details" label="Details">
1575
+ Content
1576
+ </BottomSheet>
1577
+ <BottomSheet sheetId="confirm" label="Confirm">
1578
+ Content
1579
+ </BottomSheet>
1580
+ </BottomSheetSwitcher>,
1581
+ );
1582
+ const dialogs = markup.match(/<dialog\b[^>]*>/g) ?? [];
1583
+ expect(dialogs).toHaveLength(2);
1584
+ expect(markup.match(/id="checkout"/g)).toHaveLength(1);
1585
+ expect(markup.match(/data-testid="checkout-flow"/g)).toHaveLength(1);
1586
+ const host = dialogs.find(tag => tag.includes('id="checkout"'));
1587
+ expect(host).toContain('aria-label="Confirm"');
1588
+ expect(host).toContain('data-testid="checkout-flow"');
1589
+ expect(
1590
+ dialogs.find(tag => tag.includes('aria-label="Details"')),
1591
+ ).not.toContain('id=');
1592
+ });
1593
+
1594
+ it('renders every sheet dialog closed in server markup, with the switcher id on no element until the first commit', () => {
1595
+ // Which sheet mounts first is known once its dialog registers during
1596
+ // the first commit; server rendering has no commit, so the id waits for
1597
+ // the client. What server markup must still get right: one closed
1598
+ // dialog per sheet, none `open`, and the id never duplicated.
1599
+ const markup = renderToString(
1600
+ <BottomSheetSwitcher
1601
+ id="checkout"
1602
+ data-testid="checkout-flow"
1603
+ activeSheet={null}
1604
+ onActiveSheetChange={() => {}}>
1605
+ <BottomSheet sheetId="details" label="Details">
1606
+ Content
1607
+ </BottomSheet>
1608
+ <BottomSheet sheetId="confirm" label="Confirm">
1609
+ Content
1610
+ </BottomSheet>
1611
+ </BottomSheetSwitcher>,
1612
+ );
1613
+ expect(markup.match(/<dialog\b/g)).toHaveLength(2);
1614
+ expect(markup).not.toMatch(/<dialog[^>]*\sopen/);
1615
+ expect(markup.match(/id="checkout"/g) ?? []).toHaveLength(0);
1616
+
1617
+ // Hydrating the same tree on the client: the first commit's synchronous
1618
+ // re-render puts the id on the first sheet's dialog, exactly once.
1619
+ const container = document.createElement('div');
1620
+ container.innerHTML = markup;
1621
+ document.body.appendChild(container);
1622
+ act(() => {
1623
+ hydrateRoot(
1624
+ container,
1625
+ <BottomSheetSwitcher
1626
+ id="checkout"
1627
+ data-testid="checkout-flow"
1628
+ activeSheet={null}
1629
+ onActiveSheetChange={() => {}}>
1630
+ <BottomSheet sheetId="details" label="Details">
1631
+ Content
1632
+ </BottomSheet>
1633
+ <BottomSheet sheetId="confirm" label="Confirm">
1634
+ Content
1635
+ </BottomSheet>
1636
+ </BottomSheetSwitcher>,
1637
+ );
1638
+ });
1639
+ const withId = container.querySelectorAll('[id="checkout"]');
1640
+ expect(withId).toHaveLength(1);
1641
+ expect(withId[0]).toBe(container.querySelector('dialog'));
1642
+ expect(withId[0]).toHaveAttribute('data-testid', 'checkout-flow');
1643
+ expect(withId[0]).toHaveAttribute('aria-label', 'Details');
1644
+ container.remove();
1645
+ });
1646
+
1476
1647
  it('orders a non-modal handoff inside the switcher-owned isolation surface, with no page-wide z-index on a sheet dialog', () => {
1477
1648
  render(<HostFlow hasScrim={false} initialSheet="details" />);
1478
1649
  const detailsDialog = getSheetDialog('details-sheet');
@@ -1544,6 +1715,55 @@ describe('BottomSheetSwitcher', () => {
1544
1715
  expect(getSheetDialog('b')).toHaveAttribute('aria-label', 'Confirm');
1545
1716
  });
1546
1717
 
1718
+ it('forces alertdialog on a required step and leaves the other sheet dialogs with no role when the switcher sets none', () => {
1719
+ render(
1720
+ <BottomSheetSwitcher
1721
+ activeSheet="details"
1722
+ onActiveSheetChange={() => {}}>
1723
+ <BottomSheet sheetId="details" label="Details" data-testid="a">
1724
+ Content
1725
+ </BottomSheet>
1726
+ <BottomSheet
1727
+ sheetId="danger"
1728
+ label="Danger"
1729
+ purpose="required"
1730
+ data-testid="c">
1731
+ Content
1732
+ </BottomSheet>
1733
+ </BottomSheetSwitcher>,
1734
+ );
1735
+ expect(getSheetDialog('a')).not.toHaveAttribute('role');
1736
+ expect(getSheetDialog('c')).toHaveAttribute('role', 'alertdialog');
1737
+ });
1738
+
1739
+ it('keeps the scrim takeover pin under prefers-reduced-motion: the reduced duration reads the pinned variable', () => {
1740
+ render(<HostFlow initialSheet="details" />);
1741
+ // jsdom evaluates neither @media nor ::backdrop; read the compiled
1742
+ // rules the dialog's scrim class produced. The reduced-motion rule for
1743
+ // the backdrop's transition-duration must defer to the takeover pin
1744
+ // (`--_sheet-scrim-duration: 0s` for one style flush); a literal 0.01s
1745
+ // there would win the cascade and paint a frame with no scrim.
1746
+ const rules: string[] = [];
1747
+ for (const sheet of Array.from(document.styleSheets)) {
1748
+ for (const rule of Array.from(sheet.cssRules)) {
1749
+ rules.push(rule.cssText);
1750
+ }
1751
+ }
1752
+ const reducedBackdropDurations = rules.filter(
1753
+ text =>
1754
+ text.includes('prefers-reduced-motion: reduce') &&
1755
+ text.includes('::backdrop') &&
1756
+ text.includes('transition-duration'),
1757
+ );
1758
+ expect(reducedBackdropDurations.length).toBeGreaterThan(0);
1759
+ for (const text of reducedBackdropDurations) {
1760
+ expect(text).toMatch(
1761
+ /transition-duration:\s*var\(--_sheet-scrim-duration,\s*0?\.01s\)/,
1762
+ );
1763
+ expect(text).not.toMatch(/transition-duration:\s*0?\.01s/);
1764
+ }
1765
+ });
1766
+
1547
1767
  it('paints one scrim through a handoff and hands it over without a fade', () => {
1548
1768
  render(<Flow />);
1549
1769
  fireEvent.click(screen.getByRole('button', {name: 'Start flow'}));