@ai-matrx/records-ui 0.115.89 → 0.115.91

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
@@ -2525,12 +2525,11 @@ function PersonPicker({ field: field2, value, onChange, disabled, id, className,
2525
2525
  ] });
2526
2526
  }
2527
2527
 
2528
+ // src/memberNames.ts
2529
+ import { isUuidShape as isUuidShape3 } from "@ai-matrx/kit/uuid";
2530
+
2528
2531
  // src/userIds.ts
2529
- var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2530
2532
  var PERSON_NOT_IN_ORGANIZATION = "A person no longer in this organization";
2531
- function isUserId(value) {
2532
- return typeof value === "string" && UUID.test(value);
2533
- }
2534
2533
 
2535
2534
  // src/memberNames.ts
2536
2535
  function memberWords(member) {
@@ -2576,7 +2575,7 @@ async function resolveKeptPerson(client, id, roster) {
2576
2575
  }
2577
2576
  function useKeptPeople(value, roster) {
2578
2577
  const client = useOptionalRecordsClient3();
2579
- const ids = useMemo4(() => (Array.isArray(value) ? value : [value]).filter(isUserId), [value]);
2578
+ const ids = useMemo4(() => (Array.isArray(value) ? value : [value]).filter(isUuidShape3), [value]);
2580
2579
  const key = ids.join(",");
2581
2580
  const [people, setPeople] = useState6(null);
2582
2581
  useEffect6(() => {
@@ -2596,10 +2595,11 @@ __reExport(recordVersions_exports, versions_star2);
2596
2595
  import * as versions_star2 from "@ai-matrx/records/versions";
2597
2596
 
2598
2597
  // src/personRetype.ts
2598
+ import { isUuidShape as isUuidShape4 } from "@ai-matrx/kit/uuid";
2599
2599
  var PAGE = 500;
2600
2600
  var CEILING = 2e4;
2601
2601
  function idsIn(value) {
2602
- return (Array.isArray(value) ? value : [value]).filter(isUserId);
2602
+ return (Array.isArray(value) ? value : [value]).filter(isUuidShape4);
2603
2603
  }
2604
2604
  async function readPersonColumn(client, tableId, key) {
2605
2605
  const out = [];
@@ -2681,6 +2681,23 @@ function personWordsWritten(rows, people, as) {
2681
2681
  function personWordsPatches(rows, people, key, as) {
2682
2682
  return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words2]) => ({ recordId, patch: { [key]: words2 } }));
2683
2683
  }
2684
+ async function forgetWrittenWords(client, tableId, key, written) {
2685
+ const patches = [];
2686
+ for (let offset = 0; offset < CEILING; offset += PAGE) {
2687
+ const page = await client.list({ table_id: tableId, limit: PAGE, offset });
2688
+ if (!page.ok) throw new Error(refusalSentence(page.error));
2689
+ for (const row of page.data.rows) {
2690
+ const word = written[row.id];
2691
+ const kept = (row.document ?? {})["_retired"];
2692
+ if (word === void 0 || !Array.isArray(kept)) continue;
2693
+ const rest = kept.filter((e) => !(e?.key === key && e?.value === word));
2694
+ if (rest.length !== kept.length) patches.push({ recordId: row.id, patch: { _retired: rest } });
2695
+ }
2696
+ if (page.data.rows.length < PAGE) break;
2697
+ }
2698
+ await writeRecordPatches(client, tableId, patches);
2699
+ return patches.length;
2700
+ }
2684
2701
 
2685
2702
  // src/FieldRetype.tsx
2686
2703
  import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
@@ -2810,7 +2827,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
2810
2827
  noun: "column",
2811
2828
  subject: name,
2812
2829
  undo: async () => {
2813
- const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
2830
+ const back = await client.migrateUndo({ migration_id: migration });
2814
2831
  if (!back.ok) throw new Error(refusalSentence(back.error));
2815
2832
  if (wasPerson) {
2816
2833
  await writeRecordPatches(
@@ -2818,6 +2835,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
2818
2835
  tableId,
2819
2836
  wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }))
2820
2837
  );
2838
+ if (wordsWritten) await forgetWrittenWords(client, tableId, field2.key, wordsWritten);
2821
2839
  }
2822
2840
  tableShapeChanged(tableId);
2823
2841
  onRetyped?.();
@@ -7221,6 +7239,7 @@ function withFormulaDisplayNow(field2, fields, kindOf, currencyCodeOf) {
7221
7239
 
7222
7240
  // src/values.tsx
7223
7241
  import { autonumberPrefixOf as autonumberPrefixOf2, autonumberWords as autonumberWords2, isButtonField as isButtonField2, newerKindWords, sourceArchivedOf as sourceArchivedOf2 } from "@ai-matrx/records";
7242
+ import { isUuidShape as isUuidShape7 } from "@ai-matrx/kit/uuid";
7224
7243
 
7225
7244
  // src/personNames.ts
7226
7245
  import { useSyncExternalStore as useSyncExternalStore2 } from "react";
@@ -7284,6 +7303,7 @@ import { ruleThatRefuses } from "@ai-matrx/records";
7284
7303
  import { useState as useState23 } from "react";
7285
7304
  import { useRecordsClient as useRecordsClient8 } from "@ai-matrx/records/react";
7286
7305
  import { Button as Button13 } from "@ai-matrx/design-system";
7306
+ import { isUuidShape as isUuidShape5 } from "@ai-matrx/kit/uuid";
7287
7307
  import { jsx as jsx28, jsxs as jsxs25 } from "react/jsx-runtime";
7288
7308
  function same(a, b) {
7289
7309
  return JSON.stringify(a) === JSON.stringify(b);
@@ -7363,7 +7383,7 @@ function RetiredValues({
7363
7383
  const field2 = fields.find((f) => f.key === entry.key);
7364
7384
  const name = field2 ? fieldName(field2) : entry.label ?? entry.key;
7365
7385
  const shown5 = field2 ? scalarText(field2, entry.value) : typeof entry.value === "string" ? entry.value : JSON.stringify(entry.value);
7366
- const holdsUserId = (Array.isArray(entry.value) ? entry.value : [entry.value]).some(isUserId);
7386
+ const holdsUserId = (Array.isArray(entry.value) ? entry.value : [entry.value]).some(isUuidShape5);
7367
7387
  return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-0.5", "data-records-retired-key": entry.key, children: [
7368
7388
  /* @__PURE__ */ jsxs25("div", { className: "flex flex-wrap items-baseline gap-2", children: [
7369
7389
  /* @__PURE__ */ jsx28("span", { className: "text-muted-foreground", children: name }),
@@ -7384,6 +7404,7 @@ function RetiredValues({
7384
7404
  }
7385
7405
 
7386
7406
  // src/cellMarks.tsx
7407
+ import { isUuidShape as isUuidShape6 } from "@ai-matrx/kit/uuid";
7387
7408
  import { jsx as jsx29 } from "react/jsx-runtime";
7388
7409
  function keptAsideFor(document2, key) {
7389
7410
  const doc = document2;
@@ -7413,7 +7434,7 @@ function keptAsideReason(field2, entry) {
7413
7434
  function KeptAsideValue({ field: field2, entry, shown: shown5 }) {
7414
7435
  const why = keptAsideReason(field2, entry);
7415
7436
  const open = useRecordsUi().openPerson;
7416
- const person = (Array.isArray(entry.value) ? entry.value : [entry.value]).find(isUserId);
7437
+ const person = (Array.isArray(entry.value) ? entry.value : [entry.value]).find(isUuidShape6);
7417
7438
  const opens = open && typeof person === "string";
7418
7439
  return /* @__PURE__ */ jsx29(
7419
7440
  "span",
@@ -7639,7 +7660,7 @@ function LivePersonChip({ id, name }) {
7639
7660
  var NEVER_AN_ID_KINDS = /* @__PURE__ */ new Set(["member", "person", "number", "currency", "percent", "date", "datetime", "checkbox", "boolean"]);
7640
7661
  function personWordsOf(kind2, value) {
7641
7662
  const items = Array.isArray(value) ? value : [value];
7642
- const ids = items.filter(isUserId);
7663
+ const ids = items.filter(isUuidShape7);
7643
7664
  if (ids.length === 0) return null;
7644
7665
  const wordsColumn = !NEVER_AN_ID_KINDS.has(kind2);
7645
7666
  const named = ids.map((id) => knownPerson(id));
@@ -42544,6 +42565,7 @@ function ActionInbox({
42544
42565
  }
42545
42566
 
42546
42567
  // src/HistoryPanel.tsx
42568
+ import { isUuidShape as isUuidShape8 } from "@ai-matrx/kit/uuid";
42547
42569
  import { useCallback as useCallback47, useEffect as useEffect98, useRef as useRef54, useState as useState116 } from "react";
42548
42570
 
42549
42571
  // src/undoChange.ts
@@ -43296,7 +43318,7 @@ function whenText(at) {
43296
43318
  function say(value, field2) {
43297
43319
  if (value === null || value === void 0 || value === "") return "nothing";
43298
43320
  if (field2) return scalarText(field2, value);
43299
- const ids = (Array.isArray(value) ? value : [value]).filter(isUserId);
43321
+ const ids = (Array.isArray(value) ? value : [value]).filter(isUuidShape8);
43300
43322
  if (ids.length > 0 && ids.length === (Array.isArray(value) ? value.length : 1)) {
43301
43323
  return ids.map((id) => knownPerson(id) ?? PERSON_NOT_IN_ORGANIZATION).join(", ");
43302
43324
  }
@@ -43306,6 +43328,7 @@ function say(value, field2) {
43306
43328
  }
43307
43329
 
43308
43330
  // src/CommentThread.tsx
43331
+ import { isUuidShape as isUuidShape9 } from "@ai-matrx/kit/uuid";
43309
43332
  import { useCallback as useCallback48, useEffect as useEffect99, useMemo as useMemo67, useRef as useRef55, useState as useState117 } from "react";
43310
43333
  import {
43311
43334
  useFields as useFields24,
@@ -43544,7 +43567,7 @@ function Line2({
43544
43567
  /* @__PURE__ */ jsx139("p", { className: "whitespace-pre-wrap text-xs", children: comment.body }),
43545
43568
  comment.mentions.length > 0 ? /* @__PURE__ */ jsxs127("p", { className: "text-[10px] text-muted-foreground", children: [
43546
43569
  "Told: ",
43547
- comment.mentions.map((m) => isUserId(m.name) ? PERSON_NOT_IN_ORGANIZATION : m.name).join(", ")
43570
+ comment.mentions.map((m) => isUuidShape9(m.name) ? PERSON_NOT_IN_ORGANIZATION : m.name).join(", ")
43548
43571
  ] }) : null
43549
43572
  ] });
43550
43573
  }
@@ -54012,7 +54035,7 @@ function useSlotScroll(slot) {
54012
54035
  }
54013
54036
 
54014
54037
  // src/TablePage.tsx
54015
- import { isUuidShape as isUuidShape3 } from "@ai-matrx/kit/uuid";
54038
+ import { isUuidShape as isUuidShape10 } from "@ai-matrx/kit/uuid";
54016
54039
  import { openOutbound as openOutbound4 } from "@ai-matrx/kit/outbound";
54017
54040
  import { Fragment as Fragment72, jsx as jsx178, jsxs as jsxs166 } from "react/jsx-runtime";
54018
54041
  var RAIL_TITLE = {
@@ -54244,7 +54267,7 @@ function openingView(activeView, activeDashboardId) {
54244
54267
  }
54245
54268
  function savedViewFromParam(activeView) {
54246
54269
  const word = typeof activeView === "string" ? activeView.trim() : "";
54247
- return isUuidShape3(word) ? word.toLowerCase() : null;
54270
+ return isUuidShape10(word) ? word.toLowerCase() : null;
54248
54271
  }
54249
54272
  function addressForView(view, layout) {
54250
54273
  return view && !view.isDefault ? view.id : layout;
@@ -55282,7 +55305,7 @@ function TablePage({
55282
55305
  QuestionPanel,
55283
55306
  {
55284
55307
  tableId,
55285
- activeQuestionId: questionsFromLink && activeItemId && isUuidShape3(activeItemId) ? activeItemId : null,
55308
+ activeQuestionId: questionsFromLink && activeItemId && isUuidShape10(activeItemId) ? activeItemId : null,
55286
55309
  draft: questionDraft
55287
55310
  }
55288
55311
  ) : main === "archived" ? (