@meetreeve/ui 0.17.0 → 0.18.1
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 +5 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +36 -12
- package/dist/index.mjs +36 -12
- package/package.json +1 -1
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.
|
|
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.
|
|
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
|
@@ -1090,12 +1090,17 @@ function AppSidebar({
|
|
|
1090
1090
|
const mobileCloseRef = (0, import_react8.useRef)(null);
|
|
1091
1091
|
const [collapsed, setCollapsed] = (0, import_react8.useState)(defaultCollapsed);
|
|
1092
1092
|
const [collapseHydrated, setCollapseHydrated] = (0, import_react8.useState)(false);
|
|
1093
|
+
const collapsedRef = (0, import_react8.useRef)(defaultCollapsed);
|
|
1094
|
+
function applyCollapsed(next) {
|
|
1095
|
+
collapsedRef.current = next;
|
|
1096
|
+
setCollapsed(next);
|
|
1097
|
+
}
|
|
1093
1098
|
(0, import_react8.useEffect)(() => {
|
|
1094
1099
|
if (!collapsible) return;
|
|
1095
1100
|
try {
|
|
1096
1101
|
const stored = localStorage.getItem(storageKey);
|
|
1097
|
-
if (stored === "true")
|
|
1098
|
-
else if (stored === "false")
|
|
1102
|
+
if (stored === "true") applyCollapsed(true);
|
|
1103
|
+
else if (stored === "false") applyCollapsed(false);
|
|
1099
1104
|
} catch {
|
|
1100
1105
|
}
|
|
1101
1106
|
setCollapseHydrated(true);
|
|
@@ -1108,11 +1113,9 @@ function AppSidebar({
|
|
|
1108
1113
|
}
|
|
1109
1114
|
}, [collapsed, collapseHydrated, collapsible, storageKey]);
|
|
1110
1115
|
function handleToggleCollapsed() {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
return next;
|
|
1115
|
-
});
|
|
1116
|
+
const next = !collapsedRef.current;
|
|
1117
|
+
applyCollapsed(next);
|
|
1118
|
+
onCollapsedChange?.(next);
|
|
1116
1119
|
}
|
|
1117
1120
|
const [openFlyoutId, setOpenFlyoutId] = (0, import_react8.useState)(null);
|
|
1118
1121
|
const handleFlyoutOpenChange = (0, import_react8.useCallback)((id, isOpen) => {
|
|
@@ -1362,8 +1365,12 @@ function groupItemsByOrg(rows, get) {
|
|
|
1362
1365
|
group.items.push(row);
|
|
1363
1366
|
}
|
|
1364
1367
|
const groups = [...byOrg.values()];
|
|
1368
|
+
const isPinned = get.pinned ?? (() => false);
|
|
1365
1369
|
for (const g of groups) {
|
|
1366
|
-
|
|
1370
|
+
const pinned = g.items.filter(isPinned);
|
|
1371
|
+
const rest = g.items.filter((row) => !isPinned(row));
|
|
1372
|
+
rest.sort((a, b) => get.name(a).localeCompare(get.name(b)));
|
|
1373
|
+
g.items = [...pinned, ...rest];
|
|
1367
1374
|
}
|
|
1368
1375
|
groups.sort((a, b) => (a.orgName ?? "").localeCompare(b.orgName ?? ""));
|
|
1369
1376
|
return groups;
|
|
@@ -1432,7 +1439,8 @@ function groupByOrg(items) {
|
|
|
1432
1439
|
return groupItemsByOrg(items, {
|
|
1433
1440
|
orgId: (it) => it.orgId,
|
|
1434
1441
|
orgName: (it) => it.orgName,
|
|
1435
|
-
name: (it) => it.name
|
|
1442
|
+
name: (it) => it.name,
|
|
1443
|
+
pinned: (it) => it.pinned === true
|
|
1436
1444
|
});
|
|
1437
1445
|
}
|
|
1438
1446
|
function toBrand(item) {
|
|
@@ -1491,17 +1499,33 @@ function ContextSwitcher({
|
|
|
1491
1499
|
children: [
|
|
1492
1500
|
groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
1493
1501
|
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) => {
|
|
1502
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
|
|
1495
1503
|
const isActive = item.refId === activeRefId;
|
|
1504
|
+
const next = group.items[i + 1];
|
|
1505
|
+
const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
|
|
1496
1506
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1497
1507
|
DropdownMenuItem,
|
|
1498
1508
|
{
|
|
1499
1509
|
"data-active": isActive || void 0,
|
|
1510
|
+
"data-pinned": item.pinned || void 0,
|
|
1511
|
+
"data-emphasis": item.emphasis || void 0,
|
|
1500
1512
|
onSelect: () => onSelect(item),
|
|
1501
|
-
className:
|
|
1513
|
+
className: cn(
|
|
1514
|
+
"flex w-full items-center gap-2.5 rounded-none px-3 py-2 text-sm",
|
|
1515
|
+
endsPinned && "border-b border-border/60"
|
|
1516
|
+
),
|
|
1502
1517
|
children: [
|
|
1503
1518
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BrandGlyph, { brand: toBrand(item), subtle: true }),
|
|
1504
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1519
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1520
|
+
"span",
|
|
1521
|
+
{
|
|
1522
|
+
className: cn(
|
|
1523
|
+
"flex-1 truncate text-left",
|
|
1524
|
+
item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
|
|
1525
|
+
),
|
|
1526
|
+
children: item.name
|
|
1527
|
+
}
|
|
1528
|
+
),
|
|
1505
1529
|
item.kindLabel && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1506
1530
|
" ",
|
|
1507
1531
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: item.kindLabel })
|
package/dist/index.mjs
CHANGED
|
@@ -1031,12 +1031,17 @@ function AppSidebar({
|
|
|
1031
1031
|
const mobileCloseRef = useRef4(null);
|
|
1032
1032
|
const [collapsed, setCollapsed] = useState6(defaultCollapsed);
|
|
1033
1033
|
const [collapseHydrated, setCollapseHydrated] = useState6(false);
|
|
1034
|
+
const collapsedRef = useRef4(defaultCollapsed);
|
|
1035
|
+
function applyCollapsed(next) {
|
|
1036
|
+
collapsedRef.current = next;
|
|
1037
|
+
setCollapsed(next);
|
|
1038
|
+
}
|
|
1034
1039
|
useEffect5(() => {
|
|
1035
1040
|
if (!collapsible) return;
|
|
1036
1041
|
try {
|
|
1037
1042
|
const stored = localStorage.getItem(storageKey);
|
|
1038
|
-
if (stored === "true")
|
|
1039
|
-
else if (stored === "false")
|
|
1043
|
+
if (stored === "true") applyCollapsed(true);
|
|
1044
|
+
else if (stored === "false") applyCollapsed(false);
|
|
1040
1045
|
} catch {
|
|
1041
1046
|
}
|
|
1042
1047
|
setCollapseHydrated(true);
|
|
@@ -1049,11 +1054,9 @@ function AppSidebar({
|
|
|
1049
1054
|
}
|
|
1050
1055
|
}, [collapsed, collapseHydrated, collapsible, storageKey]);
|
|
1051
1056
|
function handleToggleCollapsed() {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
return next;
|
|
1056
|
-
});
|
|
1057
|
+
const next = !collapsedRef.current;
|
|
1058
|
+
applyCollapsed(next);
|
|
1059
|
+
onCollapsedChange?.(next);
|
|
1057
1060
|
}
|
|
1058
1061
|
const [openFlyoutId, setOpenFlyoutId] = useState6(null);
|
|
1059
1062
|
const handleFlyoutOpenChange = useCallback3((id, isOpen) => {
|
|
@@ -1303,8 +1306,12 @@ function groupItemsByOrg(rows, get) {
|
|
|
1303
1306
|
group.items.push(row);
|
|
1304
1307
|
}
|
|
1305
1308
|
const groups = [...byOrg.values()];
|
|
1309
|
+
const isPinned = get.pinned ?? (() => false);
|
|
1306
1310
|
for (const g of groups) {
|
|
1307
|
-
|
|
1311
|
+
const pinned = g.items.filter(isPinned);
|
|
1312
|
+
const rest = g.items.filter((row) => !isPinned(row));
|
|
1313
|
+
rest.sort((a, b) => get.name(a).localeCompare(get.name(b)));
|
|
1314
|
+
g.items = [...pinned, ...rest];
|
|
1308
1315
|
}
|
|
1309
1316
|
groups.sort((a, b) => (a.orgName ?? "").localeCompare(b.orgName ?? ""));
|
|
1310
1317
|
return groups;
|
|
@@ -1373,7 +1380,8 @@ function groupByOrg(items) {
|
|
|
1373
1380
|
return groupItemsByOrg(items, {
|
|
1374
1381
|
orgId: (it) => it.orgId,
|
|
1375
1382
|
orgName: (it) => it.orgName,
|
|
1376
|
-
name: (it) => it.name
|
|
1383
|
+
name: (it) => it.name,
|
|
1384
|
+
pinned: (it) => it.pinned === true
|
|
1377
1385
|
});
|
|
1378
1386
|
}
|
|
1379
1387
|
function toBrand(item) {
|
|
@@ -1432,17 +1440,33 @@ function ContextSwitcher({
|
|
|
1432
1440
|
children: [
|
|
1433
1441
|
groups.map((group) => /* @__PURE__ */ jsxs6("div", { children: [
|
|
1434
1442
|
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) => {
|
|
1443
|
+
/* @__PURE__ */ jsx7("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
|
|
1436
1444
|
const isActive = item.refId === activeRefId;
|
|
1445
|
+
const next = group.items[i + 1];
|
|
1446
|
+
const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
|
|
1437
1447
|
return /* @__PURE__ */ jsxs6(
|
|
1438
1448
|
DropdownMenuItem,
|
|
1439
1449
|
{
|
|
1440
1450
|
"data-active": isActive || void 0,
|
|
1451
|
+
"data-pinned": item.pinned || void 0,
|
|
1452
|
+
"data-emphasis": item.emphasis || void 0,
|
|
1441
1453
|
onSelect: () => onSelect(item),
|
|
1442
|
-
className:
|
|
1454
|
+
className: cn(
|
|
1455
|
+
"flex w-full items-center gap-2.5 rounded-none px-3 py-2 text-sm",
|
|
1456
|
+
endsPinned && "border-b border-border/60"
|
|
1457
|
+
),
|
|
1443
1458
|
children: [
|
|
1444
1459
|
/* @__PURE__ */ jsx7(BrandGlyph, { brand: toBrand(item), subtle: true }),
|
|
1445
|
-
/* @__PURE__ */ jsx7(
|
|
1460
|
+
/* @__PURE__ */ jsx7(
|
|
1461
|
+
"span",
|
|
1462
|
+
{
|
|
1463
|
+
className: cn(
|
|
1464
|
+
"flex-1 truncate text-left",
|
|
1465
|
+
item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
|
|
1466
|
+
),
|
|
1467
|
+
children: item.name
|
|
1468
|
+
}
|
|
1469
|
+
),
|
|
1446
1470
|
item.kindLabel && /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
1447
1471
|
" ",
|
|
1448
1472
|
/* @__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.
|
|
3
|
+
"version": "0.18.1",
|
|
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",
|