@ai-matrx/records-ui 0.115.32 → 0.115.33

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.js CHANGED
@@ -30909,6 +30909,7 @@ function RecordFieldsInPlace({
30909
30909
  import { useState as useState87 } from "react";
30910
30910
  import { chooseAlternate } from "@ai-matrx/records";
30911
30911
  import { useRecordsClient as useRecordsClient61 } from "@ai-matrx/records/react";
30912
+ import { humanizeIdentifier as humanizeIdentifier12 } from "@ai-matrx/kit/text-case";
30912
30913
  import { Button as Button66, Popover as Popover12, PopoverContent as PopoverContent12, PopoverTrigger as PopoverTrigger12, Skeleton as Skeleton13 } from "@ai-matrx/design-system";
30913
30914
  import { jsx as jsx108, jsxs as jsxs97 } from "react/jsx-runtime";
30914
30915
  function sourceWords(document2, pointer) {
@@ -30918,6 +30919,14 @@ function sourceWords(document2, pointer) {
30918
30919
  const said2 = Object.values(source).map(String).join(" \xB7 ");
30919
30920
  return said2 === "" ? null : said2;
30920
30921
  }
30922
+ function sourceObjectWords(source) {
30923
+ if (!source) return null;
30924
+ const named = source["name"] ?? source["label"] ?? source["title"];
30925
+ if (typeof named === "string" && named !== "") return named;
30926
+ const kind = source["kind"];
30927
+ if (kind === "record") return "Merged record";
30928
+ return typeof kind === "string" && kind !== "" ? humanizeIdentifier12(kind) : null;
30929
+ }
30921
30930
  function shown3(field2, value) {
30922
30931
  return value === null || value === void 0 || value === "" ? "nothing" : scalarText(field2, value);
30923
30932
  }
@@ -30930,12 +30939,14 @@ function ValueAlternates({
30930
30939
  }) {
30931
30940
  const client = useRecordsClient61();
30932
30941
  const envelope = envelopeFor(document2, field2.key);
30933
- const held = envelope?.alternates ?? [];
30942
+ const offered = document2?.["_alternates"];
30943
+ const held = envelope?.alternates ?? offered?.[field2.key] ?? [];
30934
30944
  const [read, setRead] = useState87(null);
30935
30945
  const [asked3, setAsked] = useState87(false);
30936
30946
  const [refusal3, setRefusal] = useState87(null);
30937
30947
  const [busy, setBusy] = useState87(null);
30938
30948
  const [open, setOpen] = useState87(false);
30949
+ const shownList = read?.alternates && read.alternates.length > 0 ? read.alternates : held;
30939
30950
  if (held.length === 0) return null;
30940
30951
  async function opened(next) {
30941
30952
  setOpen(next);
@@ -30950,7 +30961,7 @@ function ValueAlternates({
30950
30961
  async function use(index) {
30951
30962
  setBusy(index);
30952
30963
  setRefusal(null);
30953
- const written = await chooseAlternate(client, { record_id: recordId, field_key: field2.key, alternate_index: index });
30964
+ const written = await chooseAlternate(client, { record_id: recordId, field_key: field2.key, alternate_index: index, ...shownList[index]?.rank !== void 0 ? { rank: shownList[index].rank } : {} });
30954
30965
  setBusy(null);
30955
30966
  if (!written.ok) return setRefusal(written.error);
30956
30967
  setOpen(false);
@@ -30958,7 +30969,7 @@ function ValueAlternates({
30958
30969
  onChosen();
30959
30970
  }
30960
30971
  const actor = read?.actor;
30961
- const currentFrom = sourceWords(document2, envelope?.src) ?? (read?.source ? Object.values(read.source).map(String).join(" \xB7 ") : null) ?? (typeof actor === "string" ? actor : null);
30972
+ const currentFrom = sourceWords(document2, envelope?.src) ?? sourceObjectWords(read?.source) ?? (typeof actor === "string" ? actor : null);
30962
30973
  return /* @__PURE__ */ jsxs97(Popover12, { open, onOpenChange: (next) => void opened(next), children: [
30963
30974
  /* @__PURE__ */ jsx108(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx108(
30964
30975
  "button",
@@ -30977,11 +30988,11 @@ function ValueAlternates({
30977
30988
  /* @__PURE__ */ jsx108("span", { className: "truncate font-medium", children: shown3(field2, document2?.[field2.key]) }),
30978
30989
  asked3 || currentFrom ? /* @__PURE__ */ jsx108("span", { className: "truncate text-[11px] text-muted-foreground", children: currentFrom ?? "" }) : /* @__PURE__ */ jsx108(Skeleton13, { shape: "line", width: "1/2" })
30979
30990
  ] }),
30980
- /* @__PURE__ */ jsx108("ul", { className: "flex flex-col divide-y", children: held.map((alt, i) => /* @__PURE__ */ jsxs97("li", { className: "flex items-center gap-2 py-1", "data-alternate-index": i, children: [
30991
+ /* @__PURE__ */ jsx108("ul", { className: "flex flex-col divide-y", children: shownList.map((alt, i) => /* @__PURE__ */ jsxs97("li", { className: "flex items-center gap-2 py-1", "data-alternate-index": i, children: [
30981
30992
  /* @__PURE__ */ jsxs97("span", { className: "flex min-w-0 flex-1 flex-col", children: [
30982
30993
  /* @__PURE__ */ jsx108("span", { className: "truncate font-medium", children: shown3(field2, alt.value) }),
30983
30994
  /* @__PURE__ */ jsxs97("span", { className: "truncate text-[11px] text-muted-foreground", children: [
30984
- sourceWords(document2, alt.src) ?? "Unknown source",
30995
+ sourceWords(document2, alt.src) ?? sourceObjectWords(alt.source) ?? "Unknown source",
30985
30996
  " \xB7 rank ",
30986
30997
  alt.rank
30987
30998
  ] })
@@ -31189,7 +31200,7 @@ function AddBody({ tableId }) {
31189
31200
  }
31190
31201
 
31191
31202
  // src/Peek.tsx
31192
- import { humanizeIdentifier as humanizeIdentifier12 } from "@ai-matrx/kit/text-case";
31203
+ import { humanizeIdentifier as humanizeIdentifier13 } from "@ai-matrx/kit/text-case";
31193
31204
  import { Fragment as Fragment40, jsx as jsx111, jsxs as jsxs100 } from "react/jsx-runtime";
31194
31205
  function drawnBelowOnPage(field2, bodyKey) {
31195
31206
  return field2.key === bodyKey || editorKindFor(field2) === "relation";
@@ -31338,7 +31349,7 @@ function computedLinesWorthShowing(rows, document2) {
31338
31349
  );
31339
31350
  }
31340
31351
  function computedInPlainWords(row, field2) {
31341
- const name = field2 ? fieldName(field2) : humanizeIdentifier12(row.field_key);
31352
+ const name = field2 ? fieldName(field2) : humanizeIdentifier13(row.field_key);
31342
31353
  const shown5 = row.value === null || row.value === void 0 || row.value === "" ? "nothing" : field2 ? scalarText(field2, row.value) : String(row.value);
31343
31354
  const when = new Date(row.computed_at);
31344
31355
  const at = Number.isNaN(when.getTime()) ? "" : ` on ${when.toLocaleDateString()}`;
@@ -35421,18 +35432,18 @@ function useLinkGroupNamer(block, tableId) {
35421
35432
  // src/measureWords.ts
35422
35433
  import { useEffect as useEffect83, useState as useState101 } from "react";
35423
35434
  import { useOptionalRecordsClient as useOptionalRecordsClient18 } from "@ai-matrx/records/react";
35424
- import { humanizeIdentifier as humanizeIdentifier13 } from "@ai-matrx/kit/text-case";
35435
+ import { humanizeIdentifier as humanizeIdentifier14 } from "@ai-matrx/kit/text-case";
35425
35436
  var OP_WORD = { sum: "Total", avg: "Average", min: "Lowest", max: "Highest" };
35426
35437
  function measureWords(key, fields) {
35427
35438
  if (key === "count") return "How many";
35428
35439
  const at = key.indexOf("_");
35429
- if (at < 0) return humanizeIdentifier13(key);
35440
+ if (at < 0) return humanizeIdentifier14(key);
35430
35441
  const op2 = key.slice(0, at);
35431
35442
  const column = key.slice(at + 1);
35432
35443
  const field2 = fields?.find((f) => f.key === column);
35433
- const name = field2 ? fieldName(field2) : humanizeIdentifier13(column);
35444
+ const name = field2 ? fieldName(field2) : humanizeIdentifier14(column);
35434
35445
  const word = OP_WORD[op2];
35435
- return word ? `${word} ${name.charAt(0).toLowerCase()}${name.slice(1)}` : `${humanizeIdentifier13(op2)} ${name}`;
35446
+ return word ? `${word} ${name.charAt(0).toLowerCase()}${name.slice(1)}` : `${humanizeIdentifier14(op2)} ${name}`;
35436
35447
  }
35437
35448
  function useMeasureWords(key, tableId) {
35438
35449
  const client = useOptionalRecordsClient18();
@@ -38183,7 +38194,7 @@ import { formatAbsoluteDate, formatDurationMs } from "@ai-matrx/kit/format";
38183
38194
  import { useCallback as useCallback44, useEffect as useEffect91, useMemo as useMemo62, useState as useState109 } from "react";
38184
38195
  import { useRecordsClient as useRecordsClient75, useTable as useTable24 } from "@ai-matrx/records/react";
38185
38196
  import { Badge as Badge17, BasicInput as BasicInput22, BasicTextarea as BasicTextarea9, Button as Button80, Skeleton as Skeleton19, cn as cn66 } from "@ai-matrx/design-system";
38186
- import { humanizeIdentifier as humanizeIdentifier14 } from "@ai-matrx/kit/text-case";
38197
+ import { humanizeIdentifier as humanizeIdentifier15 } from "@ai-matrx/kit/text-case";
38187
38198
  import { Fragment as Fragment49, jsx as jsx131, jsxs as jsxs119 } from "react/jsx-runtime";
38188
38199
  var DUE_WORD = DUE_STATE_LABEL;
38189
38200
  var REQUIRES_WORD = CHECKLIST_REQUIREMENT_LABEL;
@@ -38414,7 +38425,7 @@ function StepRow({
38414
38425
  /* @__PURE__ */ jsxs119("div", { className: "flex items-center gap-2", children: [
38415
38426
  /* @__PURE__ */ jsx131("span", { className: "w-5 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground", children: step2.step_order }),
38416
38427
  /* @__PURE__ */ jsx131("span", { className: cn66("min-w-0 flex-1 truncate text-xs", step2.finished && "line-through"), children: step2.title }),
38417
- step2.role ? /* @__PURE__ */ jsx131(Badge17, { variant: "outline", className: "text-[10px]", children: step2.assignee_name ?? humanizeIdentifier14(step2.role) }) : null,
38428
+ step2.role ? /* @__PURE__ */ jsx131(Badge17, { variant: "outline", className: "text-[10px]", children: step2.assignee_name ?? humanizeIdentifier15(step2.role) }) : null,
38418
38429
  step2.due_state && step2.due_state !== "undated" ? /* @__PURE__ */ jsx131(
38419
38430
  Badge17,
38420
38431
  {
@@ -39837,7 +39848,7 @@ import { useEffect as useEffect93, useMemo as useMemo64, useState as useState111
39837
39848
  import { readTypedDate as readTypedDate3, typedDateText as typedDateText3 } from "@ai-matrx/records";
39838
39849
  import { useRecordsClient as useRecordsClient77 } from "@ai-matrx/records/react";
39839
39850
  import { Button as Button82, Skeleton as Skeleton21, cn as cn68 } from "@ai-matrx/design-system";
39840
- import { humanizeIdentifier as humanizeIdentifier15 } from "@ai-matrx/kit/text-case";
39851
+ import { humanizeIdentifier as humanizeIdentifier16 } from "@ai-matrx/kit/text-case";
39841
39852
  import { Fragment as Fragment51, jsx as jsx133, jsxs as jsxs121 } from "react/jsx-runtime";
39842
39853
  function endOfDayIso(day2, zone2 = getPersonTimeZone()) {
39843
39854
  const [y, m, d] = day2.split("-").map(Number);
@@ -39980,7 +39991,7 @@ function AsOfReading({
39980
39991
  ] });
39981
39992
  }
39982
39993
  return /* @__PURE__ */ jsx133("dl", { className: cn68(box, "grid grid-cols-[minmax(5rem,9rem)_1fr] content-start gap-x-3 gap-y-0.5 p-2 text-[11px]"), "data-records-as-of-reading": "", children: rows.map(({ field: field2, was, now, differs }) => /* @__PURE__ */ jsxs121("div", { className: "contents", "data-as-of-field": field2.key, "data-as-of-differs": differs ? "" : void 0, children: [
39983
- /* @__PURE__ */ jsx133("dt", { className: "truncate text-muted-foreground", title: fieldName(field2) || humanizeIdentifier15(field2.key), children: fieldName(field2) || humanizeIdentifier15(field2.key) }),
39994
+ /* @__PURE__ */ jsx133("dt", { className: "truncate text-muted-foreground", title: fieldName(field2) || humanizeIdentifier16(field2.key), children: fieldName(field2) || humanizeIdentifier16(field2.key) }),
39984
39995
  /* @__PURE__ */ jsx133("dd", { className: cn68("min-w-0 truncate", differs && "rounded bg-amber-500/10 px-1"), children: differs ? /* @__PURE__ */ jsxs121(Fragment51, { children: [
39985
39996
  /* @__PURE__ */ jsx133("span", { className: "font-medium", children: isEmpty2(was) ? "nothing" : scalarText(field2, was) }),
39986
39997
  /* @__PURE__ */ jsx133("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
@@ -39991,7 +40002,7 @@ function AsOfReading({
39991
40002
  }
39992
40003
 
39993
40004
  // src/HistoryPanel.tsx
39994
- import { humanizeIdentifier as humanizeIdentifier16 } from "@ai-matrx/kit/text-case";
40005
+ import { humanizeIdentifier as humanizeIdentifier17 } from "@ai-matrx/kit/text-case";
39995
40006
  import { jsx as jsx134, jsxs as jsxs122 } from "react/jsx-runtime";
39996
40007
  function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
39997
40008
  const client = useRecordsClient78();
@@ -40230,7 +40241,7 @@ function ChangeLine({
40230
40241
  onAskAboutField
40231
40242
  }) {
40232
40243
  return /* @__PURE__ */ jsxs122("li", { "data-change-key": change.key, className: "flex items-baseline gap-2 text-[11px]", children: [
40233
- /* @__PURE__ */ jsx134("span", { className: "w-24 shrink-0 truncate font-medium", title: change.label, children: change.label || humanizeIdentifier16(change.key) }),
40244
+ /* @__PURE__ */ jsx134("span", { className: "w-24 shrink-0 truncate font-medium", title: change.label, children: change.label || humanizeIdentifier17(change.key) }),
40234
40245
  /* @__PURE__ */ jsxs122("span", { className: "min-w-0 flex-1 truncate", children: [
40235
40246
  /* @__PURE__ */ jsx134("span", { className: "text-muted-foreground line-through", children: say(change.before, field2) }),
40236
40247
  /* @__PURE__ */ jsx134("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
@@ -40244,7 +40255,7 @@ function ChangeLine({
40244
40255
  "span",
40245
40256
  {
40246
40257
  className: "shrink-0 text-muted-foreground",
40247
- title: Object.entries(change.source).map(([k, v]) => `${humanizeIdentifier16(k)}: ${String(v)}`).join(" \xB7 "),
40258
+ title: Object.entries(change.source).map(([k, v]) => `${humanizeIdentifier17(k)}: ${String(v)}`).join(" \xB7 "),
40248
40259
  children: "evidence"
40249
40260
  }
40250
40261
  ) : null,
@@ -40309,7 +40320,7 @@ import {
40309
40320
  useTable as useTable26
40310
40321
  } from "@ai-matrx/records/react";
40311
40322
  import { Badge as Badge20, Button as Button84, Skeleton as Skeleton23, Textarea as Textarea6, cn as cn70 } from "@ai-matrx/design-system";
40312
- import { humanizeIdentifier as humanizeIdentifier17 } from "@ai-matrx/kit/text-case";
40323
+ import { humanizeIdentifier as humanizeIdentifier18 } from "@ai-matrx/kit/text-case";
40313
40324
  import { jsx as jsx135, jsxs as jsxs123 } from "react/jsx-runtime";
40314
40325
  function CommentThread({ tableId, recordId, fieldKey, className }) {
40315
40326
  const client = useRecordsClient79();
@@ -40370,7 +40381,7 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
40370
40381
  const shown5 = fieldKey ? thread.comments.filter((c) => c.field_key === fieldKey) : thread.comments;
40371
40382
  const roots = shown5.filter((c) => !c.parent_comment_id);
40372
40383
  const repliesOf = (id) => shown5.filter((c) => c.parent_comment_id === id);
40373
- const fieldLabel = fieldKey ? (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier17(fieldKey) : null;
40384
+ const fieldLabel = fieldKey ? (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier18(fieldKey) : null;
40374
40385
  async function post() {
40375
40386
  if (draft.trim() === "") return;
40376
40387
  setBusy(true);
@@ -40522,7 +40533,7 @@ function Line2({
40522
40533
  onReply,
40523
40534
  onResolve
40524
40535
  }) {
40525
- const about = comment.field_key ? fields.find((f) => f.key === comment.field_key)?.label || humanizeIdentifier17(comment.field_key) : null;
40536
+ const about = comment.field_key ? fields.find((f) => f.key === comment.field_key)?.label || humanizeIdentifier18(comment.field_key) : null;
40526
40537
  return /* @__PURE__ */ jsxs123("div", { className: "flex flex-col gap-0.5", children: [
40527
40538
  /* @__PURE__ */ jsxs123("div", { className: "flex items-baseline gap-2 text-[11px] text-muted-foreground", children: [
40528
40539
  /* @__PURE__ */ jsx135("span", { className: "truncate font-medium text-foreground", children: comment.created_by_name }),
@@ -40553,7 +40564,7 @@ import {
40553
40564
  useTable as useTable27
40554
40565
  } from "@ai-matrx/records/react";
40555
40566
  import { Badge as Badge21, Button as Button85, Skeleton as Skeleton24, cn as cn71 } from "@ai-matrx/design-system";
40556
- import { humanizeIdentifier as humanizeIdentifier18 } from "@ai-matrx/kit/text-case";
40567
+ import { humanizeIdentifier as humanizeIdentifier19 } from "@ai-matrx/kit/text-case";
40557
40568
  import { Fragment as Fragment52, jsx as jsx136, jsxs as jsxs124 } from "react/jsx-runtime";
40558
40569
  function FieldHistoryPanel({
40559
40570
  tableId,
@@ -40586,7 +40597,7 @@ function FieldHistoryPanel({
40586
40597
  useEffect96(() => {
40587
40598
  void load();
40588
40599
  }, [load]);
40589
- const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier18(fieldKey);
40600
+ const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier19(fieldKey);
40590
40601
  if (error) return /* @__PURE__ */ jsx136(RefusalNotice, { error, className });
40591
40602
  if (!rows || fields.loading && !fields.data || table.loading && !table.data) return /* @__PURE__ */ jsx136(Skeleton24, { className: cn71("h-40 w-full", className) });
40592
40603
  async function start(row) {
@@ -43401,7 +43412,7 @@ import { useCallback as useCallback54, useEffect as useEffect104, useMemo as use
43401
43412
  import { useFields as useFields27, useOptionalRecordsClient as useOptionalRecordsClient20 } from "@ai-matrx/records/react";
43402
43413
  import { Button as Button94, Label as Label23, Progress, Skeleton as Skeleton31, cn as cn81, formThemeClasses } from "@ai-matrx/design-system";
43403
43414
  import { answerRefusal, formRoutes, pipeAnswers, submissionStamp } from "@ai-matrx/records/forms";
43404
- import { humanizeIdentifier as humanizeIdentifier19 } from "@ai-matrx/kit/text-case";
43415
+ import { humanizeIdentifier as humanizeIdentifier20 } from "@ai-matrx/kit/text-case";
43405
43416
  import { Fragment as Fragment57, jsx as jsx147, jsxs as jsxs135 } from "react/jsx-runtime";
43406
43417
  function authored(host, text, where) {
43407
43418
  return host.renderText ? host.renderText(text, where) : text;
@@ -43529,7 +43540,7 @@ function FormStage({
43529
43540
  // THE FORM'S OWN WORDS FIRST (MAKE-HOME W5). Unwritten, the Field's display name
43530
43541
  // (`fieldName`: a machine-key label is written the way a person writes it), and with no
43531
43542
  // Field at all the key humanized — a stranger never reads `full_name`.
43532
- ask: q.ask?.trim() || (field2 ? fieldName(field2) : humanizeIdentifier19(q.field)),
43543
+ ask: q.ask?.trim() || (field2 ? fieldName(field2) : humanizeIdentifier20(q.field)),
43533
43544
  help: q.help ?? null,
43534
43545
  required: q.required ?? field2?.required ?? false,
43535
43546
  field: field2,
@@ -49728,7 +49739,7 @@ import {
49728
49739
  cn as cn98,
49729
49740
  useIsMobile as useIsMobile2
49730
49741
  } from "@ai-matrx/design-system";
49731
- import { humanizeIdentifier as humanizeIdentifier20 } from "@ai-matrx/kit/text-case";
49742
+ import { humanizeIdentifier as humanizeIdentifier21 } from "@ai-matrx/kit/text-case";
49732
49743
 
49733
49744
  // src/calendarFeed.ts
49734
49745
  function webcalUrl(httpsUrl) {
@@ -50671,7 +50682,7 @@ function RailFrame({
50671
50682
  function filterInWords(filter, fields) {
50672
50683
  const nameOf2 = (key) => {
50673
50684
  const field2 = fields.find((f) => f.key === key);
50674
- return field2 ? fieldName(field2) : humanizeIdentifier20(key);
50685
+ return field2 ? fieldName(field2) : humanizeIdentifier21(key);
50675
50686
  };
50676
50687
  const parts = Object.keys(filter).map((key) => {
50677
50688
  const value = filter[key];