@stigmer/react 3.0.6 → 3.0.7-dev.20260611143057
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/agent-instance/AgentInstanceDetailPanel.d.ts.map +1 -1
- package/agent-instance/AgentInstanceDetailPanel.js +2 -9
- package/agent-instance/AgentInstanceDetailPanel.js.map +1 -1
- package/agent-instance/AgentInstanceList.d.ts.map +1 -1
- package/agent-instance/AgentInstanceList.js +2 -9
- package/agent-instance/AgentInstanceList.js.map +1 -1
- package/agent-instance/CreateAgentInstanceDialog.d.ts.map +1 -1
- package/agent-instance/CreateAgentInstanceDialog.js +1 -1
- package/agent-instance/CreateAgentInstanceDialog.js.map +1 -1
- package/composer/SessionComposer.d.ts +14 -0
- package/composer/SessionComposer.d.ts.map +1 -1
- package/composer/SessionComposer.js +15 -9
- package/composer/SessionComposer.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/library/InstanceVisibilitySelector.d.ts +23 -9
- package/library/InstanceVisibilitySelector.d.ts.map +1 -1
- package/library/InstanceVisibilitySelector.js +14 -9
- package/library/InstanceVisibilitySelector.js.map +1 -1
- package/library/VisibilityOptionRow.d.ts +52 -0
- package/library/VisibilityOptionRow.d.ts.map +1 -0
- package/library/VisibilityOptionRow.js +92 -0
- package/library/VisibilityOptionRow.js.map +1 -0
- package/library/VisibilitySelector.d.ts +47 -24
- package/library/VisibilitySelector.d.ts.map +1 -1
- package/library/VisibilitySelector.js +137 -115
- package/library/VisibilitySelector.js.map +1 -1
- package/library/visibilityLevels.d.ts +25 -3
- package/library/visibilityLevels.d.ts.map +1 -1
- package/library/visibilityLevels.js +8 -2
- package/library/visibilityLevels.js.map +1 -1
- package/package.json +4 -4
- package/session/NewSessionViewer.d.ts +32 -1
- package/session/NewSessionViewer.d.ts.map +1 -1
- package/session/NewSessionViewer.js +20 -9
- package/session/NewSessionViewer.js.map +1 -1
- package/session/SessionViewer.d.ts +24 -1
- package/session/SessionViewer.d.ts.map +1 -1
- package/session/SessionViewer.js +18 -12
- package/session/SessionViewer.js.map +1 -1
- package/session/audience.d.ts +21 -0
- package/session/audience.d.ts.map +1 -0
- package/session/audience.js +2 -0
- package/session/audience.js.map +1 -0
- package/session/index.d.ts +2 -0
- package/session/index.d.ts.map +1 -1
- package/session/index.js.map +1 -1
- package/session/runtime-env.d.ts +47 -0
- package/session/runtime-env.d.ts.map +1 -0
- package/session/runtime-env.js +20 -0
- package/session/runtime-env.js.map +1 -0
- package/session/useNewSessionFlow.d.ts +25 -0
- package/session/useNewSessionFlow.d.ts.map +1 -1
- package/session/useNewSessionFlow.js +20 -8
- package/session/useNewSessionFlow.js.map +1 -1
- package/session/useSessionPageFlow.d.ts +27 -2
- package/session/useSessionPageFlow.d.ts.map +1 -1
- package/session/useSessionPageFlow.js +34 -13
- package/session/useSessionPageFlow.js.map +1 -1
- package/src/agent-instance/AgentInstanceDetailPanel.tsx +7 -27
- package/src/agent-instance/AgentInstanceList.tsx +7 -27
- package/src/agent-instance/CreateAgentInstanceDialog.tsx +1 -0
- package/src/composer/SessionComposer.tsx +30 -8
- package/src/composer/__tests__/SessionComposer-lockAgent.test.tsx +150 -0
- package/src/index.ts +2 -0
- package/src/library/InstanceVisibilitySelector.tsx +27 -9
- package/src/library/VisibilityOptionRow.tsx +244 -0
- package/src/library/VisibilitySelector.tsx +303 -260
- package/src/library/__tests__/VisibilitySelector.test.tsx +256 -0
- package/src/library/visibilityLevels.ts +35 -5
- package/src/session/NewSessionViewer.tsx +61 -12
- package/src/session/SessionViewer.tsx +51 -15
- package/src/session/__tests__/audienceWiring.test.tsx +274 -0
- package/src/session/__tests__/useNewSessionFlow.test.tsx +122 -0
- package/src/session/__tests__/useSessionPageFlow.runtimeEnv.test.tsx +170 -0
- package/src/session/audience.ts +20 -0
- package/src/session/index.ts +3 -0
- package/src/session/runtime-env.ts +57 -0
- package/src/session/useNewSessionFlow.ts +44 -9
- package/src/session/useSessionPageFlow.ts +65 -17
- package/src/workflow/instance/CreateWorkflowInstanceDialog.tsx +1 -0
- package/src/workflow/instance/WorkflowInstanceDetailPanel.tsx +7 -27
- package/src/workflow/instance/WorkflowInstanceList.tsx +7 -27
- package/styles.css +1 -1
- package/workflow/instance/CreateWorkflowInstanceDialog.d.ts.map +1 -1
- package/workflow/instance/CreateWorkflowInstanceDialog.js +1 -1
- package/workflow/instance/CreateWorkflowInstanceDialog.js.map +1 -1
- package/workflow/instance/WorkflowInstanceDetailPanel.d.ts.map +1 -1
- package/workflow/instance/WorkflowInstanceDetailPanel.js +2 -9
- package/workflow/instance/WorkflowInstanceDetailPanel.js.map +1 -1
- package/workflow/instance/WorkflowInstanceList.d.ts.map +1 -1
- package/workflow/instance/WorkflowInstanceList.js +2 -9
- package/workflow/instance/WorkflowInstanceList.js.map +1 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { cn } from "@stigmer/theme";
|
|
5
|
+
import type { VisibilityLevelOption } from "./visibilityLevels";
|
|
6
|
+
|
|
7
|
+
/** Color treatment key shared by every visibility surface. */
|
|
8
|
+
export type VisibilityTone = VisibilityLevelOption["tone"];
|
|
9
|
+
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Chip — the read-only badge and the editable trigger share this base so the
|
|
12
|
+
// two states are visually identical apart from the trigger's caret affordance.
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/** Base classes for the visibility chip (badge + selector trigger). */
|
|
16
|
+
export const VISIBILITY_CHIP_CLASS =
|
|
17
|
+
"inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground";
|
|
18
|
+
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Option row — one selectable level inside the popover (role="option") or the
|
|
21
|
+
// create-mode inline list (role="radio"). Pure presentation; the parent owns
|
|
22
|
+
// selection, focus management, and confirmation.
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
/** Props for {@link VisibilityOptionRow}. */
|
|
26
|
+
export interface VisibilityOptionRowProps {
|
|
27
|
+
/** The level this row represents. */
|
|
28
|
+
readonly option: VisibilityLevelOption;
|
|
29
|
+
/** Whether this row is the resource's current visibility. */
|
|
30
|
+
readonly isSelected: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* ARIA role for the row. `"option"` inside the popover listbox,
|
|
33
|
+
* `"radio"` inside the create-mode radiogroup — the matching selection
|
|
34
|
+
* attribute (`aria-selected` / `aria-checked`) is applied automatically.
|
|
35
|
+
*/
|
|
36
|
+
readonly role: "option" | "radio";
|
|
37
|
+
/** Visually highlighted by keyboard/pointer navigation (popover only). */
|
|
38
|
+
readonly isHighlighted?: boolean;
|
|
39
|
+
/** Disables interaction (e.g. while a change is in flight). */
|
|
40
|
+
readonly disabled?: boolean;
|
|
41
|
+
/** Roving-tabindex value; the focused row is `0`, the rest `-1`. */
|
|
42
|
+
readonly tabIndex?: number;
|
|
43
|
+
/** Fires when the row is activated (click / Enter / Space). */
|
|
44
|
+
readonly onSelect: () => void;
|
|
45
|
+
/** Pointer hover, used to sync the keyboard highlight. */
|
|
46
|
+
readonly onMouseEnter?: () => void;
|
|
47
|
+
/** Keydown handler owned by the parent for roving focus. */
|
|
48
|
+
readonly onKeyDown?: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A single visibility level rendered as a left-aligned row: tone icon,
|
|
53
|
+
* label, one-line description, and a check when current. Shared by the
|
|
54
|
+
* {@link VisibilitySelector} popover and its create-mode inline list so
|
|
55
|
+
* option presentation has exactly one source.
|
|
56
|
+
*/
|
|
57
|
+
export const VisibilityOptionRow = forwardRef<
|
|
58
|
+
HTMLButtonElement,
|
|
59
|
+
VisibilityOptionRowProps
|
|
60
|
+
>(function VisibilityOptionRow(
|
|
61
|
+
{
|
|
62
|
+
option,
|
|
63
|
+
isSelected,
|
|
64
|
+
role,
|
|
65
|
+
isHighlighted,
|
|
66
|
+
disabled,
|
|
67
|
+
tabIndex,
|
|
68
|
+
onSelect,
|
|
69
|
+
onMouseEnter,
|
|
70
|
+
onKeyDown,
|
|
71
|
+
},
|
|
72
|
+
ref,
|
|
73
|
+
) {
|
|
74
|
+
const selectionAttr =
|
|
75
|
+
role === "radio"
|
|
76
|
+
? { "aria-checked": isSelected }
|
|
77
|
+
: { "aria-selected": isSelected };
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<button
|
|
81
|
+
ref={ref}
|
|
82
|
+
type="button"
|
|
83
|
+
role={role}
|
|
84
|
+
{...selectionAttr}
|
|
85
|
+
tabIndex={tabIndex}
|
|
86
|
+
disabled={disabled}
|
|
87
|
+
onClick={onSelect}
|
|
88
|
+
onMouseEnter={onMouseEnter}
|
|
89
|
+
onKeyDown={onKeyDown}
|
|
90
|
+
className={cn(
|
|
91
|
+
"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left transition-colors",
|
|
92
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
93
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
94
|
+
isHighlighted ? "bg-accent text-foreground" : "hover:bg-accent-hover",
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
97
|
+
<VisibilityIcon
|
|
98
|
+
tone={option.tone}
|
|
99
|
+
className="mt-0.5 size-3.5 shrink-0 text-muted-foreground"
|
|
100
|
+
/>
|
|
101
|
+
<span className="min-w-0 flex-1">
|
|
102
|
+
<span className="block text-xs font-medium text-foreground">
|
|
103
|
+
{option.label}
|
|
104
|
+
</span>
|
|
105
|
+
<span className="block text-[0.65rem] leading-snug text-muted-foreground">
|
|
106
|
+
{option.description}
|
|
107
|
+
</span>
|
|
108
|
+
</span>
|
|
109
|
+
{isSelected && <CheckIcon className="mt-0.5 size-3.5 shrink-0 text-primary" />}
|
|
110
|
+
</button>
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Tone styling — one row per visibility tone, keyed by VisibilityLevelOption
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
/** Selected-segment / active-tone treatment (also used by the inline confirm). */
|
|
119
|
+
export const SELECTED_STYLES: Record<VisibilityTone, string> = {
|
|
120
|
+
private:
|
|
121
|
+
"bg-amber-50 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300",
|
|
122
|
+
org: "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",
|
|
123
|
+
platform:
|
|
124
|
+
"bg-violet-100 text-violet-800 dark:bg-violet-900/40 dark:text-violet-300",
|
|
125
|
+
public:
|
|
126
|
+
"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Inline-confirm (escalation prompt) treatment, keyed by tone. */
|
|
130
|
+
export const PROMPT_STYLES: Record<
|
|
131
|
+
VisibilityTone,
|
|
132
|
+
{ container: string; text: string; confirm: string; cancel: string }
|
|
133
|
+
> = {
|
|
134
|
+
// Private never escalates, but the row keeps the Record total.
|
|
135
|
+
private: {
|
|
136
|
+
container:
|
|
137
|
+
"border-amber-200 bg-amber-50 dark:border-amber-800/50 dark:bg-amber-950/30",
|
|
138
|
+
text: "text-amber-800 dark:text-amber-200",
|
|
139
|
+
confirm:
|
|
140
|
+
"bg-amber-600 hover:bg-amber-700 dark:bg-amber-600 dark:hover:bg-amber-500",
|
|
141
|
+
cancel:
|
|
142
|
+
"text-amber-700 hover:text-amber-900 dark:text-amber-300 dark:hover:text-amber-100",
|
|
143
|
+
},
|
|
144
|
+
org: {
|
|
145
|
+
container:
|
|
146
|
+
"border-blue-200 bg-blue-50 dark:border-blue-800/50 dark:bg-blue-950/30",
|
|
147
|
+
text: "text-blue-800 dark:text-blue-200",
|
|
148
|
+
confirm:
|
|
149
|
+
"bg-blue-600 hover:bg-blue-700 dark:bg-blue-600 dark:hover:bg-blue-500",
|
|
150
|
+
cancel:
|
|
151
|
+
"text-blue-700 hover:text-blue-900 dark:text-blue-300 dark:hover:text-blue-100",
|
|
152
|
+
},
|
|
153
|
+
platform: {
|
|
154
|
+
container:
|
|
155
|
+
"border-violet-200 bg-violet-50 dark:border-violet-800/50 dark:bg-violet-950/30",
|
|
156
|
+
text: "text-violet-800 dark:text-violet-200",
|
|
157
|
+
confirm:
|
|
158
|
+
"bg-violet-600 hover:bg-violet-700 dark:bg-violet-600 dark:hover:bg-violet-500",
|
|
159
|
+
cancel:
|
|
160
|
+
"text-violet-700 hover:text-violet-900 dark:text-violet-300 dark:hover:text-violet-100",
|
|
161
|
+
},
|
|
162
|
+
public: {
|
|
163
|
+
container:
|
|
164
|
+
"border-emerald-200 bg-emerald-50 dark:border-emerald-800/50 dark:bg-emerald-950/30",
|
|
165
|
+
text: "text-emerald-800 dark:text-emerald-200",
|
|
166
|
+
confirm:
|
|
167
|
+
"bg-emerald-600 hover:bg-emerald-700 dark:bg-emerald-600 dark:hover:bg-emerald-500",
|
|
168
|
+
cancel:
|
|
169
|
+
"text-emerald-700 hover:text-emerald-900 dark:text-emerald-300 dark:hover:text-emerald-100",
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
// Icons — inline SVGs following the SDK pattern (no icon library dependency)
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
|
|
177
|
+
/** Icon for a visibility tone; shared by the row, badge, and trigger. */
|
|
178
|
+
export function VisibilityIcon({
|
|
179
|
+
tone,
|
|
180
|
+
className,
|
|
181
|
+
}: {
|
|
182
|
+
readonly tone: VisibilityTone;
|
|
183
|
+
readonly className?: string;
|
|
184
|
+
}) {
|
|
185
|
+
switch (tone) {
|
|
186
|
+
case "org":
|
|
187
|
+
return <UsersIcon className={className} />;
|
|
188
|
+
case "platform":
|
|
189
|
+
return <BuildingsIcon className={className} />;
|
|
190
|
+
case "public":
|
|
191
|
+
return <GlobeIcon className={className} />;
|
|
192
|
+
default:
|
|
193
|
+
return <LockIcon className={className} />;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function LockIcon({ className }: { readonly className?: string }) {
|
|
198
|
+
return (
|
|
199
|
+
<svg className={className} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
200
|
+
<rect x="3.5" y="7" width="9" height="7" rx="1.5" />
|
|
201
|
+
<path d="M5.5 7V5a2.5 2.5 0 0 1 5 0v2" />
|
|
202
|
+
</svg>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function UsersIcon({ className }: { readonly className?: string }) {
|
|
207
|
+
return (
|
|
208
|
+
<svg className={className} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
209
|
+
<circle cx="6" cy="5" r="2.5" />
|
|
210
|
+
<path d="M2 13c0-2.21 1.79-4 4-4s4 1.79 4 4" />
|
|
211
|
+
<circle cx="11.5" cy="5.5" r="2" />
|
|
212
|
+
<path d="M14 13c0-1.66-1.12-3-2.5-3-.5 0-1 .14-1.4.4" />
|
|
213
|
+
</svg>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function BuildingsIcon({ className }: { readonly className?: string }) {
|
|
218
|
+
return (
|
|
219
|
+
<svg className={className} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
220
|
+
<path d="M2 14V4.5L6.5 2v12" />
|
|
221
|
+
<path d="M6.5 6.5 14 8.5V14" />
|
|
222
|
+
<path d="M2 14h12" />
|
|
223
|
+
<path d="M4.25 6h.01M4.25 8.5h.01M4.25 11h.01M10.5 10.5h.01M10.5 12.5h.01" />
|
|
224
|
+
</svg>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function GlobeIcon({ className }: { readonly className?: string }) {
|
|
229
|
+
return (
|
|
230
|
+
<svg className={className} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
231
|
+
<circle cx="8" cy="8" r="6" />
|
|
232
|
+
<path d="M2 8h12" />
|
|
233
|
+
<path d="M8 2c1.66 1.46 2.6 3.63 2.6 6s-.94 4.54-2.6 6c-1.66-1.46-2.6-3.63-2.6-6s.94-4.54 2.6-6Z" />
|
|
234
|
+
</svg>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function CheckIcon({ className }: { readonly className?: string }) {
|
|
239
|
+
return (
|
|
240
|
+
<svg className={className} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
241
|
+
<path d="M3 8.5 6.5 12 13 4.5" />
|
|
242
|
+
</svg>
|
|
243
|
+
);
|
|
244
|
+
}
|