@ai-matrx/records-ui 0.116.55 → 0.116.57
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 +20 -1
- package/dist/{SaveToTable-EM2JT3OS.js → SaveToTable-2TQKEYJA.js} +3 -3
- package/dist/{chunk-GZJ7GRM2.js → chunk-F3NGOSYY.js} +3 -3
- package/dist/{chunk-7LELV7UI.js → chunk-NGOPU3AJ.js} +128 -44
- package/dist/chunk-NGOPU3AJ.js.map +1 -0
- package/dist/{chunk-BZ6PLCAR.js → chunk-Y6U5OFJX.js} +2 -2
- package/dist/index.cjs +10045 -9846
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +170 -69
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +2018 -1961
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-7LELV7UI.js.map +0 -1
- /package/dist/{SaveToTable-EM2JT3OS.js.map → SaveToTable-2TQKEYJA.js.map} +0 -0
- /package/dist/{chunk-GZJ7GRM2.js.map → chunk-F3NGOSYY.js.map} +0 -0
- /package/dist/{chunk-BZ6PLCAR.js.map → chunk-Y6U5OFJX.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -2509,6 +2509,13 @@ interface ViewReading {
|
|
|
2509
2509
|
presentation?: GridPresentation | undefined;
|
|
2510
2510
|
/** A hand-ordered view with no sort is read by its own id (the store places its rows). */
|
|
2511
2511
|
viewId?: string | null | undefined;
|
|
2512
|
+
/**
|
|
2513
|
+
* What the person has done in THE GRID on top of the view: the column filters she set in the header
|
|
2514
|
+
* menus and the words in the search box. The grid asks the store with them, so the file does too
|
|
2515
|
+
* (AT-FIX-I: a file listed rows the grid had filtered out).
|
|
2516
|
+
*/
|
|
2517
|
+
columnFilters?: Record<string, unknown> | undefined;
|
|
2518
|
+
search?: string | undefined;
|
|
2512
2519
|
}
|
|
2513
2520
|
|
|
2514
2521
|
/**
|
|
@@ -5908,7 +5915,7 @@ interface PageCanvasProps {
|
|
|
5908
5915
|
/** Called with a chart edited in settings (an Interface copies a published chart before changing it). */
|
|
5909
5916
|
onChart?: ((chart: ChartSpec) => void) | undefined;
|
|
5910
5917
|
}
|
|
5911
|
-
declare function PageCanvas(
|
|
5918
|
+
declare function PageCanvas(props: PageCanvasProps): react.JSX.Element;
|
|
5912
5919
|
|
|
5913
5920
|
interface InterfaceScreenProps {
|
|
5914
5921
|
interfaceId?: Uuid$1 | null | undefined;
|
|
@@ -6318,7 +6325,7 @@ interface CaptureRunProps {
|
|
|
6318
6325
|
className?: string | undefined;
|
|
6319
6326
|
}
|
|
6320
6327
|
/** What control one question gets. `attachment` is why a phone opens its camera. */
|
|
6321
|
-
declare function controlFor(field: CaptureField | undefined): "photo" | "voice" | "number" | "text";
|
|
6328
|
+
declare function controlFor(field: CaptureField | undefined): "photo" | "voice" | "number" | "text" | "paragraph";
|
|
6322
6329
|
declare function CaptureRun({ sheetId, face: given, className }: CaptureRunProps): react.JSX.Element;
|
|
6323
6330
|
|
|
6324
6331
|
interface PortalShellProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -2509,6 +2509,13 @@ interface ViewReading {
|
|
|
2509
2509
|
presentation?: GridPresentation | undefined;
|
|
2510
2510
|
/** A hand-ordered view with no sort is read by its own id (the store places its rows). */
|
|
2511
2511
|
viewId?: string | null | undefined;
|
|
2512
|
+
/**
|
|
2513
|
+
* What the person has done in THE GRID on top of the view: the column filters she set in the header
|
|
2514
|
+
* menus and the words in the search box. The grid asks the store with them, so the file does too
|
|
2515
|
+
* (AT-FIX-I: a file listed rows the grid had filtered out).
|
|
2516
|
+
*/
|
|
2517
|
+
columnFilters?: Record<string, unknown> | undefined;
|
|
2518
|
+
search?: string | undefined;
|
|
2512
2519
|
}
|
|
2513
2520
|
|
|
2514
2521
|
/**
|
|
@@ -5908,7 +5915,7 @@ interface PageCanvasProps {
|
|
|
5908
5915
|
/** Called with a chart edited in settings (an Interface copies a published chart before changing it). */
|
|
5909
5916
|
onChart?: ((chart: ChartSpec) => void) | undefined;
|
|
5910
5917
|
}
|
|
5911
|
-
declare function PageCanvas(
|
|
5918
|
+
declare function PageCanvas(props: PageCanvasProps): react.JSX.Element;
|
|
5912
5919
|
|
|
5913
5920
|
interface InterfaceScreenProps {
|
|
5914
5921
|
interfaceId?: Uuid$1 | null | undefined;
|
|
@@ -6318,7 +6325,7 @@ interface CaptureRunProps {
|
|
|
6318
6325
|
className?: string | undefined;
|
|
6319
6326
|
}
|
|
6320
6327
|
/** What control one question gets. `attachment` is why a phone opens its camera. */
|
|
6321
|
-
declare function controlFor(field: CaptureField | undefined): "photo" | "voice" | "number" | "text";
|
|
6328
|
+
declare function controlFor(field: CaptureField | undefined): "photo" | "voice" | "number" | "text" | "paragraph";
|
|
6322
6329
|
declare function CaptureRun({ sheetId, face: given, className }: CaptureRunProps): react.JSX.Element;
|
|
6323
6330
|
|
|
6324
6331
|
interface PortalShellProps {
|
package/dist/index.js
CHANGED
|
@@ -182,7 +182,7 @@ import {
|
|
|
182
182
|
withoutAddition,
|
|
183
183
|
withoutLeadingBlank,
|
|
184
184
|
workedOutErrorFor
|
|
185
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-F3NGOSYY.js";
|
|
186
186
|
import {
|
|
187
187
|
CHART_PLOT_PX,
|
|
188
188
|
EMBEDDED_ROW_PX,
|
|
@@ -293,7 +293,7 @@ import {
|
|
|
293
293
|
visibilityLaneFor,
|
|
294
294
|
whyNotAskable,
|
|
295
295
|
writeOnTheWinningVersion_exports
|
|
296
|
-
} from "./chunk-
|
|
296
|
+
} from "./chunk-Y6U5OFJX.js";
|
|
297
297
|
import {
|
|
298
298
|
ACTION_CHECKING_ACCESS_REASON,
|
|
299
299
|
ACTION_NOT_HERE_REASON,
|
|
@@ -346,6 +346,7 @@ import {
|
|
|
346
346
|
PickOrAdd,
|
|
347
347
|
ROLLUP_AGG_LABEL,
|
|
348
348
|
ROLLUP_AGG_VALUES,
|
|
349
|
+
ReadRefusalDock,
|
|
349
350
|
RecordsUiProvider,
|
|
350
351
|
RefusalLine,
|
|
351
352
|
RefusalNotice,
|
|
@@ -364,6 +365,7 @@ import {
|
|
|
364
365
|
WORK_INBOX_KIND_GROUP_LABEL,
|
|
365
366
|
WORK_INBOX_KIND_LABEL,
|
|
366
367
|
addFields,
|
|
368
|
+
askWithOneRetry,
|
|
367
369
|
cardTitleField,
|
|
368
370
|
changedRecordName,
|
|
369
371
|
choiceNudgeOf,
|
|
@@ -397,12 +399,14 @@ import {
|
|
|
397
399
|
tokenFor,
|
|
398
400
|
useChoiceNudge,
|
|
399
401
|
usePickerTables,
|
|
402
|
+
useReadAgain,
|
|
403
|
+
useReadRefusal,
|
|
400
404
|
useRecordRights,
|
|
401
405
|
useRecordsUi,
|
|
402
406
|
useRowRights,
|
|
403
407
|
useTableRights,
|
|
404
408
|
withoutInternalCodes
|
|
405
|
-
} from "./chunk-
|
|
409
|
+
} from "./chunk-NGOPU3AJ.js";
|
|
406
410
|
import {
|
|
407
411
|
FEWEST_KEY_VALUE_PAIRS,
|
|
408
412
|
FEWEST_LIST_ITEMS,
|
|
@@ -2568,11 +2572,13 @@ import { useRecordsClient as useRecordsClient5 } from "@ai-matrx/records/react";
|
|
|
2568
2572
|
function useWholeTableCount(args) {
|
|
2569
2573
|
const client = useRecordsClient5();
|
|
2570
2574
|
const [count, setCount] = useState5(null);
|
|
2575
|
+
const reads = useReadRefusal("record_aggregate");
|
|
2576
|
+
const [attempt, again] = useReadAgain();
|
|
2571
2577
|
useEffect6(() => {
|
|
2572
2578
|
if (!args.needed) return;
|
|
2573
2579
|
let live = true;
|
|
2574
|
-
void client.recordAggregate({ table_id: args.tableId, measures: [{ op: "count" }] }).then((answer) => {
|
|
2575
|
-
if (!live || !answer
|
|
2580
|
+
void askWithOneRetry(() => client.recordAggregate({ table_id: args.tableId, measures: [{ op: "count" }] })).then((answer) => {
|
|
2581
|
+
if (!live || !reads.take(answer, again)) return;
|
|
2576
2582
|
const row = answer.data?.[0];
|
|
2577
2583
|
const n = Number(row?.measures?.["count"] ?? row?.row_count);
|
|
2578
2584
|
setCount(Number.isFinite(n) ? { tableId: args.tableId, n } : null);
|
|
@@ -2580,7 +2586,7 @@ function useWholeTableCount(args) {
|
|
|
2580
2586
|
return () => {
|
|
2581
2587
|
live = false;
|
|
2582
2588
|
};
|
|
2583
|
-
}, [client, args.tableId, args.needed, args.version]);
|
|
2589
|
+
}, [client, args.tableId, args.needed, args.version, attempt]);
|
|
2584
2590
|
return args.needed && count && count.tableId === args.tableId ? count.n : null;
|
|
2585
2591
|
}
|
|
2586
2592
|
|
|
@@ -2606,6 +2612,8 @@ function useTableDecorations(tableId, revision) {
|
|
|
2606
2612
|
const [state, setState] = useState6({ data: null, loading: Boolean(tableId) });
|
|
2607
2613
|
const seen = useRef5({ tableId: void 0, revision: void 0 });
|
|
2608
2614
|
const ticket = useRef5(0);
|
|
2615
|
+
const reads = useReadRefusal("table_decorations");
|
|
2616
|
+
const [attempt, again] = useReadAgain();
|
|
2609
2617
|
useEffect7(() => {
|
|
2610
2618
|
if (!tableId) {
|
|
2611
2619
|
ticket.current += 1;
|
|
@@ -2620,11 +2628,12 @@ function useTableDecorations(tableId, revision) {
|
|
|
2620
2628
|
}
|
|
2621
2629
|
const mine = ticket.current += 1;
|
|
2622
2630
|
setState((held) => ({ data: held.data, loading: true }));
|
|
2623
|
-
void client.tableDecorations({ table_id: tableId }).then((result) => {
|
|
2631
|
+
void askWithOneRetry(() => client.tableDecorations({ table_id: tableId })).then((result) => {
|
|
2624
2632
|
if (mine !== ticket.current) return;
|
|
2625
|
-
setState({ data:
|
|
2633
|
+
if (!reads.take(result, again)) return setState((held) => ({ data: held.data, loading: false }));
|
|
2634
|
+
setState({ data: result.data, loading: false });
|
|
2626
2635
|
});
|
|
2627
|
-
}, [client, tableId, revision]);
|
|
2636
|
+
}, [client, tableId, revision, attempt]);
|
|
2628
2637
|
useEffect7(() => () => {
|
|
2629
2638
|
ticket.current += 1;
|
|
2630
2639
|
}, []);
|
|
@@ -4450,17 +4459,32 @@ function useChoiceOptions(fields, keys) {
|
|
|
4450
4459
|
const client = useRecordsClient13();
|
|
4451
4460
|
const [index, setIndex] = useState14(() => /* @__PURE__ */ new Map());
|
|
4452
4461
|
const wantedKey = keys.join("\0");
|
|
4462
|
+
const reads = useReadRefusal("field_options");
|
|
4463
|
+
const [attempt, again] = useReadAgain();
|
|
4453
4464
|
useEffect11(() => {
|
|
4454
4465
|
const missing = keys.map((key) => fields.find((f) => f.key === key)).filter((f) => f !== void 0 && !index.has(f.key));
|
|
4455
4466
|
if (missing.length === 0) return;
|
|
4456
4467
|
let cancelled = false;
|
|
4457
4468
|
void Promise.all(
|
|
4458
4469
|
missing.map(async (field) => {
|
|
4459
|
-
const got = await (0, askOnce_exports.fieldOptionsOnce)(client, field.id);
|
|
4460
|
-
return [field.key, got
|
|
4470
|
+
const got = await askWithOneRetry(() => (0, askOnce_exports.fieldOptionsOnce)(client, field.id));
|
|
4471
|
+
return [field.key, got];
|
|
4461
4472
|
})
|
|
4462
|
-
).then((
|
|
4473
|
+
).then((pairs) => {
|
|
4463
4474
|
if (cancelled) return;
|
|
4475
|
+
const refused = pairs.find(([, got]) => !got.ok);
|
|
4476
|
+
const refusedKeys = pairs.filter(([, got]) => !got.ok).map(([key]) => key);
|
|
4477
|
+
const askAgain = () => {
|
|
4478
|
+
setIndex((held) => {
|
|
4479
|
+
const next = new Map(held);
|
|
4480
|
+
for (const key of refusedKeys) next.delete(key);
|
|
4481
|
+
return next;
|
|
4482
|
+
});
|
|
4483
|
+
again();
|
|
4484
|
+
};
|
|
4485
|
+
if (refused) reads.take(refused[1], askAgain);
|
|
4486
|
+
else reads.take({ ok: true, data: null }, askAgain);
|
|
4487
|
+
const answers = pairs.map(([key, got]) => [key, got.ok ? (got.data ?? []).map(lookOf) : null]);
|
|
4464
4488
|
setIndex((held) => {
|
|
4465
4489
|
const next = new Map(held);
|
|
4466
4490
|
for (const [key, looks] of answers) next.set(key, looks ?? []);
|
|
@@ -4470,7 +4494,7 @@ function useChoiceOptions(fields, keys) {
|
|
|
4470
4494
|
return () => {
|
|
4471
4495
|
cancelled = true;
|
|
4472
4496
|
};
|
|
4473
|
-
}, [client, wantedKey, fields]);
|
|
4497
|
+
}, [client, wantedKey, fields, attempt]);
|
|
4474
4498
|
return index;
|
|
4475
4499
|
}
|
|
4476
4500
|
function lookOf(option) {
|
|
@@ -5018,20 +5042,23 @@ function useFormulaReadings(tableId, formulas) {
|
|
|
5018
5042
|
const client = useRecordsClient14();
|
|
5019
5043
|
const [readings, setReadings] = useState15({});
|
|
5020
5044
|
const key = formulas.join("\0");
|
|
5045
|
+
const reads = useReadRefusal("formula_parse");
|
|
5046
|
+
const [attempt, again] = useReadAgain();
|
|
5021
5047
|
useEffect12(() => {
|
|
5022
5048
|
if (!tableId) return;
|
|
5023
5049
|
let live = true;
|
|
5024
5050
|
for (const text of formulas) {
|
|
5025
5051
|
if (!text.trim() || text in readings) continue;
|
|
5026
|
-
void client.formulaParse({ table_id: tableId, text }).then((answer) => {
|
|
5052
|
+
void askWithOneRetry(() => client.formulaParse({ table_id: tableId, text })).then((answer) => {
|
|
5027
5053
|
if (!live) return;
|
|
5028
|
-
|
|
5054
|
+
if (!reads.take(answer, again)) return;
|
|
5055
|
+
setReadings((was) => ({ ...was, [text]: answer.data }));
|
|
5029
5056
|
});
|
|
5030
5057
|
}
|
|
5031
5058
|
return () => {
|
|
5032
5059
|
live = false;
|
|
5033
5060
|
};
|
|
5034
|
-
}, [client, tableId, key]);
|
|
5061
|
+
}, [client, tableId, key, attempt]);
|
|
5035
5062
|
return readings;
|
|
5036
5063
|
}
|
|
5037
5064
|
function ActionRowPreview({
|
|
@@ -6048,14 +6075,17 @@ function useColumnSummaries(args) {
|
|
|
6048
6075
|
};
|
|
6049
6076
|
}, [client, tableId, chosenKey, filterKey, version]);
|
|
6050
6077
|
const asking = useRef8(false);
|
|
6051
|
-
const
|
|
6052
|
-
|
|
6078
|
+
const operationReads = useReadRefusal("agg_operations");
|
|
6079
|
+
const operationsAsked = useRef8(() => void 0);
|
|
6080
|
+
operationsAsked.current = (force) => {
|
|
6081
|
+
if (!force && operations !== null || asking.current) return;
|
|
6053
6082
|
asking.current = true;
|
|
6054
|
-
void client.aggOperations().then((answered) => {
|
|
6083
|
+
void askWithOneRetry(() => client.aggOperations()).then((answered) => {
|
|
6055
6084
|
asking.current = false;
|
|
6056
|
-
setOperations(answered.
|
|
6085
|
+
setOperations(operationReads.take(answered, () => operationsAsked.current(true)) ? answered.data ?? [] : []);
|
|
6057
6086
|
});
|
|
6058
|
-
}
|
|
6087
|
+
};
|
|
6088
|
+
const askOperations = useCallback10(() => operationsAsked.current(false), []);
|
|
6059
6089
|
return { values, withheld, rowCount, loading, error, operations, askOperations };
|
|
6060
6090
|
}
|
|
6061
6091
|
function withSummaryCells(columns, render) {
|
|
@@ -6822,6 +6852,8 @@ function useMergedGridControls(args) {
|
|
|
6822
6852
|
const choiceKeys = useMemo13(() => enabled ? fields.filter(isChoiceField).map((f) => f.key) : [], [enabled, fields]);
|
|
6823
6853
|
const choiceOptions = useChoiceOptions(fields, choiceKeys);
|
|
6824
6854
|
const searchWords = (args.search ?? "").trim();
|
|
6855
|
+
const countReads = useReadRefusal("value_counts");
|
|
6856
|
+
const [countAttempt, countAgain] = useReadAgain();
|
|
6825
6857
|
const countQuestionKey = JSON.stringify([choiceKeys, query.columnFilters, args.filter ?? null, searchWords]);
|
|
6826
6858
|
const rowsKey = rows.map((row) => `${row.id}:${row.version ?? ""}`).join(",");
|
|
6827
6859
|
const fieldsRef = useRef9(fields);
|
|
@@ -6844,7 +6876,7 @@ function useMergedGridControls(args) {
|
|
|
6844
6876
|
() => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked2.filter ? { filter: asked2.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
|
|
6845
6877
|
VALUE_COUNTS_FRESH_MS
|
|
6846
6878
|
).then((answer) => {
|
|
6847
|
-
if (cancelled || !answer
|
|
6879
|
+
if (cancelled || !countReads.take(answer, countAgain)) return;
|
|
6848
6880
|
const counted = /* @__PURE__ */ new Map();
|
|
6849
6881
|
for (const row of answer.data ?? []) {
|
|
6850
6882
|
const value = row.groups?.[key];
|
|
@@ -6857,7 +6889,7 @@ function useMergedGridControls(args) {
|
|
|
6857
6889
|
return () => {
|
|
6858
6890
|
cancelled = true;
|
|
6859
6891
|
};
|
|
6860
|
-
}, [enabled, countQuestionKey, client, tableId, rowsKey]);
|
|
6892
|
+
}, [enabled, countQuestionKey, client, tableId, rowsKey, countAttempt]);
|
|
6861
6893
|
const filterFor = useCallback12(
|
|
6862
6894
|
(key) => {
|
|
6863
6895
|
if (!enabled) return void 0;
|
|
@@ -8504,14 +8536,16 @@ function useAddedRows(args) {
|
|
|
8504
8536
|
}, [pageKey, tableId]);
|
|
8505
8537
|
const pinnedKey = added.map((r) => r.id).join(",");
|
|
8506
8538
|
const asked2 = useRef12(0);
|
|
8539
|
+
const reads = useReadRefusal("list_by_ids");
|
|
8540
|
+
const [attempt, again] = useReadAgain();
|
|
8507
8541
|
useEffect22(() => {
|
|
8508
8542
|
if (!enabled || added.length === 0) return;
|
|
8509
8543
|
const onPage = new Set(pageRows.map((r) => r.id));
|
|
8510
8544
|
const missing = added.filter((r) => !onPage.has(r.id)).map((r) => r.id);
|
|
8511
8545
|
if (missing.length === 0) return;
|
|
8512
8546
|
const ticket = asked2.current += 1;
|
|
8513
|
-
void client.listByIds({ table_id: tableId, ids: missing }).then((answer) => {
|
|
8514
|
-
if (ticket !== asked2.current || !answer
|
|
8547
|
+
void askWithOneRetry(() => client.listByIds({ table_id: tableId, ids: missing })).then((answer) => {
|
|
8548
|
+
if (ticket !== asked2.current || !reads.take(answer, again)) return;
|
|
8515
8549
|
const fresh = new Map(answer.data.map((r) => [r.id, r]));
|
|
8516
8550
|
setAdded(
|
|
8517
8551
|
(held) => held.flatMap((row) => {
|
|
@@ -8521,7 +8555,7 @@ function useAddedRows(args) {
|
|
|
8521
8555
|
})
|
|
8522
8556
|
);
|
|
8523
8557
|
});
|
|
8524
|
-
}, [enabled, pageRows, pinnedKey, client, tableId]);
|
|
8558
|
+
}, [enabled, pageRows, pinnedKey, client, tableId, attempt]);
|
|
8525
8559
|
const rows = useMemo16(() => enabled ? placePinnedRows(pageRows, added, anchors) : pageRows, [enabled, pageRows, added, anchors]);
|
|
8526
8560
|
const pin = useCallback13((row, after) => {
|
|
8527
8561
|
setAdded((held) => held.some((r) => r.id === row.id) ? held : [...held, row]);
|
|
@@ -12278,17 +12312,19 @@ function useStructureHidden(tableId, level) {
|
|
|
12278
12312
|
const client = useRecordsClient33();
|
|
12279
12313
|
const asks = tableId !== null && mayHideStructure(level);
|
|
12280
12314
|
const [answer, setAnswer] = useState40(null);
|
|
12315
|
+
const reads = useReadRefusal("table_level_facts");
|
|
12316
|
+
const [attempt, again] = useReadAgain();
|
|
12281
12317
|
useEffect34(() => {
|
|
12282
12318
|
if (!asks || tableId === null) return;
|
|
12283
12319
|
let live = true;
|
|
12284
|
-
void client.tableLevelFacts({ table_id: tableId }).then((facts) => {
|
|
12320
|
+
void askWithOneRetry(() => client.tableLevelFacts({ table_id: tableId })).then((facts) => {
|
|
12285
12321
|
if (!live) return;
|
|
12286
|
-
setAnswer({ tableId, hidden: facts
|
|
12322
|
+
setAnswer({ tableId, hidden: reads.take(facts, again) && facts.data.structure_hidden === true });
|
|
12287
12323
|
});
|
|
12288
12324
|
return () => {
|
|
12289
12325
|
live = false;
|
|
12290
12326
|
};
|
|
12291
|
-
}, [client, tableId, asks]);
|
|
12327
|
+
}, [client, tableId, asks, attempt]);
|
|
12292
12328
|
if (!asks) return { settled: true, hidden: false };
|
|
12293
12329
|
const mine = answer !== null && answer.tableId === tableId ? answer : null;
|
|
12294
12330
|
return { settled: mine !== null, hidden: mine?.hidden ?? false };
|
|
@@ -18276,14 +18312,16 @@ function viewPageSorts(fields, sorts) {
|
|
|
18276
18312
|
}
|
|
18277
18313
|
async function readViewRows(client, tableId, fields, view, ceiling = VIEW_EXPORT_CEILING) {
|
|
18278
18314
|
const sort = viewPageSorts(fields, view.sorts);
|
|
18315
|
+
const asked2 = storeQuestion(fields, view.filter ?? void 0, view.columnFilters ?? {}).filter;
|
|
18316
|
+
const search = view.search?.trim() ? view.search.trim() : null;
|
|
18279
18317
|
const rows = [];
|
|
18280
18318
|
let physicalOffset = 0;
|
|
18281
18319
|
for (; ; ) {
|
|
18282
18320
|
const limit = VIEW_EXPORT_PAGE;
|
|
18283
18321
|
const answered = await client.listPage({
|
|
18284
18322
|
table_id: tableId,
|
|
18285
|
-
...
|
|
18286
|
-
search
|
|
18323
|
+
...asked2 ? { filter: asked2 } : {},
|
|
18324
|
+
search,
|
|
18287
18325
|
sort,
|
|
18288
18326
|
view_id: sort.length === 0 && view.viewId ? view.viewId : null,
|
|
18289
18327
|
limit,
|
|
@@ -18365,7 +18403,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
|
|
|
18365
18403
|
const host = useRecordsUi();
|
|
18366
18404
|
const fields = useFields17(tableId);
|
|
18367
18405
|
const page = useRecords4(view ? null : tableId, { pageSize: 500 });
|
|
18368
|
-
const viewKey = view ? JSON.stringify([view.filter ?? null, view.sorts ?? [], view.viewId ?? null]) : "";
|
|
18406
|
+
const viewKey = view ? JSON.stringify([view.filter ?? null, view.sorts ?? [], view.viewId ?? null, view.columnFilters ?? null, view.search ?? null]) : "";
|
|
18369
18407
|
const [viewRead, setViewRead] = useState57(null);
|
|
18370
18408
|
useEffect49(() => {
|
|
18371
18409
|
if (!view || !fields.data) return;
|
|
@@ -24140,12 +24178,14 @@ function useLinkGroupNamer(block, tableId) {
|
|
|
24140
24178
|
const [named, setNamed] = useState74({});
|
|
24141
24179
|
const [choices, setChoices] = useState74([]);
|
|
24142
24180
|
const labels = useRecordLabels(choices);
|
|
24181
|
+
const reads = useReadRefusal("fields_and_relation_words");
|
|
24182
|
+
const [attempt, again] = useReadAgain();
|
|
24143
24183
|
useEffect65(() => {
|
|
24144
24184
|
if (!client || groupBy.length === 0 || rows.length === 0) return;
|
|
24145
24185
|
let cancelled = false;
|
|
24146
24186
|
void (async () => {
|
|
24147
|
-
const fields = await client.fields({ table_id: tableId });
|
|
24148
|
-
if (!fields
|
|
24187
|
+
const fields = await askWithOneRetry(() => client.fields({ table_id: tableId }));
|
|
24188
|
+
if (cancelled || !reads.take(fields, again)) return;
|
|
24149
24189
|
const grouped = groupBy.map((key) => fields.data.find((f) => f.key === key)).filter((f) => !!f && f.type === "list" && editorKindFor(f) !== "relation");
|
|
24150
24190
|
if (grouped.length > 0) setChoices(grouped);
|
|
24151
24191
|
const links = groupBy.map((key) => fields.data.find((f) => f.key === key)).filter((f) => !!f && editorKindFor(f) === "relation");
|
|
@@ -24157,17 +24197,20 @@ function useLinkGroupNamer(block, tableId) {
|
|
|
24157
24197
|
const v = r.groups?.[field.key];
|
|
24158
24198
|
return typeof v === "string" ? linkIdsOf(v) : [];
|
|
24159
24199
|
}))];
|
|
24160
|
-
if (ids.length === 0) return [field.key, { words: {}, done: true }];
|
|
24161
|
-
const words2 = await client.relationWordsMany({ field_id: field.id, record_ids: ids });
|
|
24162
|
-
return [field.key, { words: words2.ok ? words2.data : {}, done: true }];
|
|
24200
|
+
if (ids.length === 0) return [field.key, { ok: true, data: {} }, { words: {}, done: true }];
|
|
24201
|
+
const words2 = await askWithOneRetry(() => client.relationWordsMany({ field_id: field.id, record_ids: ids }));
|
|
24202
|
+
return [field.key, words2, { words: words2.ok ? words2.data : {}, done: true }];
|
|
24163
24203
|
})
|
|
24164
24204
|
);
|
|
24165
|
-
if (
|
|
24205
|
+
if (cancelled) return;
|
|
24206
|
+
const refused = answered.find(([, got]) => !got.ok);
|
|
24207
|
+
if (refused) reads.take(refused[1], again);
|
|
24208
|
+
setNamed(Object.fromEntries(answered.map(([key, , column]) => [key, column])));
|
|
24166
24209
|
})();
|
|
24167
24210
|
return () => {
|
|
24168
24211
|
cancelled = true;
|
|
24169
24212
|
};
|
|
24170
|
-
}, [client, ask2]);
|
|
24213
|
+
}, [client, ask2, attempt]);
|
|
24171
24214
|
return useMemo46(() => {
|
|
24172
24215
|
if (Object.keys(named).length === 0 && choices.length === 0) return void 0;
|
|
24173
24216
|
return (key, value) => {
|
|
@@ -26374,6 +26417,8 @@ function useFarFields(all) {
|
|
|
26374
26417
|
const client = useRecordsClient63();
|
|
26375
26418
|
const targets = lookupTargets(all).sort().join(",");
|
|
26376
26419
|
const [far, setFar] = useState81(() => /* @__PURE__ */ new Map());
|
|
26420
|
+
const reads = useReadRefusal("fields");
|
|
26421
|
+
const [attempt, again] = useReadAgain();
|
|
26377
26422
|
useEffect72(() => {
|
|
26378
26423
|
let cancelled = false;
|
|
26379
26424
|
const ids = targets ? targets.split(",") : [];
|
|
@@ -26381,14 +26426,17 @@ function useFarFields(all) {
|
|
|
26381
26426
|
setFar(/* @__PURE__ */ new Map());
|
|
26382
26427
|
return;
|
|
26383
26428
|
}
|
|
26384
|
-
void Promise.all(ids.map(async (id) => [id, await client.fields({ table_id: id })])).then((answers) => {
|
|
26429
|
+
void Promise.all(ids.map(async (id) => [id, await askWithOneRetry(() => client.fields({ table_id: id }))])).then((answers) => {
|
|
26385
26430
|
if (cancelled) return;
|
|
26431
|
+
const refused = answers.find(([, r]) => !r.ok);
|
|
26432
|
+
if (refused) reads.take(refused[1], again);
|
|
26433
|
+
else reads.take({ ok: true, data: null }, again);
|
|
26386
26434
|
setFar(new Map(answers.flatMap(([id, r]) => r.ok ? [[id, r.data]] : [])));
|
|
26387
26435
|
});
|
|
26388
26436
|
return () => {
|
|
26389
26437
|
cancelled = true;
|
|
26390
26438
|
};
|
|
26391
|
-
}, [client, targets]);
|
|
26439
|
+
}, [client, targets, attempt]);
|
|
26392
26440
|
return far;
|
|
26393
26441
|
}
|
|
26394
26442
|
function offerableFields(all, want, placing) {
|
|
@@ -26413,17 +26461,20 @@ function useStageField(tableId) {
|
|
|
26413
26461
|
asked: false,
|
|
26414
26462
|
key: null
|
|
26415
26463
|
});
|
|
26464
|
+
const reads = useReadRefusal("table_stage_field");
|
|
26465
|
+
const [attempt, again] = useReadAgain();
|
|
26416
26466
|
useEffect72(() => {
|
|
26417
26467
|
let cancelled = false;
|
|
26418
26468
|
setStage({ asked: false, key: null });
|
|
26419
|
-
void client.tableStageField({ table_id: tableId }).then((r) => {
|
|
26469
|
+
void askWithOneRetry(() => client.tableStageField({ table_id: tableId })).then((r) => {
|
|
26420
26470
|
if (cancelled) return;
|
|
26421
|
-
|
|
26471
|
+
if (!reads.take(r, again)) return;
|
|
26472
|
+
setStage({ asked: true, key: r.data ?? null });
|
|
26422
26473
|
});
|
|
26423
26474
|
return () => {
|
|
26424
26475
|
cancelled = true;
|
|
26425
26476
|
};
|
|
26426
|
-
}, [client, tableId]);
|
|
26477
|
+
}, [client, tableId, attempt]);
|
|
26427
26478
|
return stage;
|
|
26428
26479
|
}
|
|
26429
26480
|
function boardColumnChoice(fields, chosenKey, stage) {
|
|
@@ -36330,20 +36381,25 @@ function useNames(tableId, ids) {
|
|
|
36330
36381
|
const [names, setNames] = useState103({});
|
|
36331
36382
|
const titleField = table.data?.title_field ?? null;
|
|
36332
36383
|
const key = ids.join("|");
|
|
36384
|
+
const reads = useReadRefusal("record_read");
|
|
36385
|
+
const [attempt, again] = useReadAgain();
|
|
36333
36386
|
useEffect92(() => {
|
|
36334
36387
|
let live = true;
|
|
36335
|
-
void Promise.all(
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
})
|
|
36340
|
-
|
|
36341
|
-
|
|
36388
|
+
void Promise.all(ids.map(async (id) => [id, await askWithOneRetry(() => client.recordRead({ record_id: id }))])).then((pairs) => {
|
|
36389
|
+
if (!live) return;
|
|
36390
|
+
const refused = pairs.find(([, got]) => !got.ok);
|
|
36391
|
+
if (refused) reads.take(refused[1], again);
|
|
36392
|
+
else reads.take({ ok: true, data: null }, again);
|
|
36393
|
+
setNames(
|
|
36394
|
+
Object.fromEntries(
|
|
36395
|
+
pairs.flatMap(([id, got]) => got.ok ? [[id, recordName(got.data.document, titleField, "Untitled")]] : [])
|
|
36396
|
+
)
|
|
36397
|
+
);
|
|
36342
36398
|
});
|
|
36343
36399
|
return () => {
|
|
36344
36400
|
live = false;
|
|
36345
36401
|
};
|
|
36346
|
-
}, [client, key, titleField]);
|
|
36402
|
+
}, [client, key, titleField, attempt]);
|
|
36347
36403
|
return names;
|
|
36348
36404
|
}
|
|
36349
36405
|
function AgentAnswer({
|
|
@@ -36519,7 +36575,13 @@ function CsvButton({ name, fields, rows }) {
|
|
|
36519
36575
|
function sameRows(had, rows) {
|
|
36520
36576
|
return had === rows || had !== void 0 && had.length === 0 && rows.length === 0;
|
|
36521
36577
|
}
|
|
36522
|
-
function PageCanvas(
|
|
36578
|
+
function PageCanvas(props) {
|
|
36579
|
+
return /* @__PURE__ */ jsxs108(Fragment50, { children: [
|
|
36580
|
+
/* @__PURE__ */ jsx115(PageCanvasBody, { ...props }),
|
|
36581
|
+
/* @__PURE__ */ jsx115(ReadRefusalDock, {})
|
|
36582
|
+
] });
|
|
36583
|
+
}
|
|
36584
|
+
function PageCanvasBody({ blocks, charts, run, subject, viewerUserId, editing, canEdit, onSave, onChart }) {
|
|
36523
36585
|
const [selected, setSelected] = useState104({});
|
|
36524
36586
|
const [listRows, setListRows] = useState104({});
|
|
36525
36587
|
const [filterValues, setFilterValues] = useState104({});
|
|
@@ -36598,6 +36660,10 @@ function useMemberQuestion(block, viewerUserId, extra, mineOn, enabled = true) {
|
|
|
36598
36660
|
const fields = useFields31(enabled ? block.table_id : null);
|
|
36599
36661
|
const all = useMemo64(() => onePerKey3(fields.data ?? []), [fields.data]);
|
|
36600
36662
|
const [view, setView] = useState104(block.view_id ? "reading" : null);
|
|
36663
|
+
const viewReads = useReadRefusal("views");
|
|
36664
|
+
const [viewAttempt, viewAgain] = useReadAgain();
|
|
36665
|
+
const meReads = useReadRefusal("me_record");
|
|
36666
|
+
const [meAttempt, meAgain] = useReadAgain();
|
|
36601
36667
|
useEffect93(() => {
|
|
36602
36668
|
if (!block.view_id || !enabled) {
|
|
36603
36669
|
setView(null);
|
|
@@ -36605,15 +36671,16 @@ function useMemberQuestion(block, viewerUserId, extra, mineOn, enabled = true) {
|
|
|
36605
36671
|
}
|
|
36606
36672
|
let live = true;
|
|
36607
36673
|
setView("reading");
|
|
36608
|
-
void client.views({ table_id: block.table_id }).then((answered) => {
|
|
36674
|
+
void askWithOneRetry(() => client.views({ table_id: block.table_id })).then((answered) => {
|
|
36609
36675
|
if (!live) return;
|
|
36610
|
-
|
|
36676
|
+
if (!viewReads.take(answered, viewAgain)) return setView(null);
|
|
36677
|
+
const row = answered.data.find((v) => v.view_id === block.view_id);
|
|
36611
36678
|
setView(row ? viewFromRow(row) : null);
|
|
36612
36679
|
});
|
|
36613
36680
|
return () => {
|
|
36614
36681
|
live = false;
|
|
36615
36682
|
};
|
|
36616
|
-
}, [client, block.table_id, block.view_id, enabled]);
|
|
36683
|
+
}, [client, block.table_id, block.view_id, enabled, viewAttempt]);
|
|
36617
36684
|
const mine = mineOn || block.me_only === true;
|
|
36618
36685
|
const meField = block.me_field ? all.find((f) => f.key === block.me_field) : void 0;
|
|
36619
36686
|
const [me, setMe] = useState104(null);
|
|
@@ -36624,13 +36691,14 @@ function useMemberQuestion(block, viewerUserId, extra, mineOn, enabled = true) {
|
|
|
36624
36691
|
}
|
|
36625
36692
|
let live = true;
|
|
36626
36693
|
setMe("reading");
|
|
36627
|
-
void client.list({ table_id: meField.relation_target, filter: { user_id: viewerUserId }, limit: 1 }).then((answered) => {
|
|
36628
|
-
if (live)
|
|
36694
|
+
void askWithOneRetry(() => client.list({ table_id: meField.relation_target, filter: { user_id: viewerUserId }, limit: 1 })).then((answered) => {
|
|
36695
|
+
if (!live) return;
|
|
36696
|
+
setMe({ id: meReads.take(answered, meAgain) ? answered.data.rows[0]?.id ?? null : null });
|
|
36629
36697
|
});
|
|
36630
36698
|
return () => {
|
|
36631
36699
|
live = false;
|
|
36632
36700
|
};
|
|
36633
|
-
}, [client, enabled, mine, meField?.relation_target, viewerUserId]);
|
|
36701
|
+
}, [client, enabled, mine, meField?.relation_target, viewerUserId, meAttempt]);
|
|
36634
36702
|
const own = {
|
|
36635
36703
|
...Object.fromEntries(Object.entries(block.filter ?? {}).filter(([, v]) => v !== null && v !== void 0)),
|
|
36636
36704
|
...extra
|
|
@@ -38349,8 +38417,16 @@ function controlFor(field) {
|
|
|
38349
38417
|
if (field.type === "range" || field.parity_type === "currency" || field.parity_type === "percent") {
|
|
38350
38418
|
return "number";
|
|
38351
38419
|
}
|
|
38420
|
+
const config = field.config;
|
|
38421
|
+
if (field.type === "long_text" || field.format === "long" || config?.multiline === true) return "paragraph";
|
|
38352
38422
|
return "text";
|
|
38353
38423
|
}
|
|
38424
|
+
function askFor(question, field) {
|
|
38425
|
+
const own = question.ask?.trim();
|
|
38426
|
+
if (own) return own;
|
|
38427
|
+
const label = field?.label?.trim();
|
|
38428
|
+
return label ? label : question.field;
|
|
38429
|
+
}
|
|
38354
38430
|
function deviceName() {
|
|
38355
38431
|
const nav = globalThis.navigator;
|
|
38356
38432
|
if (!nav?.userAgent) return "unknown device";
|
|
@@ -38442,10 +38518,13 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
38442
38518
|
}, [client, given, sheetId]);
|
|
38443
38519
|
const questions = useMemo67(() => {
|
|
38444
38520
|
const asked2 = face?.presentation?.questions ?? [];
|
|
38445
|
-
|
|
38446
|
-
|
|
38521
|
+
const fields = face?.fields ?? [];
|
|
38522
|
+
if (asked2.length > 0) {
|
|
38523
|
+
return asked2.map((x) => ({ ...x, ask: askFor(x, fields.find((f) => f.key === x.field)) }));
|
|
38524
|
+
}
|
|
38525
|
+
return fields.map((f) => ({
|
|
38447
38526
|
field: f.key,
|
|
38448
|
-
ask:
|
|
38527
|
+
ask: askFor({ field: f.key }, f),
|
|
38449
38528
|
help: null,
|
|
38450
38529
|
required: f.required
|
|
38451
38530
|
}));
|
|
@@ -38666,13 +38745,26 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
38666
38745
|
setMissing(null);
|
|
38667
38746
|
}
|
|
38668
38747
|
}
|
|
38748
|
+
) : control === "text" ? /* @__PURE__ */ jsx119(
|
|
38749
|
+
Input7,
|
|
38750
|
+
{
|
|
38751
|
+
id: `capture-${q.field}`,
|
|
38752
|
+
"data-testid": `capture-input-${q.field}`,
|
|
38753
|
+
"aria-label": q.ask ?? q.field,
|
|
38754
|
+
className: "h-14 text-lg",
|
|
38755
|
+
value: String(answers[q.field] ?? ""),
|
|
38756
|
+
onChange: (e) => {
|
|
38757
|
+
setAnswers((held) => ({ ...held, [q.field]: e.target.value }));
|
|
38758
|
+
setMissing(null);
|
|
38759
|
+
}
|
|
38760
|
+
}
|
|
38669
38761
|
) : /* @__PURE__ */ jsx119(
|
|
38670
38762
|
Textarea6,
|
|
38671
38763
|
{
|
|
38672
38764
|
id: `capture-${q.field}`,
|
|
38673
38765
|
"data-testid": `capture-input-${q.field}`,
|
|
38674
38766
|
"aria-label": q.ask ?? q.field,
|
|
38675
|
-
rows:
|
|
38767
|
+
rows: 3,
|
|
38676
38768
|
className: "min-h-12 text-lg",
|
|
38677
38769
|
value: String(answers[q.field] ?? ""),
|
|
38678
38770
|
onChange: (e) => {
|
|
@@ -41169,11 +41261,16 @@ function TablePage({
|
|
|
41169
41261
|
};
|
|
41170
41262
|
const actionOrigin = actionHost?.origin ?? (typeof window !== "undefined" ? window.location.origin : void 0);
|
|
41171
41263
|
const makeDefaultReason = !view ? "No saved view yet" : layoutShowing !== null && layoutShowing === opensAs ? "Already the default" : "This layout can't be the default";
|
|
41264
|
+
const tableSort = defaultSortOf(table.data, allFields.data ?? []);
|
|
41265
|
+
const shownSorts = gridQuery?.sort ? [{ field: gridQuery.sort.field, direction: gridQuery.sort.direction }] : shown4?.sorts && shown4.sorts.length > 0 ? shown4.sorts : shown4?.order !== "manual" && tableSort ? [{ field: tableSort.id, direction: tableSort.direction }] : shown4?.sorts;
|
|
41172
41266
|
const viewReading = {
|
|
41173
41267
|
filter: shownFilter,
|
|
41174
|
-
sorts:
|
|
41268
|
+
sorts: shownSorts,
|
|
41175
41269
|
presentation: shown4?.presentation,
|
|
41176
|
-
viewId: shown4?.order === "manual" ? shown4?.id ?? null : null
|
|
41270
|
+
viewId: shown4?.order === "manual" ? shown4?.id ?? null : null,
|
|
41271
|
+
// What she did in the grid over the view: header-menu column filters and the search box.
|
|
41272
|
+
columnFilters: gridQuery?.filters,
|
|
41273
|
+
search: gridQuery?.search
|
|
41177
41274
|
};
|
|
41178
41275
|
const subItemsLink = subItemsField(allFields.data, tableId);
|
|
41179
41276
|
const subItemsOn = subItemsLink !== null;
|
|
@@ -41949,7 +42046,8 @@ function TablePage({
|
|
|
41949
42046
|
) : null
|
|
41950
42047
|
] })
|
|
41951
42048
|
] }),
|
|
41952
|
-
embedded ? null : /* @__PURE__ */ jsx132(GridShortcutsHelp, {})
|
|
42049
|
+
embedded ? null : /* @__PURE__ */ jsx132(GridShortcutsHelp, {}),
|
|
42050
|
+
/* @__PURE__ */ jsx132(ReadRefusalDock, {})
|
|
41953
42051
|
] });
|
|
41954
42052
|
}
|
|
41955
42053
|
var PUBLIC_READ_ONLY = "Public \xB7 read only";
|
|
@@ -41957,6 +42055,8 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
|
|
|
41957
42055
|
const readOnly = rights.known && rights.read && !rights.write;
|
|
41958
42056
|
const marked = table?.published_to_web;
|
|
41959
42057
|
const [isPublic, setIsPublic] = useState121(false);
|
|
42058
|
+
const reads = useReadRefusal("table_facts");
|
|
42059
|
+
const [attempt, again] = useReadAgain();
|
|
41960
42060
|
useEffect106(() => {
|
|
41961
42061
|
if (!readOnly || !table) {
|
|
41962
42062
|
setIsPublic(false);
|
|
@@ -41967,15 +42067,16 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
|
|
|
41967
42067
|
return;
|
|
41968
42068
|
}
|
|
41969
42069
|
let live = true;
|
|
41970
|
-
void client.tableFacts(organizationId ? { organization_id: organizationId } : {}).then((answered) => {
|
|
42070
|
+
void askWithOneRetry(() => client.tableFacts(organizationId ? { organization_id: organizationId } : {})).then((answered) => {
|
|
41971
42071
|
if (!live) return;
|
|
41972
|
-
|
|
42072
|
+
if (!reads.take(answered, again)) return;
|
|
42073
|
+
const fact = (answered.data ?? []).find((f) => f.table_id === tableId);
|
|
41973
42074
|
setIsPublic(Boolean(fact && (fact.published_to_web ?? fact.visibility === "public")));
|
|
41974
42075
|
});
|
|
41975
42076
|
return () => {
|
|
41976
42077
|
live = false;
|
|
41977
42078
|
};
|
|
41978
|
-
}, [client, organizationId, tableId, readOnly, marked, table]);
|
|
42079
|
+
}, [client, organizationId, tableId, readOnly, marked, table, attempt]);
|
|
41979
42080
|
return readOnly && isPublic;
|
|
41980
42081
|
}
|
|
41981
42082
|
|