@meetreeve/ui 0.23.0 → 0.24.0

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/README.md CHANGED
@@ -187,6 +187,26 @@ its group instead (pinned items keep their input order, and a divider closes
187
187
  the pinned block), and `emphasis: true` to render its name in semibold — e.g.
188
188
  an org's default context (DEV-14817).
189
189
 
190
+ Set `badge: { label, tone }` for a status the user must see before picking the
191
+ row, e.g. `{ label: "Suspended — trial ended", tone: "danger" }` (DEV-14719).
192
+ It renders as a pill after the name in the row and in the expanded trigger;
193
+ the collapsed trigger shows a tone dot and puts the label in its accessible
194
+ name. `tone` is `danger`, `warning` or `neutral`. Keep `kindLabel` for what the
195
+ context is (a product or kind); the row reads name, badge, kind label, and its
196
+ accessible name is "Cadasense Suspended — trial ended Product". The pill never
197
+ truncates: the kind label yields first, then the name (down to a small floor).
198
+ When any item has a badge the menu sizes to its widest row (between
199
+ `min(15rem, 100vw - 1rem)` and `min(26rem, 100vw - 1rem)`), and the expanded trigger puts the pill under the
200
+ name.
201
+
202
+ The pill styles from the host's status tokens, so a Tailwind host must define
203
+ `--color-destructive-subtle(-foreground)`, `--color-warning-subtle(-foreground)`,
204
+ `--color-muted(-foreground)`, and for the dot `--color-destructive`,
205
+ `--color-warning`, `--color-sidebar` and `--color-sidebar-foreground`. `brandTheme` from `@meetreeve/ui/theme`
206
+ emits the raw variables behind all of them except `--sidebar`. Each slot has a
207
+ hook for host styling: `data-slot="context-name"`, `"context-badge"` (plus
208
+ `data-tone`), `"context-kind-label"` and `"context-badge-dot"`.
209
+
190
210
  ## InfoTip (DEV-11387)
191
211
 
192
212
  A "?" circle that reveals a short explanation, so a page can keep caveats and
package/dist/index.d.mts CHANGED
@@ -667,6 +667,18 @@ interface ContextSwitcherItem {
667
667
  pinned?: boolean;
668
668
  /** Render the row's name in semibold, to set it apart (DEV-14817). */
669
669
  emphasis?: boolean;
670
+ /**
671
+ * A status the user must see before picking this context — e.g. a
672
+ * suspended tenant (DEV-14719). Renders as a toned pill after the name, in
673
+ * the row and in the trigger, and never truncates: the name yields first.
674
+ * Status only; what the context IS stays in `kindLabel`.
675
+ */
676
+ badge?: ContextSwitcherBadge | null;
677
+ }
678
+ type ContextSwitcherBadgeTone = "danger" | "warning" | "neutral";
679
+ interface ContextSwitcherBadge {
680
+ label: string;
681
+ tone: ContextSwitcherBadgeTone;
670
682
  }
