@kelpie/ui 0.18.0 → 0.20.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/dist/api/resources/forms.d.ts +21 -2
- package/dist/api/resources/forms.d.ts.map +1 -1
- package/dist/api/resources/forms.js +51 -4
- package/dist/api/resources/forms.js.map +1 -1
- package/dist/components/AiDrawer.d.ts +13 -0
- package/dist/components/AiDrawer.d.ts.map +1 -0
- package/dist/components/AiDrawer.js +165 -0
- package/dist/components/AiDrawer.js.map +1 -0
- package/dist/components/ApiKeysPanel.js +1 -1
- package/dist/components/DataTable.js +1 -1
- package/dist/components/KanbanBoard.d.ts +5 -1
- package/dist/components/KanbanBoard.d.ts.map +1 -1
- package/dist/components/KanbanBoard.js +37 -2
- package/dist/components/KanbanBoard.js.map +1 -1
- package/dist/components/NotesPanel.js +2 -2
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/PageHeader.js +1 -1
- package/dist/components/PageHeader.js.map +1 -1
- package/dist/components/PersonIntakePanel.d.ts +21 -0
- package/dist/components/PersonIntakePanel.d.ts.map +1 -0
- package/dist/components/PersonIntakePanel.js +76 -0
- package/dist/components/PersonIntakePanel.js.map +1 -0
- package/dist/components/SegmentedControl.js +2 -2
- package/dist/components/SegmentedControl.js.map +1 -1
- package/dist/components/Shell.d.ts.map +1 -1
- package/dist/components/Shell.js +39 -3
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +10 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/components/aiDrawerState.d.ts +45 -0
- package/dist/components/aiDrawerState.d.ts.map +1 -0
- package/dist/components/aiDrawerState.js +14 -0
- package/dist/components/aiDrawerState.js.map +1 -0
- package/dist/components/personIntakeTask.d.ts +5 -0
- package/dist/components/personIntakeTask.d.ts.map +1 -0
- package/dist/components/personIntakeTask.js +13 -0
- package/dist/components/personIntakeTask.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/mediaQuery.d.ts +9 -0
- package/dist/lib/mediaQuery.d.ts.map +1 -0
- package/dist/lib/mediaQuery.js +24 -0
- package/dist/lib/mediaQuery.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +1 -1
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -1
- package/dist/modules/PersonIntakeWizard.js +9 -5
- package/dist/modules/PersonIntakeWizard.js.map +1 -1
- package/dist/pages/FormDetail.d.ts.map +1 -1
- package/dist/pages/FormDetail.js +9 -8
- package/dist/pages/FormDetail.js.map +1 -1
- package/dist/pages/FormsPage.d.ts.map +1 -1
- package/dist/pages/FormsPage.js +5 -1
- package/dist/pages/FormsPage.js.map +1 -1
- package/dist/pages/ListDetail.d.ts.map +1 -1
- package/dist/pages/ListDetail.js +2 -2
- package/dist/pages/ListDetail.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +8 -6
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/RoleDetail.d.ts.map +1 -1
- package/dist/pages/RoleDetail.js +3 -3
- package/dist/pages/RoleDetail.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.js +1 -1
- package/dist/pages/admin/DataPage.js +2 -2
- package/dist/pages/forms/AddFieldMenu.js +2 -2
- package/dist/pages/forms/AddFieldMenu.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.d.ts +5 -0
- package/dist/pages/forms/EmbedPanel.d.ts.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +79 -14
- package/dist/pages/forms/EmbedPanel.js.map +1 -1
- package/dist/pages/forms/FormActions.d.ts.map +1 -1
- package/dist/pages/forms/FormActions.js +2 -1
- package/dist/pages/forms/FormActions.js.map +1 -1
- package/dist/pages/forms/FormEmails.d.ts +6 -0
- package/dist/pages/forms/FormEmails.d.ts.map +1 -0
- package/dist/pages/forms/FormEmails.js +173 -0
- package/dist/pages/forms/FormEmails.js.map +1 -0
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +5 -3
- package/dist/pages/forms/FormSettings.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +22 -3
- package/dist/pages/forms/SubmissionDetail.js.map +1 -1
- package/dist/pages/forms/SubmissionsTable.d.ts +3 -1
- package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionsTable.js +48 -11
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/forms/embedPrompts.d.ts +45 -0
- package/dist/pages/forms/embedPrompts.d.ts.map +1 -0
- package/dist/pages/forms/embedPrompts.js +174 -0
- package/dist/pages/forms/embedPrompts.js.map +1 -0
- package/dist/pages/handbook/HandbookPage.js +4 -4
- package/dist/pages/handbook/HandbookPage.js.map +1 -1
- package/dist/registry/contributions.d.ts +8 -3
- package/dist/registry/contributions.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/resources/forms.ts +75 -4
- package/src/components/AiDrawer.tsx +272 -0
- package/src/components/ApiKeysPanel.tsx +1 -1
- package/src/components/DataTable.tsx +1 -1
- package/src/components/KanbanBoard.tsx +119 -2
- package/src/components/NotesPanel.tsx +7 -4
- package/src/components/PageHeader.tsx +1 -1
- package/src/components/{PersonIntakeDialog.tsx → PersonIntakePanel.tsx} +17 -50
- package/src/components/SegmentedControl.tsx +2 -2
- package/src/components/Shell.tsx +98 -12
- package/src/components/WorkspaceSwitcher.tsx +13 -2
- package/src/components/aiDrawerState.ts +61 -0
- package/src/components/personIntakeTask.tsx +14 -0
- package/src/index.ts +5 -0
- package/src/lib/mediaQuery.ts +32 -0
- package/src/modules/PersonIntakeWizard.tsx +10 -5
- package/src/pages/FormDetail.tsx +22 -15
- package/src/pages/FormsPage.tsx +5 -1
- package/src/pages/ListDetail.tsx +5 -3
- package/src/pages/PeoplePage.tsx +7 -10
- package/src/pages/RoleDetail.tsx +10 -5
- package/src/pages/account/ConnectedAppsPage.tsx +1 -1
- package/src/pages/admin/DataPage.tsx +2 -2
- package/src/pages/forms/AddFieldMenu.tsx +2 -2
- package/src/pages/forms/EmbedPanel.tsx +238 -34
- package/src/pages/forms/FormActions.tsx +4 -1
- package/src/pages/forms/FormEmails.tsx +449 -0
- package/src/pages/forms/FormSettings.tsx +23 -4
- package/src/pages/forms/SubmissionDetail.tsx +64 -2
- package/src/pages/forms/SubmissionsTable.tsx +123 -16
- package/src/pages/forms/embedPrompts.ts +257 -0
- package/src/pages/handbook/HandbookPage.tsx +5 -5
- package/src/registry/contributions.ts +8 -3
|
@@ -215,16 +215,19 @@ function NoteItem({
|
|
|
215
215
|
target.highlighted ? FRAGMENT_HIGHLIGHT : ''
|
|
216
216
|
}`}
|
|
217
217
|
>
|
|
218
|
-
|
|
218
|
+
{/* Below md the label and buttons sit in a row above the note, so the note
|
|
219
|
+
has the full card width; there is no hover on a phone, so the buttons
|
|
220
|
+
stay visible there. */}
|
|
221
|
+
<div className="flex flex-col gap-2 md:flex-row md:items-start md:justify-between">
|
|
219
222
|
<div className="min-w-0 flex-1">
|
|
220
223
|
<MarkdownView source={note.body} references={note.references} />
|
|
221
224
|
</div>
|
|
222
|
-
<div className="flex shrink-0 flex-col items-end gap-1">
|
|
225
|
+
<div className="order-first flex shrink-0 items-center gap-2 md:order-none md:flex-col md:items-end md:gap-1">
|
|
223
226
|
{note.pinned && (
|
|
224
227
|
<span className="text-[10px] font-semibold tracking-wide text-accent uppercase">Pinned</span>
|
|
225
228
|
)}
|
|
226
229
|
{confirmingDelete ? (
|
|
227
|
-
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
230
|
+
<div className="ml-auto flex flex-wrap items-center justify-end gap-2 md:ml-0">
|
|
228
231
|
<span className="text-[11px] text-ink-muted">Delete this note?</span>
|
|
229
232
|
<button
|
|
230
233
|
type="button"
|
|
@@ -248,7 +251,7 @@ function NoteItem({
|
|
|
248
251
|
</button>
|
|
249
252
|
</div>
|
|
250
253
|
) : (
|
|
251
|
-
<span className="flex gap-1 opacity-0
|
|
254
|
+
<span className="ml-auto flex gap-1 transition-opacity md:ml-0 md:opacity-0 md:group-hover:opacity-100 md:focus-within:opacity-100">
|
|
252
255
|
<button
|
|
253
256
|
type="button"
|
|
254
257
|
onClick={() => {
|
|
@@ -25,7 +25,7 @@ export function PageHeader({
|
|
|
25
25
|
<p className="mt-0.5 text-[13px] text-ink-muted">{description}</p>
|
|
26
26
|
)}
|
|
27
27
|
</div>
|
|
28
|
-
<div className="flex items-center gap-2">
|
|
28
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
29
29
|
{actions}
|
|
30
30
|
{onAdd !== undefined && <AddButton onClick={onAdd} label={addLabel} />}
|
|
31
31
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PERSON_INTAKE_MAX_TEXT } from '@kelpie/schemas'
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react'
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
4
|
|
|
5
5
|
import { useResolveAgentTask } from '../api/resources/agentTasks.ts'
|
|
@@ -12,9 +12,10 @@ import { ErrorPanel, LoadingPanel } from './QueryState.tsx'
|
|
|
12
12
|
* People's **Add from notes**: a second way to add a person, from what the
|
|
13
13
|
* user already knows.
|
|
14
14
|
*
|
|
15
|
-
* Core owns the button and this
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Core owns the button and this panel, which runs in the AI drawer so the page
|
|
16
|
+
* stays usable while the model works. When a module provides a wizard and it
|
|
17
|
+
* is ready (Kelpie AI enabled, with a key), the panel renders it. Without one,
|
|
18
|
+
* the panel still works: it builds the `workspace.add_person` prompt
|
|
18
19
|
* with the user's notes appended, for the user to paste into their own agent.
|
|
19
20
|
* That is the same pattern as the Log transcript task.
|
|
20
21
|
*/
|
|
@@ -37,55 +38,19 @@ export function AddFromNotesButton({ onClick }: { readonly onClick: () => void }
|
|
|
37
38
|
)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export interface
|
|
41
|
+
export interface PersonIntakePanelProps {
|
|
42
|
+
/** Ends the intake. */
|
|
41
43
|
readonly onClose: () => void
|
|
44
|
+
readonly onPendingChange: (pending: boolean) => void
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
export function
|
|
47
|
+
export function PersonIntakePanel({ onClose, onPendingChange }: PersonIntakePanelProps): React.JSX.Element {
|
|
45
48
|
const provider = usePersonIntakeProvider()
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
window.addEventListener('keydown', onKey)
|
|
52
|
-
return () => {
|
|
53
|
-
window.removeEventListener('keydown', onKey)
|
|
54
|
-
}
|
|
55
|
-
}, [onClose])
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<div
|
|
59
|
-
className="fixed inset-0 z-40 flex items-end justify-center bg-ink/30 p-4 sm:items-center"
|
|
60
|
-
role="dialog"
|
|
61
|
-
aria-modal="true"
|
|
62
|
-
aria-label="Add a person from notes"
|
|
63
|
-
onClick={onClose}
|
|
64
|
-
>
|
|
65
|
-
<div
|
|
66
|
-
className="flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-lg border border-border bg-surface"
|
|
67
|
-
onClick={(event) => {
|
|
68
|
-
event.stopPropagation()
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
<div className="flex items-start justify-between gap-3 border-b border-border px-4 py-3">
|
|
72
|
-
<div>
|
|
73
|
-
<div className="text-[14px] font-semibold text-ink">Add a person from notes</div>
|
|
74
|
-
<div className="mt-0.5 text-[12px] text-ink-muted">
|
|
75
|
-
Paste what you know. Kelpie builds the record from it.
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
<button type="button" className="text-[12px] font-medium text-ink-muted hover:text-ink" onClick={onClose}>
|
|
79
|
-
Close
|
|
80
|
-
</button>
|
|
81
|
-
</div>
|
|
82
|
-
{provider === undefined ? (
|
|
83
|
-
<CopyPromptIntake reason="The AI module is not part of this install." />
|
|
84
|
-
) : (
|
|
85
|
-
<ProvidedIntake provider={provider} onClose={onClose} />
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
50
|
+
return provider === undefined ? (
|
|
51
|
+
<CopyPromptIntake reason="The AI module is not part of this install." />
|
|
52
|
+
) : (
|
|
53
|
+
<ProvidedIntake provider={provider} onClose={onClose} onPendingChange={onPendingChange} />
|
|
89
54
|
)
|
|
90
55
|
}
|
|
91
56
|
|
|
@@ -93,9 +58,11 @@ export function PersonIntakeDialog({ onClose }: PersonIntakeDialogProps): React.
|
|
|
93
58
|
function ProvidedIntake({
|
|
94
59
|
provider,
|
|
95
60
|
onClose,
|
|
61
|
+
onPendingChange,
|
|
96
62
|
}: {
|
|
97
63
|
readonly provider: PersonIntakeProvider
|
|
98
64
|
readonly onClose: () => void
|
|
65
|
+
readonly onPendingChange: (pending: boolean) => void
|
|
99
66
|
}): React.JSX.Element {
|
|
100
67
|
const availability: AgentRunnerAvailability = provider.useAvailability({ enabled: true })
|
|
101
68
|
|
|
@@ -109,10 +76,10 @@ function ProvidedIntake({
|
|
|
109
76
|
|
|
110
77
|
const Wizard = provider.Wizard
|
|
111
78
|
|
|
112
|
-
return <Wizard onClose={onClose} />
|
|
79
|
+
return <Wizard onClose={onClose} onPendingChange={onPendingChange} />
|
|
113
80
|
}
|
|
114
81
|
|
|
115
|
-
/** The
|
|
82
|
+
/** The panel body and footer, the same frame the wizard's steps use. */
|
|
116
83
|
export function IntakeFrame({
|
|
117
84
|
children,
|
|
118
85
|
footer,
|
|
@@ -21,7 +21,7 @@ export function SegmentedControl<T extends string>({
|
|
|
21
21
|
<div
|
|
22
22
|
role="group"
|
|
23
23
|
aria-label={ariaLabel}
|
|
24
|
-
className="inline-flex rounded-md border border-border bg-surface-raised p-0.5"
|
|
24
|
+
className="inline-flex max-w-full overflow-x-auto rounded-md border border-border bg-surface-raised p-0.5"
|
|
25
25
|
>
|
|
26
26
|
{options.map((option) => {
|
|
27
27
|
const selected = value === option.id
|
|
@@ -35,7 +35,7 @@ export function SegmentedControl<T extends string>({
|
|
|
35
35
|
onChange(option.id)
|
|
36
36
|
}}
|
|
37
37
|
className={[
|
|
38
|
-
'rounded px-2.5 py-1 text-[12px] font-medium transition-colors',
|
|
38
|
+
'shrink-0 whitespace-nowrap rounded px-2.5 py-1 text-[12px] font-medium transition-colors',
|
|
39
39
|
selected ? 'bg-accent-soft text-accent-hover' : 'text-ink-muted hover:text-ink',
|
|
40
40
|
].join(' ')}
|
|
41
41
|
>
|
package/src/components/Shell.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { ONBOARDING_RERUN_ENTRY } from '../pages/onboarding/onboardingRerun.ts'
|
|
|
9
9
|
import { useNavItems } from '../registry/context.ts'
|
|
10
10
|
import type { NavItem } from '../registry/contributions.ts'
|
|
11
11
|
import { useVisibleNavItems } from '../registry/visibleNav.ts'
|
|
12
|
+
import { AiDrawerLauncher, AiDrawerPanel, AiDrawerProvider } from './AiDrawer.tsx'
|
|
12
13
|
import { ErrorBoundary } from './ErrorBoundary.tsx'
|
|
13
14
|
import { WorkspaceSwitcher } from './WorkspaceSwitcher.tsx'
|
|
14
15
|
|
|
@@ -90,6 +91,16 @@ const THEME_LABELS: Readonly<Record<ThemePreference, string>> = {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
export function Shell(): React.JSX.Element {
|
|
94
|
+
// The drawer's state sits here, above the routed outlet, so an AI task
|
|
95
|
+
// survives a route change.
|
|
96
|
+
return (
|
|
97
|
+
<AiDrawerProvider>
|
|
98
|
+
<ShellLayout />
|
|
99
|
+
</AiDrawerProvider>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function ShellLayout(): React.JSX.Element {
|
|
93
104
|
const navigate = useNavigate()
|
|
94
105
|
const location = useLocation()
|
|
95
106
|
const { account } = useAccount()
|
|
@@ -97,6 +108,9 @@ export function Shell(): React.JSX.Element {
|
|
|
97
108
|
const moduleNav = useNavItems('primary')
|
|
98
109
|
const moduleAdminNav = useNavItems('admin')
|
|
99
110
|
const [menuOpen, setMenuOpen] = useState(false)
|
|
111
|
+
// Below `md` the sidebar is an off-canvas drawer; from `md` up it is always
|
|
112
|
+
// shown and this flag has no effect.
|
|
113
|
+
const [navOpen, setNavOpen] = useState(false)
|
|
100
114
|
// The same preference the account page writes, so this button and that page
|
|
101
115
|
// cannot disagree about which theme the account is on.
|
|
102
116
|
const { theme, setTheme } = useTheme()
|
|
@@ -129,6 +143,24 @@ export function Shell(): React.JSX.Element {
|
|
|
129
143
|
}
|
|
130
144
|
}, [menuOpen])
|
|
131
145
|
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (!navOpen) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function onKeyDown(event: KeyboardEvent): void {
|
|
152
|
+
if (event.key === 'Escape') {
|
|
153
|
+
setNavOpen(false)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
document.addEventListener('keydown', onKeyDown)
|
|
158
|
+
|
|
159
|
+
return () => {
|
|
160
|
+
document.removeEventListener('keydown', onKeyDown)
|
|
161
|
+
}
|
|
162
|
+
}, [navOpen])
|
|
163
|
+
|
|
132
164
|
const navItems = useVisibleNavItems(CORE_NAV, moduleNav)
|
|
133
165
|
const topLevelItems = navItems.filter((item) => TOP_LEVEL_NAV_IDS.has(item.id))
|
|
134
166
|
const nonTopLevelItems = navItems.filter((item) => !TOP_LEVEL_NAV_IDS.has(item.id))
|
|
@@ -142,16 +174,50 @@ export function Shell(): React.JSX.Element {
|
|
|
142
174
|
|
|
143
175
|
return (
|
|
144
176
|
<div className="flex min-h-screen bg-surface">
|
|
145
|
-
|
|
146
|
-
<div
|
|
177
|
+
{navOpen && (
|
|
178
|
+
<div
|
|
179
|
+
aria-hidden
|
|
180
|
+
className="fixed inset-0 z-40 bg-black/40 md:hidden"
|
|
181
|
+
onClick={() => {
|
|
182
|
+
setNavOpen(false)
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
<aside
|
|
187
|
+
id="shell-nav"
|
|
188
|
+
className={[
|
|
189
|
+
'fixed inset-y-0 left-0 z-40 flex w-[240px] shrink-0 flex-col border-r border-sidebar-border bg-sidebar transition-transform duration-150 md:static md:w-[200px] md:translate-x-0',
|
|
190
|
+
navOpen ? 'translate-x-0' : '-translate-x-full',
|
|
191
|
+
].join(' ')}
|
|
192
|
+
>
|
|
193
|
+
<div className="flex items-center justify-between px-3 py-4">
|
|
147
194
|
<NavLink to="/dashboard" className="group block px-2">
|
|
148
195
|
<div className="text-[15px] font-semibold tracking-tight text-sidebar-ink transition-opacity group-hover:opacity-80">
|
|
149
196
|
Kelpie
|
|
150
197
|
</div>
|
|
151
198
|
</NavLink>
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
aria-label="Close navigation"
|
|
202
|
+
onClick={() => {
|
|
203
|
+
setNavOpen(false)
|
|
204
|
+
}}
|
|
205
|
+
className="rounded-md px-2 py-1 text-[12px] text-sidebar-muted transition hover:bg-sidebar-hover hover:text-sidebar-ink md:hidden"
|
|
206
|
+
>
|
|
207
|
+
Close
|
|
208
|
+
</button>
|
|
152
209
|
</div>
|
|
153
210
|
|
|
154
|
-
|
|
211
|
+
{/* A tap on any link closes the drawer, including a tap on the link
|
|
212
|
+
for the page already open, which does not change the route. */}
|
|
213
|
+
<nav
|
|
214
|
+
className="flex flex-1 flex-col gap-5 overflow-y-auto px-2 pb-4"
|
|
215
|
+
onClick={(event) => {
|
|
216
|
+
if (event.target instanceof Element && event.target.closest('a') !== null) {
|
|
217
|
+
setNavOpen(false)
|
|
218
|
+
}
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
155
221
|
{inAdminNav ? (
|
|
156
222
|
<>
|
|
157
223
|
<Link
|
|
@@ -229,9 +295,23 @@ export function Shell(): React.JSX.Element {
|
|
|
229
295
|
</aside>
|
|
230
296
|
|
|
231
297
|
<div className="flex min-w-0 flex-1 flex-col">
|
|
232
|
-
<header className="flex h-11 items-center gap-
|
|
298
|
+
<header className="flex h-11 items-center gap-2 border-b border-border px-3 sm:gap-3 md:px-5">
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
aria-label="Open navigation"
|
|
302
|
+
aria-controls="shell-nav"
|
|
303
|
+
aria-expanded={navOpen}
|
|
304
|
+
onClick={() => {
|
|
305
|
+
setNavOpen(true)
|
|
306
|
+
}}
|
|
307
|
+
className="flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-ink-muted transition hover:bg-surface-sunken hover:text-ink md:hidden"
|
|
308
|
+
>
|
|
309
|
+
<svg viewBox="0 0 16 16" aria-hidden className="h-4 w-4">
|
|
310
|
+
<path d="M2 4h12M2 8h12M2 12h12" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
311
|
+
</svg>
|
|
312
|
+
</button>
|
|
233
313
|
<form
|
|
234
|
-
className="flex-1"
|
|
314
|
+
className="min-w-0 flex-1"
|
|
235
315
|
onSubmit={(event) => {
|
|
236
316
|
event.preventDefault()
|
|
237
317
|
const term = query.trim()
|
|
@@ -253,6 +333,7 @@ export function Shell(): React.JSX.Element {
|
|
|
253
333
|
className="w-full max-w-sm rounded-md border border-transparent bg-surface-sunken px-2.5 py-1 text-[13px] text-ink outline-none transition placeholder:text-ink-faint focus:border-border focus:bg-surface-raised"
|
|
254
334
|
/>
|
|
255
335
|
</form>
|
|
336
|
+
<AiDrawerLauncher />
|
|
256
337
|
<button
|
|
257
338
|
type="button"
|
|
258
339
|
onClick={() => {
|
|
@@ -343,13 +424,18 @@ export function Shell(): React.JSX.Element {
|
|
|
343
424
|
</div>
|
|
344
425
|
</header>
|
|
345
426
|
|
|
346
|
-
<
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
<
|
|
351
|
-
|
|
352
|
-
|
|
427
|
+
<div className="flex min-h-0 flex-1">
|
|
428
|
+
<main className="min-w-0 flex-1 overflow-auto px-4 py-5 md:px-5">
|
|
429
|
+
{/* Keyed on the path so navigating away from a crashed page remounts
|
|
430
|
+
the boundary instead of leaving it stuck showing the old error. */}
|
|
431
|
+
<ErrorBoundary key={location.pathname}>
|
|
432
|
+
<Outlet />
|
|
433
|
+
</ErrorBoundary>
|
|
434
|
+
</main>
|
|
435
|
+
{/* Outside the route boundary, so a page that throws does not take a
|
|
436
|
+
running AI task with it. */}
|
|
437
|
+
<AiDrawerPanel />
|
|
438
|
+
</div>
|
|
353
439
|
</div>
|
|
354
440
|
</div>
|
|
355
441
|
)
|
|
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router'
|
|
|
3
3
|
|
|
4
4
|
import { useAccountWorkspaces, useSession, useSwitchWorkspace } from '../api/resources/session.ts'
|
|
5
5
|
import { ONBOARDING_NEW_WORKSPACE_ENTRY } from '../pages/onboarding/onboardingRerun.ts'
|
|
6
|
+
import { useAiDrawer } from './aiDrawerState.ts'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Header control: the workspace this session is in, and a menu to move it.
|
|
@@ -17,6 +18,7 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
17
18
|
const { session } = useSession()
|
|
18
19
|
const { workspaces, isLoading } = useAccountWorkspaces()
|
|
19
20
|
const switchWorkspace = useSwitchWorkspace()
|
|
21
|
+
const aiDrawer = useAiDrawer()
|
|
20
22
|
const [open, setOpen] = useState(false)
|
|
21
23
|
const menuRef = useRef<HTMLDivElement>(null)
|
|
22
24
|
const currentId = session?.workspaceId ?? null
|
|
@@ -50,7 +52,7 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
50
52
|
|
|
51
53
|
if (isLoading && workspaces.length === 0) {
|
|
52
54
|
return (
|
|
53
|
-
<span className="max-w-[
|
|
55
|
+
<span className="max-w-[8rem] truncate px-2 py-1 sm:max-w-[10rem] text-[12px] text-ink-faint" aria-hidden>
|
|
54
56
|
Workspace
|
|
55
57
|
</span>
|
|
56
58
|
)
|
|
@@ -73,7 +75,7 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
73
75
|
aria-haspopup="menu"
|
|
74
76
|
aria-label="Switch workspace"
|
|
75
77
|
title={label}
|
|
76
|
-
className="inline-flex max-w-[
|
|
78
|
+
className="inline-flex max-w-[8rem] items-center gap-1 rounded-md sm:max-w-[12rem] px-2 py-1 text-[12px] text-ink-muted transition hover:bg-surface-sunken hover:text-ink"
|
|
77
79
|
>
|
|
78
80
|
<span className="truncate">{label}</span>
|
|
79
81
|
<svg viewBox="0 0 12 12" aria-hidden className="h-2.5 w-2.5 shrink-0">
|
|
@@ -108,10 +110,19 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
108
110
|
return
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
// An AI task belongs to one workspace, so the switch discards it.
|
|
114
|
+
if (
|
|
115
|
+
aiDrawer.isPending &&
|
|
116
|
+
!window.confirm('AI is still working on a task. Switching workspace discards it. Switch anyway?')
|
|
117
|
+
) {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
111
121
|
switchWorkspace
|
|
112
122
|
.runAsync({ workspaceId: workspace.id })
|
|
113
123
|
.then(() => {
|
|
114
124
|
setOpen(false)
|
|
125
|
+
aiDrawer.finish()
|
|
115
126
|
void navigate('/dashboard', { replace: true })
|
|
116
127
|
})
|
|
117
128
|
.catch(() => undefined)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The AI drawer's contract and hook, apart from its components so the
|
|
6
|
+
* component file keeps fast refresh (the same split as `registry/context.ts`).
|
|
7
|
+
* The drawer itself is `AiDrawer.tsx`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** What a task may do to the drawer it sits in. */
|
|
11
|
+
export interface AiDrawerControls {
|
|
12
|
+
/** Hides the drawer. The task stays mounted. */
|
|
13
|
+
readonly close: () => void
|
|
14
|
+
/** Ends the task and unmounts it. */
|
|
15
|
+
readonly finish: () => void
|
|
16
|
+
/** Tells the header button to show the pending spinner. */
|
|
17
|
+
readonly setPending: (pending: boolean) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The content of the drawer. One is active at a time. */
|
|
21
|
+
export interface AiDrawerTask {
|
|
22
|
+
readonly id: string
|
|
23
|
+
readonly title: string
|
|
24
|
+
/** A line under the title. */
|
|
25
|
+
readonly description?: string
|
|
26
|
+
readonly render: (controls: AiDrawerControls) => ReactNode
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AiDrawerState {
|
|
30
|
+
readonly activeTask: AiDrawerTask | undefined
|
|
31
|
+
readonly isOpen: boolean
|
|
32
|
+
readonly isPending: boolean
|
|
33
|
+
/**
|
|
34
|
+
* Opens the drawer on `task`. When another task is active, opens on that
|
|
35
|
+
* one instead, says so, and returns `false`. Nothing is replaced silently.
|
|
36
|
+
*/
|
|
37
|
+
readonly open: (task: AiDrawerTask) => boolean
|
|
38
|
+
/** Shows the active task again. */
|
|
39
|
+
readonly reopen: () => void
|
|
40
|
+
readonly close: () => void
|
|
41
|
+
/** Ends the active task. */
|
|
42
|
+
readonly finish: () => void
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const AiDrawerContext = createContext<AiDrawerState | undefined>(undefined)
|
|
46
|
+
|
|
47
|
+
export function useAiDrawer(): AiDrawerState {
|
|
48
|
+
const state = useContext(AiDrawerContext)
|
|
49
|
+
|
|
50
|
+
if (state === undefined) {
|
|
51
|
+
throw new Error('useAiDrawer needs an AiDrawerProvider above it. Shell provides one.')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return state
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Whether the drawer says that a new task has to wait for the active one. */
|
|
58
|
+
export const AiDrawerBusyNoticeContext = createContext(false)
|
|
59
|
+
|
|
60
|
+
/** The active task's pending setter, handed to it through its controls. */
|
|
61
|
+
export const AiDrawerPendingContext = createContext<(pending: boolean) => void>(() => undefined)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AiDrawerTask } from './aiDrawerState.ts'
|
|
2
|
+
import { PersonIntakePanel } from './PersonIntakePanel.tsx'
|
|
3
|
+
|
|
4
|
+
export const PERSON_INTAKE_TASK_ID = 'person-intake'
|
|
5
|
+
|
|
6
|
+
/** The AI drawer task People's **Add from notes** opens. */
|
|
7
|
+
export function personIntakeTask(): AiDrawerTask {
|
|
8
|
+
return {
|
|
9
|
+
id: PERSON_INTAKE_TASK_ID,
|
|
10
|
+
title: 'Add a person from notes',
|
|
11
|
+
description: 'Paste what you know. Kelpie builds the record from it.',
|
|
12
|
+
render: (controls) => <PersonIntakePanel onClose={controls.finish} onPendingChange={controls.setPending} />,
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -248,6 +248,11 @@ export {
|
|
|
248
248
|
} from './registry/context.ts'
|
|
249
249
|
|
|
250
250
|
export { UiExtensionProvider } from './registry/UiExtensionProvider.tsx'
|
|
251
|
+
|
|
252
|
+
// The side drawer AI work runs in. Shell provides it; a module or page opens a
|
|
253
|
+
// task in it with `useAiDrawer().open(task)`.
|
|
254
|
+
export { useAiDrawer } from './components/aiDrawerState.ts'
|
|
255
|
+
export type { AiDrawerControls, AiDrawerState, AiDrawerTask } from './components/aiDrawerState.ts'
|
|
251
256
|
export type { UiExtensionProviderProps } from './registry/UiExtensionProvider.tsx'
|
|
252
257
|
|
|
253
258
|
// The optional `ai` module's UI. An assembly that lists `createAiModule()` on
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
|
+
|
|
3
|
+
/** Tailwind's `md` breakpoint, as a query that matches below it. */
|
|
4
|
+
export const BELOW_MD_QUERY = '(max-width: 767.98px)'
|
|
5
|
+
|
|
6
|
+
function hasMatchMedia(): boolean {
|
|
7
|
+
return typeof window !== 'undefined' && typeof window.matchMedia === 'function'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether `query` matches now, updated when it starts or stops matching. For
|
|
12
|
+
* a layout that cannot be done with CSS alone, such as rendering a different
|
|
13
|
+
* component tree. Without `matchMedia` (jsdom, server rendering) it is false.
|
|
14
|
+
*/
|
|
15
|
+
export function useMediaQuery(query: string): boolean {
|
|
16
|
+
return useSyncExternalStore(
|
|
17
|
+
(onChange: () => void): (() => void) => {
|
|
18
|
+
if (!hasMatchMedia()) {
|
|
19
|
+
return () => undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const list = window.matchMedia(query)
|
|
23
|
+
list.addEventListener('change', onChange)
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
list.removeEventListener('change', onChange)
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
(): boolean => hasMatchMedia() && window.matchMedia(query).matches,
|
|
30
|
+
(): boolean => false,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -14,14 +14,14 @@ import type {
|
|
|
14
14
|
PersonIntakeResultStatus,
|
|
15
15
|
PersonIntakeSource,
|
|
16
16
|
} from '@kelpie/schemas'
|
|
17
|
-
import { useState } from 'react'
|
|
17
|
+
import { useEffect, useState } from 'react'
|
|
18
18
|
import { Link } from 'react-router'
|
|
19
19
|
|
|
20
20
|
import { useAiServiceLabel } from '../api/resources/ai.ts'
|
|
21
21
|
import { useApplyPersonIntake, useIdentifyPerson, useResearchPerson } from '../api/resources/personIntake.ts'
|
|
22
22
|
import { Chip } from '../components/Chip.tsx'
|
|
23
23
|
import type { ChipTone } from '../components/Chip.tsx'
|
|
24
|
-
import { IntakeFrame, NotesField } from '../components/
|
|
24
|
+
import { IntakeFrame, NotesField } from '../components/PersonIntakePanel.tsx'
|
|
25
25
|
import { ErrorPanel } from '../components/QueryState.tsx'
|
|
26
26
|
import type { PersonIntakeWizardProps } from '../registry/contributions.ts'
|
|
27
27
|
import { effectiveSelection } from './personIntakeSelection.ts'
|
|
@@ -53,12 +53,17 @@ const primaryButton =
|
|
|
53
53
|
const secondaryButton =
|
|
54
54
|
'rounded-md px-2.5 py-1.5 text-[12px] font-medium text-ink-muted hover:text-ink disabled:opacity-50'
|
|
55
55
|
|
|
56
|
-
export function PersonIntakeWizard({ onClose }: PersonIntakeWizardProps): React.JSX.Element {
|
|
56
|
+
export function PersonIntakeWizard({ onClose, onPendingChange }: PersonIntakeWizardProps): React.JSX.Element {
|
|
57
57
|
const [step, setStep] = useState<Step>({ kind: 'notes' })
|
|
58
58
|
const [text, setText] = useState('')
|
|
59
59
|
const identify = useIdentifyPerson()
|
|
60
60
|
const research = useResearchPerson()
|
|
61
61
|
const apply = useApplyPersonIntake()
|
|
62
|
+
const pending = identify.isPending || research.isPending || apply.isPending
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
onPendingChange?.(pending)
|
|
66
|
+
}, [pending, onPendingChange])
|
|
62
67
|
|
|
63
68
|
async function runIdentify(): Promise<void> {
|
|
64
69
|
const identified = await identify.runAsync(text.trim())
|
|
@@ -161,7 +166,7 @@ function NotesStep({
|
|
|
161
166
|
<NotesField value={text} onChange={onChange} disabled={pending} />
|
|
162
167
|
{pending && (
|
|
163
168
|
<p className="mt-2 text-[12px] text-ink-muted">
|
|
164
|
-
{serviceLabel} is looking this person up. With web search on, this can take a minute.
|
|
169
|
+
{serviceLabel} is looking this person up. With web search on, this can take a minute. You can keep working: this task stays open in the drawer.
|
|
165
170
|
</p>
|
|
166
171
|
)}
|
|
167
172
|
{error !== null && (
|
|
@@ -323,7 +328,7 @@ function ConfirmStep({
|
|
|
323
328
|
</fieldset>
|
|
324
329
|
{pending && (
|
|
325
330
|
<p className="mt-3 text-[12px] text-ink-muted">
|
|
326
|
-
{serviceLabel} is researching this person. With web search on, this can take a minute.
|
|
331
|
+
{serviceLabel} is researching this person. With web search on, this can take a minute. You can keep working: this task stays open in the drawer.
|
|
327
332
|
</p>
|
|
328
333
|
)}
|
|
329
334
|
<Sources sources={identified.sources} />
|
package/src/pages/FormDetail.tsx
CHANGED
|
@@ -30,6 +30,7 @@ export function FormDetail(): React.JSX.Element {
|
|
|
30
30
|
const [tab, setTab] = useState<FormTab>('submissions')
|
|
31
31
|
const { record, isLoading, isNotFound, error } = useForm(id)
|
|
32
32
|
const submissions = useFormSubmissions(id)
|
|
33
|
+
const spam = useFormSubmissions(id, 'spam')
|
|
33
34
|
const deleteForm = useDeleteForm()
|
|
34
35
|
|
|
35
36
|
if (isNotFound) {
|
|
@@ -53,20 +54,24 @@ export function FormDetail(): React.JSX.Element {
|
|
|
53
54
|
← Forms
|
|
54
55
|
</Link>
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
{/* On a phone the controls go under the heading, so a long title keeps
|
|
58
|
+
the full width and does not break over several lines. */}
|
|
59
|
+
<div className="mb-6 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between">
|
|
57
60
|
<FormHeading form={record} />
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
62
|
+
<DeleteRecord
|
|
63
|
+
recordLabel="Form"
|
|
64
|
+
recordName={record.name}
|
|
65
|
+
isPending={deleteForm.isPending}
|
|
66
|
+
error={deleteForm.error}
|
|
67
|
+
onConfirm={() => {
|
|
68
|
+
deleteForm
|
|
69
|
+
.runAsync(record.id)
|
|
70
|
+
.then(() => navigate('/forms'))
|
|
71
|
+
.catch(() => undefined)
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
70
75
|
</div>
|
|
71
76
|
|
|
72
77
|
<RecordTabs
|
|
@@ -81,7 +86,9 @@ export function FormDetail(): React.JSX.Element {
|
|
|
81
86
|
onChange={setTab}
|
|
82
87
|
ariaLabel="Form sections"
|
|
83
88
|
>
|
|
84
|
-
{tab === 'submissions' &&
|
|
89
|
+
{tab === 'submissions' && (
|
|
90
|
+
<SubmissionsTable form={record} submissions={submissions} spam={spam} />
|
|
91
|
+
)}
|
|
85
92
|
{tab === 'fields' && <FieldsEditor form={record} />}
|
|
86
93
|
{tab === 'actions' && <FormActions form={record} />}
|
|
87
94
|
{tab === 'settings' && <FormSettings form={record} />}
|
|
@@ -118,7 +125,7 @@ function FormHeading({ form }: { readonly form: Form }): React.JSX.Element {
|
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
return (
|
|
121
|
-
<div className="min-w-
|
|
128
|
+
<div className="min-w-[12rem] flex-1">
|
|
122
129
|
<div className="flex flex-wrap items-center gap-2">
|
|
123
130
|
<div className="min-w-0 flex-1">
|
|
124
131
|
<InlineEdit
|
package/src/pages/FormsPage.tsx
CHANGED
|
@@ -59,10 +59,14 @@ export function FormsPage(): React.JSX.Element {
|
|
|
59
59
|
* A new form starts as the contact template rather than empty, because an
|
|
60
60
|
* empty field list is not a form the API will accept: it needs a
|
|
61
61
|
* `person.email` mapping before it can process anything.
|
|
62
|
+
*
|
|
63
|
+
* It starts with the spam check on. The API's own default is off, for a
|
|
64
|
+
* caller that posts JSON; a form made here is used through its embed, which
|
|
65
|
+
* passes the check by itself.
|
|
62
66
|
*/
|
|
63
67
|
function addForm(): void {
|
|
64
68
|
createForm
|
|
65
|
-
.runAsync({ name: 'New form', fields: CONTACT_FORM_FIELDS })
|
|
69
|
+
.runAsync({ name: 'New form', fields: CONTACT_FORM_FIELDS, requireSpamCheck: true })
|
|
66
70
|
.then((form) => navigate(`/forms/${form.id}`))
|
|
67
71
|
.catch(() => undefined)
|
|
68
72
|
}
|