@ai-matrx/records-ui 0.110.6 → 0.110.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/CHANGELOG.md +12 -0
- package/dist/index.cjs +105 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +13 -8
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +8 -3
- package/dist/pickers.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1092,6 +1092,11 @@ function inColumnWords(error, fields) {
|
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
1094
|
// src/askOnce.ts
|
|
1095
|
+
import { onTableStructureChanged } from "@ai-matrx/records/core";
|
|
1096
|
+
var structureEpoch = 0;
|
|
1097
|
+
onTableStructureChanged(() => {
|
|
1098
|
+
structureEpoch += 1;
|
|
1099
|
+
});
|
|
1095
1100
|
var asked = /* @__PURE__ */ new WeakMap();
|
|
1096
1101
|
var byPerson = /* @__PURE__ */ new WeakMap();
|
|
1097
1102
|
function heldFor(client) {
|
|
@@ -1122,7 +1127,7 @@ function askOnce(client, key, ask, freshMs) {
|
|
|
1122
1127
|
const held = heldFor(client);
|
|
1123
1128
|
const now = Date.now();
|
|
1124
1129
|
const kept = held.get(key);
|
|
1125
|
-
if (kept && now - kept.at <= freshMs) return kept.answer;
|
|
1130
|
+
if (kept && kept.epoch === structureEpoch && now - kept.at <= freshMs) return kept.answer;
|
|
1126
1131
|
const answer = ask().then(
|
|
1127
1132
|
(result) => {
|
|
1128
1133
|
if (!result.ok) held.delete(key);
|
|
@@ -1133,17 +1138,18 @@ function askOnce(client, key, ask, freshMs) {
|
|
|
1133
1138
|
throw thrown;
|
|
1134
1139
|
}
|
|
1135
1140
|
);
|
|
1136
|
-
held.set(key, { at: now, answer });
|
|
1141
|
+
held.set(key, { at: now, epoch: structureEpoch, answer });
|
|
1137
1142
|
return answer;
|
|
1138
1143
|
}
|
|
1139
1144
|
function forgetAsked(client, prefix) {
|
|
1140
1145
|
const held = heldFor(client);
|
|
1141
1146
|
for (const key of [...held.keys()]) if (key.startsWith(prefix)) held.delete(key);
|
|
1142
1147
|
}
|
|
1143
|
-
var FIELD_OPTIONS_FRESH_MS =
|
|
1148
|
+
var FIELD_OPTIONS_FRESH_MS = 1e4;
|
|
1144
1149
|
function fieldOptionsOnce(client, fieldId) {
|
|
1145
1150
|
return askOnce(client, `field_options:${fieldId}`, () => client.fieldOptions({ field_id: fieldId }), FIELD_OPTIONS_FRESH_MS);
|
|
1146
1151
|
}
|
|
1152
|
+
var ENRICH_CELLS_FRESH_MS = 5e3;
|
|
1147
1153
|
|
|
1148
1154
|
// src/labels.tsx
|
|
1149
1155
|
import { createContext as createContext3, useCallback, useContext as useContext3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
@@ -18562,12 +18568,14 @@ function useEnrichCells(tableId, recordIds) {
|
|
|
18562
18568
|
const [cells, setCells] = useState51(/* @__PURE__ */ new Map());
|
|
18563
18569
|
const [error, setError] = useState51(null);
|
|
18564
18570
|
const key = (recordIds ?? []).join(",");
|
|
18565
|
-
const
|
|
18571
|
+
const load = useCallback20(async (fresh) => {
|
|
18566
18572
|
if (!tableId || !recordIds || recordIds.length === 0) {
|
|
18567
18573
|
setCells(/* @__PURE__ */ new Map());
|
|
18568
18574
|
return;
|
|
18569
18575
|
}
|
|
18570
|
-
const
|
|
18576
|
+
const asking = `enrich_cells:${tableId}:${key}`;
|
|
18577
|
+
if (fresh) forgetAsked(client, asking);
|
|
18578
|
+
const answered = await askOnce(client, asking, () => client.enrichCells({ table_id: tableId, record_ids: recordIds }), ENRICH_CELLS_FRESH_MS);
|
|
18571
18579
|
if (!answered.ok) {
|
|
18572
18580
|
setError(answered.error);
|
|
18573
18581
|
return;
|
|
@@ -18577,9 +18585,10 @@ function useEnrichCells(tableId, recordIds) {
|
|
|
18577
18585
|
for (const cell2 of answered.data) next.set(`${cell2.record_id}:${cell2.field_key}`, cell2);
|
|
18578
18586
|
setCells(next);
|
|
18579
18587
|
}, [client, tableId, key]);
|
|
18588
|
+
const refresh = useCallback20(() => load(true), [load]);
|
|
18580
18589
|
useEffect42(() => {
|
|
18581
|
-
void
|
|
18582
|
-
}, [
|
|
18590
|
+
void load(false);
|
|
18591
|
+
}, [load]);
|
|
18583
18592
|
return { cells, refresh, error };
|
|
18584
18593
|
}
|
|
18585
18594
|
var NEVER2 = "Fill it in once and leave it alone";
|