671
683
  interface ContextOrgGroup {
672
684
  orgId: string | null;
@@ -1069,4 +1081,4 @@ declare function UnlockCta({ href, title, sub, compact, onClick, linkComponent,
1069
1081
  */
1070
1082
  declare function placeholder(mask: string, seed: string): string;
1071
1083
 
1072
- export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherItem, type ContextSwitcherProps, DEFAULT_LEGAL_LINKS, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, HOVER_CLOSE_DELAY_MS, HOVER_SWITCH_DELAY_MS, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKED_BLUR_STYLE, LOCKUP_GAP, LOCKUP_ROW, LockedBlock, type LockedBlockProps, LockedValue, type LockedValueProps, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, SiteFooter, type SiteFooterLink, type SiteFooterProps, UnlockCta, type UnlockCtaProps, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, placeholder, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
1084
+ export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherBadge, type ContextSwitcherBadgeTone, type ContextSwitcherItem, type ContextSwitcherProps, DEFAULT_LEGAL_LINKS, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, HOVER_CLOSE_DELAY_MS, HOVER_SWITCH_DELAY_MS, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKED_BLUR_STYLE, LOCKUP_GAP, LOCKUP_ROW, LockedBlock, type LockedBlockProps, LockedValue, type LockedValueProps, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, SiteFooter, type SiteFooterLink, type SiteFooterProps, UnlockCta, type UnlockCtaProps, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, placeholder, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
package/dist/index.d.ts CHANGED
@@ -667,6 +667,18 @@ interface ContextSwitcherItem {
667
667
  pinned?: boolean;
668
668
  /** Render the row's name in semibold, to set it apart (DEV-14817). */
669
669
  emphasis?: boolean;
670
+ /**
671
+ * A status the user must see before picking this context — e.g. a
672
+ * suspended tenant (DEV-14719). Renders as a toned pill after the name, in
673
+ * the row and in the trigger, and never truncates: the name yields first.
674
+ * Status only; what the context IS stays in `kindLabel`.
675
+ */
676
+ badge?: ContextSwitcherBadge | null;
677
+ }
678
+ type ContextSwitcherBadgeTone = "danger" | "warning" | "neutral";
679
+ interface ContextSwitcherBadge {
680
+ label: string;
681
+ tone: ContextSwitcherBadgeTone;
670
682
  }
671
683
  interface ContextOrgGroup {
672
684
  orgId: string | null;
@@ -1069,4 +1081,4 @@ declare function UnlockCta({ href, title, sub, compact, onClick, linkComponent,
1069
1081
  */
1070
1082
  declare function placeholder(mask: string, seed: string): string;
1071
1083
 
1072
- export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherItem, type ContextSwitcherProps, DEFAULT_LEGAL_LINKS, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, HOVER_CLOSE_DELAY_MS, HOVER_SWITCH_DELAY_MS, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKED_BLUR_STYLE, LOCKUP_GAP, LOCKUP_ROW, LockedBlock, type LockedBlockProps, LockedValue, type LockedValueProps, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, SiteFooter, type SiteFooterLink, type SiteFooterProps, UnlockCta, type UnlockCtaProps, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, placeholder, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
1084
+ export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherBadge, type ContextSwitcherBadgeTone, type ContextSwitcherItem, type ContextSwitcherProps, DEFAULT_LEGAL_LINKS, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, HOVER_CLOSE_DELAY_MS, HOVER_SWITCH_DELAY_MS, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKED_BLUR_STYLE, LOCKUP_GAP, LOCKUP_ROW, LockedBlock, type LockedBlockProps, LockedValue, type LockedValueProps, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, SiteFooter, type SiteFooterLink, type SiteFooterProps, UnlockCta, type UnlockCtaProps, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, placeholder, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
package/dist/index.js CHANGED
@@ -1593,6 +1593,31 @@ function DropdownMenuLabel({
1593
1593
 
1594
1594
  // src/context-switcher.tsx
1595
1595
  var import_jsx_runtime8 = require("react/jsx-runtime");
1596
+ var BADGE_TONE_CLASSES = {
1597
+ danger: "bg-destructive-subtle text-destructive-subtle-foreground",
1598
+ warning: "bg-warning-subtle text-warning-subtle-foreground",
1599
+ neutral: "bg-muted text-muted-foreground"
1600
+ };
1601
+ var BADGE_DOT_CLASSES = {
1602
+ danger: "bg-destructive",
1603
+ warning: "bg-warning",
1604
+ neutral: "bg-sidebar-foreground"
1605
+ };
1606
+ var NAME_FLOOR = "min-w-12";
1607
+ function StatusBadge({ badge }) {
1608
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1609
+ "span",
1610
+ {
1611
+ "data-slot": "context-badge",
1612
+ "data-tone": badge.tone,
1613
+ className: cn(
1614
+ "inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-1.5 py-0.5 text-xs font-medium leading-none",
1615
+ BADGE_TONE_CLASSES[badge.tone] ?? BADGE_TONE_CLASSES.neutral
1616
+ ),
1617
+ children: badge.label
1618
+ }
1619
+ );
1620
+ }
1596
1621
  function groupByOrg(items) {
1597
1622
  return groupItemsByOrg(items, {
1598
1623
  orgId: (it) => it.orgId,
@@ -1622,27 +1647,69 @@ function ContextSwitcher({
1622
1647
  contentClassName
1623
1648
  }) {
1624
1649
  const active = items.find((it) => it.refId === activeRefId) ?? null;
1650
+ const activeBadge = active?.badge?.label ? active.badge : null;
1651
+ const hasBadges = items.some((it) => it.badge?.label);
1652
+ const collapsedLabel = [active?.name || placeholder2, activeBadge?.label].filter(Boolean).join(" ");
1625
1653
  const groups = groupByOrg(items);
1626
1654
  const showOrgHeaders = groups.length > 1;
1627
1655
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(DropdownMenu, { children: [
1628
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1656
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1629
1657
  "button",
1630
1658
  {
1631
1659
  type: "button",
1632
- title: active?.name || placeholder2,
1633
- "aria-label": active?.name || placeholder2,
1634
- className: "flex h-10 w-10 items-center justify-center rounded-lg text-sidebar-foreground/70 transition-colors hover:bg-sidebar-foreground/5 hover:text-sidebar-foreground",
1635
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BrandGlyph, { brand: toBrand(active ?? { name: "" }), size: "lg" })
1660
+ title: collapsedLabel,
1661
+ "aria-label": collapsedLabel,
1662
+ className: "relative flex h-10 w-10 items-center justify-center rounded-lg text-sidebar-foreground/70 transition-colors hover:bg-sidebar-foreground/5 hover:text-sidebar-foreground",
1663
+ children: [
1664
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BrandGlyph, { brand: toBrand(active ?? { name: "" }), size: "lg" }),
1665
+ activeBadge && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1666
+ "span",
1667
+ {
1668
+ "data-slot": "context-badge-dot",
1669
+ "data-tone": activeBadge.tone,
1670
+ "aria-hidden": "true",
1671
+ className: cn(
1672
+ "absolute right-1 top-1 size-2.5 rounded-full ring-2 ring-sidebar",
1673
+ BADGE_DOT_CLASSES[activeBadge.tone] ?? BADGE_DOT_CLASSES.neutral
1674
+ )
1675
+ }
1676
+ )
1677
+ ]
1636
1678
  }
1637
1679
  ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1638
1680
  "button",
1639
1681
  {
1640
1682
  type: "button",
1641
- className: "group flex items-center gap-2 rounded-md border border-sidebar-border bg-sidebar-accent/60 px-2.5 py-1.5 text-sm font-medium transition-colors hover:bg-sidebar",
1683
+ className: cn(
1684
+ "group flex items-center gap-2 rounded-md border border-sidebar-border bg-sidebar-accent/60 px-2.5 py-1.5 text-sm font-medium transition-colors hover:bg-sidebar",
1685
+ activeBadge && "max-w-full"
1686
+ ),
1642
1687
  children: [
1643
1688
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BrandGlyph, { brand: toBrand(active ?? { name: "" }) }),
1644
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "max-w-[140px] truncate text-sidebar-accent-foreground", children: active?.name || placeholder2 }),
1645
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronDown, { className: "h-3.5 w-3.5 text-sidebar-foreground/70 transition-transform group-data-[state=open]:rotate-180" })
1689
+ activeBadge ? (
1690
+ // A rail is too narrow for name + pill on one line, so the pill
1691
+ // sits under the name: both stay readable, the name truncates.
1692
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "flex min-w-0 flex-col items-start gap-1", children: [
1693
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1694
+ "span",
1695
+ {
1696
+ "data-slot": "context-name",
1697
+ className: "max-w-full truncate text-sidebar-accent-foreground",
1698
+ children: active?.name || placeholder2
1699
+ }
1700
+ ),
1701
+ " ",
1702
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StatusBadge, { badge: activeBadge })
1703
+ ] })
1704
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1705
+ "span",
1706
+ {
1707
+ "data-slot": "context-name",
1708
+ className: "max-w-[140px] truncate text-sidebar-accent-foreground",
1709
+ children: active?.name || placeholder2
1710
+ }
1711
+ ),
1712
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronDown, { className: "h-3.5 w-3.5 shrink-0 text-sidebar-foreground/70 transition-transform group-data-[state=open]:rotate-180" })
1646
1713
  ]
1647
1714
  }
1648
1715
  ) }),
