@ai-matrx/records-ui 0.115.83 → 0.115.84
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 +17 -0
- package/dist/helpers.d.cts +7 -0
- package/dist/helpers.d.ts +7 -0
- package/dist/index.cjs +2617 -2581
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +403 -367
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +764 -762
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +660 -658
- package/dist/pickers.js.map +1 -1
- package/package.json +2 -2
package/dist/pickers.cjs
CHANGED
|
@@ -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_react48 = 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_react49 = 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_react46 = require("react");
|
|
2070
|
+
var import_react47 = 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");
|
|
@@ -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_react35 = require("react");
|
|
2774
|
+
var import_design_system23 = require("@ai-matrx/design-system");
|
|
2775
|
+
var import_react36 = 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");
|
|
@@ -4501,12 +4501,200 @@ function formulaSourceArchived(field, document2) {
|
|
|
4501
4501
|
}
|
|
4502
4502
|
|
|
4503
4503
|
// src/values.tsx
|
|
4504
|
+
var import_records18 = require("@ai-matrx/records");
|
|
4505
|
+
|
|
4506
|
+
// src/PersonPicker.tsx
|
|
4507
|
+
var import_react33 = require("react");
|
|
4504
4508
|
var import_records17 = require("@ai-matrx/records");
|
|
4505
|
-
var
|
|
4509
|
+
var import_react34 = require("@ai-matrx/records/react");
|
|
4510
|
+
var import_design_system21 = require("@ai-matrx/design-system");
|
|
4506
4511
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4512
|
+
function personFromRow(row) {
|
|
4513
|
+
const data = row.document ?? {};
|
|
4514
|
+
const userId = data["user_id"];
|
|
4515
|
+
return {
|
|
4516
|
+
id: row.id,
|
|
4517
|
+
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
4518
|
+
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
4519
|
+
};
|
|
4520
|
+
}
|
|
4521
|
+
function memberName(member) {
|
|
4522
|
+
const display = (member.name ?? "").trim();
|
|
4523
|
+
if (display !== "") return display;
|
|
4524
|
+
const email = (member.email ?? "").trim();
|
|
4525
|
+
if (email !== "") return email;
|
|
4526
|
+
return "A member with no name set";
|
|
4527
|
+
}
|
|
4528
|
+
async function personRecordForMember(client, personTableId, people, member) {
|
|
4529
|
+
const held = people.find((p) => p.userId === member.userId);
|
|
4530
|
+
if (held) return { ok: true, data: held.id };
|
|
4531
|
+
const written = await client.recordWrite({
|
|
4532
|
+
table_id: personTableId,
|
|
4533
|
+
data: {
|
|
4534
|
+
user_id: member.userId,
|
|
4535
|
+
full_name: memberName(member),
|
|
4536
|
+
...member.email ? { email: member.email } : {}
|
|
4537
|
+
}
|
|
4538
|
+
});
|
|
4539
|
+
return written;
|
|
4540
|
+
}
|
|
4541
|
+
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
4542
|
+
const client = (0, import_react34.useOptionalRecordsClient)();
|
|
4543
|
+
const host = useRecordsUi();
|
|
4544
|
+
const [members, setMembers] = (0, import_react33.useState)(null);
|
|
4545
|
+
const [people, setPeople] = (0, import_react33.useState)([]);
|
|
4546
|
+
const [error, setError] = (0, import_react33.useState)(null);
|
|
4547
|
+
const [search, setSearch] = (0, import_react33.useState)(initialSearch ?? "");
|
|
4548
|
+
const [open, setOpenState] = (0, import_react33.useState)(autoOpen === true);
|
|
4549
|
+
const onCloseRef = (0, import_react33.useRef)(onClose);
|
|
4550
|
+
onCloseRef.current = onClose;
|
|
4551
|
+
const setOpen = (0, import_react33.useCallback)((next) => {
|
|
4552
|
+
setOpenState(next);
|
|
4553
|
+
if (!next) onCloseRef.current?.();
|
|
4554
|
+
}, []);
|
|
4555
|
+
const [busy, setBusy] = (0, import_react33.useState)(false);
|
|
4556
|
+
const membersPort = host.members;
|
|
4557
|
+
const personTable = field.relation_target;
|
|
4558
|
+
const picked = (0, import_react33.useMemo)(
|
|
4559
|
+
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
4560
|
+
[value]
|
|
4561
|
+
);
|
|
4562
|
+
const load = (0, import_react33.useCallback)(async () => {
|
|
4563
|
+
if (!membersPort || !client) return;
|
|
4564
|
+
const [roster, records] = await Promise.all([
|
|
4565
|
+
membersPort(),
|
|
4566
|
+
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
4567
|
+
]);
|
|
4568
|
+
setMembers(roster);
|
|
4569
|
+
if (records && !records.ok) {
|
|
4570
|
+
setError(records.error);
|
|
4571
|
+
return;
|
|
4572
|
+
}
|
|
4573
|
+
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
4574
|
+
}, [membersPort, client, personTable]);
|
|
4575
|
+
(0, import_react33.useEffect)(() => {
|
|
4576
|
+
if (!open) return;
|
|
4577
|
+
void load();
|
|
4578
|
+
}, [open, load]);
|
|
4579
|
+
(0, import_react33.useEffect)(() => {
|
|
4580
|
+
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
4581
|
+
let cancelled = false;
|
|
4582
|
+
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
4583
|
+
if (cancelled || !result.ok) return;
|
|
4584
|
+
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
4585
|
+
});
|
|
4586
|
+
return () => {
|
|
4587
|
+
cancelled = true;
|
|
4588
|
+
};
|
|
4589
|
+
}, [client, personTable, picked.length, people.length]);
|
|
4590
|
+
const listed = (0, import_records17.rankTypedMatches)(members ?? [], search, memberName);
|
|
4591
|
+
if (!membersPort || !client) {
|
|
4592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: (0, import_design_system21.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
4593
|
+
}
|
|
4594
|
+
if (!personTable) {
|
|
4595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: (0, import_design_system21.cn)("text-xs text-muted-foreground", className), children: [
|
|
4596
|
+
fieldName(field),
|
|
4597
|
+
" 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."
|
|
4598
|
+
] });
|
|
4599
|
+
}
|
|
4600
|
+
const displayNameOf = (userId, recordName2) => {
|
|
4601
|
+
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
4602
|
+
const own3 = (member?.name ?? "").trim();
|
|
4603
|
+
if (own3 !== "") return own3;
|
|
4604
|
+
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
4605
|
+
const email = (member?.email ?? "").trim();
|
|
4606
|
+
return kept !== "" && kept !== email ? kept : null;
|
|
4607
|
+
};
|
|
4608
|
+
const nameOfRecord = (recordId) => {
|
|
4609
|
+
const person = people.find((p) => p.id === recordId);
|
|
4610
|
+
if (!person) return "Loading\u2026";
|
|
4611
|
+
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
4612
|
+
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
4613
|
+
};
|
|
4614
|
+
const pick = async (member) => {
|
|
4615
|
+
setBusy(true);
|
|
4616
|
+
setError(null);
|
|
4617
|
+
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
4618
|
+
setBusy(false);
|
|
4619
|
+
if (!resolved.ok) {
|
|
4620
|
+
setError(resolved.error);
|
|
4621
|
+
return;
|
|
4622
|
+
}
|
|
4623
|
+
if (!people.some((p) => p.id === resolved.data)) {
|
|
4624
|
+
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
4625
|
+
}
|
|
4626
|
+
if (!field.multi) {
|
|
4627
|
+
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
4628
|
+
setOpen(false);
|
|
4629
|
+
return;
|
|
4630
|
+
}
|
|
4631
|
+
const next = new Set(picked);
|
|
4632
|
+
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
4633
|
+
else next.add(resolved.data);
|
|
4634
|
+
onChange(next.size === 0 ? null : [...next]);
|
|
4635
|
+
};
|
|
4636
|
+
const drop = (recordId) => {
|
|
4637
|
+
const next = picked.filter((id2) => id2 !== recordId);
|
|
4638
|
+
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
4639
|
+
};
|
|
4640
|
+
const visible = listed;
|
|
4641
|
+
const pickedUserIds = new Set(
|
|
4642
|
+
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
4643
|
+
);
|
|
4644
|
+
const anchored = autoOpen === true;
|
|
4645
|
+
const cellChips = picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
4646
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: (0, import_design_system21.cn)("flex flex-wrap items-center gap-1", className), children: [
|
|
4647
|
+
anchored && !disabled ? null : cellChips,
|
|
4648
|
+
disabled ? null : (
|
|
4649
|
+
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
4650
|
+
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
4651
|
+
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
4652
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
4653
|
+
PickOrAdd,
|
|
4654
|
+
{
|
|
4655
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
4656
|
+
anchored,
|
|
4657
|
+
multi: field.multi,
|
|
4658
|
+
triggerId: id,
|
|
4659
|
+
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
4660
|
+
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
4661
|
+
open,
|
|
4662
|
+
onOpenChange: setOpen,
|
|
4663
|
+
search,
|
|
4664
|
+
onSearch: setSearch,
|
|
4665
|
+
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
4666
|
+
items: visible.map((member) => ({
|
|
4667
|
+
id: member.userId,
|
|
4668
|
+
label: displayNameOf(member.userId) ?? memberName(member),
|
|
4669
|
+
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
4670
|
+
// 19 September). They are two facts, so they are drawn as two.
|
|
4671
|
+
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
4672
|
+
picked: pickedUserIds.has(member.userId),
|
|
4673
|
+
person: true,
|
|
4674
|
+
disabled: busy
|
|
4675
|
+
})),
|
|
4676
|
+
onPick: (userId) => {
|
|
4677
|
+
const member = visible.find((m) => m.userId === userId);
|
|
4678
|
+
if (member && !busy) void pick(member);
|
|
4679
|
+
},
|
|
4680
|
+
notice: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4681
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalLine, { error, className: "p-2" }) : null,
|
|
4682
|
+
members === null ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
4683
|
+
] }),
|
|
4684
|
+
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,
|
|
4685
|
+
children: anchored ? cellChips : null
|
|
4686
|
+
}
|
|
4687
|
+
)
|
|
4688
|
+
)
|
|
4689
|
+
] });
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
// src/values.tsx
|
|
4693
|
+
var import_outbound_react5 = require("@ai-matrx/kit/outbound-react");
|
|
4694
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4507
4695
|
function statusMark(field, item, document2) {
|
|
4508
4696
|
const mark = statusMarkOf(field, item, document2);
|
|
4509
|
-
return mark ? /* @__PURE__ */ (0,
|
|
4697
|
+
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
4698
|
}
|
|
4511
4699
|
function envelopeFor(document2, key) {
|
|
4512
4700
|
const block = document2?._values;
|
|
@@ -4552,48 +4740,48 @@ function sourceArchivedSentence(state2) {
|
|
|
4552
4740
|
return state2.table ? `${state2.label} on ${state2.table} is archived` : `${state2.label} is archived`;
|
|
4553
4741
|
}
|
|
4554
4742
|
function SourceArchivedValue({ state: state2 }) {
|
|
4555
|
-
return /* @__PURE__ */ (0,
|
|
4743
|
+
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
4744
|
}
|
|
4557
4745
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4558
4746
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4559
|
-
const archivedSource = (0,
|
|
4560
|
-
if (archivedSource) return /* @__PURE__ */ (0,
|
|
4747
|
+
const archivedSource = (0, import_records18.sourceArchivedOf)(value);
|
|
4748
|
+
if (archivedSource) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SourceArchivedValue, { state: archivedSource });
|
|
4561
4749
|
const envelope = envelopeFor(document2, field.key);
|
|
4562
4750
|
if (envelope?.absent) {
|
|
4563
|
-
return /* @__PURE__ */ (0,
|
|
4751
|
+
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
4752
|
}
|
|
4565
4753
|
if (value === null || value === void 0 || value === "") {
|
|
4566
4754
|
const gone = unresolvedFor(document2, field.key);
|
|
4567
4755
|
if (gone) {
|
|
4568
|
-
return /* @__PURE__ */ (0,
|
|
4756
|
+
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
4757
|
}
|
|
4570
4758
|
const archivedInput = formulaSourceArchived(field, document2);
|
|
4571
|
-
if (archivedInput) return /* @__PURE__ */ (0,
|
|
4759
|
+
if (archivedInput) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SourceArchivedValue, { state: archivedInput });
|
|
4572
4760
|
const computed = computedEmptyOf(field, document2);
|
|
4573
|
-
if (computed?.sentence) return /* @__PURE__ */ (0,
|
|
4574
|
-
if (computed?.words) return /* @__PURE__ */ (0,
|
|
4761
|
+
if (computed?.sentence) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-xs italic text-muted-foreground", children: computed.sentence });
|
|
4762
|
+
if (computed?.words) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-records-empty-why": computed.kind, children: computed.words });
|
|
4575
4763
|
if (computed?.why) {
|
|
4576
|
-
return /* @__PURE__ */ (0,
|
|
4764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
|
|
4577
4765
|
}
|
|
4578
4766
|
if (look?.blankEmpty) return null;
|
|
4579
|
-
return /* @__PURE__ */ (0,
|
|
4767
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4580
4768
|
}
|
|
4581
|
-
if (isSignatureField(field)) return /* @__PURE__ */ (0,
|
|
4582
|
-
if ((0,
|
|
4769
|
+
if (isSignatureField(field)) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SignatureValue, { value, fieldKey: field.key, document: document2 });
|
|
4770
|
+
if ((0, import_records18.isButtonField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ButtonValue, { field });
|
|
4583
4771
|
const newer = newerKindValue(field, value);
|
|
4584
4772
|
if (newer !== void 0) return newer;
|
|
4585
4773
|
const whole = typeof value === "string" ? (0, import_core5.wholeValueOf)(document2, field.key) : null;
|
|
4586
|
-
if (whole) return /* @__PURE__ */ (0,
|
|
4774
|
+
if (whole) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WholeValueCell, { words: value, pointer: whole });
|
|
4587
4775
|
const kind = editorKindFor(field);
|
|
4588
4776
|
if (kind === "relation" || kind === "entity_reference") {
|
|
4589
|
-
return /* @__PURE__ */ (0,
|
|
4777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
|
|
4590
4778
|
}
|
|
4591
4779
|
if (kind === "member") {
|
|
4592
4780
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4593
|
-
return /* @__PURE__ */ (0,
|
|
4781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-person-chips": "", children: ids.map((id, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PersonChip, { name: scalarText(field, id, labels, stillWaitingFor) }, `${String(id)}-${i}`)) });
|
|
4594
4782
|
}
|
|
4595
4783
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4596
|
-
if (kv) return /* @__PURE__ */ (0,
|
|
4784
|
+
if (kv) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KindValueCell, { kv, where: "cell", title: field.label });
|
|
4597
4785
|
const chosen = kind === "select" || kind === "multi_select";
|
|
4598
4786
|
const chipOf = (item) => {
|
|
4599
4787
|
const chipLook = choiceChipLookOf(field, item, scalarText(field, item, labels));
|
|
@@ -4601,17 +4789,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4601
4789
|
};
|
|
4602
4790
|
if (chosen) {
|
|
4603
4791
|
const items = Array.isArray(value) ? value : [value];
|
|
4604
|
-
return /* @__PURE__ */ (0,
|
|
4792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
|
|
4605
4793
|
const chip = chipOf(item);
|
|
4606
|
-
return /* @__PURE__ */ (0,
|
|
4607
|
-
|
|
4794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4795
|
+
import_design_system22.Badge,
|
|
4608
4796
|
{
|
|
4609
4797
|
variant: "outline",
|
|
4610
|
-
className: (0,
|
|
4798
|
+
className: (0, import_design_system22.cn)("text-[11px]", chip.className),
|
|
4611
4799
|
"data-records-choice-chip": "",
|
|
4612
4800
|
...chip.tinted ? { "data-records-choice-tint": "" } : {},
|
|
4613
4801
|
children: [
|
|
4614
|
-
look?.choiceDot ? /* @__PURE__ */ (0,
|
|
4802
|
+
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
4803
|
statusMark(field, item, Array.isArray(value) ? void 0 : document2),
|
|
4616
4804
|
scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
|
|
4617
4805
|
]
|
|
@@ -4620,13 +4808,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4620
4808
|
);
|
|
4621
4809
|
}) });
|
|
4622
4810
|
}
|
|
4623
|
-
if (kind === "attachment") return /* @__PURE__ */ (0,
|
|
4811
|
+
if (kind === "attachment") return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AttachmentChips, { value });
|
|
4624
4812
|
if (Array.isArray(value)) {
|
|
4625
|
-
return /* @__PURE__ */ (0,
|
|
4813
|
+
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
4814
|
}
|
|
4627
4815
|
if (kind === "url" && typeof value === "string") {
|
|
4628
4816
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
4629
|
-
return /* @__PURE__ */ (0,
|
|
4817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4630
4818
|
import_outbound_react5.OutboundLink,
|
|
4631
4819
|
{
|
|
4632
4820
|
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 +4823,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4635
4823
|
"data-records-link-chip": "",
|
|
4636
4824
|
onClick: (event) => event.stopPropagation(),
|
|
4637
4825
|
children: [
|
|
4638
|
-
/* @__PURE__ */ (0,
|
|
4639
|
-
/* @__PURE__ */ (0,
|
|
4826
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
|
|
4827
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "truncate", children: linkChipText(value) })
|
|
4640
4828
|
]
|
|
4641
4829
|
}
|
|
4642
4830
|
);
|
|
4643
4831
|
}
|
|
4644
4832
|
if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
|
|
4645
|
-
return /* @__PURE__ */ (0,
|
|
4833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4646
4834
|
"a",
|
|
4647
4835
|
{
|
|
4648
4836
|
className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
|
|
@@ -4655,19 +4843,19 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4655
4843
|
);
|
|
4656
4844
|
}
|
|
4657
4845
|
if (kind === "email" && typeof value === "string") {
|
|
4658
|
-
return /* @__PURE__ */ (0,
|
|
4846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
|
|
4659
4847
|
}
|
|
4660
4848
|
if (typeof value === "boolean") {
|
|
4661
|
-
return /* @__PURE__ */ (0,
|
|
4849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
|
|
4662
4850
|
}
|
|
4663
|
-
return /* @__PURE__ */ (0,
|
|
4851
|
+
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) });
|
|
4664
4852
|
}
|
|
4665
4853
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4666
4854
|
if (value === null || value === void 0) return "\u2014";
|
|
4667
|
-
if ((0,
|
|
4855
|
+
if ((0, import_records18.sourceArchivedOf)(value)) return SOURCE_ARCHIVED_WORDS;
|
|
4668
4856
|
if (isSignatureField(field)) return signatureWords(value) ?? "\u2014";
|
|
4669
|
-
if ((0,
|
|
4670
|
-
const newerWords = (0,
|
|
4857
|
+
if ((0, import_records18.autonumberPrefixOf)(field)) return (0, import_records18.autonumberWords)(field, value) ?? String(value);
|
|
4858
|
+
const newerWords = (0, import_records18.newerKindWords)(field, value);
|
|
4671
4859
|
if (newerWords !== null) return newerWords;
|
|
4672
4860
|
const kind = editorKindFor(field);
|
|
4673
4861
|
if (kind === "entity_reference") return entityReferenceText(value);
|
|
@@ -4703,24 +4891,24 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4703
4891
|
}
|
|
4704
4892
|
|
|
4705
4893
|
// src/SourceArchivedNotice.tsx
|
|
4706
|
-
var
|
|
4894
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4707
4895
|
function bringBackLabel(state2) {
|
|
4708
4896
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4709
4897
|
}
|
|
4710
4898
|
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,
|
|
4899
|
+
const client = (0, import_react36.useRecordsClient)();
|
|
4900
|
+
const [state2, setState] = (0, import_react35.useState)(null);
|
|
4901
|
+
const [busy, setBusy] = (0, import_react35.useState)(false);
|
|
4902
|
+
const [refused, setRefused] = (0, import_react35.useState)(null);
|
|
4903
|
+
const read = (0, import_react35.useCallback)(async () => {
|
|
4716
4904
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4717
4905
|
if (answer.ok) setState(answer.data);
|
|
4718
4906
|
else setRefused(answer.error);
|
|
4719
4907
|
}, [client, fieldId]);
|
|
4720
|
-
(0,
|
|
4908
|
+
(0, import_react35.useEffect)(() => {
|
|
4721
4909
|
void read();
|
|
4722
4910
|
}, [read]);
|
|
4723
|
-
if (refused && !state2) return /* @__PURE__ */ (0,
|
|
4911
|
+
if (refused && !state2) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: refused });
|
|
4724
4912
|
if (!state2) return null;
|
|
4725
4913
|
const restore = async () => {
|
|
4726
4914
|
if (!state2.field_id) return;
|
|
@@ -4732,36 +4920,36 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4732
4920
|
setRefused(done.error);
|
|
4733
4921
|
return;
|
|
4734
4922
|
}
|
|
4735
|
-
if (state2.table_id) (0,
|
|
4736
|
-
(0,
|
|
4923
|
+
if (state2.table_id) (0, import_react36.tableShapeChanged)(state2.table_id);
|
|
4924
|
+
(0, import_react36.tableShapeChanged)(tableId);
|
|
4737
4925
|
await read();
|
|
4738
4926
|
};
|
|
4739
|
-
return /* @__PURE__ */ (0,
|
|
4927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4740
4928
|
"div",
|
|
4741
4929
|
{
|
|
4742
4930
|
className: "flex flex-wrap items-center gap-2 rounded-md border border-border px-3 py-2",
|
|
4743
4931
|
"data-testid": "source-archived-notice",
|
|
4744
4932
|
"data-field-id": state2.field_id ?? "",
|
|
4745
4933
|
children: [
|
|
4746
|
-
/* @__PURE__ */ (0,
|
|
4747
|
-
/* @__PURE__ */ (0,
|
|
4748
|
-
/* @__PURE__ */ (0,
|
|
4934
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
4935
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-sm", children: SOURCE_ARCHIVED_WORDS }),
|
|
4936
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate text-xs text-muted-foreground", children: sourceArchivedSentence(state2) })
|
|
4749
4937
|
] }),
|
|
4750
|
-
state2.field_id ? /* @__PURE__ */ (0,
|
|
4751
|
-
refused ? /* @__PURE__ */ (0,
|
|
4938
|
+
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,
|
|
4939
|
+
refused ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: refused, className: "basis-full" }) : null
|
|
4752
4940
|
]
|
|
4753
4941
|
}
|
|
4754
4942
|
);
|
|
4755
4943
|
}
|
|
4756
4944
|
|
|
4757
4945
|
// src/Condition.tsx
|
|
4758
|
-
var
|
|
4759
|
-
var
|
|
4760
|
-
var
|
|
4761
|
-
var
|
|
4946
|
+
var import_react38 = require("react");
|
|
4947
|
+
var import_design_system24 = require("@ai-matrx/design-system");
|
|
4948
|
+
var import_records19 = require("@ai-matrx/records");
|
|
4949
|
+
var import_react39 = require("@ai-matrx/records/react");
|
|
4762
4950
|
|
|
4763
4951
|
// src/personTime.ts
|
|
4764
|
-
var
|
|
4952
|
+
var import_react37 = require("react");
|
|
4765
4953
|
|
|
4766
4954
|
// src/personZone.ts
|
|
4767
4955
|
var import_table_style3 = require("@ai-matrx/design-system/data-table/table-style");
|
|
@@ -4798,7 +4986,7 @@ function personWallNow(at = /* @__PURE__ */ new Date()) {
|
|
|
4798
4986
|
|
|
4799
4987
|
// src/personTime.ts
|
|
4800
4988
|
function usePersonTimeZone() {
|
|
4801
|
-
return (0,
|
|
4989
|
+
return (0, import_react37.useSyncExternalStore)(
|
|
4802
4990
|
subscribePersonTimeZone,
|
|
4803
4991
|
getPersonTimeZone,
|
|
4804
4992
|
() => null
|
|
@@ -4806,7 +4994,7 @@ function usePersonTimeZone() {
|
|
|
4806
4994
|
}
|
|
4807
4995
|
|
|
4808
4996
|
// src/Condition.tsx
|
|
4809
|
-
var
|
|
4997
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4810
4998
|
var CONDITION_OPS = [
|
|
4811
4999
|
{ op: "eq", label: "is" },
|
|
4812
5000
|
{ op: "ne", label: "is not" },
|
|
@@ -4843,7 +5031,7 @@ function linkedOf(expr) {
|
|
|
4843
5031
|
if (match !== "any" && match !== "none") return null;
|
|
4844
5032
|
return { via: rel["field"], inner: a["field"], op: match === "any" ? "eq" : "ne", value: b["const"] };
|
|
4845
5033
|
}
|
|
4846
|
-
var FilterTermsContext = (0,
|
|
5034
|
+
var FilterTermsContext = (0, import_react38.createContext)(false);
|
|
4847
5035
|
var RELATIVE_DAY_TERMS = [
|
|
4848
5036
|
{ kind: "today", label: "is today" },
|
|
4849
5037
|
{ kind: "tomorrow", label: "is tomorrow" },
|
|
@@ -4894,17 +5082,17 @@ function isChoiceColumn(f) {
|
|
|
4894
5082
|
return kind === "select" || kind === "multi_select";
|
|
4895
5083
|
}
|
|
4896
5084
|
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,
|
|
5085
|
+
const client = (0, import_react39.useOptionalRecordsClient)();
|
|
5086
|
+
const [choices, setChoices] = (0, import_react38.useState)(null);
|
|
5087
|
+
const [open, setOpen] = (0, import_react38.useState)(false);
|
|
5088
|
+
const [search, setSearch] = (0, import_react38.useState)("");
|
|
5089
|
+
(0, import_react38.useEffect)(() => {
|
|
4902
5090
|
if (!client) return;
|
|
4903
5091
|
let cancelled = false;
|
|
4904
5092
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
4905
5093
|
if (cancelled) return;
|
|
4906
5094
|
setChoices(
|
|
4907
|
-
got.ok ? (got.data ?? []).map((o) => ({ key: (0,
|
|
5095
|
+
got.ok ? (got.data ?? []).map((o) => ({ key: (0, import_records19.optionKey)(o), label: (0, import_records19.optionLabel)(o) ?? "" })).filter((c) => c.label !== "") : []
|
|
4908
5096
|
);
|
|
4909
5097
|
});
|
|
4910
5098
|
return () => {
|
|
@@ -4912,8 +5100,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4912
5100
|
};
|
|
4913
5101
|
}, [client, field.id]);
|
|
4914
5102
|
if (!choices || choices.length === 0) {
|
|
4915
|
-
return /* @__PURE__ */ (0,
|
|
4916
|
-
|
|
5103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5104
|
+
import_design_system24.BasicInput,
|
|
4917
5105
|
{
|
|
4918
5106
|
className: "h-8 w-28 text-xs",
|
|
4919
5107
|
"aria-label": "Condition value",
|
|
@@ -4922,8 +5110,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4922
5110
|
}
|
|
4923
5111
|
);
|
|
4924
5112
|
}
|
|
4925
|
-
const shown2 = (0,
|
|
4926
|
-
return /* @__PURE__ */ (0,
|
|
5113
|
+
const shown2 = (0, import_records19.rankTypedMatches)(choices, search.trim(), (c) => c.label);
|
|
5114
|
+
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
5115
|
PickOrAdd,
|
|
4928
5116
|
{
|
|
4929
5117
|
triggerSize: "compact",
|
|
@@ -4949,7 +5137,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4949
5137
|
setOpen(false);
|
|
4950
5138
|
setSearch("");
|
|
4951
5139
|
},
|
|
4952
|
-
empty: /* @__PURE__ */ (0,
|
|
5140
|
+
empty: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
|
|
4953
5141
|
}
|
|
4954
5142
|
) });
|
|
4955
5143
|
}
|
|
@@ -5043,7 +5231,7 @@ function conditionValue(typed) {
|
|
|
5043
5231
|
}
|
|
5044
5232
|
function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
|
|
5045
5233
|
const node = expr ?? null;
|
|
5046
|
-
const filterTerms = (0,
|
|
5234
|
+
const filterTerms = (0, import_react38.useContext)(FilterTermsContext);
|
|
5047
5235
|
const relative = relativeDayOf(expr);
|
|
5048
5236
|
const reader = meOf(expr);
|
|
5049
5237
|
const linked = linkedOf(expr);
|
|
@@ -5089,9 +5277,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5089
5277
|
VALUELESS_OPS.has(chosenOp) ? { op: chosenOp, args: [{ field: chosenField }] } : { op: chosenOp, args: [{ field: chosenField }, { const: chosenValue }] }
|
|
5090
5278
|
);
|
|
5091
5279
|
}
|
|
5092
|
-
return /* @__PURE__ */ (0,
|
|
5093
|
-
/* @__PURE__ */ (0,
|
|
5094
|
-
/* @__PURE__ */ (0,
|
|
5280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: className ?? "flex flex-wrap items-center gap-1 text-xs", children: [
|
|
5281
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground", children: lead }),
|
|
5282
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5095
5283
|
PickOne,
|
|
5096
5284
|
{
|
|
5097
5285
|
label: "Condition field",
|
|
@@ -5102,7 +5290,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5102
5290
|
attrs: { "data-condition": "field" }
|
|
5103
5291
|
}
|
|
5104
5292
|
),
|
|
5105
|
-
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ (0,
|
|
5293
|
+
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5106
5294
|
"span",
|
|
5107
5295
|
{
|
|
5108
5296
|
className: "rounded bg-destructive px-1.5 py-0.5 text-[11px] font-medium text-destructive-foreground",
|
|
@@ -5111,8 +5299,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5111
5299
|
children: "Missing question"
|
|
5112
5300
|
}
|
|
5113
5301
|
) : null,
|
|
5114
|
-
onField ? /* @__PURE__ */ (0,
|
|
5115
|
-
/* @__PURE__ */ (0,
|
|
5302
|
+
onField ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
5303
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5116
5304
|
PickOne,
|
|
5117
5305
|
{
|
|
5118
5306
|
label: "Condition comparison",
|
|
@@ -5123,8 +5311,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5123
5311
|
attrs: { "data-condition": "comparison" }
|
|
5124
5312
|
}
|
|
5125
5313
|
),
|
|
5126
|
-
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ (0,
|
|
5127
|
-
|
|
5314
|
+
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5315
|
+
import_design_system24.BasicInput,
|
|
5128
5316
|
{
|
|
5129
5317
|
className: "h-8 w-16 text-xs",
|
|
5130
5318
|
type: "number",
|
|
@@ -5140,7 +5328,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5140
5328
|
// is asked for ONE record even when the column holds several: a clause compares
|
|
5141
5329
|
// against one value, and a picker that let somebody choose three would be
|
|
5142
5330
|
// writing an expression this row cannot draw back.
|
|
5143
|
-
/* @__PURE__ */ (0,
|
|
5331
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5144
5332
|
RelationPicker,
|
|
5145
5333
|
{
|
|
5146
5334
|
field: { ...chosen.field, multi: false },
|
|
@@ -5151,8 +5339,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5151
5339
|
allowCreate: false
|
|
5152
5340
|
}
|
|
5153
5341
|
)
|
|
5154
|
-
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ (0,
|
|
5155
|
-
|
|
5342
|
+
) : 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)(
|
|
5343
|
+
import_design_system24.BasicInput,
|
|
5156
5344
|
{
|
|
5157
5345
|
className: "h-8 w-28 text-xs",
|
|
5158
5346
|
"aria-label": "Condition value",
|
|
@@ -5228,7 +5416,7 @@ function ConditionGroup({
|
|
|
5228
5416
|
className
|
|
5229
5417
|
}) {
|
|
5230
5418
|
const { joiner, args } = clausesOf(expr);
|
|
5231
|
-
const [drafting, setDrafting] = (0,
|
|
5419
|
+
const [drafting, setDrafting] = (0, import_react38.useState)(null);
|
|
5232
5420
|
const nested = depth > 0;
|
|
5233
5421
|
const replaceAt = (index, next) => {
|
|
5234
5422
|
const nextArgs = args.slice();
|
|
@@ -5239,16 +5427,16 @@ function ConditionGroup({
|
|
|
5239
5427
|
const joinWord = (index) => index === 0 ? lead : joiner === "or" || joiner === "none" ? "or" : "and";
|
|
5240
5428
|
const showJoiner = nested || args.length > 1 || joiner === "none" || joiner === "notall";
|
|
5241
5429
|
const opposite = joiner === "or" || joiner === "none" ? "and" : "or";
|
|
5242
|
-
return /* @__PURE__ */ (0,
|
|
5430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
5243
5431
|
"div",
|
|
5244
5432
|
{
|
|
5245
5433
|
className: className ?? "flex flex-col gap-1 text-xs",
|
|
5246
5434
|
"data-testid": nested ? "condition-nested-group" : "condition-group",
|
|
5247
5435
|
"data-depth": depth,
|
|
5248
5436
|
children: [
|
|
5249
|
-
showJoiner ? /* @__PURE__ */ (0,
|
|
5250
|
-
/* @__PURE__ */ (0,
|
|
5251
|
-
/* @__PURE__ */ (0,
|
|
5437
|
+
showJoiner ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
5438
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground", children: nested ? "Group:" : lead }),
|
|
5439
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5252
5440
|
PickOne,
|
|
5253
5441
|
{
|
|
5254
5442
|
label: nested ? `How the conditions in this group are joined (level ${depth + 1})` : "How these conditions are joined",
|
|
@@ -5259,8 +5447,8 @@ function ConditionGroup({
|
|
|
5259
5447
|
attrs: { "data-condition": "joiner" }
|
|
5260
5448
|
}
|
|
5261
5449
|
),
|
|
5262
|
-
nested && onRemove ? /* @__PURE__ */ (0,
|
|
5263
|
-
|
|
5450
|
+
nested && onRemove ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5451
|
+
import_design_system24.Button,
|
|
5264
5452
|
{
|
|
5265
5453
|
size: "sm",
|
|
5266
5454
|
variant: "ghost",
|
|
@@ -5271,7 +5459,7 @@ function ConditionGroup({
|
|
|
5271
5459
|
}
|
|
5272
5460
|
) : null
|
|
5273
5461
|
] }) : null,
|
|
5274
|
-
args.length === 0 ? /* @__PURE__ */ (0,
|
|
5462
|
+
args.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5275
5463
|
ConditionRow,
|
|
5276
5464
|
{
|
|
5277
5465
|
lead,
|
|
@@ -5284,7 +5472,7 @@ function ConditionGroup({
|
|
|
5284
5472
|
const group = conditionGroupOf(arg);
|
|
5285
5473
|
const key = `clause-${index}`;
|
|
5286
5474
|
if (group && allowNesting) {
|
|
5287
|
-
return /* @__PURE__ */ (0,
|
|
5475
|
+
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
5476
|
ConditionGroup,
|
|
5289
5477
|
{
|
|
5290
5478
|
lead: joinWord(index),
|
|
@@ -5298,7 +5486,7 @@ function ConditionGroup({
|
|
|
5298
5486
|
}
|
|
5299
5487
|
) }, key);
|
|
5300
5488
|
}
|
|
5301
|
-
return /* @__PURE__ */ (0,
|
|
5489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5302
5490
|
ConditionRow,
|
|
5303
5491
|
{
|
|
5304
5492
|
lead: showJoiner || args.length > 1 ? joinWord(index) : lead,
|
|
@@ -5310,7 +5498,7 @@ function ConditionGroup({
|
|
|
5310
5498
|
key
|
|
5311
5499
|
);
|
|
5312
5500
|
}),
|
|
5313
|
-
drafting ? /* @__PURE__ */ (0,
|
|
5501
|
+
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
5502
|
ConditionRow,
|
|
5315
5503
|
{
|
|
5316
5504
|
lead: drafting === "group" ? `${joinWord(1)}, a group where` : joinWord(1),
|
|
@@ -5325,9 +5513,9 @@ function ConditionGroup({
|
|
|
5325
5513
|
}
|
|
5326
5514
|
}
|
|
5327
5515
|
) }) : null,
|
|
5328
|
-
args.length > 0 && !drafting ? /* @__PURE__ */ (0,
|
|
5329
|
-
/* @__PURE__ */ (0,
|
|
5330
|
-
|
|
5516
|
+
args.length > 0 && !drafting ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
5517
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5518
|
+
import_design_system24.Button,
|
|
5331
5519
|
{
|
|
5332
5520
|
size: "sm",
|
|
5333
5521
|
variant: "ghost",
|
|
@@ -5337,8 +5525,8 @@ function ConditionGroup({
|
|
|
5337
5525
|
children: "Add another condition"
|
|
5338
5526
|
}
|
|
5339
5527
|
),
|
|
5340
|
-
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ (0,
|
|
5341
|
-
|
|
5528
|
+
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5529
|
+
import_design_system24.Button,
|
|
5342
5530
|
{
|
|
5343
5531
|
size: "sm",
|
|
5344
5532
|
variant: "ghost",
|
|
@@ -5355,11 +5543,11 @@ function ConditionGroup({
|
|
|
5355
5543
|
}
|
|
5356
5544
|
|
|
5357
5545
|
// src/FieldRetype.tsx
|
|
5358
|
-
var
|
|
5359
|
-
var
|
|
5360
|
-
var
|
|
5361
|
-
var
|
|
5362
|
-
var
|
|
5546
|
+
var import_react40 = require("react");
|
|
5547
|
+
var import_records20 = require("@ai-matrx/records");
|
|
5548
|
+
var import_react41 = require("@ai-matrx/records/react");
|
|
5549
|
+
var import_design_system25 = require("@ai-matrx/design-system");
|
|
5550
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5363
5551
|
var RETYPE_TARGETS = [
|
|
5364
5552
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
5365
5553
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -5405,17 +5593,17 @@ function currentTarget(field) {
|
|
|
5405
5593
|
return "text";
|
|
5406
5594
|
}
|
|
5407
5595
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5408
|
-
const client = (0,
|
|
5596
|
+
const client = (0, import_react41.useRecordsClient)();
|
|
5409
5597
|
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,
|
|
5598
|
+
const [to, setTo] = (0, import_react40.useState)(null);
|
|
5599
|
+
const [preview, setPreview] = (0, import_react40.useState)(null);
|
|
5600
|
+
const [asking, setAsking] = (0, import_react40.useState)(false);
|
|
5601
|
+
const [refusal, setRefusal] = (0, import_react40.useState)(null);
|
|
5602
|
+
const [busy, setBusy] = (0, import_react40.useState)(false);
|
|
5603
|
+
const [said2, setSaid] = (0, import_react40.useState)(null);
|
|
5416
5604
|
const name = fieldName(field);
|
|
5417
5605
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5418
|
-
(0,
|
|
5606
|
+
(0, import_react40.useEffect)(() => {
|
|
5419
5607
|
if (!to) return;
|
|
5420
5608
|
let cancelled = false;
|
|
5421
5609
|
setPreview(null);
|
|
@@ -5429,14 +5617,14 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5429
5617
|
return;
|
|
5430
5618
|
}
|
|
5431
5619
|
const groups = answer.data.map((row) => ({ value: row.groups[field.key] ?? null, count: row.row_count }));
|
|
5432
|
-
setPreview((0,
|
|
5620
|
+
setPreview((0, import_records20.previewRetype)({ type: to.behaviour, kind: to.kind }, groups, answer.data.length >= PREVIEW_GROUPS));
|
|
5433
5621
|
});
|
|
5434
5622
|
return () => {
|
|
5435
5623
|
cancelled = true;
|
|
5436
5624
|
};
|
|
5437
5625
|
}, [client, tableId, field.key, to]);
|
|
5438
5626
|
if (!retypeableFrom(field)) {
|
|
5439
|
-
return /* @__PURE__ */ (0,
|
|
5627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[11px] text-muted-foreground", "data-records-retype": "not-here", children: whyNotRetypeable(field) });
|
|
5440
5628
|
}
|
|
5441
5629
|
const change = async () => {
|
|
5442
5630
|
if (!to) return;
|
|
@@ -5471,7 +5659,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5471
5659
|
undo: async () => {
|
|
5472
5660
|
const back = await client.migrateUndo({ migration_id: migration });
|
|
5473
5661
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5474
|
-
(0,
|
|
5662
|
+
(0, import_react41.tableShapeChanged)(tableId);
|
|
5475
5663
|
onRetyped?.();
|
|
5476
5664
|
}
|
|
5477
5665
|
});
|
|
@@ -5482,24 +5670,24 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5482
5670
|
);
|
|
5483
5671
|
setTo(null);
|
|
5484
5672
|
setPreview(null);
|
|
5485
|
-
(0,
|
|
5673
|
+
(0, import_react41.tableShapeChanged)(tableId);
|
|
5486
5674
|
onRetyped?.();
|
|
5487
5675
|
};
|
|
5488
|
-
return /* @__PURE__ */ (0,
|
|
5489
|
-
/* @__PURE__ */ (0,
|
|
5490
|
-
/* @__PURE__ */ (0,
|
|
5491
|
-
/* @__PURE__ */ (0,
|
|
5492
|
-
/* @__PURE__ */ (0,
|
|
5676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
|
|
5677
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5678
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_design_system25.Select, { value: to?.id ?? "", onValueChange: (next) => setTo(targets.find((t) => t.id === next) ?? null), children: [
|
|
5679
|
+
/* @__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" }) }),
|
|
5680
|
+
/* @__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
5681
|
] }),
|
|
5494
|
-
to ? /* @__PURE__ */ (0,
|
|
5495
|
-
to ? /* @__PURE__ */ (0,
|
|
5682
|
+
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,
|
|
5683
|
+
to ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_design_system25.Button, { size: "sm", variant: "ghost", onClick: () => setTo(null), disabled: busy, children: "Cancel" }) : null
|
|
5496
5684
|
] }),
|
|
5497
|
-
to && asking ? /* @__PURE__ */ (0,
|
|
5685
|
+
to && asking ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
5498
5686
|
"Counting ",
|
|
5499
5687
|
name,
|
|
5500
5688
|
"'s values\u2026"
|
|
5501
5689
|
] }) : null,
|
|
5502
|
-
to && preview ? /* @__PURE__ */ (0,
|
|
5690
|
+
to && preview ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-retype-preview": "", children: [
|
|
5503
5691
|
preview.converts,
|
|
5504
5692
|
" ",
|
|
5505
5693
|
preview.converts === 1 ? "value converts" : "values convert",
|
|
@@ -5508,16 +5696,16 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5508
5696
|
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
5697
|
preview.partial ? ". Counted over the first 1,000 different values." : "."
|
|
5510
5698
|
] }) : null,
|
|
5511
|
-
refusal ? /* @__PURE__ */ (0,
|
|
5512
|
-
said2 ? /* @__PURE__ */ (0,
|
|
5699
|
+
refusal ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(RefusalNotice, { error: refusal }) : null,
|
|
5700
|
+
said2 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-records-retype-done": "", children: said2 }) : null
|
|
5513
5701
|
] });
|
|
5514
5702
|
}
|
|
5515
5703
|
|
|
5516
5704
|
// src/FieldRulePreview.tsx
|
|
5517
|
-
var
|
|
5518
|
-
var
|
|
5519
|
-
var
|
|
5520
|
-
var
|
|
5705
|
+
var import_react42 = require("react");
|
|
5706
|
+
var import_records21 = require("@ai-matrx/records");
|
|
5707
|
+
var import_react43 = require("@ai-matrx/records/react");
|
|
5708
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
5521
5709
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5522
5710
|
function ruleWords(rules) {
|
|
5523
5711
|
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 +5722,14 @@ function groupValue(value, numbers) {
|
|
|
5534
5722
|
return /^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(text) ? Number(text) : value;
|
|
5535
5723
|
}
|
|
5536
5724
|
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,
|
|
5725
|
+
const client = (0, import_react43.useRecordsClient)();
|
|
5726
|
+
const [preview, setPreview] = (0, import_react42.useState)(null);
|
|
5727
|
+
const [refusal, setRefusal] = (0, import_react42.useState)(null);
|
|
5728
|
+
const key = (0, import_react42.useMemo)(() => ruleWords(rules), [rules]);
|
|
5729
|
+
const latest = (0, import_react42.useRef)(rules);
|
|
5542
5730
|
latest.current = rules;
|
|
5543
5731
|
const name = fieldName(field);
|
|
5544
|
-
(0,
|
|
5732
|
+
(0, import_react42.useEffect)(() => {
|
|
5545
5733
|
let cancelled = false;
|
|
5546
5734
|
setPreview(null);
|
|
5547
5735
|
setRefusal(null);
|
|
@@ -5554,7 +5742,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5554
5742
|
}
|
|
5555
5743
|
const numbers = holdsNumbers(field);
|
|
5556
5744
|
const groups = answer.data.map((row) => ({ value: groupValue(row.groups[field.key] ?? null, numbers), count: row.row_count }));
|
|
5557
|
-
setPreview((0,
|
|
5745
|
+
setPreview((0, import_records21.previewRuleChange)(latest.current, groups, answer.data.length >= PREVIEW_GROUPS2));
|
|
5558
5746
|
});
|
|
5559
5747
|
}, 300);
|
|
5560
5748
|
return () => {
|
|
@@ -5562,16 +5750,16 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5562
5750
|
clearTimeout(timer);
|
|
5563
5751
|
};
|
|
5564
5752
|
}, [client, tableId, field.key, key]);
|
|
5565
|
-
if (refusal) return /* @__PURE__ */ (0,
|
|
5753
|
+
if (refusal) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RefusalNotice, { error: refusal });
|
|
5566
5754
|
if (!preview) {
|
|
5567
|
-
return /* @__PURE__ */ (0,
|
|
5755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "counting", children: [
|
|
5568
5756
|
"Counting ",
|
|
5569
5757
|
name,
|
|
5570
5758
|
"'s values\u2026"
|
|
5571
5759
|
] });
|
|
5572
5760
|
}
|
|
5573
5761
|
if (preview.keptAside === 0) {
|
|
5574
|
-
return /* @__PURE__ */ (0,
|
|
5762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "fits", children: [
|
|
5575
5763
|
"Every value already in ",
|
|
5576
5764
|
name,
|
|
5577
5765
|
" still fits",
|
|
@@ -5579,7 +5767,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5579
5767
|
"."
|
|
5580
5768
|
] });
|
|
5581
5769
|
}
|
|
5582
|
-
return /* @__PURE__ */ (0,
|
|
5770
|
+
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
5771
|
preview.keptAside,
|
|
5584
5772
|
" ",
|
|
5585
5773
|
preview.keptAside === 1 ? "value no longer fits and will be" : "values no longer fit and will be",
|
|
@@ -5662,9 +5850,9 @@ function choiceLookForNewList(multi, rows) {
|
|
|
5662
5850
|
}
|
|
5663
5851
|
|
|
5664
5852
|
// src/NewerKindQuestions.tsx
|
|
5665
|
-
var
|
|
5666
|
-
var
|
|
5667
|
-
var
|
|
5853
|
+
var import_records22 = require("@ai-matrx/records");
|
|
5854
|
+
var import_design_system26 = require("@ai-matrx/design-system");
|
|
5855
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
5668
5856
|
var STATUS_STARTING_CHOICES = [
|
|
5669
5857
|
{ words: "Not started", group: "todo" },
|
|
5670
5858
|
{ words: "In progress", group: "in_progress" },
|
|
@@ -5683,7 +5871,7 @@ function statusGroupRows(field, rows, keyOfId, changed) {
|
|
|
5683
5871
|
if (words === "") continue;
|
|
5684
5872
|
const ref = r.id ?? words;
|
|
5685
5873
|
const key = r.id ? keyOfId[r.id] : void 0;
|
|
5686
|
-
const held = field && key ? (0,
|
|
5874
|
+
const held = field && key ? (0, import_records22.statusGroupOf)(field, key) : void 0;
|
|
5687
5875
|
out.push({ ref, words, group: changed[ref] ?? held ?? guessStatusGroup(words) });
|
|
5688
5876
|
}
|
|
5689
5877
|
return out;
|
|
@@ -5693,27 +5881,27 @@ function StatusGroupsQuestion({
|
|
|
5693
5881
|
onGroup
|
|
5694
5882
|
}) {
|
|
5695
5883
|
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,
|
|
5884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col gap-1", "data-records-status-groups": "", children: [
|
|
5885
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.Label, { className: "text-xs", children: "Groups" }),
|
|
5886
|
+
rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
5887
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "min-w-0 flex-1 truncate text-sm", children: r.words }),
|
|
5888
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.Select, { value: r.group, onValueChange: (next) => onGroup(r.ref, next), children: [
|
|
5889
|
+
/* @__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, {}) }),
|
|
5890
|
+
/* @__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
5891
|
STATUS_GROUP_MARK[g],
|
|
5704
5892
|
" ",
|
|
5705
|
-
|
|
5893
|
+
import_records22.STATUS_GROUP_WORDS[g]
|
|
5706
5894
|
] }, g)) })
|
|
5707
5895
|
] })
|
|
5708
5896
|
] }, r.ref))
|
|
5709
5897
|
] });
|
|
5710
5898
|
}
|
|
5711
5899
|
function RatingMaxQuestion({ value, onChange }) {
|
|
5712
|
-
return /* @__PURE__ */ (0,
|
|
5713
|
-
/* @__PURE__ */ (0,
|
|
5714
|
-
/* @__PURE__ */ (0,
|
|
5715
|
-
/* @__PURE__ */ (0,
|
|
5716
|
-
/* @__PURE__ */ (0,
|
|
5900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
5901
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.Label, { className: "text-xs", children: "Out of" }),
|
|
5902
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.Select, { value: String(value), onValueChange: (next) => onChange(Number(next)), children: [
|
|
5903
|
+
/* @__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, {}) }),
|
|
5904
|
+
/* @__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
5905
|
n,
|
|
5718
5906
|
" ",
|
|
5719
5907
|
n === 1 ? "star" : "stars"
|
|
@@ -5734,22 +5922,22 @@ var SYMBOLOGY_WORDS = {
|
|
|
5734
5922
|
pdf417: "PDF417"
|
|
5735
5923
|
};
|
|
5736
5924
|
function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
5737
|
-
return /* @__PURE__ */ (0,
|
|
5738
|
-
/* @__PURE__ */ (0,
|
|
5739
|
-
/* @__PURE__ */ (0,
|
|
5740
|
-
/* @__PURE__ */ (0,
|
|
5741
|
-
/* @__PURE__ */ (0,
|
|
5742
|
-
/* @__PURE__ */ (0,
|
|
5743
|
-
|
|
5925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
5926
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.Label, { className: "text-xs", children: "Code type" }),
|
|
5927
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.Select, { value: value === "" ? "any" : value, onValueChange: (next) => onChange(next === "any" ? "" : next), children: [
|
|
5928
|
+
/* @__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, {}) }),
|
|
5929
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_design_system26.SelectContent, { children: [
|
|
5930
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectItem, { value: "any", children: "Any code" }),
|
|
5931
|
+
import_records22.BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system26.SelectItem, { value: s, children: SYMBOLOGY_WORDS[s] }, s))
|
|
5744
5932
|
] })
|
|
5745
5933
|
] })
|
|
5746
5934
|
] });
|
|
5747
5935
|
}
|
|
5748
5936
|
|
|
5749
5937
|
// src/FieldFormatPicker.tsx
|
|
5750
|
-
var
|
|
5938
|
+
var import_design_system27 = require("@ai-matrx/design-system");
|
|
5751
5939
|
var import_field_formats6 = require("@ai-matrx/design-system/field-formats");
|
|
5752
|
-
var
|
|
5940
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
5753
5941
|
var KIND_WORD = {
|
|
5754
5942
|
choice: "select",
|
|
5755
5943
|
multi_choice: "multi_select",
|
|
@@ -5872,13 +6060,13 @@ function FieldFormatPicker({
|
|
|
5872
6060
|
else merged[key] = next;
|
|
5873
6061
|
onValue({ ...value, format: Object.keys(merged).length > 0 ? { id: value.format.id, options: merged } : { id: value.format.id } });
|
|
5874
6062
|
};
|
|
5875
|
-
const option = (key, label, control) => optionKeys.includes(key) ? /* @__PURE__ */ (0,
|
|
6063
|
+
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
6064
|
label,
|
|
5877
6065
|
control
|
|
5878
6066
|
] }, key) : null;
|
|
5879
|
-
return /* @__PURE__ */ (0,
|
|
5880
|
-
/* @__PURE__ */ (0,
|
|
5881
|
-
/* @__PURE__ */ (0,
|
|
6067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-col gap-1", "data-records-format-picker": "", children: [
|
|
6068
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_design_system27.Label, { className: "text-xs", htmlFor: `records-shows-as-${field.id}`, children: "Shows as" }),
|
|
6069
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5882
6070
|
PickOne,
|
|
5883
6071
|
{
|
|
5884
6072
|
id: `records-shows-as-${field.id}`,
|
|
@@ -5904,12 +6092,12 @@ function FieldFormatPicker({
|
|
|
5904
6092
|
]
|
|
5905
6093
|
}
|
|
5906
6094
|
),
|
|
5907
|
-
/* @__PURE__ */ (0,
|
|
5908
|
-
optionKeys.length > 0 ? /* @__PURE__ */ (0,
|
|
6095
|
+
/* @__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." }),
|
|
6096
|
+
optionKeys.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap items-end gap-2", children: [
|
|
5909
6097
|
option(
|
|
5910
6098
|
"currency",
|
|
5911
6099
|
"Currency",
|
|
5912
|
-
/* @__PURE__ */ (0,
|
|
6100
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5913
6101
|
PickOne,
|
|
5914
6102
|
{
|
|
5915
6103
|
label: "Currency",
|
|
@@ -5924,7 +6112,7 @@ function FieldFormatPicker({
|
|
|
5924
6112
|
option(
|
|
5925
6113
|
"percentScale",
|
|
5926
6114
|
"Stored as",
|
|
5927
|
-
/* @__PURE__ */ (0,
|
|
6115
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5928
6116
|
PickOne,
|
|
5929
6117
|
{
|
|
5930
6118
|
label: "Stored as",
|
|
@@ -5942,7 +6130,7 @@ function FieldFormatPicker({
|
|
|
5942
6130
|
option(
|
|
5943
6131
|
"durationUnit",
|
|
5944
6132
|
"Unit",
|
|
5945
|
-
/* @__PURE__ */ (0,
|
|
6133
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5946
6134
|
PickOne,
|
|
5947
6135
|
{
|
|
5948
6136
|
label: "Unit",
|
|
@@ -5962,7 +6150,7 @@ function FieldFormatPicker({
|
|
|
5962
6150
|
option(
|
|
5963
6151
|
"precision",
|
|
5964
6152
|
"Decimals",
|
|
5965
|
-
/* @__PURE__ */ (0,
|
|
6153
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5966
6154
|
"input",
|
|
5967
6155
|
{
|
|
5968
6156
|
"data-records-format-option": "precision",
|
|
@@ -5979,7 +6167,7 @@ function FieldFormatPicker({
|
|
|
5979
6167
|
option(
|
|
5980
6168
|
"ratingMax",
|
|
5981
6169
|
"Out of",
|
|
5982
|
-
/* @__PURE__ */ (0,
|
|
6170
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5983
6171
|
"input",
|
|
5984
6172
|
{
|
|
5985
6173
|
"data-records-format-option": "ratingMax",
|
|
@@ -5995,7 +6183,7 @@ function FieldFormatPicker({
|
|
|
5995
6183
|
option(
|
|
5996
6184
|
"dateStyle",
|
|
5997
6185
|
"Style",
|
|
5998
|
-
/* @__PURE__ */ (0,
|
|
6186
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5999
6187
|
PickOne,
|
|
6000
6188
|
{
|
|
6001
6189
|
label: "Style",
|
|
@@ -6014,15 +6202,15 @@ function FieldFormatPicker({
|
|
|
6014
6202
|
option(
|
|
6015
6203
|
"prefix",
|
|
6016
6204
|
"Prefix",
|
|
6017
|
-
/* @__PURE__ */ (0,
|
|
6205
|
+
/* @__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
6206
|
),
|
|
6019
6207
|
option(
|
|
6020
6208
|
"suffix",
|
|
6021
6209
|
"Suffix",
|
|
6022
|
-
/* @__PURE__ */ (0,
|
|
6210
|
+
/* @__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
6211
|
),
|
|
6024
|
-
optionKeys.includes("useGrouping") ? /* @__PURE__ */ (0,
|
|
6025
|
-
/* @__PURE__ */ (0,
|
|
6212
|
+
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: [
|
|
6213
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
6026
6214
|
"input",
|
|
6027
6215
|
{
|
|
6028
6216
|
type: "checkbox",
|
|
@@ -6060,37 +6248,37 @@ function nextFieldSort(fields) {
|
|
|
6060
6248
|
}
|
|
6061
6249
|
|
|
6062
6250
|
// src/FieldEditor.tsx
|
|
6063
|
-
var
|
|
6251
|
+
var import_records25 = require("@ai-matrx/records");
|
|
6064
6252
|
|
|
6065
6253
|
// src/ButtonSettings.tsx
|
|
6066
|
-
var
|
|
6067
|
-
var
|
|
6254
|
+
var import_react44 = require("react");
|
|
6255
|
+
var import_design_system29 = require("@ai-matrx/design-system");
|
|
6068
6256
|
var import_data_table5 = require("@ai-matrx/design-system/data-table");
|
|
6069
|
-
var
|
|
6070
|
-
var
|
|
6257
|
+
var import_records24 = require("@ai-matrx/records");
|
|
6258
|
+
var import_react45 = require("@ai-matrx/records/react");
|
|
6071
6259
|
|
|
6072
6260
|
// src/AccentSwatches.tsx
|
|
6073
|
-
var
|
|
6074
|
-
var
|
|
6261
|
+
var import_records23 = require("@ai-matrx/records");
|
|
6262
|
+
var import_design_system28 = require("@ai-matrx/design-system");
|
|
6075
6263
|
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,
|
|
6264
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
6265
|
+
function AccentSwatches({ value, onChange, options = import_records23.PORTAL_ACCENTS, noneLabel = "App colour" }) {
|
|
6266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap gap-1.5", role: "radiogroup", "aria-label": "Colour", children: [
|
|
6267
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6080
6268
|
"button",
|
|
6081
6269
|
{
|
|
6082
6270
|
type: "button",
|
|
6083
6271
|
role: "radio",
|
|
6084
6272
|
"aria-checked": value === "",
|
|
6085
6273
|
onClick: () => onChange(""),
|
|
6086
|
-
className: (0,
|
|
6274
|
+
className: (0, import_design_system28.cn)(
|
|
6087
6275
|
"h-7 rounded border px-2 text-xs",
|
|
6088
6276
|
value === "" ? "border-foreground" : "border-border text-muted-foreground"
|
|
6089
6277
|
),
|
|
6090
6278
|
children: noneLabel
|
|
6091
6279
|
}
|
|
6092
6280
|
),
|
|
6093
|
-
options.map((c) => /* @__PURE__ */ (0,
|
|
6281
|
+
options.map((c) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6094
6282
|
"button",
|
|
6095
6283
|
{
|
|
6096
6284
|
type: "button",
|
|
@@ -6099,7 +6287,7 @@ function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACC
|
|
|
6099
6287
|
"aria-label": import_data_table4.STYLE_COLOR_LABELS[c],
|
|
6100
6288
|
title: import_data_table4.STYLE_COLOR_LABELS[c],
|
|
6101
6289
|
onClick: () => onChange(c),
|
|
6102
|
-
className: (0,
|
|
6290
|
+
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
6291
|
},
|
|
6104
6292
|
c
|
|
6105
6293
|
))
|
|
@@ -6107,7 +6295,7 @@ function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACC
|
|
|
6107
6295
|
}
|
|
6108
6296
|
|
|
6109
6297
|
// src/ButtonSettings.tsx
|
|
6110
|
-
var
|
|
6298
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6111
6299
|
var DOES_WORDS = {
|
|
6112
6300
|
none: "Nothing yet",
|
|
6113
6301
|
open_url: "Open a link",
|
|
@@ -6116,7 +6304,7 @@ var DOES_WORDS = {
|
|
|
6116
6304
|
};
|
|
6117
6305
|
function buttonUrlInWords(url, fields) {
|
|
6118
6306
|
let out = url;
|
|
6119
|
-
for (const id of (0,
|
|
6307
|
+
for (const id of (0, import_records24.buttonUrlPlaceholders)(url)) {
|
|
6120
6308
|
const f = fields.find((x) => x.id === id || x.key === id);
|
|
6121
6309
|
if (f) out = out.split(`{{${id}}}`).join(`{${fieldName(f)}}`);
|
|
6122
6310
|
}
|
|
@@ -6128,11 +6316,11 @@ function ButtonSettingsEditor({
|
|
|
6128
6316
|
tableId,
|
|
6129
6317
|
fields
|
|
6130
6318
|
}) {
|
|
6131
|
-
const client = (0,
|
|
6132
|
-
const [actions, setActions] = (0,
|
|
6133
|
-
const [actionsRefused, setActionsRefused] = (0,
|
|
6134
|
-
const [automations, setAutomations] = (0,
|
|
6135
|
-
(0,
|
|
6319
|
+
const client = (0, import_react45.useOptionalRecordsClient)();
|
|
6320
|
+
const [actions, setActions] = (0, import_react44.useState)(null);
|
|
6321
|
+
const [actionsRefused, setActionsRefused] = (0, import_react44.useState)(null);
|
|
6322
|
+
const [automations, setAutomations] = (0, import_react44.useState)(null);
|
|
6323
|
+
(0, import_react44.useEffect)(() => {
|
|
6136
6324
|
if (!client || !tableId) return;
|
|
6137
6325
|
let live = true;
|
|
6138
6326
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6153,15 +6341,15 @@ function ButtonSettingsEditor({
|
|
|
6153
6341
|
}, [client, tableId, value.do, actions, automations]);
|
|
6154
6342
|
const set = (patch) => onChange({ ...value, ...patch });
|
|
6155
6343
|
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,
|
|
6344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-2 rounded-md border p-2", "data-records-button-settings": "", children: [
|
|
6345
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
6346
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
6347
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Button label" }),
|
|
6348
|
+
/* @__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
6349
|
] }),
|
|
6162
|
-
/* @__PURE__ */ (0,
|
|
6163
|
-
/* @__PURE__ */ (0,
|
|
6164
|
-
/* @__PURE__ */ (0,
|
|
6350
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
6351
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Does" }),
|
|
6352
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6165
6353
|
PickOne,
|
|
6166
6354
|
{
|
|
6167
6355
|
label: "What a press does",
|
|
@@ -6173,9 +6361,9 @@ function ButtonSettingsEditor({
|
|
|
6173
6361
|
)
|
|
6174
6362
|
] })
|
|
6175
6363
|
] }),
|
|
6176
|
-
/* @__PURE__ */ (0,
|
|
6177
|
-
/* @__PURE__ */ (0,
|
|
6178
|
-
/* @__PURE__ */ (0,
|
|
6364
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
6365
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Colour" }),
|
|
6366
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6179
6367
|
AccentSwatches,
|
|
6180
6368
|
{
|
|
6181
6369
|
value: value.color ?? "",
|
|
@@ -6185,11 +6373,11 @@ function ButtonSettingsEditor({
|
|
|
6185
6373
|
}
|
|
6186
6374
|
)
|
|
6187
6375
|
] }),
|
|
6188
|
-
value.do === "open_url" ? /* @__PURE__ */ (0,
|
|
6189
|
-
/* @__PURE__ */ (0,
|
|
6190
|
-
/* @__PURE__ */ (0,
|
|
6191
|
-
/* @__PURE__ */ (0,
|
|
6192
|
-
|
|
6376
|
+
value.do === "open_url" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
6377
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "Link" }),
|
|
6378
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-1", children: [
|
|
6379
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6380
|
+
import_design_system29.BasicInput,
|
|
6193
6381
|
{
|
|
6194
6382
|
className: "h-8 flex-1 font-mono text-xs",
|
|
6195
6383
|
placeholder: "https://",
|
|
@@ -6198,7 +6386,7 @@ function ButtonSettingsEditor({
|
|
|
6198
6386
|
onChange: (e) => set({ url: e.target.value })
|
|
6199
6387
|
}
|
|
6200
6388
|
),
|
|
6201
|
-
columns.length > 0 ? /* @__PURE__ */ (0,
|
|
6389
|
+
columns.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6202
6390
|
PickOne,
|
|
6203
6391
|
{
|
|
6204
6392
|
label: "Add a column's value",
|
|
@@ -6211,10 +6399,10 @@ function ButtonSettingsEditor({
|
|
|
6211
6399
|
}
|
|
6212
6400
|
) : null
|
|
6213
6401
|
] }),
|
|
6214
|
-
value.url && (0,
|
|
6402
|
+
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
6403
|
] }) : null,
|
|
6216
|
-
value.do === "run_action" ? !tableId ? /* @__PURE__ */ (0,
|
|
6217
|
-
actions === null || actions.length > 0 ? /* @__PURE__ */ (0,
|
|
6404
|
+
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: [
|
|
6405
|
+
actions === null || actions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6218
6406
|
PickOne,
|
|
6219
6407
|
{
|
|
6220
6408
|
label: "Row action",
|
|
@@ -6225,7 +6413,7 @@ function ButtonSettingsEditor({
|
|
|
6225
6413
|
options: (actions ?? []).map((a) => ({ value: a.id, label: a.name }))
|
|
6226
6414
|
}
|
|
6227
6415
|
) : null,
|
|
6228
|
-
actions !== null ? /* @__PURE__ */ (0,
|
|
6416
|
+
actions !== null ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6229
6417
|
NewRowAction,
|
|
6230
6418
|
{
|
|
6231
6419
|
tableId,
|
|
@@ -6239,7 +6427,7 @@ function ButtonSettingsEditor({
|
|
|
6239
6427
|
}
|
|
6240
6428
|
) : null
|
|
6241
6429
|
] }) : null,
|
|
6242
|
-
value.do === "run_automation" ? automations && automations.length === 0 ? /* @__PURE__ */ (0,
|
|
6430
|
+
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
6431
|
PickOne,
|
|
6244
6432
|
{
|
|
6245
6433
|
label: "Automation",
|
|
@@ -6264,13 +6452,13 @@ function NewRowAction({
|
|
|
6264
6452
|
columns,
|
|
6265
6453
|
onMade
|
|
6266
6454
|
}) {
|
|
6267
|
-
const client = (0,
|
|
6455
|
+
const client = (0, import_react45.useOptionalRecordsClient)();
|
|
6268
6456
|
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,
|
|
6457
|
+
const [fieldId, setFieldId] = (0, import_react44.useState)("");
|
|
6458
|
+
const [setTo, setSetTo] = (0, import_react44.useState)("");
|
|
6459
|
+
const [busy, setBusy] = (0, import_react44.useState)(false);
|
|
6460
|
+
const [refused, setRefused] = (0, import_react44.useState)(null);
|
|
6461
|
+
if (settable.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
|
|
6274
6462
|
const make = async () => {
|
|
6275
6463
|
if (!client || fieldId === "") return;
|
|
6276
6464
|
setBusy(true);
|
|
@@ -6294,10 +6482,10 @@ function NewRowAction({
|
|
|
6294
6482
|
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
6483
|
onMade(made.id, all);
|
|
6296
6484
|
};
|
|
6297
|
-
return /* @__PURE__ */ (0,
|
|
6298
|
-
/* @__PURE__ */ (0,
|
|
6299
|
-
/* @__PURE__ */ (0,
|
|
6300
|
-
/* @__PURE__ */ (0,
|
|
6485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-1", "data-records-button-new-action": "", children: [
|
|
6486
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system29.Label, { className: "text-xs", children: "New row action" }),
|
|
6487
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
6488
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6301
6489
|
PickOne,
|
|
6302
6490
|
{
|
|
6303
6491
|
label: "Column to set",
|
|
@@ -6309,19 +6497,19 @@ function NewRowAction({
|
|
|
6309
6497
|
options: settable.map((f) => ({ value: f.id, label: fieldName(f) }))
|
|
6310
6498
|
}
|
|
6311
6499
|
),
|
|
6312
|
-
/* @__PURE__ */ (0,
|
|
6313
|
-
/* @__PURE__ */ (0,
|
|
6500
|
+
/* @__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) }),
|
|
6501
|
+
/* @__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
6502
|
] }),
|
|
6315
|
-
refused ? /* @__PURE__ */ (0,
|
|
6503
|
+
refused ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RefusalLine, { error: refused }) : null
|
|
6316
6504
|
] });
|
|
6317
6505
|
}
|
|
6318
6506
|
|
|
6319
6507
|
// src/FieldEditor.tsx
|
|
6320
|
-
var
|
|
6321
|
-
var
|
|
6508
|
+
var import_records26 = require("@ai-matrx/records");
|
|
6509
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6322
6510
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
6323
|
-
var SENSITIVITIES =
|
|
6324
|
-
var AGENT_VISIBILITY =
|
|
6511
|
+
var SENSITIVITIES = import_records26.FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
6512
|
+
var AGENT_VISIBILITY = import_records26.CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
6325
6513
|
var ROLLUP_OPERATIONS = ROLLUP_AGG_VALUES.map((value) => ({
|
|
6326
6514
|
value,
|
|
6327
6515
|
label: ROLLUP_AGG_LABEL[value]
|
|
@@ -6334,7 +6522,7 @@ var FORMULA_OPERATIONS = FORMULA_OP_VALUES.map((value) => ({
|
|
|
6334
6522
|
label: FORMULA_OP_LABEL[value],
|
|
6335
6523
|
joins: FORMULA_OP_JOINS[value]
|
|
6336
6524
|
}));
|
|
6337
|
-
var STORE_BEHAVIOUR = new Map(
|
|
6525
|
+
var STORE_BEHAVIOUR = new Map(import_records26.DECLARABLE_FIELD_KINDS.map((row) => [row.kind, row.behavior]));
|
|
6338
6526
|
function holdsAValueOnAStandardTable(kind) {
|
|
6339
6527
|
if (isSystemFieldKind(kind)) return false;
|
|
6340
6528
|
const behaviour = STORE_BEHAVIOUR.get(kind);
|
|
@@ -6412,16 +6600,16 @@ function FieldEditor(props) {
|
|
|
6412
6600
|
const entityToken = props.entityToken ?? null;
|
|
6413
6601
|
const onEntity = entityToken !== null;
|
|
6414
6602
|
const tableId = props.tableId ?? "";
|
|
6415
|
-
const table = (0,
|
|
6416
|
-
const tableFields = (0,
|
|
6417
|
-
const entityFields = (0,
|
|
6603
|
+
const table = (0, import_react47.useTable)(onEntity ? null : tableId);
|
|
6604
|
+
const tableFields = (0, import_react47.useFields)(onEntity ? null : tableId);
|
|
6605
|
+
const entityFields = (0, import_react47.useEntityFields)(entityToken);
|
|
6418
6606
|
const fields = onEntity ? entityFields : tableFields;
|
|
6419
6607
|
const tableRights2 = useTableRights(onEntity ? null : table.data);
|
|
6420
|
-
const entityRights = (0,
|
|
6421
|
-
const tableMutation = (0,
|
|
6422
|
-
const entityMutation = (0,
|
|
6608
|
+
const entityRights = (0, import_react47.useEntityFieldRights)(entityToken);
|
|
6609
|
+
const tableMutation = (0, import_react47.useFieldMutation)();
|
|
6610
|
+
const entityMutation = (0, import_react47.useEntityFieldMutation)();
|
|
6423
6611
|
const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
|
|
6424
|
-
const client = (0,
|
|
6612
|
+
const client = (0, import_react47.useRecordsClient)();
|
|
6425
6613
|
const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
|
|
6426
6614
|
const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
|
|
6427
6615
|
const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
|
|
@@ -6431,56 +6619,56 @@ function FieldEditor(props) {
|
|
|
6431
6619
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6432
6620
|
const start = field ?? copyOf;
|
|
6433
6621
|
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,
|
|
6622
|
+
const [label, setLabel] = (0, import_react46.useState)(field?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
|
|
6623
|
+
const [type, setType] = (0, import_react46.useState)(() => startAs ? startAs.type : startingType(start));
|
|
6624
|
+
const [required, setRequired] = (0, import_react46.useState)(start?.required ?? false);
|
|
6625
|
+
const [multi, setMulti] = (0, import_react46.useState)(start?.multi ?? false);
|
|
6626
|
+
const [dated, setDated] = (0, import_react46.useState)(start?.dated ?? false);
|
|
6627
|
+
const [sensitivity, setSensitivity] = (0, import_react46.useState)(String(start?.sensitivity ?? "internal"));
|
|
6628
|
+
const [contextPolicy, setContextPolicy] = (0, import_react46.useState)(String(start?.context_policy ?? "include"));
|
|
6629
|
+
const [rules, setRules] = (0, import_react46.useState)(start?.rules ?? []);
|
|
6630
|
+
const [startsWith, setStartsWith] = (0, import_react46.useState)(start?.default ?? null);
|
|
6631
|
+
const [ratingMax, setRatingMax] = (0, import_react46.useState)(() => start ? (0, import_records26.ratingMaxOf)(start) : 5);
|
|
6632
|
+
const savedRules = (0, import_react46.useMemo)(
|
|
6633
|
+
() => field ? type === "rating" ? (0, import_records26.rulesWithTopStar)(field.rules ?? [], (0, import_records26.ratingMaxOf)(field)) : field.rules ?? [] : [],
|
|
6446
6634
|
[field, type]
|
|
6447
6635
|
);
|
|
6448
|
-
const editedRules = (0,
|
|
6449
|
-
const [statusGroups, setStatusGroups] = (0,
|
|
6450
|
-
const [statusKeys, setStatusKeys] = (0,
|
|
6451
|
-
const [symbology, setSymbology] = (0,
|
|
6636
|
+
const editedRules = (0, import_react46.useMemo)(() => type === "rating" ? (0, import_records26.rulesWithTopStar)(rules, ratingMax) : rules, [type, rules, ratingMax]);
|
|
6637
|
+
const [statusGroups, setStatusGroups] = (0, import_react46.useState)({});
|
|
6638
|
+
const [statusKeys, setStatusKeys] = (0, import_react46.useState)({});
|
|
6639
|
+
const [symbology, setSymbology] = (0, import_react46.useState)(String(start?.config?.["symbology"] ?? ""));
|
|
6452
6640
|
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,
|
|
6641
|
+
const [description, setDescription] = (0, import_react46.useState)(descriptionStart);
|
|
6642
|
+
const buttonStart = (0, import_react46.useMemo)(() => (0, import_records25.buttonOf)(start) ?? { label: "" }, [start]);
|
|
6643
|
+
const [buttonSettings, setButtonSettings] = (0, import_react46.useState)(buttonStart);
|
|
6644
|
+
const prefixStart = (0, import_records25.autonumberPrefixOf)(start);
|
|
6645
|
+
const [numberPrefix, setNumberPrefix] = (0, import_react46.useState)(prefixStart);
|
|
6458
6646
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6459
|
-
const [dependency, setDependency] = (0,
|
|
6460
|
-
(0,
|
|
6647
|
+
const [dependency, setDependency] = (0, import_react46.useState)(dependencyStart);
|
|
6648
|
+
(0, import_react46.useEffect)(() => {
|
|
6461
6649
|
if (!field || type !== "status") return;
|
|
6462
6650
|
let live = true;
|
|
6463
6651
|
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,
|
|
6652
|
+
if (live && got.ok) setStatusKeys(Object.fromEntries((got.data ?? []).map((o) => [String(o.id), (0, import_records26.optionKey)(o)])));
|
|
6465
6653
|
});
|
|
6466
6654
|
return () => {
|
|
6467
6655
|
live = false;
|
|
6468
6656
|
};
|
|
6469
6657
|
}, [client, field, type]);
|
|
6470
|
-
(0,
|
|
6658
|
+
(0, import_react46.useEffect)(() => {
|
|
6471
6659
|
if (field || type !== "status") return;
|
|
6472
6660
|
setNewChoices(
|
|
6473
6661
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6474
6662
|
);
|
|
6475
6663
|
}, [field, type]);
|
|
6476
|
-
(0,
|
|
6664
|
+
(0, import_react46.useEffect)(() => {
|
|
6477
6665
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6478
6666
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6479
6667
|
}, [field, type]);
|
|
6480
|
-
const [allowOther, setAllowOther] = (0,
|
|
6481
|
-
const [newChoices, setNewChoices] = (0,
|
|
6668
|
+
const [allowOther, setAllowOther] = (0, import_react46.useState)(start?.config?.["allow_other"] === true);
|
|
6669
|
+
const [newChoices, setNewChoices] = (0, import_react46.useState)([]);
|
|
6482
6670
|
const copyOfId = copyOf?.id ?? null;
|
|
6483
|
-
(0,
|
|
6671
|
+
(0, import_react46.useEffect)(() => {
|
|
6484
6672
|
if (!copyOf || !copyOfId) return;
|
|
6485
6673
|
let live = true;
|
|
6486
6674
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6492,53 +6680,53 @@ function FieldEditor(props) {
|
|
|
6492
6680
|
live = false;
|
|
6493
6681
|
};
|
|
6494
6682
|
}, [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,
|
|
6683
|
+
const [choiceList, setChoiceList] = (0, import_react46.useState)(null);
|
|
6684
|
+
const [choiceListStart, setChoiceListStart] = (0, import_react46.useState)(null);
|
|
6685
|
+
const [rehome, setRehome] = (0, import_react46.useState)({});
|
|
6686
|
+
const [rehomed, setRehomed] = (0, import_react46.useState)(null);
|
|
6687
|
+
const [rehomeRefused, setRehomeRefused] = (0, import_react46.useState)(null);
|
|
6688
|
+
const [unit, setUnit] = (0, import_react46.useState)(start?.unit ?? "$");
|
|
6689
|
+
const [withTime, setWithTime] = (0, import_react46.useState)(String(start?.config?.["kind"] ?? "date") === "datetime");
|
|
6690
|
+
const [via, setVia] = (0, import_react46.useState)(String(start?.config?.["via"] ?? ""));
|
|
6691
|
+
const [pick, setPick] = (0, import_react46.useState)(String(start?.config?.["pick"] ?? ""));
|
|
6692
|
+
const [agg, setAgg] = (0, import_react46.useState)(
|
|
6505
6693
|
start?.config?.["agg"] ?? "count"
|
|
6506
6694
|
);
|
|
6507
|
-
const [of, setOf] = (0,
|
|
6695
|
+
const [of, setOf] = (0, import_react46.useState)(String(start?.config?.["of"] ?? ""));
|
|
6508
6696
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6509
|
-
const [rollupFilter, setRollupFilter] = (0,
|
|
6697
|
+
const [rollupFilter, setRollupFilter] = (0, import_react46.useState)(
|
|
6510
6698
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6511
6699
|
);
|
|
6512
6700
|
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,
|
|
6701
|
+
const [relationTarget, setRelationTarget] = (0, import_react46.useState)(String(start?.relation_target ?? ""));
|
|
6702
|
+
const [showOnOther, setShowOnOther] = (0, import_react46.useState)(true);
|
|
6703
|
+
const [nestsSubItems, setNestsSubItems] = (0, import_react46.useState)(false);
|
|
6704
|
+
const [reverseRefused, setReverseRefused] = (0, import_react46.useState)(null);
|
|
6705
|
+
const otherTable = (0, import_react47.useTable)(!field && type === "relation" && relationTarget !== "" ? relationTarget : null);
|
|
6706
|
+
const [display, setDisplay] = (0, import_react46.useState)(start?.display ?? null);
|
|
6707
|
+
const [formulaOp, setFormulaOp] = (0, import_react46.useState)(() => formulaOpOf(start));
|
|
6708
|
+
const [formulaFields, setFormulaFields] = (0, import_react46.useState)(() => formulaFieldIdsOf(start));
|
|
6709
|
+
const [formulaSeparator, setFormulaSeparator] = (0, import_react46.useState)(() => formulaSeparatorOf(start));
|
|
6710
|
+
const [allowedTypes, setAllowedTypes] = (0, import_react46.useState)(() => entityReferenceKindsOf(start));
|
|
6523
6711
|
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,
|
|
6712
|
+
const [formulaText, setFormulaText] = (0, import_react46.useState)(startingFormulaText);
|
|
6713
|
+
const shownFormula = (0, import_react46.useRef)(startingFormulaText);
|
|
6714
|
+
(0, import_react46.useEffect)(() => {
|
|
6527
6715
|
if (shownFormula.current === startingFormulaText) return;
|
|
6528
6716
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6529
6717
|
shownFormula.current = startingFormulaText;
|
|
6530
6718
|
}, [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,
|
|
6719
|
+
const [formulaWritten, setFormulaWritten] = (0, import_react46.useState)(() => startingFormulaText.trim() !== "" || Boolean(field) || startAs?.type === "formula");
|
|
6720
|
+
const [formulaOk, setFormulaOk] = (0, import_react46.useState)(null);
|
|
6721
|
+
const [askingToRemove, setAskingToRemove] = (0, import_react46.useState)(false);
|
|
6722
|
+
const [attempted, setAttempted] = (0, import_react46.useState)(false);
|
|
6723
|
+
const [showsAs, setShowsAs] = (0, import_react46.useState)(() => start ? startingChoice(start) : { format: null, retype: null });
|
|
6724
|
+
const [backfillError, setBackfillError] = (0, import_react46.useState)(null);
|
|
6725
|
+
const [notLanded, setNotLanded] = (0, import_react46.useState)(false);
|
|
6538
6726
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6539
6727
|
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,
|
|
6728
|
+
const seededAs = (0, import_react46.useRef)(heldAs);
|
|
6729
|
+
(0, import_react46.useEffect)(() => {
|
|
6542
6730
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6543
6731
|
seededAs.current = heldAs;
|
|
6544
6732
|
setType(startingType(liveField));
|
|
@@ -6547,24 +6735,24 @@ function FieldEditor(props) {
|
|
|
6547
6735
|
setUnit(liveField.unit ?? "$");
|
|
6548
6736
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6549
6737
|
}, [heldAs]);
|
|
6550
|
-
const others = (0,
|
|
6738
|
+
const others = (0, import_react46.useMemo)(
|
|
6551
6739
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6552
6740
|
[fields.data, field?.id]
|
|
6553
6741
|
);
|
|
6554
|
-
const relations = (0,
|
|
6555
|
-
const reverse = (0,
|
|
6556
|
-
const backLinks = (0,
|
|
6557
|
-
const totalSources = (0,
|
|
6742
|
+
const relations = (0, import_react46.useMemo)(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
|
|
6743
|
+
const reverse = (0, import_react47.useReverseColumns)(onEntity ? null : tableId);
|
|
6744
|
+
const backLinks = (0, import_react46.useMemo)(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
|
|
6745
|
+
const totalSources = (0, import_react46.useMemo)(() => [...relations, ...backLinks], [relations, backLinks]);
|
|
6558
6746
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6559
6747
|
const choice = fieldTypeChoice(type);
|
|
6560
6748
|
const editing = Boolean(field);
|
|
6561
|
-
(0,
|
|
6749
|
+
(0, import_react46.useEffect)(() => {
|
|
6562
6750
|
if (!editing) setStartsWith(null);
|
|
6563
6751
|
}, [type, editing]);
|
|
6564
6752
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6565
|
-
const farFieldsOfLink = (0,
|
|
6566
|
-
const farTable = (0,
|
|
6567
|
-
const linkReaders = (0,
|
|
6753
|
+
const farFieldsOfLink = (0, import_react47.useFields)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6754
|
+
const farTable = (0, import_react47.useTable)(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6755
|
+
const linkReaders = (0, import_react46.useMemo)(
|
|
6568
6756
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6569
6757
|
[field, farFieldsOfLink.data]
|
|
6570
6758
|
);
|
|
@@ -6572,7 +6760,7 @@ function FieldEditor(props) {
|
|
|
6572
6760
|
const offersMany = multiApplies(type) && !isTitle;
|
|
6573
6761
|
if (!mayShape) {
|
|
6574
6762
|
if (onEntity && entityRights.loading) return null;
|
|
6575
|
-
return /* @__PURE__ */ (0,
|
|
6763
|
+
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
6764
|
}
|
|
6577
6765
|
const options = newChoices.map((r) => r.words.trim()).filter((word) => word !== "");
|
|
6578
6766
|
const shownStatusRows = type !== "status" ? [] : statusGroupRows(field, editing ? choiceList ?? [] : newChoices, statusKeys, statusGroups);
|
|
@@ -6584,7 +6772,7 @@ function FieldEditor(props) {
|
|
|
6584
6772
|
const nameTaken = columnNameTakenBy(label, others.map(fieldName));
|
|
6585
6773
|
const nameLine = nameTaken ? columnNameTakenLine(nameTaken, noun) : columnNameProblemLine(label, noun);
|
|
6586
6774
|
const listsChoices = type === "select" || type === "multi_select" || type === "status";
|
|
6587
|
-
const buttonMissing = type === "button" && buttonSettings.do ? (0,
|
|
6775
|
+
const buttonMissing = type === "button" && buttonSettings.do ? (0, import_records25.buttonNeeds)(buttonSettings) : null;
|
|
6588
6776
|
const missing = buttonMissing ?? (editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
|
|
6589
6777
|
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
6778
|
)));
|
|
@@ -6626,7 +6814,7 @@ function FieldEditor(props) {
|
|
|
6626
6814
|
...statusGroupsChanged ? { status_groups: statusGroupsSent } : {},
|
|
6627
6815
|
// V11 #4/#10: a rating's top star goes as `max`, the word custom.field_update now takes the way
|
|
6628
6816
|
// custom.field_declare does; the store writes the max Rule and sets aside any score above it.
|
|
6629
|
-
...type === "rating" && ratingMax !== (0,
|
|
6817
|
+
...type === "rating" && ratingMax !== (0, import_records26.ratingMaxOf)(field) ? { max: ratingMax } : {},
|
|
6630
6818
|
...type === "barcode" && symbology !== String(field.config?.["symbology"] ?? "") ? { symbology: symbology === "" ? null : symbology } : {},
|
|
6631
6819
|
...type === "button" && JSON.stringify(buttonSettings) !== JSON.stringify(buttonStart) ? { button: buttonSettings } : {},
|
|
6632
6820
|
...field.type === "relation" && dependency !== dependencyStart ? { dependency } : {},
|
|
@@ -6660,7 +6848,7 @@ function FieldEditor(props) {
|
|
|
6660
6848
|
setRehomeRefused(done.error);
|
|
6661
6849
|
return;
|
|
6662
6850
|
}
|
|
6663
|
-
(0,
|
|
6851
|
+
(0, import_react47.tableShapeChanged)(tableId);
|
|
6664
6852
|
for (const c of done.data.undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
6665
6853
|
const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
|
|
6666
6854
|
setRehome({});
|
|
@@ -6735,7 +6923,7 @@ function FieldEditor(props) {
|
|
|
6735
6923
|
if (newDefault !== null && newColumnDefaultGoes(type) === "right-after") {
|
|
6736
6924
|
const defaulted = await client.fieldUpdate({ field_id: written, patch: { default: newDefault } });
|
|
6737
6925
|
if (!defaulted.ok) {
|
|
6738
|
-
(0,
|
|
6926
|
+
(0, import_react47.tableShapeChanged)(tableId);
|
|
6739
6927
|
setBackfillError(defaulted.error);
|
|
6740
6928
|
return;
|
|
6741
6929
|
}
|
|
@@ -6761,7 +6949,7 @@ function FieldEditor(props) {
|
|
|
6761
6949
|
setReverseRefused(made.error);
|
|
6762
6950
|
return;
|
|
6763
6951
|
}
|
|
6764
|
-
(0,
|
|
6952
|
+
(0, import_react47.tableShapeChanged)(relationTarget);
|
|
6765
6953
|
}
|
|
6766
6954
|
setReverseRefused(null);
|
|
6767
6955
|
onSaved?.();
|
|
@@ -6772,16 +6960,16 @@ function FieldEditor(props) {
|
|
|
6772
6960
|
if (gone) (onRemoved ?? onSaved)?.();
|
|
6773
6961
|
else setAskingToRemove(false);
|
|
6774
6962
|
};
|
|
6775
|
-
return /* @__PURE__ */ (0,
|
|
6776
|
-
/* @__PURE__ */ (0,
|
|
6777
|
-
/* @__PURE__ */ (0,
|
|
6778
|
-
/* @__PURE__ */ (0,
|
|
6963
|
+
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: [
|
|
6964
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6965
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "font-medium", children: field ? `Field \xB7 ${fieldName(field)}` : "New field" }),
|
|
6966
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "ml-auto text-muted-foreground", children: tableLabel })
|
|
6779
6967
|
] }),
|
|
6780
|
-
/* @__PURE__ */ (0,
|
|
6781
|
-
/* @__PURE__ */ (0,
|
|
6782
|
-
/* @__PURE__ */ (0,
|
|
6783
|
-
/* @__PURE__ */ (0,
|
|
6784
|
-
|
|
6968
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
6969
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
6970
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Name" }),
|
|
6971
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6972
|
+
import_design_system30.BasicInput,
|
|
6785
6973
|
{
|
|
6786
6974
|
value: label,
|
|
6787
6975
|
autoFocus: true,
|
|
@@ -6796,7 +6984,7 @@ function FieldEditor(props) {
|
|
|
6796
6984
|
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6797
6985
|
}
|
|
6798
6986
|
),
|
|
6799
|
-
nameLine ? /* @__PURE__ */ (0,
|
|
6987
|
+
nameLine ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6800
6988
|
"span",
|
|
6801
6989
|
{
|
|
6802
6990
|
id: "field-editor-name-taken",
|
|
@@ -6807,10 +6995,10 @@ function FieldEditor(props) {
|
|
|
6807
6995
|
}
|
|
6808
6996
|
) : null
|
|
6809
6997
|
] }),
|
|
6810
|
-
field ? /* @__PURE__ */ (0,
|
|
6811
|
-
/* @__PURE__ */ (0,
|
|
6812
|
-
/* @__PURE__ */ (0,
|
|
6813
|
-
|
|
6998
|
+
field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex flex-col gap-1 sm:col-span-2", children: [
|
|
6999
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Help text" }),
|
|
7000
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7001
|
+
import_design_system30.BasicInput,
|
|
6814
7002
|
{
|
|
6815
7003
|
value: description,
|
|
6816
7004
|
maxLength: 300,
|
|
@@ -6820,30 +7008,30 @@ function FieldEditor(props) {
|
|
|
6820
7008
|
}
|
|
6821
7009
|
)
|
|
6822
7010
|
] }) : null,
|
|
6823
|
-
/* @__PURE__ */ (0,
|
|
6824
|
-
/* @__PURE__ */ (0,
|
|
6825
|
-
/* @__PURE__ */ (0,
|
|
6826
|
-
|
|
7011
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7012
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "What it holds" }),
|
|
7013
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
7014
|
+
import_design_system30.Select,
|
|
6827
7015
|
{
|
|
6828
7016
|
value: type,
|
|
6829
7017
|
disabled: editing,
|
|
6830
7018
|
onValueChange: (next) => setType(next),
|
|
6831
7019
|
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,
|
|
7020
|
+
/* @__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, {}) }),
|
|
7021
|
+
/* @__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: [
|
|
7022
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectLabel, { children: group }),
|
|
7023
|
+
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
7024
|
] }, group)) })
|
|
6837
7025
|
]
|
|
6838
7026
|
}
|
|
6839
7027
|
),
|
|
6840
|
-
editing && field ? /* @__PURE__ */ (0,
|
|
7028
|
+
editing && field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldRetype, { field: liveField ?? field, tableId }) : null
|
|
6841
7029
|
] })
|
|
6842
7030
|
] }),
|
|
6843
|
-
type === "formula" && others.length > 0 ? /* @__PURE__ */ (0,
|
|
6844
|
-
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */ (0,
|
|
6845
|
-
/* @__PURE__ */ (0,
|
|
6846
|
-
|
|
7031
|
+
type === "formula" && others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
7032
|
+
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: [
|
|
7033
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7034
|
+
import_design_system30.Button,
|
|
6847
7035
|
{
|
|
6848
7036
|
type: "button",
|
|
6849
7037
|
size: "sm",
|
|
@@ -6853,8 +7041,8 @@ function FieldEditor(props) {
|
|
|
6853
7041
|
children: "Pick the columns"
|
|
6854
7042
|
}
|
|
6855
7043
|
),
|
|
6856
|
-
/* @__PURE__ */ (0,
|
|
6857
|
-
|
|
7044
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7045
|
+
import_design_system30.Button,
|
|
6858
7046
|
{
|
|
6859
7047
|
type: "button",
|
|
6860
7048
|
size: "sm",
|
|
@@ -6865,7 +7053,7 @@ function FieldEditor(props) {
|
|
|
6865
7053
|
}
|
|
6866
7054
|
)
|
|
6867
7055
|
] }),
|
|
6868
|
-
formulaWritten ? /* @__PURE__ */ (0,
|
|
7056
|
+
formulaWritten ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6869
7057
|
FormulaTextEditor,
|
|
6870
7058
|
{
|
|
6871
7059
|
tableId,
|
|
@@ -6875,9 +7063,9 @@ function FieldEditor(props) {
|
|
|
6875
7063
|
columns: others
|
|
6876
7064
|
}
|
|
6877
7065
|
) : 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,
|
|
7066
|
+
] }) : editing && type === "formula" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No other column to read." }) : null,
|
|
7067
|
+
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(SourceArchivedNotice, { fieldId: field.id, tableId }) : null,
|
|
7068
|
+
!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
7069
|
TypeQuestions,
|
|
6882
7070
|
{
|
|
6883
7071
|
type,
|
|
@@ -6907,7 +7095,7 @@ function FieldEditor(props) {
|
|
|
6907
7095
|
setFormulaSeparator,
|
|
6908
7096
|
relations: sourcesFor(type),
|
|
6909
7097
|
others,
|
|
6910
|
-
choiceList: editing && field ? /* @__PURE__ */ (0,
|
|
7098
|
+
choiceList: editing && field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6911
7099
|
ChoiceListEditor,
|
|
6912
7100
|
{
|
|
6913
7101
|
field,
|
|
@@ -6918,10 +7106,10 @@ function FieldEditor(props) {
|
|
|
6918
7106
|
rehome,
|
|
6919
7107
|
onRehome: setRehome
|
|
6920
7108
|
}
|
|
6921
|
-
) : /* @__PURE__ */ (0,
|
|
7109
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChoiceListEditor, { isNew: true, rows: newChoices, onRows: setNewChoices }),
|
|
6922
7110
|
allowedTypes,
|
|
6923
7111
|
setAllowedTypes,
|
|
6924
|
-
newer: type === "rating" ? /* @__PURE__ */ (0,
|
|
7112
|
+
newer: type === "rating" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6925
7113
|
RatingMaxQuestion,
|
|
6926
7114
|
{
|
|
6927
7115
|
value: ratingMax,
|
|
@@ -6929,19 +7117,19 @@ function FieldEditor(props) {
|
|
|
6929
7117
|
setRatingMax(next);
|
|
6930
7118
|
}
|
|
6931
7119
|
}
|
|
6932
|
-
) : type === "status" ? /* @__PURE__ */ (0,
|
|
7120
|
+
) : 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
7121
|
}
|
|
6934
7122
|
) : null,
|
|
6935
|
-
type === "button" ? /* @__PURE__ */ (0,
|
|
6936
|
-
type === "autonumber" ? /* @__PURE__ */ (0,
|
|
6937
|
-
/* @__PURE__ */ (0,
|
|
6938
|
-
/* @__PURE__ */ (0,
|
|
7123
|
+
type === "button" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ButtonSettingsEditor, { value: buttonSettings, onChange: setButtonSettings, tableId: onEntity ? null : tableId, fields: others }) : null,
|
|
7124
|
+
type === "autonumber" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7125
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Prefix" }),
|
|
7126
|
+
/* @__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
7127
|
] }) : null,
|
|
6940
|
-
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */ (0,
|
|
6941
|
-
/* @__PURE__ */ (0,
|
|
6942
|
-
/* @__PURE__ */ (0,
|
|
7128
|
+
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: [
|
|
7129
|
+
/* @__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) }),
|
|
7130
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: "Waits on the linked records" })
|
|
6943
7131
|
] }) : null,
|
|
6944
|
-
type === "rollup" ? /* @__PURE__ */ (0,
|
|
7132
|
+
type === "rollup" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6945
7133
|
RollupFilterQuestion,
|
|
6946
7134
|
{
|
|
6947
7135
|
relation: totalSources.find((f) => f.key === via),
|
|
@@ -6951,22 +7139,22 @@ function FieldEditor(props) {
|
|
|
6951
7139
|
onChange: setRollupFilter
|
|
6952
7140
|
}
|
|
6953
7141
|
) : 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
|
-
|
|
7142
|
+
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldFormatPicker, { field, value: showsAs, onValue: setShowsAs }) : null,
|
|
7143
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-wrap items-center gap-4", children: [
|
|
7144
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7145
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7146
|
+
import_design_system30.Checkbox,
|
|
6959
7147
|
{
|
|
6960
7148
|
checked: required,
|
|
6961
7149
|
"aria-label": "Required",
|
|
6962
7150
|
onCheckedChange: (v) => setRequired(v === true)
|
|
6963
7151
|
}
|
|
6964
7152
|
),
|
|
6965
|
-
/* @__PURE__ */ (0,
|
|
7153
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { title: "Every record has to have one", children: "Required" })
|
|
6966
7154
|
] }),
|
|
6967
|
-
offersMany ? /* @__PURE__ */ (0,
|
|
6968
|
-
/* @__PURE__ */ (0,
|
|
6969
|
-
|
|
7155
|
+
offersMany ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7156
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7157
|
+
import_design_system30.Checkbox,
|
|
6970
7158
|
{
|
|
6971
7159
|
checked: multi,
|
|
6972
7160
|
"aria-label": "Can hold more than one",
|
|
@@ -6975,9 +7163,9 @@ function FieldEditor(props) {
|
|
|
6975
7163
|
),
|
|
6976
7164
|
"Can hold more than one"
|
|
6977
7165
|
] }) : null,
|
|
6978
|
-
/* @__PURE__ */ (0,
|
|
6979
|
-
/* @__PURE__ */ (0,
|
|
6980
|
-
|
|
7166
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7167
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7168
|
+
import_design_system30.Checkbox,
|
|
6981
7169
|
{
|
|
6982
7170
|
checked: dated,
|
|
6983
7171
|
"aria-label": "Each value has its own date",
|
|
@@ -6986,9 +7174,9 @@ function FieldEditor(props) {
|
|
|
6986
7174
|
),
|
|
6987
7175
|
"Each value has its own date"
|
|
6988
7176
|
] }),
|
|
6989
|
-
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ (0,
|
|
6990
|
-
/* @__PURE__ */ (0,
|
|
6991
|
-
|
|
7177
|
+
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7178
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7179
|
+
import_design_system30.Checkbox,
|
|
6992
7180
|
{
|
|
6993
7181
|
checked: showOnOther,
|
|
6994
7182
|
"aria-label": `Show on ${otherTable.data.name ?? "the other table"}`,
|
|
@@ -6999,13 +7187,13 @@ function FieldEditor(props) {
|
|
|
6999
7187
|
"Show on ",
|
|
7000
7188
|
otherTable.data.name ?? "the other table"
|
|
7001
7189
|
] }) : null,
|
|
7002
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0,
|
|
7003
|
-
/* @__PURE__ */ (0,
|
|
7004
|
-
/* @__PURE__ */ (0,
|
|
7190
|
+
!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: [
|
|
7191
|
+
/* @__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) }),
|
|
7192
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: "Waits on the linked records" })
|
|
7005
7193
|
] }) : null,
|
|
7006
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0,
|
|
7007
|
-
/* @__PURE__ */ (0,
|
|
7008
|
-
|
|
7194
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7195
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7196
|
+
import_design_system30.Checkbox,
|
|
7009
7197
|
{
|
|
7010
7198
|
checked: nestsSubItems,
|
|
7011
7199
|
"aria-label": "Sub-items",
|
|
@@ -7016,11 +7204,11 @@ function FieldEditor(props) {
|
|
|
7016
7204
|
"data-records-sub-items": ""
|
|
7017
7205
|
}
|
|
7018
7206
|
),
|
|
7019
|
-
/* @__PURE__ */ (0,
|
|
7207
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { title: "Each record sits under the one this column names", children: "Sub-items" })
|
|
7020
7208
|
] }) : null,
|
|
7021
|
-
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */ (0,
|
|
7022
|
-
/* @__PURE__ */ (0,
|
|
7023
|
-
|
|
7209
|
+
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: [
|
|
7210
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7211
|
+
import_design_system30.Checkbox,
|
|
7024
7212
|
{
|
|
7025
7213
|
checked: allowOther,
|
|
7026
7214
|
"aria-label": "A value that is not one of the choices is added to them",
|
|
@@ -7030,10 +7218,10 @@ function FieldEditor(props) {
|
|
|
7030
7218
|
"A value that is not one of the choices is added to them"
|
|
7031
7219
|
] }) : null
|
|
7032
7220
|
] }),
|
|
7033
|
-
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ (0,
|
|
7034
|
-
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ (0,
|
|
7035
|
-
/* @__PURE__ */ (0,
|
|
7036
|
-
/* @__PURE__ */ (0,
|
|
7221
|
+
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(NewColumnDefault, { type, choices: options, value: startsWith, onChange: setStartsWith }) : null,
|
|
7222
|
+
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", "data-records-field-default": "", children: [
|
|
7223
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { htmlFor: "records-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7224
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7037
7225
|
FieldControl,
|
|
7038
7226
|
{
|
|
7039
7227
|
id: "records-field-default",
|
|
@@ -7043,29 +7231,29 @@ function FieldEditor(props) {
|
|
|
7043
7231
|
}
|
|
7044
7232
|
)
|
|
7045
7233
|
] }) : null,
|
|
7046
|
-
/* @__PURE__ */ (0,
|
|
7047
|
-
/* @__PURE__ */ (0,
|
|
7048
|
-
/* @__PURE__ */ (0,
|
|
7049
|
-
/* @__PURE__ */ (0,
|
|
7050
|
-
/* @__PURE__ */ (0,
|
|
7051
|
-
/* @__PURE__ */ (0,
|
|
7052
|
-
/* @__PURE__ */ (0,
|
|
7234
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Separator, {}),
|
|
7235
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7236
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7237
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Who can see what is in it" }),
|
|
7238
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: sensitivity, onValueChange: setSensitivity, children: [
|
|
7239
|
+
/* @__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, {}) }),
|
|
7240
|
+
/* @__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
7241
|
] })
|
|
7054
7242
|
] }),
|
|
7055
|
-
/* @__PURE__ */ (0,
|
|
7056
|
-
/* @__PURE__ */ (0,
|
|
7057
|
-
/* @__PURE__ */ (0,
|
|
7058
|
-
/* @__PURE__ */ (0,
|
|
7059
|
-
/* @__PURE__ */ (0,
|
|
7243
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7244
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Can an assistant read it" }),
|
|
7245
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: contextPolicy, onValueChange: setContextPolicy, children: [
|
|
7246
|
+
/* @__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, {}) }),
|
|
7247
|
+
/* @__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
7248
|
] })
|
|
7061
7249
|
] })
|
|
7062
7250
|
] }),
|
|
7063
|
-
/* @__PURE__ */ (0,
|
|
7064
|
-
/* @__PURE__ */ (0,
|
|
7065
|
-
/* @__PURE__ */ (0,
|
|
7066
|
-
/* @__PURE__ */ (0,
|
|
7067
|
-
/* @__PURE__ */ (0,
|
|
7068
|
-
|
|
7251
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Separator, {}),
|
|
7252
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
7253
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
7254
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "font-medium", children: "What counts as a good value" }),
|
|
7255
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7256
|
+
import_design_system30.Button,
|
|
7069
7257
|
{
|
|
7070
7258
|
type: "button",
|
|
7071
7259
|
size: "sm",
|
|
@@ -7076,9 +7264,9 @@ function FieldEditor(props) {
|
|
|
7076
7264
|
}
|
|
7077
7265
|
)
|
|
7078
7266
|
] }),
|
|
7079
|
-
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */ (0,
|
|
7080
|
-
/* @__PURE__ */ (0,
|
|
7081
|
-
|
|
7267
|
+
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: [
|
|
7268
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7269
|
+
import_design_system30.Checkbox,
|
|
7082
7270
|
{
|
|
7083
7271
|
checked: rules.some((r) => r.kind === "unique"),
|
|
7084
7272
|
"aria-label": UNIQUE_LABEL,
|
|
@@ -7087,21 +7275,21 @@ function FieldEditor(props) {
|
|
|
7087
7275
|
),
|
|
7088
7276
|
UNIQUE_LABEL
|
|
7089
7277
|
] }) : null,
|
|
7090
|
-
rules.length === 0 ? /* @__PURE__ */ (0,
|
|
7091
|
-
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ (0,
|
|
7092
|
-
/* @__PURE__ */ (0,
|
|
7093
|
-
|
|
7278
|
+
rules.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-muted-foreground", children: "No checks." }) : null,
|
|
7279
|
+
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
7280
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
7281
|
+
import_design_system30.Select,
|
|
7094
7282
|
{
|
|
7095
7283
|
value: rule.kind,
|
|
7096
7284
|
onValueChange: (kind) => setRules(rules.map((r, i) => i === index ? { ...r, kind } : r)),
|
|
7097
7285
|
children: [
|
|
7098
|
-
/* @__PURE__ */ (0,
|
|
7099
|
-
/* @__PURE__ */ (0,
|
|
7286
|
+
/* @__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, {}) }),
|
|
7287
|
+
/* @__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
7288
|
]
|
|
7101
7289
|
}
|
|
7102
7290
|
),
|
|
7103
|
-
rule.kind === "length" ? /* @__PURE__ */ (0,
|
|
7104
|
-
|
|
7291
|
+
rule.kind === "length" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7292
|
+
import_design_system30.BasicInput,
|
|
7105
7293
|
{
|
|
7106
7294
|
className: "h-8 w-24",
|
|
7107
7295
|
inputMode: "numeric",
|
|
@@ -7111,8 +7299,8 @@ function FieldEditor(props) {
|
|
|
7111
7299
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withNumber(r, "min", e.target.value) : r))
|
|
7112
7300
|
}
|
|
7113
7301
|
) : null,
|
|
7114
|
-
/* @__PURE__ */ (0,
|
|
7115
|
-
|
|
7302
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7303
|
+
import_design_system30.BasicInput,
|
|
7116
7304
|
{
|
|
7117
7305
|
className: "h-8",
|
|
7118
7306
|
...rule.kind === "length" ? { inputMode: "numeric", placeholder: "most" } : {},
|
|
@@ -7121,8 +7309,8 @@ function FieldEditor(props) {
|
|
|
7121
7309
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? { ...r, value: e.target.value } : r))
|
|
7122
7310
|
}
|
|
7123
7311
|
),
|
|
7124
|
-
rule.kind === "pattern" ? /* @__PURE__ */ (0,
|
|
7125
|
-
|
|
7312
|
+
rule.kind === "pattern" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7313
|
+
import_design_system30.BasicInput,
|
|
7126
7314
|
{
|
|
7127
7315
|
className: "h-8",
|
|
7128
7316
|
placeholder: "for example 949-555-0142",
|
|
@@ -7131,8 +7319,8 @@ function FieldEditor(props) {
|
|
|
7131
7319
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withText(r, "example", e.target.value) : r))
|
|
7132
7320
|
}
|
|
7133
7321
|
) : null,
|
|
7134
|
-
/* @__PURE__ */ (0,
|
|
7135
|
-
|
|
7322
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7323
|
+
import_design_system30.Button,
|
|
7136
7324
|
{
|
|
7137
7325
|
type: "button",
|
|
7138
7326
|
size: "sm",
|
|
@@ -7144,9 +7332,9 @@ function FieldEditor(props) {
|
|
|
7144
7332
|
)
|
|
7145
7333
|
] }, `${rule.kind}-${index}`))
|
|
7146
7334
|
] }),
|
|
7147
|
-
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ (0,
|
|
7148
|
-
mutation.error ? /* @__PURE__ */ (0,
|
|
7149
|
-
notLanded ? /* @__PURE__ */ (0,
|
|
7335
|
+
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldRulePreview, { field, tableId, rules: editedRules }) : null,
|
|
7336
|
+
mutation.error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: mutation.error }) : null,
|
|
7337
|
+
notLanded ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7150
7338
|
RefusalNotice,
|
|
7151
7339
|
{
|
|
7152
7340
|
error: (0, refusals_exports.refusal)(
|
|
@@ -7156,11 +7344,11 @@ function FieldEditor(props) {
|
|
|
7156
7344
|
)
|
|
7157
7345
|
}
|
|
7158
7346
|
) : null,
|
|
7159
|
-
rehomeRefused ? /* @__PURE__ */ (0,
|
|
7160
|
-
rehomed ? /* @__PURE__ */ (0,
|
|
7161
|
-
/* @__PURE__ */ (0,
|
|
7162
|
-
rehomed.undo ? /* @__PURE__ */ (0,
|
|
7163
|
-
|
|
7347
|
+
rehomeRefused ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: rehomeRefused }) : null,
|
|
7348
|
+
rehomed ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-records-choice-rehomed": "", className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
7349
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: rehomed.said }),
|
|
7350
|
+
rehomed.undo ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7351
|
+
import_design_system30.Button,
|
|
7164
7352
|
{
|
|
7165
7353
|
type: "button",
|
|
7166
7354
|
size: "sm",
|
|
@@ -7174,7 +7362,7 @@ function FieldEditor(props) {
|
|
|
7174
7362
|
setRehomeRefused(back.error);
|
|
7175
7363
|
return;
|
|
7176
7364
|
}
|
|
7177
|
-
(0,
|
|
7365
|
+
(0, import_react47.tableShapeChanged)(tableId);
|
|
7178
7366
|
for (const c of undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
7179
7367
|
setChoiceList(null);
|
|
7180
7368
|
setChoiceListStart(null);
|
|
@@ -7184,19 +7372,19 @@ function FieldEditor(props) {
|
|
|
7184
7372
|
children: "Undo"
|
|
7185
7373
|
}
|
|
7186
7374
|
) : null,
|
|
7187
|
-
/* @__PURE__ */ (0,
|
|
7375
|
+
/* @__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
7376
|
] }) : null,
|
|
7189
|
-
reverseRefused ? /* @__PURE__ */ (0,
|
|
7190
|
-
/* @__PURE__ */ (0,
|
|
7191
|
-
/* @__PURE__ */ (0,
|
|
7377
|
+
reverseRefused ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-records-reverse-field-refused": "", className: "flex flex-col gap-1", children: [
|
|
7378
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px]", children: "The link is made. Its column on the other table was not:" }),
|
|
7379
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: reverseRefused })
|
|
7192
7380
|
] }) : null,
|
|
7193
|
-
backfillError ? /* @__PURE__ */ (0,
|
|
7194
|
-
/* @__PURE__ */ (0,
|
|
7195
|
-
/* @__PURE__ */ (0,
|
|
7381
|
+
backfillError ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-records-autonumber-backfill-refused": "", className: "flex flex-col gap-1", children: [
|
|
7382
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px]", children: "The column is made. The records already in the table were not numbered:" }),
|
|
7383
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RefusalNotice, { error: backfillError })
|
|
7196
7384
|
] }) : null,
|
|
7197
|
-
/* @__PURE__ */ (0,
|
|
7198
|
-
/* @__PURE__ */ (0,
|
|
7199
|
-
|
|
7385
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex min-w-0 flex-nowrap items-center gap-2", "data-field-editor-footer": "", children: [
|
|
7386
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7387
|
+
import_design_system30.Button,
|
|
7200
7388
|
{
|
|
7201
7389
|
size: "sm",
|
|
7202
7390
|
disabled: mutation.saving || Boolean(formulaMissing) || Boolean(nameLine) && label.trim() !== (field?.label ?? "").trim(),
|
|
@@ -7211,8 +7399,8 @@ function FieldEditor(props) {
|
|
|
7211
7399
|
children: mutation.saving ? "Saving\u2026" : field ? EDIT_FIELD_SAVE_LABEL : onEntity ? ADD_STANDARD_FIELD_SAVE_LABEL : ADD_FIELD_SAVE_LABEL
|
|
7212
7400
|
}
|
|
7213
7401
|
),
|
|
7214
|
-
onCancel ? /* @__PURE__ */ (0,
|
|
7215
|
-
/* @__PURE__ */ (0,
|
|
7402
|
+
onCancel ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Button, { size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }) : null,
|
|
7403
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7216
7404
|
"span",
|
|
7217
7405
|
{
|
|
7218
7406
|
id: "field-editor-missing",
|
|
@@ -7228,12 +7416,12 @@ function FieldEditor(props) {
|
|
|
7228
7416
|
footer is always as wide and as tall as its larger state: opening the confirm moved
|
|
7229
7417
|
the dialog card 0.2278 and closing it 0.1303. The consequence is the tooltip of
|
|
7230
7418
|
"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
|
-
|
|
7419
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "ml-auto grid shrink-0 items-center", "data-field-editor-remove": askingToRemove ? "asking" : "idle", children: [
|
|
7420
|
+
/* @__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" }) }),
|
|
7421
|
+
/* @__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: [
|
|
7422
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "whitespace-nowrap text-destructive", "data-field-editor-remove-ask": "", children: "Archive this field?" }),
|
|
7423
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7424
|
+
import_design_system30.Button,
|
|
7237
7425
|
{
|
|
7238
7426
|
size: "sm",
|
|
7239
7427
|
variant: "destructive",
|
|
@@ -7245,7 +7433,7 @@ function FieldEditor(props) {
|
|
|
7245
7433
|
children: "Remove it"
|
|
7246
7434
|
}
|
|
7247
7435
|
),
|
|
7248
|
-
/* @__PURE__ */ (0,
|
|
7436
|
+
/* @__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
7437
|
] })
|
|
7250
7438
|
] })
|
|
7251
7439
|
) : null
|
|
@@ -7336,10 +7524,10 @@ function formulaSeparatorOf(field) {
|
|
|
7336
7524
|
function TypeQuestions(props) {
|
|
7337
7525
|
const { type } = props;
|
|
7338
7526
|
if (type === "entity_reference") {
|
|
7339
|
-
return /* @__PURE__ */ (0,
|
|
7527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EntityReferenceKindPicker, { value: props.allowedTypes, onChange: props.setAllowedTypes, locked: props.editing });
|
|
7340
7528
|
}
|
|
7341
7529
|
if (type === "relation") {
|
|
7342
|
-
return /* @__PURE__ */ (0,
|
|
7530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7343
7531
|
ReferenceBuilder,
|
|
7344
7532
|
{
|
|
7345
7533
|
tableId: props.tableId,
|
|
@@ -7352,21 +7540,21 @@ function TypeQuestions(props) {
|
|
|
7352
7540
|
}
|
|
7353
7541
|
);
|
|
7354
7542
|
}
|
|
7355
|
-
if (type === "rating" || type === "barcode") return /* @__PURE__ */ (0,
|
|
7543
|
+
if (type === "rating" || type === "barcode") return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: props.newer });
|
|
7356
7544
|
if (type === "status") {
|
|
7357
|
-
return /* @__PURE__ */ (0,
|
|
7545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
7358
7546
|
props.choiceList,
|
|
7359
7547
|
props.newer
|
|
7360
7548
|
] });
|
|
7361
7549
|
}
|
|
7362
7550
|
if (type === "select" || type === "multi_select") {
|
|
7363
|
-
return /* @__PURE__ */ (0,
|
|
7551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: props.choiceList });
|
|
7364
7552
|
}
|
|
7365
7553
|
if (type === "currency") {
|
|
7366
|
-
return /* @__PURE__ */ (0,
|
|
7367
|
-
/* @__PURE__ */ (0,
|
|
7368
|
-
/* @__PURE__ */ (0,
|
|
7369
|
-
|
|
7554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7555
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "The currency" }),
|
|
7556
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7557
|
+
import_design_system30.BasicInput,
|
|
7370
7558
|
{
|
|
7371
7559
|
value: props.unit,
|
|
7372
7560
|
"aria-label": "The currency",
|
|
@@ -7377,9 +7565,9 @@ function TypeQuestions(props) {
|
|
|
7377
7565
|
] });
|
|
7378
7566
|
}
|
|
7379
7567
|
if (type === "datetime") {
|
|
7380
|
-
return /* @__PURE__ */ (0,
|
|
7381
|
-
/* @__PURE__ */ (0,
|
|
7382
|
-
|
|
7568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7569
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7570
|
+
import_design_system30.Checkbox,
|
|
7383
7571
|
{
|
|
7384
7572
|
checked: props.withTime,
|
|
7385
7573
|
"aria-label": "Include a time of day",
|
|
@@ -7392,14 +7580,14 @@ function TypeQuestions(props) {
|
|
|
7392
7580
|
if (type === "lookup" || type === "rollup" || type === "count") {
|
|
7393
7581
|
const usable = props.relations;
|
|
7394
7582
|
if (usable.length === 0) {
|
|
7395
|
-
return /* @__PURE__ */ (0,
|
|
7583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No link, Person or File column yet." });
|
|
7396
7584
|
}
|
|
7397
|
-
return /* @__PURE__ */ (0,
|
|
7398
|
-
/* @__PURE__ */ (0,
|
|
7399
|
-
/* @__PURE__ */ (0,
|
|
7400
|
-
/* @__PURE__ */ (0,
|
|
7401
|
-
/* @__PURE__ */ (0,
|
|
7402
|
-
/* @__PURE__ */ (0,
|
|
7585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7586
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7587
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: type !== "lookup" ? "Across the records in" : "Read it from" }),
|
|
7588
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: props.via, onValueChange: props.setVia, children: [
|
|
7589
|
+
/* @__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" }) }),
|
|
7590
|
+
/* @__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
7591
|
fieldName(f),
|
|
7404
7592
|
isBackLinkSource(f) ? BACK_LINK_SOURCE_SUFFIX : "",
|
|
7405
7593
|
sourceKindOf(f) === "person" ? " \u2014 a person" : sourceKindOf(f) === "file" ? " \u2014 a file" : "",
|
|
@@ -7407,7 +7595,7 @@ function TypeQuestions(props) {
|
|
|
7407
7595
|
] }, f.id)) })
|
|
7408
7596
|
] })
|
|
7409
7597
|
] }),
|
|
7410
|
-
type === "lookup" ? /* @__PURE__ */ (0,
|
|
7598
|
+
type === "lookup" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7411
7599
|
ValueOnTheOtherSide,
|
|
7412
7600
|
{
|
|
7413
7601
|
label: "The value to read",
|
|
@@ -7416,13 +7604,13 @@ function TypeQuestions(props) {
|
|
|
7416
7604
|
value: props.pick,
|
|
7417
7605
|
onChange: props.setPick
|
|
7418
7606
|
}
|
|
7419
|
-
) : type === "count" ? null : /* @__PURE__ */ (0,
|
|
7420
|
-
/* @__PURE__ */ (0,
|
|
7421
|
-
/* @__PURE__ */ (0,
|
|
7422
|
-
/* @__PURE__ */ (0,
|
|
7423
|
-
/* @__PURE__ */ (0,
|
|
7607
|
+
) : type === "count" ? null : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7608
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "What to work out" }),
|
|
7609
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: props.agg, onValueChange: (v) => props.setAgg(v), children: [
|
|
7610
|
+
/* @__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, {}) }),
|
|
7611
|
+
/* @__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
7612
|
] }),
|
|
7425
|
-
props.agg !== "count" ? /* @__PURE__ */ (0,
|
|
7613
|
+
props.agg !== "count" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7426
7614
|
ValueOnTheOtherSide,
|
|
7427
7615
|
{
|
|
7428
7616
|
label: "Of which value",
|
|
@@ -7438,22 +7626,22 @@ function TypeQuestions(props) {
|
|
|
7438
7626
|
}
|
|
7439
7627
|
if (type === "formula") {
|
|
7440
7628
|
if (props.others.length === 0) {
|
|
7441
|
-
return /* @__PURE__ */ (0,
|
|
7629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No other columns yet." });
|
|
7442
7630
|
}
|
|
7443
|
-
return /* @__PURE__ */ (0,
|
|
7444
|
-
/* @__PURE__ */ (0,
|
|
7445
|
-
/* @__PURE__ */ (0,
|
|
7446
|
-
/* @__PURE__ */ (0,
|
|
7447
|
-
/* @__PURE__ */ (0,
|
|
7448
|
-
/* @__PURE__ */ (0,
|
|
7631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
7632
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7633
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "What to do" }),
|
|
7634
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.Select, { value: props.formulaOp, onValueChange: props.setFormulaOp, children: [
|
|
7635
|
+
/* @__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, {}) }),
|
|
7636
|
+
/* @__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
7637
|
] })
|
|
7450
7638
|
] }),
|
|
7451
|
-
/* @__PURE__ */ (0,
|
|
7452
|
-
/* @__PURE__ */ (0,
|
|
7453
|
-
/* @__PURE__ */ (0,
|
|
7639
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7640
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: "Which columns" }),
|
|
7641
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "flex flex-wrap gap-1", children: props.others.map((f) => {
|
|
7454
7642
|
const picked = props.formulaFields.includes(f.id);
|
|
7455
|
-
return /* @__PURE__ */ (0,
|
|
7456
|
-
|
|
7643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7644
|
+
import_design_system30.Button,
|
|
7457
7645
|
{
|
|
7458
7646
|
type: "button",
|
|
7459
7647
|
size: "sm",
|
|
@@ -7467,10 +7655,10 @@ function TypeQuestions(props) {
|
|
|
7467
7655
|
);
|
|
7468
7656
|
}) })
|
|
7469
7657
|
] }),
|
|
7470
|
-
props.formulaOp === "concat" ? /* @__PURE__ */ (0,
|
|
7471
|
-
/* @__PURE__ */ (0,
|
|
7472
|
-
/* @__PURE__ */ (0,
|
|
7473
|
-
|
|
7658
|
+
props.formulaOp === "concat" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7659
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", children: FORMULA_SEPARATOR_LABEL }),
|
|
7660
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7661
|
+
import_design_system30.BasicInput,
|
|
7474
7662
|
{
|
|
7475
7663
|
value: props.formulaSeparator,
|
|
7476
7664
|
"aria-label": FORMULA_SEPARATOR_LABEL,
|
|
@@ -7519,26 +7707,26 @@ function RollupFilterQuestion({
|
|
|
7519
7707
|
onChange
|
|
7520
7708
|
}) {
|
|
7521
7709
|
const far = relation?.relation_target ?? null;
|
|
7522
|
-
const farFields = (0,
|
|
7523
|
-
const conditionFields = (0,
|
|
7710
|
+
const farFields = (0, import_react47.useFields)(far);
|
|
7711
|
+
const conditionFields = (0, import_react46.useMemo)(
|
|
7524
7712
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7525
7713
|
[farFields.data]
|
|
7526
7714
|
);
|
|
7527
|
-
const lastFar = (0,
|
|
7528
|
-
(0,
|
|
7715
|
+
const lastFar = (0, import_react46.useRef)(far);
|
|
7716
|
+
(0, import_react46.useEffect)(() => {
|
|
7529
7717
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7530
7718
|
lastFar.current = far;
|
|
7531
7719
|
}, [far, editing, onChange]);
|
|
7532
7720
|
if (!relation || !far) return null;
|
|
7533
|
-
return /* @__PURE__ */ (0,
|
|
7534
|
-
/* @__PURE__ */ (0,
|
|
7721
|
+
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: [
|
|
7722
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
7535
7723
|
rollupFilterLead(agg),
|
|
7536
7724
|
" ",
|
|
7537
7725
|
conditionInWords(value, conditionFields),
|
|
7538
7726
|
"."
|
|
7539
7727
|
] }),
|
|
7540
|
-
/* @__PURE__ */ (0,
|
|
7541
|
-
] }) : /* @__PURE__ */ (0,
|
|
7728
|
+
/* @__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" })
|
|
7729
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7542
7730
|
ConditionGroup,
|
|
7543
7731
|
{
|
|
7544
7732
|
lead: rollupFilterLead(agg),
|
|
@@ -7558,19 +7746,19 @@ function ValueOnTheOtherSide({
|
|
|
7558
7746
|
compact
|
|
7559
7747
|
}) {
|
|
7560
7748
|
const target = relation?.relation_target ?? null;
|
|
7561
|
-
const columns = (0,
|
|
7749
|
+
const columns = (0, import_react47.useFields)(target);
|
|
7562
7750
|
const declared = (columns.data ?? []).filter((f) => f.type !== "formula");
|
|
7563
|
-
const sample = (0,
|
|
7751
|
+
const sample = (0, import_react47.useRecords)(declared.length === 0 && !columns.loading ? target : null, { pageSize: 1 });
|
|
7564
7752
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7565
7753
|
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
7754
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
7567
|
-
const body = !relation ? /* @__PURE__ */ (0,
|
|
7568
|
-
/* @__PURE__ */ (0,
|
|
7569
|
-
/* @__PURE__ */ (0,
|
|
7755
|
+
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: [
|
|
7756
|
+
/* @__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" }) }),
|
|
7757
|
+
/* @__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
7758
|
] });
|
|
7571
|
-
if (compact) return /* @__PURE__ */ (0,
|
|
7572
|
-
return /* @__PURE__ */ (0,
|
|
7573
|
-
/* @__PURE__ */ (0,
|
|
7759
|
+
if (compact) return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "mt-1 flex flex-col gap-1", children: body });
|
|
7760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7761
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { className: "text-xs", title: help, children: label }),
|
|
7574
7762
|
body
|
|
7575
7763
|
] });
|
|
7576
7764
|
}
|
|
@@ -7596,19 +7784,19 @@ function NewColumnDefault({
|
|
|
7596
7784
|
onChange
|
|
7597
7785
|
}) {
|
|
7598
7786
|
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,
|
|
7787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", "data-records-field-default": "", "data-records-new-field-default": "", children: [
|
|
7788
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.Label, { htmlFor: "records-new-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7789
|
+
type === "checkbox" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
7790
|
+
/* @__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) }),
|
|
7791
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: "Ticked" })
|
|
7792
|
+
] }) : 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: [
|
|
7793
|
+
/* @__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, {}) }),
|
|
7794
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_design_system30.SelectContent, { children: [
|
|
7795
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: none, children: "Nothing" }),
|
|
7796
|
+
choices.map((c) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_design_system30.SelectItem, { value: c, children: c }, c))
|
|
7609
7797
|
] })
|
|
7610
|
-
] }) : /* @__PURE__ */ (0,
|
|
7611
|
-
|
|
7798
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7799
|
+
import_design_system30.BasicInput,
|
|
7612
7800
|
{
|
|
7613
7801
|
id: "records-new-field-default",
|
|
7614
7802
|
value: typeof value === "string" ? value : value === null || value === void 0 ? "" : String(value),
|
|
@@ -7622,7 +7810,7 @@ function NewColumnDefault({
|
|
|
7622
7810
|
// src/buttonCell.tsx
|
|
7623
7811
|
var import_outbound_react6 = require("@ai-matrx/kit/outbound-react");
|
|
7624
7812
|
var import_outbound = require("@ai-matrx/kit/outbound");
|
|
7625
|
-
var
|
|
7813
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7626
7814
|
function buttonPressWords(label, pressed) {
|
|
7627
7815
|
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
7628
7816
|
if (pressed.do === "run_action") {
|
|
@@ -7634,14 +7822,14 @@ function buttonPressWords(label, pressed) {
|
|
|
7634
7822
|
}
|
|
7635
7823
|
var stop = (event) => event.stopPropagation();
|
|
7636
7824
|
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,
|
|
7825
|
+
const client = (0, import_react49.useOptionalRecordsClient)();
|
|
7826
|
+
const b = (0, import_records27.buttonOf)(field);
|
|
7827
|
+
const [busy, setBusy] = (0, import_react48.useState)(false);
|
|
7828
|
+
const [said2, setSaid] = (0, import_react48.useState)(null);
|
|
7829
|
+
const [settingUp, setSettingUp] = (0, import_react48.useState)(false);
|
|
7642
7830
|
if (!b) return null;
|
|
7643
7831
|
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,
|
|
7832
|
+
const needs = (0, import_records27.buttonNeeds)(b);
|
|
7645
7833
|
const tableId = field.entity_definition_id;
|
|
7646
7834
|
const press = async () => {
|
|
7647
7835
|
if (!client || !recordId) return setSaid({ kind: "public" });
|
|
@@ -7657,10 +7845,10 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7657
7845
|
}
|
|
7658
7846
|
setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
|
|
7659
7847
|
};
|
|
7660
|
-
return /* @__PURE__ */ (0,
|
|
7661
|
-
/* @__PURE__ */ (0,
|
|
7662
|
-
/* @__PURE__ */ (0,
|
|
7663
|
-
|
|
7848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
7849
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_design_system31.Popover, { open: said2 !== null, onOpenChange: (open) => open ? null : setSaid(null), children: [
|
|
7850
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7851
|
+
import_design_system31.Button,
|
|
7664
7852
|
{
|
|
7665
7853
|
type: "button",
|
|
7666
7854
|
size: "xs",
|
|
@@ -7669,7 +7857,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7669
7857
|
"data-records-button-unset": needs ? "" : void 0,
|
|
7670
7858
|
"aria-busy": busy || void 0,
|
|
7671
7859
|
disabled: busy,
|
|
7672
|
-
className: (0,
|
|
7860
|
+
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
7861
|
onPointerDown: stop,
|
|
7674
7862
|
onDoubleClick: stop,
|
|
7675
7863
|
onClick: (event) => {
|
|
@@ -7677,21 +7865,21 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7677
7865
|
event.preventDefault();
|
|
7678
7866
|
void press();
|
|
7679
7867
|
},
|
|
7680
|
-
children: /* @__PURE__ */ (0,
|
|
7868
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "truncate", children: b.label })
|
|
7681
7869
|
}
|
|
7682
7870
|
) }),
|
|
7683
|
-
/* @__PURE__ */ (0,
|
|
7684
|
-
said2?.kind === "refused" ? /* @__PURE__ */ (0,
|
|
7685
|
-
said2?.kind === "public" ? /* @__PURE__ */ (0,
|
|
7686
|
-
said2?.kind === "ran" ? /* @__PURE__ */ (0,
|
|
7871
|
+
/* @__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: [
|
|
7872
|
+
said2?.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(RefusalLine, { error: said2.error }) : null,
|
|
7873
|
+
said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
|
|
7874
|
+
said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("p", { className: "break-words", children: [
|
|
7687
7875
|
said2.says,
|
|
7688
7876
|
" ",
|
|
7689
|
-
said2.link ? /* @__PURE__ */ (0,
|
|
7877
|
+
said2.link ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_outbound_react6.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
7690
7878
|
] }) : null,
|
|
7691
|
-
said2?.kind === "needs" ? /* @__PURE__ */ (0,
|
|
7692
|
-
/* @__PURE__ */ (0,
|
|
7693
|
-
tableId ? /* @__PURE__ */ (0,
|
|
7694
|
-
|
|
7879
|
+
said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
7880
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { children: said2.says }),
|
|
7881
|
+
tableId ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
7882
|
+
import_design_system31.Button,
|
|
7695
7883
|
{
|
|
7696
7884
|
type: "button",
|
|
7697
7885
|
size: "sm",
|
|
@@ -7709,202 +7897,16 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7709
7897
|
] }) : null
|
|
7710
7898
|
] })
|
|
7711
7899
|
] }),
|
|
7712
|
-
settingUp && tableId ? /* @__PURE__ */ (0,
|
|
7713
|
-
/* @__PURE__ */ (0,
|
|
7714
|
-
/* @__PURE__ */ (0,
|
|
7715
|
-
/* @__PURE__ */ (0,
|
|
7900
|
+
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: [
|
|
7901
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_design_system31.DialogHeader, { children: [
|
|
7902
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.DialogTitle, { children: `Column settings \xB7 ${fieldName(field)}` }),
|
|
7903
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_design_system31.DialogDescription, { className: "sr-only", children: "What the button does" })
|
|
7716
7904
|
] }),
|
|
7717
|
-
/* @__PURE__ */ (0,
|
|
7905
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(FieldEditor, { tableId, field, onSaved: () => setSettingUp(false), onCancel: () => setSettingUp(false) })
|
|
7718
7906
|
] }) }) : null
|
|
7719
7907
|
] });
|
|
7720
7908
|
}
|
|
7721
7909
|
|
|
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
7910
|
// src/FloatingRefusal.tsx
|
|
7909
7911
|
var import_react50 = require("react");
|
|
7910
7912
|
var import_react_dom = require("react-dom");
|