@ai-matrx/records-ui 0.93.7 → 0.93.8

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
@@ -5182,6 +5182,22 @@ function choiceDisplayPatch(field2, rows) {
5182
5182
  const id = held?.id ?? (editorKindFor(field2) === "multi_select" ? "multi_choice" : "choice");
5183
5183
  return { id, options: { ...held?.options ?? {}, choices } };
5184
5184
  }
5185
+ function lookFollowsRenames(field2, look, renames) {
5186
+ if (renames.size === 0) return look;
5187
+ const base = look ?? displayFormatOf(field2);
5188
+ const choices = base && Array.isArray(base.options["choices"]) ? base.options["choices"] : null;
5189
+ if (!base || !choices) return look;
5190
+ let moved = false;
5191
+ const next = choices.map((c) => {
5192
+ const was = typeof c["value"] === "string" ? c["value"] : null;
5193
+ const now = was === null ? void 0 : [...renames].find(([old]) => choiceWord(old) === choiceWord(was))?.[1];
5194
+ if (now === void 0) return c;
5195
+ moved = true;
5196
+ return { ...c, value: now };
5197
+ });
5198
+ if (!moved) return look;
5199
+ return { id: base.id, options: { ...base.options, choices: next } };
5200
+ }
5185
5201
  function ChoiceColorsEditor({
5186
5202
  field: field2,
5187
5203
  rows,
@@ -5921,7 +5937,14 @@ function FieldEditor({ tableId, field: field2, onSaved, onCancel, onRemoved, cla
5921
5937
  if (missing) return;
5922
5938
  if (editing && field2) {
5923
5939
  const chooses = type === "select" || type === "multi_select";
5924
- const look = chooses ? choiceRows ? choiceDisplayPatch(field2, choiceRows) : null : null;
5940
+ const renames = /* @__PURE__ */ new Map();
5941
+ if (chooses && choiceList && choiceListStart) {
5942
+ for (const was of choiceListStart) {
5943
+ const now = was.id ? choiceList.find((r) => r.id === was.id) : void 0;
5944
+ if (now && now.words.trim() !== "" && now.words.trim() !== was.words.trim()) renames.set(was.words.trim(), now.words.trim());
5945
+ }
5946
+ }
5947
+ const look = chooses ? lookFollowsRenames(field2, choiceRows ? choiceDisplayPatch(field2, choiceRows) : null, renames) : null;
5925
5948
  const shownAs = chooses ? void 0 : formatPatch(field2, showsAs);
5926
5949
  const patch = {
5927
5950
  // The column's look travels in the same settings patch (`display_format`), so a save is