@ai-matrx/records-ui 0.93.8 → 0.93.12
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 +29 -0
- package/dist/index.cjs +270 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.js +471 -250
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -70,7 +70,7 @@ __export(src_exports, {
|
|
|
70
70
|
ConditionGroup: () => ConditionGroup,
|
|
71
71
|
ConditionRow: () => ConditionRow,
|
|
72
72
|
CustomFieldsSection: () => CustomFieldsSection,
|
|
73
|
-
DEFAULT_FIELDS: () =>
|
|
73
|
+
DEFAULT_FIELDS: () => import_core16.DEFAULT_FIELDS,
|
|
74
74
|
DEFAULT_FOOTER: () => DEFAULT_FOOTER,
|
|
75
75
|
DEFAULT_VIEW_NAME: () => DEFAULT_VIEW_NAME,
|
|
76
76
|
DUE_STATE_LABEL: () => DUE_STATE_LABEL,
|
|
@@ -224,7 +224,7 @@ __export(src_exports, {
|
|
|
224
224
|
WithheldValue: () => WithheldValue,
|
|
225
225
|
actorBadge: () => actorBadge,
|
|
226
226
|
actorWords: () => actorWords,
|
|
227
|
-
addFields: () =>
|
|
227
|
+
addFields: () => import_core16.addFields,
|
|
228
228
|
applyLook: () => applyLook,
|
|
229
229
|
archiveConfirmSentence: () => archiveConfirmSentence,
|
|
230
230
|
archivedRowLine: () => archivedRowLine,
|
|
@@ -259,7 +259,7 @@ __export(src_exports, {
|
|
|
259
259
|
dashboardFromSummary: () => dashboardFromSummary,
|
|
260
260
|
dateFormatFor: () => dateFormatFor,
|
|
261
261
|
dateText: () => dateText,
|
|
262
|
-
declareTable: () =>
|
|
262
|
+
declareTable: () => import_core16.declareTable,
|
|
263
263
|
declareView: () => declareView,
|
|
264
264
|
defaultViewOf: () => defaultViewOf,
|
|
265
265
|
designatedLayoutOf: () => designatedLayoutOf,
|
|
@@ -267,7 +267,7 @@ __export(src_exports, {
|
|
|
267
267
|
ensureSystemTable: () => ensureSystemTable,
|
|
268
268
|
entityReferenceSpec: () => entityReferenceSpec,
|
|
269
269
|
envelopeFor: () => envelopeFor,
|
|
270
|
-
fieldDeclarationFor: () =>
|
|
270
|
+
fieldDeclarationFor: () => import_core16.fieldDeclarationFor,
|
|
271
271
|
fieldIsEditable: () => fieldIsEditable,
|
|
272
272
|
fieldName: () => fieldName,
|
|
273
273
|
fieldToken: () => fieldToken,
|
|
@@ -357,7 +357,7 @@ __export(src_exports, {
|
|
|
357
357
|
tableName: () => tableName,
|
|
358
358
|
tableOpening: () => tableOpening,
|
|
359
359
|
tableRightsAt: () => tableRightsAt,
|
|
360
|
-
tokenFor: () =>
|
|
360
|
+
tokenFor: () => import_core16.tokenFor,
|
|
361
361
|
unknownRailLine: () => unknownRailLine,
|
|
362
362
|
unknownViewLine: () => unknownViewLine,
|
|
363
363
|
useCanShare: () => useCanShare,
|
|
@@ -3107,7 +3107,7 @@ function OptionControl({ field: field2, value, onChange, disabled, id, autoOpen,
|
|
|
3107
3107
|
if (refusal2)
|
|
3108
3108
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefusalLine, { error: refusal2 }) });
|
|
3109
3109
|
if (!options) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { id, className: "text-xs text-muted-foreground", children: "Reading this field's choices\u2026" });
|
|
3110
|
-
if (CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && (0, import_records5.allowsOtherValues)(field2)) {
|
|
3110
|
+
if (CHOICE_EDITOR_ADDS_WHAT_IS_TYPED && ((0, import_records5.allowsOtherValues)(field2) || !autoOpen)) {
|
|
3111
3111
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3112
3112
|
OpenChoicePicker,
|
|
3113
3113
|
{
|
|
@@ -3118,6 +3118,7 @@ function OptionControl({ field: field2, value, onChange, disabled, id, autoOpen,
|
|
|
3118
3118
|
disabled,
|
|
3119
3119
|
id,
|
|
3120
3120
|
addsChoices,
|
|
3121
|
+
allowOther: (0, import_records5.allowsOtherValues)(field2),
|
|
3121
3122
|
onChoicesChanged: () => setReread((n) => n + 1)
|
|
3122
3123
|
}
|
|
3123
3124
|
);
|
|
@@ -3190,6 +3191,7 @@ function OpenChoicePicker({
|
|
|
3190
3191
|
disabled,
|
|
3191
3192
|
id,
|
|
3192
3193
|
addsChoices,
|
|
3194
|
+
allowOther = true,
|
|
3193
3195
|
onChoicesChanged
|
|
3194
3196
|
}) {
|
|
3195
3197
|
const client = (0, import_react18.useOptionalRecordsClient)();
|
|
@@ -3207,7 +3209,7 @@ function OpenChoicePicker({
|
|
|
3207
3209
|
});
|
|
3208
3210
|
const q = search.trim();
|
|
3209
3211
|
const visible = options.filter((o) => q === "" || titleOf(o).toLowerCase().includes(q.toLowerCase()));
|
|
3210
|
-
const decided = (0, import_records5.decideTypedChoice)({ words: q, options, allowOther
|
|
3212
|
+
const decided = (0, import_records5.decideTypedChoice)({ words: q, options, allowOther, nudge: nudge ?? "ask" });
|
|
3211
3213
|
const choose = (word, addingIt = false) => {
|
|
3212
3214
|
const pending = held.add.filter((w) => w.toLowerCase() !== word.toLowerCase());
|
|
3213
3215
|
let next;
|
|
@@ -3292,7 +3294,10 @@ function OpenChoicePicker({
|
|
|
3292
3294
|
empty: q === "" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "p-2 text-xs text-muted-foreground", children: "No choices yet \u2014 type one to add it." }) : null,
|
|
3293
3295
|
add,
|
|
3294
3296
|
foot,
|
|
3295
|
-
footNote: addRefused ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefusalLine, { error: addRefused }) :
|
|
3297
|
+
footNote: addRefused ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefusalLine, { error: addRefused }) : offList && decided.decision === "not_a_choice" ? (
|
|
3298
|
+
// never_add on a column that takes only its choices: said, never a silent nothing.
|
|
3299
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { "data-records-typed-refusal": "", className: "p-2 text-xs text-muted-foreground", children: notAChoiceSentence(field2, [q]) })
|
|
3300
|
+
) : null
|
|
3296
3301
|
}
|
|
3297
3302
|
)
|
|
3298
3303
|
)
|
|
@@ -4986,7 +4991,7 @@ var import_react64 = require("react");
|
|
|
4986
4991
|
var import_react65 = require("@ai-matrx/records/react");
|
|
4987
4992
|
var import_records17 = require("@ai-matrx/records");
|
|
4988
4993
|
var import_data_table9 = require("@ai-matrx/design-system/data-table");
|
|
4989
|
-
var
|
|
4994
|
+
var import_core9 = require("@ai-matrx/records/core");
|
|
4990
4995
|
|
|
4991
4996
|
// src/archiveWords.ts
|
|
4992
4997
|
function archiveConfirmSentence(what) {
|
|
@@ -5226,6 +5231,7 @@ var import_design_system25 = require("@ai-matrx/design-system");
|
|
|
5226
5231
|
// src/FieldEditor.tsx
|
|
5227
5232
|
var import_react36 = require("react");
|
|
5228
5233
|
var import_react37 = require("@ai-matrx/records/react");
|
|
5234
|
+
var import_core4 = require("@ai-matrx/records/core");
|
|
5229
5235
|
var import_design_system21 = require("@ai-matrx/design-system");
|
|
5230
5236
|
|
|
5231
5237
|
// src/FormulaTextEditor.tsx
|
|
@@ -5614,10 +5620,17 @@ function ChoiceListEditor({
|
|
|
5614
5620
|
field: field2,
|
|
5615
5621
|
rows,
|
|
5616
5622
|
onRows,
|
|
5617
|
-
onStart
|
|
5623
|
+
onStart,
|
|
5624
|
+
allowOther = false,
|
|
5625
|
+
rehome = {},
|
|
5626
|
+
onRehome
|
|
5618
5627
|
}) {
|
|
5619
5628
|
const client = (0, import_react35.useRecordsClient)();
|
|
5620
5629
|
const [refused, setRefused] = (0, import_react34.useState)(null);
|
|
5630
|
+
const [usage, setUsage] = (0, import_react34.useState)(null);
|
|
5631
|
+
const [asking, setAsking] = (0, import_react34.useState)(null);
|
|
5632
|
+
const [moveTo, setMoveTo] = (0, import_react34.useState)("");
|
|
5633
|
+
const [removed, setRemoved] = (0, import_react34.useState)({});
|
|
5621
5634
|
(0, import_react34.useEffect)(() => {
|
|
5622
5635
|
if (rows !== null) return;
|
|
5623
5636
|
let live = true;
|
|
@@ -5635,6 +5648,19 @@ function ChoiceListEditor({
|
|
|
5635
5648
|
live = false;
|
|
5636
5649
|
};
|
|
5637
5650
|
}, [client, field2.id, rows, onRows, onStart]);
|
|
5651
|
+
(0, import_react34.useEffect)(() => {
|
|
5652
|
+
if (!onRehome) return;
|
|
5653
|
+
let live = true;
|
|
5654
|
+
void client.fieldChoiceUsage({ field_id: field2.id }).then(
|
|
5655
|
+
(got) => {
|
|
5656
|
+
if (live && got.ok) setUsage(got.data);
|
|
5657
|
+
},
|
|
5658
|
+
() => void 0
|
|
5659
|
+
);
|
|
5660
|
+
return () => {
|
|
5661
|
+
live = false;
|
|
5662
|
+
};
|
|
5663
|
+
}, [client, field2.id, onRehome]);
|
|
5638
5664
|
if (refused) {
|
|
5639
5665
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: "text-[11px] text-muted-foreground", "data-records-choice-list": "", children: [
|
|
5640
5666
|
"The choices could not be read, so they are left as they are: ",
|
|
@@ -5651,6 +5677,37 @@ function ChoiceListEditor({
|
|
|
5651
5677
|
onRows(next);
|
|
5652
5678
|
};
|
|
5653
5679
|
const named = (r, i) => r.words.trim() === "" ? `choice ${i + 1}` : `\u201C${r.words.trim()}\u201D`;
|
|
5680
|
+
const heldBy = (r) => r.id && onRehome ? usage?.[r.id]?.records ?? 0 : 0;
|
|
5681
|
+
const remove = (i) => {
|
|
5682
|
+
const r = rows[i];
|
|
5683
|
+
if (heldBy(r) > 0) {
|
|
5684
|
+
setAsking(r);
|
|
5685
|
+
setMoveTo("");
|
|
5686
|
+
return;
|
|
5687
|
+
}
|
|
5688
|
+
onRows(rows.filter((_, j) => j !== i));
|
|
5689
|
+
};
|
|
5690
|
+
const answer = (spec) => {
|
|
5691
|
+
if (!asking?.id || !onRehome) return;
|
|
5692
|
+
const index = rows.findIndex((r) => r.id === asking.id);
|
|
5693
|
+
setRemoved({ ...removed, [asking.id]: { row: asking, index: index < 0 ? rows.length : index } });
|
|
5694
|
+
onRows(rows.filter((r) => r.id !== asking.id));
|
|
5695
|
+
onRehome({ ...rehome, [asking.id]: spec });
|
|
5696
|
+
setAsking(null);
|
|
5697
|
+
};
|
|
5698
|
+
const putBack = (id) => {
|
|
5699
|
+
const was = removed[id];
|
|
5700
|
+
if (!was || !onRehome) return;
|
|
5701
|
+
const next = [...rows];
|
|
5702
|
+
next.splice(Math.min(was.index, next.length), 0, was.row);
|
|
5703
|
+
onRows(next);
|
|
5704
|
+
const { [id]: _gone, ...rest } = rehome;
|
|
5705
|
+
onRehome(rest);
|
|
5706
|
+
const { [id]: _was, ...keep } = removed;
|
|
5707
|
+
setRemoved(keep);
|
|
5708
|
+
};
|
|
5709
|
+
const targets = rows.filter((r) => r.id && r.id !== asking?.id && r.words.trim() !== "");
|
|
5710
|
+
const wordsOf = (id) => rows.find((r) => r.id === id)?.words.trim() ?? usage?.[id]?.words ?? "";
|
|
5654
5711
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-1", "data-records-choice-list": "", children: [
|
|
5655
5712
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Label, { className: "text-xs", children: "The choices" }),
|
|
5656
5713
|
rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-xs text-muted-foreground", "data-records-choice-list-empty": "", children: "No choices yet. Add the first one here, or type it into a cell and answer Add." }) : null,
|
|
@@ -5666,10 +5723,43 @@ function ChoiceListEditor({
|
|
|
5666
5723
|
),
|
|
5667
5724
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "ghost", className: "h-7 px-1.5 text-xs", "aria-label": `Move ${named(r, i)} up`, disabled: i === 0, onClick: () => move(i, -1), children: "\u2191" }),
|
|
5668
5725
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "ghost", className: "h-7 px-1.5 text-xs", "aria-label": `Move ${named(r, i)} down`, disabled: i === rows.length - 1, onClick: () => move(i, 1), children: "\u2193" }),
|
|
5669
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "ghost", className: "h-7 px-1.5 text-xs", "aria-label": `Remove ${named(r, i)}`, onClick: () =>
|
|
5726
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "ghost", className: "h-7 px-1.5 text-xs", "aria-label": `Remove ${named(r, i)}`, onClick: () => remove(i), children: "\xD7" })
|
|
5670
5727
|
] }, r.row)) }),
|
|
5728
|
+
asking ? (
|
|
5729
|
+
// THE QUESTION, Notion-style: where do the records that hold it go?
|
|
5730
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
5731
|
+
"div",
|
|
5732
|
+
{
|
|
5733
|
+
role: "group",
|
|
5734
|
+
"aria-label": (0, import_records10.recordsUseSentence)(heldBy(asking), asking.words.trim()),
|
|
5735
|
+
"data-records-choice-removal-ask": "",
|
|
5736
|
+
className: "flex flex-col gap-1 rounded border bg-muted/40 p-2",
|
|
5737
|
+
children: [
|
|
5738
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-xs", children: (0, import_records10.recordsUseSentence)(heldBy(asking), asking.words.trim()) }),
|
|
5739
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
5740
|
+
targets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
5741
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", className: "h-7 px-2 text-xs", disabled: moveTo === "", onClick: () => answer({ then: "move", to: moveTo }), children: "Move them to" }),
|
|
5742
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_design_system19.Select, { value: moveTo, onValueChange: setMoveTo, children: [
|
|
5743
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.SelectTrigger, { size: "sm", className: "h-7 w-36 text-xs", "aria-label": "Another choice", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.SelectValue, { placeholder: "Another choice" }) }),
|
|
5744
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.SelectContent, { children: targets.map((r) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.SelectItem, { value: r.id, children: r.words.trim() }, r.id)) })
|
|
5745
|
+
] })
|
|
5746
|
+
] }) : null,
|
|
5747
|
+
allowOther ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "outline", className: "h-7 px-2 text-xs", onClick: () => answer({ then: "keep" }), children: "Keep the words as other values" }) : null,
|
|
5748
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "outline", className: "h-7 px-2 text-xs", onClick: () => answer({ then: "clear" }), children: "Clear them" }),
|
|
5749
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "ghost", className: "h-7 px-2 text-xs", onClick: () => setAsking(null), children: "Cancel" })
|
|
5750
|
+
] })
|
|
5751
|
+
]
|
|
5752
|
+
}
|
|
5753
|
+
)
|
|
5754
|
+
) : null,
|
|
5755
|
+
Object.entries(rehome).map(
|
|
5756
|
+
([id, spec]) => removed[id] ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between gap-2 text-[11px] text-muted-foreground", "data-records-choice-rehome": "", children: [
|
|
5757
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: (0, import_records10.rehomeSentence)(usage?.[id]?.records ?? 0, removed[id].row.words.trim(), spec, spec.then === "move" ? wordsOf(spec.to) : void 0) }),
|
|
5758
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-1.5 text-[11px]", onClick: () => putBack(id), children: "Put it back" })
|
|
5759
|
+
] }, id) : null
|
|
5760
|
+
),
|
|
5671
5761
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system19.Button, { type: "button", size: "sm", variant: "outline", className: "h-7 self-start text-xs", onClick: () => onRows([...rows, { id: null, words: "", row: nextRow() }]), children: "Add a choice" }),
|
|
5672
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Changing a choice\u2019s words changes them in every record that holds it.
|
|
5762
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Changing a choice\u2019s words changes them in every record that holds it. Removing a choice that records hold asks where those records go." })
|
|
5673
5763
|
] });
|
|
5674
5764
|
}
|
|
5675
5765
|
|
|
@@ -6206,6 +6296,9 @@ function FieldEditor({ tableId, field: field2, onSaved, onCancel, onRemoved, cla
|
|
|
6206
6296
|
const [optionText, setOptionText] = (0, import_react36.useState)("");
|
|
6207
6297
|
const [choiceList, setChoiceList] = (0, import_react36.useState)(null);
|
|
6208
6298
|
const [choiceListStart, setChoiceListStart] = (0, import_react36.useState)(null);
|
|
6299
|
+
const [rehome, setRehome] = (0, import_react36.useState)({});
|
|
6300
|
+
const [rehomed, setRehomed] = (0, import_react36.useState)(null);
|
|
6301
|
+
const [rehomeRefused, setRehomeRefused] = (0, import_react36.useState)(null);
|
|
6209
6302
|
const [unit, setUnit] = (0, import_react36.useState)(field2?.unit ?? "$");
|
|
6210
6303
|
const [withTime, setWithTime] = (0, import_react36.useState)(String(field2?.config?.["kind"] ?? "date") === "datetime");
|
|
6211
6304
|
const [via, setVia] = (0, import_react36.useState)(String(field2?.config?.["via"] ?? ""));
|
|
@@ -6299,6 +6392,20 @@ function FieldEditor({ tableId, field: field2, onSaved, onCancel, onRemoved, cla
|
|
|
6299
6392
|
// K2: a re-aimed formula goes WITH its type word, the arm `field_update` reads it in.
|
|
6300
6393
|
...type === "formula" && formulaWritten && formulaChanged && formulaText.trim() !== "" ? { type: "formula", formula_text: formulaText.trim() } : {}
|
|
6301
6394
|
};
|
|
6395
|
+
if (Object.keys(rehome).length > 0 && Array.isArray(patch.options)) {
|
|
6396
|
+
setRehomeRefused(null);
|
|
6397
|
+
const done = await client.fieldUpdateRehomingChoices({ field_id: field2.id, patch, rehome });
|
|
6398
|
+
if (!done.ok) {
|
|
6399
|
+
setRehomeRefused(done.error);
|
|
6400
|
+
return;
|
|
6401
|
+
}
|
|
6402
|
+
(0, import_react37.tableShapeChanged)(tableId);
|
|
6403
|
+
for (const c of done.data.undo.cells_back) (0, import_core4.announceRecordChanged)(c.record_id);
|
|
6404
|
+
const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
|
|
6405
|
+
setRehome({});
|
|
6406
|
+
setRehomed({ said: `Saved. ${n} ${n === 1 ? "record was" : "records were"} changed with the choices.`, undo: done.data.undo });
|
|
6407
|
+
return;
|
|
6408
|
+
}
|
|
6302
6409
|
const written2 = await mutation.update({ field_id: field2.id, patch });
|
|
6303
6410
|
if (written2 !== null) onSaved?.();
|
|
6304
6411
|
return;
|
|
@@ -6469,7 +6576,18 @@ function FieldEditor({ tableId, field: field2, onSaved, onCancel, onRemoved, cla
|
|
|
6469
6576
|
relations,
|
|
6470
6577
|
others,
|
|
6471
6578
|
existingOptionsTable: Boolean(field2?.options_table_id ?? field2?.config?.["options_table_id"]),
|
|
6472
|
-
choiceList: editing && field2 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6579
|
+
choiceList: editing && field2 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6580
|
+
ChoiceListEditor,
|
|
6581
|
+
{
|
|
6582
|
+
field: field2,
|
|
6583
|
+
rows: choiceList,
|
|
6584
|
+
onRows: setChoiceList,
|
|
6585
|
+
onStart: setChoiceListStart,
|
|
6586
|
+
allowOther,
|
|
6587
|
+
rehome,
|
|
6588
|
+
onRehome: setRehome
|
|
6589
|
+
}
|
|
6590
|
+
) : null,
|
|
6473
6591
|
allowedTypes,
|
|
6474
6592
|
setAllowedTypes
|
|
6475
6593
|
}
|
|
@@ -6619,6 +6737,36 @@ function FieldEditor({ tableId, field: field2, onSaved, onCancel, onRemoved, cla
|
|
|
6619
6737
|
error: refusal("internal", COLUMN_DID_NOT_LAND_SENTENCE, COLUMN_DID_NOT_LAND_REMEDY)
|
|
6620
6738
|
}
|
|
6621
6739
|
) : null,
|
|
6740
|
+
rehomeRefused ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: rehomeRefused }) : null,
|
|
6741
|
+
rehomed ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-records-choice-rehomed": "", className: "flex flex-wrap items-center gap-2 text-[11px]", children: [
|
|
6742
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: rehomed.said }),
|
|
6743
|
+
rehomed.undo ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6744
|
+
import_design_system21.Button,
|
|
6745
|
+
{
|
|
6746
|
+
type: "button",
|
|
6747
|
+
size: "sm",
|
|
6748
|
+
variant: "outline",
|
|
6749
|
+
className: "h-6 px-2 text-xs",
|
|
6750
|
+
onClick: () => {
|
|
6751
|
+
const undo = rehomed.undo;
|
|
6752
|
+
if (!undo || !field2) return;
|
|
6753
|
+
void client.fieldUpdateRehomingChoices({ field_id: field2.id, patch: { options: undo.options }, cells_back: undo.cells_back }).then((back) => {
|
|
6754
|
+
if (!back.ok) {
|
|
6755
|
+
setRehomeRefused(back.error);
|
|
6756
|
+
return;
|
|
6757
|
+
}
|
|
6758
|
+
(0, import_react37.tableShapeChanged)(tableId);
|
|
6759
|
+
for (const c of undo.cells_back) (0, import_core4.announceRecordChanged)(c.record_id);
|
|
6760
|
+
setChoiceList(null);
|
|
6761
|
+
setChoiceListStart(null);
|
|
6762
|
+
setRehomed({ said: "Undone. The choices and the records that held them are back as they were.", undo: null });
|
|
6763
|
+
});
|
|
6764
|
+
},
|
|
6765
|
+
children: "Undo"
|
|
6766
|
+
}
|
|
6767
|
+
) : null,
|
|
6768
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_design_system21.Button, { type: "button", size: "sm", className: "h-6 px-2 text-xs", onClick: () => onSaved?.(), children: "Done" })
|
|
6769
|
+
] }) : null,
|
|
6622
6770
|
backfillError ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-records-autonumber-backfill-refused": "", className: "flex flex-col gap-1", children: [
|
|
6623
6771
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-[11px]", children: "The column is made. The records already in the table were not numbered:" }),
|
|
6624
6772
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: backfillError })
|
|
@@ -7803,7 +7951,7 @@ function SummarySheetControls({
|
|
|
7803
7951
|
}
|
|
7804
7952
|
|
|
7805
7953
|
// src/pasteValues.ts
|
|
7806
|
-
var
|
|
7954
|
+
var import_core5 = require("@ai-matrx/records/core");
|
|
7807
7955
|
var import_records14 = require("@ai-matrx/records");
|
|
7808
7956
|
function wordForStoredChoice(options, value) {
|
|
7809
7957
|
if (options === void 0 || typeof value !== "string" || value === "") return null;
|
|
@@ -7881,7 +8029,7 @@ function planPastedBlock(args) {
|
|
|
7881
8029
|
});
|
|
7882
8030
|
accepted[key] = judged.value;
|
|
7883
8031
|
}
|
|
7884
|
-
const predicted = (0,
|
|
8032
|
+
const predicted = (0, import_core5.predictValueRefusals)(args.fields, accepted);
|
|
7885
8033
|
for (const refusal2 of predicted) {
|
|
7886
8034
|
const key = refusal2.field_key;
|
|
7887
8035
|
if (key === void 0) continue;
|
|
@@ -9863,7 +10011,7 @@ function GridLayoutMenu({
|
|
|
9863
10011
|
// src/gridUndo.tsx
|
|
9864
10012
|
var import_react56 = require("react");
|
|
9865
10013
|
var import_react57 = require("@ai-matrx/records/react");
|
|
9866
|
-
var
|
|
10014
|
+
var import_core6 = require("@ai-matrx/records/core");
|
|
9867
10015
|
var import_design_system32 = require("@ai-matrx/design-system");
|
|
9868
10016
|
var import_data_table8 = require("@ai-matrx/design-system/data-table");
|
|
9869
10017
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
@@ -9931,7 +10079,7 @@ function useGridUndo(args) {
|
|
|
9931
10079
|
}
|
|
9932
10080
|
forget(step2.cells.map((c) => ({ rowId: c.rowId, key: c.key })));
|
|
9933
10081
|
for (const id of /* @__PURE__ */ new Set([...step2.cells.map((c) => c.rowId), ...step2.created ?? [], ...step2.archived ?? []])) {
|
|
9934
|
-
(0,
|
|
10082
|
+
(0, import_core6.announceRecordChanged)(id);
|
|
9935
10083
|
}
|
|
9936
10084
|
setHeld(() => {
|
|
9937
10085
|
let stack = taken.stack;
|
|
@@ -10076,7 +10224,7 @@ function undoKey(event) {
|
|
|
10076
10224
|
|
|
10077
10225
|
// src/gridAssist.tsx
|
|
10078
10226
|
var import_react59 = require("react");
|
|
10079
|
-
var
|
|
10227
|
+
var import_core7 = require("@ai-matrx/records/core");
|
|
10080
10228
|
var import_content_transfer = require("@ai-matrx/design-system/content-transfer");
|
|
10081
10229
|
|
|
10082
10230
|
// src/gridAgentContext.ts
|
|
@@ -10355,7 +10503,7 @@ function useGridAssist(args) {
|
|
|
10355
10503
|
if (!row) return;
|
|
10356
10504
|
const document2 = row.document ?? {};
|
|
10357
10505
|
const value = editing.valueFor(row, fieldOf2(key));
|
|
10358
|
-
const pointer = typeof document2[key] === "string" ? (0,
|
|
10506
|
+
const pointer = typeof document2[key] === "string" ? (0, import_core7.wholeValueOf)(document2, key) : null;
|
|
10359
10507
|
setWhole({ rowId, key, rowTitle: titleOf(row), value, pointer });
|
|
10360
10508
|
},
|
|
10361
10509
|
[rowOf, fieldOf2, titleOf, editing]
|
|
@@ -10448,7 +10596,7 @@ function useGridAssist(args) {
|
|
|
10448
10596
|
// src/gridBulk.tsx
|
|
10449
10597
|
var import_react60 = require("react");
|
|
10450
10598
|
var import_react61 = require("@ai-matrx/records/react");
|
|
10451
|
-
var
|
|
10599
|
+
var import_core8 = require("@ai-matrx/records/core");
|
|
10452
10600
|
var import_design_system34 = require("@ai-matrx/design-system");
|
|
10453
10601
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
10454
10602
|
function countOf(n, one, many) {
|
|
@@ -10505,7 +10653,7 @@ function useGridBulk(args) {
|
|
|
10505
10653
|
setRefusal(done.error);
|
|
10506
10654
|
return null;
|
|
10507
10655
|
}
|
|
10508
|
-
for (const change of changes) if ("record_id" in change && change.record_id) (0,
|
|
10656
|
+
for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core8.announceRecordChanged)(change.record_id);
|
|
10509
10657
|
return done.data;
|
|
10510
10658
|
},
|
|
10511
10659
|
[client, tableId]
|
|
@@ -11647,7 +11795,7 @@ function Grid({
|
|
|
11647
11795
|
}))
|
|
11648
11796
|
);
|
|
11649
11797
|
editing.forget(cells);
|
|
11650
|
-
for (const u of updates) (0,
|
|
11798
|
+
for (const u of updates) (0, import_core9.announceRecordChanged)(u.row.recordId);
|
|
11651
11799
|
const lines = updates.length + creates.length;
|
|
11652
11800
|
undo.push({ label: `Pasted ${lines} ${lines === 1 ? "row" : "rows"}`, cells, created });
|
|
11653
11801
|
const expected = [
|
|
@@ -12819,7 +12967,7 @@ function withHeaderMenus(columns, menuFor, filterFor) {
|
|
|
12819
12967
|
// src/ExportMenu.tsx
|
|
12820
12968
|
var import_react66 = require("react");
|
|
12821
12969
|
var import_react67 = require("@ai-matrx/records/react");
|
|
12822
|
-
var
|
|
12970
|
+
var import_core10 = require("@ai-matrx/records/core");
|
|
12823
12971
|
var import_react68 = require("@ai-matrx/alchemy/react");
|
|
12824
12972
|
var import_design_system37 = require("@ai-matrx/design-system");
|
|
12825
12973
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
@@ -12838,7 +12986,7 @@ function toRows(fields, records, labels) {
|
|
|
12838
12986
|
absent_reason: envelope?.absent ?? null,
|
|
12839
12987
|
// A VALUE KEPT AS A FILE carries its pointer, so the export writes the whole text
|
|
12840
12988
|
// (`withWholeValues`), never the first words passed off as the value.
|
|
12841
|
-
source: (0,
|
|
12989
|
+
source: (0, import_core10.wholeValueOf)(document2, field2.key)
|
|
12842
12990
|
};
|
|
12843
12991
|
}
|
|
12844
12992
|
return row;
|
|
@@ -12892,7 +13040,7 @@ function ExportMenu({ tableId, rows, label, className }) {
|
|
|
12892
13040
|
);
|
|
12893
13041
|
const lookup = (field2, id) => labels(field2, id) ?? learned.get(`${field2.id}:${id}`) ?? null;
|
|
12894
13042
|
const read = host.readFileText;
|
|
12895
|
-
return (0,
|
|
13043
|
+
return (0, import_core10.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
|
|
12896
13044
|
};
|
|
12897
13045
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: (0, import_design_system37.cn)("flex items-center gap-1", className), children: [
|
|
12898
13046
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
@@ -12900,7 +13048,7 @@ function ExportMenu({ tableId, rows, label, className }) {
|
|
|
12900
13048
|
{
|
|
12901
13049
|
size: "sm",
|
|
12902
13050
|
variant: "outline",
|
|
12903
|
-
onClick: () => void exported().then((rows2) => download(`${name}.csv`, "text/csv;charset=utf-8", (0,
|
|
13051
|
+
onClick: () => void exported().then((rows2) => download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core10.exportCsv)(fields.data ?? [], rows2))).catch(
|
|
12904
13052
|
(thrown) => setFailure(refusalFromThrown(thrown, "The CSV could not be written.", "Try again in a moment."))
|
|
12905
13053
|
),
|
|
12906
13054
|
children: "CSV"
|
|
@@ -12921,7 +13069,7 @@ function ExportMenu({ tableId, rows, label, className }) {
|
|
|
12921
13069
|
);
|
|
12922
13070
|
setFailure(null);
|
|
12923
13071
|
try {
|
|
12924
|
-
exported().then((rows2) => (0,
|
|
13072
|
+
exported().then((rows2) => (0, import_core10.exportXlsx)(fields.data ?? [], rows2, name)).then(
|
|
12925
13073
|
(bytes) => download(
|
|
12926
13074
|
`${name}.xlsx`,
|
|
12927
13075
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
@@ -12942,7 +13090,7 @@ function ExportMenu({ tableId, rows, label, className }) {
|
|
|
12942
13090
|
sourceId: `records:${tableId}`,
|
|
12943
13091
|
size: "xs",
|
|
12944
13092
|
json: () => records.map((r) => r.document),
|
|
12945
|
-
human: () => (0,
|
|
13093
|
+
human: () => (0, import_core10.exportCsv)(fields.data ?? [], toRows(fields.data ?? [], records, labels))
|
|
12946
13094
|
}
|
|
12947
13095
|
),
|
|
12948
13096
|
failure ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(RefusalLine, { error: failure }) : null
|
|
@@ -12952,11 +13100,11 @@ function ExportMenu({ tableId, rows, label, className }) {
|
|
|
12952
13100
|
// src/ImportWizard.tsx
|
|
12953
13101
|
var import_react69 = require("react");
|
|
12954
13102
|
var import_react70 = require("@ai-matrx/records/react");
|
|
12955
|
-
var
|
|
13103
|
+
var import_core12 = require("@ai-matrx/records/core");
|
|
12956
13104
|
var import_design_system38 = require("@ai-matrx/design-system");
|
|
12957
13105
|
|
|
12958
13106
|
// src/importRuleCheck.ts
|
|
12959
|
-
var
|
|
13107
|
+
var import_core11 = require("@ai-matrx/records/core");
|
|
12960
13108
|
function checkImportRules(fields, rows, mapping) {
|
|
12961
13109
|
const byKey = new Map(fields.map((f) => [f.key, f]));
|
|
12962
13110
|
const verdicts = [];
|
|
@@ -12974,7 +13122,7 @@ function checkImportRules(fields, rows, mapping) {
|
|
|
12974
13122
|
let why = null;
|
|
12975
13123
|
if ("refusal" in meant) why = meant.refusal;
|
|
12976
13124
|
else {
|
|
12977
|
-
const predicted = (0,
|
|
13125
|
+
const predicted = (0, import_core11.predictValueRefusals)([field2], { [key]: meant.value }).filter(
|
|
12978
13126
|
(p) => p.field_key === void 0 || p.field_key === key
|
|
12979
13127
|
);
|
|
12980
13128
|
if (predicted.length > 0) why = predicted[0].message;
|
|
@@ -13102,7 +13250,7 @@ function ImportWizard({ tableId, onDone, onWrote, className }) {
|
|
|
13102
13250
|
try {
|
|
13103
13251
|
const xlsx = file.name.toLowerCase().endsWith(".xlsx");
|
|
13104
13252
|
const bytes = await file.arrayBuffer();
|
|
13105
|
-
const result = xlsx ? await (0,
|
|
13253
|
+
const result = xlsx ? await (0, import_core12.importXlsx)(bytes) : (0, import_core12.importCsv)(new TextDecoder().decode(bytes));
|
|
13106
13254
|
setFormat(xlsx ? "xlsx" : "csv");
|
|
13107
13255
|
setFileName(file.name);
|
|
13108
13256
|
setFileBytes(file.size);
|
|
@@ -13729,11 +13877,12 @@ function CustomFieldsSection({
|
|
|
13729
13877
|
const [newLabel, setNewLabel] = (0, import_react71.useState)("");
|
|
13730
13878
|
const [newType, setNewType] = (0, import_react71.useState)("text");
|
|
13731
13879
|
const [draft, setDraft] = (0, import_react71.useState)({});
|
|
13880
|
+
const [removing, setRemoving] = (0, import_react71.useState)(null);
|
|
13732
13881
|
const fields = (0, import_react71.useMemo)(() => read.data?.fields ?? [], [read.data]);
|
|
13733
13882
|
const mayAdd = rights.data?.may_declare === true;
|
|
13734
|
-
const live = (0, import_react71.useRef)({ fields, rights: rights.data, loading: rights.loading, reload: read.reload });
|
|
13883
|
+
const live = (0, import_react71.useRef)({ fields, rights: rights.data, loading: rights.loading, reload: read.reload, values: read.data?.custom ?? {} });
|
|
13735
13884
|
(0, import_react71.useEffect)(() => {
|
|
13736
|
-
live.current = { fields, rights: rights.data, loading: rights.loading, reload: read.reload };
|
|
13885
|
+
live.current = { fields, rights: rights.data, loading: rights.loading, reload: read.reload, values: read.data?.custom ?? {} };
|
|
13737
13886
|
});
|
|
13738
13887
|
(0, import_react71.useEffect)(() => {
|
|
13739
13888
|
if (!agentDoor) return;
|
|
@@ -13745,7 +13894,8 @@ function CustomFieldsSection({
|
|
|
13745
13894
|
entityLabel: now.rights?.label ?? null,
|
|
13746
13895
|
mayAdd: now.rights ? now.rights.may_declare === true : now.loading ? null : false,
|
|
13747
13896
|
refusal: now.rights && !now.rights.may_declare ? now.rights.reason ?? null : null,
|
|
13748
|
-
fields: now.fields.map((f) => ({ key: f.key, label: f.label, type: f.type })),
|
|
13897
|
+
fields: now.fields.map((f) => ({ key: f.key, label: f.label, type: f.type, value: now.values[f.key] })),
|
|
13898
|
+
mayFill: now.rights ? now.rights.may_fill_in !== false : now.loading ? null : false,
|
|
13749
13899
|
types: ADDABLE_TYPES
|
|
13750
13900
|
};
|
|
13751
13901
|
};
|
|
@@ -13777,7 +13927,39 @@ function CustomFieldsSection({
|
|
|
13777
13927
|
}
|
|
13778
13928
|
return { ok: true, field_id: declared2.data, label, type };
|
|
13779
13929
|
};
|
|
13780
|
-
|
|
13930
|
+
const resolveKeys = (values2) => {
|
|
13931
|
+
const now = live.current;
|
|
13932
|
+
const problems = [];
|
|
13933
|
+
const patch = {};
|
|
13934
|
+
const written2 = [];
|
|
13935
|
+
const entries = values2 && typeof values2 === "object" && !Array.isArray(values2) ? Object.entries(values2) : [];
|
|
13936
|
+
if (entries.length === 0) problems.push("Name at least one field and its value.");
|
|
13937
|
+
for (const [name, value] of entries) {
|
|
13938
|
+
const want = name.trim().toLowerCase();
|
|
13939
|
+
const field2 = now.fields.find((f) => f.key.toLowerCase() === want || f.label.trim().toLowerCase() === want);
|
|
13940
|
+
if (!field2) {
|
|
13941
|
+
problems.push(`There is no custom field "${name}". Fields: ${now.fields.map((f) => f.label).join(", ") || "none yet"}.`);
|
|
13942
|
+
continue;
|
|
13943
|
+
}
|
|
13944
|
+
patch[field2.key] = value;
|
|
13945
|
+
written2.push({ key: field2.key, label: field2.label, value });
|
|
13946
|
+
}
|
|
13947
|
+
if (now.rights && now.rights.may_fill_in === false) problems.push("This person may not fill in custom fields on this record.");
|
|
13948
|
+
return { problems, patch, written: written2 };
|
|
13949
|
+
};
|
|
13950
|
+
const checkValues = (values2) => resolveKeys(values2).problems;
|
|
13951
|
+
const setValues = async (values2) => {
|
|
13952
|
+
const { problems, patch, written: written2 } = resolveKeys(values2);
|
|
13953
|
+
if (problems.length > 0) return { ok: false, message: problems.join(" ") };
|
|
13954
|
+
const result = await client.entityValueWrite({ token: entityToken, record_id: recordId, patch });
|
|
13955
|
+
if (!result.ok) {
|
|
13956
|
+
const hint = hintForAPerson(result.error.hint);
|
|
13957
|
+
return { ok: false, message: hint ? `${result.error.message} ${hint}` : result.error.message };
|
|
13958
|
+
}
|
|
13959
|
+
live.current.reload();
|
|
13960
|
+
return { ok: true, written: written2 };
|
|
13961
|
+
};
|
|
13962
|
+
return agentDoor({ entityToken, recordId, state, check, addField, checkValues, setValues });
|
|
13781
13963
|
}, [agentDoor, client, entityToken, recordId]);
|
|
13782
13964
|
if (!read.loading && !read.error && fields.length === 0 && !mayAdd) return null;
|
|
13783
13965
|
if (read.error) return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(RefusalLine, { error: read.error, className });
|
|
@@ -13888,7 +14070,46 @@ function CustomFieldsSection({
|
|
|
13888
14070
|
const field2 = asField(f);
|
|
13889
14071
|
const id = `cf-${recordId}-${f.key}`;
|
|
13890
14072
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
13891
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.
|
|
14073
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
14074
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(FieldLabel, { field: field2, htmlFor: id }),
|
|
14075
|
+
mayAdd && removing !== f.id ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
14076
|
+
import_design_system39.Button,
|
|
14077
|
+
{
|
|
14078
|
+
size: "sm",
|
|
14079
|
+
variant: "ghost",
|
|
14080
|
+
className: "ml-auto h-6 px-2 text-xs text-muted-foreground",
|
|
14081
|
+
onClick: () => setRemoving(f.id),
|
|
14082
|
+
children: "Remove field"
|
|
14083
|
+
}
|
|
14084
|
+
) : null
|
|
14085
|
+
] }),
|
|
14086
|
+
removing === f.id ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
14087
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: "text-destructive", children: [
|
|
14088
|
+
archiveConfirmSentence(`the field \u201C${f.label}\u201D`),
|
|
14089
|
+
" It is removed for everyone in this organization; its values stay in every record and come back with it."
|
|
14090
|
+
] }),
|
|
14091
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
14092
|
+
import_design_system39.Button,
|
|
14093
|
+
{
|
|
14094
|
+
size: "sm",
|
|
14095
|
+
variant: "destructive",
|
|
14096
|
+
disabled: mutation.saving,
|
|
14097
|
+
onClick: async () => {
|
|
14098
|
+
const gone = await mutation.retire({ field_id: f.id });
|
|
14099
|
+
setRemoving(null);
|
|
14100
|
+
if (gone) {
|
|
14101
|
+
setDraft((d) => {
|
|
14102
|
+
const { [f.key]: _dropped, ...rest } = d;
|
|
14103
|
+
return rest;
|
|
14104
|
+
});
|
|
14105
|
+
read.reload();
|
|
14106
|
+
}
|
|
14107
|
+
},
|
|
14108
|
+
children: "Remove it"
|
|
14109
|
+
}
|
|
14110
|
+
),
|
|
14111
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_design_system39.Button, { size: "sm", variant: "ghost", onClick: () => setRemoving(null), children: "Keep it" })
|
|
14112
|
+
] }) : null,
|
|
13892
14113
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
13893
14114
|
FieldControl,
|
|
13894
14115
|
{
|
|
@@ -15541,10 +15762,10 @@ var import_design_system48 = require("@ai-matrx/design-system");
|
|
|
15541
15762
|
// src/RecordForm.tsx
|
|
15542
15763
|
var import_react86 = require("react");
|
|
15543
15764
|
var import_react87 = require("@ai-matrx/records/react");
|
|
15544
|
-
var
|
|
15765
|
+
var import_core14 = require("@ai-matrx/records/core");
|
|
15545
15766
|
|
|
15546
15767
|
// src/writeOnTheWinningVersion.ts
|
|
15547
|
-
var
|
|
15768
|
+
var import_core13 = require("@ai-matrx/records/core");
|
|
15548
15769
|
function sameStoredValue(left, right) {
|
|
15549
15770
|
if (left === right) return true;
|
|
15550
15771
|
const empty = (v) => v === null || v === void 0 || v === "";
|
|
@@ -15566,7 +15787,7 @@ async function updateOnTheWinningVersion(client, recordId, patch, expectedVersio
|
|
|
15566
15787
|
});
|
|
15567
15788
|
const first = await send(expectedVersion);
|
|
15568
15789
|
if (first.ok) return first;
|
|
15569
|
-
const conflict = (0,
|
|
15790
|
+
const conflict = (0, import_core13.asWriteConflict)(first.error, recordId);
|
|
15570
15791
|
if (!conflict) return first;
|
|
15571
15792
|
const untouched = base === "always" || Object.keys(patch).every((key) => sameStoredValue(conflict.contested_fields[key], base[key]));
|
|
15572
15793
|
if (!untouched) return first;
|
|
@@ -15803,7 +16024,7 @@ function RecordForm({
|
|
|
15803
16024
|
return out;
|
|
15804
16025
|
}, [draft]);
|
|
15805
16026
|
const predicted = (0, import_react86.useMemo)(
|
|
15806
|
-
() => fields.data ? (0,
|
|
16027
|
+
() => fields.data ? (0, import_core14.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
|
|
15807
16028
|
[fields.data, document2, recordType]
|
|
15808
16029
|
);
|
|
15809
16030
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(RefusalNotice, { error: fields.error, className });
|
|
@@ -15852,7 +16073,7 @@ function RecordForm({
|
|
|
15852
16073
|
setEdit({
|
|
15853
16074
|
saving: false,
|
|
15854
16075
|
error: answered2.ok ? null : answered2.error,
|
|
15855
|
-
conflict: answered2.ok ? null : (0,
|
|
16076
|
+
conflict: answered2.ok ? null : (0, import_core14.asWriteConflict)(answered2.error, recordId)
|
|
15856
16077
|
});
|
|
15857
16078
|
const moved = answered2.ok ? answered2.data : null;
|
|
15858
16079
|
if (moved !== null) {
|
|
@@ -15958,7 +16179,7 @@ function FieldRow({
|
|
|
15958
16179
|
}) {
|
|
15959
16180
|
const id = `field-${field2.id}`;
|
|
15960
16181
|
const storedWords = document2?.[field2.key];
|
|
15961
|
-
const whole = typeof storedWords === "string" ? (0,
|
|
16182
|
+
const whole = typeof storedWords === "string" ? (0, import_core14.wholeValueOf)(document2, field2.key) : null;
|
|
15962
16183
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: (0, import_design_system46.cn)("flex min-w-0 flex-col gap-1", whole && "sm:col-span-2"), children: [
|
|
15963
16184
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(FieldLabel, { field: field2, htmlFor: id, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ProvenanceBadge, { document: document2, fieldKey: field2.key }) }),
|
|
15964
16185
|
whole ? (
|
|
@@ -24460,7 +24681,7 @@ function SignBlock({ tableId, recordId, render, className }) {
|
|
|
24460
24681
|
var import_react144 = require("react");
|
|
24461
24682
|
var import_recharts = require("recharts");
|
|
24462
24683
|
var import_records24 = require("@ai-matrx/records");
|
|
24463
|
-
var
|
|
24684
|
+
var import_core15 = require("@ai-matrx/records/core");
|
|
24464
24685
|
var import_design_system74 = require("@ai-matrx/design-system");
|
|
24465
24686
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
24466
24687
|
var priorKey = (key) => `prior__${key}`;
|
|
@@ -24517,7 +24738,7 @@ function pretty(n) {
|
|
|
24517
24738
|
return Number.isInteger(n) ? n.toLocaleString() : n.toLocaleString(void 0, { maximumFractionDigits: 2 });
|
|
24518
24739
|
}
|
|
24519
24740
|
function asRefusal2(block) {
|
|
24520
|
-
return (0,
|
|
24741
|
+
return (0, import_core15.mapPgError)(
|
|
24521
24742
|
{
|
|
24522
24743
|
message: block.refused ?? "",
|
|
24523
24744
|
...block.sqlstate ? { code: block.sqlstate } : {}
|
|
@@ -27191,7 +27412,7 @@ function recordsDataSource(client, fallbackSchema = "custom") {
|
|
|
27191
27412
|
// src/TablesHome.tsx
|
|
27192
27413
|
var import_react170 = require("react");
|
|
27193
27414
|
var import_react171 = require("@ai-matrx/records/react");
|
|
27194
|
-
var
|
|
27415
|
+
var import_core17 = require("@ai-matrx/records/core");
|
|
27195
27416
|
var import_records30 = require("@ai-matrx/records");
|
|
27196
27417
|
var import_design_system86 = require("@ai-matrx/design-system");
|
|
27197
27418
|
|
|
@@ -27286,7 +27507,7 @@ function ExampleTables({
|
|
|
27286
27507
|
}
|
|
27287
27508
|
|
|
27288
27509
|
// src/createTable.ts
|
|
27289
|
-
var
|
|
27510
|
+
var import_core16 = require("@ai-matrx/records/core");
|
|
27290
27511
|
|
|
27291
27512
|
// src/WhereItLives.tsx
|
|
27292
27513
|
var import_react168 = require("react");
|
|
@@ -27565,7 +27786,7 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, classNa
|
|
|
27565
27786
|
};
|
|
27566
27787
|
}, [client]);
|
|
27567
27788
|
const listed = facts.phase === "read" ? (0, import_records30.withTablePlacement)(
|
|
27568
|
-
(0,
|
|
27789
|
+
(0, import_core17.withTableFacts)(tables.data ?? [], facts.rows, me),
|
|
27569
27790
|
facts.rows
|
|
27570
27791
|
) : tables.data ?? [];
|
|
27571
27792
|
const [showEverything, setShowEverything] = (0, import_react170.useState)(false);
|
|
@@ -27609,7 +27830,7 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, classNa
|
|
|
27609
27830
|
if (!trimmed) return;
|
|
27610
27831
|
setBusy(true);
|
|
27611
27832
|
setError(null);
|
|
27612
|
-
const result = await (0,
|
|
27833
|
+
const result = await (0, import_core16.declareTable)(client, { name: trimmed, slug: (0, import_core16.tokenFor)(trimmed) });
|
|
27613
27834
|
setBusy(false);
|
|
27614
27835
|
if (!result.ok) {
|
|
27615
27836
|
setError(result.error);
|