@meetreeve/ui 0.17.0 → 0.18.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
@@ -158,6 +158,11 @@ single-org case stays a flat list. `collapsed` swaps the trigger for an
158
158
  icon-only button (56px nav rail); `footer` adds a slot below the list (e.g.
159
159
  an "Add brand" CTA).
160
160
 
161
+ Rows sort by name within each org group. Set `pinned: true` on an item to lead
162
+ its group instead (pinned items keep their input order, and a divider closes
163
+ the pinned block), and `emphasis: true` to render its name in semibold — e.g.
164
+ an org's default context (DEV-14817).
165
+
161
166
  ## InfoTip (DEV-11387)
162
167
 
163
168
  A "?" circle that reveals a short explanation, so a page can keep caveats and
package/dist/index.d.mts CHANGED
@@ -615,13 +615,23 @@ interface ContextSwitcherItem {
615
615
  * host knows its own vocabulary for telling them apart.
616
616
  */
617
617
  kindLabel?: string | null;
618
+ /**
619
+ * Lead this row's org group instead of sorting by name (DEV-14817) — e.g.
620
+ * a host's "all" scope sentinel, or the org's default context. Pinned rows
621
+ * keep the order they were passed in; a divider separates them from the
622
+ * alphabetical rest.
623
+ */
624
+ pinned?: boolean;
625
+ /** Render the row's name in semibold, to set it apart (DEV-14817). */
626
+ emphasis?: boolean;
618
627
  }
619
628
  interface ContextOrgGroup {
620
629
  orgId: string | null;
621
630
  orgName: string | null;
622
631
  items: ContextSwitcherItem[];
623
632
  }
624
- /** Group contexts by owning org. Items sort by name; groups by org name. */
633
+ /** Group contexts by owning org. Pinned items lead their group in input
634
+ * order; the rest sort by name. Groups sort by org name. */
625
635
  declare function groupByOrg(items: ContextSwitcherItem[]): ContextOrgGroup[];
