@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/dist/index.cjs CHANGED
@@ -1248,7 +1248,7 @@ function PickOrAdd({
1248
1248
  onSearch,
1249
1249
  items,
1250
1250
  onPick,
1251
- notice,
1251
+ notice: notice2,
1252
1252
  empty,
1253
1253
  add,
1254
1254
  foot,
@@ -1334,7 +1334,7 @@ function PickOrAdd({
1334
1334
  className: "mb-1 h-8 text-sm"
1335
1335
  }
1336
1336
  ),
1337
- notice,
1337
+ notice2,
1338
1338
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_design_system6.ScrollArea, { className: "max-h-64", children: [
1339
1339
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { role: "listbox", "aria-label": triggerLabel, "aria-multiselectable": multi ? true : void 0, children: [
1340
1340
  items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -5314,6 +5314,88 @@ var init_NewTableStart = __esm({
5314
5314
  }
5315
5315
  });
5316
5316
 
5317
+ // src/bookingMessages.ts
5318
+ function notice(raw) {
5319
+ if (!raw || typeof raw !== "object") return void 0;
5320
+ const r = raw;
5321
+ const out = {};
5322
+ if (typeof r["on"] === "boolean") out.on = r["on"];
5323
+ if (typeof r["subject"] === "string" && r["subject"].trim() !== "") out.subject = r["subject"];
5324
+ if (typeof r["body"] === "string" && r["body"].trim() !== "") out.body = r["body"];
5325
+ return out;
5326
+ }
5327
+ function messagesFromPresentation(presentation) {
5328
+ const raw = presentation && typeof presentation === "object" ? presentation["booking_messages"] : null;
5329
+ if (!raw || typeof raw !== "object") return {};
5330
+ const r = raw;
5331
+ const out = {};
5332
+ for (const k of ["confirmation", "changed", "cancelled"]) {
5333
+ const n = notice(r[k]);
5334
+ if (n) out[k] = n;
5335
+ }
5336
+ const rem = notice(r["reminders"]);
5337
+ const offsets = r["reminders"]?.offsets;
5338
+ if (rem || Array.isArray(offsets)) {
5339
+ out.reminders = {
5340
+ ...rem ?? {},
5341
+ ...Array.isArray(offsets) ? { offsets: offsets.map(Number).filter((n) => Number.isInteger(n) && n > 0) } : {}
5342
+ };
5343
+ }
5344
+ const host = r["host"];
5345
+ if (host && typeof host.on === "boolean") out.host = { on: host.on };
5346
+ return out;
5347
+ }
5348
+ function messagesToPresentation(m) {
5349
+ const out = {};
5350
+ for (const k of ["confirmation", "changed", "cancelled"]) {
5351
+ const n = m[k];
5352
+ if (n && (n.on === false || n.subject?.trim() || n.body?.trim())) {
5353
+ out[k] = {
5354
+ ...n.on === false ? { on: false } : {},
5355
+ ...n.subject?.trim() ? { subject: n.subject.trim() } : {},
5356
+ ...n.body?.trim() ? { body: n.body.trim() } : {}
5357
+ };
5358
+ }
5359
+ }
5360
+ const rem = m.reminders;
5361
+ if (rem) {
5362
+ const offsets = rem.offsets && rem.offsets.length > 0 ? [...new Set(rem.offsets)].sort((a, b) => b - a) : null;
5363
+ const custom = offsets && (offsets.length !== DEFAULT_REMINDER_OFFSETS.length || offsets.some((o, i) => o !== DEFAULT_REMINDER_OFFSETS[i]));
5364
+ if (rem.on === false || custom || rem.subject?.trim() || rem.body?.trim()) {
5365
+ out.reminders = {
5366
+ ...rem.on === false ? { on: false } : {},
5367
+ ...custom && offsets ? { offsets } : {},
5368
+ ...rem.subject?.trim() ? { subject: rem.subject.trim() } : {},
5369
+ ...rem.body?.trim() ? { body: rem.body.trim() } : {}
5370
+ };
5371
+ }
5372
+ }
5373
+ if (m.host?.on === false) out.host = { on: false };
5374
+ return Object.keys(out).length > 0 ? out : null;
5375
+ }
5376
+ var DEFAULT_REMINDER_OFFSETS, REMINDER_CHOICES, BOOKING_TOKENS;
5377
+ var init_bookingMessages = __esm({
5378
+ "src/bookingMessages.ts"() {
5379
+ "use strict";
5380
+ DEFAULT_REMINDER_OFFSETS = [1440, 60];
5381
+ REMINDER_CHOICES = [
5382
+ { minutes: 10080, label: "1 week before" },
5383
+ { minutes: 2880, label: "2 days before" },
5384
+ { minutes: 1440, label: "1 day before" },
5385
+ { minutes: 180, label: "3 hours before" },
5386
+ { minutes: 60, label: "1 hour before" },
5387
+ { minutes: 15, label: "15 minutes before" }
5388
+ ];
5389
+ BOOKING_TOKENS = [
5390
+ "{{booker.name}}",
5391
+ "{{time}}",
5392
+ "{{title}}",
5393
+ "{{calendar.google}}",
5394
+ "{{calendar.outlook}}"
5395
+ ];
5396
+ }
5397
+ });
5398
+
5317
5399
  // src/publicQuestions.ts
5318
5400
  function publiclyAnswerable(field2) {
5319
5401
  return !(field2.type in CANNOT_ASK);
@@ -5441,6 +5523,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
5441
5523
  const [windows, setWindows] = (0, import_react59.useState)(() => draftWindows(null));
5442
5524
  const [asked4, setAsked] = (0, import_react59.useState)([]);
5443
5525
  const [confirmation, setConfirmation] = (0, import_react59.useState)("");
5526
+ const [messages, setMessages] = (0, import_react59.useState)({});
5444
5527
  const [offer, setOffer] = (0, import_react59.useState)(null);
5445
5528
  const [formId, setFormId] = (0, import_react59.useState)(bookingId ?? null);
5446
5529
  const madeRef = (0, import_react59.useRef)(null);
@@ -5472,6 +5555,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
5472
5555
  const questions = Array.isArray(presentation["questions"]) ? presentation["questions"] : [];
5473
5556
  const keys = questions.filter((q) => q.hidden !== true).map((q) => typeof q.field === "string" ? q.field : "").filter((k) => k !== "" && !STORE_ANSWERS_THESE.includes(k));
5474
5557
  if (keys.length > 0) setAsked(keys);
5558
+ setMessages(messagesFromPresentation(presentation));
5475
5559
  const block = presentation["booking"];
5476
5560
  if (block && typeof block === "object" && Array.isArray(block.windows)) {
5477
5561
  setOffer(block);
@@ -5561,7 +5645,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
5561
5645
  presentation: {
5562
5646
  // THE SENTENCE AFTER THE BOOKING. It is the thank-you screen every other
5563
5647
  // public surface in this package uses, so one component renders it.
5564
- thank_you: confirmation.trim() === "" ? null : { title: "You're booked", body: confirmation.trim() }
5648
+ thank_you: confirmation.trim() === "" ? null : { title: "You're booked", body: confirmation.trim() },
5649
+ ...messagesToPresentation(messages) ? { booking_messages: messagesToPresentation(messages) } : {}
5565
5650
  },
5566
5651
  ...formId ? { form_id: formId } : {}
5567
5652
  });
@@ -5753,6 +5838,63 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
5753
5838
  }
5754
5839
  )
5755
5840
  ] }),
