@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.js
CHANGED
|
@@ -1461,7 +1461,7 @@ function PersonAvatar({ name, size = "sm" }) {
|
|
|
1461
1461
|
}
|
|
1462
1462
|
);
|
|
1463
1463
|
}
|
|
1464
|
-
function PersonChip({ name, onRemove, className }) {
|
|
1464
|
+
function PersonChip({ name, onRemove, onOpen, className }) {
|
|
1465
1465
|
return /* @__PURE__ */ jsxs6(
|
|
1466
1466
|
"span",
|
|
1467
1467
|
{
|
|
@@ -1470,7 +1470,7 @@ function PersonChip({ name, onRemove, className }) {
|
|
|
1470
1470
|
className: cn5("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),
|
|
1471
1471
|
children: [
|
|
1472
1472
|
/* @__PURE__ */ jsx7(PersonAvatar, { name }),
|
|
1473
|
-
/* @__PURE__ */ jsx7("span", { className: "min-w-0 truncate", children: name }),
|
|
1473
|
+
onOpen ? /* @__PURE__ */ jsx7("button", { type: "button", onClick: onOpen, "data-records-person-open": "", className: "min-w-0 truncate hover:underline", children: name }) : /* @__PURE__ */ jsx7("span", { className: "min-w-0 truncate", children: name }),
|
|
1474
1474
|
onRemove ? /* @__PURE__ */ jsx7("button", { type: "button", onClick: onRemove, "aria-label": `Remove ${name}`, className: "shrink-0 opacity-60 hover:opacity-100", children: "\xD7" }) : null
|
|
1475
1475
|
]
|
|
1476
1476
|
}
|
|
@@ -2045,11 +2045,11 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
2045
2045
|
}
|
|
2046
2046
|
|
|
2047
2047
|
// src/buttonCell.tsx
|
|
2048
|
-
import { useState as
|
|
2049
|
-
import { Button as Button16, Dialog as Dialog2, DialogContent as DialogContent2, DialogDescription, DialogHeader as DialogHeader2, DialogTitle as DialogTitle2, Popover as Popover4, PopoverContent as PopoverContent4, PopoverTrigger as PopoverTrigger4, cn as
|
|
2048
|
+
import { useState as useState25 } from "react";
|
|
2049
|
+
import { Button as Button16, Dialog as Dialog2, DialogContent as DialogContent2, DialogDescription, DialogHeader as DialogHeader2, DialogTitle as DialogTitle2, Popover as Popover4, PopoverContent as PopoverContent4, PopoverTrigger as PopoverTrigger4, cn as cn23 } from "@ai-matrx/design-system";
|
|
2050
2050
|
import { CHOICE_CHIP_CLASS as CHOICE_CHIP_CLASS2, NEUTRAL_CHIP_CLASS as NEUTRAL_CHIP_CLASS2, isStyleColor as isStyleColor2 } from "@ai-matrx/design-system/data-table";
|
|
2051
2051
|
import { buttonNeeds as buttonNeeds2, buttonOf as buttonOf2 } from "@ai-matrx/records";
|
|
2052
|
-
import { useOptionalRecordsClient as
|
|
2052
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient9 } from "@ai-matrx/records/react";
|
|
2053
2053
|
|
|
2054
2054
|
// src/columnName.ts
|
|
2055
2055
|
var said = (name) => name.trim().replace(/\s+/g, " ");
|
|
@@ -2087,7 +2087,7 @@ function columnNameProblemLine(name, noun = "column") {
|
|
|
2087
2087
|
}
|
|
2088
2088
|
|
|
2089
2089
|
// src/FieldEditor.tsx
|
|
2090
|
-
import { useEffect as
|
|
2090
|
+
import { useEffect as useEffect18, useMemo as useMemo11, useRef as useRef13, useState as useState24 } from "react";
|
|
2091
2091
|
import {
|
|
2092
2092
|
tableShapeChanged as tableShapeChanged3,
|
|
2093
2093
|
useEntityFieldMutation,
|
|
@@ -2114,7 +2114,7 @@ import {
|
|
|
2114
2114
|
SelectTrigger as SelectTrigger6,
|
|
2115
2115
|
SelectValue as SelectValue6,
|
|
2116
2116
|
Separator,
|
|
2117
|
-
cn as
|
|
2117
|
+
cn as cn22
|
|
2118
2118
|
} from "@ai-matrx/design-system";
|
|
2119
2119
|
|
|
2120
2120
|
// src/ReferenceBuilder.tsx
|
|
@@ -2834,14 +2834,14 @@ function EntityReferenceKindPicker({ value, onChange, locked = false, className
|
|
|
2834
2834
|
}
|
|
2835
2835
|
|
|
2836
2836
|
// src/SourceArchivedNotice.tsx
|
|
2837
|
-
import { useCallback as
|
|
2837
|
+
import { useCallback as useCallback6, useEffect as useEffect13, useState as useState19 } from "react";
|
|
2838
2838
|
import { Button as Button11 } from "@ai-matrx/design-system";
|
|
2839
2839
|
import { tableShapeChanged, useRecordsClient as useRecordsClient6 } from "@ai-matrx/records/react";
|
|
2840
2840
|
|
|
2841
2841
|
// src/values.tsx
|
|
2842
2842
|
import { SWATCH_CLASS as SWATCH_CLASS2, formatColumnValue } from "@ai-matrx/design-system/data-table";
|
|
2843
2843
|
import { formatFieldValue as formatFieldValue3 } from "@ai-matrx/design-system/field-formats";
|
|
2844
|
-
import { Badge as Badge5, cn as
|
|
2844
|
+
import { Badge as Badge5, cn as cn20 } from "@ai-matrx/design-system";
|
|
2845
2845
|
|
|
2846
2846
|
// src/embeddedLook.tsx
|
|
2847
2847
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
@@ -4066,23 +4066,24 @@ function useFileRead(id) {
|
|
|
4066
4066
|
useEffect11(() => {
|
|
4067
4067
|
let cancelled = false;
|
|
4068
4068
|
if (handedHostFileIds.has(id)) {
|
|
4069
|
-
setRead({ name: null, fileId: id, why: null });
|
|
4069
|
+
setRead({ name: null, fileId: id, why: null, mime: null });
|
|
4070
4070
|
return;
|
|
4071
4071
|
}
|
|
4072
4072
|
if (!client) {
|
|
4073
|
-
setRead({ name: null, fileId: null, why: null });
|
|
4073
|
+
setRead({ name: null, fileId: null, why: null, mime: null });
|
|
4074
4074
|
return;
|
|
4075
4075
|
}
|
|
4076
4076
|
void client.recordRead({ record_id: id }).then((answered) => {
|
|
4077
4077
|
if (cancelled) return;
|
|
4078
4078
|
if (!answered.ok) {
|
|
4079
|
-
setRead({ name: null, fileId: id, why: refusalSentence(answered.error) });
|
|
4079
|
+
setRead({ name: null, fileId: id, why: refusalSentence(answered.error), mime: null });
|
|
4080
4080
|
return;
|
|
4081
4081
|
}
|
|
4082
4082
|
const doc = answered.data.document ?? {};
|
|
4083
4083
|
const fileId = typeof doc["file_id"] === "string" ? doc["file_id"] : null;
|
|
4084
4084
|
const name = typeof doc["name"] === "string" && doc["name"] !== "" ? doc["name"] : null;
|
|
4085
|
-
|
|
4085
|
+
const mime = typeof doc["mime"] === "string" ? doc["mime"] : null;
|
|
4086
|
+
setRead({ name, fileId, why: null, mime });
|
|
4086
4087
|
});
|
|
4087
4088
|
return () => {
|
|
4088
4089
|
cancelled = true;
|
|
@@ -4096,6 +4097,43 @@ function AttachmentChip({ id, onRemove, onPreview }) {
|
|
|
4096
4097
|
const words = read?.name ?? (read ? FILE_CHIP_UNREAD : "\u2026");
|
|
4097
4098
|
const href = read?.fileId ? host.hrefForFile?.({ fileId: read.fileId }) : void 0;
|
|
4098
4099
|
const title = onPreview ? `Preview ${words}` : href ? `Open ${words}` : read?.why ?? FILE_CHIP_NO_PAGE;
|
|
4100
|
+
if (read?.fileId && read.mime?.startsWith("image/") && host.fileImage) {
|
|
4101
|
+
return /* @__PURE__ */ jsxs19("span", { className: "relative inline-flex shrink-0", "data-records-file-thumb": id, children: [
|
|
4102
|
+
/* @__PURE__ */ jsx21(
|
|
4103
|
+
"button",
|
|
4104
|
+
{
|
|
4105
|
+
type: "button",
|
|
4106
|
+
title,
|
|
4107
|
+
"aria-label": onPreview ? `Preview ${words}` : words,
|
|
4108
|
+
className: cn17(
|
|
4109
|
+
"relative block size-20 overflow-hidden rounded-md border bg-muted",
|
|
4110
|
+
"[[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"
|
|
4111
|
+
),
|
|
4112
|
+
onClick: (event) => {
|
|
4113
|
+
event.stopPropagation();
|
|
4114
|
+
onPreview?.();
|
|
4115
|
+
},
|
|
4116
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
4117
|
+
onDoubleClick: (event) => event.stopPropagation(),
|
|
4118
|
+
...onPreview ? { "data-records-file-preview": id } : {},
|
|
4119
|
+
children: host.fileImage({ fileId: read.fileId, alt: words })
|
|
4120
|
+
}
|
|
4121
|
+
),
|
|
4122
|
+
onRemove ? /* @__PURE__ */ jsx21(
|
|
4123
|
+
"button",
|
|
4124
|
+
{
|
|
4125
|
+
type: "button",
|
|
4126
|
+
"aria-label": `Remove ${words}`,
|
|
4127
|
+
className: "absolute -right-1 -top-1 rounded-full border bg-background px-1 text-[10px] leading-4 text-muted-foreground hover:text-foreground",
|
|
4128
|
+
onClick: (event) => {
|
|
4129
|
+
event.stopPropagation();
|
|
4130
|
+
onRemove();
|
|
4131
|
+
},
|
|
4132
|
+
children: "\xD7"
|
|
4133
|
+
}
|
|
4134
|
+
) : null
|
|
4135
|
+
] });
|
|
4136
|
+
}
|
|
4099
4137
|
return /* @__PURE__ */ jsxs19(
|
|
4100
4138
|
Badge3,
|
|
4101
4139
|
{
|
|
@@ -4528,11 +4566,199 @@ function formulaSourceArchived(field, document2) {
|
|
|
4528
4566
|
|
|
4529
4567
|
// src/values.tsx
|
|
4530
4568
|
import { autonumberPrefixOf as autonumberPrefixOf2, autonumberWords as autonumberWords2, isButtonField as isButtonField2, newerKindWords, sourceArchivedOf as sourceArchivedOf2 } from "@ai-matrx/records";
|
|
4531
|
-
|
|
4569
|
+
|
|
4570
|
+
// src/PersonPicker.tsx
|
|
4571
|
+
import { useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo9, useRef as useRef11, useState as useState18 } from "react";
|
|
4572
|
+
import { rankTypedMatches as rankTypedMatches2 } from "@ai-matrx/records";
|
|
4573
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient6 } from "@ai-matrx/records/react";
|
|
4574
|
+
import { cn as cn19 } from "@ai-matrx/design-system";
|
|
4532
4575
|
import { Fragment as Fragment7, jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4576
|
+
function personFromRow(row) {
|
|
4577
|
+
const data = row.document ?? {};
|
|
4578
|
+
const userId = data["user_id"];
|
|
4579
|
+
return {
|
|
4580
|
+
id: row.id,
|
|
4581
|
+
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
4582
|
+
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
4583
|
+
};
|
|
4584
|
+
}
|
|
4585
|
+
function memberName(member) {
|
|
4586
|
+
const display = (member.name ?? "").trim();
|
|
4587
|
+
if (display !== "") return display;
|
|
4588
|
+
const email = (member.email ?? "").trim();
|
|
4589
|
+
if (email !== "") return email;
|
|
4590
|
+
return "A member with no name set";
|
|
4591
|
+
}
|
|
4592
|
+
async function personRecordForMember(client, personTableId, people, member) {
|
|
4593
|
+
const held = people.find((p) => p.userId === member.userId);
|
|
4594
|
+
if (held) return { ok: true, data: held.id };
|
|
4595
|
+
const written = await client.recordWrite({
|
|
4596
|
+
table_id: personTableId,
|
|
4597
|
+
data: {
|
|
4598
|
+
user_id: member.userId,
|
|
4599
|
+
full_name: memberName(member),
|
|
4600
|
+
...member.email ? { email: member.email } : {}
|
|
4601
|
+
}
|
|
4602
|
+
});
|
|
4603
|
+
return written;
|
|
4604
|
+
}
|
|
4605
|
+
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
4606
|
+
const client = useOptionalRecordsClient6();
|
|
4607
|
+
const host = useRecordsUi();
|
|
4608
|
+
const [members, setMembers] = useState18(null);
|
|
4609
|
+
const [people, setPeople] = useState18([]);
|
|
4610
|
+
const [error, setError] = useState18(null);
|
|
4611
|
+
const [search, setSearch] = useState18(initialSearch ?? "");
|
|
4612
|
+
const [open, setOpenState] = useState18(autoOpen === true);
|
|
4613
|
+
const onCloseRef = useRef11(onClose);
|
|
4614
|
+
onCloseRef.current = onClose;
|
|
4615
|
+
const setOpen = useCallback5((next) => {
|
|
4616
|
+
setOpenState(next);
|
|
4617
|
+
if (!next) onCloseRef.current?.();
|
|
4618
|
+
}, []);
|
|
4619
|
+
const [busy, setBusy] = useState18(false);
|
|
4620
|
+
const membersPort = host.members;
|
|
4621
|
+
const personTable = field.relation_target;
|
|
4622
|
+
const picked = useMemo9(
|
|
4623
|
+
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
4624
|
+
[value]
|
|
4625
|
+
);
|
|
4626
|
+
const load = useCallback5(async () => {
|
|
4627
|
+
if (!membersPort || !client) return;
|
|
4628
|
+
const [roster, records] = await Promise.all([
|
|
4629
|
+
membersPort(),
|
|
4630
|
+
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
4631
|
+
]);
|
|
4632
|
+
setMembers(roster);
|
|
4633
|
+
if (records && !records.ok) {
|
|
4634
|
+
setError(records.error);
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4637
|
+
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
4638
|
+
}, [membersPort, client, personTable]);
|
|
4639
|
+
useEffect12(() => {
|
|
4640
|
+
if (!open) return;
|
|
4641
|
+
void load();
|
|
4642
|
+
}, [open, load]);
|
|
4643
|
+
useEffect12(() => {
|
|
4644
|
+
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
4645
|
+
let cancelled = false;
|
|
4646
|
+
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
4647
|
+
if (cancelled || !result.ok) return;
|
|
4648
|
+
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
4649
|
+
});
|
|
4650
|
+
return () => {
|
|
4651
|
+
cancelled = true;
|
|
4652
|
+
};
|
|
4653
|
+
}, [client, personTable, picked.length, people.length]);
|
|
4654
|
+
const listed = rankTypedMatches2(members ?? [], search, memberName);
|
|
4655
|
+
if (!membersPort || !client) {
|
|
4656
|
+
return /* @__PURE__ */ jsx23("p", { className: cn19("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
4657
|
+
}
|
|
4658
|
+
if (!personTable) {
|
|
4659
|
+
return /* @__PURE__ */ jsxs21("p", { className: cn19("text-xs text-muted-foreground", className), children: [
|
|
4660
|
+
fieldName(field),
|
|
4661
|
+
" 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."
|
|
4662
|
+
] });
|
|
4663
|
+
}
|
|
4664
|
+
const displayNameOf = (userId, recordName2) => {
|
|
4665
|
+
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
4666
|
+
const own3 = (member?.name ?? "").trim();
|
|
4667
|
+
if (own3 !== "") return own3;
|
|
4668
|
+
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
4669
|
+
const email = (member?.email ?? "").trim();
|
|
4670
|
+
return kept !== "" && kept !== email ? kept : null;
|
|
4671
|
+
};
|
|
4672
|
+
const nameOfRecord = (recordId) => {
|
|
4673
|
+
const person = people.find((p) => p.id === recordId);
|
|
4674
|
+
if (!person) return "Loading\u2026";
|
|
4675
|
+
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
4676
|
+
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
4677
|
+
};
|
|
4678
|
+
const pick = async (member) => {
|
|
4679
|
+
setBusy(true);
|
|
4680
|
+
setError(null);
|
|
4681
|
+
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
4682
|
+
setBusy(false);
|
|
4683
|
+
if (!resolved.ok) {
|
|
4684
|
+
setError(resolved.error);
|
|
4685
|
+
return;
|
|
4686
|
+
}
|
|
4687
|
+
if (!people.some((p) => p.id === resolved.data)) {
|
|
4688
|
+
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
4689
|
+
}
|
|
4690
|
+
if (!field.multi) {
|
|
4691
|
+
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
4692
|
+
setOpen(false);
|
|
4693
|
+
return;
|
|
4694
|
+
}
|
|
4695
|
+
const next = new Set(picked);
|
|
4696
|
+
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
4697
|
+
else next.add(resolved.data);
|
|
4698
|
+
onChange(next.size === 0 ? null : [...next]);
|
|
4699
|
+
};
|
|
4700
|
+
const drop = (recordId) => {
|
|
4701
|
+
const next = picked.filter((id2) => id2 !== recordId);
|
|
4702
|
+
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
4703
|
+
};
|
|
4704
|
+
const visible = listed;
|
|
4705
|
+
const pickedUserIds = new Set(
|
|
4706
|
+
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
4707
|
+
);
|
|
4708
|
+
const anchored = autoOpen === true;
|
|
4709
|
+
const cellChips = picked.map((recordId) => /* @__PURE__ */ jsx23(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
4710
|
+
return /* @__PURE__ */ jsxs21("div", { className: cn19("flex flex-wrap items-center gap-1", className), children: [
|
|
4711
|
+
anchored && !disabled ? null : cellChips,
|
|
4712
|
+
disabled ? null : (
|
|
4713
|
+
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
4714
|
+
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
4715
|
+
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
4716
|
+
/* @__PURE__ */ jsx23(
|
|
4717
|
+
PickOrAdd,
|
|
4718
|
+
{
|
|
4719
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
4720
|
+
anchored,
|
|
4721
|
+
multi: field.multi,
|
|
4722
|
+
triggerId: id,
|
|
4723
|
+
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
4724
|
+
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
4725
|
+
open,
|
|
4726
|
+
onOpenChange: setOpen,
|
|
4727
|
+
search,
|
|
4728
|
+
onSearch: setSearch,
|
|
4729
|
+
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
4730
|
+
items: visible.map((member) => ({
|
|
4731
|
+
id: member.userId,
|
|
4732
|
+
label: displayNameOf(member.userId) ?? memberName(member),
|
|
4733
|
+
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
4734
|
+
// 19 September). They are two facts, so they are drawn as two.
|
|
4735
|
+
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
4736
|
+
picked: pickedUserIds.has(member.userId),
|
|
4737
|
+
person: true,
|
|
4738
|
+
disabled: busy
|
|
4739
|
+
})),
|
|
4740
|
+
onPick: (userId) => {
|
|
4741
|
+
const member = visible.find((m) => m.userId === userId);
|
|
4742
|
+
if (member && !busy) void pick(member);
|
|
4743
|
+
},
|
|
4744
|
+
notice: /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4745
|
+
error ? /* @__PURE__ */ jsx23(RefusalLine, { error, className: "p-2" }) : null,
|
|
4746
|
+
members === null ? /* @__PURE__ */ jsx23("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
4747
|
+
] }),
|
|
4748
|
+
empty: members !== null ? /* @__PURE__ */ jsx23("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,
|
|
4749
|
+
children: anchored ? cellChips : null
|
|
4750
|
+
}
|
|
4751
|
+
)
|
|
4752
|
+
)
|
|
4753
|
+
] });
|
|
4754
|
+
}
|
|
4755
|
+
|
|
4756
|
+
// src/values.tsx
|
|
4757
|
+
import { OutboundLink as OutboundLink5 } from "@ai-matrx/kit/outbound-react";
|
|
4758
|
+
import { Fragment as Fragment8, jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4533
4759
|
function statusMark(field, item, document2) {
|
|
4534
4760
|
const mark = statusMarkOf(field, item, document2);
|
|
4535
|
-
return mark ? /* @__PURE__ */
|
|
4761
|
+
return mark ? /* @__PURE__ */ jsx24("span", { "aria-label": mark.words, title: mark.words, className: "mr-1", "data-records-status-group": mark.group, children: mark.mark }) : null;
|
|
4536
4762
|
}
|
|
4537
4763
|
function envelopeFor(document2, key) {
|
|
4538
4764
|
const block = document2?._values;
|
|
@@ -4578,48 +4804,48 @@ function sourceArchivedSentence(state2) {
|
|
|
4578
4804
|
return state2.table ? `${state2.label} on ${state2.table} is archived` : `${state2.label} is archived`;
|
|
4579
4805
|
}
|
|
4580
4806
|
function SourceArchivedValue({ state: state2 }) {
|
|
4581
|
-
return /* @__PURE__ */
|
|
4807
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-xs italic text-muted-foreground", title: sourceArchivedSentence(state2), "data-records-source-archived": state2.field_id ?? "", children: SOURCE_ARCHIVED_WORDS });
|
|
4582
4808
|
}
|
|
4583
4809
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4584
4810
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4585
4811
|
const archivedSource = sourceArchivedOf2(value);
|
|
4586
|
-
if (archivedSource) return /* @__PURE__ */
|
|
4812
|
+
if (archivedSource) return /* @__PURE__ */ jsx24(SourceArchivedValue, { state: archivedSource });
|
|
4587
4813
|
const envelope = envelopeFor(document2, field.key);
|
|
4588
4814
|
if (envelope?.absent) {
|
|
4589
|
-
return /* @__PURE__ */
|
|
4815
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-xs italic text-muted-foreground", title: `VAL-2: ${envelope.absent}`, children: ABSENCE_WORDS[String(envelope.absent)] ?? String(envelope.absent) });
|
|
4590
4816
|
}
|
|
4591
4817
|
if (value === null || value === void 0 || value === "") {
|
|
4592
4818
|
const gone = unresolvedFor(document2, field.key);
|
|
4593
4819
|
if (gone) {
|
|
4594
|
-
return /* @__PURE__ */
|
|
4820
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-xs italic text-muted-foreground", title: `It pointed at ${gone}`, children: "The record this pointed at no longer exists" });
|
|
4595
4821
|
}
|
|
4596
4822
|
const archivedInput = formulaSourceArchived(field, document2);
|
|
4597
|
-
if (archivedInput) return /* @__PURE__ */
|
|
4823
|
+
if (archivedInput) return /* @__PURE__ */ jsx24(SourceArchivedValue, { state: archivedInput });
|
|
4598
4824
|
const computed = computedEmptyOf(field, document2);
|
|
4599
|
-
if (computed?.sentence) return /* @__PURE__ */
|
|
4600
|
-
if (computed?.words) return /* @__PURE__ */
|
|
4825
|
+
if (computed?.sentence) return /* @__PURE__ */ jsx24("span", { className: "text-xs italic text-muted-foreground", children: computed.sentence });
|
|
4826
|
+
if (computed?.words) return /* @__PURE__ */ jsx24("span", { "data-records-empty-why": computed.kind, children: computed.words });
|
|
4601
4827
|
if (computed?.why) {
|
|
4602
|
-
return /* @__PURE__ */
|
|
4828
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
|
|
4603
4829
|
}
|
|
4604
4830
|
if (look?.blankEmpty) return null;
|
|
4605
|
-
return /* @__PURE__ */
|
|
4831
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4606
4832
|
}
|
|
4607
|
-
if (isSignatureField(field)) return /* @__PURE__ */
|
|
4608
|
-
if (isButtonField2(field)) return /* @__PURE__ */
|
|
4833
|
+
if (isSignatureField(field)) return /* @__PURE__ */ jsx24(SignatureValue, { value, fieldKey: field.key, document: document2 });
|
|
4834
|
+
if (isButtonField2(field)) return /* @__PURE__ */ jsx24(ButtonValue, { field });
|
|
4609
4835
|
const newer = newerKindValue(field, value);
|
|
4610
4836
|
if (newer !== void 0) return newer;
|
|
4611
4837
|
const whole = typeof value === "string" ? wholeValueOf(document2, field.key) : null;
|
|
4612
|
-
if (whole) return /* @__PURE__ */
|
|
4838
|
+
if (whole) return /* @__PURE__ */ jsx24(WholeValueCell, { words: value, pointer: whole });
|
|
4613
4839
|
const kind = editorKindFor(field);
|
|
4614
4840
|
if (kind === "relation" || kind === "entity_reference") {
|
|
4615
|
-
return /* @__PURE__ */
|
|
4841
|
+
return /* @__PURE__ */ jsx24(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
|
|
4616
4842
|
}
|
|
4617
4843
|
if (kind === "member") {
|
|
4618
4844
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4619
|
-
return /* @__PURE__ */
|
|
4845
|
+
return /* @__PURE__ */ jsx24("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-person-chips": "", children: ids.map((id, i) => /* @__PURE__ */ jsx24(PersonChip, { name: scalarText(field, id, labels, stillWaitingFor) }, `${String(id)}-${i}`)) });
|
|
4620
4846
|
}
|
|
4621
4847
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4622
|
-
if (kv) return /* @__PURE__ */
|
|
4848
|
+
if (kv) return /* @__PURE__ */ jsx24(KindValueCell, { kv, where: "cell", title: field.label });
|
|
4623
4849
|
const chosen = kind === "select" || kind === "multi_select";
|
|
4624
4850
|
const chipOf = (item) => {
|
|
4625
4851
|
const chipLook = choiceChipLookOf(field, item, scalarText(field, item, labels));
|
|
@@ -4627,17 +4853,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4627
4853
|
};
|
|
4628
4854
|
if (chosen) {
|
|
4629
4855
|
const items = Array.isArray(value) ? value : [value];
|
|
4630
|
-
return /* @__PURE__ */
|
|
4856
|
+
return /* @__PURE__ */ jsx24("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
|
|
4631
4857
|
const chip = chipOf(item);
|
|
4632
|
-
return /* @__PURE__ */
|
|
4858
|
+
return /* @__PURE__ */ jsxs22(
|
|
4633
4859
|
Badge5,
|
|
4634
4860
|
{
|
|
4635
4861
|
variant: "outline",
|
|
4636
|
-
className:
|
|
4862
|
+
className: cn20("text-[11px]", chip.className),
|
|
4637
4863
|
"data-records-choice-chip": "",
|
|
4638
4864
|
...chip.tinted ? { "data-records-choice-tint": "" } : {},
|
|
4639
4865
|
children: [
|
|
4640
|
-
look?.choiceDot ? /* @__PURE__ */
|
|
4866
|
+
look?.choiceDot ? /* @__PURE__ */ jsx24("span", { "aria-hidden": "true", "data-matrx-pill-ink": "", "data-records-choice-dot": "", className: cn20("mr-1.5 inline-block size-1.5 shrink-0 rounded-full", chip.dot) }) : null,
|
|
4641
4867
|
statusMark(field, item, Array.isArray(value) ? void 0 : document2),
|
|
4642
4868
|
scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
|
|
4643
4869
|
]
|
|
@@ -4646,13 +4872,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4646
4872
|
);
|
|
4647
4873
|
}) });
|
|
4648
4874
|
}
|
|
4649
|
-
if (kind === "attachment") return /* @__PURE__ */
|
|
4875
|
+
if (kind === "attachment") return /* @__PURE__ */ jsx24(AttachmentChips, { value });
|
|
4650
4876
|
if (Array.isArray(value)) {
|
|
4651
|
-
return /* @__PURE__ */
|
|
4877
|
+
return /* @__PURE__ */ jsx24("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ jsx24(Badge5, { variant: "secondary", className: "text-[11px]", children: scalarText(field, item, labels) }, `${String(item)}-${i}`)) });
|
|
4652
4878
|
}
|
|
4653
4879
|
if (kind === "url" && typeof value === "string") {
|
|
4654
4880
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
4655
|
-
return /* @__PURE__ */
|
|
4881
|
+
return /* @__PURE__ */ jsxs22(
|
|
4656
4882
|
OutboundLink5,
|
|
4657
4883
|
{
|
|
4658
4884
|
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",
|
|
@@ -4661,14 +4887,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4661
4887
|
"data-records-link-chip": "",
|
|
4662
4888
|
onClick: (event) => event.stopPropagation(),
|
|
4663
4889
|
children: [
|
|
4664
|
-
/* @__PURE__ */
|
|
4665
|
-
/* @__PURE__ */
|
|
4890
|
+
/* @__PURE__ */ jsx24("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
|
|
4891
|
+
/* @__PURE__ */ jsx24("span", { className: "truncate", children: linkChipText(value) })
|
|
4666
4892
|
]
|
|
4667
4893
|
}
|
|
4668
4894
|
);
|
|
4669
4895
|
}
|
|
4670
4896
|
if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
|
|
4671
|
-
return /* @__PURE__ */
|
|
4897
|
+
return /* @__PURE__ */ jsx24(
|
|
4672
4898
|
"a",
|
|
4673
4899
|
{
|
|
4674
4900
|
className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
|
|
@@ -4681,12 +4907,12 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4681
4907
|
);
|
|
4682
4908
|
}
|
|
4683
4909
|
if (kind === "email" && typeof value === "string") {
|
|
4684
|
-
return /* @__PURE__ */
|
|
4910
|
+
return /* @__PURE__ */ jsx24("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
|
|
4685
4911
|
}
|
|
4686
4912
|
if (typeof value === "boolean") {
|
|
4687
|
-
return /* @__PURE__ */
|
|
4913
|
+
return /* @__PURE__ */ jsx24("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
|
|
4688
4914
|
}
|
|
4689
|
-
return /* @__PURE__ */
|
|
4915
|
+
return /* @__PURE__ */ jsx24("span", { className: cn20("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
|
|
4690
4916
|
}
|
|
4691
4917
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4692
4918
|
if (value === null || value === void 0) return "\u2014";
|
|
@@ -4729,24 +4955,24 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4729
4955
|
}
|
|
4730
4956
|
|
|
4731
4957
|
// src/SourceArchivedNotice.tsx
|
|
4732
|
-
import { jsx as
|
|
4958
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4733
4959
|
function bringBackLabel(state2) {
|
|
4734
4960
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4735
4961
|
}
|
|
4736
4962
|
function SourceArchivedNotice({ fieldId, tableId }) {
|
|
4737
4963
|
const client = useRecordsClient6();
|
|
4738
|
-
const [state2, setState] =
|
|
4739
|
-
const [busy, setBusy] =
|
|
4740
|
-
const [refused, setRefused] =
|
|
4741
|
-
const read =
|
|
4964
|
+
const [state2, setState] = useState19(null);
|
|
4965
|
+
const [busy, setBusy] = useState19(false);
|
|
4966
|
+
const [refused, setRefused] = useState19(null);
|
|
4967
|
+
const read = useCallback6(async () => {
|
|
4742
4968
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4743
4969
|
if (answer.ok) setState(answer.data);
|
|
4744
4970
|
else setRefused(answer.error);
|
|
4745
4971
|
}, [client, fieldId]);
|
|
4746
|
-
|
|
4972
|
+
useEffect13(() => {
|
|
4747
4973
|
void read();
|
|
4748
4974
|
}, [read]);
|
|
4749
|
-
if (refused && !state2) return /* @__PURE__ */
|
|
4975
|
+
if (refused && !state2) return /* @__PURE__ */ jsx25(RefusalNotice, { error: refused });
|
|
4750
4976
|
if (!state2) return null;
|
|
4751
4977
|
const restore = async () => {
|
|
4752
4978
|
if (!state2.field_id) return;
|
|
@@ -4762,29 +4988,29 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4762
4988
|
tableShapeChanged(tableId);
|
|
4763
4989
|
await read();
|
|
4764
4990
|
};
|
|
4765
|
-
return /* @__PURE__ */
|
|
4991
|
+
return /* @__PURE__ */ jsxs23(
|
|
4766
4992
|
"div",
|
|
4767
4993
|
{
|
|
4768
4994
|
className: "flex flex-wrap items-center gap-2 rounded-md border border-border px-3 py-2",
|
|
4769
4995
|
"data-testid": "source-archived-notice",
|
|
4770
4996
|
"data-field-id": state2.field_id ?? "",
|
|
4771
4997
|
children: [
|
|
4772
|
-
/* @__PURE__ */
|
|
4773
|
-
/* @__PURE__ */
|
|
4774
|
-
/* @__PURE__ */
|
|
4998
|
+
/* @__PURE__ */ jsxs23("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
4999
|
+
/* @__PURE__ */ jsx25("span", { className: "text-sm", children: SOURCE_ARCHIVED_WORDS }),
|
|
5000
|
+
/* @__PURE__ */ jsx25("span", { className: "truncate text-xs text-muted-foreground", children: sourceArchivedSentence(state2) })
|
|
4775
5001
|
] }),
|
|
4776
|
-
state2.field_id ? /* @__PURE__ */
|
|
4777
|
-
refused ? /* @__PURE__ */
|
|
5002
|
+
state2.field_id ? /* @__PURE__ */ jsx25(Button11, { type: "button", size: "sm", variant: "secondary", disabled: busy, onClick: () => void restore(), children: bringBackLabel(state2) }) : null,
|
|
5003
|
+
refused ? /* @__PURE__ */ jsx25(RefusalNotice, { error: refused, className: "basis-full" }) : null
|
|
4778
5004
|
]
|
|
4779
5005
|
}
|
|
4780
5006
|
);
|
|
4781
5007
|
}
|
|
4782
5008
|
|
|
4783
5009
|
// src/Condition.tsx
|
|
4784
|
-
import { createContext as createContext4, useContext as useContext4, useEffect as
|
|
5010
|
+
import { createContext as createContext4, useContext as useContext4, useEffect as useEffect14, useState as useState20 } from "react";
|
|
4785
5011
|
import { BasicInput as BasicInput7, Button as Button12 } from "@ai-matrx/design-system";
|
|
4786
|
-
import { optionKey as optionKey2, optionLabel as optionLabel2, rankTypedMatches as
|
|
4787
|
-
import { useOptionalRecordsClient as
|
|
5012
|
+
import { optionKey as optionKey2, optionLabel as optionLabel2, rankTypedMatches as rankTypedMatches3 } from "@ai-matrx/records";
|
|
5013
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient7 } from "@ai-matrx/records/react";
|
|
4788
5014
|
|
|
4789
5015
|
// src/personTime.ts
|
|
4790
5016
|
import { useSyncExternalStore } from "react";
|
|
@@ -4832,7 +5058,7 @@ function usePersonTimeZone() {
|
|
|
4832
5058
|
}
|
|
4833
5059
|
|
|
4834
5060
|
// src/Condition.tsx
|
|
4835
|
-
import { Fragment as
|
|
5061
|
+
import { Fragment as Fragment9, jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4836
5062
|
var CONDITION_OPS = [
|
|
4837
5063
|
{ op: "eq", label: "is" },
|
|
4838
5064
|
{ op: "ne", label: "is not" },
|
|
@@ -4920,11 +5146,11 @@ function isChoiceColumn(f) {
|
|
|
4920
5146
|
return kind === "select" || kind === "multi_select";
|
|
4921
5147
|
}
|
|
4922
5148
|
function ChoiceValue({ field, value, onChange }) {
|
|
4923
|
-
const client =
|
|
4924
|
-
const [choices, setChoices] =
|
|
4925
|
-
const [open, setOpen] =
|
|
4926
|
-
const [search, setSearch] =
|
|
4927
|
-
|
|
5149
|
+
const client = useOptionalRecordsClient7();
|
|
5150
|
+
const [choices, setChoices] = useState20(null);
|
|
5151
|
+
const [open, setOpen] = useState20(false);
|
|
5152
|
+
const [search, setSearch] = useState20("");
|
|
5153
|
+
useEffect14(() => {
|
|
4928
5154
|
if (!client) return;
|
|
4929
5155
|
let cancelled = false;
|
|
4930
5156
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
@@ -4938,7 +5164,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4938
5164
|
};
|
|
4939
5165
|
}, [client, field.id]);
|
|
4940
5166
|
if (!choices || choices.length === 0) {
|
|
4941
|
-
return /* @__PURE__ */
|
|
5167
|
+
return /* @__PURE__ */ jsx26(
|
|
4942
5168
|
BasicInput7,
|
|
4943
5169
|
{
|
|
4944
5170
|
className: "h-8 w-28 text-xs",
|
|
@@ -4948,8 +5174,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4948
5174
|
}
|
|
4949
5175
|
);
|
|
4950
5176
|
}
|
|
4951
|
-
const shown2 =
|
|
4952
|
-
return /* @__PURE__ */
|
|
5177
|
+
const shown2 = rankTypedMatches3(choices, search.trim(), (c) => c.label);
|
|
5178
|
+
return /* @__PURE__ */ jsx26("span", { className: "inline-flex min-w-0", "data-records-condition-choice": "", "data-pick-value": value, children: /* @__PURE__ */ jsx26(
|
|
4953
5179
|
PickOrAdd,
|
|
4954
5180
|
{
|
|
4955
5181
|
triggerSize: "compact",
|
|
@@ -4975,7 +5201,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4975
5201
|
setOpen(false);
|
|
4976
5202
|
setSearch("");
|
|
4977
5203
|
},
|
|
4978
|
-
empty: /* @__PURE__ */
|
|
5204
|
+
empty: /* @__PURE__ */ jsx26("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
|
|
4979
5205
|
}
|
|
4980
5206
|
) });
|
|
4981
5207
|
}
|
|
@@ -5115,9 +5341,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5115
5341
|
VALUELESS_OPS.has(chosenOp) ? { op: chosenOp, args: [{ field: chosenField }] } : { op: chosenOp, args: [{ field: chosenField }, { const: chosenValue }] }
|
|
5116
5342
|
);
|
|
5117
5343
|
}
|
|
5118
|
-
return /* @__PURE__ */
|
|
5119
|
-
/* @__PURE__ */
|
|
5120
|
-
/* @__PURE__ */
|
|
5344
|
+
return /* @__PURE__ */ jsxs24("div", { className: className ?? "flex flex-wrap items-center gap-1 text-xs", children: [
|
|
5345
|
+
/* @__PURE__ */ jsx26("span", { className: "text-muted-foreground", children: lead }),
|
|
5346
|
+
/* @__PURE__ */ jsx26(
|
|
5121
5347
|
PickOne,
|
|
5122
5348
|
{
|
|
5123
5349
|
label: "Condition field",
|
|
@@ -5128,7 +5354,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5128
5354
|
attrs: { "data-condition": "field" }
|
|
5129
5355
|
}
|
|
5130
5356
|
),
|
|
5131
|
-
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */
|
|
5357
|
+
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ jsx26(
|
|
5132
5358
|
"span",
|
|
5133
5359
|
{
|
|
5134
5360
|
className: "rounded bg-destructive px-1.5 py-0.5 text-[11px] font-medium text-destructive-foreground",
|
|
@@ -5137,8 +5363,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5137
5363
|
children: "Missing question"
|
|
5138
5364
|
}
|
|
5139
5365
|
) : null,
|
|
5140
|
-
onField ? /* @__PURE__ */
|
|
5141
|
-
/* @__PURE__ */
|
|
5366
|
+
onField ? /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
5367
|
+
/* @__PURE__ */ jsx26(
|
|
5142
5368
|
PickOne,
|
|
5143
5369
|
{
|
|
5144
5370
|
label: "Condition comparison",
|
|
@@ -5149,7 +5375,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5149
5375
|
attrs: { "data-condition": "comparison" }
|
|
5150
5376
|
}
|
|
5151
5377
|
),
|
|
5152
|
-
relative ? relativeTerm?.takesDays ? /* @__PURE__ */
|
|
5378
|
+
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ jsx26(
|
|
5153
5379
|
BasicInput7,
|
|
5154
5380
|
{
|
|
5155
5381
|
className: "h-8 w-16 text-xs",
|
|
@@ -5166,7 +5392,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5166
5392
|
// is asked for ONE record even when the column holds several: a clause compares
|
|
5167
5393
|
// against one value, and a picker that let somebody choose three would be
|
|
5168
5394
|
// writing an expression this row cannot draw back.
|
|
5169
|
-
/* @__PURE__ */
|
|
5395
|
+
/* @__PURE__ */ jsx26(
|
|
5170
5396
|
RelationPicker,
|
|
5171
5397
|
{
|
|
5172
5398
|
field: { ...chosen.field, multi: false },
|
|
@@ -5177,7 +5403,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5177
5403
|
allowCreate: false
|
|
5178
5404
|
}
|
|
5179
5405
|
)
|
|
5180
|
-
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */
|
|
5406
|
+
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */ jsx26(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ jsx26(
|
|
5181
5407
|
BasicInput7,
|
|
5182
5408
|
{
|
|
5183
5409
|
className: "h-8 w-28 text-xs",
|
|
@@ -5254,7 +5480,7 @@ function ConditionGroup({
|
|
|
5254
5480
|
className
|
|
5255
5481
|
}) {
|
|
5256
5482
|
const { joiner, args } = clausesOf(expr);
|
|
5257
|
-
const [drafting, setDrafting] =
|
|
5483
|
+
const [drafting, setDrafting] = useState20(null);
|
|
5258
5484
|
const nested = depth > 0;
|
|
5259
5485
|
const replaceAt = (index, next) => {
|
|
5260
5486
|
const nextArgs = args.slice();
|
|
@@ -5265,16 +5491,16 @@ function ConditionGroup({
|
|
|
5265
5491
|
const joinWord = (index) => index === 0 ? lead : joiner === "or" || joiner === "none" ? "or" : "and";
|
|
5266
5492
|
const showJoiner = nested || args.length > 1 || joiner === "none" || joiner === "notall";
|
|
5267
5493
|
const opposite = joiner === "or" || joiner === "none" ? "and" : "or";
|
|
5268
|
-
return /* @__PURE__ */
|
|
5494
|
+
return /* @__PURE__ */ jsxs24(
|
|
5269
5495
|
"div",
|
|
5270
5496
|
{
|
|
5271
5497
|
className: className ?? "flex flex-col gap-1 text-xs",
|
|
5272
5498
|
"data-testid": nested ? "condition-nested-group" : "condition-group",
|
|
5273
5499
|
"data-depth": depth,
|
|
5274
5500
|
children: [
|
|
5275
|
-
showJoiner ? /* @__PURE__ */
|
|
5276
|
-
/* @__PURE__ */
|
|
5277
|
-
/* @__PURE__ */
|
|
5501
|
+
showJoiner ? /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-1", children: [
|
|
5502
|
+
/* @__PURE__ */ jsx26("span", { className: "text-muted-foreground", children: nested ? "Group:" : lead }),
|
|
5503
|
+
/* @__PURE__ */ jsx26(
|
|
5278
5504
|
PickOne,
|
|
5279
5505
|
{
|
|
5280
5506
|
label: nested ? `How the conditions in this group are joined (level ${depth + 1})` : "How these conditions are joined",
|
|
@@ -5285,7 +5511,7 @@ function ConditionGroup({
|
|
|
5285
5511
|
attrs: { "data-condition": "joiner" }
|
|
5286
5512
|
}
|
|
5287
5513
|
),
|
|
5288
|
-
nested && onRemove ? /* @__PURE__ */
|
|
5514
|
+
nested && onRemove ? /* @__PURE__ */ jsx26(
|
|
5289
5515
|
Button12,
|
|
5290
5516
|
{
|
|
5291
5517
|
size: "sm",
|
|
@@ -5297,7 +5523,7 @@ function ConditionGroup({
|
|
|
5297
5523
|
}
|
|
5298
5524
|
) : null
|
|
5299
5525
|
] }) : null,
|
|
5300
|
-
args.length === 0 ? /* @__PURE__ */
|
|
5526
|
+
args.length === 0 ? /* @__PURE__ */ jsx26(
|
|
5301
5527
|
ConditionRow,
|
|
5302
5528
|
{
|
|
5303
5529
|
lead,
|
|
@@ -5310,7 +5536,7 @@ function ConditionGroup({
|
|
|
5310
5536
|
const group = conditionGroupOf(arg);
|
|
5311
5537
|
const key = `clause-${index}`;
|
|
5312
5538
|
if (group && allowNesting) {
|
|
5313
|
-
return /* @__PURE__ */
|
|
5539
|
+
return /* @__PURE__ */ jsx26("div", { className: "ml-4 rounded border border-dashed p-1", children: /* @__PURE__ */ jsx26(
|
|
5314
5540
|
ConditionGroup,
|
|
5315
5541
|
{
|
|
5316
5542
|
lead: joinWord(index),
|
|
@@ -5324,7 +5550,7 @@ function ConditionGroup({
|
|
|
5324
5550
|
}
|
|
5325
5551
|
) }, key);
|
|
5326
5552
|
}
|
|
5327
|
-
return /* @__PURE__ */
|
|
5553
|
+
return /* @__PURE__ */ jsx26(
|
|
5328
5554
|
ConditionRow,
|
|
5329
5555
|
{
|
|
5330
5556
|
lead: showJoiner || args.length > 1 ? joinWord(index) : lead,
|
|
@@ -5336,7 +5562,7 @@ function ConditionGroup({
|
|
|
5336
5562
|
key
|
|
5337
5563
|
);
|
|
5338
5564
|
}),
|
|
5339
|
-
drafting ? /* @__PURE__ */
|
|
5565
|
+
drafting ? /* @__PURE__ */ jsx26("div", { className: drafting === "group" ? "ml-4 rounded border border-dashed p-1" : void 0, children: /* @__PURE__ */ jsx26(
|
|
5340
5566
|
ConditionRow,
|
|
5341
5567
|
{
|
|
5342
5568
|
lead: drafting === "group" ? `${joinWord(1)}, a group where` : joinWord(1),
|
|
@@ -5351,8 +5577,8 @@ function ConditionGroup({
|
|
|
5351
5577
|
}
|
|
5352
5578
|
}
|
|
5353
5579
|
) }) : null,
|
|
5354
|
-
args.length > 0 && !drafting ? /* @__PURE__ */
|
|
5355
|
-
/* @__PURE__ */
|
|
5580
|
+
args.length > 0 && !drafting ? /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-1", children: [
|
|
5581
|
+
/* @__PURE__ */ jsx26(
|
|
5356
5582
|
Button12,
|
|
5357
5583
|
{
|
|
5358
5584
|
size: "sm",
|
|
@@ -5363,7 +5589,7 @@ function ConditionGroup({
|
|
|
5363
5589
|
children: "Add another condition"
|
|
5364
5590
|
}
|
|
5365
5591
|
),
|
|
5366
|
-
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */
|
|
5592
|
+
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ jsx26(
|
|
5367
5593
|
Button12,
|
|
5368
5594
|
{
|
|
5369
5595
|
size: "sm",
|
|
@@ -5381,11 +5607,11 @@ function ConditionGroup({
|
|
|
5381
5607
|
}
|
|
5382
5608
|
|
|
5383
5609
|
// src/FieldRetype.tsx
|
|
5384
|
-
import { useEffect as
|
|
5610
|
+
import { useEffect as useEffect15, useState as useState21 } from "react";
|
|
5385
5611
|
import { previewRetype } from "@ai-matrx/records";
|
|
5386
5612
|
import { tableShapeChanged as tableShapeChanged2, useRecordsClient as useRecordsClient7 } from "@ai-matrx/records/react";
|
|
5387
5613
|
import { Button as Button13, Select as Select4, SelectContent as SelectContent4, SelectItem as SelectItem4, SelectTrigger as SelectTrigger4, SelectValue as SelectValue4 } from "@ai-matrx/design-system";
|
|
5388
|
-
import { jsx as
|
|
5614
|
+
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5389
5615
|
var RETYPE_TARGETS = [
|
|
5390
5616
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
5391
5617
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -5433,15 +5659,15 @@ function currentTarget(field) {
|
|
|
5433
5659
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5434
5660
|
const client = useRecordsClient7();
|
|
5435
5661
|
const notify = useRecordsUi().notify;
|
|
5436
|
-
const [to, setTo] =
|
|
5437
|
-
const [preview, setPreview] =
|
|
5438
|
-
const [asking, setAsking] =
|
|
5439
|
-
const [refusal, setRefusal] =
|
|
5440
|
-
const [busy, setBusy] =
|
|
5441
|
-
const [said2, setSaid] =
|
|
5662
|
+
const [to, setTo] = useState21(null);
|
|
5663
|
+
const [preview, setPreview] = useState21(null);
|
|
5664
|
+
const [asking, setAsking] = useState21(false);
|
|
5665
|
+
const [refusal, setRefusal] = useState21(null);
|
|
5666
|
+
const [busy, setBusy] = useState21(false);
|
|
5667
|
+
const [said2, setSaid] = useState21(null);
|
|
5442
5668
|
const name = fieldName(field);
|
|
5443
5669
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5444
|
-
|
|
5670
|
+
useEffect15(() => {
|
|
5445
5671
|
if (!to) return;
|
|
5446
5672
|
let cancelled = false;
|
|
5447
5673
|
setPreview(null);
|
|
@@ -5462,7 +5688,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5462
5688
|
};
|
|
5463
5689
|
}, [client, tableId, field.key, to]);
|
|
5464
5690
|
if (!retypeableFrom(field)) {
|
|
5465
|
-
return /* @__PURE__ */
|
|
5691
|
+
return /* @__PURE__ */ jsx27("p", { className: "text-[11px] text-muted-foreground", "data-records-retype": "not-here", children: whyNotRetypeable(field) });
|
|
5466
5692
|
}
|
|
5467
5693
|
const change = async () => {
|
|
5468
5694
|
if (!to) return;
|
|
@@ -5511,21 +5737,21 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5511
5737
|
tableShapeChanged2(tableId);
|
|
5512
5738
|
onRetyped?.();
|
|
5513
5739
|
};
|
|
5514
|
-
return /* @__PURE__ */
|
|
5515
|
-
/* @__PURE__ */
|
|
5516
|
-
/* @__PURE__ */
|
|
5517
|
-
/* @__PURE__ */
|
|
5518
|
-
/* @__PURE__ */
|
|
5740
|
+
return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
|
|
5741
|
+
/* @__PURE__ */ jsxs25("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5742
|
+
/* @__PURE__ */ jsxs25(Select4, { value: to?.id ?? "", onValueChange: (next) => setTo(targets.find((t) => t.id === next) ?? null), children: [
|
|
5743
|
+
/* @__PURE__ */ jsx27(SelectTrigger4, { size: "sm", "aria-label": "Change what this column holds", className: "w-auto min-w-[12rem]", children: /* @__PURE__ */ jsx27(SelectValue4, { placeholder: "Change what this column holds" }) }),
|
|
5744
|
+
/* @__PURE__ */ jsx27(SelectContent4, { children: targets.map((t) => /* @__PURE__ */ jsx27(SelectItem4, { value: t.id, children: t.label }, t.id)) })
|
|
5519
5745
|
] }),
|
|
5520
|
-
to ? /* @__PURE__ */
|
|
5521
|
-
to ? /* @__PURE__ */
|
|
5746
|
+
to ? /* @__PURE__ */ jsx27(Button13, { size: "sm", disabled: busy || asking || preview === null, onClick: () => void change(), "data-records-retype-go": "", children: busy ? "Changing\u2026" : `Change to ${to.label}` }) : null,
|
|
5747
|
+
to ? /* @__PURE__ */ jsx27(Button13, { size: "sm", variant: "ghost", onClick: () => setTo(null), disabled: busy, children: "Cancel" }) : null
|
|
5522
5748
|
] }),
|
|
5523
|
-
to && asking ? /* @__PURE__ */
|
|
5749
|
+
to && asking ? /* @__PURE__ */ jsxs25("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
5524
5750
|
"Counting ",
|
|
5525
5751
|
name,
|
|
5526
5752
|
"'s values\u2026"
|
|
5527
5753
|
] }) : null,
|
|
5528
|
-
to && preview ? /* @__PURE__ */
|
|
5754
|
+
to && preview ? /* @__PURE__ */ jsxs25("p", { className: "text-[11px] text-muted-foreground", "data-records-retype-preview": "", children: [
|
|
5529
5755
|
preview.converts,
|
|
5530
5756
|
" ",
|
|
5531
5757
|
preview.converts === 1 ? "value converts" : "values convert",
|
|
@@ -5534,16 +5760,16 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5534
5760
|
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(", ")})` : "") : "",
|
|
5535
5761
|
preview.partial ? ". Counted over the first 1,000 different values." : "."
|
|
5536
5762
|
] }) : null,
|
|
5537
|
-
refusal ? /* @__PURE__ */
|
|
5538
|
-
said2 ? /* @__PURE__ */
|
|
5763
|
+
refusal ? /* @__PURE__ */ jsx27(RefusalNotice, { error: refusal }) : null,
|
|
5764
|
+
said2 ? /* @__PURE__ */ jsx27("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-records-retype-done": "", children: said2 }) : null
|
|
5539
5765
|
] });
|
|
5540
5766
|
}
|
|
5541
5767
|
|
|
5542
5768
|
// src/FieldRulePreview.tsx
|
|
5543
|
-
import { useEffect as
|
|
5769
|
+
import { useEffect as useEffect16, useMemo as useMemo10, useRef as useRef12, useState as useState22 } from "react";
|
|
5544
5770
|
import { previewRuleChange } from "@ai-matrx/records";
|
|
5545
5771
|
import { useRecordsClient as useRecordsClient8 } from "@ai-matrx/records/react";
|
|
5546
|
-
import { jsx as
|
|
5772
|
+
import { jsx as jsx28, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5547
5773
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5548
5774
|
function ruleWords(rules) {
|
|
5549
5775
|
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("|");
|
|
@@ -5561,13 +5787,13 @@ function groupValue(value, numbers) {
|
|
|
5561
5787
|
}
|
|
5562
5788
|
function FieldRulePreview({ field, tableId, rules }) {
|
|
5563
5789
|
const client = useRecordsClient8();
|
|
5564
|
-
const [preview, setPreview] =
|
|
5565
|
-
const [refusal, setRefusal] =
|
|
5566
|
-
const key =
|
|
5567
|
-
const latest =
|
|
5790
|
+
const [preview, setPreview] = useState22(null);
|
|
5791
|
+
const [refusal, setRefusal] = useState22(null);
|
|
5792
|
+
const key = useMemo10(() => ruleWords(rules), [rules]);
|
|
5793
|
+
const latest = useRef12(rules);
|
|
5568
5794
|
latest.current = rules;
|
|
5569
5795
|
const name = fieldName(field);
|
|
5570
|
-
|
|
5796
|
+
useEffect16(() => {
|
|
5571
5797
|
let cancelled = false;
|
|
5572
5798
|
setPreview(null);
|
|
5573
5799
|
setRefusal(null);
|
|
@@ -5588,16 +5814,16 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5588
5814
|
clearTimeout(timer);
|
|
5589
5815
|
};
|
|
5590
5816
|
}, [client, tableId, field.key, key]);
|
|
5591
|
-
if (refusal) return /* @__PURE__ */
|
|
5817
|
+
if (refusal) return /* @__PURE__ */ jsx28(RefusalNotice, { error: refusal });
|
|
5592
5818
|
if (!preview) {
|
|
5593
|
-
return /* @__PURE__ */
|
|
5819
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "counting", children: [
|
|
5594
5820
|
"Counting ",
|
|
5595
5821
|
name,
|
|
5596
5822
|
"'s values\u2026"
|
|
5597
5823
|
] });
|
|
5598
5824
|
}
|
|
5599
5825
|
if (preview.keptAside === 0) {
|
|
5600
|
-
return /* @__PURE__ */
|
|
5826
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "fits", children: [
|
|
5601
5827
|
"Every value already in ",
|
|
5602
5828
|
name,
|
|
5603
5829
|
" still fits",
|
|
@@ -5605,7 +5831,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5605
5831
|
"."
|
|
5606
5832
|
] });
|
|
5607
5833
|
}
|
|
5608
|
-
return /* @__PURE__ */
|
|
5834
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-amber-700 dark:text-amber-400", role: "status", "data-records-rule-preview": "sets-aside", children: [
|
|
5609
5835
|
preview.keptAside,
|
|
5610
5836
|
" ",
|
|
5611
5837
|
preview.keptAside === 1 ? "value no longer fits and will be" : "values no longer fit and will be",
|
|
@@ -5695,7 +5921,7 @@ import {
|
|
|
5695
5921
|
statusGroupOf as statusGroupOf2
|
|
5696
5922
|
} from "@ai-matrx/records";
|
|
5697
5923
|
import { Label as Label5, Select as Select5, SelectContent as SelectContent5, SelectItem as SelectItem5, SelectTrigger as SelectTrigger5, SelectValue as SelectValue5 } from "@ai-matrx/design-system";
|
|
5698
|
-
import { jsx as
|
|
5924
|
+
import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5699
5925
|
var STATUS_STARTING_CHOICES = [
|
|
5700
5926
|
{ words: "Not started", group: "todo" },
|
|
5701
5927
|
{ words: "In progress", group: "in_progress" },
|
|
@@ -5724,13 +5950,13 @@ function StatusGroupsQuestion({
|
|
|
5724
5950
|
onGroup
|
|
5725
5951
|
}) {
|
|
5726
5952
|
if (rows.length === 0) return null;
|
|
5727
|
-
return /* @__PURE__ */
|
|
5728
|
-
/* @__PURE__ */
|
|
5729
|
-
rows.map((r) => /* @__PURE__ */
|
|
5730
|
-
/* @__PURE__ */
|
|
5731
|
-
/* @__PURE__ */
|
|
5732
|
-
/* @__PURE__ */
|
|
5733
|
-
/* @__PURE__ */
|
|
5953
|
+
return /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-1", "data-records-status-groups": "", children: [
|
|
5954
|
+
/* @__PURE__ */ jsx29(Label5, { className: "text-xs", children: "Groups" }),
|
|
5955
|
+
rows.map((r) => /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-2", children: [
|
|
5956
|
+
/* @__PURE__ */ jsx29("span", { className: "min-w-0 flex-1 truncate text-sm", children: r.words }),
|
|
5957
|
+
/* @__PURE__ */ jsxs27(Select5, { value: r.group, onValueChange: (next) => onGroup(r.ref, next), children: [
|
|
5958
|
+
/* @__PURE__ */ jsx29(SelectTrigger5, { size: "sm", className: "w-36", "aria-label": `Group for ${r.words}`, children: /* @__PURE__ */ jsx29(SelectValue5, {}) }),
|
|
5959
|
+
/* @__PURE__ */ jsx29(SelectContent5, { children: STATUS_GROUPS.map((g) => /* @__PURE__ */ jsxs27(SelectItem5, { value: g, children: [
|
|
5734
5960
|
STATUS_GROUP_MARK[g],
|
|
5735
5961
|
" ",
|
|
5736
5962
|
STATUS_GROUP_WORDS2[g]
|
|
@@ -5740,11 +5966,11 @@ function StatusGroupsQuestion({
|
|
|
5740
5966
|
] });
|
|
5741
5967
|
}
|
|
5742
5968
|
function RatingMaxQuestion({ value, onChange }) {
|
|
5743
|
-
return /* @__PURE__ */
|
|
5744
|
-
/* @__PURE__ */
|
|
5745
|
-
/* @__PURE__ */
|
|
5746
|
-
/* @__PURE__ */
|
|
5747
|
-
/* @__PURE__ */
|
|
5969
|
+
return /* @__PURE__ */ jsxs27("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
5970
|
+
/* @__PURE__ */ jsx29(Label5, { className: "text-xs", children: "Out of" }),
|
|
5971
|
+
/* @__PURE__ */ jsxs27(Select5, { value: String(value), onValueChange: (next) => onChange(Number(next)), children: [
|
|
5972
|
+
/* @__PURE__ */ jsx29(SelectTrigger5, { size: "sm", "aria-label": "Out of", children: /* @__PURE__ */ jsx29(SelectValue5, {}) }),
|
|
5973
|
+
/* @__PURE__ */ jsx29(SelectContent5, { children: Array.from({ length: 10 }, (_, i) => i + 1).map((n) => /* @__PURE__ */ jsxs27(SelectItem5, { value: String(n), children: [
|
|
5748
5974
|
n,
|
|
5749
5975
|
" ",
|
|
5750
5976
|
n === 1 ? "star" : "stars"
|
|
@@ -5765,13 +5991,13 @@ var SYMBOLOGY_WORDS = {
|
|
|
5765
5991
|
pdf417: "PDF417"
|
|
5766
5992
|
};
|
|
5767
5993
|
function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
5768
|
-
return /* @__PURE__ */
|
|
5769
|
-
/* @__PURE__ */
|
|
5770
|
-
/* @__PURE__ */
|
|
5771
|
-
/* @__PURE__ */
|
|
5772
|
-
/* @__PURE__ */
|
|
5773
|
-
/* @__PURE__ */
|
|
5774
|
-
BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */
|
|
5994
|
+
return /* @__PURE__ */ jsxs27("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
5995
|
+
/* @__PURE__ */ jsx29(Label5, { className: "text-xs", children: "Code type" }),
|
|
5996
|
+
/* @__PURE__ */ jsxs27(Select5, { value: value === "" ? "any" : value, onValueChange: (next) => onChange(next === "any" ? "" : next), children: [
|
|
5997
|
+
/* @__PURE__ */ jsx29(SelectTrigger5, { size: "sm", "aria-label": "Code type", children: /* @__PURE__ */ jsx29(SelectValue5, {}) }),
|
|
5998
|
+
/* @__PURE__ */ jsxs27(SelectContent5, { children: [
|
|
5999
|
+
/* @__PURE__ */ jsx29(SelectItem5, { value: "any", children: "Any code" }),
|
|
6000
|
+
BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */ jsx29(SelectItem5, { value: s, children: SYMBOLOGY_WORDS[s] }, s))
|
|
5775
6001
|
] })
|
|
5776
6002
|
] })
|
|
5777
6003
|
] });
|
|
@@ -5784,7 +6010,7 @@ import {
|
|
|
5784
6010
|
getFieldFormat as getFieldFormat3,
|
|
5785
6011
|
groupedFormatsForBase
|
|
5786
6012
|
} from "@ai-matrx/design-system/field-formats";
|
|
5787
|
-
import { jsx as
|
|
6013
|
+
import { jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5788
6014
|
var KIND_WORD = {
|
|
5789
6015
|
choice: "select",
|
|
5790
6016
|
multi_choice: "multi_select",
|
|
@@ -5907,13 +6133,13 @@ function FieldFormatPicker({
|
|
|
5907
6133
|
else merged[key] = next;
|
|
5908
6134
|
onValue({ ...value, format: Object.keys(merged).length > 0 ? { id: value.format.id, options: merged } : { id: value.format.id } });
|
|
5909
6135
|
};
|
|
5910
|
-
const option = (key, label, control) => optionKeys.includes(key) ? /* @__PURE__ */
|
|
6136
|
+
const option = (key, label, control) => optionKeys.includes(key) ? /* @__PURE__ */ jsxs28("label", { className: "flex min-w-[6rem] flex-col gap-0.5 text-[11px] text-muted-foreground", children: [
|
|
5911
6137
|
label,
|
|
5912
6138
|
control
|
|
5913
6139
|
] }, key) : null;
|
|
5914
|
-
return /* @__PURE__ */
|
|
5915
|
-
/* @__PURE__ */
|
|
5916
|
-
/* @__PURE__ */
|
|
6140
|
+
return /* @__PURE__ */ jsxs28("div", { className: "flex flex-col gap-1", "data-records-format-picker": "", children: [
|
|
6141
|
+
/* @__PURE__ */ jsx30(Label6, { className: "text-xs", htmlFor: `records-shows-as-${field.id}`, children: "Shows as" }),
|
|
6142
|
+
/* @__PURE__ */ jsx30(
|
|
5917
6143
|
PickOne,
|
|
5918
6144
|
{
|
|
5919
6145
|
id: `records-shows-as-${field.id}`,
|
|
@@ -5939,12 +6165,12 @@ function FieldFormatPicker({
|
|
|
5939
6165
|
]
|
|
5940
6166
|
}
|
|
5941
6167
|
),
|
|
5942
|
-
/* @__PURE__ */
|
|
5943
|
-
optionKeys.length > 0 ? /* @__PURE__ */
|
|
6168
|
+
/* @__PURE__ */ jsx30("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." }),
|
|
6169
|
+
optionKeys.length > 0 ? /* @__PURE__ */ jsxs28("div", { className: "flex flex-wrap items-end gap-2", children: [
|
|
5944
6170
|
option(
|
|
5945
6171
|
"currency",
|
|
5946
6172
|
"Currency",
|
|
5947
|
-
/* @__PURE__ */
|
|
6173
|
+
/* @__PURE__ */ jsx30(
|
|
5948
6174
|
PickOne,
|
|
5949
6175
|
{
|
|
5950
6176
|
label: "Currency",
|
|
@@ -5959,7 +6185,7 @@ function FieldFormatPicker({
|
|
|
5959
6185
|
option(
|
|
5960
6186
|
"percentScale",
|
|
5961
6187
|
"Stored as",
|
|
5962
|
-
/* @__PURE__ */
|
|
6188
|
+
/* @__PURE__ */ jsx30(
|
|
5963
6189
|
PickOne,
|
|
5964
6190
|
{
|
|
5965
6191
|
label: "Stored as",
|
|
@@ -5977,7 +6203,7 @@ function FieldFormatPicker({
|
|
|
5977
6203
|
option(
|
|
5978
6204
|
"durationUnit",
|
|
5979
6205
|
"Unit",
|
|
5980
|
-
/* @__PURE__ */
|
|
6206
|
+
/* @__PURE__ */ jsx30(
|
|
5981
6207
|
PickOne,
|
|
5982
6208
|
{
|
|
5983
6209
|
label: "Unit",
|
|
@@ -5997,7 +6223,7 @@ function FieldFormatPicker({
|
|
|
5997
6223
|
option(
|
|
5998
6224
|
"precision",
|
|
5999
6225
|
"Decimals",
|
|
6000
|
-
/* @__PURE__ */
|
|
6226
|
+
/* @__PURE__ */ jsx30(
|
|
6001
6227
|
"input",
|
|
6002
6228
|
{
|
|
6003
6229
|
"data-records-format-option": "precision",
|
|
@@ -6014,7 +6240,7 @@ function FieldFormatPicker({
|
|
|
6014
6240
|
option(
|
|
6015
6241
|
"ratingMax",
|
|
6016
6242
|
"Out of",
|
|
6017
|
-
/* @__PURE__ */
|
|
6243
|
+
/* @__PURE__ */ jsx30(
|
|
6018
6244
|
"input",
|
|
6019
6245
|
{
|
|
6020
6246
|
"data-records-format-option": "ratingMax",
|
|
@@ -6030,7 +6256,7 @@ function FieldFormatPicker({
|
|
|
6030
6256
|
option(
|
|
6031
6257
|
"dateStyle",
|
|
6032
6258
|
"Style",
|
|
6033
|
-
/* @__PURE__ */
|
|
6259
|
+
/* @__PURE__ */ jsx30(
|
|
6034
6260
|
PickOne,
|
|
6035
6261
|
{
|
|
6036
6262
|
label: "Style",
|
|
@@ -6049,15 +6275,15 @@ function FieldFormatPicker({
|
|
|
6049
6275
|
option(
|
|
6050
6276
|
"prefix",
|
|
6051
6277
|
"Prefix",
|
|
6052
|
-
/* @__PURE__ */
|
|
6278
|
+
/* @__PURE__ */ jsx30("input", { "data-records-format-option": "prefix", className: BOX, value: options.prefix ?? "", onChange: (e) => setOption("prefix", e.target.value) })
|
|
6053
6279
|
),
|
|
6054
6280
|
option(
|
|
6055
6281
|
"suffix",
|
|
6056
6282
|
"Suffix",
|
|
6057
|
-
/* @__PURE__ */
|
|
6283
|
+
/* @__PURE__ */ jsx30("input", { "data-records-format-option": "suffix", className: BOX, placeholder: "e.g. kg", value: options.suffix ?? "", onChange: (e) => setOption("suffix", e.target.value) })
|
|
6058
6284
|
),
|
|
6059
|
-
optionKeys.includes("useGrouping") ? /* @__PURE__ */
|
|
6060
|
-
/* @__PURE__ */
|
|
6285
|
+
optionKeys.includes("useGrouping") ? /* @__PURE__ */ jsxs28("label", { className: "flex items-center gap-1.5 pb-1 text-[11px] text-muted-foreground", children: [
|
|
6286
|
+
/* @__PURE__ */ jsx30(
|
|
6061
6287
|
"input",
|
|
6062
6288
|
{
|
|
6063
6289
|
type: "checkbox",
|
|
@@ -6098,34 +6324,34 @@ function nextFieldSort(fields) {
|
|
|
6098
6324
|
import { autonumberPrefixOf as autonumberPrefixOf3, buttonNeeds, buttonOf } from "@ai-matrx/records";
|
|
6099
6325
|
|
|
6100
6326
|
// src/ButtonSettings.tsx
|
|
6101
|
-
import { useEffect as
|
|
6327
|
+
import { useEffect as useEffect17, useState as useState23 } from "react";
|
|
6102
6328
|
import { BasicInput as BasicInput8, Button as Button14, Label as Label7 } from "@ai-matrx/design-system";
|
|
6103
6329
|
import { STYLE_COLORS as STYLE_COLORS3 } from "@ai-matrx/design-system/data-table";
|
|
6104
6330
|
import { buttonUrlPlaceholders } from "@ai-matrx/records";
|
|
6105
|
-
import { useOptionalRecordsClient as
|
|
6331
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient8 } from "@ai-matrx/records/react";
|
|
6106
6332
|
|
|
6107
6333
|
// src/AccentSwatches.tsx
|
|
6108
6334
|
import { PORTAL_ACCENTS } from "@ai-matrx/records";
|
|
6109
|
-
import { cn as
|
|
6335
|
+
import { cn as cn21 } from "@ai-matrx/design-system";
|
|
6110
6336
|
import { STYLE_COLOR_LABELS as STYLE_COLOR_LABELS2, SWATCH_CLASS as SWATCH_CLASS3 } from "@ai-matrx/design-system/data-table";
|
|
6111
|
-
import { jsx as
|
|
6337
|
+
import { jsx as jsx31, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6112
6338
|
function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel = "App colour" }) {
|
|
6113
|
-
return /* @__PURE__ */
|
|
6114
|
-
/* @__PURE__ */
|
|
6339
|
+
return /* @__PURE__ */ jsxs29("div", { className: "flex flex-wrap gap-1.5", role: "radiogroup", "aria-label": "Colour", children: [
|
|
6340
|
+
/* @__PURE__ */ jsx31(
|
|
6115
6341
|
"button",
|
|
6116
6342
|
{
|
|
6117
6343
|
type: "button",
|
|
6118
6344
|
role: "radio",
|
|
6119
6345
|
"aria-checked": value === "",
|
|
6120
6346
|
onClick: () => onChange(""),
|
|
6121
|
-
className:
|
|
6347
|
+
className: cn21(
|
|
6122
6348
|
"h-7 rounded border px-2 text-xs",
|
|
6123
6349
|
value === "" ? "border-foreground" : "border-border text-muted-foreground"
|
|
6124
6350
|
),
|
|
6125
6351
|
children: noneLabel
|
|
6126
6352
|
}
|
|
6127
6353
|
),
|
|
6128
|
-
options.map((c) => /* @__PURE__ */
|
|
6354
|
+
options.map((c) => /* @__PURE__ */ jsx31(
|
|
6129
6355
|
"button",
|
|
6130
6356
|
{
|
|
6131
6357
|
type: "button",
|
|
@@ -6134,7 +6360,7 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
|
|
|
6134
6360
|
"aria-label": STYLE_COLOR_LABELS2[c],
|
|
6135
6361
|
title: STYLE_COLOR_LABELS2[c],
|
|
6136
6362
|
onClick: () => onChange(c),
|
|
6137
|
-
className:
|
|
6363
|
+
className: cn21("h-7 w-7 rounded-full border-2", SWATCH_CLASS3[c], value === c ? "border-foreground" : "border-transparent")
|
|
6138
6364
|
},
|
|
6139
6365
|
c
|
|
6140
6366
|
))
|
|
@@ -6142,7 +6368,7 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
|
|
|
6142
6368
|
}
|
|
6143
6369
|
|
|
6144
6370
|
// src/ButtonSettings.tsx
|
|
6145
|
-
import { jsx as
|
|
6371
|
+
import { jsx as jsx32, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6146
6372
|
var DOES_WORDS = {
|
|
6147
6373
|
none: "Nothing yet",
|
|
6148
6374
|
open_url: "Open a link",
|
|
@@ -6163,11 +6389,11 @@ function ButtonSettingsEditor({
|
|
|
6163
6389
|
tableId,
|
|
6164
6390
|
fields
|
|
6165
6391
|
}) {
|
|
6166
|
-
const client =
|
|
6167
|
-
const [actions, setActions] =
|
|
6168
|
-
const [actionsRefused, setActionsRefused] =
|
|
6169
|
-
const [automations, setAutomations] =
|
|
6170
|
-
|
|
6392
|
+
const client = useOptionalRecordsClient8();
|
|
6393
|
+
const [actions, setActions] = useState23(null);
|
|
6394
|
+
const [actionsRefused, setActionsRefused] = useState23(null);
|
|
6395
|
+
const [automations, setAutomations] = useState23(null);
|
|
6396
|
+
useEffect17(() => {
|
|
6171
6397
|
if (!client || !tableId) return;
|
|
6172
6398
|
let live = true;
|
|
6173
6399
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6188,15 +6414,15 @@ function ButtonSettingsEditor({
|
|
|
6188
6414
|
}, [client, tableId, value.do, actions, automations]);
|
|
6189
6415
|
const set = (patch) => onChange({ ...value, ...patch });
|
|
6190
6416
|
const columns = fields.filter((f) => !(f.type === "text" && f.format === "button"));
|
|
6191
|
-
return /* @__PURE__ */
|
|
6192
|
-
/* @__PURE__ */
|
|
6193
|
-
/* @__PURE__ */
|
|
6194
|
-
/* @__PURE__ */
|
|
6195
|
-
/* @__PURE__ */
|
|
6417
|
+
return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-2 rounded-md border p-2", "data-records-button-settings": "", children: [
|
|
6418
|
+
/* @__PURE__ */ jsxs30("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
6419
|
+
/* @__PURE__ */ jsxs30("label", { className: "flex flex-col gap-1", children: [
|
|
6420
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Button label" }),
|
|
6421
|
+
/* @__PURE__ */ jsx32(BasicInput8, { className: "h-8 text-xs", value: value.label, "data-records-button-label": "", onChange: (e) => set({ label: e.target.value }) })
|
|
6196
6422
|
] }),
|
|
6197
|
-
/* @__PURE__ */
|
|
6198
|
-
/* @__PURE__ */
|
|
6199
|
-
/* @__PURE__ */
|
|
6423
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6424
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Does" }),
|
|
6425
|
+
/* @__PURE__ */ jsx32(
|
|
6200
6426
|
PickOne,
|
|
6201
6427
|
{
|
|
6202
6428
|
label: "What a press does",
|
|
@@ -6208,9 +6434,9 @@ function ButtonSettingsEditor({
|
|
|
6208
6434
|
)
|
|
6209
6435
|
] })
|
|
6210
6436
|
] }),
|
|
6211
|
-
/* @__PURE__ */
|
|
6212
|
-
/* @__PURE__ */
|
|
6213
|
-
/* @__PURE__ */
|
|
6437
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6438
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Colour" }),
|
|
6439
|
+
/* @__PURE__ */ jsx32(
|
|
6214
6440
|
AccentSwatches,
|
|
6215
6441
|
{
|
|
6216
6442
|
value: value.color ?? "",
|
|
@@ -6220,10 +6446,10 @@ function ButtonSettingsEditor({
|
|
|
6220
6446
|
}
|
|
6221
6447
|
)
|
|
6222
6448
|
] }),
|
|
6223
|
-
value.do === "open_url" ? /* @__PURE__ */
|
|
6224
|
-
/* @__PURE__ */
|
|
6225
|
-
/* @__PURE__ */
|
|
6226
|
-
/* @__PURE__ */
|
|
6449
|
+
value.do === "open_url" ? /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6450
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Link" }),
|
|
6451
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex gap-1", children: [
|
|
6452
|
+
/* @__PURE__ */ jsx32(
|
|
6227
6453
|
BasicInput8,
|
|
6228
6454
|
{
|
|
6229
6455
|
className: "h-8 flex-1 font-mono text-xs",
|
|
@@ -6233,7 +6459,7 @@ function ButtonSettingsEditor({
|
|
|
6233
6459
|
onChange: (e) => set({ url: e.target.value })
|
|
6234
6460
|
}
|
|
6235
6461
|
),
|
|
6236
|
-
columns.length > 0 ? /* @__PURE__ */
|
|
6462
|
+
columns.length > 0 ? /* @__PURE__ */ jsx32(
|
|
6237
6463
|
PickOne,
|
|
6238
6464
|
{
|
|
6239
6465
|
label: "Add a column's value",
|
|
@@ -6246,10 +6472,10 @@ function ButtonSettingsEditor({
|
|
|
6246
6472
|
}
|
|
6247
6473
|
) : null
|
|
6248
6474
|
] }),
|
|
6249
|
-
value.url && buttonUrlPlaceholders(value.url).length > 0 ? /* @__PURE__ */
|
|
6475
|
+
value.url && buttonUrlPlaceholders(value.url).length > 0 ? /* @__PURE__ */ jsx32("p", { className: "truncate text-[11px] text-muted-foreground", "data-records-button-url-words": "", children: buttonUrlInWords(value.url, fields) }) : null
|
|
6250
6476
|
] }) : null,
|
|
6251
|
-
value.do === "run_action" ? !tableId ? /* @__PURE__ */
|
|
6252
|
-
actions === null || actions.length > 0 ? /* @__PURE__ */
|
|
6477
|
+
value.do === "run_action" ? !tableId ? /* @__PURE__ */ jsx32("p", { className: "text-xs text-muted-foreground", children: "Row actions belong to a table" }) : actionsRefused ? /* @__PURE__ */ jsx32(RefusalLine, { error: actionsRefused }) : /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-2", "data-records-button-action": "", children: [
|
|
6478
|
+
actions === null || actions.length > 0 ? /* @__PURE__ */ jsx32(
|
|
6253
6479
|
PickOne,
|
|
6254
6480
|
{
|
|
6255
6481
|
label: "Row action",
|
|
@@ -6260,7 +6486,7 @@ function ButtonSettingsEditor({
|
|
|
6260
6486
|
options: (actions ?? []).map((a) => ({ value: a.id, label: a.name }))
|
|
6261
6487
|
}
|
|
6262
6488
|
) : null,
|
|
6263
|
-
actions !== null ? /* @__PURE__ */
|
|
6489
|
+
actions !== null ? /* @__PURE__ */ jsx32(
|
|
6264
6490
|
NewRowAction,
|
|
6265
6491
|
{
|
|
6266
6492
|
tableId,
|
|
@@ -6274,7 +6500,7 @@ function ButtonSettingsEditor({
|
|
|
6274
6500
|
}
|
|
6275
6501
|
) : null
|
|
6276
6502
|
] }) : null,
|
|
6277
|
-
value.do === "run_automation" ? automations && automations.length === 0 ? /* @__PURE__ */
|
|
6503
|
+
value.do === "run_automation" ? automations && automations.length === 0 ? /* @__PURE__ */ jsx32("p", { className: "text-xs text-muted-foreground", children: "No automations yet. Add one in Table \u22EF \u2192 Automations." }) : /* @__PURE__ */ jsx32(
|
|
6278
6504
|
PickOne,
|
|
6279
6505
|
{
|
|
6280
6506
|
label: "Automation",
|
|
@@ -6299,13 +6525,13 @@ function NewRowAction({
|
|
|
6299
6525
|
columns,
|
|
6300
6526
|
onMade
|
|
6301
6527
|
}) {
|
|
6302
|
-
const client =
|
|
6528
|
+
const client = useOptionalRecordsClient8();
|
|
6303
6529
|
const settable = settableColumns(columns);
|
|
6304
|
-
const [fieldId, setFieldId] =
|
|
6305
|
-
const [setTo, setSetTo] =
|
|
6306
|
-
const [busy, setBusy] =
|
|
6307
|
-
const [refused, setRefused] =
|
|
6308
|
-
if (settable.length === 0) return /* @__PURE__ */
|
|
6530
|
+
const [fieldId, setFieldId] = useState23("");
|
|
6531
|
+
const [setTo, setSetTo] = useState23("");
|
|
6532
|
+
const [busy, setBusy] = useState23(false);
|
|
6533
|
+
const [refused, setRefused] = useState23(null);
|
|
6534
|
+
if (settable.length === 0) return /* @__PURE__ */ jsx32("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
|
|
6309
6535
|
const make = async () => {
|
|
6310
6536
|
if (!client || fieldId === "") return;
|
|
6311
6537
|
setBusy(true);
|
|
@@ -6329,10 +6555,10 @@ function NewRowAction({
|
|
|
6329
6555
|
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." });
|
|
6330
6556
|
onMade(made.id, all);
|
|
6331
6557
|
};
|
|
6332
|
-
return /* @__PURE__ */
|
|
6333
|
-
/* @__PURE__ */
|
|
6334
|
-
/* @__PURE__ */
|
|
6335
|
-
/* @__PURE__ */
|
|
6558
|
+
return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", "data-records-button-new-action": "", children: [
|
|
6559
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "New row action" }),
|
|
6560
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
6561
|
+
/* @__PURE__ */ jsx32(
|
|
6336
6562
|
PickOne,
|
|
6337
6563
|
{
|
|
6338
6564
|
label: "Column to set",
|
|
@@ -6344,16 +6570,16 @@ function NewRowAction({
|
|
|
6344
6570
|
options: settable.map((f) => ({ value: f.id, label: fieldName(f) }))
|
|
6345
6571
|
}
|
|
6346
6572
|
),
|
|
6347
|
-
/* @__PURE__ */
|
|
6348
|
-
/* @__PURE__ */
|
|
6573
|
+
/* @__PURE__ */ jsx32(BasicInput8, { 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) }),
|
|
6574
|
+
/* @__PURE__ */ jsx32(Button14, { type: "button", size: "sm", variant: "outline", disabled: busy || fieldId === "", "data-records-button-action-make": "", onClick: () => void make(), children: busy ? "Making\u2026" : "Make" })
|
|
6349
6575
|
] }),
|
|
6350
|
-
refused ? /* @__PURE__ */
|
|
6576
|
+
refused ? /* @__PURE__ */ jsx32(RefusalLine, { error: refused }) : null
|
|
6351
6577
|
] });
|
|
6352
6578
|
}
|
|
6353
6579
|
|
|
6354
6580
|
// src/FieldEditor.tsx
|
|
6355
6581
|
import { FIELD_SENSITIVITIES, CONTEXT_POLICIES, DECLARABLE_FIELD_KINDS as DECLARABLE_FIELD_KINDS2, optionKey as optionKey3, ratingMaxOf as ratingMaxOf2, rulesWithTopStar } from "@ai-matrx/records";
|
|
6356
|
-
import { Fragment as
|
|
6582
|
+
import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
6357
6583
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
6358
6584
|
var SENSITIVITIES = FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
6359
6585
|
var AGENT_VISIBILITY = CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
@@ -6466,33 +6692,33 @@ function FieldEditor(props) {
|
|
|
6466
6692
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6467
6693
|
const start = field ?? copyOf;
|
|
6468
6694
|
const startAs = start ? void 0 : props.startAs;
|
|
6469
|
-
const [label, setLabel] =
|
|
6470
|
-
const [type, setType] =
|
|
6471
|
-
const [required, setRequired] =
|
|
6472
|
-
const [multi, setMulti] =
|
|
6473
|
-
const [dated, setDated] =
|
|
6474
|
-
const [sensitivity, setSensitivity] =
|
|
6475
|
-
const [contextPolicy, setContextPolicy] =
|
|
6476
|
-
const [rules, setRules] =
|
|
6477
|
-
const [startsWith, setStartsWith] =
|
|
6478
|
-
const [ratingMax, setRatingMax] =
|
|
6479
|
-
const savedRules =
|
|
6695
|
+
const [label, setLabel] = useState24(field?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
|
|
6696
|
+
const [type, setType] = useState24(() => startAs ? startAs.type : startingType(start));
|
|
6697
|
+
const [required, setRequired] = useState24(start?.required ?? false);
|
|
6698
|
+
const [multi, setMulti] = useState24(start?.multi ?? false);
|
|
6699
|
+
const [dated, setDated] = useState24(start?.dated ?? false);
|
|
6700
|
+
const [sensitivity, setSensitivity] = useState24(String(start?.sensitivity ?? "internal"));
|
|
6701
|
+
const [contextPolicy, setContextPolicy] = useState24(String(start?.context_policy ?? "include"));
|
|
6702
|
+
const [rules, setRules] = useState24(start?.rules ?? []);
|
|
6703
|
+
const [startsWith, setStartsWith] = useState24(start?.default ?? null);
|
|
6704
|
+
const [ratingMax, setRatingMax] = useState24(() => start ? ratingMaxOf2(start) : 5);
|
|
6705
|
+
const savedRules = useMemo11(
|
|
6480
6706
|
() => field ? type === "rating" ? rulesWithTopStar(field.rules ?? [], ratingMaxOf2(field)) : field.rules ?? [] : [],
|
|
6481
6707
|
[field, type]
|
|
6482
6708
|
);
|
|
6483
|
-
const editedRules =
|
|
6484
|
-
const [statusGroups, setStatusGroups] =
|
|
6485
|
-
const [statusKeys, setStatusKeys] =
|
|
6486
|
-
const [symbology, setSymbology] =
|
|
6709
|
+
const editedRules = useMemo11(() => type === "rating" ? rulesWithTopStar(rules, ratingMax) : rules, [type, rules, ratingMax]);
|
|
6710
|
+
const [statusGroups, setStatusGroups] = useState24({});
|
|
6711
|
+
const [statusKeys, setStatusKeys] = useState24({});
|
|
6712
|
+
const [symbology, setSymbology] = useState24(String(start?.config?.["symbology"] ?? ""));
|
|
6487
6713
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
6488
|
-
const [description, setDescription] =
|
|
6489
|
-
const buttonStart =
|
|
6490
|
-
const [buttonSettings, setButtonSettings] =
|
|
6714
|
+
const [description, setDescription] = useState24(descriptionStart);
|
|
6715
|
+
const buttonStart = useMemo11(() => buttonOf(start) ?? { label: "" }, [start]);
|
|
6716
|
+
const [buttonSettings, setButtonSettings] = useState24(buttonStart);
|
|
6491
6717
|
const prefixStart = autonumberPrefixOf3(start);
|
|
6492
|
-
const [numberPrefix, setNumberPrefix] =
|
|
6718
|
+
const [numberPrefix, setNumberPrefix] = useState24(prefixStart);
|
|
6493
6719
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6494
|
-
const [dependency, setDependency] =
|
|
6495
|
-
|
|
6720
|
+
const [dependency, setDependency] = useState24(dependencyStart);
|
|
6721
|
+
useEffect18(() => {
|
|
6496
6722
|
if (!field || type !== "status") return;
|
|
6497
6723
|
let live = true;
|
|
6498
6724
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
@@ -6502,20 +6728,20 @@ function FieldEditor(props) {
|
|
|
6502
6728
|
live = false;
|
|
6503
6729
|
};
|
|
6504
6730
|
}, [client, field, type]);
|
|
6505
|
-
|
|
6731
|
+
useEffect18(() => {
|
|
6506
6732
|
if (field || type !== "status") return;
|
|
6507
6733
|
setNewChoices(
|
|
6508
6734
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6509
6735
|
);
|
|
6510
6736
|
}, [field, type]);
|
|
6511
|
-
|
|
6737
|
+
useEffect18(() => {
|
|
6512
6738
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6513
6739
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6514
6740
|
}, [field, type]);
|
|
6515
|
-
const [allowOther, setAllowOther] =
|
|
6516
|
-
const [newChoices, setNewChoices] =
|
|
6741
|
+
const [allowOther, setAllowOther] = useState24(start?.config?.["allow_other"] === true);
|
|
6742
|
+
const [newChoices, setNewChoices] = useState24([]);
|
|
6517
6743
|
const copyOfId = copyOf?.id ?? null;
|
|
6518
|
-
|
|
6744
|
+
useEffect18(() => {
|
|
6519
6745
|
if (!copyOf || !copyOfId) return;
|
|
6520
6746
|
let live = true;
|
|
6521
6747
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6527,53 +6753,53 @@ function FieldEditor(props) {
|
|
|
6527
6753
|
live = false;
|
|
6528
6754
|
};
|
|
6529
6755
|
}, [client, copyOfId]);
|
|
6530
|
-
const [choiceList, setChoiceList] =
|
|
6531
|
-
const [choiceListStart, setChoiceListStart] =
|
|
6532
|
-
const [rehome, setRehome] =
|
|
6533
|
-
const [rehomed, setRehomed] =
|
|
6534
|
-
const [rehomeRefused, setRehomeRefused] =
|
|
6535
|
-
const [unit, setUnit] =
|
|
6536
|
-
const [withTime, setWithTime] =
|
|
6537
|
-
const [via, setVia] =
|
|
6538
|
-
const [pick, setPick] =
|
|
6539
|
-
const [agg, setAgg] =
|
|
6756
|
+
const [choiceList, setChoiceList] = useState24(null);
|
|
6757
|
+
const [choiceListStart, setChoiceListStart] = useState24(null);
|
|
6758
|
+
const [rehome, setRehome] = useState24({});
|
|
6759
|
+
const [rehomed, setRehomed] = useState24(null);
|
|
6760
|
+
const [rehomeRefused, setRehomeRefused] = useState24(null);
|
|
6761
|
+
const [unit, setUnit] = useState24(start?.unit ?? "$");
|
|
6762
|
+
const [withTime, setWithTime] = useState24(String(start?.config?.["kind"] ?? "date") === "datetime");
|
|
6763
|
+
const [via, setVia] = useState24(String(start?.config?.["via"] ?? ""));
|
|
6764
|
+
const [pick, setPick] = useState24(String(start?.config?.["pick"] ?? ""));
|
|
6765
|
+
const [agg, setAgg] = useState24(
|
|
6540
6766
|
start?.config?.["agg"] ?? "count"
|
|
6541
6767
|
);
|
|
6542
|
-
const [of, setOf] =
|
|
6768
|
+
const [of, setOf] = useState24(String(start?.config?.["of"] ?? ""));
|
|
6543
6769
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6544
|
-
const [rollupFilter, setRollupFilter] =
|
|
6770
|
+
const [rollupFilter, setRollupFilter] = useState24(
|
|
6545
6771
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6546
6772
|
);
|
|
6547
6773
|
const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
|
|
6548
|
-
const [relationTarget, setRelationTarget] =
|
|
6549
|
-
const [showOnOther, setShowOnOther] =
|
|
6550
|
-
const [nestsSubItems, setNestsSubItems] =
|
|
6551
|
-
const [reverseRefused, setReverseRefused] =
|
|
6774
|
+
const [relationTarget, setRelationTarget] = useState24(String(start?.relation_target ?? ""));
|
|
6775
|
+
const [showOnOther, setShowOnOther] = useState24(true);
|
|
6776
|
+
const [nestsSubItems, setNestsSubItems] = useState24(false);
|
|
6777
|
+
const [reverseRefused, setReverseRefused] = useState24(null);
|
|
6552
6778
|
const otherTable = useTable(!field && type === "relation" && relationTarget !== "" ? relationTarget : null);
|
|
6553
|
-
const [display, setDisplay] =
|
|
6554
|
-
const [formulaOp, setFormulaOp] =
|
|
6555
|
-
const [formulaFields, setFormulaFields] =
|
|
6556
|
-
const [formulaSeparator, setFormulaSeparator] =
|
|
6557
|
-
const [allowedTypes, setAllowedTypes] =
|
|
6779
|
+
const [display, setDisplay] = useState24(start?.display ?? null);
|
|
6780
|
+
const [formulaOp, setFormulaOp] = useState24(() => formulaOpOf(start));
|
|
6781
|
+
const [formulaFields, setFormulaFields] = useState24(() => formulaFieldIdsOf(start));
|
|
6782
|
+
const [formulaSeparator, setFormulaSeparator] = useState24(() => formulaSeparatorOf(start));
|
|
6783
|
+
const [allowedTypes, setAllowedTypes] = useState24(() => entityReferenceKindsOf(start));
|
|
6558
6784
|
const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
|
|
6559
|
-
const [formulaText, setFormulaText] =
|
|
6560
|
-
const shownFormula =
|
|
6561
|
-
|
|
6785
|
+
const [formulaText, setFormulaText] = useState24(startingFormulaText);
|
|
6786
|
+
const shownFormula = useRef13(startingFormulaText);
|
|
6787
|
+
useEffect18(() => {
|
|
6562
6788
|
if (shownFormula.current === startingFormulaText) return;
|
|
6563
6789
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6564
6790
|
shownFormula.current = startingFormulaText;
|
|
6565
6791
|
}, [startingFormulaText]);
|
|
6566
|
-
const [formulaWritten, setFormulaWritten] =
|
|
6567
|
-
const [formulaOk, setFormulaOk] =
|
|
6568
|
-
const [askingToRemove, setAskingToRemove] =
|
|
6569
|
-
const [attempted, setAttempted] =
|
|
6570
|
-
const [showsAs, setShowsAs] =
|
|
6571
|
-
const [backfillError, setBackfillError] =
|
|
6572
|
-
const [notLanded, setNotLanded] =
|
|
6792
|
+
const [formulaWritten, setFormulaWritten] = useState24(() => startingFormulaText.trim() !== "" || Boolean(field) || startAs?.type === "formula");
|
|
6793
|
+
const [formulaOk, setFormulaOk] = useState24(null);
|
|
6794
|
+
const [askingToRemove, setAskingToRemove] = useState24(false);
|
|
6795
|
+
const [attempted, setAttempted] = useState24(false);
|
|
6796
|
+
const [showsAs, setShowsAs] = useState24(() => start ? startingChoice(start) : { format: null, retype: null });
|
|
6797
|
+
const [backfillError, setBackfillError] = useState24(null);
|
|
6798
|
+
const [notLanded, setNotLanded] = useState24(false);
|
|
6573
6799
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6574
6800
|
const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
|
|
6575
|
-
const seededAs =
|
|
6576
|
-
|
|
6801
|
+
const seededAs = useRef13(heldAs);
|
|
6802
|
+
useEffect18(() => {
|
|
6577
6803
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6578
6804
|
seededAs.current = heldAs;
|
|
6579
6805
|
setType(startingType(liveField));
|
|
@@ -6582,24 +6808,24 @@ function FieldEditor(props) {
|
|
|
6582
6808
|
setUnit(liveField.unit ?? "$");
|
|
6583
6809
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6584
6810
|
}, [heldAs]);
|
|
6585
|
-
const others =
|
|
6811
|
+
const others = useMemo11(
|
|
6586
6812
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6587
6813
|
[fields.data, field?.id]
|
|
6588
6814
|
);
|
|
6589
|
-
const relations =
|
|
6815
|
+
const relations = useMemo11(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
|
|
6590
6816
|
const reverse = useReverseColumns(onEntity ? null : tableId);
|
|
6591
|
-
const backLinks =
|
|
6592
|
-
const totalSources =
|
|
6817
|
+
const backLinks = useMemo11(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
|
|
6818
|
+
const totalSources = useMemo11(() => [...relations, ...backLinks], [relations, backLinks]);
|
|
6593
6819
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6594
6820
|
const choice = fieldTypeChoice(type);
|
|
6595
6821
|
const editing = Boolean(field);
|
|
6596
|
-
|
|
6822
|
+
useEffect18(() => {
|
|
6597
6823
|
if (!editing) setStartsWith(null);
|
|
6598
6824
|
}, [type, editing]);
|
|
6599
6825
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6600
6826
|
const farFieldsOfLink = useFields2(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6601
6827
|
const farTable = useTable(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6602
|
-
const linkReaders =
|
|
6828
|
+
const linkReaders = useMemo11(
|
|
6603
6829
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6604
6830
|
[field, farFieldsOfLink.data]
|
|
6605
6831
|
);
|
|
@@ -6607,7 +6833,7 @@ function FieldEditor(props) {
|
|
|
6607
6833
|
const offersMany = multiApplies(type) && !isTitle;
|
|
6608
6834
|
if (!mayShape) {
|
|
6609
6835
|
if (onEntity && entityRights.loading) return null;
|
|
6610
|
-
return /* @__PURE__ */
|
|
6836
|
+
return /* @__PURE__ */ jsx33("p", { className: cn22("text-xs text-muted-foreground", className), children: props.tableLabel && storeLabel && whyNot ? whyNot.split(storeLabel).join(props.tableLabel) : whyNot });
|
|
6611
6837
|
}
|
|
6612
6838
|
const options = newChoices.map((r) => r.words.trim()).filter((word) => word !== "");
|
|
6613
6839
|
const shownStatusRows = type !== "status" ? [] : statusGroupRows(field, editing ? choiceList ?? [] : newChoices, statusKeys, statusGroups);
|
|
@@ -6807,15 +7033,15 @@ function FieldEditor(props) {
|
|
|
6807
7033
|
if (gone) (onRemoved ?? onSaved)?.();
|
|
6808
7034
|
else setAskingToRemove(false);
|
|
6809
7035
|
};
|
|
6810
|
-
return /* @__PURE__ */
|
|
6811
|
-
/* @__PURE__ */
|
|
6812
|
-
/* @__PURE__ */
|
|
6813
|
-
/* @__PURE__ */
|
|
7036
|
+
return /* @__PURE__ */ jsxs31("div", { className: cn22("flex min-w-0 flex-col gap-3 text-xs", className), "data-records-field-editor": "", children: [
|
|
7037
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-2", children: [
|
|
7038
|
+
/* @__PURE__ */ jsx33("span", { className: "font-medium", children: field ? `Field \xB7 ${fieldName(field)}` : "New field" }),
|
|
7039
|
+
/* @__PURE__ */ jsx33("span", { className: "ml-auto text-muted-foreground", children: tableLabel })
|
|
6814
7040
|
] }),
|
|
6815
|
-
/* @__PURE__ */
|
|
6816
|
-
/* @__PURE__ */
|
|
6817
|
-
/* @__PURE__ */
|
|
6818
|
-
/* @__PURE__ */
|
|
7041
|
+
/* @__PURE__ */ jsxs31("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7042
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex flex-col gap-1", children: [
|
|
7043
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Name" }),
|
|
7044
|
+
/* @__PURE__ */ jsx33(
|
|
6819
7045
|
BasicInput9,
|
|
6820
7046
|
{
|
|
6821
7047
|
value: label,
|
|
@@ -6831,7 +7057,7 @@ function FieldEditor(props) {
|
|
|
6831
7057
|
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6832
7058
|
}
|
|
6833
7059
|
),
|
|
6834
|
-
nameLine ? /* @__PURE__ */
|
|
7060
|
+
nameLine ? /* @__PURE__ */ jsx33(
|
|
6835
7061
|
"span",
|
|
6836
7062
|
{
|
|
6837
7063
|
id: "field-editor-name-taken",
|
|
@@ -6842,9 +7068,9 @@ function FieldEditor(props) {
|
|
|
6842
7068
|
}
|
|
6843
7069
|
) : null
|
|
6844
7070
|
] }),
|
|
6845
|
-
field ? /* @__PURE__ */
|
|
6846
|
-
/* @__PURE__ */
|
|
6847
|
-
/* @__PURE__ */
|
|
7071
|
+
field ? /* @__PURE__ */ jsxs31("label", { className: "flex flex-col gap-1 sm:col-span-2", children: [
|
|
7072
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Help text" }),
|
|
7073
|
+
/* @__PURE__ */ jsx33(
|
|
6848
7074
|
BasicInput9,
|
|
6849
7075
|
{
|
|
6850
7076
|
value: description,
|
|
@@ -6855,29 +7081,29 @@ function FieldEditor(props) {
|
|
|
6855
7081
|
}
|
|
6856
7082
|
)
|
|
6857
7083
|
] }) : null,
|
|
6858
|
-
/* @__PURE__ */
|
|
6859
|
-
/* @__PURE__ */
|
|
6860
|
-
/* @__PURE__ */
|
|
7084
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7085
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "What it holds" }),
|
|
7086
|
+
/* @__PURE__ */ jsxs31(
|
|
6861
7087
|
Select6,
|
|
6862
7088
|
{
|
|
6863
7089
|
value: type,
|
|
6864
7090
|
disabled: editing,
|
|
6865
7091
|
onValueChange: (next) => setType(next),
|
|
6866
7092
|
children: [
|
|
6867
|
-
/* @__PURE__ */
|
|
6868
|
-
/* @__PURE__ */
|
|
6869
|
-
/* @__PURE__ */
|
|
6870
|
-
FIELD_TYPE_CATALOGUE.filter((c) => c.group === group && (c.id === type || offered.includes(c))).map((c) => /* @__PURE__ */
|
|
7093
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "What this field holds", ...choice?.explanation ? { title: choice.explanation } : {}, children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7094
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: FIELD_TYPE_GROUPS.filter((group) => offered.some((c) => c.group === group)).map((group) => /* @__PURE__ */ jsxs31(SelectGroup2, { children: [
|
|
7095
|
+
/* @__PURE__ */ jsx33(SelectLabel2, { children: group }),
|
|
7096
|
+
FIELD_TYPE_CATALOGUE.filter((c) => c.group === group && (c.id === type || offered.includes(c))).map((c) => /* @__PURE__ */ jsx33(SelectItem6, { value: c.id, children: c.label }, c.id))
|
|
6871
7097
|
] }, group)) })
|
|
6872
7098
|
]
|
|
6873
7099
|
}
|
|
6874
7100
|
),
|
|
6875
|
-
editing && field ? /* @__PURE__ */
|
|
7101
|
+
editing && field ? /* @__PURE__ */ jsx33(FieldRetype, { field: liveField ?? field, tableId }) : null
|
|
6876
7102
|
] })
|
|
6877
7103
|
] }),
|
|
6878
|
-
type === "formula" && others.length > 0 ? /* @__PURE__ */
|
|
6879
|
-
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */
|
|
6880
|
-
/* @__PURE__ */
|
|
7104
|
+
type === "formula" && others.length > 0 ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-2", children: [
|
|
7105
|
+
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: EDITING_A_WORKED_OUT_COLUMN }) : null : /* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-1", role: "group", "aria-label": "How to make this column", children: [
|
|
7106
|
+
/* @__PURE__ */ jsx33(
|
|
6881
7107
|
Button15,
|
|
6882
7108
|
{
|
|
6883
7109
|
type: "button",
|
|
@@ -6888,7 +7114,7 @@ function FieldEditor(props) {
|
|
|
6888
7114
|
children: "Pick the columns"
|
|
6889
7115
|
}
|
|
6890
7116
|
),
|
|
6891
|
-
/* @__PURE__ */
|
|
7117
|
+
/* @__PURE__ */ jsx33(
|
|
6892
7118
|
Button15,
|
|
6893
7119
|
{
|
|
6894
7120
|
type: "button",
|
|
@@ -6900,7 +7126,7 @@ function FieldEditor(props) {
|
|
|
6900
7126
|
}
|
|
6901
7127
|
)
|
|
6902
7128
|
] }),
|
|
6903
|
-
formulaWritten ? /* @__PURE__ */
|
|
7129
|
+
formulaWritten ? /* @__PURE__ */ jsx33(
|
|
6904
7130
|
FormulaTextEditor,
|
|
6905
7131
|
{
|
|
6906
7132
|
tableId,
|
|
@@ -6910,9 +7136,9 @@ function FieldEditor(props) {
|
|
|
6910
7136
|
columns: others
|
|
6911
7137
|
}
|
|
6912
7138
|
) : null
|
|
6913
|
-
] }) : editing && type === "formula" ? /* @__PURE__ */
|
|
6914
|
-
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */
|
|
6915
|
-
!editing && !(type === "formula" && formulaWritten) || type === "select" || type === "multi_select" || type === "status" || type === "rating" || type === "barcode" || type === "relation" || type === "entity_reference" ? /* @__PURE__ */
|
|
7139
|
+
] }) : editing && type === "formula" ? /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No other column to read." }) : null,
|
|
7140
|
+
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */ jsx33(SourceArchivedNotice, { fieldId: field.id, tableId }) : null,
|
|
7141
|
+
!editing && !(type === "formula" && formulaWritten) || type === "select" || type === "multi_select" || type === "status" || type === "rating" || type === "barcode" || type === "relation" || type === "entity_reference" ? /* @__PURE__ */ jsx33(
|
|
6916
7142
|
TypeQuestions,
|
|
6917
7143
|
{
|
|
6918
7144
|
type,
|
|
@@ -6942,7 +7168,7 @@ function FieldEditor(props) {
|
|
|
6942
7168
|
setFormulaSeparator,
|
|
6943
7169
|
relations: sourcesFor(type),
|
|
6944
7170
|
others,
|
|
6945
|
-
choiceList: editing && field ? /* @__PURE__ */
|
|
7171
|
+
choiceList: editing && field ? /* @__PURE__ */ jsx33(
|
|
6946
7172
|
ChoiceListEditor,
|
|
6947
7173
|
{
|
|
6948
7174
|
field,
|
|
@@ -6953,10 +7179,10 @@ function FieldEditor(props) {
|
|
|
6953
7179
|
rehome,
|
|
6954
7180
|
onRehome: setRehome
|
|
6955
7181
|
}
|
|
6956
|
-
) : /* @__PURE__ */
|
|
7182
|
+
) : /* @__PURE__ */ jsx33(ChoiceListEditor, { isNew: true, rows: newChoices, onRows: setNewChoices }),
|
|
6957
7183
|
allowedTypes,
|
|
6958
7184
|
setAllowedTypes,
|
|
6959
|
-
newer: type === "rating" ? /* @__PURE__ */
|
|
7185
|
+
newer: type === "rating" ? /* @__PURE__ */ jsx33(
|
|
6960
7186
|
RatingMaxQuestion,
|
|
6961
7187
|
{
|
|
6962
7188
|
value: ratingMax,
|
|
@@ -6964,19 +7190,19 @@ function FieldEditor(props) {
|
|
|
6964
7190
|
setRatingMax(next);
|
|
6965
7191
|
}
|
|
6966
7192
|
}
|
|
6967
|
-
) : type === "status" ? /* @__PURE__ */
|
|
7193
|
+
) : type === "status" ? /* @__PURE__ */ jsx33(StatusGroupsQuestion, { rows: shownStatusRows, onGroup: (ref, next) => setStatusGroups({ ...statusGroups, [ref]: next }) }) : type === "barcode" ? /* @__PURE__ */ jsx33(BarcodeSymbologyQuestion, { value: symbology, onChange: setSymbology }) : null
|
|
6968
7194
|
}
|
|
6969
7195
|
) : null,
|
|
6970
|
-
type === "button" ? /* @__PURE__ */
|
|
6971
|
-
type === "autonumber" ? /* @__PURE__ */
|
|
6972
|
-
/* @__PURE__ */
|
|
6973
|
-
/* @__PURE__ */
|
|
7196
|
+
type === "button" ? /* @__PURE__ */ jsx33(ButtonSettingsEditor, { value: buttonSettings, onChange: setButtonSettings, tableId: onEntity ? null : tableId, fields: others }) : null,
|
|
7197
|
+
type === "autonumber" ? /* @__PURE__ */ jsxs31("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7198
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Prefix" }),
|
|
7199
|
+
/* @__PURE__ */ jsx33(BasicInput9, { className: "h-8 text-xs", placeholder: "TASK-", maxLength: 16, "data-records-autonumber-prefix": "", value: numberPrefix, onChange: (e) => setNumberPrefix(e.target.value) })
|
|
6974
7200
|
] }) : null,
|
|
6975
|
-
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */
|
|
6976
|
-
/* @__PURE__ */
|
|
6977
|
-
/* @__PURE__ */
|
|
7201
|
+
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5 text-sm", title: "A timeline draws a line to each record this one waits on", children: [
|
|
7202
|
+
/* @__PURE__ */ jsx33(Checkbox4, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
|
|
7203
|
+
/* @__PURE__ */ jsx33("span", { children: "Waits on the linked records" })
|
|
6978
7204
|
] }) : null,
|
|
6979
|
-
type === "rollup" ? /* @__PURE__ */
|
|
7205
|
+
type === "rollup" ? /* @__PURE__ */ jsx33(
|
|
6980
7206
|
RollupFilterQuestion,
|
|
6981
7207
|
{
|
|
6982
7208
|
relation: totalSources.find((f) => f.key === via),
|
|
@@ -6986,10 +7212,10 @@ function FieldEditor(props) {
|
|
|
6986
7212
|
onChange: setRollupFilter
|
|
6987
7213
|
}
|
|
6988
7214
|
) : null,
|
|
6989
|
-
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */
|
|
6990
|
-
/* @__PURE__ */
|
|
6991
|
-
/* @__PURE__ */
|
|
6992
|
-
/* @__PURE__ */
|
|
7215
|
+
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */ jsx33(FieldFormatPicker, { field, value: showsAs, onValue: setShowsAs }) : null,
|
|
7216
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-wrap items-center gap-4", children: [
|
|
7217
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7218
|
+
/* @__PURE__ */ jsx33(
|
|
6993
7219
|
Checkbox4,
|
|
6994
7220
|
{
|
|
6995
7221
|
checked: required,
|
|
@@ -6997,10 +7223,10 @@ function FieldEditor(props) {
|
|
|
6997
7223
|
onCheckedChange: (v) => setRequired(v === true)
|
|
6998
7224
|
}
|
|
6999
7225
|
),
|
|
7000
|
-
/* @__PURE__ */
|
|
7226
|
+
/* @__PURE__ */ jsx33("span", { title: "Every record has to have one", children: "Required" })
|
|
7001
7227
|
] }),
|
|
7002
|
-
offersMany ? /* @__PURE__ */
|
|
7003
|
-
/* @__PURE__ */
|
|
7228
|
+
offersMany ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7229
|
+
/* @__PURE__ */ jsx33(
|
|
7004
7230
|
Checkbox4,
|
|
7005
7231
|
{
|
|
7006
7232
|
checked: multi,
|
|
@@ -7010,8 +7236,8 @@ function FieldEditor(props) {
|
|
|
7010
7236
|
),
|
|
7011
7237
|
"Can hold more than one"
|
|
7012
7238
|
] }) : null,
|
|
7013
|
-
/* @__PURE__ */
|
|
7014
|
-
/* @__PURE__ */
|
|
7239
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7240
|
+
/* @__PURE__ */ jsx33(
|
|
7015
7241
|
Checkbox4,
|
|
7016
7242
|
{
|
|
7017
7243
|
checked: dated,
|
|
@@ -7021,8 +7247,8 @@ function FieldEditor(props) {
|
|
|
7021
7247
|
),
|
|
7022
7248
|
"Each value has its own date"
|
|
7023
7249
|
] }),
|
|
7024
|
-
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */
|
|
7025
|
-
/* @__PURE__ */
|
|
7250
|
+
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7251
|
+
/* @__PURE__ */ jsx33(
|
|
7026
7252
|
Checkbox4,
|
|
7027
7253
|
{
|
|
7028
7254
|
checked: showOnOther,
|
|
@@ -7034,12 +7260,12 @@ function FieldEditor(props) {
|
|
|
7034
7260
|
"Show on ",
|
|
7035
7261
|
otherTable.data.name ?? "the other table"
|
|
7036
7262
|
] }) : null,
|
|
7037
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */
|
|
7038
|
-
/* @__PURE__ */
|
|
7039
|
-
/* @__PURE__ */
|
|
7263
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", title: "A timeline draws a line to each record this one waits on", children: [
|
|
7264
|
+
/* @__PURE__ */ jsx33(Checkbox4, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
|
|
7265
|
+
/* @__PURE__ */ jsx33("span", { children: "Waits on the linked records" })
|
|
7040
7266
|
] }) : null,
|
|
7041
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */
|
|
7042
|
-
/* @__PURE__ */
|
|
7267
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7268
|
+
/* @__PURE__ */ jsx33(
|
|
7043
7269
|
Checkbox4,
|
|
7044
7270
|
{
|
|
7045
7271
|
checked: nestsSubItems,
|
|
@@ -7051,10 +7277,10 @@ function FieldEditor(props) {
|
|
|
7051
7277
|
"data-records-sub-items": ""
|
|
7052
7278
|
}
|
|
7053
7279
|
),
|
|
7054
|
-
/* @__PURE__ */
|
|
7280
|
+
/* @__PURE__ */ jsx33("span", { title: "Each record sits under the one this column names", children: "Sub-items" })
|
|
7055
7281
|
] }) : null,
|
|
7056
|
-
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */
|
|
7057
|
-
/* @__PURE__ */
|
|
7282
|
+
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7283
|
+
/* @__PURE__ */ jsx33(
|
|
7058
7284
|
Checkbox4,
|
|
7059
7285
|
{
|
|
7060
7286
|
checked: allowOther,
|
|
@@ -7065,10 +7291,10 @@ function FieldEditor(props) {
|
|
|
7065
7291
|
"A value that is not one of the choices is added to them"
|
|
7066
7292
|
] }) : null
|
|
7067
7293
|
] }),
|
|
7068
|
-
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */
|
|
7069
|
-
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */
|
|
7070
|
-
/* @__PURE__ */
|
|
7071
|
-
/* @__PURE__ */
|
|
7294
|
+
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ jsx33(NewColumnDefault, { type, choices: options, value: startsWith, onChange: setStartsWith }) : null,
|
|
7295
|
+
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", "data-records-field-default": "", children: [
|
|
7296
|
+
/* @__PURE__ */ jsx33(Label8, { htmlFor: "records-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7297
|
+
/* @__PURE__ */ jsx33(
|
|
7072
7298
|
FieldControl,
|
|
7073
7299
|
{
|
|
7074
7300
|
id: "records-field-default",
|
|
@@ -7078,28 +7304,28 @@ function FieldEditor(props) {
|
|
|
7078
7304
|
}
|
|
7079
7305
|
)
|
|
7080
7306
|
] }) : null,
|
|
7081
|
-
/* @__PURE__ */
|
|
7082
|
-
/* @__PURE__ */
|
|
7083
|
-
/* @__PURE__ */
|
|
7084
|
-
/* @__PURE__ */
|
|
7085
|
-
/* @__PURE__ */
|
|
7086
|
-
/* @__PURE__ */
|
|
7087
|
-
/* @__PURE__ */
|
|
7307
|
+
/* @__PURE__ */ jsx33(Separator, {}),
|
|
7308
|
+
/* @__PURE__ */ jsxs31("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7309
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7310
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Who can see what is in it" }),
|
|
7311
|
+
/* @__PURE__ */ jsxs31(Select6, { value: sensitivity, onValueChange: setSensitivity, children: [
|
|
7312
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "Who can see what is in it", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7313
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: sensitivities.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7088
7314
|
] })
|
|
7089
7315
|
] }),
|
|
7090
|
-
/* @__PURE__ */
|
|
7091
|
-
/* @__PURE__ */
|
|
7092
|
-
/* @__PURE__ */
|
|
7093
|
-
/* @__PURE__ */
|
|
7094
|
-
/* @__PURE__ */
|
|
7316
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7317
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Can an assistant read it" }),
|
|
7318
|
+
/* @__PURE__ */ jsxs31(Select6, { value: contextPolicy, onValueChange: setContextPolicy, children: [
|
|
7319
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "Can an assistant read it", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7320
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: AGENT_VISIBILITY.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7095
7321
|
] })
|
|
7096
7322
|
] })
|
|
7097
7323
|
] }),
|
|
7098
|
-
/* @__PURE__ */
|
|
7099
|
-
/* @__PURE__ */
|
|
7100
|
-
/* @__PURE__ */
|
|
7101
|
-
/* @__PURE__ */
|
|
7102
|
-
/* @__PURE__ */
|
|
7324
|
+
/* @__PURE__ */ jsx33(Separator, {}),
|
|
7325
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-2", children: [
|
|
7326
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-2", children: [
|
|
7327
|
+
/* @__PURE__ */ jsx33("span", { className: "font-medium", children: "What counts as a good value" }),
|
|
7328
|
+
/* @__PURE__ */ jsx33(
|
|
7103
7329
|
Button15,
|
|
7104
7330
|
{
|
|
7105
7331
|
type: "button",
|
|
@@ -7111,8 +7337,8 @@ function FieldEditor(props) {
|
|
|
7111
7337
|
}
|
|
7112
7338
|
)
|
|
7113
7339
|
] }),
|
|
7114
|
-
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */
|
|
7115
|
-
/* @__PURE__ */
|
|
7340
|
+
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", "data-records-field-unique": "", children: [
|
|
7341
|
+
/* @__PURE__ */ jsx33(
|
|
7116
7342
|
Checkbox4,
|
|
7117
7343
|
{
|
|
7118
7344
|
checked: rules.some((r) => r.kind === "unique"),
|
|
@@ -7122,20 +7348,20 @@ function FieldEditor(props) {
|
|
|
7122
7348
|
),
|
|
7123
7349
|
UNIQUE_LABEL
|
|
7124
7350
|
] }) : null,
|
|
7125
|
-
rules.length === 0 ? /* @__PURE__ */
|
|
7126
|
-
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */
|
|
7127
|
-
/* @__PURE__ */
|
|
7351
|
+
rules.length === 0 ? /* @__PURE__ */ jsx33("p", { className: "text-muted-foreground", children: "No checks." }) : null,
|
|
7352
|
+
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-1", children: [
|
|
7353
|
+
/* @__PURE__ */ jsxs31(
|
|
7128
7354
|
Select6,
|
|
7129
7355
|
{
|
|
7130
7356
|
value: rule.kind,
|
|
7131
7357
|
onValueChange: (kind) => setRules(rules.map((r, i) => i === index ? { ...r, kind } : r)),
|
|
7132
7358
|
children: [
|
|
7133
|
-
/* @__PURE__ */
|
|
7134
|
-
/* @__PURE__ */
|
|
7359
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", className: "w-52", "aria-label": `Check ${index + 1}`, children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7360
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: RULE_KINDS.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.kind, children: row.label }, row.kind)) })
|
|
7135
7361
|
]
|
|
7136
7362
|
}
|
|
7137
7363
|
),
|
|
7138
|
-
rule.kind === "length" ? /* @__PURE__ */
|
|
7364
|
+
rule.kind === "length" ? /* @__PURE__ */ jsx33(
|
|
7139
7365
|
BasicInput9,
|
|
7140
7366
|
{
|
|
7141
7367
|
className: "h-8 w-24",
|
|
@@ -7146,7 +7372,7 @@ function FieldEditor(props) {
|
|
|
7146
7372
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withNumber(r, "min", e.target.value) : r))
|
|
7147
7373
|
}
|
|
7148
7374
|
) : null,
|
|
7149
|
-
/* @__PURE__ */
|
|
7375
|
+
/* @__PURE__ */ jsx33(
|
|
7150
7376
|
BasicInput9,
|
|
7151
7377
|
{
|
|
7152
7378
|
className: "h-8",
|
|
@@ -7156,7 +7382,7 @@ function FieldEditor(props) {
|
|
|
7156
7382
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? { ...r, value: e.target.value } : r))
|
|
7157
7383
|
}
|
|
7158
7384
|
),
|
|
7159
|
-
rule.kind === "pattern" ? /* @__PURE__ */
|
|
7385
|
+
rule.kind === "pattern" ? /* @__PURE__ */ jsx33(
|
|
7160
7386
|
BasicInput9,
|
|
7161
7387
|
{
|
|
7162
7388
|
className: "h-8",
|
|
@@ -7166,7 +7392,7 @@ function FieldEditor(props) {
|
|
|
7166
7392
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withText(r, "example", e.target.value) : r))
|
|
7167
7393
|
}
|
|
7168
7394
|
) : null,
|
|
7169
|
-
/* @__PURE__ */
|
|
7395
|
+
/* @__PURE__ */ jsx33(
|
|
7170
7396
|
Button15,
|
|
7171
7397
|
{
|
|
7172
7398
|
type: "button",
|
|
@@ -7179,9 +7405,9 @@ function FieldEditor(props) {
|
|
|
7179
7405
|
)
|
|
7180
7406
|
] }, `${rule.kind}-${index}`))
|
|
7181
7407
|
] }),
|
|
7182
|
-
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */
|
|
7183
|
-
mutation.error ? /* @__PURE__ */
|
|
7184
|
-
notLanded ? /* @__PURE__ */
|
|
7408
|
+
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ jsx33(FieldRulePreview, { field, tableId, rules: editedRules }) : null,
|
|
7409
|
+
mutation.error ? /* @__PURE__ */ jsx33(RefusalNotice, { error: mutation.error }) : null,
|
|
7410
|
+
notLanded ? /* @__PURE__ */ jsx33(
|
|
7185
7411
|
RefusalNotice,
|
|
7186
7412
|
{
|
|
7187
7413
|
error: (0, refusals_exports.refusal)(
|
|
@@ -7191,10 +7417,10 @@ function FieldEditor(props) {
|
|
|
7191
7417
|
)
|
|
7192
7418
|
}
|
|
7193
7419
|
) : null,
|
|
7194
|
-
rehomeRefused ? /* @__PURE__ */
|
|
7195
|
-
rehomed ? /* @__PURE__ */
|
|
7196
|
-
/* @__PURE__ */
|
|
7197
|
-
rehomed.undo ? /* @__PURE__ */
|
|
7420
|
+
rehomeRefused ? /* @__PURE__ */ jsx33(RefusalNotice, { error: rehomeRefused }) : null,
|
|
7421
|
+
rehomed ? /* @__PURE__ */ jsxs31("div", { "data-records-choice-rehomed": "", className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
7422
|
+
/* @__PURE__ */ jsx33("span", { children: rehomed.said }),
|
|
7423
|
+
rehomed.undo ? /* @__PURE__ */ jsx33(
|
|
7198
7424
|
Button15,
|
|
7199
7425
|
{
|
|
7200
7426
|
type: "button",
|
|
@@ -7219,18 +7445,18 @@ function FieldEditor(props) {
|
|
|
7219
7445
|
children: "Undo"
|
|
7220
7446
|
}
|
|
7221
7447
|
) : null,
|
|
7222
|
-
/* @__PURE__ */
|
|
7448
|
+
/* @__PURE__ */ jsx33(Button15, { type: "button", size: "sm", className: "h-6 px-2 text-xs", onClick: () => onSaved?.(), children: "Done" })
|
|
7223
7449
|
] }) : null,
|
|
7224
|
-
reverseRefused ? /* @__PURE__ */
|
|
7225
|
-
/* @__PURE__ */
|
|
7226
|
-
/* @__PURE__ */
|
|
7450
|
+
reverseRefused ? /* @__PURE__ */ jsxs31("div", { "data-records-reverse-field-refused": "", className: "flex flex-col gap-1", children: [
|
|
7451
|
+
/* @__PURE__ */ jsx33("p", { className: "text-[11px]", children: "The link is made. Its column on the other table was not:" }),
|
|
7452
|
+
/* @__PURE__ */ jsx33(RefusalNotice, { error: reverseRefused })
|
|
7227
7453
|
] }) : null,
|
|
7228
|
-
backfillError ? /* @__PURE__ */
|
|
7229
|
-
/* @__PURE__ */
|
|
7230
|
-
/* @__PURE__ */
|
|
7454
|
+
backfillError ? /* @__PURE__ */ jsxs31("div", { "data-records-autonumber-backfill-refused": "", className: "flex flex-col gap-1", children: [
|
|
7455
|
+
/* @__PURE__ */ jsx33("p", { className: "text-[11px]", children: "The column is made. The records already in the table were not numbered:" }),
|
|
7456
|
+
/* @__PURE__ */ jsx33(RefusalNotice, { error: backfillError })
|
|
7231
7457
|
] }) : null,
|
|
7232
|
-
/* @__PURE__ */
|
|
7233
|
-
/* @__PURE__ */
|
|
7458
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex min-w-0 flex-nowrap items-center gap-2", "data-field-editor-footer": "", children: [
|
|
7459
|
+
/* @__PURE__ */ jsx33(
|
|
7234
7460
|
Button15,
|
|
7235
7461
|
{
|
|
7236
7462
|
size: "sm",
|
|
@@ -7246,8 +7472,8 @@ function FieldEditor(props) {
|
|
|
7246
7472
|
children: mutation.saving ? "Saving\u2026" : field ? EDIT_FIELD_SAVE_LABEL : onEntity ? ADD_STANDARD_FIELD_SAVE_LABEL : ADD_FIELD_SAVE_LABEL
|
|
7247
7473
|
}
|
|
7248
7474
|
),
|
|
7249
|
-
onCancel ? /* @__PURE__ */
|
|
7250
|
-
/* @__PURE__ */
|
|
7475
|
+
onCancel ? /* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }) : null,
|
|
7476
|
+
/* @__PURE__ */ jsx33(
|
|
7251
7477
|
"span",
|
|
7252
7478
|
{
|
|
7253
7479
|
id: "field-editor-missing",
|
|
@@ -7263,11 +7489,11 @@ function FieldEditor(props) {
|
|
|
7263
7489
|
footer is always as wide and as tall as its larger state: opening the confirm moved
|
|
7264
7490
|
the dialog card 0.2278 and closing it 0.1303. The consequence is the tooltip of
|
|
7265
7491
|
"Remove it" (interface-text: the slot holds a label, never a paragraph). */
|
|
7266
|
-
/* @__PURE__ */
|
|
7267
|
-
/* @__PURE__ */
|
|
7268
|
-
/* @__PURE__ */
|
|
7269
|
-
/* @__PURE__ */
|
|
7270
|
-
/* @__PURE__ */
|
|
7492
|
+
/* @__PURE__ */ jsxs31("div", { className: "ml-auto grid shrink-0 items-center", "data-field-editor-remove": askingToRemove ? "asking" : "idle", children: [
|
|
7493
|
+
/* @__PURE__ */ jsx33("div", { className: cn22("col-start-1 row-start-1 flex items-center justify-end gap-2", askingToRemove && "invisible"), "aria-hidden": askingToRemove || void 0, children: /* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "outline", tabIndex: askingToRemove ? -1 : void 0, onClick: () => setAskingToRemove(true), children: "Remove this field" }) }),
|
|
7494
|
+
/* @__PURE__ */ jsxs31("div", { className: cn22("col-start-1 row-start-1 flex items-center justify-end gap-2", !askingToRemove && "invisible"), "aria-hidden": !askingToRemove || void 0, children: [
|
|
7495
|
+
/* @__PURE__ */ jsx33("span", { className: "whitespace-nowrap text-destructive", "data-field-editor-remove-ask": "", children: "Archive this field?" }),
|
|
7496
|
+
/* @__PURE__ */ jsx33(
|
|
7271
7497
|
Button15,
|
|
7272
7498
|
{
|
|
7273
7499
|
size: "sm",
|
|
@@ -7280,7 +7506,7 @@ function FieldEditor(props) {
|
|
|
7280
7506
|
children: "Remove it"
|
|
7281
7507
|
}
|
|
7282
7508
|
),
|
|
7283
|
-
/* @__PURE__ */
|
|
7509
|
+
/* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "ghost", tabIndex: askingToRemove ? void 0 : -1, onClick: () => setAskingToRemove(false), children: "Keep it" })
|
|
7284
7510
|
] })
|
|
7285
7511
|
] })
|
|
7286
7512
|
) : null
|
|
@@ -7371,10 +7597,10 @@ function formulaSeparatorOf(field) {
|
|
|
7371
7597
|
function TypeQuestions(props) {
|
|
7372
7598
|
const { type } = props;
|
|
7373
7599
|
if (type === "entity_reference") {
|
|
7374
|
-
return /* @__PURE__ */
|
|
7600
|
+
return /* @__PURE__ */ jsx33(EntityReferenceKindPicker, { value: props.allowedTypes, onChange: props.setAllowedTypes, locked: props.editing });
|
|
7375
7601
|
}
|
|
7376
7602
|
if (type === "relation") {
|
|
7377
|
-
return /* @__PURE__ */
|
|
7603
|
+
return /* @__PURE__ */ jsx33(
|
|
7378
7604
|
ReferenceBuilder,
|
|
7379
7605
|
{
|
|
7380
7606
|
tableId: props.tableId,
|
|
@@ -7387,20 +7613,20 @@ function TypeQuestions(props) {
|
|
|
7387
7613
|
}
|
|
7388
7614
|
);
|
|
7389
7615
|
}
|
|
7390
|
-
if (type === "rating" || type === "barcode") return /* @__PURE__ */
|
|
7616
|
+
if (type === "rating" || type === "barcode") return /* @__PURE__ */ jsx33(Fragment10, { children: props.newer });
|
|
7391
7617
|
if (type === "status") {
|
|
7392
|
-
return /* @__PURE__ */
|
|
7618
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-3", children: [
|
|
7393
7619
|
props.choiceList,
|
|
7394
7620
|
props.newer
|
|
7395
7621
|
] });
|
|
7396
7622
|
}
|
|
7397
7623
|
if (type === "select" || type === "multi_select") {
|
|
7398
|
-
return /* @__PURE__ */
|
|
7624
|
+
return /* @__PURE__ */ jsx33(Fragment10, { children: props.choiceList });
|
|
7399
7625
|
}
|
|
7400
7626
|
if (type === "currency") {
|
|
7401
|
-
return /* @__PURE__ */
|
|
7402
|
-
/* @__PURE__ */
|
|
7403
|
-
/* @__PURE__ */
|
|
7627
|
+
return /* @__PURE__ */ jsxs31("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7628
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "The currency" }),
|
|
7629
|
+
/* @__PURE__ */ jsx33(
|
|
7404
7630
|
BasicInput9,
|
|
7405
7631
|
{
|
|
7406
7632
|
value: props.unit,
|
|
@@ -7412,8 +7638,8 @@ function TypeQuestions(props) {
|
|
|
7412
7638
|
] });
|
|
7413
7639
|
}
|
|
7414
7640
|
if (type === "datetime") {
|
|
7415
|
-
return /* @__PURE__ */
|
|
7416
|
-
/* @__PURE__ */
|
|
7641
|
+
return /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7642
|
+
/* @__PURE__ */ jsx33(
|
|
7417
7643
|
Checkbox4,
|
|
7418
7644
|
{
|
|
7419
7645
|
checked: props.withTime,
|
|
@@ -7427,14 +7653,14 @@ function TypeQuestions(props) {
|
|
|
7427
7653
|
if (type === "lookup" || type === "rollup" || type === "count") {
|
|
7428
7654
|
const usable = props.relations;
|
|
7429
7655
|
if (usable.length === 0) {
|
|
7430
|
-
return /* @__PURE__ */
|
|
7656
|
+
return /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No link, Person or File column yet." });
|
|
7431
7657
|
}
|
|
7432
|
-
return /* @__PURE__ */
|
|
7433
|
-
/* @__PURE__ */
|
|
7434
|
-
/* @__PURE__ */
|
|
7435
|
-
/* @__PURE__ */
|
|
7436
|
-
/* @__PURE__ */
|
|
7437
|
-
/* @__PURE__ */
|
|
7658
|
+
return /* @__PURE__ */ jsxs31("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7659
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7660
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: type !== "lookup" ? "Across the records in" : "Read it from" }),
|
|
7661
|
+
/* @__PURE__ */ jsxs31(Select6, { value: props.via, onValueChange: props.setVia, children: [
|
|
7662
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": type !== "lookup" ? "Across the records in" : "Read it from", children: /* @__PURE__ */ jsx33(SelectValue6, { placeholder: "Choose a column" }) }),
|
|
7663
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: usable.map((f) => /* @__PURE__ */ jsxs31(SelectItem6, { value: f.key, children: [
|
|
7438
7664
|
fieldName(f),
|
|
7439
7665
|
isBackLinkSource(f) ? BACK_LINK_SOURCE_SUFFIX : "",
|
|
7440
7666
|
sourceKindOf(f) === "person" ? " \u2014 a person" : sourceKindOf(f) === "file" ? " \u2014 a file" : "",
|
|
@@ -7442,7 +7668,7 @@ function TypeQuestions(props) {
|
|
|
7442
7668
|
] }, f.id)) })
|
|
7443
7669
|
] })
|
|
7444
7670
|
] }),
|
|
7445
|
-
type === "lookup" ? /* @__PURE__ */
|
|
7671
|
+
type === "lookup" ? /* @__PURE__ */ jsx33(
|
|
7446
7672
|
ValueOnTheOtherSide,
|
|
7447
7673
|
{
|
|
7448
7674
|
label: "The value to read",
|
|
@@ -7451,13 +7677,13 @@ function TypeQuestions(props) {
|
|
|
7451
7677
|
value: props.pick,
|
|
7452
7678
|
onChange: props.setPick
|
|
7453
7679
|
}
|
|
7454
|
-
) : type === "count" ? null : /* @__PURE__ */
|
|
7455
|
-
/* @__PURE__ */
|
|
7456
|
-
/* @__PURE__ */
|
|
7457
|
-
/* @__PURE__ */
|
|
7458
|
-
/* @__PURE__ */
|
|
7680
|
+
) : type === "count" ? null : /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7681
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "What to work out" }),
|
|
7682
|
+
/* @__PURE__ */ jsxs31(Select6, { value: props.agg, onValueChange: (v) => props.setAgg(v), children: [
|
|
7683
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "What to work out", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7684
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: ROLLUP_OPERATIONS.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7459
7685
|
] }),
|
|
7460
|
-
props.agg !== "count" ? /* @__PURE__ */
|
|
7686
|
+
props.agg !== "count" ? /* @__PURE__ */ jsx33(
|
|
7461
7687
|
ValueOnTheOtherSide,
|
|
7462
7688
|
{
|
|
7463
7689
|
label: "Of which value",
|
|
@@ -7473,21 +7699,21 @@ function TypeQuestions(props) {
|
|
|
7473
7699
|
}
|
|
7474
7700
|
if (type === "formula") {
|
|
7475
7701
|
if (props.others.length === 0) {
|
|
7476
|
-
return /* @__PURE__ */
|
|
7702
|
+
return /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No other columns yet." });
|
|
7477
7703
|
}
|
|
7478
|
-
return /* @__PURE__ */
|
|
7479
|
-
/* @__PURE__ */
|
|
7480
|
-
/* @__PURE__ */
|
|
7481
|
-
/* @__PURE__ */
|
|
7482
|
-
/* @__PURE__ */
|
|
7483
|
-
/* @__PURE__ */
|
|
7704
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-2", children: [
|
|
7705
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7706
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "What to do" }),
|
|
7707
|
+
/* @__PURE__ */ jsxs31(Select6, { value: props.formulaOp, onValueChange: props.setFormulaOp, children: [
|
|
7708
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", className: "max-w-[18rem]", "aria-label": "What to do", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7709
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: FORMULA_OPERATIONS.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7484
7710
|
] })
|
|
7485
7711
|
] }),
|
|
7486
|
-
/* @__PURE__ */
|
|
7487
|
-
/* @__PURE__ */
|
|
7488
|
-
/* @__PURE__ */
|
|
7712
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7713
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Which columns" }),
|
|
7714
|
+
/* @__PURE__ */ jsx33("div", { className: "flex flex-wrap gap-1", children: props.others.map((f) => {
|
|
7489
7715
|
const picked = props.formulaFields.includes(f.id);
|
|
7490
|
-
return /* @__PURE__ */
|
|
7716
|
+
return /* @__PURE__ */ jsx33(
|
|
7491
7717
|
Button15,
|
|
7492
7718
|
{
|
|
7493
7719
|
type: "button",
|
|
@@ -7502,9 +7728,9 @@ function TypeQuestions(props) {
|
|
|
7502
7728
|
);
|
|
7503
7729
|
}) })
|
|
7504
7730
|
] }),
|
|
7505
|
-
props.formulaOp === "concat" ? /* @__PURE__ */
|
|
7506
|
-
/* @__PURE__ */
|
|
7507
|
-
/* @__PURE__ */
|
|
7731
|
+
props.formulaOp === "concat" ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7732
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: FORMULA_SEPARATOR_LABEL }),
|
|
7733
|
+
/* @__PURE__ */ jsx33(
|
|
7508
7734
|
BasicInput9,
|
|
7509
7735
|
{
|
|
7510
7736
|
value: props.formulaSeparator,
|
|
@@ -7555,25 +7781,25 @@ function RollupFilterQuestion({
|
|
|
7555
7781
|
}) {
|
|
7556
7782
|
const far = relation?.relation_target ?? null;
|
|
7557
7783
|
const farFields = useFields2(far);
|
|
7558
|
-
const conditionFields =
|
|
7784
|
+
const conditionFields = useMemo11(
|
|
7559
7785
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7560
7786
|
[farFields.data]
|
|
7561
7787
|
);
|
|
7562
|
-
const lastFar =
|
|
7563
|
-
|
|
7788
|
+
const lastFar = useRef13(far);
|
|
7789
|
+
useEffect18(() => {
|
|
7564
7790
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7565
7791
|
lastFar.current = far;
|
|
7566
7792
|
}, [far, editing, onChange]);
|
|
7567
7793
|
if (!relation || !far) return null;
|
|
7568
|
-
return /* @__PURE__ */
|
|
7569
|
-
/* @__PURE__ */
|
|
7794
|
+
return /* @__PURE__ */ jsx33("div", { className: "flex flex-col gap-1", "data-records-rollup-filter": "", children: !conditionIsDrawable(value) ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
7795
|
+
/* @__PURE__ */ jsxs31("span", { className: "text-muted-foreground", children: [
|
|
7570
7796
|
rollupFilterLead(agg),
|
|
7571
7797
|
" ",
|
|
7572
7798
|
conditionInWords(value, conditionFields),
|
|
7573
7799
|
"."
|
|
7574
7800
|
] }),
|
|
7575
|
-
/* @__PURE__ */
|
|
7576
|
-
] }) : /* @__PURE__ */
|
|
7801
|
+
/* @__PURE__ */ jsx33(Button15, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onChange(null), children: "Clear" })
|
|
7802
|
+
] }) : /* @__PURE__ */ jsx33(
|
|
7577
7803
|
ConditionGroup,
|
|
7578
7804
|
{
|
|
7579
7805
|
lead: rollupFilterLead(agg),
|
|
@@ -7599,13 +7825,13 @@ function ValueOnTheOtherSide({
|
|
|
7599
7825
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7600
7826
|
const offered = declared.length > 0 ? declared.map((f) => ({ key: f.key, name: fieldName(f) })) : Object.keys(carried ?? {}).map((key) => ({ key, name: humanizeIdentifier4(key) }));
|
|
7601
7827
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
7602
|
-
const body = !relation ? /* @__PURE__ */
|
|
7603
|
-
/* @__PURE__ */
|
|
7604
|
-
/* @__PURE__ */
|
|
7828
|
+
const body = !relation ? /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "Choose the column above first." }) : stillAsking ? /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "Reading that table's columns\u2026" }) : offered.length === 0 ? /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No columns to read yet." }) : /* @__PURE__ */ jsxs31(Select6, { value, onValueChange: onChange, children: [
|
|
7829
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": label, children: /* @__PURE__ */ jsx33(SelectValue6, { placeholder: "Choose a column" }) }),
|
|
7830
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: offered.map((column) => /* @__PURE__ */ jsx33(SelectItem6, { value: column.key, children: column.name }, column.key)) })
|
|
7605
7831
|
] });
|
|
7606
|
-
if (compact) return /* @__PURE__ */
|
|
7607
|
-
return /* @__PURE__ */
|
|
7608
|
-
/* @__PURE__ */
|
|
7832
|
+
if (compact) return /* @__PURE__ */ jsx33("div", { className: "mt-1 flex flex-col gap-1", children: body });
|
|
7833
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7834
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", title: help, children: label }),
|
|
7609
7835
|
body
|
|
7610
7836
|
] });
|
|
7611
7837
|
}
|
|
@@ -7631,18 +7857,18 @@ function NewColumnDefault({
|
|
|
7631
7857
|
onChange
|
|
7632
7858
|
}) {
|
|
7633
7859
|
const none = "__none__";
|
|
7634
|
-
return /* @__PURE__ */
|
|
7635
|
-
/* @__PURE__ */
|
|
7636
|
-
type === "checkbox" ? /* @__PURE__ */
|
|
7637
|
-
/* @__PURE__ */
|
|
7638
|
-
/* @__PURE__ */
|
|
7639
|
-
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */
|
|
7640
|
-
/* @__PURE__ */
|
|
7641
|
-
/* @__PURE__ */
|
|
7642
|
-
/* @__PURE__ */
|
|
7643
|
-
choices.map((c) => /* @__PURE__ */
|
|
7860
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", "data-records-field-default": "", "data-records-new-field-default": "", children: [
|
|
7861
|
+
/* @__PURE__ */ jsx33(Label8, { htmlFor: "records-new-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7862
|
+
type === "checkbox" ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-2", children: [
|
|
7863
|
+
/* @__PURE__ */ jsx33(Checkbox4, { id: "records-new-field-default", "aria-label": DEFAULT_LABEL, checked: value === true, onCheckedChange: (on) => onChange(on === true ? true : null) }),
|
|
7864
|
+
/* @__PURE__ */ jsx33("span", { children: "Ticked" })
|
|
7865
|
+
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */ jsxs31(Select6, { value: typeof value === "string" && choices.includes(value) ? value : none, onValueChange: (v) => onChange(v === none ? null : v), children: [
|
|
7866
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { id: "records-new-field-default", size: "sm", "aria-label": DEFAULT_LABEL, children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7867
|
+
/* @__PURE__ */ jsxs31(SelectContent6, { children: [
|
|
7868
|
+
/* @__PURE__ */ jsx33(SelectItem6, { value: none, children: "Nothing" }),
|
|
7869
|
+
choices.map((c) => /* @__PURE__ */ jsx33(SelectItem6, { value: c, children: c }, c))
|
|
7644
7870
|
] })
|
|
7645
|
-
] }) : /* @__PURE__ */
|
|
7871
|
+
] }) : /* @__PURE__ */ jsx33(
|
|
7646
7872
|
BasicInput9,
|
|
7647
7873
|
{
|
|
7648
7874
|
id: "records-new-field-default",
|
|
@@ -7657,7 +7883,7 @@ function NewColumnDefault({
|
|
|
7657
7883
|
// src/buttonCell.tsx
|
|
7658
7884
|
import { OutboundLink as OutboundLink6 } from "@ai-matrx/kit/outbound-react";
|
|
7659
7885
|
import { openOutbound } from "@ai-matrx/kit/outbound";
|
|
7660
|
-
import { Fragment as
|
|
7886
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7661
7887
|
function buttonPressWords(label, pressed) {
|
|
7662
7888
|
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
7663
7889
|
if (pressed.do === "run_action") {
|
|
@@ -7669,11 +7895,11 @@ function buttonPressWords(label, pressed) {
|
|
|
7669
7895
|
}
|
|
7670
7896
|
var stop = (event) => event.stopPropagation();
|
|
7671
7897
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7672
|
-
const client =
|
|
7898
|
+
const client = useOptionalRecordsClient9();
|
|
7673
7899
|
const b = buttonOf2(field);
|
|
7674
|
-
const [busy, setBusy] =
|
|
7675
|
-
const [said2, setSaid] =
|
|
7676
|
-
const [settingUp, setSettingUp] =
|
|
7900
|
+
const [busy, setBusy] = useState25(false);
|
|
7901
|
+
const [said2, setSaid] = useState25(null);
|
|
7902
|
+
const [settingUp, setSettingUp] = useState25(false);
|
|
7677
7903
|
if (!b) return null;
|
|
7678
7904
|
const color = isStyleColor2(b.color) ? CHOICE_CHIP_CLASS2[b.color] : NEUTRAL_CHIP_CLASS2;
|
|
7679
7905
|
const needs = buttonNeeds2(b);
|
|
@@ -7692,9 +7918,9 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7692
7918
|
}
|
|
7693
7919
|
setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
|
|
7694
7920
|
};
|
|
7695
|
-
return /* @__PURE__ */
|
|
7696
|
-
/* @__PURE__ */
|
|
7697
|
-
/* @__PURE__ */
|
|
7921
|
+
return /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
7922
|
+
/* @__PURE__ */ jsxs32(Popover4, { open: said2 !== null, onOpenChange: (open) => open ? null : setSaid(null), children: [
|
|
7923
|
+
/* @__PURE__ */ jsx34(PopoverTrigger4, { asChild: true, children: /* @__PURE__ */ jsx34(
|
|
7698
7924
|
Button16,
|
|
7699
7925
|
{
|
|
7700
7926
|
type: "button",
|
|
@@ -7704,7 +7930,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7704
7930
|
"data-records-button-unset": needs ? "" : void 0,
|
|
7705
7931
|
"aria-busy": busy || void 0,
|
|
7706
7932
|
disabled: busy,
|
|
7707
|
-
className:
|
|
7933
|
+
className: cn23("max-w-full gap-1 border px-2 font-medium", inCell ? "h-5" : "h-6", color, needs && "border-dashed opacity-80"),
|
|
7708
7934
|
onPointerDown: stop,
|
|
7709
7935
|
onDoubleClick: stop,
|
|
7710
7936
|
onClick: (event) => {
|
|
@@ -7712,20 +7938,20 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7712
7938
|
event.preventDefault();
|
|
7713
7939
|
void press();
|
|
7714
7940
|
},
|
|
7715
|
-
children: /* @__PURE__ */
|
|
7941
|
+
children: /* @__PURE__ */ jsx34("span", { className: "truncate", children: b.label })
|
|
7716
7942
|
}
|
|
7717
7943
|
) }),
|
|
7718
|
-
/* @__PURE__ */
|
|
7719
|
-
said2?.kind === "refused" ? /* @__PURE__ */
|
|
7720
|
-
said2?.kind === "public" ? /* @__PURE__ */
|
|
7721
|
-
said2?.kind === "ran" ? /* @__PURE__ */
|
|
7944
|
+
/* @__PURE__ */ jsxs32(PopoverContent4, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
|
|
7945
|
+
said2?.kind === "refused" ? /* @__PURE__ */ jsx34(RefusalLine, { error: said2.error }) : null,
|
|
7946
|
+
said2?.kind === "public" ? /* @__PURE__ */ jsx34("p", { children: "Buttons run for signed-in people." }) : null,
|
|
7947
|
+
said2?.kind === "ran" ? /* @__PURE__ */ jsxs32("p", { className: "break-words", children: [
|
|
7722
7948
|
said2.says,
|
|
7723
7949
|
" ",
|
|
7724
|
-
said2.link ? /* @__PURE__ */
|
|
7950
|
+
said2.link ? /* @__PURE__ */ jsx34(OutboundLink6, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
7725
7951
|
] }) : null,
|
|
7726
|
-
said2?.kind === "needs" ? /* @__PURE__ */
|
|
7727
|
-
/* @__PURE__ */
|
|
7728
|
-
tableId ? /* @__PURE__ */
|
|
7952
|
+
said2?.kind === "needs" ? /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
7953
|
+
/* @__PURE__ */ jsx34("p", { children: said2.says }),
|
|
7954
|
+
tableId ? /* @__PURE__ */ jsxs32(
|
|
7729
7955
|
Button16,
|
|
7730
7956
|
{
|
|
7731
7957
|
type: "button",
|
|
@@ -7744,202 +7970,16 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7744
7970
|
] }) : null
|
|
7745
7971
|
] })
|
|
7746
7972
|
] }),
|
|
7747
|
-
settingUp && tableId ? /* @__PURE__ */
|
|
7748
|
-
/* @__PURE__ */
|
|
7749
|
-
/* @__PURE__ */
|
|
7750
|
-
/* @__PURE__ */
|
|
7973
|
+
settingUp && tableId ? /* @__PURE__ */ jsx34(Dialog2, { open: true, onOpenChange: (open) => open ? null : setSettingUp(false), children: /* @__PURE__ */ jsxs32(DialogContent2, { className: "max-h-[85vh] overflow-y-auto sm:max-w-2xl", onClick: stop, onPointerDown: stop, children: [
|
|
7974
|
+
/* @__PURE__ */ jsxs32(DialogHeader2, { children: [
|
|
7975
|
+
/* @__PURE__ */ jsx34(DialogTitle2, { children: `Column settings \xB7 ${fieldName(field)}` }),
|
|
7976
|
+
/* @__PURE__ */ jsx34(DialogDescription, { className: "sr-only", children: "What the button does" })
|
|
7751
7977
|
] }),
|
|
7752
|
-
/* @__PURE__ */
|
|
7978
|
+
/* @__PURE__ */ jsx34(FieldEditor, { tableId, field, onSaved: () => setSettingUp(false), onCancel: () => setSettingUp(false) })
|
|
7753
7979
|
] }) }) : null
|
|
7754
7980
|
] });
|
|
7755
7981
|
}
|
|
7756
7982
|
|
|
7757
|
-
// src/PersonPicker.tsx
|
|
7758
|
-
import { useCallback as useCallback6, useEffect as useEffect18, useMemo as useMemo11, useRef as useRef13, useState as useState25 } from "react";
|
|
7759
|
-
import { rankTypedMatches as rankTypedMatches3 } from "@ai-matrx/records";
|
|
7760
|
-
import { useOptionalRecordsClient as useOptionalRecordsClient9 } from "@ai-matrx/records/react";
|
|
7761
|
-
import { cn as cn23 } from "@ai-matrx/design-system";
|
|
7762
|
-
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7763
|
-
function personFromRow(row) {
|
|
7764
|
-
const data = row.document ?? {};
|
|
7765
|
-
const userId = data["user_id"];
|
|
7766
|
-
return {
|
|
7767
|
-
id: row.id,
|
|
7768
|
-
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
7769
|
-
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
7770
|
-
};
|
|
7771
|
-
}
|
|
7772
|
-
function memberName(member) {
|
|
7773
|
-
const display = (member.name ?? "").trim();
|
|
7774
|
-
if (display !== "") return display;
|
|
7775
|
-
const email = (member.email ?? "").trim();
|
|
7776
|
-
if (email !== "") return email;
|
|
7777
|
-
return "A member with no name set";
|
|
7778
|
-
}
|
|
7779
|
-
async function personRecordForMember(client, personTableId, people, member) {
|
|
7780
|
-
const held = people.find((p) => p.userId === member.userId);
|
|
7781
|
-
if (held) return { ok: true, data: held.id };
|
|
7782
|
-
const written = await client.recordWrite({
|
|
7783
|
-
table_id: personTableId,
|
|
7784
|
-
data: {
|
|
7785
|
-
user_id: member.userId,
|
|
7786
|
-
full_name: memberName(member),
|
|
7787
|
-
...member.email ? { email: member.email } : {}
|
|
7788
|
-
}
|
|
7789
|
-
});
|
|
7790
|
-
return written;
|
|
7791
|
-
}
|
|
7792
|
-
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
7793
|
-
const client = useOptionalRecordsClient9();
|
|
7794
|
-
const host = useRecordsUi();
|
|
7795
|
-
const [members, setMembers] = useState25(null);
|
|
7796
|
-
const [people, setPeople] = useState25([]);
|
|
7797
|
-
const [error, setError] = useState25(null);
|
|
7798
|
-
const [search, setSearch] = useState25(initialSearch ?? "");
|
|
7799
|
-
const [open, setOpenState] = useState25(autoOpen === true);
|
|
7800
|
-
const onCloseRef = useRef13(onClose);
|
|
7801
|
-
onCloseRef.current = onClose;
|
|
7802
|
-
const setOpen = useCallback6((next) => {
|
|
7803
|
-
setOpenState(next);
|
|
7804
|
-
if (!next) onCloseRef.current?.();
|
|
7805
|
-
}, []);
|
|
7806
|
-
const [busy, setBusy] = useState25(false);
|
|
7807
|
-
const membersPort = host.members;
|
|
7808
|
-
const personTable = field.relation_target;
|
|
7809
|
-
const picked = useMemo11(
|
|
7810
|
-
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
7811
|
-
[value]
|
|
7812
|
-
);
|
|
7813
|
-
const load = useCallback6(async () => {
|
|
7814
|
-
if (!membersPort || !client) return;
|
|
7815
|
-
const [roster, records] = await Promise.all([
|
|
7816
|
-
membersPort(),
|
|
7817
|
-
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
7818
|
-
]);
|
|
7819
|
-
setMembers(roster);
|
|
7820
|
-
if (records && !records.ok) {
|
|
7821
|
-
setError(records.error);
|
|
7822
|
-
return;
|
|
7823
|
-
}
|
|
7824
|
-
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
7825
|
-
}, [membersPort, client, personTable]);
|
|
7826
|
-
useEffect18(() => {
|
|
7827
|
-
if (!open) return;
|
|
7828
|
-
void load();
|
|
7829
|
-
}, [open, load]);
|
|
7830
|
-
useEffect18(() => {
|
|
7831
|
-
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
7832
|
-
let cancelled = false;
|
|
7833
|
-
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
7834
|
-
if (cancelled || !result.ok) return;
|
|
7835
|
-
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
7836
|
-
});
|
|
7837
|
-
return () => {
|
|
7838
|
-
cancelled = true;
|
|
7839
|
-
};
|
|
7840
|
-
}, [client, personTable, picked.length, people.length]);
|
|
7841
|
-
const listed = rankTypedMatches3(members ?? [], search, memberName);
|
|
7842
|
-
if (!membersPort || !client) {
|
|
7843
|
-
return /* @__PURE__ */ jsx34("p", { className: cn23("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
7844
|
-
}
|
|
7845
|
-
if (!personTable) {
|
|
7846
|
-
return /* @__PURE__ */ jsxs32("p", { className: cn23("text-xs text-muted-foreground", className), children: [
|
|
7847
|
-
fieldName(field),
|
|
7848
|
-
" 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."
|
|
7849
|
-
] });
|
|
7850
|
-
}
|
|
7851
|
-
const displayNameOf = (userId, recordName2) => {
|
|
7852
|
-
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
7853
|
-
const own3 = (member?.name ?? "").trim();
|
|
7854
|
-
if (own3 !== "") return own3;
|
|
7855
|
-
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
7856
|
-
const email = (member?.email ?? "").trim();
|
|
7857
|
-
return kept !== "" && kept !== email ? kept : null;
|
|
7858
|
-
};
|
|
7859
|
-
const nameOfRecord = (recordId) => {
|
|
7860
|
-
const person = people.find((p) => p.id === recordId);
|
|
7861
|
-
if (!person) return "Loading\u2026";
|
|
7862
|
-
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
7863
|
-
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
7864
|
-
};
|
|
7865
|
-
const pick = async (member) => {
|
|
7866
|
-
setBusy(true);
|
|
7867
|
-
setError(null);
|
|
7868
|
-
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
7869
|
-
setBusy(false);
|
|
7870
|
-
if (!resolved.ok) {
|
|
7871
|
-
setError(resolved.error);
|
|
7872
|
-
return;
|
|
7873
|
-
}
|
|
7874
|
-
if (!people.some((p) => p.id === resolved.data)) {
|
|
7875
|
-
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
7876
|
-
}
|
|
7877
|
-
if (!field.multi) {
|
|
7878
|
-
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
7879
|
-
setOpen(false);
|
|
7880
|
-
return;
|
|
7881
|
-
}
|
|
7882
|
-
const next = new Set(picked);
|
|
7883
|
-
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
7884
|
-
else next.add(resolved.data);
|
|
7885
|
-
onChange(next.size === 0 ? null : [...next]);
|
|
7886
|
-
};
|
|
7887
|
-
const drop = (recordId) => {
|
|
7888
|
-
const next = picked.filter((id2) => id2 !== recordId);
|
|
7889
|
-
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
7890
|
-
};
|
|
7891
|
-
const visible = listed;
|
|
7892
|
-
const pickedUserIds = new Set(
|
|
7893
|
-
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
7894
|
-
);
|
|
7895
|
-
const anchored = autoOpen === true;
|
|
7896
|
-
const cellChips = picked.map((recordId) => /* @__PURE__ */ jsx34(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
7897
|
-
return /* @__PURE__ */ jsxs32("div", { className: cn23("flex flex-wrap items-center gap-1", className), children: [
|
|
7898
|
-
anchored && !disabled ? null : cellChips,
|
|
7899
|
-
disabled ? null : (
|
|
7900
|
-
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
7901
|
-
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
7902
|
-
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
7903
|
-
/* @__PURE__ */ jsx34(
|
|
7904
|
-
PickOrAdd,
|
|
7905
|
-
{
|
|
7906
|
-
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
7907
|
-
anchored,
|
|
7908
|
-
multi: field.multi,
|
|
7909
|
-
triggerId: id,
|
|
7910
|
-
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
7911
|
-
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
7912
|
-
open,
|
|
7913
|
-
onOpenChange: setOpen,
|
|
7914
|
-
search,
|
|
7915
|
-
onSearch: setSearch,
|
|
7916
|
-
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
7917
|
-
items: visible.map((member) => ({
|
|
7918
|
-
id: member.userId,
|
|
7919
|
-
label: displayNameOf(member.userId) ?? memberName(member),
|
|
7920
|
-
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
7921
|
-
// 19 September). They are two facts, so they are drawn as two.
|
|
7922
|
-
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
7923
|
-
picked: pickedUserIds.has(member.userId),
|
|
7924
|
-
person: true,
|
|
7925
|
-
disabled: busy
|
|
7926
|
-
})),
|
|
7927
|
-
onPick: (userId) => {
|
|
7928
|
-
const member = visible.find((m) => m.userId === userId);
|
|
7929
|
-
if (member && !busy) void pick(member);
|
|
7930
|
-
},
|
|
7931
|
-
notice: /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
7932
|
-
error ? /* @__PURE__ */ jsx34(RefusalLine, { error, className: "p-2" }) : null,
|
|
7933
|
-
members === null ? /* @__PURE__ */ jsx34("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
7934
|
-
] }),
|
|
7935
|
-
empty: members !== null ? /* @__PURE__ */ jsx34("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,
|
|
7936
|
-
children: anchored ? cellChips : null
|
|
7937
|
-
}
|
|
7938
|
-
)
|
|
7939
|
-
)
|
|
7940
|
-
] });
|
|
7941
|
-
}
|
|
7942
|
-
|
|
7943
7983
|
// src/FloatingRefusal.tsx
|
|
7944
7984
|
import { useLayoutEffect, useRef as useRef14, useState as useState26 } from "react";
|
|
7945
7985
|
import { createPortal } from "react-dom";
|