@burdenoff/fe-libs 2026.1115.5 → 2026.1115.7

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.
@@ -1,7 +1,8 @@
1
+ import { SuggestionSettlement } from './SuggestionCard';
1
2
  export interface ProactiveInboxProps {
2
3
  className?: string;
3
4
  /** Called after a suggestion's action ran, or it was dismissed or snoozed. */
4
- onSettled?: () => void;
5
+ onSettled?: (settlement: SuggestionSettlement) => void;
5
6
  /** Hide the inbox's own heading (when the host already titles it). */
6
7
  hideHeading?: boolean;
7
8
  }
@@ -2,34 +2,35 @@ import { usePrefersReducedMotion as e } from "../../assistant/ui/usePrefersReduc
2
2
  import { Popover as t, PopoverContent as n, PopoverTrigger as r } from "../../../ui/popover.js";
3
3
  import { cn as i } from "../../utils/cn.js";
4
4
  import { useProactiveOrNull as a } from "../context.js";
5
- import { SuggestionCard as o } from "./SuggestionCard.js";
6
- import { useId as s, useState as c } from "react";
7
- import { Sparkles as l } from "lucide-react";
8
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
5
+ import { inboxClosesAfter as o } from "./inboxPolicy.js";
6
+ import { SuggestionCard as s } from "./SuggestionCard.js";
7
+ import { useId as c, useState as l } from "react";
8
+ import { Sparkles as u } from "lucide-react";
9
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
10
  // src/shared/proactive/ui/ProactiveInbox.tsx
