@ai-matrx/records-ui 0.107.0 → 0.107.1
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +66 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +66 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -4677,6 +4677,13 @@ interface FormNotify {
|
|
|
4677
4677
|
webhookUrl?: string | null;
|
|
4678
4678
|
/** The `custom.automation_declare` row that posts to `webhookUrl` (trigger form_answered). */
|
|
4679
4679
|
webhookAutomationId?: Uuid | null;
|
|
4680
|
+
/**
|
|
4681
|
+
* EMAIL THE RESPONDENT (TYPEFORM-2), off unless set: one email to the address the person typed
|
|
4682
|
+
* in `respondentField` (an email question), worded from the ending reached — sent by
|
|
4683
|
+
* `custom.form_respondent_copy` through the platform's notification sender.
|
|
4684
|
+
*/
|
|
4685
|
+
emailRespondent?: boolean | null;
|
|
4686
|
+
respondentField?: string | null;
|
|
4680
4687
|
}
|
|
4681
4688
|
/**
|
|
4682
4689
|
* A form as `custom.forms` reports it — the spec a screen renders, plus the
|
package/dist/index.d.ts
CHANGED
|
@@ -4677,6 +4677,13 @@ interface FormNotify {
|
|
|
4677
4677
|
webhookUrl?: string | null;
|
|
4678
4678
|
/** The `custom.automation_declare` row that posts to `webhookUrl` (trigger form_answered). */
|
|
4679
4679
|
webhookAutomationId?: Uuid | null;
|
|
4680
|
+
/**
|
|
4681
|
+
* EMAIL THE RESPONDENT (TYPEFORM-2), off unless set: one email to the address the person typed
|
|
4682
|
+
* in `respondentField` (an email question), worded from the ending reached — sent by
|
|
4683
|
+
* `custom.form_respondent_copy` through the platform's notification sender.
|
|
4684
|
+
*/
|
|
4685
|
+
emailRespondent?: boolean | null;
|
|
4686
|
+
respondentField?: string | null;
|
|
4680
4687
|
}
|
|
4681
4688
|
/**
|
|
4682
4689
|
* A form as `custom.forms` reports it — the spec a screen renders, plus the
|
package/dist/index.js
CHANGED
|
@@ -37759,14 +37759,26 @@ function formPresentation(spec) {
|
|
|
37759
37759
|
theme: themeDocument(spec.theme ?? null),
|
|
37760
37760
|
...typeof spec.showOwnerHeader === "boolean" ? { show_owner_header: spec.showOwnerHeader } : {},
|
|
37761
37761
|
...typeof spec.autoAdvance === "boolean" ? { auto_advance: spec.autoAdvance } : {},
|
|
37762
|
-
...spec.notify && (spec.notify.webhookUrl || spec.notify.webhookAutomationId
|
|
37762
|
+
...spec.notify && (spec.notify.webhookUrl || spec.notify.webhookAutomationId || spec.notify.emailRespondent) ? {
|
|
37763
|
+
notify: strip({
|
|
37764
|
+
webhook_url: text(spec.notify.webhookUrl),
|
|
37765
|
+
webhook_automation_id: text(spec.notify.webhookAutomationId),
|
|
37766
|
+
email_respondent: spec.notify.emailRespondent ? true : null,
|
|
37767
|
+
respondent_field: spec.notify.emailRespondent ? text(spec.notify.respondentField) : null
|
|
37768
|
+
})
|
|
37769
|
+
} : {}
|
|
37763
37770
|
};
|
|
37764
37771
|
}
|
|
37765
37772
|
function notifyFromDocument(raw) {
|
|
37766
37773
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
37767
37774
|
const d = raw;
|
|
37768
|
-
const n = {
|
|
37769
|
-
|
|
37775
|
+
const n = {
|
|
37776
|
+
webhookUrl: text(d["webhook_url"]),
|
|
37777
|
+
webhookAutomationId: text(d["webhook_automation_id"]),
|
|
37778
|
+
emailRespondent: d["email_respondent"] === true ? true : null,
|
|
37779
|
+
respondentField: text(d["respondent_field"])
|
|
37780
|
+
};
|
|
37781
|
+
return n.webhookUrl || n.webhookAutomationId || n.emailRespondent ? n : null;
|
|
37770
37782
|
}
|
|
37771
37783
|
var bool = (v) => typeof v === "boolean" ? v : null;
|
|
37772
37784
|
function answerRefusal(kind, required, value) {
|
|
@@ -42390,6 +42402,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
|
|
|
42390
42402
|
const [shownUrl, setShownUrl] = useState110(null);
|
|
42391
42403
|
const [lookOptions, setLookOptions] = useState110(null);
|
|
42392
42404
|
const [lookUnread, setLookUnread] = useState110(null);
|
|
42405
|
+
const [orgKnobs, setOrgKnobs] = useState110(null);
|
|
42393
42406
|
const [restoredAt, setRestoredAt] = useState110(null);
|
|
42394
42407
|
const [showResults, setShowResults] = useState110(false);
|
|
42395
42408
|
const [adding, setAdding] = useState110(false);
|
|
@@ -42426,6 +42439,15 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
|
|
|
42426
42439
|
useEffect96(() => {
|
|
42427
42440
|
void load();
|
|
42428
42441
|
}, [load]);
|
|
42442
|
+
useEffect96(() => {
|
|
42443
|
+
let cancelled = false;
|
|
42444
|
+
Promise.resolve().then(() => client.formKnobs()).then((r) => {
|
|
42445
|
+
if (!cancelled && r.ok) setOrgKnobs(r.data);
|
|
42446
|
+
}).catch(() => void 0);
|
|
42447
|
+
return () => {
|
|
42448
|
+
cancelled = true;
|
|
42449
|
+
};
|
|
42450
|
+
}, [client]);
|
|
42429
42451
|
useEffect96(() => {
|
|
42430
42452
|
if (!forms || forms.length === 0) return;
|
|
42431
42453
|
if (createOnMount && makeOnMount !== "made") return;
|
|
@@ -42726,6 +42748,11 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
|
|
|
42726
42748
|
formName: draft.name,
|
|
42727
42749
|
ruleId: draft.notifyRuleId,
|
|
42728
42750
|
notify: draft.notify ?? null,
|
|
42751
|
+
emailQuestion: (
|
|
42752
|
+
// An email field first; else a question whose field is named for an email (an imported
|
|
42753
|
+
// "Contact email" kept as text). The store's resolver refuses an answer that is not one.
|
|
42754
|
+
(draft.questions.map((q) => byKey.get(q.field)).find((f) => f && String(editorKindFor(f)) === "email") ?? draft.questions.map((q) => byKey.get(q.field)).find((f) => f && /e-?mail/i.test(`${f.key} ${f.label ?? ""}`)))?.key ?? null
|
|
42755
|
+
),
|
|
42729
42756
|
onRule: (ruleId) => void chooseNotify(ruleId),
|
|
42730
42757
|
onNotify: (notify) => void chooseWebhook(notify)
|
|
42731
42758
|
}
|
|
@@ -42735,7 +42762,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
|
|
|
42735
42762
|
/* @__PURE__ */ jsx133(
|
|
42736
42763
|
Checkbox15,
|
|
42737
42764
|
{
|
|
42738
|
-
checked: draft.showOwnerHeader ?? true,
|
|
42765
|
+
checked: draft.showOwnerHeader ?? orgKnobs?.show_owner_header ?? true,
|
|
42739
42766
|
onCheckedChange: (checked) => patch({ showOwnerHeader: checked === true }),
|
|
42740
42767
|
"aria-label": "Show our logo and name"
|
|
42741
42768
|
}
|
|
@@ -42746,7 +42773,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
|
|
|
42746
42773
|
/* @__PURE__ */ jsx133(
|
|
42747
42774
|
Checkbox15,
|
|
42748
42775
|
{
|
|
42749
|
-
checked: draft.autoAdvance ?? true,
|
|
42776
|
+
checked: draft.autoAdvance ?? orgKnobs?.choice_auto_advance ?? true,
|
|
42750
42777
|
onCheckedChange: (checked) => patch({ autoAdvance: checked === true }),
|
|
42751
42778
|
"aria-label": "Next after a choice"
|
|
42752
42779
|
}
|
|
@@ -42915,7 +42942,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
|
|
|
42915
42942
|
{
|
|
42916
42943
|
className: "w-full shrink-0 overflow-auto rounded border p-2 @3xl:sticky @3xl:top-2 @3xl:max-h-[calc(100dvh-6rem)] @3xl:w-[min(45%,520px)]",
|
|
42917
42944
|
"data-records-form-preview": "",
|
|
42918
|
-
children: showResults && stored ? /* @__PURE__ */ jsx133(FormResultsPanel, { form: stored }) : /* @__PURE__ */ jsx133(FormLookFrame, { look: lookOptions?.look ?? null, title: draft.name, contained: true, showOwnerHeader: draft.showOwnerHeader ?? true, children: /* @__PURE__ */ jsx133(FormRunner, { form: draft, preview: true }) })
|
|
42945
|
+
children: showResults && stored ? /* @__PURE__ */ jsx133(FormResultsPanel, { form: stored }) : /* @__PURE__ */ jsx133(FormLookFrame, { look: lookOptions?.look ?? null, title: draft.name, contained: true, showOwnerHeader: draft.showOwnerHeader ?? orgKnobs?.show_owner_header ?? true, children: /* @__PURE__ */ jsx133(FormRunner, { form: draft, preview: true, autoAdvance: draft.autoAdvance ?? orgKnobs?.choice_auto_advance ?? true }) })
|
|
42919
42946
|
}
|
|
42920
42947
|
)
|
|
42921
42948
|
) : null
|
|
@@ -43168,6 +43195,7 @@ function NotifyOnAnswer({
|
|
|
43168
43195
|
formName,
|
|
43169
43196
|
ruleId,
|
|
43170
43197
|
notify,
|
|
43198
|
+
emailQuestion,
|
|
43171
43199
|
onRule,
|
|
43172
43200
|
onNotify
|
|
43173
43201
|
}) {
|
|
@@ -43233,7 +43261,7 @@ function NotifyOnAnswer({
|
|
|
43233
43261
|
try {
|
|
43234
43262
|
if (next === "") {
|
|
43235
43263
|
if (notify?.webhookAutomationId) await client.automationArchive({ automation_id: notify.webhookAutomationId });
|
|
43236
|
-
onNotify(null);
|
|
43264
|
+
onNotify(notify?.emailRespondent ? { ...notify, webhookUrl: null, webhookAutomationId: null } : null);
|
|
43237
43265
|
return;
|
|
43238
43266
|
}
|
|
43239
43267
|
const declared2 = await client.automationDeclare({
|
|
@@ -43246,22 +43274,43 @@ function NotifyOnAnswer({
|
|
|
43246
43274
|
setSaid(Object.values(declared2.data._errors)[0] ?? "Not saved");
|
|
43247
43275
|
return;
|
|
43248
43276
|
}
|
|
43249
|
-
onNotify({ webhookUrl: next, webhookAutomationId: declared2.data.automation_id });
|
|
43277
|
+
onNotify({ ...notify ?? {}, webhookUrl: next, webhookAutomationId: declared2.data.automation_id });
|
|
43250
43278
|
} finally {
|
|
43251
43279
|
setBusy(false);
|
|
43252
43280
|
}
|
|
43253
43281
|
}
|
|
43254
43282
|
return /* @__PURE__ */ jsxs123("section", { className: "flex flex-col gap-2 rounded border px-2.5 py-2 text-xs", "aria-label": "Notify on answer", "data-records-form-notify": "", children: [
|
|
43255
43283
|
/* @__PURE__ */ jsx133("span", { className: "font-medium", children: "Notify on answer" }),
|
|
43256
|
-
/* @__PURE__ */
|
|
43257
|
-
/* @__PURE__ */
|
|
43258
|
-
|
|
43259
|
-
|
|
43260
|
-
"(",
|
|
43261
|
-
|
|
43262
|
-
|
|
43263
|
-
|
|
43264
|
-
|
|
43284
|
+
/* @__PURE__ */ jsxs123("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1", children: [
|
|
43285
|
+
/* @__PURE__ */ jsxs123("label", { className: "flex items-center gap-2", title: "An email to you each time somebody answers.", children: [
|
|
43286
|
+
/* @__PURE__ */ jsx133(Checkbox15, { checked: Boolean(ruleId), disabled: busy, onCheckedChange: (c) => void emailMe(c === true), "aria-label": "Email me" }),
|
|
43287
|
+
"Email me",
|
|
43288
|
+
chosen && chosen.channel !== "email" ? /* @__PURE__ */ jsxs123("span", { className: "text-muted-foreground", children: [
|
|
43289
|
+
"(",
|
|
43290
|
+
chosen.channel === "sms" ? "text" : "in app",
|
|
43291
|
+
")"
|
|
43292
|
+
] }) : null
|
|
43293
|
+
] }),
|
|
43294
|
+
/* @__PURE__ */ jsxs123(
|
|
43295
|
+
"label",
|
|
43296
|
+
{
|
|
43297
|
+
className: cn78("flex items-center gap-2", !emailQuestion && "text-muted-foreground"),
|
|
43298
|
+
title: emailQuestion ? "An email to the person who answered, in your ending's words." : "Add an email question first.",
|
|
43299
|
+
children: [
|
|
43300
|
+
/* @__PURE__ */ jsx133(
|
|
43301
|
+
Checkbox15,
|
|
43302
|
+
{
|
|
43303
|
+
checked: Boolean(notify?.emailRespondent) && Boolean(emailQuestion),
|
|
43304
|
+
disabled: busy || !emailQuestion,
|
|
43305
|
+
onCheckedChange: (c) => onNotify({ ...notify ?? {}, emailRespondent: c === true ? true : null, respondentField: c === true ? emailQuestion : null }),
|
|
43306
|
+
"aria-label": "Email the respondent"
|
|
43307
|
+
}
|
|
43308
|
+
),
|
|
43309
|
+
"Email the respondent"
|
|
43310
|
+
]
|
|
43311
|
+
}
|
|
43312
|
+
)
|
|
43313
|
+
] }),
|
|
43265
43314
|
/* @__PURE__ */ jsxs123("label", { className: "flex items-center gap-2", children: [
|
|
43266
43315
|
/* @__PURE__ */ jsx133("span", { className: "shrink-0", children: "Webhook" }),
|
|
43267
43316
|
/* @__PURE__ */ jsx133(
|