5841
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex flex-col gap-2", "data-booking-messages": "", children: [
5842
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_design_system34.Label, { className: "text-xs font-medium", children: "Emails to the person who books" }),
5843
+ [
5844
+ ["confirmation", "Confirmation, with a calendar file"],
5845
+ ["changed", "When they move it"],
5846
+ ["cancelled", "When they cancel"]
5847
+ ].map(([key, label]) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5848
+ MessageRow,
5849
+ {
5850
+ label,
5851
+ value: messages[key],
5852
+ onChange: (n) => setMessages((m) => ({ ...m, [key]: n }))
5853
+ },
5854
+ key
5855
+ )),
5856
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5857
+ MessageRow,
5858
+ {
5859
+ label: "Reminders",
5860
+ value: messages.reminders,
5861
+ onChange: (n) => setMessages((m) => ({ ...m, reminders: { ...m.reminders, ...n } })),
5862
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex flex-wrap gap-x-3 gap-y-1", children: REMINDER_CHOICES.map((c) => {
5863
+ const offsets = messages.reminders?.offsets ?? [...DEFAULT_REMINDER_OFFSETS];
5864
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("label", { className: "flex items-center gap-1.5 text-xs", children: [
5865
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5866
+ import_design_system34.Checkbox,
5867
+ {
5868
+ checked: offsets.includes(c.minutes),
5869
+ onCheckedChange: (on) => setMessages((m) => ({
5870
+ ...m,
5871
+ reminders: {
5872
+ ...m.reminders,
5873
+ offsets: on === true ? [...offsets, c.minutes] : offsets.filter((o) => o !== c.minutes)
5874
+ }
5875
+ }))
5876
+ }
5877
+ ),
5878
+ c.label
5879
+ ] }, c.minutes);
5880
+ }) })
5881
+ }
5882
+ ),
5883
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("label", { className: "flex items-center gap-2 text-xs", children: [
5884
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5885
+ import_design_system34.Checkbox,
5886
+ {
5887
+ checked: messages.host?.on !== false,
5888
+ onCheckedChange: (on) => setMessages((m) => ({ ...m, host: { on: on === true } }))
5889
+ }
5890
+ ),
5891
+ "Tell me when someone books, moves or cancels"
5892
+ ] }),
5893
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "text-xs text-muted-foreground", children: [
5894
+ "Words can use ",
5895
+ BOOKING_TOKENS.join(" ")
5896
+ ] })
5897
+ ] }),
5756
5898
  shown5 ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "rounded-md border bg-muted/40 p-2.5 text-xs", children: [
5757
5899
  "Saved. The page offers ",
5758
5900
  shown5.slot_minutes,
@@ -5802,6 +5944,42 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
5802
5944
  ] })
