@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 +12 -0
- package/dist/index.cjs +34 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
};
|
|
@@ -7383,7 +7390,9 @@ function useChoiceOptions(fields, keys) {
|
|
|
7383
7390
|
return index;
|
|
7384
7391
|
}
|
|
7385
7392
|
function lookOf(option) {
|
|
7386
|
-
|
|
7393
|
+
const raw = option.data?.["color"];
|
|
7394
|
+
const color = typeof raw === "string" && STYLE_COLORS4.includes(raw) ? raw : void 0;
|
|
7395
|
+
return { id: String(option.id), key: optionKey2(option), label: optionLabel2(option), ...color ? { color } : {} };
|
|
7387
7396
|
}
|
|
7388
7397
|
function paintByOption(style, fields, index, lookup) {
|
|
7389
7398
|
if (index.size === 0) return { style, documentOf: (doc) => doc, choiceColorFor: lookup };
|
|
@@ -7407,10 +7416,13 @@ function paintByOption(style, fields, index, lookup) {
|
|
|
7407
7416
|
}
|
|
7408
7417
|
return out ?? doc;
|
|
7409
7418
|
},
|
|
7419
|
+
// A CHOICE PAINTS IN ITS OWN COLOUR (DATA-V2-BASICS-2 C1b): an option kept in its own Table
|
|
7420
|
+
// carries the colour its owner gave it; coloured by Status, a "Verified" (green) row was tinted
|
|
7421
|
+
// pink by the hash. The option's colour first, then the column's stored colours, then the hash.
|
|
7410
7422
|
choiceColorFor: (fieldKey, value) => {
|
|
7411
7423
|
const option = optionFor(index.get(fieldKey), value);
|
|
7412
7424
|
if (!option) return lookup(fieldKey, value);
|
|
7413
|
-
return lookup(fieldKey, option.label) ?? lookup(fieldKey, option.key);
|
|
7425
|
+
return option.color ?? lookup(fieldKey, option.label) ?? lookup(fieldKey, option.key);
|
|
7414
7426
|
}
|
|
7415
7427
|
};
|
|
7416
7428
|
}
|
|
@@ -12970,9 +12982,19 @@ function Grid({
|
|
|
12970
12982
|
records.reload();
|
|
12971
12983
|
}, [added, controls.columns, columnIds, fields.data, editing, records]);
|
|
12972
12984
|
addRowRef.current = () => void addRowHere();
|
|
12985
|
+
const labels = useRecordLabels(ordered);
|
|
12986
|
+
const labelsNow = useRef16(labels);
|
|
12987
|
+
labelsNow.current = labels;
|
|
12988
|
+
const labelFor = useCallback18((field2, id) => labelsNow.current(field2, id), []);
|
|
12989
|
+
useEffect32(() => {
|
|
12990
|
+
for (const field2 of ordered) {
|
|
12991
|
+
if (!pointsAtRecords(field2)) continue;
|
|
12992
|
+
for (const row of rows) for (const id of idsOf(row.document?.[field2.key])) labels(field2, id);
|
|
12993
|
+
}
|
|
12994
|
+
}, [ordered, rows, labels]);
|
|
12973
12995
|
const fieldColumns = useMemo23(
|
|
12974
|
-
() => ordered.map(
|
|
12975
|
-
|
|
12996
|
+
() => ordered.map((field2) => ({
|
|
12997
|
+
...columnForField(
|
|
12976
12998
|
// A formula's hover text names its columns as they are called NOW (review 2, C3).
|
|
12977
12999
|
// …and shows as its inputs do (money in, money out), blank when it has nothing to work on.
|
|
12978
13000
|
withFormulaDisplayNow(field2, ordered, (f) => String(editorKindFor(f)), currencyCodeFor),
|
|
@@ -12990,8 +13012,9 @@ function Grid({
|
|
|
12990
13012
|
cellFor: (recordId) => enrichCells.get(`${recordId}:${field2.key}`),
|
|
12991
13013
|
onPin: canWrite ? pinCell : void 0
|
|
12992
13014
|
}
|
|
12993
|
-
)
|
|
12994
|
-
|
|
13015
|
+
),
|
|
13016
|
+
...pointsAtRecords(field2) ? { copyValue: (row) => shownValue(field2, row.document?.[field2.key], labelFor) } : {}
|
|
13017
|
+
})),
|
|
12995
13018
|
[
|
|
12996
13019
|
ordered,
|
|
12997
13020
|
canWrite,
|
|
@@ -13061,9 +13084,10 @@ function Grid({
|
|
|
13061
13084
|
tableId,
|
|
13062
13085
|
tableName: tableName(table.data),
|
|
13063
13086
|
fields: ordered,
|
|
13064
|
-
rowLabel: (row) => recordNameIn(table.data, row.document ?? {})
|
|
13087
|
+
rowLabel: (row) => recordNameIn(table.data, row.document ?? {}),
|
|
13088
|
+
labels: labelFor
|
|
13065
13089
|
}) : null,
|
|
13066
|
-
[tableId, table.data, ordered]
|
|
13090
|
+
[tableId, table.data, ordered, labelFor]
|
|
13067
13091
|
);
|
|
13068
13092
|
const tableStyleProp = useMemo23(
|
|
13069
13093
|
() => tableStyleIsEmpty2(paint.style) ? null : {
|
|
@@ -13956,13 +13980,6 @@ function toRows(fields, records, labels) {
|
|
|
13956
13980
|
return row;
|
|
13957
13981
|
});
|
|
13958
13982
|
}
|
|
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
13983
|
function download(name, mime, bytes) {
|
|
13967
13984
|
const url = URL.createObjectURL(new Blob([bytes], { type: mime }));
|
|
13968
13985
|
const anchor = document.createElement("a");
|