@kelpie/ui 0.16.0 → 0.18.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/client.d.ts +1 -1
- package/dist/api/resources/ai.d.ts +21 -0
- package/dist/api/resources/ai.d.ts.map +1 -0
- package/dist/api/resources/ai.js +101 -0
- package/dist/api/resources/ai.js.map +1 -0
- package/dist/api/resources/conversions.js +1 -1
- package/dist/api/resources/conversions.js.map +1 -1
- package/dist/api/resources/forms.d.ts +8 -0
- package/dist/api/resources/forms.d.ts.map +1 -1
- package/dist/api/resources/forms.js +39 -0
- package/dist/api/resources/forms.js.map +1 -1
- package/dist/api/resources/personIntake.d.ts +12 -0
- package/dist/api/resources/personIntake.d.ts.map +1 -0
- package/dist/api/resources/personIntake.js +54 -0
- package/dist/api/resources/personIntake.js.map +1 -0
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +3 -1
- package/dist/api/resources/session.js.map +1 -1
- package/dist/api/resources/workspace.d.ts +2 -2
- package/dist/api/resources/workspace.js +2 -2
- package/dist/app/KelpieApp.js +2 -2
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/ActivitiesPanel.d.ts +7 -4
- package/dist/components/ActivitiesPanel.d.ts.map +1 -1
- package/dist/components/ActivitiesPanel.js +12 -2
- package/dist/components/ActivitiesPanel.js.map +1 -1
- package/dist/components/ActivityAction.d.ts +15 -0
- package/dist/components/ActivityAction.d.ts.map +1 -0
- package/dist/components/ActivityAction.js +20 -0
- package/dist/components/ActivityAction.js.map +1 -0
- package/dist/components/AgentTasks.d.ts +5 -0
- package/dist/components/AgentTasks.d.ts.map +1 -1
- package/dist/components/AgentTasks.js +88 -10
- package/dist/components/AgentTasks.js.map +1 -1
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +3 -1
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/LinkedText.d.ts +12 -0
- package/dist/components/LinkedText.d.ts.map +1 -0
- package/dist/components/LinkedText.js +25 -0
- package/dist/components/LinkedText.js.map +1 -0
- package/dist/components/MarkdownView.d.ts +3 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +17 -3
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts +2 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +6 -7
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/PersonIntakeDialog.d.ts +19 -0
- package/dist/components/PersonIntakeDialog.d.ts.map +1 -0
- package/dist/components/PersonIntakeDialog.js +87 -0
- package/dist/components/PersonIntakeDialog.js.map +1 -0
- package/dist/components/PlanPanel.d.ts.map +1 -1
- package/dist/components/PlanPanel.js +3 -1
- package/dist/components/PlanPanel.js.map +1 -1
- package/dist/components/RecordLinkTextarea.d.ts +12 -0
- package/dist/components/RecordLinkTextarea.d.ts.map +1 -0
- package/dist/components/RecordLinkTextarea.js +142 -0
- package/dist/components/RecordLinkTextarea.js.map +1 -0
- package/dist/components/Shell.js +1 -1
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts +2 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +7 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/fragmentTarget.d.ts +18 -0
- package/dist/lib/fragmentTarget.d.ts.map +1 -0
- package/dist/lib/fragmentTarget.js +73 -0
- package/dist/lib/fragmentTarget.js.map +1 -0
- package/dist/lib/recordLinks.d.ts +17 -0
- package/dist/lib/recordLinks.d.ts.map +1 -0
- package/dist/lib/recordLinks.js +48 -0
- package/dist/lib/recordLinks.js.map +1 -0
- package/dist/lib/recordReferences.d.ts +41 -0
- package/dist/lib/recordReferences.d.ts.map +1 -0
- package/dist/lib/recordReferences.js +92 -0
- package/dist/lib/recordReferences.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +3 -0
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -0
- package/dist/modules/PersonIntakeWizard.js +223 -0
- package/dist/modules/PersonIntakeWizard.js.map +1 -0
- package/dist/modules/ai.d.ts +14 -0
- package/dist/modules/ai.d.ts.map +1 -0
- package/dist/modules/ai.js +26 -0
- package/dist/modules/ai.js.map +1 -0
- package/dist/modules/aiRunner.d.ts +3 -0
- package/dist/modules/aiRunner.d.ts.map +1 -0
- package/dist/modules/aiRunner.js +68 -0
- package/dist/modules/aiRunner.js.map +1 -0
- package/dist/modules/personIntakeSelection.d.ts +7 -0
- package/dist/modules/personIntakeSelection.d.ts.map +1 -0
- package/dist/modules/personIntakeSelection.js +21 -0
- package/dist/modules/personIntakeSelection.js.map +1 -0
- package/dist/pages/CompanyDetail.d.ts.map +1 -1
- package/dist/pages/CompanyDetail.js +2 -1
- package/dist/pages/CompanyDetail.js.map +1 -1
- package/dist/pages/DealDetail.d.ts.map +1 -1
- package/dist/pages/DealDetail.js +2 -1
- package/dist/pages/DealDetail.js.map +1 -1
- package/dist/pages/EnquiryDetail.d.ts.map +1 -1
- package/dist/pages/EnquiryDetail.js +2 -1
- package/dist/pages/EnquiryDetail.js.map +1 -1
- package/dist/pages/EventDetail.d.ts.map +1 -1
- package/dist/pages/EventDetail.js +2 -1
- package/dist/pages/EventDetail.js.map +1 -1
- package/dist/pages/FormsPage.js +4 -4
- package/dist/pages/FormsPage.js.map +1 -1
- package/dist/pages/OpportunityDetail.d.ts.map +1 -1
- package/dist/pages/OpportunityDetail.js +2 -1
- package/dist/pages/OpportunityDetail.js.map +1 -1
- package/dist/pages/PartnershipDetail.d.ts.map +1 -1
- package/dist/pages/PartnershipDetail.js +2 -1
- package/dist/pages/PartnershipDetail.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +7 -1
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/PersonDetail.d.ts.map +1 -1
- package/dist/pages/PersonDetail.js +2 -1
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/RaiseDetail.d.ts.map +1 -1
- package/dist/pages/RaiseDetail.js +2 -1
- package/dist/pages/RaiseDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +26 -14
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/admin/AiAdminPage.d.ts +2 -0
- package/dist/pages/admin/AiAdminPage.d.ts.map +1 -0
- package/dist/pages/admin/AiAdminPage.js +19 -0
- package/dist/pages/admin/AiAdminPage.js.map +1 -0
- package/dist/pages/admin/AiPage.d.ts +5 -0
- package/dist/pages/admin/AiPage.d.ts.map +1 -0
- package/dist/pages/admin/AiPage.js +196 -0
- package/dist/pages/admin/AiPage.js.map +1 -0
- package/dist/pages/admin/McpPage.js +2 -2
- package/dist/pages/admin/McpPage.js.map +1 -1
- package/dist/pages/admin/McpPanel.d.ts +3 -0
- package/dist/pages/admin/McpPanel.d.ts.map +1 -0
- package/dist/pages/admin/McpPanel.js +123 -0
- package/dist/pages/admin/McpPanel.js.map +1 -0
- package/dist/pages/admin/PrivacyPage.js +19 -3
- package/dist/pages/admin/PrivacyPage.js.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts +5 -6
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.js +12 -17
- package/dist/pages/admin/WorkspaceSettingsPage.js.map +1 -1
- package/dist/pages/dashboard/attention.d.ts +0 -5
- package/dist/pages/dashboard/attention.d.ts.map +1 -1
- package/dist/pages/dashboard/attention.js +1 -21
- package/dist/pages/dashboard/attention.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +6 -3
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +5 -2
- package/dist/pages/forms/EmbedPanel.js.map +1 -1
- package/dist/pages/forms/FieldsEditor.d.ts.map +1 -1
- package/dist/pages/forms/FieldsEditor.js +90 -8
- package/dist/pages/forms/FieldsEditor.js.map +1 -1
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +73 -6
- 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 +2 -1
- package/dist/pages/forms/SubmissionDetail.js.map +1 -1
- package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionsTable.js +2 -1
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/forms/fieldList.d.ts +2 -2
- package/dist/pages/forms/fieldList.d.ts.map +1 -1
- package/dist/pages/forms/fieldList.js +38 -10
- package/dist/pages/forms/fieldList.js.map +1 -1
- package/dist/pages/forms/template.d.ts.map +1 -1
- package/dist/pages/forms/template.js +13 -0
- package/dist/pages/forms/template.js.map +1 -1
- package/dist/pages/handbook/HandbookPage.d.ts.map +1 -1
- package/dist/pages/handbook/HandbookPage.js +2 -3
- package/dist/pages/handbook/HandbookPage.js.map +1 -1
- package/dist/pages/onboarding/WorkspaceStepPage.d.ts.map +1 -1
- package/dist/pages/onboarding/WorkspaceStepPage.js +9 -27
- package/dist/pages/onboarding/WorkspaceStepPage.js.map +1 -1
- package/dist/pages/onboarding/onboardingRerun.d.ts +9 -0
- package/dist/pages/onboarding/onboardingRerun.d.ts.map +1 -1
- package/dist/pages/onboarding/onboardingRerun.js +11 -0
- package/dist/pages/onboarding/onboardingRerun.js.map +1 -1
- package/dist/registry/context.d.ts +7 -1
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +12 -0
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/contributions.d.ts +70 -1
- package/dist/registry/contributions.d.ts.map +1 -1
- package/dist/registry/registry.d.ts +12 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +21 -0
- package/dist/registry/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/api/client.ts +1 -1
- package/src/api/resources/ai.ts +120 -0
- package/src/api/resources/conversions.ts +1 -1
- package/src/api/resources/forms.ts +56 -0
- package/src/api/resources/personIntake.ts +95 -0
- package/src/api/resources/session.ts +3 -1
- package/src/api/resources/workspace.ts +4 -4
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/ActivitiesPanel.tsx +39 -10
- package/src/components/ActivityAction.tsx +33 -0
- package/src/components/AgentTasks.tsx +138 -10
- package/src/components/DecisionsPanel.tsx +9 -1
- package/src/components/LinkedText.tsx +51 -0
- package/src/components/MarkdownView.tsx +37 -7
- package/src/components/NotesPanel.tsx +18 -12
- package/src/components/PersonIntakeDialog.tsx +226 -0
- package/src/components/PlanPanel.tsx +9 -1
- package/src/components/RecordLinkTextarea.tsx +257 -0
- package/src/components/Shell.tsx +1 -1
- package/src/components/WorkspaceSwitcher.tsx +15 -1
- package/src/index.ts +16 -0
- package/src/lib/fragmentTarget.ts +96 -0
- package/src/lib/recordLinks.ts +57 -0
- package/src/lib/recordReferences.ts +139 -0
- package/src/modules/PersonIntakeWizard.tsx +633 -0
- package/src/modules/ai.tsx +27 -0
- package/src/modules/aiRunner.ts +83 -0
- package/src/modules/personIntakeSelection.ts +24 -0
- package/src/pages/CompanyDetail.tsx +2 -1
- package/src/pages/DealDetail.tsx +2 -1
- package/src/pages/EnquiryDetail.tsx +2 -1
- package/src/pages/EventDetail.tsx +2 -1
- package/src/pages/FormsPage.tsx +4 -4
- package/src/pages/OpportunityDetail.tsx +2 -1
- package/src/pages/PartnershipDetail.tsx +2 -1
- package/src/pages/PeoplePage.tsx +21 -5
- package/src/pages/PersonDetail.tsx +2 -1
- package/src/pages/RaiseDetail.tsx +2 -1
- package/src/pages/SearchPage.tsx +30 -15
- package/src/pages/admin/AiAdminPage.tsx +52 -0
- package/src/pages/admin/AiPage.tsx +457 -0
- package/src/pages/admin/{McpPage.tsx → McpPanel.tsx} +15 -11
- package/src/pages/admin/PrivacyPage.tsx +42 -0
- package/src/pages/admin/WorkspaceSettingsPage.tsx +13 -28
- package/src/pages/dashboard/attention.ts +1 -24
- package/src/pages/dashboard/sections.tsx +9 -4
- package/src/pages/forms/EmbedPanel.tsx +5 -1
- package/src/pages/forms/FieldsEditor.tsx +204 -15
- package/src/pages/forms/FormSettings.tsx +156 -9
- package/src/pages/forms/SubmissionDetail.tsx +2 -1
- package/src/pages/forms/SubmissionsTable.tsx +2 -1
- package/src/pages/forms/fieldList.ts +39 -10
- package/src/pages/forms/template.ts +13 -0
- package/src/pages/handbook/HandbookPage.tsx +5 -6
- package/src/pages/onboarding/WorkspaceStepPage.tsx +19 -43
- package/src/pages/onboarding/onboardingRerun.ts +14 -0
- package/src/registry/context.ts +19 -0
- package/src/registry/contributions.ts +64 -1
- package/src/registry/registry.ts +48 -0
|
@@ -23,14 +23,13 @@ import { TimezoneSearch } from '../../components/TimezoneSearch.tsx'
|
|
|
23
23
|
/**
|
|
24
24
|
* Workspace settings, and the one screen that can end a workspace.
|
|
25
25
|
*
|
|
26
|
-
* Ported from the mockup's Workspace page.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* clicking one button.
|
|
26
|
+
* Ported from the mockup's Workspace page. One difference, because there is an
|
|
27
|
+
* API behind it now: the danger zone deletes for real, so it asks the reader to
|
|
28
|
+
* type the workspace name rather than clicking one button.
|
|
30
29
|
*
|
|
31
30
|
* The form saves explicitly instead of per keystroke. Every field here is
|
|
32
|
-
* workspace-wide,
|
|
33
|
-
*
|
|
31
|
+
* workspace-wide, so committing on each character would be a stream of
|
|
32
|
+
* half-typed values.
|
|
34
33
|
*/
|
|
35
34
|
|
|
36
35
|
export function WorkspaceSettingsPage(): React.JSX.Element {
|
|
@@ -57,7 +56,6 @@ function WorkspaceSettingsForm({
|
|
|
57
56
|
const { session } = useSession()
|
|
58
57
|
const update = useUpdateWorkspace()
|
|
59
58
|
const [name, setName] = useState(workspace.name)
|
|
60
|
-
const [slug, setSlug] = useState(workspace.slug)
|
|
61
59
|
const [timezone, setTimezone] = useState(workspace.timezone)
|
|
62
60
|
const [saved, setSaved] = useState(false)
|
|
63
61
|
|
|
@@ -70,7 +68,6 @@ function WorkspaceSettingsForm({
|
|
|
70
68
|
update
|
|
71
69
|
.runAsync({
|
|
72
70
|
name: name.trim(),
|
|
73
|
-
slug: slug.trim(),
|
|
74
71
|
timezone,
|
|
75
72
|
})
|
|
76
73
|
.then(() => {
|
|
@@ -83,7 +80,7 @@ function WorkspaceSettingsForm({
|
|
|
83
80
|
<div className="animate-slide-in mx-auto max-w-4xl space-y-8">
|
|
84
81
|
<PageHeader
|
|
85
82
|
title="Workspace"
|
|
86
|
-
description="Name
|
|
83
|
+
description="Name and timezone."
|
|
87
84
|
/>
|
|
88
85
|
|
|
89
86
|
<form onSubmit={save} className="space-y-4">
|
|
@@ -99,18 +96,6 @@ function WorkspaceSettingsForm({
|
|
|
99
96
|
/>
|
|
100
97
|
</Field>
|
|
101
98
|
|
|
102
|
-
<Field label="Slug" hint="Lowercase letters, digits, and hyphens. It appears in URLs.">
|
|
103
|
-
<input
|
|
104
|
-
value={slug}
|
|
105
|
-
onChange={(event) => {
|
|
106
|
-
setSlug(event.target.value)
|
|
107
|
-
}}
|
|
108
|
-
required
|
|
109
|
-
disabled={!canEdit}
|
|
110
|
-
className="w-full max-w-md rounded-md border border-border bg-surface-raised px-3 py-2 font-mono text-[13px] outline-none focus:border-accent focus:ring-2 focus:ring-accent/20 disabled:opacity-60"
|
|
111
|
-
/>
|
|
112
|
-
</Field>
|
|
113
|
-
|
|
114
99
|
<Field label="Timezone">
|
|
115
100
|
<div className="max-w-md">
|
|
116
101
|
<TimezoneSearch
|
|
@@ -146,7 +131,7 @@ function WorkspaceSettingsForm({
|
|
|
146
131
|
|
|
147
132
|
<OwnCompanySection canEdit={canEdit} />
|
|
148
133
|
|
|
149
|
-
{session?.role === 'owner' && <DangerZone
|
|
134
|
+
{session?.role === 'owner' && <DangerZone name={workspace.name} />}
|
|
150
135
|
</div>
|
|
151
136
|
)
|
|
152
137
|
}
|
|
@@ -277,11 +262,11 @@ function OwnCompanySection({ canEdit }: { readonly canEdit: boolean }): React.JS
|
|
|
277
262
|
/**
|
|
278
263
|
* Deleting the workspace, behind the workspace's own name.
|
|
279
264
|
*
|
|
280
|
-
* Owner only, both here and in the API. The typed
|
|
265
|
+
* Owner only, both here and in the API. The typed name is what the request
|
|
281
266
|
* carries, so this is the same guard on both sides rather than a browser-side
|
|
282
267
|
* flourish over an endpoint that would have deleted anyway.
|
|
283
268
|
*/
|
|
284
|
-
function DangerZone({
|
|
269
|
+
function DangerZone({ name }: { readonly name: string }): React.JSX.Element {
|
|
285
270
|
const navigate = useNavigate()
|
|
286
271
|
const remove = useDeleteWorkspace()
|
|
287
272
|
const [confirmation, setConfirmation] = useState('')
|
|
@@ -290,7 +275,7 @@ function DangerZone({ slug }: { readonly slug: string }): React.JSX.Element {
|
|
|
290
275
|
event.preventDefault()
|
|
291
276
|
|
|
292
277
|
remove
|
|
293
|
-
.runAsync({
|
|
278
|
+
.runAsync({ name: confirmation.trim() })
|
|
294
279
|
// Nothing left to render here: the workspace this page describes is gone,
|
|
295
280
|
// and the account is back to having none.
|
|
296
281
|
.then(() => navigate('/onboarding/workspace', { replace: true }))
|
|
@@ -307,19 +292,19 @@ function DangerZone({ slug }: { readonly slug: string }): React.JSX.Element {
|
|
|
307
292
|
<form onSubmit={submit} className="mt-3 flex flex-wrap items-end gap-2">
|
|
308
293
|
<label className="block">
|
|
309
294
|
<span className="mb-1.5 block text-[12px] font-medium text-ink">
|
|
310
|
-
Type <span className="font-
|
|
295
|
+
Type <span className="font-semibold">{name}</span> to confirm
|
|
311
296
|
</span>
|
|
312
297
|
<input
|
|
313
298
|
value={confirmation}
|
|
314
299
|
onChange={(event) => {
|
|
315
300
|
setConfirmation(event.target.value)
|
|
316
301
|
}}
|
|
317
|
-
className="w-56 rounded-md border border-border bg-surface-raised px-3 py-1.5
|
|
302
|
+
className="w-56 rounded-md border border-border bg-surface-raised px-3 py-1.5 text-[12px] outline-none focus:border-danger"
|
|
318
303
|
/>
|
|
319
304
|
</label>
|
|
320
305
|
<button
|
|
321
306
|
type="submit"
|
|
322
|
-
disabled={confirmation.trim() !==
|
|
307
|
+
disabled={confirmation.trim() !== name || remove.isPending}
|
|
323
308
|
className="rounded-md border border-danger bg-surface-raised px-3 py-1.5 text-[12px] font-medium text-danger transition hover:bg-danger hover:text-danger-fg disabled:opacity-40 disabled:hover:bg-surface-raised disabled:hover:text-danger"
|
|
324
309
|
>
|
|
325
310
|
{remove.isPending ? 'Deleting…' : 'Delete workspace'}
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
import type { ChipTone } from '../../components/Chip.tsx'
|
|
11
11
|
import { formatDate, formatDay } from '../../lib/dates.ts'
|
|
12
|
+
import { targetHref } from '../../lib/recordLinks.ts'
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Reading the workspace snapshot as a page: one attention list from the
|
|
@@ -20,20 +21,6 @@ import { formatDate, formatDay } from '../../lib/dates.ts'
|
|
|
20
21
|
* re-derived it from its own clock would disagree with the totals beside it.
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
|
-
/** Where each kind of record lives. A Candidate has no page of its own: it is reached through its Role. */
|
|
24
|
-
const ROUTES: Readonly<Record<RecordTargetType, string | undefined>> = {
|
|
25
|
-
person: '/people',
|
|
26
|
-
company: '/companies',
|
|
27
|
-
deal: '/deals',
|
|
28
|
-
opportunity: '/opportunities',
|
|
29
|
-
partnership: '/partnerships',
|
|
30
|
-
raise: '/fundraising',
|
|
31
|
-
enquiry: '/enquiries',
|
|
32
|
-
candidate: undefined,
|
|
33
|
-
event: '/events',
|
|
34
|
-
attendance: undefined,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
24
|
const TARGET_TYPE_LABELS: Readonly<Record<RecordTargetType, string>> = {
|
|
38
25
|
person: 'Person',
|
|
39
26
|
company: 'Company',
|
|
@@ -51,16 +38,6 @@ export function targetTypeLabel(targetType: RecordTargetType): string {
|
|
|
51
38
|
return TARGET_TYPE_LABELS[targetType]
|
|
52
39
|
}
|
|
53
40
|
|
|
54
|
-
/**
|
|
55
|
-
* @returns The record's page, or undefined when it has none. A row without a
|
|
56
|
-
* link renders as plain text rather than as a link to nowhere.
|
|
57
|
-
*/
|
|
58
|
-
export function targetHref(targetType: RecordTargetType, targetId: string): string | undefined {
|
|
59
|
-
const route = ROUTES[targetType]
|
|
60
|
-
|
|
61
|
-
return route === undefined ? undefined : `${route}/${targetId}`
|
|
62
|
-
}
|
|
63
|
-
|
|
64
41
|
/** How a target reads when it is named on another record's row. */
|
|
65
42
|
export function targetDescription(item: {
|
|
66
43
|
readonly targetType: RecordTargetType
|
|
@@ -8,11 +8,14 @@ import type {
|
|
|
8
8
|
import type { ReactNode } from 'react'
|
|
9
9
|
import { Link } from 'react-router'
|
|
10
10
|
|
|
11
|
+
import { ActivityAction } from '../../components/ActivityAction.tsx'
|
|
11
12
|
import { Chip } from '../../components/Chip.tsx'
|
|
13
|
+
import { LinkedText } from '../../components/LinkedText.tsx'
|
|
12
14
|
import { MarkdownView } from '../../components/MarkdownView.tsx'
|
|
13
15
|
import { SectionHeader } from '../../components/SectionHeader.tsx'
|
|
14
16
|
import { formatDate, formatRelativeTime } from '../../lib/dates.ts'
|
|
15
|
-
import { targetHref
|
|
17
|
+
import { targetHref } from '../../lib/recordLinks.ts'
|
|
18
|
+
import { targetTypeLabel } from './attention.ts'
|
|
16
19
|
import type { AttentionRow } from './attention.ts'
|
|
17
20
|
|
|
18
21
|
/**
|
|
@@ -169,7 +172,7 @@ export function ActivityFeed({
|
|
|
169
172
|
<div className="flex items-baseline justify-between gap-3">
|
|
170
173
|
<p className="min-w-0 text-[12px] leading-snug text-ink">
|
|
171
174
|
<span className="font-semibold">{actorNameFor(activity, nameById)}</span>{' '}
|
|
172
|
-
<
|
|
175
|
+
<ActivityAction action={activity.action} subject={activity.subject} />
|
|
173
176
|
</p>
|
|
174
177
|
<time
|
|
175
178
|
dateTime={activity.createdAt.toISOString()}
|
|
@@ -184,7 +187,9 @@ export function ActivityFeed({
|
|
|
184
187
|
<TargetLink target={activity} />
|
|
185
188
|
</p>
|
|
186
189
|
{activity.detail !== null && (
|
|
187
|
-
<p className="text-[11px] leading-snug text-ink-faint">
|
|
190
|
+
<p className="text-[11px] leading-snug text-ink-faint">
|
|
191
|
+
<LinkedText text={activity.detail} references={activity.references} />
|
|
192
|
+
</p>
|
|
188
193
|
)}
|
|
189
194
|
</div>
|
|
190
195
|
</li>
|
|
@@ -230,7 +235,7 @@ export function NotesList({
|
|
|
230
235
|
<li key={note.id} className="py-3">
|
|
231
236
|
<div className="flex items-start justify-between gap-2">
|
|
232
237
|
<div className="line-clamp-3 min-w-0 flex-1">
|
|
233
|
-
<MarkdownView source={note.body} />
|
|
238
|
+
<MarkdownView source={note.body} references={note.references} />
|
|
234
239
|
</div>
|
|
235
240
|
{note.pinned && (
|
|
236
241
|
<span className="shrink-0 text-[10px] font-medium tracking-wide text-accent uppercase">
|
|
@@ -160,10 +160,14 @@ function EmbedPreviewModal({
|
|
|
160
160
|
return
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// The same check the pasted snippet makes: only the embed page may resize it.
|
|
164
|
+
const embedOrigin = new URL(url, window.location.href).origin
|
|
165
|
+
|
|
163
166
|
function onMessage(event: MessageEvent): void {
|
|
164
167
|
const data = event.data as { kelpie?: string; formId?: string; height?: number } | null
|
|
165
168
|
|
|
166
169
|
if (
|
|
170
|
+
event.origin !== embedOrigin ||
|
|
167
171
|
data === null ||
|
|
168
172
|
typeof data !== 'object' ||
|
|
169
173
|
data.kelpie !== 'height' ||
|
|
@@ -182,7 +186,7 @@ function EmbedPreviewModal({
|
|
|
182
186
|
return () => {
|
|
183
187
|
window.removeEventListener('message', onMessage)
|
|
184
188
|
}
|
|
185
|
-
}, [formId, mode])
|
|
189
|
+
}, [formId, mode, url])
|
|
186
190
|
|
|
187
191
|
useEffect(() => {
|
|
188
192
|
function onKeyDown(event: KeyboardEvent): void {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import type { DragEndEvent } from '@dnd-kit/core'
|
|
10
10
|
import { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'
|
|
11
11
|
import { CSS } from '@dnd-kit/utilities'
|
|
12
|
-
import { FORM_OPTION_VALUE_TYPES } from '@kelpie/schemas'
|
|
12
|
+
import { FORM_OPTION_VALUE_TYPES, consentCheckboxText, formFieldDisplayLabel } from '@kelpie/schemas'
|
|
13
13
|
import type {
|
|
14
14
|
Form,
|
|
15
15
|
FormFieldInput,
|
|
@@ -20,8 +20,10 @@ import { useEffect, useMemo, useRef, useState } from 'react'
|
|
|
20
20
|
|
|
21
21
|
import { useConsentPurposes } from '../../api/resources/consentPurposes.ts'
|
|
22
22
|
import { useCustomFields } from '../../api/resources/customFields.ts'
|
|
23
|
-
import type { ConsentPurpose } from '@kelpie/schemas'
|
|
23
|
+
import type { ConsentPurpose, List } from '@kelpie/schemas'
|
|
24
24
|
import { useUpdateFormFields } from '../../api/resources/forms.ts'
|
|
25
|
+
import { useLists } from '../../api/resources/lists.ts'
|
|
26
|
+
import { useWorkspace } from '../../api/resources/workspace.ts'
|
|
25
27
|
import { ErrorPanel } from '../../components/QueryState.tsx'
|
|
26
28
|
import { AddFieldMenu } from './AddFieldMenu.tsx'
|
|
27
29
|
import { MapTargetSearch } from './MapTargetSearch.tsx'
|
|
@@ -281,8 +283,8 @@ function PreviewField({ field, selected, problem, onSelect }: PreviewFieldProps)
|
|
|
281
283
|
>
|
|
282
284
|
<button
|
|
283
285
|
type="button"
|
|
284
|
-
className="
|
|
285
|
-
aria-label={`Drag ${field
|
|
286
|
+
className="shrink-0 self-center cursor-grab touch-none rounded-md px-1 py-1 text-[10px] leading-none text-ink-faint opacity-0 transition hover:text-ink focus-visible:opacity-100 active:cursor-grabbing group-hover:opacity-100"
|
|
287
|
+
aria-label={`Drag ${formFieldDisplayLabel(field)} to reorder`}
|
|
286
288
|
{...attributes}
|
|
287
289
|
{...listeners}
|
|
288
290
|
>
|
|
@@ -302,16 +304,19 @@ function PreviewField({ field, selected, problem, onSelect }: PreviewFieldProps)
|
|
|
302
304
|
<button
|
|
303
305
|
type="button"
|
|
304
306
|
onClick={onSelect}
|
|
305
|
-
aria-label={`Edit ${field
|
|
307
|
+
aria-label={`Edit ${formFieldDisplayLabel(field)}`}
|
|
306
308
|
aria-pressed={selected}
|
|
307
309
|
className="absolute inset-0 z-10 cursor-pointer rounded-md"
|
|
308
310
|
/>
|
|
309
311
|
|
|
310
312
|
<div className="pointer-events-none">
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
{/* No label, no heading: the same as the embed. */}
|
|
314
|
+
{field.label.trim().length > 0 && (
|
|
315
|
+
<span className="mb-1 block text-[13px] font-medium text-ink">
|
|
316
|
+
{field.label}
|
|
317
|
+
{(field.required ?? false) && <span className="ml-0.5 text-danger">*</span>}
|
|
318
|
+
</span>
|
|
319
|
+
)}
|
|
315
320
|
<PreviewControl field={field} />
|
|
316
321
|
{problem !== undefined && <p className="mt-1.5 text-[12px] text-danger">{problem}</p>}
|
|
317
322
|
</div>
|
|
@@ -368,6 +373,10 @@ function PreviewControl({ field }: { readonly field: EditableField }): React.JSX
|
|
|
368
373
|
return <NoticePreview field={field} />
|
|
369
374
|
}
|
|
370
375
|
|
|
376
|
+
if (field.type === 'list') {
|
|
377
|
+
return <ListPreview field={field} />
|
|
378
|
+
}
|
|
379
|
+
|
|
371
380
|
return (
|
|
372
381
|
<input
|
|
373
382
|
readOnly
|
|
@@ -405,10 +414,15 @@ function NoticePreview({ field }: { readonly field: EditableField }): React.JSX.
|
|
|
405
414
|
)
|
|
406
415
|
}
|
|
407
416
|
|
|
417
|
+
/** Until the workspace loads, the preview shows the token rather than a guess. */
|
|
418
|
+
const WORKSPACE_TOKEN = '{{workspace}}'
|
|
419
|
+
|
|
408
420
|
function ConsentPreview({ field }: { readonly field: EditableField }): React.JSX.Element {
|
|
409
421
|
const purposes = useConsentPurposes({ sort: 'sort_order', limit: 200 })
|
|
410
|
-
const
|
|
411
|
-
|
|
422
|
+
const { workspace } = useWorkspace()
|
|
423
|
+
const workspaceName = workspace?.name ?? WORKSPACE_TOKEN
|
|
424
|
+
const purposeById = new Map<string, ConsentPurpose>(
|
|
425
|
+
purposes.records.map((purpose: ConsentPurpose) => [purpose.id, purpose]),
|
|
412
426
|
)
|
|
413
427
|
const statement = field.statement ?? field.label
|
|
414
428
|
const ids = field.consentPurposeIds ?? []
|
|
@@ -426,7 +440,11 @@ function ConsentPreview({ field }: { readonly field: EditableField }): React.JSX
|
|
|
426
440
|
<div key={id} className="flex items-start gap-2">
|
|
427
441
|
<input readOnly tabIndex={-1} type="checkbox" className="mt-0.5" />
|
|
428
442
|
<span className="text-[13px] text-ink">
|
|
429
|
-
{
|
|
443
|
+
{consentCheckboxText(
|
|
444
|
+
overrides[id],
|
|
445
|
+
purposeById.get(id) ?? { label: id, statement: '' },
|
|
446
|
+
workspaceName,
|
|
447
|
+
)}
|
|
430
448
|
</span>
|
|
431
449
|
</div>
|
|
432
450
|
))
|
|
@@ -435,6 +453,51 @@ function ConsentPreview({ field }: { readonly field: EditableField }): React.JSX
|
|
|
435
453
|
)
|
|
436
454
|
}
|
|
437
455
|
|
|
456
|
+
/**
|
|
457
|
+
* The lists a form can feed: person lists get the submitter, company lists the
|
|
458
|
+
* resolved company. The same two the form's Actions tab offers.
|
|
459
|
+
*/
|
|
460
|
+
function useFormLists(): { readonly isLoading: boolean; readonly records: readonly List[] } {
|
|
461
|
+
const personLists = useLists({ targetType: 'person' })
|
|
462
|
+
const companyLists = useLists({ targetType: 'company' })
|
|
463
|
+
const records = useMemo(
|
|
464
|
+
() => [...personLists.records, ...companyLists.records],
|
|
465
|
+
[personLists.records, companyLists.records],
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
return { isLoading: personLists.isLoading || companyLists.isLoading, records }
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* The Add to list preview — what the visitor sees: the statement, then one
|
|
473
|
+
* checkbox per list, each with the field's own text or else the list's name.
|
|
474
|
+
*/
|
|
475
|
+
function ListPreview({ field }: { readonly field: EditableField }): React.JSX.Element {
|
|
476
|
+
const lists = useFormLists()
|
|
477
|
+
const nameById = new Map(lists.records.map((list) => [list.id, list.name]))
|
|
478
|
+
const statement = (field.statement ?? '').trim()
|
|
479
|
+
const ids = field.listIds ?? []
|
|
480
|
+
const overrides = field.listLabels ?? {}
|
|
481
|
+
|
|
482
|
+
return (
|
|
483
|
+
<div className="space-y-1.5">
|
|
484
|
+
{statement.length > 0 && <p className="text-[12px] text-ink-muted">{statement}</p>}
|
|
485
|
+
{ids.length === 0 ? (
|
|
486
|
+
<p className="text-[11px] italic text-ink-faint">
|
|
487
|
+
Pick at least one list in the settings panel.
|
|
488
|
+
</p>
|
|
489
|
+
) : (
|
|
490
|
+
ids.map((id) => (
|
|
491
|
+
<div key={id} className="flex items-start gap-2">
|
|
492
|
+
<input readOnly tabIndex={-1} type="checkbox" className="mt-0.5" />
|
|
493
|
+
<span className="text-[13px] text-ink">{overrides[id] ?? nameById.get(id) ?? id}</span>
|
|
494
|
+
</div>
|
|
495
|
+
))
|
|
496
|
+
)}
|
|
497
|
+
</div>
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
|
|
438
501
|
interface FieldSettingsProps {
|
|
439
502
|
readonly field: EditableField
|
|
440
503
|
readonly fields: readonly EditableField[]
|
|
@@ -590,6 +653,33 @@ function FieldSettings({
|
|
|
590
653
|
</>
|
|
591
654
|
)}
|
|
592
655
|
|
|
656
|
+
{field.type === 'list' && (
|
|
657
|
+
<>
|
|
658
|
+
<label className="block">
|
|
659
|
+
<span className="mb-1 block text-[11px] font-medium text-ink-faint">
|
|
660
|
+
Description (text above the checkboxes)
|
|
661
|
+
</span>
|
|
662
|
+
<textarea
|
|
663
|
+
className={inputClass}
|
|
664
|
+
rows={3}
|
|
665
|
+
value={field.statement ?? ''}
|
|
666
|
+
onChange={(event) => {
|
|
667
|
+
const value = event.target.value
|
|
668
|
+
onChange({ statement: value.length === 0 ? null : value })
|
|
669
|
+
}}
|
|
670
|
+
placeholder="We send one email a month."
|
|
671
|
+
/>
|
|
672
|
+
</label>
|
|
673
|
+
<FormListPicker
|
|
674
|
+
value={field.listIds ?? []}
|
|
675
|
+
labels={field.listLabels ?? {}}
|
|
676
|
+
onChange={(listIds, listLabels) => {
|
|
677
|
+
onChange({ listIds, listLabels })
|
|
678
|
+
}}
|
|
679
|
+
/>
|
|
680
|
+
</>
|
|
681
|
+
)}
|
|
682
|
+
|
|
593
683
|
{problem !== undefined && <p className="text-[12px] text-danger">{problem}</p>}
|
|
594
684
|
|
|
595
685
|
<button
|
|
@@ -701,7 +791,7 @@ function OptionsEditor({
|
|
|
701
791
|
* beside each selected purpose so the admin can override the checkbox text.
|
|
702
792
|
* The override is bound to the same purpose the checkbox grants — the wording
|
|
703
793
|
* changes, the mapping never does. An empty override falls back to the
|
|
704
|
-
* workspace purpose's
|
|
794
|
+
* workspace purpose's consent statement, then its label, at render time.
|
|
705
795
|
*/
|
|
706
796
|
function ConsentPurposePicker({
|
|
707
797
|
mode,
|
|
@@ -790,7 +880,7 @@ function ConsentPurposePicker({
|
|
|
790
880
|
{isChosen && mode === 'checkbox' && (
|
|
791
881
|
<label className="mt-1.5 block">
|
|
792
882
|
<span className="mb-1 block text-[11px] font-medium text-ink-faint">
|
|
793
|
-
Checkbox text (defaults to the purpose
|
|
883
|
+
Checkbox text (defaults to the purpose's consent statement)
|
|
794
884
|
</span>
|
|
795
885
|
<input
|
|
796
886
|
className={inputClass}
|
|
@@ -798,7 +888,106 @@ function ConsentPurposePicker({
|
|
|
798
888
|
onChange={(event) => {
|
|
799
889
|
setLabel(purpose.id, event.target.value)
|
|
800
890
|
}}
|
|
801
|
-
placeholder={
|
|
891
|
+
placeholder={
|
|
892
|
+
purpose.statement.trim().length > 0 ? purpose.statement : purpose.label
|
|
893
|
+
}
|
|
894
|
+
/>
|
|
895
|
+
</label>
|
|
896
|
+
)}
|
|
897
|
+
</div>
|
|
898
|
+
)
|
|
899
|
+
})}
|
|
900
|
+
</div>
|
|
901
|
+
</fieldset>
|
|
902
|
+
)
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Picks the lists an Add to list field offers, with a text input beside each
|
|
907
|
+
* chosen list to override its checkbox text. An empty override falls back to
|
|
908
|
+
* the list's name. The workspace's list order is the order the visitor sees.
|
|
909
|
+
*/
|
|
910
|
+
function FormListPicker({
|
|
911
|
+
value,
|
|
912
|
+
labels,
|
|
913
|
+
onChange,
|
|
914
|
+
}: {
|
|
915
|
+
readonly value: readonly string[]
|
|
916
|
+
readonly labels: Readonly<Record<string, string>>
|
|
917
|
+
readonly onChange: (ids: readonly string[], labels: Readonly<Record<string, string>>) => void
|
|
918
|
+
}): React.JSX.Element {
|
|
919
|
+
const lists = useFormLists()
|
|
920
|
+
|
|
921
|
+
if (lists.isLoading) {
|
|
922
|
+
return <p className="text-[12px] text-ink-muted">Loading lists…</p>
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
if (lists.records.length === 0) {
|
|
926
|
+
return (
|
|
927
|
+
<p className="text-[12px] text-ink-muted">
|
|
928
|
+
No person or company lists yet. Add one on the Lists page, then pick it here.
|
|
929
|
+
</p>
|
|
930
|
+
)
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
const chosen = new Set(value)
|
|
934
|
+
|
|
935
|
+
function toggle(id: string, checked: boolean): void {
|
|
936
|
+
const nextIds = lists.records
|
|
937
|
+
.map((list) => list.id)
|
|
938
|
+
.filter((listId) => (listId === id ? checked : chosen.has(listId)))
|
|
939
|
+
// A list taken off the field drops its text too, so it does not come
|
|
940
|
+
// back if the list is picked again later.
|
|
941
|
+
const nextLabels: Record<string, string> = {}
|
|
942
|
+
for (const [key, text] of Object.entries(labels)) {
|
|
943
|
+
if (nextIds.includes(key)) nextLabels[key] = text
|
|
944
|
+
}
|
|
945
|
+
onChange(nextIds, nextLabels)
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
function setLabel(id: string, text: string): void {
|
|
949
|
+
const nextLabels: Record<string, string> = { ...labels }
|
|
950
|
+
if (text.length === 0) {
|
|
951
|
+
delete nextLabels[id]
|
|
952
|
+
} else {
|
|
953
|
+
nextLabels[id] = text
|
|
954
|
+
}
|
|
955
|
+
onChange(value, nextLabels)
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
return (
|
|
959
|
+
<fieldset className="block">
|
|
960
|
+
<legend className="mb-1 block text-[11px] font-medium text-ink-faint">
|
|
961
|
+
Lists (each selected one becomes a checkbox)
|
|
962
|
+
</legend>
|
|
963
|
+
<div className="flex flex-col gap-2">
|
|
964
|
+
{lists.records.map((list) => {
|
|
965
|
+
const isChosen = chosen.has(list.id)
|
|
966
|
+
return (
|
|
967
|
+
<div key={list.id} className="rounded-md border border-border p-2">
|
|
968
|
+
<label className="flex items-center gap-2 text-[13px] text-ink">
|
|
969
|
+
<input
|
|
970
|
+
type="checkbox"
|
|
971
|
+
checked={isChosen}
|
|
972
|
+
onChange={(event) => {
|
|
973
|
+
toggle(list.id, event.target.checked)
|
|
974
|
+
}}
|
|
975
|
+
/>
|
|
976
|
+
{list.name}
|
|
977
|
+
<span className="text-[11px] text-ink-faint">{list.targetType}</span>
|
|
978
|
+
</label>
|
|
979
|
+
{isChosen && (
|
|
980
|
+
<label className="mt-1.5 block">
|
|
981
|
+
<span className="mb-1 block text-[11px] font-medium text-ink-faint">
|
|
982
|
+
Checkbox text (defaults to the list's name)
|
|
983
|
+
</span>
|
|
984
|
+
<input
|
|
985
|
+
className={inputClass}
|
|
986
|
+
value={labels[list.id] ?? ''}
|
|
987
|
+
onChange={(event) => {
|
|
988
|
+
setLabel(list.id, event.target.value)
|
|
989
|
+
}}
|
|
990
|
+
placeholder={list.name}
|
|
802
991
|
/>
|
|
803
992
|
</label>
|
|
804
993
|
)}
|