@ai-matrx/records-ui 0.93.28 → 0.93.29

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
@@ -1351,6 +1351,13 @@ function isId(value) {
1351
1351
  function pointsAtRecords(field2) {
1352
1352
  return field2.type === "list" || field2.type === "relation";
1353
1353
  }
1354
+ function shownValue(field2, value, labels) {
1355
+ if (!labels || !pointsAtRecords(field2)) return value;
1356
+ const ids = idsOf(value);
1357
+ if (ids.length === 0) return value;
1358
+ const words2 = ids.map((id) => labels(field2, id) ?? id);
1359
+ return Array.isArray(value) ? words2 : words2[0];
1360
+ }
1354
1361
  function RecordLabelProvider({ children }) {
1355
1362
  const client = useRecordsClient();
1356
1363
  const [names, setNames] = useState4({});
@@ -6223,12 +6230,12 @@ function measuresFor(field2, storeOps, firstColumn) {
6223
6230
  });
6224
6231
  }
6225
6232
  function gridCopyConfig(args) {
6226
- const { tableId, tableName: tableName2, fields, rowLabel } = args;
6233
+ const { tableId, tableName: tableName2, fields, rowLabel, labels } = args;
6227
6234
  const shown3 = (row) => {
6228
6235
  const document2 = row.document ?? {};
6229
6236
  const out = {};
6230
6237
  for (const field2 of fields) {
6231
- if (document2[field2.key] !== void 0) out[fieldName(field2)] = document2[field2.key];
6238
+ if (document2[field2.key] !== void 0) out[fieldName(field2)] = shownValue(field2, document2[field2.key], labels);
6232
6239
  }
6233
6240
  return out;
6234
6241
  };
@@ -12970,9 +12977,19 @@ function Grid({
12970
12977
  records.reload();
12971
12978
  }, [added, controls.columns, columnIds, fields.data, editing, records]);
12972
12979
  addRowRef.current = () => void addRowHere();
12980
+ const labels = useRecordLabels(ordered);
12981
+ const labelsNow = useRef16(labels);
12982
+ labelsNow.current = labels;
12983
+ const labelFor = useCallback18((field2, id) => labelsNow.current(field2, id), []);
12984
+ useEffect32(() => {
12985
+ for (const field2 of ordered) {
12986
+ if (!pointsAtRecords(field2)) continue;
12987
+ for (const row of rows) for (const id of idsOf(row.document?.[field2.key])) labels(field2, id);
12988
+ }
12989
+ }, [ordered, rows, labels]);
12973
12990
  const fieldColumns = useMemo23(
12974
- () => ordered.map(
12975
- (field2) => columnForField(
12991
+ () => ordered.map((field2) => ({
12992
+ ...columnForField(
12976
12993
  // A formula's hover text names its columns as they are called NOW (review 2, C3).
12977
12994
  // …and shows as its inputs do (money in, money out), blank when it has nothing to work on.
12978
12995
  withFormulaDisplayNow(field2, ordered, (f) => String(editorKindFor(f)), currencyCodeFor),
@@ -12990,8 +13007,9 @@ function Grid({
12990
13007
  cellFor: (recordId) => enrichCells.get(`${recordId}:${field2.key}`),
12991
13008
  onPin: canWrite ? pinCell : void 0
12992
13009
  }
12993
- )
12994
- ),
13010
+ ),
13011
+ ...pointsAtRecords(field2) ? { copyValue: (row) => shownValue(field2, row.document?.[field2.key], labelFor) } : {}
13012
+ })),
12995
13013
  [
12996
13014
  ordered,
12997
13015
  canWrite,
@@ -13061,9 +13079,10 @@ function Grid({
13061
13079
  tableId,
13062
13080
  tableName: tableName(table.data),
13063
13081
  fields: ordered,
13064
- rowLabel: (row) => recordNameIn(table.data, row.document ?? {})
13082
+ rowLabel: (row) => recordNameIn(table.data, row.document ?? {}),
13083
+ labels: labelFor
13065
13084
  }) : null,
13066
- [tableId, table.data, ordered]
13085
+ [tableId, table.data, ordered, labelFor]
13067
13086
  );
13068
13087
  const tableStyleProp = useMemo23(
13069
13088
  () => tableStyleIsEmpty2(paint.style) ? null : {
@@ -13956,13 +13975,6 @@ function toRows(fields, records, labels) {
13956
13975
  return row;
13957
13976
  });
13958
13977
  }
13959
- function shownValue(field2, value, labels) {
13960
- if (!labels || !pointsAtRecords(field2)) return value;
13961
- const ids = idsOf(value);
13962
- if (ids.length === 0) return value;
13963
- const words2 = ids.map((id) => labels(field2, id) ?? id);
13964
- return Array.isArray(value) ? words2 : words2[0];
13965
- }
13966
13978
  function download(name, mime, bytes) {
13967
13979
  const url = URL.createObjectURL(new Blob([bytes], { type: mime }));
13968
13980
  const anchor = document.createElement("a");