@burdenoff/fe-libs 2026.1112.6 → 2026.1113.2

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.
Files changed (57) hide show
  1. package/dist/shared/assistant/i18nManifest.d.ts +40 -0
  2. package/dist/shared/assistant/i18nManifest.js +40 -0
  3. package/dist/shared/proactive/ProactiveProvider.d.ts +67 -0
  4. package/dist/shared/proactive/ProactiveProvider.js +128 -0
  5. package/dist/shared/proactive/actions.d.ts +101 -0
  6. package/dist/shared/proactive/actions.js +71 -0
  7. package/dist/shared/proactive/activity.d.ts +27 -0
  8. package/dist/shared/proactive/activity.js +37 -0
  9. package/dist/shared/proactive/adapters.d.ts +54 -0
  10. package/dist/shared/proactive/adapters.js +62 -0
  11. package/dist/shared/proactive/anchors.d.ts +47 -0
  12. package/dist/shared/proactive/anchors.js +53 -0
  13. package/dist/shared/proactive/budget.d.ts +17 -0
  14. package/dist/shared/proactive/budget.js +30 -0
  15. package/dist/shared/proactive/capabilities.d.ts +26 -0
  16. package/dist/shared/proactive/capabilities.js +63 -0
  17. package/dist/shared/proactive/coalesce.d.ts +11 -0
  18. package/dist/shared/proactive/coalesce.js +15 -0
  19. package/dist/shared/proactive/context.d.ts +42 -0
  20. package/dist/shared/proactive/context.js +31 -0
  21. package/dist/shared/proactive/flags.d.ts +5 -0
  22. package/dist/shared/proactive/flags.js +11 -0
  23. package/dist/shared/proactive/index.d.ts +40 -0
  24. package/dist/shared/proactive/metadata.d.ts +48 -0
  25. package/dist/shared/proactive/metadata.js +126 -0
  26. package/dist/shared/proactive/operations.d.ts +96 -0
  27. package/dist/shared/proactive/operations.js +117 -0
  28. package/dist/shared/proactive/severityCopy.d.ts +4 -0
  29. package/dist/shared/proactive/severityCopy.js +10 -0
  30. package/dist/shared/proactive/snooze.d.ts +4 -0
  31. package/dist/shared/proactive/snooze.js +9 -0
  32. package/dist/shared/proactive/transport.d.ts +32 -0
  33. package/dist/shared/proactive/transport.js +124 -0
  34. package/dist/shared/proactive/types.d.ts +83 -0
  35. package/dist/shared/proactive/ui/ProactiveInbox.d.ts +20 -0
  36. package/dist/shared/proactive/ui/ProactiveInbox.js +78 -0
  37. package/dist/shared/proactive/ui/ProactiveSettingsPanel.d.ts +8 -0
  38. package/dist/shared/proactive/ui/ProactiveSettingsPanel.js +210 -0
  39. package/dist/shared/proactive/ui/SuggestionAnchorsLayer.d.ts +9 -0
  40. package/dist/shared/proactive/ui/SuggestionAnchorsLayer.js +140 -0
  41. package/dist/shared/proactive/ui/SuggestionBadge.d.ts +11 -0
  42. package/dist/shared/proactive/ui/SuggestionBadge.js +53 -0
  43. package/dist/shared/proactive/ui/SuggestionCard.d.ts +23 -0
  44. package/dist/shared/proactive/ui/SuggestionCard.js +119 -0
  45. package/dist/shared/proactive/ui/anchorLayerDom.d.ts +28 -0
  46. package/dist/shared/proactive/ui/anchorLayerDom.js +23 -0
  47. package/dist/shared/proactive/useProactiveSession.d.ts +56 -0
  48. package/dist/shared/proactive/useProactiveSession.js +150 -0
  49. package/dist/shared/proactive/useSuggestionControls.d.ts +25 -0
  50. package/dist/shared/proactive/useSuggestionControls.js +118 -0
  51. package/dist/shared/providers/shell/PermissionProvider.d.ts +16 -0
  52. package/dist/shared/providers/shell/PermissionProvider.js +51 -30
  53. package/dist/shared/providers/shell/index.d.ts +1 -1
  54. package/dist/shared-proactive.d.ts +2 -0
  55. package/dist/shared-proactive.js +21 -0
  56. package/dist/shared-providers-shell.js +14 -14
  57. package/package.json +5 -1