5803
5945
  );
5804
5946
  }
5947
+ function MessageRow({
5948
+ label,
5949
+ value,
5950
+ onChange,
5951
+ children
5952
+ }) {
5953
+ const on = value?.on !== false;
5954
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex flex-col gap-1.5 rounded-md border p-2", children: [
5955
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("label", { className: "flex items-center gap-2 text-xs font-medium", children: [
5956
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_design_system34.Checkbox, { checked: on, onCheckedChange: (next) => onChange({ ...value, on: next === true }) }),
5957
+ label
5958
+ ] }),
5959
+ on ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
5960
+ children,
5961
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5962
+ import_design_system34.BasicInput,
5963
+ {
5964
+ "aria-label": `${label}: subject`,
5965
+ placeholder: "Subject (blank = the default)",
5966
+ value: value?.subject ?? "",
5967
+ onChange: (e) => onChange({ ...value, subject: e.target.value })
5968
+ }
5969
+ ),
5970
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5971
+ import_design_system34.BasicTextarea,
5972
+ {
5973
+ "aria-label": `${label}: message`,
5974
+ rows: 2,
5975
+ placeholder: "Message (blank = the default)",
5976
+ value: value?.body ?? "",
5977
+ onChange: (e) => onChange({ ...value, body: e.target.value })
5978
+ }
5979
+ )
5980
+ ] }) : null
5981
+ ] });
5982
+ }
5805
5983
  function isWhoField(field2) {
5806
5984
  const kind2 = editorKindFor(field2);
5807
5985
  return kind2 === "email" || kind2 === "phone" || /\bname\b/i.test(fieldName(field2));
@@ -5825,6 +6003,7 @@ var init_BookingBuilder = __esm({
5825
6003
  import_records21 = require("@ai-matrx/records");
5826
6004
  import_design_system34 = require("@ai-matrx/design-system");
5827
6005
  import_controls2 = require("@ai-matrx/design-system/controls");
6006
+ init_bookingMessages();
5828
6007
  init_publicQuestions();
5829
6008
  init_Refusal();
5830
6009
  init_TimeZoneInput();
@@ -9237,17 +9416,50 @@ function NumberBox({
9237
9416
  function unitOf(format) {
9238
9417
  return format.options?.unit ?? "px";
9239
9418
  }
9419
+ function MeasureMini({ px, kind: kind2 }) {
9420
+ if (kind2 === "spacing") {
9421
+ const gap = Math.max(1, Math.min(px, 48));
9422
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { "aria-hidden": true, "data-records-measure-mini": "spacing", className: "inline-flex h-4 shrink-0 items-center", children: [
9423
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "h-4 w-2.5 rounded-sm border border-border bg-muted" }),
9424
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { width: gap } }),
9425
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "h-4 w-2.5 rounded-sm border border-border bg-muted" })
9426
+ ] });
9427
+ }
9428
+ if (kind2 === "radius") {
9429
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9430
+ "span",
9431
+ {
9432
+ "aria-hidden": true,
9433
+ "data-records-measure-mini": "radius",
9434
+ className: "inline-block h-5 w-5 shrink-0 border-2 border-foreground bg-card",
9435
+ style: { borderRadius: Math.min(px, 10) }
9436
+ }
9437
+ );
9438
+ }
9439
+ return null;
9440
+ }
9240
9441
  function MeasureView({ value, format }) {
9241
9442
  const n = numberOf(value);
9242
9443
  if (n === null) return null;
9243
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { "data-records-look": "measure", className: "tabular-nums", children: [
9244
- n,
9245
- " ",
9246
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-muted-foreground", children: unitOf(format) })
9444
+ const px = pixels(n, unitOf(format));
9445
+ const kind2 = format.options?.measurePreview ?? "none";
9446
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { "data-records-look": "measure", className: "inline-flex items-center gap-2 tabular-nums", children: [
9447
+ px !== null && (kind2 === "spacing" || kind2 === "radius") ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MeasureMini, { px, kind: kind2 }) : null,
9448
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
9449
+ n,
9450
+ " ",
9451
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-muted-foreground", children: unitOf(format) })
9452
+ ] })
9247
9453
  ] });
