@ai-matrx/records-ui 0.115.83 → 0.115.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/helpers.d.cts +10 -0
- package/dist/helpers.d.ts +10 -0
- package/dist/index.cjs +3882 -3615
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +3437 -3170
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +1102 -879
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +993 -770
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/pickers.js
CHANGED
|
@@ -14,7 +14,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
|
|
16
16
|
// src/TablePickers.tsx
|
|
17
|
-
import { useEffect as
|
|
17
|
+
import { useEffect as useEffect23, useMemo as useMemo13, useState as useState32 } from "react";
|
|
18
18
|
import { RecordsProvider as RecordsProvider2, useFields as useFields3, useRecords as useRecords3, useTable as useTable2 } from "@ai-matrx/records/react";
|
|
19
19
|
import { Button as Button18, CreatablePicker } from "@ai-matrx/design-system";
|
|
20
20
|
|
|
@@ -676,19 +676,19 @@ function quiet(may, say) {
|
|
|
676
676
|
}
|
|
677
677
|
function useTableRights(table) {
|
|
678
678
|
const host = useRecordsUi();
|
|
679
|
-
const
|
|
680
|
-
return useMemo(() => quiet(
|
|
679
|
+
const asked3 = useTableRightsAsked(table, host);
|
|
680
|
+
return useMemo(() => quiet(asked3, host.sayLevelNeeded), [asked3, host.sayLevelNeeded]);
|
|
681
681
|
}
|
|
682
682
|
function useTableRightsAsked(table, host) {
|
|
683
683
|
const bound = Boolean(host.rights);
|
|
684
|
-
const
|
|
684
|
+
const asked3 = useMyLevel(bound || !table ? null : table.id);
|
|
685
685
|
return useMemo(() => {
|
|
686
686
|
if (!table) return NO_RIGHTS;
|
|
687
687
|
if (host.rights) return host.rights(table);
|
|
688
|
-
if (
|
|
689
|
-
const level =
|
|
688
|
+
if (asked3.loading) return tableRights(NOT_ANSWERED_YET);
|
|
689
|
+
const level = asked3.error ? null : asked3.data;
|
|
690
690
|
return tableRights(whatYouMayDoWithTable(table, level, true));
|
|
691
|
-
}, [host, table, bound,
|
|
691
|
+
}, [host, table, bound, asked3.loading, asked3.error, asked3.data]);
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
// src/ArchivedOrganizationNotice.tsx
|
|
@@ -872,9 +872,9 @@ function AddChoicesInline({ field, onAdded, disabled = false }) {
|
|
|
872
872
|
}
|
|
873
873
|
|
|
874
874
|
// src/editors.tsx
|
|
875
|
-
import { useCallback as useCallback7, useEffect as
|
|
875
|
+
import { useCallback as useCallback7, useEffect as useEffect22, useLayoutEffect as useLayoutEffect2, useRef as useRef16, useState as useState31 } from "react";
|
|
876
876
|
import { isButtonField as isButtonField3, allowsOtherValues, choiceValuesOf, coerceTypedAnswer, newerKindOf as newerKindOf5, decideTypedChoice, isTheChosen, optionKey as optionKey4, rankTypedMatches as rankTypedMatches4, readTypedTime as readTypedTime2, typedDateText as typedDateText2, typedTimeText as typedTimeText2 } from "@ai-matrx/records";
|
|
877
|
-
import { useOptionalRecordsClient as
|
|
877
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient12 } from "@ai-matrx/records/react";
|
|
878
878
|
import {
|
|
879
879
|
BasicInput as BasicInput11,
|
|
880
880
|
BasicTextarea as BasicTextarea4,
|
|
@@ -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 useState26 } 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 useOptionalRecordsClient10 } 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 useEffect19, useMemo as useMemo12, useRef as useRef13, useState as useState25 } 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
|
|
@@ -2635,8 +2635,8 @@ function FormulaTextEditor({
|
|
|
2635
2635
|
const report = useRef5(onChecked);
|
|
2636
2636
|
report.current = onChecked;
|
|
2637
2637
|
useEffect7(() => {
|
|
2638
|
-
const
|
|
2639
|
-
if (
|
|
2638
|
+
const asked3 = text.trim();
|
|
2639
|
+
if (asked3 === "") {
|
|
2640
2640
|
setParsed(null);
|
|
2641
2641
|
setError(null);
|
|
2642
2642
|
report.current(null);
|
|
@@ -2645,7 +2645,7 @@ function FormulaTextEditor({
|
|
|
2645
2645
|
report.current(null);
|
|
2646
2646
|
let cancelled = false;
|
|
2647
2647
|
const timer = setTimeout(() => {
|
|
2648
|
-
void client.formulaPreview({ table_id: tableId, record_id: sampled, text:
|
|
2648
|
+
void client.formulaPreview({ table_id: tableId, record_id: sampled, text: asked3 }).then((previewed) => previewed.ok ? previewed : client.formulaParse({ table_id: tableId, text: asked3 })).then((answered) => {
|
|
2649
2649
|
if (cancelled) return;
|
|
2650
2650
|
if (!answered.ok) {
|
|
2651
2651
|
setError(answered.error);
|
|
@@ -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 useEffect14, useState as useState20 } 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";
|
|
@@ -2966,31 +2966,31 @@ var FILES = /* @__PURE__ */ new WeakMap();
|
|
|
2966
2966
|
function signatureFilesOf(client, recordId) {
|
|
2967
2967
|
let held = SOURCES.get(client);
|
|
2968
2968
|
if (!held) SOURCES.set(client, held = /* @__PURE__ */ new Map());
|
|
2969
|
-
let
|
|
2970
|
-
if (!
|
|
2971
|
-
|
|
2969
|
+
let asked3 = held.get(recordId);
|
|
2970
|
+
if (!asked3) {
|
|
2971
|
+
asked3 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
|
|
2972
2972
|
if (!answered.ok) return {};
|
|
2973
2973
|
return Object.fromEntries(answered.data.map((v) => [v.field_key, signatureFileOf(v.source)]));
|
|
2974
2974
|
});
|
|
2975
|
-
held.set(recordId,
|
|
2975
|
+
held.set(recordId, asked3);
|
|
2976
2976
|
}
|
|
2977
|
-
return
|
|
2977
|
+
return asked3;
|
|
2978
2978
|
}
|
|
2979
2979
|
function drawingOf(client, fileId) {
|
|
2980
2980
|
let held = FILES.get(client);
|
|
2981
2981
|
if (!held) FILES.set(client, held = /* @__PURE__ */ new Map());
|
|
2982
|
-
let
|
|
2983
|
-
if (!
|
|
2984
|
-
|
|
2982
|
+
let asked3 = held.get(fileId);
|
|
2983
|
+
if (!asked3) {
|
|
2984
|
+
asked3 = client.recordRead({ record_id: fileId }).then((answered) => {
|
|
2985
2985
|
if (!answered.ok) return { src: null, hostFileId: null };
|
|
2986
2986
|
const doc = answered.data.document ?? {};
|
|
2987
2987
|
const content = drawnSignatureOf(doc["content"]);
|
|
2988
2988
|
const hostFileId = typeof doc["file_id"] === "string" && doc["file_id"] !== "" ? doc["file_id"] : null;
|
|
2989
2989
|
return { src: content, hostFileId };
|
|
2990
2990
|
});
|
|
2991
|
-
held.set(fileId,
|
|
2991
|
+
held.set(fileId, asked3);
|
|
2992
2992
|
}
|
|
2993
|
-
return
|
|
2993
|
+
return asked3;
|
|
2994
2994
|
}
|
|
2995
2995
|
function DrawnImage({ src, inCell }) {
|
|
2996
2996
|
return /* @__PURE__ */ jsx14(
|
|
@@ -3233,12 +3233,12 @@ function pointsAtRecords(field) {
|
|
|
3233
3233
|
}
|
|
3234
3234
|
function RecordLabelProvider({ children }) {
|
|
3235
3235
|
const client = useRecordsClient5();
|
|
3236
|
-
const [
|
|
3236
|
+
const [names2, setNames] = useState12({});
|
|
3237
3237
|
const [archivedRefs, setArchivedRefs] = useState12({});
|
|
3238
3238
|
const [iconsOf, setIconsOf] = useState12({});
|
|
3239
3239
|
const [settled, setSettled] = useState12({});
|
|
3240
3240
|
const [waitingLines, setWaitingLines] = useState12({});
|
|
3241
|
-
const
|
|
3241
|
+
const asked3 = useRef7(/* @__PURE__ */ new Set());
|
|
3242
3242
|
const chased = useRef7(/* @__PURE__ */ new Set());
|
|
3243
3243
|
const timers = useRef7(/* @__PURE__ */ new Map());
|
|
3244
3244
|
const startWaitClock = useCallback3((field, target) => {
|
|
@@ -3276,8 +3276,8 @@ function RecordLabelProvider({ children }) {
|
|
|
3276
3276
|
const want = useCallback3(
|
|
3277
3277
|
(field) => {
|
|
3278
3278
|
if (!pointsAtRecords(field)) return;
|
|
3279
|
-
if (
|
|
3280
|
-
|
|
3279
|
+
if (asked3.current.has(field.id)) return;
|
|
3280
|
+
asked3.current.add(field.id);
|
|
3281
3281
|
startWaitClock(field, null);
|
|
3282
3282
|
void (async () => {
|
|
3283
3283
|
if (field.type === "list") {
|
|
@@ -3363,22 +3363,22 @@ function RecordLabelProvider({ children }) {
|
|
|
3363
3363
|
const lookupWords = useCallback3(
|
|
3364
3364
|
(field, id) => {
|
|
3365
3365
|
if (field.type === "list" && !isId(id)) {
|
|
3366
|
-
const named =
|
|
3366
|
+
const named = names2[choiceKeyName(field.id, id)];
|
|
3367
3367
|
if (named !== void 0) return named;
|
|
3368
3368
|
const once = choiceKeyName(field.id, id);
|
|
3369
3369
|
if (settled[field.id] && !rereadFor.current.has(once)) {
|
|
3370
3370
|
rereadFor.current.add(once);
|
|
3371
|
-
|
|
3371
|
+
asked3.current.delete(field.id);
|
|
3372
3372
|
want(field);
|
|
3373
3373
|
}
|
|
3374
3374
|
return null;
|
|
3375
3375
|
}
|
|
3376
|
-
const known =
|
|
3376
|
+
const known = names2[id];
|
|
3377
3377
|
if (known !== void 0) return known;
|
|
3378
3378
|
if (settled[field.id]) chase(field, id);
|
|
3379
3379
|
return null;
|
|
3380
3380
|
},
|
|
3381
|
-
[
|
|
3381
|
+
[names2, settled, chase, want]
|
|
3382
3382
|
);
|
|
3383
3383
|
const lookup = useMemo7(
|
|
3384
3384
|
() => {
|
|
@@ -4531,13 +4531,13 @@ var BRACE = /\{([^{}]*)\}/g;
|
|
|
4531
4531
|
function formulaTextNow(text, expr, fields) {
|
|
4532
4532
|
if (!text || !fields || fields.length === 0) return text;
|
|
4533
4533
|
const refs = fieldRefsOf(expr);
|
|
4534
|
-
const
|
|
4535
|
-
if (refs.length === 0 || refs.length !==
|
|
4534
|
+
const names2 = [...text.matchAll(BRACE)].map((m) => m[1] ?? "");
|
|
4535
|
+
if (refs.length === 0 || refs.length !== names2.length) return text;
|
|
4536
4536
|
const byId = new Map(fields.map((f) => [String(f.id), f]));
|
|
4537
4537
|
const becomes = /* @__PURE__ */ new Map();
|
|
4538
4538
|
const replacement = [];
|
|
4539
|
-
for (let i2 = 0; i2 <
|
|
4540
|
-
const name =
|
|
4539
|
+
for (let i2 = 0; i2 < names2.length; i2 += 1) {
|
|
4540
|
+
const name = names2[i2];
|
|
4541
4541
|
const field = byId.get(refs[i2]);
|
|
4542
4542
|
if (!field) return text;
|
|
4543
4543
|
const now = fieldName(field);
|
|
@@ -4566,11 +4566,290 @@ 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/userIds.ts
|
|
4571
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4572
|
+
var PERSON_NOT_IN_ORGANIZATION = "A person no longer in this organization";
|
|
4573
|
+
function isUserId(value) {
|
|
4574
|
+
return typeof value === "string" && UUID.test(value);
|
|
4575
|
+
}
|
|
4576
|
+
|
|
4577
|
+
// src/personNames.ts
|
|
4578
|
+
import { useSyncExternalStore } from "react";
|
|
4579
|
+
var names = /* @__PURE__ */ new Map();
|
|
4580
|
+
var asked = /* @__PURE__ */ new Set();
|
|
4581
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
4582
|
+
var version = 0;
|
|
4583
|
+
var resolver = null;
|
|
4584
|
+
var opener = null;
|
|
4585
|
+
async function openStoredPerson(id, open) {
|
|
4586
|
+
if (!open) return;
|
|
4587
|
+
const who = opener ? await opener(id) : null;
|
|
4588
|
+
open(who ?? { recordId: id });
|
|
4589
|
+
}
|
|
4590
|
+
function bump() {
|
|
4591
|
+
version += 1;
|
|
4592
|
+
for (const l of listeners) l();
|
|
4593
|
+
}
|
|
4594
|
+
function rememberPerson(id, name) {
|
|
4595
|
+
const key = id.toLowerCase();
|
|
4596
|
+
if (names.get(key) === name) return;
|
|
4597
|
+
names.set(key, name);
|
|
4598
|
+
bump();
|
|
4599
|
+
}
|
|
4600
|
+
function knownPerson(id) {
|
|
4601
|
+
const key = id.toLowerCase();
|
|
4602
|
+
const held = names.get(key);
|
|
4603
|
+
if (held !== void 0) return held;
|
|
4604
|
+
if (resolver && !asked.has(key)) {
|
|
4605
|
+
asked.add(key);
|
|
4606
|
+
const run = resolver;
|
|
4607
|
+
void run(id).then((name) => {
|
|
4608
|
+
if (name) rememberPerson(key, name);
|
|
4609
|
+
}).catch(() => asked.delete(key));
|
|
4610
|
+
}
|
|
4611
|
+
return null;
|
|
4612
|
+
}
|
|
4613
|
+
|
|
4614
|
+
// src/memberNames.ts
|
|
4615
|
+
import { useEffect as useEffect13, useMemo as useMemo10, useState as useState19 } from "react";
|
|
4616
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient7 } from "@ai-matrx/records/react";
|
|
4617
|
+
|
|
4618
|
+
// src/PersonPicker.tsx
|
|
4619
|
+
import { useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo9, useRef as useRef11, useState as useState18 } from "react";
|
|
4620
|
+
import { rankTypedMatches as rankTypedMatches2 } from "@ai-matrx/records";
|
|
4621
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient6 } from "@ai-matrx/records/react";
|
|
4622
|
+
import { cn as cn19 } from "@ai-matrx/design-system";
|
|
4570
4623
|
import { Fragment as Fragment7, jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4624
|
+
function personFromRow(row) {
|
|
4625
|
+
const data = row.document ?? {};
|
|
4626
|
+
const userId = data["user_id"];
|
|
4627
|
+
return {
|
|
4628
|
+
id: row.id,
|
|
4629
|
+
userId: typeof userId === "string" && userId !== "" ? userId : null,
|
|
4630
|
+
name: String(data["full_name"] ?? data["name"] ?? data["email"] ?? "").trim()
|
|
4631
|
+
};
|
|
4632
|
+
}
|
|
4633
|
+
function memberName(member) {
|
|
4634
|
+
const display = (member.name ?? "").trim();
|
|
4635
|
+
if (display !== "") return display;
|
|
4636
|
+
const email = (member.email ?? "").trim();
|
|
4637
|
+
if (email !== "") return email;
|
|
4638
|
+
return "A member with no name set";
|
|
4639
|
+
}
|
|
4640
|
+
async function personRecordForMember(client, personTableId, people, member) {
|
|
4641
|
+
const held = people.find((p) => p.userId === member.userId);
|
|
4642
|
+
if (held) return { ok: true, data: held.id };
|
|
4643
|
+
const written = await client.recordWrite({
|
|
4644
|
+
table_id: personTableId,
|
|
4645
|
+
data: {
|
|
4646
|
+
user_id: member.userId,
|
|
4647
|
+
full_name: memberName(member),
|
|
4648
|
+
...member.email ? { email: member.email } : {}
|
|
4649
|
+
}
|
|
4650
|
+
});
|
|
4651
|
+
return written;
|
|
4652
|
+
}
|
|
4653
|
+
function PersonPicker({ field, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
4654
|
+
const client = useOptionalRecordsClient6();
|
|
4655
|
+
const host = useRecordsUi();
|
|
4656
|
+
const [members, setMembers] = useState18(null);
|
|
4657
|
+
const [people, setPeople] = useState18([]);
|
|
4658
|
+
const [error, setError] = useState18(null);
|
|
4659
|
+
const [search, setSearch] = useState18(initialSearch ?? "");
|
|
4660
|
+
const [open, setOpenState] = useState18(autoOpen === true);
|
|
4661
|
+
const onCloseRef = useRef11(onClose);
|
|
4662
|
+
onCloseRef.current = onClose;
|
|
4663
|
+
const setOpen = useCallback5((next) => {
|
|
4664
|
+
setOpenState(next);
|
|
4665
|
+
if (!next) onCloseRef.current?.();
|
|
4666
|
+
}, []);
|
|
4667
|
+
const [busy, setBusy] = useState18(false);
|
|
4668
|
+
const membersPort = host.members;
|
|
4669
|
+
const personTable = field.relation_target;
|
|
4670
|
+
const picked = useMemo9(
|
|
4671
|
+
() => Array.isArray(value) ? value.map(String) : value === null || value === void 0 ? [] : [String(value)],
|
|
4672
|
+
[value]
|
|
4673
|
+
);
|
|
4674
|
+
const load = useCallback5(async () => {
|
|
4675
|
+
if (!membersPort || !client) return;
|
|
4676
|
+
const [roster, records] = await Promise.all([
|
|
4677
|
+
membersPort(),
|
|
4678
|
+
personTable ? client.list({ table_id: personTable, limit: 500 }) : Promise.resolve(null)
|
|
4679
|
+
]);
|
|
4680
|
+
setMembers(roster);
|
|
4681
|
+
if (records && !records.ok) {
|
|
4682
|
+
setError(records.error);
|
|
4683
|
+
return;
|
|
4684
|
+
}
|
|
4685
|
+
setPeople(records ? records.data.rows.map(personFromRow).filter((p) => p.userId !== null) : []);
|
|
4686
|
+
}, [membersPort, client, personTable]);
|
|
4687
|
+
useEffect12(() => {
|
|
4688
|
+
if (!open) return;
|
|
4689
|
+
void load();
|
|
4690
|
+
}, [open, load]);
|
|
4691
|
+
useEffect12(() => {
|
|
4692
|
+
if (picked.length === 0 || !personTable || people.length > 0 || !client) return;
|
|
4693
|
+
let cancelled = false;
|
|
4694
|
+
void client.list({ table_id: personTable, limit: 500 }).then((result) => {
|
|
4695
|
+
if (cancelled || !result.ok) return;
|
|
4696
|
+
setPeople(result.data.rows.map(personFromRow).filter((p) => p.userId !== null));
|
|
4697
|
+
});
|
|
4698
|
+
return () => {
|
|
4699
|
+
cancelled = true;
|
|
4700
|
+
};
|
|
4701
|
+
}, [client, personTable, picked.length, people.length]);
|
|
4702
|
+
const listed = rankTypedMatches2(members ?? [], search, memberName);
|
|
4703
|
+
if (!membersPort || !client) {
|
|
4704
|
+
return /* @__PURE__ */ jsx23("p", { className: cn19("text-xs text-muted-foreground", className), children: NO_MEMBERS_REASON });
|
|
4705
|
+
}
|
|
4706
|
+
if (!personTable) {
|
|
4707
|
+
return /* @__PURE__ */ jsxs21("p", { className: cn19("text-xs text-muted-foreground", className), children: [
|
|
4708
|
+
fieldName(field),
|
|
4709
|
+
" 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."
|
|
4710
|
+
] });
|
|
4711
|
+
}
|
|
4712
|
+
const displayNameOf = (userId, recordName2) => {
|
|
4713
|
+
const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
|
|
4714
|
+
const own3 = (member?.name ?? "").trim();
|
|
4715
|
+
if (own3 !== "") return own3;
|
|
4716
|
+
const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
|
|
4717
|
+
const email = (member?.email ?? "").trim();
|
|
4718
|
+
return kept !== "" && kept !== email ? kept : null;
|
|
4719
|
+
};
|
|
4720
|
+
const nameOfRecord = (recordId) => {
|
|
4721
|
+
const person = people.find((p) => p.id === recordId);
|
|
4722
|
+
if (!person) return "Loading\u2026";
|
|
4723
|
+
const member = (members ?? []).find((m) => m.userId === person.userId);
|
|
4724
|
+
return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
|
|
4725
|
+
};
|
|
4726
|
+
const pick = async (member) => {
|
|
4727
|
+
setBusy(true);
|
|
4728
|
+
setError(null);
|
|
4729
|
+
const resolved = await personRecordForMember(client, personTable, people, member);
|
|
4730
|
+
setBusy(false);
|
|
4731
|
+
if (!resolved.ok) {
|
|
4732
|
+
setError(resolved.error);
|
|
4733
|
+
return;
|
|
4734
|
+
}
|
|
4735
|
+
if (!people.some((p) => p.id === resolved.data)) {
|
|
4736
|
+
setPeople((held) => [...held, { id: resolved.data, userId: member.userId, name: memberName(member) }]);
|
|
4737
|
+
}
|
|
4738
|
+
if (!field.multi) {
|
|
4739
|
+
onChange(picked[0] === resolved.data ? null : resolved.data);
|
|
4740
|
+
setOpen(false);
|
|
4741
|
+
return;
|
|
4742
|
+
}
|
|
4743
|
+
const next = new Set(picked);
|
|
4744
|
+
if (next.has(resolved.data)) next.delete(resolved.data);
|
|
4745
|
+
else next.add(resolved.data);
|
|
4746
|
+
onChange(next.size === 0 ? null : [...next]);
|
|
4747
|
+
};
|
|
4748
|
+
const drop = (recordId) => {
|
|
4749
|
+
const next = picked.filter((id2) => id2 !== recordId);
|
|
4750
|
+
onChange(next.length === 0 ? null : field.multi ? next : next[0] ?? null);
|
|
4751
|
+
};
|
|
4752
|
+
const visible = listed;
|
|
4753
|
+
const pickedUserIds = new Set(
|
|
4754
|
+
picked.map((recordId) => people.find((p) => p.id === recordId)?.userId).filter(Boolean)
|
|
4755
|
+
);
|
|
4756
|
+
const anchored = autoOpen === true;
|
|
4757
|
+
const cellChips = picked.map((recordId) => /* @__PURE__ */ jsx23(PersonChip, { name: nameOfRecord(recordId), ...disabled || anchored ? {} : { onRemove: () => drop(recordId) } }, recordId));
|
|
4758
|
+
return /* @__PURE__ */ jsxs21("div", { className: cn19("flex flex-wrap items-center gap-1", className), children: [
|
|
4759
|
+
anchored && !disabled ? null : cellChips,
|
|
4760
|
+
disabled ? null : (
|
|
4761
|
+
// THE ONE "PICK OR ADD" BUILDER (lane CELL-EDITORS, 2026-10-06): the person list used to carry
|
|
4762
|
+
// its own copy of the list's layout and keys; it now draws the same rows, ticks, highlight and
|
|
4763
|
+
// head chips as every other picker, and in a grid cell hangs from the cell.
|
|
4764
|
+
/* @__PURE__ */ jsx23(
|
|
4765
|
+
PickOrAdd,
|
|
4766
|
+
{
|
|
4767
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
4768
|
+
anchored,
|
|
4769
|
+
multi: field.multi,
|
|
4770
|
+
triggerId: id,
|
|
4771
|
+
triggerLabel: `Pick a person for ${fieldName(field)}`,
|
|
4772
|
+
triggerText: picked.length === 0 ? "Pick a person" : "Change",
|
|
4773
|
+
open,
|
|
4774
|
+
onOpenChange: setOpen,
|
|
4775
|
+
search,
|
|
4776
|
+
onSearch: setSearch,
|
|
4777
|
+
chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), person: true, onRemove: () => drop(recordId) })),
|
|
4778
|
+
items: visible.map((member) => ({
|
|
4779
|
+
id: member.userId,
|
|
4780
|
+
label: displayNameOf(member.userId) ?? memberName(member),
|
|
4781
|
+
// A name and an email with nothing between them read as one run-on string (verdict,
|
|
4782
|
+
// 19 September). They are two facts, so they are drawn as two.
|
|
4783
|
+
detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
|
|
4784
|
+
picked: pickedUserIds.has(member.userId),
|
|
4785
|
+
person: true,
|
|
4786
|
+
disabled: busy
|
|
4787
|
+
})),
|
|
4788
|
+
onPick: (userId) => {
|
|
4789
|
+
const member = visible.find((m) => m.userId === userId);
|
|
4790
|
+
if (member && !busy) void pick(member);
|
|
4791
|
+
},
|
|
4792
|
+
notice: /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4793
|
+
error ? /* @__PURE__ */ jsx23(RefusalLine, { error, className: "p-2" }) : null,
|
|
4794
|
+
members === null ? /* @__PURE__ */ jsx23("p", { className: "p-2 text-xs text-muted-foreground", children: "Reading the members\u2026" }) : null
|
|
4795
|
+
] }),
|
|
4796
|
+
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,
|
|
4797
|
+
children: anchored ? cellChips : null
|
|
4798
|
+
}
|
|
4799
|
+
)
|
|
4800
|
+
)
|
|
4801
|
+
] });
|
|
4802
|
+
}
|
|
4803
|
+
|
|
4804
|
+
// src/memberNames.ts
|
|
4805
|
+
function memberWords(member) {
|
|
4806
|
+
const name = member?.name?.trim();
|
|
4807
|
+
if (name) return name;
|
|
4808
|
+
const email = member?.email?.trim();
|
|
4809
|
+
return email ? email : null;
|
|
4810
|
+
}
|
|
4811
|
+
function useMemberRoster() {
|
|
4812
|
+
const host = useRecordsUi();
|
|
4813
|
+
const members = host.members;
|
|
4814
|
+
const [roster, setRoster] = useState19(null);
|
|
4815
|
+
useEffect13(() => {
|
|
4816
|
+
if (!members) {
|
|
4817
|
+
setRoster(/* @__PURE__ */ new Map());
|
|
4818
|
+
return;
|
|
4819
|
+
}
|
|
4820
|
+
let cancelled = false;
|
|
4821
|
+
void members().then((list) => !cancelled && setRoster(new Map(list.map((m) => [m.userId.toLowerCase(), m])))).catch(() => !cancelled && setRoster(/* @__PURE__ */ new Map()));
|
|
4822
|
+
return () => {
|
|
4823
|
+
cancelled = true;
|
|
4824
|
+
};
|
|
4825
|
+
}, [members]);
|
|
4826
|
+
return roster;
|
|
4827
|
+
}
|
|
4828
|
+
async function resolveKeptPerson(client, id, roster) {
|
|
4829
|
+
if (client) {
|
|
4830
|
+
try {
|
|
4831
|
+
const read = await client.recordRead({ record_id: id });
|
|
4832
|
+
if (read.ok) {
|
|
4833
|
+
const person = personFromRow({ id, document: read.data.document });
|
|
4834
|
+
const member = person.userId ? roster.get(person.userId.toLowerCase()) : void 0;
|
|
4835
|
+
const named = memberWords(member) ?? (person.name !== "" ? person.name : null);
|
|
4836
|
+
const doc = read.data.document ?? {};
|
|
4837
|
+
const email = (typeof doc["email"] === "string" && doc["email"].trim() !== "" ? doc["email"].trim() : null) ?? member?.email?.trim() ?? null;
|
|
4838
|
+
if (person.userId || named) return { id, recordId: id, name: named ?? PERSON_NOT_IN_ORGANIZATION, userId: person.userId, email };
|
|
4839
|
+
}
|
|
4840
|
+
} catch {
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
const direct = roster.get(id.toLowerCase());
|
|
4844
|
+
return { id, recordId: null, name: memberWords(direct) ?? PERSON_NOT_IN_ORGANIZATION, userId: direct ? id : null, email: direct?.email?.trim() || null };
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4847
|
+
// src/values.tsx
|
|
4848
|
+
import { OutboundLink as OutboundLink5 } from "@ai-matrx/kit/outbound-react";
|
|
4849
|
+
import { Fragment as Fragment8, jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4571
4850
|
function statusMark(field, item, document2) {
|
|
4572
4851
|
const mark = statusMarkOf(field, item, document2);
|
|
4573
|
-
return mark ? /* @__PURE__ */
|
|
4852
|
+
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
4853
|
}
|
|
4575
4854
|
function envelopeFor(document2, key) {
|
|
4576
4855
|
const block = document2?._values;
|
|
@@ -4616,48 +4895,48 @@ function sourceArchivedSentence(state2) {
|
|
|
4616
4895
|
return state2.table ? `${state2.label} on ${state2.table} is archived` : `${state2.label} is archived`;
|
|
4617
4896
|
}
|
|
4618
4897
|
function SourceArchivedValue({ state: state2 }) {
|
|
4619
|
-
return /* @__PURE__ */
|
|
4898
|
+
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
4899
|
}
|
|
4621
4900
|
var ABSENCE_WORDS = ABSENCE_WORD_LABEL;
|
|
4622
4901
|
function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
4623
4902
|
const archivedSource = sourceArchivedOf2(value);
|
|
4624
|
-
if (archivedSource) return /* @__PURE__ */
|
|
4903
|
+
if (archivedSource) return /* @__PURE__ */ jsx24(SourceArchivedValue, { state: archivedSource });
|
|
4625
4904
|
const envelope = envelopeFor(document2, field.key);
|
|
4626
4905
|
if (envelope?.absent) {
|
|
4627
|
-
return /* @__PURE__ */
|
|
4906
|
+
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
4907
|
}
|
|
4629
4908
|
if (value === null || value === void 0 || value === "") {
|
|
4630
4909
|
const gone = unresolvedFor(document2, field.key);
|
|
4631
4910
|
if (gone) {
|
|
4632
|
-
return /* @__PURE__ */
|
|
4911
|
+
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
4912
|
}
|
|
4634
4913
|
const archivedInput = formulaSourceArchived(field, document2);
|
|
4635
|
-
if (archivedInput) return /* @__PURE__ */
|
|
4914
|
+
if (archivedInput) return /* @__PURE__ */ jsx24(SourceArchivedValue, { state: archivedInput });
|
|
4636
4915
|
const computed = computedEmptyOf(field, document2);
|
|
4637
|
-
if (computed?.sentence) return /* @__PURE__ */
|
|
4638
|
-
if (computed?.words) return /* @__PURE__ */
|
|
4916
|
+
if (computed?.sentence) return /* @__PURE__ */ jsx24("span", { className: "text-xs italic text-muted-foreground", children: computed.sentence });
|
|
4917
|
+
if (computed?.words) return /* @__PURE__ */ jsx24("span", { "data-records-empty-why": computed.kind, children: computed.words });
|
|
4639
4918
|
if (computed?.why) {
|
|
4640
|
-
return /* @__PURE__ */
|
|
4919
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", title: computed.why, "data-records-empty-why": computed.kind, children: "\u2014" });
|
|
4641
4920
|
}
|
|
4642
4921
|
if (look?.blankEmpty) return null;
|
|
4643
|
-
return /* @__PURE__ */
|
|
4922
|
+
return /* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
4644
4923
|
}
|
|
4645
|
-
if (isSignatureField(field)) return /* @__PURE__ */
|
|
4646
|
-
if (isButtonField2(field)) return /* @__PURE__ */
|
|
4924
|
+
if (isSignatureField(field)) return /* @__PURE__ */ jsx24(SignatureValue, { value, fieldKey: field.key, document: document2 });
|
|
4925
|
+
if (isButtonField2(field)) return /* @__PURE__ */ jsx24(ButtonValue, { field });
|
|
4647
4926
|
const newer = newerKindValue(field, value);
|
|
4648
4927
|
if (newer !== void 0) return newer;
|
|
4649
4928
|
const whole = typeof value === "string" ? wholeValueOf(document2, field.key) : null;
|
|
4650
|
-
if (whole) return /* @__PURE__ */
|
|
4929
|
+
if (whole) return /* @__PURE__ */ jsx24(WholeValueCell, { words: value, pointer: whole });
|
|
4651
4930
|
const kind = editorKindFor(field);
|
|
4652
4931
|
if (kind === "relation" || kind === "entity_reference") {
|
|
4653
|
-
return /* @__PURE__ */
|
|
4932
|
+
return /* @__PURE__ */ jsx24(ReferenceChips, { refs: referencesOf(field, value, kind, labels), waiting: stillWaitingFor });
|
|
4654
4933
|
}
|
|
4655
4934
|
if (kind === "member") {
|
|
4656
4935
|
const ids = (Array.isArray(value) ? value : [value]).filter((v) => v !== null && v !== void 0 && v !== "");
|
|
4657
|
-
return /* @__PURE__ */
|
|
4936
|
+
return /* @__PURE__ */ jsx24("span", { className: "flex min-w-0 flex-wrap gap-1", "data-records-person-chips": "", children: ids.map((id, i) => /* @__PURE__ */ jsx24(LivePersonChip, { id: String(id), name: scalarText(field, id, labels, stillWaitingFor) }, `${String(id)}-${i}`)) });
|
|
4658
4937
|
}
|
|
4659
4938
|
const kv = kind === "attachment" ? null : kindValueOf(value);
|
|
4660
|
-
if (kv) return /* @__PURE__ */
|
|
4939
|
+
if (kv) return /* @__PURE__ */ jsx24(KindValueCell, { kv, where: "cell", title: field.label });
|
|
4661
4940
|
const chosen = kind === "select" || kind === "multi_select";
|
|
4662
4941
|
const chipOf = (item) => {
|
|
4663
4942
|
const chipLook = choiceChipLookOf(field, item, scalarText(field, item, labels));
|
|
@@ -4665,17 +4944,17 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4665
4944
|
};
|
|
4666
4945
|
if (chosen) {
|
|
4667
4946
|
const items = Array.isArray(value) ? value : [value];
|
|
4668
|
-
return /* @__PURE__ */
|
|
4947
|
+
return /* @__PURE__ */ jsx24("span", { className: "flex flex-wrap gap-1", "data-records-choice-chips": "", children: items.map((item, i) => {
|
|
4669
4948
|
const chip = chipOf(item);
|
|
4670
|
-
return /* @__PURE__ */
|
|
4949
|
+
return /* @__PURE__ */ jsxs22(
|
|
4671
4950
|
Badge5,
|
|
4672
4951
|
{
|
|
4673
4952
|
variant: "outline",
|
|
4674
|
-
className:
|
|
4953
|
+
className: cn20("text-[11px]", chip.className),
|
|
4675
4954
|
"data-records-choice-chip": "",
|
|
4676
4955
|
...chip.tinted ? { "data-records-choice-tint": "" } : {},
|
|
4677
4956
|
children: [
|
|
4678
|
-
look?.choiceDot ? /* @__PURE__ */
|
|
4957
|
+
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
4958
|
statusMark(field, item, Array.isArray(value) ? void 0 : document2),
|
|
4680
4959
|
scalarText(field, item, labels, Array.isArray(value) ? void 0 : stillWaitingFor)
|
|
4681
4960
|
]
|
|
@@ -4684,13 +4963,13 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4684
4963
|
);
|
|
4685
4964
|
}) });
|
|
4686
4965
|
}
|
|
4687
|
-
if (kind === "attachment") return /* @__PURE__ */
|
|
4966
|
+
if (kind === "attachment") return /* @__PURE__ */ jsx24(AttachmentChips, { value });
|
|
4688
4967
|
if (Array.isArray(value)) {
|
|
4689
|
-
return /* @__PURE__ */
|
|
4968
|
+
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
4969
|
}
|
|
4691
4970
|
if (kind === "url" && typeof value === "string") {
|
|
4692
4971
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
4693
|
-
return /* @__PURE__ */
|
|
4972
|
+
return /* @__PURE__ */ jsxs22(
|
|
4694
4973
|
OutboundLink5,
|
|
4695
4974
|
{
|
|
4696
4975
|
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 +4978,14 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4699
4978
|
"data-records-link-chip": "",
|
|
4700
4979
|
onClick: (event) => event.stopPropagation(),
|
|
4701
4980
|
children: [
|
|
4702
|
-
/* @__PURE__ */
|
|
4703
|
-
/* @__PURE__ */
|
|
4981
|
+
/* @__PURE__ */ jsx24("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2197" }),
|
|
4982
|
+
/* @__PURE__ */ jsx24("span", { className: "truncate", children: linkChipText(value) })
|
|
4704
4983
|
]
|
|
4705
4984
|
}
|
|
4706
4985
|
);
|
|
4707
4986
|
}
|
|
4708
4987
|
if (kind === "phone" && typeof value === "string" && value.trim() !== "") {
|
|
4709
|
-
return /* @__PURE__ */
|
|
4988
|
+
return /* @__PURE__ */ jsx24(
|
|
4710
4989
|
"a",
|
|
4711
4990
|
{
|
|
4712
4991
|
className: "truncate tabular-nums text-primary underline-offset-2 hover:underline",
|
|
@@ -4719,12 +4998,26 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look) {
|
|
|
4719
4998
|
);
|
|
4720
4999
|
}
|
|
4721
5000
|
if (kind === "email" && typeof value === "string") {
|
|
4722
|
-
return /* @__PURE__ */
|
|
5001
|
+
return /* @__PURE__ */ jsx24("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
|
|
4723
5002
|
}
|
|
4724
5003
|
if (typeof value === "boolean") {
|
|
4725
|
-
return /* @__PURE__ */
|
|
5004
|
+
return /* @__PURE__ */ jsx24("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
|
|
4726
5005
|
}
|
|
4727
|
-
return /* @__PURE__ */
|
|
5006
|
+
return /* @__PURE__ */ jsx24("span", { className: cn20("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
|
|
5007
|
+
}
|
|
5008
|
+
function LivePersonChip({ id, name }) {
|
|
5009
|
+
const open = useRecordsUi().openPerson;
|
|
5010
|
+
return /* @__PURE__ */ jsx24(PersonChip, { name, ...open ? { onOpen: () => void openStoredPerson(id, open) } : {} });
|
|
5011
|
+
}
|
|
5012
|
+
var NEVER_AN_ID_KINDS = /* @__PURE__ */ new Set(["member", "person", "number", "currency", "percent", "date", "datetime", "checkbox", "boolean"]);
|
|
5013
|
+
function personWordsOf(kind, value) {
|
|
5014
|
+
const items = Array.isArray(value) ? value : [value];
|
|
5015
|
+
const ids = items.filter(isUserId);
|
|
5016
|
+
if (ids.length === 0) return null;
|
|
5017
|
+
const wordsColumn = !NEVER_AN_ID_KINDS.has(kind);
|
|
5018
|
+
const named = ids.map((id) => knownPerson(id));
|
|
5019
|
+
if (wordsColumn && named.some((n) => n === null)) return null;
|
|
5020
|
+
return named.map((n) => n ?? PERSON_NOT_IN_ORGANIZATION).join(", ");
|
|
4728
5021
|
}
|
|
4729
5022
|
function scalarText(field, value, labels, stillWaitingFor) {
|
|
4730
5023
|
if (value === null || value === void 0) return "\u2014";
|
|
@@ -4743,6 +5036,8 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4743
5036
|
if (isId(value) && (field.type === "list" || field.type === "relation")) {
|
|
4744
5037
|
return labels?.(field, String(value)) ?? stillWaitingFor ?? "Loading\u2026";
|
|
4745
5038
|
}
|
|
5039
|
+
const personal = personWordsOf(kind, value);
|
|
5040
|
+
if (personal !== null) return personal;
|
|
4746
5041
|
if (field.type === "list" && typeof value === "string" && labels) {
|
|
4747
5042
|
const words = labels(field, value);
|
|
4748
5043
|
if (words) return words;
|
|
@@ -4767,24 +5062,24 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
4767
5062
|
}
|
|
4768
5063
|
|
|
4769
5064
|
// src/SourceArchivedNotice.tsx
|
|
4770
|
-
import { jsx as
|
|
5065
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4771
5066
|
function bringBackLabel(state2) {
|
|
4772
5067
|
return state2.label ? `Bring back ${state2.label}` : "Bring it back";
|
|
4773
5068
|
}
|
|
4774
5069
|
function SourceArchivedNotice({ fieldId, tableId }) {
|
|
4775
5070
|
const client = useRecordsClient6();
|
|
4776
|
-
const [state2, setState] =
|
|
4777
|
-
const [busy, setBusy] =
|
|
4778
|
-
const [refused, setRefused] =
|
|
4779
|
-
const read =
|
|
5071
|
+
const [state2, setState] = useState20(null);
|
|
5072
|
+
const [busy, setBusy] = useState20(false);
|
|
5073
|
+
const [refused, setRefused] = useState20(null);
|
|
5074
|
+
const read = useCallback6(async () => {
|
|
4780
5075
|
const answer = await client.fieldSourceArchived({ field_id: fieldId });
|
|
4781
5076
|
if (answer.ok) setState(answer.data);
|
|
4782
5077
|
else setRefused(answer.error);
|
|
4783
5078
|
}, [client, fieldId]);
|
|
4784
|
-
|
|
5079
|
+
useEffect14(() => {
|
|
4785
5080
|
void read();
|
|
4786
5081
|
}, [read]);
|
|
4787
|
-
if (refused && !state2) return /* @__PURE__ */
|
|
5082
|
+
if (refused && !state2) return /* @__PURE__ */ jsx25(RefusalNotice, { error: refused });
|
|
4788
5083
|
if (!state2) return null;
|
|
4789
5084
|
const restore = async () => {
|
|
4790
5085
|
if (!state2.field_id) return;
|
|
@@ -4800,32 +5095,32 @@ function SourceArchivedNotice({ fieldId, tableId }) {
|
|
|
4800
5095
|
tableShapeChanged(tableId);
|
|
4801
5096
|
await read();
|
|
4802
5097
|
};
|
|
4803
|
-
return /* @__PURE__ */
|
|
5098
|
+
return /* @__PURE__ */ jsxs23(
|
|
4804
5099
|
"div",
|
|
4805
5100
|
{
|
|
4806
5101
|
className: "flex flex-wrap items-center gap-2 rounded-md border border-border px-3 py-2",
|
|
4807
5102
|
"data-testid": "source-archived-notice",
|
|
4808
5103
|
"data-field-id": state2.field_id ?? "",
|
|
4809
5104
|
children: [
|
|
4810
|
-
/* @__PURE__ */
|
|
4811
|
-
/* @__PURE__ */
|
|
4812
|
-
/* @__PURE__ */
|
|
5105
|
+
/* @__PURE__ */ jsxs23("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
5106
|
+
/* @__PURE__ */ jsx25("span", { className: "text-sm", children: SOURCE_ARCHIVED_WORDS }),
|
|
5107
|
+
/* @__PURE__ */ jsx25("span", { className: "truncate text-xs text-muted-foreground", children: sourceArchivedSentence(state2) })
|
|
4813
5108
|
] }),
|
|
4814
|
-
state2.field_id ? /* @__PURE__ */
|
|
4815
|
-
refused ? /* @__PURE__ */
|
|
5109
|
+
state2.field_id ? /* @__PURE__ */ jsx25(Button11, { type: "button", size: "sm", variant: "secondary", disabled: busy, onClick: () => void restore(), children: bringBackLabel(state2) }) : null,
|
|
5110
|
+
refused ? /* @__PURE__ */ jsx25(RefusalNotice, { error: refused, className: "basis-full" }) : null
|
|
4816
5111
|
]
|
|
4817
5112
|
}
|
|
4818
5113
|
);
|
|
4819
5114
|
}
|
|
4820
5115
|
|
|
4821
5116
|
// src/Condition.tsx
|
|
4822
|
-
import { createContext as createContext4, useContext as useContext4, useEffect as
|
|
5117
|
+
import { createContext as createContext4, useContext as useContext4, useEffect as useEffect15, useState as useState21 } from "react";
|
|
4823
5118
|
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
|
|
5119
|
+
import { optionKey as optionKey2, optionLabel as optionLabel2, rankTypedMatches as rankTypedMatches3 } from "@ai-matrx/records";
|
|
5120
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient8 } from "@ai-matrx/records/react";
|
|
4826
5121
|
|
|
4827
5122
|
// src/personTime.ts
|
|
4828
|
-
import { useSyncExternalStore } from "react";
|
|
5123
|
+
import { useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
4829
5124
|
|
|
4830
5125
|
// src/personZone.ts
|
|
4831
5126
|
import { setColorRuleTimeZone } from "@ai-matrx/design-system/data-table/table-style";
|
|
@@ -4862,7 +5157,7 @@ function personWallNow(at = /* @__PURE__ */ new Date()) {
|
|
|
4862
5157
|
|
|
4863
5158
|
// src/personTime.ts
|
|
4864
5159
|
function usePersonTimeZone() {
|
|
4865
|
-
return
|
|
5160
|
+
return useSyncExternalStore2(
|
|
4866
5161
|
subscribePersonTimeZone,
|
|
4867
5162
|
getPersonTimeZone,
|
|
4868
5163
|
() => null
|
|
@@ -4870,7 +5165,7 @@ function usePersonTimeZone() {
|
|
|
4870
5165
|
}
|
|
4871
5166
|
|
|
4872
5167
|
// src/Condition.tsx
|
|
4873
|
-
import { Fragment as
|
|
5168
|
+
import { Fragment as Fragment9, jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4874
5169
|
var CONDITION_OPS = [
|
|
4875
5170
|
{ op: "eq", label: "is" },
|
|
4876
5171
|
{ op: "ne", label: "is not" },
|
|
@@ -4958,11 +5253,11 @@ function isChoiceColumn(f) {
|
|
|
4958
5253
|
return kind === "select" || kind === "multi_select";
|
|
4959
5254
|
}
|
|
4960
5255
|
function ChoiceValue({ field, value, onChange }) {
|
|
4961
|
-
const client =
|
|
4962
|
-
const [choices, setChoices] =
|
|
4963
|
-
const [open, setOpen] =
|
|
4964
|
-
const [search, setSearch] =
|
|
4965
|
-
|
|
5256
|
+
const client = useOptionalRecordsClient8();
|
|
5257
|
+
const [choices, setChoices] = useState21(null);
|
|
5258
|
+
const [open, setOpen] = useState21(false);
|
|
5259
|
+
const [search, setSearch] = useState21("");
|
|
5260
|
+
useEffect15(() => {
|
|
4966
5261
|
if (!client) return;
|
|
4967
5262
|
let cancelled = false;
|
|
4968
5263
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((got) => {
|
|
@@ -4976,7 +5271,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4976
5271
|
};
|
|
4977
5272
|
}, [client, field.id]);
|
|
4978
5273
|
if (!choices || choices.length === 0) {
|
|
4979
|
-
return /* @__PURE__ */
|
|
5274
|
+
return /* @__PURE__ */ jsx26(
|
|
4980
5275
|
BasicInput7,
|
|
4981
5276
|
{
|
|
4982
5277
|
className: "h-8 w-28 text-xs",
|
|
@@ -4986,8 +5281,8 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
4986
5281
|
}
|
|
4987
5282
|
);
|
|
4988
5283
|
}
|
|
4989
|
-
const shown2 =
|
|
4990
|
-
return /* @__PURE__ */
|
|
5284
|
+
const shown2 = rankTypedMatches3(choices, search.trim(), (c) => c.label);
|
|
5285
|
+
return /* @__PURE__ */ jsx26("span", { className: "inline-flex min-w-0", "data-records-condition-choice": "", "data-pick-value": value, children: /* @__PURE__ */ jsx26(
|
|
4991
5286
|
PickOrAdd,
|
|
4992
5287
|
{
|
|
4993
5288
|
triggerSize: "compact",
|
|
@@ -5013,7 +5308,7 @@ function ChoiceValue({ field, value, onChange }) {
|
|
|
5013
5308
|
setOpen(false);
|
|
5014
5309
|
setSearch("");
|
|
5015
5310
|
},
|
|
5016
|
-
empty: /* @__PURE__ */
|
|
5311
|
+
empty: /* @__PURE__ */ jsx26("p", { className: "p-2 text-xs text-muted-foreground", children: "No match" })
|
|
5017
5312
|
}
|
|
5018
5313
|
) });
|
|
5019
5314
|
}
|
|
@@ -5153,9 +5448,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5153
5448
|
VALUELESS_OPS.has(chosenOp) ? { op: chosenOp, args: [{ field: chosenField }] } : { op: chosenOp, args: [{ field: chosenField }, { const: chosenValue }] }
|
|
5154
5449
|
);
|
|
5155
5450
|
}
|
|
5156
|
-
return /* @__PURE__ */
|
|
5157
|
-
/* @__PURE__ */
|
|
5158
|
-
/* @__PURE__ */
|
|
5451
|
+
return /* @__PURE__ */ jsxs24("div", { className: className ?? "flex flex-wrap items-center gap-1 text-xs", children: [
|
|
5452
|
+
/* @__PURE__ */ jsx26("span", { className: "text-muted-foreground", children: lead }),
|
|
5453
|
+
/* @__PURE__ */ jsx26(
|
|
5159
5454
|
PickOne,
|
|
5160
5455
|
{
|
|
5161
5456
|
label: "Condition field",
|
|
@@ -5166,7 +5461,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5166
5461
|
attrs: { "data-condition": "field" }
|
|
5167
5462
|
}
|
|
5168
5463
|
),
|
|
5169
|
-
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */
|
|
5464
|
+
onField && !fields.some((f) => f.id === onField) ? /* @__PURE__ */ jsx26(
|
|
5170
5465
|
"span",
|
|
5171
5466
|
{
|
|
5172
5467
|
className: "rounded bg-destructive px-1.5 py-0.5 text-[11px] font-medium text-destructive-foreground",
|
|
@@ -5175,8 +5470,8 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5175
5470
|
children: "Missing question"
|
|
5176
5471
|
}
|
|
5177
5472
|
) : null,
|
|
5178
|
-
onField ? /* @__PURE__ */
|
|
5179
|
-
/* @__PURE__ */
|
|
5473
|
+
onField ? /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
5474
|
+
/* @__PURE__ */ jsx26(
|
|
5180
5475
|
PickOne,
|
|
5181
5476
|
{
|
|
5182
5477
|
label: "Condition comparison",
|
|
@@ -5187,7 +5482,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5187
5482
|
attrs: { "data-condition": "comparison" }
|
|
5188
5483
|
}
|
|
5189
5484
|
),
|
|
5190
|
-
relative ? relativeTerm?.takesDays ? /* @__PURE__ */
|
|
5485
|
+
relative ? relativeTerm?.takesDays ? /* @__PURE__ */ jsx26(
|
|
5191
5486
|
BasicInput7,
|
|
5192
5487
|
{
|
|
5193
5488
|
className: "h-8 w-16 text-xs",
|
|
@@ -5204,7 +5499,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5204
5499
|
// is asked for ONE record even when the column holds several: a clause compares
|
|
5205
5500
|
// against one value, and a picker that let somebody choose three would be
|
|
5206
5501
|
// writing an expression this row cannot draw back.
|
|
5207
|
-
/* @__PURE__ */
|
|
5502
|
+
/* @__PURE__ */ jsx26(
|
|
5208
5503
|
RelationPicker,
|
|
5209
5504
|
{
|
|
5210
5505
|
field: { ...chosen.field, multi: false },
|
|
@@ -5215,7 +5510,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5215
5510
|
allowCreate: false
|
|
5216
5511
|
}
|
|
5217
5512
|
)
|
|
5218
|
-
) : isChoiceColumn(chosen) && (op === "eq" || op === "ne" || op === "contains" || op === "not_contains") ? /* @__PURE__ */
|
|
5513
|
+
) : 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
5514
|
BasicInput7,
|
|
5220
5515
|
{
|
|
5221
5516
|
className: "h-8 w-28 text-xs",
|
|
@@ -5292,7 +5587,7 @@ function ConditionGroup({
|
|
|
5292
5587
|
className
|
|
5293
5588
|
}) {
|
|
5294
5589
|
const { joiner, args } = clausesOf(expr);
|
|
5295
|
-
const [drafting, setDrafting] =
|
|
5590
|
+
const [drafting, setDrafting] = useState21(null);
|
|
5296
5591
|
const nested = depth > 0;
|
|
5297
5592
|
const replaceAt = (index, next) => {
|
|
5298
5593
|
const nextArgs = args.slice();
|
|
@@ -5303,16 +5598,16 @@ function ConditionGroup({
|
|
|
5303
5598
|
const joinWord = (index) => index === 0 ? lead : joiner === "or" || joiner === "none" ? "or" : "and";
|
|
5304
5599
|
const showJoiner = nested || args.length > 1 || joiner === "none" || joiner === "notall";
|
|
5305
5600
|
const opposite = joiner === "or" || joiner === "none" ? "and" : "or";
|
|
5306
|
-
return /* @__PURE__ */
|
|
5601
|
+
return /* @__PURE__ */ jsxs24(
|
|
5307
5602
|
"div",
|
|
5308
5603
|
{
|
|
5309
5604
|
className: className ?? "flex flex-col gap-1 text-xs",
|
|
5310
5605
|
"data-testid": nested ? "condition-nested-group" : "condition-group",
|
|
5311
5606
|
"data-depth": depth,
|
|
5312
5607
|
children: [
|
|
5313
|
-
showJoiner ? /* @__PURE__ */
|
|
5314
|
-
/* @__PURE__ */
|
|
5315
|
-
/* @__PURE__ */
|
|
5608
|
+
showJoiner ? /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-1", children: [
|
|
5609
|
+
/* @__PURE__ */ jsx26("span", { className: "text-muted-foreground", children: nested ? "Group:" : lead }),
|
|
5610
|
+
/* @__PURE__ */ jsx26(
|
|
5316
5611
|
PickOne,
|
|
5317
5612
|
{
|
|
5318
5613
|
label: nested ? `How the conditions in this group are joined (level ${depth + 1})` : "How these conditions are joined",
|
|
@@ -5323,7 +5618,7 @@ function ConditionGroup({
|
|
|
5323
5618
|
attrs: { "data-condition": "joiner" }
|
|
5324
5619
|
}
|
|
5325
5620
|
),
|
|
5326
|
-
nested && onRemove ? /* @__PURE__ */
|
|
5621
|
+
nested && onRemove ? /* @__PURE__ */ jsx26(
|
|
5327
5622
|
Button12,
|
|
5328
5623
|
{
|
|
5329
5624
|
size: "sm",
|
|
@@ -5335,7 +5630,7 @@ function ConditionGroup({
|
|
|
5335
5630
|
}
|
|
5336
5631
|
) : null
|
|
5337
5632
|
] }) : null,
|
|
5338
|
-
args.length === 0 ? /* @__PURE__ */
|
|
5633
|
+
args.length === 0 ? /* @__PURE__ */ jsx26(
|
|
5339
5634
|
ConditionRow,
|
|
5340
5635
|
{
|
|
5341
5636
|
lead,
|
|
@@ -5348,7 +5643,7 @@ function ConditionGroup({
|
|
|
5348
5643
|
const group = conditionGroupOf(arg);
|
|
5349
5644
|
const key = `clause-${index}`;
|
|
5350
5645
|
if (group && allowNesting) {
|
|
5351
|
-
return /* @__PURE__ */
|
|
5646
|
+
return /* @__PURE__ */ jsx26("div", { className: "ml-4 rounded border border-dashed p-1", children: /* @__PURE__ */ jsx26(
|
|
5352
5647
|
ConditionGroup,
|
|
5353
5648
|
{
|
|
5354
5649
|
lead: joinWord(index),
|
|
@@ -5362,7 +5657,7 @@ function ConditionGroup({
|
|
|
5362
5657
|
}
|
|
5363
5658
|
) }, key);
|
|
5364
5659
|
}
|
|
5365
|
-
return /* @__PURE__ */
|
|
5660
|
+
return /* @__PURE__ */ jsx26(
|
|
5366
5661
|
ConditionRow,
|
|
5367
5662
|
{
|
|
5368
5663
|
lead: showJoiner || args.length > 1 ? joinWord(index) : lead,
|
|
@@ -5374,7 +5669,7 @@ function ConditionGroup({
|
|
|
5374
5669
|
key
|
|
5375
5670
|
);
|
|
5376
5671
|
}),
|
|
5377
|
-
drafting ? /* @__PURE__ */
|
|
5672
|
+
drafting ? /* @__PURE__ */ jsx26("div", { className: drafting === "group" ? "ml-4 rounded border border-dashed p-1" : void 0, children: /* @__PURE__ */ jsx26(
|
|
5378
5673
|
ConditionRow,
|
|
5379
5674
|
{
|
|
5380
5675
|
lead: drafting === "group" ? `${joinWord(1)}, a group where` : joinWord(1),
|
|
@@ -5389,8 +5684,8 @@ function ConditionGroup({
|
|
|
5389
5684
|
}
|
|
5390
5685
|
}
|
|
5391
5686
|
) }) : null,
|
|
5392
|
-
args.length > 0 && !drafting ? /* @__PURE__ */
|
|
5393
|
-
/* @__PURE__ */
|
|
5687
|
+
args.length > 0 && !drafting ? /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-1", children: [
|
|
5688
|
+
/* @__PURE__ */ jsx26(
|
|
5394
5689
|
Button12,
|
|
5395
5690
|
{
|
|
5396
5691
|
size: "sm",
|
|
@@ -5401,7 +5696,7 @@ function ConditionGroup({
|
|
|
5401
5696
|
children: "Add another condition"
|
|
5402
5697
|
}
|
|
5403
5698
|
),
|
|
5404
|
-
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */
|
|
5699
|
+
allowNesting && (maxDepth === void 0 || depth < maxDepth) ? /* @__PURE__ */ jsx26(
|
|
5405
5700
|
Button12,
|
|
5406
5701
|
{
|
|
5407
5702
|
size: "sm",
|
|
@@ -5419,11 +5714,74 @@ function ConditionGroup({
|
|
|
5419
5714
|
}
|
|
5420
5715
|
|
|
5421
5716
|
// src/FieldRetype.tsx
|
|
5422
|
-
import { useEffect as
|
|
5717
|
+
import { useEffect as useEffect16, useState as useState22 } from "react";
|
|
5423
5718
|
import { previewRetype } from "@ai-matrx/records";
|
|
5424
5719
|
import { tableShapeChanged as tableShapeChanged2, useRecordsClient as useRecordsClient7 } from "@ai-matrx/records/react";
|
|
5425
5720
|
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
|
-
|
|
5721
|
+
|
|
5722
|
+
// src/personRetype.ts
|
|
5723
|
+
var PAGE = 500;
|
|
5724
|
+
var CEILING = 2e4;
|
|
5725
|
+
function idsIn(value) {
|
|
5726
|
+
return (Array.isArray(value) ? value : [value]).filter(isUserId);
|
|
5727
|
+
}
|
|
5728
|
+
async function readPersonColumn(client, tableId, key) {
|
|
5729
|
+
const out = [];
|
|
5730
|
+
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5731
|
+
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5732
|
+
if (!page.ok) throw new Error(page.error.message ?? "The records could not be read");
|
|
5733
|
+
for (const row of page.data.rows) {
|
|
5734
|
+
const doc = row.document ?? {};
|
|
5735
|
+
let ids = idsIn(doc[key]);
|
|
5736
|
+
if (ids.length === 0 && Array.isArray(doc["_retired"])) {
|
|
5737
|
+
const kept = doc["_retired"].filter((e) => e.key === key);
|
|
5738
|
+
const last = kept[kept.length - 1];
|
|
5739
|
+
if (last) ids = idsIn(last.value);
|
|
5740
|
+
}
|
|
5741
|
+
if (ids.length > 0) out.push({ recordId: row.id, ids });
|
|
5742
|
+
}
|
|
5743
|
+
if (page.data.rows.length < PAGE) break;
|
|
5744
|
+
}
|
|
5745
|
+
return out;
|
|
5746
|
+
}
|
|
5747
|
+
async function resolvePeople(client, rows, roster) {
|
|
5748
|
+
const distinct = [...new Set(rows.flatMap((r) => r.ids))];
|
|
5749
|
+
const people = await Promise.all(distinct.map((id) => resolveKeptPerson(client, id, roster)));
|
|
5750
|
+
return new Map(people.map((p) => [p.id, p]));
|
|
5751
|
+
}
|
|
5752
|
+
function wordsFor(ids, people, as) {
|
|
5753
|
+
const said2 = ids.map((id) => as === "name" ? people.get(id)?.name : people.get(id)?.email).filter((w) => typeof w === "string" && w.trim() !== "" && !w.startsWith("A person no longer"));
|
|
5754
|
+
return said2.length > 0 ? said2.join(", ") : null;
|
|
5755
|
+
}
|
|
5756
|
+
function previewPersonWords(rows, people, as) {
|
|
5757
|
+
let converts = 0;
|
|
5758
|
+
let keptAside = 0;
|
|
5759
|
+
const examples = [];
|
|
5760
|
+
for (const row of rows) {
|
|
5761
|
+
if (wordsFor(row.ids, people, as) !== null) converts += 1;
|
|
5762
|
+
else {
|
|
5763
|
+
keptAside += 1;
|
|
5764
|
+
const who = people.get(row.ids[0] ?? "")?.name;
|
|
5765
|
+
if (who && examples.length < 5 && !examples.includes(who)) examples.push(who);
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
return { converts, keptAside, examples, partial: false };
|
|
5769
|
+
}
|
|
5770
|
+
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5771
|
+
const changes = [];
|
|
5772
|
+
for (const row of rows) {
|
|
5773
|
+
const words = wordsFor(row.ids, people, as);
|
|
5774
|
+
if (words !== null) changes.push({ op: "update", record_id: row.recordId, patch: { [key]: words } });
|
|
5775
|
+
}
|
|
5776
|
+
for (let i = 0; i < changes.length; i += 100) {
|
|
5777
|
+
const done = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5778
|
+
if (!done.ok) throw new Error(done.error.message ?? "The words could not be written");
|
|
5779
|
+
}
|
|
5780
|
+
return changes.length;
|
|
5781
|
+
}
|
|
5782
|
+
|
|
5783
|
+
// src/FieldRetype.tsx
|
|
5784
|
+
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5427
5785
|
var RETYPE_TARGETS = [
|
|
5428
5786
|
{ id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
|
|
5429
5787
|
{ id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
|
|
@@ -5446,6 +5804,7 @@ var RETYPE_TARGETS = [
|
|
|
5446
5804
|
];
|
|
5447
5805
|
var PREVIEW_GROUPS = 1e3;
|
|
5448
5806
|
function retypeableFrom(field) {
|
|
5807
|
+
if (isPersonField(field)) return true;
|
|
5449
5808
|
const behaviour = String(field.type);
|
|
5450
5809
|
return behaviour === "text" || behaviour === "range" || behaviour === "boolean";
|
|
5451
5810
|
}
|
|
@@ -5460,7 +5819,11 @@ function whyNotRetypeable(field) {
|
|
|
5460
5819
|
}
|
|
5461
5820
|
return "Its kind is not changed here.";
|
|
5462
5821
|
}
|
|
5822
|
+
function isPersonField(field) {
|
|
5823
|
+
return String(editorKindFor(field)) === "member";
|
|
5824
|
+
}
|
|
5463
5825
|
function currentTarget(field) {
|
|
5826
|
+
if (isPersonField(field)) return "person";
|
|
5464
5827
|
const kind = String(editorKindFor(field));
|
|
5465
5828
|
if (String(field.type) === "boolean") return "checkbox";
|
|
5466
5829
|
if (kind === "datetime" || kind === "date") return "date";
|
|
@@ -5468,23 +5831,51 @@ function currentTarget(field) {
|
|
|
5468
5831
|
if (String(field.type) === "range") return "number";
|
|
5469
5832
|
return "text";
|
|
5470
5833
|
}
|
|
5834
|
+
function failure(e, fallback) {
|
|
5835
|
+
return { code: "internal", message: e instanceof Error && e.message ? e.message : fallback };
|
|
5836
|
+
}
|
|
5471
5837
|
function FieldRetype({ field, tableId, onRetyped }) {
|
|
5472
5838
|
const client = useRecordsClient7();
|
|
5473
5839
|
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] =
|
|
5840
|
+
const [to, setTo] = useState22(null);
|
|
5841
|
+
const [preview, setPreview] = useState22(null);
|
|
5842
|
+
const [asking, setAsking] = useState22(false);
|
|
5843
|
+
const [refusal, setRefusal] = useState22(null);
|
|
5844
|
+
const [busy, setBusy] = useState22(false);
|
|
5845
|
+
const [said2, setSaid] = useState22(null);
|
|
5846
|
+
const roster = useMemberRoster();
|
|
5847
|
+
const person = isPersonField(field);
|
|
5848
|
+
const [read, setRead] = useState22(null);
|
|
5480
5849
|
const name = fieldName(field);
|
|
5481
5850
|
const targets = RETYPE_TARGETS.filter((t) => t.id !== currentTarget(field));
|
|
5482
|
-
|
|
5851
|
+
useEffect16(() => {
|
|
5483
5852
|
if (!to) return;
|
|
5484
5853
|
let cancelled = false;
|
|
5485
5854
|
setPreview(null);
|
|
5486
5855
|
setRefusal(null);
|
|
5487
5856
|
setAsking(true);
|
|
5857
|
+
if (person) {
|
|
5858
|
+
if (!roster) return;
|
|
5859
|
+
void readPersonColumn(client, tableId, field.key).then(async (rows) => {
|
|
5860
|
+
const people = await resolvePeople(client, rows, roster);
|
|
5861
|
+
if (cancelled) return;
|
|
5862
|
+
setRead({ rows, people });
|
|
5863
|
+
setAsking(false);
|
|
5864
|
+
if (to.id === "text" || to.id === "email") {
|
|
5865
|
+
setPreview(previewPersonWords(rows, people, to.id === "email" ? "email" : "name"));
|
|
5866
|
+
return;
|
|
5867
|
+
}
|
|
5868
|
+
const groups = rows.map((r) => ({ value: r.ids.map((id) => people.get(id)?.name ?? "").join(", "), count: 1 }));
|
|
5869
|
+
setPreview(previewRetype({ type: to.behaviour, kind: to.kind }, groups, false));
|
|
5870
|
+
}).catch((e) => {
|
|
5871
|
+
if (cancelled) return;
|
|
5872
|
+
setAsking(false);
|
|
5873
|
+
setRefusal(failure(e, "The people could not be read"));
|
|
5874
|
+
});
|
|
5875
|
+
return () => {
|
|
5876
|
+
cancelled = true;
|
|
5877
|
+
};
|
|
5878
|
+
}
|
|
5488
5879
|
void client.recordAggregate({ table_id: tableId, groupBy: [field.key], measures: [{ op: "count" }], limit: PREVIEW_GROUPS }).then((answer) => {
|
|
5489
5880
|
if (cancelled) return;
|
|
5490
5881
|
setAsking(false);
|
|
@@ -5498,9 +5889,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5498
5889
|
return () => {
|
|
5499
5890
|
cancelled = true;
|
|
5500
5891
|
};
|
|
5501
|
-
}, [client, tableId, field.key, to]);
|
|
5892
|
+
}, [client, tableId, field.key, to, person, roster]);
|
|
5502
5893
|
if (!retypeableFrom(field)) {
|
|
5503
|
-
return /* @__PURE__ */
|
|
5894
|
+
return /* @__PURE__ */ jsx27("p", { className: "text-[11px] text-muted-foreground", "data-records-retype": "not-here", children: whyNotRetypeable(field) });
|
|
5504
5895
|
}
|
|
5505
5896
|
const change = async () => {
|
|
5506
5897
|
if (!to) return;
|
|
@@ -5535,12 +5926,30 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5535
5926
|
undo: async () => {
|
|
5536
5927
|
const back = await client.migrateUndo({ migration_id: migration });
|
|
5537
5928
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5929
|
+
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5930
|
+
const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }));
|
|
5931
|
+
for (let i = 0; i < changes.length; i += 100) {
|
|
5932
|
+
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5933
|
+
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5538
5936
|
tableShapeChanged2(tableId);
|
|
5539
5937
|
onRetyped?.();
|
|
5540
5938
|
}
|
|
5541
5939
|
});
|
|
5542
5940
|
}
|
|
5543
5941
|
}
|
|
5942
|
+
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5943
|
+
const as = to.id === "email" ? "email" : "name";
|
|
5944
|
+
try {
|
|
5945
|
+
const written = await writePersonWords(client, tableId, read.rows, read.people, field.key, as);
|
|
5946
|
+
holding = written;
|
|
5947
|
+
aside = read.rows.length - written;
|
|
5948
|
+
} catch (e) {
|
|
5949
|
+
setRefusal(failure(e, "The words could not be written"));
|
|
5950
|
+
return;
|
|
5951
|
+
}
|
|
5952
|
+
}
|
|
5544
5953
|
setSaid(
|
|
5545
5954
|
`${name} now holds ${to.holds}. ${holding} ${holding === 1 ? "record holds" : "records hold"} a value` + (aside > 0 ? `; ${aside} ${aside === 1 ? "value that did not fit was" : "values that did not fit were"} kept with ${aside === 1 ? "its record" : "their records"}, with the reason.` : ".")
|
|
5546
5955
|
);
|
|
@@ -5549,21 +5958,21 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5549
5958
|
tableShapeChanged2(tableId);
|
|
5550
5959
|
onRetyped?.();
|
|
5551
5960
|
};
|
|
5552
|
-
return /* @__PURE__ */
|
|
5553
|
-
/* @__PURE__ */
|
|
5554
|
-
/* @__PURE__ */
|
|
5555
|
-
/* @__PURE__ */
|
|
5556
|
-
/* @__PURE__ */
|
|
5961
|
+
return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-1.5", "data-records-retype": "", children: [
|
|
5962
|
+
/* @__PURE__ */ jsxs25("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5963
|
+
/* @__PURE__ */ jsxs25(Select4, { value: to?.id ?? "", onValueChange: (next) => setTo(targets.find((t) => t.id === next) ?? null), children: [
|
|
5964
|
+
/* @__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" }) }),
|
|
5965
|
+
/* @__PURE__ */ jsx27(SelectContent4, { children: targets.map((t) => /* @__PURE__ */ jsx27(SelectItem4, { value: t.id, children: t.label }, t.id)) })
|
|
5557
5966
|
] }),
|
|
5558
|
-
to ? /* @__PURE__ */
|
|
5559
|
-
to ? /* @__PURE__ */
|
|
5967
|
+
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,
|
|
5968
|
+
to ? /* @__PURE__ */ jsx27(Button13, { size: "sm", variant: "ghost", onClick: () => setTo(null), disabled: busy, children: "Cancel" }) : null
|
|
5560
5969
|
] }),
|
|
5561
|
-
to && asking ? /* @__PURE__ */
|
|
5970
|
+
to && asking ? /* @__PURE__ */ jsxs25("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
5562
5971
|
"Counting ",
|
|
5563
5972
|
name,
|
|
5564
5973
|
"'s values\u2026"
|
|
5565
5974
|
] }) : null,
|
|
5566
|
-
to && preview ? /* @__PURE__ */
|
|
5975
|
+
to && preview ? /* @__PURE__ */ jsxs25("p", { className: "text-[11px] text-muted-foreground", "data-records-retype-preview": "", children: [
|
|
5567
5976
|
preview.converts,
|
|
5568
5977
|
" ",
|
|
5569
5978
|
preview.converts === 1 ? "value converts" : "values convert",
|
|
@@ -5572,16 +5981,16 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5572
5981
|
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
5982
|
preview.partial ? ". Counted over the first 1,000 different values." : "."
|
|
5574
5983
|
] }) : null,
|
|
5575
|
-
refusal ? /* @__PURE__ */
|
|
5576
|
-
said2 ? /* @__PURE__ */
|
|
5984
|
+
refusal ? /* @__PURE__ */ jsx27(RefusalNotice, { error: refusal }) : null,
|
|
5985
|
+
said2 ? /* @__PURE__ */ jsx27("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-records-retype-done": "", children: said2 }) : null
|
|
5577
5986
|
] });
|
|
5578
5987
|
}
|
|
5579
5988
|
|
|
5580
5989
|
// src/FieldRulePreview.tsx
|
|
5581
|
-
import { useEffect as
|
|
5990
|
+
import { useEffect as useEffect17, useMemo as useMemo11, useRef as useRef12, useState as useState23 } from "react";
|
|
5582
5991
|
import { previewRuleChange } from "@ai-matrx/records";
|
|
5583
5992
|
import { useRecordsClient as useRecordsClient8 } from "@ai-matrx/records/react";
|
|
5584
|
-
import { jsx as
|
|
5993
|
+
import { jsx as jsx28, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5585
5994
|
var PREVIEW_GROUPS2 = 1e3;
|
|
5586
5995
|
function ruleWords(rules) {
|
|
5587
5996
|
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 +6008,13 @@ function groupValue(value, numbers) {
|
|
|
5599
6008
|
}
|
|
5600
6009
|
function FieldRulePreview({ field, tableId, rules }) {
|
|
5601
6010
|
const client = useRecordsClient8();
|
|
5602
|
-
const [preview, setPreview] =
|
|
5603
|
-
const [refusal, setRefusal] =
|
|
5604
|
-
const key =
|
|
5605
|
-
const latest =
|
|
6011
|
+
const [preview, setPreview] = useState23(null);
|
|
6012
|
+
const [refusal, setRefusal] = useState23(null);
|
|
6013
|
+
const key = useMemo11(() => ruleWords(rules), [rules]);
|
|
6014
|
+
const latest = useRef12(rules);
|
|
5606
6015
|
latest.current = rules;
|
|
5607
6016
|
const name = fieldName(field);
|
|
5608
|
-
|
|
6017
|
+
useEffect17(() => {
|
|
5609
6018
|
let cancelled = false;
|
|
5610
6019
|
setPreview(null);
|
|
5611
6020
|
setRefusal(null);
|
|
@@ -5626,16 +6035,16 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5626
6035
|
clearTimeout(timer);
|
|
5627
6036
|
};
|
|
5628
6037
|
}, [client, tableId, field.key, key]);
|
|
5629
|
-
if (refusal) return /* @__PURE__ */
|
|
6038
|
+
if (refusal) return /* @__PURE__ */ jsx28(RefusalNotice, { error: refusal });
|
|
5630
6039
|
if (!preview) {
|
|
5631
|
-
return /* @__PURE__ */
|
|
6040
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "counting", children: [
|
|
5632
6041
|
"Counting ",
|
|
5633
6042
|
name,
|
|
5634
6043
|
"'s values\u2026"
|
|
5635
6044
|
] });
|
|
5636
6045
|
}
|
|
5637
6046
|
if (preview.keptAside === 0) {
|
|
5638
|
-
return /* @__PURE__ */
|
|
6047
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-muted-foreground", "data-records-rule-preview": "fits", children: [
|
|
5639
6048
|
"Every value already in ",
|
|
5640
6049
|
name,
|
|
5641
6050
|
" still fits",
|
|
@@ -5643,7 +6052,7 @@ function FieldRulePreview({ field, tableId, rules }) {
|
|
|
5643
6052
|
"."
|
|
5644
6053
|
] });
|
|
5645
6054
|
}
|
|
5646
|
-
return /* @__PURE__ */
|
|
6055
|
+
return /* @__PURE__ */ jsxs26("p", { className: "text-[11px] text-amber-700 dark:text-amber-400", role: "status", "data-records-rule-preview": "sets-aside", children: [
|
|
5647
6056
|
preview.keptAside,
|
|
5648
6057
|
" ",
|
|
5649
6058
|
preview.keptAside === 1 ? "value no longer fits and will be" : "values no longer fit and will be",
|
|
@@ -5733,7 +6142,7 @@ import {
|
|
|
5733
6142
|
statusGroupOf as statusGroupOf2
|
|
5734
6143
|
} from "@ai-matrx/records";
|
|
5735
6144
|
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
|
|
6145
|
+
import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5737
6146
|
var STATUS_STARTING_CHOICES = [
|
|
5738
6147
|
{ words: "Not started", group: "todo" },
|
|
5739
6148
|
{ words: "In progress", group: "in_progress" },
|
|
@@ -5762,13 +6171,13 @@ function StatusGroupsQuestion({
|
|
|
5762
6171
|
onGroup
|
|
5763
6172
|
}) {
|
|
5764
6173
|
if (rows.length === 0) return null;
|
|
5765
|
-
return /* @__PURE__ */
|
|
5766
|
-
/* @__PURE__ */
|
|
5767
|
-
rows.map((r) => /* @__PURE__ */
|
|
5768
|
-
/* @__PURE__ */
|
|
5769
|
-
/* @__PURE__ */
|
|
5770
|
-
/* @__PURE__ */
|
|
5771
|
-
/* @__PURE__ */
|
|
6174
|
+
return /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-1", "data-records-status-groups": "", children: [
|
|
6175
|
+
/* @__PURE__ */ jsx29(Label5, { className: "text-xs", children: "Groups" }),
|
|
6176
|
+
rows.map((r) => /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-2", children: [
|
|
6177
|
+
/* @__PURE__ */ jsx29("span", { className: "min-w-0 flex-1 truncate text-sm", children: r.words }),
|
|
6178
|
+
/* @__PURE__ */ jsxs27(Select5, { value: r.group, onValueChange: (next) => onGroup(r.ref, next), children: [
|
|
6179
|
+
/* @__PURE__ */ jsx29(SelectTrigger5, { size: "sm", className: "w-36", "aria-label": `Group for ${r.words}`, children: /* @__PURE__ */ jsx29(SelectValue5, {}) }),
|
|
6180
|
+
/* @__PURE__ */ jsx29(SelectContent5, { children: STATUS_GROUPS.map((g) => /* @__PURE__ */ jsxs27(SelectItem5, { value: g, children: [
|
|
5772
6181
|
STATUS_GROUP_MARK[g],
|
|
5773
6182
|
" ",
|
|
5774
6183
|
STATUS_GROUP_WORDS2[g]
|
|
@@ -5778,11 +6187,11 @@ function StatusGroupsQuestion({
|
|
|
5778
6187
|
] });
|
|
5779
6188
|
}
|
|
5780
6189
|
function RatingMaxQuestion({ value, onChange }) {
|
|
5781
|
-
return /* @__PURE__ */
|
|
5782
|
-
/* @__PURE__ */
|
|
5783
|
-
/* @__PURE__ */
|
|
5784
|
-
/* @__PURE__ */
|
|
5785
|
-
/* @__PURE__ */
|
|
6190
|
+
return /* @__PURE__ */ jsxs27("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
6191
|
+
/* @__PURE__ */ jsx29(Label5, { className: "text-xs", children: "Out of" }),
|
|
6192
|
+
/* @__PURE__ */ jsxs27(Select5, { value: String(value), onValueChange: (next) => onChange(Number(next)), children: [
|
|
6193
|
+
/* @__PURE__ */ jsx29(SelectTrigger5, { size: "sm", "aria-label": "Out of", children: /* @__PURE__ */ jsx29(SelectValue5, {}) }),
|
|
6194
|
+
/* @__PURE__ */ jsx29(SelectContent5, { children: Array.from({ length: 10 }, (_, i) => i + 1).map((n) => /* @__PURE__ */ jsxs27(SelectItem5, { value: String(n), children: [
|
|
5786
6195
|
n,
|
|
5787
6196
|
" ",
|
|
5788
6197
|
n === 1 ? "star" : "stars"
|
|
@@ -5803,13 +6212,13 @@ var SYMBOLOGY_WORDS = {
|
|
|
5803
6212
|
pdf417: "PDF417"
|
|
5804
6213
|
};
|
|
5805
6214
|
function BarcodeSymbologyQuestion({ value, onChange }) {
|
|
5806
|
-
return /* @__PURE__ */
|
|
5807
|
-
/* @__PURE__ */
|
|
5808
|
-
/* @__PURE__ */
|
|
5809
|
-
/* @__PURE__ */
|
|
5810
|
-
/* @__PURE__ */
|
|
5811
|
-
/* @__PURE__ */
|
|
5812
|
-
BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */
|
|
6215
|
+
return /* @__PURE__ */ jsxs27("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
6216
|
+
/* @__PURE__ */ jsx29(Label5, { className: "text-xs", children: "Code type" }),
|
|
6217
|
+
/* @__PURE__ */ jsxs27(Select5, { value: value === "" ? "any" : value, onValueChange: (next) => onChange(next === "any" ? "" : next), children: [
|
|
6218
|
+
/* @__PURE__ */ jsx29(SelectTrigger5, { size: "sm", "aria-label": "Code type", children: /* @__PURE__ */ jsx29(SelectValue5, {}) }),
|
|
6219
|
+
/* @__PURE__ */ jsxs27(SelectContent5, { children: [
|
|
6220
|
+
/* @__PURE__ */ jsx29(SelectItem5, { value: "any", children: "Any code" }),
|
|
6221
|
+
BARCODE_SYMBOLOGIES.map((s) => /* @__PURE__ */ jsx29(SelectItem5, { value: s, children: SYMBOLOGY_WORDS[s] }, s))
|
|
5813
6222
|
] })
|
|
5814
6223
|
] })
|
|
5815
6224
|
] });
|
|
@@ -5822,7 +6231,7 @@ import {
|
|
|
5822
6231
|
getFieldFormat as getFieldFormat3,
|
|
5823
6232
|
groupedFormatsForBase
|
|
5824
6233
|
} from "@ai-matrx/design-system/field-formats";
|
|
5825
|
-
import { jsx as
|
|
6234
|
+
import { jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5826
6235
|
var KIND_WORD = {
|
|
5827
6236
|
choice: "select",
|
|
5828
6237
|
multi_choice: "multi_select",
|
|
@@ -5945,13 +6354,13 @@ function FieldFormatPicker({
|
|
|
5945
6354
|
else merged[key] = next;
|
|
5946
6355
|
onValue({ ...value, format: Object.keys(merged).length > 0 ? { id: value.format.id, options: merged } : { id: value.format.id } });
|
|
5947
6356
|
};
|
|
5948
|
-
const option = (key, label, control) => optionKeys.includes(key) ? /* @__PURE__ */
|
|
6357
|
+
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
6358
|
label,
|
|
5950
6359
|
control
|
|
5951
6360
|
] }, key) : null;
|
|
5952
|
-
return /* @__PURE__ */
|
|
5953
|
-
/* @__PURE__ */
|
|
5954
|
-
/* @__PURE__ */
|
|
6361
|
+
return /* @__PURE__ */ jsxs28("div", { className: "flex flex-col gap-1", "data-records-format-picker": "", children: [
|
|
6362
|
+
/* @__PURE__ */ jsx30(Label6, { className: "text-xs", htmlFor: `records-shows-as-${field.id}`, children: "Shows as" }),
|
|
6363
|
+
/* @__PURE__ */ jsx30(
|
|
5955
6364
|
PickOne,
|
|
5956
6365
|
{
|
|
5957
6366
|
id: `records-shows-as-${field.id}`,
|
|
@@ -5977,12 +6386,12 @@ function FieldFormatPicker({
|
|
|
5977
6386
|
]
|
|
5978
6387
|
}
|
|
5979
6388
|
),
|
|
5980
|
-
/* @__PURE__ */
|
|
5981
|
-
optionKeys.length > 0 ? /* @__PURE__ */
|
|
6389
|
+
/* @__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." }),
|
|
6390
|
+
optionKeys.length > 0 ? /* @__PURE__ */ jsxs28("div", { className: "flex flex-wrap items-end gap-2", children: [
|
|
5982
6391
|
option(
|
|
5983
6392
|
"currency",
|
|
5984
6393
|
"Currency",
|
|
5985
|
-
/* @__PURE__ */
|
|
6394
|
+
/* @__PURE__ */ jsx30(
|
|
5986
6395
|
PickOne,
|
|
5987
6396
|
{
|
|
5988
6397
|
label: "Currency",
|
|
@@ -5997,7 +6406,7 @@ function FieldFormatPicker({
|
|
|
5997
6406
|
option(
|
|
5998
6407
|
"percentScale",
|
|
5999
6408
|
"Stored as",
|
|
6000
|
-
/* @__PURE__ */
|
|
6409
|
+
/* @__PURE__ */ jsx30(
|
|
6001
6410
|
PickOne,
|
|
6002
6411
|
{
|
|
6003
6412
|
label: "Stored as",
|
|
@@ -6015,7 +6424,7 @@ function FieldFormatPicker({
|
|
|
6015
6424
|
option(
|
|
6016
6425
|
"durationUnit",
|
|
6017
6426
|
"Unit",
|
|
6018
|
-
/* @__PURE__ */
|
|
6427
|
+
/* @__PURE__ */ jsx30(
|
|
6019
6428
|
PickOne,
|
|
6020
6429
|
{
|
|
6021
6430
|
label: "Unit",
|
|
@@ -6035,7 +6444,7 @@ function FieldFormatPicker({
|
|
|
6035
6444
|
option(
|
|
6036
6445
|
"precision",
|
|
6037
6446
|
"Decimals",
|
|
6038
|
-
/* @__PURE__ */
|
|
6447
|
+
/* @__PURE__ */ jsx30(
|
|
6039
6448
|
"input",
|
|
6040
6449
|
{
|
|
6041
6450
|
"data-records-format-option": "precision",
|
|
@@ -6052,7 +6461,7 @@ function FieldFormatPicker({
|
|
|
6052
6461
|
option(
|
|
6053
6462
|
"ratingMax",
|
|
6054
6463
|
"Out of",
|
|
6055
|
-
/* @__PURE__ */
|
|
6464
|
+
/* @__PURE__ */ jsx30(
|
|
6056
6465
|
"input",
|
|
6057
6466
|
{
|
|
6058
6467
|
"data-records-format-option": "ratingMax",
|
|
@@ -6068,7 +6477,7 @@ function FieldFormatPicker({
|
|
|
6068
6477
|
option(
|
|
6069
6478
|
"dateStyle",
|
|
6070
6479
|
"Style",
|
|
6071
|
-
/* @__PURE__ */
|
|
6480
|
+
/* @__PURE__ */ jsx30(
|
|
6072
6481
|
PickOne,
|
|
6073
6482
|
{
|
|
6074
6483
|
label: "Style",
|
|
@@ -6087,15 +6496,15 @@ function FieldFormatPicker({
|
|
|
6087
6496
|
option(
|
|
6088
6497
|
"prefix",
|
|
6089
6498
|
"Prefix",
|
|
6090
|
-
/* @__PURE__ */
|
|
6499
|
+
/* @__PURE__ */ jsx30("input", { "data-records-format-option": "prefix", className: BOX, value: options.prefix ?? "", onChange: (e) => setOption("prefix", e.target.value) })
|
|
6091
6500
|
),
|
|
6092
6501
|
option(
|
|
6093
6502
|
"suffix",
|
|
6094
6503
|
"Suffix",
|
|
6095
|
-
/* @__PURE__ */
|
|
6504
|
+
/* @__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
6505
|
),
|
|
6097
|
-
optionKeys.includes("useGrouping") ? /* @__PURE__ */
|
|
6098
|
-
/* @__PURE__ */
|
|
6506
|
+
optionKeys.includes("useGrouping") ? /* @__PURE__ */ jsxs28("label", { className: "flex items-center gap-1.5 pb-1 text-[11px] text-muted-foreground", children: [
|
|
6507
|
+
/* @__PURE__ */ jsx30(
|
|
6099
6508
|
"input",
|
|
6100
6509
|
{
|
|
6101
6510
|
type: "checkbox",
|
|
@@ -6136,34 +6545,34 @@ function nextFieldSort(fields) {
|
|
|
6136
6545
|
import { autonumberPrefixOf as autonumberPrefixOf3, buttonNeeds, buttonOf } from "@ai-matrx/records";
|
|
6137
6546
|
|
|
6138
6547
|
// src/ButtonSettings.tsx
|
|
6139
|
-
import { useEffect as
|
|
6548
|
+
import { useEffect as useEffect18, useState as useState24 } from "react";
|
|
6140
6549
|
import { BasicInput as BasicInput8, Button as Button14, Label as Label7 } from "@ai-matrx/design-system";
|
|
6141
6550
|
import { STYLE_COLORS as STYLE_COLORS3 } from "@ai-matrx/design-system/data-table";
|
|
6142
6551
|
import { buttonUrlPlaceholders } from "@ai-matrx/records";
|
|
6143
|
-
import { useOptionalRecordsClient as
|
|
6552
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient9 } from "@ai-matrx/records/react";
|
|
6144
6553
|
|
|
6145
6554
|
// src/AccentSwatches.tsx
|
|
6146
6555
|
import { PORTAL_ACCENTS } from "@ai-matrx/records";
|
|
6147
|
-
import { cn as
|
|
6556
|
+
import { cn as cn21 } from "@ai-matrx/design-system";
|
|
6148
6557
|
import { STYLE_COLOR_LABELS as STYLE_COLOR_LABELS2, SWATCH_CLASS as SWATCH_CLASS3 } from "@ai-matrx/design-system/data-table";
|
|
6149
|
-
import { jsx as
|
|
6558
|
+
import { jsx as jsx31, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6150
6559
|
function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel = "App colour" }) {
|
|
6151
|
-
return /* @__PURE__ */
|
|
6152
|
-
/* @__PURE__ */
|
|
6560
|
+
return /* @__PURE__ */ jsxs29("div", { className: "flex flex-wrap gap-1.5", role: "radiogroup", "aria-label": "Colour", children: [
|
|
6561
|
+
/* @__PURE__ */ jsx31(
|
|
6153
6562
|
"button",
|
|
6154
6563
|
{
|
|
6155
6564
|
type: "button",
|
|
6156
6565
|
role: "radio",
|
|
6157
6566
|
"aria-checked": value === "",
|
|
6158
6567
|
onClick: () => onChange(""),
|
|
6159
|
-
className:
|
|
6568
|
+
className: cn21(
|
|
6160
6569
|
"h-7 rounded border px-2 text-xs",
|
|
6161
6570
|
value === "" ? "border-foreground" : "border-border text-muted-foreground"
|
|
6162
6571
|
),
|
|
6163
6572
|
children: noneLabel
|
|
6164
6573
|
}
|
|
6165
6574
|
),
|
|
6166
|
-
options.map((c) => /* @__PURE__ */
|
|
6575
|
+
options.map((c) => /* @__PURE__ */ jsx31(
|
|
6167
6576
|
"button",
|
|
6168
6577
|
{
|
|
6169
6578
|
type: "button",
|
|
@@ -6172,7 +6581,7 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
|
|
|
6172
6581
|
"aria-label": STYLE_COLOR_LABELS2[c],
|
|
6173
6582
|
title: STYLE_COLOR_LABELS2[c],
|
|
6174
6583
|
onClick: () => onChange(c),
|
|
6175
|
-
className:
|
|
6584
|
+
className: cn21("h-7 w-7 rounded-full border-2", SWATCH_CLASS3[c], value === c ? "border-foreground" : "border-transparent")
|
|
6176
6585
|
},
|
|
6177
6586
|
c
|
|
6178
6587
|
))
|
|
@@ -6180,7 +6589,7 @@ function AccentSwatches({ value, onChange, options = PORTAL_ACCENTS, noneLabel =
|
|
|
6180
6589
|
}
|
|
6181
6590
|
|
|
6182
6591
|
// src/ButtonSettings.tsx
|
|
6183
|
-
import { jsx as
|
|
6592
|
+
import { jsx as jsx32, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6184
6593
|
var DOES_WORDS = {
|
|
6185
6594
|
none: "Nothing yet",
|
|
6186
6595
|
open_url: "Open a link",
|
|
@@ -6201,11 +6610,11 @@ function ButtonSettingsEditor({
|
|
|
6201
6610
|
tableId,
|
|
6202
6611
|
fields
|
|
6203
6612
|
}) {
|
|
6204
|
-
const client =
|
|
6205
|
-
const [actions, setActions] =
|
|
6206
|
-
const [actionsRefused, setActionsRefused] =
|
|
6207
|
-
const [automations, setAutomations] =
|
|
6208
|
-
|
|
6613
|
+
const client = useOptionalRecordsClient9();
|
|
6614
|
+
const [actions, setActions] = useState24(null);
|
|
6615
|
+
const [actionsRefused, setActionsRefused] = useState24(null);
|
|
6616
|
+
const [automations, setAutomations] = useState24(null);
|
|
6617
|
+
useEffect18(() => {
|
|
6209
6618
|
if (!client || !tableId) return;
|
|
6210
6619
|
let live = true;
|
|
6211
6620
|
if (value.do === "run_action" && actions === null) {
|
|
@@ -6226,15 +6635,15 @@ function ButtonSettingsEditor({
|
|
|
6226
6635
|
}, [client, tableId, value.do, actions, automations]);
|
|
6227
6636
|
const set = (patch) => onChange({ ...value, ...patch });
|
|
6228
6637
|
const columns = fields.filter((f) => !(f.type === "text" && f.format === "button"));
|
|
6229
|
-
return /* @__PURE__ */
|
|
6230
|
-
/* @__PURE__ */
|
|
6231
|
-
/* @__PURE__ */
|
|
6232
|
-
/* @__PURE__ */
|
|
6233
|
-
/* @__PURE__ */
|
|
6638
|
+
return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-2 rounded-md border p-2", "data-records-button-settings": "", children: [
|
|
6639
|
+
/* @__PURE__ */ jsxs30("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
6640
|
+
/* @__PURE__ */ jsxs30("label", { className: "flex flex-col gap-1", children: [
|
|
6641
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Button label" }),
|
|
6642
|
+
/* @__PURE__ */ jsx32(BasicInput8, { className: "h-8 text-xs", value: value.label, "data-records-button-label": "", onChange: (e) => set({ label: e.target.value }) })
|
|
6234
6643
|
] }),
|
|
6235
|
-
/* @__PURE__ */
|
|
6236
|
-
/* @__PURE__ */
|
|
6237
|
-
/* @__PURE__ */
|
|
6644
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6645
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Does" }),
|
|
6646
|
+
/* @__PURE__ */ jsx32(
|
|
6238
6647
|
PickOne,
|
|
6239
6648
|
{
|
|
6240
6649
|
label: "What a press does",
|
|
@@ -6246,9 +6655,9 @@ function ButtonSettingsEditor({
|
|
|
6246
6655
|
)
|
|
6247
6656
|
] })
|
|
6248
6657
|
] }),
|
|
6249
|
-
/* @__PURE__ */
|
|
6250
|
-
/* @__PURE__ */
|
|
6251
|
-
/* @__PURE__ */
|
|
6658
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6659
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Colour" }),
|
|
6660
|
+
/* @__PURE__ */ jsx32(
|
|
6252
6661
|
AccentSwatches,
|
|
6253
6662
|
{
|
|
6254
6663
|
value: value.color ?? "",
|
|
@@ -6258,10 +6667,10 @@ function ButtonSettingsEditor({
|
|
|
6258
6667
|
}
|
|
6259
6668
|
)
|
|
6260
6669
|
] }),
|
|
6261
|
-
value.do === "open_url" ? /* @__PURE__ */
|
|
6262
|
-
/* @__PURE__ */
|
|
6263
|
-
/* @__PURE__ */
|
|
6264
|
-
/* @__PURE__ */
|
|
6670
|
+
value.do === "open_url" ? /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
|
|
6671
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "Link" }),
|
|
6672
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex gap-1", children: [
|
|
6673
|
+
/* @__PURE__ */ jsx32(
|
|
6265
6674
|
BasicInput8,
|
|
6266
6675
|
{
|
|
6267
6676
|
className: "h-8 flex-1 font-mono text-xs",
|
|
@@ -6271,7 +6680,7 @@ function ButtonSettingsEditor({
|
|
|
6271
6680
|
onChange: (e) => set({ url: e.target.value })
|
|
6272
6681
|
}
|
|
6273
6682
|
),
|
|
6274
|
-
columns.length > 0 ? /* @__PURE__ */
|
|
6683
|
+
columns.length > 0 ? /* @__PURE__ */ jsx32(
|
|
6275
6684
|
PickOne,
|
|
6276
6685
|
{
|
|
6277
6686
|
label: "Add a column's value",
|
|
@@ -6284,10 +6693,10 @@ function ButtonSettingsEditor({
|
|
|
6284
6693
|
}
|
|
6285
6694
|
) : null
|
|
6286
6695
|
] }),
|
|
6287
|
-
value.url && buttonUrlPlaceholders(value.url).length > 0 ? /* @__PURE__ */
|
|
6696
|
+
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
6697
|
] }) : null,
|
|
6289
|
-
value.do === "run_action" ? !tableId ? /* @__PURE__ */
|
|
6290
|
-
actions === null || actions.length > 0 ? /* @__PURE__ */
|
|
6698
|
+
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: [
|
|
6699
|
+
actions === null || actions.length > 0 ? /* @__PURE__ */ jsx32(
|
|
6291
6700
|
PickOne,
|
|
6292
6701
|
{
|
|
6293
6702
|
label: "Row action",
|
|
@@ -6298,7 +6707,7 @@ function ButtonSettingsEditor({
|
|
|
6298
6707
|
options: (actions ?? []).map((a) => ({ value: a.id, label: a.name }))
|
|
6299
6708
|
}
|
|
6300
6709
|
) : null,
|
|
6301
|
-
actions !== null ? /* @__PURE__ */
|
|
6710
|
+
actions !== null ? /* @__PURE__ */ jsx32(
|
|
6302
6711
|
NewRowAction,
|
|
6303
6712
|
{
|
|
6304
6713
|
tableId,
|
|
@@ -6312,7 +6721,7 @@ function ButtonSettingsEditor({
|
|
|
6312
6721
|
}
|
|
6313
6722
|
) : null
|
|
6314
6723
|
] }) : null,
|
|
6315
|
-
value.do === "run_automation" ? automations && automations.length === 0 ? /* @__PURE__ */
|
|
6724
|
+
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
6725
|
PickOne,
|
|
6317
6726
|
{
|
|
6318
6727
|
label: "Automation",
|
|
@@ -6337,13 +6746,13 @@ function NewRowAction({
|
|
|
6337
6746
|
columns,
|
|
6338
6747
|
onMade
|
|
6339
6748
|
}) {
|
|
6340
|
-
const client =
|
|
6749
|
+
const client = useOptionalRecordsClient9();
|
|
6341
6750
|
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__ */
|
|
6751
|
+
const [fieldId, setFieldId] = useState24("");
|
|
6752
|
+
const [setTo, setSetTo] = useState24("");
|
|
6753
|
+
const [busy, setBusy] = useState24(false);
|
|
6754
|
+
const [refused, setRefused] = useState24(null);
|
|
6755
|
+
if (settable.length === 0) return /* @__PURE__ */ jsx32("p", { className: "text-xs text-muted-foreground", children: "No column to set" });
|
|
6347
6756
|
const make = async () => {
|
|
6348
6757
|
if (!client || fieldId === "") return;
|
|
6349
6758
|
setBusy(true);
|
|
@@ -6367,10 +6776,10 @@ function NewRowAction({
|
|
|
6367
6776
|
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
6777
|
onMade(made.id, all);
|
|
6369
6778
|
};
|
|
6370
|
-
return /* @__PURE__ */
|
|
6371
|
-
/* @__PURE__ */
|
|
6372
|
-
/* @__PURE__ */
|
|
6373
|
-
/* @__PURE__ */
|
|
6779
|
+
return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", "data-records-button-new-action": "", children: [
|
|
6780
|
+
/* @__PURE__ */ jsx32(Label7, { className: "text-xs", children: "New row action" }),
|
|
6781
|
+
/* @__PURE__ */ jsxs30("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
6782
|
+
/* @__PURE__ */ jsx32(
|
|
6374
6783
|
PickOne,
|
|
6375
6784
|
{
|
|
6376
6785
|
label: "Column to set",
|
|
@@ -6382,16 +6791,16 @@ function NewRowAction({
|
|
|
6382
6791
|
options: settable.map((f) => ({ value: f.id, label: fieldName(f) }))
|
|
6383
6792
|
}
|
|
6384
6793
|
),
|
|
6385
|
-
/* @__PURE__ */
|
|
6386
|
-
/* @__PURE__ */
|
|
6794
|
+
/* @__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) }),
|
|
6795
|
+
/* @__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
6796
|
] }),
|
|
6388
|
-
refused ? /* @__PURE__ */
|
|
6797
|
+
refused ? /* @__PURE__ */ jsx32(RefusalLine, { error: refused }) : null
|
|
6389
6798
|
] });
|
|
6390
6799
|
}
|
|
6391
6800
|
|
|
6392
6801
|
// src/FieldEditor.tsx
|
|
6393
6802
|
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
|
|
6803
|
+
import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
6395
6804
|
var RULE_KINDS = FIELD_RULE_KIND_VALUES.map((kind) => ({ kind, label: FIELD_RULE_KIND_LABEL[kind] }));
|
|
6396
6805
|
var SENSITIVITIES = FIELD_SENSITIVITIES.map((value) => ({ value, label: FIELD_SENSITIVITY_LABEL[value] }));
|
|
6397
6806
|
var AGENT_VISIBILITY = CONTEXT_POLICIES.map((value) => ({ value, label: CONTEXT_POLICY_LABEL[value] }));
|
|
@@ -6504,33 +6913,33 @@ function FieldEditor(props) {
|
|
|
6504
6913
|
const copyOf = field ? void 0 : props.copyOf;
|
|
6505
6914
|
const start = field ?? copyOf;
|
|
6506
6915
|
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 =
|
|
6916
|
+
const [label, setLabel] = useState25(field?.label ?? (copyOf ? `${copyOf.label} (1)` : startAs?.label ?? ""));
|
|
6917
|
+
const [type, setType] = useState25(() => startAs ? startAs.type : startingType(start));
|
|
6918
|
+
const [required, setRequired] = useState25(start?.required ?? false);
|
|
6919
|
+
const [multi, setMulti] = useState25(start?.multi ?? false);
|
|
6920
|
+
const [dated, setDated] = useState25(start?.dated ?? false);
|
|
6921
|
+
const [sensitivity, setSensitivity] = useState25(String(start?.sensitivity ?? "internal"));
|
|
6922
|
+
const [contextPolicy, setContextPolicy] = useState25(String(start?.context_policy ?? "include"));
|
|
6923
|
+
const [rules, setRules] = useState25(start?.rules ?? []);
|
|
6924
|
+
const [startsWith, setStartsWith] = useState25(start?.default ?? null);
|
|
6925
|
+
const [ratingMax, setRatingMax] = useState25(() => start ? ratingMaxOf2(start) : 5);
|
|
6926
|
+
const savedRules = useMemo12(
|
|
6518
6927
|
() => field ? type === "rating" ? rulesWithTopStar(field.rules ?? [], ratingMaxOf2(field)) : field.rules ?? [] : [],
|
|
6519
6928
|
[field, type]
|
|
6520
6929
|
);
|
|
6521
|
-
const editedRules =
|
|
6522
|
-
const [statusGroups, setStatusGroups] =
|
|
6523
|
-
const [statusKeys, setStatusKeys] =
|
|
6524
|
-
const [symbology, setSymbology] =
|
|
6930
|
+
const editedRules = useMemo12(() => type === "rating" ? rulesWithTopStar(rules, ratingMax) : rules, [type, rules, ratingMax]);
|
|
6931
|
+
const [statusGroups, setStatusGroups] = useState25({});
|
|
6932
|
+
const [statusKeys, setStatusKeys] = useState25({});
|
|
6933
|
+
const [symbology, setSymbology] = useState25(String(start?.config?.["symbology"] ?? ""));
|
|
6525
6934
|
const descriptionStart = String(start?.config?.["description"] ?? "");
|
|
6526
|
-
const [description, setDescription] =
|
|
6527
|
-
const buttonStart =
|
|
6528
|
-
const [buttonSettings, setButtonSettings] =
|
|
6935
|
+
const [description, setDescription] = useState25(descriptionStart);
|
|
6936
|
+
const buttonStart = useMemo12(() => buttonOf(start) ?? { label: "" }, [start]);
|
|
6937
|
+
const [buttonSettings, setButtonSettings] = useState25(buttonStart);
|
|
6529
6938
|
const prefixStart = autonumberPrefixOf3(start);
|
|
6530
|
-
const [numberPrefix, setNumberPrefix] =
|
|
6939
|
+
const [numberPrefix, setNumberPrefix] = useState25(prefixStart);
|
|
6531
6940
|
const dependencyStart = start?.config?.["dependency"] === true;
|
|
6532
|
-
const [dependency, setDependency] =
|
|
6533
|
-
|
|
6941
|
+
const [dependency, setDependency] = useState25(dependencyStart);
|
|
6942
|
+
useEffect19(() => {
|
|
6534
6943
|
if (!field || type !== "status") return;
|
|
6535
6944
|
let live = true;
|
|
6536
6945
|
void client.fieldOptions({ field_id: field.id }).then((got) => {
|
|
@@ -6540,20 +6949,20 @@ function FieldEditor(props) {
|
|
|
6540
6949
|
live = false;
|
|
6541
6950
|
};
|
|
6542
6951
|
}, [client, field, type]);
|
|
6543
|
-
|
|
6952
|
+
useEffect19(() => {
|
|
6544
6953
|
if (field || type !== "status") return;
|
|
6545
6954
|
setNewChoices(
|
|
6546
6955
|
(rows) => rows.length > 0 ? rows : STATUS_STARTING_CHOICES.map((c, i) => ({ id: null, words: c.words, row: `status-${i}` }))
|
|
6547
6956
|
);
|
|
6548
6957
|
}, [field, type]);
|
|
6549
|
-
|
|
6958
|
+
useEffect19(() => {
|
|
6550
6959
|
if (field || type !== "select" && type !== "multi_select") return;
|
|
6551
6960
|
setNewChoices((rows) => rows.length > 0 ? rows : [newChoiceRow([])]);
|
|
6552
6961
|
}, [field, type]);
|
|
6553
|
-
const [allowOther, setAllowOther] =
|
|
6554
|
-
const [newChoices, setNewChoices] =
|
|
6962
|
+
const [allowOther, setAllowOther] = useState25(start?.config?.["allow_other"] === true);
|
|
6963
|
+
const [newChoices, setNewChoices] = useState25([]);
|
|
6555
6964
|
const copyOfId = copyOf?.id ?? null;
|
|
6556
|
-
|
|
6965
|
+
useEffect19(() => {
|
|
6557
6966
|
if (!copyOf || !copyOfId) return;
|
|
6558
6967
|
let live = true;
|
|
6559
6968
|
void client.fieldOptions({ field_id: copyOfId }).then((got) => {
|
|
@@ -6565,53 +6974,53 @@ function FieldEditor(props) {
|
|
|
6565
6974
|
live = false;
|
|
6566
6975
|
};
|
|
6567
6976
|
}, [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] =
|
|
6977
|
+
const [choiceList, setChoiceList] = useState25(null);
|
|
6978
|
+
const [choiceListStart, setChoiceListStart] = useState25(null);
|
|
6979
|
+
const [rehome, setRehome] = useState25({});
|
|
6980
|
+
const [rehomed, setRehomed] = useState25(null);
|
|
6981
|
+
const [rehomeRefused, setRehomeRefused] = useState25(null);
|
|
6982
|
+
const [unit, setUnit] = useState25(start?.unit ?? "$");
|
|
6983
|
+
const [withTime, setWithTime] = useState25(String(start?.config?.["kind"] ?? "date") === "datetime");
|
|
6984
|
+
const [via, setVia] = useState25(String(start?.config?.["via"] ?? ""));
|
|
6985
|
+
const [pick, setPick] = useState25(String(start?.config?.["pick"] ?? ""));
|
|
6986
|
+
const [agg, setAgg] = useState25(
|
|
6578
6987
|
start?.config?.["agg"] ?? "count"
|
|
6579
6988
|
);
|
|
6580
|
-
const [of, setOf] =
|
|
6989
|
+
const [of, setOf] = useState25(String(start?.config?.["of"] ?? ""));
|
|
6581
6990
|
const savedRollupFilter = field?.config?.["filter"] ?? null;
|
|
6582
|
-
const [rollupFilter, setRollupFilter] =
|
|
6991
|
+
const [rollupFilter, setRollupFilter] = useState25(
|
|
6583
6992
|
field ? savedRollupFilter : copyOf?.config?.["filter"] ?? null
|
|
6584
6993
|
);
|
|
6585
6994
|
const rollupFilterChanged = JSON.stringify(rollupFilter) !== JSON.stringify(savedRollupFilter);
|
|
6586
|
-
const [relationTarget, setRelationTarget] =
|
|
6587
|
-
const [showOnOther, setShowOnOther] =
|
|
6588
|
-
const [nestsSubItems, setNestsSubItems] =
|
|
6589
|
-
const [reverseRefused, setReverseRefused] =
|
|
6995
|
+
const [relationTarget, setRelationTarget] = useState25(String(start?.relation_target ?? ""));
|
|
6996
|
+
const [showOnOther, setShowOnOther] = useState25(true);
|
|
6997
|
+
const [nestsSubItems, setNestsSubItems] = useState25(false);
|
|
6998
|
+
const [reverseRefused, setReverseRefused] = useState25(null);
|
|
6590
6999
|
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] =
|
|
7000
|
+
const [display, setDisplay] = useState25(start?.display ?? null);
|
|
7001
|
+
const [formulaOp, setFormulaOp] = useState25(() => formulaOpOf(start));
|
|
7002
|
+
const [formulaFields, setFormulaFields] = useState25(() => formulaFieldIdsOf(start));
|
|
7003
|
+
const [formulaSeparator, setFormulaSeparator] = useState25(() => formulaSeparatorOf(start));
|
|
7004
|
+
const [allowedTypes, setAllowedTypes] = useState25(() => entityReferenceKindsOf(start));
|
|
6596
7005
|
const startingFormulaText = start ? formulaTextNow(String(start.config?.["formula_text"] ?? ""), start.config?.["expr"] ?? start.expr, fields.data) : "";
|
|
6597
|
-
const [formulaText, setFormulaText] =
|
|
6598
|
-
const shownFormula =
|
|
6599
|
-
|
|
7006
|
+
const [formulaText, setFormulaText] = useState25(startingFormulaText);
|
|
7007
|
+
const shownFormula = useRef13(startingFormulaText);
|
|
7008
|
+
useEffect19(() => {
|
|
6600
7009
|
if (shownFormula.current === startingFormulaText) return;
|
|
6601
7010
|
setFormulaText((typed) => typed === shownFormula.current ? startingFormulaText : typed);
|
|
6602
7011
|
shownFormula.current = startingFormulaText;
|
|
6603
7012
|
}, [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] =
|
|
7013
|
+
const [formulaWritten, setFormulaWritten] = useState25(() => startingFormulaText.trim() !== "" || Boolean(field) || startAs?.type === "formula");
|
|
7014
|
+
const [formulaOk, setFormulaOk] = useState25(null);
|
|
7015
|
+
const [askingToRemove, setAskingToRemove] = useState25(false);
|
|
7016
|
+
const [attempted, setAttempted] = useState25(false);
|
|
7017
|
+
const [showsAs, setShowsAs] = useState25(() => start ? startingChoice(start) : { format: null, retype: null });
|
|
7018
|
+
const [backfillError, setBackfillError] = useState25(null);
|
|
7019
|
+
const [notLanded, setNotLanded] = useState25(false);
|
|
6611
7020
|
const liveField = field ? fields.data?.find((f) => f.id === field.id) ?? field : void 0;
|
|
6612
7021
|
const heldAs = liveField ? JSON.stringify([liveField.type, liveField.config?.["kind"] ?? null, liveField.format ?? null, liveField.multi ?? false, liveField.unit ?? null]) : "";
|
|
6613
|
-
const seededAs =
|
|
6614
|
-
|
|
7022
|
+
const seededAs = useRef13(heldAs);
|
|
7023
|
+
useEffect19(() => {
|
|
6615
7024
|
if (!liveField || seededAs.current === heldAs) return;
|
|
6616
7025
|
seededAs.current = heldAs;
|
|
6617
7026
|
setType(startingType(liveField));
|
|
@@ -6620,24 +7029,24 @@ function FieldEditor(props) {
|
|
|
6620
7029
|
setUnit(liveField.unit ?? "$");
|
|
6621
7030
|
setWithTime(String(liveField.config?.["kind"] ?? "date") === "datetime");
|
|
6622
7031
|
}, [heldAs]);
|
|
6623
|
-
const others =
|
|
7032
|
+
const others = useMemo12(
|
|
6624
7033
|
() => (fields.data ?? []).filter((f) => f.id !== field?.id),
|
|
6625
7034
|
[fields.data, field?.id]
|
|
6626
7035
|
);
|
|
6627
|
-
const relations =
|
|
7036
|
+
const relations = useMemo12(() => others.filter((f) => sourceKindOf(f) !== null), [others]);
|
|
6628
7037
|
const reverse = useReverseColumns(onEntity ? null : tableId);
|
|
6629
|
-
const backLinks =
|
|
6630
|
-
const totalSources =
|
|
7038
|
+
const backLinks = useMemo12(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
|
|
7039
|
+
const totalSources = useMemo12(() => [...relations, ...backLinks], [relations, backLinks]);
|
|
6631
7040
|
const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
|
|
6632
7041
|
const choice = fieldTypeChoice(type);
|
|
6633
7042
|
const editing = Boolean(field);
|
|
6634
|
-
|
|
7043
|
+
useEffect19(() => {
|
|
6635
7044
|
if (!editing) setStartsWith(null);
|
|
6636
7045
|
}, [type, editing]);
|
|
6637
7046
|
const newDefault = !editing && !onEntity && newColumnTakesADefault(type) ? defaultToKeep(startsWith) : null;
|
|
6638
7047
|
const farFieldsOfLink = useFields2(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6639
7048
|
const farTable = useTable(field && sourceKindOf(field) === "link" && !onEntity ? field.relation_target ?? null : null);
|
|
6640
|
-
const linkReaders =
|
|
7049
|
+
const linkReaders = useMemo12(
|
|
6641
7050
|
() => field ? readingThroughLink(field, farFieldsOfLink.data ?? []) : [],
|
|
6642
7051
|
[field, farFieldsOfLink.data]
|
|
6643
7052
|
);
|
|
@@ -6645,7 +7054,7 @@ function FieldEditor(props) {
|
|
|
6645
7054
|
const offersMany = multiApplies(type) && !isTitle;
|
|
6646
7055
|
if (!mayShape) {
|
|
6647
7056
|
if (onEntity && entityRights.loading) return null;
|
|
6648
|
-
return /* @__PURE__ */
|
|
7057
|
+
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
7058
|
}
|
|
6650
7059
|
const options = newChoices.map((r) => r.words.trim()).filter((word) => word !== "");
|
|
6651
7060
|
const shownStatusRows = type !== "status" ? [] : statusGroupRows(field, editing ? choiceList ?? [] : newChoices, statusKeys, statusGroups);
|
|
@@ -6845,15 +7254,15 @@ function FieldEditor(props) {
|
|
|
6845
7254
|
if (gone) (onRemoved ?? onSaved)?.();
|
|
6846
7255
|
else setAskingToRemove(false);
|
|
6847
7256
|
};
|
|
6848
|
-
return /* @__PURE__ */
|
|
6849
|
-
/* @__PURE__ */
|
|
6850
|
-
/* @__PURE__ */
|
|
6851
|
-
/* @__PURE__ */
|
|
7257
|
+
return /* @__PURE__ */ jsxs31("div", { className: cn22("flex min-w-0 flex-col gap-3 text-xs", className), "data-records-field-editor": "", children: [
|
|
7258
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-2", children: [
|
|
7259
|
+
/* @__PURE__ */ jsx33("span", { className: "font-medium", children: field ? `Field \xB7 ${fieldName(field)}` : "New field" }),
|
|
7260
|
+
/* @__PURE__ */ jsx33("span", { className: "ml-auto text-muted-foreground", children: tableLabel })
|
|
6852
7261
|
] }),
|
|
6853
|
-
/* @__PURE__ */
|
|
6854
|
-
/* @__PURE__ */
|
|
6855
|
-
/* @__PURE__ */
|
|
6856
|
-
/* @__PURE__ */
|
|
7262
|
+
/* @__PURE__ */ jsxs31("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7263
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex flex-col gap-1", children: [
|
|
7264
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Name" }),
|
|
7265
|
+
/* @__PURE__ */ jsx33(
|
|
6857
7266
|
BasicInput9,
|
|
6858
7267
|
{
|
|
6859
7268
|
value: label,
|
|
@@ -6869,7 +7278,7 @@ function FieldEditor(props) {
|
|
|
6869
7278
|
...nameLine ? { "aria-invalid": true, "aria-describedby": "field-editor-name-taken" } : {}
|
|
6870
7279
|
}
|
|
6871
7280
|
),
|
|
6872
|
-
nameLine ? /* @__PURE__ */
|
|
7281
|
+
nameLine ? /* @__PURE__ */ jsx33(
|
|
6873
7282
|
"span",
|
|
6874
7283
|
{
|
|
6875
7284
|
id: "field-editor-name-taken",
|
|
@@ -6880,9 +7289,9 @@ function FieldEditor(props) {
|
|
|
6880
7289
|
}
|
|
6881
7290
|
) : null
|
|
6882
7291
|
] }),
|
|
6883
|
-
field ? /* @__PURE__ */
|
|
6884
|
-
/* @__PURE__ */
|
|
6885
|
-
/* @__PURE__ */
|
|
7292
|
+
field ? /* @__PURE__ */ jsxs31("label", { className: "flex flex-col gap-1 sm:col-span-2", children: [
|
|
7293
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Help text" }),
|
|
7294
|
+
/* @__PURE__ */ jsx33(
|
|
6886
7295
|
BasicInput9,
|
|
6887
7296
|
{
|
|
6888
7297
|
value: description,
|
|
@@ -6893,29 +7302,29 @@ function FieldEditor(props) {
|
|
|
6893
7302
|
}
|
|
6894
7303
|
)
|
|
6895
7304
|
] }) : null,
|
|
6896
|
-
/* @__PURE__ */
|
|
6897
|
-
/* @__PURE__ */
|
|
6898
|
-
/* @__PURE__ */
|
|
7305
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7306
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "What it holds" }),
|
|
7307
|
+
/* @__PURE__ */ jsxs31(
|
|
6899
7308
|
Select6,
|
|
6900
7309
|
{
|
|
6901
7310
|
value: type,
|
|
6902
7311
|
disabled: editing,
|
|
6903
7312
|
onValueChange: (next) => setType(next),
|
|
6904
7313
|
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__ */
|
|
7314
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "What this field holds", ...choice?.explanation ? { title: choice.explanation } : {}, children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7315
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: FIELD_TYPE_GROUPS.filter((group) => offered.some((c) => c.group === group)).map((group) => /* @__PURE__ */ jsxs31(SelectGroup2, { children: [
|
|
7316
|
+
/* @__PURE__ */ jsx33(SelectLabel2, { children: group }),
|
|
7317
|
+
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
7318
|
] }, group)) })
|
|
6910
7319
|
]
|
|
6911
7320
|
}
|
|
6912
7321
|
),
|
|
6913
|
-
editing && field ? /* @__PURE__ */
|
|
7322
|
+
editing && field ? /* @__PURE__ */ jsx33(FieldRetype, { field: liveField ?? field, tableId }) : null
|
|
6914
7323
|
] })
|
|
6915
7324
|
] }),
|
|
6916
|
-
type === "formula" && others.length > 0 ? /* @__PURE__ */
|
|
6917
|
-
editing ? startingFormulaText.trim() === "" ? /* @__PURE__ */
|
|
6918
|
-
/* @__PURE__ */
|
|
7325
|
+
type === "formula" && others.length > 0 ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-2", children: [
|
|
7326
|
+
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: [
|
|
7327
|
+
/* @__PURE__ */ jsx33(
|
|
6919
7328
|
Button15,
|
|
6920
7329
|
{
|
|
6921
7330
|
type: "button",
|
|
@@ -6926,7 +7335,7 @@ function FieldEditor(props) {
|
|
|
6926
7335
|
children: "Pick the columns"
|
|
6927
7336
|
}
|
|
6928
7337
|
),
|
|
6929
|
-
/* @__PURE__ */
|
|
7338
|
+
/* @__PURE__ */ jsx33(
|
|
6930
7339
|
Button15,
|
|
6931
7340
|
{
|
|
6932
7341
|
type: "button",
|
|
@@ -6938,7 +7347,7 @@ function FieldEditor(props) {
|
|
|
6938
7347
|
}
|
|
6939
7348
|
)
|
|
6940
7349
|
] }),
|
|
6941
|
-
formulaWritten ? /* @__PURE__ */
|
|
7350
|
+
formulaWritten ? /* @__PURE__ */ jsx33(
|
|
6942
7351
|
FormulaTextEditor,
|
|
6943
7352
|
{
|
|
6944
7353
|
tableId,
|
|
@@ -6948,9 +7357,9 @@ function FieldEditor(props) {
|
|
|
6948
7357
|
columns: others
|
|
6949
7358
|
}
|
|
6950
7359
|
) : 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__ */
|
|
7360
|
+
] }) : editing && type === "formula" ? /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No other column to read." }) : null,
|
|
7361
|
+
editing && field && !onEntity && (type === "lookup" || type === "rollup") ? /* @__PURE__ */ jsx33(SourceArchivedNotice, { fieldId: field.id, tableId }) : null,
|
|
7362
|
+
!editing && !(type === "formula" && formulaWritten) || type === "select" || type === "multi_select" || type === "status" || type === "rating" || type === "barcode" || type === "relation" || type === "entity_reference" ? /* @__PURE__ */ jsx33(
|
|
6954
7363
|
TypeQuestions,
|
|
6955
7364
|
{
|
|
6956
7365
|
type,
|
|
@@ -6980,7 +7389,7 @@ function FieldEditor(props) {
|
|
|
6980
7389
|
setFormulaSeparator,
|
|
6981
7390
|
relations: sourcesFor(type),
|
|
6982
7391
|
others,
|
|
6983
|
-
choiceList: editing && field ? /* @__PURE__ */
|
|
7392
|
+
choiceList: editing && field ? /* @__PURE__ */ jsx33(
|
|
6984
7393
|
ChoiceListEditor,
|
|
6985
7394
|
{
|
|
6986
7395
|
field,
|
|
@@ -6991,10 +7400,10 @@ function FieldEditor(props) {
|
|
|
6991
7400
|
rehome,
|
|
6992
7401
|
onRehome: setRehome
|
|
6993
7402
|
}
|
|
6994
|
-
) : /* @__PURE__ */
|
|
7403
|
+
) : /* @__PURE__ */ jsx33(ChoiceListEditor, { isNew: true, rows: newChoices, onRows: setNewChoices }),
|
|
6995
7404
|
allowedTypes,
|
|
6996
7405
|
setAllowedTypes,
|
|
6997
|
-
newer: type === "rating" ? /* @__PURE__ */
|
|
7406
|
+
newer: type === "rating" ? /* @__PURE__ */ jsx33(
|
|
6998
7407
|
RatingMaxQuestion,
|
|
6999
7408
|
{
|
|
7000
7409
|
value: ratingMax,
|
|
@@ -7002,19 +7411,19 @@ function FieldEditor(props) {
|
|
|
7002
7411
|
setRatingMax(next);
|
|
7003
7412
|
}
|
|
7004
7413
|
}
|
|
7005
|
-
) : type === "status" ? /* @__PURE__ */
|
|
7414
|
+
) : 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
7415
|
}
|
|
7007
7416
|
) : null,
|
|
7008
|
-
type === "button" ? /* @__PURE__ */
|
|
7009
|
-
type === "autonumber" ? /* @__PURE__ */
|
|
7010
|
-
/* @__PURE__ */
|
|
7011
|
-
/* @__PURE__ */
|
|
7417
|
+
type === "button" ? /* @__PURE__ */ jsx33(ButtonSettingsEditor, { value: buttonSettings, onChange: setButtonSettings, tableId: onEntity ? null : tableId, fields: others }) : null,
|
|
7418
|
+
type === "autonumber" ? /* @__PURE__ */ jsxs31("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7419
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Prefix" }),
|
|
7420
|
+
/* @__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
7421
|
] }) : null,
|
|
7013
|
-
editing && field?.type === "relation" && field.relation_target && field.relation_target === field.entity_definition_id ? /* @__PURE__ */
|
|
7014
|
-
/* @__PURE__ */
|
|
7015
|
-
/* @__PURE__ */
|
|
7422
|
+
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: [
|
|
7423
|
+
/* @__PURE__ */ jsx33(Checkbox4, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
|
|
7424
|
+
/* @__PURE__ */ jsx33("span", { children: "Waits on the linked records" })
|
|
7016
7425
|
] }) : null,
|
|
7017
|
-
type === "rollup" ? /* @__PURE__ */
|
|
7426
|
+
type === "rollup" ? /* @__PURE__ */ jsx33(
|
|
7018
7427
|
RollupFilterQuestion,
|
|
7019
7428
|
{
|
|
7020
7429
|
relation: totalSources.find((f) => f.key === via),
|
|
@@ -7024,10 +7433,10 @@ function FieldEditor(props) {
|
|
|
7024
7433
|
onChange: setRollupFilter
|
|
7025
7434
|
}
|
|
7026
7435
|
) : null,
|
|
7027
|
-
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */
|
|
7028
|
-
/* @__PURE__ */
|
|
7029
|
-
/* @__PURE__ */
|
|
7030
|
-
/* @__PURE__ */
|
|
7436
|
+
editing && field && !(type === "select" || type === "multi_select" || type === "status" || type === "autonumber") ? /* @__PURE__ */ jsx33(FieldFormatPicker, { field, value: showsAs, onValue: setShowsAs }) : null,
|
|
7437
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-wrap items-center gap-4", children: [
|
|
7438
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7439
|
+
/* @__PURE__ */ jsx33(
|
|
7031
7440
|
Checkbox4,
|
|
7032
7441
|
{
|
|
7033
7442
|
checked: required,
|
|
@@ -7035,10 +7444,10 @@ function FieldEditor(props) {
|
|
|
7035
7444
|
onCheckedChange: (v) => setRequired(v === true)
|
|
7036
7445
|
}
|
|
7037
7446
|
),
|
|
7038
|
-
/* @__PURE__ */
|
|
7447
|
+
/* @__PURE__ */ jsx33("span", { title: "Every record has to have one", children: "Required" })
|
|
7039
7448
|
] }),
|
|
7040
|
-
offersMany ? /* @__PURE__ */
|
|
7041
|
-
/* @__PURE__ */
|
|
7449
|
+
offersMany ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7450
|
+
/* @__PURE__ */ jsx33(
|
|
7042
7451
|
Checkbox4,
|
|
7043
7452
|
{
|
|
7044
7453
|
checked: multi,
|
|
@@ -7048,8 +7457,8 @@ function FieldEditor(props) {
|
|
|
7048
7457
|
),
|
|
7049
7458
|
"Can hold more than one"
|
|
7050
7459
|
] }) : null,
|
|
7051
|
-
/* @__PURE__ */
|
|
7052
|
-
/* @__PURE__ */
|
|
7460
|
+
/* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7461
|
+
/* @__PURE__ */ jsx33(
|
|
7053
7462
|
Checkbox4,
|
|
7054
7463
|
{
|
|
7055
7464
|
checked: dated,
|
|
@@ -7059,8 +7468,8 @@ function FieldEditor(props) {
|
|
|
7059
7468
|
),
|
|
7060
7469
|
"Each value has its own date"
|
|
7061
7470
|
] }),
|
|
7062
|
-
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */
|
|
7063
|
-
/* @__PURE__ */
|
|
7471
|
+
!field && type === "relation" && otherTable.data && otherTable.data.id !== tableId ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7472
|
+
/* @__PURE__ */ jsx33(
|
|
7064
7473
|
Checkbox4,
|
|
7065
7474
|
{
|
|
7066
7475
|
checked: showOnOther,
|
|
@@ -7072,12 +7481,12 @@ function FieldEditor(props) {
|
|
|
7072
7481
|
"Show on ",
|
|
7073
7482
|
otherTable.data.name ?? "the other table"
|
|
7074
7483
|
] }) : null,
|
|
7075
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */
|
|
7076
|
-
/* @__PURE__ */
|
|
7077
|
-
/* @__PURE__ */
|
|
7484
|
+
!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: [
|
|
7485
|
+
/* @__PURE__ */ jsx33(Checkbox4, { checked: dependency, "aria-label": "Waits on the linked records", "data-records-dependency": "", onCheckedChange: (v) => setDependency(v === true) }),
|
|
7486
|
+
/* @__PURE__ */ jsx33("span", { children: "Waits on the linked records" })
|
|
7078
7487
|
] }) : null,
|
|
7079
|
-
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */
|
|
7080
|
-
/* @__PURE__ */
|
|
7488
|
+
!field && type === "relation" && relationTarget === tableId ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7489
|
+
/* @__PURE__ */ jsx33(
|
|
7081
7490
|
Checkbox4,
|
|
7082
7491
|
{
|
|
7083
7492
|
checked: nestsSubItems,
|
|
@@ -7089,10 +7498,10 @@ function FieldEditor(props) {
|
|
|
7089
7498
|
"data-records-sub-items": ""
|
|
7090
7499
|
}
|
|
7091
7500
|
),
|
|
7092
|
-
/* @__PURE__ */
|
|
7501
|
+
/* @__PURE__ */ jsx33("span", { title: "Each record sits under the one this column names", children: "Sub-items" })
|
|
7093
7502
|
] }) : null,
|
|
7094
|
-
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */
|
|
7095
|
-
/* @__PURE__ */
|
|
7503
|
+
CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (type === "select" || type === "multi_select") ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7504
|
+
/* @__PURE__ */ jsx33(
|
|
7096
7505
|
Checkbox4,
|
|
7097
7506
|
{
|
|
7098
7507
|
checked: allowOther,
|
|
@@ -7103,10 +7512,10 @@ function FieldEditor(props) {
|
|
|
7103
7512
|
"A value that is not one of the choices is added to them"
|
|
7104
7513
|
] }) : null
|
|
7105
7514
|
] }),
|
|
7106
|
-
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */
|
|
7107
|
-
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */
|
|
7108
|
-
/* @__PURE__ */
|
|
7109
|
-
/* @__PURE__ */
|
|
7515
|
+
!editing && !onEntity && newColumnTakesADefault(type) ? /* @__PURE__ */ jsx33(NewColumnDefault, { type, choices: options, value: startsWith, onChange: setStartsWith }) : null,
|
|
7516
|
+
editing && field && takesADefault(liveField ?? field) ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", "data-records-field-default": "", children: [
|
|
7517
|
+
/* @__PURE__ */ jsx33(Label8, { htmlFor: "records-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
7518
|
+
/* @__PURE__ */ jsx33(
|
|
7110
7519
|
FieldControl,
|
|
7111
7520
|
{
|
|
7112
7521
|
id: "records-field-default",
|
|
@@ -7116,28 +7525,28 @@ function FieldEditor(props) {
|
|
|
7116
7525
|
}
|
|
7117
7526
|
)
|
|
7118
7527
|
] }) : null,
|
|
7119
|
-
/* @__PURE__ */
|
|
7120
|
-
/* @__PURE__ */
|
|
7121
|
-
/* @__PURE__ */
|
|
7122
|
-
/* @__PURE__ */
|
|
7123
|
-
/* @__PURE__ */
|
|
7124
|
-
/* @__PURE__ */
|
|
7125
|
-
/* @__PURE__ */
|
|
7528
|
+
/* @__PURE__ */ jsx33(Separator, {}),
|
|
7529
|
+
/* @__PURE__ */ jsxs31("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7530
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7531
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Who can see what is in it" }),
|
|
7532
|
+
/* @__PURE__ */ jsxs31(Select6, { value: sensitivity, onValueChange: setSensitivity, children: [
|
|
7533
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "Who can see what is in it", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7534
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: sensitivities.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7126
7535
|
] })
|
|
7127
7536
|
] }),
|
|
7128
|
-
/* @__PURE__ */
|
|
7129
|
-
/* @__PURE__ */
|
|
7130
|
-
/* @__PURE__ */
|
|
7131
|
-
/* @__PURE__ */
|
|
7132
|
-
/* @__PURE__ */
|
|
7537
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7538
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Can an assistant read it" }),
|
|
7539
|
+
/* @__PURE__ */ jsxs31(Select6, { value: contextPolicy, onValueChange: setContextPolicy, children: [
|
|
7540
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "Can an assistant read it", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7541
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: AGENT_VISIBILITY.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7133
7542
|
] })
|
|
7134
7543
|
] })
|
|
7135
7544
|
] }),
|
|
7136
|
-
/* @__PURE__ */
|
|
7137
|
-
/* @__PURE__ */
|
|
7138
|
-
/* @__PURE__ */
|
|
7139
|
-
/* @__PURE__ */
|
|
7140
|
-
/* @__PURE__ */
|
|
7545
|
+
/* @__PURE__ */ jsx33(Separator, {}),
|
|
7546
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-2", children: [
|
|
7547
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-2", children: [
|
|
7548
|
+
/* @__PURE__ */ jsx33("span", { className: "font-medium", children: "What counts as a good value" }),
|
|
7549
|
+
/* @__PURE__ */ jsx33(
|
|
7141
7550
|
Button15,
|
|
7142
7551
|
{
|
|
7143
7552
|
type: "button",
|
|
@@ -7149,8 +7558,8 @@ function FieldEditor(props) {
|
|
|
7149
7558
|
}
|
|
7150
7559
|
)
|
|
7151
7560
|
] }),
|
|
7152
|
-
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */
|
|
7153
|
-
/* @__PURE__ */
|
|
7561
|
+
canBeUnique(type, multi) || rules.some((r) => r.kind === "unique") ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", "data-records-field-unique": "", children: [
|
|
7562
|
+
/* @__PURE__ */ jsx33(
|
|
7154
7563
|
Checkbox4,
|
|
7155
7564
|
{
|
|
7156
7565
|
checked: rules.some((r) => r.kind === "unique"),
|
|
@@ -7160,20 +7569,20 @@ function FieldEditor(props) {
|
|
|
7160
7569
|
),
|
|
7161
7570
|
UNIQUE_LABEL
|
|
7162
7571
|
] }) : null,
|
|
7163
|
-
rules.length === 0 ? /* @__PURE__ */
|
|
7164
|
-
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */
|
|
7165
|
-
/* @__PURE__ */
|
|
7572
|
+
rules.length === 0 ? /* @__PURE__ */ jsx33("p", { className: "text-muted-foreground", children: "No checks." }) : null,
|
|
7573
|
+
rules.map((rule, index) => rule.kind === "unique" ? null : /* @__PURE__ */ jsxs31("div", { className: "flex items-center gap-1", children: [
|
|
7574
|
+
/* @__PURE__ */ jsxs31(
|
|
7166
7575
|
Select6,
|
|
7167
7576
|
{
|
|
7168
7577
|
value: rule.kind,
|
|
7169
7578
|
onValueChange: (kind) => setRules(rules.map((r, i) => i === index ? { ...r, kind } : r)),
|
|
7170
7579
|
children: [
|
|
7171
|
-
/* @__PURE__ */
|
|
7172
|
-
/* @__PURE__ */
|
|
7580
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", className: "w-52", "aria-label": `Check ${index + 1}`, children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7581
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: RULE_KINDS.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.kind, children: row.label }, row.kind)) })
|
|
7173
7582
|
]
|
|
7174
7583
|
}
|
|
7175
7584
|
),
|
|
7176
|
-
rule.kind === "length" ? /* @__PURE__ */
|
|
7585
|
+
rule.kind === "length" ? /* @__PURE__ */ jsx33(
|
|
7177
7586
|
BasicInput9,
|
|
7178
7587
|
{
|
|
7179
7588
|
className: "h-8 w-24",
|
|
@@ -7184,7 +7593,7 @@ function FieldEditor(props) {
|
|
|
7184
7593
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withNumber(r, "min", e.target.value) : r))
|
|
7185
7594
|
}
|
|
7186
7595
|
) : null,
|
|
7187
|
-
/* @__PURE__ */
|
|
7596
|
+
/* @__PURE__ */ jsx33(
|
|
7188
7597
|
BasicInput9,
|
|
7189
7598
|
{
|
|
7190
7599
|
className: "h-8",
|
|
@@ -7194,7 +7603,7 @@ function FieldEditor(props) {
|
|
|
7194
7603
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? { ...r, value: e.target.value } : r))
|
|
7195
7604
|
}
|
|
7196
7605
|
),
|
|
7197
|
-
rule.kind === "pattern" ? /* @__PURE__ */
|
|
7606
|
+
rule.kind === "pattern" ? /* @__PURE__ */ jsx33(
|
|
7198
7607
|
BasicInput9,
|
|
7199
7608
|
{
|
|
7200
7609
|
className: "h-8",
|
|
@@ -7204,7 +7613,7 @@ function FieldEditor(props) {
|
|
|
7204
7613
|
onChange: (e) => setRules(rules.map((r, i) => i === index ? withText(r, "example", e.target.value) : r))
|
|
7205
7614
|
}
|
|
7206
7615
|
) : null,
|
|
7207
|
-
/* @__PURE__ */
|
|
7616
|
+
/* @__PURE__ */ jsx33(
|
|
7208
7617
|
Button15,
|
|
7209
7618
|
{
|
|
7210
7619
|
type: "button",
|
|
@@ -7217,9 +7626,9 @@ function FieldEditor(props) {
|
|
|
7217
7626
|
)
|
|
7218
7627
|
] }, `${rule.kind}-${index}`))
|
|
7219
7628
|
] }),
|
|
7220
|
-
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */
|
|
7221
|
-
mutation.error ? /* @__PURE__ */
|
|
7222
|
-
notLanded ? /* @__PURE__ */
|
|
7629
|
+
editing && field && !onEntity && rulesChanged(savedRules, editedRules) ? /* @__PURE__ */ jsx33(FieldRulePreview, { field, tableId, rules: editedRules }) : null,
|
|
7630
|
+
mutation.error ? /* @__PURE__ */ jsx33(RefusalNotice, { error: mutation.error }) : null,
|
|
7631
|
+
notLanded ? /* @__PURE__ */ jsx33(
|
|
7223
7632
|
RefusalNotice,
|
|
7224
7633
|
{
|
|
7225
7634
|
error: (0, refusals_exports.refusal)(
|
|
@@ -7229,10 +7638,10 @@ function FieldEditor(props) {
|
|
|
7229
7638
|
)
|
|
7230
7639
|
}
|
|
7231
7640
|
) : null,
|
|
7232
|
-
rehomeRefused ? /* @__PURE__ */
|
|
7233
|
-
rehomed ? /* @__PURE__ */
|
|
7234
|
-
/* @__PURE__ */
|
|
7235
|
-
rehomed.undo ? /* @__PURE__ */
|
|
7641
|
+
rehomeRefused ? /* @__PURE__ */ jsx33(RefusalNotice, { error: rehomeRefused }) : null,
|
|
7642
|
+
rehomed ? /* @__PURE__ */ jsxs31("div", { "data-records-choice-rehomed": "", className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
7643
|
+
/* @__PURE__ */ jsx33("span", { children: rehomed.said }),
|
|
7644
|
+
rehomed.undo ? /* @__PURE__ */ jsx33(
|
|
7236
7645
|
Button15,
|
|
7237
7646
|
{
|
|
7238
7647
|
type: "button",
|
|
@@ -7257,18 +7666,18 @@ function FieldEditor(props) {
|
|
|
7257
7666
|
children: "Undo"
|
|
7258
7667
|
}
|
|
7259
7668
|
) : null,
|
|
7260
|
-
/* @__PURE__ */
|
|
7669
|
+
/* @__PURE__ */ jsx33(Button15, { type: "button", size: "sm", className: "h-6 px-2 text-xs", onClick: () => onSaved?.(), children: "Done" })
|
|
7261
7670
|
] }) : null,
|
|
7262
|
-
reverseRefused ? /* @__PURE__ */
|
|
7263
|
-
/* @__PURE__ */
|
|
7264
|
-
/* @__PURE__ */
|
|
7671
|
+
reverseRefused ? /* @__PURE__ */ jsxs31("div", { "data-records-reverse-field-refused": "", className: "flex flex-col gap-1", children: [
|
|
7672
|
+
/* @__PURE__ */ jsx33("p", { className: "text-[11px]", children: "The link is made. Its column on the other table was not:" }),
|
|
7673
|
+
/* @__PURE__ */ jsx33(RefusalNotice, { error: reverseRefused })
|
|
7265
7674
|
] }) : null,
|
|
7266
|
-
backfillError ? /* @__PURE__ */
|
|
7267
|
-
/* @__PURE__ */
|
|
7268
|
-
/* @__PURE__ */
|
|
7675
|
+
backfillError ? /* @__PURE__ */ jsxs31("div", { "data-records-autonumber-backfill-refused": "", className: "flex flex-col gap-1", children: [
|
|
7676
|
+
/* @__PURE__ */ jsx33("p", { className: "text-[11px]", children: "The column is made. The records already in the table were not numbered:" }),
|
|
7677
|
+
/* @__PURE__ */ jsx33(RefusalNotice, { error: backfillError })
|
|
7269
7678
|
] }) : null,
|
|
7270
|
-
/* @__PURE__ */
|
|
7271
|
-
/* @__PURE__ */
|
|
7679
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex min-w-0 flex-nowrap items-center gap-2", "data-field-editor-footer": "", children: [
|
|
7680
|
+
/* @__PURE__ */ jsx33(
|
|
7272
7681
|
Button15,
|
|
7273
7682
|
{
|
|
7274
7683
|
size: "sm",
|
|
@@ -7284,8 +7693,8 @@ function FieldEditor(props) {
|
|
|
7284
7693
|
children: mutation.saving ? "Saving\u2026" : field ? EDIT_FIELD_SAVE_LABEL : onEntity ? ADD_STANDARD_FIELD_SAVE_LABEL : ADD_FIELD_SAVE_LABEL
|
|
7285
7694
|
}
|
|
7286
7695
|
),
|
|
7287
|
-
onCancel ? /* @__PURE__ */
|
|
7288
|
-
/* @__PURE__ */
|
|
7696
|
+
onCancel ? /* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }) : null,
|
|
7697
|
+
/* @__PURE__ */ jsx33(
|
|
7289
7698
|
"span",
|
|
7290
7699
|
{
|
|
7291
7700
|
id: "field-editor-missing",
|
|
@@ -7301,11 +7710,11 @@ function FieldEditor(props) {
|
|
|
7301
7710
|
footer is always as wide and as tall as its larger state: opening the confirm moved
|
|
7302
7711
|
the dialog card 0.2278 and closing it 0.1303. The consequence is the tooltip of
|
|
7303
7712
|
"Remove it" (interface-text: the slot holds a label, never a paragraph). */
|
|
7304
|
-
/* @__PURE__ */
|
|
7305
|
-
/* @__PURE__ */
|
|
7306
|
-
/* @__PURE__ */
|
|
7307
|
-
/* @__PURE__ */
|
|
7308
|
-
/* @__PURE__ */
|
|
7713
|
+
/* @__PURE__ */ jsxs31("div", { className: "ml-auto grid shrink-0 items-center", "data-field-editor-remove": askingToRemove ? "asking" : "idle", children: [
|
|
7714
|
+
/* @__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" }) }),
|
|
7715
|
+
/* @__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: [
|
|
7716
|
+
/* @__PURE__ */ jsx33("span", { className: "whitespace-nowrap text-destructive", "data-field-editor-remove-ask": "", children: "Archive this field?" }),
|
|
7717
|
+
/* @__PURE__ */ jsx33(
|
|
7309
7718
|
Button15,
|
|
7310
7719
|
{
|
|
7311
7720
|
size: "sm",
|
|
@@ -7318,7 +7727,7 @@ function FieldEditor(props) {
|
|
|
7318
7727
|
children: "Remove it"
|
|
7319
7728
|
}
|
|
7320
7729
|
),
|
|
7321
|
-
/* @__PURE__ */
|
|
7730
|
+
/* @__PURE__ */ jsx33(Button15, { size: "sm", variant: "ghost", tabIndex: askingToRemove ? void 0 : -1, onClick: () => setAskingToRemove(false), children: "Keep it" })
|
|
7322
7731
|
] })
|
|
7323
7732
|
] })
|
|
7324
7733
|
) : null
|
|
@@ -7409,10 +7818,10 @@ function formulaSeparatorOf(field) {
|
|
|
7409
7818
|
function TypeQuestions(props) {
|
|
7410
7819
|
const { type } = props;
|
|
7411
7820
|
if (type === "entity_reference") {
|
|
7412
|
-
return /* @__PURE__ */
|
|
7821
|
+
return /* @__PURE__ */ jsx33(EntityReferenceKindPicker, { value: props.allowedTypes, onChange: props.setAllowedTypes, locked: props.editing });
|
|
7413
7822
|
}
|
|
7414
7823
|
if (type === "relation") {
|
|
7415
|
-
return /* @__PURE__ */
|
|
7824
|
+
return /* @__PURE__ */ jsx33(
|
|
7416
7825
|
ReferenceBuilder,
|
|
7417
7826
|
{
|
|
7418
7827
|
tableId: props.tableId,
|
|
@@ -7425,20 +7834,20 @@ function TypeQuestions(props) {
|
|
|
7425
7834
|
}
|
|
7426
7835
|
);
|
|
7427
7836
|
}
|
|
7428
|
-
if (type === "rating" || type === "barcode") return /* @__PURE__ */
|
|
7837
|
+
if (type === "rating" || type === "barcode") return /* @__PURE__ */ jsx33(Fragment10, { children: props.newer });
|
|
7429
7838
|
if (type === "status") {
|
|
7430
|
-
return /* @__PURE__ */
|
|
7839
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-3", children: [
|
|
7431
7840
|
props.choiceList,
|
|
7432
7841
|
props.newer
|
|
7433
7842
|
] });
|
|
7434
7843
|
}
|
|
7435
7844
|
if (type === "select" || type === "multi_select") {
|
|
7436
|
-
return /* @__PURE__ */
|
|
7845
|
+
return /* @__PURE__ */ jsx33(Fragment10, { children: props.choiceList });
|
|
7437
7846
|
}
|
|
7438
7847
|
if (type === "currency") {
|
|
7439
|
-
return /* @__PURE__ */
|
|
7440
|
-
/* @__PURE__ */
|
|
7441
|
-
/* @__PURE__ */
|
|
7848
|
+
return /* @__PURE__ */ jsxs31("label", { className: "flex max-w-[16rem] flex-col gap-1", children: [
|
|
7849
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "The currency" }),
|
|
7850
|
+
/* @__PURE__ */ jsx33(
|
|
7442
7851
|
BasicInput9,
|
|
7443
7852
|
{
|
|
7444
7853
|
value: props.unit,
|
|
@@ -7450,8 +7859,8 @@ function TypeQuestions(props) {
|
|
|
7450
7859
|
] });
|
|
7451
7860
|
}
|
|
7452
7861
|
if (type === "datetime") {
|
|
7453
|
-
return /* @__PURE__ */
|
|
7454
|
-
/* @__PURE__ */
|
|
7862
|
+
return /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-1.5", children: [
|
|
7863
|
+
/* @__PURE__ */ jsx33(
|
|
7455
7864
|
Checkbox4,
|
|
7456
7865
|
{
|
|
7457
7866
|
checked: props.withTime,
|
|
@@ -7465,14 +7874,14 @@ function TypeQuestions(props) {
|
|
|
7465
7874
|
if (type === "lookup" || type === "rollup" || type === "count") {
|
|
7466
7875
|
const usable = props.relations;
|
|
7467
7876
|
if (usable.length === 0) {
|
|
7468
|
-
return /* @__PURE__ */
|
|
7877
|
+
return /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No link, Person or File column yet." });
|
|
7469
7878
|
}
|
|
7470
|
-
return /* @__PURE__ */
|
|
7471
|
-
/* @__PURE__ */
|
|
7472
|
-
/* @__PURE__ */
|
|
7473
|
-
/* @__PURE__ */
|
|
7474
|
-
/* @__PURE__ */
|
|
7475
|
-
/* @__PURE__ */
|
|
7879
|
+
return /* @__PURE__ */ jsxs31("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
7880
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7881
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: type !== "lookup" ? "Across the records in" : "Read it from" }),
|
|
7882
|
+
/* @__PURE__ */ jsxs31(Select6, { value: props.via, onValueChange: props.setVia, children: [
|
|
7883
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": type !== "lookup" ? "Across the records in" : "Read it from", children: /* @__PURE__ */ jsx33(SelectValue6, { placeholder: "Choose a column" }) }),
|
|
7884
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: usable.map((f) => /* @__PURE__ */ jsxs31(SelectItem6, { value: f.key, children: [
|
|
7476
7885
|
fieldName(f),
|
|
7477
7886
|
isBackLinkSource(f) ? BACK_LINK_SOURCE_SUFFIX : "",
|
|
7478
7887
|
sourceKindOf(f) === "person" ? " \u2014 a person" : sourceKindOf(f) === "file" ? " \u2014 a file" : "",
|
|
@@ -7480,7 +7889,7 @@ function TypeQuestions(props) {
|
|
|
7480
7889
|
] }, f.id)) })
|
|
7481
7890
|
] })
|
|
7482
7891
|
] }),
|
|
7483
|
-
type === "lookup" ? /* @__PURE__ */
|
|
7892
|
+
type === "lookup" ? /* @__PURE__ */ jsx33(
|
|
7484
7893
|
ValueOnTheOtherSide,
|
|
7485
7894
|
{
|
|
7486
7895
|
label: "The value to read",
|
|
@@ -7489,13 +7898,13 @@ function TypeQuestions(props) {
|
|
|
7489
7898
|
value: props.pick,
|
|
7490
7899
|
onChange: props.setPick
|
|
7491
7900
|
}
|
|
7492
|
-
) : type === "count" ? null : /* @__PURE__ */
|
|
7493
|
-
/* @__PURE__ */
|
|
7494
|
-
/* @__PURE__ */
|
|
7495
|
-
/* @__PURE__ */
|
|
7496
|
-
/* @__PURE__ */
|
|
7901
|
+
) : type === "count" ? null : /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7902
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "What to work out" }),
|
|
7903
|
+
/* @__PURE__ */ jsxs31(Select6, { value: props.agg, onValueChange: (v) => props.setAgg(v), children: [
|
|
7904
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": "What to work out", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7905
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: ROLLUP_OPERATIONS.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7497
7906
|
] }),
|
|
7498
|
-
props.agg !== "count" ? /* @__PURE__ */
|
|
7907
|
+
props.agg !== "count" ? /* @__PURE__ */ jsx33(
|
|
7499
7908
|
ValueOnTheOtherSide,
|
|
7500
7909
|
{
|
|
7501
7910
|
label: "Of which value",
|
|
@@ -7511,21 +7920,21 @@ function TypeQuestions(props) {
|
|
|
7511
7920
|
}
|
|
7512
7921
|
if (type === "formula") {
|
|
7513
7922
|
if (props.others.length === 0) {
|
|
7514
|
-
return /* @__PURE__ */
|
|
7923
|
+
return /* @__PURE__ */ jsx33("p", { className: "text-[11px] text-muted-foreground", children: "No other columns yet." });
|
|
7515
7924
|
}
|
|
7516
|
-
return /* @__PURE__ */
|
|
7517
|
-
/* @__PURE__ */
|
|
7518
|
-
/* @__PURE__ */
|
|
7519
|
-
/* @__PURE__ */
|
|
7520
|
-
/* @__PURE__ */
|
|
7521
|
-
/* @__PURE__ */
|
|
7925
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-2", children: [
|
|
7926
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7927
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "What to do" }),
|
|
7928
|
+
/* @__PURE__ */ jsxs31(Select6, { value: props.formulaOp, onValueChange: props.setFormulaOp, children: [
|
|
7929
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", className: "max-w-[18rem]", "aria-label": "What to do", children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
7930
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: FORMULA_OPERATIONS.map((row) => /* @__PURE__ */ jsx33(SelectItem6, { value: row.value, children: row.label }, row.value)) })
|
|
7522
7931
|
] })
|
|
7523
7932
|
] }),
|
|
7524
|
-
/* @__PURE__ */
|
|
7525
|
-
/* @__PURE__ */
|
|
7526
|
-
/* @__PURE__ */
|
|
7933
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7934
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: "Which columns" }),
|
|
7935
|
+
/* @__PURE__ */ jsx33("div", { className: "flex flex-wrap gap-1", children: props.others.map((f) => {
|
|
7527
7936
|
const picked = props.formulaFields.includes(f.id);
|
|
7528
|
-
return /* @__PURE__ */
|
|
7937
|
+
return /* @__PURE__ */ jsx33(
|
|
7529
7938
|
Button15,
|
|
7530
7939
|
{
|
|
7531
7940
|
type: "button",
|
|
@@ -7540,9 +7949,9 @@ function TypeQuestions(props) {
|
|
|
7540
7949
|
);
|
|
7541
7950
|
}) })
|
|
7542
7951
|
] }),
|
|
7543
|
-
props.formulaOp === "concat" ? /* @__PURE__ */
|
|
7544
|
-
/* @__PURE__ */
|
|
7545
|
-
/* @__PURE__ */
|
|
7952
|
+
props.formulaOp === "concat" ? /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
7953
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", children: FORMULA_SEPARATOR_LABEL }),
|
|
7954
|
+
/* @__PURE__ */ jsx33(
|
|
7546
7955
|
BasicInput9,
|
|
7547
7956
|
{
|
|
7548
7957
|
value: props.formulaSeparator,
|
|
@@ -7593,25 +8002,25 @@ function RollupFilterQuestion({
|
|
|
7593
8002
|
}) {
|
|
7594
8003
|
const far = relation?.relation_target ?? null;
|
|
7595
8004
|
const farFields = useFields2(far);
|
|
7596
|
-
const conditionFields =
|
|
8005
|
+
const conditionFields = useMemo12(
|
|
7597
8006
|
() => (farFields.data ?? []).filter((f) => f.type !== "formula").map((f) => ({ id: f.id, key: f.key, label: fieldName(f), field: f })),
|
|
7598
8007
|
[farFields.data]
|
|
7599
8008
|
);
|
|
7600
|
-
const lastFar =
|
|
7601
|
-
|
|
8009
|
+
const lastFar = useRef13(far);
|
|
8010
|
+
useEffect19(() => {
|
|
7602
8011
|
if (lastFar.current !== null && far !== lastFar.current && !editing) onChange(null);
|
|
7603
8012
|
lastFar.current = far;
|
|
7604
8013
|
}, [far, editing, onChange]);
|
|
7605
8014
|
if (!relation || !far) return null;
|
|
7606
|
-
return /* @__PURE__ */
|
|
7607
|
-
/* @__PURE__ */
|
|
8015
|
+
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: [
|
|
8016
|
+
/* @__PURE__ */ jsxs31("span", { className: "text-muted-foreground", children: [
|
|
7608
8017
|
rollupFilterLead(agg),
|
|
7609
8018
|
" ",
|
|
7610
8019
|
conditionInWords(value, conditionFields),
|
|
7611
8020
|
"."
|
|
7612
8021
|
] }),
|
|
7613
|
-
/* @__PURE__ */
|
|
7614
|
-
] }) : /* @__PURE__ */
|
|
8022
|
+
/* @__PURE__ */ jsx33(Button15, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onChange(null), children: "Clear" })
|
|
8023
|
+
] }) : /* @__PURE__ */ jsx33(
|
|
7615
8024
|
ConditionGroup,
|
|
7616
8025
|
{
|
|
7617
8026
|
lead: rollupFilterLead(agg),
|
|
@@ -7637,13 +8046,13 @@ function ValueOnTheOtherSide({
|
|
|
7637
8046
|
const carried = sample.data?.rows[0]?.document ?? null;
|
|
7638
8047
|
const offered = declared.length > 0 ? declared.map((f) => ({ key: f.key, name: fieldName(f) })) : Object.keys(carried ?? {}).map((key) => ({ key, name: humanizeIdentifier4(key) }));
|
|
7639
8048
|
const stillAsking = columns.loading || declared.length === 0 && sample.loading;
|
|
7640
|
-
const body = !relation ? /* @__PURE__ */
|
|
7641
|
-
/* @__PURE__ */
|
|
7642
|
-
/* @__PURE__ */
|
|
8049
|
+
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: [
|
|
8050
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { size: "sm", "aria-label": label, children: /* @__PURE__ */ jsx33(SelectValue6, { placeholder: "Choose a column" }) }),
|
|
8051
|
+
/* @__PURE__ */ jsx33(SelectContent6, { children: offered.map((column) => /* @__PURE__ */ jsx33(SelectItem6, { value: column.key, children: column.name }, column.key)) })
|
|
7643
8052
|
] });
|
|
7644
|
-
if (compact) return /* @__PURE__ */
|
|
7645
|
-
return /* @__PURE__ */
|
|
7646
|
-
/* @__PURE__ */
|
|
8053
|
+
if (compact) return /* @__PURE__ */ jsx33("div", { className: "mt-1 flex flex-col gap-1", children: body });
|
|
8054
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", children: [
|
|
8055
|
+
/* @__PURE__ */ jsx33(Label8, { className: "text-xs", title: help, children: label }),
|
|
7647
8056
|
body
|
|
7648
8057
|
] });
|
|
7649
8058
|
}
|
|
@@ -7669,18 +8078,18 @@ function NewColumnDefault({
|
|
|
7669
8078
|
onChange
|
|
7670
8079
|
}) {
|
|
7671
8080
|
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__ */
|
|
8081
|
+
return /* @__PURE__ */ jsxs31("div", { className: "flex flex-col gap-1", "data-records-field-default": "", "data-records-new-field-default": "", children: [
|
|
8082
|
+
/* @__PURE__ */ jsx33(Label8, { htmlFor: "records-new-field-default", className: "text-xs", children: DEFAULT_LABEL }),
|
|
8083
|
+
type === "checkbox" ? /* @__PURE__ */ jsxs31("label", { className: "flex items-center gap-2", children: [
|
|
8084
|
+
/* @__PURE__ */ jsx33(Checkbox4, { id: "records-new-field-default", "aria-label": DEFAULT_LABEL, checked: value === true, onCheckedChange: (on) => onChange(on === true ? true : null) }),
|
|
8085
|
+
/* @__PURE__ */ jsx33("span", { children: "Ticked" })
|
|
8086
|
+
] }) : 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: [
|
|
8087
|
+
/* @__PURE__ */ jsx33(SelectTrigger6, { id: "records-new-field-default", size: "sm", "aria-label": DEFAULT_LABEL, children: /* @__PURE__ */ jsx33(SelectValue6, {}) }),
|
|
8088
|
+
/* @__PURE__ */ jsxs31(SelectContent6, { children: [
|
|
8089
|
+
/* @__PURE__ */ jsx33(SelectItem6, { value: none, children: "Nothing" }),
|
|
8090
|
+
choices.map((c) => /* @__PURE__ */ jsx33(SelectItem6, { value: c, children: c }, c))
|
|
7682
8091
|
] })
|
|
7683
|
-
] }) : /* @__PURE__ */
|
|
8092
|
+
] }) : /* @__PURE__ */ jsx33(
|
|
7684
8093
|
BasicInput9,
|
|
7685
8094
|
{
|
|
7686
8095
|
id: "records-new-field-default",
|
|
@@ -7695,7 +8104,7 @@ function NewColumnDefault({
|
|
|
7695
8104
|
// src/buttonCell.tsx
|
|
7696
8105
|
import { OutboundLink as OutboundLink6 } from "@ai-matrx/kit/outbound-react";
|
|
7697
8106
|
import { openOutbound } from "@ai-matrx/kit/outbound";
|
|
7698
|
-
import { Fragment as
|
|
8107
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7699
8108
|
function buttonPressWords(label, pressed) {
|
|
7700
8109
|
if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
|
|
7701
8110
|
if (pressed.do === "run_action") {
|
|
@@ -7707,11 +8116,11 @@ function buttonPressWords(label, pressed) {
|
|
|
7707
8116
|
}
|
|
7708
8117
|
var stop = (event) => event.stopPropagation();
|
|
7709
8118
|
function ButtonValue({ field, recordId, inCell }) {
|
|
7710
|
-
const client =
|
|
8119
|
+
const client = useOptionalRecordsClient10();
|
|
7711
8120
|
const b = buttonOf2(field);
|
|
7712
|
-
const [busy, setBusy] =
|
|
7713
|
-
const [said2, setSaid] =
|
|
7714
|
-
const [settingUp, setSettingUp] =
|
|
8121
|
+
const [busy, setBusy] = useState26(false);
|
|
8122
|
+
const [said2, setSaid] = useState26(null);
|
|
8123
|
+
const [settingUp, setSettingUp] = useState26(false);
|
|
7715
8124
|
if (!b) return null;
|
|
7716
8125
|
const color = isStyleColor2(b.color) ? CHOICE_CHIP_CLASS2[b.color] : NEUTRAL_CHIP_CLASS2;
|
|
7717
8126
|
const needs = buttonNeeds2(b);
|
|
@@ -7730,9 +8139,9 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7730
8139
|
}
|
|
7731
8140
|
setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
|
|
7732
8141
|
};
|
|
7733
|
-
return /* @__PURE__ */
|
|
7734
|
-
/* @__PURE__ */
|
|
7735
|
-
/* @__PURE__ */
|
|
8142
|
+
return /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
8143
|
+
/* @__PURE__ */ jsxs32(Popover4, { open: said2 !== null, onOpenChange: (open) => open ? null : setSaid(null), children: [
|
|
8144
|
+
/* @__PURE__ */ jsx34(PopoverTrigger4, { asChild: true, children: /* @__PURE__ */ jsx34(
|
|
7736
8145
|
Button16,
|
|
7737
8146
|
{
|
|
7738
8147
|
type: "button",
|
|
@@ -7742,7 +8151,7 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7742
8151
|
"data-records-button-unset": needs ? "" : void 0,
|
|
7743
8152
|
"aria-busy": busy || void 0,
|
|
7744
8153
|
disabled: busy,
|
|
7745
|
-
className:
|
|
8154
|
+
className: cn23("max-w-full gap-1 border px-2 font-medium", inCell ? "h-5" : "h-6", color, needs && "border-dashed opacity-80"),
|
|
7746
8155
|
onPointerDown: stop,
|
|
7747
8156
|
onDoubleClick: stop,
|
|
7748
8157
|
onClick: (event) => {
|
|
@@ -7750,20 +8159,20 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7750
8159
|
event.preventDefault();
|
|
7751
8160
|
void press();
|
|
7752
8161
|
},
|
|
7753
|
-
children: /* @__PURE__ */
|
|
8162
|
+
children: /* @__PURE__ */ jsx34("span", { className: "truncate", children: b.label })
|
|
7754
8163
|
}
|
|
7755
8164
|
) }),
|
|
7756
|
-
/* @__PURE__ */
|
|
7757
|
-
said2?.kind === "refused" ? /* @__PURE__ */
|
|
7758
|
-
said2?.kind === "public" ? /* @__PURE__ */
|
|
7759
|
-
said2?.kind === "ran" ? /* @__PURE__ */
|
|
8165
|
+
/* @__PURE__ */ jsxs32(PopoverContent4, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
|
|
8166
|
+
said2?.kind === "refused" ? /* @__PURE__ */ jsx34(RefusalLine, { error: said2.error }) : null,
|
|
8167
|
+
said2?.kind === "public" ? /* @__PURE__ */ jsx34("p", { children: "Buttons run for signed-in people." }) : null,
|
|
8168
|
+
said2?.kind === "ran" ? /* @__PURE__ */ jsxs32("p", { className: "break-words", children: [
|
|
7760
8169
|
said2.says,
|
|
7761
8170
|
" ",
|
|
7762
|
-
said2.link ? /* @__PURE__ */
|
|
8171
|
+
said2.link ? /* @__PURE__ */ jsx34(OutboundLink6, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
7763
8172
|
] }) : null,
|
|
7764
|
-
said2?.kind === "needs" ? /* @__PURE__ */
|
|
7765
|
-
/* @__PURE__ */
|
|
7766
|
-
tableId ? /* @__PURE__ */
|
|
8173
|
+
said2?.kind === "needs" ? /* @__PURE__ */ jsxs32(Fragment11, { children: [
|
|
8174
|
+
/* @__PURE__ */ jsx34("p", { children: said2.says }),
|
|
8175
|
+
tableId ? /* @__PURE__ */ jsxs32(
|
|
7767
8176
|
Button16,
|
|
7768
8177
|
{
|
|
7769
8178
|
type: "button",
|
|
@@ -7782,204 +8191,18 @@ function ButtonValue({ field, recordId, inCell }) {
|
|
|
7782
8191
|
] }) : null
|
|
7783
8192
|
] })
|
|
7784
8193
|
] }),
|
|
7785
|
-
settingUp && tableId ? /* @__PURE__ */
|
|
7786
|
-
/* @__PURE__ */
|
|
7787
|
-
/* @__PURE__ */
|
|
7788
|
-
/* @__PURE__ */
|
|
8194
|
+
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: [
|
|
8195
|
+
/* @__PURE__ */ jsxs32(DialogHeader2, { children: [
|
|
8196
|
+
/* @__PURE__ */ jsx34(DialogTitle2, { children: `Column settings \xB7 ${fieldName(field)}` }),
|
|
8197
|
+
/* @__PURE__ */ jsx34(DialogDescription, { className: "sr-only", children: "What the button does" })
|
|
7789
8198
|
] }),
|
|
7790
|
-
/* @__PURE__ */
|
|
8199
|
+
/* @__PURE__ */ jsx34(FieldEditor, { tableId, field, onSaved: () => setSettingUp(false), onCancel: () => setSettingUp(false) })
|
|
7791
8200
|
] }) }) : null
|
|
7792
8201
|
] });
|
|
7793
8202
|
}
|
|
7794
8203
|
|
|
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
8204
|
// src/FloatingRefusal.tsx
|
|
7982
|
-
import { useLayoutEffect, useRef as useRef14, useState as
|
|
8205
|
+
import { useLayoutEffect, useRef as useRef14, useState as useState27 } from "react";
|
|
7983
8206
|
import { createPortal } from "react-dom";
|
|
7984
8207
|
import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
7985
8208
|
var GAP = 4;
|
|
@@ -7999,8 +8222,8 @@ function placeFor(anchor, note) {
|
|
|
7999
8222
|
function FloatingRefusal({ text, why }) {
|
|
8000
8223
|
const spot = useRef14(null);
|
|
8001
8224
|
const note = useRef14(null);
|
|
8002
|
-
const [style, setStyle] =
|
|
8003
|
-
const [floating, setFloating] =
|
|
8225
|
+
const [style, setStyle] = useState27(null);
|
|
8226
|
+
const [floating, setFloating] = useState27(false);
|
|
8004
8227
|
useLayoutEffect(() => {
|
|
8005
8228
|
const here = spot.current;
|
|
8006
8229
|
if (!here) return;
|
|
@@ -8043,7 +8266,7 @@ function FloatingRefusal({ text, why }) {
|
|
|
8043
8266
|
}
|
|
8044
8267
|
|
|
8045
8268
|
// src/formatControls.tsx
|
|
8046
|
-
import { useEffect as
|
|
8269
|
+
import { useEffect as useEffect20, useRef as useRef15, useState as useState28 } from "react";
|
|
8047
8270
|
import { BasicInput as BasicInput10, BasicTextarea as BasicTextarea3 } from "@ai-matrx/design-system";
|
|
8048
8271
|
import { getFieldFormat as getFieldFormat4, parseFieldInput } from "@ai-matrx/design-system/field-formats";
|
|
8049
8272
|
import { jsx as jsx36, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
@@ -8063,9 +8286,9 @@ function keptValue(format, raw) {
|
|
|
8063
8286
|
return parsed;
|
|
8064
8287
|
}
|
|
8065
8288
|
function NumberInFormat({ format, value, onChange, disabled, id }) {
|
|
8066
|
-
const [text, setText] =
|
|
8289
|
+
const [text, setText] = useState28(() => typedText(format, value));
|
|
8067
8290
|
const lastSent = useRef15(void 0);
|
|
8068
|
-
|
|
8291
|
+
useEffect20(() => {
|
|
8069
8292
|
if (value === lastSent.current) return;
|
|
8070
8293
|
setText(typedText(format, value));
|
|
8071
8294
|
}, [value, format]);
|
|
@@ -8139,7 +8362,7 @@ function formatControl(args) {
|
|
|
8139
8362
|
}
|
|
8140
8363
|
|
|
8141
8364
|
// src/typedDateHelper.tsx
|
|
8142
|
-
import { useState as
|
|
8365
|
+
import { useState as useState29 } from "react";
|
|
8143
8366
|
import { Popover as Popover5, PopoverContent as PopoverContent5, PopoverTrigger as PopoverTrigger5, cn as cn24 } from "@ai-matrx/design-system";
|
|
8144
8367
|
import { readTypedDate, readTypedTime, typedDateText, typedTimeText } from "@ai-matrx/records";
|
|
8145
8368
|
import { jsx as jsx37, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
@@ -8163,7 +8386,7 @@ function readBox(text, kind) {
|
|
|
8163
8386
|
}
|
|
8164
8387
|
return { day: read.day, time: null };
|
|
8165
8388
|
}
|
|
8166
|
-
function
|
|
8389
|
+
function wordsFor2(kind, day, time) {
|
|
8167
8390
|
if (kind === "time") return time ? typedTimeText(time.h, time.m) : "";
|
|
8168
8391
|
if (!day) return "";
|
|
8169
8392
|
const dayText = typedDateText(day);
|
|
@@ -8190,12 +8413,12 @@ function TypedDateHelper({
|
|
|
8190
8413
|
onPicked,
|
|
8191
8414
|
startOpen = false
|
|
8192
8415
|
}) {
|
|
8193
|
-
const [open, setOpen] =
|
|
8416
|
+
const [open, setOpen] = useState29(startOpen);
|
|
8194
8417
|
const held = readBox(text, kind);
|
|
8195
8418
|
usePersonTimeZone();
|
|
8196
8419
|
const today = personWallNow();
|
|
8197
8420
|
const start = held.day ? new Date(Number(held.day.slice(0, 4)), Number(held.day.slice(5, 7)) - 1, 1) : new Date(today.getFullYear(), today.getMonth(), 1);
|
|
8198
|
-
const [month, setMonth] =
|
|
8421
|
+
const [month, setMonth] = useState29(null);
|
|
8199
8422
|
const shown2 = month ?? { y: start.getFullYear(), m: start.getMonth() };
|
|
8200
8423
|
const first = new Date(shown2.y, shown2.m, 1).getDay();
|
|
8201
8424
|
const days = new Date(shown2.y, shown2.m + 1, 0).getDate();
|
|
@@ -8204,7 +8427,7 @@ function TypedDateHelper({
|
|
|
8204
8427
|
const times = Array.from({ length: 48 }, (_, i) => ({ h: Math.floor(i / 2), m: i % 2 * 30 }));
|
|
8205
8428
|
const pickDay = (d) => {
|
|
8206
8429
|
const day = `${shown2.y}-${pad(shown2.m + 1)}-${pad(d)}`;
|
|
8207
|
-
onText(
|
|
8430
|
+
onText(wordsFor2(kind, day, held.time));
|
|
8208
8431
|
if (kind === "date") {
|
|
8209
8432
|
setOpen(false);
|
|
8210
8433
|
onPicked?.();
|
|
@@ -8212,7 +8435,7 @@ function TypedDateHelper({
|
|
|
8212
8435
|
};
|
|
8213
8436
|
const pickTime = (t) => {
|
|
8214
8437
|
const day = kind === "datetime" ? held.day ?? todayKey : null;
|
|
8215
|
-
onText(
|
|
8438
|
+
onText(wordsFor2(kind, day, t));
|
|
8216
8439
|
setOpen(false);
|
|
8217
8440
|
onPicked?.();
|
|
8218
8441
|
};
|
|
@@ -8300,24 +8523,24 @@ function TypedDateHelper({
|
|
|
8300
8523
|
}
|
|
8301
8524
|
|
|
8302
8525
|
// src/choiceNudge.ts
|
|
8303
|
-
import { useEffect as
|
|
8304
|
-
import { useOptionalRecordsClient as
|
|
8305
|
-
var
|
|
8526
|
+
import { useEffect as useEffect21, useState as useState30 } from "react";
|
|
8527
|
+
import { useOptionalRecordsClient as useOptionalRecordsClient11 } from "@ai-matrx/records/react";
|
|
8528
|
+
var asked2 = /* @__PURE__ */ new WeakMap();
|
|
8306
8529
|
function choiceNudgeOf(client) {
|
|
8307
|
-
let answer =
|
|
8530
|
+
let answer = asked2.get(client);
|
|
8308
8531
|
if (!answer) {
|
|
8309
8532
|
answer = Promise.resolve().then(() => client.choiceNudge()).then(
|
|
8310
8533
|
(result) => result.ok ? result.data : "ask",
|
|
8311
8534
|
() => "ask"
|
|
8312
8535
|
);
|
|
8313
|
-
|
|
8536
|
+
asked2.set(client, answer);
|
|
8314
8537
|
}
|
|
8315
8538
|
return answer;
|
|
8316
8539
|
}
|
|
8317
8540
|
function useChoiceNudge(enabled = true) {
|
|
8318
|
-
const client =
|
|
8319
|
-
const [nudge, setNudge] =
|
|
8320
|
-
|
|
8541
|
+
const client = useOptionalRecordsClient11();
|
|
8542
|
+
const [nudge, setNudge] = useState30(null);
|
|
8543
|
+
useEffect21(() => {
|
|
8321
8544
|
if (!enabled || !client) return;
|
|
8322
8545
|
let live = true;
|
|
8323
8546
|
void choiceNudgeOf(client).then((answer) => {
|
|
@@ -8469,7 +8692,7 @@ function openingText(field, value) {
|
|
|
8469
8692
|
}
|
|
8470
8693
|
function ReadsAsNote({ typed, always, children }) {
|
|
8471
8694
|
const note = useRef16(null);
|
|
8472
|
-
const [repeats, setRepeats] =
|
|
8695
|
+
const [repeats, setRepeats] = useState31(false);
|
|
8473
8696
|
useLayoutEffect2(() => {
|
|
8474
8697
|
if (always) return;
|
|
8475
8698
|
const words = (t) => (t ?? "").replace(/^Reads as/, "").replace(/\s+/g, "").toLowerCase();
|
|
@@ -8479,12 +8702,12 @@ function ReadsAsNote({ typed, always, children }) {
|
|
|
8479
8702
|
return /* @__PURE__ */ jsx38("span", { ref: note, "data-records-typed-reads-as": "", "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children });
|
|
8480
8703
|
}
|
|
8481
8704
|
function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCancel }) {
|
|
8482
|
-
const client =
|
|
8705
|
+
const client = useOptionalRecordsClient12();
|
|
8483
8706
|
const kind = String(editorKindFor(field));
|
|
8484
8707
|
const needsChoices = kind === "select" || kind === "multi_select";
|
|
8485
8708
|
const nudge = useChoiceNudge(needsChoices);
|
|
8486
|
-
const [choices, setChoices] =
|
|
8487
|
-
|
|
8709
|
+
const [choices, setChoices] = useState31(null);
|
|
8710
|
+
useEffect22(() => {
|
|
8488
8711
|
if (!needsChoices || !client) return;
|
|
8489
8712
|
let cancelled = false;
|
|
8490
8713
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
|
|
@@ -8494,7 +8717,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
8494
8717
|
cancelled = true;
|
|
8495
8718
|
};
|
|
8496
8719
|
}, [client, field.id, needsChoices]);
|
|
8497
|
-
|
|
8720
|
+
useEffect22(() => {
|
|
8498
8721
|
if (choices && nudge && value.judged === null) onChange({ ...value, judged: judgeTyped(field, value.text, choices, nudge) });
|
|
8499
8722
|
}, [choices, nudge, value, field, onChange]);
|
|
8500
8723
|
const judged = value.judged;
|
|
@@ -8570,7 +8793,7 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8570
8793
|
const host = useRecordsUi();
|
|
8571
8794
|
const kind = editorKindFor(field);
|
|
8572
8795
|
const inputId = id ?? `field-${field.key}`;
|
|
8573
|
-
const ownDetails =
|
|
8796
|
+
const ownDetails = useOptionalRecordsClient12() === null;
|
|
8574
8797
|
if (isTypedDraft(value)) return /* @__PURE__ */ jsx38(TypedTextControl, { field, value, onChange, disabled, id: inputId, onCommit, onCancel });
|
|
8575
8798
|
if (isSignatureField(field)) return /* @__PURE__ */ jsx38(SignaturePad, { id: inputId, value, onChange, disabled });
|
|
8576
8799
|
if (isButtonField3(field)) return /* @__PURE__ */ jsx38(ButtonValue, { field });
|
|
@@ -8690,11 +8913,11 @@ function FieldControl({ field, value, onChange, disabled, id, autoOpen, onClose,
|
|
|
8690
8913
|
}
|
|
8691
8914
|
}
|
|
8692
8915
|
function TypedWordsControl({ field, value, onChange, disabled, id }) {
|
|
8693
|
-
const [text, setText] =
|
|
8694
|
-
const [refusal, setRefusal] =
|
|
8695
|
-
const [why, setWhy] =
|
|
8916
|
+
const [text, setText] = useState31(() => openingText(field, value));
|
|
8917
|
+
const [refusal, setRefusal] = useState31(null);
|
|
8918
|
+
const [why, setWhy] = useState31(void 0);
|
|
8696
8919
|
const sent = useRef16(value);
|
|
8697
|
-
|
|
8920
|
+
useEffect22(() => {
|
|
8698
8921
|
if (value === sent.current) return;
|
|
8699
8922
|
sent.current = value;
|
|
8700
8923
|
setText(openingText(field, value));
|
|
@@ -8774,8 +8997,8 @@ function CheckboxControl({ field, value, onChange, disabled, id }) {
|
|
|
8774
8997
|
}
|
|
8775
8998
|
function JsonControl({ field, value, onChange, disabled, id }) {
|
|
8776
8999
|
const initial = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
8777
|
-
const [text, setText] =
|
|
8778
|
-
const [broken, setBroken] =
|
|
9000
|
+
const [text, setText] = useState31(initial);
|
|
9001
|
+
const [broken, setBroken] = useState31(null);
|
|
8779
9002
|
return /* @__PURE__ */ jsxs36("div", { className: "flex flex-col gap-1", children: [
|
|
8780
9003
|
/* @__PURE__ */ jsx38(
|
|
8781
9004
|
BasicTextarea4,
|
|
@@ -8836,11 +9059,11 @@ function inTheStoresOrder(options) {
|
|
|
8836
9059
|
return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
|
|
8837
9060
|
}
|
|
8838
9061
|
function OptionControl({ field, value, onChange, disabled, id, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm, onChosen }) {
|
|
8839
|
-
const client =
|
|
8840
|
-
const [options, setOptions] =
|
|
8841
|
-
const [refusal, setRefusal] =
|
|
8842
|
-
const [reread, setReread] =
|
|
8843
|
-
|
|
9062
|
+
const client = useOptionalRecordsClient12();
|
|
9063
|
+
const [options, setOptions] = useState31(null);
|
|
9064
|
+
const [refusal, setRefusal] = useState31(null);
|
|
9065
|
+
const [reread, setReread] = useState31(0);
|
|
9066
|
+
useEffect22(() => {
|
|
8844
9067
|
if (!client) return;
|
|
8845
9068
|
let cancelled = false;
|
|
8846
9069
|
void (0, askOnce_exports.fieldOptionsOnce)(client, field.id).then((result) => {
|
|
@@ -9004,18 +9227,18 @@ function OpenChoicePicker({
|
|
|
9004
9227
|
allowOther = true,
|
|
9005
9228
|
onChoicesChanged
|
|
9006
9229
|
}) {
|
|
9007
|
-
const client =
|
|
9230
|
+
const client = useOptionalRecordsClient12();
|
|
9008
9231
|
const nudge = useChoiceNudge();
|
|
9009
|
-
const [open, setOpenState] =
|
|
9232
|
+
const [open, setOpenState] = useState31(autoOpen === true);
|
|
9010
9233
|
const onCloseRef = useRef16(onClose);
|
|
9011
9234
|
onCloseRef.current = onClose;
|
|
9012
9235
|
const setOpen = useCallback7((next) => {
|
|
9013
9236
|
setOpenState(next);
|
|
9014
9237
|
if (!next) onCloseRef.current?.();
|
|
9015
9238
|
}, []);
|
|
9016
|
-
const [search, setSearch] =
|
|
9017
|
-
const [adding, setAdding] =
|
|
9018
|
-
const [addRefused, setAddRefused] =
|
|
9239
|
+
const [search, setSearch] = useState31(initialSearch ?? "");
|
|
9240
|
+
const [adding, setAdding] = useState31(false);
|
|
9241
|
+
const [addRefused, setAddRefused] = useState31(null);
|
|
9019
9242
|
const titleOf = (option) => recordName(option.data, null, "Unnamed choice");
|
|
9020
9243
|
const held = withoutAddition(value);
|
|
9021
9244
|
const current = choiceValuesOf(held.value);
|
|
@@ -9172,7 +9395,7 @@ function ChoiceAnswer({
|
|
|
9172
9395
|
isChosen,
|
|
9173
9396
|
onChosen
|
|
9174
9397
|
}) {
|
|
9175
|
-
const [search, setSearch] =
|
|
9398
|
+
const [search, setSearch] = useState31("");
|
|
9176
9399
|
const held = field.multi ? choiceValuesOf(value) : value === null || value === void 0 || value === "" ? [] : [value];
|
|
9177
9400
|
const on = (choice) => held.some((v) => isChosen ? isChosen(choice, v) : String(v) === choice.key || String(v) === choice.label);
|
|
9178
9401
|
const press = (choice) => {
|
|
@@ -9286,10 +9509,10 @@ var dataSources = globalSlot2("ai-matrx.records-ui.data-sources", () => /* @__PU
|
|
|
9286
9509
|
|
|
9287
9510
|
// src/RecordsMount.tsx
|
|
9288
9511
|
import { RecordsProvider } from "@ai-matrx/records/react";
|
|
9289
|
-
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
9512
|
+
import { jsx as jsx39, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
9290
9513
|
|
|
9291
9514
|
// src/TablePickers.tsx
|
|
9292
|
-
import { Fragment as Fragment14, jsx as jsx40, jsxs as
|
|
9515
|
+
import { Fragment as Fragment14, jsx as jsx40, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
9293
9516
|
var SHARED_FOR_MS = 5e3;
|
|
9294
9517
|
var sharedReads = /* @__PURE__ */ new WeakMap();
|
|
9295
9518
|
function readTablesAnywhere(dataSource) {
|
|
@@ -9321,8 +9544,8 @@ function readTablesAnywhere(dataSource) {
|
|
|
9321
9544
|
return read;
|
|
9322
9545
|
}
|
|
9323
9546
|
function useTablesAnywhere(dataSource) {
|
|
9324
|
-
const [state2, setState] =
|
|
9325
|
-
|
|
9547
|
+
const [state2, setState] = useState32({ loading: true, error: null, rows: [] });
|
|
9548
|
+
useEffect23(() => {
|
|
9326
9549
|
let live = true;
|
|
9327
9550
|
void readTablesAnywhere(dataSource).then((result) => {
|
|
9328
9551
|
if (live) setState(result);
|
|
@@ -9359,7 +9582,7 @@ function TablePicker({ dataSource, value, onChange, disabled, tables }) {
|
|
|
9359
9582
|
hint: t.organization_name,
|
|
9360
9583
|
keywords: t.organization_name,
|
|
9361
9584
|
...twin && second ? {
|
|
9362
|
-
render: /* @__PURE__ */
|
|
9585
|
+
render: /* @__PURE__ */ jsxs38("span", { className: "flex min-w-0 flex-col", children: [
|
|
9363
9586
|
/* @__PURE__ */ jsx40("span", { className: "truncate", children: t.table_name }),
|
|
9364
9587
|
/* @__PURE__ */ jsx40("span", { className: "truncate text-[11px] text-muted-foreground", children: second })
|
|
9365
9588
|
] })
|
|
@@ -9367,7 +9590,7 @@ function TablePicker({ dataSource, value, onChange, disabled, tables }) {
|
|
|
9367
9590
|
};
|
|
9368
9591
|
});
|
|
9369
9592
|
const missing = Boolean(value) && !list.loading && !list.error && !list.rows.some((t) => t.table_id === value);
|
|
9370
|
-
return /* @__PURE__ */
|
|
9593
|
+
return /* @__PURE__ */ jsxs38("div", { className: "flex flex-col gap-1", children: [
|
|
9371
9594
|
/* @__PURE__ */ jsx40(
|
|
9372
9595
|
CreatablePicker,
|
|
9373
9596
|
{
|
|
@@ -9396,10 +9619,10 @@ function TableScope({ dataSource, userId, tableId, children, fallback = null, un
|
|
|
9396
9619
|
}
|
|
9397
9620
|
function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
|
|
9398
9621
|
const fields = useFields3(tableId);
|
|
9399
|
-
const all =
|
|
9400
|
-
const byKey =
|
|
9622
|
+
const all = useMemo13(() => fields.data ?? [], [fields.data]);
|
|
9623
|
+
const byKey = useMemo13(() => new Map(all.map((f) => [f.key, f])), [all]);
|
|
9401
9624
|
const keys = Object.keys(value);
|
|
9402
|
-
const [adding, setAdding] =
|
|
9625
|
+
const [adding, setAdding] = useState32(false);
|
|
9403
9626
|
const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
|
|
9404
9627
|
const rename = (from, to) => {
|
|
9405
9628
|
if (from === to) return;
|
|
@@ -9412,7 +9635,7 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
|
|
|
9412
9635
|
void _gone;
|
|
9413
9636
|
onChange(rest);
|
|
9414
9637
|
};
|
|
9415
|
-
return /* @__PURE__ */
|
|
9638
|
+
return /* @__PURE__ */ jsxs38("div", { className: "flex flex-col gap-2", children: [
|
|
9416
9639
|
fields.error && /* @__PURE__ */ jsx40(RefusalLine, { error: fields.error }),
|
|
9417
9640
|
keys.map((key) => {
|
|
9418
9641
|
const field = byKey.get(key);
|
|
@@ -9465,8 +9688,8 @@ function ColumnValueRow({
|
|
|
9465
9688
|
}) {
|
|
9466
9689
|
const orphan = columnKey !== null && !loading && field === void 0;
|
|
9467
9690
|
const shown2 = orphan ? [{ value: columnKey, label: columnKey, hint: "Not a column" }, ...options] : options;
|
|
9468
|
-
return /* @__PURE__ */
|
|
9469
|
-
/* @__PURE__ */
|
|
9691
|
+
return /* @__PURE__ */ jsxs38("div", { className: "flex flex-col gap-1 rounded-md border border-border/60 p-2", children: [
|
|
9692
|
+
/* @__PURE__ */ jsxs38("div", { className: "flex items-center gap-2", children: [
|
|
9470
9693
|
/* @__PURE__ */ jsx40("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx40(
|
|
9471
9694
|
CreatablePicker,
|
|
9472
9695
|
{
|
|
@@ -9495,7 +9718,7 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
|
9495
9718
|
label: rowNameIn(table.data ?? null, row)
|
|
9496
9719
|
}));
|
|
9497
9720
|
const missing = Boolean(value) && !records.loading && !records.error && !rows.some((r) => r.id === value);
|
|
9498
|
-
return /* @__PURE__ */
|
|
9721
|
+
return /* @__PURE__ */ jsxs38("div", { className: "flex flex-col gap-1", children: [
|
|
9499
9722
|
/* @__PURE__ */ jsx40(
|
|
9500
9723
|
CreatablePicker,
|
|
9501
9724
|
{
|
|
@@ -9515,11 +9738,11 @@ function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
|
9515
9738
|
}
|
|
9516
9739
|
|
|
9517
9740
|
// src/DataBindingPicker.tsx
|
|
9518
|
-
import { useEffect as
|
|
9741
|
+
import { useEffect as useEffect24, useMemo as useMemo14 } from "react";
|
|
9519
9742
|
import { isEntityReferenceConfig } from "@ai-matrx/records";
|
|
9520
9743
|
import { useFields as useFields4, useTable as useTable3 } from "@ai-matrx/records/react";
|
|
9521
9744
|
import { BasicInput as BasicInput12, Button as Button19, CreatablePicker as CreatablePicker2, cn as cn26 } from "@ai-matrx/design-system";
|
|
9522
|
-
import { jsx as jsx41, jsxs as
|
|
9745
|
+
import { jsx as jsx41, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
9523
9746
|
var DATA_BINDING_SHAPES = [
|
|
9524
9747
|
{ value: "collection", label: "The whole table" },
|
|
9525
9748
|
{ value: "reference", label: "One record" },
|
|
@@ -9586,7 +9809,7 @@ function DataBindingPicker({ dataSource, userId, binding, onChange, disabled, de
|
|
|
9586
9809
|
...binding.semantic_type === "collection" && defaultRowLimit ? { limit: defaultRowLimit } : {}
|
|
9587
9810
|
});
|
|
9588
9811
|
};
|
|
9589
|
-
return /* @__PURE__ */
|
|
9812
|
+
return /* @__PURE__ */ jsxs39("div", { className: "flex flex-col gap-2", children: [
|
|
9590
9813
|
/* @__PURE__ */ jsx41(TablePicker, { dataSource, value: tableId, onChange: selectTable, disabled: Boolean(disabled), tables }),
|
|
9591
9814
|
/* @__PURE__ */ jsx41(TableScope, { dataSource, userId, tableId, tables, children: tableId && /* @__PURE__ */ jsx41(
|
|
9592
9815
|
BindingDetails,
|
|
@@ -9609,9 +9832,9 @@ function BindingDetails({
|
|
|
9609
9832
|
}) {
|
|
9610
9833
|
const table = useTable3(tableId);
|
|
9611
9834
|
const fields = useFields4(tableId);
|
|
9612
|
-
const fieldList =
|
|
9835
|
+
const fieldList = useMemo14(() => fields.data ?? [], [fields.data]);
|
|
9613
9836
|
const shape = binding.semantic_type;
|
|
9614
|
-
|
|
9837
|
+
useEffect24(() => {
|
|
9615
9838
|
if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
|
|
9616
9839
|
onChange({
|
|
9617
9840
|
...binding,
|
|
@@ -9652,7 +9875,7 @@ function BindingDetails({
|
|
|
9652
9875
|
const fieldOptions = fieldList.map((f) => ({ value: f.key, label: fieldName(f) }));
|
|
9653
9876
|
const template = binding.transform?.template ?? "";
|
|
9654
9877
|
const setTemplate = (next) => onChange({ ...binding, transform: { join: "\n", ...binding.transform, name: "list", template: next } });
|
|
9655
|
-
return /* @__PURE__ */
|
|
9878
|
+
return /* @__PURE__ */ jsxs39("div", { className: "flex flex-col gap-2", children: [
|
|
9656
9879
|
/* @__PURE__ */ jsx41("div", { className: "flex flex-wrap gap-1", role: "radiogroup", "aria-label": "What to read", children: DATA_BINDING_SHAPES.map((s) => /* @__PURE__ */ jsx41(
|
|
9657
9880
|
Button19,
|
|
9658
9881
|
{
|
|
@@ -9690,7 +9913,7 @@ function BindingDetails({
|
|
|
9690
9913
|
ariaLabel: "Column"
|
|
9691
9914
|
}
|
|
9692
9915
|
),
|
|
9693
|
-
shape !== "value" && /* @__PURE__ */
|
|
9916
|
+
shape !== "value" && /* @__PURE__ */ jsxs39("div", { className: "flex flex-col gap-1", children: [
|
|
9694
9917
|
/* @__PURE__ */ jsx41(
|
|
9695
9918
|
"textarea",
|
|
9696
9919
|
{
|
|
@@ -9716,7 +9939,7 @@ function BindingDetails({
|
|
|
9716
9939
|
p.token
|
|
9717
9940
|
)) })
|
|
9718
9941
|
] }),
|
|
9719
|
-
shape === "collection" && /* @__PURE__ */
|
|
9942
|
+
shape === "collection" && /* @__PURE__ */ jsxs39("label", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
9720
9943
|
"Up to",
|
|
9721
9944
|
/* @__PURE__ */ jsx41(
|
|
9722
9945
|
BasicInput12,
|
|
@@ -9735,7 +9958,7 @@ function BindingDetails({
|
|
|
9735
9958
|
),
|
|
9736
9959
|
"rows"
|
|
9737
9960
|
] }),
|
|
9738
|
-
/* @__PURE__ */
|
|
9961
|
+
/* @__PURE__ */ jsxs39("div", { className: "flex flex-wrap items-center gap-1", role: "radiogroup", "aria-label": "If nothing is found", children: [
|
|
9739
9962
|
/* @__PURE__ */ jsx41("span", { className: "text-xs text-muted-foreground", children: "If nothing is found" }),
|
|
9740
9963
|
DATA_BINDING_MISSING.map((m) => /* @__PURE__ */ jsx41(
|
|
9741
9964
|
Button19,
|
|
@@ -9757,7 +9980,7 @@ function BindingDetails({
|
|
|
9757
9980
|
|
|
9758
9981
|
// src/PickedSummaries.tsx
|
|
9759
9982
|
import { useFields as useFields5, useRecord, useTable as useTable4 } from "@ai-matrx/records/react";
|
|
9760
|
-
import { Fragment as Fragment15, jsx as jsx42, jsxs as
|
|
9983
|
+
import { Fragment as Fragment15, jsx as jsx42, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
9761
9984
|
function TableNameText({ dataSource, tableId }) {
|
|
9762
9985
|
const tables = useTablesAnywhere(dataSource);
|
|
9763
9986
|
if (!tableId) return /* @__PURE__ */ jsx42(Fragment15, { children: "\u2014" });
|
|
@@ -9795,7 +10018,7 @@ function ColumnValuesWords({ tableId, value }) {
|
|
|
9795
10018
|
const field = (fields.data ?? []).find((f) => f.key === key);
|
|
9796
10019
|
if (parts.length) parts.push(/* @__PURE__ */ jsx42("span", { children: ", " }, `${key}-sep`));
|
|
9797
10020
|
parts.push(
|
|
9798
|
-
/* @__PURE__ */
|
|
10021
|
+
/* @__PURE__ */ jsxs40("span", { children: [
|
|
9799
10022
|
field ? fieldName(field) : "A removed column",
|
|
9800
10023
|
" is ",
|
|
9801
10024
|
field ? renderValue(field, stored, void 0, labels) : "\u2014"
|
|
@@ -9833,10 +10056,10 @@ function RecordNameWords({ tableId, recordId }) {
|
|
|
9833
10056
|
}
|
|
9834
10057
|
|
|
9835
10058
|
// src/HeldChangeDecision.tsx
|
|
9836
|
-
import { useEffect as
|
|
10059
|
+
import { useEffect as useEffect25, useState as useState33 } from "react";
|
|
9837
10060
|
import { RecordsProvider as RecordsProvider3, useRecordsClient as useRecordsClient10 } from "@ai-matrx/records/react";
|
|
9838
10061
|
import { Button as Button20 } from "@ai-matrx/design-system";
|
|
9839
|
-
import { jsx as jsx43, jsxs as
|
|
10062
|
+
import { jsx as jsx43, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
9840
10063
|
function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided, approveLabel }) {
|
|
9841
10064
|
return /* @__PURE__ */ jsx43(RecordsProvider3, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ jsx43(Decision, { approvalId, onDecided, approveLabel: approveLabel ?? "Approve" }) });
|
|
9842
10065
|
}
|
|
@@ -9846,10 +10069,10 @@ function Decision({
|
|
|
9846
10069
|
approveLabel
|
|
9847
10070
|
}) {
|
|
9848
10071
|
const client = useRecordsClient10();
|
|
9849
|
-
const [may, setMay] =
|
|
9850
|
-
const [busy, setBusy] =
|
|
9851
|
-
const [error, setError] =
|
|
9852
|
-
|
|
10072
|
+
const [may, setMay] = useState33(null);
|
|
10073
|
+
const [busy, setBusy] = useState33(null);
|
|
10074
|
+
const [error, setError] = useState33(null);
|
|
10075
|
+
useEffect25(() => {
|
|
9853
10076
|
let live = true;
|
|
9854
10077
|
void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
|
|
9855
10078
|
if (!live) return;
|
|
@@ -9872,8 +10095,8 @@ function Decision({
|
|
|
9872
10095
|
else setError(res.error);
|
|
9873
10096
|
};
|
|
9874
10097
|
if (may === null) return /* @__PURE__ */ jsx43("p", { className: "text-xs text-muted-foreground", children: "Checking who can decide\u2026" });
|
|
9875
|
-
return /* @__PURE__ */
|
|
9876
|
-
may ? /* @__PURE__ */
|
|
10098
|
+
return /* @__PURE__ */ jsxs41("div", { className: "flex flex-col gap-1.5", children: [
|
|
10099
|
+
may ? /* @__PURE__ */ jsxs41("div", { className: "flex gap-2", children: [
|
|
9877
10100
|
/* @__PURE__ */ jsx43(Button20, { type: "button", size: "sm", disabled: busy !== null, onClick: () => void decide(true), children: busy === "approve" ? "Approving\u2026" : approveLabel }),
|
|
9878
10101
|
/* @__PURE__ */ jsx43(Button20, { type: "button", size: "sm", variant: "outline", disabled: busy !== null, onClick: () => void decide(false), children: busy === "refuse" ? "Refusing\u2026" : "Refuse" })
|
|
9879
10102
|
] }) : !error && /* @__PURE__ */ jsx43("p", { className: "text-xs text-muted-foreground", children: "An owner or admin of this organization decides this." }),
|