@jsenv/navi 0.29.155 → 0.29.156

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.
@@ -5432,6 +5432,11 @@ const CONTROL_ATTRIBUTE_SET = new Set([
5432
5432
  "spellcheck",
5433
5433
  "autoCorrect",
5434
5434
  "aria-controls",
5435
+ // The name goes where the role is: the root box has none, so an aria-label
5436
+ // left on it names nothing at all, while the host is what the user focuses
5437
+ // and what a screen reader announces (and what getByRole({ name }) reads).
5438
+ "aria-label",
5439
+ "aria-labelledby",
5435
5440
  "tabIndex",
5436
5441
  "command",
5437
5442
  "commandFor",
@@ -6419,6 +6424,11 @@ const css$12 = /* css */`
6419
6424
  * @param {Object} options - Configuration options
6420
6425
  * @param {HTMLElement} [options.anchorElement] - Element the callout should follow. If not provided or too big, callout will be centered in viewport
6421
6426
  * @param {string} [options.status=""] - Callout status: "info" | "warning" | "error" | "success"
6427
+ * @param {string} [options.testId] - `data-testid` on the callout element. The callout is
6428
+ * drawn by navi, so nothing the caller renders can carry the name a test needs — same
6429
+ * situation as a picker's `popupTestId` (see docs/testid.md). A role is already there
6430
+ * for free (`status`/`alert`); reach for this when the role is not enough to tell two
6431
+ * callouts apart.
6422
6432
  * @param {Function} [options.onClose] - Callback when callout is closed
6423
6433
  * @param {boolean} [options.closeOnClickOutside] - Whether to close on outside clicks (defaults to true for "info" status)
6424
6434
  * @param {boolean} [options.icon=true] - Whether the status icon is shown beside the message.
@@ -6465,6 +6475,7 @@ const openCallout = (message, {
6465
6475
  // "success" - positive feedback (e.g., "Changes saved successfully")
6466
6476
  // "" - neutral information
6467
6477
  status = "",
6478
+ testId,
6468
6479
  onClose,
6469
6480
  closeOnClickOutside = status === "info",
6470
6481
  closeOnFocusLeave = closeOnClickOutside,
@@ -6642,6 +6653,15 @@ const openCallout = (message, {
6642
6653
  calloutElement.removeAttribute("data-icon");
6643
6654
  }
6644
6655
  }
6656
+ if (Object.hasOwn(options, "testId")) {
6657
+ // Per message, like the cross below: a callout is a slot several things
6658
+ // speak through, and the one speaking is what a test is looking at.
6659
+ if (options.testId) {
6660
+ calloutElement.setAttribute("data-testid", options.testId);
6661
+ } else {
6662
+ calloutElement.removeAttribute("data-testid");
6663
+ }
6664
+ }
6645
6665
  if (Object.hasOwn(options, "closeButton")) {
6646
6666
  // Per message rather than per callout: what replaces a message (a
6647
6667
  // constraint taking over a tooltip's callout) brings its own cross back.
@@ -7042,6 +7062,7 @@ const openCallout = (message, {
7042
7062
  }
7043
7063
  update(message, {
7044
7064
  status,
7065
+ testId,
7045
7066
  icon,
7046
7067
  closeButton
7047
7068
  });
@@ -7698,7 +7719,7 @@ const generateSvgWithoutArrow = (width, height) => {
7698
7719
  *
7699
7720
  * Usage:
7700
7721
  * const myToken = createOpenToken();
7701
- * calloutManager.addOpenToken(myToken, { message, status, anchorElement, event, skipFocus, onClose });
7722
+ * calloutManager.addOpenToken(myToken, { message, status, testId, anchorElement, event, skipFocus, onClose });
7702
7723
  * calloutManager.removeOpenToken(myToken, event);
7703
7724
  * calloutManager.requestCloseCallout(event, debugReason); // force-close all
7704
7725
  * calloutManager.callout // current open callout or null
@@ -7744,6 +7765,7 @@ const createCalloutManager = (
7744
7765
  const [, remainingTokenData] = tokens.entries().next().value;
7745
7766
  callout.update(remainingTokenData.message, {
7746
7767
  status: remainingTokenData.status,
7768
+ testId: remainingTokenData.testId,
7747
7769
  icon: remainingTokenData.icon,
7748
7770
  closeButton: remainingTokenData.closeButton,
7749
7771
  });
@@ -7770,6 +7792,7 @@ const createCalloutManager = (
7770
7792
  {
7771
7793
  message,
7772
7794
  status,
7795
+ testId,
7773
7796
  icon,
7774
7797
  closeButton,
7775
7798
  anchorElement,
@@ -7784,12 +7807,13 @@ const createCalloutManager = (
7784
7807
  }
7785
7808
  const calloutOptions = {
7786
7809
  status,
7810
+ testId,
7787
7811
  icon,
7788
7812
  closeButton,
7789
7813
  closeOnClickOutside: status !== "error",
7790
7814
  };
7791
7815
 
7792
- tokens.set(token, { message, status, icon, closeButton, onClose });
7816
+ tokens.set(token, { message, status, testId, icon, closeButton, onClose });
7793
7817
  if (callout) {
7794
7818
  callout.update(message, calloutOptions);
7795
7819
  return;
@@ -59315,6 +59339,7 @@ const PickerContentInsidePopup = props => {
59315
59339
  children: isCallout ? jsx(PickerCalloutPopup, {
59316
59340
  ...popupProps,
59317
59341
  pickerRef: props.ref,
59342
+ testId: popupTestId,
59318
59343
  status: calloutStatus,
59319
59344
  icon: calloutIcon,
59320
59345
  closeButton: calloutCloseButton,
@@ -59379,6 +59404,7 @@ const PickerCalloutPopup = ({
59379
59404
  anchor,
59380
59405
  openController,
59381
59406
  pickerRef,
59407
+ testId,
59382
59408
  status,
59383
59409
  icon,
59384
59410
  closeButton,
@@ -59404,6 +59430,10 @@ const PickerCalloutPopup = ({
59404
59430
  const anchorElement = anchor === pickerRef ? undefined : anchor && "current" in anchor ? anchor.current : anchor;
59405
59431
  calloutManager.addOpenToken(PICKER_CALLOUT_CONTENT_TOKEN, {
59406
59432
  message: hostRef.current,
59433
+ // The popup a `popupTestId` names is this callout: it is the surface the
59434
+ // picker opens, drawn by navi, so it is the one thing the caller cannot
59435
+ // name from its own children.
59436
+ testId,
59407
59437
  // "none" is the picker's word for it; the callout's is no status at all.
59408
59438
  status: status === "none" ? undefined : status,
59409
59439
  icon,