@ai-matrx/records-ui 0.115.83 → 0.115.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/helpers.d.cts +7 -0
- package/dist/helpers.d.ts +7 -0
- package/dist/index.cjs +2617 -2581
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +403 -367
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +764 -762
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +660 -658
- package/dist/pickers.js.map +1 -1
- package/package.json +2 -2
package/dist/pickers.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";
|
|
@@ -4566,11 +4566,199 @@ function formulaSourceArchived(field, document2) {
|
|
|
4566
4566
|
|
|
4567
4567
|
// src/values.tsx
|
|
4568
4568
|
import { autonumberPrefixOf as autonumberPrefixOf2, autonumberWords as autonumberWords2, isButtonField as isButtonField2, newerKindWords, sourceArchivedOf as sourceArchivedOf2 } from "@ai-matrx/records";
|
|
4569
|
-
|
|
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";
|
|
4570
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";
|
|
4571
4759
|
function statusMark(field, item, document2) {
|
|
4572
4760
|
const mark = statusMarkOf(field, item, document2);
|
|
4573
|
-
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;
|
|
4574
4762
|
}
|
|
4575
4763
|
function envelopeFor(document2, key) {
|
|
4576
4764
|
const block = document2?._values;
|
|
@@ -4616,48 +4804,48 @@ function sourceArchivedSentence(state2) {
|
|
|
4616
4804
|
return state2.table ? `${state2.label} on ${state2.table} is archived` : `${state2.label} is archived`;
|
|
4617
4805
|
}
|
|
4618
4806
|
function SourceArchivedValue({ state: state2 }) {
|
|
4619
|
-
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 });
|
|
4620
4808
|
}
|
|
4621
4809
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4622
4810
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4623
4811
|
const archivedSource = sourceArchivedOf2(value);
|
|
4624
|
-
if (archivedSource) return /* @__PURE__ */
|
|
4812
|
+
if (archivedSource) return /* @__PURE__ */ jsx24(SourceArchivedValue, { state: archivedSource });
|
|
4625
4813
|
const envelope = envelopeFor(document2, field.key);
|
|
4626
4814
|
if (envelope?.absent) {
|
|
4627
|
-
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) });
|
|
4628
4816
|
}
|
|
4629
4817
|
if (value === null || value === void 0 || value === "") {
|
|
4630
4818
|
const gone = unresolvedFor(document2, field.key);
|
|
4631
4819
|
if (gone) {
|
|
4632
|
-
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" });
|
|
4633
4821
|
}
|
|
4634
4822
|
const archivedInput = formulaSourceArchived(field, document2);
|
|
4635
|
-
if (archivedInput) return /* @__PURE__ */
|
|
4823
|
+
if (archivedInput) return /* @__PURE__ */ jsx24(SourceArchivedValue, { state: archivedInput });
|
|
4636
4824
|
const computed = computedEmptyOf(field, document2);
|
|
4637
|
-
if (computed?.sentence) return /* @__PURE__ */
|
|
4638
|
-
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 });
|
|
4639
4827
|
if (computed?.why) {
|
|
4640
|
-
return /* @__PURE__ */
|
|
4828
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
|
|
4641
4829
|
}
|
|
4642
4830
|
if (look?.blankEmpty) return null;
|
|
4643
|
-
return /* @__PURE__ */
|
|
4831
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4644
4832
|
}
|
|
4645
|
-
if (isSignatureField(field)) return /* @__PURE__ */
|
|
4646
|
-
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 });
|
|
4647
4835
|
const newer = newerKindValue(field, value);
|
|
4648
4836
|
if (newer !== void 0) return newer;
|
|
4649
4837
|
const whole = typeof value === "string" ? wholeValueOf(document2, field.key) : null;
|
|
4650
|
-
if (whole) return /* @__PURE__ */
|
|
4838
|
+
if (whole) return /* @__PURE__ */ jsx24(WholeValueCell, { words: value, pointer: whole });
|
|
4651
4839
|
const kind = editorKindFor(field);
|
|
4652
4840
|
if (kind === "relation" || kind === "entity_reference") {
|
|
4653
|
-
return /* @__PURE__ */
|
|
4841
|
+
return /* @__PURE__ */ jsx24(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
|
|
4654
4842
|
}
|
|
4655
4843
|
if (kind === "member") {
|
|
4656
4844
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4657
|
-
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}`)) });
|
|
4658
4846
|
}
|
|
4659
4847
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4660
|
-
if (kv) return /* @__PURE__ */
|
|
4848
|
+
if (kv) return /* @__PURE__ */ jsx24(KindValueCell, { kv, where: "cell", title: field.label });
|
|
4661
4849
|
const chosen = kind === "select" || kind === "multi_select";
|
|
4662
4850
|
const chipOf = (item) => {
|
|
4663
4851
|
const chipLook = choiceChipLookOf(field, item, scalarText(field, item, labels));
|
|
@@ -4665,17 +4853,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4665
4853
|
};
|
|
4666
4854
|
if (chosen) {
|
|
4667
4855
|
const items = Array.isArray(value) ? value : [value];
|
|
4668
|
-
return /* @__PURE__ */
|
|
4856
|
+
return /* @__PURE__ */ jsx24("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
|
|
4669
4857
|
const chip = chipOf(item);
|
|
4670
|
-
return /* @__PURE__ */
|
|
4858
|
+
return /* @__PURE__ */ jsxs22(
|
|
4671
4859
|
Badge5,
|
|
4672
4860
|
{
|
|
4673
4861
|
variant: "outline",
|
|
4674
|
-
className:
|
|
4862
|
+
className: cn20("text-[11px]", chip.className),
|
|
4675
4863
|
"data-records-choice-chip": "",
|
|
4676
4864
|
...chip.tinted ? { "data-records-choice-tint": "" } : {},
|
|
4677
4865
|
children: [
|
|
4678
|
-
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,
|
|
4679
4867
|
statusMark(field, item, Array.isArray(value) ? void 0 : document2),
|
|
4680
4868
|
scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
|
|
4681
4869
|
]
|
|
@@ -4684,13 +4872,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4684
4872
|
);
|
|
4685
4873
|
}) });
|
|
4686
4874
|
}
|
|
4687
|
-
if (kind === "attachment") return /* @__PURE__ */
|
|
4875
|
+
if (kind === "attachment") return /* @__PURE__ */ jsx24(AttachmentChips, { value });
|
|
4688
4876
|
if (Array.isArray(value)) {
|
|
4689
|
-
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}`)) });
|
|
4690
4878
|
}
|
|
4691
4879
|
if (kind === "url" && typeof value === "string") {
|
|
4692
4880
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
4693
|
-
return /* @__PURE__ */
|
|
4881
|
+
return /* @__PURE__ */ jsxs22(
|
|
4694
4882
|
OutboundLink5,
|
|
4695
4883
|
{
|
|
4696
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",
|
|
@@ -4699,14 +4887,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4699
4887
|
"data-records-link-chip": "",
|
|
4700
4888
|
onClick: (event) => event.stopPropagation(),
|
|
4701
4889
|
children: [
|
|
4702
|
-
/* @__PURE__ */
|
|
4703
|
-
/* @__PURE__ */
|
|
4890
|
+
/* @__PURE__ */ jsx24("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
|
|
4891
|
+
/* @__PURE__ */ jsx24("span", { className: "truncate", children: linkChipText(value) })
|
|
4704
4892
|
]
|
|
4705
4893
|
}
|
|
4706
4894
|
);
|
|
4707
4895
|
}
|
|
4708
4896
|
if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
|
|
4709
|
-
return /* @__PURE__ */
|
|
4897
|
+
return /* @__PURE__ */ jsx24(
|
|
4710
4898
|
"a",
|
|
4711
4899
|
{
|
|
4712
4900
|
className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
|
|
@@ -4719,12 +4907,12 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4719
4907
|
);
|
|
4720
4908
|
}
|
|
4721
4909
|
if (kind === "email" && typeof value === "string") {
|
|
4722
|
-
return /* @__PURE__ */
|
|
4910
|
+
return /* @__PURE__ */ jsx24("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
|
|
4723
4911
|
}
|
|
4724
4912
|
if (typeof value === "boolean") {
|
|
4725
|
-
return /* @__PURE__ */
|
|
4913
|
+
return /* @__PURE__ */ jsx24("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
|
|
4726
4914
|
}
|
|
4727
|
-
return /* @__PURE__ */
|
|
4915
|
+
return /* @__PURE__ */ jsx24("span", { className: cn20("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
|
|
4728
4916
|
}
|
|
4729
4917
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4730
4918
|
if (value === null || value === void 0) return "\u2014";
|
|
@@ -4767,24 +4955,24 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4767
4955
|
}
|
|
4768
4956
|
|
|
4769
4957
|
// src/SourceArchivedNotice.tsx
|
|
4770
|
-
import { jsx as
|
|
4958
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4771
4959
|
function bringBackLabel(state2) {
|
|
4772
4960
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4773
4961
|
}
|
|
4774
4962
|
function SourceArchivedNotice({ fieldId, tableId }) {
|
|
4775
4963
|
const client = useRecordsClient6();
|
|
4776
|
-
const [state2, setState] =
|
|
4777
|
-
const [busy, setBusy] =
|
|
4778
|
-
const [refused, setRefused] =
|
|
4779
|
-
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 () => {
|
|
4780
4968
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4781
4969
|
if (answer.ok) setState(answer.data);
|
|
4782
4970
|
else setRefused(answer.error);
|
|
4783
4971
|
}, [client, fieldId]);
|
|
4784
|
-
|
|
4972
|
+
useEffect13(() => {
|
|
4785
4973
|
void read();
|
|
4786
4974
|
}, [read]);
|
|
4787
|
-
if (refused && !state2) return /* @__PURE__ */
|
|
4975
|
+
if (refused && !state2) return /* @__PURE__ */ jsx25(RefusalNotice, { error: refused });
|
|
4788
4976
|
if (!state2) return null;
|
|
4789
4977
|
const restore = async () => {
|
|
4790
4978
|
if (!state2.field_id) return;
|
|
@@ -4800,29 +4988,29 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4800
4988
|
tableShapeChanged(tableId);
|
|
4801
4989
|
await read();
|
|
4802
4990
|
};
|
|
4803
|
-
return /* @__PURE__ */
|
|
4991
|
+
return /* @__PURE__ */ jsxs23(
|
|
4804
4992
|
"div",
|
|
4805
4993
|
{
|
|
4806
4994
|
className: "flex flex-wrap items-center gap-2 rounded-md border border-border px-3 py-2",
|
|
4807
4995
|
"data-testid": "source-archived-notice",
|
|
4808
4996
|
"data-field-id": state2.field_id ?? "",
|
|
4809
4997
|
children: [
|
|
4810
|
-
/* @__PURE__ */
|
|
4811
|
-
/* @__PURE__ */
|
|
4812
|
-
/* @__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) })
|
|
4813
5001
|
] }),
|
|
4814
|
-
state2.field_id ? /* @__PURE__ */
|
|
4815
|
-
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
|
|
4816
5004
|
]
|
|
4817
5005
|
}
|
|
4818
5006
|
);
|
|
4819
5007
|
}
|
|
4820
5008
|
|
|
4821
5009
|
// src/Condition.tsx
|
|
4822
|
-
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";
|
|
4823
5011
|
import { BasicInput as BasicInput7, Button as Button12 } from "@ai-matrx/design-system";
|
|
4824
|
-
import { optionKey as optionKey2, optionLabel as optionLabel2, rankTypedMatches as
|
|
4825
|
-
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";
|
|
4826
5014
|
|
|
4827
5015
|
// src/personTime.ts
|
|
4828
5016
|
import { useSyncExternalStore } from "react";
|
|
@@ -4870,7 +5058,7 @@ function usePersonTimeZone() {
|
|
|
4870
5058
|
}
|
|
4871
5059
|
|
|
4872
5060
|
// src/Condition.tsx
|
|
4873
|
-
import { Fragment as
|
|
5061
|
+
import { Fragment as Fragment9, jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4874
5062
|
var CONDITION_OPS = [
|
|
4875
5063
|
{ op: "eq", label: "is" },
|
|
4876
5064
|
{ op: "ne", label: "is not" },
|
|
@@ -4958,11 +5146,11 @@ function isChoiceColumn(f) {
|
|
|
4958
5146
|
return kind === "select" || kind === "multi_select";
|
|
4959
5147
|
}
|
|
4960
5148
|
function ChoiceValue({ field, value, onChange }) {
|
|
4961
|
-
const client =
|
|
4962
|
-
const [choices, setChoices] =
|
|
4963
|
-
const [open, setOpen] =
|
|
4964
|
-
const [search, setSearch] =
|
|
4965
|
-
|
|
5149
|
+
const client = useOptionalRecordsClient7();
|
|
5150
|
+
const [choices, setChoices] = useState20(null);
|
|
5151
|
+
const [open, setOpen] = useState20(false);
|
|
5152
|
+
const [search, setSearch] = useState20("");
|
|
5153
|
+
useEffect14(() => {
|
|
4966
5154
|
if (!client) return;
|
|
4967
5155
|
let cancelled = false;
|
|
4968
5156
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
@@ -4976,7 +5164,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4976
5164
|
};
|
|
4977
5165
|
}, [client, field.id]);
|
|
4978
5166
|
if (!choices || choices.length === 0) {
|
|
4979
|
-
return /* @__PURE__ */
|
|
5167
|
+
return /* @__PURE__ */ jsx26(
|
|
4980
5168
|
BasicInput7,
|
|
4981
5169
|
{
|
|
4982
5170
|
className: "h-8 w-28 text-xs",
|
|
@@ -4986,8 +5174,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4986
5174
|
}
|
|
4987
5175
|
);
|
|
4988
5176
|
}
|
|
4989
|
-
const shown2 =
|
|
4990
|
-
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(
|
|
4991
5179
|
PickOrAdd,
|
|
4992
5180
|
{
|
|
4993
5181
|
triggerSize: "compact",
|
|
@@ -5013,7 +5201,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
5013
5201
|
setOpen(false);
|
|
5014
5202
|
setSearch("");
|
|
5015
5203
|
},
|
|
5016
|
-
empty: /* @__PURE__ */
|
|
5204
|
+
empty: /* @__PURE__ */ jsx26("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
|
|
5017
5205
|
}
|
|
5018
5206
|
) });
|
|
5019
5207
|
}
|
|
@@ -5153,9 +5341,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5153
5341
|
VALUELESS_OPS.has(chosenOp) ? { op: chosenOp, args: [{ field: chosenField }] } : { op: chosenOp, args: [{ field: chosenField }, { const: chosenValue }] }
|
|
5154
5342
|
);
|
|
5155
5343
|
}
|
|
5156
|
-
return /* @__PURE__ */
|
|
5157
|
-
/* @__PURE__ */
|
|
5158
|
-
/* @__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(
|
|
5159
5347
|
PickOne,
|
|
5160
5348
|
{
|
|
5161
5349
|
label: "Condition field",
|
|
@@ -5166,7 +5354,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5166
5354
|
attrs: { "data-condition": "field" }
|
|
5167
5355
|
}
|
|
5168
5356
|
),
|
|
5169
|
-
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */
|
|
5357
|
+
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ jsx26(
|
|
5170
5358
|
"span",
|
|
5171
5359
|
{
|
|
5172
5360
|
className: "rounded bg-destructive px-1.5 py-0.5 text-[11px] font-medium text-destructive-foreground",
|
|
@@ -5175,8 +5363,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5175
5363
|
children: "Missing question"
|
|
5176
5364
|
}
|
|
5177
5365
|
) : null,
|
|
5178
|
-
onField ? /* @__PURE__ */
|
|
5179
|
-
/* @__PURE__ */
|
|
5366
|
+
onField ? /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
5367
|
+
/* @__PURE__ */ jsx26(
|
|
5180
5368
|
PickOne,
|
|
5181
5369
|
{
|
|
5182
5370
|
label: "Condition comparison",
|
|
@@ -5187,7 +5375,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5187
5375
|
attrs: { "data-condition": "comparison" }
|
|
5188
5376
|
}
|
|
5189
5377
|
),
|
|
5190
|
-
relative ? relativeTerm?.takesDays ? /* @__PURE__ */
|
|
5378
|
+
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ jsx26(
|
|
5191
5379
|
BasicInput7,
|
|
5192
5380
|
{
|
|
5193
5381
|
className: "h-8 w-16 text-xs",
|
|
@@ -5204,7 +5392,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5204
5392
|
// is asked for ONE record even when the column holds several: a clause compares
|
|
5205
5393
|
// against one value, and a picker that let somebody choose three would be
|
|
5206
5394
|
// writing an expression this row cannot draw back.
|
|
5207
|
-
/* @__PURE__ */
|
|
5395
|
+
/* @__PURE__ */ jsx26(
|
|
5208
5396
|
RelationPicker,
|
|
5209
5397
|
{
|
|
5210
5398
|
field: { ...chosen.field, multi: false },
|
|
@@ -5215,7 +5403,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5215
5403
|
allowCreate: false
|
|
5216
5404
|
}
|
|
5217
5405
|
)
|
|
5218
|
-
) : 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(
|
|
5219
5407
|
BasicInput7,
|
|
5220
5408
|
{
|
|
5221
5409
|
className: "h-8 w-28 text-xs",
|
|
@@ -5292,7 +5480,7 @@ function ConditionGroup({
|
|
|
5292
5480
|
className
|
|
5293
5481
|
}) {
|
|
5294
5482
|
const { joiner, args } = clausesOf(expr);
|
|
5295
|
-
const [drafting, setDrafting] =
|
|
5483
|
+
const [drafting, setDrafting] = useState20(null);
|
|
5296
5484
|
const nested = depth > 0;
|
|
5297
5485
|
const replaceAt = (index, next) => {
|
|
5298
5486
|
const nextArgs = args.slice();
|
|
@@ -5303,16 +5491,16 @@ function ConditionGroup({
|
|
|
5303
5491
|
const joinWord = (index) => index === 0 ? lead : joiner === "or" || joiner === "none" ? "or" : "and";
|
|
5304
5492
|
const showJoiner = nested || args.length > 1 || joiner === "none" || joiner === "notall";
|
|
5305
5493
|
const opposite = joiner === "or" || joiner === "none" ? "and" : "or";
|
|
5306
|
-
return /* @__PURE__ */
|
|
5494
|
+
return /* @__PURE__ */ jsxs24(
|
|
5307
5495
|
"div",
|
|
5308
5496
|
{
|
|
5309
5497
|
className: className ?? "flex flex-col gap-1 text-xs",
|
|
5310
5498
|
"data-testid": nested ? "condition-nested-group" : "condition-group",
|
|
5311
5499
|
"data-depth": depth,
|
|
5312
5500
|
children: [
|
|
5313
|
-
showJoiner ? /* @__PURE__ */
|
|
5314
|
-
/* @__PURE__ */
|
|
5315
|
-
/* @__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(
|
|
5316
5504
|
PickOne,
|
|
5317
5505
|
{
|
|
5318
5506
|
label: nested ? `How the conditions in this group are joined (level ${depth + 1})` : "How these conditions are joined",
|
|
@@ -5323,7 +5511,7 @@ function ConditionGroup({
|
|
|
5323
5511
|
attrs: { "data-condition": "joiner" }
|
|
5324
5512
|
}
|
|
5325
5513
|
),
|
|
5326
|
-
nested && onRemove ? /* @__PURE__ */
|
|
5514
|
+
nested && onRemove ? /* @__PURE__ */ jsx26(
|
|
5327
5515
|
Button12,
|
|
5328
5516
|
{
|
|
5329
5517
|
size: "sm",
|
|
@@ -5335,7 +5523,7 @@ function ConditionGroup({
|
|
|
5335
5523
|
}
|
|
5336
5524
|
) : null
|
|
5337
5525
|
] }) : null,
|
|
5338
|
-
args.length === 0 ? /* @__PURE__ */
|
|
5526
|
+
args.length === 0 ? /* @__PURE__ */ jsx26(
|
|
5339
5527
|
ConditionRow,
|
|
5340
5528
|
{
|
|
5341
5529
|
lead,
|
|
@@ -5348,7 +5536,7 @@ function ConditionGroup({
|
|
|
5348
5536
|
const group = conditionGroupOf(arg);
|
|
5349
5537
|
const key = `clause-${index}`;
|
|
5350
5538
|
if (group && allowNesting) {
|
|
5351
|
-
return /* @__PURE__ */
|
|
5539
|
+
return /* @__PURE__ */ jsx26("div", { className: "ml-4 rounded border border-dashed p-1", children: /* @__PURE__ */ jsx26(
|
|
5352
5540
|
ConditionGroup,
|
|
5353
5541
|
{
|
|
5354
5542
|
lead: joinWord(index),
|
|
@@ -5362,7 +5550,7 @@ function ConditionGroup({
|
|
|
5362
5550
|
}
|
|
5363
5551
|
) }, key);
|
|
5364
5552
|
}
|
|
5365
|
-
return /* @__PURE__ */
|
|
5553
|
+
return /* @__PURE__ */ jsx26(
|
|
5366
5554
|
ConditionRow,
|
|
5367
5555
|
{
|
|
5368
5556
|
lead: showJoiner || args.length > 1 ? joinWord(index) : lead,
|
|
@@ -5374,7 +5562,7 @@ function ConditionGroup({
|
|
|
5374
5562
|
key
|
|
5375
5563
|
);
|
|
5376
5564
|
}),
|
|
5377
|
-
drafting ? /* @__PURE__ */
|
|
5565
|
+
drafting ? /* @__PURE__ */ jsx26("div", { className: drafting === "group" ? "ml-4 rounded border border-dashed p-1" : void 0, children: /* @__PURE__ */ jsx26(
|
|
5378
5566
|
ConditionRow,
|
|
5379
5567
|
{
|
|
5380
5568
|
lead: drafting === "group" ? `${joinWord(1)}, a group where` : joinWord(1),
|
|
@@ -5389,8 +5577,8 @@ function ConditionGroup({
|
|
|
5389
5577
|
}
|
|
5390
5578
|
}
|
|
5391
5579
|
) }) : null,
|
|
5392
|
-
args.length > 0 && !drafting ? /* @__PURE__ */
|
|
5393
|
-
/* @__PURE__ */
|
|
5580
|
+
args.length > 0 && !drafting ? /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-1", children: [
|
|
5581
|
+
/* @__PURE__ */ jsx26(
|
|
5394
5582
|
Button12,
|
|
5395
5583
|
{
|
|
5396
5584
|
size: "sm",
|
|
@@ -5401,7 +5589,7 @@ function ConditionGroup({
|
|
|
5401
5589
|
children: "Add another condition"
|
|
5402
5590
|
}
|
|
5403
5591
|
),
|
|
5404
|
-
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */
|
|
5592
|
+
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ jsx26(
|
|
5405
5593
|
Button12,
|
|
5406
5594
|
{
|
|
5407
5595
|
size: "sm",
|
|
@@ -5419,11 +5607,11 @@ function ConditionGroup({
|
|
|
5419
5607
|
}
|
|
5420
5608
|
|
|
5421
5609
|
// src/FieldRetype.tsx
|
|
5422
|
-
import { useEffect as
|
|
5610
|
+
import { useEffect as useEffect15, useState as useState21 } from "react";
|
|
5423
5611
|
import { previewRetype } from "@ai-matrx/records";
|
|
5424
5612
|
import { tableShapeChanged as tableShapeChanged2, useRecordsClient as useRecordsClient7 } from "@ai-matrx/records/react";
|
|
5425
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";
|
|
5426
|
-
import { jsx as
|
|
5614
|
+
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5427
5615
|
var RETYPE_TARGETS = [
|
|
5428
5616
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
5429
5617
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -5471,15 +5659,15 @@ function currentTarget(field) {
|
|
|
5471
5659
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5472
5660
|
const client = useRecordsClient7();
|
|
5473
5661
|
const notify = useRecordsUi().notify;
|
|
5474
|
-
const [to, setTo] =
|
|
5475
|
-
const [preview, setPreview] =
|
|
5476
|
-
const [asking, setAsking] =
|
|
5477
|
-
const [refusal, setRefusal] =
|
|
5478
|
-
const [busy, setBusy] =
|
|
5479
|
-
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);
|
|
5480
5668
|
const name = fieldName(field);
|
|
5481
5669
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5482
|
-
|
|
5670
|
+
useEffect15(() => {
|
|
5483
5671
|
if (!to) return;
|
|
5484
5672
|
let cancelled = false;
|
|
5485
5673
|
setPreview(null);
|
|
@@ -5500,7 +5688,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5500
5688
|
};
|
|
5501
5689
|
}, [client, tableId, field.key, to]);
|
|
5502
5690
|
if (!retypeableFrom(field)) {
|
|
5503
|
-
return /* @__PURE__ */
|
|
5691
|
+
return /* @__PURE__ */ jsx27("p", { className: "text-[11px] text-muted-foreground", "data-records-retype": "not-here", children: whyNotRetypeable(field) });
|
|
5504
5692
|
}
|
|
5505
5693
|
const change = async () => {
|
|
5506
5694
|
if (!to) return;
|
|
@@ -5549,21 +5737,21 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5549
5737
|
tableShapeChanged2(tableId);
|
|
5550
5738
|
onRetyped?.();
|
|
5551
5739
|
};
|
|
5552
|
-
return /* @__PURE__ */
|
|
5553
|
-
/* @__PURE__ */
|
|
5554
|
-
/* @__PURE__ */
|
|
5555
|
-
/* @__PURE__ */
|
|
5556
|
-
/* @__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)) })
|
|
5557
5745
|
] }),
|
|
5558
|
-
to ? /* @__PURE__ */
|
|
5559
|
-
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
|
|
5560
5748
|
] }),
|
|
5561
|
-
to && asking ? /* @__PURE__ */
|
|
5749
|
+
to && asking ? /* @__PURE__ */ jsxs25("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
5562
5750
|
"Counting ",
|
|
5563
5751
|
name,
|
|
5564
5752
|
"'s values\u2026"
|
|
5565
5753
|
] }) : null,
|
|
5566
|
-
to && preview ? /* @__PURE__ */
|
|
5754
|
+
to && preview ? /* @__PURE__ */ jsxs25("p", { className: "text-[11px] text-muted-foreground", "data-records-retype-preview": "", children: [
|
|
5567
5755
|
preview.converts,
|
|
5568
5756
|
" ",
|
|
5569
5757
|
preview.converts === 1 ? "value converts" : "values convert",
|
|
@@ -5572,16 +5760,16 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5572
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(", ")})` : "") : "",
|
|
5573
5761
|
preview.partial ? ". Counted over the first 1,000 different values." : "."
|
|
5574
5762
|
] }) : null,
|
|
5575
|
-
refusal ? /* @__PURE__ */
|
|
5576
|
-
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
|
|
5577
5765
|
] });
|
|
5578
5766
|
}
|
|
5579
5767
|
|
|
5580
5768
|
// src/FieldRulePreview.tsx
|
|
5581
|
-
import { useEffect as
|
|
5769
|
+
import { useEffect as useEffect16, useMemo as useMemo10, useRef as useRef12, useState as useState22 } from "react";
|
|
5582
5770
|
import { previewRuleChange } from "@ai-matrx/records";
|
|
5583
5771
|
import { useRecordsClient as useRecordsClient8 } from "@ai-matrx/records/react";
|
|
5584
|
-
import { jsx as
|
|
5772
|
+
import { jsx as jsx28, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5585
5773
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5586
5774
|
function ruleWords(rules) {
|
|
5587
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("|");
|
|
@@ -5599,13 +5787,13 @@ function groupValue(value, numbers) {
|
|
|
5599
5787
|
}
|
|
5600
5788
|
function FieldRulePreview({ field, tableId, rules }) {
|
|
5601
5789
|
const client = useRecordsClient8();
|
|
5602
|
-
const [preview, setPreview] =
|
|
5603
|
-
const [refusal, setRefusal] =
|
|
5604
|
-
const key =
|
|
5605
|
-
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);
|
|
5606
5794
|
latest.current = rules;
|
|
5607
5795
|
const name = fieldName(field);
|
|
5608
|
-
|
|
5796
|
+
useEffect16(() => {
|
|
5609
5797
|
let cancelled = false;
|
|
5610
5798
|
setPreview(null);
|
|
5611
5799
|
setRefusal(null);
|
|
@@ -5626,16 +5814,16 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5626
5814
|
clearTimeout(timer);
|
|
5627
5815
|
};
|
|
5628
5816
|
}, [client, tableId, field.key, key]);
|
|
5629
|
-
if (refusal) return /* @__PURE__ */
|
|
5817
|
+
if (refusal) return /* @__PURE__ */ jsx28(RefusalNotice, { error: refusal });
|
|
5630
5818
|
if (!preview) {
|
|
5631
|
-
return /* @__PURE__ */
|
|
5819
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "counting", children: [
|
|
5632
5820
|
"Counting ",
|
|
5633
5821
|
name,
|
|
5634
5822
|
"'s values\u2026"
|
|
5635
5823
|
] });
|
|
5636
5824
|
}
|
|
5637
5825
|
if (preview.keptAside === 0) {
|
|
5638
|
-
return /* @__PURE__ */
|
|
5826
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "fits", children: [
|
|
5639
5827
|
"Every value already in ",
|
|
5640
5828
|
name,
|
|
5641
5829
|
" still fits",
|
|
@@ -5643,7 +5831,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5643
5831
|
"."
|
|
5644
5832
|
] });
|
|
5645
5833
|
}
|
|
5646
|
-
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: [
|
|
5647
5835
|
preview.keptAside,
|
|
5648
5836
|
" ",
|
|
5649
5837
|
preview.keptAside === 1 ? "value no longer fits and will be" : "values no longer fit and will be",
|
|
@@ -5733,7 +5921,7 @@ import {
|
|
|
5733
5921
|
statusGroupOf as statusGroupOf2
|
|
5734
5922
|
} from "@ai-matrx/records";
|
|
5735
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";
|
|
5736
|
-
import { jsx as
|
|
5924
|
+
import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5737
5925
|
var STATUS_STARTING_CHOICES = [
|
|
5738
5926
|
{ words: "Not started", group: "todo" },
|
|
5739
5927
|
{ words: "In progress", group: "in_progress" },
|
|
@@ -5762,13 +5950,13 @@ function StatusGroupsQuestion({
|
|
|
5762
5950
|
onGroup
|
|
5763
5951
|
}) {
|
|
5764
5952
|
if (rows.length === 0) return null;
|
|
5765
|
-
return /* @__PURE__ */
|
|
5766
|
-
/* @__PURE__ */
|
|
5767
|
-
rows.map((r) => /* @__PURE__ */
|
|
5768
|
-
/* @__PURE__ */
|
|
5769
|
-
/* @__PURE__ */
|
|
5770
|
-
/* @__PURE__ */
|
|
5771
|
-
/* @__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: [
|
|
5772
5960
|
STATUS_GROUP_MARK[g],
|
|
5773
5961
|
" ",
|
|
5774
5962
|
STATUS_GROUP_WORDS2[g]
|
|
@@ -5778,11 +5966,11 @@ function StatusGroupsQuestion({
|
|
|
5778
5966
|
] });
|
|
5779
5967
|
}
|
|
5780
5968
|
function RatingMaxQuestion({ value, onChange }) {
|
|
5781
|
-
return /* @__PURE__ */
|
|
5782
|
-
/* @__PURE__ */
|
|
5783
|
-
/* @__PURE__ */
|
|
5784
|
-
/* @__PURE__ */
|
|
5785
|
-
/* @__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: [
|
|
5786
5974
|
n,
|
|
5787
5975
|
" ",
|
|
5788
5976
|
n === 1 ? "star" : "stars"
|
|
@@ -5803,13 +5991,13 @@ var SYMBOLOGY_WORDS = {
|
|
|
5803
5991
|
pdf417: "PDF417"
|
|
5804
5992
|
};
|
|
5805
5993
|
function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
5806
|
-
return /* @__PURE__ */
|
|
5807
|
-
/* @__PURE__ */
|
|
5808
|
-
/* @__PURE__ */
|
|
5809
|
-
/* @__PURE__ */
|
|
5810
|
-
/* @__PURE__ */
|
|
5811
|
-
/* @__PURE__ */
|
|
5812
|
-
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))
|
|
5813
6001
|
] })
|
|
5814
6002
|
] })
|
|
5815
6003
|
] });
|
|
@@ -5822,7 +6010,7 @@ import {
|
|
|
5822
6010
|
getFieldFormat as getFieldFormat3,
|
|
5823
6011
|
groupedFormatsForBase
|
|
5824
6012
|
} from "@ai-matrx/design-system/field-formats";
|
|
5825
|
-
import { jsx as
|
|
6013
|
+
import { jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5826
6014
|
var KIND_WORD = {
|
|
5827
6015
|
choice: "select",
|
|
5828
6016
|
multi_choice: "multi_select",
|
|
@@ -5945,13 +6133,13 @@ function FieldFormatPicker({
|
|
|
5945
6133
|
else merged[key] = next;
|
|
5946
6134
|
onValue({ ...value, format: Object.keys(merged).length > 0 ? { id: value.format.id, options: merged } : { id: value.format.id } });
|
|
5947
6135
|
};
|
|
5948
|
-
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: [
|
|
5949
6137
|
label,
|
|
5950
6138
|
control
|
|
5951
6139
|
] }, key) : null;
|
|
5952
|
-
return /* @__PURE__ */
|
|
5953
|
-
/* @__PURE__ */
|
|
5954
|
-
/* @__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(
|
|
5955
6143
|
PickOne,
|
|
5956
6144
|
{
|
|
5957
6145
|
id: `records-shows-as-${field.id}`,
|
|
@@ -5977,12 +6165,12 @@ function FieldFormatPicker({
|
|
|
5977
6165
|
]
|
|
5978
6166
|
}
|
|
5979
6167
|
),
|
|
5980
|
-
/* @__PURE__ */
|
|
5981
|
-
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: [
|
|
5982
6170
|
option(
|
|
5983
6171
|
"currency",
|
|
5984
6172
|
"Currency",
|
|
5985
|
-
/* @__PURE__ */
|
|
6173
|
+
/* @__PURE__ */ jsx30(
|
|
5986
6174
|
PickOne,
|
|
5987
6175
|
{
|
|
5988
6176
|
label: "Currency",
|
|
@@ -5997,7 +6185,7 @@ function FieldFormatPicker({
|
|
|
5997
6185
|
option(
|
|
5998
6186
|
"percentScale",
|
|
5999
6187
|
"Stored as",
|
|
6000
|
-
/* @__PURE__ */
|
|
6188
|
+
/* @__PURE__ */ jsx30(
|
|
6001
6189
|
PickOne,
|
|
6002
6190
|
{
|
|
6003
6191
|
label: "Stored as",
|
|
@@ -6015,7 +6203,7 @@ function FieldFormatPicker({
|
|
|
6015
6203
|
option(
|
|
6016
6204
|
"durationUnit",
|
|
6017
6205
|
"Unit",
|
|
6018
|
-
/* @__PURE__ */
|
|
6206
|
+
/* @__PURE__ */ jsx30(
|
|
6019
6207
|
PickOne,
|
|
6020
6208
|
{
|
|
6021
6209
|
label: "Unit",
|
|
@@ -6035,7 +6223,7 @@ function FieldFormatPicker({
|
|
|
6035
6223
|
option(
|
|
6036
6224
|
"precision",
|
|
6037
6225
|
"Decimals",
|
|
6038
|
-
/* @__PURE__ */
|
|
6226
|
+
/* @__PURE__ */ jsx30(
|
|
6039
6227
|
"input",
|
|
6040
6228
|
{
|
|
6041
6229
|
"data-records-format-option": "precision",
|
|
@@ -6052,7 +6240,7 @@ function FieldFormatPicker({
|
|
|
6052
6240
|
option(
|
|
6053
6241
|
"ratingMax",
|
|
6054
6242
|
"Out of",
|
|
6055
|
-
/* @__PURE__ */
|
|
6243
|
+
/* @__PURE__ */ jsx30(
|
|
6056
6244
|
"input",
|
|
6057
6245
|
{
|
|
6058
6246
|
"data-records-format-option": "ratingMax",
|
|
@@ -6068,7 +6256,7 @@ function FieldFormatPicker({
|
|
|
6068
6256
|
option(
|
|
6069
6257
|
"dateStyle",
|
|
6070
6258
|
"Style",
|
|
6071
|
-
/* @__PURE__ */
|
|
6259
|
+
/* @__PURE__ */ jsx30(
|
|
6072
6260
|
PickOne,
|
|
6073
6261
|
{
|
|
6074
6262
|
label: "Style",
|
|
@@ -6087,15 +6275,15 @@ function FieldFormatPicker({
|
|
|
6087
6275
|
option(
|
|
6088
6276
|
"prefix",
|
|
6089
6277
|
"Prefix",
|
|
6090
|
-
/* @__PURE__ */
|
|
6278
|
+
/* @__PURE__ */ jsx30("input", { "data-records-format-option": "prefix", className: BOX, value: options.prefix ?? "", onChange: (e) => setOption("prefix", e.target.value) })
|
|
6091
6279
|
),
|
|
6092
6280
|
option(
|
|
6093
6281
|
"suffix",
|
|
6094
6282
|
"Suffix",
|
|
6095
|
-
/* @__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) })
|
|
6096
6284
|
),
|
|
6097
|
-
optionKeys.includes("useGrouping") ? /* @__PURE__ */
|
|
6098
|
-
/* @__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(
|
|
6099
6287
|
"input",
|
|
6100
6288
|
{
|
|
6101
6289
|
type: "checkbox",
|
|
@@ -6136,34 +6324,34 @@ function nextFieldSort(fields) {
|
|
|
6136
6324
|
import { autonumberPrefixOf as autonumberPrefixOf3, buttonNeeds, buttonOf } from "@ai-matrx/records";
|
|
6137
6325
|
|
|
6138
6326
|
// src/ButtonSettings.tsx
|
|
6139
|
-
import { useEffect as
|
|
6327
|
+
import { useEffect as useEffect17, useState as useState23 } from "react";
|
|
6140
6328
|
import { BasicInput as BasicInput8, Button as Button14, Label as Label7 } from "@ai-matrx/design-system";
|
|
6141
6329
|
import { STYLE_COLORS as STYLE_COLORS3 } from "@ai-matrx/design-system/data-table";
|
|
6142
6330
|
import { buttonUrlPlaceholders } from "@ai-matrx/records";
|
|
6143
|
-
import { useOptionalRecordsClient as
|
|
6331
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient8 } from "@ai-matrx/records/react";
|
|
6144
6332
|
|
|
6145
6333
|
// src/AccentSwatches.tsx
|
|
6146
6334
|
import { PORTAL_ACCENTS } from "@ai-matrx/records";
|
|
6147
|
-
import { cn as
|
|
6335
|
+
import { cn as cn21 } from "@ai-matrx/design-system";
|
|
6148
6336
|
import { STYLE_COLOR_LABELS as STYLE_COLOR_LABELS2, SWATCH_CLASS as SWATCH_CLASS3 } from "@ai-matrx/design-system/data-table";
|
|
6149
|
-
import { jsx as
|
|
6337
|
+
import { jsx as jsx31, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6150
6338
|
function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel = "App colour" }) {
|
|
6151
|
-
return /* @__PURE__ */
|
|
6152
|
-
/* @__PURE__ */
|
|
6339
|
+
return /* @__PURE__ */ jsxs29("div", { className: "flex flex-wrap gap-1.5", role: "radiogroup", "aria-label": "Colour", children: [
|
|
6340
|
+
/* @__PURE__ */ jsx31(
|
|
6153
6341
|
"button",
|
|
6154
6342
|
{
|
|
6155
6343
|
type: "button",
|
|
6156
6344
|
role: "radio",
|
|
6157
6345
|
"aria-checked": value === "",
|
|
6158
6346
|
onClick: () => onChange(""),
|
|
6159
|
-
className:
|
|
6347
|
+
className: cn21(
|
|
6160
6348
|
"h-7 rounded border px-2 text-xs",
|
|
6161
6349
|
value === "" ? "border-foreground" : "border-border text-muted-foreground"
|
|
6162
6350
|
),
|
|
6163
6351
|
children: noneLabel
|
|
6164
6352
|
}
|
|
6165
6353
|
),
|
|
6166
|
-
options.map((c) => /* @__PURE__ */
|
|
6354
|
+
options.map((c) => /* @__PURE__ */ jsx31(
|
|
6167
6355
|
"button",
|
|
6168
6356
|
{
|
|
6169
6357
|
type: "button",
|
|
@@ -6172,7 +6360,7 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
|
|
|
6172
6360
|
"aria-label": STYLE_COLOR_LABELS2[c],
|
|
6173
6361
|
title: STYLE_COLOR_LABELS2[c],
|
|
6174
6362
|
onClick: () => onChange(c),
|
|
6175
|
-
className:
|
|
6363
|
+
className: cn21("h-7 w-7 rounded-full border-2", SWATCH_CLASS3[c], value === c ? "border-foreground" : "border-transparent")
|
|
6176
6364
|
},
|
|
6177
6365
|
c
|
|
6178
6366
|
))
|
|
@@ -6180,7 +6368,7 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
|
|
|
6180
6368
|
}
|
|
6181
6369
|
|
|
6182
6370
|
// src/ButtonSettings.tsx
|
|
6183
|
-
import { jsx as
|
|
6371
|
+
import { jsx as jsx32, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6184
6372
|
var DOES_WORDS = {
|
|
6185
6373
|
none: "Nothing yet",
|
|
6186
6374
|
open_url: "Open a link",
|
|
@@ -6201,11 +6389,11 @@ function ButtonSettingsEditor({
|
|
|
6201
6389
|
tableId,
|
|
6202
6390
|
fields
|
|
6203
6391
|
}) {
|
|
6204
|
-
const client =
|
|
6205
|
-
const [actions, setActions] =
|
|
6206
|
-
const [actionsRefused, setActionsRefused] =
|
|
6207
|
-
const [automations, setAutomations] =
|
|
6208
|
-
|
|
6392
|
+
const client = useOptionalRecordsClient8();
|
|
6393
|
+
const [actions, setActions] = useState23(null);
|
|
6394
|
+
const [actionsRefused, setActionsRefused] = useState23(null);
|
|
6395
|
+
const [automations, setAutomations] = useState23(null);
|
|
6396
|
+
useEffect17(() => {
|
|
6209
6397
|
if (!client || !tableId) return;
|
|
6210
6398
|
let live = true;
|
|
6211
6399
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6226,15 +6414,15 @@ function ButtonSettingsEditor({
|
|
|
6226
6414
|
}, [client, tableId, value.do, actions, automations]);
|
|
6227
6415
|
const set = (patch) => onChange({ ...value, ...patch });
|
|
6228
6416
|
const columns = fields.filter((f) => !(f.type === "text" && f.format === "button"));
|
|
6229
|
-
return /* @__PURE__ */
|
|
6230
|
-
/* @__PURE__ */
|
|
6231
|
-
/* @__PURE__ */
|
|
6232
|
-
/* @__PURE__ */
|
|
6233
|
-
/* @__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 }) })
|
|
6234
6422
|
] }),
|
|
6235
|
-
/* @__PURE__ */
|
|
6236
|
-
/* @__PURE__ */
|
|
6237
|
-
/* @__PURE__ */
|
|
6423
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6424
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Does" }),
|
|
6425
|
+
/* @__PURE__ */ jsx32(
|
|
6238
6426
|
PickOne,
|
|
6239
6427
|
{
|
|
6240
6428
|
label: "What a press does",
|
|
@@ -6246,9 +6434,9 @@ function ButtonSettingsEditor({
|
|
|
6246
6434
|
)
|
|
6247
6435
|
] })
|
|
6248
6436
|
] }),
|
|
6249
|
-
/* @__PURE__ */
|
|
6250
|
-
/* @__PURE__ */
|
|
6251
|
-
/* @__PURE__ */
|
|
6437
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6438
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Colour" }),
|
|
6439
|
+
/* @__PURE__ */ jsx32(
|
|
6252
6440
|
AccentSwatches,
|
|
6253
6441
|
{
|
|
6254
6442
|
value: value.color ?? "",
|
|
@@ -6258,10 +6446,10 @@ function ButtonSettingsEditor({
|
|
|
6258
6446
|
}
|
|
6259
6447
|
)
|
|
6260
6448
|
] }),
|
|
6261
|
-
value.do === "open_url" ? /* @__PURE__ */
|
|
6262
|
-
/* @__PURE__ */
|
|
6263
|
-
/* @__PURE__ */
|
|
6264
|
-
/* @__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(
|
|
6265
6453
|
BasicInput8,
|
|
6266
6454
|
{
|
|
6267
6455
|
className: "h-8 flex-1 font-mono text-xs",
|
|
@@ -6271,7 +6459,7 @@ function ButtonSettingsEditor({
|
|
|
6271
6459
|
onChange: (e) => set({ url: e.target.value })
|
|
6272
6460
|
}
|
|
6273
6461
|
),
|
|
6274
|
-
columns.length > 0 ? /* @__PURE__ */
|
|
6462
|
+
columns.length > 0 ? /* @__PURE__ */ jsx32(
|
|
6275
6463
|
PickOne,
|
|
6276
6464
|
{
|
|
6277
6465
|
label: "Add a column's value",
|
|
@@ -6284,10 +6472,10 @@ function ButtonSettingsEditor({
|
|
|
6284
6472
|
}
|
|
6285
6473
|
) : null
|
|
6286
6474
|
] }),
|
|
6287
|
-
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
|
|
6288
6476
|
] }) : null,
|
|
6289
|
-
value.do === "run_action" ? !tableId ? /* @__PURE__ */
|
|
6290
|
-
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(
|
|
6291
6479
|
PickOne,
|
|
6292
6480
|
{
|
|
6293
6481
|
label: "Row action",
|
|
@@ -6298,7 +6486,7 @@ function ButtonSettingsEditor({
|
|
|
6298
6486
|
options: (actions ?? []).map((a) => ({ value: a.id, label: a.name }))
|
|
6299
6487
|
}
|
|
6300
6488
|
) : null,
|
|
6301
|
-
actions !== null ? /* @__PURE__ */
|
|
6489
|
+
actions !== null ? /* @__PURE__ */ jsx32(
|
|
6302
6490
|
NewRowAction,
|
|
6303
6491
|
{
|
|
6304
6492
|
tableId,
|
|
@@ -6312,7 +6500,7 @@ function ButtonSettingsEditor({
|
|
|
6312
6500
|
}
|
|
6313
6501
|
) : null
|
|
6314
6502
|
] }) : null,
|
|
6315
|
-
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(
|
|
6316
6504
|
PickOne,
|
|
6317
6505
|
{
|
|
6318
6506
|
label: "Automation",
|
|
@@ -6337,13 +6525,13 @@ function NewRowAction({
|
|
|
6337
6525
|
columns,
|
|
6338
6526
|
onMade
|
|
6339
6527
|
}) {
|
|
6340
|
-
const client =
|
|
6528
|
+
const client = useOptionalRecordsClient8();
|
|
6341
6529
|
const settable = settableColumns(columns);
|
|
6342
|
-
const [fieldId, setFieldId] =
|
|
6343
|
-
const [setTo, setSetTo] =
|
|
6344
|
-
const [busy, setBusy] =
|
|
6345
|
-
const [refused, setRefused] =
|
|
6346
|
-
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" });
|
|
6347
6535
|
const make = async () => {
|
|
6348
6536
|
if (!client || fieldId === "") return;
|
|
6349
6537
|
setBusy(true);
|
|
@@ -6367,10 +6555,10 @@ function NewRowAction({
|
|
|
6367
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." });
|
|
6368
6556
|
onMade(made.id, all);
|
|
6369
6557
|
};
|
|
6370
|
-
return /* @__PURE__ */
|
|
6371
|
-
/* @__PURE__ */
|
|
6372
|
-
/* @__PURE__ */
|
|
6373
|
-
/* @__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(
|
|
6374
6562
|
PickOne,
|
|
6375
6563
|
{
|
|
6376
6564
|
label: "Column to set",
|
|
@@ -6382,16 +6570,16 @@ function NewRowAction({
|
|
|
6382
6570
|
options: settable.map((f) => ({ value: f.id, label: fieldName(f) }))
|
|
6383
6571
|
}
|
|
6384
6572
|
),
|
|
6385
|
-
/* @__PURE__ */
|
|
6386
|
-
/* @__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" })
|
|
6387
6575
|
] }),
|
|
6388
|
-
refused ? /* @__PURE__ */
|
|
6576
|
+
refused ? /* @__PURE__ */ jsx32(RefusalLine, { error: refused }) : null
|
|
6389
6577
|
] });
|
|
6390
6578
|
}
|
|
6391
6579
|
|
|
6392
6580
|
// src/FieldEditor.tsx
|
|
6393
6581
|
import { FIELD_SENSITIVITIES, CONTEXT_POLICIES, DECLARABLE_FIELD_KINDS as DECLARABLE_FIELD_KINDS2, optionKey as optionKey3, ratingMaxOf as ratingMaxOf2, rulesWithTopStar } from "@ai-matrx/records";
|
|
6394
|
-
import { Fragment as
|
|
6582
|
+
import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
6395
6583
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
6396
6584
|
var SENSITIVITIES = FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
6397
6585
|
var AGENT_VISIBILITY = CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
@@ -6504,33 +6692,33 @@ function FieldEditor(props) {
|
|
|
6504
6692
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6505
6693
|
const start = field ?? copyOf;
|
|
6506
6694
|
const startAs = start ? void 0 : props.startAs;
|
|
6507
|
-
const [label, setLabel] =
|
|
6508
|
-
const [type, setType] =
|
|
6509
|
-
const [required, setRequired] =
|
|
6510
|
-
const [multi, setMulti] =
|
|
6511
|
-
const [dated, setDated] =
|
|
6512
|
-
const [sensitivity, setSensitivity] =
|
|
6513
|
-
const [contextPolicy, setContextPolicy] =
|
|
6514
|
-
const [rules, setRules] =
|
|
6515
|
-
const [startsWith, setStartsWith] =
|
|
6516
|
-
const [ratingMax, setRatingMax] =
|
|
6517
|
-
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(
|
|
6518
6706
|
() => field ? type === "rating" ? rulesWithTopStar(field.rules ?? [], ratingMaxOf2(field)) : field.rules ?? [] : [],
|
|
6519
6707
|
[field, type]
|
|
6520
6708
|
);
|
|
6521
|
-
const editedRules =
|
|
6522
|
-
const [statusGroups, setStatusGroups] =
|
|
6523
|
-
const [statusKeys, setStatusKeys] =
|
|
6524
|
-
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"] ?? ""));
|
|
6525
6713
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
6526
|
-
const [description, setDescription] =
|
|
6527
|
-
const buttonStart =
|
|
6528
|
-
const [buttonSettings, setButtonSettings] =
|
|
6714
|
+
const [description, setDescription] = useState24(descriptionStart);
|
|
6715
|
+
const buttonStart = useMemo11(() => buttonOf(start) ?? { label: "" }, [start]);
|
|
6716
|
+
const [buttonSettings, setButtonSettings] = useState24(buttonStart);
|
|
6529
6717
|
const prefixStart = autonumberPrefixOf3(start);
|
|
6530
|
-
const [numberPrefix, setNumberPrefix] =
|
|
6718
|
+
const [numberPrefix, setNumberPrefix] = useState24(prefixStart);
|
|
6531
6719
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6532
|
-
const [dependency, setDependency] =
|
|
6533
|
-
|
|
6720
|
+
const [dependency, setDependency] = useState24(dependencyStart);
|
|
6721
|
+
useEffect18(() => {
|
|
6534
6722
|
if (!field || type !== "status") return;
|
|
6535
6723
|
let live = true;
|
|
6536
6724
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
@@ -6540,20 +6728,20 @@ function FieldEditor(props) {
|
|
|
6540
6728
|
live = false;
|
|
6541
6729
|
};
|
|
6542
6730
|
}, [client, field, type]);
|
|
6543
|
-
|
|
6731
|
+
useEffect18(() => {
|
|
6544
6732
|
if (field || type !== "status") return;
|
|
6545
6733
|
setNewChoices(
|
|
6546
6734
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6547
6735
|
);
|
|
6548
6736
|
}, [field, type]);
|
|
6549
|
-
|
|
6737
|
+
useEffect18(() => {
|
|
6550
6738
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6551
6739
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6552
6740
|
}, [field, type]);
|
|
6553
|
-
const [allowOther, setAllowOther] =
|
|
6554
|
-
const [newChoices, setNewChoices] =
|
|
6741
|
+
const [allowOther, setAllowOther] = useState24(start?.config?.["allow_other"] === true);
|
|
6742
|
+
const [newChoices, setNewChoices] = useState24([]);
|
|
6555
6743
|
const copyOfId = copyOf?.id ?? null;
|
|
6556
|
-
|
|
6744
|
+
useEffect18(() => {
|
|
6557
6745
|
if (!copyOf || !copyOfId) return;
|
|
6558
6746
|
let live = true;
|
|
6559
6747
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6565,53 +6753,53 @@ function FieldEditor(props) {
|
|
|
6565
6753
|
live = false;
|
|
6566
6754
|
};
|
|
6567
6755
|
}, [client, copyOfId]);
|
|
6568
|
-
const [choiceList, setChoiceList] =
|
|
6569
|
-
const [choiceListStart, setChoiceListStart] =
|
|
6570
|
-
const [rehome, setRehome] =
|
|
6571
|
-
const [rehomed, setRehomed] =
|
|
6572
|
-
const [rehomeRefused, setRehomeRefused] =
|
|
6573
|
-
const [unit, setUnit] =
|
|
6574
|
-
const [withTime, setWithTime] =
|
|
6575
|
-
const [via, setVia] =
|
|
6576
|
-
const [pick, setPick] =
|
|
6577
|
-
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(
|
|
6578
6766
|
start?.config?.["agg"] ?? "count"
|
|
6579
6767
|
);
|
|
6580
|
-
const [of, setOf] =
|
|
6768
|
+
const [of, setOf] = useState24(String(start?.config?.["of"] ?? ""));
|
|
6581
6769
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6582
|
-
const [rollupFilter, setRollupFilter] =
|
|
6770
|
+
const [rollupFilter, setRollupFilter] = useState24(
|
|
6583
6771
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6584
6772
|
);
|
|
6585
6773
|
const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
|
|
6586
|
-
const [relationTarget, setRelationTarget] =
|
|
6587
|
-
const [showOnOther, setShowOnOther] =
|
|
6588
|
-
const [nestsSubItems, setNestsSubItems] =
|
|
6589
|
-
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);
|
|
6590
6778
|
const otherTable = useTable(!field && type === "relation" && relationTarget !== "" ? relationTarget : null);
|
|
6591
|
-
const [display, setDisplay] =
|
|
6592
|
-
const [formulaOp, setFormulaOp] =
|
|
6593
|
-
const [formulaFields, setFormulaFields] =
|
|
6594
|
-
const [formulaSeparator, setFormulaSeparator] =
|
|
6595
|
-
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));
|
|
6596
6784
|
const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
|
|
6597
|
-
const [formulaText, setFormulaText] =
|
|
6598
|
-
const shownFormula =
|
|
6599
|
-
|
|
6785
|
+
const [formulaText, setFormulaText] = useState24(startingFormulaText);
|
|
6786
|
+
const shownFormula = useRef13(startingFormulaText);
|
|
6787
|
+
useEffect18(() => {
|
|
6600
6788
|
if (shownFormula.current === startingFormulaText) return;
|
|
6601
6789
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6602
6790
|
shownFormula.current = startingFormulaText;
|
|
6603
6791
|
}, [startingFormulaText]);
|
|
6604
|
-
const [formulaWritten, setFormulaWritten] =
|
|
6605
|
-
const [formulaOk, setFormulaOk] =
|
|
6606
|
-
const [askingToRemove, setAskingToRemove] =
|
|
6607
|
-
const [attempted, setAttempted] =
|
|
6608
|
-
const [showsAs, setShowsAs] =
|
|
6609
|
-
const [backfillError, setBackfillError] =
|
|
6610
|
-
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);
|
|
6611
6799
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6612
6800
|
const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
|
|
6613
|
-
const seededAs =
|
|
6614
|
-
|
|
6801
|
+
const seededAs = useRef13(heldAs);
|
|
6802
|
+
useEffect18(() => {
|
|
6615
6803
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6616
6804
|
seededAs.current = heldAs;
|
|
6617
6805
|
setType(startingType(liveField));
|
|
@@ -6620,24 +6808,24 @@ function FieldEditor(props) {
|
|
|
6620
6808
|
setUnit(liveField.unit ?? "$");
|
|
6621
6809
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6622
6810
|
}, [heldAs]);
|
|
6623
|
-
const others =
|
|
6811
|
+
const others = useMemo11(
|
|
6624
6812
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6625
6813
|
[fields.data, field?.id]
|
|
6626
6814
|
);
|
|
6627
|
-
const relations =
|
|
6815
|
+
const relations = useMemo11(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
|
|
6628
6816
|
const reverse = useReverseColumns(onEntity ? null : tableId);
|
|
6629
|
-
const backLinks =
|
|
6630
|
-
const totalSources =
|
|
6817
|
+
const backLinks = useMemo11(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
|
|
6818
|
+
const totalSources = useMemo11(() => [...relations, ...backLinks], [relations, backLinks]);
|
|
6631
6819
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6632
6820
|
const choice = fieldTypeChoice(type);
|
|
6633
6821
|
const editing = Boolean(field);
|
|
6634
|
-
|
|
6822
|
+
useEffect18(() => {
|
|
6635
6823
|
if (!editing) setStartsWith(null);
|
|
6636
6824
|
}, [type, editing]);
|
|
6637
6825
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6638
6826
|
const farFieldsOfLink = useFields2(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6639
6827
|
const farTable = useTable(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6640
|
-
const linkReaders =
|
|
6828
|
+
const linkReaders = useMemo11(
|
|
6641
6829
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6642
6830
|
[field, farFieldsOfLink.data]
|
|
6643
6831
|
);
|
|
@@ -6645,7 +6833,7 @@ function FieldEditor(props) {
|
|
|
6645
6833
|
const offersMany = multiApplies(type) && !isTitle;
|
|
6646
6834
|
if (!mayShape) {
|
|
6647
6835
|
if (onEntity && entityRights.loading) return null;
|
|
6648
|
-
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 });
|
|
6649
6837
|
}
|
|
6650
6838
|
const options = newChoices.map((r) => r.words.trim()).filter((word) => word !== "");
|
|
6651
6839
|
const shownStatusRows = type !== "status" ? [] : statusGroupRows(field, editing ? choiceList ?? [] : newChoices, statusKeys, statusGroups);
|
|
@@ -6845,15 +7033,15 @@ function FieldEditor(props) {
|
|
|
6845
7033
|
if (gone) (onRemoved ?? onSaved)?.();
|
|
6846
7034
|
else setAskingToRemove(false);
|
|
6847
7035
|
};
|
|
6848
|
-
return /* @__PURE__ */
|
|
6849
|
-
/* @__PURE__ */
|
|
6850
|
-
/* @__PURE__ */
|
|
6851
|
-
/* @__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 })
|
|
6852
7040
|
] }),
|
|
6853
|
-
/* @__PURE__ */
|
|
6854
|
-
/* @__PURE__ */
|
|
6855
|
-
/* @__PURE__ */
|
|
6856
|
-
/* @__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(
|
|
6857
7045
|
BasicInput9,
|
|
6858
7046
|
{
|
|
6859
7047
|
value: label,
|
|
@@ -6869,7 +7057,7 @@ function FieldEditor(props) {
|
|
|
6869
7057
|
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6870
7058
|
}
|
|
6871
7059
|
),
|
|
6872
|
-
nameLine ? /* @__PURE__ */
|
|
7060
|
+
nameLine ? /* @__PURE__ */ jsx33(
|
|
6873
7061
|
"span",
|
|
6874
7062
|
{
|
|
6875
7063
|
id: "field-editor-name-taken",
|
|
@@ -6880,9 +7068,9 @@ function FieldEditor(props) {
|
|
|
6880
7068
|
}
|
|
6881
7069
|
) : null
|
|
6882
7070
|
] }),
|
|
6883
|
-
field ? /* @__PURE__ */
|
|
6884
|
-
/* @__PURE__ */
|
|
6885
|
-
/* @__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(
|
|
6886
7074
|
BasicInput9,
|
|
6887
7075
|
{
|
|
6888
7076
|
value: description,
|
|
@@ -6893,29 +7081,29 @@ function FieldEditor(props) {
|
|
|
6893
7081
|
}
|
|
6894
7082
|
)
|
|
6895
7083
|
] }) : null,
|
|
6896
|
-
/* @__PURE__ */
|
|
6897
|
-
/* @__PURE__ */
|
|
6898
|
-
/* @__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(
|
|
6899
7087
|
Select6,
|
|
6900
7088
|
{
|
|
6901
7089
|
value: type,
|
|
6902
7090
|
disabled: editing,
|
|
6903
7091
|
onValueChange: (next) => setType(next),
|
|
6904
7092
|
children: [
|
|
6905
|
-
/* @__PURE__ */
|
|
6906
|
-
/* @__PURE__ */
|
|
6907
|
-
/* @__PURE__ */
|
|
6908
|
-
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))
|
|
6909
7097
|
] }, group)) })
|
|
6910
7098
|
]
|
|
6911
7099
|
}
|
|
6912
7100
|
),
|
|
6913
|
-
editing && field ? /* @__PURE__ */
|
|
7101
|
+
editing && field ? /* @__PURE__ */ jsx33(FieldRetype, { field: liveField ?? field, tableId }) : null
|
|
6914
7102
|
] })
|
|
6915
7103
|
] }),
|
|
6916
|
-
type === "formula" && others.length > 0 ? /* @__PURE__ */
|
|
6917
|
-
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */
|
|
6918
|
-
/* @__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(
|
|
6919
7107
|
Button15,
|
|
6920
7108
|
{
|
|
6921
7109
|
type: "button",
|
|
@@ -6926,7 +7114,7 @@ function FieldEditor(props) {
|
|
|
6926
7114
|
children: "Pick the columns"
|
|
6927
7115
|
}
|
|
6928
7116
|
),
|
|
6929
|
-
/* @__PURE__ */
|
|
7117
|
+
/* @__PURE__ */ jsx33(
|
|
6930
7118
|
Button15,
|
|
6931
7119
|
{
|
|
6932
7120
|
type: "button",
|
|
@@ -6938,7 +7126,7 @@ function FieldEditor(props) {
|
|
|
6938
7126
|
}
|
|
6939
7127
|
)
|
|
6940
7128
|
] }),
|
|
6941
|
-
formulaWritten ? /* @__PURE__ */
|
|
7129
|
+
formulaWritten ? /* @__PURE__ */ jsx33(
|
|
6942
7130
|
FormulaTextEditor,
|
|
6943
7131
|
{
|
|
6944
7132
|
tableId,
|
|
@@ -6948,9 +7136,9 @@ function FieldEditor(props) {
|
|
|
6948
7136
|
columns: others
|
|
6949
7137
|
}
|
|
6950
7138
|
) : null
|
|
6951
|
-
] }) : editing && type === "formula" ? /* @__PURE__ */
|
|
6952
|
-
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */
|
|
6953
|
-
!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(
|
|
6954
7142
|
TypeQuestions,
|
|
6955
7143
|
{
|
|
6956
7144
|
type,
|
|
@@ -6980,7 +7168,7 @@ function FieldEditor(props) {
|
|
|
6980
7168
|
setFormulaSeparator,
|
|
6981
7169
|
relations: sourcesFor(type),
|
|
6982
7170
|
others,
|
|
6983
|
-
choiceList: editing && field ? /* @__PURE__ */
|
|
7171
|
+
choiceList: editing && field ? /* @__PURE__ */ jsx33(
|
|
6984
7172
|
ChoiceListEditor,
|
|
6985
7173
|
{
|
|
6986
7174
|
field,
|
|
@@ -6991,10 +7179,10 @@ function FieldEditor(props) {
|
|
|
6991
7179
|
rehome,
|
|
6992
7180
|
onRehome: setRehome
|
|
6993
7181
|
}
|
|
6994
|
-
) : /* @__PURE__ */
|
|
7182
|
+
) : /* @__PURE__ */ jsx33(ChoiceListEditor, { isNew: true, rows: newChoices, onRows: setNewChoices }),
|
|
6995
7183
|
allowedTypes,
|
|
6996
7184
|
setAllowedTypes,
|
|
6997
|
-
newer: type === "rating" ? /* @__PURE__ */
|
|
7185
|
+
newer: type === "rating" ? /* @__PURE__ */ jsx33(
|
|
6998
7186
|
RatingMaxQuestion,
|
|
6999
7187
|
{
|
|
7000
7188
|
value: ratingMax,
|
|
@@ -7002,19 +7190,19 @@ function FieldEditor(props) {
|
|
|
7002
7190
|
setRatingMax(next);
|
|
7003
7191
|
}
|
|
7004
7192
|
}
|
|
7005
|
-
) : 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
|
|
7006
7194
|
}
|
|
7007
7195
|
) : null,
|
|
7008
|
-
type === "button" ? /* @__PURE__ */
|
|
7009
|
-
type === "autonumber" ? /* @__PURE__ */
|
|
7010
|
-
/* @__PURE__ */
|
|
7011
|
-
/* @__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) })
|
|
7012
7200
|
] }) : null,
|
|
7013
|
-
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */
|
|
7014
|
-
/* @__PURE__ */
|
|
7015
|
-
/* @__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" })
|
|
7016
7204
|
] }) : null,
|
|
7017
|
-
type === "rollup" ? /* @__PURE__ */
|
|
7205
|
+
type === "rollup" ? /* @__PURE__ */ jsx33(
|
|
7018
7206
|
RollupFilterQuestion,
|
|
7019
7207
|
{
|
|
7020
7208
|
relation: totalSources.find((f) => f.key === via),
|
|
@@ -7024,10 +7212,10 @@ function FieldEditor(props) {
|
|
|
7024
7212
|
onChange: setRollupFilter
|
|
7025
7213
|
}
|
|
7026
7214
|
) : null,
|
|
7027
|
-
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */
|
|
7028
|
-
/* @__PURE__ */
|
|
7029
|
-
/* @__PURE__ */
|
|
7030
|
-
/* @__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(
|
|
7031
7219
|
Checkbox4,
|
|
7032
7220
|
{
|
|
7033
7221
|
checked: required,
|
|
@@ -7035,10 +7223,10 @@ function FieldEditor(props) {
|
|
|
7035
7223
|
onCheckedChange: (v) => setRequired(v === true)
|
|
7036
7224
|
}
|
|
7037
7225
|
),
|
|
7038
|
-
/* @__PURE__ */
|
|
7226
|
+
/* @__PURE__ */ jsx33("span", { title: "Every record has to have one", children: "Required" })
|
|
7039
7227
|
] }),
|
|
7040
|
-
offersMany ? /* @__PURE__ */
|
|
7041
|
-
/* @__PURE__ */
|
|
7228
|
+
offersMany ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7229
|
+
/* @__PURE__ */ jsx33(
|
|
7042
7230
|
Checkbox4,
|
|
7043
7231
|
{
|
|
7044
7232
|
checked: multi,
|
|
@@ -7048,8 +7236,8 @@ function FieldEditor(props) {
|
|
|
7048
7236
|
),
|
|
7049
7237
|
"Can hold more than one"
|
|
7050
7238
|
] }) : null,
|
|
7051
|
-
/* @__PURE__ */
|
|
7052
|
-
/* @__PURE__ */
|
|
7239
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7240
|
+
/* @__PURE__ */ jsx33(
|
|
7053
7241
|
Checkbox4,
|
|
7054
7242
|
{
|
|
7055
7243
|
checked: dated,
|
|
@@ -7059,8 +7247,8 @@ function FieldEditor(props) {
|
|
|
7059
7247
|
),
|
|
7060
7248
|
"Each value has its own date"
|
|
7061
7249
|
] }),
|
|
7062
|
-
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */
|
|
7063
|
-
/* @__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(
|
|
7064
7252
|
Checkbox4,
|
|
7065
7253
|
{
|
|
7066
7254
|
checked: showOnOther,
|
|
@@ -7072,12 +7260,12 @@ function FieldEditor(props) {
|
|
|
7072
7260
|
"Show on ",
|
|
7073
7261
|
otherTable.data.name ?? "the other table"
|
|
7074
7262
|
] }) : null,
|
|
7075
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */
|
|
7076
|
-
/* @__PURE__ */
|
|
7077
|
-
/* @__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" })
|
|
7078
7266
|
] }) : null,
|
|
7079
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */
|
|
7080
|
-
/* @__PURE__ */
|
|
7267
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7268
|
+
/* @__PURE__ */ jsx33(
|
|
7081
7269
|
Checkbox4,
|
|
7082
7270
|
{
|
|
7083
7271
|
checked: nestsSubItems,
|
|
@@ -7089,10 +7277,10 @@ function FieldEditor(props) {
|
|
|
7089
7277
|
"data-records-sub-items": ""
|
|
7090
7278
|
}
|
|
7091
7279
|
),
|
|
7092
|
-
/* @__PURE__ */
|
|
7280
|
+
/* @__PURE__ */ jsx33("span", { title: "Each record sits under the one this column names", children: "Sub-items" })
|
|
7093
7281
|
] }) : null,
|
|
7094
|
-
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */
|
|
7095
|
-
/* @__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(
|
|
7096
7284
|
Checkbox4,
|
|
7097
7285
|
{
|
|
7098
7286
|
checked: allowOther,
|
|
@@ -7103,10 +7291,10 @@ function FieldEditor(props) {
|
|
|
7103
7291
|
"A value that is not one of the choices is added to them"
|
|
7104
7292
|
] }) : null
|
|
7105
7293
|
] }),
|
|
7106
|
-
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */
|
|
7107
|
-
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */
|
|
7108
|
-
/* @__PURE__ */
|
|
7109
|
-
/* @__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(
|
|
7110
7298
|
FieldControl,
|
|
7111
7299
|
{
|
|
7112
7300
|
id: "records-field-default",
|
|
@@ -7116,28 +7304,28 @@ function FieldEditor(props) {
|
|
|
7116
7304
|
}
|
|
7117
7305
|
)
|
|
7118
7306
|
] }) : null,
|
|
7119
|
-
/* @__PURE__ */
|
|
7120
|
-
/* @__PURE__ */
|
|
7121
|
-
/* @__PURE__ */
|
|
7122
|
-
/* @__PURE__ */
|
|
7123
|
-
/* @__PURE__ */
|
|
7124
|
-
/* @__PURE__ */
|
|
7125
|
-
/* @__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)) })
|
|
7126
7314
|
] })
|
|
7127
7315
|
] }),
|
|
7128
|
-
/* @__PURE__ */
|
|
7129
|
-
/* @__PURE__ */
|
|
7130
|
-
/* @__PURE__ */
|
|
7131
|
-
/* @__PURE__ */
|
|
7132
|
-
/* @__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)) })
|
|
7133
7321
|
] })
|
|
7134
7322
|
] })
|
|
7135
7323
|
] }),
|
|
7136
|
-
/* @__PURE__ */
|
|
7137
|
-
/* @__PURE__ */
|
|
7138
|
-
/* @__PURE__ */
|
|
7139
|
-
/* @__PURE__ */
|
|
7140
|
-
/* @__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(
|
|
7141
7329
|
Button15,
|
|
7142
7330
|
{
|
|
7143
7331
|
type: "button",
|
|
@@ -7149,8 +7337,8 @@ function FieldEditor(props) {
|
|
|
7149
7337
|
}
|
|
7150
7338
|
)
|
|
7151
7339
|
] }),
|
|
7152
|
-
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */
|
|
7153
|
-
/* @__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(
|
|
7154
7342
|
Checkbox4,
|
|
7155
7343
|
{
|
|
7156
7344
|
checked: rules.some((r) => r.kind === "unique"),
|
|
@@ -7160,20 +7348,20 @@ function FieldEditor(props) {
|
|
|
7160
7348
|
),
|
|
7161
7349
|
UNIQUE_LABEL
|
|
7162
7350
|
] }) : null,
|
|
7163
|
-
rules.length === 0 ? /* @__PURE__ */
|
|
7164
|
-
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */
|
|
7165
|
-
/* @__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(
|
|
7166
7354
|
Select6,
|
|
7167
7355
|
{
|
|
7168
7356
|
value: rule.kind,
|
|
7169
7357
|
onValueChange: (kind) => setRules(rules.map((r, i) => i === index ? { ...r, kind } : r)),
|
|
7170
7358
|
children: [
|
|
7171
|
-
/* @__PURE__ */
|
|
7172
|
-
/* @__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)) })
|
|
7173
7361
|
]
|
|
7174
7362
|
}
|
|
7175
7363
|
),
|
|
7176
|
-
rule.kind === "length" ? /* @__PURE__ */
|
|
7364
|
+
rule.kind === "length" ? /* @__PURE__ */ jsx33(
|
|
7177
7365
|
BasicInput9,
|
|
7178
7366
|
{
|
|
7179
7367
|
className: "h-8 w-24",
|
|
@@ -7184,7 +7372,7 @@ function FieldEditor(props) {
|
|
|
7184
7372
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withNumber(r, "min", e.target.value) : r))
|
|
7185
7373
|
}
|
|
7186
7374
|
) : null,
|
|
7187
|
-
/* @__PURE__ */
|
|
7375
|
+
/* @__PURE__ */ jsx33(
|
|
7188
7376
|
BasicInput9,
|
|
7189
7377
|
{
|
|
7190
7378
|
className: "h-8",
|
|
@@ -7194,7 +7382,7 @@ function FieldEditor(props) {
|
|
|
7194
7382
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? { ...r, value: e.target.value } : r))
|
|
7195
7383
|
}
|
|
7196
7384
|
),
|
|
7197
|
-
rule.kind === "pattern" ? /* @__PURE__ */
|
|
7385
|
+
rule.kind === "pattern" ? /* @__PURE__ */ jsx33(
|
|
7198
7386
|
BasicInput9,
|
|
7199
7387
|
{
|
|
7200
7388
|
className: "h-8",
|
|
@@ -7204,7 +7392,7 @@ function FieldEditor(props) {
|
|
|
7204
7392
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withText(r, "example", e.target.value) : r))
|
|
7205
7393
|
}
|
|
7206
7394
|
) : null,
|
|
7207
|
-
/* @__PURE__ */
|
|
7395
|
+
/* @__PURE__ */ jsx33(
|
|
7208
7396
|
Button15,
|
|
7209
7397
|
{
|
|
7210
7398
|
type: "button",
|
|
@@ -7217,9 +7405,9 @@ function FieldEditor(props) {
|
|
|
7217
7405
|
)
|
|
7218
7406
|
] }, `${rule.kind}-${index}`))
|
|
7219
7407
|
] }),
|
|
7220
|
-
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */
|
|
7221
|
-
mutation.error ? /* @__PURE__ */
|
|
7222
|
-
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(
|
|
7223
7411
|
RefusalNotice,
|
|
7224
7412
|
{
|
|
7225
7413
|
error: (0, refusals_exports.refusal)(
|
|
@@ -7229,10 +7417,10 @@ function FieldEditor(props) {
|
|
|
7229
7417
|
)
|
|
7230
7418
|
}
|
|
7231
7419
|
) : null,
|
|
7232
|
-
rehomeRefused ? /* @__PURE__ */
|
|
7233
|
-
rehomed ? /* @__PURE__ */
|
|
7234
|
-
/* @__PURE__ */
|
|
7235
|
-
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(
|
|
7236
7424
|
Button15,
|
|
7237
7425
|
{
|
|
7238
7426
|
type: "button",
|
|
@@ -7257,18 +7445,18 @@ function FieldEditor(props) {
|
|
|
7257
7445
|
children: "Undo"
|
|
7258
7446
|
}
|
|
7259
7447
|
) : null,
|
|
7260
|
-
/* @__PURE__ */
|
|
7448
|
+
/* @__PURE__ */ jsx33(Button15, { type: "button", size: "sm", className: "h-6 px-2 text-xs", onClick: () => onSaved?.(), children: "Done" })
|
|
7261
7449
|
] }) : null,
|
|
7262
|
-
reverseRefused ? /* @__PURE__ */
|
|
7263
|
-
/* @__PURE__ */
|
|
7264
|
-
/* @__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 })
|
|
7265
7453
|
] }) : null,
|
|
7266
|
-
backfillError ? /* @__PURE__ */
|
|
7267
|
-
/* @__PURE__ */
|
|
7268
|
-
/* @__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 })
|
|
7269
7457
|
] }) : null,
|
|
7270
|
-
/* @__PURE__ */
|
|
7271
|
-
/* @__PURE__ */
|
|
7458
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex min-w-0 flex-nowrap items-center gap-2", "data-field-editor-footer": "", children: [
|
|
7459
|
+
/* @__PURE__ */ jsx33(
|
|
7272
7460
|
Button15,
|
|
7273
7461
|
{
|
|
7274
7462
|
size: "sm",
|
|
@@ -7284,8 +7472,8 @@ function FieldEditor(props) {
|
|
|
7284
7472
|
children: mutation.saving ? "Saving\u2026" : field ? EDIT_FIELD_SAVE_LABEL : onEntity ? ADD_STANDARD_FIELD_SAVE_LABEL : ADD_FIELD_SAVE_LABEL
|
|
7285
7473
|
}
|
|
7286
7474
|
),
|
|
7287
|
-
onCancel ? /* @__PURE__ */
|
|
7288
|
-
/* @__PURE__ */
|
|
7475
|
+
onCancel ? /* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }) : null,
|
|
7476
|
+
/* @__PURE__ */ jsx33(
|
|
7289
7477
|
"span",
|
|
7290
7478
|
{
|
|
7291
7479
|
id: "field-editor-missing",
|
|
@@ -7301,11 +7489,11 @@ function FieldEditor(props) {
|
|
|
7301
7489
|
footer is always as wide and as tall as its larger state: opening the confirm moved
|
|
7302
7490
|
the dialog card 0.2278 and closing it 0.1303. The consequence is the tooltip of
|
|
7303
7491
|
"Remove it" (interface-text: the slot holds a label, never a paragraph). */
|
|
7304
|
-
/* @__PURE__ */
|
|
7305
|
-
/* @__PURE__ */
|
|
7306
|
-
/* @__PURE__ */
|
|
7307
|
-
/* @__PURE__ */
|
|
7308
|
-
/* @__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(
|
|
7309
7497
|
Button15,
|
|
7310
7498
|
{
|
|
7311
7499
|
size: "sm",
|
|
@@ -7318,7 +7506,7 @@ function FieldEditor(props) {
|
|
|
7318
7506
|
children: "Remove it"
|
|
7319
7507
|
}
|
|
7320
7508
|
),
|
|
7321
|
-
/* @__PURE__ */
|
|
7509
|
+
/* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "ghost", tabIndex: askingToRemove ? void 0 : -1, onClick: () => setAskingToRemove(false), children: "Keep it" })
|
|
7322
7510
|
] })
|
|
7323
7511
|
] })
|
|
7324
7512
|
) : null
|
|
@@ -7409,10 +7597,10 @@ function formulaSeparatorOf(field) {
|
|
|
7409
7597
|
function TypeQuestions(props) {
|
|
7410
7598
|
const { type } = props;
|
|
7411
7599
|
if (type === "entity_reference") {
|
|
7412
|
-
return /* @__PURE__ */
|
|
7600
|
+
return /* @__PURE__ */ jsx33(EntityReferenceKindPicker, { value: props.allowedTypes, onChange: props.setAllowedTypes, locked: props.editing });
|
|
7413
7601
|
}
|
|
7414
7602
|
if (type === "relation") {
|
|
7415
|
-
return /* @__PURE__ */
|
|
7603
|
+
return /* @__PURE__ */ jsx33(
|
|
7416
7604
|
ReferenceBuilder,
|
|
7417
7605
|
{
|
|
7418
7606
|
tableId: props.tableId,
|
|
@@ -7425,20 +7613,20 @@ function TypeQuestions(props) {
|
|
|
7425
7613
|
}
|
|
7426
7614
|
);
|
|
7427
7615
|
}
|
|
7428
|
-
if (type === "rating" || type === "barcode") return /* @__PURE__ */
|
|
7616
|
+
if (type === "rating" || type === "barcode") return /* @__PURE__ */ jsx33(Fragment10, { children: props.newer });
|
|
7429
7617
|
if (type === "status") {
|
|
7430
|
-
return /* @__PURE__ */
|
|
7618
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-3", children: [
|
|
7431
7619
|
props.choiceList,
|
|
7432
7620
|
props.newer
|
|
7433
7621
|
] });
|
|
7434
7622
|
}
|
|
7435
7623
|
if (type === "select" || type === "multi_select") {
|
|
7436
|
-
return /* @__PURE__ */
|
|
7624
|
+
return /* @__PURE__ */ jsx33(Fragment10, { children: props.choiceList });
|
|
7437
7625
|
}
|
|
7438
7626
|
if (type === "currency") {
|
|
7439
|
-
return /* @__PURE__ */
|
|
7440
|
-
/* @__PURE__ */
|
|
7441
|
-
/* @__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(
|
|
7442
7630
|
BasicInput9,
|
|
7443
7631
|
{
|
|
7444
7632
|
value: props.unit,
|
|
@@ -7450,8 +7638,8 @@ function TypeQuestions(props) {
|
|
|
7450
7638
|
] });
|
|
7451
7639
|
}
|
|
7452
7640
|
if (type === "datetime") {
|
|
7453
|
-
return /* @__PURE__ */
|
|
7454
|
-
/* @__PURE__ */
|
|
7641
|
+
return /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7642
|
+
/* @__PURE__ */ jsx33(
|
|
7455
7643
|
Checkbox4,
|
|
7456
7644
|
{
|
|
7457
7645
|
checked: props.withTime,
|
|
@@ -7465,14 +7653,14 @@ function TypeQuestions(props) {
|
|
|
7465
7653
|
if (type === "lookup" || type === "rollup" || type === "count") {
|
|
7466
7654
|
const usable = props.relations;
|
|
7467
7655
|
if (usable.length === 0) {
|
|
7468
|
-
return /* @__PURE__ */
|
|
7656
|
+
return /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No link, Person or File column yet." });
|
|
7469
7657
|
}
|
|
7470
|
-
return /* @__PURE__ */
|
|
7471
|
-
/* @__PURE__ */
|
|
7472
|
-
/* @__PURE__ */
|
|
7473
|
-
/* @__PURE__ */
|
|
7474
|
-
/* @__PURE__ */
|
|
7475
|
-
/* @__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: [
|
|
7476
7664
|
fieldName(f),
|
|
7477
7665
|
isBackLinkSource(f) ? BACK_LINK_SOURCE_SUFFIX : "",
|
|
7478
7666
|
sourceKindOf(f) === "person" ? " \u2014 a person" : sourceKindOf(f) === "file" ? " \u2014 a file" : "",
|
|
@@ -7480,7 +7668,7 @@ function TypeQuestions(props) {
|
|
|
7480
7668
|
] }, f.id)) })
|
|
7481
7669
|
] })
|
|
7482
7670
|
] }),
|
|
7483
|
-
type === "lookup" ? /* @__PURE__ */
|
|
7671
|
+
type === "lookup" ? /* @__PURE__ */ jsx33(
|
|
7484
7672
|
ValueOnTheOtherSide,
|
|
7485
7673
|
{
|
|
7486
7674
|
label: "The value to read",
|
|
@@ -7489,13 +7677,13 @@ function TypeQuestions(props) {
|
|
|
7489
7677
|
value: props.pick,
|
|
7490
7678
|
onChange: props.setPick
|
|
7491
7679
|
}
|
|
7492
|
-
) : type === "count" ? null : /* @__PURE__ */
|
|
7493
|
-
/* @__PURE__ */
|
|
7494
|
-
/* @__PURE__ */
|
|
7495
|
-
/* @__PURE__ */
|
|
7496
|
-
/* @__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)) })
|
|
7497
7685
|
] }),
|
|
7498
|
-
props.agg !== "count" ? /* @__PURE__ */
|
|
7686
|
+
props.agg !== "count" ? /* @__PURE__ */ jsx33(
|
|
7499
7687
|
ValueOnTheOtherSide,
|
|
7500
7688
|
{
|
|
7501
7689
|
label: "Of which value",
|
|
@@ -7511,21 +7699,21 @@ function TypeQuestions(props) {
|
|
|
7511
7699
|
}
|
|
7512
7700
|
if (type === "formula") {
|
|
7513
7701
|
if (props.others.length === 0) {
|
|
7514
|
-
return /* @__PURE__ */
|
|
7702
|
+
return /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No other columns yet." });
|
|
7515
7703
|
}
|
|
7516
|
-
return /* @__PURE__ */
|
|
7517
|
-
/* @__PURE__ */
|
|
7518
|
-
/* @__PURE__ */
|
|
7519
|
-
/* @__PURE__ */
|
|
7520
|
-
/* @__PURE__ */
|
|
7521
|
-
/* @__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)) })
|
|
7522
7710
|
] })
|
|
7523
7711
|
] }),
|
|
7524
|
-
/* @__PURE__ */
|
|
7525
|
-
/* @__PURE__ */
|
|
7526
|
-
/* @__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) => {
|
|
7527
7715
|
const picked = props.formulaFields.includes(f.id);
|
|
7528
|
-
return /* @__PURE__ */
|
|
7716
|
+
return /* @__PURE__ */ jsx33(
|
|
7529
7717
|
Button15,
|
|
7530
7718
|
{
|
|
7531
7719
|
type: "button",
|
|
@@ -7540,9 +7728,9 @@ function TypeQuestions(props) {
|
|
|
7540
7728
|
);
|
|
7541
7729
|
}) })
|
|
7542
7730
|
] }),
|
|
7543
|
-
props.formulaOp === "concat" ? /* @__PURE__ */
|
|
7544
|
-
/* @__PURE__ */
|
|
7545
|
-
/* @__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(
|
|
7546
7734
|
BasicInput9,
|
|
7547
7735
|
{
|
|
7548
7736
|
value: props.formulaSeparator,
|
|
@@ -7593,25 +7781,25 @@ function RollupFilterQuestion({
|
|
|
7593
7781
|
}) {
|
|
7594
7782
|
const far = relation?.relation_target ?? null;
|
|
7595
7783
|
const farFields = useFields2(far);
|
|
7596
|
-
const conditionFields =
|
|
7784
|
+
const conditionFields = useMemo11(
|
|
7597
7785
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7598
7786
|
[farFields.data]
|
|
7599
7787
|
);
|
|
7600
|
-
const lastFar =
|
|
7601
|
-
|
|
7788
|
+
const lastFar = useRef13(far);
|
|
7789
|
+
useEffect18(() => {
|
|
7602
7790
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7603
7791
|
lastFar.current = far;
|
|
7604
7792
|
}, [far, editing, onChange]);
|
|
7605
7793
|
if (!relation || !far) return null;
|
|
7606
|
-
return /* @__PURE__ */
|
|
7607
|
-
/* @__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: [
|
|
7608
7796
|
rollupFilterLead(agg),
|
|
7609
7797
|
" ",
|
|
7610
7798
|
conditionInWords(value, conditionFields),
|
|
7611
7799
|
"."
|
|
7612
7800
|
] }),
|
|
7613
|
-
/* @__PURE__ */
|
|
7614
|
-
] }) : /* @__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(
|
|
7615
7803
|
ConditionGroup,
|
|
7616
7804
|
{
|
|
7617
7805
|
lead: rollupFilterLead(agg),
|
|
@@ -7637,13 +7825,13 @@ function ValueOnTheOtherSide({
|
|
|
7637
7825
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7638
7826
|
const offered = declared.length > 0 ? declared.map((f) => ({ key: f.key, name: fieldName(f) })) : Object.keys(carried ?? {}).map((key) => ({ key, name: humanizeIdentifier4(key) }));
|
|
7639
7827
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
7640
|
-
const body = !relation ? /* @__PURE__ */
|
|
7641
|
-
/* @__PURE__ */
|
|
7642
|
-
/* @__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)) })
|
|
7643
7831
|
] });
|
|
7644
|
-
if (compact) return /* @__PURE__ */
|
|
7645
|
-
return /* @__PURE__ */
|
|
7646
|
-
/* @__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 }),
|
|
7647
7835
|
body
|
|
7648
7836
|
] });
|
|
7649
7837
|
}
|
|
@@ -7669,18 +7857,18 @@ function NewColumnDefault({
|
|
|
7669
7857
|
onChange
|
|
7670
7858
|
}) {
|
|
7671
7859
|
const none = "__none__";
|
|
7672
|
-
return /* @__PURE__ */
|
|
7673
|
-
/* @__PURE__ */
|
|
7674
|
-
type === "checkbox" ? /* @__PURE__ */
|
|
7675
|
-
/* @__PURE__ */
|
|
7676
|
-
/* @__PURE__ */
|
|
7677
|
-
] }) : type === "select" || type === "multi_select" || type === "status" ? /* @__PURE__ */
|
|
7678
|
-
/* @__PURE__ */
|
|
7679
|
-
/* @__PURE__ */
|
|
7680
|
-
/* @__PURE__ */
|
|
7681
|
-
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))
|
|
7682
7870
|
] })
|
|
7683
|
-
] }) : /* @__PURE__ */
|
|
7871
|
+
] }) : /* @__PURE__ */ jsx33(
|
|
7684
7872
|
BasicInput9,
|
|
7685
7873
|
{
|
|
7686
7874
|
id: "records-new-field-default",
|
|
@@ -7695,7 +7883,7 @@ function NewColumnDefault({
|
|
|
7695
7883
|
// src/buttonCell.tsx
|
|
7696
7884
|
import { OutboundLink as OutboundLink6 } from "@ai-matrx/kit/outbound-react";
|
|
7697
7885
|
import { openOutbound } from "@ai-matrx/kit/outbound";
|
|
7698
|
-
import { Fragment as
|
|
7886
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7699
7887
|
function buttonPressWords(label, pressed) {
|
|
7700
7888
|
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
7701
7889
|
if (pressed.do === "run_action") {
|
|
@@ -7707,11 +7895,11 @@ function buttonPressWords(label, pressed) {
|
|
|
7707
7895
|
}
|
|
7708
7896
|
var stop = (event) => event.stopPropagation();
|
|
7709
7897
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7710
|
-
const client =
|
|
7898
|
+
const client = useOptionalRecordsClient9();
|
|
7711
7899
|
const b = buttonOf2(field);
|
|
7712
|
-
const [busy, setBusy] =
|
|
7713
|
-
const [said2, setSaid] =
|
|
7714
|
-
const [settingUp, setSettingUp] =
|
|
7900
|
+
const [busy, setBusy] = useState25(false);
|
|
7901
|
+
const [said2, setSaid] = useState25(null);
|
|
7902
|
+
const [settingUp, setSettingUp] = useState25(false);
|
|
7715
7903
|
if (!b) return null;
|
|
7716
7904
|
const color = isStyleColor2(b.color) ? CHOICE_CHIP_CLASS2[b.color] : NEUTRAL_CHIP_CLASS2;
|
|
7717
7905
|
const needs = buttonNeeds2(b);
|
|
@@ -7730,9 +7918,9 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7730
7918
|
}
|
|
7731
7919
|
setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
|
|
7732
7920
|
};
|
|
7733
|
-
return /* @__PURE__ */
|
|
7734
|
-
/* @__PURE__ */
|
|
7735
|
-
/* @__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(
|
|
7736
7924
|
Button16,
|
|
7737
7925
|
{
|
|
7738
7926
|
type: "button",
|
|
@@ -7742,7 +7930,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7742
7930
|
"data-records-button-unset": needs ? "" : void 0,
|
|
7743
7931
|
"aria-busy": busy || void 0,
|
|
7744
7932
|
disabled: busy,
|
|
7745
|
-
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"),
|
|
7746
7934
|
onPointerDown: stop,
|
|
7747
7935
|
onDoubleClick: stop,
|
|
7748
7936
|
onClick: (event) => {
|
|
@@ -7750,20 +7938,20 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7750
7938
|
event.preventDefault();
|
|
7751
7939
|
void press();
|
|
7752
7940
|
},
|
|
7753
|
-
children: /* @__PURE__ */
|
|
7941
|
+
children: /* @__PURE__ */ jsx34("span", { className: "truncate", children: b.label })
|
|
7754
7942
|
}
|
|
7755
7943
|
) }),
|
|
7756
|
-
/* @__PURE__ */
|
|
7757
|
-
said2?.kind === "refused" ? /* @__PURE__ */
|
|
7758
|
-
said2?.kind === "public" ? /* @__PURE__ */
|
|
7759
|
-
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: [
|
|
7760
7948
|
said2.says,
|
|
7761
7949
|
" ",
|
|
7762
|
-
said2.link ? /* @__PURE__ */
|
|
7950
|
+
said2.link ? /* @__PURE__ */ jsx34(OutboundLink6, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
7763
7951
|
] }) : null,
|
|
7764
|
-
said2?.kind === "needs" ? /* @__PURE__ */
|
|
7765
|
-
/* @__PURE__ */
|
|
7766
|
-
tableId ? /* @__PURE__ */
|
|
7952
|
+
said2?.kind === "needs" ? /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
7953
|
+
/* @__PURE__ */ jsx34("p", { children: said2.says }),
|
|
7954
|
+
tableId ? /* @__PURE__ */ jsxs32(
|
|
7767
7955
|
Button16,
|
|
7768
7956
|
{
|
|
7769
7957
|
type: "button",
|
|
@@ -7782,202 +7970,16 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7782
7970
|
] }) : null
|
|
7783
7971
|
] })
|
|
7784
7972
|
] }),
|
|
7785
|
-
settingUp && tableId ? /* @__PURE__ */
|
|
7786
|
-
/* @__PURE__ */
|
|
7787
|
-
/* @__PURE__ */
|
|
7788
|
-
/* @__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" })
|
|
7789
7977
|
] }),
|
|
7790
|
-
/* @__PURE__ */
|
|
7978
|
+
/* @__PURE__ */ jsx34(FieldEditor, { tableId, field, onSaved: () => setSettingUp(false), onCancel: () => setSettingUp(false) })
|
|
7791
7979
|
] }) }) : null
|
|
7792
7980
|
] });
|
|
7793
7981
|
}
|
|
7794
7982
|
|
|
7795
|
-
// src/PersonPicker.tsx
|
|
7796
|
-
import { useCallback as useCallback6, useEffect as useEffect18, useMemo as useMemo11, useRef as useRef13, useState as useState25 } from "react";
|
|
7797
|
-
import { rankTypedMatches as rankTypedMatches3 } from "@ai-matrx/records";
|
|
7798
|
-
import { useOptionalRecordsClient as useOptionalRecordsClient9 } from "@ai-matrx/records/react";
|
|
7799
|
-
import { cn as cn23 } from "@ai-matrx/design-system";
|
|
7800
|
-
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7801
|
-
function personFromRow(row) {
|
|
7802
|
-
const data = row.document ?? {};
|
|
7803
|
-
const userId = data["user_id"];
|
|
7804
|
-
return {
|
|
7805
|
-
id: row.id,
|
|
7806
|
-
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
7807
|
-
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
7808
|
-
};
|
|
7809
|
-
}
|
|
7810
|
-
function memberName(member) {
|
|
7811
|
-
const display = (member.name ?? "").trim();
|
|
7812
|
-
if (display !== "") return display;
|
|
7813
|
-
const email = (member.email ?? "").trim();
|
|
7814
|
-
if (email !== "") return email;
|
|
7815
|
-
return "A member with no name set";
|
|
7816
|
-
}
|
|
7817
|
-
async function personRecordForMember(client, personTableId, people, member) {
|
|
7818
|
-
const held = people.find((p) => p.userId === member.userId);
|
|
7819
|
-
if (held) return { ok: true, data: held.id };
|
|
7820
|
-
const written = await client.recordWrite({
|
|
7821
|
-
table_id: personTableId,
|
|
7822
|
-
data: {
|
|
7823
|
-
user_id: member.userId,
|
|
7824
|
-
full_name: memberName(member),
|
|
7825
|
-
...member.email ? { email: member.email } : {}
|
|
7826
|
-
}
|
|
7827
|
-
});
|
|
7828
|
-
return written;
|
|
7829
|
-
}
|
|
7830
|
-
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
7831
|
-
const client = useOptionalRecordsClient9();
|
|
7832
|
-
const host = useRecordsUi();
|
|
7833
|
-
const [members, setMembers] = useState25(null);
|
|
7834
|
-
const [people, setPeople] = useState25([]);
|
|
7835
|
-
const [error, setError] = useState25(null);
|
|
7836
|
-
const [search, setSearch] = useState25(initialSearch ?? "");
|
|
7837
|
-
const [open, setOpenState] = useState25(autoOpen === true);
|
|
7838
|
-
const onCloseRef = useRef13(onClose);
|
|
7839
|
-
onCloseRef.current = onClose;
|
|
7840
|
-
const setOpen = useCallback6((next) => {
|
|
7841
|
-
setOpenState(next);
|
|
7842
|
-
if (!next) onCloseRef.current?.();
|
|
7843
|
-
}, []);
|
|
7844
|
-
const [busy, setBusy] = useState25(false);
|
|
7845
|
-
const membersPort = host.members;
|
|
7846
|
-
const personTable = field.relation_target;
|
|
7847
|
-
const picked = useMemo11(
|
|
7848
|
-
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
7849
|
-
[value]
|
|
7850
|
-
);
|
|
7851
|
-
const load = useCallback6(async () => {
|
|
7852
|
-
if (!membersPort || !client) return;
|
|
7853
|
-
const [roster, records] = await Promise.all([
|
|
7854
|
-
membersPort(),
|
|
7855
|
-
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
7856
|
-
]);
|
|
7857
|
-
setMembers(roster);
|
|
7858
|
-
if (records && !records.ok) {
|
|
7859
|
-
setError(records.error);
|
|
7860
|
-
return;
|
|
7861
|
-
}
|
|
7862
|
-
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
7863
|
-
}, [membersPort, client, personTable]);
|
|
7864
|
-
useEffect18(() => {
|
|
7865
|
-
if (!open) return;
|
|
7866
|
-
void load();
|
|
7867
|
-
}, [open, load]);
|
|
7868
|
-
useEffect18(() => {
|
|
7869
|
-
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
7870
|
-
let cancelled = false;
|
|
7871
|
-
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
7872
|
-
if (cancelled || !result.ok) return;
|
|
7873
|
-
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
7874
|
-
});
|
|
7875
|
-
return () => {
|
|
7876
|
-
cancelled = true;
|
|
7877
|
-
};
|
|
7878
|
-
}, [client, personTable, picked.length, people.length]);
|
|
7879
|
-
const listed = rankTypedMatches3(members ?? [], search, memberName);
|
|
7880
|
-
if (!membersPort || !client) {
|
|
7881
|
-
return /* @__PURE__ */ jsx34("p", { className: cn23("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
7882
|
-
}
|
|
7883
|
-
if (!personTable) {
|
|
7884
|
-
return /* @__PURE__ */ jsxs32("p", { className: cn23("text-xs text-muted-foreground", className), children: [
|
|
7885
|
-
fieldName(field),
|
|
7886
|
-
" 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."
|
|
7887
|
-
] });
|
|
7888
|
-
}
|
|
7889
|
-
const displayNameOf = (userId, recordName2) => {
|
|
7890
|
-
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
7891
|
-
const own3 = (member?.name ?? "").trim();
|
|
7892
|
-
if (own3 !== "") return own3;
|
|
7893
|
-
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
7894
|
-
const email = (member?.email ?? "").trim();
|
|
7895
|
-
return kept !== "" && kept !== email ? kept : null;
|
|
7896
|
-
};
|
|
7897
|
-
const nameOfRecord = (recordId) => {
|
|
7898
|
-
const person = people.find((p) => p.id === recordId);
|
|
7899
|
-
if (!person) return "Loading\u2026";
|
|
7900
|
-
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
7901
|
-
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
7902
|
-
};
|
|
7903
|
-
const pick = async (member) => {
|
|
7904
|
-
setBusy(true);
|
|
7905
|
-
setError(null);
|
|
7906
|
-
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
7907
|
-
setBusy(false);
|
|
7908
|
-
if (!resolved.ok) {
|
|
7909
|
-
setError(resolved.error);
|
|
7910
|
-
return;
|
|
7911
|
-
}
|
|
7912
|
-
if (!people.some((p) => p.id === resolved.data)) {
|
|
7913
|
-
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
7914
|
-
}
|
|
7915
|
-
if (!field.multi) {
|
|
7916
|
-
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
7917
|
-
setOpen(false);
|
|
7918
|
-
return;
|
|
7919
|
-
}
|
|
7920
|
-
const next = new Set(picked);
|
|
7921
|
-
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
7922
|
-
else next.add(resolved.data);
|
|
7923
|
-
onChange(next.size === 0 ? null : [...next]);
|
|
7924
|
-
};
|
|
7925
|
-
const drop = (recordId) => {
|
|
7926
|
-
const next = picked.filter((id2) => id2 !== recordId);
|
|
7927
|
-
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
7928
|
-
};
|
|
7929
|
-
const visible = listed;
|
|
7930
|
-
const pickedUserIds = new Set(
|
|
7931
|
-
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
7932
|
-
);
|
|
7933
|
-
const anchored = autoOpen === true;
|
|
7934
|
-
const cellChips = picked.map((recordId) => /* @__PURE__ */ jsx34(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
7935
|
-
return /* @__PURE__ */ jsxs32("div", { className: cn23("flex flex-wrap items-center gap-1", className), children: [
|
|
7936
|
-
anchored && !disabled ? null : cellChips,
|
|
7937
|
-
disabled ? null : (
|
|
7938
|
-
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
7939
|
-
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
7940
|
-
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
7941
|
-
/* @__PURE__ */ jsx34(
|
|
7942
|
-
PickOrAdd,
|
|
7943
|
-
{
|
|
7944
|
-
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
7945
|
-
anchored,
|
|
7946
|
-
multi: field.multi,
|
|
7947
|
-
triggerId: id,
|
|
7948
|
-
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
7949
|
-
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
7950
|
-
open,
|
|
7951
|
-
onOpenChange: setOpen,
|
|
7952
|
-
search,
|
|
7953
|
-
onSearch: setSearch,
|
|
7954
|
-
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
7955
|
-
items: visible.map((member) => ({
|
|
7956
|
-
id: member.userId,
|
|
7957
|
-
label: displayNameOf(member.userId) ?? memberName(member),
|
|
7958
|
-
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
7959
|
-
// 19 September). They are two facts, so they are drawn as two.
|
|
7960
|
-
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
7961
|
-
picked: pickedUserIds.has(member.userId),
|
|
7962
|
-
person: true,
|
|
7963
|
-
disabled: busy
|
|
7964
|
-
})),
|
|
7965
|
-
onPick: (userId) => {
|
|
7966
|
-
const member = visible.find((m) => m.userId === userId);
|
|
7967
|
-
if (member && !busy) void pick(member);
|
|
7968
|
-
},
|
|
7969
|
-
notice: /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
7970
|
-
error ? /* @__PURE__ */ jsx34(RefusalLine, { error, className: "p-2" }) : null,
|
|
7971
|
-
members === null ? /* @__PURE__ */ jsx34("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
7972
|
-
] }),
|
|
7973
|
-
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,
|
|
7974
|
-
children: anchored ? cellChips : null
|
|
7975
|
-
}
|
|
7976
|
-
)
|
|
7977
|
-
)
|
|
7978
|
-
] });
|
|
7979
|
-
}
|
|
7980
|
-
|
|
7981
7983
|
// src/FloatingRefusal.tsx
|
|
7982
7984
|
import { useLayoutEffect, useRef as useRef14, useState as useState26 } from "react";
|
|
7983
7985
|
import { createPortal } from "react-dom";
|