@kelpie/ui 0.19.0 → 0.21.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.
Files changed (46) hide show
  1. package/dist/api/resources/forms.d.ts +21 -2
  2. package/dist/api/resources/forms.d.ts.map +1 -1
  3. package/dist/api/resources/forms.js +51 -4
  4. package/dist/api/resources/forms.js.map +1 -1
  5. package/dist/pages/FormDetail.d.ts.map +1 -1
  6. package/dist/pages/FormDetail.js +2 -1
  7. package/dist/pages/FormDetail.js.map +1 -1
  8. package/dist/pages/FormsPage.d.ts.map +1 -1
  9. package/dist/pages/FormsPage.js +5 -1
  10. package/dist/pages/FormsPage.js.map +1 -1
  11. package/dist/pages/forms/EmbedPanel.d.ts +5 -0
  12. package/dist/pages/forms/EmbedPanel.d.ts.map +1 -1
  13. package/dist/pages/forms/EmbedPanel.js +79 -14
  14. package/dist/pages/forms/EmbedPanel.js.map +1 -1
  15. package/dist/pages/forms/FormActions.d.ts.map +1 -1
  16. package/dist/pages/forms/FormActions.js +2 -1
  17. package/dist/pages/forms/FormActions.js.map +1 -1
  18. package/dist/pages/forms/FormEmails.d.ts +6 -0
  19. package/dist/pages/forms/FormEmails.d.ts.map +1 -0
  20. package/dist/pages/forms/FormEmails.js +173 -0
  21. package/dist/pages/forms/FormEmails.js.map +1 -0
  22. package/dist/pages/forms/FormSettings.d.ts.map +1 -1
  23. package/dist/pages/forms/FormSettings.js +5 -3
  24. package/dist/pages/forms/FormSettings.js.map +1 -1
  25. package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
  26. package/dist/pages/forms/SubmissionDetail.js +22 -3
  27. package/dist/pages/forms/SubmissionDetail.js.map +1 -1
  28. package/dist/pages/forms/SubmissionsTable.d.ts +3 -1
  29. package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
  30. package/dist/pages/forms/SubmissionsTable.js +48 -11
  31. package/dist/pages/forms/SubmissionsTable.js.map +1 -1
  32. package/dist/pages/forms/embedPrompts.d.ts +45 -0
  33. package/dist/pages/forms/embedPrompts.d.ts.map +1 -0
  34. package/dist/pages/forms/embedPrompts.js +174 -0
  35. package/dist/pages/forms/embedPrompts.js.map +1 -0
  36. package/package.json +2 -2
  37. package/src/api/resources/forms.ts +75 -4
  38. package/src/pages/FormDetail.tsx +4 -1
  39. package/src/pages/FormsPage.tsx +5 -1
  40. package/src/pages/forms/EmbedPanel.tsx +238 -34
  41. package/src/pages/forms/FormActions.tsx +4 -1
  42. package/src/pages/forms/FormEmails.tsx +449 -0
  43. package/src/pages/forms/FormSettings.tsx +23 -4
  44. package/src/pages/forms/SubmissionDetail.tsx +64 -2
  45. package/src/pages/forms/SubmissionsTable.tsx +123 -16
  46. package/src/pages/forms/embedPrompts.ts +257 -0
@@ -1,11 +1,17 @@
1
- import { formFieldDisplayLabel } from '@kelpie/schemas'
2
- import type { Form, FormSubmission, FormSubmissionActionEntry } from '@kelpie/schemas'
3
- import { useMemo } from 'react'
1
+ import { FORM_SPAM_REASON_LABELS, formFieldDisplayLabel } from '@kelpie/schemas'
2
+ import type {
3
+ Form,
4
+ FormSubmission,
5
+ FormSubmissionActionEntry,
6
+ FormSubmissionStatus,
7
+ } from '@kelpie/schemas'
8
+ import { useMemo, useState } from 'react'
4
9
  import { Link, useNavigate } from 'react-router'
5
10
 
6
11
  import type { RecordListResult } from '../../api/resource.ts'
7
12
  import { useTimezone } from '../../api/resources/account.ts'
8
13
  import { useCompanies } from '../../api/resources/companies.ts'
14
+ import { useReleaseFormSubmission } from '../../api/resources/forms.ts'
9
15
  import { usePeople } from '../../api/resources/people.ts'
