@ai-matrx/records-ui 0.115.84 → 0.115.85
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 +14 -1
- package/dist/helpers.d.cts +3 -0
- package/dist/helpers.d.ts +3 -0
- package/dist/index.cjs +3869 -3638
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3145 -2914
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +502 -281
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +444 -223
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/pickers.cjs
CHANGED
|
@@ -43,8 +43,8 @@ __export(pickers_exports, {
|
|
|
43
43
|
module.exports = __toCommonJS(pickers_exports);
|
|
44
44
|
|
|
45
45
|
// src/TablePickers.tsx
|
|
46
|
-
var
|
|
47
|
-
var
|
|
46
|
+
var import_react62 = require("react");
|
|
47
|
+
var import_react63 = require("@ai-matrx/records/react");
|
|
48
48
|
var import_design_system35 = require("@ai-matrx/design-system");
|
|
49
49
|
|
|
50
50
|
// src/askOnce.ts
|
|
@@ -691,19 +691,19 @@ function quiet(may, say) {
|
|
|
691
691
|
}
|
|
692
692
|
function useTableRights(table) {
|
|
693
693
|
const host = useRecordsUi();
|
|
694
|
-
const
|
|
695
|
-
return (0, import_react3.useMemo)(() => quiet(
|
|
694
|
+
const asked3 = useTableRightsAsked(table, host);
|
|
695
|
+
return (0, import_react3.useMemo)(() => quiet(asked3, host.sayLevelNeeded), [asked3, host.sayLevelNeeded]);
|
|
696
696
|
}
|
|
697
697
|
function useTableRightsAsked(table, host) {
|
|
698
698
|
const bound = Boolean(host.rights);
|
|
699
|
-
const
|
|
699
|
+
const asked3 = (0, import_react4.useMyLevel)(bound || !table ? null : table.id);
|
|
700
700
|
return (0, import_react3.useMemo)(() => {
|
|
701
701
|
if (!table) return NO_RIGHTS;
|
|
702
702
|
if (host.rights) return host.rights(table);
|
|
703
|
-
if (
|
|
704
|
-
const level =
|
|
703
|
+
if (asked3.loading) return tableRights(NOT_ANSWERED_YET);
|
|
704
|
+
const level = asked3.error ? null : asked3.data;
|
|
705
705
|
return tableRights(whatYouMayDoWithTable(table, level, true));
|
|
706
|
-
}, [host, table, bound,
|
|
706
|
+
}, [host, table, bound, asked3.loading, asked3.error, asked3.data]);
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
// src/ArchivedOrganizationNotice.tsx
|
|
@@ -887,9 +887,9 @@ function AddChoicesInline({ field, onAdded, disabled = false }) {
|
|
|
887
887
|
}
|
|
888
888
|
|
|
889
889
|
// src/editors.tsx
|
|
890
|
-
var
|
|
890
|
+
var import_react58 = require("react");
|
|
891
891
|
var import_records29 = require("@ai-matrx/records");
|
|
892
|
-
var
|
|
892
|
+
var import_react59 = require("@ai-matrx/records/react");
|
|
893
893
|
var import_design_system34 = require("@ai-matrx/design-system");
|
|
894
894
|
|
|
895
895
|
// src/dates.ts
|
|
@@ -2024,11 +2024,11 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
2024
2024
|
}
|
|
2025
2025
|
|
|
2026
2026
|
// src/buttonCell.tsx
|
|
2027
|
-
var
|
|
2027
|
+
var import_react51 = require("react");
|
|
2028
2028
|
var import_design_system31 = require("@ai-matrx/design-system");
|
|
2029
2029
|
var import_data_table6 = require("@ai-matrx/design-system/data-table");
|
|
2030
2030
|
var import_records27 = require("@ai-matrx/records");
|
|
2031
|
-
var
|
|
2031
|
+
var import_react52 = require("@ai-matrx/records/react");
|
|
2032
2032
|
|
|
2033
2033
|
// src/columnName.ts
|
|
2034
2034
|
var said = (name) => name.trim().replace(/\s+/g, " ");
|
|
@@ -2066,8 +2066,8 @@ function columnNameProblemLine(name, noun = "column") {
|
|
|
2066
2066
|
}
|
|
2067
2067
|
|
|
2068
2068
|
// src/FieldEditor.tsx
|
|
2069
|
-
var
|
|
2070
|
-
var
|
|
2069
|
+
var import_react49 = require("react");
|
|
2070
|
+
var import_react50 = require("@ai-matrx/records/react");
|
|
2071
2071
|
var import_core6 = require("@ai-matrx/records/core");
|
|
2072
2072
|
var import_design_system30 = require("@ai-matrx/design-system");
|
|
2073
2073
|
|
|
@@ -2571,8 +2571,8 @@ function FormulaTextEditor({
|
|
|
2571
2571
|
const report = (0, import_react16.useRef)(onChecked);
|
|
2572
2572
|
report.current = onChecked;
|
|
2573
2573
|
(0, import_react16.useEffect)(() => {
|
|
2574
|
-
const
|
|
2575
|
-
if (
|
|
2574
|
+
const asked3 = text.trim();
|
|
2575
|
+
if (asked3 === "") {
|
|
2576
2576
|
setParsed(null);
|
|
2577
2577
|
setError(null);
|
|
2578
2578
|
report.current(null);
|
|
@@ -2581,7 +2581,7 @@ function FormulaTextEditor({
|
|
|
2581
2581
|
report.current(null);
|
|
2582
2582
|
let cancelled = false;
|
|
2583
2583
|
const timer = setTimeout(() => {
|
|
2584
|
-
void client.formulaPreview({ table_id: tableId, record_id: sampled, text:
|
|
2584
|
+
void client.formulaPreview({ table_id: tableId, record_id: sampled, text: asked3 }).then((previewed) => previewed.ok ? previewed : client.formulaParse({ table_id: tableId, text: asked3 })).then((answered) => {
|
|
2585
2585
|
if (cancelled) return;
|
|
2586
2586
|
if (!answered.ok) {
|
|
2587
2587
|
setError(answered.error);
|
|
@@ -2770,9 +2770,9 @@ function EntityReferenceKindPicker({ value, onChange, locked = false, className
|
|
|
2770
2770
|
}
|
|
2771
2771
|
|
|
2772
2772
|
// src/SourceArchivedNotice.tsx
|
|
2773
|
-
var
|
|
2773
|
+
var import_react38 = require("react");
|
|
2774
2774
|
var import_design_system23 = require("@ai-matrx/design-system");
|
|
2775
|
-
var
|
|
2775
|
+
var import_react39 = require("@ai-matrx/records/react");
|
|
2776
2776
|
|
|
2777
2777
|
// src/values.tsx
|
|
2778
2778
|
var import_data_table3 = require("@ai-matrx/design-system/data-table");
|
|
@@ -2902,31 +2902,31 @@ var FILES = /* @__PURE__ */ new WeakMap();
|
|
|
2902
2902
|
function signatureFilesOf(client, recordId) {
|
|
2903
2903
|
let held = SOURCES.get(client);
|
|
2904
2904
|
if (!held) SOURCES.set(client, held = /* @__PURE__ */ new Map());
|
|
2905
|
-
let
|
|
2906
|
-
if (!
|
|
2907
|
-
|
|
2905
|
+
let asked3 = held.get(recordId);
|
|
2906
|
+
if (!asked3) {
|
|
2907
|
+
asked3 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
|
|
2908
2908
|
if (!answered.ok) return {};
|
|
2909
2909
|
return Object.fromEntries(answered.data.map((v) => [v.field_key, signatureFileOf(v.source)]));
|
|
2910
2910
|
});
|
|
2911
|
-
held.set(recordId,
|
|
2911
|
+
held.set(recordId, asked3);
|
|
2912
2912
|
}
|
|
2913
|
-
return
|
|
2913
|
+
return asked3;
|
|
2914
2914
|
}
|
|
2915
2915
|
function drawingOf(client, fileId) {
|
|
2916
2916
|
let held = FILES.get(client);
|
|
2917
2917
|
if (!held) FILES.set(client, held = /* @__PURE__ */ new Map());
|
|
2918
|
-
let
|
|
2919
|
-
if (!
|
|
2920
|
-
|
|
2918
|
+
let asked3 = held.get(fileId);
|
|
2919
|
+
if (!asked3) {
|
|
2920
|
+
asked3 = client.recordRead({ record_id: fileId }).then((answered) => {
|
|
2921
2921
|
if (!answered.ok) return { src: null, hostFileId: null };
|
|
2922
2922
|
const doc = answered.data.document ?? {};
|
|
2923
2923
|
const content = drawnSignatureOf(doc["content"]);
|
|
2924
2924
|
const hostFileId = typeof doc["file_id"] === "string" && doc["file_id"] !== "" ? doc["file_id"] : null;
|
|
2925
2925
|
return { src: content, hostFileId };
|
|
2926
2926
|
});
|
|
2927
|
-
held.set(fileId,
|
|
2927
|
+
held.set(fileId, asked3);
|
|
2928
2928
|
}
|
|
2929
|
-
return
|
|
2929
|
+
return asked3;
|
|
2930
2930
|
}
|
|
2931
2931
|
function DrawnImage({ src, inCell }) {
|
|
2932
2932
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
@@ -3169,12 +3169,12 @@ function pointsAtRecords(field) {
|
|
|
3169
3169
|
}
|
|
3170
3170
|
function RecordLabelProvider({ children }) {
|
|
3171
3171
|
const client = (0, import_react24.useRecordsClient)();
|
|
3172
|
-
const [
|
|
3172
|
+
const [names2, setNames] = (0, import_react23.useState)({});
|
|
3173
3173
|
const [archivedRefs, setArchivedRefs] = (0, import_react23.useState)({});
|
|
3174
3174
|
const [iconsOf, setIconsOf] = (0, import_react23.useState)({});
|
|
3175
3175
|
const [settled, setSettled] = (0, import_react23.useState)({});
|
|
3176
3176
|
const [waitingLines, setWaitingLines] = (0, import_react23.useState)({});
|
|
3177
|
-
const
|
|
3177
|
+
const asked3 = (0, import_react23.useRef)(/* @__PURE__ */ new Set());
|
|
3178
3178
|
const chased = (0, import_react23.useRef)(/* @__PURE__ */ new Set());
|
|
3179
3179
|
const timers = (0, import_react23.useRef)(/* @__PURE__ */ new Map());
|
|
3180
3180
|
const startWaitClock = (0, import_react23.useCallback)((field, target) => {
|
|
@@ -3212,8 +3212,8 @@ function RecordLabelProvider({ children }) {
|
|
|
3212
3212
|
const want = (0, import_react23.useCallback)(
|
|
3213
3213
|
(field) => {
|
|
3214
3214
|
if (!pointsAtRecords(field)) return;
|
|
3215
|
-
if (
|
|
3216
|
-
|
|
3215
|
+
if (asked3.current.has(field.id)) return;
|
|
3216
|
+
asked3.current.add(field.id);
|
|
3217
3217
|
startWaitClock(field, null);
|
|
3218
3218
|
void (async () => {
|
|
3219
3219
|
if (field.type === "list") {
|
|
@@ -3299,22 +3299,22 @@ function RecordLabelProvider({ children }) {
|
|
|
3299
3299
|
const lookupWords = (0, import_react23.useCallback)(
|
|
3300
3300
|
(field, id) => {
|
|
3301
3301
|
if (field.type === "list" && !isId(id)) {
|
|
3302
|
-
const named =
|
|
3302
|
+
const named = names2[choiceKeyName(field.id, id)];
|
|
3303
3303
|
if (named !== void 0) return named;
|
|
3304
3304
|
const once = choiceKeyName(field.id, id);
|
|
3305
3305
|
if (settled[field.id] && !rereadFor.current.has(once)) {
|
|
3306
3306
|
rereadFor.current.add(once);
|
|
3307
|
-
|
|
3307
|
+
asked3.current.delete(field.id);
|
|
3308
3308
|
want(field);
|
|
3309
3309
|
}
|
|
3310
3310
|
return null;
|
|
3311
3311
|
}
|
|
3312
|
-
const known =
|
|
3312
|
+
const known = names2[id];
|
|
3313
3313
|
if (known !== void 0) return known;
|
|
3314
3314
|
if (settled[field.id]) chase(field, id);
|
|
3315
3315
|
return null;
|
|
3316
3316
|
},
|
|
3317
|
-
[
|
|
3317
|
+
[names2, settled, chase, want]
|
|
3318
3318
|
);
|
|
3319
3319
|
const lookup = (0, import_react23.useMemo)(
|
|
3320
3320
|
() => {
|
|
@@ -4467,13 +4467,13 @@ var BRACE = /\{([^{}]*)\}/g;
|
|
|
4467
4467
|
function formulaTextNow(text, expr, fields) {
|
|
4468
4468
|
if (!text || !fields || fields.length === 0) return text;
|
|
4469
4469
|
const refs = fieldRefsOf(expr);
|
|
4470
|
-
const
|
|
4471
|
-
if (refs.length === 0 || refs.length !==
|
|
4470
|
+
const names2 = [...text.matchAll(BRACE)].map((m) => m[1] ?? "");
|
|
4471
|
+
if (refs.length === 0 || refs.length !== names2.length) return text;
|
|
4472
4472
|
const byId = new Map(fields.map((f) => [String(f.id), f]));
|
|
4473
4473
|
const becomes = /* @__PURE__ */ new Map();
|
|
4474
4474
|
const replacement = [];
|
|
4475
|
-
for (let i2 = 0; i2 <
|
|
4476
|
-
const name =
|
|
4475
|
+
for (let i2 = 0; i2 < names2.length; i2 += 1) {
|
|
4476
|
+
const name = names2[i2];
|
|
4477
4477
|
const field = byId.get(refs[i2]);
|
|
4478
4478
|
if (!field) return text;
|
|
4479
4479
|
const now = fieldName(field);
|
|
@@ -4503,10 +4503,58 @@ function formulaSourceArchived(field, document2) {
|
|
|
4503
4503
|
// src/values.tsx
|
|
4504
4504
|
var import_records18 = require("@ai-matrx/records");
|
|
4505
4505
|
|
|
4506
|
-
// src/
|
|
4506
|
+
// src/userIds.ts
|
|
4507
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4508
|
+
var PERSON_NOT_IN_ORGANIZATION = "A person no longer in this organization";
|
|
4509
|
+
function isUserId(value) {
|
|
4510
|
+
return typeof value === "string" && UUID.test(value);
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
// src/personNames.ts
|
|
4507
4514
|
var import_react33 = require("react");
|
|
4515
|
+
var names = /* @__PURE__ */ new Map();
|
|
4516
|
+
var asked = /* @__PURE__ */ new Set();
|
|
4517
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
4518
|
+
var version = 0;
|
|
4519
|
+
var resolver = null;
|
|
4520
|
+
var opener = null;
|
|
4521
|
+
async function openStoredPerson(id, open) {
|
|
4522
|
+
if (!open) return;
|
|
4523
|
+
const who = opener ? await opener(id) : null;
|
|
4524
|
+
open(who ?? { recordId: id });
|
|
4525
|
+
}
|
|
4526
|
+
function bump() {
|
|
4527
|
+
version += 1;
|
|
4528
|
+
for (const l of listeners) l();
|
|
4529
|
+
}
|
|
4530
|
+
function rememberPerson(id, name) {
|
|
4531
|
+
const key = id.toLowerCase();
|
|
4532
|
+
if (names.get(key) === name) return;
|
|
4533
|
+
names.set(key, name);
|
|
4534
|
+
bump();
|
|
4535
|
+
}
|
|
4536
|
+
function knownPerson(id) {
|
|
4537
|
+
const key = id.toLowerCase();
|
|
4538
|
+
const held = names.get(key);
|
|
4539
|
+
if (held !== void 0) return held;
|
|
4540
|
+
if (resolver && !asked.has(key)) {
|
|
4541
|
+
asked.add(key);
|
|
4542
|
+
const run = resolver;
|
|
4543
|
+
void run(id).then((name) => {
|
|
4544
|
+
if (name) rememberPerson(key, name);
|
|
4545
|
+
}).catch(() => asked.delete(key));
|
|
4546
|
+
}
|
|
4547
|
+
return null;
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
// src/memberNames.ts
|
|
4551
|
+
var import_react36 = require("react");
|
|
4552
|
+
var import_react37 = require("@ai-matrx/records/react");
|
|
4553
|
+
|
|
4554
|
+
// src/PersonPicker.tsx
|
|
4555
|
+
var import_react34 = require("react");
|
|
4508
4556
|
var import_records17 = require("@ai-matrx/records");
|
|
4509
|
-
var
|
|
4557
|
+
var import_react35 = require("@ai-matrx/records/react");
|
|
4510
4558
|
var import_design_system21 = require("@ai-matrx/design-system");
|
|
4511
4559
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4512
4560
|
function personFromRow(row) {
|
|
@@ -4539,27 +4587,27 @@ async function personRecordForMember(client, personTableId, people, member) {
|
|
|
4539
4587
|
return written;
|
|
4540
4588
|
}
|
|
4541
4589
|
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
4542
|
-
const client = (0,
|
|
4590
|
+
const client = (0, import_react35.useOptionalRecordsClient)();
|
|
4543
4591
|
const host = useRecordsUi();
|
|
4544
|
-
const [members, setMembers] = (0,
|
|
4545
|
-
const [people, setPeople] = (0,
|
|
4546
|
-
const [error, setError] = (0,
|
|
4547
|
-
const [search, setSearch] = (0,
|
|
4548
|
-
const [open, setOpenState] = (0,
|
|
4549
|
-
const onCloseRef = (0,
|
|
4592
|
+
const [members, setMembers] = (0, import_react34.useState)(null);
|
|
4593
|
+
const [people, setPeople] = (0, import_react34.useState)([]);
|
|
4594
|
+
const [error, setError] = (0, import_react34.useState)(null);
|
|
4595
|
+
const [search, setSearch] = (0, import_react34.useState)(initialSearch ?? "");
|
|
4596
|
+
const [open, setOpenState] = (0, import_react34.useState)(autoOpen === true);
|
|
4597
|
+
const onCloseRef = (0, import_react34.useRef)(onClose);
|
|
4550
4598
|
onCloseRef.current = onClose;
|
|
4551
|
-
const setOpen = (0,
|
|
4599
|
+
const setOpen = (0, import_react34.useCallback)((next) => {
|
|
4552
4600
|
setOpenState(next);
|
|
4553
4601
|
if (!next) onCloseRef.current?.();
|
|
4554
4602
|
}, []);
|
|
4555
|
-
const [busy, setBusy] = (0,
|
|
4603
|
+
const [busy, setBusy] = (0, import_react34.useState)(false);
|
|
4556
4604
|
const membersPort = host.members;
|
|
4557
4605
|
const personTable = field.relation_target;
|
|
4558
|
-
const picked = (0,
|
|
4606
|
+
const picked = (0, import_react34.useMemo)(
|
|
4559
4607
|
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
4560
4608
|
[value]
|
|
4561
4609
|
);
|
|
4562
|
-
const load = (0,
|
|
4610
|
+
const load = (0, import_react34.useCallback)(async () => {
|
|
4563
4611
|
if (!membersPort || !client) return;
|
|
4564
4612
|
const [roster, records] = await Promise.all([
|
|
4565
4613
|
membersPort(),
|
|
@@ -4572,11 +4620,11 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
|
|
|
4572
4620
|
}
|
|
4573
4621
|
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
4574
4622
|
}, [membersPort, client, personTable]);
|
|
4575
|
-
(0,
|
|
4623
|
+
(0, import_react34.useEffect)(() => {
|
|
4576
4624
|
if (!open) return;
|
|
4577
4625
|
void load();
|
|
4578
4626
|
}, [open, load]);
|
|
4579
|
-
(0,
|
|
4627
|
+
(0, import_react34.useEffect)(() => {
|
|
4580
4628
|
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
4581
4629
|
let cancelled = false;
|
|
4582
4630
|
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
@@ -4689,6 +4737,49 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
|
|
|
4689
4737
|
] });
|
|
4690
4738
|
}
|
|
4691
4739
|
|
|
4740
|
+
// src/memberNames.ts
|
|
4741
|
+
function memberWords(member) {
|
|
4742
|
+
const name = member?.name?.trim();
|
|
4743
|
+
if (name) return name;
|
|
4744
|
+
const email = member?.email?.trim();
|
|
4745
|
+
return email ? email : null;
|
|
4746
|
+
}
|
|
4747
|
+
function useMemberRoster() {
|
|
4748
|
+
const host = useRecordsUi();
|
|
4749
|
+
const members = host.members;
|
|
4750
|
+
const [roster, setRoster] = (0, import_react36.useState)(null);
|
|
4751
|
+
(0, import_react36.useEffect)(() => {
|
|
4752
|
+
if (!members) {
|
|
4753
|
+
setRoster(/* @__PURE__ */ new Map());
|
|
4754
|
+
return;
|
|
4755
|
+
}
|
|
4756
|
+
let cancelled = false;
|
|
4757
|
+
void members().then((list) => !cancelled && setRoster(new Map(list.map((m) => [m.userId.toLowerCase(), m])))).catch(() => !cancelled && setRoster(/* @__PURE__ */ new Map()));
|
|
4758
|
+
return () => {
|
|
4759
|
+
cancelled = true;
|
|
4760
|
+
};
|
|
4761
|
+
}, [members]);
|
|
4762
|
+
return roster;
|
|
4763
|
+
}
|
|
4764
|
+
async function resolveKeptPerson(client, id, roster) {
|
|
4765
|
+
if (client) {
|
|
4766
|
+
try {
|
|
4767
|
+
const read = await client.recordRead({ record_id: id });
|
|
4768
|
+
if (read.ok) {
|
|
4769
|
+
const person = personFromRow({ id, document: read.data.document });
|
|
4770
|
+
const member = person.userId ? roster.get(person.userId.toLowerCase()) : void 0;
|
|
4771
|
+
const named = memberWords(member) ?? (person.name !== "" ? person.name : null);
|
|
4772
|
+
const doc = read.data.document ?? {};
|
|
4773
|
+
const email = (typeof doc["email"] === "string" && doc["email"].trim() !== "" ? doc["email"].trim() : null) ?? member?.email?.trim() ?? null;
|
|
4774
|
+
if (person.userId || named) return { id, recordId: id, name: named ?? PERSON_NOT_IN_ORGANIZATION, userId: person.userId, email };
|
|
4775
|
+
}
|
|
4776
|
+
} catch {
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
const direct = roster.get(id.toLowerCase());
|
|
4780
|
+
return { id, recordId: null, name: memberWords(direct) ?? PERSON_NOT_IN_ORGANIZATION, userId: direct ? id : null, email: direct?.email?.trim() || null };
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4692
4783
|
// src/values.tsx
|
|
4693
4784
|
var import_outbound_react5 = require("@ai-matrx/kit/outbound-react");
|
|
4694
4785
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
@@ -4778,7 +4869,7 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4778
4869
|
}
|
|
4779
4870
|
if (kind === "member") {
|
|
4780
4871
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4781
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-person-chips": "", children: ids.map((id, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-person-chips": "", children: ids.map((id, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(LivePersonChip, { id: String(id), name: scalarText(field, id, labels, stillWaitingFor) }, `${String(id)}-${i}`)) });
|
|
4782
4873
|
}
|
|
4783
4874
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4784
4875
|
if (kv) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KindValueCell, { kv, where: "cell", title: field.label });
|
|
@@ -4850,6 +4941,20 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4850
4941
|
}
|
|
4851
4942
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: (0, import_design_system22.cn)("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
|
|
4852
4943
|
}
|
|
4944
|
+
function LivePersonChip({ id, name }) {
|
|
4945
|
+
const open = useRecordsUi().openPerson;
|
|
4946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PersonChip, { name, ...open ? { onOpen: () => void openStoredPerson(id, open) } : {} });
|
|
4947
|
+
}
|
|
4948
|
+
var NEVER_AN_ID_KINDS = /* @__PURE__ */ new Set(["member", "person", "number", "currency", "percent", "date", "datetime", "checkbox", "boolean"]);
|
|
4949
|
+
function personWordsOf(kind, value) {
|
|
4950
|
+
const items = Array.isArray(value) ? value : [value];
|
|
4951
|
+
const ids = items.filter(isUserId);
|
|
4952
|
+
if (ids.length === 0) return null;
|
|
4953
|
+
const wordsColumn = !NEVER_AN_ID_KINDS.has(kind);
|
|
4954
|
+
const named = ids.map((id) => knownPerson(id));
|
|
4955
|
+
if (wordsColumn && named.some((n) => n === null)) return null;
|
|
4956
|
+
return named.map((n) => n ?? PERSON_NOT_IN_ORGANIZATION).join(", ");
|
|
4957
|
+
}
|
|
4853
4958
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4854
4959
|
if (value === null || value === void 0) return "\u2014";
|
|
4855
4960
|
if ((0, import_records18.sourceArchivedOf)(value)) return SOURCE_ARCHIVED_WORDS;
|
|
@@ -4867,6 +4972,8 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4867
4972
|
if (isId(value) && (field.type === "list" || field.type === "relation")) {
|
|
4868
4973
|
return labels?.(field, String(value)) ?? stillWaitingFor ?? "Loading\u2026";
|
|
4869
4974
|
}
|
|
4975
|
+
const personal = personWordsOf(kind, value);
|
|
4976
|
+
if (personal !== null) return personal;
|
|
4870
4977
|
if (field.type === "list" && typeof value === "string" && labels) {
|
|
4871
4978
|
const words = labels(field, value);
|
|
4872
4979
|
if (words) return words;
|
|
@@ -4896,16 +5003,16 @@ function bringBackLabel(state2) {
|
|
|
4896
5003
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4897
5004
|
}
|
|
4898
5005
|
function SourceArchivedNotice({ fieldId, tableId }) {
|
|
4899
|
-
const client = (0,
|
|
4900
|
-
const [state2, setState] = (0,
|
|
4901
|
-
const [busy, setBusy] = (0,
|
|
4902
|
-
const [refused, setRefused] = (0,
|
|
4903
|
-
const read = (0,
|
|
5006
|
+
const client = (0, import_react39.useRecordsClient)();
|
|
5007
|
+
const [state2, setState] = (0, import_react38.useState)(null);
|
|
5008
|
+
const [busy, setBusy] = (0, import_react38.useState)(false);
|
|
5009
|
+
const [refused, setRefused] = (0, import_react38.useState)(null);
|
|
5010
|
+
const read = (0, import_react38.useCallback)(async () => {
|
|
4904
5011
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4905
5012
|
if (answer.ok) setState(answer.data);
|
|
4906
5013
|
else setRefused(answer.error);
|
|
4907
5014
|
}, [client, fieldId]);
|
|
4908
|
-
(0,
|
|
5015
|
+
(0, import_react38.useEffect)(() => {
|
|
4909
5016
|
void read();
|
|
4910
5017
|
}, [read]);
|
|
4911
5018
|
if (refused && !state2) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: refused });
|
|
@@ -4920,8 +5027,8 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4920
5027
|
setRefused(done.error);
|
|
4921
5028
|
return;
|
|
4922
5029
|
}
|
|
4923
|
-
if (state2.table_id) (0,
|
|
4924
|
-
(0,
|
|
5030
|
+
if (state2.table_id) (0, import_react39.tableShapeChanged)(state2.table_id);
|
|
5031
|
+
(0, import_react39.tableShapeChanged)(tableId);
|
|
4925
5032
|
await read();
|
|
4926
5033
|
};
|
|
4927
5034
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
@@ -4943,13 +5050,13 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4943
5050
|
}
|
|
4944
5051
|
|
|
4945
5052
|
// src/Condition.tsx
|
|
4946
|
-
var
|
|
5053
|
+
var import_react41 = require("react");
|
|
4947
5054
|
var import_design_system24 = require("@ai-matrx/design-system");
|
|
4948
5055
|
var import_records19 = require("@ai-matrx/records");
|
|
4949
|
-
var
|
|
5056
|
+
var import_react42 = require("@ai-matrx/records/react");
|
|
4950
5057
|
|
|
4951
5058
|
// src/personTime.ts
|
|
4952
|
-
var
|
|
5059
|
+
var import_react40 = require("react");
|
|
4953
5060
|
|
|
4954
5061
|
// src/personZone.ts
|
|
4955
5062
|
var import_table_style3 = require("@ai-matrx/design-system/data-table/table-style");
|
|
@@ -4986,7 +5093,7 @@ function personWallNow(at = /* @__PURE__ */ new Date()) {
|
|
|
4986
5093
|
|
|
4987
5094
|
// src/personTime.ts
|
|
4988
5095
|
function usePersonTimeZone() {
|
|
4989
|
-
return (0,
|
|
5096
|
+
return (0, import_react40.useSyncExternalStore)(
|
|
4990
5097
|
subscribePersonTimeZone,
|
|
4991
5098
|
getPersonTimeZone,
|
|
4992
5099
|
() => null
|
|
@@ -5031,7 +5138,7 @@ function linkedOf(expr) {
|
|
|
5031
5138
|
if (match !== "any" && match !== "none") return null;
|
|
5032
5139
|
return { via: rel["field"], inner: a["field"], op: match === "any" ? "eq" : "ne", value: b["const"] };
|
|
5033
5140
|
}
|
|
5034
|
-
var FilterTermsContext = (0,
|
|
5141
|
+
var FilterTermsContext = (0, import_react41.createContext)(false);
|
|
5035
5142
|
var RELATIVE_DAY_TERMS = [
|
|
5036
5143
|
{ kind: "today", label: "is today" },
|
|
5037
5144
|
{ kind: "tomorrow", label: "is tomorrow" },
|
|
@@ -5082,11 +5189,11 @@ function isChoiceColumn(f) {
|
|
|
5082
5189
|
return kind === "select" || kind === "multi_select";
|
|
5083
5190
|
}
|
|
5084
5191
|
function ChoiceValue({ field, value, onChange }) {
|
|
5085
|
-
const client = (0,
|
|
5086
|
-
const [choices, setChoices] = (0,
|
|
5087
|
-
const [open, setOpen] = (0,
|
|
5088
|
-
const [search, setSearch] = (0,
|
|
5089
|
-
(0,
|
|
5192
|
+
const client = (0, import_react42.useOptionalRecordsClient)();
|
|
5193
|
+
const [choices, setChoices] = (0, import_react41.useState)(null);
|
|
5194
|
+
const [open, setOpen] = (0, import_react41.useState)(false);
|
|
5195
|
+
const [search, setSearch] = (0, import_react41.useState)("");
|
|
5196
|
+
(0, import_react41.useEffect)(() => {
|
|
5090
5197
|
if (!client) return;
|
|
5091
5198
|
let cancelled = false;
|
|
5092
5199
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
@@ -5231,7 +5338,7 @@ function conditionValue(typed) {
|
|
|
5231
5338
|
}
|
|
5232
5339
|
function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
|
|
5233
5340
|
const node = expr ?? null;
|
|
5234
|
-
const filterTerms = (0,
|
|
5341
|
+
const filterTerms = (0, import_react41.useContext)(FilterTermsContext);
|
|
5235
5342
|
const relative = relativeDayOf(expr);
|
|
5236
5343
|
const reader = meOf(expr);
|
|
5237
5344
|
const linked = linkedOf(expr);
|
|
@@ -5416,7 +5523,7 @@ function ConditionGroup({
|
|
|
5416
5523
|
className
|
|
5417
5524
|
}) {
|
|
5418
5525
|
const { joiner, args } = clausesOf(expr);
|
|
5419
|
-
const [drafting, setDrafting] = (0,
|
|
5526
|
+
const [drafting, setDrafting] = (0, import_react41.useState)(null);
|
|
5420
5527
|
const nested = depth > 0;
|
|
5421
5528
|
const replaceAt = (index, next) => {
|
|
5422
5529
|
const nextArgs = args.slice();
|
|
@@ -5543,10 +5650,73 @@ function ConditionGroup({
|
|
|
5543
5650
|
}
|
|
5544
5651
|
|
|
5545
5652
|
// src/FieldRetype.tsx
|
|
5546
|
-
var
|
|
5653
|
+
var import_react43 = require("react");
|
|
5547
5654
|
var import_records20 = require("@ai-matrx/records");
|
|
5548
|
-
var
|
|
5655
|
+
var import_react44 = require("@ai-matrx/records/react");
|
|
5549
5656
|
var import_design_system25 = require("@ai-matrx/design-system");
|
|
5657
|
+
|
|
5658
|
+
// src/personRetype.ts
|
|
5659
|
+
var PAGE = 500;
|
|
5660
|
+
var CEILING = 2e4;
|
|
5661
|
+
function idsIn(value) {
|
|
5662
|
+
return (Array.isArray(value) ? value : [value]).filter(isUserId);
|
|
5663
|
+
}
|
|
5664
|
+
async function readPersonColumn(client, tableId, key) {
|
|
5665
|
+
const out = [];
|
|
5666
|
+
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5667
|
+
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5668
|
+
if (!page.ok) throw new Error(page.error.message ?? "The records could not be read");
|
|
5669
|
+
for (const row of page.data.rows) {
|
|
5670
|
+
const doc = row.document ?? {};
|
|
5671
|
+
let ids = idsIn(doc[key]);
|
|
5672
|
+
if (ids.length === 0 && Array.isArray(doc["_retired"])) {
|
|
5673
|
+
const kept = doc["_retired"].filter((e) => e.key === key);
|
|
5674
|
+
const last = kept[kept.length - 1];
|
|
5675
|
+
if (last) ids = idsIn(last.value);
|
|
5676
|
+
}
|
|
5677
|
+
if (ids.length > 0) out.push({ recordId: row.id, ids });
|
|
5678
|
+
}
|
|
5679
|
+
if (page.data.rows.length < PAGE) break;
|
|
5680
|
+
}
|
|
5681
|
+
return out;
|
|
5682
|
+
}
|
|
5683
|
+
async function resolvePeople(client, rows, roster) {
|
|
5684
|
+
const distinct = [...new Set(rows.flatMap((r) => r.ids))];
|
|
5685
|
+
const people = await Promise.all(distinct.map((id) => resolveKeptPerson(client, id, roster)));
|
|
5686
|
+
return new Map(people.map((p) => [p.id, p]));
|
|
5687
|
+
}
|
|
5688
|
+
function wordsFor(ids, people, as) {
|
|
5689
|
+
const said2 = ids.map((id) => as === "name" ? people.get(id)?.name : people.get(id)?.email).filter((w) => typeof w === "string" && w.trim() !== "" && !w.startsWith("A person no longer"));
|
|
5690
|
+
return said2.length > 0 ? said2.join(", ") : null;
|
|
5691
|
+
}
|
|
5692
|
+
function previewPersonWords(rows, people, as) {
|
|
5693
|
+
let converts = 0;
|
|
5694
|
+
let keptAside = 0;
|
|
5695
|
+
const examples = [];
|
|
5696
|
+
for (const row of rows) {
|
|
5697
|
+
if (wordsFor(row.ids, people, as) !== null) converts += 1;
|
|
5698
|
+
else {
|
|
5699
|
+
keptAside += 1;
|
|
5700
|
+
const who = people.get(row.ids[0] ?? "")?.name;
|
|
5701
|
+
if (who && examples.length < 5 && !examples.includes(who)) examples.push(who);
|
|
5702
|
+
}
|
|
5703
|
+
}
|
|
5704
|
+
return { converts, keptAside, examples, partial: false };
|
|
5705
|
+
}
|
|
5706
|
+
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5707
|
+
const changes = [];
|
|
5708
|
+
for (const row of rows) {
|
|
5709
|
+
const words = wordsFor(row.ids, people, as);
|
|
5710
|
+
if (words !== null) changes.push({ op: "update", record_id: row.recordId, patch: { [key]: words } });
|
|
5711
|
+
}
|
|
5712
|
+
for (let i = 0; i < changes.length; i += 100) {
|
|
5713
|
+
const done = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5714
|
+
if (!done.ok) throw new Error(done.error.message ?? "The words could not be written");
|
|
5715
|
+
}
|
|
5716
|
+
return changes.length;
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
// src/FieldRetype.tsx
|
|
5550
5720
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5551
5721
|
var RETYPE_TARGETS = [
|
|
5552
5722
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
@@ -5570,6 +5740,7 @@ var RETYPE_TARGETS = [
|
|
|
5570
5740
|
];
|
|
5571
5741
|
var PREVIEW_GROUPS = 1e3;
|
|
5572
5742
|
function retypeableFrom(field) {
|
|
5743
|
+
if (isPersonField(field)) return true;
|
|
5573
5744
|
const behaviour = String(field.type);
|
|
5574
5745
|
return behaviour === "text" || behaviour === "range" || behaviour === "boolean";
|
|
5575
5746
|
}
|
|
@@ -5584,7 +5755,11 @@ function whyNotRetypeable(field) {
|
|
|
5584
5755
|
}
|
|
5585
5756
|
return "Its kind is not changed here.";
|
|
5586
5757
|
}
|
|
5758
|
+
function isPersonField(field) {
|
|
5759
|
+
return String(editorKindFor(field)) === "member";
|
|
5760
|
+
}
|
|
5587
5761
|
function currentTarget(field) {
|
|
5762
|
+
if (isPersonField(field)) return "person";
|
|
5588
5763
|
const kind = String(editorKindFor(field));
|
|
5589
5764
|
if (String(field.type) === "boolean") return "checkbox";
|
|
5590
5765
|
if (kind === "datetime" || kind === "date") return "date";
|
|
@@ -5592,23 +5767,51 @@ function currentTarget(field) {
|
|
|
5592
5767
|
if (String(field.type) === "range") return "number";
|
|
5593
5768
|
return "text";
|
|
5594
5769
|
}
|
|
5770
|
+
function failure(e, fallback) {
|
|
5771
|
+
return { code: "internal", message: e instanceof Error && e.message ? e.message : fallback };
|
|
5772
|
+
}
|
|
5595
5773
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5596
|
-
const client = (0,
|
|
5774
|
+
const client = (0, import_react44.useRecordsClient)();
|
|
5597
5775
|
const notify = useRecordsUi().notify;
|
|
5598
|
-
const [to, setTo] = (0,
|
|
5599
|
-
const [preview, setPreview] = (0,
|
|
5600
|
-
const [asking, setAsking] = (0,
|
|
5601
|
-
const [refusal, setRefusal] = (0,
|
|
5602
|
-
const [busy, setBusy] = (0,
|
|
5603
|
-
const [said2, setSaid] = (0,
|
|
5776
|
+
const [to, setTo] = (0, import_react43.useState)(null);
|
|
5777
|
+
const [preview, setPreview] = (0, import_react43.useState)(null);
|
|
5778
|
+
const [asking, setAsking] = (0, import_react43.useState)(false);
|
|
5779
|
+
const [refusal, setRefusal] = (0, import_react43.useState)(null);
|
|
5780
|
+
const [busy, setBusy] = (0, import_react43.useState)(false);
|
|
5781
|
+
const [said2, setSaid] = (0, import_react43.useState)(null);
|
|
5782
|
+
const roster = useMemberRoster();
|
|
5783
|
+
const person = isPersonField(field);
|
|
5784
|
+
const [read, setRead] = (0, import_react43.useState)(null);
|
|
5604
5785
|
const name = fieldName(field);
|
|
5605
5786
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5606
|
-
(0,
|
|
5787
|
+
(0, import_react43.useEffect)(() => {
|
|
5607
5788
|
if (!to) return;
|
|
5608
5789
|
let cancelled = false;
|
|
5609
5790
|
setPreview(null);
|
|
5610
5791
|
setRefusal(null);
|
|
5611
5792
|
setAsking(true);
|
|
5793
|
+
if (person) {
|
|
5794
|
+
if (!roster) return;
|
|
5795
|
+
void readPersonColumn(client, tableId, field.key).then(async (rows) => {
|
|
5796
|
+
const people = await resolvePeople(client, rows, roster);
|
|
5797
|
+
if (cancelled) return;
|
|
5798
|
+
setRead({ rows, people });
|
|
5799
|
+
setAsking(false);
|
|
5800
|
+
if (to.id === "text" || to.id === "email") {
|
|
5801
|
+
setPreview(previewPersonWords(rows, people, to.id === "email" ? "email" : "name"));
|
|
5802
|
+
return;
|
|
5803
|
+
}
|
|
5804
|
+
const groups = rows.map((r) => ({ value: r.ids.map((id) => people.get(id)?.name ?? "").join(", "), count: 1 }));
|
|
5805
|
+
setPreview((0, import_records20.previewRetype)({ type: to.behaviour, kind: to.kind }, groups, false));
|
|
5806
|
+
}).catch((e) => {
|
|
5807
|
+
if (cancelled) return;
|
|
5808
|
+
setAsking(false);
|
|
5809
|
+
setRefusal(failure(e, "The people could not be read"));
|
|
5810
|
+
});
|
|
5811
|
+
return () => {
|
|
5812
|
+
cancelled = true;
|
|
5813
|
+
};
|
|
5814
|
+
}
|
|
5612
5815
|
void client.recordAggregate({ table_id: tableId, groupBy: [field.key], measures: [{ op: "count" }], limit: PREVIEW_GROUPS }).then((answer) => {
|
|
5613
5816
|
if (cancelled) return;
|
|
5614
5817
|
setAsking(false);
|
|
@@ -5622,7 +5825,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5622
5825
|
return () => {
|
|
5623
5826
|
cancelled = true;
|
|
5624
5827
|
};
|
|
5625
|
-
}, [client, tableId, field.key, to]);
|
|
5828
|
+
}, [client, tableId, field.key, to, person, roster]);
|
|
5626
5829
|
if (!retypeableFrom(field)) {
|
|
5627
5830
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[11px] text-muted-foreground", "data-records-retype": "not-here", children: whyNotRetypeable(field) });
|
|
5628
5831
|
}
|
|
@@ -5659,18 +5862,36 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5659
5862
|
undo: async () => {
|
|
5660
5863
|
const back = await client.migrateUndo({ migration_id: migration });
|
|
5661
5864
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5662
|
-
(
|
|
5865
|
+
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5866
|
+
const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }));
|
|
5867
|
+
for (let i = 0; i < changes.length; i += 100) {
|
|
5868
|
+
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5869
|
+
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5872
|
+
(0, import_react44.tableShapeChanged)(tableId);
|
|
5663
5873
|
onRetyped?.();
|
|
5664
5874
|
}
|
|
5665
5875
|
});
|
|
5666
5876
|
}
|
|
5667
5877
|
}
|
|
5878
|
+
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5879
|
+
const as = to.id === "email" ? "email" : "name";
|
|
5880
|
+
try {
|
|
5881
|
+
const written = await writePersonWords(client, tableId, read.rows, read.people, field.key, as);
|
|
5882
|
+
holding = written;
|
|
5883
|
+
aside = read.rows.length - written;
|
|
5884
|
+
} catch (e) {
|
|
5885
|
+
setRefusal(failure(e, "The words could not be written"));
|
|
5886
|
+
return;
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5668
5889
|
setSaid(
|
|
5669
5890
|
`${name} now holds ${to.holds}. ${holding} ${holding === 1 ? "record holds" : "records hold"} a value` + (aside > 0 ? `; ${aside} ${aside === 1 ? "value that did not fit was" : "values that did not fit were"} kept with ${aside === 1 ? "its record" : "their records"}, with the reason.` : ".")
|
|
5670
5891
|
);
|
|
5671
5892
|
setTo(null);
|
|
5672
5893
|
setPreview(null);
|
|
5673
|
-
(0,
|
|
5894
|
+
(0, import_react44.tableShapeChanged)(tableId);
|
|
5674
5895
|
onRetyped?.();
|
|
5675
5896
|
};
|
|
5676
5897
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
|
|
@@ -5702,9 +5923,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5702
5923
|
}
|
|
5703
5924
|
|
|
5704
5925
|
// src/FieldRulePreview.tsx
|
|
5705
|
-
var
|
|
5926
|
+
var import_react45 = require("react");
|
|
5706
5927
|
var import_records21 = require("@ai-matrx/records");
|
|
5707
|
-
var
|
|
5928
|
+
var import_react46 = require("@ai-matrx/records/react");
|
|
5708
5929
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
5709
5930
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5710
5931
|
function ruleWords(rules) {
|
|
@@ -5722,14 +5943,14 @@ function groupValue(value, numbers) {
|
|
|
5722
5943
|
return /^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(text) ? Number(text) : value;
|
|
5723
5944
|
}
|
|
5724
5945
|
function FieldRulePreview({ field, tableId, rules }) {
|
|
5725
|
-
const client = (0,
|
|
5726
|
-
const [preview, setPreview] = (0,
|
|
5727
|
-
const [refusal, setRefusal] = (0,
|
|
5728
|
-
const key = (0,
|
|
5729
|
-
const latest = (0,
|
|
5946
|
+
const client = (0, import_react46.useRecordsClient)();
|
|
5947
|
+
const [preview, setPreview] = (0, import_react45.useState)(null);
|
|
5948
|
+
const [refusal, setRefusal] = (0, import_react45.useState)(null);
|
|
5949
|
+
const key = (0, import_react45.useMemo)(() => ruleWords(rules), [rules]);
|
|
5950
|
+
const latest = (0, import_react45.useRef)(rules);
|
|
5730
5951
|
latest.current = rules;
|
|
5731
5952
|
const name = fieldName(field);
|
|
5732
|
-
(0,
|
|
5953
|
+
(0, import_react45.useEffect)(() => {
|
|
5733
5954
|
let cancelled = false;
|
|
5734
5955
|
setPreview(null);
|
|
5735
5956
|
setRefusal(null);
|
|
@@ -6251,11 +6472,11 @@ function nextFieldSort(fields) {
|
|
|
6251
6472
|
var import_records25 = require("@ai-matrx/records");
|
|
6252
6473
|
|
|
6253
6474
|
// src/ButtonSettings.tsx
|
|
6254
|
-
var
|
|
6475
|
+
var import_react47 = require("react");
|
|
6255
6476
|
var import_design_system29 = require("@ai-matrx/design-system");
|
|
6256
6477
|
var import_data_table5 = require("@ai-matrx/design-system/data-table");
|
|
6257
6478
|
var import_records24 = require("@ai-matrx/records");
|
|
6258
|
-
var
|
|
6479
|
+
var import_react48 = require("@ai-matrx/records/react");
|
|
6259
6480
|
|
|
6260
6481
|
// src/AccentSwatches.tsx
|
|
6261
6482
|
var import_records23 = require("@ai-matrx/records");
|
|
@@ -6316,11 +6537,11 @@ function ButtonSettingsEditor({
|
|
|
6316
6537
|
tableId,
|
|
6317
6538
|
fields
|
|
6318
6539
|
}) {
|
|
6319
|
-
const client = (0,
|
|
6320
|
-
const [actions, setActions] = (0,
|
|
6321
|
-
const [actionsRefused, setActionsRefused] = (0,
|
|
6322
|
-
const [automations, setAutomations] = (0,
|
|
6323
|
-
(0,
|
|
6540
|
+
const client = (0, import_react48.useOptionalRecordsClient)();
|
|
6541
|
+
const [actions, setActions] = (0, import_react47.useState)(null);
|
|
6542
|
+
const [actionsRefused, setActionsRefused] = (0, import_react47.useState)(null);
|
|
6543
|
+
const [automations, setAutomations] = (0, import_react47.useState)(null);
|
|
6544
|
+
(0, import_react47.useEffect)(() => {
|
|
6324
6545
|
if (!client || !tableId) return;
|
|
6325
6546
|
let live = true;
|
|
6326
6547
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6452,12 +6673,12 @@ function NewRowAction({
|
|
|
6452
6673
|
columns,
|
|
6453
6674
|
onMade
|
|
6454
6675
|
}) {
|
|
6455
|
-
const client = (0,
|
|
6676
|
+
const client = (0, import_react48.useOptionalRecordsClient)();
|
|
6456
6677
|
const settable = settableColumns(columns);
|
|
6457
|
-
const [fieldId, setFieldId] = (0,
|
|
6458
|
-
const [setTo, setSetTo] = (0,
|
|
6459
|
-
const [busy, setBusy] = (0,
|
|
6460
|
-
const [refused, setRefused] = (0,
|
|
6678
|
+
const [fieldId, setFieldId] = (0, import_react47.useState)("");
|
|
6679
|
+
const [setTo, setSetTo] = (0, import_react47.useState)("");
|
|
6680
|
+
const [busy, setBusy] = (0, import_react47.useState)(false);
|
|
6681
|
+
const [refused, setRefused] = (0, import_react47.useState)(null);
|
|
6461
6682
|
if (settable.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
|
|
6462
6683
|
const make = async () => {
|
|
6463
6684
|
if (!client || fieldId === "") return;
|
|
@@ -6600,16 +6821,16 @@ function FieldEditor(props) {
|
|
|
6600
6821
|
const entityToken = props.entityToken ?? null;
|
|
6601
6822
|
const onEntity = entityToken !== null;
|
|
6602
6823
|
const tableId = props.tableId ?? "";
|
|
6603
|
-
const table = (0,
|
|
6604
|
-
const tableFields = (0,
|
|
6605
|
-
const entityFields = (0,
|
|
6824
|
+
const table = (0, import_react50.useTable)(onEntity ? null : tableId);
|
|
6825
|
+
const tableFields = (0, import_react50.useFields)(onEntity ? null : tableId);
|
|
6826
|
+
const entityFields = (0, import_react50.useEntityFields)(entityToken);
|
|
6606
6827
|
const fields = onEntity ? entityFields : tableFields;
|
|
6607
6828
|
const tableRights2 = useTableRights(onEntity ? null : table.data);
|
|
6608
|
-
const entityRights = (0,
|
|
6609
|
-
const tableMutation = (0,
|
|
6610
|
-
const entityMutation = (0,
|
|
6829
|
+
const entityRights = (0, import_react50.useEntityFieldRights)(entityToken);
|
|
6830
|
+
const tableMutation = (0, import_react50.useFieldMutation)();
|
|
6831
|
+
const entityMutation = (0, import_react50.useEntityFieldMutation)();
|
|
6611
6832
|
const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
|
|
6612
|
-
const client = (0,
|
|
6833
|
+
const client = (0, import_react50.useRecordsClient)();
|
|
6613
6834
|
const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
|
|
6614
6835
|
const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
|
|
6615
6836
|
const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
|
|
@@ -6619,33 +6840,33 @@ function FieldEditor(props) {
|
|
|
6619
6840
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6620
6841
|
const start = field ?? copyOf;
|
|
6621
6842
|
const startAs = start ? void 0 : props.startAs;
|
|
6622
|
-
const [label, setLabel] = (0,
|
|
6623
|
-
const [type, setType] = (0,
|
|
6624
|
-
const [required, setRequired] = (0,
|
|
6625
|
-
const [multi, setMulti] = (0,
|
|
6626
|
-
const [dated, setDated] = (0,
|
|
6627
|
-
const [sensitivity, setSensitivity] = (0,
|
|
6628
|
-
const [contextPolicy, setContextPolicy] = (0,
|
|
6629
|
-
const [rules, setRules] = (0,
|
|
6630
|
-
const [startsWith, setStartsWith] = (0,
|
|
6631
|
-
const [ratingMax, setRatingMax] = (0,
|
|
6632
|
-
const savedRules = (0,
|
|
6843
|
+
const [label, setLabel] = (0, import_react49.useState)(field?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
|
|
6844
|
+
const [type, setType] = (0, import_react49.useState)(() => startAs ? startAs.type : startingType(start));
|
|
6845
|
+
const [required, setRequired] = (0, import_react49.useState)(start?.required ?? false);
|
|
6846
|
+
const [multi, setMulti] = (0, import_react49.useState)(start?.multi ?? false);
|
|
6847
|
+
const [dated, setDated] = (0, import_react49.useState)(start?.dated ?? false);
|
|
6848
|
+
const [sensitivity, setSensitivity] = (0, import_react49.useState)(String(start?.sensitivity ?? "internal"));
|
|
6849
|
+
const [contextPolicy, setContextPolicy] = (0, import_react49.useState)(String(start?.context_policy ?? "include"));
|
|
6850
|
+
const [rules, setRules] = (0, import_react49.useState)(start?.rules ?? []);
|
|
6851
|
+
const [startsWith, setStartsWith] = (0, import_react49.useState)(start?.default ?? null);
|
|
6852
|
+
const [ratingMax, setRatingMax] = (0, import_react49.useState)(() => start ? (0, import_records26.ratingMaxOf)(start) : 5);
|
|
6853
|
+
const savedRules = (0, import_react49.useMemo)(
|
|
6633
6854
|
() => field ? type === "rating" ? (0, import_records26.rulesWithTopStar)(field.rules ?? [], (0, import_records26.ratingMaxOf)(field)) : field.rules ?? [] : [],
|
|
6634
6855
|
[field, type]
|
|
6635
6856
|
);
|
|
6636
|
-
const editedRules = (0,
|
|
6637
|
-
const [statusGroups, setStatusGroups] = (0,
|
|
6638
|
-
const [statusKeys, setStatusKeys] = (0,
|
|
6639
|
-
const [symbology, setSymbology] = (0,
|
|
6857
|
+
const editedRules = (0, import_react49.useMemo)(() => type === "rating" ? (0, import_records26.rulesWithTopStar)(rules, ratingMax) : rules, [type, rules, ratingMax]);
|
|
6858
|
+
const [statusGroups, setStatusGroups] = (0, import_react49.useState)({});
|
|
6859
|
+
const [statusKeys, setStatusKeys] = (0, import_react49.useState)({});
|
|
6860
|
+
const [symbology, setSymbology] = (0, import_react49.useState)(String(start?.config?.["symbology"] ?? ""));
|
|
6640
6861
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
6641
|
-
const [description, setDescription] = (0,
|
|
6642
|
-
const buttonStart = (0,
|
|
6643
|
-
const [buttonSettings, setButtonSettings] = (0,
|
|
6862
|
+
const [description, setDescription] = (0, import_react49.useState)(descriptionStart);
|
|
6863
|
+
const buttonStart = (0, import_react49.useMemo)(() => (0, import_records25.buttonOf)(start) ?? { label: "" }, [start]);
|
|
6864
|
+
const [buttonSettings, setButtonSettings] = (0, import_react49.useState)(buttonStart);
|
|
6644
6865
|
const prefixStart = (0, import_records25.autonumberPrefixOf)(start);
|
|
6645
|
-
const [numberPrefix, setNumberPrefix] = (0,
|
|
6866
|
+
const [numberPrefix, setNumberPrefix] = (0, import_react49.useState)(prefixStart);
|
|
6646
6867
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6647
|
-
const [dependency, setDependency] = (0,
|
|
6648
|
-
(0,
|
|
6868
|
+
const [dependency, setDependency] = (0, import_react49.useState)(dependencyStart);
|
|
6869
|
+
(0, import_react49.useEffect)(() => {
|
|
6649
6870
|
if (!field || type !== "status") return;
|
|
6650
6871
|
let live = true;
|
|
6651
6872
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
@@ -6655,20 +6876,20 @@ function FieldEditor(props) {
|
|
|
6655
6876
|
live = false;
|
|
6656
6877
|
};
|
|
6657
6878
|
}, [client, field, type]);
|
|
6658
|
-
(0,
|
|
6879
|
+
(0, import_react49.useEffect)(() => {
|
|
6659
6880
|
if (field || type !== "status") return;
|
|
6660
6881
|
setNewChoices(
|
|
6661
6882
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6662
6883
|
);
|
|
6663
6884
|
}, [field, type]);
|
|
6664
|
-
(0,
|
|
6885
|
+
(0, import_react49.useEffect)(() => {
|
|
6665
6886
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6666
6887
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6667
6888
|
}, [field, type]);
|
|
6668
|
-
const [allowOther, setAllowOther] = (0,
|
|
6669
|
-
const [newChoices, setNewChoices] = (0,
|
|
6889
|
+
const [allowOther, setAllowOther] = (0, import_react49.useState)(start?.config?.["allow_other"] === true);
|
|
6890
|
+
const [newChoices, setNewChoices] = (0, import_react49.useState)([]);
|
|
6670
6891
|
const copyOfId = copyOf?.id ?? null;
|
|
6671
|
-
(0,
|
|
6892
|
+
(0, import_react49.useEffect)(() => {
|
|
6672
6893
|
if (!copyOf || !copyOfId) return;
|
|
6673
6894
|
let live = true;
|
|
6674
6895
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6680,53 +6901,53 @@ function FieldEditor(props) {
|
|
|
6680
6901
|
live = false;
|
|
6681
6902
|
};
|
|
6682
6903
|
}, [client, copyOfId]);
|
|
6683
|
-
const [choiceList, setChoiceList] = (0,
|
|
6684
|
-
const [choiceListStart, setChoiceListStart] = (0,
|
|
6685
|
-
const [rehome, setRehome] = (0,
|
|
6686
|
-
const [rehomed, setRehomed] = (0,
|
|
6687
|
-
const [rehomeRefused, setRehomeRefused] = (0,
|
|
6688
|
-
const [unit, setUnit] = (0,
|
|
6689
|
-
const [withTime, setWithTime] = (0,
|
|
6690
|
-
const [via, setVia] = (0,
|
|
6691
|
-
const [pick, setPick] = (0,
|
|
6692
|
-
const [agg, setAgg] = (0,
|
|
6904
|
+
const [choiceList, setChoiceList] = (0, import_react49.useState)(null);
|
|
6905
|
+
const [choiceListStart, setChoiceListStart] = (0, import_react49.useState)(null);
|
|
6906
|
+
const [rehome, setRehome] = (0, import_react49.useState)({});
|
|
6907
|
+
const [rehomed, setRehomed] = (0, import_react49.useState)(null);
|
|
6908
|
+
const [rehomeRefused, setRehomeRefused] = (0, import_react49.useState)(null);
|
|
6909
|
+
const [unit, setUnit] = (0, import_react49.useState)(start?.unit ?? "$");
|
|
6910
|
+
const [withTime, setWithTime] = (0, import_react49.useState)(String(start?.config?.["kind"] ?? "date") === "datetime");
|
|
6911
|
+
const [via, setVia] = (0, import_react49.useState)(String(start?.config?.["via"] ?? ""));
|
|
6912
|
+
const [pick, setPick] = (0, import_react49.useState)(String(start?.config?.["pick"] ?? ""));
|
|
6913
|
+
const [agg, setAgg] = (0, import_react49.useState)(
|
|
6693
6914
|
start?.config?.["agg"] ?? "count"
|
|
6694
6915
|
);
|
|
6695
|
-
const [of, setOf] = (0,
|
|
6916
|
+
const [of, setOf] = (0, import_react49.useState)(String(start?.config?.["of"] ?? ""));
|
|
6696
6917
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6697
|
-
const [rollupFilter, setRollupFilter] = (0,
|
|
6918
|
+
const [rollupFilter, setRollupFilter] = (0, import_react49.useState)(
|
|
6698
6919
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6699
6920
|
);
|
|
6700
6921
|
const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
|
|
6701
|
-
const [relationTarget, setRelationTarget] = (0,
|
|
6702
|
-
const [showOnOther, setShowOnOther] = (0,
|
|
6703
|
-
const [nestsSubItems, setNestsSubItems] = (0,
|
|
6704
|
-
const [reverseRefused, setReverseRefused] = (0,
|
|
6705
|
-
const otherTable = (0,
|
|
6706
|
-
const [display, setDisplay] = (0,
|
|
6707
|
-
const [formulaOp, setFormulaOp] = (0,
|
|
6708
|
-
const [formulaFields, setFormulaFields] = (0,
|
|
6709
|
-
const [formulaSeparator, setFormulaSeparator] = (0,
|
|
6710
|
-
const [allowedTypes, setAllowedTypes] = (0,
|
|
6922
|
+
const [relationTarget, setRelationTarget] = (0, import_react49.useState)(String(start?.relation_target ?? ""));
|
|
6923
|
+
const [showOnOther, setShowOnOther] = (0, import_react49.useState)(true);
|
|
6924
|
+
const [nestsSubItems, setNestsSubItems] = (0, import_react49.useState)(false);
|
|
6925
|
+
const [reverseRefused, setReverseRefused] = (0, import_react49.useState)(null);
|
|
6926
|
+
const otherTable = (0, import_react50.useTable)(!field && type === "relation" && relationTarget !== "" ? relationTarget : null);
|
|
6927
|
+
const [display, setDisplay] = (0, import_react49.useState)(start?.display ?? null);
|
|
6928
|
+
const [formulaOp, setFormulaOp] = (0, import_react49.useState)(() => formulaOpOf(start));
|
|
6929
|
+
const [formulaFields, setFormulaFields] = (0, import_react49.useState)(() => formulaFieldIdsOf(start));
|
|
6930
|
+
const [formulaSeparator, setFormulaSeparator] = (0, import_react49.useState)(() => formulaSeparatorOf(start));
|
|
6931
|
+
const [allowedTypes, setAllowedTypes] = (0, import_react49.useState)(() => entityReferenceKindsOf(start));
|
|
6711
6932
|
const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
|
|
6712
|
-
const [formulaText, setFormulaText] = (0,
|
|
6713
|
-
const shownFormula = (0,
|
|
6714
|
-
(0,
|
|
6933
|
+
const [formulaText, setFormulaText] = (0, import_react49.useState)(startingFormulaText);
|
|
6934
|
+
const shownFormula = (0, import_react49.useRef)(startingFormulaText);
|
|
6935
|
+
(0, import_react49.useEffect)(() => {
|
|
6715
6936
|
if (shownFormula.current === startingFormulaText) return;
|
|
6716
6937
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6717
6938
|
shownFormula.current = startingFormulaText;
|
|
6718
6939
|
}, [startingFormulaText]);
|
|
6719
|
-
const [formulaWritten, setFormulaWritten] = (0,
|
|
6720
|
-
const [formulaOk, setFormulaOk] = (0,
|
|
6721
|
-
const [askingToRemove, setAskingToRemove] = (0,
|
|
6722
|
-
const [attempted, setAttempted] = (0,
|
|
6723
|
-
const [showsAs, setShowsAs] = (0,
|
|
6724
|
-
const [backfillError, setBackfillError] = (0,
|
|
6725
|
-
const [notLanded, setNotLanded] = (0,
|
|
6940
|
+
const [formulaWritten, setFormulaWritten] = (0, import_react49.useState)(() => startingFormulaText.trim() !== "" || Boolean(field) || startAs?.type === "formula");
|
|
6941
|
+
const [formulaOk, setFormulaOk] = (0, import_react49.useState)(null);
|
|
6942
|
+
const [askingToRemove, setAskingToRemove] = (0, import_react49.useState)(false);
|
|
6943
|
+
const [attempted, setAttempted] = (0, import_react49.useState)(false);
|
|
6944
|
+
const [showsAs, setShowsAs] = (0, import_react49.useState)(() => start ? startingChoice(start) : { format: null, retype: null });
|
|
6945
|
+
const [backfillError, setBackfillError] = (0, import_react49.useState)(null);
|
|
6946
|
+
const [notLanded, setNotLanded] = (0, import_react49.useState)(false);
|
|
6726
6947
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6727
6948
|
const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
|
|
6728
|
-
const seededAs = (0,
|
|
6729
|
-
(0,
|
|
6949
|
+
const seededAs = (0, import_react49.useRef)(heldAs);
|
|
6950
|
+
(0, import_react49.useEffect)(() => {
|
|
6730
6951
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6731
6952
|
seededAs.current = heldAs;
|
|
6732
6953
|
setType(startingType(liveField));
|
|
@@ -6735,24 +6956,24 @@ function FieldEditor(props) {
|
|
|
6735
6956
|
setUnit(liveField.unit ?? "$");
|
|
6736
6957
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6737
6958
|
}, [heldAs]);
|
|
6738
|
-
const others = (0,
|
|
6959
|
+
const others = (0, import_react49.useMemo)(
|
|
6739
6960
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6740
6961
|
[fields.data, field?.id]
|
|
6741
6962
|
);
|
|
6742
|
-
const relations = (0,
|
|
6743
|
-
const reverse = (0,
|
|
6744
|
-
const backLinks = (0,
|
|
6745
|
-
const totalSources = (0,
|
|
6963
|
+
const relations = (0, import_react49.useMemo)(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
|
|
6964
|
+
const reverse = (0, import_react50.useReverseColumns)(onEntity ? null : tableId);
|
|
6965
|
+
const backLinks = (0, import_react49.useMemo)(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
|
|
6966
|
+
const totalSources = (0, import_react49.useMemo)(() => [...relations, ...backLinks], [relations, backLinks]);
|
|
6746
6967
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6747
6968
|
const choice = fieldTypeChoice(type);
|
|
6748
6969
|
const editing = Boolean(field);
|
|
6749
|
-
(0,
|
|
6970
|
+
(0, import_react49.useEffect)(() => {
|
|
6750
6971
|
if (!editing) setStartsWith(null);
|
|
6751
6972
|
}, [type, editing]);
|
|
6752
6973
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6753
|
-
const farFieldsOfLink = (0,
|
|
6754
|
-
const farTable = (0,
|
|
6755
|
-
const linkReaders = (0,
|
|
6974
|
+
const farFieldsOfLink = (0, import_react50.useFields)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6975
|
+
const farTable = (0, import_react50.useTable)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6976
|
+
const linkReaders = (0, import_react49.useMemo)(
|
|
6756
6977
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6757
6978
|
[field, farFieldsOfLink.data]
|
|
6758
6979
|
);
|
|
@@ -6848,7 +7069,7 @@ function FieldEditor(props) {
|
|
|
6848
7069
|
setRehomeRefused(done.error);
|
|
6849
7070
|
return;
|
|
6850
7071
|
}
|
|
6851
|
-
(0,
|
|
7072
|
+
(0, import_react50.tableShapeChanged)(tableId);
|
|
6852
7073
|
for (const c of done.data.undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
6853
7074
|
const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
|
|
6854
7075
|
setRehome({});
|
|
@@ -6923,7 +7144,7 @@ function FieldEditor(props) {
|
|
|
6923
7144
|
if (newDefault !== null && newColumnDefaultGoes(type) === "right-after") {
|
|
6924
7145
|
const defaulted = await client.fieldUpdate({ field_id: written, patch: { default: newDefault } });
|
|
6925
7146
|
if (!defaulted.ok) {
|
|
6926
|
-
(0,
|
|
7147
|
+
(0, import_react50.tableShapeChanged)(tableId);
|
|
6927
7148
|
setBackfillError(defaulted.error);
|
|
6928
7149
|
return;
|
|
6929
7150
|
}
|
|
@@ -6949,7 +7170,7 @@ function FieldEditor(props) {
|
|
|
6949
7170
|
setReverseRefused(made.error);
|
|
6950
7171
|
return;
|
|
6951
7172
|
}
|
|
6952
|
-
(0,
|
|
7173
|
+
(0, import_react50.tableShapeChanged)(relationTarget);
|
|
6953
7174
|
}
|
|
6954
7175
|
setReverseRefused(null);
|
|
6955
7176
|
onSaved?.();
|
|
@@ -7362,7 +7583,7 @@ function FieldEditor(props) {
|
|
|
7362
7583
|
setRehomeRefused(back.error);
|
|
7363
7584
|
return;
|
|
7364
7585
|
}
|
|
7365
|
-
(0,
|
|
7586
|
+
(0, import_react50.tableShapeChanged)(tableId);
|
|
7366
7587
|
for (const c of undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
7367
7588
|
setChoiceList(null);
|
|
7368
7589
|
setChoiceListStart(null);
|
|
@@ -7707,13 +7928,13 @@ function RollupFilterQuestion({
|
|
|
7707
7928
|
onChange
|
|
7708
7929
|
}) {
|
|
7709
7930
|
const far = relation?.relation_target ?? null;
|
|
7710
|
-
const farFields = (0,
|
|
7711
|
-
const conditionFields = (0,
|
|
7931
|
+
const farFields = (0, import_react50.useFields)(far);
|
|
7932
|
+
const conditionFields = (0, import_react49.useMemo)(
|
|
7712
7933
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7713
7934
|
[farFields.data]
|
|
7714
7935
|
);
|
|
7715
|
-
const lastFar = (0,
|
|
7716
|
-
(0,
|
|
7936
|
+
const lastFar = (0, import_react49.useRef)(far);
|
|
7937
|
+
(0, import_react49.useEffect)(() => {
|
|
7717
7938
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7718
7939
|
lastFar.current = far;
|
|
7719
7940
|
}, [far, editing, onChange]);
|
|
@@ -7746,9 +7967,9 @@ function ValueOnTheOtherSide({
|
|
|
7746
7967
|
compact
|
|
7747
7968
|
}) {
|
|
7748
7969
|
const target = relation?.relation_target ?? null;
|
|
7749
|
-
const columns = (0,
|
|
7970
|
+
const columns = (0, import_react50.useFields)(target);
|
|
7750
7971
|
const declared = (columns.data ?? []).filter((f) => f.type !== "formula");
|
|
7751
|
-
const sample = (0,
|
|
7972
|
+
const sample = (0, import_react50.useRecords)(declared.length === 0 && !columns.loading ? target : null, { pageSize: 1 });
|
|
7752
7973
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7753
7974
|
const offered = declared.length > 0 ? declared.map((f) => ({ key: f.key, name: fieldName(f) })) : Object.keys(carried ?? {}).map((key) => ({ key, name: (0, import_text_case4.humanizeIdentifier)(key) }));
|
|
7754
7975
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
@@ -7822,11 +8043,11 @@ function buttonPressWords(label, pressed) {
|
|
|
7822
8043
|
}
|
|
7823
8044
|
var stop = (event) => event.stopPropagation();
|
|
7824
8045
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7825
|
-
const client = (0,
|
|
8046
|
+
const client = (0, import_react52.useOptionalRecordsClient)();
|
|
7826
8047
|
const b = (0, import_records27.buttonOf)(field);
|
|
7827
|
-
const [busy, setBusy] = (0,
|
|
7828
|
-
const [said2, setSaid] = (0,
|
|
7829
|
-
const [settingUp, setSettingUp] = (0,
|
|
8048
|
+
const [busy, setBusy] = (0, import_react51.useState)(false);
|
|
8049
|
+
const [said2, setSaid] = (0, import_react51.useState)(null);
|
|
8050
|
+
const [settingUp, setSettingUp] = (0, import_react51.useState)(false);
|
|
7830
8051
|
if (!b) return null;
|
|
7831
8052
|
const color = (0, import_data_table6.isStyleColor)(b.color) ? import_data_table6.CHOICE_CHIP_CLASS[b.color] : import_data_table6.NEUTRAL_CHIP_CLASS;
|
|
7832
8053
|
const needs = (0, import_records27.buttonNeeds)(b);
|
|
@@ -7908,7 +8129,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7908
8129
|
}
|
|
7909
8130
|
|
|
7910
8131
|
// src/FloatingRefusal.tsx
|
|
7911
|
-
var
|
|
8132
|
+
var import_react53 = require("react");
|
|
7912
8133
|
var import_react_dom = require("react-dom");
|
|
7913
8134
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7914
8135
|
var GAP = 4;
|
|
@@ -7926,11 +8147,11 @@ function placeFor(anchor, note) {
|
|
|
7926
8147
|
return { position: "fixed", top: a.top + (a.height - height) / 2, left: Math.max(a.left, a.right - width - 8) };
|
|
7927
8148
|
}
|
|
7928
8149
|
function FloatingRefusal({ text, why }) {
|
|
7929
|
-
const spot = (0,
|
|
7930
|
-
const note = (0,
|
|
7931
|
-
const [style, setStyle] = (0,
|
|
7932
|
-
const [floating, setFloating] = (0,
|
|
7933
|
-
(0,
|
|
8150
|
+
const spot = (0, import_react53.useRef)(null);
|
|
8151
|
+
const note = (0, import_react53.useRef)(null);
|
|
8152
|
+
const [style, setStyle] = (0, import_react53.useState)(null);
|
|
8153
|
+
const [floating, setFloating] = (0, import_react53.useState)(false);
|
|
8154
|
+
(0, import_react53.useLayoutEffect)(() => {
|
|
7934
8155
|
const here = spot.current;
|
|
7935
8156
|
if (!here) return;
|
|
7936
8157
|
const anchor = here.closest("[data-matrx-cell-editor]");
|
|
@@ -7972,7 +8193,7 @@ function FloatingRefusal({ text, why }) {
|
|
|
7972
8193
|
}
|
|
7973
8194
|
|
|
7974
8195
|
// src/formatControls.tsx
|
|
7975
|
-
var
|
|
8196
|
+
var import_react54 = require("react");
|
|
7976
8197
|
var import_design_system32 = require("@ai-matrx/design-system");
|
|
7977
8198
|
var import_field_formats7 = require("@ai-matrx/design-system/field-formats");
|
|
7978
8199
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
@@ -7992,9 +8213,9 @@ function keptValue(format, raw) {
|
|
|
7992
8213
|
return parsed;
|
|
7993
8214
|
}
|
|
7994
8215
|
function NumberInFormat({ format, value, onChange, disabled, id }) {
|
|
7995
|
-
const [text, setText] = (0,
|
|
7996
|
-
const lastSent = (0,
|
|
7997
|
-
(0,
|
|
8216
|
+
const [text, setText] = (0, import_react54.useState)(() => typedText(format, value));
|
|
8217
|
+
const lastSent = (0, import_react54.useRef)(void 0);
|
|
8218
|
+
(0, import_react54.useEffect)(() => {
|
|
7998
8219
|
if (value === lastSent.current) return;
|
|
7999
8220
|
setText(typedText(format, value));
|
|
8000
8221
|
}, [value, format]);
|
|
@@ -8068,7 +8289,7 @@ function formatControl(args) {
|
|
|
8068
8289
|
}
|
|
8069
8290
|
|
|
8070
8291
|
// src/typedDateHelper.tsx
|
|
8071
|
-
var
|
|
8292
|
+
var import_react55 = require("react");
|
|
8072
8293
|
var import_design_system33 = require("@ai-matrx/design-system");
|
|
8073
8294
|
var import_records28 = require("@ai-matrx/records");
|
|
8074
8295
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
@@ -8092,7 +8313,7 @@ function readBox(text, kind) {
|
|
|
8092
8313
|
}
|
|
8093
8314
|
return { day: read.day, time: null };
|
|
8094
8315
|
}
|
|
8095
|
-
function
|
|
8316
|
+
function wordsFor2(kind, day, time) {
|
|
8096
8317
|
if (kind === "time") return time ? (0, import_records28.typedTimeText)(time.h, time.m) : "";
|
|
8097
8318
|
if (!day) return "";
|
|
8098
8319
|
const dayText = (0, import_records28.typedDateText)(day);
|
|
@@ -8119,12 +8340,12 @@ function TypedDateHelper({
|
|
|
8119
8340
|
onPicked,
|
|
8120
8341
|
startOpen = false
|
|
8121
8342
|
}) {
|
|
8122
|
-
const [open, setOpen] = (0,
|
|
8343
|
+
const [open, setOpen] = (0, import_react55.useState)(startOpen);
|
|
8123
8344
|
const held = readBox(text, kind);
|
|
8124
8345
|
usePersonTimeZone();
|
|
8125
8346
|
const today = personWallNow();
|
|
8126
8347
|
const start = held.day ? new Date(Number(held.day.slice(0, 4)), Number(held.day.slice(5, 7)) - 1, 1) : new Date(today.getFullYear(), today.getMonth(), 1);
|
|
8127
|
-
const [month, setMonth] = (0,
|
|
8348
|
+
const [month, setMonth] = (0, import_react55.useState)(null);
|
|
8128
8349
|
const shown2 = month ?? { y: start.getFullYear(), m: start.getMonth() };
|
|
8129
8350
|
const first = new Date(shown2.y, shown2.m, 1).getDay();
|
|
8130
8351
|
const days = new Date(shown2.y, shown2.m + 1, 0).getDate();
|
|
@@ -8133,7 +8354,7 @@ function TypedDateHelper({
|
|
|
8133
8354
|
const times = Array.from({ length: 48 }, (_, i) => ({ h: Math.floor(i / 2), m: i % 2 * 30 }));
|
|
8134
8355
|
const pickDay = (d) => {
|
|
8135
8356
|
const day = `${shown2.y}-${pad(shown2.m + 1)}-${pad(d)}`;
|
|
8136
|
-
onText(
|
|
8357
|
+
onText(wordsFor2(kind, day, held.time));
|
|
8137
8358
|
if (kind === "date") {
|
|
8138
8359
|
setOpen(false);
|
|
8139
8360
|
onPicked?.();
|
|
@@ -8141,7 +8362,7 @@ function TypedDateHelper({
|
|
|
8141
8362
|
};
|
|
8142
8363
|
const pickTime = (t) => {
|
|
8143
8364
|
const day = kind === "datetime" ? held.day ?? todayKey : null;
|
|
8144
|
-
onText(
|
|
8365
|
+
onText(wordsFor2(kind, day, t));
|
|
8145
8366
|
setOpen(false);
|
|
8146
8367
|
onPicked?.();
|
|
8147
8368
|
};
|
|
@@ -8229,24 +8450,24 @@ function TypedDateHelper({
|
|
|
8229
8450
|
}
|
|
8230
8451
|
|
|
8231
8452
|
// src/choiceNudge.ts
|
|
8232
|
-
var
|
|
8233
|
-
var
|
|
8234
|
-
var
|
|
8453
|
+
var import_react56 = require("react");
|
|
8454
|
+
var import_react57 = require("@ai-matrx/records/react");
|
|
8455
|
+
var asked2 = /* @__PURE__ */ new WeakMap();
|
|
8235
8456
|
function choiceNudgeOf(client) {
|
|
8236
|
-
let answer =
|
|
8457
|
+
let answer = asked2.get(client);
|
|
8237
8458
|
if (!answer) {
|
|
8238
8459
|
answer = Promise.resolve().then(() => client.choiceNudge()).then(
|
|
8239
8460
|
(result) => result.ok ? result.data : "ask",
|
|
8240
8461
|
() => "ask"
|
|
8241
8462
|
);
|
|
8242
|
-
|
|
8463
|
+
asked2.set(client, answer);
|
|
8243
8464
|
}
|
|
8244
8465
|
return answer;
|
|
8245
8466
|
}
|
|
8246
8467
|
function useChoiceNudge(enabled = true) {
|
|
8247
|
-
const client = (0,
|
|
8248
|
-
const [nudge, setNudge] = (0,
|
|
8249
|
-
(0,
|
|
8468
|
+
const client = (0, import_react57.useOptionalRecordsClient)();
|
|
8469
|
+
const [nudge, setNudge] = (0, import_react56.useState)(null);
|
|
8470
|
+
(0, import_react56.useEffect)(() => {
|
|
8250
8471
|
if (!enabled || !client) return;
|
|
8251
8472
|
let live = true;
|
|
8252
8473
|
void choiceNudgeOf(client).then((answer) => {
|
|
@@ -8397,9 +8618,9 @@ function openingText(field, value) {
|
|
|
8397
8618
|
return format ? typedText(format, value) : String(value);
|
|
8398
8619
|
}
|
|
8399
8620
|
function ReadsAsNote({ typed, always, children }) {
|
|
8400
|
-
const note = (0,
|
|
8401
|
-
const [repeats, setRepeats] = (0,
|
|
8402
|
-
(0,
|
|
8621
|
+
const note = (0, import_react58.useRef)(null);
|
|
8622
|
+
const [repeats, setRepeats] = (0, import_react58.useState)(false);
|
|
8623
|
+
(0, import_react58.useLayoutEffect)(() => {
|
|
8403
8624
|
if (always) return;
|
|
8404
8625
|
const words = (t) => (t ?? "").replace(/^Reads as/, "").replace(/\s+/g, "").toLowerCase();
|
|
8405
8626
|
setRepeats(words(note.current?.textContent) === words(typed));
|
|
@@ -8408,12 +8629,12 @@ function ReadsAsNote({ typed, always, children }) {
|
|
|
8408
8629
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { ref: note, "data-records-typed-reads-as": "", "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children });
|
|
8409
8630
|
}
|
|
8410
8631
|
function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCancel }) {
|
|
8411
|
-
const client = (0,
|
|
8632
|
+
const client = (0, import_react59.useOptionalRecordsClient)();
|
|
8412
8633
|
const kind = String(editorKindFor(field));
|
|
8413
8634
|
const needsChoices = kind === "select" || kind === "multi_select";
|
|
8414
8635
|
const nudge = useChoiceNudge(needsChoices);
|
|
8415
|
-
const [choices, setChoices] = (0,
|
|
8416
|
-
(0,
|
|
8636
|
+
const [choices, setChoices] = (0, import_react58.useState)(null);
|
|
8637
|
+
(0, import_react58.useEffect)(() => {
|
|
8417
8638
|
if (!needsChoices || !client) return;
|
|
8418
8639
|
let cancelled = false;
|
|
8419
8640
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
|
|
@@ -8423,7 +8644,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
8423
8644
|
cancelled = true;
|
|
8424
8645
|
};
|
|
8425
8646
|
}, [client, field.id, needsChoices]);
|
|
8426
|
-
(0,
|
|
8647
|
+
(0, import_react58.useEffect)(() => {
|
|
8427
8648
|
if (choices && nudge && value.judged === null) onChange({ ...value, judged: judgeTyped(field, value.text, choices, nudge) });
|
|
8428
8649
|
}, [choices, nudge, value, field, onChange]);
|
|
8429
8650
|
const judged = value.judged;
|
|
@@ -8499,7 +8720,7 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8499
8720
|
const host = useRecordsUi();
|
|
8500
8721
|
const kind = editorKindFor(field);
|
|
8501
8722
|
const inputId = id ?? `field-${field.key}`;
|
|
8502
|
-
const ownDetails = (0,
|
|
8723
|
+
const ownDetails = (0, import_react59.useOptionalRecordsClient)() === null;
|
|
8503
8724
|
if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
|
|
8504
8725
|
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
|
|
8505
8726
|
if ((0, import_records29.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ButtonValue, { field });
|
|
@@ -8619,11 +8840,11 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8619
8840
|
}
|
|
8620
8841
|
}
|
|
8621
8842
|
function TypedWordsControl({ field, value, onChange, disabled, id }) {
|
|
8622
|
-
const [text, setText] = (0,
|
|
8623
|
-
const [refusal, setRefusal] = (0,
|
|
8624
|
-
const [why, setWhy] = (0,
|
|
8625
|
-
const sent = (0,
|
|
8626
|
-
(0,
|
|
8843
|
+
const [text, setText] = (0, import_react58.useState)(() => openingText(field, value));
|
|
8844
|
+
const [refusal, setRefusal] = (0, import_react58.useState)(null);
|
|
8845
|
+
const [why, setWhy] = (0, import_react58.useState)(void 0);
|
|
8846
|
+
const sent = (0, import_react58.useRef)(value);
|
|
8847
|
+
(0, import_react58.useEffect)(() => {
|
|
8627
8848
|
if (value === sent.current) return;
|
|
8628
8849
|
sent.current = value;
|
|
8629
8850
|
setText(openingText(field, value));
|
|
@@ -8703,8 +8924,8 @@ function CheckboxControl({ field, value, onChange, disabled, id }) {
|
|
|
8703
8924
|
}
|
|
8704
8925
|
function JsonControl({ field, value, onChange, disabled, id }) {
|
|
8705
8926
|
const initial = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
8706
|
-
const [text, setText] = (0,
|
|
8707
|
-
const [broken, setBroken] = (0,
|
|
8927
|
+
const [text, setText] = (0, import_react58.useState)(initial);
|
|
8928
|
+
const [broken, setBroken] = (0, import_react58.useState)(null);
|
|
8708
8929
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
8709
8930
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8710
8931
|
import_design_system34.BasicTextarea,
|
|
@@ -8765,11 +8986,11 @@ function inTheStoresOrder(options) {
|
|
|
8765
8986
|
return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
|
|
8766
8987
|
}
|
|
8767
8988
|
function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm, onChosen }) {
|
|
8768
|
-
const client = (0,
|
|
8769
|
-
const [options, setOptions] = (0,
|
|
8770
|
-
const [refusal, setRefusal] = (0,
|
|
8771
|
-
const [reread, setReread] = (0,
|
|
8772
|
-
(0,
|
|
8989
|
+
const client = (0, import_react59.useOptionalRecordsClient)();
|
|
8990
|
+
const [options, setOptions] = (0, import_react58.useState)(null);
|
|
8991
|
+
const [refusal, setRefusal] = (0, import_react58.useState)(null);
|
|
8992
|
+
const [reread, setReread] = (0, import_react58.useState)(0);
|
|
8993
|
+
(0, import_react58.useEffect)(() => {
|
|
8773
8994
|
if (!client) return;
|
|
8774
8995
|
let cancelled = false;
|
|
8775
8996
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
|
|
@@ -8933,18 +9154,18 @@ function OpenChoicePicker({
|
|
|
8933
9154
|
allowOther = true,
|
|
8934
9155
|
onChoicesChanged
|
|
8935
9156
|
}) {
|
|
8936
|
-
const client = (0,
|
|
9157
|
+
const client = (0, import_react59.useOptionalRecordsClient)();
|
|
8937
9158
|
const nudge = useChoiceNudge();
|
|
8938
|
-
const [open, setOpenState] = (0,
|
|
8939
|
-
const onCloseRef = (0,
|
|
9159
|
+
const [open, setOpenState] = (0, import_react58.useState)(autoOpen === true);
|
|
9160
|
+
const onCloseRef = (0, import_react58.useRef)(onClose);
|
|
8940
9161
|
onCloseRef.current = onClose;
|
|
8941
|
-
const setOpen = (0,
|
|
9162
|
+
const setOpen = (0, import_react58.useCallback)((next) => {
|
|
8942
9163
|
setOpenState(next);
|
|
8943
9164
|
if (!next) onCloseRef.current?.();
|
|
8944
9165
|
}, []);
|
|
8945
|
-
const [search, setSearch] = (0,
|
|
8946
|
-
const [adding, setAdding] = (0,
|
|
8947
|
-
const [addRefused, setAddRefused] = (0,
|
|
9166
|
+
const [search, setSearch] = (0, import_react58.useState)(initialSearch ?? "");
|
|
9167
|
+
const [adding, setAdding] = (0, import_react58.useState)(false);
|
|
9168
|
+
const [addRefused, setAddRefused] = (0, import_react58.useState)(null);
|
|
8948
9169
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
8949
9170
|
const held = withoutAddition(value);
|
|
8950
9171
|
const current = (0, import_records29.choiceValuesOf)(held.value);
|
|
@@ -9101,7 +9322,7 @@ function ChoiceAnswer({
|
|
|
9101
9322
|
isChosen,
|
|
9102
9323
|
onChosen
|
|
9103
9324
|
}) {
|
|
9104
|
-
const [search, setSearch] = (0,
|
|
9325
|
+
const [search, setSearch] = (0, import_react58.useState)("");
|
|
9105
9326
|
const held = field.multi ? (0, import_records29.choiceValuesOf)(value) : value === null || value === void 0 || value === "" ? [] : [value];
|
|
9106
9327
|
const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
|
|
9107
9328
|
const press = (choice) => {
|
|
@@ -9204,7 +9425,7 @@ function ChoiceAnswer({
|
|
|
9204
9425
|
}
|
|
9205
9426
|
|
|
9206
9427
|
// src/RecordsMount.tsx
|
|
9207
|
-
var
|
|
9428
|
+
var import_react60 = require("react");
|
|
9208
9429
|
|
|
9209
9430
|
// src/dataSource.ts
|
|
9210
9431
|
var import_global_slot2 = require("@ai-matrx/kit/global-slot");
|
|
@@ -9214,7 +9435,7 @@ function personActor(userId) {
|
|
|
9214
9435
|
var dataSources = (0, import_global_slot2.globalSlot)("ai-matrx.records-ui.data-sources", () => /* @__PURE__ */ new WeakMap());
|
|
9215
9436
|
|
|
9216
9437
|
// src/RecordsMount.tsx
|
|
9217
|
-
var
|
|
9438
|
+
var import_react61 = require("@ai-matrx/records/react");
|
|
9218
9439
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
9219
9440
|
|
|
9220
9441
|
// src/TablePickers.tsx
|
|
@@ -9250,8 +9471,8 @@ function readTablesAnywhere(dataSource) {
|
|
|
9250
9471
|
return read;
|
|
9251
9472
|
}
|
|
9252
9473
|
function useTablesAnywhere(dataSource) {
|
|
9253
|
-
const [state2, setState] = (0,
|
|
9254
|
-
(0,
|
|
9474
|
+
const [state2, setState] = (0, import_react62.useState)({ loading: true, error: null, rows: [] });
|
|
9475
|
+
(0, import_react62.useEffect)(() => {
|
|
9255
9476
|
let live = true;
|
|
9256
9477
|
void readTablesAnywhere(dataSource).then((result) => {
|
|
9257
9478
|
if (live) setState(result);
|
|
@@ -9321,14 +9542,14 @@ function TableScope({ dataSource, userId, tableId, children, fallback = null, un
|
|
|
9321
9542
|
const organizationId = list.rows.find((t) => t.table_id === tableId)?.organization_id ?? null;
|
|
9322
9543
|
if (tableId && !organizationId && !list.loading) return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: unavailable ?? fallback });
|
|
9323
9544
|
if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: fallback });
|
|
9324
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
9545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_react63.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
|
|
9325
9546
|
}
|
|
9326
9547
|
function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
|
|
9327
|
-
const fields = (0,
|
|
9328
|
-
const all = (0,
|
|
9329
|
-
const byKey = (0,
|
|
9548
|
+
const fields = (0, import_react63.useFields)(tableId);
|
|
9549
|
+
const all = (0, import_react62.useMemo)(() => fields.data ?? [], [fields.data]);
|
|
9550
|
+
const byKey = (0, import_react62.useMemo)(() => new Map(all.map((f) => [f.key, f])), [all]);
|
|
9330
9551
|
const keys = Object.keys(value);
|
|
9331
|
-
const [adding, setAdding] = (0,
|
|
9552
|
+
const [adding, setAdding] = (0, import_react62.useState)(false);
|
|
9332
9553
|
const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
|
|
9333
9554
|
const rename = (from, to) => {
|
|
9334
9555
|
if (from === to) return;
|
|
@@ -9416,8 +9637,8 @@ function ColumnValueRow({
|
|
|
9416
9637
|
] });
|
|
9417
9638
|
}
|
|
9418
9639
|
function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
9419
|
-
const table = (0,
|
|
9420
|
-
const records = (0,
|
|
9640
|
+
const table = (0, import_react63.useTable)(tableId);
|
|
9641
|
+
const records = (0, import_react63.useRecords)(tableId, { pageSize: 200 });
|
|
9421
9642
|
const rows = records.data?.rows ?? [];
|
|
9422
9643
|
const options = rows.map((row) => ({
|
|
9423
9644
|
value: row.id,
|
|
@@ -9444,9 +9665,9 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
|
9444
9665
|
}
|
|
9445
9666
|
|
|
9446
9667
|
// src/DataBindingPicker.tsx
|
|
9447
|
-
var
|
|
9668
|
+
var import_react64 = require("react");
|
|
9448
9669
|
var import_records30 = require("@ai-matrx/records");
|
|
9449
|
-
var
|
|
9670
|
+
var import_react65 = require("@ai-matrx/records/react");
|
|
9450
9671
|
var import_design_system36 = require("@ai-matrx/design-system");
|
|
9451
9672
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
9452
9673
|
var DATA_BINDING_SHAPES = [
|
|
@@ -9536,11 +9757,11 @@ function BindingDetails({
|
|
|
9536
9757
|
disabled,
|
|
9537
9758
|
defaultRowLimit
|
|
9538
9759
|
}) {
|
|
9539
|
-
const table = (0,
|
|
9540
|
-
const fields = (0,
|
|
9541
|
-
const fieldList = (0,
|
|
9760
|
+
const table = (0, import_react65.useTable)(tableId);
|
|
9761
|
+
const fields = (0, import_react65.useFields)(tableId);
|
|
9762
|
+
const fieldList = (0, import_react64.useMemo)(() => fields.data ?? [], [fields.data]);
|
|
9542
9763
|
const shape = binding.semantic_type;
|
|
9543
|
-
(0,
|
|
9764
|
+
(0, import_react64.useEffect)(() => {
|
|
9544
9765
|
if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
|
|
9545
9766
|
onChange({
|
|
9546
9767
|
...binding,
|
|
@@ -9685,7 +9906,7 @@ function BindingDetails({
|
|
|
9685
9906
|
}
|
|
9686
9907
|
|
|
9687
9908
|
// src/PickedSummaries.tsx
|
|
9688
|
-
var
|
|
9909
|
+
var import_react66 = require("@ai-matrx/records/react");
|
|
9689
9910
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
9690
9911
|
function TableNameText({ dataSource, tableId }) {
|
|
9691
9912
|
const tables = useTablesAnywhere(dataSource);
|
|
@@ -9714,7 +9935,7 @@ function ColumnValuesText({
|
|
|
9714
9935
|
);
|
|
9715
9936
|
}
|
|
9716
9937
|
function ColumnValuesWords({ tableId, value }) {
|
|
9717
|
-
const fields = (0,
|
|
9938
|
+
const fields = (0, import_react66.useFields)(tableId);
|
|
9718
9939
|
const labels = useRecordLabels(fields.data ?? void 0);
|
|
9719
9940
|
if (fields.loading) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "\u2026" });
|
|
9720
9941
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "Couldn't load this table's columns" });
|
|
@@ -9753,8 +9974,8 @@ function RecordNameText({
|
|
|
9753
9974
|
);
|
|
9754
9975
|
}
|
|
9755
9976
|
function RecordNameWords({ tableId, recordId }) {
|
|
9756
|
-
const table = (0,
|
|
9757
|
-
const record = (0,
|
|
9977
|
+
const table = (0, import_react66.useTable)(tableId);
|
|
9978
|
+
const record = (0, import_react66.useRecord)(recordId);
|
|
9758
9979
|
if (record.loading || table.loading) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "\u2026" });
|
|
9759
9980
|
if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "Couldn't load this record" });
|
|
9760
9981
|
if (!record.data) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "A record you cannot open" });
|
|
@@ -9762,23 +9983,23 @@ function RecordNameWords({ tableId, recordId }) {
|
|
|
9762
9983
|
}
|
|
9763
9984
|
|
|
9764
9985
|
// src/HeldChangeDecision.tsx
|
|
9765
|
-
var
|
|
9766
|
-
var
|
|
9986
|
+
var import_react67 = require("react");
|
|
9987
|
+
var import_react68 = require("@ai-matrx/records/react");
|
|
9767
9988
|
var import_design_system37 = require("@ai-matrx/design-system");
|
|
9768
9989
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
9769
9990
|
function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided, approveLabel }) {
|
|
9770
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
9991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_react68.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Decision, { approvalId, onDecided, approveLabel: approveLabel ?? "Approve" }) });
|
|
9771
9992
|
}
|
|
9772
9993
|
function Decision({
|
|
9773
9994
|
approvalId,
|
|
9774
9995
|
onDecided,
|
|
9775
9996
|
approveLabel
|
|
9776
9997
|
}) {
|
|
9777
|
-
const client = (0,
|
|
9778
|
-
const [may, setMay] = (0,
|
|
9779
|
-
const [busy, setBusy] = (0,
|
|
9780
|
-
const [error, setError] = (0,
|
|
9781
|
-
(0,
|
|
9998
|
+
const client = (0, import_react68.useRecordsClient)();
|
|
9999
|
+
const [may, setMay] = (0, import_react67.useState)(null);
|
|
10000
|
+
const [busy, setBusy] = (0, import_react67.useState)(null);
|
|
10001
|
+
const [error, setError] = (0, import_react67.useState)(null);
|
|
10002
|
+
(0, import_react67.useEffect)(() => {
|
|
9782
10003
|
let live = true;
|
|
9783
10004
|
void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
|
|
9784
10005
|
if (!live) return;
|