@eqtylab/equality 5.0.1 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  Notable changes to Equality are recorded here, following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
4
 
5
+ ## 5.0.2 - 2026-10-28
6
+
7
+ ### Added
8
+
9
+ - `NavSwitcher` takes `error`, `retrying` and `onRetry`, and `error` needs `onRetry`. With `error`,
10
+ the list shows "Couldn't load {collection}." with a Retry row above any options it already has.
11
+ Picking Retry calls `onRetry` and keeps the list open; with `retrying` the row reads
12
+ "Retrying...". Screen readers hear the failure, the retry and its result, but not a refetch of a
13
+ list that never failed.
14
+
15
+ ### Changed
16
+
17
+ - A `NavSwitcher` with one option is now a switcher where it was a plain heading, so a user with a
18
+ single project sees the switcher they will get with more. Apps showing one item will see a
19
+ dropdown appear. It is a plain heading only when it has no options, no `action` and no `error`.
20
+ - `Spinner` renders spans, not divs, so it can sit inside text such as a select option.
21
+
5
22
  ## 5.0.1 - 2026-10-28
6
23
 
7
24
  ### Fixed
package/dist/index.cjs CHANGED
@@ -2768,9 +2768,9 @@ var Input = React15__namespace.forwardRef(
2768
2768
  );
2769
2769
  Input.displayName = "Input";
2770
2770
  var Spinner = ({ size = "md", variant = "primary" }) => {
2771
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles31__default.default["spinner-container"], children: [
2772
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles31__default.default["spinner"], styles31__default.default[size], styles31__default.default[variant]) }),
2773
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles31__default.default["spinner-background"], styles31__default.default[size]) })
2771
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles31__default.default["spinner-container"], children: [
2772
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(styles31__default.default["spinner"], styles31__default.default[size], styles31__default.default[variant]) }),
2773
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(styles31__default.default["spinner-background"], styles31__default.default[size]) })
2774
2774
  ] });
2775
2775
  };
2776
2776
  function LoadingOverlay({ isVisible, message = "Loading..." }) {
@@ -3490,11 +3490,39 @@ function Skeleton({ className, ...props }) {
3490
3490
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles39__default.default["skeleton"], className), ...props });
3491
3491
  }
3492
3492
  var NavSwitcherSelect = React15__namespace.forwardRef(
3493
- ({ label, noun, collection, options, value, onValueChange, onHighlight, onHighlightEnd, action }, ref) => {
3493
+ ({
3494
+ label,
3495
+ noun,
3496
+ collection,
3497
+ options,
3498
+ value,
3499
+ onValueChange,
3500
+ onHighlight,
3501
+ onHighlightEnd,
3502
+ action,
3503
+ error,
3504
+ retrying,
3505
+ onRetry
3506
+ }, ref) => {
3494
3507
  const labelId = React15__namespace.useId();
3495
3508
  const actionValue = React15__namespace.useId();
3509
+ const retryValue = React15__namespace.useId();
3510
+ const errorId = React15__namespace.useId();
3496
3511
  const actionPending = React15__namespace.useRef(false);
3497
- if (options.length <= 1 && !action) {
3512
+ const [open, setOpen] = React15__namespace.useState(false);
3513
+ const keepOpen = React15__namespace.useRef(false);
3514
+ const [announcement, setAnnouncement] = React15__namespace.useState("");
3515
+ const [listState, setListState] = React15__namespace.useState({ error, retrying });
3516
+ if (listState.error !== error || listState.retrying !== retrying) {
3517
+ setListState({ error, retrying });
3518
+ if (error || listState.error) {
3519
+ setAnnouncement(
3520
+ error ? retrying ? "Retrying..." : `Couldn't load ${collection}.` : options.length > 0 ? `Loaded ${collection}.` : `No ${collection} found.`
3521
+ );
3522
+ }
3523
+ }
3524
+ const empty = options.length === 0 && !action && !error;
3525
+ if (empty && !open) {
3498
3526
  return /* @__PURE__ */ jsxRuntime.jsx("h2", { className: styles40__default.default["nav-switcher-heading"], children: /* @__PURE__ */ jsxRuntime.jsx(
3499
3527
  "span",
3500
3528
  {
@@ -3508,9 +3536,24 @@ var NavSwitcherSelect = React15__namespace.forwardRef(
3508
3536
  Select,
3509
3537
  {
3510
3538
  value,
3539
+ open,
3540
+ onOpenChange: (next) => {
3541
+ if (!next && keepOpen.current) keepOpen.current = false;
3542
+ else {
3543
+ setOpen(next);
3544
+ setAnnouncement("");
3545
+ }
3546
+ },
3511
3547
  onValueChange: (next) => {
3512
3548
  if (next === actionValue) actionPending.current = true;
3513
- else onValueChange(next);
3549
+ else if (next === retryValue) {
3550
+ if (!open) return;
3551
+ keepOpen.current = true;
3552
+ queueMicrotask(() => {
3553
+ keepOpen.current = false;
3554
+ });
3555
+ if (!retrying) onRetry?.();
3556
+ } else onValueChange(next);
3514
3557
  },
3515
3558
  children: [
3516
3559
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -3544,14 +3587,48 @@ var NavSwitcherSelect = React15__namespace.forwardRef(
3544
3587
  action?.onSelect();
3545
3588
  },
3546
3589
  children: [
3590
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles40__default.default["nav-switcher-status"], role: "status", "aria-live": "polite", children: announcement }),
3547
3591
  /* @__PURE__ */ jsxRuntime.jsx(
3548
3592
  SelectSearch,
3549
3593
  {
3550
3594
  placeholder: `Search ${collection}...`,
3551
- "aria-label": `Search ${collection}`
3595
+ "aria-label": `Search ${collection}`,
3596
+ "aria-describedby": error ? errorId : void 0
3552
3597
  }
3553
3598
  ),
3554
- /* @__PURE__ */ jsxRuntime.jsxs(SelectEmpty, { children: [
3599
+ error && /* @__PURE__ */ jsxRuntime.jsx(
3600
+ SelectItem,
3601
+ {
3602
+ value: retryValue,
3603
+ textValue: `Couldn't load ${collection}. ${retrying ? "Retrying" : "Retry"}`,
3604
+ persistent: true,
3605
+ "aria-disabled": retrying || void 0,
3606
+ className: styles40__default.default["nav-switcher-retry"],
3607
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles40__default.default["nav-switcher-error"], children: [
3608
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { id: errorId, className: styles40__default.default["nav-switcher-error-message"], children: [
3609
+ /* @__PURE__ */ jsxRuntime.jsx(
3610
+ LucideIcons.TriangleAlert,
3611
+ {
3612
+ className: styles40__default.default["nav-switcher-error-icon"],
3613
+ "aria-hidden": "true"
3614
+ }
3615
+ ),
3616
+ "Couldn't load ",
3617
+ collection,
3618
+ "."
3619
+ ] }),
3620
+ retrying ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles40__default.default["nav-switcher-error-message"], children: [
3621
+ /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: "xs", variant: "neutral" }),
3622
+ "Retrying..."
3623
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: buttonVariants({ variant: "link", size: "sm" }), children: "Retry" })
3624
+ ] })
3625
+ }
3626
+ ),
3627
+ empty ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles40__default.default["nav-switcher-empty"], children: [
3628
+ "No ",
3629
+ collection,
3630
+ " found"
3631
+ ] }) : (!error || options.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs(SelectEmpty, { children: [
3555
3632
  "No ",
3556
3633
  collection,
3557
3634
  " found"