@@ -1653,12 +1720,19 @@ function ContextSwitcher({
1653
1720
  align,
1654
1721
  sideOffset: 6,
1655
1722
  collisionPadding: 8,
1656
- className: cn("w-60 overflow-hidden p-0", contentClassName),
1723
+ className: cn(
1724
+ // `!` on the floor: `cn` only joins strings, and the primitive's own
1725
+ // `min-w-[8rem]` otherwise wins the cascade.
1726
+ hasBadges ? "w-max !min-w-[min(15rem,calc(100vw-1rem))] max-w-[min(26rem,calc(100vw-1rem))]" : "w-60",
1727
+ "overflow-hidden p-0",
1728
+ contentClassName
1729
+ ),
1657
1730
  children: [
1658
1731
  groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1659
1732
  showOrgHeaders && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuLabel, { className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: group.orgName ?? "Other" }),
1660
1733
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
1661
1734
  const isActive = item.refId === activeRefId;
1735
+ const badge = item.badge?.label ? item.badge : null;
1662
1736
  const next = group.items[i + 1];
1663
1737
  const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
1664
1738
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
@@ -1677,16 +1751,35 @@ function ContextSwitcher({
1677
1751
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1678
1752
  "span",
1679
1753
  {
1754
+ "data-slot": "context-name",
1680
1755
  className: cn(
1681
1756
  "flex-1 truncate text-left",
1757
+ badge && NAME_FLOOR,
1682
1758
  item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
1683
1759
  ),
1684
1760
  children: item.name
1685
1761
  }
1686
1762
  ),
1763
+ badge && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1764
+ " ",
1765
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StatusBadge, { badge })
1766
+ ] }),
1687
1767
  item.kindLabel && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1688
