@ai-matrx/records-ui 0.115.83 → 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 +30 -0
- package/dist/helpers.d.cts +10 -0
- package/dist/helpers.d.ts +10 -0
- package/dist/index.cjs +3882 -3615
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +3437 -3170
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +1102 -879
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +993 -770
- 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
|
|
@@ -1441,7 +1441,7 @@ function PersonAvatar({ name, size = "sm" }) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
);
|
|
1443
1443
|
}
|
|
1444
|
-
function PersonChip({ name, onRemove, className }) {
|
|
1444
|
+
function PersonChip({ name, onRemove, onOpen, className }) {
|
|
1445
1445
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1446
1446
|
"span",
|
|
1447
1447
|
{
|
|
@@ -1450,7 +1450,7 @@ function PersonChip({ name, onRemove, className }) {
|
|
|
1450
1450
|
className: (0, import_design_system6.cn)("inline-flex min-w-0 max-w-full items-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-[11px] text-foreground", className),
|
|
1451
1451
|
children: [
|
|
1452
1452
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PersonAvatar, { name }),
|
|
1453
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 truncate", children: name }),
|
|
1453
|
+
onOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: onOpen, "data-records-person-open": "", className: "min-w-0 truncate hover:underline", children: name }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 truncate", children: name }),
|
|
1454
1454
|
onRemove ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: onRemove, "aria-label": `Remove ${name}`, className: "shrink-0 opacity-60 hover:opacity-100", children: "\xD7" }) : null
|
|
1455
1455
|
]
|
|
1456
1456
|
}
|
|
@@ -2024,11 +2024,11 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
2024
2024
|
}
|
|
2025
2025
|
|
|
2026
2026
|
// src/buttonCell.tsx
|
|
2027
|
-
var
|
|
2028
|
-
var
|
|
2027
|
+
var import_react51 = require("react");
|
|
2028
|
+
var import_design_system31 = require("@ai-matrx/design-system");
|
|
2029
2029
|
var import_data_table6 = require("@ai-matrx/design-system/data-table");
|
|
2030
|
-
var
|
|
2031
|
-
var
|
|
2030
|
+
var import_records27 = require("@ai-matrx/records");
|
|
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,10 +2066,10 @@ 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
|
-
var
|
|
2072
|
+
var import_design_system30 = require("@ai-matrx/design-system");
|
|
2073
2073
|
|
|
2074
2074
|
// src/ReferenceBuilder.tsx
|
|
2075
2075
|
var import_react14 = require("react");
|
|
@@ -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,14 +2770,14 @@ function EntityReferenceKindPicker({ value, onChange, locked = false, className
|
|
|
2770
2770
|
}
|
|
2771
2771
|
|
|
2772
2772
|
// src/SourceArchivedNotice.tsx
|
|
2773
|
-
var
|
|
2774
|
-
var
|
|
2775
|
-
var
|
|
2773
|
+
var import_react38 = require("react");
|
|
2774
|
+
var import_design_system23 = require("@ai-matrx/design-system");
|
|
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");
|
|
2779
2779
|
var import_field_formats4 = require("@ai-matrx/design-system/field-formats");
|
|
2780
|
-
var
|
|
2780
|
+
var import_design_system22 = require("@ai-matrx/design-system");
|
|
2781
2781
|
|
|
2782
2782
|
// src/embeddedLook.tsx
|
|
2783
2783
|
var import_react20 = require("react");
|
|
@@ -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);
|
|
@@ -4501,12 +4501,291 @@ function formulaSourceArchived(field, document2) {
|
|
|
4501
4501
|
}
|
|
4502
4502
|
|
|
4503
4503
|
// src/values.tsx
|
|
4504
|
+
var import_records18 = require("@ai-matrx/records");
|
|
4505
|
+
|
|
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
|
|
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");
|
|
4504
4556
|
var import_records17 = require("@ai-matrx/records");
|
|
4505
|
-
var
|
|
4557
|
+
var import_react35 = require("@ai-matrx/records/react");
|
|
4558
|
+
var import_design_system21 = require("@ai-matrx/design-system");
|
|
4506
4559
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4560
|
+
function personFromRow(row) {
|
|
4561
|
+
const data = row.document ?? {};
|
|
4562
|
+
const userId = data["user_id"];
|
|
4563
|
+
return {
|
|
4564
|
+
id: row.id,
|
|
4565
|
+
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
4566
|
+
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
4567
|
+
};
|
|
4568
|
+
}
|
|
4569
|
+
function memberName(member) {
|
|
4570
|
+
const display = (member.name ?? "").trim();
|
|
4571
|
+
if (display !== "") return display;
|
|
4572
|
+
const email = (member.email ?? "").trim();
|
|
4573
|
+
if (email !== "") return email;
|
|
4574
|
+
return "A member with no name set";
|
|
4575
|
+
}
|
|
4576
|
+
async function personRecordForMember(client, personTableId, people, member) {
|
|
4577
|
+
const held = people.find((p) => p.userId === member.userId);
|
|
4578
|
+
if (held) return { ok: true, data: held.id };
|
|
4579
|
+
const written = await client.recordWrite({
|
|
4580
|
+
table_id: personTableId,
|
|
4581
|
+
data: {
|
|
4582
|
+
user_id: member.userId,
|
|
4583
|
+
full_name: memberName(member),
|
|
4584
|
+
...member.email ? { email: member.email } : {}
|
|
4585
|
+
}
|
|
4586
|
+
});
|
|
4587
|
+
return written;
|
|
4588
|
+
}
|
|
4589
|
+
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
4590
|
+
const client = (0, import_react35.useOptionalRecordsClient)();
|
|
4591
|
+
const host = useRecordsUi();
|
|
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);
|
|
4598
|
+
onCloseRef.current = onClose;
|
|
4599
|
+
const setOpen = (0, import_react34.useCallback)((next) => {
|
|
4600
|
+
setOpenState(next);
|
|
4601
|
+
if (!next) onCloseRef.current?.();
|
|
4602
|
+
}, []);
|
|
4603
|
+
const [busy, setBusy] = (0, import_react34.useState)(false);
|
|
4604
|
+
const membersPort = host.members;
|
|
4605
|
+
const personTable = field.relation_target;
|
|
4606
|
+
const picked = (0, import_react34.useMemo)(
|
|
4607
|
+
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
4608
|
+
[value]
|
|
4609
|
+
);
|
|
4610
|
+
const load = (0, import_react34.useCallback)(async () => {
|
|
4611
|
+
if (!membersPort || !client) return;
|
|
4612
|
+
const [roster, records] = await Promise.all([
|
|
4613
|
+
membersPort(),
|
|
4614
|
+
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
4615
|
+
]);
|
|
4616
|
+
setMembers(roster);
|
|
4617
|
+
if (records && !records.ok) {
|
|
4618
|
+
setError(records.error);
|
|
4619
|
+
return;
|
|
4620
|
+
}
|
|
4621
|
+
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
4622
|
+
}, [membersPort, client, personTable]);
|
|
4623
|
+
(0, import_react34.useEffect)(() => {
|
|
4624
|
+
if (!open) return;
|
|
4625
|
+
void load();
|
|
4626
|
+
}, [open, load]);
|
|
4627
|
+
(0, import_react34.useEffect)(() => {
|
|
4628
|
+
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
4629
|
+
let cancelled = false;
|
|
4630
|
+
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
4631
|
+
if (cancelled || !result.ok) return;
|
|
4632
|
+
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
4633
|
+
});
|
|
4634
|
+
return () => {
|
|
4635
|
+
cancelled = true;
|
|
4636
|
+
};
|
|
4637
|
+
}, [client, personTable, picked.length, people.length]);
|
|
4638
|
+
const listed = (0, import_records17.rankTypedMatches)(members ?? [], search, memberName);
|
|
4639
|
+
if (!membersPort || !client) {
|
|
4640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: (0, import_design_system21.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
4641
|
+
}
|
|
4642
|
+
if (!personTable) {
|
|
4643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: (0, import_design_system21.cn)("text-xs text-muted-foreground", className), children: [
|
|
4644
|
+
fieldName(field),
|
|
4645
|
+
" is a person field, but it does not say which Table the people are records of yet, so there is nothing to pick from. A table admin sets its target in the field editor."
|
|
4646
|
+
] });
|
|
4647
|
+
}
|
|
4648
|
+
const displayNameOf = (userId, recordName2) => {
|
|
4649
|
+
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
4650
|
+
const own3 = (member?.name ?? "").trim();
|
|
4651
|
+
if (own3 !== "") return own3;
|
|
4652
|
+
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
4653
|
+
const email = (member?.email ?? "").trim();
|
|
4654
|
+
return kept !== "" && kept !== email ? kept : null;
|
|
4655
|
+
};
|
|
4656
|
+
const nameOfRecord = (recordId) => {
|
|
4657
|
+
const person = people.find((p) => p.id === recordId);
|
|
4658
|
+
if (!person) return "Loading\u2026";
|
|
4659
|
+
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
4660
|
+
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
4661
|
+
};
|
|
4662
|
+
const pick = async (member) => {
|
|
4663
|
+
setBusy(true);
|
|
4664
|
+
setError(null);
|
|
4665
|
+
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
4666
|
+
setBusy(false);
|
|
4667
|
+
if (!resolved.ok) {
|
|
4668
|
+
setError(resolved.error);
|
|
4669
|
+
return;
|
|
4670
|
+
}
|
|
4671
|
+
if (!people.some((p) => p.id === resolved.data)) {
|
|
4672
|
+
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
4673
|
+
}
|
|
4674
|
+
if (!field.multi) {
|
|
4675
|
+
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
4676
|
+
setOpen(false);
|
|
4677
|
+
return;
|
|
4678
|
+
}
|
|
4679
|
+
const next = new Set(picked);
|
|
4680
|
+
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
4681
|
+
else next.add(resolved.data);
|
|
4682
|
+
onChange(next.size === 0 ? null : [...next]);
|
|
4683
|
+
};
|
|
4684
|
+
const drop = (recordId) => {
|
|
4685
|
+
const next = picked.filter((id2) => id2 !== recordId);
|
|
4686
|
+
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
4687
|
+
};
|
|
4688
|
+
const visible = listed;
|
|
4689
|
+
const pickedUserIds = new Set(
|
|
4690
|
+
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
4691
|
+
);
|
|
4692
|
+
const anchored = autoOpen === true;
|
|
4693
|
+
const cellChips = picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
4694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: (0, import_design_system21.cn)("flex flex-wrap items-center gap-1", className), children: [
|
|
4695
|
+
anchored && !disabled ? null : cellChips,
|
|
4696
|
+
disabled ? null : (
|
|
4697
|
+
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
4698
|
+
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
4699
|
+
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
4700
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
4701
|
+
PickOrAdd,
|
|
4702
|
+
{
|
|
4703
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
4704
|
+
anchored,
|
|
4705
|
+
multi: field.multi,
|
|
4706
|
+
triggerId: id,
|
|
4707
|
+
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
4708
|
+
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
4709
|
+
open,
|
|
4710
|
+
onOpenChange: setOpen,
|
|
4711
|
+
search,
|
|
4712
|
+
onSearch: setSearch,
|
|
4713
|
+
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
4714
|
+
items: visible.map((member) => ({
|
|
4715
|
+
id: member.userId,
|
|
4716
|
+
label: displayNameOf(member.userId) ?? memberName(member),
|
|
4717
|
+
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
4718
|
+
// 19 September). They are two facts, so they are drawn as two.
|
|
4719
|
+
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
4720
|
+
picked: pickedUserIds.has(member.userId),
|
|
4721
|
+
person: true,
|
|
4722
|
+
disabled: busy
|
|
4723
|
+
})),
|
|
4724
|
+
onPick: (userId) => {
|
|
4725
|
+
const member = visible.find((m) => m.userId === userId);
|
|
4726
|
+
if (member && !busy) void pick(member);
|
|
4727
|
+
},
|
|
4728
|
+
notice: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4729
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalLine, { error, className: "p-2" }) : null,
|
|
4730
|
+
members === null ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
4731
|
+
] }),
|
|
4732
|
+
empty: members !== null ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: members.length === 0 ? "This organization has no other members yet, so there is nobody to assign." : "Nobody in this organization matches." }) : null,
|
|
4733
|
+
children: anchored ? cellChips : null
|
|
4734
|
+
}
|
|
4735
|
+
)
|
|
4736
|
+
)
|
|
4737
|
+
] });
|
|
4738
|
+
}
|
|
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
|
+
|
|
4783
|
+
// src/values.tsx
|
|
4784
|
+
var import_outbound_react5 = require("@ai-matrx/kit/outbound-react");
|
|
4785
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4507
4786
|
function statusMark(field, item, document2) {
|
|
4508
4787
|
const mark = statusMarkOf(field, item, document2);
|
|
4509
|
-
return mark ? /* @__PURE__ */ (0,
|
|
4788
|
+
return mark ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-label": mark.words, title: mark.words, className: "mr-1", "data-records-status-group": mark.group, children: mark.mark }) : null;
|
|
4510
4789
|
}
|
|
4511
4790
|
function envelopeFor(document2, key) {
|
|
4512
4791
|
const block = document2?._values;
|
|
@@ -4552,48 +4831,48 @@ function sourceArchivedSentence(state2) {
|
|
|
4552
4831
|
return state2.table ? `${state2.label} on ${state2.table} is archived` : `${state2.label} is archived`;
|
|
4553
4832
|
}
|
|
4554
4833
|
function SourceArchivedValue({ state: state2 }) {
|
|
4555
|
-
return /* @__PURE__ */ (0,
|
|
4834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-xs italic text-muted-foreground", title: sourceArchivedSentence(state2), "data-records-source-archived": state2.field_id ?? "", children: SOURCE_ARCHIVED_WORDS });
|
|
4556
4835
|
}
|
|
4557
4836
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4558
4837
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4559
|
-
const archivedSource = (0,
|
|
4560
|
-
if (archivedSource) return /* @__PURE__ */ (0,
|
|
4838
|
+
const archivedSource = (0, import_records18.sourceArchivedOf)(value);
|
|
4839
|
+
if (archivedSource) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SourceArchivedValue, { state: archivedSource });
|
|
4561
4840
|
const envelope = envelopeFor(document2, field.key);
|
|
4562
4841
|
if (envelope?.absent) {
|
|
4563
|
-
return /* @__PURE__ */ (0,
|
|
4842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `VAL-2: ${envelope.absent}`, children: ABSENCE_WORDS[String(envelope.absent)] ?? String(envelope.absent) });
|
|
4564
4843
|
}
|
|
4565
4844
|
if (value === null || value === void 0 || value === "") {
|
|
4566
4845
|
const gone = unresolvedFor(document2, field.key);
|
|
4567
4846
|
if (gone) {
|
|
4568
|
-
return /* @__PURE__ */ (0,
|
|
4847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-xs italic text-muted-foreground", title: `It pointed at ${gone}`, children: "The record this pointed at no longer exists" });
|
|
4569
4848
|
}
|
|
4570
4849
|
const archivedInput = formulaSourceArchived(field, document2);
|
|
4571
|
-
if (archivedInput) return /* @__PURE__ */ (0,
|
|
4850
|
+
if (archivedInput) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SourceArchivedValue, { state: archivedInput });
|
|
4572
4851
|
const computed = computedEmptyOf(field, document2);
|
|
4573
|
-
if (computed?.sentence) return /* @__PURE__ */ (0,
|
|
4574
|
-
if (computed?.words) return /* @__PURE__ */ (0,
|
|
4852
|
+
if (computed?.sentence) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-xs italic text-muted-foreground", children: computed.sentence });
|
|
4853
|
+
if (computed?.words) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-records-empty-why": computed.kind, children: computed.words });
|
|
4575
4854
|
if (computed?.why) {
|
|
4576
|
-
return /* @__PURE__ */ (0,
|
|
4855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
|
|
4577
4856
|
}
|
|
4578
4857
|
if (look?.blankEmpty) return null;
|
|
4579
|
-
return /* @__PURE__ */ (0,
|
|
4858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4580
4859
|
}
|
|
4581
|
-
if (isSignatureField(field)) return /* @__PURE__ */ (0,
|
|
4582
|
-
if ((0,
|
|
4860
|
+
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SignatureValue, { value, fieldKey: field.key, document: document2 });
|
|
4861
|
+
if ((0, import_records18.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ButtonValue, { field });
|
|
4583
4862
|
const newer = newerKindValue(field, value);
|
|
4584
4863
|
if (newer !== void 0) return newer;
|
|
4585
4864
|
const whole = typeof value === "string" ? (0, import_core5.wholeValueOf)(document2, field.key) : null;
|
|
4586
|
-
if (whole) return /* @__PURE__ */ (0,
|
|
4865
|
+
if (whole) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WholeValueCell, { words: value, pointer: whole });
|
|
4587
4866
|
const kind = editorKindFor(field);
|
|
4588
4867
|
if (kind === "relation" || kind === "entity_reference") {
|
|
4589
|
-
return /* @__PURE__ */ (0,
|
|
4868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
|
|
4590
4869
|
}
|
|
4591
4870
|
if (kind === "member") {
|
|
4592
4871
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4593
|
-
return /* @__PURE__ */ (0,
|
|
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}`)) });
|
|
4594
4873
|
}
|
|
4595
4874
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4596
|
-
if (kv) return /* @__PURE__ */ (0,
|
|
4875
|
+
if (kv) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KindValueCell, { kv, where: "cell", title: field.label });
|
|
4597
4876
|
const chosen = kind === "select" || kind === "multi_select";
|
|
4598
4877
|
const chipOf = (item) => {
|
|
4599
4878
|
const chipLook = choiceChipLookOf(field, item, scalarText(field, item, labels));
|
|
@@ -4601,17 +4880,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4601
4880
|
};
|
|
4602
4881
|
if (chosen) {
|
|
4603
4882
|
const items = Array.isArray(value) ? value : [value];
|
|
4604
|
-
return /* @__PURE__ */ (0,
|
|
4883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
|
|
4605
4884
|
const chip = chipOf(item);
|
|
4606
|
-
return /* @__PURE__ */ (0,
|
|
4607
|
-
|
|
4885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4886
|
+
import_design_system22.Badge,
|
|
4608
4887
|
{
|
|
4609
4888
|
variant: "outline",
|
|
4610
|
-
className: (0,
|
|
4889
|
+
className: (0, import_design_system22.cn)("text-[11px]", chip.className),
|
|
4611
4890
|
"data-records-choice-chip": "",
|
|
4612
4891
|
...chip.tinted ? { "data-records-choice-tint": "" } : {},
|
|
4613
4892
|
children: [
|
|
4614
|
-
look?.choiceDot ? /* @__PURE__ */ (0,
|
|
4893
|
+
look?.choiceDot ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-hidden": "true", "data-matrx-pill-ink": "", "data-records-choice-dot": "", className: (0, import_design_system22.cn)("mr-1.5 inline-block size-1.5 shrink-0 rounded-full", chip.dot) }) : null,
|
|
4615
4894
|
statusMark(field, item, Array.isArray(value) ? void 0 : document2),
|
|
4616
4895
|
scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
|
|
4617
4896
|
]
|
|
@@ -4620,13 +4899,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4620
4899
|
);
|
|
4621
4900
|
}) });
|
|
4622
4901
|
}
|
|
4623
|
-
if (kind === "attachment") return /* @__PURE__ */ (0,
|
|
4902
|
+
if (kind === "attachment") return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AttachmentChips, { value });
|
|
4624
4903
|
if (Array.isArray(value)) {
|
|
4625
|
-
return /* @__PURE__ */ (0,
|
|
4904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_design_system22.Badge, { variant: "secondary", className: "text-[11px]", children: scalarText(field, item, labels) }, `${String(item)}-${i}`)) });
|
|
4626
4905
|
}
|
|
4627
4906
|
if (kind === "url" && typeof value === "string") {
|
|
4628
4907
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
4629
|
-
return /* @__PURE__ */ (0,
|
|
4908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4630
4909
|
import_outbound_react5.OutboundLink,
|
|
4631
4910
|
{
|
|
4632
4911
|
className: "inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border border-border bg-muted/60 px-1.5 py-0.5 text-[11px] text-foreground hover:bg-accent",
|
|
@@ -4635,14 +4914,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4635
4914
|
"data-records-link-chip": "",
|
|
4636
4915
|
onClick: (event) => event.stopPropagation(),
|
|
4637
4916
|
children: [
|
|
4638
|
-
/* @__PURE__ */ (0,
|
|
4639
|
-
/* @__PURE__ */ (0,
|
|
4917
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
|
|
4918
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "truncate", children: linkChipText(value) })
|
|
4640
4919
|
]
|
|
4641
4920
|
}
|
|
4642
4921
|
);
|
|
4643
4922
|
}
|
|
4644
4923
|
if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
|
|
4645
|
-
return /* @__PURE__ */ (0,
|
|
4924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4646
4925
|
"a",
|
|
4647
4926
|
{
|
|
4648
4927
|
className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
|
|
@@ -4655,19 +4934,33 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4655
4934
|
);
|
|
4656
4935
|
}
|
|
4657
4936
|
if (kind === "email" && typeof value === "string") {
|
|
4658
|
-
return /* @__PURE__ */ (0,
|
|
4937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
|
|
4659
4938
|
}
|
|
4660
4939
|
if (typeof value === "boolean") {
|
|
4661
|
-
return /* @__PURE__ */ (0,
|
|
4940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
|
|
4662
4941
|
}
|
|
4663
|
-
return /* @__PURE__ */ (0,
|
|
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) });
|
|
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(", ");
|
|
4664
4957
|
}
|
|
4665
4958
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4666
4959
|
if (value === null || value === void 0) return "\u2014";
|
|
4667
|
-
if ((0,
|
|
4960
|
+
if ((0, import_records18.sourceArchivedOf)(value)) return SOURCE_ARCHIVED_WORDS;
|
|
4668
4961
|
if (isSignatureField(field)) return signatureWords(value) ?? "\u2014";
|
|
4669
|
-
if ((0,
|
|
4670
|
-
const newerWords = (0,
|
|
4962
|
+
if ((0, import_records18.autonumberPrefixOf)(field)) return (0, import_records18.autonumberWords)(field, value) ?? String(value);
|
|
4963
|
+
const newerWords = (0, import_records18.newerKindWords)(field, value);
|
|
4671
4964
|
if (newerWords !== null) return newerWords;
|
|
4672
4965
|
const kind = editorKindFor(field);
|
|
4673
4966
|
if (kind === "entity_reference") return entityReferenceText(value);
|
|
@@ -4679,6 +4972,8 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4679
4972
|
if (isId(value) && (field.type === "list" || field.type === "relation")) {
|
|
4680
4973
|
return labels?.(field, String(value)) ?? stillWaitingFor ?? "Loading\u2026";
|
|
4681
4974
|
}
|
|
4975
|
+
const personal = personWordsOf(kind, value);
|
|
4976
|
+
if (personal !== null) return personal;
|
|
4682
4977
|
if (field.type === "list" && typeof value === "string" && labels) {
|
|
4683
4978
|
const words = labels(field, value);
|
|
4684
4979
|
if (words) return words;
|
|
@@ -4703,24 +4998,24 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4703
4998
|
}
|
|
4704
4999
|
|
|
4705
5000
|
// src/SourceArchivedNotice.tsx
|
|
4706
|
-
var
|
|
5001
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4707
5002
|
function bringBackLabel(state2) {
|
|
4708
5003
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4709
5004
|
}
|
|
4710
5005
|
function SourceArchivedNotice({ fieldId, tableId }) {
|
|
4711
|
-
const client = (0,
|
|
4712
|
-
const [state2, setState] = (0,
|
|
4713
|
-
const [busy, setBusy] = (0,
|
|
4714
|
-
const [refused, setRefused] = (0,
|
|
4715
|
-
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 () => {
|
|
4716
5011
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4717
5012
|
if (answer.ok) setState(answer.data);
|
|
4718
5013
|
else setRefused(answer.error);
|
|
4719
5014
|
}, [client, fieldId]);
|
|
4720
|
-
(0,
|
|
5015
|
+
(0, import_react38.useEffect)(() => {
|
|
4721
5016
|
void read();
|
|
4722
5017
|
}, [read]);
|
|
4723
|
-
if (refused && !state2) return /* @__PURE__ */ (0,
|
|
5018
|
+
if (refused && !state2) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: refused });
|
|
4724
5019
|
if (!state2) return null;
|
|
4725
5020
|
const restore = async () => {
|
|
4726
5021
|
if (!state2.field_id) return;
|
|
@@ -4732,36 +5027,36 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4732
5027
|
setRefused(done.error);
|
|
4733
5028
|
return;
|
|
4734
5029
|
}
|
|
4735
|
-
if (state2.table_id) (0,
|
|
4736
|
-
(0,
|
|
5030
|
+
if (state2.table_id) (0, import_react39.tableShapeChanged)(state2.table_id);
|
|
5031
|
+
(0, import_react39.tableShapeChanged)(tableId);
|
|
4737
5032
|
await read();
|
|
4738
5033
|
};
|
|
4739
|
-
return /* @__PURE__ */ (0,
|
|
5034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4740
5035
|
"div",
|
|
4741
5036
|
{
|
|
4742
5037
|
className: "flex flex-wrap items-center gap-2 rounded-md border border-border px-3 py-2",
|
|
4743
5038
|
"data-testid": "source-archived-notice",
|
|
4744
5039
|
"data-field-id": state2.field_id ?? "",
|
|
4745
5040
|
children: [
|
|
4746
|
-
/* @__PURE__ */ (0,
|
|
4747
|
-
/* @__PURE__ */ (0,
|
|
4748
|
-
/* @__PURE__ */ (0,
|
|
5041
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
5042
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-sm", children: SOURCE_ARCHIVED_WORDS }),
|
|
5043
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate text-xs text-muted-foreground", children: sourceArchivedSentence(state2) })
|
|
4749
5044
|
] }),
|
|
4750
|
-
state2.field_id ? /* @__PURE__ */ (0,
|
|
4751
|
-
refused ? /* @__PURE__ */ (0,
|
|
5045
|
+
state2.field_id ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_design_system23.Button, { type: "button", size: "sm", variant: "secondary", disabled: busy, onClick: () => void restore(), children: bringBackLabel(state2) }) : null,
|
|
5046
|
+
refused ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: refused, className: "basis-full" }) : null
|
|
4752
5047
|
]
|
|
4753
5048
|
}
|
|
4754
5049
|
);
|
|
4755
5050
|
}
|
|
4756
5051
|
|
|
4757
5052
|
// src/Condition.tsx
|
|
4758
|
-
var
|
|
4759
|
-
var
|
|
4760
|
-
var
|
|
4761
|
-
var
|
|
5053
|
+
var import_react41 = require("react");
|
|
5054
|
+
var import_design_system24 = require("@ai-matrx/design-system");
|
|
5055
|
+
var import_records19 = require("@ai-matrx/records");
|
|
5056
|
+
var import_react42 = require("@ai-matrx/records/react");
|
|
4762
5057
|
|
|
4763
5058
|
// src/personTime.ts
|
|
4764
|
-
var
|
|
5059
|
+
var import_react40 = require("react");
|
|
4765
5060
|
|
|
4766
5061
|
// src/personZone.ts
|
|
4767
5062
|
var import_table_style3 = require("@ai-matrx/design-system/data-table/table-style");
|
|
@@ -4798,7 +5093,7 @@ function personWallNow(at = /* @__PURE__ */ new Date()) {
|
|
|
4798
5093
|
|
|
4799
5094
|
// src/personTime.ts
|
|
4800
5095
|
function usePersonTimeZone() {
|
|
4801
|
-
return (0,
|
|
5096
|
+
return (0, import_react40.useSyncExternalStore)(
|
|
4802
5097
|
subscribePersonTimeZone,
|
|
4803
5098
|
getPersonTimeZone,
|
|
4804
5099
|
() => null
|
|
@@ -4806,7 +5101,7 @@ function usePersonTimeZone() {
|
|
|
4806
5101
|
}
|
|
4807
5102
|
|
|
4808
5103
|
// src/Condition.tsx
|
|
4809
|
-
var
|
|
5104
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4810
5105
|
var CONDITION_OPS = [
|
|
4811
5106
|
{ op: "eq", label: "is" },
|
|
4812
5107
|
{ op: "ne", label: "is not" },
|
|
@@ -4843,7 +5138,7 @@ function linkedOf(expr) {
|
|
|
4843
5138
|
if (match !== "any" && match !== "none") return null;
|
|
4844
5139
|
return { via: rel["field"], inner: a["field"], op: match === "any" ? "eq" : "ne", value: b["const"] };
|
|
4845
5140
|
}
|
|
4846
|
-
var FilterTermsContext = (0,
|
|
5141
|
+
var FilterTermsContext = (0, import_react41.createContext)(false);
|
|
4847
5142
|
var RELATIVE_DAY_TERMS = [
|
|
4848
5143
|
{ kind: "today", label: "is today" },
|
|
4849
5144
|
{ kind: "tomorrow", label: "is tomorrow" },
|
|
@@ -4894,17 +5189,17 @@ function isChoiceColumn(f) {
|
|
|
4894
5189
|
return kind === "select" || kind === "multi_select";
|
|
4895
5190
|
}
|
|
4896
5191
|
function ChoiceValue({ field, value, onChange }) {
|
|
4897
|
-
const client = (0,
|
|
4898
|
-
const [choices, setChoices] = (0,
|
|
4899
|
-
const [open, setOpen] = (0,
|
|
4900
|
-
const [search, setSearch] = (0,
|
|
4901
|
-
(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)(() => {
|
|
4902
5197
|
if (!client) return;
|
|
4903
5198
|
let cancelled = false;
|
|
4904
5199
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
4905
5200
|
if (cancelled) return;
|
|
4906
5201
|
setChoices(
|
|
4907
|
-
got.ok ? (got.data ?? []).map((o) => ({ key: (0,
|
|
5202
|
+
got.ok ? (got.data ?? []).map((o) => ({ key: (0, import_records19.optionKey)(o), label: (0, import_records19.optionLabel)(o) ?? "" })).filter((c) => c.label !== "") : []
|
|
4908
5203
|
);
|
|
4909
5204
|
});
|
|
4910
5205
|
return () => {
|
|
@@ -4912,8 +5207,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4912
5207
|
};
|
|
4913
5208
|
}, [client, field.id]);
|
|
4914
5209
|
if (!choices || choices.length === 0) {
|
|
4915
|
-
return /* @__PURE__ */ (0,
|
|
4916
|
-
|
|
5210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5211
|
+
import_design_system24.BasicInput,
|
|
4917
5212
|
{
|
|
4918
5213
|
className: "h-8 w-28 text-xs",
|
|
4919
5214
|
"aria-label": "Condition value",
|
|
@@ -4922,8 +5217,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4922
5217
|
}
|
|
4923
5218
|
);
|
|
4924
5219
|
}
|
|
4925
|
-
const shown2 = (0,
|
|
4926
|
-
return /* @__PURE__ */ (0,
|
|
5220
|
+
const shown2 = (0, import_records19.rankTypedMatches)(choices, search.trim(), (c) => c.label);
|
|
5221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "inline-flex min-w-0", "data-records-condition-choice": "", "data-pick-value": value, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4927
5222
|
PickOrAdd,
|
|
4928
5223
|
{
|
|
4929
5224
|
triggerSize: "compact",
|
|
@@ -4949,7 +5244,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4949
5244
|
setOpen(false);
|
|
4950
5245
|
setSearch("");
|
|
4951
5246
|
},
|
|
4952
|
-
empty: /* @__PURE__ */ (0,
|
|
5247
|
+
empty: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
|
|
4953
5248
|
}
|
|
4954
5249
|
) });
|
|
4955
5250
|
}
|
|
@@ -5043,7 +5338,7 @@ function conditionValue(typed) {
|
|
|
5043
5338
|
}
|
|
5044
5339
|
function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
|
|
5045
5340
|
const node = expr ?? null;
|
|
5046
|
-
const filterTerms = (0,
|
|
5341
|
+
const filterTerms = (0, import_react41.useContext)(FilterTermsContext);
|
|
5047
5342
|
const relative = relativeDayOf(expr);
|
|
5048
5343
|
const reader = meOf(expr);
|
|
5049
5344
|
const linked = linkedOf(expr);
|
|
@@ -5089,9 +5384,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5089
5384
|
VALUELESS_OPS.has(chosenOp) ? { op: chosenOp, args: [{ field: chosenField }] } : { op: chosenOp, args: [{ field: chosenField }, { const: chosenValue }] }
|
|
5090
5385
|
);
|
|
5091
5386
|
}
|
|
5092
|
-
return /* @__PURE__ */ (0,
|
|
5093
|
-
/* @__PURE__ */ (0,
|
|
5094
|
-
/* @__PURE__ */ (0,
|
|
5387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: className ?? "flex flex-wrap items-center gap-1 text-xs", children: [
|
|
5388
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground", children: lead }),
|
|
5389
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5095
5390
|
PickOne,
|
|
5096
5391
|
{
|
|
5097
5392
|
label: "Condition field",
|
|
@@ -5102,7 +5397,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5102
5397
|
attrs: { "data-condition": "field" }
|
|
5103
5398
|
}
|
|
5104
5399
|
),
|
|
5105
|
-
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ (0,
|
|
5400
|
+
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5106
5401
|
"span",
|
|
5107
5402
|
{
|
|
5108
5403
|
className: "rounded bg-destructive px-1.5 py-0.5 text-[11px] font-medium text-destructive-foreground",
|
|
@@ -5111,8 +5406,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5111
5406
|
children: "Missing question"
|
|
5112
5407
|
}
|
|
5113
5408
|
) : null,
|
|
5114
|
-
onField ? /* @__PURE__ */ (0,
|
|
5115
|
-
/* @__PURE__ */ (0,
|
|
5409
|
+
onField ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
5410
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5116
5411
|
PickOne,
|
|
5117
5412
|
{
|
|
5118
5413
|
label: "Condition comparison",
|
|
@@ -5123,8 +5418,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5123
5418
|
attrs: { "data-condition": "comparison" }
|
|
5124
5419
|
}
|
|
5125
5420
|
),
|
|
5126
|
-
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ (0,
|
|
5127
|
-
|
|
5421
|
+
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5422
|
+
import_design_system24.BasicInput,
|
|
5128
5423
|
{
|
|
5129
5424
|
className: "h-8 w-16 text-xs",
|
|
5130
5425
|
type: "number",
|
|
@@ -5140,7 +5435,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5140
5435
|
// is asked for ONE record even when the column holds several: a clause compares
|
|
5141
5436
|
// against one value, and a picker that let somebody choose three would be
|
|
5142
5437
|
// writing an expression this row cannot draw back.
|
|
5143
|
-
/* @__PURE__ */ (0,
|
|
5438
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5144
5439
|
RelationPicker,
|
|
5145
5440
|
{
|
|
5146
5441
|
field: { ...chosen.field, multi: false },
|
|
@@ -5151,8 +5446,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5151
5446
|
allowCreate: false
|
|
5152
5447
|
}
|
|
5153
5448
|
)
|
|
5154
|
-
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ (0,
|
|
5155
|
-
|
|
5449
|
+
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5450
|
+
import_design_system24.BasicInput,
|
|
5156
5451
|
{
|
|
5157
5452
|
className: "h-8 w-28 text-xs",
|
|
5158
5453
|
"aria-label": "Condition value",
|
|
@@ -5228,7 +5523,7 @@ function ConditionGroup({
|
|
|
5228
5523
|
className
|
|
5229
5524
|
}) {
|
|
5230
5525
|
const { joiner, args } = clausesOf(expr);
|
|
5231
|
-
const [drafting, setDrafting] = (0,
|
|
5526
|
+
const [drafting, setDrafting] = (0, import_react41.useState)(null);
|
|
5232
5527
|
const nested = depth > 0;
|
|
5233
5528
|
const replaceAt = (index, next) => {
|
|
5234
5529
|
const nextArgs = args.slice();
|
|
@@ -5239,16 +5534,16 @@ function ConditionGroup({
|
|
|
5239
5534
|
const joinWord = (index) => index === 0 ? lead : joiner === "or" || joiner === "none" ? "or" : "and";
|
|
5240
5535
|
const showJoiner = nested || args.length > 1 || joiner === "none" || joiner === "notall";
|
|
5241
5536
|
const opposite = joiner === "or" || joiner === "none" ? "and" : "or";
|
|
5242
|
-
return /* @__PURE__ */ (0,
|
|
5537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
5243
5538
|
"div",
|
|
5244
5539
|
{
|
|
5245
5540
|
className: className ?? "flex flex-col gap-1 text-xs",
|
|
5246
5541
|
"data-testid": nested ? "condition-nested-group" : "condition-group",
|
|
5247
5542
|
"data-depth": depth,
|
|
5248
5543
|
children: [
|
|
5249
|
-
showJoiner ? /* @__PURE__ */ (0,
|
|
5250
|
-
/* @__PURE__ */ (0,
|
|
5251
|
-
/* @__PURE__ */ (0,
|
|
5544
|
+
showJoiner ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
5545
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground", children: nested ? "Group:" : lead }),
|
|
5546
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5252
5547
|
PickOne,
|
|
5253
5548
|
{
|
|
5254
5549
|
label: nested ? `How the conditions in this group are joined (level ${depth + 1})` : "How these conditions are joined",
|
|
@@ -5259,8 +5554,8 @@ function ConditionGroup({
|
|
|
5259
5554
|
attrs: { "data-condition": "joiner" }
|
|
5260
5555
|
}
|
|
5261
5556
|
),
|
|
5262
|
-
nested && onRemove ? /* @__PURE__ */ (0,
|
|
5263
|
-
|
|
5557
|
+
nested && onRemove ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5558
|
+
import_design_system24.Button,
|
|
5264
5559
|
{
|
|
5265
5560
|
size: "sm",
|
|
5266
5561
|
variant: "ghost",
|
|
@@ -5271,7 +5566,7 @@ function ConditionGroup({
|
|
|
5271
5566
|
}
|
|
5272
5567
|
) : null
|
|
5273
5568
|
] }) : null,
|
|
5274
|
-
args.length === 0 ? /* @__PURE__ */ (0,
|
|
5569
|
+
args.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5275
5570
|
ConditionRow,
|
|
5276
5571
|
{
|
|
5277
5572
|
lead,
|
|
@@ -5284,7 +5579,7 @@ function ConditionGroup({
|
|
|
5284
5579
|
const group = conditionGroupOf(arg);
|
|
5285
5580
|
const key = `clause-${index}`;
|
|
5286
5581
|
if (group && allowNesting) {
|
|
5287
|
-
return /* @__PURE__ */ (0,
|
|
5582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "ml-4 rounded border border-dashed p-1", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5288
5583
|
ConditionGroup,
|
|
5289
5584
|
{
|
|
5290
5585
|
lead: joinWord(index),
|
|
@@ -5298,7 +5593,7 @@ function ConditionGroup({
|
|
|
5298
5593
|
}
|
|
5299
5594
|
) }, key);
|
|
5300
5595
|
}
|
|
5301
|
-
return /* @__PURE__ */ (0,
|
|
5596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5302
5597
|
ConditionRow,
|
|
5303
5598
|
{
|
|
5304
5599
|
lead: showJoiner || args.length > 1 ? joinWord(index) : lead,
|
|
@@ -5310,7 +5605,7 @@ function ConditionGroup({
|
|
|
5310
5605
|
key
|
|
5311
5606
|
);
|
|
5312
5607
|
}),
|
|
5313
|
-
drafting ? /* @__PURE__ */ (0,
|
|
5608
|
+
drafting ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: drafting === "group" ? "ml-4 rounded border border-dashed p-1" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5314
5609
|
ConditionRow,
|
|
5315
5610
|
{
|
|
5316
5611
|
lead: drafting === "group" ? `${joinWord(1)}, a group where` : joinWord(1),
|
|
@@ -5325,9 +5620,9 @@ function ConditionGroup({
|
|
|
5325
5620
|
}
|
|
5326
5621
|
}
|
|
5327
5622
|
) }) : null,
|
|
5328
|
-
args.length > 0 && !drafting ? /* @__PURE__ */ (0,
|
|
5329
|
-
/* @__PURE__ */ (0,
|
|
5330
|
-
|
|
5623
|
+
args.length > 0 && !drafting ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
5624
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5625
|
+
import_design_system24.Button,
|
|
5331
5626
|
{
|
|
5332
5627
|
size: "sm",
|
|
5333
5628
|
variant: "ghost",
|
|
@@ -5337,8 +5632,8 @@ function ConditionGroup({
|
|
|
5337
5632
|
children: "Add another condition"
|
|
5338
5633
|
}
|
|
5339
5634
|
),
|
|
5340
|
-
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ (0,
|
|
5341
|
-
|
|
5635
|
+
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5636
|
+
import_design_system24.Button,
|
|
5342
5637
|
{
|
|
5343
5638
|
size: "sm",
|
|
5344
5639
|
variant: "ghost",
|
|
@@ -5355,11 +5650,74 @@ function ConditionGroup({
|
|
|
5355
5650
|
}
|
|
5356
5651
|
|
|
5357
5652
|
// src/FieldRetype.tsx
|
|
5358
|
-
var
|
|
5359
|
-
var
|
|
5360
|
-
var
|
|
5361
|
-
var
|
|
5362
|
-
|
|
5653
|
+
var import_react43 = require("react");
|
|
5654
|
+
var import_records20 = require("@ai-matrx/records");
|
|
5655
|
+
var import_react44 = require("@ai-matrx/records/react");
|
|
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
|
|
5720
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5363
5721
|
var RETYPE_TARGETS = [
|
|
5364
5722
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
5365
5723
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -5382,6 +5740,7 @@ var RETYPE_TARGETS = [
|
|
|
5382
5740
|
];
|
|
5383
5741
|
var PREVIEW_GROUPS = 1e3;
|
|
5384
5742
|
function retypeableFrom(field) {
|
|
5743
|
+
if (isPersonField(field)) return true;
|
|
5385
5744
|
const behaviour = String(field.type);
|
|
5386
5745
|
return behaviour === "text" || behaviour === "range" || behaviour === "boolean";
|
|
5387
5746
|
}
|
|
@@ -5396,7 +5755,11 @@ function whyNotRetypeable(field) {
|
|
|
5396
5755
|
}
|
|
5397
5756
|
return "Its kind is not changed here.";
|
|
5398
5757
|
}
|
|
5758
|
+
function isPersonField(field) {
|
|
5759
|
+
return String(editorKindFor(field)) === "member";
|
|
5760
|
+
}
|
|
5399
5761
|
function currentTarget(field) {
|
|
5762
|
+
if (isPersonField(field)) return "person";
|
|
5400
5763
|
const kind = String(editorKindFor(field));
|
|
5401
5764
|
if (String(field.type) === "boolean") return "checkbox";
|
|
5402
5765
|
if (kind === "datetime" || kind === "date") return "date";
|
|
@@ -5404,23 +5767,51 @@ function currentTarget(field) {
|
|
|
5404
5767
|
if (String(field.type) === "range") return "number";
|
|
5405
5768
|
return "text";
|
|
5406
5769
|
}
|
|
5770
|
+
function failure(e, fallback) {
|
|
5771
|
+
return { code: "internal", message: e instanceof Error && e.message ? e.message : fallback };
|
|
5772
|
+
}
|
|
5407
5773
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5408
|
-
const client = (0,
|
|
5774
|
+
const client = (0, import_react44.useRecordsClient)();
|
|
5409
5775
|
const notify = useRecordsUi().notify;
|
|
5410
|
-
const [to, setTo] = (0,
|
|
5411
|
-
const [preview, setPreview] = (0,
|
|
5412
|
-
const [asking, setAsking] = (0,
|
|
5413
|
-
const [refusal, setRefusal] = (0,
|
|
5414
|
-
const [busy, setBusy] = (0,
|
|
5415
|
-
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);
|
|
5416
5785
|
const name = fieldName(field);
|
|
5417
5786
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5418
|
-
(0,
|
|
5787
|
+
(0, import_react43.useEffect)(() => {
|
|
5419
5788
|
if (!to) return;
|
|
5420
5789
|
let cancelled = false;
|
|
5421
5790
|
setPreview(null);
|
|
5422
5791
|
setRefusal(null);
|
|
5423
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
|
+
}
|
|
5424
5815
|
void client.recordAggregate({ table_id: tableId, groupBy: [field.key], measures: [{ op: "count" }], limit: PREVIEW_GROUPS }).then((answer) => {
|
|
5425
5816
|
if (cancelled) return;
|
|
5426
5817
|
setAsking(false);
|
|
@@ -5429,14 +5820,14 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5429
5820
|
return;
|
|
5430
5821
|
}
|
|
5431
5822
|
const groups = answer.data.map((row) => ({ value: row.groups[field.key] ?? null, count: row.row_count }));
|
|
5432
|
-
setPreview((0,
|
|
5823
|
+
setPreview((0, import_records20.previewRetype)({ type: to.behaviour, kind: to.kind }, groups, answer.data.length >= PREVIEW_GROUPS));
|
|
5433
5824
|
});
|
|
5434
5825
|
return () => {
|
|
5435
5826
|
cancelled = true;
|
|
5436
5827
|
};
|
|
5437
|
-
}, [client, tableId, field.key, to]);
|
|
5828
|
+
}, [client, tableId, field.key, to, person, roster]);
|
|
5438
5829
|
if (!retypeableFrom(field)) {
|
|
5439
|
-
return /* @__PURE__ */ (0,
|
|
5830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[11px] text-muted-foreground", "data-records-retype": "not-here", children: whyNotRetypeable(field) });
|
|
5440
5831
|
}
|
|
5441
5832
|
const change = async () => {
|
|
5442
5833
|
if (!to) return;
|
|
@@ -5471,35 +5862,53 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5471
5862
|
undo: async () => {
|
|
5472
5863
|
const back = await client.migrateUndo({ migration_id: migration });
|
|
5473
5864
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5474
|
-
(
|
|
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);
|
|
5475
5873
|
onRetyped?.();
|
|
5476
5874
|
}
|
|
5477
5875
|
});
|
|
5478
5876
|
}
|
|
5479
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
|
+
}
|
|
5480
5889
|
setSaid(
|
|
5481
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.` : ".")
|
|
5482
5891
|
);
|
|
5483
5892
|
setTo(null);
|
|
5484
5893
|
setPreview(null);
|
|
5485
|
-
(0,
|
|
5894
|
+
(0, import_react44.tableShapeChanged)(tableId);
|
|
5486
5895
|
onRetyped?.();
|
|
5487
5896
|
};
|
|
5488
|
-
return /* @__PURE__ */ (0,
|
|
5489
|
-
/* @__PURE__ */ (0,
|
|
5490
|
-
/* @__PURE__ */ (0,
|
|
5491
|
-
/* @__PURE__ */ (0,
|
|
5492
|
-
/* @__PURE__ */ (0,
|
|
5897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
|
|
5898
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5899
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_design_system25.Select, { value: to?.id ?? "", onValueChange: (next) => setTo(targets.find((t) => t.id === next) ?? null), children: [
|
|
5900
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.SelectTrigger, { size: "sm", "aria-label": "Change what this column holds", className: "w-auto min-w-[12rem]", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.SelectValue, { placeholder: "Change what this column holds" }) }),
|
|
5901
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.SelectContent, { children: targets.map((t) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.SelectItem, { value: t.id, children: t.label }, t.id)) })
|
|
5493
5902
|
] }),
|
|
5494
|
-
to ? /* @__PURE__ */ (0,
|
|
5495
|
-
to ? /* @__PURE__ */ (0,
|
|
5903
|
+
to ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.Button, { size: "sm", disabled: busy || asking || preview === null, onClick: () => void change(), "data-records-retype-go": "", children: busy ? "Changing\u2026" : `Change to ${to.label}` }) : null,
|
|
5904
|
+
to ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.Button, { size: "sm", variant: "ghost", onClick: () => setTo(null), disabled: busy, children: "Cancel" }) : null
|
|
5496
5905
|
] }),
|
|
5497
|
-
to && asking ? /* @__PURE__ */ (0,
|
|
5906
|
+
to && asking ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
5498
5907
|
"Counting ",
|
|
5499
5908
|
name,
|
|
5500
5909
|
"'s values\u2026"
|
|
5501
5910
|
] }) : null,
|
|
5502
|
-
to && preview ? /* @__PURE__ */ (0,
|
|
5911
|
+
to && preview ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-retype-preview": "", children: [
|
|
5503
5912
|
preview.converts,
|
|
5504
5913
|
" ",
|
|
5505
5914
|
preview.converts === 1 ? "value converts" : "values convert",
|
|
@@ -5508,16 +5917,16 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5508
5917
|
preview.keptAside > 0 ? `; ${preview.keptAside} ${preview.keptAside === 1 ? "value does" : "values do"} not fit and will be kept aside with ${preview.keptAside === 1 ? "its record" : "their records"}, with the reason \u2014 nothing is deleted` + (preview.examples.length > 0 ? ` (for example ${preview.examples.map((e) => `\u201C${e}\u201D`).join(", ")})` : "") : "",
|
|
5509
5918
|
preview.partial ? ". Counted over the first 1,000 different values." : "."
|
|
5510
5919
|
] }) : null,
|
|
5511
|
-
refusal ? /* @__PURE__ */ (0,
|
|
5512
|
-
said2 ? /* @__PURE__ */ (0,
|
|
5920
|
+
refusal ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(RefusalNotice, { error: refusal }) : null,
|
|
5921
|
+
said2 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-records-retype-done": "", children: said2 }) : null
|
|
5513
5922
|
] });
|
|
5514
5923
|
}
|
|
5515
5924
|
|
|
5516
5925
|
// src/FieldRulePreview.tsx
|
|
5517
|
-
var
|
|
5518
|
-
var
|
|
5519
|
-
var
|
|
5520
|
-
var
|
|
5926
|
+
var import_react45 = require("react");
|
|
5927
|
+
var import_records21 = require("@ai-matrx/records");
|
|
5928
|
+
var import_react46 = require("@ai-matrx/records/react");
|
|
5929
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
5521
5930
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5522
5931
|
function ruleWords(rules) {
|
|
5523
5932
|
return rules.map((r) => JSON.stringify([r.kind, r.value === void 0 || r.value === "" ? null : String(r.value), r.min ?? null, r.example ?? null])).sort().join("|");
|
|
@@ -5534,14 +5943,14 @@ function groupValue(value, numbers) {
|
|
|
5534
5943
|
return /^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(text) ? Number(text) : value;
|
|
5535
5944
|
}
|
|
5536
5945
|
function FieldRulePreview({ field, tableId, rules }) {
|
|
5537
|
-
const client = (0,
|
|
5538
|
-
const [preview, setPreview] = (0,
|
|
5539
|
-
const [refusal, setRefusal] = (0,
|
|
5540
|
-
const key = (0,
|
|
5541
|
-
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);
|
|
5542
5951
|
latest.current = rules;
|
|
5543
5952
|
const name = fieldName(field);
|
|
5544
|
-
(0,
|
|
5953
|
+
(0, import_react45.useEffect)(() => {
|
|
5545
5954
|
let cancelled = false;
|
|
5546
5955
|
setPreview(null);
|
|
5547
5956
|
setRefusal(null);
|
|
@@ -5554,7 +5963,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5554
5963
|
}
|
|
5555
5964
|
const numbers = holdsNumbers(field);
|
|
5556
5965
|
const groups = answer.data.map((row) => ({ value: groupValue(row.groups[field.key] ?? null, numbers), count: row.row_count }));
|
|
5557
|
-
setPreview((0,
|
|
5966
|
+
setPreview((0, import_records21.previewRuleChange)(latest.current, groups, answer.data.length >= PREVIEW_GROUPS2));
|
|
5558
5967
|
});
|
|
5559
5968
|
}, 300);
|
|
5560
5969
|
return () => {
|
|
@@ -5562,16 +5971,16 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5562
5971
|
clearTimeout(timer);
|
|
5563
5972
|
};
|
|
5564
5973
|
}, [client, tableId, field.key, key]);
|
|
5565
|
-
if (refusal) return /* @__PURE__ */ (0,
|
|
5974
|
+
if (refusal) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RefusalNotice, { error: refusal });
|
|
5566
5975
|
if (!preview) {
|
|
5567
|
-
return /* @__PURE__ */ (0,
|
|
5976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "counting", children: [
|
|
5568
5977
|
"Counting ",
|
|
5569
5978
|
name,
|
|
5570
5979
|
"'s values\u2026"
|
|
5571
5980
|
] });
|
|
5572
5981
|
}
|
|
5573
5982
|
if (preview.keptAside === 0) {
|
|
5574
|
-
return /* @__PURE__ */ (0,
|
|
5983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "fits", children: [
|
|
5575
5984
|
"Every value already in ",
|
|
5576
5985
|
name,
|
|
5577
5986
|
" still fits",
|
|
@@ -5579,7 +5988,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5579
5988
|
"."
|
|
5580
5989
|
] });
|
|
5581
5990
|
}
|
|
5582
|
-
return /* @__PURE__ */ (0,
|
|
5991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-amber-700 dark:text-amber-400", role: "status", "data-records-rule-preview": "sets-aside", children: [
|
|
5583
5992
|
preview.keptAside,
|
|
5584
5993
|
" ",
|
|
5585
5994
|
preview.keptAside === 1 ? "value no longer fits and will be" : "values no longer fit and will be",
|
|
@@ -5662,9 +6071,9 @@ function choiceLookForNewList(multi, rows) {
|
|
|
5662
6071
|
}
|
|
5663
6072
|
|
|
5664
6073
|
// src/NewerKindQuestions.tsx
|
|
5665
|
-
var
|
|
5666
|
-
var
|
|
5667
|
-
var
|
|
6074
|
+
var import_records22 = require("@ai-matrx/records");
|
|
6075
|
+
var import_design_system26 = require("@ai-matrx/design-system");
|
|
6076
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
5668
6077
|
var STATUS_STARTING_CHOICES = [
|
|
5669
6078
|
{ words: "Not started", group: "todo" },
|
|
5670
6079
|
{ words: "In progress", group: "in_progress" },
|
|
@@ -5683,7 +6092,7 @@ function statusGroupRows(field, rows, keyOfId, changed) {
|
|
|
5683
6092
|
if (words === "") continue;
|
|
5684
6093
|
const ref = r.id ?? words;
|
|
5685
6094
|
const key = r.id ? keyOfId[r.id] : void 0;
|
|
5686
|
-
const held = field && key ? (0,
|
|
6095
|
+
const held = field && key ? (0, import_records22.statusGroupOf)(field, key) : void 0;
|
|
5687
6096
|
out.push({ ref, words, group: changed[ref] ?? held ?? guessStatusGroup(words) });
|
|
5688
6097
|
}
|
|
5689
6098
|
return out;
|
|
@@ -5693,27 +6102,27 @@ function StatusGroupsQuestion({
|
|
|
5693
6102
|
onGroup
|
|
5694
6103
|
}) {
|
|
5695
6104
|
if (rows.length === 0) return null;
|
|
5696
|
-
return /* @__PURE__ */ (0,
|
|
5697
|
-
/* @__PURE__ */ (0,
|
|
5698
|
-
rows.map((r) => /* @__PURE__ */ (0,
|
|
5699
|
-
/* @__PURE__ */ (0,
|
|
5700
|
-
/* @__PURE__ */ (0,
|
|
5701
|
-
/* @__PURE__ */ (0,
|
|
5702
|
-
/* @__PURE__ */ (0,
|
|
6105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col gap-1", "data-records-status-groups": "", children: [
|
|
6106
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.Label, { className: "text-xs", children: "Groups" }),
|
|
6107
|
+
rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6108
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "min-w-0 flex-1 truncate text-sm", children: r.words }),
|
|
6109
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.Select, { value: r.group, onValueChange: (next) => onGroup(r.ref, next), children: [
|
|
6110
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectTrigger, { size: "sm", className: "w-36", "aria-label": `Group for ${r.words}`, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectValue, {}) }),
|
|
6111
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectContent, { children: import_records22.STATUS_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.SelectItem, { value: g, children: [
|
|
5703
6112
|
STATUS_GROUP_MARK[g],
|
|
5704
6113
|
" ",
|
|
5705
|
-
|
|
6114
|
+
import_records22.STATUS_GROUP_WORDS[g]
|
|
5706
6115
|
] }, g)) })
|
|
5707
6116
|
] })
|
|
5708
6117
|
] }, r.ref))
|
|
5709
6118
|
] });
|
|
5710
6119
|
}
|
|
5711
6120
|
function RatingMaxQuestion({ value, onChange }) {
|
|
5712
|
-
return /* @__PURE__ */ (0,
|
|
5713
|
-
/* @__PURE__ */ (0,
|
|
5714
|
-
/* @__PURE__ */ (0,
|
|
5715
|
-
/* @__PURE__ */ (0,
|
|
5716
|
-
/* @__PURE__ */ (0,
|
|
6121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
6122
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.Label, { className: "text-xs", children: "Out of" }),
|
|
6123
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.Select, { value: String(value), onValueChange: (next) => onChange(Number(next)), children: [
|
|
6124
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectTrigger, { size: "sm", "aria-label": "Out of", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectValue, {}) }),
|
|
6125
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectContent, { children: Array.from({ length: 10 }, (_, i) => i + 1).map((n) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.SelectItem, { value: String(n), children: [
|
|
5717
6126
|
n,
|
|
5718
6127
|
" ",
|
|
5719
6128
|
n === 1 ? "star" : "stars"
|
|
@@ -5734,22 +6143,22 @@ var SYMBOLOGY_WORDS = {
|
|
|
5734
6143
|
pdf417: "PDF417"
|
|
5735
6144
|
};
|
|
5736
6145
|
function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
5737
|
-
return /* @__PURE__ */ (0,
|
|
5738
|
-
/* @__PURE__ */ (0,
|
|
5739
|
-
/* @__PURE__ */ (0,
|
|
5740
|
-
/* @__PURE__ */ (0,
|
|
5741
|
-
/* @__PURE__ */ (0,
|
|
5742
|
-
/* @__PURE__ */ (0,
|
|
5743
|
-
|
|
6146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
6147
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.Label, { className: "text-xs", children: "Code type" }),
|
|
6148
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.Select, { value: value === "" ? "any" : value, onValueChange: (next) => onChange(next === "any" ? "" : next), children: [
|
|
6149
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectTrigger, { size: "sm", "aria-label": "Code type", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectValue, {}) }),
|
|
6150
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.SelectContent, { children: [
|
|
6151
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectItem, { value: "any", children: "Any code" }),
|
|
6152
|
+
import_records22.BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectItem, { value: s, children: SYMBOLOGY_WORDS[s] }, s))
|
|
5744
6153
|
] })
|
|
5745
6154
|
] })
|
|
5746
6155
|
] });
|
|
5747
6156
|
}
|
|
5748
6157
|
|
|
5749
6158
|
// src/FieldFormatPicker.tsx
|
|
5750
|
-
var
|
|
6159
|
+
var import_design_system27 = require("@ai-matrx/design-system");
|
|
5751
6160
|
var import_field_formats6 = require("@ai-matrx/design-system/field-formats");
|
|
5752
|
-
var
|
|
6161
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
5753
6162
|
var KIND_WORD = {
|
|
5754
6163
|
choice: "select",
|
|
5755
6164
|
multi_choice: "multi_select",
|
|
@@ -5872,13 +6281,13 @@ function FieldFormatPicker({
|
|
|
5872
6281
|
else merged[key] = next;
|
|
5873
6282
|
onValue({ ...value, format: Object.keys(merged).length > 0 ? { id: value.format.id, options: merged } : { id: value.format.id } });
|
|
5874
6283
|
};
|
|
5875
|
-
const option = (key, label, control) => optionKeys.includes(key) ? /* @__PURE__ */ (0,
|
|
6284
|
+
const option = (key, label, control) => optionKeys.includes(key) ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "flex min-w-[6rem] flex-col gap-0.5 text-[11px] text-muted-foreground", children: [
|
|
5876
6285
|
label,
|
|
5877
6286
|
control
|
|
5878
6287
|
] }, key) : null;
|
|
5879
|
-
return /* @__PURE__ */ (0,
|
|
5880
|
-
/* @__PURE__ */ (0,
|
|
5881
|
-
/* @__PURE__ */ (0,
|
|
6288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-col gap-1", "data-records-format-picker": "", children: [
|
|
6289
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_design_system27.Label, { className: "text-xs", htmlFor: `records-shows-as-${field.id}`, children: "Shows as" }),
|
|
6290
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5882
6291
|
PickOne,
|
|
5883
6292
|
{
|
|
5884
6293
|
id: `records-shows-as-${field.id}`,
|
|
@@ -5904,12 +6313,12 @@ function FieldFormatPicker({
|
|
|
5904
6313
|
]
|
|
5905
6314
|
}
|
|
5906
6315
|
),
|
|
5907
|
-
/* @__PURE__ */ (0,
|
|
5908
|
-
optionKeys.length > 0 ? /* @__PURE__ */ (0,
|
|
6316
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[11px] text-muted-foreground", children: retypedTo ? `This changes what the column stores, to ${storesWord(retypedTo.def)}. The store converts each value it can, and says so before it keeps anything it cannot.` : active ? active.description : "How every value in this column is written, wherever it appears." }),
|
|
6317
|
+
optionKeys.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap items-end gap-2", children: [
|
|
5909
6318
|
option(
|
|
5910
6319
|
"currency",
|
|
5911
6320
|
"Currency",
|
|
5912
|
-
/* @__PURE__ */ (0,
|
|
6321
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5913
6322
|
PickOne,
|
|
5914
6323
|
{
|
|
5915
6324
|
label: "Currency",
|
|
@@ -5924,7 +6333,7 @@ function FieldFormatPicker({
|
|
|
5924
6333
|
option(
|
|
5925
6334
|
"percentScale",
|
|
5926
6335
|
"Stored as",
|
|
5927
|
-
/* @__PURE__ */ (0,
|
|
6336
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5928
6337
|
PickOne,
|
|
5929
6338
|
{
|
|
5930
6339
|
label: "Stored as",
|
|
@@ -5942,7 +6351,7 @@ function FieldFormatPicker({
|
|
|
5942
6351
|
option(
|
|
5943
6352
|
"durationUnit",
|
|
5944
6353
|
"Unit",
|
|
5945
|
-
/* @__PURE__ */ (0,
|
|
6354
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5946
6355
|
PickOne,
|
|
5947
6356
|
{
|
|
5948
6357
|
label: "Unit",
|
|
@@ -5962,7 +6371,7 @@ function FieldFormatPicker({
|
|
|
5962
6371
|
option(
|
|
5963
6372
|
"precision",
|
|
5964
6373
|
"Decimals",
|
|
5965
|
-
/* @__PURE__ */ (0,
|
|
6374
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5966
6375
|
"input",
|
|
5967
6376
|
{
|
|
5968
6377
|
"data-records-format-option": "precision",
|
|
@@ -5979,7 +6388,7 @@ function FieldFormatPicker({
|
|
|
5979
6388
|
option(
|
|
5980
6389
|
"ratingMax",
|
|
5981
6390
|
"Out of",
|
|
5982
|
-
/* @__PURE__ */ (0,
|
|
6391
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5983
6392
|
"input",
|
|
5984
6393
|
{
|
|
5985
6394
|
"data-records-format-option": "ratingMax",
|
|
@@ -5995,7 +6404,7 @@ function FieldFormatPicker({
|
|
|
5995
6404
|
option(
|
|
5996
6405
|
"dateStyle",
|
|
5997
6406
|
"Style",
|
|
5998
|
-
/* @__PURE__ */ (0,
|
|
6407
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5999
6408
|
PickOne,
|
|
6000
6409
|
{
|
|
6001
6410
|
label: "Style",
|
|
@@ -6014,15 +6423,15 @@ function FieldFormatPicker({
|
|
|
6014
6423
|
option(
|
|
6015
6424
|
"prefix",
|
|
6016
6425
|
"Prefix",
|
|
6017
|
-
/* @__PURE__ */ (0,
|
|
6426
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { "data-records-format-option": "prefix", className: BOX, value: options.prefix ?? "", onChange: (e) => setOption("prefix", e.target.value) })
|
|
6018
6427
|
),
|
|
6019
6428
|
option(
|
|
6020
6429
|
"suffix",
|
|
6021
6430
|
"Suffix",
|
|
6022
|
-
/* @__PURE__ */ (0,
|
|
6431
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { "data-records-format-option": "suffix", className: BOX, placeholder: "e.g. kg", value: options.suffix ?? "", onChange: (e) => setOption("suffix", e.target.value) })
|
|
6023
6432
|
),
|
|
6024
|
-
optionKeys.includes("useGrouping") ? /* @__PURE__ */ (0,
|
|
6025
|
-
/* @__PURE__ */ (0,
|
|
6433
|
+
optionKeys.includes("useGrouping") ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "flex items-center gap-1.5 pb-1 text-[11px] text-muted-foreground", children: [
|
|
6434
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
6026
6435
|
"input",
|
|
6027
6436
|
{
|
|
6028
6437
|
type: "checkbox",
|
|
@@ -6060,37 +6469,37 @@ function nextFieldSort(fields) {
|
|
|
6060
6469
|
}
|
|
6061
6470
|
|
|
6062
6471
|
// src/FieldEditor.tsx
|
|
6063
|
-
var
|
|
6472
|
+
var import_records25 = require("@ai-matrx/records");
|
|
6064
6473
|
|
|
6065
6474
|
// src/ButtonSettings.tsx
|
|
6066
|
-
var
|
|
6067
|
-
var
|
|
6475
|
+
var import_react47 = require("react");
|
|
6476
|
+
var import_design_system29 = require("@ai-matrx/design-system");
|
|
6068
6477
|
var import_data_table5 = require("@ai-matrx/design-system/data-table");
|
|
6069
|
-
var
|
|
6070
|
-
var
|
|
6478
|
+
var import_records24 = require("@ai-matrx/records");
|
|
6479
|
+
var import_react48 = require("@ai-matrx/records/react");
|
|
6071
6480
|
|
|
6072
6481
|
// src/AccentSwatches.tsx
|
|
6073
|
-
var
|
|
6074
|
-
var
|
|
6482
|
+
var import_records23 = require("@ai-matrx/records");
|
|
6483
|
+
var import_design_system28 = require("@ai-matrx/design-system");
|
|
6075
6484
|
var import_data_table4 = require("@ai-matrx/design-system/data-table");
|
|
6076
|
-
var
|
|
6077
|
-
function AccentSwatches({ value, onChange, options =
|
|
6078
|
-
return /* @__PURE__ */ (0,
|
|
6079
|
-
/* @__PURE__ */ (0,
|
|
6485
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
6486
|
+
function AccentSwatches({ value, onChange, options = import_records23.PORTAL_ACCENTS, noneLabel = "App colour" }) {
|
|
6487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap gap-1.5", role: "radiogroup", "aria-label": "Colour", children: [
|
|
6488
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6080
6489
|
"button",
|
|
6081
6490
|
{
|
|
6082
6491
|
type: "button",
|
|
6083
6492
|
role: "radio",
|
|
6084
6493
|
"aria-checked": value === "",
|
|
6085
6494
|
onClick: () => onChange(""),
|
|
6086
|
-
className: (0,
|
|
6495
|
+
className: (0, import_design_system28.cn)(
|
|
6087
6496
|
"h-7 rounded border px-2 text-xs",
|
|
6088
6497
|
value === "" ? "border-foreground" : "border-border text-muted-foreground"
|
|
6089
6498
|
),
|
|
6090
6499
|
children: noneLabel
|
|
6091
6500
|
}
|
|
6092
6501
|
),
|
|
6093
|
-
options.map((c) => /* @__PURE__ */ (0,
|
|
6502
|
+
options.map((c) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6094
6503
|
"button",
|
|
6095
6504
|
{
|
|
6096
6505
|
type: "button",
|
|
@@ -6099,7 +6508,7 @@ function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACC
|
|
|
6099
6508
|
"aria-label": import_data_table4.STYLE_COLOR_LABELS[c],
|
|
6100
6509
|
title: import_data_table4.STYLE_COLOR_LABELS[c],
|
|
6101
6510
|
onClick: () => onChange(c),
|
|
6102
|
-
className: (0,
|
|
6511
|
+
className: (0, import_design_system28.cn)("h-7 w-7 rounded-full border-2", import_data_table4.SWATCH_CLASS[c], value === c ? "border-foreground" : "border-transparent")
|
|
6103
6512
|
},
|
|
6104
6513
|
c
|
|
6105
6514
|
))
|
|
@@ -6107,7 +6516,7 @@ function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACC
|
|
|
6107
6516
|
}
|
|
6108
6517
|
|
|
6109
6518
|
// src/ButtonSettings.tsx
|
|
6110
|
-
var
|
|
6519
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6111
6520
|
var DOES_WORDS = {
|
|
6112
6521
|
none: "Nothing yet",
|
|
6113
6522
|
open_url: "Open a link",
|
|
@@ -6116,7 +6525,7 @@ var DOES_WORDS = {
|
|
|
6116
6525
|
};
|
|
6117
6526
|
function buttonUrlInWords(url, fields) {
|
|
6118
6527
|
let out = url;
|
|
6119
|
-
for (const id of (0,
|
|
6528
|
+
for (const id of (0, import_records24.buttonUrlPlaceholders)(url)) {
|
|
6120
6529
|
const f = fields.find((x) => x.id === id || x.key === id);
|
|
6121
6530
|
if (f) out = out.split(`{{${id}}}`).join(`{${fieldName(f)}}`);
|
|
6122
6531
|
}
|
|
@@ -6128,11 +6537,11 @@ function ButtonSettingsEditor({
|
|
|
6128
6537
|
tableId,
|
|
6129
6538
|
fields
|
|
6130
6539
|
}) {
|
|
6131
|
-
const client = (0,
|
|
6132
|
-
const [actions, setActions] = (0,
|
|
6133
|
-
const [actionsRefused, setActionsRefused] = (0,
|
|
6134
|
-
const [automations, setAutomations] = (0,
|
|
6135
|
-
(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)(() => {
|
|
6136
6545
|
if (!client || !tableId) return;
|
|
6137
6546
|
let live = true;
|
|
6138
6547
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6153,15 +6562,15 @@ function ButtonSettingsEditor({
|
|
|
6153
6562
|
}, [client, tableId, value.do, actions, automations]);
|
|
6154
6563
|
const set = (patch) => onChange({ ...value, ...patch });
|
|
6155
6564
|
const columns = fields.filter((f) => !(f.type === "text" && f.format === "button"));
|
|
6156
|
-
return /* @__PURE__ */ (0,
|
|
6157
|
-
/* @__PURE__ */ (0,
|
|
6158
|
-
/* @__PURE__ */ (0,
|
|
6159
|
-
/* @__PURE__ */ (0,
|
|
6160
|
-
/* @__PURE__ */ (0,
|
|
6565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-2 rounded-md border p-2", "data-records-button-settings": "", children: [
|
|
6566
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
6567
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
6568
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Button label" }),
|
|
6569
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.BasicInput, { className: "h-8 text-xs", value: value.label, "data-records-button-label": "", onChange: (e) => set({ label: e.target.value }) })
|
|
6161
6570
|
] }),
|
|
6162
|
-
/* @__PURE__ */ (0,
|
|
6163
|
-
/* @__PURE__ */ (0,
|
|
6164
|
-
/* @__PURE__ */ (0,
|
|
6571
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
6572
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Does" }),
|
|
6573
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6165
6574
|
PickOne,
|
|
6166
6575
|
{
|
|
6167
6576
|
label: "What a press does",
|
|
@@ -6173,9 +6582,9 @@ function ButtonSettingsEditor({
|
|
|
6173
6582
|
)
|
|
6174
6583
|
] })
|
|
6175
6584
|
] }),
|
|
6176
|
-
/* @__PURE__ */ (0,
|
|
6177
|
-
/* @__PURE__ */ (0,
|
|
6178
|
-
/* @__PURE__ */ (0,
|
|
6585
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
6586
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Colour" }),
|
|
6587
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6179
6588
|
AccentSwatches,
|
|
6180
6589
|
{
|
|
6181
6590
|
value: value.color ?? "",
|
|
@@ -6185,11 +6594,11 @@ function ButtonSettingsEditor({
|
|
|
6185
6594
|
}
|
|
6186
6595
|
)
|
|
6187
6596
|
] }),
|
|
6188
|
-
value.do === "open_url" ? /* @__PURE__ */ (0,
|
|
6189
|
-
/* @__PURE__ */ (0,
|
|
6190
|
-
/* @__PURE__ */ (0,
|
|
6191
|
-
/* @__PURE__ */ (0,
|
|
6192
|
-
|
|
6597
|
+
value.do === "open_url" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
6598
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Link" }),
|
|
6599
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-1", children: [
|
|
6600
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6601
|
+
import_design_system29.BasicInput,
|
|
6193
6602
|
{
|
|
6194
6603
|
className: "h-8 flex-1 font-mono text-xs",
|
|
6195
6604
|
placeholder: "https://",
|
|
@@ -6198,7 +6607,7 @@ function ButtonSettingsEditor({
|
|
|
6198
6607
|
onChange: (e) => set({ url: e.target.value })
|
|
6199
6608
|
}
|
|
6200
6609
|
),
|
|
6201
|
-
columns.length > 0 ? /* @__PURE__ */ (0,
|
|
6610
|
+
columns.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6202
6611
|
PickOne,
|
|
6203
6612
|
{
|
|
6204
6613
|
label: "Add a column's value",
|
|
@@ -6211,10 +6620,10 @@ function ButtonSettingsEditor({
|
|
|
6211
6620
|
}
|
|
6212
6621
|
) : null
|
|
6213
6622
|
] }),
|
|
6214
|
-
value.url && (0,
|
|
6623
|
+
value.url && (0, import_records24.buttonUrlPlaceholders)(value.url).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "truncate text-[11px] text-muted-foreground", "data-records-button-url-words": "", children: buttonUrlInWords(value.url, fields) }) : null
|
|
6215
6624
|
] }) : null,
|
|
6216
|
-
value.do === "run_action" ? !tableId ? /* @__PURE__ */ (0,
|
|
6217
|
-
actions === null || actions.length > 0 ? /* @__PURE__ */ (0,
|
|
6625
|
+
value.do === "run_action" ? !tableId ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-muted-foreground", children: "Row actions belong to a table" }) : actionsRefused ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RefusalLine, { error: actionsRefused }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-2", "data-records-button-action": "", children: [
|
|
6626
|
+
actions === null || actions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6218
6627
|
PickOne,
|
|
6219
6628
|
{
|
|
6220
6629
|
label: "Row action",
|
|
@@ -6225,7 +6634,7 @@ function ButtonSettingsEditor({
|
|
|
6225
6634
|
options: (actions ?? []).map((a) => ({ value: a.id, label: a.name }))
|
|
6226
6635
|
}
|
|
6227
6636
|
) : null,
|
|
6228
|
-
actions !== null ? /* @__PURE__ */ (0,
|
|
6637
|
+
actions !== null ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6229
6638
|
NewRowAction,
|
|
6230
6639
|
{
|
|
6231
6640
|
tableId,
|
|
@@ -6239,7 +6648,7 @@ function ButtonSettingsEditor({
|
|
|
6239
6648
|
}
|
|
6240
6649
|
) : null
|
|
6241
6650
|
] }) : null,
|
|
6242
|
-
value.do === "run_automation" ? automations && automations.length === 0 ? /* @__PURE__ */ (0,
|
|
6651
|
+
value.do === "run_automation" ? automations && automations.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-muted-foreground", children: "No automations yet. Add one in Table \u22EF \u2192 Automations." }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6243
6652
|
PickOne,
|
|
6244
6653
|
{
|
|
6245
6654
|
label: "Automation",
|
|
@@ -6264,13 +6673,13 @@ function NewRowAction({
|
|
|
6264
6673
|
columns,
|
|
6265
6674
|
onMade
|
|
6266
6675
|
}) {
|
|
6267
|
-
const client = (0,
|
|
6676
|
+
const client = (0, import_react48.useOptionalRecordsClient)();
|
|
6268
6677
|
const settable = settableColumns(columns);
|
|
6269
|
-
const [fieldId, setFieldId] = (0,
|
|
6270
|
-
const [setTo, setSetTo] = (0,
|
|
6271
|
-
const [busy, setBusy] = (0,
|
|
6272
|
-
const [refused, setRefused] = (0,
|
|
6273
|
-
if (settable.length === 0) return /* @__PURE__ */ (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);
|
|
6682
|
+
if (settable.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
|
|
6274
6683
|
const make = async () => {
|
|
6275
6684
|
if (!client || fieldId === "") return;
|
|
6276
6685
|
setBusy(true);
|
|
@@ -6294,10 +6703,10 @@ function NewRowAction({
|
|
|
6294
6703
|
if (!made?.id) return setRefused({ code: "internal", message: "The row action was saved but could not be read back.", hint: "Reopen this column's settings and pick it from the list." });
|
|
6295
6704
|
onMade(made.id, all);
|
|
6296
6705
|
};
|
|
6297
|
-
return /* @__PURE__ */ (0,
|
|
6298
|
-
/* @__PURE__ */ (0,
|
|
6299
|
-
/* @__PURE__ */ (0,
|
|
6300
|
-
/* @__PURE__ */ (0,
|
|
6706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", "data-records-button-new-action": "", children: [
|
|
6707
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "New row action" }),
|
|
6708
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
6709
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6301
6710
|
PickOne,
|
|
6302
6711
|
{
|
|
6303
6712
|
label: "Column to set",
|
|
@@ -6309,19 +6718,19 @@ function NewRowAction({
|
|
|
6309
6718
|
options: settable.map((f) => ({ value: f.id, label: fieldName(f) }))
|
|
6310
6719
|
}
|
|
6311
6720
|
),
|
|
6312
|
-
/* @__PURE__ */ (0,
|
|
6313
|
-
/* @__PURE__ */ (0,
|
|
6721
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.BasicInput, { className: "h-8 w-32 text-xs", placeholder: "Value", "aria-label": "Value", "data-records-button-action-value": "", value: setTo, onChange: (e) => setSetTo(e.target.value) }),
|
|
6722
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Button, { type: "button", size: "sm", variant: "outline", disabled: busy || fieldId === "", "data-records-button-action-make": "", onClick: () => void make(), children: busy ? "Making\u2026" : "Make" })
|
|
6314
6723
|
] }),
|
|
6315
|
-
refused ? /* @__PURE__ */ (0,
|
|
6724
|
+
refused ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RefusalLine, { error: refused }) : null
|
|
6316
6725
|
] });
|
|
6317
6726
|
}
|
|
6318
6727
|
|
|
6319
6728
|
// src/FieldEditor.tsx
|
|
6320
|
-
var
|
|
6321
|
-
var
|
|
6729
|
+
var import_records26 = require("@ai-matrx/records");
|
|
6730
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6322
6731
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
6323
|
-
var SENSITIVITIES =
|
|
6324
|
-
var AGENT_VISIBILITY =
|
|
6732
|
+
var SENSITIVITIES = import_records26.FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
6733
|
+
var AGENT_VISIBILITY = import_records26.CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
6325
6734
|
var ROLLUP_OPERATIONS = ROLLUP_AGG_VALUES.map((value) => ({
|
|
6326
6735
|
value,
|
|
6327
6736
|
label: ROLLUP_AGG_LABEL[value]
|
|
@@ -6334,7 +6743,7 @@ var FORMULA_OPERATIONS = FORMULA_OP_VALUES.map((value) => ({
|
|
|
6334
6743
|
label: FORMULA_OP_LABEL[value],
|
|
6335
6744
|
joins: FORMULA_OP_JOINS[value]
|
|
6336
6745
|
}));
|
|
6337
|
-
var STORE_BEHAVIOUR = new Map(
|
|
6746
|
+
var STORE_BEHAVIOUR = new Map(import_records26.DECLARABLE_FIELD_KINDS.map((row) => [row.kind, row.behavior]));
|
|
6338
6747
|
function holdsAValueOnAStandardTable(kind) {
|
|
6339
6748
|
if (isSystemFieldKind(kind)) return false;
|
|
6340
6749
|
const behaviour = STORE_BEHAVIOUR.get(kind);
|
|
@@ -6412,16 +6821,16 @@ function FieldEditor(props) {
|
|
|
6412
6821
|
const entityToken = props.entityToken ?? null;
|
|
6413
6822
|
const onEntity = entityToken !== null;
|
|
6414
6823
|
const tableId = props.tableId ?? "";
|
|
6415
|
-
const table = (0,
|
|
6416
|
-
const tableFields = (0,
|
|
6417
|
-
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);
|
|
6418
6827
|
const fields = onEntity ? entityFields : tableFields;
|
|
6419
6828
|
const tableRights2 = useTableRights(onEntity ? null : table.data);
|
|
6420
|
-
const entityRights = (0,
|
|
6421
|
-
const tableMutation = (0,
|
|
6422
|
-
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)();
|
|
6423
6832
|
const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
|
|
6424
|
-
const client = (0,
|
|
6833
|
+
const client = (0, import_react50.useRecordsClient)();
|
|
6425
6834
|
const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
|
|
6426
6835
|
const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
|
|
6427
6836
|
const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
|
|
@@ -6431,56 +6840,56 @@ function FieldEditor(props) {
|
|
|
6431
6840
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6432
6841
|
const start = field ?? copyOf;
|
|
6433
6842
|
const startAs = start ? void 0 : props.startAs;
|
|
6434
|
-
const [label, setLabel] = (0,
|
|
6435
|
-
const [type, setType] = (0,
|
|
6436
|
-
const [required, setRequired] = (0,
|
|
6437
|
-
const [multi, setMulti] = (0,
|
|
6438
|
-
const [dated, setDated] = (0,
|
|
6439
|
-
const [sensitivity, setSensitivity] = (0,
|
|
6440
|
-
const [contextPolicy, setContextPolicy] = (0,
|
|
6441
|
-
const [rules, setRules] = (0,
|
|
6442
|
-
const [startsWith, setStartsWith] = (0,
|
|
6443
|
-
const [ratingMax, setRatingMax] = (0,
|
|
6444
|
-
const savedRules = (0,
|
|
6445
|
-
() => field ? type === "rating" ? (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)(
|
|
6854
|
+
() => field ? type === "rating" ? (0, import_records26.rulesWithTopStar)(field.rules ?? [], (0, import_records26.ratingMaxOf)(field)) : field.rules ?? [] : [],
|
|
6446
6855
|
[field, type]
|
|
6447
6856
|
);
|
|
6448
|
-
const editedRules = (0,
|
|
6449
|
-
const [statusGroups, setStatusGroups] = (0,
|
|
6450
|
-
const [statusKeys, setStatusKeys] = (0,
|
|
6451
|
-
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"] ?? ""));
|
|
6452
6861
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
6453
|
-
const [description, setDescription] = (0,
|
|
6454
|
-
const buttonStart = (0,
|
|
6455
|
-
const [buttonSettings, setButtonSettings] = (0,
|
|
6456
|
-
const prefixStart = (0,
|
|
6457
|
-
const [numberPrefix, setNumberPrefix] = (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);
|
|
6865
|
+
const prefixStart = (0, import_records25.autonumberPrefixOf)(start);
|
|
6866
|
+
const [numberPrefix, setNumberPrefix] = (0, import_react49.useState)(prefixStart);
|
|
6458
6867
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6459
|
-
const [dependency, setDependency] = (0,
|
|
6460
|
-
(0,
|
|
6868
|
+
const [dependency, setDependency] = (0, import_react49.useState)(dependencyStart);
|
|
6869
|
+
(0, import_react49.useEffect)(() => {
|
|
6461
6870
|
if (!field || type !== "status") return;
|
|
6462
6871
|
let live = true;
|
|
6463
6872
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
6464
|
-
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0,
|
|
6873
|
+
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0, import_records26.optionKey)(o)])));
|
|
6465
6874
|
});
|
|
6466
6875
|
return () => {
|
|
6467
6876
|
live = false;
|
|
6468
6877
|
};
|
|
6469
6878
|
}, [client, field, type]);
|
|
6470
|
-
(0,
|
|
6879
|
+
(0, import_react49.useEffect)(() => {
|
|
6471
6880
|
if (field || type !== "status") return;
|
|
6472
6881
|
setNewChoices(
|
|
6473
6882
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6474
6883
|
);
|
|
6475
6884
|
}, [field, type]);
|
|
6476
|
-
(0,
|
|
6885
|
+
(0, import_react49.useEffect)(() => {
|
|
6477
6886
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6478
6887
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6479
6888
|
}, [field, type]);
|
|
6480
|
-
const [allowOther, setAllowOther] = (0,
|
|
6481
|
-
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)([]);
|
|
6482
6891
|
const copyOfId = copyOf?.id ?? null;
|
|
6483
|
-
(0,
|
|
6892
|
+
(0, import_react49.useEffect)(() => {
|
|
6484
6893
|
if (!copyOf || !copyOfId) return;
|
|
6485
6894
|
let live = true;
|
|
6486
6895
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6492,53 +6901,53 @@ function FieldEditor(props) {
|
|
|
6492
6901
|
live = false;
|
|
6493
6902
|
};
|
|
6494
6903
|
}, [client, copyOfId]);
|
|
6495
|
-
const [choiceList, setChoiceList] = (0,
|
|
6496
|
-
const [choiceListStart, setChoiceListStart] = (0,
|
|
6497
|
-
const [rehome, setRehome] = (0,
|
|
6498
|
-
const [rehomed, setRehomed] = (0,
|
|
6499
|
-
const [rehomeRefused, setRehomeRefused] = (0,
|
|
6500
|
-
const [unit, setUnit] = (0,
|
|
6501
|
-
const [withTime, setWithTime] = (0,
|
|
6502
|
-
const [via, setVia] = (0,
|
|
6503
|
-
const [pick, setPick] = (0,
|
|
6504
|
-
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)(
|
|
6505
6914
|
start?.config?.["agg"] ?? "count"
|
|
6506
6915
|
);
|
|
6507
|
-
const [of, setOf] = (0,
|
|
6916
|
+
const [of, setOf] = (0, import_react49.useState)(String(start?.config?.["of"] ?? ""));
|
|
6508
6917
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6509
|
-
const [rollupFilter, setRollupFilter] = (0,
|
|
6918
|
+
const [rollupFilter, setRollupFilter] = (0, import_react49.useState)(
|
|
6510
6919
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6511
6920
|
);
|
|
6512
6921
|
const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
|
|
6513
|
-
const [relationTarget, setRelationTarget] = (0,
|
|
6514
|
-
const [showOnOther, setShowOnOther] = (0,
|
|
6515
|
-
const [nestsSubItems, setNestsSubItems] = (0,
|
|
6516
|
-
const [reverseRefused, setReverseRefused] = (0,
|
|
6517
|
-
const otherTable = (0,
|
|
6518
|
-
const [display, setDisplay] = (0,
|
|
6519
|
-
const [formulaOp, setFormulaOp] = (0,
|
|
6520
|
-
const [formulaFields, setFormulaFields] = (0,
|
|
6521
|
-
const [formulaSeparator, setFormulaSeparator] = (0,
|
|
6522
|
-
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));
|
|
6523
6932
|
const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
|
|
6524
|
-
const [formulaText, setFormulaText] = (0,
|
|
6525
|
-
const shownFormula = (0,
|
|
6526
|
-
(0,
|
|
6933
|
+
const [formulaText, setFormulaText] = (0, import_react49.useState)(startingFormulaText);
|
|
6934
|
+
const shownFormula = (0, import_react49.useRef)(startingFormulaText);
|
|
6935
|
+
(0, import_react49.useEffect)(() => {
|
|
6527
6936
|
if (shownFormula.current === startingFormulaText) return;
|
|
6528
6937
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6529
6938
|
shownFormula.current = startingFormulaText;
|
|
6530
6939
|
}, [startingFormulaText]);
|
|
6531
|
-
const [formulaWritten, setFormulaWritten] = (0,
|
|
6532
|
-
const [formulaOk, setFormulaOk] = (0,
|
|
6533
|
-
const [askingToRemove, setAskingToRemove] = (0,
|
|
6534
|
-
const [attempted, setAttempted] = (0,
|
|
6535
|
-
const [showsAs, setShowsAs] = (0,
|
|
6536
|
-
const [backfillError, setBackfillError] = (0,
|
|
6537
|
-
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);
|
|
6538
6947
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6539
6948
|
const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
|
|
6540
|
-
const seededAs = (0,
|
|
6541
|
-
(0,
|
|
6949
|
+
const seededAs = (0, import_react49.useRef)(heldAs);
|
|
6950
|
+
(0, import_react49.useEffect)(() => {
|
|
6542
6951
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6543
6952
|
seededAs.current = heldAs;
|
|
6544
6953
|
setType(startingType(liveField));
|
|
@@ -6547,24 +6956,24 @@ function FieldEditor(props) {
|
|
|
6547
6956
|
setUnit(liveField.unit ?? "$");
|
|
6548
6957
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6549
6958
|
}, [heldAs]);
|
|
6550
|
-
const others = (0,
|
|
6959
|
+
const others = (0, import_react49.useMemo)(
|
|
6551
6960
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6552
6961
|
[fields.data, field?.id]
|
|
6553
6962
|
);
|
|
6554
|
-
const relations = (0,
|
|
6555
|
-
const reverse = (0,
|
|
6556
|
-
const backLinks = (0,
|
|
6557
|
-
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]);
|
|
6558
6967
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6559
6968
|
const choice = fieldTypeChoice(type);
|
|
6560
6969
|
const editing = Boolean(field);
|
|
6561
|
-
(0,
|
|
6970
|
+
(0, import_react49.useEffect)(() => {
|
|
6562
6971
|
if (!editing) setStartsWith(null);
|
|
6563
6972
|
}, [type, editing]);
|
|
6564
6973
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6565
|
-
const farFieldsOfLink = (0,
|
|
6566
|
-
const farTable = (0,
|
|
6567
|
-
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)(
|
|
6568
6977
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6569
6978
|
[field, farFieldsOfLink.data]
|
|
6570
6979
|
);
|
|
@@ -6572,7 +6981,7 @@ function FieldEditor(props) {
|
|
|
6572
6981
|
const offersMany = multiApplies(type) && !isTitle;
|
|
6573
6982
|
if (!mayShape) {
|
|
6574
6983
|
if (onEntity && entityRights.loading) return null;
|
|
6575
|
-
return /* @__PURE__ */ (0,
|
|
6984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: (0, import_design_system30.cn)("text-xs text-muted-foreground", className), children: props.tableLabel && storeLabel && whyNot ? whyNot.split(storeLabel).join(props.tableLabel) : whyNot });
|
|
6576
6985
|
}
|
|
6577
6986
|
const options = newChoices.map((r) => r.words.trim()).filter((word) => word !== "");
|
|
6578
6987
|
const shownStatusRows = type !== "status" ? [] : statusGroupRows(field, editing ? choiceList ?? [] : newChoices, statusKeys, statusGroups);
|
|
@@ -6584,7 +6993,7 @@ function FieldEditor(props) {
|
|
|
6584
6993
|
const nameTaken = columnNameTakenBy(label, others.map(fieldName));
|
|
6585
6994
|
const nameLine = nameTaken ? columnNameTakenLine(nameTaken, noun) : columnNameProblemLine(label, noun);
|
|
6586
6995
|
const listsChoices = type === "select" || type === "multi_select" || type === "status";
|
|
6587
|
-
const buttonMissing = type === "button" && buttonSettings.do ? (0,
|
|
6996
|
+
const buttonMissing = type === "button" && buttonSettings.do ? (0, import_records25.buttonNeeds)(buttonSettings) : null;
|
|
6588
6997
|
const missing = buttonMissing ?? (editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
|
|
6589
6998
|
type === "count" ? { type: "rollup", label, options, via, pick, agg: "count", of, relations: totalSources, formulaFields, relationTarget, allowedTypes, noun } : { type, label, options, via, pick, agg, of, relations: sourcesFor(type), formulaFields, relationTarget, allowedTypes, noun }
|
|
6590
6999
|
)));
|
|
@@ -6626,7 +7035,7 @@ function FieldEditor(props) {
|
|
|
6626
7035
|
...statusGroupsChanged ? { status_groups: statusGroupsSent } : {},
|
|
6627
7036
|
// V11 #4/#10: a rating's top star goes as `max`, the word custom.field_update now takes the way
|
|
6628
7037
|
// custom.field_declare does; the store writes the max Rule and sets aside any score above it.
|
|
6629
|
-
...type === "rating" && ratingMax !== (0,
|
|
7038
|
+
...type === "rating" && ratingMax !== (0, import_records26.ratingMaxOf)(field) ? { max: ratingMax } : {},
|
|
6630
7039
|
...type === "barcode" && symbology !== String(field.config?.["symbology"] ?? "") ? { symbology: symbology === "" ? null : symbology } : {},
|
|
6631
7040
|
...type === "button" && JSON.stringify(buttonSettings) !== JSON.stringify(buttonStart) ? { button: buttonSettings } : {},
|
|
6632
7041
|
...field.type === "relation" && dependency !== dependencyStart ? { dependency } : {},
|
|
@@ -6660,7 +7069,7 @@ function FieldEditor(props) {
|
|
|
6660
7069
|
setRehomeRefused(done.error);
|
|
6661
7070
|
return;
|
|
6662
7071
|
}
|
|
6663
|
-
(0,
|
|
7072
|
+
(0, import_react50.tableShapeChanged)(tableId);
|
|
6664
7073
|
for (const c of done.data.undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
6665
7074
|
const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
|
|
6666
7075
|
setRehome({});
|
|
@@ -6735,7 +7144,7 @@ function FieldEditor(props) {
|
|
|
6735
7144
|
if (newDefault !== null && newColumnDefaultGoes(type) === "right-after") {
|
|
6736
7145
|
const defaulted = await client.fieldUpdate({ field_id: written, patch: { default: newDefault } });
|
|
6737
7146
|
if (!defaulted.ok) {
|
|
6738
|
-
(0,
|
|
7147
|
+
(0, import_react50.tableShapeChanged)(tableId);
|
|
6739
7148
|
setBackfillError(defaulted.error);
|
|
6740
7149
|
return;
|
|
6741
7150
|
}
|
|
@@ -6761,7 +7170,7 @@ function FieldEditor(props) {
|
|
|
6761
7170
|
setReverseRefused(made.error);
|
|
6762
7171
|
return;
|
|
6763
7172
|
}
|
|
6764
|
-
(0,
|
|
7173
|
+
(0, import_react50.tableShapeChanged)(relationTarget);
|
|
6765
7174
|
}
|
|
6766
7175
|
setReverseRefused(null);
|
|
6767
7176
|
onSaved?.();
|
|
@@ -6772,16 +7181,16 @@ function FieldEditor(props) {
|
|
|
6772
7181
|
if (gone) (onRemoved ?? onSaved)?.();
|
|
6773
7182
|
else setAskingToRemove(false);
|
|
6774
7183
|
};
|
|
6775
|
-
return /* @__PURE__ */ (0,
|
|
6776
|
-
/* @__PURE__ */ (0,
|
|
6777
|
-
/* @__PURE__ */ (0,
|
|
6778
|
-
/* @__PURE__ */ (0,
|
|
7184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: (0, import_design_system30.cn)("flex min-w-0 flex-col gap-3 text-xs", className), "data-records-field-editor": "", children: [
|
|
7185
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
7186
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "font-medium", children: field ? `Field \xB7 ${fieldName(field)}` : "New field" }),
|
|
7187
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "ml-auto text-muted-foreground", children: tableLabel })
|
|
6779
7188
|
] }),
|
|
6780
|
-
/* @__PURE__ */ (0,
|
|
6781
|
-
/* @__PURE__ */ (0,
|
|
6782
|
-
/* @__PURE__ */ (0,
|
|
6783
|
-
/* @__PURE__ */ (0,
|
|
6784
|
-
|
|
7189
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7190
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
7191
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Name" }),
|
|
7192
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7193
|
+
import_design_system30.BasicInput,
|
|
6785
7194
|
{
|
|
6786
7195
|
value: label,
|
|
6787
7196
|
autoFocus: true,
|
|
@@ -6796,7 +7205,7 @@ function FieldEditor(props) {
|
|
|
6796
7205
|
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6797
7206
|
}
|
|
6798
7207
|
),
|
|
6799
|
-
nameLine ? /* @__PURE__ */ (0,
|
|
7208
|
+
nameLine ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6800
7209
|
"span",
|
|
6801
7210
|
{
|
|
6802
7211
|
id: "field-editor-name-taken",
|
|
@@ -6807,10 +7216,10 @@ function FieldEditor(props) {
|
|
|
6807
7216
|
}
|
|
6808
7217
|
) : null
|
|
6809
7218
|
] }),
|
|
6810
|
-
field ? /* @__PURE__ */ (0,
|
|
6811
|
-
/* @__PURE__ */ (0,
|
|
6812
|
-
/* @__PURE__ */ (0,
|
|
6813
|
-
|
|
7219
|
+
field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex flex-col gap-1 sm:col-span-2", children: [
|
|
7220
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Help text" }),
|
|
7221
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7222
|
+
import_design_system30.BasicInput,
|
|
6814
7223
|
{
|
|
6815
7224
|
value: description,
|
|
6816
7225
|
maxLength: 300,
|
|
@@ -6820,30 +7229,30 @@ function FieldEditor(props) {
|
|
|
6820
7229
|
}
|
|
6821
7230
|
)
|
|
6822
7231
|
] }) : null,
|
|
6823
|
-
/* @__PURE__ */ (0,
|
|
6824
|
-
/* @__PURE__ */ (0,
|
|
6825
|
-
/* @__PURE__ */ (0,
|
|
6826
|
-
|
|
7232
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7233
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "What it holds" }),
|
|
7234
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
7235
|
+
import_design_system30.Select,
|
|
6827
7236
|
{
|
|
6828
7237
|
value: type,
|
|
6829
7238
|
disabled: editing,
|
|
6830
7239
|
onValueChange: (next) => setType(next),
|
|
6831
7240
|
children: [
|
|
6832
|
-
/* @__PURE__ */ (0,
|
|
6833
|
-
/* @__PURE__ */ (0,
|
|
6834
|
-
/* @__PURE__ */ (0,
|
|
6835
|
-
FIELD_TYPE_CATALOGUE.filter((c) => c.group === group && (c.id === type || offered.includes(c))).map((c) => /* @__PURE__ */ (0,
|
|
7241
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", "aria-label": "What this field holds", ...choice?.explanation ? { title: choice.explanation } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
7242
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: FIELD_TYPE_GROUPS.filter((group) => offered.some((c) => c.group === group)).map((group) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.SelectGroup, { children: [
|
|
7243
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectLabel, { children: group }),
|
|
7244
|
+
FIELD_TYPE_CATALOGUE.filter((c) => c.group === group && (c.id === type || offered.includes(c))).map((c) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: c.id, children: c.label }, c.id))
|
|
6836
7245
|
] }, group)) })
|
|
6837
7246
|
]
|
|
6838
7247
|
}
|
|
6839
7248
|
),
|
|
6840
|
-
editing && field ? /* @__PURE__ */ (0,
|
|
7249
|
+
editing && field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldRetype, { field: liveField ?? field, tableId }) : null
|
|
6841
7250
|
] })
|
|
6842
7251
|
] }),
|
|
6843
|
-
type === "formula" && others.length > 0 ? /* @__PURE__ */ (0,
|
|
6844
|
-
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */ (0,
|
|
6845
|
-
/* @__PURE__ */ (0,
|
|
6846
|
-
|
|
7252
|
+
type === "formula" && others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
7253
|
+
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: EDITING_A_WORKED_OUT_COLUMN }) : null : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-1", role: "group", "aria-label": "How to make this column", children: [
|
|
7254
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7255
|
+
import_design_system30.Button,
|
|
6847
7256
|
{
|
|
6848
7257
|
type: "button",
|
|
6849
7258
|
size: "sm",
|
|
@@ -6853,8 +7262,8 @@ function FieldEditor(props) {
|
|
|
6853
7262
|
children: "Pick the columns"
|
|
6854
7263
|
}
|
|
6855
7264
|
),
|
|
6856
|
-
/* @__PURE__ */ (0,
|
|
6857
|
-
|
|
7265
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7266
|
+
import_design_system30.Button,
|
|
6858
7267
|
{
|
|
6859
7268
|
type: "button",
|
|
6860
7269
|
size: "sm",
|
|
@@ -6865,7 +7274,7 @@ function FieldEditor(props) {
|
|
|
6865
7274
|
}
|
|
6866
7275
|
)
|
|
6867
7276
|
] }),
|
|
6868
|
-
formulaWritten ? /* @__PURE__ */ (0,
|
|
7277
|
+
formulaWritten ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6869
7278
|
FormulaTextEditor,
|
|
6870
7279
|
{
|
|
6871
7280
|
tableId,
|
|
@@ -6875,9 +7284,9 @@ function FieldEditor(props) {
|
|
|
6875
7284
|
columns: others
|
|
6876
7285
|
}
|
|
6877
7286
|
) : null
|
|
6878
|
-
] }) : editing && type === "formula" ? /* @__PURE__ */ (0,
|
|
6879
|
-
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */ (0,
|
|
6880
|
-
!editing && !(type === "formula" && formulaWritten) || type === "select" || type === "multi_select" || type === "status" || type === "rating" || type === "barcode" || type === "relation" || type === "entity_reference" ? /* @__PURE__ */ (0,
|
|
7287
|
+
] }) : editing && type === "formula" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No other column to read." }) : null,
|
|
7288
|
+
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(SourceArchivedNotice, { fieldId: field.id, tableId }) : null,
|
|
7289
|
+
!editing && !(type === "formula" && formulaWritten) || type === "select" || type === "multi_select" || type === "status" || type === "rating" || type === "barcode" || type === "relation" || type === "entity_reference" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6881
7290
|
TypeQuestions,
|
|
6882
7291
|
{
|
|
6883
7292
|
type,
|
|
@@ -6907,7 +7316,7 @@ function FieldEditor(props) {
|
|
|
6907
7316
|
setFormulaSeparator,
|
|
6908
7317
|
relations: sourcesFor(type),
|
|
6909
7318
|
others,
|
|
6910
|
-
choiceList: editing && field ? /* @__PURE__ */ (0,
|
|
7319
|
+
choiceList: editing && field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6911
7320
|
ChoiceListEditor,
|
|
6912
7321
|
{
|
|
6913
7322
|
field,
|
|
@@ -6918,10 +7327,10 @@ function FieldEditor(props) {
|
|
|
6918
7327
|
rehome,
|
|
6919
7328
|
onRehome: setRehome
|
|
6920
7329
|
}
|
|
6921
|
-
) : /* @__PURE__ */ (0,
|
|
7330
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChoiceListEditor, { isNew: true, rows: newChoices, onRows: setNewChoices }),
|
|
6922
7331
|
allowedTypes,
|
|
6923
7332
|
setAllowedTypes,
|
|
6924
|
-
newer: type === "rating" ? /* @__PURE__ */ (0,
|
|
7333
|
+
newer: type === "rating" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6925
7334
|
RatingMaxQuestion,
|
|
6926
7335
|
{
|
|
6927
7336
|
value: ratingMax,
|
|
@@ -6929,19 +7338,19 @@ function FieldEditor(props) {
|
|
|
6929
7338
|
setRatingMax(next);
|
|
6930
7339
|
}
|
|
6931
7340
|
}
|
|
6932
|
-
) : type === "status" ? /* @__PURE__ */ (0,
|
|
7341
|
+
) : type === "status" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(StatusGroupsQuestion, { rows: shownStatusRows, onGroup: (ref, next) => setStatusGroups({ ...statusGroups, [ref]: next }) }) : type === "barcode" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(BarcodeSymbologyQuestion, { value: symbology, onChange: setSymbology }) : null
|
|
6933
7342
|
}
|
|
6934
7343
|
) : null,
|
|
6935
|
-
type === "button" ? /* @__PURE__ */ (0,
|
|
6936
|
-
type === "autonumber" ? /* @__PURE__ */ (0,
|
|
6937
|
-
/* @__PURE__ */ (0,
|
|
6938
|
-
/* @__PURE__ */ (0,
|
|
7344
|
+
type === "button" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ButtonSettingsEditor, { value: buttonSettings, onChange: setButtonSettings, tableId: onEntity ? null : tableId, fields: others }) : null,
|
|
7345
|
+
type === "autonumber" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7346
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Prefix" }),
|
|
7347
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.BasicInput, { className: "h-8 text-xs", placeholder: "TASK-", maxLength: 16, "data-records-autonumber-prefix": "", value: numberPrefix, onChange: (e) => setNumberPrefix(e.target.value) })
|
|
6939
7348
|
] }) : null,
|
|
6940
|
-
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */ (0,
|
|
6941
|
-
/* @__PURE__ */ (0,
|
|
6942
|
-
/* @__PURE__ */ (0,
|
|
7349
|
+
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5 text-sm", title: "A timeline draws a line to each record this one waits on", children: [
|
|
7350
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Checkbox, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
|
|
7351
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: "Waits on the linked records" })
|
|
6943
7352
|
] }) : null,
|
|
6944
|
-
type === "rollup" ? /* @__PURE__ */ (0,
|
|
7353
|
+
type === "rollup" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6945
7354
|
RollupFilterQuestion,
|
|
6946
7355
|
{
|
|
6947
7356
|
relation: totalSources.find((f) => f.key === via),
|
|
@@ -6951,22 +7360,22 @@ function FieldEditor(props) {
|
|
|
6951
7360
|
onChange: setRollupFilter
|
|
6952
7361
|
}
|
|
6953
7362
|
) : null,
|
|
6954
|
-
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */ (0,
|
|
6955
|
-
/* @__PURE__ */ (0,
|
|
6956
|
-
/* @__PURE__ */ (0,
|
|
6957
|
-
/* @__PURE__ */ (0,
|
|
6958
|
-
|
|
7363
|
+
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldFormatPicker, { field, value: showsAs, onValue: setShowsAs }) : null,
|
|
7364
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-wrap items-center gap-4", children: [
|
|
7365
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7366
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7367
|
+
import_design_system30.Checkbox,
|
|
6959
7368
|
{
|
|
6960
7369
|
checked: required,
|
|
6961
7370
|
"aria-label": "Required",
|
|
6962
7371
|
onCheckedChange: (v) => setRequired(v === true)
|
|
6963
7372
|
}
|
|
6964
7373
|
),
|
|
6965
|
-
/* @__PURE__ */ (0,
|
|
7374
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { title: "Every record has to have one", children: "Required" })
|
|
6966
7375
|
] }),
|
|
6967
|
-
offersMany ? /* @__PURE__ */ (0,
|
|
6968
|
-
/* @__PURE__ */ (0,
|
|
6969
|
-
|
|
7376
|
+
offersMany ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7377
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7378
|
+
import_design_system30.Checkbox,
|
|
6970
7379
|
{
|
|
6971
7380
|
checked: multi,
|
|
6972
7381
|
"aria-label": "Can hold more than one",
|
|
@@ -6975,9 +7384,9 @@ function FieldEditor(props) {
|
|
|
6975
7384
|
),
|
|
6976
7385
|
"Can hold more than one"
|
|
6977
7386
|
] }) : null,
|
|
6978
|
-
/* @__PURE__ */ (0,
|
|
6979
|
-
/* @__PURE__ */ (0,
|
|
6980
|
-
|
|
7387
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7388
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7389
|
+
import_design_system30.Checkbox,
|
|
6981
7390
|
{
|
|
6982
7391
|
checked: dated,
|
|
6983
7392
|
"aria-label": "Each value has its own date",
|
|
@@ -6986,9 +7395,9 @@ function FieldEditor(props) {
|
|
|
6986
7395
|
),
|
|
6987
7396
|
"Each value has its own date"
|
|
6988
7397
|
] }),
|
|
6989
|
-
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ (0,
|
|
6990
|
-
/* @__PURE__ */ (0,
|
|
6991
|
-
|
|
7398
|
+
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7399
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7400
|
+
import_design_system30.Checkbox,
|
|
6992
7401
|
{
|
|
6993
7402
|
checked: showOnOther,
|
|
6994
7403
|
"aria-label": `Show on ${otherTable.data.name ?? "the other table"}`,
|
|
@@ -6999,13 +7408,13 @@ function FieldEditor(props) {
|
|
|
6999
7408
|
"Show on ",
|
|
7000
7409
|
otherTable.data.name ?? "the other table"
|
|
7001
7410
|
] }) : null,
|
|
7002
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0,
|
|
7003
|
-
/* @__PURE__ */ (0,
|
|
7004
|
-
/* @__PURE__ */ (0,
|
|
7411
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", title: "A timeline draws a line to each record this one waits on", children: [
|
|
7412
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Checkbox, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
|
|
7413
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: "Waits on the linked records" })
|
|
7005
7414
|
] }) : null,
|
|
7006
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0,
|
|
7007
|
-
/* @__PURE__ */ (0,
|
|
7008
|
-
|
|
7415
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7416
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7417
|
+
import_design_system30.Checkbox,
|
|
7009
7418
|
{
|
|
7010
7419
|
checked: nestsSubItems,
|
|
7011
7420
|
"aria-label": "Sub-items",
|
|
@@ -7016,11 +7425,11 @@ function FieldEditor(props) {
|
|
|
7016
7425
|
"data-records-sub-items": ""
|
|
7017
7426
|
}
|
|
7018
7427
|
),
|
|
7019
|
-
/* @__PURE__ */ (0,
|
|
7428
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { title: "Each record sits under the one this column names", children: "Sub-items" })
|
|
7020
7429
|
] }) : null,
|
|
7021
|
-
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */ (0,
|
|
7022
|
-
/* @__PURE__ */ (0,
|
|
7023
|
-
|
|
7430
|
+
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7431
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7432
|
+
import_design_system30.Checkbox,
|
|
7024
7433
|
{
|
|
7025
7434
|
checked: allowOther,
|
|
7026
7435
|
"aria-label": "A value that is not one of the choices is added to them",
|
|
@@ -7030,10 +7439,10 @@ function FieldEditor(props) {
|
|
|
7030
7439
|
"A value that is not one of the choices is added to them"
|
|
7031
7440
|
] }) : null
|
|
7032
7441
|
] }),
|
|
7033
|
-
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ (0,
|
|
7034
|
-
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ (0,
|
|
7035
|
-
/* @__PURE__ */ (0,
|
|
7036
|
-
/* @__PURE__ */ (0,
|
|
7442
|
+
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(NewColumnDefault, { type, choices: options, value: startsWith, onChange: setStartsWith }) : null,
|
|
7443
|
+
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", "data-records-field-default": "", children: [
|
|
7444
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { htmlFor: "records-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7445
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7037
7446
|
FieldControl,
|
|
7038
7447
|
{
|
|
7039
7448
|
id: "records-field-default",
|
|
@@ -7043,29 +7452,29 @@ function FieldEditor(props) {
|
|
|
7043
7452
|
}
|
|
7044
7453
|
)
|
|
7045
7454
|
] }) : null,
|
|
7046
|
-
/* @__PURE__ */ (0,
|
|
7047
|
-
/* @__PURE__ */ (0,
|
|
7048
|
-
/* @__PURE__ */ (0,
|
|
7049
|
-
/* @__PURE__ */ (0,
|
|
7050
|
-
/* @__PURE__ */ (0,
|
|
7051
|
-
/* @__PURE__ */ (0,
|
|
7052
|
-
/* @__PURE__ */ (0,
|
|
7455
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Separator, {}),
|
|
7456
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7457
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7458
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Who can see what is in it" }),
|
|
7459
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: sensitivity, onValueChange: setSensitivity, children: [
|
|
7460
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", "aria-label": "Who can see what is in it", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
7461
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: sensitivities.map((row) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: row.value, children: row.label }, row.value)) })
|
|
7053
7462
|
] })
|
|
7054
7463
|
] }),
|
|
7055
|
-
/* @__PURE__ */ (0,
|
|
7056
|
-
/* @__PURE__ */ (0,
|
|
7057
|
-
/* @__PURE__ */ (0,
|
|
7058
|
-
/* @__PURE__ */ (0,
|
|
7059
|
-
/* @__PURE__ */ (0,
|
|
7464
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7465
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Can an assistant read it" }),
|
|
7466
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: contextPolicy, onValueChange: setContextPolicy, children: [
|
|
7467
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", "aria-label": "Can an assistant read it", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
7468
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: AGENT_VISIBILITY.map((row) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: row.value, children: row.label }, row.value)) })
|
|
7060
7469
|
] })
|
|
7061
7470
|
] })
|
|
7062
7471
|
] }),
|
|
7063
|
-
/* @__PURE__ */ (0,
|
|
7064
|
-
/* @__PURE__ */ (0,
|
|
7065
|
-
/* @__PURE__ */ (0,
|
|
7066
|
-
/* @__PURE__ */ (0,
|
|
7067
|
-
/* @__PURE__ */ (0,
|
|
7068
|
-
|
|
7472
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Separator, {}),
|
|
7473
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
7474
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
7475
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "font-medium", children: "What counts as a good value" }),
|
|
7476
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7477
|
+
import_design_system30.Button,
|
|
7069
7478
|
{
|
|
7070
7479
|
type: "button",
|
|
7071
7480
|
size: "sm",
|
|
@@ -7076,9 +7485,9 @@ function FieldEditor(props) {
|
|
|
7076
7485
|
}
|
|
7077
7486
|
)
|
|
7078
7487
|
] }),
|
|
7079
|
-
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */ (0,
|
|
7080
|
-
/* @__PURE__ */ (0,
|
|
7081
|
-
|
|
7488
|
+
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", "data-records-field-unique": "", children: [
|
|
7489
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7490
|
+
import_design_system30.Checkbox,
|
|
7082
7491
|
{
|
|
7083
7492
|
checked: rules.some((r) => r.kind === "unique"),
|
|
7084
7493
|
"aria-label": UNIQUE_LABEL,
|
|
@@ -7087,21 +7496,21 @@ function FieldEditor(props) {
|
|
|
7087
7496
|
),
|
|
7088
7497
|
UNIQUE_LABEL
|
|
7089
7498
|
] }) : null,
|
|
7090
|
-
rules.length === 0 ? /* @__PURE__ */ (0,
|
|
7091
|
-
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ (0,
|
|
7092
|
-
/* @__PURE__ */ (0,
|
|
7093
|
-
|
|
7499
|
+
rules.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-muted-foreground", children: "No checks." }) : null,
|
|
7500
|
+
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
7501
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
7502
|
+
import_design_system30.Select,
|
|
7094
7503
|
{
|
|
7095
7504
|
value: rule.kind,
|
|
7096
7505
|
onValueChange: (kind) => setRules(rules.map((r, i) => i === index ? { ...r, kind } : r)),
|
|
7097
7506
|
children: [
|
|
7098
|
-
/* @__PURE__ */ (0,
|
|
7099
|
-
/* @__PURE__ */ (0,
|
|
7507
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", className: "w-52", "aria-label": `Check ${index + 1}`, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
7508
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: RULE_KINDS.map((row) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: row.kind, children: row.label }, row.kind)) })
|
|
7100
7509
|
]
|
|
7101
7510
|
}
|
|
7102
7511
|
),
|
|
7103
|
-
rule.kind === "length" ? /* @__PURE__ */ (0,
|
|
7104
|
-
|
|
7512
|
+
rule.kind === "length" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7513
|
+
import_design_system30.BasicInput,
|
|
7105
7514
|
{
|
|
7106
7515
|
className: "h-8 w-24",
|
|
7107
7516
|
inputMode: "numeric",
|
|
@@ -7111,8 +7520,8 @@ function FieldEditor(props) {
|
|
|
7111
7520
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withNumber(r, "min", e.target.value) : r))
|
|
7112
7521
|
}
|
|
7113
7522
|
) : null,
|
|
7114
|
-
/* @__PURE__ */ (0,
|
|
7115
|
-
|
|
7523
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7524
|
+
import_design_system30.BasicInput,
|
|
7116
7525
|
{
|
|
7117
7526
|
className: "h-8",
|
|
7118
7527
|
...rule.kind === "length" ? { inputMode: "numeric", placeholder: "most" } : {},
|
|
@@ -7121,8 +7530,8 @@ function FieldEditor(props) {
|
|
|
7121
7530
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? { ...r, value: e.target.value } : r))
|
|
7122
7531
|
}
|
|
7123
7532
|
),
|
|
7124
|
-
rule.kind === "pattern" ? /* @__PURE__ */ (0,
|
|
7125
|
-
|
|
7533
|
+
rule.kind === "pattern" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7534
|
+
import_design_system30.BasicInput,
|
|
7126
7535
|
{
|
|
7127
7536
|
className: "h-8",
|
|
7128
7537
|
placeholder: "for example 949-555-0142",
|
|
@@ -7131,8 +7540,8 @@ function FieldEditor(props) {
|
|
|
7131
7540
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withText(r, "example", e.target.value) : r))
|
|
7132
7541
|
}
|
|
7133
7542
|
) : null,
|
|
7134
|
-
/* @__PURE__ */ (0,
|
|
7135
|
-
|
|
7543
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7544
|
+
import_design_system30.Button,
|
|
7136
7545
|
{
|
|
7137
7546
|
type: "button",
|
|
7138
7547
|
size: "sm",
|
|
@@ -7144,9 +7553,9 @@ function FieldEditor(props) {
|
|
|
7144
7553
|
)
|
|
7145
7554
|
] }, `${rule.kind}-${index}`))
|
|
7146
7555
|
] }),
|
|
7147
|
-
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ (0,
|
|
7148
|
-
mutation.error ? /* @__PURE__ */ (0,
|
|
7149
|
-
notLanded ? /* @__PURE__ */ (0,
|
|
7556
|
+
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldRulePreview, { field, tableId, rules: editedRules }) : null,
|
|
7557
|
+
mutation.error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: mutation.error }) : null,
|
|
7558
|
+
notLanded ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7150
7559
|
RefusalNotice,
|
|
7151
7560
|
{
|
|
7152
7561
|
error: (0, refusals_exports.refusal)(
|
|
@@ -7156,11 +7565,11 @@ function FieldEditor(props) {
|
|
|
7156
7565
|
)
|
|
7157
7566
|
}
|
|
7158
7567
|
) : null,
|
|
7159
|
-
rehomeRefused ? /* @__PURE__ */ (0,
|
|
7160
|
-
rehomed ? /* @__PURE__ */ (0,
|
|
7161
|
-
/* @__PURE__ */ (0,
|
|
7162
|
-
rehomed.undo ? /* @__PURE__ */ (0,
|
|
7163
|
-
|
|
7568
|
+
rehomeRefused ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: rehomeRefused }) : null,
|
|
7569
|
+
rehomed ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-records-choice-rehomed": "", className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
7570
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: rehomed.said }),
|
|
7571
|
+
rehomed.undo ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7572
|
+
import_design_system30.Button,
|
|
7164
7573
|
{
|
|
7165
7574
|
type: "button",
|
|
7166
7575
|
size: "sm",
|
|
@@ -7174,7 +7583,7 @@ function FieldEditor(props) {
|
|
|
7174
7583
|
setRehomeRefused(back.error);
|
|
7175
7584
|
return;
|
|
7176
7585
|
}
|
|
7177
|
-
(0,
|
|
7586
|
+
(0, import_react50.tableShapeChanged)(tableId);
|
|
7178
7587
|
for (const c of undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
7179
7588
|
setChoiceList(null);
|
|
7180
7589
|
setChoiceListStart(null);
|
|
@@ -7184,19 +7593,19 @@ function FieldEditor(props) {
|
|
|
7184
7593
|
children: "Undo"
|
|
7185
7594
|
}
|
|
7186
7595
|
) : null,
|
|
7187
|
-
/* @__PURE__ */ (0,
|
|
7596
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Button, { type: "button", size: "sm", className: "h-6 px-2 text-xs", onClick: () => onSaved?.(), children: "Done" })
|
|
7188
7597
|
] }) : null,
|
|
7189
|
-
reverseRefused ? /* @__PURE__ */ (0,
|
|
7190
|
-
/* @__PURE__ */ (0,
|
|
7191
|
-
/* @__PURE__ */ (0,
|
|
7598
|
+
reverseRefused ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-records-reverse-field-refused": "", className: "flex flex-col gap-1", children: [
|
|
7599
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px]", children: "The link is made. Its column on the other table was not:" }),
|
|
7600
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: reverseRefused })
|
|
7192
7601
|
] }) : null,
|
|
7193
|
-
backfillError ? /* @__PURE__ */ (0,
|
|
7194
|
-
/* @__PURE__ */ (0,
|
|
7195
|
-
/* @__PURE__ */ (0,
|
|
7602
|
+
backfillError ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-records-autonumber-backfill-refused": "", className: "flex flex-col gap-1", children: [
|
|
7603
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px]", children: "The column is made. The records already in the table were not numbered:" }),
|
|
7604
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: backfillError })
|
|
7196
7605
|
] }) : null,
|
|
7197
|
-
/* @__PURE__ */ (0,
|
|
7198
|
-
/* @__PURE__ */ (0,
|
|
7199
|
-
|
|
7606
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex min-w-0 flex-nowrap items-center gap-2", "data-field-editor-footer": "", children: [
|
|
7607
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7608
|
+
import_design_system30.Button,
|
|
7200
7609
|
{
|
|
7201
7610
|
size: "sm",
|
|
7202
7611
|
disabled: mutation.saving || Boolean(formulaMissing) || Boolean(nameLine) && label.trim() !== (field?.label ?? "").trim(),
|
|
@@ -7211,8 +7620,8 @@ function FieldEditor(props) {
|
|
|
7211
7620
|
children: mutation.saving ? "Saving\u2026" : field ? EDIT_FIELD_SAVE_LABEL : onEntity ? ADD_STANDARD_FIELD_SAVE_LABEL : ADD_FIELD_SAVE_LABEL
|
|
7212
7621
|
}
|
|
7213
7622
|
),
|
|
7214
|
-
onCancel ? /* @__PURE__ */ (0,
|
|
7215
|
-
/* @__PURE__ */ (0,
|
|
7623
|
+
onCancel ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Button, { size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }) : null,
|
|
7624
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7216
7625
|
"span",
|
|
7217
7626
|
{
|
|
7218
7627
|
id: "field-editor-missing",
|
|
@@ -7228,12 +7637,12 @@ function FieldEditor(props) {
|
|
|
7228
7637
|
footer is always as wide and as tall as its larger state: opening the confirm moved
|
|
7229
7638
|
the dialog card 0.2278 and closing it 0.1303. The consequence is the tooltip of
|
|
7230
7639
|
"Remove it" (interface-text: the slot holds a label, never a paragraph). */
|
|
7231
|
-
/* @__PURE__ */ (0,
|
|
7232
|
-
/* @__PURE__ */ (0,
|
|
7233
|
-
/* @__PURE__ */ (0,
|
|
7234
|
-
/* @__PURE__ */ (0,
|
|
7235
|
-
/* @__PURE__ */ (0,
|
|
7236
|
-
|
|
7640
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "ml-auto grid shrink-0 items-center", "data-field-editor-remove": askingToRemove ? "asking" : "idle", children: [
|
|
7641
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: (0, import_design_system30.cn)("col-start-1 row-start-1 flex items-center justify-end gap-2", askingToRemove && "invisible"), "aria-hidden": askingToRemove || void 0, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Button, { size: "sm", variant: "outline", tabIndex: askingToRemove ? -1 : void 0, onClick: () => setAskingToRemove(true), children: "Remove this field" }) }),
|
|
7642
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: (0, import_design_system30.cn)("col-start-1 row-start-1 flex items-center justify-end gap-2", !askingToRemove && "invisible"), "aria-hidden": !askingToRemove || void 0, children: [
|
|
7643
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "whitespace-nowrap text-destructive", "data-field-editor-remove-ask": "", children: "Archive this field?" }),
|
|
7644
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7645
|
+
import_design_system30.Button,
|
|
7237
7646
|
{
|
|
7238
7647
|
size: "sm",
|
|
7239
7648
|
variant: "destructive",
|
|
@@ -7245,7 +7654,7 @@ function FieldEditor(props) {
|
|
|
7245
7654
|
children: "Remove it"
|
|
7246
7655
|
}
|
|
7247
7656
|
),
|
|
7248
|
-
/* @__PURE__ */ (0,
|
|
7657
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Button, { size: "sm", variant: "ghost", tabIndex: askingToRemove ? void 0 : -1, onClick: () => setAskingToRemove(false), children: "Keep it" })
|
|
7249
7658
|
] })
|
|
7250
7659
|
] })
|
|
7251
7660
|
) : null
|
|
@@ -7336,10 +7745,10 @@ function formulaSeparatorOf(field) {
|
|
|
7336
7745
|
function TypeQuestions(props) {
|
|
7337
7746
|
const { type } = props;
|
|
7338
7747
|
if (type === "entity_reference") {
|
|
7339
|
-
return /* @__PURE__ */ (0,
|
|
7748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EntityReferenceKindPicker, { value: props.allowedTypes, onChange: props.setAllowedTypes, locked: props.editing });
|
|
7340
7749
|
}
|
|
7341
7750
|
if (type === "relation") {
|
|
7342
|
-
return /* @__PURE__ */ (0,
|
|
7751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7343
7752
|
ReferenceBuilder,
|
|
7344
7753
|
{
|
|
7345
7754
|
tableId: props.tableId,
|
|
@@ -7352,21 +7761,21 @@ function TypeQuestions(props) {
|
|
|
7352
7761
|
}
|
|
7353
7762
|
);
|
|
7354
7763
|
}
|
|
7355
|
-
if (type === "rating" || type === "barcode") return /* @__PURE__ */ (0,
|
|
7764
|
+
if (type === "rating" || type === "barcode") return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: props.newer });
|
|
7356
7765
|
if (type === "status") {
|
|
7357
|
-
return /* @__PURE__ */ (0,
|
|
7766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
7358
7767
|
props.choiceList,
|
|
7359
7768
|
props.newer
|
|
7360
7769
|
] });
|
|
7361
7770
|
}
|
|
7362
7771
|
if (type === "select" || type === "multi_select") {
|
|
7363
|
-
return /* @__PURE__ */ (0,
|
|
7772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: props.choiceList });
|
|
7364
7773
|
}
|
|
7365
7774
|
if (type === "currency") {
|
|
7366
|
-
return /* @__PURE__ */ (0,
|
|
7367
|
-
/* @__PURE__ */ (0,
|
|
7368
|
-
/* @__PURE__ */ (0,
|
|
7369
|
-
|
|
7775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7776
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "The currency" }),
|
|
7777
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7778
|
+
import_design_system30.BasicInput,
|
|
7370
7779
|
{
|
|
7371
7780
|
value: props.unit,
|
|
7372
7781
|
"aria-label": "The currency",
|
|
@@ -7377,9 +7786,9 @@ function TypeQuestions(props) {
|
|
|
7377
7786
|
] });
|
|
7378
7787
|
}
|
|
7379
7788
|
if (type === "datetime") {
|
|
7380
|
-
return /* @__PURE__ */ (0,
|
|
7381
|
-
/* @__PURE__ */ (0,
|
|
7382
|
-
|
|
7789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7790
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7791
|
+
import_design_system30.Checkbox,
|
|
7383
7792
|
{
|
|
7384
7793
|
checked: props.withTime,
|
|
7385
7794
|
"aria-label": "Include a time of day",
|
|
@@ -7392,14 +7801,14 @@ function TypeQuestions(props) {
|
|
|
7392
7801
|
if (type === "lookup" || type === "rollup" || type === "count") {
|
|
7393
7802
|
const usable = props.relations;
|
|
7394
7803
|
if (usable.length === 0) {
|
|
7395
|
-
return /* @__PURE__ */ (0,
|
|
7804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No link, Person or File column yet." });
|
|
7396
7805
|
}
|
|
7397
|
-
return /* @__PURE__ */ (0,
|
|
7398
|
-
/* @__PURE__ */ (0,
|
|
7399
|
-
/* @__PURE__ */ (0,
|
|
7400
|
-
/* @__PURE__ */ (0,
|
|
7401
|
-
/* @__PURE__ */ (0,
|
|
7402
|
-
/* @__PURE__ */ (0,
|
|
7806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7807
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7808
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: type !== "lookup" ? "Across the records in" : "Read it from" }),
|
|
7809
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: props.via, onValueChange: props.setVia, children: [
|
|
7810
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", "aria-label": type !== "lookup" ? "Across the records in" : "Read it from", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, { placeholder: "Choose a column" }) }),
|
|
7811
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: usable.map((f) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.SelectItem, { value: f.key, children: [
|
|
7403
7812
|
fieldName(f),
|
|
7404
7813
|
isBackLinkSource(f) ? BACK_LINK_SOURCE_SUFFIX : "",
|
|
7405
7814
|
sourceKindOf(f) === "person" ? " \u2014 a person" : sourceKindOf(f) === "file" ? " \u2014 a file" : "",
|
|
@@ -7407,7 +7816,7 @@ function TypeQuestions(props) {
|
|
|
7407
7816
|
] }, f.id)) })
|
|
7408
7817
|
] })
|
|
7409
7818
|
] }),
|
|
7410
|
-
type === "lookup" ? /* @__PURE__ */ (0,
|
|
7819
|
+
type === "lookup" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7411
7820
|
ValueOnTheOtherSide,
|
|
7412
7821
|
{
|
|
7413
7822
|
label: "The value to read",
|
|
@@ -7416,13 +7825,13 @@ function TypeQuestions(props) {
|
|
|
7416
7825
|
value: props.pick,
|
|
7417
7826
|
onChange: props.setPick
|
|
7418
7827
|
}
|
|
7419
|
-
) : type === "count" ? null : /* @__PURE__ */ (0,
|
|
7420
|
-
/* @__PURE__ */ (0,
|
|
7421
|
-
/* @__PURE__ */ (0,
|
|
7422
|
-
/* @__PURE__ */ (0,
|
|
7423
|
-
/* @__PURE__ */ (0,
|
|
7828
|
+
) : type === "count" ? null : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7829
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "What to work out" }),
|
|
7830
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: props.agg, onValueChange: (v) => props.setAgg(v), children: [
|
|
7831
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", "aria-label": "What to work out", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
7832
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: ROLLUP_OPERATIONS.map((row) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: row.value, children: row.label }, row.value)) })
|
|
7424
7833
|
] }),
|
|
7425
|
-
props.agg !== "count" ? /* @__PURE__ */ (0,
|
|
7834
|
+
props.agg !== "count" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7426
7835
|
ValueOnTheOtherSide,
|
|
7427
7836
|
{
|
|
7428
7837
|
label: "Of which value",
|
|
@@ -7438,22 +7847,22 @@ function TypeQuestions(props) {
|
|
|
7438
7847
|
}
|
|
7439
7848
|
if (type === "formula") {
|
|
7440
7849
|
if (props.others.length === 0) {
|
|
7441
|
-
return /* @__PURE__ */ (0,
|
|
7850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No other columns yet." });
|
|
7442
7851
|
}
|
|
7443
|
-
return /* @__PURE__ */ (0,
|
|
7444
|
-
/* @__PURE__ */ (0,
|
|
7445
|
-
/* @__PURE__ */ (0,
|
|
7446
|
-
/* @__PURE__ */ (0,
|
|
7447
|
-
/* @__PURE__ */ (0,
|
|
7448
|
-
/* @__PURE__ */ (0,
|
|
7852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
7853
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7854
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "What to do" }),
|
|
7855
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: props.formulaOp, onValueChange: props.setFormulaOp, children: [
|
|
7856
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", className: "max-w-[18rem]", "aria-label": "What to do", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
7857
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: FORMULA_OPERATIONS.map((row) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: row.value, children: row.label }, row.value)) })
|
|
7449
7858
|
] })
|
|
7450
7859
|
] }),
|
|
7451
|
-
/* @__PURE__ */ (0,
|
|
7452
|
-
/* @__PURE__ */ (0,
|
|
7453
|
-
/* @__PURE__ */ (0,
|
|
7860
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7861
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Which columns" }),
|
|
7862
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "flex flex-wrap gap-1", children: props.others.map((f) => {
|
|
7454
7863
|
const picked = props.formulaFields.includes(f.id);
|
|
7455
|
-
return /* @__PURE__ */ (0,
|
|
7456
|
-
|
|
7864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7865
|
+
import_design_system30.Button,
|
|
7457
7866
|
{
|
|
7458
7867
|
type: "button",
|
|
7459
7868
|
size: "sm",
|
|
@@ -7467,10 +7876,10 @@ function TypeQuestions(props) {
|
|
|
7467
7876
|
);
|
|
7468
7877
|
}) })
|
|
7469
7878
|
] }),
|
|
7470
|
-
props.formulaOp === "concat" ? /* @__PURE__ */ (0,
|
|
7471
|
-
/* @__PURE__ */ (0,
|
|
7472
|
-
/* @__PURE__ */ (0,
|
|
7473
|
-
|
|
7879
|
+
props.formulaOp === "concat" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7880
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: FORMULA_SEPARATOR_LABEL }),
|
|
7881
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7882
|
+
import_design_system30.BasicInput,
|
|
7474
7883
|
{
|
|
7475
7884
|
value: props.formulaSeparator,
|
|
7476
7885
|
"aria-label": FORMULA_SEPARATOR_LABEL,
|
|
@@ -7519,26 +7928,26 @@ function RollupFilterQuestion({
|
|
|
7519
7928
|
onChange
|
|
7520
7929
|
}) {
|
|
7521
7930
|
const far = relation?.relation_target ?? null;
|
|
7522
|
-
const farFields = (0,
|
|
7523
|
-
const conditionFields = (0,
|
|
7931
|
+
const farFields = (0, import_react50.useFields)(far);
|
|
7932
|
+
const conditionFields = (0, import_react49.useMemo)(
|
|
7524
7933
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7525
7934
|
[farFields.data]
|
|
7526
7935
|
);
|
|
7527
|
-
const lastFar = (0,
|
|
7528
|
-
(0,
|
|
7936
|
+
const lastFar = (0, import_react49.useRef)(far);
|
|
7937
|
+
(0, import_react49.useEffect)(() => {
|
|
7529
7938
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7530
7939
|
lastFar.current = far;
|
|
7531
7940
|
}, [far, editing, onChange]);
|
|
7532
7941
|
if (!relation || !far) return null;
|
|
7533
|
-
return /* @__PURE__ */ (0,
|
|
7534
|
-
/* @__PURE__ */ (0,
|
|
7942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "flex flex-col gap-1", "data-records-rollup-filter": "", children: !conditionIsDrawable(value) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
7943
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
7535
7944
|
rollupFilterLead(agg),
|
|
7536
7945
|
" ",
|
|
7537
7946
|
conditionInWords(value, conditionFields),
|
|
7538
7947
|
"."
|
|
7539
7948
|
] }),
|
|
7540
|
-
/* @__PURE__ */ (0,
|
|
7541
|
-
] }) : /* @__PURE__ */ (0,
|
|
7949
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onChange(null), children: "Clear" })
|
|
7950
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7542
7951
|
ConditionGroup,
|
|
7543
7952
|
{
|
|
7544
7953
|
lead: rollupFilterLead(agg),
|
|
@@ -7558,19 +7967,19 @@ function ValueOnTheOtherSide({
|
|
|
7558
7967
|
compact
|
|
7559
7968
|
}) {
|
|
7560
7969
|
const target = relation?.relation_target ?? null;
|
|
7561
|
-
const columns = (0,
|
|
7970
|
+
const columns = (0, import_react50.useFields)(target);
|
|
7562
7971
|
const declared = (columns.data ?? []).filter((f) => f.type !== "formula");
|
|
7563
|
-
const sample = (0,
|
|
7972
|
+
const sample = (0, import_react50.useRecords)(declared.length === 0 && !columns.loading ? target : null, { pageSize: 1 });
|
|
7564
7973
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7565
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) }));
|
|
7566
7975
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
7567
|
-
const body = !relation ? /* @__PURE__ */ (0,
|
|
7568
|
-
/* @__PURE__ */ (0,
|
|
7569
|
-
/* @__PURE__ */ (0,
|
|
7976
|
+
const body = !relation ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Choose the column above first." }) : stillAsking ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Reading that table's columns\u2026" }) : offered.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No columns to read yet." }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value, onValueChange: onChange, children: [
|
|
7977
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { size: "sm", "aria-label": label, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, { placeholder: "Choose a column" }) }),
|
|
7978
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectContent, { children: offered.map((column) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: column.key, children: column.name }, column.key)) })
|
|
7570
7979
|
] });
|
|
7571
|
-
if (compact) return /* @__PURE__ */ (0,
|
|
7572
|
-
return /* @__PURE__ */ (0,
|
|
7573
|
-
/* @__PURE__ */ (0,
|
|
7980
|
+
if (compact) return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "mt-1 flex flex-col gap-1", children: body });
|
|
7981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7982
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", title: help, children: label }),
|
|
7574
7983
|
body
|
|
7575
7984
|
] });
|
|
7576
7985
|
}
|
|
@@ -7596,19 +8005,19 @@ function NewColumnDefault({
|
|
|
7596
8005
|
onChange
|
|
7597
8006
|
}) {
|
|
7598
8007
|
const none = "__none__";
|
|
7599
|
-
return /* @__PURE__ */ (0,
|
|
7600
|
-
/* @__PURE__ */ (0,
|
|
7601
|
-
type === "checkbox" ? /* @__PURE__ */ (0,
|
|
7602
|
-
/* @__PURE__ */ (0,
|
|
7603
|
-
/* @__PURE__ */ (0,
|
|
7604
|
-
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */ (0,
|
|
7605
|
-
/* @__PURE__ */ (0,
|
|
7606
|
-
/* @__PURE__ */ (0,
|
|
7607
|
-
/* @__PURE__ */ (0,
|
|
7608
|
-
choices.map((c) => /* @__PURE__ */ (0,
|
|
8008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", "data-records-field-default": "", "data-records-new-field-default": "", children: [
|
|
8009
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { htmlFor: "records-new-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
8010
|
+
type === "checkbox" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
8011
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Checkbox, { id: "records-new-field-default", "aria-label": DEFAULT_LABEL, checked: value === true, onCheckedChange: (on) => onChange(on === true ? true : null) }),
|
|
8012
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: "Ticked" })
|
|
8013
|
+
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: typeof value === "string" && choices.includes(value) ? value : none, onValueChange: (v) => onChange(v === none ? null : v), children: [
|
|
8014
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectTrigger, { id: "records-new-field-default", size: "sm", "aria-label": DEFAULT_LABEL, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectValue, {}) }),
|
|
8015
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.SelectContent, { children: [
|
|
8016
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: none, children: "Nothing" }),
|
|
8017
|
+
choices.map((c) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: c, children: c }, c))
|
|
7609
8018
|
] })
|
|
7610
|
-
] }) : /* @__PURE__ */ (0,
|
|
7611
|
-
|
|
8019
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
8020
|
+
import_design_system30.BasicInput,
|
|
7612
8021
|
{
|
|
7613
8022
|
id: "records-new-field-default",
|
|
7614
8023
|
value: typeof value === "string" ? value : value === null || value === void 0 ? "" : String(value),
|
|
@@ -7622,7 +8031,7 @@ function NewColumnDefault({
|
|
|
7622
8031
|
// src/buttonCell.tsx
|
|
7623
8032
|
var import_outbound_react6 = require("@ai-matrx/kit/outbound-react");
|
|
7624
8033
|
var import_outbound = require("@ai-matrx/kit/outbound");
|
|
7625
|
-
var
|
|
8034
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7626
8035
|
function buttonPressWords(label, pressed) {
|
|
7627
8036
|
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
7628
8037
|
if (pressed.do === "run_action") {
|
|
@@ -7634,14 +8043,14 @@ function buttonPressWords(label, pressed) {
|
|
|
7634
8043
|
}
|
|
7635
8044
|
var stop = (event) => event.stopPropagation();
|
|
7636
8045
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7637
|
-
const client = (0,
|
|
7638
|
-
const b = (0,
|
|
7639
|
-
const [busy, setBusy] = (0,
|
|
7640
|
-
const [said2, setSaid] = (0,
|
|
7641
|
-
const [settingUp, setSettingUp] = (0,
|
|
8046
|
+
const client = (0, import_react52.useOptionalRecordsClient)();
|
|
8047
|
+
const b = (0, import_records27.buttonOf)(field);
|
|
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);
|
|
7642
8051
|
if (!b) return null;
|
|
7643
8052
|
const color = (0, import_data_table6.isStyleColor)(b.color) ? import_data_table6.CHOICE_CHIP_CLASS[b.color] : import_data_table6.NEUTRAL_CHIP_CLASS;
|
|
7644
|
-
const needs = (0,
|
|
8053
|
+
const needs = (0, import_records27.buttonNeeds)(b);
|
|
7645
8054
|
const tableId = field.entity_definition_id;
|
|
7646
8055
|
const press = async () => {
|
|
7647
8056
|
if (!client || !recordId) return setSaid({ kind: "public" });
|
|
@@ -7657,10 +8066,10 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7657
8066
|
}
|
|
7658
8067
|
setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
|
|
7659
8068
|
};
|
|
7660
|
-
return /* @__PURE__ */ (0,
|
|
7661
|
-
/* @__PURE__ */ (0,
|
|
7662
|
-
/* @__PURE__ */ (0,
|
|
7663
|
-
|
|
8069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
8070
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_design_system31.Popover, { open: said2 !== null, onOpenChange: (open) => open ? null : setSaid(null), children: [
|
|
8071
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
8072
|
+
import_design_system31.Button,
|
|
7664
8073
|
{
|
|
7665
8074
|
type: "button",
|
|
7666
8075
|
size: "xs",
|
|
@@ -7669,7 +8078,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7669
8078
|
"data-records-button-unset": needs ? "" : void 0,
|
|
7670
8079
|
"aria-busy": busy || void 0,
|
|
7671
8080
|
disabled: busy,
|
|
7672
|
-
className: (0,
|
|
8081
|
+
className: (0, import_design_system31.cn)("max-w-full gap-1 border px-2 font-medium", inCell ? "h-5" : "h-6", color, needs && "border-dashed opacity-80"),
|
|
7673
8082
|
onPointerDown: stop,
|
|
7674
8083
|
onDoubleClick: stop,
|
|
7675
8084
|
onClick: (event) => {
|
|
@@ -7677,21 +8086,21 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7677
8086
|
event.preventDefault();
|
|
7678
8087
|
void press();
|
|
7679
8088
|
},
|
|
7680
|
-
children: /* @__PURE__ */ (0,
|
|
8089
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "truncate", children: b.label })
|
|
7681
8090
|
}
|
|
7682
8091
|
) }),
|
|
7683
|
-
/* @__PURE__ */ (0,
|
|
7684
|
-
said2?.kind === "refused" ? /* @__PURE__ */ (0,
|
|
7685
|
-
said2?.kind === "public" ? /* @__PURE__ */ (0,
|
|
7686
|
-
said2?.kind === "ran" ? /* @__PURE__ */ (0,
|
|
8092
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_design_system31.PopoverContent, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
|
|
8093
|
+
said2?.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(RefusalLine, { error: said2.error }) : null,
|
|
8094
|
+
said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
|
|
8095
|
+
said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("p", { className: "break-words", children: [
|
|
7687
8096
|
said2.says,
|
|
7688
8097
|
" ",
|
|
7689
|
-
said2.link ? /* @__PURE__ */ (0,
|
|
8098
|
+
said2.link ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_outbound_react6.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
7690
8099
|
] }) : null,
|
|
7691
|
-
said2?.kind === "needs" ? /* @__PURE__ */ (0,
|
|
7692
|
-
/* @__PURE__ */ (0,
|
|
7693
|
-
tableId ? /* @__PURE__ */ (0,
|
|
7694
|
-
|
|
8100
|
+
said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
8101
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { children: said2.says }),
|
|
8102
|
+
tableId ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
8103
|
+
import_design_system31.Button,
|
|
7695
8104
|
{
|
|
7696
8105
|
type: "button",
|
|
7697
8106
|
size: "sm",
|
|
@@ -7709,204 +8118,18 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7709
8118
|
] }) : null
|
|
7710
8119
|
] })
|
|
7711
8120
|
] }),
|
|
7712
|
-
settingUp && tableId ? /* @__PURE__ */ (0,
|
|
7713
|
-
/* @__PURE__ */ (0,
|
|
7714
|
-
/* @__PURE__ */ (0,
|
|
7715
|
-
/* @__PURE__ */ (0,
|
|
8121
|
+
settingUp && tableId ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.Dialog, { open: true, onOpenChange: (open) => open ? null : setSettingUp(false), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_design_system31.DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-2xl", onClick: stop, onPointerDown: stop, children: [
|
|
8122
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_design_system31.DialogHeader, { children: [
|
|
8123
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.DialogTitle, { children: `Column settings \xB7 ${fieldName(field)}` }),
|
|
8124
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.DialogDescription, { className: "sr-only", children: "What the button does" })
|
|
7716
8125
|
] }),
|
|
7717
|
-
/* @__PURE__ */ (0,
|
|
8126
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(FieldEditor, { tableId, field, onSaved: () => setSettingUp(false), onCancel: () => setSettingUp(false) })
|
|
7718
8127
|
] }) }) : null
|
|
7719
8128
|
] });
|
|
7720
8129
|
}
|
|
7721
8130
|
|
|
7722
|
-
// src/PersonPicker.tsx
|
|
7723
|
-
var import_react48 = require("react");
|
|
7724
|
-
var import_records27 = require("@ai-matrx/records");
|
|
7725
|
-
var import_react49 = require("@ai-matrx/records/react");
|
|
7726
|
-
var import_design_system31 = require("@ai-matrx/design-system");
|
|
7727
|
-
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7728
|
-
function personFromRow(row) {
|
|
7729
|
-
const data = row.document ?? {};
|
|
7730
|
-
const userId = data["user_id"];
|
|
7731
|
-
return {
|
|
7732
|
-
id: row.id,
|
|
7733
|
-
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
7734
|
-
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
7735
|
-
};
|
|
7736
|
-
}
|
|
7737
|
-
function memberName(member) {
|
|
7738
|
-
const display = (member.name ?? "").trim();
|
|
7739
|
-
if (display !== "") return display;
|
|
7740
|
-
const email = (member.email ?? "").trim();
|
|
7741
|
-
if (email !== "") return email;
|
|
7742
|
-
return "A member with no name set";
|
|
7743
|
-
}
|
|
7744
|
-
async function personRecordForMember(client, personTableId, people, member) {
|
|
7745
|
-
const held = people.find((p) => p.userId === member.userId);
|
|
7746
|
-
if (held) return { ok: true, data: held.id };
|
|
7747
|
-
const written = await client.recordWrite({
|
|
7748
|
-
table_id: personTableId,
|
|
7749
|
-
data: {
|
|
7750
|
-
user_id: member.userId,
|
|
7751
|
-
full_name: memberName(member),
|
|
7752
|
-
...member.email ? { email: member.email } : {}
|
|
7753
|
-
}
|
|
7754
|
-
});
|
|
7755
|
-
return written;
|
|
7756
|
-
}
|
|
7757
|
-
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
7758
|
-
const client = (0, import_react49.useOptionalRecordsClient)();
|
|
7759
|
-
const host = useRecordsUi();
|
|
7760
|
-
const [members, setMembers] = (0, import_react48.useState)(null);
|
|
7761
|
-
const [people, setPeople] = (0, import_react48.useState)([]);
|
|
7762
|
-
const [error, setError] = (0, import_react48.useState)(null);
|
|
7763
|
-
const [search, setSearch] = (0, import_react48.useState)(initialSearch ?? "");
|
|
7764
|
-
const [open, setOpenState] = (0, import_react48.useState)(autoOpen === true);
|
|
7765
|
-
const onCloseRef = (0, import_react48.useRef)(onClose);
|
|
7766
|
-
onCloseRef.current = onClose;
|
|
7767
|
-
const setOpen = (0, import_react48.useCallback)((next) => {
|
|
7768
|
-
setOpenState(next);
|
|
7769
|
-
if (!next) onCloseRef.current?.();
|
|
7770
|
-
}, []);
|
|
7771
|
-
const [busy, setBusy] = (0, import_react48.useState)(false);
|
|
7772
|
-
const membersPort = host.members;
|
|
7773
|
-
const personTable = field.relation_target;
|
|
7774
|
-
const picked = (0, import_react48.useMemo)(
|
|
7775
|
-
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
7776
|
-
[value]
|
|
7777
|
-
);
|
|
7778
|
-
const load = (0, import_react48.useCallback)(async () => {
|
|
7779
|
-
if (!membersPort || !client) return;
|
|
7780
|
-
const [roster, records] = await Promise.all([
|
|
7781
|
-
membersPort(),
|
|
7782
|
-
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
7783
|
-
]);
|
|
7784
|
-
setMembers(roster);
|
|
7785
|
-
if (records && !records.ok) {
|
|
7786
|
-
setError(records.error);
|
|
7787
|
-
return;
|
|
7788
|
-
}
|
|
7789
|
-
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
7790
|
-
}, [membersPort, client, personTable]);
|
|
7791
|
-
(0, import_react48.useEffect)(() => {
|
|
7792
|
-
if (!open) return;
|
|
7793
|
-
void load();
|
|
7794
|
-
}, [open, load]);
|
|
7795
|
-
(0, import_react48.useEffect)(() => {
|
|
7796
|
-
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
7797
|
-
let cancelled = false;
|
|
7798
|
-
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
7799
|
-
if (cancelled || !result.ok) return;
|
|
7800
|
-
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
7801
|
-
});
|
|
7802
|
-
return () => {
|
|
7803
|
-
cancelled = true;
|
|
7804
|
-
};
|
|
7805
|
-
}, [client, personTable, picked.length, people.length]);
|
|
7806
|
-
const listed = (0, import_records27.rankTypedMatches)(members ?? [], search, memberName);
|
|
7807
|
-
if (!membersPort || !client) {
|
|
7808
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: (0, import_design_system31.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
7809
|
-
}
|
|
7810
|
-
if (!personTable) {
|
|
7811
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("p", { className: (0, import_design_system31.cn)("text-xs text-muted-foreground", className), children: [
|
|
7812
|
-
fieldName(field),
|
|
7813
|
-
" is a person field, but it does not say which Table the people are records of yet, so there is nothing to pick from. A table admin sets its target in the field editor."
|
|
7814
|
-
] });
|
|
7815
|
-
}
|
|
7816
|
-
const displayNameOf = (userId, recordName2) => {
|
|
7817
|
-
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
7818
|
-
const own3 = (member?.name ?? "").trim();
|
|
7819
|
-
if (own3 !== "") return own3;
|
|
7820
|
-
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
7821
|
-
const email = (member?.email ?? "").trim();
|
|
7822
|
-
return kept !== "" && kept !== email ? kept : null;
|
|
7823
|
-
};
|
|
7824
|
-
const nameOfRecord = (recordId) => {
|
|
7825
|
-
const person = people.find((p) => p.id === recordId);
|
|
7826
|
-
if (!person) return "Loading\u2026";
|
|
7827
|
-
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
7828
|
-
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
7829
|
-
};
|
|
7830
|
-
const pick = async (member) => {
|
|
7831
|
-
setBusy(true);
|
|
7832
|
-
setError(null);
|
|
7833
|
-
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
7834
|
-
setBusy(false);
|
|
7835
|
-
if (!resolved.ok) {
|
|
7836
|
-
setError(resolved.error);
|
|
7837
|
-
return;
|
|
7838
|
-
}
|
|
7839
|
-
if (!people.some((p) => p.id === resolved.data)) {
|
|
7840
|
-
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
7841
|
-
}
|
|
7842
|
-
if (!field.multi) {
|
|
7843
|
-
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
7844
|
-
setOpen(false);
|
|
7845
|
-
return;
|
|
7846
|
-
}
|
|
7847
|
-
const next = new Set(picked);
|
|
7848
|
-
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
7849
|
-
else next.add(resolved.data);
|
|
7850
|
-
onChange(next.size === 0 ? null : [...next]);
|
|
7851
|
-
};
|
|
7852
|
-
const drop = (recordId) => {
|
|
7853
|
-
const next = picked.filter((id2) => id2 !== recordId);
|
|
7854
|
-
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
7855
|
-
};
|
|
7856
|
-
const visible = listed;
|
|
7857
|
-
const pickedUserIds = new Set(
|
|
7858
|
-
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
7859
|
-
);
|
|
7860
|
-
const anchored = autoOpen === true;
|
|
7861
|
-
const cellChips = picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
7862
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: (0, import_design_system31.cn)("flex flex-wrap items-center gap-1", className), children: [
|
|
7863
|
-
anchored && !disabled ? null : cellChips,
|
|
7864
|
-
disabled ? null : (
|
|
7865
|
-
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
7866
|
-
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
7867
|
-
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
7868
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7869
|
-
PickOrAdd,
|
|
7870
|
-
{
|
|
7871
|
-
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
7872
|
-
anchored,
|
|
7873
|
-
multi: field.multi,
|
|
7874
|
-
triggerId: id,
|
|
7875
|
-
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
7876
|
-
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
7877
|
-
open,
|
|
7878
|
-
onOpenChange: setOpen,
|
|
7879
|
-
search,
|
|
7880
|
-
onSearch: setSearch,
|
|
7881
|
-
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
7882
|
-
items: visible.map((member) => ({
|
|
7883
|
-
id: member.userId,
|
|
7884
|
-
label: displayNameOf(member.userId) ?? memberName(member),
|
|
7885
|
-
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
7886
|
-
// 19 September). They are two facts, so they are drawn as two.
|
|
7887
|
-
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
7888
|
-
picked: pickedUserIds.has(member.userId),
|
|
7889
|
-
person: true,
|
|
7890
|
-
disabled: busy
|
|
7891
|
-
})),
|
|
7892
|
-
onPick: (userId) => {
|
|
7893
|
-
const member = visible.find((m) => m.userId === userId);
|
|
7894
|
-
if (member && !busy) void pick(member);
|
|
7895
|
-
},
|
|
7896
|
-
notice: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
7897
|
-
error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(RefusalLine, { error, className: "p-2" }) : null,
|
|
7898
|
-
members === null ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
7899
|
-
] }),
|
|
7900
|
-
empty: members !== null ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: members.length === 0 ? "This organization has no other members yet, so there is nobody to assign." : "Nobody in this organization matches." }) : null,
|
|
7901
|
-
children: anchored ? cellChips : null
|
|
7902
|
-
}
|
|
7903
|
-
)
|
|
7904
|
-
)
|
|
7905
|
-
] });
|
|
7906
|
-
}
|
|
7907
|
-
|
|
7908
8131
|
// src/FloatingRefusal.tsx
|
|
7909
|
-
var
|
|
8132
|
+
var import_react53 = require("react");
|
|
7910
8133
|
var import_react_dom = require("react-dom");
|
|
7911
8134
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7912
8135
|
var GAP = 4;
|
|
@@ -7924,11 +8147,11 @@ function placeFor(anchor, note) {
|
|
|
7924
8147
|
return { position: "fixed", top: a.top + (a.height - height) / 2, left: Math.max(a.left, a.right - width - 8) };
|
|
7925
8148
|
}
|
|
7926
8149
|
function FloatingRefusal({ text, why }) {
|
|
7927
|
-
const spot = (0,
|
|
7928
|
-
const note = (0,
|
|
7929
|
-
const [style, setStyle] = (0,
|
|
7930
|
-
const [floating, setFloating] = (0,
|
|
7931
|
-
(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)(() => {
|
|
7932
8155
|
const here = spot.current;
|
|
7933
8156
|
if (!here) return;
|
|
7934
8157
|
const anchor = here.closest("[data-matrx-cell-editor]");
|
|
@@ -7970,7 +8193,7 @@ function FloatingRefusal({ text, why }) {
|
|
|
7970
8193
|
}
|
|
7971
8194
|
|
|
7972
8195
|
// src/formatControls.tsx
|
|
7973
|
-
var
|
|
8196
|
+
var import_react54 = require("react");
|
|
7974
8197
|
var import_design_system32 = require("@ai-matrx/design-system");
|
|
7975
8198
|
var import_field_formats7 = require("@ai-matrx/design-system/field-formats");
|
|
7976
8199
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
@@ -7990,9 +8213,9 @@ function keptValue(format, raw) {
|
|
|
7990
8213
|
return parsed;
|
|
7991
8214
|
}
|
|
7992
8215
|
function NumberInFormat({ format, value, onChange, disabled, id }) {
|
|
7993
|
-
const [text, setText] = (0,
|
|
7994
|
-
const lastSent = (0,
|
|
7995
|
-
(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)(() => {
|
|
7996
8219
|
if (value === lastSent.current) return;
|
|
7997
8220
|
setText(typedText(format, value));
|
|
7998
8221
|
}, [value, format]);
|
|
@@ -8066,7 +8289,7 @@ function formatControl(args) {
|
|
|
8066
8289
|
}
|
|
8067
8290
|
|
|
8068
8291
|
// src/typedDateHelper.tsx
|
|
8069
|
-
var
|
|
8292
|
+
var import_react55 = require("react");
|
|
8070
8293
|
var import_design_system33 = require("@ai-matrx/design-system");
|
|
8071
8294
|
var import_records28 = require("@ai-matrx/records");
|
|
8072
8295
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
@@ -8090,7 +8313,7 @@ function readBox(text, kind) {
|
|
|
8090
8313
|
}
|
|
8091
8314
|
return { day: read.day, time: null };
|
|
8092
8315
|
}
|
|
8093
|
-
function
|
|
8316
|
+
function wordsFor2(kind, day, time) {
|
|
8094
8317
|
if (kind === "time") return time ? (0, import_records28.typedTimeText)(time.h, time.m) : "";
|
|
8095
8318
|
if (!day) return "";
|
|
8096
8319
|
const dayText = (0, import_records28.typedDateText)(day);
|
|
@@ -8117,12 +8340,12 @@ function TypedDateHelper({
|
|
|
8117
8340
|
onPicked,
|
|
8118
8341
|
startOpen = false
|
|
8119
8342
|
}) {
|
|
8120
|
-
const [open, setOpen] = (0,
|
|
8343
|
+
const [open, setOpen] = (0, import_react55.useState)(startOpen);
|
|
8121
8344
|
const held = readBox(text, kind);
|
|
8122
8345
|
usePersonTimeZone();
|
|
8123
8346
|
const today = personWallNow();
|
|
8124
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);
|
|
8125
|
-
const [month, setMonth] = (0,
|
|
8348
|
+
const [month, setMonth] = (0, import_react55.useState)(null);
|
|
8126
8349
|
const shown2 = month ?? { y: start.getFullYear(), m: start.getMonth() };
|
|
8127
8350
|
const first = new Date(shown2.y, shown2.m, 1).getDay();
|
|
8128
8351
|
const days = new Date(shown2.y, shown2.m + 1, 0).getDate();
|
|
@@ -8131,7 +8354,7 @@ function TypedDateHelper({
|
|
|
8131
8354
|
const times = Array.from({ length: 48 }, (_, i) => ({ h: Math.floor(i / 2), m: i % 2 * 30 }));
|
|
8132
8355
|
const pickDay = (d) => {
|
|
8133
8356
|
const day = `${shown2.y}-${pad(shown2.m + 1)}-${pad(d)}`;
|
|
8134
|
-
onText(
|
|
8357
|
+
onText(wordsFor2(kind, day, held.time));
|
|
8135
8358
|
if (kind === "date") {
|
|
8136
8359
|
setOpen(false);
|
|
8137
8360
|
onPicked?.();
|
|
@@ -8139,7 +8362,7 @@ function TypedDateHelper({
|
|
|
8139
8362
|
};
|
|
8140
8363
|
const pickTime = (t) => {
|
|
8141
8364
|
const day = kind === "datetime" ? held.day ?? todayKey : null;
|
|
8142
|
-
onText(
|
|
8365
|
+
onText(wordsFor2(kind, day, t));
|
|
8143
8366
|
setOpen(false);
|
|
8144
8367
|
onPicked?.();
|
|
8145
8368
|
};
|
|
@@ -8227,24 +8450,24 @@ function TypedDateHelper({
|
|
|
8227
8450
|
}
|
|
8228
8451
|
|
|
8229
8452
|
// src/choiceNudge.ts
|
|
8230
|
-
var
|
|
8231
|
-
var
|
|
8232
|
-
var
|
|
8453
|
+
var import_react56 = require("react");
|
|
8454
|
+
var import_react57 = require("@ai-matrx/records/react");
|
|
8455
|
+
var asked2 = /* @__PURE__ */ new WeakMap();
|
|
8233
8456
|
function choiceNudgeOf(client) {
|
|
8234
|
-
let answer =
|
|
8457
|
+
let answer = asked2.get(client);
|
|
8235
8458
|
if (!answer) {
|
|
8236
8459
|
answer = Promise.resolve().then(() => client.choiceNudge()).then(
|
|
8237
8460
|
(result) => result.ok ? result.data : "ask",
|
|
8238
8461
|
() => "ask"
|
|
8239
8462
|
);
|
|
8240
|
-
|
|
8463
|
+
asked2.set(client, answer);
|
|
8241
8464
|
}
|
|
8242
8465
|
return answer;
|
|
8243
8466
|
}
|
|
8244
8467
|
function useChoiceNudge(enabled = true) {
|
|
8245
|
-
const client = (0,
|
|
8246
|
-
const [nudge, setNudge] = (0,
|
|
8247
|
-
(0,
|
|
8468
|
+
const client = (0, import_react57.useOptionalRecordsClient)();
|
|
8469
|
+
const [nudge, setNudge] = (0, import_react56.useState)(null);
|
|
8470
|
+
(0, import_react56.useEffect)(() => {
|
|
8248
8471
|
if (!enabled || !client) return;
|
|
8249
8472
|
let live = true;
|
|
8250
8473
|
void choiceNudgeOf(client).then((answer) => {
|
|
@@ -8395,9 +8618,9 @@ function openingText(field, value) {
|
|
|
8395
8618
|
return format ? typedText(format, value) : String(value);
|
|
8396
8619
|
}
|
|
8397
8620
|
function ReadsAsNote({ typed, always, children }) {
|
|
8398
|
-
const note = (0,
|
|
8399
|
-
const [repeats, setRepeats] = (0,
|
|
8400
|
-
(0,
|
|
8621
|
+
const note = (0, import_react58.useRef)(null);
|
|
8622
|
+
const [repeats, setRepeats] = (0, import_react58.useState)(false);
|
|
8623
|
+
(0, import_react58.useLayoutEffect)(() => {
|
|
8401
8624
|
if (always) return;
|
|
8402
8625
|
const words = (t) => (t ?? "").replace(/^Reads as/, "").replace(/\s+/g, "").toLowerCase();
|
|
8403
8626
|
setRepeats(words(note.current?.textContent) === words(typed));
|
|
@@ -8406,12 +8629,12 @@ function ReadsAsNote({ typed, always, children }) {
|
|
|
8406
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 });
|
|
8407
8630
|
}
|
|
8408
8631
|
function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCancel }) {
|
|
8409
|
-
const client = (0,
|
|
8632
|
+
const client = (0, import_react59.useOptionalRecordsClient)();
|
|
8410
8633
|
const kind = String(editorKindFor(field));
|
|
8411
8634
|
const needsChoices = kind === "select" || kind === "multi_select";
|
|
8412
8635
|
const nudge = useChoiceNudge(needsChoices);
|
|
8413
|
-
const [choices, setChoices] = (0,
|
|
8414
|
-
(0,
|
|
8636
|
+
const [choices, setChoices] = (0, import_react58.useState)(null);
|
|
8637
|
+
(0, import_react58.useEffect)(() => {
|
|
8415
8638
|
if (!needsChoices || !client) return;
|
|
8416
8639
|
let cancelled = false;
|
|
8417
8640
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
|
|
@@ -8421,7 +8644,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
8421
8644
|
cancelled = true;
|
|
8422
8645
|
};
|
|
8423
8646
|
}, [client, field.id, needsChoices]);
|
|
8424
|
-
(0,
|
|
8647
|
+
(0, import_react58.useEffect)(() => {
|
|
8425
8648
|
if (choices && nudge && value.judged === null) onChange({ ...value, judged: judgeTyped(field, value.text, choices, nudge) });
|
|
8426
8649
|
}, [choices, nudge, value, field, onChange]);
|
|
8427
8650
|
const judged = value.judged;
|
|
@@ -8497,7 +8720,7 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8497
8720
|
const host = useRecordsUi();
|
|
8498
8721
|
const kind = editorKindFor(field);
|
|
8499
8722
|
const inputId = id ?? `field-${field.key}`;
|
|
8500
|
-
const ownDetails = (0,
|
|
8723
|
+
const ownDetails = (0, import_react59.useOptionalRecordsClient)() === null;
|
|
8501
8724
|
if (isTypedDraft(value)) return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
|
|
8502
8725
|
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SignaturePad, { id: inputId, value, onChange, disabled });
|
|
8503
8726
|
if ((0, import_records29.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ButtonValue, { field });
|
|
@@ -8617,11 +8840,11 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8617
8840
|
}
|
|
8618
8841
|
}
|
|
8619
8842
|
function TypedWordsControl({ field, value, onChange, disabled, id }) {
|
|
8620
|
-
const [text, setText] = (0,
|
|
8621
|
-
const [refusal, setRefusal] = (0,
|
|
8622
|
-
const [why, setWhy] = (0,
|
|
8623
|
-
const sent = (0,
|
|
8624
|
-
(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)(() => {
|
|
8625
8848
|
if (value === sent.current) return;
|
|
8626
8849
|
sent.current = value;
|
|
8627
8850
|
setText(openingText(field, value));
|
|
@@ -8701,8 +8924,8 @@ function CheckboxControl({ field, value, onChange, disabled, id }) {
|
|
|
8701
8924
|
}
|
|
8702
8925
|
function JsonControl({ field, value, onChange, disabled, id }) {
|
|
8703
8926
|
const initial = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
8704
|
-
const [text, setText] = (0,
|
|
8705
|
-
const [broken, setBroken] = (0,
|
|
8927
|
+
const [text, setText] = (0, import_react58.useState)(initial);
|
|
8928
|
+
const [broken, setBroken] = (0, import_react58.useState)(null);
|
|
8706
8929
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
8707
8930
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
8708
8931
|
import_design_system34.BasicTextarea,
|
|
@@ -8763,11 +8986,11 @@ function inTheStoresOrder(options) {
|
|
|
8763
8986
|
return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
|
|
8764
8987
|
}
|
|
8765
8988
|
function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm, onChosen }) {
|
|
8766
|
-
const client = (0,
|
|
8767
|
-
const [options, setOptions] = (0,
|
|
8768
|
-
const [refusal, setRefusal] = (0,
|
|
8769
|
-
const [reread, setReread] = (0,
|
|
8770
|
-
(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)(() => {
|
|
8771
8994
|
if (!client) return;
|
|
8772
8995
|
let cancelled = false;
|
|
8773
8996
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
|
|
@@ -8931,18 +9154,18 @@ function OpenChoicePicker({
|
|
|
8931
9154
|
allowOther = true,
|
|
8932
9155
|
onChoicesChanged
|
|
8933
9156
|
}) {
|
|
8934
|
-
const client = (0,
|
|
9157
|
+
const client = (0, import_react59.useOptionalRecordsClient)();
|
|
8935
9158
|
const nudge = useChoiceNudge();
|
|
8936
|
-
const [open, setOpenState] = (0,
|
|
8937
|
-
const onCloseRef = (0,
|
|
9159
|
+
const [open, setOpenState] = (0, import_react58.useState)(autoOpen === true);
|
|
9160
|
+
const onCloseRef = (0, import_react58.useRef)(onClose);
|
|
8938
9161
|
onCloseRef.current = onClose;
|
|
8939
|
-
const setOpen = (0,
|
|
9162
|
+
const setOpen = (0, import_react58.useCallback)((next) => {
|
|
8940
9163
|
setOpenState(next);
|
|
8941
9164
|
if (!next) onCloseRef.current?.();
|
|
8942
9165
|
}, []);
|
|
8943
|
-
const [search, setSearch] = (0,
|
|
8944
|
-
const [adding, setAdding] = (0,
|
|
8945
|
-
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);
|
|
8946
9169
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
8947
9170
|
const held = withoutAddition(value);
|
|
8948
9171
|
const current = (0, import_records29.choiceValuesOf)(held.value);
|
|
@@ -9099,7 +9322,7 @@ function ChoiceAnswer({
|
|
|
9099
9322
|
isChosen,
|
|
9100
9323
|
onChosen
|
|
9101
9324
|
}) {
|
|
9102
|
-
const [search, setSearch] = (0,
|
|
9325
|
+
const [search, setSearch] = (0, import_react58.useState)("");
|
|
9103
9326
|
const held = field.multi ? (0, import_records29.choiceValuesOf)(value) : value === null || value === void 0 || value === "" ? [] : [value];
|
|
9104
9327
|
const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
|
|
9105
9328
|
const press = (choice) => {
|
|
@@ -9202,7 +9425,7 @@ function ChoiceAnswer({
|
|
|
9202
9425
|
}
|
|
9203
9426
|
|
|
9204
9427
|
// src/RecordsMount.tsx
|
|
9205
|
-
var
|
|
9428
|
+
var import_react60 = require("react");
|
|
9206
9429
|
|
|
9207
9430
|
// src/dataSource.ts
|
|
9208
9431
|
var import_global_slot2 = require("@ai-matrx/kit/global-slot");
|
|
@@ -9212,7 +9435,7 @@ function personActor(userId) {
|
|
|
9212
9435
|
var dataSources = (0, import_global_slot2.globalSlot)("ai-matrx.records-ui.data-sources", () => /* @__PURE__ */ new WeakMap());
|
|
9213
9436
|
|
|
9214
9437
|
// src/RecordsMount.tsx
|
|
9215
|
-
var
|
|
9438
|
+
var import_react61 = require("@ai-matrx/records/react");
|
|
9216
9439
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
9217
9440
|
|
|
9218
9441
|
// src/TablePickers.tsx
|
|
@@ -9248,8 +9471,8 @@ function readTablesAnywhere(dataSource) {
|
|
|
9248
9471
|
return read;
|
|
9249
9472
|
}
|
|
9250
9473
|
function useTablesAnywhere(dataSource) {
|
|
9251
|
-
const [state2, setState] = (0,
|
|
9252
|
-
(0,
|
|
9474
|
+
const [state2, setState] = (0, import_react62.useState)({ loading: true, error: null, rows: [] });
|
|
9475
|
+
(0, import_react62.useEffect)(() => {
|
|
9253
9476
|
let live = true;
|
|
9254
9477
|
void readTablesAnywhere(dataSource).then((result) => {
|
|
9255
9478
|
if (live) setState(result);
|
|
@@ -9319,14 +9542,14 @@ function TableScope({ dataSource, userId, tableId, children, fallback = null, un
|
|
|
9319
9542
|
const organizationId = list.rows.find((t) => t.table_id === tableId)?.organization_id ?? null;
|
|
9320
9543
|
if (tableId && !organizationId && !list.loading) return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: unavailable ?? fallback });
|
|
9321
9544
|
if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: fallback });
|
|
9322
|
-
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 });
|
|
9323
9546
|
}
|
|
9324
9547
|
function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
|
|
9325
|
-
const fields = (0,
|
|
9326
|
-
const all = (0,
|
|
9327
|
-
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]);
|
|
9328
9551
|
const keys = Object.keys(value);
|
|
9329
|
-
const [adding, setAdding] = (0,
|
|
9552
|
+
const [adding, setAdding] = (0, import_react62.useState)(false);
|
|
9330
9553
|
const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
|
|
9331
9554
|
const rename = (from, to) => {
|
|
9332
9555
|
if (from === to) return;
|
|
@@ -9414,8 +9637,8 @@ function ColumnValueRow({
|
|
|
9414
9637
|
] });
|
|
9415
9638
|
}
|
|
9416
9639
|
function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
9417
|
-
const table = (0,
|
|
9418
|
-
const records = (0,
|
|
9640
|
+
const table = (0, import_react63.useTable)(tableId);
|
|
9641
|
+
const records = (0, import_react63.useRecords)(tableId, { pageSize: 200 });
|
|
9419
9642
|
const rows = records.data?.rows ?? [];
|
|
9420
9643
|
const options = rows.map((row) => ({
|
|
9421
9644
|
value: row.id,
|
|
@@ -9442,9 +9665,9 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
|
9442
9665
|
}
|
|
9443
9666
|
|
|
9444
9667
|
// src/DataBindingPicker.tsx
|
|
9445
|
-
var
|
|
9668
|
+
var import_react64 = require("react");
|
|
9446
9669
|
var import_records30 = require("@ai-matrx/records");
|
|
9447
|
-
var
|
|
9670
|
+
var import_react65 = require("@ai-matrx/records/react");
|
|
9448
9671
|
var import_design_system36 = require("@ai-matrx/design-system");
|
|
9449
9672
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
9450
9673
|
var DATA_BINDING_SHAPES = [
|
|
@@ -9534,11 +9757,11 @@ function BindingDetails({
|
|
|
9534
9757
|
disabled,
|
|
9535
9758
|
defaultRowLimit
|
|
9536
9759
|
}) {
|
|
9537
|
-
const table = (0,
|
|
9538
|
-
const fields = (0,
|
|
9539
|
-
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]);
|
|
9540
9763
|
const shape = binding.semantic_type;
|
|
9541
|
-
(0,
|
|
9764
|
+
(0, import_react64.useEffect)(() => {
|
|
9542
9765
|
if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
|
|
9543
9766
|
onChange({
|
|
9544
9767
|
...binding,
|
|
@@ -9683,7 +9906,7 @@ function BindingDetails({
|
|
|
9683
9906
|
}
|
|
9684
9907
|
|
|
9685
9908
|
// src/PickedSummaries.tsx
|
|
9686
|
-
var
|
|
9909
|
+
var import_react66 = require("@ai-matrx/records/react");
|
|
9687
9910
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
9688
9911
|
function TableNameText({ dataSource, tableId }) {
|
|
9689
9912
|
const tables = useTablesAnywhere(dataSource);
|
|
@@ -9712,7 +9935,7 @@ function ColumnValuesText({
|
|
|
9712
9935
|
);
|
|
9713
9936
|
}
|
|
9714
9937
|
function ColumnValuesWords({ tableId, value }) {
|
|
9715
|
-
const fields = (0,
|
|
9938
|
+
const fields = (0, import_react66.useFields)(tableId);
|
|
9716
9939
|
const labels = useRecordLabels(fields.data ?? void 0);
|
|
9717
9940
|
if (fields.loading) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "\u2026" });
|
|
9718
9941
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "Couldn't load this table's columns" });
|
|
@@ -9751,8 +9974,8 @@ function RecordNameText({
|
|
|
9751
9974
|
);
|
|
9752
9975
|
}
|
|
9753
9976
|
function RecordNameWords({ tableId, recordId }) {
|
|
9754
|
-
const table = (0,
|
|
9755
|
-
const record = (0,
|
|
9977
|
+
const table = (0, import_react66.useTable)(tableId);
|
|
9978
|
+
const record = (0, import_react66.useRecord)(recordId);
|
|
9756
9979
|
if (record.loading || table.loading) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "\u2026" });
|
|
9757
9980
|
if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "Couldn't load this record" });
|
|
9758
9981
|
if (!record.data) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: "A record you cannot open" });
|
|
@@ -9760,23 +9983,23 @@ function RecordNameWords({ tableId, recordId }) {
|
|
|
9760
9983
|
}
|
|
9761
9984
|
|
|
9762
9985
|
// src/HeldChangeDecision.tsx
|
|
9763
|
-
var
|
|
9764
|
-
var
|
|
9986
|
+
var import_react67 = require("react");
|
|
9987
|
+
var import_react68 = require("@ai-matrx/records/react");
|
|
9765
9988
|
var import_design_system37 = require("@ai-matrx/design-system");
|
|
9766
9989
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
9767
9990
|
function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided, approveLabel }) {
|
|
9768
|
-
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" }) });
|
|
9769
9992
|
}
|
|
9770
9993
|
function Decision({
|
|
9771
9994
|
approvalId,
|
|
9772
9995
|
onDecided,
|
|
9773
9996
|
approveLabel
|
|
9774
9997
|
}) {
|
|
9775
|
-
const client = (0,
|
|
9776
|
-
const [may, setMay] = (0,
|
|
9777
|
-
const [busy, setBusy] = (0,
|
|
9778
|
-
const [error, setError] = (0,
|
|
9779
|
-
(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)(() => {
|
|
9780
10003
|
let live = true;
|
|
9781
10004
|
void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
|
|
9782
10005
|
if (!live) return;
|