10
- function f({ className: e, onSettled: t, hideHeading: n = !1 }) {
11
- let r = a(), c = s();
11
+ function p({ className: e, onSettled: t, hideHeading: n = !1 }) {
12
+ let r = a(), o = c();
12
13
  if (!r || r.status !== "ready") return null;
13
- let l = r.controls.tr, { suggestions: f, controls: p } = r;
14
- return /* @__PURE__ */ d("section", {
15
- "aria-labelledby": n ? void 0 : c,
14
+ let l = r.controls.tr, { suggestions: u, controls: p } = r;
15
+ return /* @__PURE__ */ f("section", {
16
+ "aria-labelledby": n ? void 0 : o,
16
17
  "aria-label": n ? l("proactive.inbox.title", "Suggestions") : void 0,
17
18
  "data-agent": "deny",
18
19
  "data-proactive-ui": "",
19
20
  "data-testid": "proactive-inbox",
20
21
  className: i("flex flex-col gap-3", e),
21
- children: [n ? null : /* @__PURE__ */ u("h2", {
22
- id: c,
22
+ children: [n ? null : /* @__PURE__ */ d("h2", {
23
+ id: o,
23
24
  className: "text-sm font-semibold text-text-primary",
24
25
  children: l("proactive.inbox.title", "Suggestions")
25
- }), f.length === 0 ? /* @__PURE__ */ u("p", {
26
+ }), u.length === 0 ? /* @__PURE__ */ d("p", {
26
27
  className: "text-xs text-text-secondary",
27
28
  children: l("proactive.inbox.empty", "No suggestions right now. When the assistant finds something worth a look, it shows up here.")
28
- }) : /* @__PURE__ */ u("ul", {
29
+ }) : /* @__PURE__ */ d("ul", {
29
30
  className: "flex flex-col gap-2",
30
- children: f.map((e) => /* @__PURE__ */ u("li", {
31
+ children: u.map((e) => /* @__PURE__ */ d("li", {
31
32
  className: "rounded-card border border-border-subtle bg-bg-surface p-3",
32
- children: /* @__PURE__ */ u(o, {
33
+ children: /* @__PURE__ */ d(s, {
33
34
  suggestion: e,
34
35
  controls: p,
35
36
  headingLevel: "h3",
@@ -39,40 +40,42 @@ function f({ className: e, onSettled: t, hideHeading: n = !1 }) {
39
40
  })]
40
41
  });
41
42
  }
42
- function p({ className: o, side: s = "bottom", align: p = "end" }) {
43
- let m = a(), [h, g] = c(!1), _ = e();
44
- if (!m || m.status !== "ready") return null;
45
- let v = m.controls.tr, y = m.suggestions.length;
46
- return /* @__PURE__ */ d(t, {
47
- open: h,
48
- onOpenChange: g,
49
- children: [/* @__PURE__ */ u(r, {
43
+ function m({ className: s, side: c = "bottom", align: m = "end" }) {
44
+ let h = a(), [g, _] = l(!1), v = e();
45
+ if (!h || h.status !== "ready") return null;
46
+ let y = h.controls.tr, b = h.suggestions.length;
47
+ return /* @__PURE__ */ f(t, {
48
+ open: g,
49
+ onOpenChange: _,
50
+ children: [/* @__PURE__ */ d(r, {
50
51
  asChild: !0,
51
- children: /* @__PURE__ */ d("button", {
52
+ children: /* @__PURE__ */ f("button", {
52
53
  type: "button",
53
- "aria-label": y === 0 ? v("proactive.inbox.button", "Suggestions") : v("proactive.inbox.buttonWithCount", "Suggestions ({{count}})", { count: y }),
54
+ "aria-label": b === 0 ? y("proactive.inbox.button", "Suggestions") : y("proactive.inbox.buttonWithCount", "Suggestions ({{count}})", { count: b }),
54
55
  "data-agent": "deny",
55
56
  "data-proactive-ui": "",
56
57
  "data-testid": "proactive-inbox-button",
57
- className: i("relative inline-flex size-9 items-center justify-center rounded-button text-text-secondary outline-none", "hover:bg-action-ghost-bgHover hover:text-text-primary motion-safe:transition-colors", "focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", o),
58
- children: [/* @__PURE__ */ u(l, {
58
+ className: i("relative inline-flex size-9 items-center justify-center rounded-button text-text-secondary outline-none", "hover:bg-action-ghost-bgHover hover:text-text-primary motion-safe:transition-colors", "focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", s),
59
+ children: [/* @__PURE__ */ d(u, {
59
60
  "aria-hidden": "true",
60
61
  className: "size-4"
61
- }), y > 0 ? /* @__PURE__ */ u("span", {
62
+ }), b > 0 ? /* @__PURE__ */ d("span", {
62
63
  "aria-hidden": "true",
63
64
  className: "absolute -top-0.5 -end-0.5 min-w-4 rounded-full bg-action-primary-bg px-1 text-[10px] font-semibold leading-4 text-action-primary-text",
64
- children: y > 9 ? "9+" : y
65
+ children: b > 9 ? "9+" : b
65
66
  }) : null]
66
67
  })
67
- }), /* @__PURE__ */ u(n, {
68
- side: s,
69
- align: p,
68
+ }), /* @__PURE__ */ d(n, {
69
+ side: c,
70
+ align: m,
70
71
  collisionPadding: 8,
71
72
  "data-agent": "deny",
72
73
  "data-proactive-ui": "",
73
- className: i("max-h-[min(32rem,80vh)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto p-3", _ && "animate-none!"),
74
- children: /* @__PURE__ */ u(f, { onSettled: y <= 1 ? () => g(!1) : void 0 })
74
+ className: i("max-h-[min(32rem,80vh)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto p-3", v && "animate-none!"),
75
+ children: /* @__PURE__ */ d(p, { onSettled: (e) => {
76
+ o(e, b) && _(!1);
77
+ } })
75
78
  })]
76
79
  });
77
80
  }
78
- export { f as ProactiveInbox, p as ProactiveInboxButton };
81
+ export { p as ProactiveInbox, m as ProactiveInboxButton };
@@ -9,11 +9,13 @@ export declare function SeverityBadge({ severity, tr }: {
9
9
  export declare function AiBadge({ tr }: {
10
10
  tr: AssistantTr;
11
11
  }): import('react').JSX.Element;
12
+ /** How a suggestion card was settled: one of its actions ran, or it was dismissed or snoozed. */
13
+ export type SuggestionSettlement = 'action' | 'dismissed' | 'snoozed';
12
14
  export interface SuggestionCardProps {
13
15
  suggestion: ProactiveSuggestion;
14
16
  controls: SuggestionControls;
15
- /** Called after an action ran, or the suggestion was dismissed or snoozed. */
16
- onSettled?: () => void;
17
+ /** Called after an action ran, or the suggestion was dismissed or snoozed, with which. */
18
+ onSettled?: (settlement: SuggestionSettlement) => void;
17
19
  /** Heading level of the title; the inbox nests cards under its own heading. */
18
20
  headingLevel?: 'h3' | 'h4';
19
21
  /** Extra content under the buttons (e.g. a product's "open" link). */
@@ -32,15 +32,15 @@ function p({ suggestion: e, controls: r, onSettled: o, headingLevel: u = "h3", f
32
32
  id: t.id
33
33
  }), b(null);
34
34
  let n = await r.runAction(e, t);
35
- v(null), n.status === "done" ? o?.() : b(n.status === "failed" ? h("proactive.card.actionFailed", "That didn't work. Try again, or open it yourself.") : h("proactive.card.actionUnavailable", "This action isn't available any more."));
35
+ v(null), n.status === "done" ? o?.("action") : b(n.status === "failed" ? h("proactive.card.actionFailed", "That didn't work. Try again, or open it yourself.") : h("proactive.card.actionUnavailable", "This action isn't available any more."));
36
36
  }, w = async () => {
37
37
  v({ kind: "dismiss" }), b(null);
38
38
  let t = await r.dismiss(e);
39
- v(null), t ? o?.() : b(h("proactive.card.dismissFailed", "Couldn't dismiss this suggestion. Try again."));
39
+ v(null), t ? o?.("dismissed") : b(h("proactive.card.dismissFailed", "Couldn't dismiss this suggestion. Try again."));
40
40
  }, T = async (t) => {
41
41
  v({ kind: "snooze" }), b(null);
42
42
  let n = await r.snooze(e, t);
43
- v(null), n ? o?.() : b(h("proactive.card.snoozeFailed", "Couldn't snooze this suggestion. Try again."));
43
+ v(null), n ? o?.("snoozed") : b(h("proactive.card.snoozeFailed", "Couldn't snooze this suggestion. Try again."));
44
44
  };
45
45
  return /* @__PURE__ */ l("article", {
46
46
  "aria-labelledby": g,
@@ -0,0 +1,8 @@
1
+ import { SuggestionSettlement } from './SuggestionCard';
2
+ /**
3
+ * Whether the inbox popover closes after a card settles. An action always closes it: it takes
4
+ * the person somewhere (a page, a dialog, the assistant), and a popover left open would cover
5
+ * it. A dismiss or snooze closes it only when that was the last suggestion, so several can be
6
+ * cleared in a row.
7
+ */
8
+ export declare function inboxClosesAfter(settlement: SuggestionSettlement, suggestionsBefore: number): boolean;
@@ -0,0 +1,5 @@
1
+ // src/shared/proactive/ui/inboxPolicy.ts
2
+ function e(e, t) {
3
+ return e === "action" || t <= 1;
4
+ }
5
+ export { e as inboxClosesAfter };