10
16
  import { DataTable } from '../../components/DataTable.tsx'
11
17
  import type { Column } from '../../components/DataTable.tsx'
@@ -26,6 +32,10 @@ import { formatDateTime } from '../../lib/dates.ts'
26
32
  * A row opens `/forms/:id/submissions/:submissionId`. Inline person/company
27
33
  * links still navigate, and stop the row click so opening a person does not
28
34
  * also open the submission.
35
+ *
36
+ * What the spam check held is a second list, behind the Spam button. Those rows
37
+ * link no records, so they show the reason and a Release button in place of the
38
+ * person and company.
29
39
  */
30
40
 
31
41
  /** `?limit=` maxes out at 200 (`docs/agents/api-and-webhooks.md`). */
@@ -34,9 +44,17 @@ const MAX_PAGE = 200
34
44
  export interface SubmissionsTableProps {
35
45
  readonly form: Form
36
46
  readonly submissions: RecordListResult<FormSubmission>
47
+ /** The submissions the spam check held. */
48
+ readonly spam: RecordListResult<FormSubmission>
37
49
  }
38
50
 
39
- export function SubmissionsTable({ form, submissions }: SubmissionsTableProps): React.JSX.Element {
51
+ export function SubmissionsTable({
52
+ form,
53
+ submissions,
54
+ spam,
55
+ }: SubmissionsTableProps): React.JSX.Element {
56
+ const [view, setView] = useState<FormSubmissionStatus>('accepted')
57
+ const release = useReleaseFormSubmission()
40
58
  const navigate = useNavigate()
41
59
  const people = usePeople({ limit: MAX_PAGE })
42
60
  const companies = useCompanies({ limit: MAX_PAGE })
@@ -110,11 +128,53 @@ export function SubmissionsTable({ form, submissions }: SubmissionsTableProps):
110
128
  },
111
129
  ]
112
130
 
113
- if (submissions.error !== null) {
114
- return <ErrorPanel error={submissions.error} />
131
+ const spamColumns: readonly Column<FormSubmission>[] = [
132
+ ...columns.filter((column) => column.key === 'submitted'),
133
+ {
134
+ key: 'reason',
135
+ header: 'Why it was held',
136
+ render: (submission) => (
137
+ <span className="text-[12px] text-ink-muted">
138
+ {submission.spamReason === null ? '—' : FORM_SPAM_REASON_LABELS[submission.spamReason]}
139
+ </span>
140
+ ),
141
+ },
142
+ {
143
+ key: 'answers',
144
+ header: 'Answers',
145
+ render: (submission) => (
146
+ <span className="text-[12px] text-ink-muted">
147
+ {summarise(form, submission, NO_TARGETS)}
148
+ </span>
149
+ ),
150
+ },
151
+ {
152
+ key: 'release',
153
+ header: '',
154
+ className: 'w-24 text-right',
155
+ render: (submission) => (
156
+ <button
157
+ type="button"
158
+ disabled={release.isPending}
159
+ onClick={(event) => {
160
+ event.stopPropagation()
161
+ release.run({ formId: form.id, submissionId: submission.id })
162
+ }}
163
+ className="rounded-md border border-border bg-surface-raised px-2.5 py-1 text-[12px] font-medium text-ink transition hover:bg-surface disabled:opacity-50"
164
+ >
165
+ Release
166
+ </button>
167
+ ),
168
+ },
169
+ ]
170
+
171
+ const list = view === 'spam' ? spam : submissions
172
+
173
+ if (list.error !== null) {
174
+ return <ErrorPanel error={list.error} />
115
175
  }
116
176
 
117
- if (submissions.isLoading) {
177
+ if (list.isLoading) {
118
178
  return <LoadingPanel label="Loading submissions…" />
119
179
  }
120
180
 
@@ -122,23 +182,63 @@ export function SubmissionsTable({ form, submissions }: SubmissionsTableProps):
122
182
  <div>
123
183
  <SectionHeader
124
184
  title="Submissions"
125
- description="Inbound answers, and the records each one created or matched. Click a row to open it."
185
+ description={
186
+ view === 'spam'
187
+ ? 'Submissions the spam check held. Nothing was written to your CRM. Release one to process it as a normal submission. A held submission is deleted after 30 days.'
188
+ : 'Inbound answers, and the records each one created or matched. Click a row to open it.'
189
+ }
126
190
  />
127
- <Paginator list={submissions} placement="top" />
191
+ <div className="mb-3 flex gap-1" role="group" aria-label="Which submissions to show">
192
+ <ViewButton active={view === 'accepted'} onClick={() => setView('accepted')}>
193
+ Accepted
194
+ </ViewButton>
195
+ <ViewButton active={view === 'spam'} onClick={() => setView('spam')}>
196
+ Spam{spam.records.length > 0 ? ` (${String(spam.records.length)})` : ''}
197
+ </ViewButton>
198
+ </div>
199
+ {release.error !== null && (
200
+ <div className="mb-3">
201
+ <ErrorPanel error={release.error} />
202
+ </div>
203
+ )}
204
+ <Paginator list={list} placement="top" />
128
205
  <DataTable
129
- columns={columns}
130
- rows={submissions.records}
206
+ columns={view === 'spam' ? spamColumns : columns}
207
+ rows={list.records}
131
208
  getRowId={(submission) => submission.id}
132
- emptyMessage="No submissions yet"
209
+ emptyMessage={view === 'spam' ? 'No submissions held as spam' : 'No submissions yet'}
133
210
  onRowClick={(submission) => {
134
211
  void navigate(`/forms/${form.id}/submissions/${submission.id}`)
135
212
  }}
136
213
  />
137
- <Paginator list={submissions} />
214
+ <Paginator list={list} />
138
215
  </div>
139
216
  )
140
217
  }