9248
9454
  }
9249
9455
  function MeasureEditor({ value, format, onChange, disabled, id, label }) {
9250
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberBox, { id, label, value: numberOf(value), unit: unitOf(format), disabled, className: "w-full max-w-40", onChange });
9456
+ const n = numberOf(value);
9457
+ const px = n === null ? null : pixels(n, unitOf(format));
9458
+ const kind2 = format.options?.measurePreview ?? "none";
9459
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "flex items-center gap-2", children: [
9460
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberBox, { id, label, value: n, unit: unitOf(format), disabled, className: "w-full max-w-40", onChange }),
9461
+ px !== null && (kind2 === "spacing" || kind2 === "radius") ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MeasureMini, { px, kind: kind2 }) : null
9462
+ ] });
9251
9463
  }
9252
9464
  function pixels(n, unit) {
9253
9465
  if (unit === "px" || unit === "pt") return n;
@@ -13514,26 +13726,26 @@ var import_field_formats6 = require("@ai-matrx/design-system/field-formats");
13514
13726
  init_names();
13515
13727
  var WITHHELD_WORD = "Withheld";
13516
13728
  function withheldNoticeOf(hidden, key) {
13517
- const notice = hidden?.[key];
13518
- return notice && typeof notice === "object" ? notice : null;
13729
+ const notice2 = hidden?.[key];
13730
+ return notice2 && typeof notice2 === "object" ? notice2 : null;
13519
13731
  }
13520
- function withheldSentence(field2, notice) {
13521
- const extra = notice;
13732
+ function withheldSentence(field2, notice2) {
13733
+ const extra = notice2;
13522
13734
  if (typeof extra.says === "string" && extra.says.trim() !== "") return extra.says.trim();
13523
13735
  const name = fieldName(field2);
13524
13736
  if (typeof extra.part === "string" && extra.part.trim() !== "" && typeof extra.who === "string" && extra.who.trim() !== "") {
13525
13737
  return `${name} is in ${extra.part.trim()} \u2014 ${extra.who.trim()} see it.`;
13526
13738
  }
13527
- const reason = notice.reason ? ` It is ${notice.reason}` : "";
13528
- const needs = notice.needs ? `${reason ? "," : " It"} and reading it needs ${notice.needs}` : "";
13529
- const or = notice.or ? `${needs || reason ? ", or" : " It needs"} ${notice.or}` : "";
13739
+ const reason = notice2.reason ? ` It is ${notice2.reason}` : "";
13740
+ const needs = notice2.needs ? `${reason ? "," : " It"} and reading it needs ${notice2.needs}` : "";
13741
+ const or = notice2.or ? `${needs || reason ? ", or" : " It needs"} ${notice2.or}` : "";
13530
13742
  return `${name} is withheld from you.${reason}${needs}${or}${reason || needs || or ? "." : ""}`;
13531
13743
  }
13532
13744
 
13533
13745
  // src/withheld.tsx
13534
13746
  var import_jsx_runtime25 = require("react/jsx-runtime");
13535
- function WithheldValue({ field: field2, notice }) {
13536
- const sentence2 = withheldSentence(field2, notice);
13747
+ function WithheldValue({ field: field2, notice: notice2 }) {
13748
+ const sentence2 = withheldSentence(field2, notice2);
13537
13749
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
13538
13750
  "span",
13539
13751
  {
@@ -13688,7 +13900,7 @@ function EntityReferencePicker({
13688
13900
  options: [{ value: "", label: "Any kind" }, ...allowed.map((token2) => ({ value: token2, label: labelOfKind(token2) }))]
13689
13901
  }
13690
13902
  ) : null;
13691
- const notice = /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
13903
+ const notice2 = /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
13692
13904
  kindChoice,
13693
13905
  found.error ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(RefusalLine, { error: found.error, className: "px-2 py-1 text-[11px]" }) : null,
13694
13906
  found.loading && !found.data ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "px-2 py-1 text-[11px] text-muted-foreground", children: "Searching\u2026" }) : null
@@ -13707,7 +13919,7 @@ function EntityReferencePicker({
13707
13919
  search,
13708
13920
  onSearch: setSearch,
13709
13921
  items,
13710
- notice,
13922
+ notice: notice2,
13711
13923
  empty: found.loading ? null : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "px-2 py-1 text-[11px] text-muted-foreground", children: search.trim() ? `No ${kindWords} you can open is called \u201C${search.trim()}\u201D.` : `There is no ${kindWords} you can open yet.` }),
13712
13924
  onPick: (key) => {
13713
13925
  const r = (found.data ?? []).find((x) => `${x.token}:${x.id}` === key);
@@ -15687,9 +15899,9 @@ function ONE_FIELD_ARRAY_CACHE(field2) {
15687
15899
  function cardWords(record, field2, labels) {
15688
15900
  if (!field2) return { text: rowName(record, null, "Untitled"), withheld: null };
15689
15901
  const value = (record.document ?? {})[field2.key];
15690
- const notice = withheldNoticeOf(record.hidden, field2.key);
15691
- if (notice && (value === null || value === void 0)) {
15692
- return { text: WITHHELD_WORD, withheld: withheldSentence(field2, notice) };
15902
+ const notice2 = withheldNoticeOf(record.hidden, field2.key);
15903
+ if (notice2 && (value === null || value === void 0)) {
15904
+ return { text: WITHHELD_WORD, withheld: withheldSentence(field2, notice2) };
15693
15905
  }
15694
15906
  const empty = value === null || value === void 0 || typeof value === "string" && value.trim() === "";
15695
15907
  return { text: empty ? "Untitled" : scalarText(field2, value, labels), withheld: null };
@@ -17370,6 +17582,25 @@ function FieldEditor(props) {
17370
17582
  const watchStart = (0, import_react83.useMemo)(() => watchedFieldsOf(start), [start]);
17371
17583
  const [watchFields, setWatchFields] = (0, import_react83.useState)(watchStart);
17372
17584
  const [dependency, setDependency] = (0, import_react83.useState)(dependencyStart);
17585
+ const [notifyStart, setNotifyStart] = (0, import_react83.useState)(field2 ? null : false);
17586
+ const [notify, setNotify] = (0, import_react83.useState)(false);
17587
+ const [notifyReadError, setNotifyReadError] = (0, import_react83.useState)(null);
17588
+ const personColumn = !onEntity && type === "member";
17589
+ (0, import_react83.useEffect)(() => {
17590
+ if (!field2 || onEntity || type !== "member") return;
17591
+ let live = true;
17592
+ void client.fieldNotifyOnAssign({ field_id: field2.id, on: null }).then((got) => {
17593
+ if (!live) return;
17594
+ if (got.ok) {
17595
+ setNotifyStart(got.data.notify_on_assign === true);
17596
+ setNotify(got.data.notify_on_assign === true);
17597
+ setNotifyReadError(null);
17598
+ } else setNotifyReadError(got.error);
17599
+ });
17600
+ return () => {
17601
+ live = false;
17602
+ };
17603
+ }, [client, field2, onEntity, type]);
17373
17604
  (0, import_react83.useEffect)(() => {
17374
17605
  if (!field2 || type !== "status") return;
17375
17606
  let live = true;
@@ -17582,7 +17813,16 @@ function FieldEditor(props) {
17582
17813
  return;
17583
17814
  }
17584
17815
  const written2 = await tableMutation.update({ field_id: field2.id, patch });
17585
- if (written2 !== null) onSaved?.();
17816
+ if (written2 === null) return;
17817
+ if (personColumn && notifyStart !== null && notify !== notifyStart) {
17818
+ const told = await client.fieldNotifyOnAssign({ field_id: field2.id, on: notify });
17819
+ if (!told.ok) {
17820
+ setBackfillError(told.error);
17821
+ return;
17822
+ }
17823
+ setNotifyStart(notify);
17824
+ }
17825
+ onSaved?.();
17586
17826
  return;
17587
17827
  }
17588
17828
  const spec = {
@@ -17662,6 +17902,13 @@ function FieldEditor(props) {
17662
17902
  return;
17663
17903
  }
17664
17904
  }
17905
+ if (personColumn && notify) {
17906
+ const told = await client.fieldNotifyOnAssign({ field_id: written, on: true });
17907
+ if (!told.ok) {
17908
+ setBackfillError(told.error);
17909
+ return;
17910
+ }
17911
+ }
17665
17912
  setBackfillError(null);
17666
17913
  if (type === "relation" && relationTarget === tableId && dependency && !onEntity) {
17667
17914
  const marked = await client.fieldUpdate({ field_id: written, patch: { dependency: true } });
@@ -17857,6 +18104,20 @@ function FieldEditor(props) {
17857
18104
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_design_system51.Checkbox, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
17858
18105
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: "Waits on the linked records" })
17859
18106
  ] }) : null,
18107
+ personColumn ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("label", { className: "flex items-center gap-1.5 text-sm", title: "Each person added to this column gets a notice", children: [
18108
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
18109
+ import_design_system51.Checkbox,
18110
+ {
18111
+ checked: notify,
18112
+ disabled: notifyStart === null,
18113
+ "aria-label": "Notify people when they're added",
18114
+ "data-records-notify-on-assign": "",
18115
+ onCheckedChange: (v) => setNotify(v === true)
18116
+ }
18117
+ ),
18118
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: "Notify people when they're added" })
18119
+ ] }) : null,
18120
+ notifyReadError ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(RefusalNotice, { error: notifyReadError }) : null,
17860
18121
  type === "rollup" ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
17861
18122
  RollupFilterQuestion,
17862
18123
  {
@@ -21302,7 +21563,7 @@ function CellRefusalNotice({
21302
21563
  }) {
21303
21564
  const [open, setOpen] = (0, import_react95.useState)(true);
21304
21565
  const line = refusal3.unsent ? UNSENT_LINE : refusalLineForAPerson(refusal3.error);
21305
- const notice = refusal3.unsent ? (
21566
+ const notice2 = refusal3.unsent ? (
21306
21567
  // NOT SENT, NOT REFUSED: what was typed is still in the cell; it goes again once online.
21307
21568
  /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "flex flex-col gap-1.5 px-3 py-2 text-xs", "data-records-cell-unsent": "", children: [
21308
21569
  /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "font-medium", children: UNSENT_LINE }),
@@ -21359,7 +21620,7 @@ function CellRefusalNotice({
21359
21620
  "data-records-cell-refusal": "",
21360
21621
  onOpenAutoFocus: (event) => event.preventDefault(),
21361
21622
  onCloseAutoFocus: (event) => event.preventDefault(),
21362
- children: notice
21623
+ children: notice2
21363
21624
  }
21364
21625
  )
21365
21626
  ] });
@@ -24532,8 +24793,8 @@ function useColumnSummaries(args) {
24532
24793
  for (const [key, op2] of entries) {
24533
24794
  const measure = op2 === "count" ? { op: "count" } : { op: op2, key };
24534
24795
  out[key] = row?.measures?.[(0, import_records41.measureKey)(measure)] ?? null;
24535
- const notice = row?.withheld?.[(0, import_records41.measureKey)(measure)];
24536
- if (notice) why[key] = notice;
24796
+ const notice2 = row?.withheld?.[(0, import_records41.measureKey)(measure)];
24797
+ if (notice2) why[key] = notice2;
24537
24798
  }
24538
24799
  setValues(out);
24539
24800
  setWithheld(why);
@@ -26226,8 +26487,8 @@ function CustomFieldsSection({
26226
26487
  mayAdd: now.rights ? now.rights.may_declare === true : now.loading ? null : false,
26227
26488
  refusal: now.rights && !now.rights.may_declare ? now.rights.reason ?? null : null,
26228
26489
  fields: now.fields.map((f) => {
26229
- const notice = noticeOf(f);
26230
- return notice ? { key: f.key, label: f.label, type: f.type, withheld: withheldSentence(asField(f), notice) } : { key: f.key, label: f.label, type: f.type, value: now.values[f.key] };
26490
+ const notice2 = noticeOf(f);
26491
+ return notice2 ? { key: f.key, label: f.label, type: f.type, withheld: withheldSentence(asField(f), notice2) } : { key: f.key, label: f.label, type: f.type, value: now.values[f.key] };
26231
26492
  }),
26232
26493
  mayFill: now.rights ? now.rights.may_fill_in !== false : now.loading ? null : false,
26233
26494
  types: ADDABLE_TYPES
@@ -29948,8 +30209,8 @@ function useGroupFacts(args) {
29948
30209
  for (const [fieldKey, op2] of entries) {
29949
30210
  const m = op2 === "count" ? { op: "count" } : { op: op2, key: fieldKey };
29950
30211
  values[fieldKey] = row.measures?.[(0, import_records45.measureKey)(m)] ?? null;
29951
- const notice = row.withheld?.[(0, import_records45.measureKey)(m)];
29952
- if (notice) withheld[fieldKey] = notice;
30212
+ const notice2 = row.withheld?.[(0, import_records45.measureKey)(m)];
30213
+ if (notice2) withheld[fieldKey] = notice2;
29953
30214
  }
29954
30215
  out.set(key, { count: typeof row.measures?.["count"] === "number" ? row.measures["count"] : row.row_count ?? null, measures: values, withheld });
29955
30216
  }
@@ -29981,9 +30242,9 @@ function groupWithheldNotice(rows, key, value) {
29981
30242
  if (groupValueKey(value) !== "" || rows.length === 0) return null;
29982
30243
  let first = null;
29983
30244
  for (const row of rows) {
29984
- const notice = withheldNoticeOf(row.hidden, key);
29985
- if (!notice) return null;
29986
- first ??= notice;
30245
+ const notice2 = withheldNoticeOf(row.hidden, key);
30246
+ if (!notice2) return null;
30247
+ first ??= notice2;
29987
30248
  }
29988
30249
  return first;
29989
30250
  }
@@ -30057,7 +30318,7 @@ function useGridUndo(args) {
30057
30318
  const heldRef = (0, import_react160.useRef)(held);
30058
30319
  heldRef.current = held;
30059
30320
  const [busy, setBusy] = (0, import_react160.useState)(false);
30060
- const [notice, setNotice] = (0, import_react160.useState)(null);
30321
+ const [notice2, setNotice] = (0, import_react160.useState)(null);
30061
30322
  const counter = (0, import_react160.useRef)(0);
30062
30323
  const dismiss = (0, import_react160.useCallback)(() => setNotice(null), []);
30063
30324
  const push = (0, import_react160.useCallback)((step2) => {
@@ -30146,12 +30407,12 @@ function useGridUndo(args) {
30146
30407
  canRedo: held.stack.future.length > 0 && !busy,
30147
30408
  depth: { back: held.stack.past.length, forward: held.stack.future.length },
30148
30409
  busy,
30149
- notice,
30410
+ notice: notice2,
30150
30411
  dismiss,
30151
30412
  // `offerUndo`: the line speaks for the LAST step (an edit that moved its row out of the view).
30152
30413
  say: (says, sticky = false, offerUndo = false) => setNotice({ says, refusal: sticky ? { code: "internal", message: says } : null, canUndo: offerUndo })
30153
30414
  }),
30154
- [push, undo, redo, held, busy, notice, dismiss]
30415
+ [push, undo, redo, held, busy, notice2, dismiss]
30155
30416
  );
30156
30417
  }
30157
30418
  function useUndoSource(undo) {
@@ -30227,25 +30488,25 @@ function UndoRedoPair({ face, onUndo, onRedo }) {
30227
30488
  ] });
30228
30489
  }
30229
30490
  function UndoNotice({ undo, placement = "frame" }) {
30230
- const notice = undo.notice;
30491
+ const notice2 = undo.notice;
30231
30492
  const dismiss = undo.dismiss;
30232
30493
  (0, import_react160.useEffect)(() => {
30233
- if (!notice || notice.refusal) return;
30494
+ if (!notice2 || notice2.refusal) return;
30234
30495
  const timer = setTimeout(dismiss, 8e3);
30235
30496
  return () => clearTimeout(timer);
30236
- }, [notice, dismiss]);
30237
- if (!notice) return null;
30497
+ }, [notice2, dismiss]);
30498
+ if (!notice2) return null;
30238
30499
  return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
30239
30500
  "p",
30240
30501
  {
30241
30502
  role: "status",
30242
- "data-records-undo-notice": notice.refusal ? "refused" : "done",
30503
+ "data-records-undo-notice": notice2.refusal ? "refused" : "done",
30243
30504
  "data-records-undo-placement": placement,
30244
30505
  className: `pointer-events-auto ${placement === "viewport" ? "fixed bottom-4 z-50" : "absolute bottom-3 z-30"} left-1/2 flex max-w-[min(36rem,calc(100%-2rem))] -translate-x-1/2 items-center gap-2 rounded-md border border-border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-lg`,
30245
30506
  children: [
30246
- /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { children: notice.says }),
30247
- notice.canUndo && undo.canUndo ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_design_system84.Button, { size: "sm", variant: "outline", className: "ml-auto h-6", "data-records-undo-now": "", onClick: () => void undo.undo(), children: "Undo" }) : null,
30248
- /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_design_system84.Button, { size: "sm", variant: "ghost", className: notice.canUndo && undo.canUndo ? "h-6" : "ml-auto h-6", onClick: undo.dismiss, children: "Dismiss" })
30507
+ /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { children: notice2.says }),
30508
+ notice2.canUndo && undo.canUndo ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_design_system84.Button, { size: "sm", variant: "outline", className: "ml-auto h-6", "data-records-undo-now": "", onClick: () => void undo.undo(), children: "Undo" }) : null,
30509
+ /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_design_system84.Button, { size: "sm", variant: "ghost", className: notice2.canUndo && undo.canUndo ? "h-6" : "ml-auto h-6", onClick: undo.dismiss, children: "Dismiss" })
30249
30510
  ]
