@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/pickers.js CHANGED
@@ -4566,13 +4566,10 @@ function formulaSourceArchived(field, document2) {
4566
4566
 
4567
4567
  // src/values.tsx
4568
4568
  import { autonumberPrefixOf as autonumberPrefixOf2, autonumberWords as autonumberWords2, isButtonField as isButtonField2, newerKindWords, sourceArchivedOf as sourceArchivedOf2 } from "@ai-matrx/records";
4569
+ import { isUuidShape as isUuidShape4 } from "@ai-matrx/kit/uuid";
4569
4570
 
4570
4571
  // src/userIds.ts
4571
- var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4572
4572
  var PERSON_NOT_IN_ORGANIZATION = "A person no longer in this organization";
4573
- function isUserId(value) {
4574
- return typeof value === "string" && UUID.test(value);
4575
- }
4576
4573
 
4577
4574
  // src/personNames.ts
4578
4575
  import { useSyncExternalStore } from "react";
@@ -4807,6 +4804,7 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
4807
4804
  }
4808
4805
 
4809
4806
  // src/memberNames.ts
4807
+ import { isUuidShape as isUuidShape3 } from "@ai-matrx/kit/uuid";
4810
4808
  function memberWords(member) {
4811
4809
  const name = member?.name?.trim();
4812
4810
  if (name) return name;
@@ -5017,7 +5015,7 @@ function LivePersonChip({ id, name }) {
5017
5015
  var NEVER_AN_ID_KINDS = /* @__PURE__ */ new Set(["member", "person", "number", "currency", "percent", "date", "datetime", "checkbox", "boolean"]);
5018
5016
  function personWordsOf(kind, value) {
5019
5017
  const items = Array.isArray(value) ? value : [value];
5020
- const ids = items.filter(isUserId);
5018
+ const ids = items.filter(isUuidShape4);
5021
5019
  if (ids.length === 0) return null;
5022
5020
  const wordsColumn = !NEVER_AN_ID_KINDS.has(kind);
5023
5021
  const named = ids.map((id) => knownPerson(id));
@@ -5725,10 +5723,11 @@ import { tableShapeChanged as tableShapeChanged2, useRecordsClient as useRecords
5725
5723
  import { Button as Button13, Select as Select4, SelectContent as SelectContent4, SelectItem as SelectItem4, SelectTrigger as SelectTrigger4, SelectValue as SelectValue4 } from "@ai-matrx/design-system";
5726
5724
 
5727
5725
  // src/personRetype.ts
5726
+ import { isUuidShape as isUuidShape5 } from "@ai-matrx/kit/uuid";
5728
5727
  var PAGE = 500;
5729
5728
  var CEILING = 2e4;
5730
5729
  function idsIn(value) {
5731
- return (Array.isArray(value) ? value : [value]).filter(isUserId);
5730
+ return (Array.isArray(value) ? value : [value]).filter(isUuidShape5);
5732
5731
  }
5733
5732
  async function readPersonColumn(client, tableId, key) {
5734
5733
  const out = [];
@@ -5810,6 +5809,23 @@ function personWordsWritten(rows, people, as) {
5810
5809
  function personWordsPatches(rows, people, key, as) {
5811
5810
  return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words]) => ({ recordId, patch: { [key]: words } }));
5812
5811
  }
5812
+ async function forgetWrittenWords(client, tableId, key, written) {
5813
+ const patches = [];
5814
+ for (let offset = 0; offset < CEILING; offset += PAGE) {
5815
+ const page = await client.list({ table_id: tableId, limit: PAGE, offset });
5816
+ if (!page.ok) throw new Error(refusalSentence(page.error));
5817
+ for (const row of page.data.rows) {
5818
+ const word = written[row.id];
5819
+ const kept = (row.document ?? {})["_retired"];
5820
+ if (word === void 0 || !Array.isArray(kept)) continue;
5821
+ const rest = kept.filter((e) => !(e?.key === key && e?.value === word));
5822
+ if (rest.length !== kept.length) patches.push({ recordId: row.id, patch: { _retired: rest } });
5823
+ }
5824
+ if (page.data.rows.length < PAGE) break;
5825
+ }
5826
+ await writeRecordPatches(client, tableId, patches);
5827
+ return patches.length;
5828
+ }
5813
5829
 
5814
5830
  // src/FieldRetype.tsx
5815
5831
  import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
@@ -5939,7 +5955,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
5939
5955
  noun: "column",
5940
5956
  subject: name,
5941
5957
  undo: async () => {
5942
- const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
5958
+ const back = await client.migrateUndo({ migration_id: migration });
5943
5959
  if (!back.ok) throw new Error(refusalSentence(back.error));
5944
5960
  if (wasPerson) {
5945
5961
  await writeRecordPatches(
@@ -5947,6 +5963,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
5947
5963
  tableId,
5948
5964
  wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
5949
5965
  );
5966
+ if (wordsWritten) await forgetWrittenWords(client, tableId, field.key, wordsWritten);
5950
5967
  }
5951
5968
  tableShapeChanged2(tableId);
5952
5969
  onRetyped?.();