@ai-matrx/records-ui 0.115.82 → 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 +21 -1
- package/dist/helpers.d.cts +13 -0
- package/dist/helpers.d.ts +13 -0
- package/dist/index.cjs +2703 -2584
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1806 -1687
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +806 -766
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +702 -662
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
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");
|
|
@@ -4002,23 +4002,24 @@ function useFileRead(id) {
|
|
|
4002
4002
|
(0, import_react31.useEffect)(() => {
|
|
4003
4003
|
let cancelled = false;
|
|
4004
4004
|
if (handedHostFileIds.has(id)) {
|
|
4005
|
-
setRead({ name: null, fileId: id, why: null });
|
|
4005
|
+
setRead({ name: null, fileId: id, why: null, mime: null });
|
|
4006
4006
|
return;
|
|
4007
4007
|
}
|
|
4008
4008
|
if (!client) {
|
|
4009
|
-
setRead({ name: null, fileId: null, why: null });
|
|
4009
|
+
setRead({ name: null, fileId: null, why: null, mime: null });
|
|
4010
4010
|
return;
|
|
4011
4011
|
}
|
|
4012
4012
|
void client.recordRead({ record_id: id }).then((answered) => {
|
|
4013
4013
|
if (cancelled) return;
|
|
4014
4014
|
if (!answered.ok) {
|
|
4015
|
-
setRead({ name: null, fileId: id, why: refusalSentence(answered.error) });
|
|
4015
|
+
setRead({ name: null, fileId: id, why: refusalSentence(answered.error), mime: null });
|
|
4016
4016
|
return;
|
|
4017
4017
|
}
|
|
4018
4018
|
const doc = answered.data.document ?? {};
|
|
4019
4019
|
const fileId = typeof doc["file_id"] === "string" ? doc["file_id"] : null;
|
|
4020
4020
|
const name = typeof doc["name"] === "string" && doc["name"] !== "" ? doc["name"] : null;
|
|
4021
|
-
|
|
4021
|
+
const mime = typeof doc["mime"] === "string" ? doc["mime"] : null;
|
|
4022
|
+
setRead({ name, fileId, why: null, mime });
|
|
4022
4023
|
});
|
|
4023
4024
|
return () => {
|
|
4024
4025
|
cancelled = true;
|
|
@@ -4032,6 +4033,43 @@ function AttachmentChip({ id, onRemove, onPreview }) {
|
|
|
4032
4033
|
const words = read?.name ?? (read ? FILE_CHIP_UNREAD : "\u2026");
|
|
4033
4034
|
const href = read?.fileId ? host.hrefForFile?.({ fileId: read.fileId }) : void 0;
|
|
4034
4035
|
const title = onPreview ? `Preview ${words}` : href ? `Open ${words}` : read?.why ?? FILE_CHIP_NO_PAGE;
|
|
4036
|
+
if (read?.fileId && read.mime?.startsWith("image/") && host.fileImage) {
|
|
4037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "relative inline-flex shrink-0", "data-records-file-thumb": id, children: [
|
|
4038
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
4039
|
+
"button",
|
|
4040
|
+
{
|
|
4041
|
+
type: "button",
|
|
4042
|
+
title,
|
|
4043
|
+
"aria-label": onPreview ? `Preview ${words}` : words,
|
|
4044
|
+
className: (0, import_design_system19.cn)(
|
|
4045
|
+
"relative block size-20 overflow-hidden rounded-md border bg-muted",
|
|
4046
|
+
"[[data-matrx-cell-lines]_&]:size-6 [[data-matrx-cell-lines=two]_&]:size-10 [[data-matrx-cell-lines=four]_&]:size-[4.5rem] [[data-matrx-cell-lines=six]_&]:size-24"
|
|
4047
|
+
),
|
|
4048
|
+
onClick: (event) => {
|
|
4049
|
+
event.stopPropagation();
|
|
4050
|
+
onPreview?.();
|
|
4051
|
+
},
|
|
4052
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
4053
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
4054
|
+
...onPreview ? { "data-records-file-preview": id } : {},
|
|
4055
|
+
children: host.fileImage({ fileId: read.fileId, alt: words })
|
|
4056
|
+
}
|
|
4057
|
+
),
|
|
4058
|
+
onRemove ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
4059
|
+
"button",
|
|
4060
|
+
{
|
|
4061
|
+
type: "button",
|
|
4062
|
+
"aria-label": `Remove ${words}`,
|
|
4063
|
+
className: "absolute -right-1 -top-1 rounded-full border bg-background px-1 text-[10px] leading-4 text-muted-foreground hover:text-foreground",
|
|
4064
|
+
onClick: (event) => {
|
|
4065
|
+
event.stopPropagation();
|
|
4066
|
+
onRemove();
|
|
4067
|
+
},
|
|
4068
|
+
children: "\xD7"
|
|
4069
|
+
}
|
|
4070
|
+
) : null
|
|
4071
|
+
] });
|
|
4072
|
+
}
|
|
4035
4073
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
4036
4074
|
import_design_system19.Badge,
|
|
4037
4075
|
{
|
|
@@ -4463,12 +4501,200 @@ function formulaSourceArchived(field, document2) {
|
|
|
4463
4501
|
}
|
|
4464
4502
|
|
|
4465
4503
|
// src/values.tsx
|
|
4504
|
+
var import_records18 = require("@ai-matrx/records");
|
|
4505
|
+
|
|
4506
|
+
// src/PersonPicker.tsx
|
|
4507
|
+
var import_react33 = require("react");
|
|
4466
4508
|
var import_records17 = require("@ai-matrx/records");
|
|
4467
|
-
var
|
|
4509
|
+
var import_react34 = require("@ai-matrx/records/react");
|
|
4510
|
+
var import_design_system21 = require("@ai-matrx/design-system");
|
|
4468
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");
|
|
4469
4695
|
function statusMark(field, item, document2) {
|
|
4470
4696
|
const mark = statusMarkOf(field, item, document2);
|
|
4471
|
-
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;
|
|
4472
4698
|
}
|
|
4473
4699
|
function envelopeFor(document2, key) {
|
|
4474
4700
|
const block = document2?._values;
|
|
@@ -4514,48 +4740,48 @@ function sourceArchivedSentence(state2) {
|
|
|
4514
4740
|
return state2.table ? `${state2.label} on ${state2.table} is archived` : `${state2.label} is archived`;
|
|
4515
4741
|
}
|
|
4516
4742
|
function SourceArchivedValue({ state: state2 }) {
|
|
4517
|
-
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 });
|
|
4518
4744
|
}
|
|
4519
4745
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4520
4746
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4521
|
-
const archivedSource = (0,
|
|
4522
|
-
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 });
|
|
4523
4749
|
const envelope = envelopeFor(document2, field.key);
|
|
4524
4750
|
if (envelope?.absent) {
|
|
4525
|
-
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) });
|
|
4526
4752
|
}
|
|
4527
4753
|
if (value === null || value === void 0 || value === "") {
|
|
4528
4754
|
const gone = unresolvedFor(document2, field.key);
|
|
4529
4755
|
if (gone) {
|
|
4530
|
-
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" });
|
|
4531
4757
|
}
|
|
4532
4758
|
const archivedInput = formulaSourceArchived(field, document2);
|
|
4533
|
-
if (archivedInput) return /* @__PURE__ */ (0,
|
|
4759
|
+
if (archivedInput) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SourceArchivedValue, { state: archivedInput });
|
|
4534
4760
|
const computed = computedEmptyOf(field, document2);
|
|
4535
|
-
if (computed?.sentence) return /* @__PURE__ */ (0,
|
|
4536
|
-
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 });
|
|
4537
4763
|
if (computed?.why) {
|
|
4538
|
-
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" });
|
|
4539
4765
|
}
|
|
4540
4766
|
if (look?.blankEmpty) return null;
|
|
4541
|
-
return /* @__PURE__ */ (0,
|
|
4767
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4542
4768
|
}
|
|
4543
|
-
if (isSignatureField(field)) return /* @__PURE__ */ (0,
|
|
4544
|
-
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 });
|
|
4545
4771
|
const newer = newerKindValue(field, value);
|
|
4546
4772
|
if (newer !== void 0) return newer;
|
|
4547
4773
|
const whole = typeof value === "string" ? (0, import_core5.wholeValueOf)(document2, field.key) : null;
|
|
4548
|
-
if (whole) return /* @__PURE__ */ (0,
|
|
4774
|
+
if (whole) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WholeValueCell, { words: value, pointer: whole });
|
|
4549
4775
|
const kind = editorKindFor(field);
|
|
4550
4776
|
if (kind === "relation" || kind === "entity_reference") {
|
|
4551
|
-
return /* @__PURE__ */ (0,
|
|
4777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
|
|
4552
4778
|
}
|
|
4553
4779
|
if (kind === "member") {
|
|
4554
4780
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4555
|
-
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}`)) });
|
|
4556
4782
|
}
|
|
4557
4783
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4558
|
-
if (kv) return /* @__PURE__ */ (0,
|
|
4784
|
+
if (kv) return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(KindValueCell, { kv, where: "cell", title: field.label });
|
|
4559
4785
|
const chosen = kind === "select" || kind === "multi_select";
|
|
4560
4786
|
const chipOf = (item) => {
|
|
4561
4787
|
const chipLook = choiceChipLookOf(field, item, scalarText(field, item, labels));
|
|
@@ -4563,17 +4789,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4563
4789
|
};
|
|
4564
4790
|
if (chosen) {
|
|
4565
4791
|
const items = Array.isArray(value) ? value : [value];
|
|
4566
|
-
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) => {
|
|
4567
4793
|
const chip = chipOf(item);
|
|
4568
|
-
return /* @__PURE__ */ (0,
|
|
4569
|
-
|
|
4794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4795
|
+
import_design_system22.Badge,
|
|
4570
4796
|
{
|
|
4571
4797
|
variant: "outline",
|
|
4572
|
-
className: (0,
|
|
4798
|
+
className: (0, import_design_system22.cn)("text-[11px]", chip.className),
|
|
4573
4799
|
"data-records-choice-chip": "",
|
|
4574
4800
|
...chip.tinted ? { "data-records-choice-tint": "" } : {},
|
|
4575
4801
|
children: [
|
|
4576
|
-
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,
|
|
4577
4803
|
statusMark(field, item, Array.isArray(value) ? void 0 : document2),
|
|
4578
4804
|
scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
|
|
4579
4805
|
]
|
|
@@ -4582,13 +4808,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4582
4808
|
);
|
|
4583
4809
|
}) });
|
|
4584
4810
|
}
|
|
4585
|
-
if (kind === "attachment") return /* @__PURE__ */ (0,
|
|
4811
|
+
if (kind === "attachment") return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AttachmentChips, { value });
|
|
4586
4812
|
if (Array.isArray(value)) {
|
|
4587
|
-
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}`)) });
|
|
4588
4814
|
}
|
|
4589
4815
|
if (kind === "url" && typeof value === "string") {
|
|
4590
4816
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
4591
|
-
return /* @__PURE__ */ (0,
|
|
4817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4592
4818
|
import_outbound_react5.OutboundLink,
|
|
4593
4819
|
{
|
|
4594
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",
|
|
@@ -4597,14 +4823,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4597
4823
|
"data-records-link-chip": "",
|
|
4598
4824
|
onClick: (event) => event.stopPropagation(),
|
|
4599
4825
|
children: [
|
|
4600
|
-
/* @__PURE__ */ (0,
|
|
4601
|
-
/* @__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) })
|
|
4602
4828
|
]
|
|
4603
4829
|
}
|
|
4604
4830
|
);
|
|
4605
4831
|
}
|
|
4606
4832
|
if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
|
|
4607
|
-
return /* @__PURE__ */ (0,
|
|
4833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4608
4834
|
"a",
|
|
4609
4835
|
{
|
|
4610
4836
|
className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
|
|
@@ -4617,19 +4843,19 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4617
4843
|
);
|
|
4618
4844
|
}
|
|
4619
4845
|
if (kind === "email" && typeof value === "string") {
|
|
4620
|
-
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 });
|
|
4621
4847
|
}
|
|
4622
4848
|
if (typeof value === "boolean") {
|
|
4623
|
-
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" });
|
|
4624
4850
|
}
|
|
4625
|
-
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) });
|
|
4626
4852
|
}
|
|
4627
4853
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4628
4854
|
if (value === null || value === void 0) return "\u2014";
|
|
4629
|
-
if ((0,
|
|
4855
|
+
if ((0, import_records18.sourceArchivedOf)(value)) return SOURCE_ARCHIVED_WORDS;
|
|
4630
4856
|
if (isSignatureField(field)) return signatureWords(value) ?? "\u2014";
|
|
4631
|
-
if ((0,
|
|
4632
|
-
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);
|
|
4633
4859
|
if (newerWords !== null) return newerWords;
|
|
4634
4860
|
const kind = editorKindFor(field);
|
|
4635
4861
|
if (kind === "entity_reference") return entityReferenceText(value);
|
|
@@ -4665,24 +4891,24 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4665
4891
|
}
|
|
4666
4892
|
|
|
4667
4893
|
// src/SourceArchivedNotice.tsx
|
|
4668
|
-
var
|
|
4894
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4669
4895
|
function bringBackLabel(state2) {
|
|
4670
4896
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4671
4897
|
}
|
|
4672
4898
|
function SourceArchivedNotice({ fieldId, tableId }) {
|
|
4673
|
-
const client = (0,
|
|
4674
|
-
const [state2, setState] = (0,
|
|
4675
|
-
const [busy, setBusy] = (0,
|
|
4676
|
-
const [refused, setRefused] = (0,
|
|
4677
|
-
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 () => {
|
|
4678
4904
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4679
4905
|
if (answer.ok) setState(answer.data);
|
|
4680
4906
|
else setRefused(answer.error);
|
|
4681
4907
|
}, [client, fieldId]);
|
|
4682
|
-
(0,
|
|
4908
|
+
(0, import_react35.useEffect)(() => {
|
|
4683
4909
|
void read();
|
|
4684
4910
|
}, [read]);
|
|
4685
|
-
if (refused && !state2) return /* @__PURE__ */ (0,
|
|
4911
|
+
if (refused && !state2) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: refused });
|
|
4686
4912
|
if (!state2) return null;
|
|
4687
4913
|
const restore = async () => {
|
|
4688
4914
|
if (!state2.field_id) return;
|
|
@@ -4694,36 +4920,36 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4694
4920
|
setRefused(done.error);
|
|
4695
4921
|
return;
|
|
4696
4922
|
}
|
|
4697
|
-
if (state2.table_id) (0,
|
|
4698
|
-
(0,
|
|
4923
|
+
if (state2.table_id) (0, import_react36.tableShapeChanged)(state2.table_id);
|
|
4924
|
+
(0, import_react36.tableShapeChanged)(tableId);
|
|
4699
4925
|
await read();
|
|
4700
4926
|
};
|
|
4701
|
-
return /* @__PURE__ */ (0,
|
|
4927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4702
4928
|
"div",
|
|
4703
4929
|
{
|
|
4704
4930
|
className: "flex flex-wrap items-center gap-2 rounded-md border border-border px-3 py-2",
|
|
4705
4931
|
"data-testid": "source-archived-notice",
|
|
4706
4932
|
"data-field-id": state2.field_id ?? "",
|
|
4707
4933
|
children: [
|
|
4708
|
-
/* @__PURE__ */ (0,
|
|
4709
|
-
/* @__PURE__ */ (0,
|
|
4710
|
-
/* @__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) })
|
|
4711
4937
|
] }),
|
|
4712
|
-
state2.field_id ? /* @__PURE__ */ (0,
|
|
4713
|
-
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
|
|
4714
4940
|
]
|
|
4715
4941
|
}
|
|
4716
4942
|
);
|
|
4717
4943
|
}
|
|
4718
4944
|
|
|
4719
4945
|
// src/Condition.tsx
|
|
4720
|
-
var
|
|
4721
|
-
var
|
|
4722
|
-
var
|
|
4723
|
-
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");
|
|
4724
4950
|
|
|
4725
4951
|
// src/personTime.ts
|
|
4726
|
-
var
|
|
4952
|
+
var import_react37 = require("react");
|
|
4727
4953
|
|
|
4728
4954
|
// src/personZone.ts
|
|
4729
4955
|
var import_table_style3 = require("@ai-matrx/design-system/data-table/table-style");
|
|
@@ -4760,7 +4986,7 @@ function personWallNow(at = /* @__PURE__ */ new Date()) {
|
|
|
4760
4986
|
|
|
4761
4987
|
// src/personTime.ts
|
|
4762
4988
|
function usePersonTimeZone() {
|
|
4763
|
-
return (0,
|
|
4989
|
+
return (0, import_react37.useSyncExternalStore)(
|
|
4764
4990
|
subscribePersonTimeZone,
|
|
4765
4991
|
getPersonTimeZone,
|
|
4766
4992
|
() => null
|
|
@@ -4768,7 +4994,7 @@ function usePersonTimeZone() {
|
|
|
4768
4994
|
}
|
|
4769
4995
|
|
|
4770
4996
|
// src/Condition.tsx
|
|
4771
|
-
var
|
|
4997
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4772
4998
|
var CONDITION_OPS = [
|
|
4773
4999
|
{ op: "eq", label: "is" },
|
|
4774
5000
|
{ op: "ne", label: "is not" },
|
|
@@ -4805,7 +5031,7 @@ function linkedOf(expr) {
|
|
|
4805
5031
|
if (match !== "any" && match !== "none") return null;
|
|
4806
5032
|
return { via: rel["field"], inner: a["field"], op: match === "any" ? "eq" : "ne", value: b["const"] };
|
|
4807
5033
|
}
|
|
4808
|
-
var FilterTermsContext = (0,
|
|
5034
|
+
var FilterTermsContext = (0, import_react38.createContext)(false);
|
|
4809
5035
|
var RELATIVE_DAY_TERMS = [
|
|
4810
5036
|
{ kind: "today", label: "is today" },
|
|
4811
5037
|
{ kind: "tomorrow", label: "is tomorrow" },
|
|
@@ -4856,17 +5082,17 @@ function isChoiceColumn(f) {
|
|
|
4856
5082
|
return kind === "select" || kind === "multi_select";
|
|
4857
5083
|
}
|
|
4858
5084
|
function ChoiceValue({ field, value, onChange }) {
|
|
4859
|
-
const client = (0,
|
|
4860
|
-
const [choices, setChoices] = (0,
|
|
4861
|
-
const [open, setOpen] = (0,
|
|
4862
|
-
const [search, setSearch] = (0,
|
|
4863
|
-
(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)(() => {
|
|
4864
5090
|
if (!client) return;
|
|
4865
5091
|
let cancelled = false;
|
|
4866
5092
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
4867
5093
|
if (cancelled) return;
|
|
4868
5094
|
setChoices(
|
|
4869
|
-
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 !== "") : []
|
|
4870
5096
|
);
|
|
4871
5097
|
});
|
|
4872
5098
|
return () => {
|
|
@@ -4874,8 +5100,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4874
5100
|
};
|
|
4875
5101
|
}, [client, field.id]);
|
|
4876
5102
|
if (!choices || choices.length === 0) {
|
|
4877
|
-
return /* @__PURE__ */ (0,
|
|
4878
|
-
|
|
5103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5104
|
+
import_design_system24.BasicInput,
|
|
4879
5105
|
{
|
|
4880
5106
|
className: "h-8 w-28 text-xs",
|
|
4881
5107
|
"aria-label": "Condition value",
|
|
@@ -4884,8 +5110,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4884
5110
|
}
|
|
4885
5111
|
);
|
|
4886
5112
|
}
|
|
4887
|
-
const shown2 = (0,
|
|
4888
|
-
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)(
|
|
4889
5115
|
PickOrAdd,
|
|
4890
5116
|
{
|
|
4891
5117
|
triggerSize: "compact",
|
|
@@ -4911,7 +5137,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4911
5137
|
setOpen(false);
|
|
4912
5138
|
setSearch("");
|
|
4913
5139
|
},
|
|
4914
|
-
empty: /* @__PURE__ */ (0,
|
|
5140
|
+
empty: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
|
|
4915
5141
|
}
|
|
4916
5142
|
) });
|
|
4917
5143
|
}
|
|
@@ -5005,7 +5231,7 @@ function conditionValue(typed) {
|
|
|
5005
5231
|
}
|
|
5006
5232
|
function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
|
|
5007
5233
|
const node = expr ?? null;
|
|
5008
|
-
const filterTerms = (0,
|
|
5234
|
+
const filterTerms = (0, import_react38.useContext)(FilterTermsContext);
|
|
5009
5235
|
const relative = relativeDayOf(expr);
|
|
5010
5236
|
const reader = meOf(expr);
|
|
5011
5237
|
const linked = linkedOf(expr);
|
|
@@ -5051,9 +5277,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5051
5277
|
VALUELESS_OPS.has(chosenOp) ? { op: chosenOp, args: [{ field: chosenField }] } : { op: chosenOp, args: [{ field: chosenField }, { const: chosenValue }] }
|
|
5052
5278
|
);
|
|
5053
5279
|
}
|
|
5054
|
-
return /* @__PURE__ */ (0,
|
|
5055
|
-
/* @__PURE__ */ (0,
|
|
5056
|
-
/* @__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)(
|
|
5057
5283
|
PickOne,
|
|
5058
5284
|
{
|
|
5059
5285
|
label: "Condition field",
|
|
@@ -5064,7 +5290,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5064
5290
|
attrs: { "data-condition": "field" }
|
|
5065
5291
|
}
|
|
5066
5292
|
),
|
|
5067
|
-
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ (0,
|
|
5293
|
+
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5068
5294
|
"span",
|
|
5069
5295
|
{
|
|
5070
5296
|
className: "rounded bg-destructive px-1.5 py-0.5 text-[11px] font-medium text-destructive-foreground",
|
|
@@ -5073,8 +5299,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5073
5299
|
children: "Missing question"
|
|
5074
5300
|
}
|
|
5075
5301
|
) : null,
|
|
5076
|
-
onField ? /* @__PURE__ */ (0,
|
|
5077
|
-
/* @__PURE__ */ (0,
|
|
5302
|
+
onField ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
5303
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5078
5304
|
PickOne,
|
|
5079
5305
|
{
|
|
5080
5306
|
label: "Condition comparison",
|
|
@@ -5085,8 +5311,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5085
5311
|
attrs: { "data-condition": "comparison" }
|
|
5086
5312
|
}
|
|
5087
5313
|
),
|
|
5088
|
-
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ (0,
|
|
5089
|
-
|
|
5314
|
+
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5315
|
+
import_design_system24.BasicInput,
|
|
5090
5316
|
{
|
|
5091
5317
|
className: "h-8 w-16 text-xs",
|
|
5092
5318
|
type: "number",
|
|
@@ -5102,7 +5328,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5102
5328
|
// is asked for ONE record even when the column holds several: a clause compares
|
|
5103
5329
|
// against one value, and a picker that let somebody choose three would be
|
|
5104
5330
|
// writing an expression this row cannot draw back.
|
|
5105
|
-
/* @__PURE__ */ (0,
|
|
5331
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5106
5332
|
RelationPicker,
|
|
5107
5333
|
{
|
|
5108
5334
|
field: { ...chosen.field, multi: false },
|
|
@@ -5113,8 +5339,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5113
5339
|
allowCreate: false
|
|
5114
5340
|
}
|
|
5115
5341
|
)
|
|
5116
|
-
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ (0,
|
|
5117
|
-
|
|
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,
|
|
5118
5344
|
{
|
|
5119
5345
|
className: "h-8 w-28 text-xs",
|
|
5120
5346
|
"aria-label": "Condition value",
|
|
@@ -5190,7 +5416,7 @@ function ConditionGroup({
|
|
|
5190
5416
|
className
|
|
5191
5417
|
}) {
|
|
5192
5418
|
const { joiner, args } = clausesOf(expr);
|
|
5193
|
-
const [drafting, setDrafting] = (0,
|
|
5419
|
+
const [drafting, setDrafting] = (0, import_react38.useState)(null);
|
|
5194
5420
|
const nested = depth > 0;
|
|
5195
5421
|
const replaceAt = (index, next) => {
|
|
5196
5422
|
const nextArgs = args.slice();
|
|
@@ -5201,16 +5427,16 @@ function ConditionGroup({
|
|
|
5201
5427
|
const joinWord = (index) => index === 0 ? lead : joiner === "or" || joiner === "none" ? "or" : "and";
|
|
5202
5428
|
const showJoiner = nested || args.length > 1 || joiner === "none" || joiner === "notall";
|
|
5203
5429
|
const opposite = joiner === "or" || joiner === "none" ? "and" : "or";
|
|
5204
|
-
return /* @__PURE__ */ (0,
|
|
5430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
5205
5431
|
"div",
|
|
5206
5432
|
{
|
|
5207
5433
|
className: className ?? "flex flex-col gap-1 text-xs",
|
|
5208
5434
|
"data-testid": nested ? "condition-nested-group" : "condition-group",
|
|
5209
5435
|
"data-depth": depth,
|
|
5210
5436
|
children: [
|
|
5211
|
-
showJoiner ? /* @__PURE__ */ (0,
|
|
5212
|
-
/* @__PURE__ */ (0,
|
|
5213
|
-
/* @__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)(
|
|
5214
5440
|
PickOne,
|
|
5215
5441
|
{
|
|
5216
5442
|
label: nested ? `How the conditions in this group are joined (level ${depth + 1})` : "How these conditions are joined",
|
|
@@ -5221,8 +5447,8 @@ function ConditionGroup({
|
|
|
5221
5447
|
attrs: { "data-condition": "joiner" }
|
|
5222
5448
|
}
|
|
5223
5449
|
),
|
|
5224
|
-
nested && onRemove ? /* @__PURE__ */ (0,
|
|
5225
|
-
|
|
5450
|
+
nested && onRemove ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5451
|
+
import_design_system24.Button,
|
|
5226
5452
|
{
|
|
5227
5453
|
size: "sm",
|
|
5228
5454
|
variant: "ghost",
|
|
@@ -5233,7 +5459,7 @@ function ConditionGroup({
|
|
|
5233
5459
|
}
|
|
5234
5460
|
) : null
|
|
5235
5461
|
] }) : null,
|
|
5236
|
-
args.length === 0 ? /* @__PURE__ */ (0,
|
|
5462
|
+
args.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5237
5463
|
ConditionRow,
|
|
5238
5464
|
{
|
|
5239
5465
|
lead,
|
|
@@ -5246,7 +5472,7 @@ function ConditionGroup({
|
|
|
5246
5472
|
const group = conditionGroupOf(arg);
|
|
5247
5473
|
const key = `clause-${index}`;
|
|
5248
5474
|
if (group && allowNesting) {
|
|
5249
|
-
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)(
|
|
5250
5476
|
ConditionGroup,
|
|
5251
5477
|
{
|
|
5252
5478
|
lead: joinWord(index),
|
|
@@ -5260,7 +5486,7 @@ function ConditionGroup({
|
|
|
5260
5486
|
}
|
|
5261
5487
|
) }, key);
|
|
5262
5488
|
}
|
|
5263
|
-
return /* @__PURE__ */ (0,
|
|
5489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5264
5490
|
ConditionRow,
|
|
5265
5491
|
{
|
|
5266
5492
|
lead: showJoiner || args.length > 1 ? joinWord(index) : lead,
|
|
@@ -5272,7 +5498,7 @@ function ConditionGroup({
|
|
|
5272
5498
|
key
|
|
5273
5499
|
);
|
|
5274
5500
|
}),
|
|
5275
|
-
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)(
|
|
5276
5502
|
ConditionRow,
|
|
5277
5503
|
{
|
|
5278
5504
|
lead: drafting === "group" ? `${joinWord(1)}, a group where` : joinWord(1),
|
|
@@ -5287,9 +5513,9 @@ function ConditionGroup({
|
|
|
5287
5513
|
}
|
|
5288
5514
|
}
|
|
5289
5515
|
) }) : null,
|
|
5290
|
-
args.length > 0 && !drafting ? /* @__PURE__ */ (0,
|
|
5291
|
-
/* @__PURE__ */ (0,
|
|
5292
|
-
|
|
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,
|
|
5293
5519
|
{
|
|
5294
5520
|
size: "sm",
|
|
5295
5521
|
variant: "ghost",
|
|
@@ -5299,8 +5525,8 @@ function ConditionGroup({
|
|
|
5299
5525
|
children: "Add another condition"
|
|
5300
5526
|
}
|
|
5301
5527
|
),
|
|
5302
|
-
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ (0,
|
|
5303
|
-
|
|
5528
|
+
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5529
|
+
import_design_system24.Button,
|
|
5304
5530
|
{
|
|
5305
5531
|
size: "sm",
|
|
5306
5532
|
variant: "ghost",
|
|
@@ -5317,11 +5543,11 @@ function ConditionGroup({
|
|
|
5317
5543
|
}
|
|
5318
5544
|
|
|
5319
5545
|
// src/FieldRetype.tsx
|
|
5320
|
-
var
|
|
5321
|
-
var
|
|
5322
|
-
var
|
|
5323
|
-
var
|
|
5324
|
-
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");
|
|
5325
5551
|
var RETYPE_TARGETS = [
|
|
5326
5552
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
5327
5553
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -5367,17 +5593,17 @@ function currentTarget(field) {
|
|
|
5367
5593
|
return "text";
|
|
5368
5594
|
}
|
|
5369
5595
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5370
|
-
const client = (0,
|
|
5596
|
+
const client = (0, import_react41.useRecordsClient)();
|
|
5371
5597
|
const notify = useRecordsUi().notify;
|
|
5372
|
-
const [to, setTo] = (0,
|
|
5373
|
-
const [preview, setPreview] = (0,
|
|
5374
|
-
const [asking, setAsking] = (0,
|
|
5375
|
-
const [refusal, setRefusal] = (0,
|
|
5376
|
-
const [busy, setBusy] = (0,
|
|
5377
|
-
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);
|
|
5378
5604
|
const name = fieldName(field);
|
|
5379
5605
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5380
|
-
(0,
|
|
5606
|
+
(0, import_react40.useEffect)(() => {
|
|
5381
5607
|
if (!to) return;
|
|
5382
5608
|
let cancelled = false;
|
|
5383
5609
|
setPreview(null);
|
|
@@ -5391,14 +5617,14 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5391
5617
|
return;
|
|
5392
5618
|
}
|
|
5393
5619
|
const groups = answer.data.map((row) => ({ value: row.groups[field.key] ?? null, count: row.row_count }));
|
|
5394
|
-
setPreview((0,
|
|
5620
|
+
setPreview((0, import_records20.previewRetype)({ type: to.behaviour, kind: to.kind }, groups, answer.data.length >= PREVIEW_GROUPS));
|
|
5395
5621
|
});
|
|
5396
5622
|
return () => {
|
|
5397
5623
|
cancelled = true;
|
|
5398
5624
|
};
|
|
5399
5625
|
}, [client, tableId, field.key, to]);
|
|
5400
5626
|
if (!retypeableFrom(field)) {
|
|
5401
|
-
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) });
|
|
5402
5628
|
}
|
|
5403
5629
|
const change = async () => {
|
|
5404
5630
|
if (!to) return;
|
|
@@ -5433,7 +5659,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5433
5659
|
undo: async () => {
|
|
5434
5660
|
const back = await client.migrateUndo({ migration_id: migration });
|
|
5435
5661
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5436
|
-
(0,
|
|
5662
|
+
(0, import_react41.tableShapeChanged)(tableId);
|
|
5437
5663
|
onRetyped?.();
|
|
5438
5664
|
}
|
|
5439
5665
|
});
|
|
@@ -5444,24 +5670,24 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5444
5670
|
);
|
|
5445
5671
|
setTo(null);
|
|
5446
5672
|
setPreview(null);
|
|
5447
|
-
(0,
|
|
5673
|
+
(0, import_react41.tableShapeChanged)(tableId);
|
|
5448
5674
|
onRetyped?.();
|
|
5449
5675
|
};
|
|
5450
|
-
return /* @__PURE__ */ (0,
|
|
5451
|
-
/* @__PURE__ */ (0,
|
|
5452
|
-
/* @__PURE__ */ (0,
|
|
5453
|
-
/* @__PURE__ */ (0,
|
|
5454
|
-
/* @__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)) })
|
|
5455
5681
|
] }),
|
|
5456
|
-
to ? /* @__PURE__ */ (0,
|
|
5457
|
-
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
|
|
5458
5684
|
] }),
|
|
5459
|
-
to && asking ? /* @__PURE__ */ (0,
|
|
5685
|
+
to && asking ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
5460
5686
|
"Counting ",
|
|
5461
5687
|
name,
|
|
5462
5688
|
"'s values\u2026"
|
|
5463
5689
|
] }) : null,
|
|
5464
|
-
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: [
|
|
5465
5691
|
preview.converts,
|
|
5466
5692
|
" ",
|
|
5467
5693
|
preview.converts === 1 ? "value converts" : "values convert",
|
|
@@ -5470,16 +5696,16 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5470
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(", ")})` : "") : "",
|
|
5471
5697
|
preview.partial ? ". Counted over the first 1,000 different values." : "."
|
|
5472
5698
|
] }) : null,
|
|
5473
|
-
refusal ? /* @__PURE__ */ (0,
|
|
5474
|
-
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
|
|
5475
5701
|
] });
|
|
5476
5702
|
}
|
|
5477
5703
|
|
|
5478
5704
|
// src/FieldRulePreview.tsx
|
|
5479
|
-
var
|
|
5480
|
-
var
|
|
5481
|
-
var
|
|
5482
|
-
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");
|
|
5483
5709
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5484
5710
|
function ruleWords(rules) {
|
|
5485
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("|");
|
|
@@ -5496,14 +5722,14 @@ function groupValue(value, numbers) {
|
|
|
5496
5722
|
return /^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(text) ? Number(text) : value;
|
|
5497
5723
|
}
|
|
5498
5724
|
function FieldRulePreview({ field, tableId, rules }) {
|
|
5499
|
-
const client = (0,
|
|
5500
|
-
const [preview, setPreview] = (0,
|
|
5501
|
-
const [refusal, setRefusal] = (0,
|
|
5502
|
-
const key = (0,
|
|
5503
|
-
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);
|
|
5504
5730
|
latest.current = rules;
|
|
5505
5731
|
const name = fieldName(field);
|
|
5506
|
-
(0,
|
|
5732
|
+
(0, import_react42.useEffect)(() => {
|
|
5507
5733
|
let cancelled = false;
|
|
5508
5734
|
setPreview(null);
|
|
5509
5735
|
setRefusal(null);
|
|
@@ -5516,7 +5742,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5516
5742
|
}
|
|
5517
5743
|
const numbers = holdsNumbers(field);
|
|
5518
5744
|
const groups = answer.data.map((row) => ({ value: groupValue(row.groups[field.key] ?? null, numbers), count: row.row_count }));
|
|
5519
|
-
setPreview((0,
|
|
5745
|
+
setPreview((0, import_records21.previewRuleChange)(latest.current, groups, answer.data.length >= PREVIEW_GROUPS2));
|
|
5520
5746
|
});
|
|
5521
5747
|
}, 300);
|
|
5522
5748
|
return () => {
|
|
@@ -5524,16 +5750,16 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5524
5750
|
clearTimeout(timer);
|
|
5525
5751
|
};
|
|
5526
5752
|
}, [client, tableId, field.key, key]);
|
|
5527
|
-
if (refusal) return /* @__PURE__ */ (0,
|
|
5753
|
+
if (refusal) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RefusalNotice, { error: refusal });
|
|
5528
5754
|
if (!preview) {
|
|
5529
|
-
return /* @__PURE__ */ (0,
|
|
5755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "counting", children: [
|
|
5530
5756
|
"Counting ",
|
|
5531
5757
|
name,
|
|
5532
5758
|
"'s values\u2026"
|
|
5533
5759
|
] });
|
|
5534
5760
|
}
|
|
5535
5761
|
if (preview.keptAside === 0) {
|
|
5536
|
-
return /* @__PURE__ */ (0,
|
|
5762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "fits", children: [
|
|
5537
5763
|
"Every value already in ",
|
|
5538
5764
|
name,
|
|
5539
5765
|
" still fits",
|
|
@@ -5541,7 +5767,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5541
5767
|
"."
|
|
5542
5768
|
] });
|
|
5543
5769
|
}
|
|
5544
|
-
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: [
|
|
5545
5771
|
preview.keptAside,
|
|
5546
5772
|
" ",
|
|
5547
5773
|
preview.keptAside === 1 ? "value no longer fits and will be" : "values no longer fit and will be",
|
|
@@ -5624,9 +5850,9 @@ function choiceLookForNewList(multi, rows) {
|
|
|
5624
5850
|
}
|
|
5625
5851
|
|
|
5626
5852
|
// src/NewerKindQuestions.tsx
|
|
5627
|
-
var
|
|
5628
|
-
var
|
|
5629
|
-
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");
|
|
5630
5856
|
var STATUS_STARTING_CHOICES = [
|
|
5631
5857
|
{ words: "Not started", group: "todo" },
|
|
5632
5858
|
{ words: "In progress", group: "in_progress" },
|
|
@@ -5645,7 +5871,7 @@ function statusGroupRows(field, rows, keyOfId, changed) {
|
|
|
5645
5871
|
if (words === "") continue;
|
|
5646
5872
|
const ref = r.id ?? words;
|
|
5647
5873
|
const key = r.id ? keyOfId[r.id] : void 0;
|
|
5648
|
-
const held = field && key ? (0,
|
|
5874
|
+
const held = field && key ? (0, import_records22.statusGroupOf)(field, key) : void 0;
|
|
5649
5875
|
out.push({ ref, words, group: changed[ref] ?? held ?? guessStatusGroup(words) });
|
|
5650
5876
|
}
|
|
5651
5877
|
return out;
|
|
@@ -5655,27 +5881,27 @@ function StatusGroupsQuestion({
|
|
|
5655
5881
|
onGroup
|
|
5656
5882
|
}) {
|
|
5657
5883
|
if (rows.length === 0) return null;
|
|
5658
|
-
return /* @__PURE__ */ (0,
|
|
5659
|
-
/* @__PURE__ */ (0,
|
|
5660
|
-
rows.map((r) => /* @__PURE__ */ (0,
|
|
5661
|
-
/* @__PURE__ */ (0,
|
|
5662
|
-
/* @__PURE__ */ (0,
|
|
5663
|
-
/* @__PURE__ */ (0,
|
|
5664
|
-
/* @__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: [
|
|
5665
5891
|
STATUS_GROUP_MARK[g],
|
|
5666
5892
|
" ",
|
|
5667
|
-
|
|
5893
|
+
import_records22.STATUS_GROUP_WORDS[g]
|
|
5668
5894
|
] }, g)) })
|
|
5669
5895
|
] })
|
|
5670
5896
|
] }, r.ref))
|
|
5671
5897
|
] });
|
|
5672
5898
|
}
|
|
5673
5899
|
function RatingMaxQuestion({ value, onChange }) {
|
|
5674
|
-
return /* @__PURE__ */ (0,
|
|
5675
|
-
/* @__PURE__ */ (0,
|
|
5676
|
-
/* @__PURE__ */ (0,
|
|
5677
|
-
/* @__PURE__ */ (0,
|
|
5678
|
-
/* @__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: [
|
|
5679
5905
|
n,
|
|
5680
5906
|
" ",
|
|
5681
5907
|
n === 1 ? "star" : "stars"
|
|
@@ -5696,22 +5922,22 @@ var SYMBOLOGY_WORDS = {
|
|
|
5696
5922
|
pdf417: "PDF417"
|
|
5697
5923
|
};
|
|
5698
5924
|
function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
5699
|
-
return /* @__PURE__ */ (0,
|
|
5700
|
-
/* @__PURE__ */ (0,
|
|
5701
|
-
/* @__PURE__ */ (0,
|
|
5702
|
-
/* @__PURE__ */ (0,
|
|
5703
|
-
/* @__PURE__ */ (0,
|
|
5704
|
-
/* @__PURE__ */ (0,
|
|
5705
|
-
|
|
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))
|
|
5706
5932
|
] })
|
|
5707
5933
|
] })
|
|
5708
5934
|
] });
|
|
5709
5935
|
}
|
|
5710
5936
|
|
|
5711
5937
|
// src/FieldFormatPicker.tsx
|
|
5712
|
-
var
|
|
5938
|
+
var import_design_system27 = require("@ai-matrx/design-system");
|
|
5713
5939
|
var import_field_formats6 = require("@ai-matrx/design-system/field-formats");
|
|
5714
|
-
var
|
|
5940
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
5715
5941
|
var KIND_WORD = {
|
|
5716
5942
|
choice: "select",
|
|
5717
5943
|
multi_choice: "multi_select",
|
|
@@ -5834,13 +6060,13 @@ function FieldFormatPicker({
|
|
|
5834
6060
|
else merged[key] = next;
|
|
5835
6061
|
onValue({ ...value, format: Object.keys(merged).length > 0 ? { id: value.format.id, options: merged } : { id: value.format.id } });
|
|
5836
6062
|
};
|
|
5837
|
-
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: [
|
|
5838
6064
|
label,
|
|
5839
6065
|
control
|
|
5840
6066
|
] }, key) : null;
|
|
5841
|
-
return /* @__PURE__ */ (0,
|
|
5842
|
-
/* @__PURE__ */ (0,
|
|
5843
|
-
/* @__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)(
|
|
5844
6070
|
PickOne,
|
|
5845
6071
|
{
|
|
5846
6072
|
id: `records-shows-as-${field.id}`,
|
|
@@ -5866,12 +6092,12 @@ function FieldFormatPicker({
|
|
|
5866
6092
|
]
|
|
5867
6093
|
}
|
|
5868
6094
|
),
|
|
5869
|
-
/* @__PURE__ */ (0,
|
|
5870
|
-
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: [
|
|
5871
6097
|
option(
|
|
5872
6098
|
"currency",
|
|
5873
6099
|
"Currency",
|
|
5874
|
-
/* @__PURE__ */ (0,
|
|
6100
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5875
6101
|
PickOne,
|
|
5876
6102
|
{
|
|
5877
6103
|
label: "Currency",
|
|
@@ -5886,7 +6112,7 @@ function FieldFormatPicker({
|
|
|
5886
6112
|
option(
|
|
5887
6113
|
"percentScale",
|
|
5888
6114
|
"Stored as",
|
|
5889
|
-
/* @__PURE__ */ (0,
|
|
6115
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5890
6116
|
PickOne,
|
|
5891
6117
|
{
|
|
5892
6118
|
label: "Stored as",
|
|
@@ -5904,7 +6130,7 @@ function FieldFormatPicker({
|
|
|
5904
6130
|
option(
|
|
5905
6131
|
"durationUnit",
|
|
5906
6132
|
"Unit",
|
|
5907
|
-
/* @__PURE__ */ (0,
|
|
6133
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5908
6134
|
PickOne,
|
|
5909
6135
|
{
|
|
5910
6136
|
label: "Unit",
|
|
@@ -5924,7 +6150,7 @@ function FieldFormatPicker({
|
|
|
5924
6150
|
option(
|
|
5925
6151
|
"precision",
|
|
5926
6152
|
"Decimals",
|
|
5927
|
-
/* @__PURE__ */ (0,
|
|
6153
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5928
6154
|
"input",
|
|
5929
6155
|
{
|
|
5930
6156
|
"data-records-format-option": "precision",
|
|
@@ -5941,7 +6167,7 @@ function FieldFormatPicker({
|
|
|
5941
6167
|
option(
|
|
5942
6168
|
"ratingMax",
|
|
5943
6169
|
"Out of",
|
|
5944
|
-
/* @__PURE__ */ (0,
|
|
6170
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5945
6171
|
"input",
|
|
5946
6172
|
{
|
|
5947
6173
|
"data-records-format-option": "ratingMax",
|
|
@@ -5957,7 +6183,7 @@ function FieldFormatPicker({
|
|
|
5957
6183
|
option(
|
|
5958
6184
|
"dateStyle",
|
|
5959
6185
|
"Style",
|
|
5960
|
-
/* @__PURE__ */ (0,
|
|
6186
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
5961
6187
|
PickOne,
|
|
5962
6188
|
{
|
|
5963
6189
|
label: "Style",
|
|
@@ -5976,15 +6202,15 @@ function FieldFormatPicker({
|
|
|
5976
6202
|
option(
|
|
5977
6203
|
"prefix",
|
|
5978
6204
|
"Prefix",
|
|
5979
|
-
/* @__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) })
|
|
5980
6206
|
),
|
|
5981
6207
|
option(
|
|
5982
6208
|
"suffix",
|
|
5983
6209
|
"Suffix",
|
|
5984
|
-
/* @__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) })
|
|
5985
6211
|
),
|
|
5986
|
-
optionKeys.includes("useGrouping") ? /* @__PURE__ */ (0,
|
|
5987
|
-
/* @__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)(
|
|
5988
6214
|
"input",
|
|
5989
6215
|
{
|
|
5990
6216
|
type: "checkbox",
|
|
@@ -6022,37 +6248,37 @@ function nextFieldSort(fields) {
|
|
|
6022
6248
|
}
|
|
6023
6249
|
|
|
6024
6250
|
// src/FieldEditor.tsx
|
|
6025
|
-
var
|
|
6251
|
+
var import_records25 = require("@ai-matrx/records");
|
|
6026
6252
|
|
|
6027
6253
|
// src/ButtonSettings.tsx
|
|
6028
|
-
var
|
|
6029
|
-
var
|
|
6254
|
+
var import_react44 = require("react");
|
|
6255
|
+
var import_design_system29 = require("@ai-matrx/design-system");
|
|
6030
6256
|
var import_data_table5 = require("@ai-matrx/design-system/data-table");
|
|
6031
|
-
var
|
|
6032
|
-
var
|
|
6257
|
+
var import_records24 = require("@ai-matrx/records");
|
|
6258
|
+
var import_react45 = require("@ai-matrx/records/react");
|
|
6033
6259
|
|
|
6034
6260
|
// src/AccentSwatches.tsx
|
|
6035
|
-
var
|
|
6036
|
-
var
|
|
6261
|
+
var import_records23 = require("@ai-matrx/records");
|
|
6262
|
+
var import_design_system28 = require("@ai-matrx/design-system");
|
|
6037
6263
|
var import_data_table4 = require("@ai-matrx/design-system/data-table");
|
|
6038
|
-
var
|
|
6039
|
-
function AccentSwatches({ value, onChange, options =
|
|
6040
|
-
return /* @__PURE__ */ (0,
|
|
6041
|
-
/* @__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)(
|
|
6042
6268
|
"button",
|
|
6043
6269
|
{
|
|
6044
6270
|
type: "button",
|
|
6045
6271
|
role: "radio",
|
|
6046
6272
|
"aria-checked": value === "",
|
|
6047
6273
|
onClick: () => onChange(""),
|
|
6048
|
-
className: (0,
|
|
6274
|
+
className: (0, import_design_system28.cn)(
|
|
6049
6275
|
"h-7 rounded border px-2 text-xs",
|
|
6050
6276
|
value === "" ? "border-foreground" : "border-border text-muted-foreground"
|
|
6051
6277
|
),
|
|
6052
6278
|
children: noneLabel
|
|
6053
6279
|
}
|
|
6054
6280
|
),
|
|
6055
|
-
options.map((c) => /* @__PURE__ */ (0,
|
|
6281
|
+
options.map((c) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
6056
6282
|
"button",
|
|
6057
6283
|
{
|
|
6058
6284
|
type: "button",
|
|
@@ -6061,7 +6287,7 @@ function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACC
|
|
|
6061
6287
|
"aria-label": import_data_table4.STYLE_COLOR_LABELS[c],
|
|
6062
6288
|
title: import_data_table4.STYLE_COLOR_LABELS[c],
|
|
6063
6289
|
onClick: () => onChange(c),
|
|
6064
|
-
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")
|
|
6065
6291
|
},
|
|
6066
6292
|
c
|
|
6067
6293
|
))
|
|
@@ -6069,7 +6295,7 @@ function AccentSwatches({ value, onChange, options = import_records22.PORTAL_ACC
|
|
|
6069
6295
|
}
|
|
6070
6296
|
|
|
6071
6297
|
// src/ButtonSettings.tsx
|
|
6072
|
-
var
|
|
6298
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6073
6299
|
var DOES_WORDS = {
|
|
6074
6300
|
none: "Nothing yet",
|
|
6075
6301
|
open_url: "Open a link",
|
|
@@ -6078,7 +6304,7 @@ var DOES_WORDS = {
|
|
|
6078
6304
|
};
|
|
6079
6305
|
function buttonUrlInWords(url, fields) {
|
|
6080
6306
|
let out = url;
|
|
6081
|
-
for (const id of (0,
|
|
6307
|
+
for (const id of (0, import_records24.buttonUrlPlaceholders)(url)) {
|
|
6082
6308
|
const f = fields.find((x) => x.id === id || x.key === id);
|
|
6083
6309
|
if (f) out = out.split(`{{${id}}}`).join(`{${fieldName(f)}}`);
|
|
6084
6310
|
}
|
|
@@ -6090,11 +6316,11 @@ function ButtonSettingsEditor({
|
|
|
6090
6316
|
tableId,
|
|
6091
6317
|
fields
|
|
6092
6318
|
}) {
|
|
6093
|
-
const client = (0,
|
|
6094
|
-
const [actions, setActions] = (0,
|
|
6095
|
-
const [actionsRefused, setActionsRefused] = (0,
|
|
6096
|
-
const [automations, setAutomations] = (0,
|
|
6097
|
-
(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)(() => {
|
|
6098
6324
|
if (!client || !tableId) return;
|
|
6099
6325
|
let live = true;
|
|
6100
6326
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6115,15 +6341,15 @@ function ButtonSettingsEditor({
|
|
|
6115
6341
|
}, [client, tableId, value.do, actions, automations]);
|
|
6116
6342
|
const set = (patch) => onChange({ ...value, ...patch });
|
|
6117
6343
|
const columns = fields.filter((f) => !(f.type === "text" && f.format === "button"));
|
|
6118
|
-
return /* @__PURE__ */ (0,
|
|
6119
|
-
/* @__PURE__ */ (0,
|
|
6120
|
-
/* @__PURE__ */ (0,
|
|
6121
|
-
/* @__PURE__ */ (0,
|
|
6122
|
-
/* @__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 }) })
|
|
6123
6349
|
] }),
|
|
6124
|
-
/* @__PURE__ */ (0,
|
|
6125
|
-
/* @__PURE__ */ (0,
|
|
6126
|
-
/* @__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)(
|
|
6127
6353
|
PickOne,
|
|
6128
6354
|
{
|
|
6129
6355
|
label: "What a press does",
|
|
@@ -6135,9 +6361,9 @@ function ButtonSettingsEditor({
|
|
|
6135
6361
|
)
|
|
6136
6362
|
] })
|
|
6137
6363
|
] }),
|
|
6138
|
-
/* @__PURE__ */ (0,
|
|
6139
|
-
/* @__PURE__ */ (0,
|
|
6140
|
-
/* @__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)(
|
|
6141
6367
|
AccentSwatches,
|
|
6142
6368
|
{
|
|
6143
6369
|
value: value.color ?? "",
|
|
@@ -6147,11 +6373,11 @@ function ButtonSettingsEditor({
|
|
|
6147
6373
|
}
|
|
6148
6374
|
)
|
|
6149
6375
|
] }),
|
|
6150
|
-
value.do === "open_url" ? /* @__PURE__ */ (0,
|
|
6151
|
-
/* @__PURE__ */ (0,
|
|
6152
|
-
/* @__PURE__ */ (0,
|
|
6153
|
-
/* @__PURE__ */ (0,
|
|
6154
|
-
|
|
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,
|
|
6155
6381
|
{
|
|
6156
6382
|
className: "h-8 flex-1 font-mono text-xs",
|
|
6157
6383
|
placeholder: "https://",
|
|
@@ -6160,7 +6386,7 @@ function ButtonSettingsEditor({
|
|
|
6160
6386
|
onChange: (e) => set({ url: e.target.value })
|
|
6161
6387
|
}
|
|
6162
6388
|
),
|
|
6163
|
-
columns.length > 0 ? /* @__PURE__ */ (0,
|
|
6389
|
+
columns.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6164
6390
|
PickOne,
|
|
6165
6391
|
{
|
|
6166
6392
|
label: "Add a column's value",
|
|
@@ -6173,10 +6399,10 @@ function ButtonSettingsEditor({
|
|
|
6173
6399
|
}
|
|
6174
6400
|
) : null
|
|
6175
6401
|
] }),
|
|
6176
|
-
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
|
|
6177
6403
|
] }) : null,
|
|
6178
|
-
value.do === "run_action" ? !tableId ? /* @__PURE__ */ (0,
|
|
6179
|
-
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)(
|
|
6180
6406
|
PickOne,
|
|
6181
6407
|
{
|
|
6182
6408
|
label: "Row action",
|
|
@@ -6187,7 +6413,7 @@ function ButtonSettingsEditor({
|
|
|
6187
6413
|
options: (actions ?? []).map((a) => ({ value: a.id, label: a.name }))
|
|
6188
6414
|
}
|
|
6189
6415
|
) : null,
|
|
6190
|
-
actions !== null ? /* @__PURE__ */ (0,
|
|
6416
|
+
actions !== null ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6191
6417
|
NewRowAction,
|
|
6192
6418
|
{
|
|
6193
6419
|
tableId,
|
|
@@ -6201,7 +6427,7 @@ function ButtonSettingsEditor({
|
|
|
6201
6427
|
}
|
|
6202
6428
|
) : null
|
|
6203
6429
|
] }) : null,
|
|
6204
|
-
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)(
|
|
6205
6431
|
PickOne,
|
|
6206
6432
|
{
|
|
6207
6433
|
label: "Automation",
|
|
@@ -6226,13 +6452,13 @@ function NewRowAction({
|
|
|
6226
6452
|
columns,
|
|
6227
6453
|
onMade
|
|
6228
6454
|
}) {
|
|
6229
|
-
const client = (0,
|
|
6455
|
+
const client = (0, import_react45.useOptionalRecordsClient)();
|
|
6230
6456
|
const settable = settableColumns(columns);
|
|
6231
|
-
const [fieldId, setFieldId] = (0,
|
|
6232
|
-
const [setTo, setSetTo] = (0,
|
|
6233
|
-
const [busy, setBusy] = (0,
|
|
6234
|
-
const [refused, setRefused] = (0,
|
|
6235
|
-
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" });
|
|
6236
6462
|
const make = async () => {
|
|
6237
6463
|
if (!client || fieldId === "") return;
|
|
6238
6464
|
setBusy(true);
|
|
@@ -6256,10 +6482,10 @@ function NewRowAction({
|
|
|
6256
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." });
|
|
6257
6483
|
onMade(made.id, all);
|
|
6258
6484
|
};
|
|
6259
|
-
return /* @__PURE__ */ (0,
|
|
6260
|
-
/* @__PURE__ */ (0,
|
|
6261
|
-
/* @__PURE__ */ (0,
|
|
6262
|
-
/* @__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)(
|
|
6263
6489
|
PickOne,
|
|
6264
6490
|
{
|
|
6265
6491
|
label: "Column to set",
|
|
@@ -6271,19 +6497,19 @@ function NewRowAction({
|
|
|
6271
6497
|
options: settable.map((f) => ({ value: f.id, label: fieldName(f) }))
|
|
6272
6498
|
}
|
|
6273
6499
|
),
|
|
6274
|
-
/* @__PURE__ */ (0,
|
|
6275
|
-
/* @__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" })
|
|
6276
6502
|
] }),
|
|
6277
|
-
refused ? /* @__PURE__ */ (0,
|
|
6503
|
+
refused ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RefusalLine, { error: refused }) : null
|
|
6278
6504
|
] });
|
|
6279
6505
|
}
|
|
6280
6506
|
|
|
6281
6507
|
// src/FieldEditor.tsx
|
|
6282
|
-
var
|
|
6283
|
-
var
|
|
6508
|
+
var import_records26 = require("@ai-matrx/records");
|
|
6509
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6284
6510
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
6285
|
-
var SENSITIVITIES =
|
|
6286
|
-
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] }));
|
|
6287
6513
|
var ROLLUP_OPERATIONS = ROLLUP_AGG_VALUES.map((value) => ({
|
|
6288
6514
|
value,
|
|
6289
6515
|
label: ROLLUP_AGG_LABEL[value]
|
|
@@ -6296,7 +6522,7 @@ var FORMULA_OPERATIONS = FORMULA_OP_VALUES.map((value) => ({
|
|
|
6296
6522
|
label: FORMULA_OP_LABEL[value],
|
|
6297
6523
|
joins: FORMULA_OP_JOINS[value]
|
|
6298
6524
|
}));
|
|
6299
|
-
var STORE_BEHAVIOUR = new Map(
|
|
6525
|
+
var STORE_BEHAVIOUR = new Map(import_records26.DECLARABLE_FIELD_KINDS.map((row) => [row.kind, row.behavior]));
|
|
6300
6526
|
function holdsAValueOnAStandardTable(kind) {
|
|
6301
6527
|
if (isSystemFieldKind(kind)) return false;
|
|
6302
6528
|
const behaviour = STORE_BEHAVIOUR.get(kind);
|
|
@@ -6374,16 +6600,16 @@ function FieldEditor(props) {
|
|
|
6374
6600
|
const entityToken = props.entityToken ?? null;
|
|
6375
6601
|
const onEntity = entityToken !== null;
|
|
6376
6602
|
const tableId = props.tableId ?? "";
|
|
6377
|
-
const table = (0,
|
|
6378
|
-
const tableFields = (0,
|
|
6379
|
-
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);
|
|
6380
6606
|
const fields = onEntity ? entityFields : tableFields;
|
|
6381
6607
|
const tableRights2 = useTableRights(onEntity ? null : table.data);
|
|
6382
|
-
const entityRights = (0,
|
|
6383
|
-
const tableMutation = (0,
|
|
6384
|
-
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)();
|
|
6385
6611
|
const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
|
|
6386
|
-
const client = (0,
|
|
6612
|
+
const client = (0, import_react47.useRecordsClient)();
|
|
6387
6613
|
const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
|
|
6388
6614
|
const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
|
|
6389
6615
|
const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
|
|
@@ -6393,56 +6619,56 @@ function FieldEditor(props) {
|
|
|
6393
6619
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6394
6620
|
const start = field ?? copyOf;
|
|
6395
6621
|
const startAs = start ? void 0 : props.startAs;
|
|
6396
|
-
const [label, setLabel] = (0,
|
|
6397
|
-
const [type, setType] = (0,
|
|
6398
|
-
const [required, setRequired] = (0,
|
|
6399
|
-
const [multi, setMulti] = (0,
|
|
6400
|
-
const [dated, setDated] = (0,
|
|
6401
|
-
const [sensitivity, setSensitivity] = (0,
|
|
6402
|
-
const [contextPolicy, setContextPolicy] = (0,
|
|
6403
|
-
const [rules, setRules] = (0,
|
|
6404
|
-
const [startsWith, setStartsWith] = (0,
|
|
6405
|
-
const [ratingMax, setRatingMax] = (0,
|
|
6406
|
-
const savedRules = (0,
|
|
6407
|
-
() => 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 ?? [] : [],
|
|
6408
6634
|
[field, type]
|
|
6409
6635
|
);
|
|
6410
|
-
const editedRules = (0,
|
|
6411
|
-
const [statusGroups, setStatusGroups] = (0,
|
|
6412
|
-
const [statusKeys, setStatusKeys] = (0,
|
|
6413
|
-
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"] ?? ""));
|
|
6414
6640
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
6415
|
-
const [description, setDescription] = (0,
|
|
6416
|
-
const buttonStart = (0,
|
|
6417
|
-
const [buttonSettings, setButtonSettings] = (0,
|
|
6418
|
-
const prefixStart = (0,
|
|
6419
|
-
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);
|
|
6420
6646
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6421
|
-
const [dependency, setDependency] = (0,
|
|
6422
|
-
(0,
|
|
6647
|
+
const [dependency, setDependency] = (0, import_react46.useState)(dependencyStart);
|
|
6648
|
+
(0, import_react46.useEffect)(() => {
|
|
6423
6649
|
if (!field || type !== "status") return;
|
|
6424
6650
|
let live = true;
|
|
6425
6651
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
6426
|
-
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)])));
|
|
6427
6653
|
});
|
|
6428
6654
|
return () => {
|
|
6429
6655
|
live = false;
|
|
6430
6656
|
};
|
|
6431
6657
|
}, [client, field, type]);
|
|
6432
|
-
(0,
|
|
6658
|
+
(0, import_react46.useEffect)(() => {
|
|
6433
6659
|
if (field || type !== "status") return;
|
|
6434
6660
|
setNewChoices(
|
|
6435
6661
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6436
6662
|
);
|
|
6437
6663
|
}, [field, type]);
|
|
6438
|
-
(0,
|
|
6664
|
+
(0, import_react46.useEffect)(() => {
|
|
6439
6665
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6440
6666
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6441
6667
|
}, [field, type]);
|
|
6442
|
-
const [allowOther, setAllowOther] = (0,
|
|
6443
|
-
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)([]);
|
|
6444
6670
|
const copyOfId = copyOf?.id ?? null;
|
|
6445
|
-
(0,
|
|
6671
|
+
(0, import_react46.useEffect)(() => {
|
|
6446
6672
|
if (!copyOf || !copyOfId) return;
|
|
6447
6673
|
let live = true;
|
|
6448
6674
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6454,53 +6680,53 @@ function FieldEditor(props) {
|
|
|
6454
6680
|
live = false;
|
|
6455
6681
|
};
|
|
6456
6682
|
}, [client, copyOfId]);
|
|
6457
|
-
const [choiceList, setChoiceList] = (0,
|
|
6458
|
-
const [choiceListStart, setChoiceListStart] = (0,
|
|
6459
|
-
const [rehome, setRehome] = (0,
|
|
6460
|
-
const [rehomed, setRehomed] = (0,
|
|
6461
|
-
const [rehomeRefused, setRehomeRefused] = (0,
|
|
6462
|
-
const [unit, setUnit] = (0,
|
|
6463
|
-
const [withTime, setWithTime] = (0,
|
|
6464
|
-
const [via, setVia] = (0,
|
|
6465
|
-
const [pick, setPick] = (0,
|
|
6466
|
-
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)(
|
|
6467
6693
|
start?.config?.["agg"] ?? "count"
|
|
6468
6694
|
);
|
|
6469
|
-
const [of, setOf] = (0,
|
|
6695
|
+
const [of, setOf] = (0, import_react46.useState)(String(start?.config?.["of"] ?? ""));
|
|
6470
6696
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6471
|
-
const [rollupFilter, setRollupFilter] = (0,
|
|
6697
|
+
const [rollupFilter, setRollupFilter] = (0, import_react46.useState)(
|
|
6472
6698
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6473
6699
|
);
|
|
6474
6700
|
const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
|
|
6475
|
-
const [relationTarget, setRelationTarget] = (0,
|
|
6476
|
-
const [showOnOther, setShowOnOther] = (0,
|
|
6477
|
-
const [nestsSubItems, setNestsSubItems] = (0,
|
|
6478
|
-
const [reverseRefused, setReverseRefused] = (0,
|
|
6479
|
-
const otherTable = (0,
|
|
6480
|
-
const [display, setDisplay] = (0,
|
|
6481
|
-
const [formulaOp, setFormulaOp] = (0,
|
|
6482
|
-
const [formulaFields, setFormulaFields] = (0,
|
|
6483
|
-
const [formulaSeparator, setFormulaSeparator] = (0,
|
|
6484
|
-
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));
|
|
6485
6711
|
const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
|
|
6486
|
-
const [formulaText, setFormulaText] = (0,
|
|
6487
|
-
const shownFormula = (0,
|
|
6488
|
-
(0,
|
|
6712
|
+
const [formulaText, setFormulaText] = (0, import_react46.useState)(startingFormulaText);
|
|
6713
|
+
const shownFormula = (0, import_react46.useRef)(startingFormulaText);
|
|
6714
|
+
(0, import_react46.useEffect)(() => {
|
|
6489
6715
|
if (shownFormula.current === startingFormulaText) return;
|
|
6490
6716
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6491
6717
|
shownFormula.current = startingFormulaText;
|
|
6492
6718
|
}, [startingFormulaText]);
|
|
6493
|
-
const [formulaWritten, setFormulaWritten] = (0,
|
|
6494
|
-
const [formulaOk, setFormulaOk] = (0,
|
|
6495
|
-
const [askingToRemove, setAskingToRemove] = (0,
|
|
6496
|
-
const [attempted, setAttempted] = (0,
|
|
6497
|
-
const [showsAs, setShowsAs] = (0,
|
|
6498
|
-
const [backfillError, setBackfillError] = (0,
|
|
6499
|
-
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);
|
|
6500
6726
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6501
6727
|
const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
|
|
6502
|
-
const seededAs = (0,
|
|
6503
|
-
(0,
|
|
6728
|
+
const seededAs = (0, import_react46.useRef)(heldAs);
|
|
6729
|
+
(0, import_react46.useEffect)(() => {
|
|
6504
6730
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6505
6731
|
seededAs.current = heldAs;
|
|
6506
6732
|
setType(startingType(liveField));
|
|
@@ -6509,24 +6735,24 @@ function FieldEditor(props) {
|
|
|
6509
6735
|
setUnit(liveField.unit ?? "$");
|
|
6510
6736
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6511
6737
|
}, [heldAs]);
|
|
6512
|
-
const others = (0,
|
|
6738
|
+
const others = (0, import_react46.useMemo)(
|
|
6513
6739
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6514
6740
|
[fields.data, field?.id]
|
|
6515
6741
|
);
|
|
6516
|
-
const relations = (0,
|
|
6517
|
-
const reverse = (0,
|
|
6518
|
-
const backLinks = (0,
|
|
6519
|
-
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]);
|
|
6520
6746
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6521
6747
|
const choice = fieldTypeChoice(type);
|
|
6522
6748
|
const editing = Boolean(field);
|
|
6523
|
-
(0,
|
|
6749
|
+
(0, import_react46.useEffect)(() => {
|
|
6524
6750
|
if (!editing) setStartsWith(null);
|
|
6525
6751
|
}, [type, editing]);
|
|
6526
6752
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6527
|
-
const farFieldsOfLink = (0,
|
|
6528
|
-
const farTable = (0,
|
|
6529
|
-
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)(
|
|
6530
6756
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6531
6757
|
[field, farFieldsOfLink.data]
|
|
6532
6758
|
);
|
|
@@ -6534,7 +6760,7 @@ function FieldEditor(props) {
|
|
|
6534
6760
|
const offersMany = multiApplies(type) && !isTitle;
|
|
6535
6761
|
if (!mayShape) {
|
|
6536
6762
|
if (onEntity && entityRights.loading) return null;
|
|
6537
|
-
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 });
|
|
6538
6764
|
}
|
|
6539
6765
|
const options = newChoices.map((r) => r.words.trim()).filter((word) => word !== "");
|
|
6540
6766
|
const shownStatusRows = type !== "status" ? [] : statusGroupRows(field, editing ? choiceList ?? [] : newChoices, statusKeys, statusGroups);
|
|
@@ -6546,7 +6772,7 @@ function FieldEditor(props) {
|
|
|
6546
6772
|
const nameTaken = columnNameTakenBy(label, others.map(fieldName));
|
|
6547
6773
|
const nameLine = nameTaken ? columnNameTakenLine(nameTaken, noun) : columnNameProblemLine(label, noun);
|
|
6548
6774
|
const listsChoices = type === "select" || type === "multi_select" || type === "status";
|
|
6549
|
-
const buttonMissing = type === "button" && buttonSettings.do ? (0,
|
|
6775
|
+
const buttonMissing = type === "button" && buttonSettings.do ? (0, import_records25.buttonNeeds)(buttonSettings) : null;
|
|
6550
6776
|
const missing = buttonMissing ?? (editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
|
|
6551
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 }
|
|
6552
6778
|
)));
|
|
@@ -6588,7 +6814,7 @@ function FieldEditor(props) {
|
|
|
6588
6814
|
...statusGroupsChanged ? { status_groups: statusGroupsSent } : {},
|
|
6589
6815
|
// V11 #4/#10: a rating's top star goes as `max`, the word custom.field_update now takes the way
|
|
6590
6816
|
// custom.field_declare does; the store writes the max Rule and sets aside any score above it.
|
|
6591
|
-
...type === "rating" && ratingMax !== (0,
|
|
6817
|
+
...type === "rating" && ratingMax !== (0, import_records26.ratingMaxOf)(field) ? { max: ratingMax } : {},
|
|
6592
6818
|
...type === "barcode" && symbology !== String(field.config?.["symbology"] ?? "") ? { symbology: symbology === "" ? null : symbology } : {},
|
|
6593
6819
|
...type === "button" && JSON.stringify(buttonSettings) !== JSON.stringify(buttonStart) ? { button: buttonSettings } : {},
|
|
6594
6820
|
...field.type === "relation" && dependency !== dependencyStart ? { dependency } : {},
|
|
@@ -6622,7 +6848,7 @@ function FieldEditor(props) {
|
|
|
6622
6848
|
setRehomeRefused(done.error);
|
|
6623
6849
|
return;
|
|
6624
6850
|
}
|
|
6625
|
-
(0,
|
|
6851
|
+
(0, import_react47.tableShapeChanged)(tableId);
|
|
6626
6852
|
for (const c of done.data.undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
6627
6853
|
const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
|
|
6628
6854
|
setRehome({});
|
|
@@ -6697,7 +6923,7 @@ function FieldEditor(props) {
|
|
|
6697
6923
|
if (newDefault !== null && newColumnDefaultGoes(type) === "right-after") {
|
|
6698
6924
|
const defaulted = await client.fieldUpdate({ field_id: written, patch: { default: newDefault } });
|
|
6699
6925
|
if (!defaulted.ok) {
|
|
6700
|
-
(0,
|
|
6926
|
+
(0, import_react47.tableShapeChanged)(tableId);
|
|
6701
6927
|
setBackfillError(defaulted.error);
|
|
6702
6928
|
return;
|
|
6703
6929
|
}
|
|
@@ -6723,7 +6949,7 @@ function FieldEditor(props) {
|
|
|
6723
6949
|
setReverseRefused(made.error);
|
|
6724
6950
|
return;
|
|
6725
6951
|
}
|
|
6726
|
-
(0,
|
|
6952
|
+
(0, import_react47.tableShapeChanged)(relationTarget);
|
|
6727
6953
|
}
|
|
6728
6954
|
setReverseRefused(null);
|
|
6729
6955
|
onSaved?.();
|
|
@@ -6734,16 +6960,16 @@ function FieldEditor(props) {
|
|
|
6734
6960
|
if (gone) (onRemoved ?? onSaved)?.();
|
|
6735
6961
|
else setAskingToRemove(false);
|
|
6736
6962
|
};
|
|
6737
|
-
return /* @__PURE__ */ (0,
|
|
6738
|
-
/* @__PURE__ */ (0,
|
|
6739
|
-
/* @__PURE__ */ (0,
|
|
6740
|
-
/* @__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 })
|
|
6741
6967
|
] }),
|
|
6742
|
-
/* @__PURE__ */ (0,
|
|
6743
|
-
/* @__PURE__ */ (0,
|
|
6744
|
-
/* @__PURE__ */ (0,
|
|
6745
|
-
/* @__PURE__ */ (0,
|
|
6746
|
-
|
|
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,
|
|
6747
6973
|
{
|
|
6748
6974
|
value: label,
|
|
6749
6975
|
autoFocus: true,
|
|
@@ -6758,7 +6984,7 @@ function FieldEditor(props) {
|
|
|
6758
6984
|
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6759
6985
|
}
|
|
6760
6986
|
),
|
|
6761
|
-
nameLine ? /* @__PURE__ */ (0,
|
|
6987
|
+
nameLine ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6762
6988
|
"span",
|
|
6763
6989
|
{
|
|
6764
6990
|
id: "field-editor-name-taken",
|
|
@@ -6769,10 +6995,10 @@ function FieldEditor(props) {
|
|
|
6769
6995
|
}
|
|
6770
6996
|
) : null
|
|
6771
6997
|
] }),
|
|
6772
|
-
field ? /* @__PURE__ */ (0,
|
|
6773
|
-
/* @__PURE__ */ (0,
|
|
6774
|
-
/* @__PURE__ */ (0,
|
|
6775
|
-
|
|
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,
|
|
6776
7002
|
{
|
|
6777
7003
|
value: description,
|
|
6778
7004
|
maxLength: 300,
|
|
@@ -6782,30 +7008,30 @@ function FieldEditor(props) {
|
|
|
6782
7008
|
}
|
|
6783
7009
|
)
|
|
6784
7010
|
] }) : null,
|
|
6785
|
-
/* @__PURE__ */ (0,
|
|
6786
|
-
/* @__PURE__ */ (0,
|
|
6787
|
-
/* @__PURE__ */ (0,
|
|
6788
|
-
|
|
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,
|
|
6789
7015
|
{
|
|
6790
7016
|
value: type,
|
|
6791
7017
|
disabled: editing,
|
|
6792
7018
|
onValueChange: (next) => setType(next),
|
|
6793
7019
|
children: [
|
|
6794
|
-
/* @__PURE__ */ (0,
|
|
6795
|
-
/* @__PURE__ */ (0,
|
|
6796
|
-
/* @__PURE__ */ (0,
|
|
6797
|
-
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))
|
|
6798
7024
|
] }, group)) })
|
|
6799
7025
|
]
|
|
6800
7026
|
}
|
|
6801
7027
|
),
|
|
6802
|
-
editing && field ? /* @__PURE__ */ (0,
|
|
7028
|
+
editing && field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldRetype, { field: liveField ?? field, tableId }) : null
|
|
6803
7029
|
] })
|
|
6804
7030
|
] }),
|
|
6805
|
-
type === "formula" && others.length > 0 ? /* @__PURE__ */ (0,
|
|
6806
|
-
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */ (0,
|
|
6807
|
-
/* @__PURE__ */ (0,
|
|
6808
|
-
|
|
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,
|
|
6809
7035
|
{
|
|
6810
7036
|
type: "button",
|
|
6811
7037
|
size: "sm",
|
|
@@ -6815,8 +7041,8 @@ function FieldEditor(props) {
|
|
|
6815
7041
|
children: "Pick the columns"
|
|
6816
7042
|
}
|
|
6817
7043
|
),
|
|
6818
|
-
/* @__PURE__ */ (0,
|
|
6819
|
-
|
|
7044
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7045
|
+
import_design_system30.Button,
|
|
6820
7046
|
{
|
|
6821
7047
|
type: "button",
|
|
6822
7048
|
size: "sm",
|
|
@@ -6827,7 +7053,7 @@ function FieldEditor(props) {
|
|
|
6827
7053
|
}
|
|
6828
7054
|
)
|
|
6829
7055
|
] }),
|
|
6830
|
-
formulaWritten ? /* @__PURE__ */ (0,
|
|
7056
|
+
formulaWritten ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6831
7057
|
FormulaTextEditor,
|
|
6832
7058
|
{
|
|
6833
7059
|
tableId,
|
|
@@ -6837,9 +7063,9 @@ function FieldEditor(props) {
|
|
|
6837
7063
|
columns: others
|
|
6838
7064
|
}
|
|
6839
7065
|
) : null
|
|
6840
|
-
] }) : editing && type === "formula" ? /* @__PURE__ */ (0,
|
|
6841
|
-
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */ (0,
|
|
6842
|
-
!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)(
|
|
6843
7069
|
TypeQuestions,
|
|
6844
7070
|
{
|
|
6845
7071
|
type,
|
|
@@ -6869,7 +7095,7 @@ function FieldEditor(props) {
|
|
|
6869
7095
|
setFormulaSeparator,
|
|
6870
7096
|
relations: sourcesFor(type),
|
|
6871
7097
|
others,
|
|
6872
|
-
choiceList: editing && field ? /* @__PURE__ */ (0,
|
|
7098
|
+
choiceList: editing && field ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6873
7099
|
ChoiceListEditor,
|
|
6874
7100
|
{
|
|
6875
7101
|
field,
|
|
@@ -6880,10 +7106,10 @@ function FieldEditor(props) {
|
|
|
6880
7106
|
rehome,
|
|
6881
7107
|
onRehome: setRehome
|
|
6882
7108
|
}
|
|
6883
|
-
) : /* @__PURE__ */ (0,
|
|
7109
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChoiceListEditor, { isNew: true, rows: newChoices, onRows: setNewChoices }),
|
|
6884
7110
|
allowedTypes,
|
|
6885
7111
|
setAllowedTypes,
|
|
6886
|
-
newer: type === "rating" ? /* @__PURE__ */ (0,
|
|
7112
|
+
newer: type === "rating" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6887
7113
|
RatingMaxQuestion,
|
|
6888
7114
|
{
|
|
6889
7115
|
value: ratingMax,
|
|
@@ -6891,19 +7117,19 @@ function FieldEditor(props) {
|
|
|
6891
7117
|
setRatingMax(next);
|
|
6892
7118
|
}
|
|
6893
7119
|
}
|
|
6894
|
-
) : 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
|
|
6895
7121
|
}
|
|
6896
7122
|
) : null,
|
|
6897
|
-
type === "button" ? /* @__PURE__ */ (0,
|
|
6898
|
-
type === "autonumber" ? /* @__PURE__ */ (0,
|
|
6899
|
-
/* @__PURE__ */ (0,
|
|
6900
|
-
/* @__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) })
|
|
6901
7127
|
] }) : null,
|
|
6902
|
-
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */ (0,
|
|
6903
|
-
/* @__PURE__ */ (0,
|
|
6904
|
-
/* @__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" })
|
|
6905
7131
|
] }) : null,
|
|
6906
|
-
type === "rollup" ? /* @__PURE__ */ (0,
|
|
7132
|
+
type === "rollup" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6907
7133
|
RollupFilterQuestion,
|
|
6908
7134
|
{
|
|
6909
7135
|
relation: totalSources.find((f) => f.key === via),
|
|
@@ -6913,22 +7139,22 @@ function FieldEditor(props) {
|
|
|
6913
7139
|
onChange: setRollupFilter
|
|
6914
7140
|
}
|
|
6915
7141
|
) : null,
|
|
6916
|
-
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */ (0,
|
|
6917
|
-
/* @__PURE__ */ (0,
|
|
6918
|
-
/* @__PURE__ */ (0,
|
|
6919
|
-
/* @__PURE__ */ (0,
|
|
6920
|
-
|
|
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,
|
|
6921
7147
|
{
|
|
6922
7148
|
checked: required,
|
|
6923
7149
|
"aria-label": "Required",
|
|
6924
7150
|
onCheckedChange: (v) => setRequired(v === true)
|
|
6925
7151
|
}
|
|
6926
7152
|
),
|
|
6927
|
-
/* @__PURE__ */ (0,
|
|
7153
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { title: "Every record has to have one", children: "Required" })
|
|
6928
7154
|
] }),
|
|
6929
|
-
offersMany ? /* @__PURE__ */ (0,
|
|
6930
|
-
/* @__PURE__ */ (0,
|
|
6931
|
-
|
|
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,
|
|
6932
7158
|
{
|
|
6933
7159
|
checked: multi,
|
|
6934
7160
|
"aria-label": "Can hold more than one",
|
|
@@ -6937,9 +7163,9 @@ function FieldEditor(props) {
|
|
|
6937
7163
|
),
|
|
6938
7164
|
"Can hold more than one"
|
|
6939
7165
|
] }) : null,
|
|
6940
|
-
/* @__PURE__ */ (0,
|
|
6941
|
-
/* @__PURE__ */ (0,
|
|
6942
|
-
|
|
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,
|
|
6943
7169
|
{
|
|
6944
7170
|
checked: dated,
|
|
6945
7171
|
"aria-label": "Each value has its own date",
|
|
@@ -6948,9 +7174,9 @@ function FieldEditor(props) {
|
|
|
6948
7174
|
),
|
|
6949
7175
|
"Each value has its own date"
|
|
6950
7176
|
] }),
|
|
6951
|
-
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ (0,
|
|
6952
|
-
/* @__PURE__ */ (0,
|
|
6953
|
-
|
|
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,
|
|
6954
7180
|
{
|
|
6955
7181
|
checked: showOnOther,
|
|
6956
7182
|
"aria-label": `Show on ${otherTable.data.name ?? "the other table"}`,
|
|
@@ -6961,13 +7187,13 @@ function FieldEditor(props) {
|
|
|
6961
7187
|
"Show on ",
|
|
6962
7188
|
otherTable.data.name ?? "the other table"
|
|
6963
7189
|
] }) : null,
|
|
6964
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0,
|
|
6965
|
-
/* @__PURE__ */ (0,
|
|
6966
|
-
/* @__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" })
|
|
6967
7193
|
] }) : null,
|
|
6968
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ (0,
|
|
6969
|
-
/* @__PURE__ */ (0,
|
|
6970
|
-
|
|
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,
|
|
6971
7197
|
{
|
|
6972
7198
|
checked: nestsSubItems,
|
|
6973
7199
|
"aria-label": "Sub-items",
|
|
@@ -6978,11 +7204,11 @@ function FieldEditor(props) {
|
|
|
6978
7204
|
"data-records-sub-items": ""
|
|
6979
7205
|
}
|
|
6980
7206
|
),
|
|
6981
|
-
/* @__PURE__ */ (0,
|
|
7207
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { title: "Each record sits under the one this column names", children: "Sub-items" })
|
|
6982
7208
|
] }) : null,
|
|
6983
|
-
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */ (0,
|
|
6984
|
-
/* @__PURE__ */ (0,
|
|
6985
|
-
|
|
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,
|
|
6986
7212
|
{
|
|
6987
7213
|
checked: allowOther,
|
|
6988
7214
|
"aria-label": "A value that is not one of the choices is added to them",
|
|
@@ -6992,10 +7218,10 @@ function FieldEditor(props) {
|
|
|
6992
7218
|
"A value that is not one of the choices is added to them"
|
|
6993
7219
|
] }) : null
|
|
6994
7220
|
] }),
|
|
6995
|
-
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ (0,
|
|
6996
|
-
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ (0,
|
|
6997
|
-
/* @__PURE__ */ (0,
|
|
6998
|
-
/* @__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)(
|
|
6999
7225
|
FieldControl,
|
|
7000
7226
|
{
|
|
7001
7227
|
id: "records-field-default",
|
|
@@ -7005,29 +7231,29 @@ function FieldEditor(props) {
|
|
|
7005
7231
|
}
|
|
7006
7232
|
)
|
|
7007
7233
|
] }) : null,
|
|
7008
|
-
/* @__PURE__ */ (0,
|
|
7009
|
-
/* @__PURE__ */ (0,
|
|
7010
|
-
/* @__PURE__ */ (0,
|
|
7011
|
-
/* @__PURE__ */ (0,
|
|
7012
|
-
/* @__PURE__ */ (0,
|
|
7013
|
-
/* @__PURE__ */ (0,
|
|
7014
|
-
/* @__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)) })
|
|
7015
7241
|
] })
|
|
7016
7242
|
] }),
|
|
7017
|
-
/* @__PURE__ */ (0,
|
|
7018
|
-
/* @__PURE__ */ (0,
|
|
7019
|
-
/* @__PURE__ */ (0,
|
|
7020
|
-
/* @__PURE__ */ (0,
|
|
7021
|
-
/* @__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)) })
|
|
7022
7248
|
] })
|
|
7023
7249
|
] })
|
|
7024
7250
|
] }),
|
|
7025
|
-
/* @__PURE__ */ (0,
|
|
7026
|
-
/* @__PURE__ */ (0,
|
|
7027
|
-
/* @__PURE__ */ (0,
|
|
7028
|
-
/* @__PURE__ */ (0,
|
|
7029
|
-
/* @__PURE__ */ (0,
|
|
7030
|
-
|
|
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,
|
|
7031
7257
|
{
|
|
7032
7258
|
type: "button",
|
|
7033
7259
|
size: "sm",
|
|
@@ -7038,9 +7264,9 @@ function FieldEditor(props) {
|
|
|
7038
7264
|
}
|
|
7039
7265
|
)
|
|
7040
7266
|
] }),
|
|
7041
|
-
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */ (0,
|
|
7042
|
-
/* @__PURE__ */ (0,
|
|
7043
|
-
|
|
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,
|
|
7044
7270
|
{
|
|
7045
7271
|
checked: rules.some((r) => r.kind === "unique"),
|
|
7046
7272
|
"aria-label": UNIQUE_LABEL,
|
|
@@ -7049,21 +7275,21 @@ function FieldEditor(props) {
|
|
|
7049
7275
|
),
|
|
7050
7276
|
UNIQUE_LABEL
|
|
7051
7277
|
] }) : null,
|
|
7052
|
-
rules.length === 0 ? /* @__PURE__ */ (0,
|
|
7053
|
-
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ (0,
|
|
7054
|
-
/* @__PURE__ */ (0,
|
|
7055
|
-
|
|
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,
|
|
7056
7282
|
{
|
|
7057
7283
|
value: rule.kind,
|
|
7058
7284
|
onValueChange: (kind) => setRules(rules.map((r, i) => i === index ? { ...r, kind } : r)),
|
|
7059
7285
|
children: [
|
|
7060
|
-
/* @__PURE__ */ (0,
|
|
7061
|
-
/* @__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)) })
|
|
7062
7288
|
]
|
|
7063
7289
|
}
|
|
7064
7290
|
),
|
|
7065
|
-
rule.kind === "length" ? /* @__PURE__ */ (0,
|
|
7066
|
-
|
|
7291
|
+
rule.kind === "length" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7292
|
+
import_design_system30.BasicInput,
|
|
7067
7293
|
{
|
|
7068
7294
|
className: "h-8 w-24",
|
|
7069
7295
|
inputMode: "numeric",
|
|
@@ -7073,8 +7299,8 @@ function FieldEditor(props) {
|
|
|
7073
7299
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withNumber(r, "min", e.target.value) : r))
|
|
7074
7300
|
}
|
|
7075
7301
|
) : null,
|
|
7076
|
-
/* @__PURE__ */ (0,
|
|
7077
|
-
|
|
7302
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7303
|
+
import_design_system30.BasicInput,
|
|
7078
7304
|
{
|
|
7079
7305
|
className: "h-8",
|
|
7080
7306
|
...rule.kind === "length" ? { inputMode: "numeric", placeholder: "most" } : {},
|
|
@@ -7083,8 +7309,8 @@ function FieldEditor(props) {
|
|
|
7083
7309
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? { ...r, value: e.target.value } : r))
|
|
7084
7310
|
}
|
|
7085
7311
|
),
|
|
7086
|
-
rule.kind === "pattern" ? /* @__PURE__ */ (0,
|
|
7087
|
-
|
|
7312
|
+
rule.kind === "pattern" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7313
|
+
import_design_system30.BasicInput,
|
|
7088
7314
|
{
|
|
7089
7315
|
className: "h-8",
|
|
7090
7316
|
placeholder: "for example 949-555-0142",
|
|
@@ -7093,8 +7319,8 @@ function FieldEditor(props) {
|
|
|
7093
7319
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withText(r, "example", e.target.value) : r))
|
|
7094
7320
|
}
|
|
7095
7321
|
) : null,
|
|
7096
|
-
/* @__PURE__ */ (0,
|
|
7097
|
-
|
|
7322
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7323
|
+
import_design_system30.Button,
|
|
7098
7324
|
{
|
|
7099
7325
|
type: "button",
|
|
7100
7326
|
size: "sm",
|
|
@@ -7106,9 +7332,9 @@ function FieldEditor(props) {
|
|
|
7106
7332
|
)
|
|
7107
7333
|
] }, `${rule.kind}-${index}`))
|
|
7108
7334
|
] }),
|
|
7109
|
-
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ (0,
|
|
7110
|
-
mutation.error ? /* @__PURE__ */ (0,
|
|
7111
|
-
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)(
|
|
7112
7338
|
RefusalNotice,
|
|
7113
7339
|
{
|
|
7114
7340
|
error: (0, refusals_exports.refusal)(
|
|
@@ -7118,11 +7344,11 @@ function FieldEditor(props) {
|
|
|
7118
7344
|
)
|
|
7119
7345
|
}
|
|
7120
7346
|
) : null,
|
|
7121
|
-
rehomeRefused ? /* @__PURE__ */ (0,
|
|
7122
|
-
rehomed ? /* @__PURE__ */ (0,
|
|
7123
|
-
/* @__PURE__ */ (0,
|
|
7124
|
-
rehomed.undo ? /* @__PURE__ */ (0,
|
|
7125
|
-
|
|
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,
|
|
7126
7352
|
{
|
|
7127
7353
|
type: "button",
|
|
7128
7354
|
size: "sm",
|
|
@@ -7136,7 +7362,7 @@ function FieldEditor(props) {
|
|
|
7136
7362
|
setRehomeRefused(back.error);
|
|
7137
7363
|
return;
|
|
7138
7364
|
}
|
|
7139
|
-
(0,
|
|
7365
|
+
(0, import_react47.tableShapeChanged)(tableId);
|
|
7140
7366
|
for (const c of undo.cells_back) (0, import_core6.announceRecordChanged)(c.record_id);
|
|
7141
7367
|
setChoiceList(null);
|
|
7142
7368
|
setChoiceListStart(null);
|
|
@@ -7146,19 +7372,19 @@ function FieldEditor(props) {
|
|
|
7146
7372
|
children: "Undo"
|
|
7147
7373
|
}
|
|
7148
7374
|
) : null,
|
|
7149
|
-
/* @__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" })
|
|
7150
7376
|
] }) : null,
|
|
7151
|
-
reverseRefused ? /* @__PURE__ */ (0,
|
|
7152
|
-
/* @__PURE__ */ (0,
|
|
7153
|
-
/* @__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 })
|
|
7154
7380
|
] }) : null,
|
|
7155
|
-
backfillError ? /* @__PURE__ */ (0,
|
|
7156
|
-
/* @__PURE__ */ (0,
|
|
7157
|
-
/* @__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 })
|
|
7158
7384
|
] }) : null,
|
|
7159
|
-
/* @__PURE__ */ (0,
|
|
7160
|
-
/* @__PURE__ */ (0,
|
|
7161
|
-
|
|
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,
|
|
7162
7388
|
{
|
|
7163
7389
|
size: "sm",
|
|
7164
7390
|
disabled: mutation.saving || Boolean(formulaMissing) || Boolean(nameLine) && label.trim() !== (field?.label ?? "").trim(),
|
|
@@ -7173,8 +7399,8 @@ function FieldEditor(props) {
|
|
|
7173
7399
|
children: mutation.saving ? "Saving\u2026" : field ? EDIT_FIELD_SAVE_LABEL : onEntity ? ADD_STANDARD_FIELD_SAVE_LABEL : ADD_FIELD_SAVE_LABEL
|
|
7174
7400
|
}
|
|
7175
7401
|
),
|
|
7176
|
-
onCancel ? /* @__PURE__ */ (0,
|
|
7177
|
-
/* @__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)(
|
|
7178
7404
|
"span",
|
|
7179
7405
|
{
|
|
7180
7406
|
id: "field-editor-missing",
|
|
@@ -7190,12 +7416,12 @@ function FieldEditor(props) {
|
|
|
7190
7416
|
footer is always as wide and as tall as its larger state: opening the confirm moved
|
|
7191
7417
|
the dialog card 0.2278 and closing it 0.1303. The consequence is the tooltip of
|
|
7192
7418
|
"Remove it" (interface-text: the slot holds a label, never a paragraph). */
|
|
7193
|
-
/* @__PURE__ */ (0,
|
|
7194
|
-
/* @__PURE__ */ (0,
|
|
7195
|
-
/* @__PURE__ */ (0,
|
|
7196
|
-
/* @__PURE__ */ (0,
|
|
7197
|
-
/* @__PURE__ */ (0,
|
|
7198
|
-
|
|
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,
|
|
7199
7425
|
{
|
|
7200
7426
|
size: "sm",
|
|
7201
7427
|
variant: "destructive",
|
|
@@ -7207,7 +7433,7 @@ function FieldEditor(props) {
|
|
|
7207
7433
|
children: "Remove it"
|
|
7208
7434
|
}
|
|
7209
7435
|
),
|
|
7210
|
-
/* @__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" })
|
|
7211
7437
|
] })
|
|
7212
7438
|
] })
|
|
7213
7439
|
) : null
|
|
@@ -7298,10 +7524,10 @@ function formulaSeparatorOf(field) {
|
|
|
7298
7524
|
function TypeQuestions(props) {
|
|
7299
7525
|
const { type } = props;
|
|
7300
7526
|
if (type === "entity_reference") {
|
|
7301
|
-
return /* @__PURE__ */ (0,
|
|
7527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EntityReferenceKindPicker, { value: props.allowedTypes, onChange: props.setAllowedTypes, locked: props.editing });
|
|
7302
7528
|
}
|
|
7303
7529
|
if (type === "relation") {
|
|
7304
|
-
return /* @__PURE__ */ (0,
|
|
7530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7305
7531
|
ReferenceBuilder,
|
|
7306
7532
|
{
|
|
7307
7533
|
tableId: props.tableId,
|
|
@@ -7314,21 +7540,21 @@ function TypeQuestions(props) {
|
|
|
7314
7540
|
}
|
|
7315
7541
|
);
|
|
7316
7542
|
}
|
|
7317
|
-
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 });
|
|
7318
7544
|
if (type === "status") {
|
|
7319
|
-
return /* @__PURE__ */ (0,
|
|
7545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
7320
7546
|
props.choiceList,
|
|
7321
7547
|
props.newer
|
|
7322
7548
|
] });
|
|
7323
7549
|
}
|
|
7324
7550
|
if (type === "select" || type === "multi_select") {
|
|
7325
|
-
return /* @__PURE__ */ (0,
|
|
7551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: props.choiceList });
|
|
7326
7552
|
}
|
|
7327
7553
|
if (type === "currency") {
|
|
7328
|
-
return /* @__PURE__ */ (0,
|
|
7329
|
-
/* @__PURE__ */ (0,
|
|
7330
|
-
/* @__PURE__ */ (0,
|
|
7331
|
-
|
|
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,
|
|
7332
7558
|
{
|
|
7333
7559
|
value: props.unit,
|
|
7334
7560
|
"aria-label": "The currency",
|
|
@@ -7339,9 +7565,9 @@ function TypeQuestions(props) {
|
|
|
7339
7565
|
] });
|
|
7340
7566
|
}
|
|
7341
7567
|
if (type === "datetime") {
|
|
7342
|
-
return /* @__PURE__ */ (0,
|
|
7343
|
-
/* @__PURE__ */ (0,
|
|
7344
|
-
|
|
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,
|
|
7345
7571
|
{
|
|
7346
7572
|
checked: props.withTime,
|
|
7347
7573
|
"aria-label": "Include a time of day",
|
|
@@ -7354,14 +7580,14 @@ function TypeQuestions(props) {
|
|
|
7354
7580
|
if (type === "lookup" || type === "rollup" || type === "count") {
|
|
7355
7581
|
const usable = props.relations;
|
|
7356
7582
|
if (usable.length === 0) {
|
|
7357
|
-
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." });
|
|
7358
7584
|
}
|
|
7359
|
-
return /* @__PURE__ */ (0,
|
|
7360
|
-
/* @__PURE__ */ (0,
|
|
7361
|
-
/* @__PURE__ */ (0,
|
|
7362
|
-
/* @__PURE__ */ (0,
|
|
7363
|
-
/* @__PURE__ */ (0,
|
|
7364
|
-
/* @__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: [
|
|
7365
7591
|
fieldName(f),
|
|
7366
7592
|
isBackLinkSource(f) ? BACK_LINK_SOURCE_SUFFIX : "",
|
|
7367
7593
|
sourceKindOf(f) === "person" ? " \u2014 a person" : sourceKindOf(f) === "file" ? " \u2014 a file" : "",
|
|
@@ -7369,7 +7595,7 @@ function TypeQuestions(props) {
|
|
|
7369
7595
|
] }, f.id)) })
|
|
7370
7596
|
] })
|
|
7371
7597
|
] }),
|
|
7372
|
-
type === "lookup" ? /* @__PURE__ */ (0,
|
|
7598
|
+
type === "lookup" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7373
7599
|
ValueOnTheOtherSide,
|
|
7374
7600
|
{
|
|
7375
7601
|
label: "The value to read",
|
|
@@ -7378,13 +7604,13 @@ function TypeQuestions(props) {
|
|
|
7378
7604
|
value: props.pick,
|
|
7379
7605
|
onChange: props.setPick
|
|
7380
7606
|
}
|
|
7381
|
-
) : type === "count" ? null : /* @__PURE__ */ (0,
|
|
7382
|
-
/* @__PURE__ */ (0,
|
|
7383
|
-
/* @__PURE__ */ (0,
|
|
7384
|
-
/* @__PURE__ */ (0,
|
|
7385
|
-
/* @__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)) })
|
|
7386
7612
|
] }),
|
|
7387
|
-
props.agg !== "count" ? /* @__PURE__ */ (0,
|
|
7613
|
+
props.agg !== "count" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7388
7614
|
ValueOnTheOtherSide,
|
|
7389
7615
|
{
|
|
7390
7616
|
label: "Of which value",
|
|
@@ -7400,22 +7626,22 @@ function TypeQuestions(props) {
|
|
|
7400
7626
|
}
|
|
7401
7627
|
if (type === "formula") {
|
|
7402
7628
|
if (props.others.length === 0) {
|
|
7403
|
-
return /* @__PURE__ */ (0,
|
|
7629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No other columns yet." });
|
|
7404
7630
|
}
|
|
7405
|
-
return /* @__PURE__ */ (0,
|
|
7406
|
-
/* @__PURE__ */ (0,
|
|
7407
|
-
/* @__PURE__ */ (0,
|
|
7408
|
-
/* @__PURE__ */ (0,
|
|
7409
|
-
/* @__PURE__ */ (0,
|
|
7410
|
-
/* @__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)) })
|
|
7411
7637
|
] })
|
|
7412
7638
|
] }),
|
|
7413
|
-
/* @__PURE__ */ (0,
|
|
7414
|
-
/* @__PURE__ */ (0,
|
|
7415
|
-
/* @__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) => {
|
|
7416
7642
|
const picked = props.formulaFields.includes(f.id);
|
|
7417
|
-
return /* @__PURE__ */ (0,
|
|
7418
|
-
|
|
7643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7644
|
+
import_design_system30.Button,
|
|
7419
7645
|
{
|
|
7420
7646
|
type: "button",
|
|
7421
7647
|
size: "sm",
|
|
@@ -7429,10 +7655,10 @@ function TypeQuestions(props) {
|
|
|
7429
7655
|
);
|
|
7430
7656
|
}) })
|
|
7431
7657
|
] }),
|
|
7432
|
-
props.formulaOp === "concat" ? /* @__PURE__ */ (0,
|
|
7433
|
-
/* @__PURE__ */ (0,
|
|
7434
|
-
/* @__PURE__ */ (0,
|
|
7435
|
-
|
|
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,
|
|
7436
7662
|
{
|
|
7437
7663
|
value: props.formulaSeparator,
|
|
7438
7664
|
"aria-label": FORMULA_SEPARATOR_LABEL,
|
|
@@ -7481,26 +7707,26 @@ function RollupFilterQuestion({
|
|
|
7481
7707
|
onChange
|
|
7482
7708
|
}) {
|
|
7483
7709
|
const far = relation?.relation_target ?? null;
|
|
7484
|
-
const farFields = (0,
|
|
7485
|
-
const conditionFields = (0,
|
|
7710
|
+
const farFields = (0, import_react47.useFields)(far);
|
|
7711
|
+
const conditionFields = (0, import_react46.useMemo)(
|
|
7486
7712
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7487
7713
|
[farFields.data]
|
|
7488
7714
|
);
|
|
7489
|
-
const lastFar = (0,
|
|
7490
|
-
(0,
|
|
7715
|
+
const lastFar = (0, import_react46.useRef)(far);
|
|
7716
|
+
(0, import_react46.useEffect)(() => {
|
|
7491
7717
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7492
7718
|
lastFar.current = far;
|
|
7493
7719
|
}, [far, editing, onChange]);
|
|
7494
7720
|
if (!relation || !far) return null;
|
|
7495
|
-
return /* @__PURE__ */ (0,
|
|
7496
|
-
/* @__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: [
|
|
7497
7723
|
rollupFilterLead(agg),
|
|
7498
7724
|
" ",
|
|
7499
7725
|
conditionInWords(value, conditionFields),
|
|
7500
7726
|
"."
|
|
7501
7727
|
] }),
|
|
7502
|
-
/* @__PURE__ */ (0,
|
|
7503
|
-
] }) : /* @__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)(
|
|
7504
7730
|
ConditionGroup,
|
|
7505
7731
|
{
|
|
7506
7732
|
lead: rollupFilterLead(agg),
|
|
@@ -7520,19 +7746,19 @@ function ValueOnTheOtherSide({
|
|
|
7520
7746
|
compact
|
|
7521
7747
|
}) {
|
|
7522
7748
|
const target = relation?.relation_target ?? null;
|
|
7523
|
-
const columns = (0,
|
|
7749
|
+
const columns = (0, import_react47.useFields)(target);
|
|
7524
7750
|
const declared = (columns.data ?? []).filter((f) => f.type !== "formula");
|
|
7525
|
-
const sample = (0,
|
|
7751
|
+
const sample = (0, import_react47.useRecords)(declared.length === 0 && !columns.loading ? target : null, { pageSize: 1 });
|
|
7526
7752
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7527
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) }));
|
|
7528
7754
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
7529
|
-
const body = !relation ? /* @__PURE__ */ (0,
|
|
7530
|
-
/* @__PURE__ */ (0,
|
|
7531
|
-
/* @__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)) })
|
|
7532
7758
|
] });
|
|
7533
|
-
if (compact) return /* @__PURE__ */ (0,
|
|
7534
|
-
return /* @__PURE__ */ (0,
|
|
7535
|
-
/* @__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 }),
|
|
7536
7762
|
body
|
|
7537
7763
|
] });
|
|
7538
7764
|
}
|
|
@@ -7558,19 +7784,19 @@ function NewColumnDefault({
|
|
|
7558
7784
|
onChange
|
|
7559
7785
|
}) {
|
|
7560
7786
|
const none = "__none__";
|
|
7561
|
-
return /* @__PURE__ */ (0,
|
|
7562
|
-
/* @__PURE__ */ (0,
|
|
7563
|
-
type === "checkbox" ? /* @__PURE__ */ (0,
|
|
7564
|
-
/* @__PURE__ */ (0,
|
|
7565
|
-
/* @__PURE__ */ (0,
|
|
7566
|
-
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */ (0,
|
|
7567
|
-
/* @__PURE__ */ (0,
|
|
7568
|
-
/* @__PURE__ */ (0,
|
|
7569
|
-
/* @__PURE__ */ (0,
|
|
7570
|
-
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))
|
|
7571
7797
|
] })
|
|
7572
|
-
] }) : /* @__PURE__ */ (0,
|
|
7573
|
-
|
|
7798
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
7799
|
+
import_design_system30.BasicInput,
|
|
7574
7800
|
{
|
|
7575
7801
|
id: "records-new-field-default",
|
|
7576
7802
|
value: typeof value === "string" ? value : value === null || value === void 0 ? "" : String(value),
|
|
@@ -7584,7 +7810,7 @@ function NewColumnDefault({
|
|
|
7584
7810
|
// src/buttonCell.tsx
|
|
7585
7811
|
var import_outbound_react6 = require("@ai-matrx/kit/outbound-react");
|
|
7586
7812
|
var import_outbound = require("@ai-matrx/kit/outbound");
|
|
7587
|
-
var
|
|
7813
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7588
7814
|
function buttonPressWords(label, pressed) {
|
|
7589
7815
|
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
7590
7816
|
if (pressed.do === "run_action") {
|
|
@@ -7596,14 +7822,14 @@ function buttonPressWords(label, pressed) {
|
|
|
7596
7822
|
}
|
|
7597
7823
|
var stop = (event) => event.stopPropagation();
|
|
7598
7824
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7599
|
-
const client = (0,
|
|
7600
|
-
const b = (0,
|
|
7601
|
-
const [busy, setBusy] = (0,
|
|
7602
|
-
const [said2, setSaid] = (0,
|
|
7603
|
-
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);
|
|
7604
7830
|
if (!b) return null;
|
|
7605
7831
|
const color = (0, import_data_table6.isStyleColor)(b.color) ? import_data_table6.CHOICE_CHIP_CLASS[b.color] : import_data_table6.NEUTRAL_CHIP_CLASS;
|
|
7606
|
-
const needs = (0,
|
|
7832
|
+
const needs = (0, import_records27.buttonNeeds)(b);
|
|
7607
7833
|
const tableId = field.entity_definition_id;
|
|
7608
7834
|
const press = async () => {
|
|
7609
7835
|
if (!client || !recordId) return setSaid({ kind: "public" });
|
|
@@ -7619,10 +7845,10 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7619
7845
|
}
|
|
7620
7846
|
setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
|
|
7621
7847
|
};
|
|
7622
|
-
return /* @__PURE__ */ (0,
|
|
7623
|
-
/* @__PURE__ */ (0,
|
|
7624
|
-
/* @__PURE__ */ (0,
|
|
7625
|
-
|
|
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,
|
|
7626
7852
|
{
|
|
7627
7853
|
type: "button",
|
|
7628
7854
|
size: "xs",
|
|
@@ -7631,7 +7857,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7631
7857
|
"data-records-button-unset": needs ? "" : void 0,
|
|
7632
7858
|
"aria-busy": busy || void 0,
|
|
7633
7859
|
disabled: busy,
|
|
7634
|
-
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"),
|
|
7635
7861
|
onPointerDown: stop,
|
|
7636
7862
|
onDoubleClick: stop,
|
|
7637
7863
|
onClick: (event) => {
|
|
@@ -7639,21 +7865,21 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7639
7865
|
event.preventDefault();
|
|
7640
7866
|
void press();
|
|
7641
7867
|
},
|
|
7642
|
-
children: /* @__PURE__ */ (0,
|
|
7868
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "truncate", children: b.label })
|
|
7643
7869
|
}
|
|
7644
7870
|
) }),
|
|
7645
|
-
/* @__PURE__ */ (0,
|
|
7646
|
-
said2?.kind === "refused" ? /* @__PURE__ */ (0,
|
|
7647
|
-
said2?.kind === "public" ? /* @__PURE__ */ (0,
|
|
7648
|
-
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: [
|
|
7649
7875
|
said2.says,
|
|
7650
7876
|
" ",
|
|
7651
|
-
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
|
|
7652
7878
|
] }) : null,
|
|
7653
|
-
said2?.kind === "needs" ? /* @__PURE__ */ (0,
|
|
7654
|
-
/* @__PURE__ */ (0,
|
|
7655
|
-
tableId ? /* @__PURE__ */ (0,
|
|
7656
|
-
|
|
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,
|
|
7657
7883
|
{
|
|
7658
7884
|
type: "button",
|
|
7659
7885
|
size: "sm",
|
|
@@ -7671,202 +7897,16 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7671
7897
|
] }) : null
|
|
7672
7898
|
] })
|
|
7673
7899
|
] }),
|
|
7674
|
-
settingUp && tableId ? /* @__PURE__ */ (0,
|
|
7675
|
-
/* @__PURE__ */ (0,
|
|
7676
|
-
/* @__PURE__ */ (0,
|
|
7677
|
-
/* @__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" })
|
|
7678
7904
|
] }),
|
|
7679
|
-
/* @__PURE__ */ (0,
|
|
7905
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(FieldEditor, { tableId, field, onSaved: () => setSettingUp(false), onCancel: () => setSettingUp(false) })
|
|
7680
7906
|
] }) }) : null
|
|
7681
7907
|
] });
|
|
7682
7908
|
}
|
|
7683
7909
|
|
|
7684
|
-
// src/PersonPicker.tsx
|
|
7685
|
-
var import_react48 = require("react");
|
|
7686
|
-
var import_records27 = require("@ai-matrx/records");
|
|
7687
|
-
var import_react49 = require("@ai-matrx/records/react");
|
|
7688
|
-
var import_design_system31 = require("@ai-matrx/design-system");
|
|
7689
|
-
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7690
|
-
function personFromRow(row) {
|
|
7691
|
-
const data = row.document ?? {};
|
|
7692
|
-
const userId = data["user_id"];
|
|
7693
|
-
return {
|
|
7694
|
-
id: row.id,
|
|
7695
|
-
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
7696
|
-
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
7697
|
-
};
|
|
7698
|
-
}
|
|
7699
|
-
function memberName(member) {
|
|
7700
|
-
const display = (member.name ?? "").trim();
|
|
7701
|
-
if (display !== "") return display;
|
|
7702
|
-
const email = (member.email ?? "").trim();
|
|
7703
|
-
if (email !== "") return email;
|
|
7704
|
-
return "A member with no name set";
|
|
7705
|
-
}
|
|
7706
|
-
async function personRecordForMember(client, personTableId, people, member) {
|
|
7707
|
-
const held = people.find((p) => p.userId === member.userId);
|
|
7708
|
-
if (held) return { ok: true, data: held.id };
|
|
7709
|
-
const written = await client.recordWrite({
|
|
7710
|
-
table_id: personTableId,
|
|
7711
|
-
data: {
|
|
7712
|
-
user_id: member.userId,
|
|
7713
|
-
full_name: memberName(member),
|
|
7714
|
-
...member.email ? { email: member.email } : {}
|
|
7715
|
-
}
|
|
7716
|
-
});
|
|
7717
|
-
return written;
|
|
7718
|
-
}
|
|
7719
|
-
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
7720
|
-
const client = (0, import_react49.useOptionalRecordsClient)();
|
|
7721
|
-
const host = useRecordsUi();
|
|
7722
|
-
const [members, setMembers] = (0, import_react48.useState)(null);
|
|
7723
|
-
const [people, setPeople] = (0, import_react48.useState)([]);
|
|
7724
|
-
const [error, setError] = (0, import_react48.useState)(null);
|
|
7725
|
-
const [search, setSearch] = (0, import_react48.useState)(initialSearch ?? "");
|
|
7726
|
-
const [open, setOpenState] = (0, import_react48.useState)(autoOpen === true);
|
|
7727
|
-
const onCloseRef = (0, import_react48.useRef)(onClose);
|
|
7728
|
-
onCloseRef.current = onClose;
|
|
7729
|
-
const setOpen = (0, import_react48.useCallback)((next) => {
|
|
7730
|
-
setOpenState(next);
|
|
7731
|
-
if (!next) onCloseRef.current?.();
|
|
7732
|
-
}, []);
|
|
7733
|
-
const [busy, setBusy] = (0, import_react48.useState)(false);
|
|
7734
|
-
const membersPort = host.members;
|
|
7735
|
-
const personTable = field.relation_target;
|
|
7736
|
-
const picked = (0, import_react48.useMemo)(
|
|
7737
|
-
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
7738
|
-
[value]
|
|
7739
|
-
);
|
|
7740
|
-
const load = (0, import_react48.useCallback)(async () => {
|
|
7741
|
-
if (!membersPort || !client) return;
|
|
7742
|
-
const [roster, records] = await Promise.all([
|
|
7743
|
-
membersPort(),
|
|
7744
|
-
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
7745
|
-
]);
|
|
7746
|
-
setMembers(roster);
|
|
7747
|
-
if (records && !records.ok) {
|
|
7748
|
-
setError(records.error);
|
|
7749
|
-
return;
|
|
7750
|
-
}
|
|
7751
|
-
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
7752
|
-
}, [membersPort, client, personTable]);
|
|
7753
|
-
(0, import_react48.useEffect)(() => {
|
|
7754
|
-
if (!open) return;
|
|
7755
|
-
void load();
|
|
7756
|
-
}, [open, load]);
|
|
7757
|
-
(0, import_react48.useEffect)(() => {
|
|
7758
|
-
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
7759
|
-
let cancelled = false;
|
|
7760
|
-
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
7761
|
-
if (cancelled || !result.ok) return;
|
|
7762
|
-
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
7763
|
-
});
|
|
7764
|
-
return () => {
|
|
7765
|
-
cancelled = true;
|
|
7766
|
-
};
|
|
7767
|
-
}, [client, personTable, picked.length, people.length]);
|
|
7768
|
-
const listed = (0, import_records27.rankTypedMatches)(members ?? [], search, memberName);
|
|
7769
|
-
if (!membersPort || !client) {
|
|
7770
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: (0, import_design_system31.cn)("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
7771
|
-
}
|
|
7772
|
-
if (!personTable) {
|
|
7773
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("p", { className: (0, import_design_system31.cn)("text-xs text-muted-foreground", className), children: [
|
|
7774
|
-
fieldName(field),
|
|
7775
|
-
" 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."
|
|
7776
|
-
] });
|
|
7777
|
-
}
|
|
7778
|
-
const displayNameOf = (userId, recordName2) => {
|
|
7779
|
-
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
7780
|
-
const own3 = (member?.name ?? "").trim();
|
|
7781
|
-
if (own3 !== "") return own3;
|
|
7782
|
-
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
7783
|
-
const email = (member?.email ?? "").trim();
|
|
7784
|
-
return kept !== "" && kept !== email ? kept : null;
|
|
7785
|
-
};
|
|
7786
|
-
const nameOfRecord = (recordId) => {
|
|
7787
|
-
const person = people.find((p) => p.id === recordId);
|
|
7788
|
-
if (!person) return "Loading\u2026";
|
|
7789
|
-
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
7790
|
-
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
7791
|
-
};
|
|
7792
|
-
const pick = async (member) => {
|
|
7793
|
-
setBusy(true);
|
|
7794
|
-
setError(null);
|
|
7795
|
-
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
7796
|
-
setBusy(false);
|
|
7797
|
-
if (!resolved.ok) {
|
|
7798
|
-
setError(resolved.error);
|
|
7799
|
-
return;
|
|
7800
|
-
}
|
|
7801
|
-
if (!people.some((p) => p.id === resolved.data)) {
|
|
7802
|
-
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
7803
|
-
}
|
|
7804
|
-
if (!field.multi) {
|
|
7805
|
-
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
7806
|
-
setOpen(false);
|
|
7807
|
-
return;
|
|
7808
|
-
}
|
|
7809
|
-
const next = new Set(picked);
|
|
7810
|
-
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
7811
|
-
else next.add(resolved.data);
|
|
7812
|
-
onChange(next.size === 0 ? null : [...next]);
|
|
7813
|
-
};
|
|
7814
|
-
const drop = (recordId) => {
|
|
7815
|
-
const next = picked.filter((id2) => id2 !== recordId);
|
|
7816
|
-
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
7817
|
-
};
|
|
7818
|
-
const visible = listed;
|
|
7819
|
-
const pickedUserIds = new Set(
|
|
7820
|
-
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
7821
|
-
);
|
|
7822
|
-
const anchored = autoOpen === true;
|
|
7823
|
-
const cellChips = picked.map((recordId) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
7824
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: (0, import_design_system31.cn)("flex flex-wrap items-center gap-1", className), children: [
|
|
7825
|
-
anchored && !disabled ? null : cellChips,
|
|
7826
|
-
disabled ? null : (
|
|
7827
|
-
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
7828
|
-
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
7829
|
-
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
7830
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7831
|
-
PickOrAdd,
|
|
7832
|
-
{
|
|
7833
|
-
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
7834
|
-
anchored,
|
|
7835
|
-
multi: field.multi,
|
|
7836
|
-
triggerId: id,
|
|
7837
|
-
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
7838
|
-
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
7839
|
-
open,
|
|
7840
|
-
onOpenChange: setOpen,
|
|
7841
|
-
search,
|
|
7842
|
-
onSearch: setSearch,
|
|
7843
|
-
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
7844
|
-
items: visible.map((member) => ({
|
|
7845
|
-
id: member.userId,
|
|
7846
|
-
label: displayNameOf(member.userId) ?? memberName(member),
|
|
7847
|
-
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
7848
|
-
// 19 September). They are two facts, so they are drawn as two.
|
|
7849
|
-
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
7850
|
-
picked: pickedUserIds.has(member.userId),
|
|
7851
|
-
person: true,
|
|
7852
|
-
disabled: busy
|
|
7853
|
-
})),
|
|
7854
|
-
onPick: (userId) => {
|
|
7855
|
-
const member = visible.find((m) => m.userId === userId);
|
|
7856
|
-
if (member && !busy) void pick(member);
|
|
7857
|
-
},
|
|
7858
|
-
notice: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
7859
|
-
error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(RefusalLine, { error, className: "p-2" }) : null,
|
|
7860
|
-
members === null ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
7861
|
-
] }),
|
|
7862
|
-
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,
|
|
7863
|
-
children: anchored ? cellChips : null
|
|
7864
|
-
}
|
|
7865
|
-
)
|
|
7866
|
-
)
|
|
7867
|
-
] });
|
|
7868
|
-
}
|
|
7869
|
-
|
|
7870
7910
|
// src/FloatingRefusal.tsx
|
|
7871
7911
|
var import_react50 = require("react");
|
|
7872
7912
|
var import_react_dom = require("react-dom");
|