30250
30511
  }
30251
30512
  );
@@ -38991,7 +39252,7 @@ function useRecordMoves({
38991
39252
  versions.refresh([id]);
38992
39253
  onMoved?.();
38993
39254
  }, [versions, stale, onMoved]);
38994
- const notice = /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
39255
+ const notice2 = /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
38995
39256
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(UndoNotice, { undo }),
38996
39257
  stale ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
38997
39258
  "p",
@@ -39010,7 +39271,7 @@ function useRecordMoves({
39010
39271
  ) : null
39011
39272
  ] });
39012
39273
  return (0, import_react228.useMemo)(
39013
- () => ({ move, moveMany, create, refused, say: (says, sticky) => undo.say(says, sticky), undo, onKeyDown, notice }),
39274
+ () => ({ move, moveMany, create, refused, say: (says, sticky) => undo.say(says, sticky), undo, onKeyDown, notice: notice2 }),
39014
39275
  // eslint-disable-next-line react-hooks/exhaustive-deps
39015
39276
  [move, moveMany, create, refused, undo, onKeyDown, stale, reloadStale]
39016
39277
  );
@@ -54488,10 +54749,10 @@ function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATE
54488
54749
  return value;
54489
54750
  };
54490
54751
  const withheld = (key, row) => {
54491
- const notice = row.withheld[key];
54492
- if (!notice) return null;
54752
+ const notice2 = row.withheld[key];
54753
+ if (!notice2) return null;
54493
54754
  const f = fields.find((x) => x.key === key.slice(key.indexOf("_") + 1));
54494
- return f ? withheldSentence(f, notice) : notice.says ?? "Withheld";
54755
+ return f ? withheldSentence(f, notice2) : notice2.says ?? "Withheld";
54495
54756
  };