1768
  " ",
1689
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: item.kindLabel })
1769
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1770
+ "span",
1771
+ {
1772
+ "data-slot": "context-kind-label",
1773
+ className: cn(
1774
+ "text-[11px] text-muted-foreground",
1775
+ // Beside a badge the kind label is what yields, so
1776
+ // status and (at least the start of) the name stay
1777
+ // on screen in a narrow menu (DEV-14719).
1778
+ badge ? "min-w-0 truncate" : "shrink-0"
1779
+ ),
1780
+ children: item.kindLabel
1781
+ }
1782
+ )
1690
1783
  ] }),
1691
1784
  isActive && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Check, { className: "size-3.5 text-emerald-500" })
1692
1785
  ]
package/dist/index.mjs CHANGED
@@ -1527,6 +1527,31 @@ function DropdownMenuLabel({
1527
1527
 
1528
1528
  // src/context-switcher.tsx
1529
1529
  import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1530
+ var BADGE_TONE_CLASSES = {
1531
+ danger: "bg-destructive-subtle text-destructive-subtle-foreground",
1532
+ warning: "bg-warning-subtle text-warning-subtle-foreground",
1533
+ neutral: "bg-muted text-muted-foreground"
1534
+ };
1535
+ var BADGE_DOT_CLASSES = {
1536
+ danger: "bg-destructive",
1537
+ warning: "bg-warning",
1538
+ neutral: "bg-sidebar-foreground"
1539
+ };
1540
+ var NAME_FLOOR = "min-w-12";
1541
+ function StatusBadge({ badge }) {
1542
+ return /* @__PURE__ */ jsx8(
1543
+ "span",
1544
+ {
1545
+ "data-slot": "context-badge",
1546
+ "data-tone": badge.tone,
1547
+ className: cn(
1548
+ "inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-1.5 py-0.5 text-xs font-medium leading-none",
1549
+ BADGE_TONE_CLASSES[badge.tone] ?? BADGE_TONE_CLASSES.neutral
1550
+ ),
1551
+ children: badge.label
1552
+ }
1553
+ );
1554
+ }
1530
1555
  function groupByOrg(items) {
1531
1556
  return groupItemsByOrg(items, {
1532
1557
  orgId: (it) => it.orgId,
@@ -1556,27 +1581,69 @@ function ContextSwitcher({
1556
1581
  contentClassName
1557
1582
  }) {
1558
1583
  const active = items.find((it) => it.refId === activeRefId) ?? null;
1584
+ const activeBadge = active?.badge?.label ? active.badge : null;
1585
+ const hasBadges = items.some((it) => it.badge?.label);
1586
+ const collapsedLabel = [active?.name || placeholder2, activeBadge?.label].filter(Boolean).join(" ");
1559
1587
  const groups = groupByOrg(items);
1560
1588
  const showOrgHeaders = groups.length > 1;
1561
1589
  return /* @__PURE__ */ jsxs7(DropdownMenu, { children: [
1562
- /* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ jsx8(
1590
+ /* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ jsxs7(
1563
1591
  "button",
1564
1592
  {
1565
1593
  type: "button",
1566
- title: active?.name || placeholder2,
1567
- "aria-label": active?.name || placeholder2,
1568
- className: "flex h-10 w-10 items-center justify-center rounded-lg text-sidebar-foreground/70 transition-colors hover:bg-sidebar-foreground/5 hover:text-sidebar-foreground",
1569
- children: /* @__PURE__ */ jsx8(BrandGlyph, { brand: toBrand(active ?? { name: "" }), size: "lg" })
1594
+ title: collapsedLabel,
1595
+ "aria-label": collapsedLabel,
1596
+ className: "relative flex h-10 w-10 items-center justify-center rounded-lg text-sidebar-foreground/70 transition-colors hover:bg-sidebar-foreground/5 hover:text-sidebar-foreground",
1597
+ children: [
1598
+ /* @__PURE__ */ jsx8(BrandGlyph, { brand: toBrand(active ?? { name: "" }), size: "lg" }),
1599
+ activeBadge && /* @__PURE__ */ jsx8(
1600
+ "span",
1601
+ {
1602
+ "data-slot": "context-badge-dot",
1603
+ "data-tone": activeBadge.tone,
1604
+ "aria-hidden": "true",
1605
+ className: cn(
1606
+ "absolute right-1 top-1 size-2.5 rounded-full ring-2 ring-sidebar",
1607
+ BADGE_DOT_CLASSES[activeBadge.tone] ?? BADGE_DOT_CLASSES.neutral
1608
+ )
1609
+ }
1610
+ )
1611
+ ]
1570
1612
  }
1571
1613
  ) : /* @__PURE__ */ jsxs7(
1572
1614
  "button",
1573
1615
  {
1574
1616
  type: "button",
1575
- className: "group flex items-center gap-2 rounded-md border border-sidebar-border bg-sidebar-accent/60 px-2.5 py-1.5 text-sm font-medium transition-colors hover:bg-sidebar",
1617
+ className: cn(
1618
+ "group flex items-center gap-2 rounded-md border border-sidebar-border bg-sidebar-accent/60 px-2.5 py-1.5 text-sm font-medium transition-colors hover:bg-sidebar",
1619
+ activeBadge && "max-w-full"
1620
+ ),
1576
1621
  children: [
1577
1622
  /* @__PURE__ */ jsx8(BrandGlyph, { brand: toBrand(active ?? { name: "" }) }),
1578
- /* @__PURE__ */ jsx8("span", { className: "max-w-[140px] truncate text-sidebar-accent-foreground", children: active?.name || placeholder2 }),
1579
- /* @__PURE__ */ jsx8(ChevronDown, { className: "h-3.5 w-3.5 text-sidebar-foreground/70 transition-transform group-data-[state=open]:rotate-180" })
1623
+ activeBadge ? (
1624
+ // A rail is too narrow for name + pill on one line, so the pill
1625
+ // sits under the name: both stay readable, the name truncates.
1626
+ /* @__PURE__ */ jsxs7("span", { className: "flex min-w-0 flex-col items-start gap-1", children: [
1627
+ /* @__PURE__ */ jsx8(
1628
+ "span",
1629
+ {
1630
+ "data-slot": "context-name",
1631
+ className: "max-w-full truncate text-sidebar-accent-foreground",
1632
+ children: active?.name || placeholder2
1633
+ }
1634
+ ),
1635
+ " ",
1636
+ /* @__PURE__ */ jsx8(StatusBadge, { badge: activeBadge })
1637
+ ] })
1638
+ ) : /* @__PURE__ */ jsx8(
1639
+ "span",
1640
+ {
1641
+ "data-slot": "context-name",
1642
+ className: "max-w-[140px] truncate text-sidebar-accent-foreground",
1643
+ children: active?.name || placeholder2
1644
+ }
1645
+ ),
1646
+ /* @__PURE__ */ jsx8(ChevronDown, { className: "h-3.5 w-3.5 shrink-0 text-sidebar-foreground/70 transition-transform group-data-[state=open]:rotate-180" })
1580
1647
  ]
1581
1648
  }
1582
1649
  ) }),
@@ -1587,12 +1654,19 @@ function ContextSwitcher({
1587
1654
  align,
1588
1655
  sideOffset: 6,
1589
1656
  collisionPadding: 8,
1590
- className: cn("w-60 overflow-hidden p-0", contentClassName),
1657
+ className: cn(
1658
+ // `!` on the floor: `cn` only joins strings, and the primitive's own
1659
+ // `min-w-[8rem]` otherwise wins the cascade.
1660
+ hasBadges ? "w-max !min-w-[min(15rem,calc(100vw-1rem))] max-w-[min(26rem,calc(100vw-1rem))]" : "w-60",
1661
+ "overflow-hidden p-0",
1662
+ contentClassName
1663
+ ),
1591
1664
  children: [
1592
1665
  groups.map((group) => /* @__PURE__ */ jsxs7("div", { children: [
1593
1666
  showOrgHeaders && /* @__PURE__ */ jsx8(DropdownMenuLabel, { className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: group.orgName ?? "Other" }),
1594
1667
  /* @__PURE__ */ jsx8("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
1595
1668
  const isActive = item.refId === activeRefId;
1669
+ const badge = item.badge?.label ? item.badge : null;
1596
1670
  const next = group.items[i + 1];
1597
1671
  const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
1598
1672
  return /* @__PURE__ */ jsxs7(
@@ -1611,16 +1685,35 @@ function ContextSwitcher({
1611
1685
  /* @__PURE__ */ jsx8(
1612
1686
  "span",
1613
1687
  {
1688
+ "data-slot": "context-name",
1614
1689
  className: cn(
1615
1690
  "flex-1 truncate text-left",
1691
+ badge && NAME_FLOOR,
1616
1692
  item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
1617
1693
  ),
1618
1694
  children: item.name
1619
1695
  }
1620
1696
  ),
1697
+ badge && /* @__PURE__ */ jsxs7(Fragment3, { children: [
1698
+ " ",
1699
+ /* @__PURE__ */ jsx8(StatusBadge, { badge })
1700
+ ] }),
1621
1701
  item.kindLabel && /* @__PURE__ */ jsxs7(Fragment3, { children: [
1622
1702
  " ",
1623
- /* @__PURE__ */ jsx8("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: item.kindLabel })
1703
+ /* @__PURE__ */ jsx8(
1704
+ "span",
1705
+ {
1706
+ "data-slot": "context-kind-label",
1707
+ className: cn(
1708
+ "text-[11px] text-muted-foreground",
1709
+ // Beside a badge the kind label is what yields, so
1710
+ // status and (at least the start of) the name stay
1711
+ // on screen in a narrow menu (DEV-14719).
1712
+ badge ? "min-w-0 truncate" : "shrink-0"
1713
+ ),
1714
+ children: item.kindLabel
1715
+ }
1716
+ )
1624
1717
  ] }),
1625
1718
  isActive && /* @__PURE__ */ jsx8(Check, { className: "size-3.5 text-emerald-500" })
1626
1719
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetreeve/ui",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Shared brand-adaptive UI primitives for MindFortress frontends — min-size tokens, a favicon→logo→monogram BrandGlyph, a responsive header that keeps the search bar usable on mobile, AppSidebar's viewport-driven auto-collapse ladder, the StageRail flow-of-cards primitives, the tenant SiteFooter, the LockedValue/LockedBlock/UnlockCta paywall primitives, the @meetreeve/ui/charts dashboard kit (token-driven charts, KpiCard, ChartCard, DashboardGrid), and @meetreeve/ui/theme (brandTheme: one brand's inputs to contrast-checked light and dark semantic tokens, with the Reeve preset).",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",