@ai-matrx/records-ui 0.93.28 → 0.93.30

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
+ ## 0.93.30
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records-ui/v0.93.29..npm/records-ui/v0.93.30 -- apps/shared/records-ui`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.93.29
10
+
11
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
12
+ `git diff npm/records-ui/v0.93.28..npm/records-ui/v0.93.29 -- apps/shared/records-ui`).
13
+ No source changes intended and no consumer action required.
14
+
3
15
  ## 0.93.28
4
16
 
5
17
  Automatic changed-only republish (docs/metadata drift since the last tag — see
package/dist/index.cjs CHANGED
@@ -1710,6 +1710,13 @@ function isId(value) {
1710
1710
  function pointsAtRecords(field2) {
1711
1711
  return field2.type === "list" || field2.type === "relation";
1712
1712
  }
1713
+ function shownValue(field2, value, labels) {
1714
+ if (!labels || !pointsAtRecords(field2)) return value;
1715
+ const ids = idsOf(value);
1716
+ if (ids.length === 0) return value;
1717
+ const words2 = ids.map((id) => labels(field2, id) ?? id);
1718
+ return Array.isArray(value) ? words2 : words2[0];
1719
+ }
1713
1720
  function RecordLabelProvider({ children }) {
1714
1721
  const client = (0, import_react9.useRecordsClient)();
1715
1722
  const [names, setNames] = (0, import_react8.useState)({});
@@ -6534,12 +6541,12 @@ function measuresFor(field2, storeOps, firstColumn) {
6534
6541
  });
6535
6542
  }
6536
6543
  function gridCopyConfig(args) {
6537
- const { tableId, tableName: tableName2, fields, rowLabel } = args;
6544
+ const { tableId, tableName: tableName2, fields, rowLabel, labels } = args;
6538
6545
  const shown3 = (row) => {
6539
6546
  const document2 = row.document ?? {};
6540
6547
  const out = {};
6541
6548
  for (const field2 of fields) {
6542
- if (document2[field2.key] !== void 0) out[fieldName(field2)] = document2[field2.key];
6549
+ if (document2[field2.key] !== void 0) out[fieldName(field2)] = shownValue(field2, document2[field2.key], labels);
6543
6550
  }
6544
6551
  return out;
6545
6552
  };
@@ -7680,7 +7687,9 @@ function useChoiceOptions(fields, keys) {
7680
7687
  return index;
7681
7688
  }
7682
7689
  function lookOf(option) {
7683
- return { id: String(option.id), key: (0, import_records12.optionKey)(option), label: (0, import_records12.optionLabel)(option) };
7690
+ const raw = option.data?.["color"];
7691
+ const color = typeof raw === "string" && import_data_table7.STYLE_COLORS.includes(raw) ? raw : void 0;
7692
+ return { id: String(option.id), key: (0, import_records12.optionKey)(option), label: (0, import_records12.optionLabel)(option), ...color ? { color } : {} };
7684
7693
  }
7685
7694
  function paintByOption(style, fields, index, lookup) {
7686
7695
  if (index.size === 0) return { style, documentOf: (doc) => doc, choiceColorFor: lookup };
@@ -7704,10 +7713,13 @@ function paintByOption(style, fields, index, lookup) {
7704
7713
  }
7705
7714
  return out ?? doc;
7706
7715
  },
7716
+ // A CHOICE PAINTS IN ITS OWN COLOUR (DATA-V2-BASICS-2 C1b): an option kept in its own Table
7717
+ // carries the colour its owner gave it; coloured by Status, a "Verified" (green) row was tinted
7718
+ // pink by the hash. The option's colour first, then the column's stored colours, then the hash.
7707
7719
  choiceColorFor: (fieldKey, value) => {
7708
7720
  const option = optionFor(index.get(fieldKey), value);
7709
7721
  if (!option) return lookup(fieldKey, value);
7710
- return lookup(fieldKey, option.label) ?? lookup(fieldKey, option.key);
7722
+ return option.color ?? lookup(fieldKey, option.label) ?? lookup(fieldKey, option.key);
7711
7723
  }
7712
7724
  };
7713
7725
  }
@@ -13179,9 +13191,19 @@ function Grid({
13179
13191
  records.reload();
13180
13192
  }, [added, controls.columns, columnIds, fields.data, editing, records]);
13181
13193
  addRowRef.current = () => void addRowHere();
13194
+ const labels = useRecordLabels(ordered);
13195
+ const labelsNow = (0, import_react72.useRef)(labels);
13196
+ labelsNow.current = labels;
13197
+ const labelFor = (0, import_react72.useCallback)((field2, id) => labelsNow.current(field2, id), []);
13198
+ (0, import_react72.useEffect)(() => {
13199
+ for (const field2 of ordered) {
13200
+ if (!pointsAtRecords(field2)) continue;
13201
+ for (const row of rows) for (const id of idsOf(row.document?.[field2.key])) labels(field2, id);
13202
+ }
13203
+ }, [ordered, rows, labels]);
13182
13204
  const fieldColumns = (0, import_react72.useMemo)(
13183
- () => ordered.map(
13184
- (field2) => columnForField(
13205
+ () => ordered.map((field2) => ({
13206
+ ...columnForField(
13185
13207
  // A formula's hover text names its columns as they are called NOW (review 2, C3).
13186
13208
  // …and shows as its inputs do (money in, money out), blank when it has nothing to work on.
13187
13209
  withFormulaDisplayNow(field2, ordered, (f) => String(editorKindFor(f)), currencyCodeFor),
@@ -13199,8 +13221,9 @@ function Grid({
13199
13221
  cellFor: (recordId) => enrichCells.get(`${recordId}:${field2.key}`),
13200
13222
  onPin: canWrite ? pinCell : void 0
13201
13223
  }
13202
- )
13203
- ),
13224
+ ),
13225
+ ...pointsAtRecords(field2) ? { copyValue: (row) => shownValue(field2, row.document?.[field2.key], labelFor) } : {}
13226
+ })),
13204
13227
  [
13205
13228
  ordered,
13206
13229
  canWrite,
@@ -13270,9 +13293,10 @@ function Grid({
13270
13293
  tableId,
13271
13294
  tableName: tableName(table.data),
13272
13295
  fields: ordered,
13273
- rowLabel: (row) => recordNameIn(table.data, row.document ?? {})
13296
+ rowLabel: (row) => recordNameIn(table.data, row.document ?? {}),
13297
+ labels: labelFor
13274
13298
  }) : null,
13275
- [tableId, table.data, ordered]
13299
+ [tableId, table.data, ordered, labelFor]
13276
13300
  );
13277
13301
  const tableStyleProp = (0, import_react72.useMemo)(
13278
13302
  () => (0, import_data_table9.tableStyleIsEmpty)(paint.style) ? null : {
@@ -14165,13 +14189,6 @@ function toRows(fields, records, labels) {
14165
14189
  return row;
14166
14190
  });
14167
14191
  }
14168
- function shownValue(field2, value, labels) {
14169
- if (!labels || !pointsAtRecords(field2)) return value;
14170
- const ids = idsOf(value);
14171
- if (ids.length === 0) return value;
14172
- const words2 = ids.map((id) => labels(field2, id) ?? id);
14173
- return Array.isArray(value) ? words2 : words2[0];
14174
- }
14175
14192
  function download(name, mime, bytes) {
14176
14193
  const url = URL.createObjectURL(new Blob([bytes], { type: mime }));
14177
14194
  const anchor = document.createElement("a");