141
218
 
219
+ function ViewButton({
220
+ active,
221
+ onClick,
222
+ children,
223
+ }: {
224
+ readonly active: boolean
225
+ readonly onClick: () => void
226
+ readonly children: React.ReactNode
227
+ }): React.JSX.Element {
228
+ return (
229
+ <button
230
+ type="button"
231
+ aria-pressed={active}
232
+ onClick={onClick}
233
+ className={`rounded-md px-2.5 py-1 text-[12px] font-medium transition ${
234
+ active ? 'bg-accent-soft text-accent' : 'text-ink-muted hover:bg-surface hover:text-ink'
235
+ }`}
236
+ >
237
+ {children}
238
+ </button>
239
+ )
240
+ }
241
+
142
242
  function CreatedLink({
143
243
  to,
144
244
  id,
@@ -230,16 +330,23 @@ const PERSON_COLUMN_TARGETS: ReadonlySet<string> = new Set([
230
330
  'person.email',
231
331
  ])
232
332
 
333
+ const NO_TARGETS: ReadonlySet<string> = new Set()
334
+
233
335
  /**
234
336
  * The first two answers that are not already a column.
235
337
  *
236
338
  * Name and email are the Person link, so repeating them would spend the row's
237
339
  * remaining width saying what it already said. A select shows its label rather
238
- * than the key that was stored.
340
+ * than the key that was stored. A held submission has no Person link, so it
341
+ * passes `NO_TARGETS` and its name and email are the first two answers.
239
342
  */
240
- function summarise(form: Form, submission: FormSubmission): string {
343
+ function summarise(
344
+ form: Form,
345
+ submission: FormSubmission,
346
+ shown: ReadonlySet<string> = PERSON_COLUMN_TARGETS,
347
+ ): string {
241
348
  const parts = form.fields
242
- .filter((field) => !PERSON_COLUMN_TARGETS.has(field.mapTo))
349
+ .filter((field) => !shown.has(field.mapTo))
243
350
  .map((field) => {
244
351
  const answer = submission.answers[field.id]
245
352
 
@@ -0,0 +1,257 @@
1
+ import { consentCheckboxText, formFieldDisplayLabel } from '@kelpie/schemas'
2
+ import type { ConsentPurpose, FormField } from '@kelpie/schemas'
3
+
4
+ /**
5
+ * Prompts a person can paste into an AI coding assistant to put a form on their
6
+ * site.
7
+ *
8
+ * Each prompt carries the exact URL or snippet from the API, so the assistant
9
+ * has nothing to guess, and names the parts it must not change: the embed
10
+ * address and the origin check in the resize listener.
11
+ *
12
+ * The JSON prompt is for a site that builds its own markup and posts to the
13
+ * public submit endpoint. It also carries the form's fields as they are now,
14
+ * with the ids the answers are keyed by and the exact text the embed shows
15
+ * beside each consent and list checkbox.
16
+ */
17
+
18
+ export interface EmbedPromptInput {
19
+ /** The form's display name, for the assistant's context. */
20
+ readonly formName: string
21
+ readonly url: string
22
+ readonly iframeSnippet: string
23
+ readonly scriptSnippet: string
24
+ }
25
+
26
+ export interface EmbedPrompts {
27
+ readonly hosted: string
28
+ readonly iframe: string
29
+ readonly script: string
30
+ }
31
+
32
+ export function buildEmbedPrompts({
33
+ formName,
34
+ url,
35
+ iframeSnippet,
36
+ scriptSnippet,
37
+ }: EmbedPromptInput): EmbedPrompts {
38
+ return {
39
+ hosted: [
40
+ `I want to link to my "${formName}" form from my website. The form is hosted by Kelpie, a CRM, at this URL:`,
41
+ '',
42
+ url,
43
+ '',
44
+ 'Please:',
45
+ '1. Look at my site and suggest where a link or button to this form fits best (for example the navigation, footer, or a contact section). Ask me if it is not clear.',
46
+ "2. Add the link using my site's existing components and styles for links or buttons.",
47
+ '3. Use the URL exactly as given. Do not change or rebuild it.',
48
+ '4. Decide with me whether it opens in the same tab or a new tab. If a new tab, add rel="noopener noreferrer".',
49
+ '',
50
+ 'Do not rebuild the form yourself and do not send submissions anywhere else. The hosted page handles submission.',
51
+ ].join('\n'),
52
+ iframe: [
53
+ `I want to embed my "${formName}" form on my website. The form is hosted by Kelpie, a CRM. This is the embed code:`,
54
+ '',
55
+ '```html',
56
+ iframeSnippet,
57
+ '```',
58
+ '',
59
+ 'Please:',
60
+ '1. Find the page where the form belongs. Ask me if it is not clear.',
61
+ "2. Add the iframe in the way my site's framework expects (for example JSX attributes and a style object in React, or a component in Vue or Svelte).",
62
+ '3. Keep the src URL exactly as given. Keep width 100% and no border. The height is fixed; change it only if the form is cut off or leaves a large gap.',
63
+ "4. Place it inside my page's existing layout so it matches the content width.",
64
+ '5. If my site sets a Content-Security-Policy, add the origin of the src URL to frame-src.',
65
+ '',
66
+ 'Do not rebuild the form yourself and do not send submissions anywhere else. The iframe handles submission.',
67
+ ].join('\n'),
68
+ script: [
69
+ `I want to embed my "${formName}" form on my website so that it resizes to fit its content. The form is hosted by Kelpie, a CRM. This is the embed code, an iframe and a script that listens for height messages from it:`,
70
+ '',
71
+ '```html',
72
+ scriptSnippet,
73
+ '```',
74
+ '',
75
+ 'Please:',
76
+ '1. Find the page where the form belongs. Ask me if it is not clear.',
77
+ "2. Add the iframe and the listener in the way my site's framework expects. In a component framework such as React, Vue or Svelte, register the message listener when the component mounts and remove it when it unmounts, and use a ref for the iframe instead of getElementById.",
78
+ '3. Keep the src URL exactly as given. Keep the origin check and the formId check in the listener exactly as given. They stop other pages from resizing the frame.',
79
+ "4. Place it inside my page's existing layout so it matches the content width.",
80
+ '5. If my site sets a Content-Security-Policy, add the origin of the src URL to frame-src, and allow the inline script or move it into a script file.',
81
+ '',
82
+ 'Do not rebuild the form yourself and do not send submissions anywhere else. The iframe handles submission.',
83
+ ].join('\n'),
84
+ }
85
+ }
86
+
87
+ export interface JsonSubmitPromptInput {
88
+ readonly formName: string
89
+ readonly submitUrl: string
90
+ /**
91
+ * Where the site gets its spam-check token, when the form requires the check.
92
+ * Null when it does not, and the prompt then says nothing about the check.
93
+ */
94
+ readonly tokenUrl: string | null
95
+ readonly fields: readonly FormField[]
96
+ readonly thankYouMessage: string
97
+ /** Workspace consent purposes by id, for the checkbox text a consent field shows. */
98
+ readonly consentPurposes: ReadonlyMap<string, Pick<ConsentPurpose, 'label' | 'statement'>>
99
+ /** List names by id, for the checkbox text an "Add to list" field shows. */
100
+ readonly listNames: ReadonlyMap<string, string>
101
+ readonly workspaceName: string
102
+ }
103
+
104
+ export function buildJsonSubmitPrompt({
105
+ formName,
106
+ submitUrl,
107
+ tokenUrl,
108
+ fields,
109
+ thankYouMessage,
110
+ consentPurposes,
111
+ listNames,
112
+ workspaceName,
113
+ }: JsonSubmitPromptInput): string {
114
+ const ordered = [...fields].sort((left, right) => left.sortOrder - right.sortOrder)
115
+ const describe = (field: FormField): string =>
116
+ describeField(field, consentPurposes, listNames, workspaceName)
117
+ const example = Object.fromEntries(
118
+ ordered
119
+ .filter((field) => field.type !== 'notice')
120
+ .map((field): [string, string] => [field.id, exampleAnswer(field)]),
121
+ )
122
+
123
+ return [
124
+ `I want to build my own form on my website that sends its answers to my "${formName}" form in Kelpie, a CRM, as JSON.`,
125
+ '',
126
+ '## Endpoint',
127
+ '',
128
+ `POST ${submitUrl}`,
129
+ 'Content-Type: application/json',
130
+ '',
131
+ 'Send no API key, cookie or other credential. The endpoint accepts requests from any origin, so the browser can call it directly.',
132
+ '',
133
+ '## Request body',
134
+ '',
135
+ '```json',
136
+ JSON.stringify({ answers: example }, null, 2),
137
+ '```',
138
+ '',
139
+ 'The values above are examples. Rules for `answers`:',
140
+ '- The keys are the field ids below. An unknown key makes the request fail.',
141
+ '- Every value is a string.',
142
+ '- If the visitor gives no answer, leave the key out. A required field must have a value.',
143
+ '- Select: send the option key, not the text the visitor sees.',
144
+ '- Consent and "Add to list": send the ids of the ticked boxes as one comma-separated string, for example "id1,id2". Show the statement and the checkbox text exactly as given below.',
145
+ '- Notice: show the text. Send no answer for it.',
146
+ '',
147
+ '## Fields, in display order',
148
+ '',
149
+ ...ordered.map(describe),
150
+ '',
151
+ ...(tokenUrl === null ? [] : spamCheckSection(tokenUrl)),
152
+ '## Responses',
153
+ '',
154
+ '- 201: `{ "id", "form_id", "submitted_at", "thank_you_message" }`. Replace the form with `thank_you_message`.' +
155
+ (thankYouMessage.trim().length > 0 ? ` It is currently: "${thankYouMessage}"` : ''),
156
+ '- 422 `validation_failed`: `{ "error": { "code", "message", "details": [{ "field": "answers.<field id>", "message" }] } }`. Show each detail message next to its field, and `error.message` above the form.',
157
+ '- 404 (form not found), 409 (form paused) and 429 (too many requests): `{ "error": { "code", "message" } }`. Show `error.message`.',
158
+ '',
159
+ '## Please',
160
+ '',
161
+ '1. Find the page where the form belongs. Ask me if it is not clear.',
162
+ "2. Build the form with my site's existing components and styles: one input for each field above, in the order given. Use an email input for email fields, a textarea for textarea fields, a select for select fields, and checkboxes for consent and \"Add to list\" fields.",
163
+ "3. Submit with fetch or my framework's usual data layer. Disable the submit button while the request is pending, and show the responses as described above.",
164
+ '4. Keep the endpoint URL exactly as given. If my site sets a Content-Security-Policy, add the origin of the endpoint to connect-src.',
165
+ tokenUrl === null
166
+ ? '5. Do not add credentials, extra headers or extra keys to the request.'
167
+ : '5. Do not add credentials or extra headers to the request. The only keys in the body are `answers`, `token` and `trap`.',
168
+ '',
169
+ 'The endpoint URL contains the form\'s slug. If the slug changes in Kelpie, the URL changes. If fields change in Kelpie, this field list changes. In both cases, copy a new prompt from Kelpie.',
170
+ ].join('\n')
171
+ }
172
+
173
+ /**
174
+ * What a site's own form must do for a form that requires the spam check.
175
+ * Without it Kelpie holds every submission as spam, and the response does not
176
+ * say so, which is why the prompt says it plainly.
177
+ */
178
+ function spamCheckSection(tokenUrl: string): readonly string[] {
179
+ return [
180
+ '## Spam check',
181
+ '',
182
+ 'This form requires a spam check. If the request does not pass it, Kelpie still answers 201, but it holds the submission as spam and my team does not see it as a lead. Do all three steps.',
183
+ '',
184
+ `1. When the page that shows the form loads, send \`GET ${tokenUrl}\` with no credentials. The response is \`{ "token": "…" }\`. Keep the token. Do not get it at submit time: Kelpie holds a submit that arrives less than a few seconds after its token was issued. A token is good for 24 hours.`,
185
+ '2. Add `"token": "<the token>"` to the request body, beside `answers`.',
186
+ '3. Add one extra text input to the form that people cannot see or reach: move it off screen with CSS (do not use `display: none`), and give it `tabindex="-1"`, `autocomplete="off"` and `aria-hidden="true"` on its wrapper. If it has a value at submit time, add `"trap": "<its value>"` to the request body. A person leaves it empty, so leave the key out.',
187
+ '',
188
+ 'If my Kelpie uses a CAPTCHA provider, my own form cannot pass the check. Tell me to use the Kelpie iframe embed instead.',
189
+ '',
190
+ ]
191
+ }
192
+
193
+ function describeField(
194
+ field: FormField,
195
+ consentPurposes: ReadonlyMap<string, Pick<ConsentPurpose, 'label' | 'statement'>>,
196
+ listNames: ReadonlyMap<string, string>,
197
+ workspaceName: string,
198
+ ): string {
199
+ const label = field.label.trim()
200
+ const heading = label.length > 0 ? `"${label}"` : `no visible label (holds ${formFieldDisplayLabel(field)})`
201
+ const lines = [`- \`${field.id}\`: ${heading}. Type ${field.type}, ${field.required ? 'required' : 'optional'}.`]
202
+
203
+ if (field.placeholder !== null && field.placeholder.trim().length > 0) {
204
+ lines.push(` Placeholder: "${field.placeholder}"`)
205
+ }
206
+
207
+ if (field.type === 'select') {
208
+ lines.push(' Options (key: text shown):')
209
+ lines.push(...field.options.map((option) => ` - \`${option.key}\`: "${option.value}"`))
210
+ }
211
+
212
+ if (field.type === 'notice') {
213
+ lines.push(` Text: "${field.statement ?? ''}"`)
214
+ }
215
+
216
+ if (field.type === 'consent') {
217
+ lines.push(` Statement: "${field.statement ?? field.label}"`)
218
+ lines.push(' Checkboxes (id: text shown):')
219
+ lines.push(
220
+ ...field.consentPurposeIds.map((id) => {
221
+ const purpose = consentPurposes.get(id) ?? { label: id, statement: '' }
222
+ const text = consentCheckboxText(field.consentPurposeLabels[id], purpose, workspaceName)
223
+ return ` - \`${id}\`: "${text}"`
224
+ }),
225
+ )
226
+ }
227
+
228
+ if (field.type === 'list') {
229
+ const statement = (field.statement ?? '').trim()
230
+ if (statement.length > 0) {
231
+ lines.push(` Statement: "${statement}"`)
232
+ }
233
+ lines.push(' Checkboxes (id: text shown):')
234
+ lines.push(
235
+ ...field.listIds.map((id) => ` - \`${id}\`: "${field.listLabels[id] ?? listNames.get(id) ?? id}"`),
236
+ )
237
+ }
238
+
239
+ return lines.join('\n')
240
+ }
241
+
242
+ function exampleAnswer(field: FormField): string {
243
+ switch (field.type) {
244
+ case 'email':
245
+ return 'jane@example.com'
246
+ case 'select':
247
+ return field.options[0]?.key ?? ''
248
+ case 'consent':
249
+ return field.consentPurposeIds.join(',')
250
+ case 'list':
251
+ return field.listIds.join(',')
252
+ case 'textarea':
253
+ return 'A longer answer.'
254
+ default:
255
+ return 'Example'
256
+ }
257
+ }