@meetreeve/ui 0.22.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 +61 -0
- package/dist/index.d.mts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/index.js +106 -11
- package/dist/index.mjs +106 -11
- package/dist/theme/index.d.mts +190 -0
- package/dist/theme/index.d.ts +190 -0
- package/dist/theme/index.js +351 -0
- package/dist/theme/index.mjs +309 -0
- package/dist/tokens.css +19 -17
- package/package.json +7 -2
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
|
|
@@ -350,6 +370,47 @@ chart in a tenant's brand colours, set those variables. Hosts that don't import
|
|
|
350
370
|
|
|
351
371
|
Third-party code is credited in `THIRD_PARTY_NOTICES.md`.
|
|
352
372
|
|
|
373
|
+
## Theme — `@meetreeve/ui/theme` (DEV-17886)
|
|
374
|
+
|
|
375
|
+
One brand's inputs in, light and dark semantic tokens out. Reeve's own look is
|
|
376
|
+
`brandTheme(reevePreset)`; a store or tenant site passes its own accent.
|
|
377
|
+
|
|
378
|
+
```ts
|
|
379
|
+
import { brandTheme, reevePreset } from "@meetreeve/ui/theme";
|
|
380
|
+
|
|
381
|
+
const { light, dark } = brandTheme({ accent: brand.accentColor, neutralTemperature: "cool" });
|
|
382
|
+
// light["--action"], light["--action-foreground"], light["--link"], dark["--chart-1"], …
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
- **Inputs:** `accent` (null or invalid → Reeve's dot `#FF6B2B`), `ink` (the
|
|
386
|
+
neutral primary button), `neutralTemperature` (`"cool"` navy/slate, the
|
|
387
|
+
Reeve default; `"neutral"` zinc; `"warm"` stone), `radius`, `fonts`
|
|
388
|
+
(`sans` / `display` / `mono`). `radius` and fonts are emitted only when they
|
|
389
|
+
are a plain CSS length or a font-family list.
|
|
390
|
+
- **Outputs (per mode):** the shadcn set (`--background`, `--foreground`,
|
|
391
|
+
`--card`, `--popover`, `--primary`, `--secondary`, `--muted`, `--accent`,
|
|
392
|
+
each with `-foreground`; `--border`, `--input`, `--ring`), plus `--link`,
|
|
393
|
+
`--action` (+fg, the one dominant action), `--brand-accent` (the dot),
|
|
394
|
+
`--destructive` / `--success` / `--warning` (+fg, and a `-subtle` surface
|
|
395
|
+
with its own `-foreground`), `--shadow-sm/md/lg` and `--chart-1..8`.
|
|
396
|
+
`--accent` stays shadcn's quiet hover surface; the brand colour is
|
|
397
|
+
`--brand-accent`.
|
|
398
|
+
- **Contrast is derived, not hoped for.** Every foreground is picked by WCAG
|
|
399
|
+
2.x contrast; when nothing passes, lightness is stepped in OKLCH (hue kept)
|
|
400
|
+
until text reaches 4.5 and rings and indicators reach 3 on the background,
|
|
401
|
+
card and muted surfaces. Fills are judged differently: the action keeps the
|
|
402
|
+
accent unless it is perceptually lost against the page (OKLab ΔE under
|
|
403
|
+
0.1, e.g. a white brand on white), and a pale `ink` is held to 3:1. Status
|
|
404
|
+
hues are fixed per mode and never follow the accent. Sidebar tokens are not
|
|
405
|
+
emitted: the sidebar is Reeve chrome.
|
|
406
|
+
- **The contrast helper** is exported too: `contrastRatio`,
|
|
407
|
+
`relativeLuminance`, `readableOn(color, backgrounds, min)`,
|
|
408
|
+
`pickForeground`, `solidPair`, `deltaE`, `CONTRAST` (`{ text: 4.5, indicator: 3 }`).
|
|
409
|
+
Use it instead of writing another copy.
|
|
410
|
+
|
|
411
|
+
Pure functions with no React or DOM, so the entry is server-safe. The chart
|
|
412
|
+
defaults in `tokens.css` are `brandTheme(reevePreset)`'s `--chart-*`.
|
|
413
|
+
|
|
353
414
|
## Tokens
|
|
354
415
|
|
|
355
416
|
```ts
|
package/dist/index.d.mts
CHANGED
|
@@ -2,19 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ElementType, RefObject, CSSProperties, MouseEventHandler } from 'react';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Brand glyph with a favicon-first cascade (ported/generalised from
|
|
7
|
-
* DEV-4164's `context/brand-glyph`).
|
|
8
|
-
*
|
|
9
|
-
* A tiny square favicon reads far better than a wide wordmark, so we try, in
|
|
10
|
-
* order:
|
|
11
|
-
* 1. `brand.favicon` — the site's own square icon,
|
|
12
|
-
* 2. `brand.logo` rendered `object-contain` (no squish),
|
|
13
|
-
* 3. a single-letter monogram in the brand colour + an accent dot
|
|
14
|
-
* (DEV-4539 — modeled on Reeve's own "R." canon; no boxed container).
|
|
15
|
-
* Each image load error advances to the next candidate.
|
|
16
|
-
*/
|
|
17
5
|
declare const REEVE_ACCENT = "#FF6B2B";
|
|
6
|
+
|
|
18
7
|
interface Brand {
|
|
19
8
|
/** Display name — drives the wordmark and the monogram fallback. */
|
|
20
9
|
name: string;
|
|
@@ -678,6 +667,18 @@ interface ContextSwitcherItem {
|
|
|
678
667
|
pinned?: boolean;
|
|
679
668
|
/** Render the row's name in semibold, to set it apart (DEV-14817). */
|
|
680
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;
|
|
681
682
|
}
|
|
682
683
|
interface ContextOrgGroup {
|
|
683
684
|
orgId: string | null;
|
|
@@ -1080,4 +1081,4 @@ declare function UnlockCta({ href, title, sub, compact, onClick, linkComponent,
|
|
|
1080
1081
|
*/
|
|
1081
1082
|
declare function placeholder(mask: string, seed: string): string;
|
|
1082
1083
|
|
|
1083
|
-
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
|
@@ -2,19 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ElementType, RefObject, CSSProperties, MouseEventHandler } from 'react';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Brand glyph with a favicon-first cascade (ported/generalised from
|
|
7
|
-
* DEV-4164's `context/brand-glyph`).
|
|
8
|
-
*
|
|
9
|
-
* A tiny square favicon reads far better than a wide wordmark, so we try, in
|
|
10
|
-
* order:
|
|
11
|
-
* 1. `brand.favicon` — the site's own square icon,
|
|
12
|
-
* 2. `brand.logo` rendered `object-contain` (no squish),
|
|
13
|
-
* 3. a single-letter monogram in the brand colour + an accent dot
|
|
14
|
-
* (DEV-4539 — modeled on Reeve's own "R." canon; no boxed container).
|
|
15
|
-
* Each image load error advances to the next candidate.
|
|
16
|
-
*/
|
|
17
5
|
declare const REEVE_ACCENT = "#FF6B2B";
|
|
6
|
+
|
|
18
7
|
interface Brand {
|
|
19
8
|
/** Display name — drives the wordmark and the monogram fallback. */
|
|
20
9
|
name: string;
|
|
@@ -678,6 +667,18 @@ interface ContextSwitcherItem {
|
|
|
678
667
|
pinned?: boolean;
|
|
679
668
|
/** Render the row's name in semibold, to set it apart (DEV-14817). */
|
|
680
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;
|
|
681
682
|
}
|
|
682
683
|
interface ContextOrgGroup {
|
|
683
684
|
orgId: string | null;
|
|
@@ -1080,4 +1081,4 @@ declare function UnlockCta({ href, title, sub, compact, onClick, linkComponent,
|
|
|
1080
1081
|
*/
|
|
1081
1082
|
declare function placeholder(mask: string, seed: string): string;
|
|
1082
1083
|
|
|
1083
|
-
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
|
@@ -132,9 +132,11 @@ function monogramColor(seed) {
|
|
|
132
132
|
return MONOGRAM_COLORS[Math.abs(h) % MONOGRAM_COLORS.length];
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// src/lib/reeve-accent.ts
|
|
136
|
+
var REEVE_ACCENT = "#FF6B2B";
|
|
137
|
+
|
|
135
138
|
// src/brand-glyph.tsx
|
|
136
139
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
137
|
-
var REEVE_ACCENT = "#FF6B2B";
|
|
138
140
|
function faviconUrl(domain) {
|
|
139
141
|
if (!domain) return null;
|
|
140
142
|
const host = domain.trim().toLowerCase();
|
|
@@ -1591,6 +1593,31 @@ function DropdownMenuLabel({
|
|
|
1591
1593
|
|
|
1592
1594
|
// src/context-switcher.tsx
|
|
1593
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
|
+
}
|
|
1594
1621
|
function groupByOrg(items) {
|
|
1595
1622
|
return groupItemsByOrg(items, {
|
|
1596
1623
|
orgId: (it) => it.orgId,
|
|
@@ -1620,27 +1647,69 @@ function ContextSwitcher({
|
|
|
1620
1647
|
contentClassName
|
|
1621
1648
|
}) {
|
|
1622
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(" ");
|
|
1623
1653
|
const groups = groupByOrg(items);
|
|
1624
1654
|
const showOrgHeaders = groups.length > 1;
|
|
1625
1655
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(DropdownMenu, { children: [
|
|
1626
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime8.
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1627
1657
|
"button",
|
|
1628
1658
|
{
|
|
1629
1659
|
type: "button",
|
|
1630
|
-
title:
|
|
1631
|
-
"aria-label":
|
|
1632
|
-
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",
|
|
1633
|
-
children:
|
|
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
|
+
]
|
|
1634
1678
|
}
|
|
1635
1679
|
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1636
1680
|
"button",
|
|
1637
1681
|
{
|
|
1638
1682
|
type: "button",
|
|
1639
|
-
className:
|
|
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
|
+
),
|
|
1640
1687
|
children: [
|
|
1641
1688
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BrandGlyph, { brand: toBrand(active ?? { name: "" }) }),
|
|
1642
|
-
|
|
1643
|
-
|
|
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" })
|
|
1644
1713
|
]
|
|
1645
1714
|
}
|
|
1646
1715
|
) }),
|
|
@@ -1651,12 +1720,19 @@ function ContextSwitcher({
|
|
|
1651
1720
|
align,
|
|
1652
1721
|
sideOffset: 6,
|
|
1653
1722
|
collisionPadding: 8,
|
|
1654
|
-
className: cn(
|
|
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
|
+
),
|
|
1655
1730
|
children: [
|
|
1656
1731
|
groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
1657
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" }),
|
|
1658
1733
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
|
|
1659
1734
|
const isActive = item.refId === activeRefId;
|
|
1735
|
+
const badge = item.badge?.label ? item.badge : null;
|
|
1660
1736
|
const next = group.items[i + 1];
|
|
1661
1737
|
const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
|
|
1662
1738
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
@@ -1675,16 +1751,35 @@ function ContextSwitcher({
|
|
|
1675
1751
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1676
1752
|
"span",
|
|
1677
1753
|
{
|
|
1754
|
+
"data-slot": "context-name",
|
|
1678
1755
|
className: cn(
|
|
1679
1756
|
"flex-1 truncate text-left",
|
|
1757
|
+
badge && NAME_FLOOR,
|
|
1680
1758
|
item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
|
|
1681
1759
|
),
|
|
1682
1760
|
children: item.name
|
|
1683
1761
|
}
|
|
1684
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
|
+
] }),
|
|
1685
1767
|
item.kindLabel && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1686
1768
|
" ",
|
|
1687
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
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
|
+
)
|
|
1688
1783
|
] }),
|
|
1689
1784
|
isActive && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Check, { className: "size-3.5 text-emerald-500" })
|
|
1690
1785
|
]
|
package/dist/index.mjs
CHANGED
|
@@ -66,9 +66,11 @@ function monogramColor(seed) {
|
|
|
66
66
|
return MONOGRAM_COLORS[Math.abs(h) % MONOGRAM_COLORS.length];
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// src/lib/reeve-accent.ts
|
|
70
|
+
var REEVE_ACCENT = "#FF6B2B";
|
|
71
|
+
|
|
69
72
|
// src/brand-glyph.tsx
|
|
70
73
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
71
|
-
var REEVE_ACCENT = "#FF6B2B";
|
|
72
74
|
function faviconUrl(domain) {
|
|
73
75
|
if (!domain) return null;
|
|
74
76
|
const host = domain.trim().toLowerCase();
|
|
@@ -1525,6 +1527,31 @@ function DropdownMenuLabel({
|
|
|
1525
1527
|
|
|
1526
1528
|
// src/context-switcher.tsx
|
|
1527
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
|
+
}
|
|
1528
1555
|
function groupByOrg(items) {
|
|
1529
1556
|
return groupItemsByOrg(items, {
|
|
1530
1557
|
orgId: (it) => it.orgId,
|
|
@@ -1554,27 +1581,69 @@ function ContextSwitcher({
|
|
|
1554
1581
|
contentClassName
|
|
1555
1582
|
}) {
|
|
1556
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(" ");
|
|
1557
1587
|
const groups = groupByOrg(items);
|
|
1558
1588
|
const showOrgHeaders = groups.length > 1;
|
|
1559
1589
|
return /* @__PURE__ */ jsxs7(DropdownMenu, { children: [
|
|
1560
|
-
/* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */
|
|
1590
|
+
/* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: true, children: collapsed ? /* @__PURE__ */ jsxs7(
|
|
1561
1591
|
"button",
|
|
1562
1592
|
{
|
|
1563
1593
|
type: "button",
|
|
1564
|
-
title:
|
|
1565
|
-
"aria-label":
|
|
1566
|
-
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",
|
|
1567
|
-
children:
|
|
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
|
+
]
|
|
1568
1612
|
}
|
|
1569
1613
|
) : /* @__PURE__ */ jsxs7(
|
|
1570
1614
|
"button",
|
|
1571
1615
|
{
|
|
1572
1616
|
type: "button",
|
|
1573
|
-
className:
|
|
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
|
+
),
|
|
1574
1621
|
children: [
|
|
1575
1622
|
/* @__PURE__ */ jsx8(BrandGlyph, { brand: toBrand(active ?? { name: "" }) }),
|
|
1576
|
-
|
|
1577
|
-
|
|
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" })
|
|
1578
1647
|
]
|
|
1579
1648
|
}
|
|
1580
1649
|
) }),
|
|
@@ -1585,12 +1654,19 @@ function ContextSwitcher({
|
|
|
1585
1654
|
align,
|
|
1586
1655
|
sideOffset: 6,
|
|
1587
1656
|
collisionPadding: 8,
|
|
1588
|
-
className: cn(
|
|
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
|
+
),
|
|
1589
1664
|
children: [
|
|
1590
1665
|
groups.map((group) => /* @__PURE__ */ jsxs7("div", { children: [
|
|
1591
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" }),
|
|
1592
1667
|
/* @__PURE__ */ jsx8("div", { className: cn(showOrgHeaders && "ml-5 border-l border-border/60"), children: group.items.map((item, i) => {
|
|
1593
1668
|
const isActive = item.refId === activeRefId;
|
|
1669
|
+
const badge = item.badge?.label ? item.badge : null;
|
|
1594
1670
|
const next = group.items[i + 1];
|
|
1595
1671
|
const endsPinned = item.pinned === true && next !== void 0 && next.pinned !== true;
|
|
1596
1672
|
return /* @__PURE__ */ jsxs7(
|
|
@@ -1609,16 +1685,35 @@ function ContextSwitcher({
|
|
|
1609
1685
|
/* @__PURE__ */ jsx8(
|
|
1610
1686
|
"span",
|
|
1611
1687
|
{
|
|
1688
|
+
"data-slot": "context-name",
|
|
1612
1689
|
className: cn(
|
|
1613
1690
|
"flex-1 truncate text-left",
|
|
1691
|
+
badge && NAME_FLOOR,
|
|
1614
1692
|
item.emphasis ? "font-semibold text-foreground" : "text-foreground/90"
|
|
1615
1693
|
),
|
|
1616
1694
|
children: item.name
|
|
1617
1695
|
}
|
|
1618
1696
|
),
|
|
1697
|
+
badge && /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
1698
|
+
" ",
|
|
1699
|
+
/* @__PURE__ */ jsx8(StatusBadge, { badge })
|
|
1700
|
+
] }),
|
|
1619
1701
|
item.kindLabel && /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
1620
1702
|
" ",
|
|
1621
|
-
/* @__PURE__ */ jsx8(
|
|
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
|
+
)
|
|
1622
1717
|
] }),
|
|
1623
1718
|
isActive && /* @__PURE__ */ jsx8(Check, { className: "size-3.5 text-emerald-500" })
|
|
1624
1719
|
]
|