54496
54757
  const notes = /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)("div", { className: "mt-2 flex flex-wrap gap-1 text-muted-foreground", children: [
54497
54758
  answer.asOf ? /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_design_system152.Badge, { variant: "outline", "data-testid": "question-as-of-note", children: [
@@ -57586,8 +57847,8 @@ function PublicViewPage({ slug, className }) {
57586
57847
  const [plan, setPlan] = (0, import_react321.useState)(null);
57587
57848
  const [gap, setGap] = (0, import_react321.useState)(null);
57588
57849
  const load = (0, import_react321.useCallback)(async () => {
57589
- const notice = await client.worldPublishGapNotice();
57590
- if (notice.ok) setGap(notice.data);
57850
+ const notice2 = await client.worldPublishGapNotice();
57851
+ if (notice2.ok) setGap(notice2.data);
57591
57852
  const resolved = await client.resolvePublishBindingKind({ slug });
57592
57853
  if (!resolved.ok) {
57593
57854
  setError(resolved.error);
@@ -61343,6 +61604,17 @@ function sectionColumns(fields, titleField, props) {
61343
61604
  const values = props.valueFields ? props.valueFields.map((k) => live.find((f) => f.key === k)).filter((f) => f !== void 0 && f.key !== readsOn) : live.filter((f) => !taken.has(f.key));
61344
61605
  return { name, group, note, readsOn, values };
61345
61606
  }
61607
+ var NATURAL = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
61608
+ function orderedRows(rows, nameKey) {
61609
+ if (!nameKey) return [...rows];
61610
+ const nameOf3 = (r) => String((r.document ?? {})[nameKey] ?? "");
61611
+ return [...rows].sort((a, b) => {
61612
+ const x = nameOf3(a);
61613
+ const y = nameOf3(b);
61614
+ if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
61615
+ return NATURAL.compare(x, y);
61616
+ });
61617
+ }
61346
61618
  function sectionGroups(rows, groupKey) {
61347
61619
  if (!groupKey) return [{ key: UNGROUPED, rows: [...rows] }];
61348
61620
  const map = /* @__PURE__ */ new Map();
@@ -61641,7 +61913,9 @@ function SectionCard(props) {
61641
61913
  const { tableId, readOnly, noun = "entry", onFix, className } = props;
61642
61914
  const table = (0, import_react349.useTable)(tableId);
61643
61915
  const fieldsRead = (0, import_react349.useFields)(tableId);
61644
- const page = (0, import_react349.useRecordPage)(tableId, { pageSize: 200 });
61916
+ const tableSort = (0, import_first_page3.defaultSortOf)(table.data ?? null, fieldsRead.data ?? []);
61917
+ const page = (0, import_react349.useRecordPage)(tableId, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
61918
+ const sortedByStore = tableSort !== null;
61645
61919
  const mutation = (0, import_react349.useRecordMutation)();
61646
61920
  const [adding, setAdding] = (0, import_react348.useState)(null);
61647
61921
  const [failed, setFailed] = (0, import_react348.useState)(null);
@@ -61652,7 +61926,7 @@ function SectionCard(props) {
61652
61926
  const noteField = cols.note ? fields.find((f) => f.key === cols.note) : void 0;
61653
61927
  const readsOnField = cols.readsOn ? fields.find((f) => f.key === cols.readsOn) : void 0;
61654
61928
  const columns = columnsOf(cols.values);
61655
- const rows = page.data?.rows ?? [];
61929
+ const rows = sortedByStore ? page.data?.rows ?? [] : orderedRows(page.data?.rows ?? [], cols.name);
61656
61930
  const groups = sectionGroups(rows, cols.group);
61657
61931
  const level = rows[0]?.level ?? null;
61658
61932
  const mayWrite = !readOnly && (rows.length === 0 ? !readOnly : (0, import_field_kinds9.atLeast)(level, "edit_content"));