@ai-matrx/records-ui 0.116.16 → 0.116.17
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 +22 -1
- package/dist/{SaveToTable-54FVMGKL.js → SaveToTable-62C57VOL.js} +2 -2
- package/dist/{chunk-QVTYE4XU.js → chunk-4GZVOFJJ.js} +90 -8
- package/dist/chunk-4GZVOFJJ.js.map +1 -0
- package/dist/{chunk-YIGEIVU7.js → chunk-U3ZEY6BB.js} +174 -2
- package/dist/chunk-U3ZEY6BB.js.map +1 -0
- package/dist/index.cjs +328 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +88 -6
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-QVTYE4XU.js.map +0 -1
- package/dist/chunk-YIGEIVU7.js.map +0 -1
- /package/dist/{SaveToTable-54FVMGKL.js.map → SaveToTable-62C57VOL.js.map} +0 -0
|
@@ -2838,6 +2838,82 @@ import {
|
|
|
2838
2838
|
import { BasicInput as BasicInput3, BasicTextarea, Button as Button3, Checkbox, Label as Label3, Skeleton, cn as cn3 } from "@ai-matrx/design-system";
|
|
2839
2839
|
import { Select as Select3 } from "@ai-matrx/design-system/controls";
|
|
2840
2840
|
|
|
2841
|
+
// src/bookingMessages.ts
|
|
2842
|
+
var DEFAULT_REMINDER_OFFSETS = [1440, 60];
|
|
2843
|
+
var REMINDER_CHOICES = [
|
|
2844
|
+
{ minutes: 10080, label: "1 week before" },
|
|
2845
|
+
{ minutes: 2880, label: "2 days before" },
|
|
2846
|
+
{ minutes: 1440, label: "1 day before" },
|
|
2847
|
+
{ minutes: 180, label: "3 hours before" },
|
|
2848
|
+
{ minutes: 60, label: "1 hour before" },
|
|
2849
|
+
{ minutes: 15, label: "15 minutes before" }
|
|
2850
|
+
];
|
|
2851
|
+
var BOOKING_TOKENS = [
|
|
2852
|
+
"{{booker.name}}",
|
|
2853
|
+
"{{time}}",
|
|
2854
|
+
"{{title}}",
|
|
2855
|
+
"{{calendar.google}}",
|
|
2856
|
+
"{{calendar.outlook}}"
|
|
2857
|
+
];
|
|
2858
|
+
function notice(raw) {
|
|
2859
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
2860
|
+
const r = raw;
|
|
2861
|
+
const out = {};
|
|
2862
|
+
if (typeof r["on"] === "boolean") out.on = r["on"];
|
|
2863
|
+
if (typeof r["subject"] === "string" && r["subject"].trim() !== "") out.subject = r["subject"];
|
|
2864
|
+
if (typeof r["body"] === "string" && r["body"].trim() !== "") out.body = r["body"];
|
|
2865
|
+
return out;
|
|
2866
|
+
}
|
|
2867
|
+
function messagesFromPresentation(presentation) {
|
|
2868
|
+
const raw = presentation && typeof presentation === "object" ? presentation["booking_messages"] : null;
|
|
2869
|
+
if (!raw || typeof raw !== "object") return {};
|
|
2870
|
+
const r = raw;
|
|
2871
|
+
const out = {};
|
|
2872
|
+
for (const k of ["confirmation", "changed", "cancelled"]) {
|
|
2873
|
+
const n = notice(r[k]);
|
|
2874
|
+
if (n) out[k] = n;
|
|
2875
|
+
}
|
|
2876
|
+
const rem = notice(r["reminders"]);
|
|
2877
|
+
const offsets = r["reminders"]?.offsets;
|
|
2878
|
+
if (rem || Array.isArray(offsets)) {
|
|
2879
|
+
out.reminders = {
|
|
2880
|
+
...rem ?? {},
|
|
2881
|
+
...Array.isArray(offsets) ? { offsets: offsets.map(Number).filter((n) => Number.isInteger(n) && n > 0) } : {}
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
const host = r["host"];
|
|
2885
|
+
if (host && typeof host.on === "boolean") out.host = { on: host.on };
|
|
2886
|
+
return out;
|
|
2887
|
+
}
|
|
2888
|
+
function messagesToPresentation(m) {
|
|
2889
|
+
const out = {};
|
|
2890
|
+
for (const k of ["confirmation", "changed", "cancelled"]) {
|
|
2891
|
+
const n = m[k];
|
|
2892
|
+
if (n && (n.on === false || n.subject?.trim() || n.body?.trim())) {
|
|
2893
|
+
out[k] = {
|
|
2894
|
+
...n.on === false ? { on: false } : {},
|
|
2895
|
+
...n.subject?.trim() ? { subject: n.subject.trim() } : {},
|
|
2896
|
+
...n.body?.trim() ? { body: n.body.trim() } : {}
|
|
2897
|
+
};
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
const rem = m.reminders;
|
|
2901
|
+
if (rem) {
|
|
2902
|
+
const offsets = rem.offsets && rem.offsets.length > 0 ? [...new Set(rem.offsets)].sort((a, b) => b - a) : null;
|
|
2903
|
+
const custom = offsets && (offsets.length !== DEFAULT_REMINDER_OFFSETS.length || offsets.some((o, i) => o !== DEFAULT_REMINDER_OFFSETS[i]));
|
|
2904
|
+
if (rem.on === false || custom || rem.subject?.trim() || rem.body?.trim()) {
|
|
2905
|
+
out.reminders = {
|
|
2906
|
+
...rem.on === false ? { on: false } : {},
|
|
2907
|
+
...custom && offsets ? { offsets } : {},
|
|
2908
|
+
...rem.subject?.trim() ? { subject: rem.subject.trim() } : {},
|
|
2909
|
+
...rem.body?.trim() ? { body: rem.body.trim() } : {}
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
if (m.host?.on === false) out.host = { on: false };
|
|
2914
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2841
2917
|
// src/publicQuestions.ts
|
|
2842
2918
|
var CANNOT_ASK = {
|
|
2843
2919
|
relation: "points at a record in another table, and somebody with no account cannot see that table to pick from it",
|
|
@@ -2965,6 +3041,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
|
|
|
2965
3041
|
const [windows, setWindows] = useState3(() => draftWindows(null));
|
|
2966
3042
|
const [asked, setAsked] = useState3([]);
|
|
2967
3043
|
const [confirmation, setConfirmation] = useState3("");
|
|
3044
|
+
const [messages, setMessages] = useState3({});
|
|
2968
3045
|
const [offer, setOffer] = useState3(null);
|
|
2969
3046
|
const [formId, setFormId] = useState3(bookingId ?? null);
|
|
2970
3047
|
const madeRef = useRef2(null);
|
|
@@ -2996,6 +3073,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
|
|
|
2996
3073
|
const questions = Array.isArray(presentation["questions"]) ? presentation["questions"] : [];
|
|
2997
3074
|
const keys = questions.filter((q) => q.hidden !== true).map((q) => typeof q.field === "string" ? q.field : "").filter((k) => k !== "" && !STORE_ANSWERS_THESE.includes(k));
|
|
2998
3075
|
if (keys.length > 0) setAsked(keys);
|
|
3076
|
+
setMessages(messagesFromPresentation(presentation));
|
|
2999
3077
|
const block = presentation["booking"];
|
|
3000
3078
|
if (block && typeof block === "object" && Array.isArray(block.windows)) {
|
|
3001
3079
|
setOffer(block);
|
|
@@ -3085,7 +3163,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
|
|
|
3085
3163
|
presentation: {
|
|
3086
3164
|
// THE SENTENCE AFTER THE BOOKING. It is the thank-you screen every other
|
|
3087
3165
|
// public surface in this package uses, so one component renders it.
|
|
3088
|
-
thank_you: confirmation.trim() === "" ? null : { title: "You're booked", body: confirmation.trim() }
|
|
3166
|
+
thank_you: confirmation.trim() === "" ? null : { title: "You're booked", body: confirmation.trim() },
|
|
3167
|
+
...messagesToPresentation(messages) ? { booking_messages: messagesToPresentation(messages) } : {}
|
|
3089
3168
|
},
|
|
3090
3169
|
...formId ? { form_id: formId } : {}
|
|
3091
3170
|
});
|
|
@@ -3277,6 +3356,63 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
|
|
|
3277
3356
|
}
|
|
3278
3357
|
)
|
|
3279
3358
|
] }),
|
|
3359
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-2", "data-booking-messages": "", children: [
|
|
3360
|
+
/* @__PURE__ */ jsx4(Label3, { className: "text-xs font-medium", children: "Emails to the person who books" }),
|
|
3361
|
+
[
|
|
3362
|
+
["confirmation", "Confirmation, with a calendar file"],
|
|
3363
|
+
["changed", "When they move it"],
|
|
3364
|
+
["cancelled", "When they cancel"]
|
|
3365
|
+
].map(([key, label]) => /* @__PURE__ */ jsx4(
|
|
3366
|
+
MessageRow,
|
|
3367
|
+
{
|
|
3368
|
+
label,
|
|
3369
|
+
value: messages[key],
|
|
3370
|
+
onChange: (n) => setMessages((m) => ({ ...m, [key]: n }))
|
|
3371
|
+
},
|
|
3372
|
+
key
|
|
3373
|
+
)),
|
|
3374
|
+
/* @__PURE__ */ jsx4(
|
|
3375
|
+
MessageRow,
|
|
3376
|
+
{
|
|
3377
|
+
label: "Reminders",
|
|
3378
|
+
value: messages.reminders,
|
|
3379
|
+
onChange: (n) => setMessages((m) => ({ ...m, reminders: { ...m.reminders, ...n } })),
|
|
3380
|
+
children: /* @__PURE__ */ jsx4("div", { className: "flex flex-wrap gap-x-3 gap-y-1", children: REMINDER_CHOICES.map((c) => {
|
|
3381
|
+
const offsets = messages.reminders?.offsets ?? [...DEFAULT_REMINDER_OFFSETS];
|
|
3382
|
+
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-1.5 text-xs", children: [
|
|
3383
|
+
/* @__PURE__ */ jsx4(
|
|
3384
|
+
Checkbox,
|
|
3385
|
+
{
|
|
3386
|
+
checked: offsets.includes(c.minutes),
|
|
3387
|
+
onCheckedChange: (on) => setMessages((m) => ({
|
|
3388
|
+
...m,
|
|
3389
|
+
reminders: {
|
|
3390
|
+
...m.reminders,
|
|
3391
|
+
offsets: on === true ? [...offsets, c.minutes] : offsets.filter((o) => o !== c.minutes)
|
|
3392
|
+
}
|
|
3393
|
+
}))
|
|
3394
|
+
}
|
|
3395
|
+
),
|
|
3396
|
+
c.label
|
|
3397
|
+
] }, c.minutes);
|
|
3398
|
+
}) })
|
|
3399
|
+
}
|
|
3400
|
+
),
|
|
3401
|
+
/* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2 text-xs", children: [
|
|
3402
|
+
/* @__PURE__ */ jsx4(
|
|
3403
|
+
Checkbox,
|
|
3404
|
+
{
|
|
3405
|
+
checked: messages.host?.on !== false,
|
|
3406
|
+
onCheckedChange: (on) => setMessages((m) => ({ ...m, host: { on: on === true } }))
|
|
3407
|
+
}
|
|
3408
|
+
),
|
|
3409
|
+
"Tell me when someone books, moves or cancels"
|
|
3410
|
+
] }),
|
|
3411
|
+
/* @__PURE__ */ jsxs4("p", { className: "text-xs text-muted-foreground", children: [
|
|
3412
|
+
"Words can use ",
|
|
3413
|
+
BOOKING_TOKENS.join(" ")
|
|
3414
|
+
] })
|
|
3415
|
+
] }),
|
|
3280
3416
|
shown ? /* @__PURE__ */ jsxs4("p", { className: "rounded-md border bg-muted/40 p-2.5 text-xs", children: [
|
|
3281
3417
|
"Saved. The page offers ",
|
|
3282
3418
|
shown.slot_minutes,
|
|
@@ -3326,6 +3462,42 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
|
|
|
3326
3462
|
] })
|
|
3327
3463
|
);
|
|
3328
3464
|
}
|
|
3465
|
+
function MessageRow({
|
|
3466
|
+
label,
|
|
3467
|
+
value,
|
|
3468
|
+
onChange,
|
|
3469
|
+
children
|
|
3470
|
+
}) {
|
|
3471
|
+
const on = value?.on !== false;
|
|
3472
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1.5 rounded-md border p-2", children: [
|
|
3473
|
+
/* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2 text-xs font-medium", children: [
|
|
3474
|
+
/* @__PURE__ */ jsx4(Checkbox, { checked: on, onCheckedChange: (next) => onChange({ ...value, on: next === true }) }),
|
|
3475
|
+
label
|
|
3476
|
+
] }),
|
|
3477
|
+
on ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
3478
|
+
children,
|
|
3479
|
+
/* @__PURE__ */ jsx4(
|
|
3480
|
+
BasicInput3,
|
|
3481
|
+
{
|
|
3482
|
+
"aria-label": `${label}: subject`,
|
|
3483
|
+
placeholder: "Subject (blank = the default)",
|
|
3484
|
+
value: value?.subject ?? "",
|
|
3485
|
+
onChange: (e) => onChange({ ...value, subject: e.target.value })
|
|
3486
|
+
}
|
|
3487
|
+
),
|
|
3488
|
+
/* @__PURE__ */ jsx4(
|
|
3489
|
+
BasicTextarea,
|
|
3490
|
+
{
|
|
3491
|
+
"aria-label": `${label}: message`,
|
|
3492
|
+
rows: 2,
|
|
3493
|
+
placeholder: "Message (blank = the default)",
|
|
3494
|
+
value: value?.body ?? "",
|
|
3495
|
+
onChange: (e) => onChange({ ...value, body: e.target.value })
|
|
3496
|
+
}
|
|
3497
|
+
)
|
|
3498
|
+
] }) : null
|
|
3499
|
+
] });
|
|
3500
|
+
}
|
|
3329
3501
|
function isWhoField(field) {
|
|
3330
3502
|
const kind = editorKindFor(field);
|
|
3331
3503
|
return kind === "email" || kind === "phone" || /\bname\b/i.test(fieldName(field));
|
|
@@ -4868,4 +5040,4 @@ export {
|
|
|
4868
5040
|
shapesOfSource,
|
|
4869
5041
|
SaveToTable
|
|
4870
5042
|
};
|
|
4871
|
-
//# sourceMappingURL=chunk-
|
|
5043
|
+
//# sourceMappingURL=chunk-U3ZEY6BB.js.map
|