626
636
  interface ContextSwitcherProps {
627
637
  items: ContextSwitcherItem[];
package/dist/index.d.ts CHANGED
@@ -615,13 +615,23 @@ interface ContextSwitcherItem {
615
615
  * host knows its own vocabulary for telling them apart.
616
616
  */
617
617
  kindLabel?: string | null;
618
+ /**
619
+ * Lead this row's org group instead of sorting by name (DEV-14817) — e.g.
620
+ * a host's "all" scope sentinel, or the org's default context. Pinned rows
621
+ * keep the order they were passed in; a divider separates them from the
622
+ * alphabetical rest.
623
+ */
624
+ pinned?: boolean;
625
+ /** Render the row's name in semibold, to set it apart (DEV-14817). */
626
+ emphasis?: boolean;
618
627
  }
619
628
  interface ContextOrgGroup {
620
629
  orgId: string | null;
621
630
  orgName: string | null;
622
631
  items: ContextSwitcherItem[];
623
632
  }
624
- /** Group contexts by owning org. Items sort by name; groups by org name. */
633
+ /** Group contexts by owning org. Pinned items lead their group in input
634
+ * order; the rest sort by name. Groups sort by org name. */
625
635
  declare function groupByOrg(items: ContextSwitcherItem[]): ContextOrgGroup[];
626
636
  interface ContextSwitcherProps {
627
637
  items: ContextSwitcherItem[];
package/dist/index.js CHANGED
@@ -1362,8 +1362,12 @@ function groupItemsByOrg(rows, get) {
1362
1362
  group.items.push(row);
1363
1363
  }
1364
1364
  const groups = [...byOrg.values()];
1365
+ const isPinned = get.pinned ?? (() => false);
1365
1366
  for (const g of groups) {
1366
- g.items.sort((a, b) => get.name(a).localeCompare(get.name(b)));
1367
+ const pinned = g.items.filter(isPinned);
1368
+ const rest = g.items.filter((row) => !isPinned(row));
1369
+ rest.sort((a, b) => get.name(a).localeCompare(get.name(b)));
1370
+ g.items = [...pinned, ...rest];
1367
1371
  }
1368
1372
  groups.sort((a, b) => (a.orgName ?? "").localeCompare(b.orgName ?? ""));
1369
1373
  return groups;
@@ -1432,7 +1436,8 @@ function groupByOrg(items) {
1432
1436
  return groupItemsByOrg(items, {
1433
1437
  orgId: (it) => it.orgId,
1434
1438
  orgName: (it) => it.orgName,
1435
- name: (it) => it.name
1439
+ name: (it) => it.name,
1440
+ pinned: (it) => it.pinned === true
1436
1441
  });
1437
1442
  }
1438
1443
  function toBrand(item) {
@@ -1491,17 +1496,33 @@ function ContextSwitcher({
1491
1496
  children: [
1492
1497
  groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1493
1498
  showOrgHeaders && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenuLabel, { className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: group.orgName ?? "Other" }),
1494
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item) => {
1499
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
1495
1500
  const isActive = item.refId === activeRefId;
1501
+ const next = group.items[i + 1];
1502
+ const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
1496
1503
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1497
1504
  DropdownMenuItem,
1498
1505
  {
1499
1506
  "data-active": isActive || void 0,
1507
+ "data-pinned": item.pinned || void 0,
1508
+ "data-emphasis": item.emphasis || void 0,
1500
1509
  onSelect: () => onSelect(item),
1501
- className: "flex w-full items-center gap-2.5 rounded-none px-3 py-2 text-sm",
1510
+ className: cn(
1511
+ "flex w-full items-center gap-2.5 rounded-none px-3 py-2 text-sm",
1512
+ endsPinned && "border-b border-border/60"
1513
+ ),
1502
1514
  children: [
1503
1515
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BrandGlyph, { brand: toBrand(item), subtle: true }),
1504
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex-1 truncate text-left text-foreground/90", children: item.name }),
1516
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1517
+ "span",
1518
+ {
1519
+ className: cn(
1520
+ "flex-1 truncate text-left",
1521
+ item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
1522
+ ),
1523
+ children: item.name
1524
+ }
1525
+ ),
1505
1526
  item.kindLabel && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1506
1527
  " ",
1507
1528
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: item.kindLabel })
package/dist/index.mjs CHANGED
@@ -1303,8 +1303,12 @@ function groupItemsByOrg(rows, get) {
1303
1303
  group.items.push(row);
1304
1304
  }
1305
1305
  const groups = [...byOrg.values()];
1306
+ const isPinned = get.pinned ?? (() => false);
1306
1307
  for (const g of groups) {
1307
- g.items.sort((a, b) => get.name(a).localeCompare(get.name(b)));
1308
+ const pinned = g.items.filter(isPinned);
1309
+ const rest = g.items.filter((row) => !isPinned(row));
1310
+ rest.sort((a, b) => get.name(a).localeCompare(get.name(b)));
1311
+ g.items = [...pinned, ...rest];
1308
1312
  }
1309
1313
  groups.sort((a, b) => (a.orgName ?? "").localeCompare(b.orgName ?? ""));
1310
1314
  return groups;
@@ -1373,7 +1377,8 @@ function groupByOrg(items) {
1373
1377
  return groupItemsByOrg(items, {
1374
1378
  orgId: (it) => it.orgId,
1375
1379
  orgName: (it) => it.orgName,
1376
- name: (it) => it.name
1380
+ name: (it) => it.name,
1381
+ pinned: (it) => it.pinned === true
1377
1382
  });
1378
1383
  }
1379
1384
  function toBrand(item) {
@@ -1432,17 +1437,33 @@ function ContextSwitcher({
1432
1437
  children: [
1433
1438
  groups.map((group) => /* @__PURE__ */ jsxs6("div", { children: [
1434
1439
  showOrgHeaders && /* @__PURE__ */ jsx7(DropdownMenuLabel, { className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: group.orgName ?? "Other" }),
1435
- /* @__PURE__ */ jsx7("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item) => {
1440
+ /* @__PURE__ */ jsx7("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
1436
1441
  const isActive = item.refId === activeRefId;
1442
+ const next = group.items[i + 1];
1443
+ const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
1437
1444
  return /* @__PURE__ */ jsxs6(
1438
1445
  DropdownMenuItem,
1439
1446
  {
1440
1447
  "data-active": isActive || void 0,
1448
+ "data-pinned": item.pinned || void 0,
1449
+ "data-emphasis": item.emphasis || void 0,
1441
1450
  onSelect: () => onSelect(item),
1442
- className: "flex w-full items-center gap-2.5 rounded-none px-3 py-2 text-sm",
1451
+ className: cn(
1452
+ "flex w-full items-center gap-2.5 rounded-none px-3 py-2 text-sm",
1453
+ endsPinned && "border-b border-border/60"
1454
+ ),
1443
1455
  children: [
1444
1456
  /* @__PURE__ */ jsx7(BrandGlyph, { brand: toBrand(item), subtle: true }),
1445
- /* @__PURE__ */ jsx7("span", { className: "flex-1 truncate text-left text-foreground/90", children: item.name }),
1457
+ /* @__PURE__ */ jsx7(
1458
+ "span",
1459
+ {
1460
+ className: cn(
1461
+ "flex-1 truncate text-left",
1462
+ item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
1463
+ ),
1464
+ children: item.name
1465
+ }
1466
+ ),
1446
1467
  item.kindLabel && /* @__PURE__ */ jsxs6(Fragment3, { children: [
1447
1468
  " ",
1448
1469
  /* @__PURE__ */ jsx7("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: item.kindLabel })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetreeve/ui",
3
- "version": "0.17.0",
3
+ "version": "0.18.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, and the StageRail flow-of-cards primitives.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",