@@ -0,0 +1,210 @@
1
+ import { Button as e } from "../../../ui/button.js";
2
+ import { Switch as t } from "../../../ui/switch.js";
3
+ import { useOptionalI18n as n } from "../../providers/shell/I18nProvider.js";
4
+ import { cn as r } from "../../utils/cn.js";
5
+ import { useProactiveOrNull as i } from "../context.js";
6
+ import { useId as a, useMemo as o, useState as s } from "react";
7
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ // src/shared/proactive/ui/ProactiveSettingsPanel.tsx
9
+ function d() {
10
+ let e = n()?.locale, t = o(() => {
11
+ try {
12
+ return new Intl.DateTimeFormat(e, { dateStyle: "medium" });
13
+ } catch {
14
+ return null;
15
+ }
16
+ }, [e]);
17
+ return (e) => {
18
+ let n = Date.parse(e);
19
+ return Number.isFinite(n) ? t ? t.format(new Date(n)) : new Date(n).toISOString().slice(0, 10) : null;
20
+ };
21
+ }
22
+ function f({ productName: t, notificationSettingsHref: n, className: a }) {
23
+ let o = i();
24
+ if (!o) return null;
25
+ let { status: s, settings: d } = o;
26
+ if (s === "disabled" || s === "unsupported") return null;
27
+ let f = o.controls.tr;
28
+ return d ? /* @__PURE__ */ l(v, {
29
+ proactive: o,
30
+ settings: d,
31
+ productName: t ?? f("proactive.settings.productFallback", "this app"),
32
+ notificationSettingsHref: n,
33
+ className: a
34
+ }) : /* @__PURE__ */ l("section", {
35
+ "data-proactive-ui": "",
36
+ "data-testid": "proactive-settings",
37
+ className: r("flex flex-col gap-2", a),
38
+ children: s === "error" ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("p", {
39
+ className: "text-sm text-text-secondary",
40
+ children: f("proactive.settings.loadFailed", "Your suggestion settings couldn't be loaded.")
41
+ }), /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(e, {
42
+ type: "button",
43
+ size: "sm",
44
+ variant: "outline",
45
+ onClick: o.refresh,
46
+ children: f("proactive.settings.retry", "Try again")
47
+ }) })] }) : /* @__PURE__ */ l("p", {
48
+ className: "text-sm text-text-secondary",
49
+ children: f("proactive.settings.loading", "Loading your suggestion settings…")
50
+ })
51
+ });
52
+ }
53
+ function p(e, t) {
54
+ let [n, r] = s({}), [i, a] = s(!1), [o, c] = s(null), l = n.enabled ?? t.enabled, u = n.frequency ?? t.frequency, d = l && u !== t.frequency, f = l !== t.enabled || d;
55
+ return {
56
+ enabled: l,
57
+ frequency: u,
58
+ dirty: f,
59
+ saving: i,
60
+ notice: o,
61
+ setEnabled: (e) => r((t) => ({
62
+ ...t,
63
+ enabled: e
64
+ })),
65
+ setFrequency: (e) => r((t) => ({
66
+ ...t,
67
+ frequency: e
68
+ })),
69
+ submit: async (t) => {
70
+ if (t.preventDefault(), !i && f) {
71
+ a(!0), c(null);
72
+ try {
73
+ let t = await e.saveSettings({
74
+ enabled: l,
75
+ ...d ? { frequency: u } : {}
76
+ });
77
+ t.status === "saved" && r({}), c(m(t));
78
+ } catch {
79
+ c("failed");
80
+ } finally {
81
+ a(!1);
82
+ }
83
+ }
84
+ }
85
+ };
86
+ }
87
+ function m(e) {
88
+ return e.status === "saved" ? e.frequencyUnavailable ? "frequency-unavailable" : "saved" : "failed";
89
+ }
90
+ function h({ tr: e, name: t, value: n, disabled: r, onChange: i }) {
91
+ let a = [
92
+ {
93
+ value: "IMMEDIATE",
94
+ label: e("proactive.settings.frequency.immediate", "As they come")
95
+ },
96
+ {
97
+ value: "DAILY_DIGEST",
98
+ label: e("proactive.settings.frequency.daily", "In a daily digest")
99
+ },
100
+ {
101
+ value: "WEEKLY_DIGEST",
102
+ label: e("proactive.settings.frequency.weekly", "In a weekly digest")
103
+ }
104
+ ];
105
+ return /* @__PURE__ */ u("fieldset", {
106
+ className: "flex flex-col gap-2",
107
+ disabled: r,
108
+ children: [/* @__PURE__ */ l("legend", {
109
+ className: "mb-1 text-sm font-medium text-text-primary",
110
+ children: e("proactive.settings.frequencyLegend", "When you're away, send suggestions")
111
+ }), a.map((e) => /* @__PURE__ */ u("label", {
112
+ className: "flex items-center gap-2 text-sm text-text-primary",
113
+ children: [/* @__PURE__ */ l("input", {
114
+ type: "radio",
115
+ name: t,
116
+ value: e.value,
117
+ checked: n === e.value,
118
+ onChange: () => i(e.value),
119
+ className: "size-4 accent-action-primary-bg"
120
+ }), e.label]
121
+ }, e.value))]
122
+ });
123
+ }
124
+ function g(e, t) {
125
+ switch (t) {
126
+ case "saved": return e("proactive.settings.saved", "Saved.");
127
+ case "frequency-unavailable": return e("proactive.settings.frequencyUnavailable", "Saved. The delivery choice can't be stored yet, so suggestions arrive as they come.");
128
+ case "failed": return e("proactive.settings.saveFailed", "Your settings couldn't be saved. Try again.");
129
+ case null: return null;
130
+ }
131
+ }
132
+ function _({ tr: t, saving: n, dirty: r, notice: i }) {
133
+ return /* @__PURE__ */ u("div", {
134
+ className: "flex items-center gap-3",
135
+ children: [/* @__PURE__ */ l(e, {
136
+ type: "submit",
137
+ size: "sm",
138
+ disabled: n || !r,
139
+ "aria-busy": n || void 0,
140
+ children: n ? t("proactive.settings.saving", "Saving…") : t("proactive.settings.save", "Save")
141
+ }), /* @__PURE__ */ l("p", {
142
+ role: "status",
143
+ className: "text-xs text-text-secondary",
144
+ children: g(t, i)
145
+ })]
146
+ });
147
+ }
148
+ function v({ proactive: e, settings: n, productName: i, notificationSettingsHref: o, className: s }) {
149
+ let c = e.controls.tr, f = a(), m = d(), g = p(e, n), v = n.enabled && n.consentExpiresAt ? m(n.consentExpiresAt) : null;
150
+ return /* @__PURE__ */ u("section", {
151
+ "aria-labelledby": `${f}-title`,
152
+ "data-proactive-ui": "",
153
+ "data-testid": "proactive-settings",
154
+ className: r("flex flex-col gap-4", s),
155
+ children: [/* @__PURE__ */ u("div", {
156
+ className: "flex flex-col gap-1",
157
+ children: [/* @__PURE__ */ l("h2", {
158
+ id: `${f}-title`,
159
+ className: "text-base font-semibold text-text-primary",
160
+ children: c("proactive.settings.title", "Proactive suggestions")
161
+ }), /* @__PURE__ */ l("p", {
162
+ id: `${f}-consent`,
163
+ className: "text-sm leading-relaxed text-text-secondary",
164
+ children: c("proactive.settings.consent", "When this is on, the assistant looks through {{product}} in the background to find problems and opportunities. It reads as you and only reads: it never changes anything, and every suggestion waits for you to act on it.", { product: i })
165
+ })]
166
+ }), /* @__PURE__ */ u("form", {
167
+ className: "flex flex-col gap-4",
168
+ onSubmit: (e) => void g.submit(e),
169
+ children: [
170
+ /* @__PURE__ */ u("div", {
171
+ className: "flex items-center gap-3",
172
+ children: [/* @__PURE__ */ l(t, {
173
+ id: `${f}-enabled`,
174
+ checked: g.enabled,
175
+ onCheckedChange: g.setEnabled,
176
+ "aria-describedby": `${f}-consent`,
177
+ disabled: g.saving
178
+ }), /* @__PURE__ */ l("label", {
179
+ htmlFor: `${f}-enabled`,
180
+ className: "text-sm font-medium text-text-primary",
181
+ children: c("proactive.settings.toggle", "Let the assistant look for suggestions")
182
+ })]
183
+ }),
184
+ g.enabled ? /* @__PURE__ */ l(h, {
185
+ tr: c,
186
+ name: `${f}-frequency`,
187
+ value: g.frequency,
188
+ disabled: g.saving,
189
+ onChange: g.setFrequency
190
+ }) : null,
191
+ v ? /* @__PURE__ */ l("p", {
192
+ className: "text-xs text-text-secondary",
193
+ children: c("proactive.settings.consentUntil", "Your permission lasts until {{date}}. Turning this off withdraws it at once.", { date: v })
194
+ }) : null,
195
+ o ? /* @__PURE__ */ l("a", {
196
+ href: o,
197
+ className: "text-xs text-text-link underline-offset-4 hover:underline",
198
+ children: c("proactive.settings.quietHours", "Quiet hours and delivery channels")
199
+ }) : null,
200
+ /* @__PURE__ */ l(_, {
201
+ tr: c,
202
+ saving: g.saving,
203
+ dirty: g.dirty,
204
+ notice: g.notice
205
+ })
206
+ ]
207
+ })]
208
+ });
209
+ }
210
+ export { f as ProactiveSettingsPanel };
@@ -0,0 +1,9 @@
1
+ import { SuggestionControls } from '../adapters';
2
+ import { ProactiveSuggestion } from '../types';
3
+ export interface SuggestionAnchorsLayerProps {
4
+ /** Severity-ordered live suggestions. */
5
+ suggestions: readonly ProactiveSuggestion[];
6
+ controls: SuggestionControls;
7
+ maxVisiblePins: number;
8
+ }
9
+ export declare function SuggestionAnchorsLayer({ suggestions, controls, maxVisiblePins, }: SuggestionAnchorsLayerProps): import('react').ReactPortal | null;
@@ -0,0 +1,140 @@
1
+ import { SUGGEST_ANCHOR_ATTRIBUTE as e, findAnchorElement as t, queryAnchorCandidates as n } from "../anchors.js";
2
+ import { EMPTY_CONTROLS as r, getSuggestionAnchorAdapter as i, getSuggestionAnchorAdapterVersion as a, listSuggestionAnchorAdapterTypes as o, subscribeSuggestionAnchorAdapters as s } from "../adapters.js";
3
+ import { selectPinnedSuggestions as c } from "../budget.js";
4
+ import { OWN_SELECTOR as l, mutationsConcernAnchors as u, pinPositionFor as d } from "./anchorLayerDom.js";
5
+ import { SuggestionBadge as f } from "./SuggestionBadge.js";
6
+ import { memo as p, useCallback as m, useEffect as h, useRef as g, useState as _, useSyncExternalStore as v } from "react";
7
+ import { jsx as y } from "react/jsx-runtime";
8
+ import { createPortal as b } from "react-dom";
9
+ // src/shared/proactive/ui/SuggestionAnchorsLayer.tsx
10
+ var x = 2e3;
11
+ function S(e, t) {
12
+ return e.length === t.length && e.every((e, n) => e.suggestion === t[n]?.suggestion && e.element === t[n]?.element);
13
+ }
14
+ function C(e, t) {
15
+ return e !== void 0 && e.length === t.length && e.every((e, n) => e === t[n]);
16
+ }
17
+ function w({ suggestions: d, controls: f, maxVisiblePins: p }) {
18
+ let w = v(s, a, () => 0), [T, E] = _([]), O = g(/* @__PURE__ */ new Map()), k = g({
19
+ suggestions: d,
20
+ controls: f,
21
+ maxVisiblePins: p
22
+ });
23
+ h(() => {
24
+ k.current = {
25
+ suggestions: d,
26
+ controls: f,
27
+ maxVisiblePins: p
28
+ };
29
+ });
30
+ let A = m(() => {
31
+ let { suggestions: e, controls: r, maxVisiblePins: a } = k.current, s = n(document).filter((e) => e.closest(l) === null), u = /* @__PURE__ */ new Map(), d = c(e, (e) => {
32
+ let n = i(e.anchor.entityType);
33
+ if (n) return n.canResolve?.(e.anchor) ?? !0;
34
+ let r = t(s, e.anchor);
35
+ return r && u.set(e.notificationId, r), r !== null;
36
+ }, a), f = /* @__PURE__ */ new Map(), p = [];
37
+ for (let e of d) {
38
+ let t = e.anchor.entityType, n = u.get(e.notificationId);
39
+ i(t) ? f.set(t, [...f.get(t) ?? [], e]) : n && p.push({
40
+ suggestion: e,
41
+ element: n
42
+ });
43
+ }
44
+ for (let e of o()) {
45
+ let t = i(e);
46
+ if (!t) continue;
47
+ let n = f.get(e) ?? [], a = O.current.get(e);
48
+ a && a.adapter === t && a.controls === r && C(a.suggestions, n) || (O.current.set(e, {
49
+ adapter: t,
50
+ suggestions: n,
51
+ controls: r
52
+ }), t.update(n, r));
53
+ }
54
+ for (let e of [...O.current.keys()]) i(e) || O.current.delete(e);
55
+ E((e) => S(e, p) ? e : p);
56
+ }, []), j = g(null), M = m(() => {
57
+ j.current === null && (j.current = requestAnimationFrame(() => {
58
+ j.current = null, A();
59
+ }));
60
+ }, [A]);
61
+ return h(() => {
62
+ if (typeof document > "u" || !document.body) return;
63
+ let t = typeof MutationObserver > "u" ? null : new MutationObserver((e) => {
64
+ u(e) && M();
65
+ });
66
+ t?.observe(document.body, {
67
+ childList: !0,
68
+ subtree: !0,
69
+ attributes: !0,
70
+ attributeFilter: [e]
71
+ }), window.addEventListener("resize", M);
72
+ let n = window.setInterval(M, x);
73
+ return () => {
74
+ t?.disconnect(), window.removeEventListener("resize", M), window.clearInterval(n), j.current !== null && cancelAnimationFrame(j.current), j.current = null;
75
+ };
76
+ }, [M]), h(() => {
77
+ M();
78
+ }, [
79
+ d,
80
+ f,
81
+ p,
82
+ w,
83
+ M
84
+ ]), h(() => {
85
+ let e = O.current;
86
+ return () => {
87
+ for (let t of e.keys()) i(t)?.update([], r);
88
+ e.clear();
89
+ };
90
+ }, []), typeof document > "u" || !document.body || T.length === 0 ? null : b(/* @__PURE__ */ y("div", {
91
+ "data-proactive-ui": "",
92
+ "data-agent": "deny",
93
+ "data-testid": "proactive-anchor-layer",
94
+ children: T.map((e) => /* @__PURE__ */ y(D, {
95
+ suggestion: e.suggestion,
96
+ element: e.element,
97
+ controls: f
98
+ }, e.suggestion.notificationId))
99
+ }), document.body);
100
+ }
101
+ function T(e, t) {
102
+ return e !== null && e.top === t.top && e.left === t.left && e.visible === t.visible;
103
+ }
104
+ function E(e) {
105
+ let t = typeof getComputedStyle == "function" && getComputedStyle(document.documentElement).direction === "rtl";
106
+ return d(e.getBoundingClientRect(), {
107
+ width: window.innerWidth,
108
+ height: window.innerHeight
109
+ }, t);
110
+ }
111
+ var D = p(function({ suggestion: e, element: t, controls: n }) {
112
+ let [r, i] = _(null);
113
+ return h(() => {
114
+ let e = null, n = () => {
115
+ e === null && (e = requestAnimationFrame(() => {
116
+ e = null;
117
+ let n = E(t);
118
+ i((e) => T(e, n) ? e : n);
119
+ }));
120
+ };
121
+ n();
122
+ let r = typeof ResizeObserver > "u" ? null : new ResizeObserver(n);
123
+ return r?.observe(t), window.addEventListener("scroll", n, !0), window.addEventListener("resize", n), () => {
124
+ r?.disconnect(), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n), e !== null && cancelAnimationFrame(e);
125
+ };
126
+ }, [t]), !r || !r.visible ? null : /* @__PURE__ */ y("div", {
127
+ "data-proactive-ui": "",
128
+ "data-agent": "deny",
129
+ className: "fixed z-30",
130
+ style: {
131
+ top: r.top,
132
+ left: r.left
133
+ },
134
+ children: /* @__PURE__ */ y(f, {
135
+ suggestion: e,
136
+ controls: n
137
+ })
138
+ });
139
+ });
140
+ export { w as SuggestionAnchorsLayer };
@@ -0,0 +1,11 @@
1
+ import { SuggestionControls } from '../adapters';
2
+ import { ProactiveSuggestion } from '../types';
3
+ export interface SuggestionBadgeProps {
4
+ suggestion: ProactiveSuggestion;
5
+ controls: SuggestionControls;
6
+ /** Which side of the badge the card opens on. Default `bottom`. */
7
+ side?: 'top' | 'right' | 'bottom' | 'left';
8
+ align?: 'start' | 'center' | 'end';
9
+ className?: string;
10
+ }
11
+ export declare function SuggestionBadge({ suggestion, controls, side, align, className, }: SuggestionBadgeProps): import('react').JSX.Element;
@@ -0,0 +1,53 @@
1
+ import { usePrefersReducedMotion as e } from "../../assistant/ui/usePrefersReducedMotion.js";
2
+ import { Popover as t, PopoverContent as n, PopoverTrigger as r } from "../../../ui/popover.js";
3
+ import { cn as i } from "../../utils/cn.js";
4
+ import { SuggestionCard as a } from "./SuggestionCard.js";
5
+ import { useState as o } from "react";
6
+ import { Sparkles as s } from "lucide-react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ // src/shared/proactive/ui/SuggestionBadge.tsx
9
+ var u = {
10
+ urgent: "border-status-error-border text-status-error-text bg-status-error-bg-subtle",
11
+ high: "border-status-warning-border text-status-warning-text bg-status-warning-bg-subtle",
12
+ medium: "border-status-info-border text-status-info-text bg-status-info-bg-subtle",
13
+ low: "border-border-default text-text-secondary bg-bg-elevated"
14
+ };
15
+ function d({ suggestion: d, controls: f, side: p = "bottom", align: m = "start", className: h }) {
16
+ let g = f.tr, [_, v] = o(!1), y = e();
17
+ return /* @__PURE__ */ l(t, {
18
+ open: _,
19
+ onOpenChange: (e) => {
20
+ v(e), e && f.markSeen(d);
21
+ },
22
+ children: [/* @__PURE__ */ c(r, {
23
+ asChild: !0,
24
+ children: /* @__PURE__ */ c("button", {
25
+ type: "button",
26
+ "aria-label": g("proactive.pin.label", "AI suggestion: {{title}}", { title: d.title }),
27
+ "data-agent": "deny",
28
+ "data-proactive-ui": "",
29
+ "data-testid": "proactive-suggestion-pin",
30
+ "data-severity": d.severity,
31
+ className: i("inline-flex size-6 items-center justify-center rounded-full border shadow-elevation-2 outline-none", "motion-safe:transition-colors hover:border-border-strong", "focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", u[d.severity], h),
32
+ children: /* @__PURE__ */ c(s, {
33
+ "aria-hidden": "true",
34
+ className: "size-3.5"
35
+ })
36
+ })
37
+ }), /* @__PURE__ */ c(n, {
38
+ side: p,
39
+ align: m,
40
+ collisionPadding: 8,
41
+ "aria-label": g("proactive.pin.cardLabel", "AI suggestion"),
42
+ "data-agent": "deny",
43
+ "data-proactive-ui": "",
44
+ className: i("w-80 max-w-[calc(100vw-1rem)] p-3", y && "animate-none!"),
45
+ children: /* @__PURE__ */ c(a, {
46
+ suggestion: d,
47
+ controls: f,
48
+ onSettled: () => v(!1)
49
+ })
50
+ })]
51
+ });
52
+ }
53
+ export { d as SuggestionBadge };
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ import { AssistantTr } from '../../assistant/i18n';
3
+ import { SuggestionControls } from '../adapters';
4
+ import { ProactiveSeverity, ProactiveSuggestion } from '../types';
5
+ export declare function SeverityBadge({ severity, tr }: {
6
+ severity: ProactiveSeverity;
7
+ tr: AssistantTr;
8
+ }): import('react').JSX.Element;
9
+ export declare function AiBadge({ tr }: {
10
+ tr: AssistantTr;
11
+ }): import('react').JSX.Element;
12
+ export interface SuggestionCardProps {
13
+ suggestion: ProactiveSuggestion;
14
+ controls: SuggestionControls;
15
+ /** Called after an action ran, or the suggestion was dismissed or snoozed. */
16
+ onSettled?: () => void;
17
+ /** Heading level of the title; the inbox nests cards under its own heading. */
18
+ headingLevel?: 'h3' | 'h4';
19
+ /** Extra content under the buttons (e.g. a product's "open" link). */
20
+ footer?: ReactNode;
21
+ className?: string;
22
+ }
23
+ export declare function SuggestionCard({ suggestion, controls, onSettled, headingLevel, footer, className, }: SuggestionCardProps): import('react').JSX.Element;
@@ -0,0 +1,119 @@
1
+ import { Badge as e } from "../../../ui/badge.js";
2
+ import { Button as t } from "../../../ui/button.js";
3
+ import { cn as n } from "../../utils/cn.js";
4
+ import { severityLabel as r } from "../severityCopy.js";
5
+ import { useId as i, useState as a } from "react";
6
+ import { Sparkles as o } from "lucide-react";
7
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ // src/shared/proactive/ui/SuggestionCard.tsx
9
+ var u = {
10
+ urgent: "destructive",
11
+ high: "warning",
12
+ medium: "info",
13
+ low: "secondary"
14
+ };
15
+ function d({ severity: t, tr: n }) {
16
+ return /* @__PURE__ */ c(e, {
17
+ variant: u[t],
18
+ "data-severity": t,
19
+ children: r(n, t)
20
+ });
21
+ }
22
+ function f({ tr: t }) {
23
+ return /* @__PURE__ */ l(e, {
24
+ variant: "outline",
25
+ children: [/* @__PURE__ */ c(o, { "aria-hidden": "true" }), t("proactive.card.aiBadge", "AI suggestion")]
26
+ });
27
+ }
28
+ function p({ suggestion: e, controls: r, onSettled: o, headingLevel: u = "h3", footer: p, className: m }) {
29
+ let h = r.tr, g = i(), [_, v] = a(null), [y, b] = a(null), x = r.offeredActions(e), S = u, C = async (t) => {
30
+ v({
31
+ kind: "action",
32
+ id: t.id
33
+ }), b(null);
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."));
36
+ }, w = async () => {
37
+ v({ kind: "dismiss" }), b(null);
38
+ let t = await r.dismiss(e);
39
+ v(null), t ? o?.() : b(h("proactive.card.dismissFailed", "Couldn't dismiss this suggestion. Try again."));
40
+ }, T = async (t) => {
41
+ v({ kind: "snooze" }), b(null);
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."));
44
+ };
45
+ return /* @__PURE__ */ l("article", {
46
+ "aria-labelledby": g,
47
+ "data-agent": "deny",
48
+ "data-proactive-ui": "",
49
+ "data-testid": "proactive-suggestion-card",
50
+ "data-suggestion-id": e.suggestionId,
51
+ className: n("flex flex-col gap-2 text-start", m),
52
+ children: [
53
+ /* @__PURE__ */ l("div", {
54
+ className: "flex flex-wrap items-center gap-1.5",
55
+ children: [/* @__PURE__ */ c(d, {
56
+ severity: e.severity,
57
+ tr: h
58
+ }), /* @__PURE__ */ c(f, { tr: h })]
59
+ }),
60
+ /* @__PURE__ */ c(S, {
61
+ id: g,
62
+ className: "text-sm font-semibold text-text-primary break-words",
63
+ children: e.title
64
+ }),
65
+ /* @__PURE__ */ c("p", {
66
+ className: "text-xs leading-relaxed text-text-secondary break-words",
67
+ children: e.why
68
+ }),
69
+ x.length > 0 ? /* @__PURE__ */ c("div", {
70
+ className: "flex flex-wrap gap-2 pt-1",
71
+ children: x.map((e) => /* @__PURE__ */ c(t, {
72
+ type: "button",
73
+ size: "sm",
74
+ variant: "secondary",
75
+ disabled: _ !== null,
76
+ "aria-busy": _?.kind === "action" && _.id === e.id || void 0,
77
+ onClick: () => void C(e),
78
+ children: e.label
79
+ }, e.id))
80
+ }) : null,
81
+ /* @__PURE__ */ l("div", {
82
+ className: "flex flex-wrap items-center gap-1 border-t border-border-subtle pt-2",
83
+ children: [/* @__PURE__ */ c(t, {
84
+ type: "button",
85
+ size: "sm",
86
+ variant: "ghost",
87
+ className: "px-2",
88
+ disabled: _ !== null,
89
+ "aria-busy": _?.kind === "dismiss" || void 0,
90
+ onClick: () => void w(),
91
+ children: h("proactive.card.dismiss", "Dismiss")
92
+ }), r.canSnooze ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(t, {
93
+ type: "button",
94
+ size: "sm",
95
+ variant: "ghost",
96
+ className: "px-2",
97
+ disabled: _ !== null,
98
+ onClick: () => void T("1d"),
99
+ children: h("proactive.card.snoozeDay", "Snooze 1 day")
100
+ }), /* @__PURE__ */ c(t, {
101
+ type: "button",
102
+ size: "sm",
103
+ variant: "ghost",
104
+ className: "px-2",
105
+ disabled: _ !== null,
106
+ onClick: () => void T("1w"),
107
+ children: h("proactive.card.snoozeWeek", "Snooze 1 week")
108
+ })] }) : null]
109
+ }),
110
+ y ? /* @__PURE__ */ c("p", {
111
+ role: "alert",
112
+ className: "text-xs text-status-error-text",
113
+ children: y
114
+ }) : null,
115
+ p
116
+ ]
117
+ });
118
+ }
119
+ export { f as AiBadge, d as SeverityBadge, p as SuggestionCard };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * DOM helpers of the inline comment layer (BOFF-13165), kept apart from the
3
+ * component so the component file exports components only.
4
+ */
5
+ /** The marker on every element the proactive UI renders. */
6
+ export declare const PROACTIVE_UI_ATTRIBUTE = "data-proactive-ui";
7
+ export declare const OWN_SELECTOR = "[data-proactive-ui]";
8
+ /** Is `node` part of the proactive UI itself? */
9
+ export declare function isOwnProactiveNode(node: Node | null): boolean;
10
+ /** Does this batch of mutations touch anything but the proactive UI? */
11
+ export declare function mutationsConcernAnchors(records: readonly MutationRecord[]): boolean;
12
+ export interface PinPosition {
13
+ top: number;
14
+ left: number;
15
+ visible: boolean;
16
+ }
17
+ /** Where the badge goes for an anchor rectangle, or hidden when it is out of view. */
18
+ export declare function pinPositionFor(rect: {
19
+ top: number;
20
+ left: number;
21
+ right: number;
22
+ bottom: number;
23
+ width: number;
24
+ height: number;
25
+ }, viewport: {
26
+ width: number;
27
+ height: number;
28
+ }, rtl: boolean): PinPosition;
@@ -0,0 +1,23 @@
1
+ // src/shared/proactive/ui/anchorLayerDom.ts
2
+ var e = "data-proactive-ui", t = `[${e}]`, n = 10;
3
+ function r(e) {
4
+ if (!e || e.nodeType !== 1) return !1;
5
+ let t = e;
6
+ return t.closest("[data-proactive-ui]") !== null || t.querySelector("[data-proactive-ui]") !== null;
7
+ }
8
+ function i(e) {
9
+ return e.some((e) => {
10
+ if (e.type === "attributes") return !r(e.target);
11
+ let t = [...Array.from(e.addedNodes), ...Array.from(e.removedNodes)];
12
+ return t.length !== 0 && t.some((e) => e.nodeType === 1 && !r(e));
13
+ });
14
+ }
15
+ function a(e, t, r) {
16
+ let i = (e.width > 0 || e.height > 0) && e.bottom > 0 && e.right > 0 && e.top < t.height && e.left < t.width;
17
+ return {
18
+ top: Math.round(e.top - n),
19
+ left: Math.round(r ? e.left - n : e.right - n * 1.4),
20
+ visible: i
21
+ };
22
+ }
23
+ export { t as OWN_SELECTOR, e as PROACTIVE_UI_ATTRIBUTE, r as isOwnProactiveNode, i as mutationsConcernAnchors, a as pinPositionFor };
@@ -0,0 +1,56 @@
1
+ import { ProactiveTransport } from './transport';
2
+ import { ProactiveActivityEntity, ProactiveSettings, ProactiveStatus, ProactiveSuggestion } from './types';
3
+ /** How often the open entity and the active workspace are re-read. */
4
+ export declare const PAGE_POLL_MS = 1000;
5
+ export interface SessionState {
6
+ /** The product and workspace this state was loaded for; '' before anything loaded. */
7
+ key: string;
8
+ status: Exclude<ProactiveStatus, 'disabled'>;
9
+ settings: ProactiveSettings | null;
10
+ suggestions: readonly ProactiveSuggestion[];
11
+ /** The list has been read at least once for this session. */
12
+ listLoaded: boolean;
13
+ }
14
+ export declare const NO_SUGGESTIONS: readonly ProactiveSuggestion[];
15
+ /**
16
+ * The active workspace, followed while `active` (popstate plus a 1 s poll, the
17
+ * same router-agnostic pattern as `useAssistantPageLabel`).
18
+ */
19
+ export declare function useStoredWorkspaceId(active: boolean): string | null;
20
+ export interface ProactiveSessionOptions {
21
+ /** Flags on, a transport, and authentication ready. */
22
+ active: boolean;
23
+ product: string;
24
+ transport: ProactiveTransport | null;
25
+ }
26
+ export interface ProactiveSession {
27
+ /** Product and workspace, or null while inactive. */
28
+ sessionKey: string | null;
29
+ status: ProactiveStatus;
30
+ settings: ProactiveSettings | null;
31
+ /** Unordered, as loaded. */
32
+ suggestions: readonly ProactiveSuggestion[];
33
+ listLoaded: boolean;
34
+ /** Change the session's state (ignored once the session changed). */
35
+ update(patch: (base: SessionState) => Partial<SessionState>): void;
36
+ /** The backend does not know the proactive fields: off for this page. */
37
+ markUnsupported(): void;
38
+ reloadSettings(): void;
39
+ reloadList(): void;
40
+ }
41
+ export declare function useProactiveSession({ active, product, transport, }: ProactiveSessionOptions): ProactiveSession;
42
+ export interface ActivityReportingOptions {
43
+ /** The session is ready (opted in). Restarted per session key. */
44
+ enabled: boolean;
45
+ sessionKey: string | null;
46
+ product: string;
47
+ transport: ProactiveTransport | null;
48
+ /** The entity open now; read on every poll. */
49
+ readEntity: () => ProactiveActivityEntity | null;
50
+ }
51
+ /**
52
+ * Reports the session start and entity changes (`activity.ts`). Restarted per
53
+ * session (product and workspace), so each opted-in workspace gets its own
54
+ * session-start report and nothing is sent for one that is not.
55
+ */
56
+ export declare function useActivityReporting({ enabled, sessionKey, product, transport, readEntity, }: ActivityReportingOptions): void;