@ai-matrx/records-ui 0.59.0 → 0.60.0
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/dist/index.cjs +795 -632
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +685 -522
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -51,6 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
ChecklistTemplateEditor: () => ChecklistTemplateEditor,
|
|
52
52
|
ChecklistsPanel: () => ChecklistsPanel,
|
|
53
53
|
CommentThread: () => CommentThread,
|
|
54
|
+
ConditionGroup: () => ConditionGroup,
|
|
54
55
|
ConditionRow: () => ConditionRow,
|
|
55
56
|
CustomFieldsSection: () => CustomFieldsSection,
|
|
56
57
|
DEFAULT_FIELDS: () => DEFAULT_FIELDS,
|
|
@@ -165,6 +166,7 @@ __export(src_exports, {
|
|
|
165
166
|
colorFromTheValue: () => colorFromTheValue,
|
|
166
167
|
columnForField: () => columnForField,
|
|
167
168
|
conditionInWords: () => conditionInWords,
|
|
169
|
+
conditionIsDrawable: () => conditionIsDrawable,
|
|
168
170
|
conditionIsSimple: () => conditionIsSimple,
|
|
169
171
|
conditionValue: () => conditionValue,
|
|
170
172
|
controlFor: () => controlFor,
|
|
@@ -513,11 +515,17 @@ function recordName(document2, titleKey, fallback = "Untitled") {
|
|
|
513
515
|
);
|
|
514
516
|
for (const key of keys) {
|
|
515
517
|
const value = data[key];
|
|
516
|
-
if (typeof value === "string" && value.trim() !== ""
|
|
518
|
+
if (typeof value === "string" && value.trim() !== "" && !looksLikeId(value.trim())) {
|
|
519
|
+
return value.trim();
|
|
520
|
+
}
|
|
517
521
|
if (typeof value === "number") return String(value);
|
|
518
522
|
}
|
|
519
523
|
return fallback;
|
|
520
524
|
}
|
|
525
|
+
var RECORD_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
526
|
+
function looksLikeId(value) {
|
|
527
|
+
return typeof value === "string" && RECORD_ID.test(value.trim());
|
|
528
|
+
}
|
|
521
529
|
function rowName(row, titleKey, fallback = "Untitled") {
|
|
522
530
|
return recordName(row?.document, titleKey, fallback);
|
|
523
531
|
}
|
|
@@ -4961,11 +4969,12 @@ function ValueOnTheOtherSide({
|
|
|
4961
4969
|
}
|
|
4962
4970
|
|
|
4963
4971
|
// src/StageRules.tsx
|
|
4964
|
-
var
|
|
4965
|
-
var
|
|
4972
|
+
var import_react30 = require("react");
|
|
4973
|
+
var import_react31 = require("@ai-matrx/records/react");
|
|
4966
4974
|
var import_design_system15 = require("@ai-matrx/design-system");
|
|
4967
4975
|
|
|
4968
4976
|
// src/Condition.tsx
|
|
4977
|
+
var import_react29 = require("react");
|
|
4969
4978
|
var import_design_system14 = require("@ai-matrx/design-system");
|
|
4970
4979
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4971
4980
|
var CONDITION_OPS = [
|
|
@@ -5095,6 +5104,155 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
|
|
|
5095
5104
|
] }) : null
|
|
5096
5105
|
] });
|
|
5097
5106
|
}
|
|
5107
|
+
var JOINERS = [
|
|
5108
|
+
{ op: "and", label: "All of these are true" },
|
|
5109
|
+
{ op: "or", label: "Any of these is true" }
|
|
5110
|
+
];
|
|
5111
|
+
function asNode(expr) {
|
|
5112
|
+
return expr && typeof expr === "object" && !Array.isArray(expr) ? expr : null;
|
|
5113
|
+
}
|
|
5114
|
+
function groupOf(expr) {
|
|
5115
|
+
const node = asNode(expr);
|
|
5116
|
+
if (!node) return null;
|
|
5117
|
+
const op = node["op"];
|
|
5118
|
+
if (op !== "and" && op !== "or") return null;
|
|
5119
|
+
const args = Array.isArray(node["args"]) ? node["args"] : [];
|
|
5120
|
+
return { op, args };
|
|
5121
|
+
}
|
|
5122
|
+
function conditionIsDrawable(expr, depth = 1) {
|
|
5123
|
+
if (expr === null || expr === void 0) return true;
|
|
5124
|
+
const group = groupOf(expr);
|
|
5125
|
+
if (!group) return conditionIsSimple(expr);
|
|
5126
|
+
if (group.args.length === 0) return true;
|
|
5127
|
+
return group.args.every((arg) => {
|
|
5128
|
+
const node = asNode(arg);
|
|
5129
|
+
if (node === null) return false;
|
|
5130
|
+
return conditionIsSimple(node) || depth > 0 && conditionIsDrawable(node, depth - 1);
|
|
5131
|
+
});
|
|
5132
|
+
}
|
|
5133
|
+
function clausesOf(expr) {
|
|
5134
|
+
const group = groupOf(expr);
|
|
5135
|
+
if (group) return group;
|
|
5136
|
+
return { op: "and", args: expr === null || expr === void 0 ? [] : [expr] };
|
|
5137
|
+
}
|
|
5138
|
+
function writeGroup(op, args) {
|
|
5139
|
+
const kept = args.filter((a) => a !== null && a !== void 0);
|
|
5140
|
+
if (kept.length === 0) return null;
|
|
5141
|
+
if (kept.length === 1) return kept[0];
|
|
5142
|
+
return { op, args: kept };
|
|
5143
|
+
}
|
|
5144
|
+
function ConditionGroup({
|
|
5145
|
+
lead,
|
|
5146
|
+
expr,
|
|
5147
|
+
fields,
|
|
5148
|
+
onChange,
|
|
5149
|
+
emptyLabel = "always",
|
|
5150
|
+
allowNesting = true,
|
|
5151
|
+
className
|
|
5152
|
+
}) {
|
|
5153
|
+
const { op, args } = clausesOf(expr);
|
|
5154
|
+
const [drafting, setDrafting] = (0, import_react29.useState)(false);
|
|
5155
|
+
const replaceAt = (index, next) => {
|
|
5156
|
+
const nextArgs = args.slice();
|
|
5157
|
+
if (next === null || next === void 0) nextArgs.splice(index, 1);
|
|
5158
|
+
else nextArgs[index] = next;
|
|
5159
|
+
onChange(writeGroup(op, nextArgs));
|
|
5160
|
+
};
|
|
5161
|
+
const joinWord = (index) => index === 0 ? lead : op === "and" ? "and" : "or";
|
|
5162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: className ?? "flex flex-col gap-1 text-xs", "data-testid": "condition-group", children: [
|
|
5163
|
+
args.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
5164
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-muted-foreground", children: lead }),
|
|
5165
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5166
|
+
"select",
|
|
5167
|
+
{
|
|
5168
|
+
"aria-label": "How these conditions are joined",
|
|
5169
|
+
className: "h-8 rounded border bg-background px-1 text-xs",
|
|
5170
|
+
value: op,
|
|
5171
|
+
onChange: (e) => onChange(writeGroup(e.target.value, args)),
|
|
5172
|
+
children: JOINERS.map((j) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: j.op, children: j.label }, j.op))
|
|
5173
|
+
}
|
|
5174
|
+
)
|
|
5175
|
+
] }) : null,
|
|
5176
|
+
args.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5177
|
+
ConditionRow,
|
|
5178
|
+
{
|
|
5179
|
+
lead,
|
|
5180
|
+
emptyLabel,
|
|
5181
|
+
expr: null,
|
|
5182
|
+
fields,
|
|
5183
|
+
onChange: (next) => onChange(next)
|
|
5184
|
+
}
|
|
5185
|
+
) : args.map((arg, index) => {
|
|
5186
|
+
const nested = groupOf(arg);
|
|
5187
|
+
const key = `clause-${index}`;
|
|
5188
|
+
if (nested && allowNesting) {
|
|
5189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "ml-4 rounded border border-dashed p-1", "data-testid": "condition-nested-group", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5190
|
+
ConditionGroup,
|
|
5191
|
+
{
|
|
5192
|
+
lead: op === "and" ? "and also, any of:" : "or, all of:",
|
|
5193
|
+
expr: arg,
|
|
5194
|
+
fields,
|
|
5195
|
+
onChange: (next) => replaceAt(index, next),
|
|
5196
|
+
emptyLabel,
|
|
5197
|
+
allowNesting: false
|
|
5198
|
+
}
|
|
5199
|
+
) }, key);
|
|
5200
|
+
}
|
|
5201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5202
|
+
ConditionRow,
|
|
5203
|
+
{
|
|
5204
|
+
lead: args.length > 1 ? joinWord(index) : lead,
|
|
5205
|
+
emptyLabel,
|
|
5206
|
+
expr: arg,
|
|
5207
|
+
fields,
|
|
5208
|
+
onChange: (next) => replaceAt(index, next)
|
|
5209
|
+
},
|
|
5210
|
+
key
|
|
5211
|
+
);
|
|
5212
|
+
}),
|
|
5213
|
+
drafting ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5214
|
+
ConditionRow,
|
|
5215
|
+
{
|
|
5216
|
+
lead: op === "and" ? "and" : "or",
|
|
5217
|
+
emptyLabel,
|
|
5218
|
+
expr: null,
|
|
5219
|
+
fields,
|
|
5220
|
+
onChange: (next) => {
|
|
5221
|
+
if (next === null) return;
|
|
5222
|
+
setDrafting(false);
|
|
5223
|
+
onChange(writeGroup(op, [...args, next]));
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
) : null,
|
|
5227
|
+
args.length > 0 && !drafting ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
5228
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5229
|
+
import_design_system14.Button,
|
|
5230
|
+
{
|
|
5231
|
+
size: "sm",
|
|
5232
|
+
variant: "ghost",
|
|
5233
|
+
className: "h-6 px-1 text-xs",
|
|
5234
|
+
"data-testid": "condition-add-clause",
|
|
5235
|
+
onClick: () => setDrafting(true),
|
|
5236
|
+
children: "Add another condition"
|
|
5237
|
+
}
|
|
5238
|
+
),
|
|
5239
|
+
allowNesting && args.length > 1 && !args.some((a) => groupOf(a) !== null) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5240
|
+
import_design_system14.Button,
|
|
5241
|
+
{
|
|
5242
|
+
size: "sm",
|
|
5243
|
+
variant: "ghost",
|
|
5244
|
+
className: "h-6 px-1 text-xs",
|
|
5245
|
+
"data-testid": "condition-add-group",
|
|
5246
|
+
onClick: () => replaceAt(args.length - 1, {
|
|
5247
|
+
op: op === "and" ? "or" : "and",
|
|
5248
|
+
args: [args[args.length - 1]]
|
|
5249
|
+
}),
|
|
5250
|
+
children: "Group the last one"
|
|
5251
|
+
}
|
|
5252
|
+
) : null
|
|
5253
|
+
] }) : null
|
|
5254
|
+
] });
|
|
5255
|
+
}
|
|
5098
5256
|
|
|
5099
5257
|
// src/StageRules.tsx
|
|
5100
5258
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
@@ -5128,38 +5286,38 @@ function draftOf(rule) {
|
|
|
5128
5286
|
};
|
|
5129
5287
|
}
|
|
5130
5288
|
function StageRulesSection({ tableId, stage, className }) {
|
|
5131
|
-
const client = (0,
|
|
5132
|
-
const table = (0,
|
|
5289
|
+
const client = (0, import_react31.useRecordsClient)();
|
|
5290
|
+
const table = (0, import_react31.useTable)(tableId);
|
|
5133
5291
|
const rights = useTableRights(table.data);
|
|
5134
|
-
const fields = (0,
|
|
5135
|
-
const [pipeline, setPipeline] = (0,
|
|
5136
|
-
const [enforcement, setEnforcement] = (0,
|
|
5137
|
-
const [asked, setAsked] = (0,
|
|
5138
|
-
const [error, setError] = (0,
|
|
5139
|
-
const [chosen, setChosen] = (0,
|
|
5140
|
-
const [draft, setDraft] = (0,
|
|
5141
|
-
const [preview, setPreview] = (0,
|
|
5142
|
-
const [previewError, setPreviewError] = (0,
|
|
5143
|
-
const [saving, setSaving] = (0,
|
|
5144
|
-
const load = (0,
|
|
5292
|
+
const fields = (0, import_react31.useFields)(tableId);
|
|
5293
|
+
const [pipeline, setPipeline] = (0, import_react30.useState)(null);
|
|
5294
|
+
const [enforcement, setEnforcement] = (0, import_react30.useState)(null);
|
|
5295
|
+
const [asked, setAsked] = (0, import_react30.useState)(false);
|
|
5296
|
+
const [error, setError] = (0, import_react30.useState)(null);
|
|
5297
|
+
const [chosen, setChosen] = (0, import_react30.useState)(stage ?? null);
|
|
5298
|
+
const [draft, setDraft] = (0, import_react30.useState)(null);
|
|
5299
|
+
const [preview, setPreview] = (0, import_react30.useState)(null);
|
|
5300
|
+
const [previewError, setPreviewError] = (0, import_react30.useState)(null);
|
|
5301
|
+
const [saving, setSaving] = (0, import_react30.useState)(false);
|
|
5302
|
+
const load = (0, import_react30.useCallback)(async () => {
|
|
5145
5303
|
const [read, mode] = await Promise.all([client.pipelineRead({ table_id: tableId }), client.stageRuleEnforcement()]);
|
|
5146
5304
|
if (!read.ok) setError(read.error);
|
|
5147
5305
|
else setPipeline(read.data);
|
|
5148
5306
|
if (mode.ok) setEnforcement(mode.data);
|
|
5149
5307
|
setAsked(true);
|
|
5150
5308
|
}, [client, tableId]);
|
|
5151
|
-
(0,
|
|
5309
|
+
(0, import_react30.useEffect)(() => {
|
|
5152
5310
|
void load();
|
|
5153
5311
|
}, [load]);
|
|
5154
5312
|
const stages = pipeline?.stages ?? [];
|
|
5155
5313
|
const stageKey = chosen ?? stages.find((s) => !s.retired)?.key ?? null;
|
|
5156
5314
|
const stageLabel = stages.find((s) => s.key === stageKey)?.label ?? stageKey ?? "";
|
|
5157
|
-
const gates = (0,
|
|
5158
|
-
const conditionFields = (0,
|
|
5315
|
+
const gates = (0, import_react30.useMemo)(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
|
|
5316
|
+
const conditionFields = (0, import_react30.useMemo)(
|
|
5159
5317
|
() => (fields.data ?? []).map((f) => ({ id: String(f.id), key: f.key, label: fieldName(f) })),
|
|
5160
5318
|
[fields.data]
|
|
5161
5319
|
);
|
|
5162
|
-
(0,
|
|
5320
|
+
(0, import_react30.useEffect)(() => {
|
|
5163
5321
|
if (!draft || !stageKey || !draft.demands || Object.keys(draft.demands).length === 0) {
|
|
5164
5322
|
setPreview(null);
|
|
5165
5323
|
setPreviewError(null);
|
|
@@ -5342,15 +5500,15 @@ function Clause({
|
|
|
5342
5500
|
fields,
|
|
5343
5501
|
onChange
|
|
5344
5502
|
}) {
|
|
5345
|
-
const [replacing, setReplacing] = (0,
|
|
5346
|
-
const drawable =
|
|
5503
|
+
const [replacing, setReplacing] = (0, import_react30.useState)(false);
|
|
5504
|
+
const drawable = conditionIsDrawable(expr) || replacing;
|
|
5347
5505
|
if (drawable) {
|
|
5348
5506
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
5349
|
-
|
|
5507
|
+
ConditionGroup,
|
|
5350
5508
|
{
|
|
5351
5509
|
lead,
|
|
5352
5510
|
emptyLabel,
|
|
5353
|
-
expr: replacing && !
|
|
5511
|
+
expr: replacing && !conditionIsDrawable(expr) ? null : expr,
|
|
5354
5512
|
fields,
|
|
5355
5513
|
onChange
|
|
5356
5514
|
}
|
|
@@ -5381,8 +5539,8 @@ function Clause({
|
|
|
5381
5539
|
}
|
|
5382
5540
|
|
|
5383
5541
|
// src/TableSettings.tsx
|
|
5384
|
-
var
|
|
5385
|
-
var
|
|
5542
|
+
var import_react32 = require("react");
|
|
5543
|
+
var import_react33 = require("@ai-matrx/records/react");
|
|
5386
5544
|
var import_design_system16 = require("@ai-matrx/design-system");
|
|
5387
5545
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5388
5546
|
function TableSettings({
|
|
@@ -5393,15 +5551,15 @@ function TableSettings({
|
|
|
5393
5551
|
onDeleted,
|
|
5394
5552
|
className
|
|
5395
5553
|
}) {
|
|
5396
|
-
const table = (0,
|
|
5397
|
-
const fields = (0,
|
|
5554
|
+
const table = (0, import_react33.useTable)(tableId);
|
|
5555
|
+
const fields = (0, import_react33.useFields)(tableId);
|
|
5398
5556
|
const rights = useTableRights(table.data);
|
|
5399
|
-
const mutation = (0,
|
|
5400
|
-
const shape = (0,
|
|
5401
|
-
const [editing, setEditing] = (0,
|
|
5402
|
-
const [askingToDelete, setAskingToDelete] = (0,
|
|
5403
|
-
const [askingToRemove, setAskingToRemove] = (0,
|
|
5404
|
-
const [enriching, setEnriching] = (0,
|
|
5557
|
+
const mutation = (0, import_react33.useRecordMutation)();
|
|
5558
|
+
const shape = (0, import_react33.useFieldMutation)();
|
|
5559
|
+
const [editing, setEditing] = (0, import_react32.useState)(null);
|
|
5560
|
+
const [askingToDelete, setAskingToDelete] = (0, import_react32.useState)(false);
|
|
5561
|
+
const [askingToRemove, setAskingToRemove] = (0, import_react32.useState)(null);
|
|
5562
|
+
const [enriching, setEnriching] = (0, import_react32.useState)(null);
|
|
5405
5563
|
if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalNotice, { error: table.error, className });
|
|
5406
5564
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalNotice, { error: fields.error, className });
|
|
5407
5565
|
if (!rights.structure) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: (0, import_design_system16.cn)("text-xs text-muted-foreground", className), children: rights.why("structure") });
|
|
@@ -5572,22 +5730,22 @@ function TableSettings({
|
|
|
5572
5730
|
}
|
|
5573
5731
|
|
|
5574
5732
|
// src/Peek.tsx
|
|
5575
|
-
var
|
|
5576
|
-
var
|
|
5577
|
-
var
|
|
5733
|
+
var import_react41 = require("react");
|
|
5734
|
+
var import_react42 = require("@ai-matrx/records/react");
|
|
5735
|
+
var import_react43 = require("@ai-matrx/alchemy/react");
|
|
5578
5736
|
|
|
5579
5737
|
// src/RecordChat.tsx
|
|
5580
|
-
var
|
|
5581
|
-
var
|
|
5738
|
+
var import_react34 = require("react");
|
|
5739
|
+
var import_react35 = require("@ai-matrx/records/react");
|
|
5582
5740
|
var import_design_system17 = require("@ai-matrx/design-system");
|
|
5583
5741
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
5584
5742
|
var NO_CHAT_REASON = "No chat port is bound, so this panel is absent rather than showing a composer that goes nowhere. Bind `chat` on <RecordsUiProvider> with your host's own chat surface \u2014 in AI Matrx that is `AgentConversationColumn`, launched through a Mandate \u2014 and this panel becomes that surface with this record as its context. This package deliberately ships no second chat UI.";
|
|
5585
5743
|
function RecordChat({ tableId, recordId, className }) {
|
|
5586
|
-
const client = (0,
|
|
5744
|
+
const client = (0, import_react35.useRecordsClient)();
|
|
5587
5745
|
const host = useRecordsUi();
|
|
5588
|
-
const [scope, setScope] = (0,
|
|
5589
|
-
const [error, setError] = (0,
|
|
5590
|
-
(0,
|
|
5746
|
+
const [scope, setScope] = (0, import_react34.useState)(null);
|
|
5747
|
+
const [error, setError] = (0, import_react34.useState)(null);
|
|
5748
|
+
(0, import_react34.useEffect)(() => {
|
|
5591
5749
|
let cancelled = false;
|
|
5592
5750
|
setScope(null);
|
|
5593
5751
|
setError(null);
|
|
@@ -5603,7 +5761,7 @@ function RecordChat({ tableId, recordId, className }) {
|
|
|
5603
5761
|
cancelled = true;
|
|
5604
5762
|
};
|
|
5605
5763
|
}, [client, recordId]);
|
|
5606
|
-
const context = (0,
|
|
5764
|
+
const context = (0, import_react34.useMemo)(() => {
|
|
5607
5765
|
if (!scope) return null;
|
|
5608
5766
|
return {
|
|
5609
5767
|
surfaceKey: `records-ui:record-chat:${recordId}`,
|
|
@@ -5704,14 +5862,14 @@ function entriesFor(scope) {
|
|
|
5704
5862
|
var import_design_system20 = require("@ai-matrx/design-system");
|
|
5705
5863
|
|
|
5706
5864
|
// src/RecordForm.tsx
|
|
5707
|
-
var
|
|
5708
|
-
var
|
|
5865
|
+
var import_react38 = require("react");
|
|
5866
|
+
var import_react39 = require("@ai-matrx/records/react");
|
|
5709
5867
|
var import_core5 = require("@ai-matrx/records/core");
|
|
5710
5868
|
var import_design_system18 = require("@ai-matrx/design-system");
|
|
5711
5869
|
|
|
5712
5870
|
// src/systemTable.ts
|
|
5713
|
-
var
|
|
5714
|
-
var
|
|
5871
|
+
var import_react36 = require("react");
|
|
5872
|
+
var import_react37 = require("@ai-matrx/records/react");
|
|
5715
5873
|
var inFlight = /* @__PURE__ */ new Map();
|
|
5716
5874
|
async function ensureSystemTable(client, spec) {
|
|
5717
5875
|
const cacheKey = `${client.config.organizationId}:${spec.slug}`;
|
|
@@ -5839,11 +5997,11 @@ async function declare(client, spec) {
|
|
|
5839
5997
|
return { ok: true, data: table.data };
|
|
5840
5998
|
}
|
|
5841
5999
|
function useSystemTable(spec) {
|
|
5842
|
-
const client = (0,
|
|
5843
|
-
const [state, setState] = (0,
|
|
6000
|
+
const client = (0, import_react37.useRecordsClient)();
|
|
6001
|
+
const [state, setState] = (0, import_react36.useState)({ tableId: null, loading: true, error: null });
|
|
5844
6002
|
const slug = spec.slug;
|
|
5845
|
-
const stable = (0,
|
|
5846
|
-
(0,
|
|
6003
|
+
const stable = (0, import_react36.useMemo)(() => spec, [slug]);
|
|
6004
|
+
(0, import_react36.useEffect)(() => {
|
|
5847
6005
|
let cancelled = false;
|
|
5848
6006
|
setState({ tableId: null, loading: true, error: null });
|
|
5849
6007
|
void ensureSystemTable(client, stable).then((result) => {
|
|
@@ -5859,9 +6017,9 @@ function useSystemTable(spec) {
|
|
|
5859
6017
|
return state;
|
|
5860
6018
|
}
|
|
5861
6019
|
function useRecordVersion(recordId) {
|
|
5862
|
-
const client = (0,
|
|
5863
|
-
const [version, setVersion] = (0,
|
|
5864
|
-
(0,
|
|
6020
|
+
const client = (0, import_react37.useRecordsClient)();
|
|
6021
|
+
const [version, setVersion] = (0, import_react36.useState)(null);
|
|
6022
|
+
(0, import_react36.useEffect)(() => {
|
|
5865
6023
|
let cancelled = false;
|
|
5866
6024
|
setVersion(null);
|
|
5867
6025
|
if (!recordId) return;
|
|
@@ -5891,18 +6049,18 @@ function RecordForm({
|
|
|
5891
6049
|
className
|
|
5892
6050
|
}) {
|
|
5893
6051
|
const host = useRecordsUi();
|
|
5894
|
-
const fields = (0,
|
|
5895
|
-
const existing = (0,
|
|
5896
|
-
const mutation = (0,
|
|
5897
|
-
const [draft, setDraft] = (0,
|
|
5898
|
-
const [touched, setTouched] = (0,
|
|
6052
|
+
const fields = (0, import_react39.useFields)(tableId, recordType);
|
|
6053
|
+
const existing = (0, import_react39.useRecord)(recordId ?? null);
|
|
6054
|
+
const mutation = (0, import_react39.useRecordMutation)();
|
|
6055
|
+
const [draft, setDraft] = (0, import_react38.useState)({});
|
|
6056
|
+
const [touched, setTouched] = (0, import_react38.useState)(false);
|
|
5899
6057
|
const loaded = useRecordVersion(recordId ?? null);
|
|
5900
6058
|
const loadedVersion = loaded.version;
|
|
5901
|
-
(0,
|
|
6059
|
+
(0, import_react38.useEffect)(() => {
|
|
5902
6060
|
const document3 = existing.data?.document;
|
|
5903
6061
|
if (document3) setDraft({ ...document3 });
|
|
5904
6062
|
}, [existing.data?.record_id, loadedVersion]);
|
|
5905
|
-
const document2 = (0,
|
|
6063
|
+
const document2 = (0, import_react38.useMemo)(() => {
|
|
5906
6064
|
const out = {};
|
|
5907
6065
|
for (const [key, value] of Object.entries(draft)) {
|
|
5908
6066
|
if (key.startsWith("_")) continue;
|
|
@@ -5910,7 +6068,7 @@ function RecordForm({
|
|
|
5910
6068
|
}
|
|
5911
6069
|
return out;
|
|
5912
6070
|
}, [draft]);
|
|
5913
|
-
const predicted = (0,
|
|
6071
|
+
const predicted = (0, import_react38.useMemo)(
|
|
5914
6072
|
() => fields.data ? (0, import_core5.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
|
|
5915
6073
|
[fields.data, document2, recordType]
|
|
5916
6074
|
);
|
|
@@ -6025,7 +6183,7 @@ function asWords(value) {
|
|
|
6025
6183
|
}
|
|
6026
6184
|
|
|
6027
6185
|
// src/ShareControl.tsx
|
|
6028
|
-
var
|
|
6186
|
+
var import_react40 = require("react");
|
|
6029
6187
|
var import_design_system19 = require("@ai-matrx/design-system");
|
|
6030
6188
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
6031
6189
|
function useCanShare() {
|
|
@@ -6045,7 +6203,7 @@ function ShareControl({
|
|
|
6045
6203
|
className
|
|
6046
6204
|
}) {
|
|
6047
6205
|
const host = useRecordsUi();
|
|
6048
|
-
const [open, setOpen] = (0,
|
|
6206
|
+
const [open, setOpen] = (0, import_react40.useState)(false);
|
|
6049
6207
|
const asked = useRecordRights(may === void 0 ? subjectId : null);
|
|
6050
6208
|
const mayShare = may ?? asked.share;
|
|
6051
6209
|
if (!host.share) return null;
|
|
@@ -6077,14 +6235,14 @@ function ShareControl({
|
|
|
6077
6235
|
// src/Peek.tsx
|
|
6078
6236
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6079
6237
|
function Peek({ tableId, recordId, onClose, className }) {
|
|
6080
|
-
const table = (0,
|
|
6081
|
-
const fields = (0,
|
|
6082
|
-
const record = (0,
|
|
6238
|
+
const table = (0, import_react42.useTable)(tableId);
|
|
6239
|
+
const fields = (0, import_react42.useFields)(tableId);
|
|
6240
|
+
const record = (0, import_react42.useRecord)(recordId, true);
|
|
6083
6241
|
const may = useRecordRights(recordId);
|
|
6084
6242
|
const host = useRecordsUi();
|
|
6085
|
-
const organizationId = (0,
|
|
6086
|
-
const [editing, setEditing] = (0,
|
|
6087
|
-
const [talking, setTalking] = (0,
|
|
6243
|
+
const organizationId = (0, import_react42.useRecordsClient)().config.organizationId;
|
|
6244
|
+
const [editing, setEditing] = (0, import_react41.useState)(false);
|
|
6245
|
+
const [talking, setTalking] = (0, import_react41.useState)(false);
|
|
6088
6246
|
if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalNotice, { error: record.error, className });
|
|
6089
6247
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalNotice, { error: fields.error, className });
|
|
6090
6248
|
const document2 = record.data?.document;
|
|
@@ -6094,7 +6252,7 @@ function Peek({ tableId, recordId, onClose, className }) {
|
|
|
6094
6252
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6095
6253
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h3", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: record.loading && !document2 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system20.Skeleton, { className: "h-4 w-40" }) : title }),
|
|
6096
6254
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6097
|
-
|
|
6255
|
+
import_react43.AlchemyMenu,
|
|
6098
6256
|
{
|
|
6099
6257
|
label: title || "Record",
|
|
6100
6258
|
sourceId: `record:${recordId}`,
|
|
@@ -6287,13 +6445,13 @@ function parseSorts(raw) {
|
|
|
6287
6445
|
}
|
|
6288
6446
|
|
|
6289
6447
|
// src/ViewSwitcher.tsx
|
|
6290
|
-
var
|
|
6291
|
-
var
|
|
6448
|
+
var import_react46 = require("react");
|
|
6449
|
+
var import_react47 = require("@ai-matrx/records/react");
|
|
6292
6450
|
var import_design_system22 = require("@ai-matrx/design-system");
|
|
6293
6451
|
|
|
6294
6452
|
// src/Pipeline.tsx
|
|
6295
|
-
var
|
|
6296
|
-
var
|
|
6453
|
+
var import_react44 = require("react");
|
|
6454
|
+
var import_react45 = require("@ai-matrx/records/react");
|
|
6297
6455
|
var import_design_system21 = require("@ai-matrx/design-system");
|
|
6298
6456
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
6299
6457
|
var UNPLACED = "\0unplaced";
|
|
@@ -6326,24 +6484,24 @@ function PipelineBoard({
|
|
|
6326
6484
|
onMoved,
|
|
6327
6485
|
className
|
|
6328
6486
|
}) {
|
|
6329
|
-
const client = (0,
|
|
6330
|
-
const fields = (0,
|
|
6331
|
-
const [definition, setDefinition] = (0,
|
|
6332
|
-
const [columns, setColumns] = (0,
|
|
6333
|
-
const [error, setError] = (0,
|
|
6334
|
-
const [loading, setLoading] = (0,
|
|
6335
|
-
const [pending, setPending] = (0,
|
|
6336
|
-
const [waiting, setWaiting] = (0,
|
|
6337
|
-
const [dragging, setDragging] = (0,
|
|
6338
|
-
const [over, setOver] = (0,
|
|
6339
|
-
const alive = (0,
|
|
6340
|
-
(0,
|
|
6487
|
+
const client = (0, import_react45.useRecordsClient)();
|
|
6488
|
+
const fields = (0, import_react45.useFields)(tableId);
|
|
6489
|
+
const [definition, setDefinition] = (0, import_react44.useState)(null);
|
|
6490
|
+
const [columns, setColumns] = (0, import_react44.useState)([]);
|
|
6491
|
+
const [error, setError] = (0, import_react44.useState)(null);
|
|
6492
|
+
const [loading, setLoading] = (0, import_react44.useState)(true);
|
|
6493
|
+
const [pending, setPending] = (0, import_react44.useState)({ kind: "none" });
|
|
6494
|
+
const [waiting, setWaiting] = (0, import_react44.useState)(/* @__PURE__ */ new Map());
|
|
6495
|
+
const [dragging, setDragging] = (0, import_react44.useState)(null);
|
|
6496
|
+
const [over, setOver] = (0, import_react44.useState)(null);
|
|
6497
|
+
const alive = (0, import_react44.useRef)(true);
|
|
6498
|
+
(0, import_react44.useEffect)(() => {
|
|
6341
6499
|
alive.current = true;
|
|
6342
6500
|
return () => {
|
|
6343
6501
|
alive.current = false;
|
|
6344
6502
|
};
|
|
6345
6503
|
}, []);
|
|
6346
|
-
const reload = (0,
|
|
6504
|
+
const reload = (0, import_react44.useCallback)(async () => {
|
|
6347
6505
|
setLoading(true);
|
|
6348
6506
|
const [read, board, held] = await Promise.all([
|
|
6349
6507
|
client.pipelineRead({ table_id: tableId }),
|
|
@@ -6361,11 +6519,11 @@ function PipelineBoard({
|
|
|
6361
6519
|
setWaiting(held.ok ? new Map((held.data ?? []).map((p) => [p.record_id, p])) : /* @__PURE__ */ new Map());
|
|
6362
6520
|
setColumns(board.ok ? board.data ?? [] : []);
|
|
6363
6521
|
}, [client, tableId, measure]);
|
|
6364
|
-
(0,
|
|
6522
|
+
(0, import_react44.useEffect)(() => {
|
|
6365
6523
|
void reload();
|
|
6366
6524
|
}, [reload]);
|
|
6367
6525
|
const stageKey = definition?.stage_field ?? null;
|
|
6368
|
-
const cardsByStage = (0,
|
|
6526
|
+
const cardsByStage = (0, import_react44.useMemo)(() => {
|
|
6369
6527
|
const map = /* @__PURE__ */ new Map();
|
|
6370
6528
|
if (!stageKey) return map;
|
|
6371
6529
|
for (const row of rows) {
|
|
@@ -6376,15 +6534,16 @@ function PipelineBoard({
|
|
|
6376
6534
|
}, [rows, stageKey, definition?.stages]);
|
|
6377
6535
|
const unplaced = cardsByStage.get(UNPLACED) ?? [];
|
|
6378
6536
|
const all = fields.data ?? [];
|
|
6379
|
-
const titleField = (0,
|
|
6537
|
+
const titleField = (0, import_react44.useMemo)(
|
|
6380
6538
|
() => all.find((f) => f.key !== stageKey) ?? all[0],
|
|
6381
6539
|
[all, stageKey]
|
|
6382
6540
|
);
|
|
6383
|
-
const
|
|
6541
|
+
const unplacedLabels = useRecordLabels(titleField ? [titleField] : []);
|
|
6542
|
+
const measurable = (0, import_react44.useMemo)(
|
|
6384
6543
|
() => all.filter((f) => ["number", "currency", "percentage"].includes(String(f.type ?? ""))),
|
|
6385
6544
|
[all]
|
|
6386
6545
|
);
|
|
6387
|
-
const drop = (0,
|
|
6546
|
+
const drop = (0, import_react44.useCallback)(
|
|
6388
6547
|
async (recordId, to) => {
|
|
6389
6548
|
setOver(null);
|
|
6390
6549
|
setDragging(null);
|
|
@@ -6423,7 +6582,7 @@ function PipelineBoard({
|
|
|
6423
6582
|
},
|
|
6424
6583
|
[client, onMoved, reload]
|
|
6425
6584
|
);
|
|
6426
|
-
const askForApproval = (0,
|
|
6585
|
+
const askForApproval = (0, import_react44.useCallback)(
|
|
6427
6586
|
async (recordId, to) => {
|
|
6428
6587
|
const moved = await client.pipelineMove({ record_id: recordId, to });
|
|
6429
6588
|
if (!alive.current) return;
|
|
@@ -6437,7 +6596,7 @@ function PipelineBoard({
|
|
|
6437
6596
|
},
|
|
6438
6597
|
[client, reload]
|
|
6439
6598
|
);
|
|
6440
|
-
const moveWith = (0,
|
|
6599
|
+
const moveWith = (0, import_react44.useCallback)(
|
|
6441
6600
|
async (recordId, to, also) => {
|
|
6442
6601
|
const moved = await client.pipelineMove({ record_id: recordId, to, also });
|
|
6443
6602
|
if (!alive.current) return;
|
|
@@ -6550,7 +6709,7 @@ function PipelineBoard({
|
|
|
6550
6709
|
unplaced.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { className: "text-xs text-muted-foreground", "data-testid": "pipeline-unplaced", children: [
|
|
6551
6710
|
unplaced.length === 1 ? "One record is" : `${unplaced.length} records are`,
|
|
6552
6711
|
" not in any of these columns \u2014 ",
|
|
6553
|
-
unplaced.slice(0, 3).map((r) =>
|
|
6712
|
+
unplaced.slice(0, 3).map((r) => unplacedName(r, titleField, unplacedLabels)).join(", "),
|
|
6554
6713
|
unplaced.length > 3 ? ` and ${unplaced.length - 3} more` : "",
|
|
6555
6714
|
". Their stage is not one this pipeline offers, so nothing here can draw them; open one from the grid to move it."
|
|
6556
6715
|
] }) : null
|
|
@@ -6566,7 +6725,7 @@ function Held({
|
|
|
6566
6725
|
onFill,
|
|
6567
6726
|
onAsk
|
|
6568
6727
|
}) {
|
|
6569
|
-
const [draft, setDraft] = (0,
|
|
6728
|
+
const [draft, setDraft] = (0, import_react44.useState)({});
|
|
6570
6729
|
if (pending.kind === "asking") {
|
|
6571
6730
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "px-2 py-1 text-xs text-muted-foreground", children: "Asking\u2026" });
|
|
6572
6731
|
}
|
|
@@ -6653,7 +6812,7 @@ function Card({
|
|
|
6653
6812
|
stages
|
|
6654
6813
|
}) {
|
|
6655
6814
|
const labels = useRecordLabels(field ? [field] : []);
|
|
6656
|
-
const draggable = (0,
|
|
6815
|
+
const draggable = (0, import_react45.mayDrag)(record.level);
|
|
6657
6816
|
const label = field ? scalarText(field, (record.document ?? {})[field.key], labels) : rowName(record, null, "Untitled");
|
|
6658
6817
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
6659
6818
|
"button",
|
|
@@ -6687,20 +6846,24 @@ function Card({
|
|
|
6687
6846
|
}
|
|
6688
6847
|
);
|
|
6689
6848
|
}
|
|
6849
|
+
function unplacedName(record, field, labels) {
|
|
6850
|
+
if (!field) return rowName(record, null, "Untitled");
|
|
6851
|
+
return scalarText(field, (record.document ?? {})[field.key], labels);
|
|
6852
|
+
}
|
|
6690
6853
|
|
|
6691
6854
|
// src/ViewSwitcher.tsx
|
|
6692
6855
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
6693
6856
|
var NO_FIELDS = [];
|
|
6694
6857
|
function useViewRecords(view, pageSize = 200) {
|
|
6695
|
-
const client = (0,
|
|
6696
|
-
const table = (0,
|
|
6697
|
-
const [ruled, setRuled] = (0,
|
|
6858
|
+
const client = (0, import_react47.useRecordsClient)();
|
|
6859
|
+
const table = (0, import_react47.useRecords)(view.ruleId ? null : view.subject, { pageSize });
|
|
6860
|
+
const [ruled, setRuled] = (0, import_react46.useState)({
|
|
6698
6861
|
rows: [],
|
|
6699
6862
|
loading: Boolean(view.ruleId),
|
|
6700
6863
|
error: null
|
|
6701
6864
|
});
|
|
6702
6865
|
const ruleId = view.ruleId ?? null;
|
|
6703
|
-
(0,
|
|
6866
|
+
(0, import_react46.useEffect)(() => {
|
|
6704
6867
|
if (!ruleId) return;
|
|
6705
6868
|
let cancelled = false;
|
|
6706
6869
|
setRuled({ rows: [], loading: true, error: null });
|
|
@@ -6750,9 +6913,9 @@ function ViewSwitcher({
|
|
|
6750
6913
|
pageSize = 200,
|
|
6751
6914
|
className
|
|
6752
6915
|
}) {
|
|
6753
|
-
const [layout, setLayout] = (0,
|
|
6754
|
-
const [local, setLocal] = (0,
|
|
6755
|
-
(0,
|
|
6916
|
+
const [layout, setLayout] = (0, import_react46.useState)(view.layout);
|
|
6917
|
+
const [local, setLocal] = (0, import_react46.useState)({});
|
|
6918
|
+
(0, import_react46.useEffect)(() => {
|
|
6756
6919
|
setLayout(view.layout);
|
|
6757
6920
|
setLocal({});
|
|
6758
6921
|
}, [view.layout, view.name, view.subject]);
|
|
@@ -6812,12 +6975,12 @@ function offerableFields(all, want) {
|
|
|
6812
6975
|
});
|
|
6813
6976
|
}
|
|
6814
6977
|
function useStageField(tableId) {
|
|
6815
|
-
const client = (0,
|
|
6816
|
-
const [stage, setStage] = (0,
|
|
6978
|
+
const client = (0, import_react47.useRecordsClient)();
|
|
6979
|
+
const [stage, setStage] = (0, import_react46.useState)({
|
|
6817
6980
|
asked: false,
|
|
6818
6981
|
key: null
|
|
6819
6982
|
});
|
|
6820
|
-
(0,
|
|
6983
|
+
(0, import_react46.useEffect)(() => {
|
|
6821
6984
|
let cancelled = false;
|
|
6822
6985
|
setStage({ asked: false, key: null });
|
|
6823
6986
|
void client.tableStageField({ table_id: tableId }).then((r) => {
|
|
@@ -6848,7 +7011,7 @@ function Board({
|
|
|
6848
7011
|
onOpenRecord,
|
|
6849
7012
|
onMoved
|
|
6850
7013
|
}) {
|
|
6851
|
-
const fields = (0,
|
|
7014
|
+
const fields = (0, import_react47.useFields)(view.subject);
|
|
6852
7015
|
const records = useViewRecords(view, pageSize);
|
|
6853
7016
|
const stage = useStageField(view.subject);
|
|
6854
7017
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: fields.error });
|
|
@@ -6958,9 +7121,9 @@ function Kanban({
|
|
|
6958
7121
|
onOpenRecord,
|
|
6959
7122
|
note
|
|
6960
7123
|
}) {
|
|
6961
|
-
const groupFields = (0,
|
|
7124
|
+
const groupFields = (0, import_react46.useMemo)(() => [groupField], [groupField]);
|
|
6962
7125
|
const labels = useRecordLabels(groupFields);
|
|
6963
|
-
const columns = (0,
|
|
7126
|
+
const columns = (0, import_react46.useMemo)(() => {
|
|
6964
7127
|
const map = /* @__PURE__ */ new Map();
|
|
6965
7128
|
for (const row of rows) {
|
|
6966
7129
|
const raw = (row.document ?? {})[groupField.key];
|
|
@@ -6987,7 +7150,7 @@ function Calendar({
|
|
|
6987
7150
|
onOpenRecord,
|
|
6988
7151
|
note
|
|
6989
7152
|
}) {
|
|
6990
|
-
const { days, undated } = (0,
|
|
7153
|
+
const { days, undated } = (0, import_react46.useMemo)(() => {
|
|
6991
7154
|
const byDay = /* @__PURE__ */ new Map();
|
|
6992
7155
|
const without = [];
|
|
6993
7156
|
for (const row of rows) {
|
|
@@ -7060,7 +7223,7 @@ function Card2({
|
|
|
7060
7223
|
onOpenRecord
|
|
7061
7224
|
}) {
|
|
7062
7225
|
const host = useRecordsUi();
|
|
7063
|
-
const wanted = (0,
|
|
7226
|
+
const wanted = (0, import_react46.useMemo)(
|
|
7064
7227
|
() => field && pointsAtRecords(field) ? [field] : NO_FIELDS,
|
|
7065
7228
|
[field]
|
|
7066
7229
|
);
|
|
@@ -7082,15 +7245,15 @@ function Card2({
|
|
|
7082
7245
|
}
|
|
7083
7246
|
|
|
7084
7247
|
// src/ViewBar.tsx
|
|
7085
|
-
var
|
|
7086
|
-
var
|
|
7248
|
+
var import_react49 = require("react");
|
|
7249
|
+
var import_react50 = require("@ai-matrx/records/react");
|
|
7087
7250
|
var import_design_system23 = require("@ai-matrx/design-system");
|
|
7088
7251
|
|
|
7089
7252
|
// src/seedOnce.ts
|
|
7090
|
-
var
|
|
7253
|
+
var import_react48 = require("react");
|
|
7091
7254
|
function useSeedGuard() {
|
|
7092
|
-
const claimed = (0,
|
|
7093
|
-
return (0,
|
|
7255
|
+
const claimed = (0, import_react48.useRef)(/* @__PURE__ */ new Set());
|
|
7256
|
+
return (0, import_react48.useCallback)((name) => {
|
|
7094
7257
|
if (claimed.current.has(name)) return false;
|
|
7095
7258
|
claimed.current.add(name);
|
|
7096
7259
|
return true;
|
|
@@ -7098,22 +7261,22 @@ function useSeedGuard() {
|
|
|
7098
7261
|
}
|
|
7099
7262
|
|
|
7100
7263
|
// src/ViewBar.tsx
|
|
7101
|
-
var
|
|
7264
|
+
var import_react51 = require("@ai-matrx/records/react");
|
|
7102
7265
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
7103
7266
|
var SAVED_VIEWS_UNAVAILABLE = "Saved views are not available in this organization right now, so the layout you pick here is not being kept. Everything else on this table works as usual.";
|
|
7104
7267
|
function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
|
|
7105
|
-
const client = (0,
|
|
7268
|
+
const client = (0, import_react50.useRecordsClient)();
|
|
7106
7269
|
const claimSeed = useSeedGuard();
|
|
7107
|
-
const table = (0,
|
|
7270
|
+
const table = (0, import_react51.useTable)(tableId);
|
|
7108
7271
|
const rights = useTableRights(table.data);
|
|
7109
7272
|
const home = useSystemTable(VIEW_TABLE);
|
|
7110
|
-
const [views, setViews] = (0,
|
|
7111
|
-
const [error, setError] = (0,
|
|
7112
|
-
const [active, setActive] = (0,
|
|
7113
|
-
const [naming, setNaming] = (0,
|
|
7114
|
-
const [draftName, setDraftName] = (0,
|
|
7273
|
+
const [views, setViews] = (0, import_react49.useState)(null);
|
|
7274
|
+
const [error, setError] = (0, import_react49.useState)(null);
|
|
7275
|
+
const [active, setActive] = (0, import_react49.useState)(activeViewId ?? null);
|
|
7276
|
+
const [naming, setNaming] = (0, import_react49.useState)(false);
|
|
7277
|
+
const [draftName, setDraftName] = (0, import_react49.useState)("");
|
|
7115
7278
|
const viewTableId = home.tableId;
|
|
7116
|
-
const load = (0,
|
|
7279
|
+
const load = (0, import_react49.useCallback)(async () => {
|
|
7117
7280
|
if (!viewTableId) return;
|
|
7118
7281
|
const result = await client.list({ table_id: viewTableId, limit: 500 });
|
|
7119
7282
|
if (!result.ok) {
|
|
@@ -7145,10 +7308,10 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
|
|
|
7145
7308
|
setError(null);
|
|
7146
7309
|
setViews(mine);
|
|
7147
7310
|
}, [client, viewTableId, tableId, seed]);
|
|
7148
|
-
(0,
|
|
7311
|
+
(0, import_react49.useEffect)(() => {
|
|
7149
7312
|
void load();
|
|
7150
7313
|
}, [load]);
|
|
7151
|
-
(0,
|
|
7314
|
+
(0, import_react49.useEffect)(() => {
|
|
7152
7315
|
if (!views || views.length === 0) return;
|
|
7153
7316
|
const chosen = views.find((v) => v.id === (activeViewId ?? active)) ?? views.find((v) => v.isDefault) ?? views[0];
|
|
7154
7317
|
if (chosen.id !== active) setActive(chosen.id);
|
|
@@ -7222,8 +7385,8 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
|
|
|
7222
7385
|
}
|
|
7223
7386
|
|
|
7224
7387
|
// src/ProposalRow.tsx
|
|
7225
|
-
var
|
|
7226
|
-
var
|
|
7388
|
+
var import_react52 = require("react");
|
|
7389
|
+
var import_react53 = require("@ai-matrx/records/react");
|
|
7227
7390
|
var import_design_system24 = require("@ai-matrx/design-system");
|
|
7228
7391
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
7229
7392
|
var ACT_WORD = {
|
|
@@ -7240,10 +7403,10 @@ function ProposalRow({
|
|
|
7240
7403
|
onSettled,
|
|
7241
7404
|
className
|
|
7242
7405
|
}) {
|
|
7243
|
-
const client = (0,
|
|
7244
|
-
const [settled, setSettled] = (0,
|
|
7245
|
-
const [busy, setBusy] = (0,
|
|
7246
|
-
const [confirming, setConfirming] = (0,
|
|
7406
|
+
const client = (0, import_react53.useRecordsClient)();
|
|
7407
|
+
const [settled, setSettled] = (0, import_react52.useState)(outcome ?? null);
|
|
7408
|
+
const [busy, setBusy] = (0, import_react52.useState)(false);
|
|
7409
|
+
const [confirming, setConfirming] = (0, import_react52.useState)(false);
|
|
7247
7410
|
async function applyThroughTheStore() {
|
|
7248
7411
|
if (change.act === "add") {
|
|
7249
7412
|
if (!change.table) {
|
|
@@ -7328,13 +7491,13 @@ function ProposalRow({
|
|
|
7328
7491
|
}
|
|
7329
7492
|
|
|
7330
7493
|
// src/ActionInbox.tsx
|
|
7331
|
-
var
|
|
7332
|
-
var
|
|
7494
|
+
var import_react56 = require("react");
|
|
7495
|
+
var import_react57 = require("@ai-matrx/records/react");
|
|
7333
7496
|
var import_design_system26 = require("@ai-matrx/design-system");
|
|
7334
7497
|
|
|
7335
7498
|
// src/ChecklistRunner.tsx
|
|
7336
|
-
var
|
|
7337
|
-
var
|
|
7499
|
+
var import_react54 = require("react");
|
|
7500
|
+
var import_react55 = require("@ai-matrx/records/react");
|
|
7338
7501
|
var import_design_system25 = require("@ai-matrx/design-system");
|
|
7339
7502
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
7340
7503
|
var DUE_WORD = {
|
|
@@ -7361,18 +7524,18 @@ function ChecklistRunner({
|
|
|
7361
7524
|
offerToStart,
|
|
7362
7525
|
className
|
|
7363
7526
|
}) {
|
|
7364
|
-
const client = (0,
|
|
7365
|
-
const table = (0,
|
|
7527
|
+
const client = (0, import_react55.useRecordsClient)();
|
|
7528
|
+
const table = (0, import_react55.useTable)(tableId ?? null);
|
|
7366
7529
|
const rights = useTableRights(table.data);
|
|
7367
|
-
const [runs, setRuns] = (0,
|
|
7368
|
-
const [activeId, setActiveId] = (0,
|
|
7369
|
-
const [steps, setSteps] = (0,
|
|
7370
|
-
const [templates, setTemplates] = (0,
|
|
7371
|
-
const [error, setError] = (0,
|
|
7372
|
-
const [busy, setBusy] = (0,
|
|
7373
|
-
const [said, setSaid] = (0,
|
|
7530
|
+
const [runs, setRuns] = (0, import_react54.useState)(null);
|
|
7531
|
+
const [activeId, setActiveId] = (0, import_react54.useState)(runId ?? null);
|
|
7532
|
+
const [steps, setSteps] = (0, import_react54.useState)(null);
|
|
7533
|
+
const [templates, setTemplates] = (0, import_react54.useState)(null);
|
|
7534
|
+
const [error, setError] = (0, import_react54.useState)(null);
|
|
7535
|
+
const [busy, setBusy] = (0, import_react54.useState)(null);
|
|
7536
|
+
const [said, setSaid] = (0, import_react54.useState)(null);
|
|
7374
7537
|
const mayStart = offerToStart ?? Boolean(recordId);
|
|
7375
|
-
const loadRuns = (0,
|
|
7538
|
+
const loadRuns = (0, import_react54.useCallback)(async () => {
|
|
7376
7539
|
if (runId) {
|
|
7377
7540
|
setRuns(null);
|
|
7378
7541
|
return;
|
|
@@ -7394,13 +7557,13 @@ function ChecklistRunner({
|
|
|
7394
7557
|
(held) => held && answered.data.some((r) => r.run_id === held) ? held : answered.data[0]?.run_id ?? null
|
|
7395
7558
|
);
|
|
7396
7559
|
}, [client, includeClosed, recordId, runId, tableId]);
|
|
7397
|
-
(0,
|
|
7560
|
+
(0, import_react54.useEffect)(() => {
|
|
7398
7561
|
void loadRuns();
|
|
7399
7562
|
}, [loadRuns]);
|
|
7400
|
-
(0,
|
|
7563
|
+
(0, import_react54.useEffect)(() => {
|
|
7401
7564
|
if (runId) setActiveId(runId);
|
|
7402
7565
|
}, [runId]);
|
|
7403
|
-
const loadSteps = (0,
|
|
7566
|
+
const loadSteps = (0, import_react54.useCallback)(async () => {
|
|
7404
7567
|
if (!activeId) {
|
|
7405
7568
|
setSteps(null);
|
|
7406
7569
|
return;
|
|
@@ -7414,10 +7577,10 @@ function ChecklistRunner({
|
|
|
7414
7577
|
setError(null);
|
|
7415
7578
|
setSteps(answered.data);
|
|
7416
7579
|
}, [client, activeId]);
|
|
7417
|
-
(0,
|
|
7580
|
+
(0, import_react54.useEffect)(() => {
|
|
7418
7581
|
void loadSteps();
|
|
7419
7582
|
}, [loadSteps]);
|
|
7420
|
-
(0,
|
|
7583
|
+
(0, import_react54.useEffect)(() => {
|
|
7421
7584
|
if (!mayStart || !tableId) return;
|
|
7422
7585
|
let cancelled = false;
|
|
7423
7586
|
void client.checklistTemplates({ about_table_id: tableId, limit: 50 }).then((answered) => {
|
|
@@ -7428,7 +7591,7 @@ function ChecklistRunner({
|
|
|
7428
7591
|
cancelled = true;
|
|
7429
7592
|
};
|
|
7430
7593
|
}, [client, mayStart, tableId]);
|
|
7431
|
-
const start = (0,
|
|
7594
|
+
const start = (0, import_react54.useCallback)(
|
|
7432
7595
|
async (templateId) => {
|
|
7433
7596
|
setBusy(templateId);
|
|
7434
7597
|
setSaid(null);
|
|
@@ -7450,7 +7613,7 @@ function ChecklistRunner({
|
|
|
7450
7613
|
},
|
|
7451
7614
|
[client, loadRuns, recordId]
|
|
7452
7615
|
);
|
|
7453
|
-
const complete = (0,
|
|
7616
|
+
const complete = (0, import_react54.useCallback)(
|
|
7454
7617
|
async (step2, evidence) => {
|
|
7455
7618
|
setBusy(step2.step_id);
|
|
7456
7619
|
setSaid(null);
|
|
@@ -7467,7 +7630,7 @@ function ChecklistRunner({
|
|
|
7467
7630
|
},
|
|
7468
7631
|
[client, loadSteps, loadRuns]
|
|
7469
7632
|
);
|
|
7470
|
-
const active = (0,
|
|
7633
|
+
const active = (0, import_react54.useMemo)(
|
|
7471
7634
|
() => runs?.find((r) => r.run_id === activeId) ?? null,
|
|
7472
7635
|
[runs, activeId]
|
|
7473
7636
|
);
|
|
@@ -7537,7 +7700,7 @@ function StepRow({
|
|
|
7537
7700
|
onComplete,
|
|
7538
7701
|
className
|
|
7539
7702
|
}) {
|
|
7540
|
-
const [answer, setAnswer] = (0,
|
|
7703
|
+
const [answer, setAnswer] = (0, import_react54.useState)("");
|
|
7541
7704
|
const key = step2.requires_key ?? (step2.requires === "note" ? "note" : null);
|
|
7542
7705
|
const asksHere = step2.requires === "note" || step2.requires === "answer";
|
|
7543
7706
|
const needsAnswer = asksHere && answer.trim().length === 0;
|
|
@@ -7610,12 +7773,12 @@ function StepRow({
|
|
|
7610
7773
|
);
|
|
7611
7774
|
}
|
|
7612
7775
|
function useMyChecklistSteps(limit = 25) {
|
|
7613
|
-
const client = (0,
|
|
7776
|
+
const client = (0, import_react55.useRecordsClient)();
|
|
7614
7777
|
const me = client.config.actor.user_id ?? null;
|
|
7615
|
-
const [steps, setSteps] = (0,
|
|
7616
|
-
const [loading, setLoading] = (0,
|
|
7617
|
-
const [error, setError] = (0,
|
|
7618
|
-
const refresh = (0,
|
|
7778
|
+
const [steps, setSteps] = (0, import_react54.useState)([]);
|
|
7779
|
+
const [loading, setLoading] = (0, import_react54.useState)(true);
|
|
7780
|
+
const [error, setError] = (0, import_react54.useState)(null);
|
|
7781
|
+
const refresh = (0, import_react54.useCallback)(async () => {
|
|
7619
7782
|
if (!me) {
|
|
7620
7783
|
setSteps([]);
|
|
7621
7784
|
setLoading(false);
|
|
@@ -7643,17 +7806,17 @@ function useMyChecklistSteps(limit = 25) {
|
|
|
7643
7806
|
setSteps(held);
|
|
7644
7807
|
setLoading(false);
|
|
7645
7808
|
}, [client, limit, me]);
|
|
7646
|
-
(0,
|
|
7809
|
+
(0, import_react54.useEffect)(() => {
|
|
7647
7810
|
void refresh();
|
|
7648
7811
|
}, [refresh]);
|
|
7649
7812
|
return { steps, loading, error, refresh };
|
|
7650
7813
|
}
|
|
7651
7814
|
function MyChecklistSteps({ className }) {
|
|
7652
|
-
const client = (0,
|
|
7815
|
+
const client = (0, import_react55.useRecordsClient)();
|
|
7653
7816
|
const { steps, loading, error, refresh } = useMyChecklistSteps();
|
|
7654
|
-
const [busy, setBusy] = (0,
|
|
7655
|
-
const [refusal, setRefusal] = (0,
|
|
7656
|
-
const complete = (0,
|
|
7817
|
+
const [busy, setBusy] = (0, import_react54.useState)(null);
|
|
7818
|
+
const [refusal, setRefusal] = (0, import_react54.useState)(null);
|
|
7819
|
+
const complete = (0, import_react54.useCallback)(
|
|
7657
7820
|
async (step2, evidence) => {
|
|
7658
7821
|
setBusy(step2.step_id);
|
|
7659
7822
|
const answered = await client.checklistStepComplete({ step_id: step2.step_id, evidence });
|
|
@@ -7688,15 +7851,15 @@ function MyChecklistSteps({ className }) {
|
|
|
7688
7851
|
] });
|
|
7689
7852
|
}
|
|
7690
7853
|
function ChecklistsPanel({ tableId, onOpenRecord, className }) {
|
|
7691
|
-
const client = (0,
|
|
7692
|
-
const table = (0,
|
|
7854
|
+
const client = (0, import_react55.useRecordsClient)();
|
|
7855
|
+
const table = (0, import_react55.useTable)(tableId);
|
|
7693
7856
|
const rights = useTableRights(table.data);
|
|
7694
|
-
const [templates, setTemplates] = (0,
|
|
7695
|
-
const [runs, setRuns] = (0,
|
|
7696
|
-
const [error, setError] = (0,
|
|
7697
|
-
const [editing, setEditing] = (0,
|
|
7698
|
-
const [openRun, setOpenRun] = (0,
|
|
7699
|
-
const load = (0,
|
|
7857
|
+
const [templates, setTemplates] = (0, import_react54.useState)(null);
|
|
7858
|
+
const [runs, setRuns] = (0, import_react54.useState)(null);
|
|
7859
|
+
const [error, setError] = (0, import_react54.useState)(null);
|
|
7860
|
+
const [editing, setEditing] = (0, import_react54.useState)(null);
|
|
7861
|
+
const [openRun, setOpenRun] = (0, import_react54.useState)(null);
|
|
7862
|
+
const load = (0, import_react54.useCallback)(async () => {
|
|
7700
7863
|
const [t, r] = await Promise.all([
|
|
7701
7864
|
client.checklistTemplates({ about_table_id: tableId, limit: 100 }),
|
|
7702
7865
|
client.checklistRuns({ about_table_id: tableId, includeClosed: true, limit: 100 })
|
|
@@ -7710,7 +7873,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
|
|
|
7710
7873
|
if (!r.ok) setRuns([]);
|
|
7711
7874
|
else setRuns(r.data);
|
|
7712
7875
|
}, [client, tableId]);
|
|
7713
|
-
(0,
|
|
7876
|
+
(0, import_react54.useEffect)(() => {
|
|
7714
7877
|
void load();
|
|
7715
7878
|
}, [load]);
|
|
7716
7879
|
if (templates === null) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system25.Skeleton, { className: (0, import_design_system25.cn)("h-40 w-full", className) });
|
|
@@ -7849,14 +8012,14 @@ function ChecklistTemplateEditor({
|
|
|
7849
8012
|
onDone,
|
|
7850
8013
|
className
|
|
7851
8014
|
}) {
|
|
7852
|
-
const client = (0,
|
|
7853
|
-
const [name, setName] = (0,
|
|
7854
|
-
const [rows, setRows] = (0,
|
|
7855
|
-
const [refusal, setRefusal] = (0,
|
|
7856
|
-
const [error, setError] = (0,
|
|
7857
|
-
const [busy, setBusy] = (0,
|
|
7858
|
-
const [loading, setLoading] = (0,
|
|
7859
|
-
(0,
|
|
8015
|
+
const client = (0, import_react55.useRecordsClient)();
|
|
8016
|
+
const [name, setName] = (0, import_react54.useState)("");
|
|
8017
|
+
const [rows, setRows] = (0, import_react54.useState)([{ ...EMPTY_ROW }]);
|
|
8018
|
+
const [refusal, setRefusal] = (0, import_react54.useState)(null);
|
|
8019
|
+
const [error, setError] = (0, import_react54.useState)(null);
|
|
8020
|
+
const [busy, setBusy] = (0, import_react54.useState)(false);
|
|
8021
|
+
const [loading, setLoading] = (0, import_react54.useState)(Boolean(templateId));
|
|
8022
|
+
(0, import_react54.useEffect)(() => {
|
|
7860
8023
|
if (!templateId) return;
|
|
7861
8024
|
let cancelled = false;
|
|
7862
8025
|
void client.checklistTemplateShape({ template_id: templateId }).then((answered) => {
|
|
@@ -7884,7 +8047,7 @@ function ChecklistTemplateEditor({
|
|
|
7884
8047
|
cancelled = true;
|
|
7885
8048
|
};
|
|
7886
8049
|
}, [client, templateId]);
|
|
7887
|
-
const spec = (0,
|
|
8050
|
+
const spec = (0, import_react54.useMemo)(
|
|
7888
8051
|
() => ({
|
|
7889
8052
|
name: name.trim(),
|
|
7890
8053
|
about_table_id: aboutTableId,
|
|
@@ -7893,7 +8056,7 @@ function ChecklistTemplateEditor({
|
|
|
7893
8056
|
}),
|
|
7894
8057
|
[aboutTableId, name, rows]
|
|
7895
8058
|
);
|
|
7896
|
-
(0,
|
|
8059
|
+
(0, import_react54.useEffect)(() => {
|
|
7897
8060
|
if (spec.steps.length === 0 || spec.name.length === 0) {
|
|
7898
8061
|
setRefusal(null);
|
|
7899
8062
|
return;
|
|
@@ -7907,7 +8070,7 @@ function ChecklistTemplateEditor({
|
|
|
7907
8070
|
cancelled = true;
|
|
7908
8071
|
};
|
|
7909
8072
|
}, [client, spec]);
|
|
7910
|
-
const save = (0,
|
|
8073
|
+
const save = (0, import_react54.useCallback)(async () => {
|
|
7911
8074
|
setBusy(true);
|
|
7912
8075
|
const answered = await client.checklistDeclare({
|
|
7913
8076
|
spec,
|
|
@@ -8072,14 +8235,14 @@ var DUE_WORD2 = {
|
|
|
8072
8235
|
finished: "Finished"
|
|
8073
8236
|
};
|
|
8074
8237
|
function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className }) {
|
|
8075
|
-
const client = (0,
|
|
8076
|
-
const [items, setItems] = (0,
|
|
8077
|
-
const [error, setError] = (0,
|
|
8078
|
-
const [outcome, setOutcome] = (0,
|
|
8079
|
-
const [busy, setBusy] = (0,
|
|
8080
|
-
const [cursor, setCursor] = (0,
|
|
8081
|
-
const listRef = (0,
|
|
8082
|
-
const load = (0,
|
|
8238
|
+
const client = (0, import_react57.useRecordsClient)();
|
|
8239
|
+
const [items, setItems] = (0, import_react56.useState)(null);
|
|
8240
|
+
const [error, setError] = (0, import_react56.useState)(null);
|
|
8241
|
+
const [outcome, setOutcome] = (0, import_react56.useState)({});
|
|
8242
|
+
const [busy, setBusy] = (0, import_react56.useState)(null);
|
|
8243
|
+
const [cursor, setCursor] = (0, import_react56.useState)(0);
|
|
8244
|
+
const listRef = (0, import_react56.useRef)(null);
|
|
8245
|
+
const load = (0, import_react56.useCallback)(async () => {
|
|
8083
8246
|
const result = await client.workInbox({ limit: 200, includeDecided: includeSettled });
|
|
8084
8247
|
if (!result.ok) {
|
|
8085
8248
|
setError(result.error);
|
|
@@ -8089,22 +8252,22 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
|
|
|
8089
8252
|
setError(null);
|
|
8090
8253
|
setItems(result.data);
|
|
8091
8254
|
}, [client, includeSettled]);
|
|
8092
|
-
(0,
|
|
8255
|
+
(0, import_react56.useEffect)(() => {
|
|
8093
8256
|
void load();
|
|
8094
8257
|
}, [load]);
|
|
8095
|
-
const shown = (0,
|
|
8258
|
+
const shown = (0, import_react56.useMemo)(() => {
|
|
8096
8259
|
const all = items ?? [];
|
|
8097
8260
|
if (!tableId) return all;
|
|
8098
8261
|
return all.filter((i) => i.kind !== "assignment" || i.subject_kind !== "record" || true);
|
|
8099
8262
|
}, [items, tableId]);
|
|
8100
|
-
(0,
|
|
8263
|
+
(0, import_react56.useEffect)(() => {
|
|
8101
8264
|
if (cursor >= shown.length) setCursor(Math.max(0, shown.length - 1));
|
|
8102
8265
|
}, [shown.length, cursor]);
|
|
8103
|
-
(0,
|
|
8266
|
+
(0, import_react56.useEffect)(() => {
|
|
8104
8267
|
const el = listRef.current?.querySelector(`[data-row="${cursor}"]`);
|
|
8105
8268
|
el?.scrollIntoView({ block: "nearest" });
|
|
8106
8269
|
}, [cursor, shown.length]);
|
|
8107
|
-
const decide = (0,
|
|
8270
|
+
const decide = (0, import_react56.useCallback)(
|
|
8108
8271
|
async (item, approve) => {
|
|
8109
8272
|
if (item.kind === "assignment") return;
|
|
8110
8273
|
setBusy(item.item_id);
|
|
@@ -8119,14 +8282,14 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
|
|
|
8119
8282
|
},
|
|
8120
8283
|
[client, load]
|
|
8121
8284
|
);
|
|
8122
|
-
const open = (0,
|
|
8285
|
+
const open = (0, import_react56.useCallback)(
|
|
8123
8286
|
(item) => {
|
|
8124
8287
|
if (!onOpenRecord || !item.subject_id) return;
|
|
8125
8288
|
onOpenRecord(item.subject_id, tableId ?? item.subject_id);
|
|
8126
8289
|
},
|
|
8127
8290
|
[onOpenRecord, tableId]
|
|
8128
8291
|
);
|
|
8129
|
-
const onKeyDown = (0,
|
|
8292
|
+
const onKeyDown = (0, import_react56.useCallback)(
|
|
8130
8293
|
(event) => {
|
|
8131
8294
|
const item = shown[cursor];
|
|
8132
8295
|
const key = event.key;
|
|
@@ -8226,22 +8389,22 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
|
|
|
8226
8389
|
}
|
|
8227
8390
|
|
|
8228
8391
|
// src/HistoryPanel.tsx
|
|
8229
|
-
var
|
|
8230
|
-
var
|
|
8392
|
+
var import_react58 = require("react");
|
|
8393
|
+
var import_react59 = require("@ai-matrx/records/react");
|
|
8231
8394
|
var import_design_system27 = require("@ai-matrx/design-system");
|
|
8232
8395
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
8233
8396
|
function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
|
|
8234
|
-
const client = (0,
|
|
8235
|
-
const table = (0,
|
|
8236
|
-
const fields = (0,
|
|
8397
|
+
const client = (0, import_react59.useRecordsClient)();
|
|
8398
|
+
const table = (0, import_react59.useTable)(tableId);
|
|
8399
|
+
const fields = (0, import_react59.useFields)(tableId);
|
|
8237
8400
|
const rights = useTableRights(table.data);
|
|
8238
|
-
const [entries, setEntries] = (0,
|
|
8239
|
-
const [error, setError] = (0,
|
|
8240
|
-
const [open, setOpen] = (0,
|
|
8241
|
-
const [pending, setPending] = (0,
|
|
8242
|
-
const [said, setSaid] = (0,
|
|
8243
|
-
const listRef = (0,
|
|
8244
|
-
const load = (0,
|
|
8401
|
+
const [entries, setEntries] = (0, import_react58.useState)(null);
|
|
8402
|
+
const [error, setError] = (0, import_react58.useState)(null);
|
|
8403
|
+
const [open, setOpen] = (0, import_react58.useState)(null);
|
|
8404
|
+
const [pending, setPending] = (0, import_react58.useState)({ phase: "idle" });
|
|
8405
|
+
const [said, setSaid] = (0, import_react58.useState)(null);
|
|
8406
|
+
const listRef = (0, import_react58.useRef)(null);
|
|
8407
|
+
const load = (0, import_react58.useCallback)(async () => {
|
|
8245
8408
|
const answered = await client.recordHistory({ record_id: recordId });
|
|
8246
8409
|
if (!answered.ok) {
|
|
8247
8410
|
setError(answered.error);
|
|
@@ -8250,7 +8413,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
|
|
|
8250
8413
|
setError(null);
|
|
8251
8414
|
setEntries(answered.data);
|
|
8252
8415
|
}, [client, recordId]);
|
|
8253
|
-
(0,
|
|
8416
|
+
(0, import_react58.useEffect)(() => {
|
|
8254
8417
|
void load();
|
|
8255
8418
|
}, [load]);
|
|
8256
8419
|
if (error) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RefusalNotice, { error, className });
|
|
@@ -8531,27 +8694,27 @@ function say(value, field) {
|
|
|
8531
8694
|
}
|
|
8532
8695
|
|
|
8533
8696
|
// src/CommentThread.tsx
|
|
8534
|
-
var
|
|
8535
|
-
var
|
|
8697
|
+
var import_react60 = require("react");
|
|
8698
|
+
var import_react61 = require("@ai-matrx/records/react");
|
|
8536
8699
|
var import_design_system28 = require("@ai-matrx/design-system");
|
|
8537
8700
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
8538
8701
|
function CommentThread({ tableId, recordId, fieldKey, className }) {
|
|
8539
|
-
const client = (0,
|
|
8540
|
-
const table = (0,
|
|
8541
|
-
const fields = (0,
|
|
8702
|
+
const client = (0, import_react61.useRecordsClient)();
|
|
8703
|
+
const table = (0, import_react61.useTable)(tableId);
|
|
8704
|
+
const fields = (0, import_react61.useFields)(tableId);
|
|
8542
8705
|
const host = useRecordsUi();
|
|
8543
|
-
const [thread, setThread] = (0,
|
|
8544
|
-
const [error, setError] = (0,
|
|
8545
|
-
const [draft, setDraft] = (0,
|
|
8546
|
-
const [replyTo, setReplyTo] = (0,
|
|
8547
|
-
const [busy, setBusy] = (0,
|
|
8548
|
-
const [said, setSaid] = (0,
|
|
8549
|
-
const [showResolved, setShowResolved] = (0,
|
|
8550
|
-
const [people, setPeople] = (0,
|
|
8551
|
-
const [mentionQuery, setMentionQuery] = (0,
|
|
8552
|
-
const [picked, setPicked] = (0,
|
|
8553
|
-
const box = (0,
|
|
8554
|
-
const load = (0,
|
|
8706
|
+
const [thread, setThread] = (0, import_react60.useState)(null);
|
|
8707
|
+
const [error, setError] = (0, import_react60.useState)(null);
|
|
8708
|
+
const [draft, setDraft] = (0, import_react60.useState)("");
|
|
8709
|
+
const [replyTo, setReplyTo] = (0, import_react60.useState)(null);
|
|
8710
|
+
const [busy, setBusy] = (0, import_react60.useState)(false);
|
|
8711
|
+
const [said, setSaid] = (0, import_react60.useState)(null);
|
|
8712
|
+
const [showResolved, setShowResolved] = (0, import_react60.useState)(false);
|
|
8713
|
+
const [people, setPeople] = (0, import_react60.useState)([]);
|
|
8714
|
+
const [mentionQuery, setMentionQuery] = (0, import_react60.useState)(null);
|
|
8715
|
+
const [picked, setPicked] = (0, import_react60.useState)([]);
|
|
8716
|
+
const box = (0, import_react60.useRef)(null);
|
|
8717
|
+
const load = (0, import_react60.useCallback)(async () => {
|
|
8555
8718
|
const answered = await client.commentThread({ record_id: recordId, include_resolved: showResolved });
|
|
8556
8719
|
if (!answered.ok) {
|
|
8557
8720
|
setError(answered.error);
|
|
@@ -8564,10 +8727,10 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
|
|
|
8564
8727
|
mayResolve: answered.data.may_resolve
|
|
8565
8728
|
});
|
|
8566
8729
|
}, [client, recordId, showResolved]);
|
|
8567
|
-
(0,
|
|
8730
|
+
(0, import_react60.useEffect)(() => {
|
|
8568
8731
|
void load();
|
|
8569
8732
|
}, [load]);
|
|
8570
|
-
(0,
|
|
8733
|
+
(0, import_react60.useEffect)(() => {
|
|
8571
8734
|
let alive = true;
|
|
8572
8735
|
if (!host.members) return;
|
|
8573
8736
|
void host.members().then((roster) => {
|
|
@@ -8584,7 +8747,7 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
|
|
|
8584
8747
|
alive = false;
|
|
8585
8748
|
};
|
|
8586
8749
|
}, [host]);
|
|
8587
|
-
const candidates = (0,
|
|
8750
|
+
const candidates = (0, import_react60.useMemo)(() => {
|
|
8588
8751
|
if (mentionQuery === null) return [];
|
|
8589
8752
|
const q = mentionQuery.trim().toLowerCase();
|
|
8590
8753
|
return people.filter((p) => !picked.some((already) => already.userId === p.userId)).filter((p) => q === "" || (p.name ?? p.email ?? "").toLowerCase().includes(q)).slice(0, 6);
|
|
@@ -8770,8 +8933,8 @@ function Line({
|
|
|
8770
8933
|
}
|
|
8771
8934
|
|
|
8772
8935
|
// src/FieldHistoryPanel.tsx
|
|
8773
|
-
var
|
|
8774
|
-
var
|
|
8936
|
+
var import_react62 = require("react");
|
|
8937
|
+
var import_react63 = require("@ai-matrx/records/react");
|
|
8775
8938
|
var import_design_system29 = require("@ai-matrx/design-system");
|
|
8776
8939
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
8777
8940
|
function FieldHistoryPanel({
|
|
@@ -8782,15 +8945,15 @@ function FieldHistoryPanel({
|
|
|
8782
8945
|
onOpenRecord,
|
|
8783
8946
|
className
|
|
8784
8947
|
}) {
|
|
8785
|
-
const client = (0,
|
|
8786
|
-
const table = (0,
|
|
8787
|
-
const fields = (0,
|
|
8948
|
+
const client = (0, import_react63.useRecordsClient)();
|
|
8949
|
+
const table = (0, import_react63.useTable)(tableId);
|
|
8950
|
+
const fields = (0, import_react63.useFields)(tableId);
|
|
8788
8951
|
const rights = useTableRights(table.data);
|
|
8789
|
-
const [rows, setRows] = (0,
|
|
8790
|
-
const [error, setError] = (0,
|
|
8791
|
-
const [pending, setPending] = (0,
|
|
8792
|
-
const [said, setSaid] = (0,
|
|
8793
|
-
const load = (0,
|
|
8952
|
+
const [rows, setRows] = (0, import_react62.useState)(null);
|
|
8953
|
+
const [error, setError] = (0, import_react62.useState)(null);
|
|
8954
|
+
const [pending, setPending] = (0, import_react62.useState)({ phase: "idle" });
|
|
8955
|
+
const [said, setSaid] = (0, import_react62.useState)(null);
|
|
8956
|
+
const load = (0, import_react62.useCallback)(async () => {
|
|
8794
8957
|
const answered = await client.fieldHistory(
|
|
8795
8958
|
recordId ? { table_id: tableId, field_key: fieldKey, record_id: recordId } : { table_id: tableId, field_key: fieldKey }
|
|
8796
8959
|
);
|
|
@@ -8801,7 +8964,7 @@ function FieldHistoryPanel({
|
|
|
8801
8964
|
setError(null);
|
|
8802
8965
|
setRows(answered.data);
|
|
8803
8966
|
}, [client, tableId, fieldKey, recordId]);
|
|
8804
|
-
(0,
|
|
8967
|
+
(0, import_react62.useEffect)(() => {
|
|
8805
8968
|
void load();
|
|
8806
8969
|
}, [load]);
|
|
8807
8970
|
const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanize(fieldKey);
|
|
@@ -8994,28 +9157,28 @@ function submissionStamp(args) {
|
|
|
8994
9157
|
}
|
|
8995
9158
|
|
|
8996
9159
|
// src/PortalBuilder.tsx
|
|
8997
|
-
var
|
|
8998
|
-
var
|
|
9160
|
+
var import_react64 = require("react");
|
|
9161
|
+
var import_react65 = require("@ai-matrx/records/react");
|
|
8999
9162
|
var import_design_system30 = require("@ai-matrx/design-system");
|
|
9000
9163
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
9001
9164
|
var RESTATING_REPLACES = "Saving replaces what this portal shows: a table you untick stops being visible to every client the moment you save. Who is invited is not touched.";
|
|
9002
9165
|
function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
|
|
9003
|
-
const client = (0,
|
|
9004
|
-
const tables = (0,
|
|
9005
|
-
const [title, setTitle] = (0,
|
|
9006
|
-
const [clientTableId, setClientTableId] = (0,
|
|
9007
|
-
const [exposures, setExposures] = (0,
|
|
9008
|
-
const [fieldsByTable, setFieldsByTable] = (0,
|
|
9009
|
-
const [error, setError] = (0,
|
|
9010
|
-
const [saving, setSaving] = (0,
|
|
9011
|
-
const [savedId, setSavedId] = (0,
|
|
9012
|
-
const [existing, setExisting] = (0,
|
|
9013
|
-
const [loading, setLoading] = (0,
|
|
9014
|
-
const [inviteEmail, setInviteEmail] = (0,
|
|
9015
|
-
const [inviteRecordId, setInviteRecordId] = (0,
|
|
9016
|
-
const [inviting, setInviting] = (0,
|
|
9017
|
-
const [invitationSaid, setInvitationSaid] = (0,
|
|
9018
|
-
const loadFields = (0,
|
|
9166
|
+
const client = (0, import_react65.useRecordsClient)();
|
|
9167
|
+
const tables = (0, import_react65.useTables)();
|
|
9168
|
+
const [title, setTitle] = (0, import_react64.useState)("");
|
|
9169
|
+
const [clientTableId, setClientTableId] = (0, import_react64.useState)(null);
|
|
9170
|
+
const [exposures, setExposures] = (0, import_react64.useState)({});
|
|
9171
|
+
const [fieldsByTable, setFieldsByTable] = (0, import_react64.useState)({});
|
|
9172
|
+
const [error, setError] = (0, import_react64.useState)(null);
|
|
9173
|
+
const [saving, setSaving] = (0, import_react64.useState)(false);
|
|
9174
|
+
const [savedId, setSavedId] = (0, import_react64.useState)(portalId ?? null);
|
|
9175
|
+
const [existing, setExisting] = (0, import_react64.useState)(null);
|
|
9176
|
+
const [loading, setLoading] = (0, import_react64.useState)(Boolean(portalId));
|
|
9177
|
+
const [inviteEmail, setInviteEmail] = (0, import_react64.useState)("");
|
|
9178
|
+
const [inviteRecordId, setInviteRecordId] = (0, import_react64.useState)("");
|
|
9179
|
+
const [inviting, setInviting] = (0, import_react64.useState)(false);
|
|
9180
|
+
const [invitationSaid, setInvitationSaid] = (0, import_react64.useState)(null);
|
|
9181
|
+
const loadFields = (0, import_react64.useCallback)(
|
|
9019
9182
|
async (id) => {
|
|
9020
9183
|
if (fieldsByTable[id]) return;
|
|
9021
9184
|
const answered = await client.fields({ table_id: id });
|
|
@@ -9027,7 +9190,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
|
|
|
9027
9190
|
},
|
|
9028
9191
|
[client, fieldsByTable]
|
|
9029
9192
|
);
|
|
9030
|
-
(0,
|
|
9193
|
+
(0, import_react64.useEffect)(() => {
|
|
9031
9194
|
if (!portalId) return;
|
|
9032
9195
|
void (async () => {
|
|
9033
9196
|
const answered = await client.portalCard({ portal_id: portalId });
|
|
@@ -9041,7 +9204,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
|
|
|
9041
9204
|
setClientTableId(answered.data.client_table_id);
|
|
9042
9205
|
})();
|
|
9043
9206
|
}, [client, portalId]);
|
|
9044
|
-
(0,
|
|
9207
|
+
(0, import_react64.useEffect)(() => {
|
|
9045
9208
|
if (!tableId) return;
|
|
9046
9209
|
setExposures(
|
|
9047
9210
|
(prev) => prev[tableId] ? prev : {
|
|
@@ -9051,8 +9214,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
|
|
|
9051
9214
|
);
|
|
9052
9215
|
void loadFields(tableId);
|
|
9053
9216
|
}, [tableId]);
|
|
9054
|
-
const ticked = (0,
|
|
9055
|
-
const tiesTo = (0,
|
|
9217
|
+
const ticked = (0, import_react64.useMemo)(() => Object.values(exposures).filter((e) => e.on), [exposures]);
|
|
9218
|
+
const tiesTo = (0, import_react64.useCallback)(
|
|
9056
9219
|
(id) => (fieldsByTable[id] ?? []).filter(
|
|
9057
9220
|
(f) => f.type === "relation" && f.relation_target === clientTableId
|
|
9058
9221
|
),
|
|
@@ -9289,8 +9452,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
|
|
|
9289
9452
|
}
|
|
9290
9453
|
|
|
9291
9454
|
// src/PortalsPanel.tsx
|
|
9292
|
-
var
|
|
9293
|
-
var
|
|
9455
|
+
var import_react66 = require("react");
|
|
9456
|
+
var import_react67 = require("@ai-matrx/records/react");
|
|
9294
9457
|
var import_records6 = require("@ai-matrx/records");
|
|
9295
9458
|
var import_design_system32 = require("@ai-matrx/design-system");
|
|
9296
9459
|
|
|
@@ -9355,13 +9518,13 @@ function stateWords(person) {
|
|
|
9355
9518
|
}
|
|
9356
9519
|
var PORTAL_SUGGESTION = "Let each of my customers sign in and see their own jobs and invoices, and nothing else.";
|
|
9357
9520
|
function PortalsPanel({ tableId, className }) {
|
|
9358
|
-
const client = (0,
|
|
9521
|
+
const client = (0, import_react67.useRecordsClient)();
|
|
9359
9522
|
const host = useRecordsUi();
|
|
9360
|
-
const [portals, setPortals] = (0,
|
|
9361
|
-
const [listError, setListError] = (0,
|
|
9362
|
-
const [openId, setOpenId] = (0,
|
|
9363
|
-
const [building, setBuilding] = (0,
|
|
9364
|
-
const load = (0,
|
|
9523
|
+
const [portals, setPortals] = (0, import_react66.useState)(null);
|
|
9524
|
+
const [listError, setListError] = (0, import_react66.useState)(null);
|
|
9525
|
+
const [openId, setOpenId] = (0, import_react66.useState)(null);
|
|
9526
|
+
const [building, setBuilding] = (0, import_react66.useState)(false);
|
|
9527
|
+
const load = (0, import_react66.useCallback)(async () => {
|
|
9365
9528
|
const answered = await client.portals();
|
|
9366
9529
|
if (!answered.ok) {
|
|
9367
9530
|
setListError(answered.error);
|
|
@@ -9371,7 +9534,7 @@ function PortalsPanel({ tableId, className }) {
|
|
|
9371
9534
|
setListError(null);
|
|
9372
9535
|
setPortals(answered.data);
|
|
9373
9536
|
}, [client]);
|
|
9374
|
-
(0,
|
|
9537
|
+
(0, import_react66.useEffect)(() => {
|
|
9375
9538
|
void load();
|
|
9376
9539
|
}, [load]);
|
|
9377
9540
|
if (portals === null) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_design_system32.Skeleton, { className: (0, import_design_system32.cn)("h-32 w-full", className) });
|
|
@@ -9453,8 +9616,8 @@ function PortalsPanel({ tableId, className }) {
|
|
|
9453
9616
|
] });
|
|
9454
9617
|
}
|
|
9455
9618
|
function CopyLink({ url }) {
|
|
9456
|
-
const [copied, setCopied] = (0,
|
|
9457
|
-
const [shown, setShown] = (0,
|
|
9619
|
+
const [copied, setCopied] = (0, import_react66.useState)(false);
|
|
9620
|
+
const [shown, setShown] = (0, import_react66.useState)(false);
|
|
9458
9621
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
9459
9622
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9460
9623
|
import_design_system32.Button,
|
|
@@ -9487,10 +9650,10 @@ function PortalDetail({
|
|
|
9487
9650
|
tableId,
|
|
9488
9651
|
onChanged
|
|
9489
9652
|
}) {
|
|
9490
|
-
const client = (0,
|
|
9491
|
-
const [card, setCard] = (0,
|
|
9492
|
-
const [error, setError] = (0,
|
|
9493
|
-
const load = (0,
|
|
9653
|
+
const client = (0, import_react67.useRecordsClient)();
|
|
9654
|
+
const [card, setCard] = (0, import_react66.useState)(null);
|
|
9655
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
9656
|
+
const load = (0, import_react66.useCallback)(async () => {
|
|
9494
9657
|
const answered = await client.portalCard({ portal_id: portalId });
|
|
9495
9658
|
if (!answered.ok) {
|
|
9496
9659
|
setError(answered.error);
|
|
@@ -9500,10 +9663,10 @@ function PortalDetail({
|
|
|
9500
9663
|
setError(null);
|
|
9501
9664
|
setCard(answered.data);
|
|
9502
9665
|
}, [client, portalId]);
|
|
9503
|
-
(0,
|
|
9666
|
+
(0, import_react66.useEffect)(() => {
|
|
9504
9667
|
void load();
|
|
9505
9668
|
}, [load]);
|
|
9506
|
-
const revoke = (0,
|
|
9669
|
+
const revoke = (0, import_react66.useCallback)(
|
|
9507
9670
|
async (person) => {
|
|
9508
9671
|
const answered = await client.portalRevoke({
|
|
9509
9672
|
portal_id: portalId,
|
|
@@ -9516,7 +9679,7 @@ function PortalDetail({
|
|
|
9516
9679
|
},
|
|
9517
9680
|
[client, load, onChanged, portalId]
|
|
9518
9681
|
);
|
|
9519
|
-
const preview = (0,
|
|
9682
|
+
const preview = (0, import_react66.useCallback)(
|
|
9520
9683
|
async (person, subject) => {
|
|
9521
9684
|
const answered = await client.portalPreview({
|
|
9522
9685
|
portal_id: portalId,
|
|
@@ -9598,12 +9761,12 @@ function People({
|
|
|
9598
9761
|
onRevoke,
|
|
9599
9762
|
onPreview
|
|
9600
9763
|
}) {
|
|
9601
|
-
const [askingToRevoke, setAskingToRevoke] = (0,
|
|
9602
|
-
const [busy, setBusy] = (0,
|
|
9603
|
-
const [said, setSaid] = (0,
|
|
9604
|
-
const [error, setError] = (0,
|
|
9605
|
-
const [previewing, setPreviewing] = (0,
|
|
9606
|
-
const revoke = (0,
|
|
9764
|
+
const [askingToRevoke, setAskingToRevoke] = (0, import_react66.useState)(null);
|
|
9765
|
+
const [busy, setBusy] = (0, import_react66.useState)(false);
|
|
9766
|
+
const [said, setSaid] = (0, import_react66.useState)(null);
|
|
9767
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
9768
|
+
const [previewing, setPreviewing] = (0, import_react66.useState)(null);
|
|
9769
|
+
const revoke = (0, import_react66.useCallback)(
|
|
9607
9770
|
async (person) => {
|
|
9608
9771
|
setBusy(true);
|
|
9609
9772
|
const answered = await onRevoke(person);
|
|
@@ -9680,10 +9843,10 @@ function Preview({
|
|
|
9680
9843
|
onPreview
|
|
9681
9844
|
}) {
|
|
9682
9845
|
const first = card.tables[0];
|
|
9683
|
-
const [which, setWhich] = (0,
|
|
9684
|
-
const [rows, setRows] = (0,
|
|
9685
|
-
const [error, setError] = (0,
|
|
9686
|
-
(0,
|
|
9846
|
+
const [which, setWhich] = (0, import_react66.useState)(first?.table_id ?? null);
|
|
9847
|
+
const [rows, setRows] = (0, import_react66.useState)(null);
|
|
9848
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
9849
|
+
(0, import_react66.useEffect)(() => {
|
|
9687
9850
|
if (!which) return;
|
|
9688
9851
|
let cancelled = false;
|
|
9689
9852
|
setRows(null);
|
|
@@ -9720,16 +9883,16 @@ function Preview({
|
|
|
9720
9883
|
] });
|
|
9721
9884
|
}
|
|
9722
9885
|
function Invite({ card, onInvited }) {
|
|
9723
|
-
const client = (0,
|
|
9724
|
-
const [rows, setRows] = (0,
|
|
9725
|
-
const [titleKey, setTitleKey] = (0,
|
|
9726
|
-
const [search, setSearch] = (0,
|
|
9727
|
-
const [picked, setPicked] = (0,
|
|
9728
|
-
const [email, setEmail] = (0,
|
|
9729
|
-
const [busy, setBusy] = (0,
|
|
9730
|
-
const [said, setSaid] = (0,
|
|
9731
|
-
const [error, setError] = (0,
|
|
9732
|
-
(0,
|
|
9886
|
+
const client = (0, import_react67.useRecordsClient)();
|
|
9887
|
+
const [rows, setRows] = (0, import_react66.useState)(null);
|
|
9888
|
+
const [titleKey, setTitleKey] = (0, import_react66.useState)(null);
|
|
9889
|
+
const [search, setSearch] = (0, import_react66.useState)("");
|
|
9890
|
+
const [picked, setPicked] = (0, import_react66.useState)(null);
|
|
9891
|
+
const [email, setEmail] = (0, import_react66.useState)("");
|
|
9892
|
+
const [busy, setBusy] = (0, import_react66.useState)(false);
|
|
9893
|
+
const [said, setSaid] = (0, import_react66.useState)(null);
|
|
9894
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
9895
|
+
(0, import_react66.useEffect)(() => {
|
|
9733
9896
|
let cancelled = false;
|
|
9734
9897
|
void client.list({ table_id: card.client_table_id, limit: 200 }).then((answered) => {
|
|
9735
9898
|
if (cancelled) return;
|
|
@@ -9747,12 +9910,12 @@ function Invite({ card, onInvited }) {
|
|
|
9747
9910
|
cancelled = true;
|
|
9748
9911
|
};
|
|
9749
9912
|
}, [client, card.client_table_id]);
|
|
9750
|
-
const options = (0,
|
|
9913
|
+
const options = (0, import_react66.useMemo)(() => {
|
|
9751
9914
|
const all = (rows ?? []).map((row) => ({ id: row.id, name: rowName(row, titleKey) }));
|
|
9752
9915
|
const needle = search.trim().toLowerCase();
|
|
9753
9916
|
return needle === "" ? all.slice(0, 25) : all.filter((o) => o.name.toLowerCase().includes(needle)).slice(0, 25);
|
|
9754
9917
|
}, [rows, titleKey, search]);
|
|
9755
|
-
const send = (0,
|
|
9918
|
+
const send = (0, import_react66.useCallback)(async () => {
|
|
9756
9919
|
if (!picked) return;
|
|
9757
9920
|
setBusy(true);
|
|
9758
9921
|
const answered = await client.portalInvite({
|
|
@@ -9831,8 +9994,8 @@ function Invite({ card, onInvited }) {
|
|
|
9831
9994
|
}
|
|
9832
9995
|
|
|
9833
9996
|
// src/DigestScheduler.tsx
|
|
9834
|
-
var
|
|
9835
|
-
var
|
|
9997
|
+
var import_react68 = require("react");
|
|
9998
|
+
var import_react69 = require("@ai-matrx/records/react");
|
|
9836
9999
|
var import_design_system33 = require("@ai-matrx/design-system");
|
|
9837
10000
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9838
10001
|
var WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
|
|
@@ -9856,27 +10019,27 @@ function DigestScheduler({
|
|
|
9856
10019
|
onClose,
|
|
9857
10020
|
className
|
|
9858
10021
|
}) {
|
|
9859
|
-
const client = (0,
|
|
10022
|
+
const client = (0, import_react69.useRecordsClient)();
|
|
9860
10023
|
const host = useRecordsUi();
|
|
9861
|
-
const [views, setViews] = (0,
|
|
9862
|
-
const [cadences, setCadences] = (0,
|
|
9863
|
-
const [members, setMembers] = (0,
|
|
9864
|
-
const [error, setError] = (0,
|
|
9865
|
-
const [viewId, setViewId] = (0,
|
|
9866
|
-
const [name, setName] = (0,
|
|
9867
|
-
const [cadence, setCadence] = (0,
|
|
9868
|
-
const [weekday, setWeekday] = (0,
|
|
9869
|
-
const [time, setTime] = (0,
|
|
9870
|
-
const [channel, setChannel] = (0,
|
|
9871
|
-
const [quiet, setQuiet] = (0,
|
|
9872
|
-
const [quietFrom, setQuietFrom] = (0,
|
|
9873
|
-
const [quietTo, setQuietTo] = (0,
|
|
9874
|
-
const [recipients, setRecipients] = (0,
|
|
9875
|
-
const [saving, setSaving] = (0,
|
|
9876
|
-
const [outcomes, setOutcomes] = (0,
|
|
9877
|
-
const [preview, setPreview] = (0,
|
|
9878
|
-
const [previewing, setPreviewing] = (0,
|
|
9879
|
-
const load = (0,
|
|
10024
|
+
const [views, setViews] = (0, import_react68.useState)(null);
|
|
10025
|
+
const [cadences, setCadences] = (0, import_react68.useState)([]);
|
|
10026
|
+
const [members, setMembers] = (0, import_react68.useState)(null);
|
|
10027
|
+
const [error, setError] = (0, import_react68.useState)(null);
|
|
10028
|
+
const [viewId, setViewId] = (0, import_react68.useState)(savedViewId ?? "");
|
|
10029
|
+
const [name, setName] = (0, import_react68.useState)(subjectName?.trim() ? `${subjectName.trim()} summary` : "");
|
|
10030
|
+
const [cadence, setCadence] = (0, import_react68.useState)("weekly");
|
|
10031
|
+
const [weekday, setWeekday] = (0, import_react68.useState)("monday");
|
|
10032
|
+
const [time, setTime] = (0, import_react68.useState)("08:00");
|
|
10033
|
+
const [channel, setChannel] = (0, import_react68.useState)("in_app");
|
|
10034
|
+
const [quiet, setQuiet] = (0, import_react68.useState)(false);
|
|
10035
|
+
const [quietFrom, setQuietFrom] = (0, import_react68.useState)("22:00");
|
|
10036
|
+
const [quietTo, setQuietTo] = (0, import_react68.useState)("07:00");
|
|
10037
|
+
const [recipients, setRecipients] = (0, import_react68.useState)([]);
|
|
10038
|
+
const [saving, setSaving] = (0, import_react68.useState)(false);
|
|
10039
|
+
const [outcomes, setOutcomes] = (0, import_react68.useState)(null);
|
|
10040
|
+
const [preview, setPreview] = (0, import_react68.useState)(null);
|
|
10041
|
+
const [previewing, setPreviewing] = (0, import_react68.useState)(false);
|
|
10042
|
+
const load = (0, import_react68.useCallback)(async () => {
|
|
9880
10043
|
const [saved, offered] = await Promise.all([
|
|
9881
10044
|
// The store's own door onto `platform.saved_view`, narrowed in SQL to
|
|
9882
10045
|
// Tables this person can already open — never a grant on the table behind it.
|
|
@@ -9895,15 +10058,15 @@ function DigestScheduler({
|
|
|
9895
10058
|
setMembers([]);
|
|
9896
10059
|
}
|
|
9897
10060
|
}, [client, tableId, host]);
|
|
9898
|
-
(0,
|
|
10061
|
+
(0, import_react68.useEffect)(() => {
|
|
9899
10062
|
void load();
|
|
9900
10063
|
}, [load]);
|
|
9901
|
-
const schedule = (0,
|
|
10064
|
+
const schedule = (0, import_react68.useMemo)(() => {
|
|
9902
10065
|
if (cadence === "weekly") return `${weekday} ${time}`;
|
|
9903
10066
|
if (cadence === "daily") return time;
|
|
9904
10067
|
return null;
|
|
9905
10068
|
}, [cadence, weekday, time]);
|
|
9906
|
-
const quietHours = (0,
|
|
10069
|
+
const quietHours = (0, import_react68.useMemo)(
|
|
9907
10070
|
() => quiet ? { start: quietFrom, end: quietTo } : null,
|
|
9908
10071
|
[quiet, quietFrom, quietTo]
|
|
9909
10072
|
);
|
|
@@ -10125,8 +10288,8 @@ function DigestScheduler({
|
|
|
10125
10288
|
}
|
|
10126
10289
|
|
|
10127
10290
|
// src/SubscriptionsPanel.tsx
|
|
10128
|
-
var
|
|
10129
|
-
var
|
|
10291
|
+
var import_react70 = require("react");
|
|
10292
|
+
var import_react71 = require("@ai-matrx/records/react");
|
|
10130
10293
|
var import_design_system34 = require("@ai-matrx/design-system");
|
|
10131
10294
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
10132
10295
|
function whenItFires(subscription) {
|
|
@@ -10141,14 +10304,14 @@ var CHANNEL_WORDS2 = {
|
|
|
10141
10304
|
};
|
|
10142
10305
|
var DIGEST_SUGGESTION = "Email me a summary of this every Monday at 8 in the morning.";
|
|
10143
10306
|
function SubscriptionsPanel({ tableId, className }) {
|
|
10144
|
-
const client = (0,
|
|
10145
|
-
const [rows, setRows] = (0,
|
|
10146
|
-
const [error, setError] = (0,
|
|
10147
|
-
const [busy, setBusy] = (0,
|
|
10148
|
-
const [preview, setPreview] = (0,
|
|
10149
|
-
const [scheduling, setScheduling] = (0,
|
|
10307
|
+
const client = (0, import_react71.useRecordsClient)();
|
|
10308
|
+
const [rows, setRows] = (0, import_react70.useState)(null);
|
|
10309
|
+
const [error, setError] = (0, import_react70.useState)(null);
|
|
10310
|
+
const [busy, setBusy] = (0, import_react70.useState)(null);
|
|
10311
|
+
const [preview, setPreview] = (0, import_react70.useState)(null);
|
|
10312
|
+
const [scheduling, setScheduling] = (0, import_react70.useState)(false);
|
|
10150
10313
|
const host = useRecordsUi();
|
|
10151
|
-
const load = (0,
|
|
10314
|
+
const load = (0, import_react70.useCallback)(async () => {
|
|
10152
10315
|
const answered = await client.subscriptions({ table_id: tableId });
|
|
10153
10316
|
if (!answered.ok) {
|
|
10154
10317
|
setError(answered.error);
|
|
@@ -10158,10 +10321,10 @@ function SubscriptionsPanel({ tableId, className }) {
|
|
|
10158
10321
|
setError(null);
|
|
10159
10322
|
setRows(answered.data);
|
|
10160
10323
|
}, [client, tableId]);
|
|
10161
|
-
(0,
|
|
10324
|
+
(0, import_react70.useEffect)(() => {
|
|
10162
10325
|
void load();
|
|
10163
10326
|
}, [load]);
|
|
10164
|
-
const flip = (0,
|
|
10327
|
+
const flip = (0, import_react70.useCallback)(
|
|
10165
10328
|
async (subscription, on) => {
|
|
10166
10329
|
setBusy(subscription.rule_id);
|
|
10167
10330
|
const answered = await client.subscriptionMute({
|
|
@@ -10177,7 +10340,7 @@ function SubscriptionsPanel({ tableId, className }) {
|
|
|
10177
10340
|
},
|
|
10178
10341
|
[client, load]
|
|
10179
10342
|
);
|
|
10180
|
-
const showOne = (0,
|
|
10343
|
+
const showOne = (0, import_react70.useCallback)(
|
|
10181
10344
|
async (subscription) => {
|
|
10182
10345
|
setBusy(subscription.rule_id);
|
|
10183
10346
|
const answered = await client.subscriptionPreview({ rule_id: subscription.rule_id });
|
|
@@ -10310,14 +10473,14 @@ function SubscriptionsPanel({ tableId, className }) {
|
|
|
10310
10473
|
}
|
|
10311
10474
|
|
|
10312
10475
|
// src/FormBuilder.tsx
|
|
10313
|
-
var
|
|
10314
|
-
var
|
|
10476
|
+
var import_react74 = require("react");
|
|
10477
|
+
var import_react75 = require("@ai-matrx/records/react");
|
|
10315
10478
|
var import_records7 = require("@ai-matrx/records");
|
|
10316
10479
|
var import_design_system36 = require("@ai-matrx/design-system");
|
|
10317
10480
|
|
|
10318
10481
|
// src/FormRunner.tsx
|
|
10319
|
-
var
|
|
10320
|
-
var
|
|
10482
|
+
var import_react72 = require("react");
|
|
10483
|
+
var import_react73 = require("@ai-matrx/records/react");
|
|
10321
10484
|
var import_design_system35 = require("@ai-matrx/design-system");
|
|
10322
10485
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
10323
10486
|
function FormRunner(props) {
|
|
@@ -10327,10 +10490,10 @@ function FormRunner(props) {
|
|
|
10327
10490
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ConnectedFormRunner, { ...props });
|
|
10328
10491
|
}
|
|
10329
10492
|
function ConnectedFormRunner(props) {
|
|
10330
|
-
const client = (0,
|
|
10331
|
-
const fields = (0,
|
|
10493
|
+
const client = (0, import_react73.useOptionalRecordsClient)();
|
|
10494
|
+
const fields = (0, import_react73.useFields)(props.form.subject);
|
|
10332
10495
|
const { form, className } = props;
|
|
10333
|
-
const submit = (0,
|
|
10496
|
+
const submit = (0, import_react72.useCallback)(
|
|
10334
10497
|
async (values) => {
|
|
10335
10498
|
if (!client) {
|
|
10336
10499
|
return {
|
|
@@ -10353,7 +10516,7 @@ function ConnectedFormRunner(props) {
|
|
|
10353
10516
|
},
|
|
10354
10517
|
[client, form]
|
|
10355
10518
|
);
|
|
10356
|
-
const evaluate = (0,
|
|
10519
|
+
const evaluate = (0, import_react72.useCallback)(
|
|
10357
10520
|
async (expr, values) => {
|
|
10358
10521
|
if (!client) return null;
|
|
10359
10522
|
const answered = await client.ruleEval({ expr, values });
|
|
@@ -10387,16 +10550,16 @@ function FormStage({
|
|
|
10387
10550
|
connected = false
|
|
10388
10551
|
}) {
|
|
10389
10552
|
const host = useRecordsUi();
|
|
10390
|
-
const [answers, setAnswers] = (0,
|
|
10391
|
-
const [at, setAt] = (0,
|
|
10392
|
-
const [error, setError] = (0,
|
|
10393
|
-
const [refusal, setRefusal] = (0,
|
|
10394
|
-
const [writing, setWriting] = (0,
|
|
10395
|
-
const [done, setDone] = (0,
|
|
10396
|
-
const [hidden, setHidden] = (0,
|
|
10397
|
-
const decoy = (0,
|
|
10398
|
-
const stage = (0,
|
|
10399
|
-
const questions = (0,
|
|
10553
|
+
const [answers, setAnswers] = (0, import_react72.useState)({});
|
|
10554
|
+
const [at, setAt] = (0, import_react72.useState)(0);
|
|
10555
|
+
const [error, setError] = (0, import_react72.useState)(null);
|
|
10556
|
+
const [refusal, setRefusal] = (0, import_react72.useState)(null);
|
|
10557
|
+
const [writing, setWriting] = (0, import_react72.useState)(false);
|
|
10558
|
+
const [done, setDone] = (0, import_react72.useState)(null);
|
|
10559
|
+
const [hidden, setHidden] = (0, import_react72.useState)({});
|
|
10560
|
+
const decoy = (0, import_react72.useRef)("");
|
|
10561
|
+
const stage = (0, import_react72.useRef)(null);
|
|
10562
|
+
const questions = (0, import_react72.useMemo)(() => {
|
|
10400
10563
|
const byKey = new Map((fields ?? []).map((f) => [f.key, f]));
|
|
10401
10564
|
return (form.questions ?? []).map((q) => {
|
|
10402
10565
|
const field = byKey.get(q.field) ?? null;
|
|
@@ -10410,7 +10573,7 @@ function FormStage({
|
|
|
10410
10573
|
};
|
|
10411
10574
|
});
|
|
10412
10575
|
}, [fields, form.questions]);
|
|
10413
|
-
(0,
|
|
10576
|
+
(0, import_react72.useEffect)(() => {
|
|
10414
10577
|
let cancelled = false;
|
|
10415
10578
|
const conditional = questions.filter((q) => q.showIf);
|
|
10416
10579
|
if (conditional.length === 0 || !evaluate) return;
|
|
@@ -10444,7 +10607,7 @@ function FormStage({
|
|
|
10444
10607
|
const v = answers[q.key];
|
|
10445
10608
|
return q.required && (v === void 0 || v === null || v === "");
|
|
10446
10609
|
});
|
|
10447
|
-
const submit = (0,
|
|
10610
|
+
const submit = (0, import_react72.useCallback)(async () => {
|
|
10448
10611
|
if (preview) {
|
|
10449
10612
|
setDone("preview");
|
|
10450
10613
|
return;
|
|
@@ -10481,7 +10644,7 @@ function FormStage({
|
|
|
10481
10644
|
if (event.shiftKey) retreat();
|
|
10482
10645
|
else advance();
|
|
10483
10646
|
}
|
|
10484
|
-
(0,
|
|
10647
|
+
(0, import_react72.useEffect)(() => {
|
|
10485
10648
|
const input = stage.current?.querySelector(
|
|
10486
10649
|
"input:not([tabindex='-1']), textarea, select, [role='combobox']"
|
|
10487
10650
|
);
|
|
@@ -10575,7 +10738,7 @@ function Question({
|
|
|
10575
10738
|
onChange,
|
|
10576
10739
|
upload
|
|
10577
10740
|
}) {
|
|
10578
|
-
const [uploadError, setUploadError] = (0,
|
|
10741
|
+
const [uploadError, setUploadError] = (0, import_react72.useState)(null);
|
|
10579
10742
|
const field = question.field;
|
|
10580
10743
|
if (!field) return null;
|
|
10581
10744
|
const id = `form-${field.key}`;
|
|
@@ -10632,23 +10795,23 @@ function whyNotAskable(fields, hidden = []) {
|
|
|
10632
10795
|
// src/FormBuilder.tsx
|
|
10633
10796
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
10634
10797
|
function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
|
|
10635
|
-
const client = (0,
|
|
10798
|
+
const client = (0, import_react75.useRecordsClient)();
|
|
10636
10799
|
const host = useRecordsUi();
|
|
10637
10800
|
const claimSeed = useSeedGuard();
|
|
10638
|
-
const table = (0,
|
|
10801
|
+
const table = (0, import_react75.useTable)(tableId);
|
|
10639
10802
|
const rights = useTableRights(table.data);
|
|
10640
|
-
const fields = (0,
|
|
10641
|
-
const [forms, setForms] = (0,
|
|
10642
|
-
const [error, setError] = (0,
|
|
10643
|
-
const [activeId, setActiveId] = (0,
|
|
10644
|
-
const [draft, setDraft] = (0,
|
|
10645
|
-
const [saving, setSaving] = (0,
|
|
10646
|
-
const [saved, setSaved] = (0,
|
|
10647
|
-
const [publishing, setPublishing] = (0,
|
|
10648
|
-
const [copied, setCopied] = (0,
|
|
10649
|
-
const [shownUrl, setShownUrl] = (0,
|
|
10803
|
+
const fields = (0, import_react75.useFields)(tableId);
|
|
10804
|
+
const [forms, setForms] = (0, import_react74.useState)(null);
|
|
10805
|
+
const [error, setError] = (0, import_react74.useState)(null);
|
|
10806
|
+
const [activeId, setActiveId] = (0, import_react74.useState)(activeFormId ?? null);
|
|
10807
|
+
const [draft, setDraft] = (0, import_react74.useState)(null);
|
|
10808
|
+
const [saving, setSaving] = (0, import_react74.useState)(false);
|
|
10809
|
+
const [saved, setSaved] = (0, import_react74.useState)(null);
|
|
10810
|
+
const [publishing, setPublishing] = (0, import_react74.useState)(false);
|
|
10811
|
+
const [copied, setCopied] = (0, import_react74.useState)(false);
|
|
10812
|
+
const [shownUrl, setShownUrl] = (0, import_react74.useState)(null);
|
|
10650
10813
|
const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
|
|
10651
|
-
const load = (0,
|
|
10814
|
+
const load = (0, import_react74.useCallback)(async () => {
|
|
10652
10815
|
const answered = await client.forms({ table_id: tableId });
|
|
10653
10816
|
if (!answered.ok) {
|
|
10654
10817
|
setError(answered.error);
|
|
@@ -10675,17 +10838,17 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
|
|
|
10675
10838
|
setError(null);
|
|
10676
10839
|
setForms(mine);
|
|
10677
10840
|
}, [client, tableId, seed, claimSeed]);
|
|
10678
|
-
(0,
|
|
10841
|
+
(0, import_react74.useEffect)(() => {
|
|
10679
10842
|
void load();
|
|
10680
10843
|
}, [load]);
|
|
10681
|
-
(0,
|
|
10844
|
+
(0, import_react74.useEffect)(() => {
|
|
10682
10845
|
if (!forms || forms.length === 0) return;
|
|
10683
10846
|
const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
|
|
10684
10847
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
10685
10848
|
setDraft(chosen);
|
|
10686
10849
|
onActiveForm?.(chosen);
|
|
10687
10850
|
}, [forms, activeFormId]);
|
|
10688
|
-
const byKey = (0,
|
|
10851
|
+
const byKey = (0, import_react74.useMemo)(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
|
|
10689
10852
|
function patch(change) {
|
|
10690
10853
|
setDraft((prev) => prev ? { ...prev, ...change } : prev);
|
|
10691
10854
|
setSaved(null);
|
|
@@ -10980,13 +11143,13 @@ function Condition({
|
|
|
10980
11143
|
onChange
|
|
10981
11144
|
}) {
|
|
10982
11145
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
10983
|
-
|
|
11146
|
+
ConditionGroup,
|
|
10984
11147
|
{
|
|
10985
11148
|
lead: "Ask only when",
|
|
10986
11149
|
expr: question.showIf,
|
|
10987
11150
|
fields: fieldKeys,
|
|
10988
11151
|
onChange,
|
|
10989
|
-
className: "col-span-2 flex
|
|
11152
|
+
className: "col-span-2 flex flex-col gap-1 text-xs"
|
|
10990
11153
|
}
|
|
10991
11154
|
);
|
|
10992
11155
|
}
|
|
@@ -11076,13 +11239,13 @@ function groupLabel(groups) {
|
|
|
11076
11239
|
}
|
|
11077
11240
|
|
|
11078
11241
|
// src/chartFrame.tsx
|
|
11079
|
-
var
|
|
11242
|
+
var import_react76 = require("react");
|
|
11080
11243
|
var import_design_system37 = require("@ai-matrx/design-system");
|
|
11081
11244
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
11082
11245
|
function useMeasuredWidth(fallback = 480) {
|
|
11083
|
-
const ref = (0,
|
|
11084
|
-
const [width, setWidth] = (0,
|
|
11085
|
-
(0,
|
|
11246
|
+
const ref = (0, import_react76.useRef)(null);
|
|
11247
|
+
const [width, setWidth] = (0, import_react76.useState)(fallback);
|
|
11248
|
+
(0, import_react76.useEffect)(() => {
|
|
11086
11249
|
const node = ref.current;
|
|
11087
11250
|
if (!node) return;
|
|
11088
11251
|
const apply = () => {
|
|
@@ -11112,7 +11275,7 @@ function ChartFrame({
|
|
|
11112
11275
|
children
|
|
11113
11276
|
}) {
|
|
11114
11277
|
const [ref, width] = useMeasuredWidth();
|
|
11115
|
-
const chartId = `records-chart-${(0,
|
|
11278
|
+
const chartId = `records-chart-${(0, import_react76.useId)().replace(/:/g, "")}`;
|
|
11116
11279
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
11117
11280
|
"div",
|
|
11118
11281
|
{
|
|
@@ -11206,24 +11369,24 @@ function isSignatureField(field) {
|
|
|
11206
11369
|
}
|
|
11207
11370
|
|
|
11208
11371
|
// src/DocTemplate.tsx
|
|
11209
|
-
var
|
|
11210
|
-
var
|
|
11372
|
+
var import_react77 = require("react");
|
|
11373
|
+
var import_react78 = require("@ai-matrx/records/react");
|
|
11211
11374
|
var import_design_system38 = require("@ai-matrx/design-system");
|
|
11212
11375
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
11213
11376
|
function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, className }) {
|
|
11214
|
-
const client = (0,
|
|
11377
|
+
const client = (0, import_react78.useRecordsClient)();
|
|
11215
11378
|
const claimSeed = useSeedGuard();
|
|
11216
|
-
const table = (0,
|
|
11379
|
+
const table = (0, import_react78.useTable)(tableId);
|
|
11217
11380
|
const rights = useTableRights(table.data);
|
|
11218
|
-
const fields = (0,
|
|
11219
|
-
const [templates, setTemplates] = (0,
|
|
11220
|
-
const [error, setError] = (0,
|
|
11221
|
-
const [activeId, setActiveId] = (0,
|
|
11222
|
-
const [draftName, setDraftName] = (0,
|
|
11223
|
-
const [draftBody, setDraftBody] = (0,
|
|
11224
|
-
const [unresolved, setUnresolved] = (0,
|
|
11225
|
-
const [saving, setSaving] = (0,
|
|
11226
|
-
const load = (0,
|
|
11381
|
+
const fields = (0, import_react78.useFields)(tableId);
|
|
11382
|
+
const [templates, setTemplates] = (0, import_react77.useState)(null);
|
|
11383
|
+
const [error, setError] = (0, import_react77.useState)(null);
|
|
11384
|
+
const [activeId, setActiveId] = (0, import_react77.useState)(activeTemplateId ?? null);
|
|
11385
|
+
const [draftName, setDraftName] = (0, import_react77.useState)("");
|
|
11386
|
+
const [draftBody, setDraftBody] = (0, import_react77.useState)("");
|
|
11387
|
+
const [unresolved, setUnresolved] = (0, import_react77.useState)([]);
|
|
11388
|
+
const [saving, setSaving] = (0, import_react77.useState)(false);
|
|
11389
|
+
const load = (0, import_react77.useCallback)(async () => {
|
|
11227
11390
|
const held = await client.docTemplates({ table_id: tableId });
|
|
11228
11391
|
if (!held.ok) {
|
|
11229
11392
|
setError(held.error);
|
|
@@ -11254,10 +11417,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
|
|
|
11254
11417
|
setError(null);
|
|
11255
11418
|
setTemplates(rows);
|
|
11256
11419
|
}, [client, tableId, seed, fields.data]);
|
|
11257
|
-
(0,
|
|
11420
|
+
(0, import_react77.useEffect)(() => {
|
|
11258
11421
|
void load();
|
|
11259
11422
|
}, [load]);
|
|
11260
|
-
(0,
|
|
11423
|
+
(0, import_react77.useEffect)(() => {
|
|
11261
11424
|
if (!templates || templates.length === 0) return;
|
|
11262
11425
|
const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
|
|
11263
11426
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
@@ -11265,7 +11428,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
|
|
|
11265
11428
|
setDraftBody(chosen.body);
|
|
11266
11429
|
onActiveTemplate?.(chosen);
|
|
11267
11430
|
}, [templates, activeTemplateId]);
|
|
11268
|
-
(0,
|
|
11431
|
+
(0, import_react77.useEffect)(() => {
|
|
11269
11432
|
let cancelled = false;
|
|
11270
11433
|
if (draftBody.trim() === "") {
|
|
11271
11434
|
setUnresolved([]);
|
|
@@ -11385,19 +11548,19 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
|
|
|
11385
11548
|
}
|
|
11386
11549
|
|
|
11387
11550
|
// src/DocRender.tsx
|
|
11388
|
-
var
|
|
11389
|
-
var
|
|
11551
|
+
var import_react79 = require("react");
|
|
11552
|
+
var import_react80 = require("@ai-matrx/records/react");
|
|
11390
11553
|
var import_design_system39 = require("@ai-matrx/design-system");
|
|
11391
11554
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
11392
11555
|
function DocRender({ templateId, recordId, filename, onRendered, className }) {
|
|
11393
|
-
const client = (0,
|
|
11394
|
-
const [preview, setPreview] = (0,
|
|
11395
|
-
const [renders, setRenders] = (0,
|
|
11396
|
-
const [showing, setShowing] = (0,
|
|
11397
|
-
const [error, setError] = (0,
|
|
11398
|
-
const [busy, setBusy] = (0,
|
|
11399
|
-
const paper = (0,
|
|
11400
|
-
const load = (0,
|
|
11556
|
+
const client = (0, import_react80.useRecordsClient)();
|
|
11557
|
+
const [preview, setPreview] = (0, import_react79.useState)(null);
|
|
11558
|
+
const [renders, setRenders] = (0, import_react79.useState)(null);
|
|
11559
|
+
const [showing, setShowing] = (0, import_react79.useState)(null);
|
|
11560
|
+
const [error, setError] = (0, import_react79.useState)(null);
|
|
11561
|
+
const [busy, setBusy] = (0, import_react79.useState)(null);
|
|
11562
|
+
const paper = (0, import_react79.useRef)(null);
|
|
11563
|
+
const load = (0, import_react79.useCallback)(async () => {
|
|
11401
11564
|
const [body, held] = await Promise.all([
|
|
11402
11565
|
client.docRenderBody({ template_id: templateId, record_id: recordId }),
|
|
11403
11566
|
client.docRenders({ record_id: recordId })
|
|
@@ -11414,7 +11577,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
|
|
|
11414
11577
|
setPreview(body.data);
|
|
11415
11578
|
setRenders(held.data.filter((r) => r.template_id === templateId));
|
|
11416
11579
|
}, [client, templateId, recordId]);
|
|
11417
|
-
(0,
|
|
11580
|
+
(0, import_react79.useEffect)(() => {
|
|
11418
11581
|
void load();
|
|
11419
11582
|
}, [load]);
|
|
11420
11583
|
async function freeze() {
|
|
@@ -11498,22 +11661,22 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
|
|
|
11498
11661
|
}
|
|
11499
11662
|
|
|
11500
11663
|
// src/SignBlock.tsx
|
|
11501
|
-
var
|
|
11502
|
-
var import_react81 = require("@ai-matrx/records/react");
|
|
11503
|
-
var import_design_system40 = require("@ai-matrx/design-system");
|
|
11664
|
+
var import_react81 = require("react");
|
|
11504
11665
|
var import_react82 = require("@ai-matrx/records/react");
|
|
11666
|
+
var import_design_system40 = require("@ai-matrx/design-system");
|
|
11667
|
+
var import_react83 = require("@ai-matrx/records/react");
|
|
11505
11668
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
11506
11669
|
function SignBlock({ tableId, recordId, render, className }) {
|
|
11507
|
-
const client = (0,
|
|
11508
|
-
const table = (0,
|
|
11670
|
+
const client = (0, import_react82.useRecordsClient)();
|
|
11671
|
+
const table = (0, import_react83.useTable)(tableId);
|
|
11509
11672
|
const rights = useTableRights(table.data);
|
|
11510
|
-
const fields = (0,
|
|
11511
|
-
const [signatures, setSignatures] = (0,
|
|
11512
|
-
const [verdicts, setVerdicts] = (0,
|
|
11513
|
-
const [error, setError] = (0,
|
|
11514
|
-
const [name, setName] = (0,
|
|
11515
|
-
const [busy, setBusy] = (0,
|
|
11516
|
-
const load = (0,
|
|
11673
|
+
const fields = (0, import_react82.useFields)(tableId);
|
|
11674
|
+
const [signatures, setSignatures] = (0, import_react81.useState)(null);
|
|
11675
|
+
const [verdicts, setVerdicts] = (0, import_react81.useState)({});
|
|
11676
|
+
const [error, setError] = (0, import_react81.useState)(null);
|
|
11677
|
+
const [name, setName] = (0, import_react81.useState)("");
|
|
11678
|
+
const [busy, setBusy] = (0, import_react81.useState)(false);
|
|
11679
|
+
const load = (0, import_react81.useCallback)(async () => {
|
|
11517
11680
|
const held = await client.docSignatures({ record_id: recordId });
|
|
11518
11681
|
if (!held.ok) {
|
|
11519
11682
|
setError(held.error);
|
|
@@ -11528,7 +11691,7 @@ function SignBlock({ tableId, recordId, render, className }) {
|
|
|
11528
11691
|
}
|
|
11529
11692
|
setVerdicts(answers);
|
|
11530
11693
|
}, [client, recordId]);
|
|
11531
|
-
(0,
|
|
11694
|
+
(0, import_react81.useEffect)(() => {
|
|
11532
11695
|
void load();
|
|
11533
11696
|
}, [load]);
|
|
11534
11697
|
async function sign(field) {
|
|
@@ -11635,8 +11798,8 @@ function SignBlock({ tableId, recordId, render, className }) {
|
|
|
11635
11798
|
}
|
|
11636
11799
|
|
|
11637
11800
|
// src/NotifyRuleEditor.tsx
|
|
11638
|
-
var
|
|
11639
|
-
var
|
|
11801
|
+
var import_react84 = require("react");
|
|
11802
|
+
var import_react85 = require("@ai-matrx/records/react");
|
|
11640
11803
|
var import_design_system41 = require("@ai-matrx/design-system");
|
|
11641
11804
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
11642
11805
|
var CADENCE_WORDS2 = {
|
|
@@ -11651,16 +11814,16 @@ var CHANNEL_WORDS3 = {
|
|
|
11651
11814
|
sms: "by text"
|
|
11652
11815
|
};
|
|
11653
11816
|
function NotifyRuleEditor({ tableId, seed, className }) {
|
|
11654
|
-
const client = (0,
|
|
11817
|
+
const client = (0, import_react85.useRecordsClient)();
|
|
11655
11818
|
const host = useRecordsUi();
|
|
11656
|
-
const table = (0,
|
|
11819
|
+
const table = (0, import_react85.useTable)(tableId);
|
|
11657
11820
|
const rights = useTableRights(table.data);
|
|
11658
|
-
const [subscriptions, setSubscriptions] = (0,
|
|
11659
|
-
const [cadences, setCadences] = (0,
|
|
11660
|
-
const [views, setViews] = (0,
|
|
11661
|
-
const [error, setError] = (0,
|
|
11662
|
-
const [busy, setBusy] = (0,
|
|
11663
|
-
const load = (0,
|
|
11821
|
+
const [subscriptions, setSubscriptions] = (0, import_react84.useState)(null);
|
|
11822
|
+
const [cadences, setCadences] = (0, import_react84.useState)([]);
|
|
11823
|
+
const [views, setViews] = (0, import_react84.useState)(null);
|
|
11824
|
+
const [error, setError] = (0, import_react84.useState)(null);
|
|
11825
|
+
const [busy, setBusy] = (0, import_react84.useState)(false);
|
|
11826
|
+
const load = (0, import_react84.useCallback)(async () => {
|
|
11664
11827
|
const [held, offered] = await Promise.all([
|
|
11665
11828
|
// THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
|
|
11666
11829
|
// to them plus — only where they hold admin on this Table — anyone's over
|
|
@@ -11680,10 +11843,10 @@ function NotifyRuleEditor({ tableId, seed, className }) {
|
|
|
11680
11843
|
if (host.savedViews) setViews(await host.savedViews());
|
|
11681
11844
|
else setViews(null);
|
|
11682
11845
|
}, [client, host, tableId]);
|
|
11683
|
-
(0,
|
|
11846
|
+
(0, import_react84.useEffect)(() => {
|
|
11684
11847
|
void load();
|
|
11685
11848
|
}, [load]);
|
|
11686
|
-
const write = (0,
|
|
11849
|
+
const write = (0, import_react84.useCallback)(
|
|
11687
11850
|
async (spec) => {
|
|
11688
11851
|
const declared = await client.subscriptionDeclare({
|
|
11689
11852
|
table_id: tableId,
|
|
@@ -11708,7 +11871,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
|
|
|
11708
11871
|
},
|
|
11709
11872
|
[client, tableId]
|
|
11710
11873
|
);
|
|
11711
|
-
(0,
|
|
11874
|
+
(0, import_react84.useEffect)(() => {
|
|
11712
11875
|
if (!subscriptions || !seed || seed.length === 0) return;
|
|
11713
11876
|
const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
|
|
11714
11877
|
if (missing.length === 0) return;
|
|
@@ -11851,7 +12014,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
|
|
|
11851
12014
|
}
|
|
11852
12015
|
|
|
11853
12016
|
// src/ChartBlock.tsx
|
|
11854
|
-
var
|
|
12017
|
+
var import_react86 = require("react");
|
|
11855
12018
|
var import_recharts = require("recharts");
|
|
11856
12019
|
var import_records8 = require("@ai-matrx/records");
|
|
11857
12020
|
var import_core6 = require("@ai-matrx/records/core");
|
|
@@ -11876,7 +12039,7 @@ function ChartBlock({ block, subject, className }) {
|
|
|
11876
12039
|
const measures = block.measures && block.measures.length > 0 ? block.measures : [{ op: "count" }];
|
|
11877
12040
|
const primary = (0, import_records8.measureKey)(measures[0]);
|
|
11878
12041
|
const series = [primary];
|
|
11879
|
-
const points = (0,
|
|
12042
|
+
const points = (0, import_react86.useMemo)(() => {
|
|
11880
12043
|
if (kind === "stuck") return [];
|
|
11881
12044
|
const rows = block.rows ?? [];
|
|
11882
12045
|
return rows.map((row) => ({
|
|
@@ -11888,7 +12051,7 @@ function ChartBlock({ block, subject, className }) {
|
|
|
11888
12051
|
n: row.row_count
|
|
11889
12052
|
}));
|
|
11890
12053
|
}, [block.rows, kind, series.join("|")]);
|
|
11891
|
-
const config = (0,
|
|
12054
|
+
const config = (0, import_react86.useMemo)(() => {
|
|
11892
12055
|
const out = {};
|
|
11893
12056
|
series.forEach((key, index) => {
|
|
11894
12057
|
out[key] = {
|
|
@@ -12149,25 +12312,25 @@ function Drawing({
|
|
|
12149
12312
|
}
|
|
12150
12313
|
|
|
12151
12314
|
// src/DashboardCanvas.tsx
|
|
12152
|
-
var
|
|
12153
|
-
var
|
|
12315
|
+
var import_react87 = require("react");
|
|
12316
|
+
var import_react88 = require("@ai-matrx/records/react");
|
|
12154
12317
|
var import_design_system43 = require("@ai-matrx/design-system");
|
|
12155
12318
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
12156
12319
|
function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
12157
|
-
const client = (0,
|
|
12320
|
+
const client = (0, import_react88.useRecordsClient)();
|
|
12158
12321
|
const host = useRecordsUi();
|
|
12159
|
-
const table = (0,
|
|
12322
|
+
const table = (0, import_react88.useTable)(tableId);
|
|
12160
12323
|
const rights = useTableRights(table.data);
|
|
12161
|
-
const fields = (0,
|
|
12162
|
-
const [boards, setBoards] = (0,
|
|
12163
|
-
const [error, setError] = (0,
|
|
12164
|
-
const [activeId, setActiveId] = (0,
|
|
12165
|
-
const [run, setRun] = (0,
|
|
12166
|
-
const [running, setRunning] = (0,
|
|
12167
|
-
const [question, setQuestion] = (0,
|
|
12168
|
-
const [asking, setAsking] = (0,
|
|
12169
|
-
const [scheduling, setScheduling] = (0,
|
|
12170
|
-
const load = (0,
|
|
12324
|
+
const fields = (0, import_react88.useFields)(tableId);
|
|
12325
|
+
const [boards, setBoards] = (0, import_react87.useState)(null);
|
|
12326
|
+
const [error, setError] = (0, import_react87.useState)(null);
|
|
12327
|
+
const [activeId, setActiveId] = (0, import_react87.useState)(activeDashboardId ?? null);
|
|
12328
|
+
const [run, setRun] = (0, import_react87.useState)(null);
|
|
12329
|
+
const [running, setRunning] = (0, import_react87.useState)(false);
|
|
12330
|
+
const [question, setQuestion] = (0, import_react87.useState)("");
|
|
12331
|
+
const [asking, setAsking] = (0, import_react87.useState)(false);
|
|
12332
|
+
const [scheduling, setScheduling] = (0, import_react87.useState)(false);
|
|
12333
|
+
const load = (0, import_react87.useCallback)(async () => {
|
|
12171
12334
|
const answered = await client.dashboards({ table_id: tableId });
|
|
12172
12335
|
if (!answered.ok) {
|
|
12173
12336
|
setError(answered.error);
|
|
@@ -12176,17 +12339,17 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
12176
12339
|
setError(null);
|
|
12177
12340
|
setBoards(answered.data.map(dashboardFromSummary));
|
|
12178
12341
|
}, [client, tableId]);
|
|
12179
|
-
(0,
|
|
12342
|
+
(0, import_react87.useEffect)(() => {
|
|
12180
12343
|
void load();
|
|
12181
12344
|
}, [load]);
|
|
12182
|
-
(0,
|
|
12345
|
+
(0, import_react87.useEffect)(() => {
|
|
12183
12346
|
if (!boards || boards.length === 0) return;
|
|
12184
12347
|
const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
|
|
12185
12348
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
12186
12349
|
}, [boards, activeDashboardId]);
|
|
12187
|
-
const board = (0,
|
|
12350
|
+
const board = (0, import_react87.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
|
|
12188
12351
|
const filterKey = JSON.stringify(filter ?? {});
|
|
12189
|
-
(0,
|
|
12352
|
+
(0, import_react87.useEffect)(() => {
|
|
12190
12353
|
if (!activeId) {
|
|
12191
12354
|
setRun(null);
|
|
12192
12355
|
return;
|
|
@@ -12204,7 +12367,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
12204
12367
|
cancelled = true;
|
|
12205
12368
|
};
|
|
12206
12369
|
}, [client, activeId, filterKey]);
|
|
12207
|
-
const declare2 = (0,
|
|
12370
|
+
const declare2 = (0, import_react87.useCallback)(
|
|
12208
12371
|
async (next, blocks) => {
|
|
12209
12372
|
const written = await client.dashboardDeclare(
|
|
12210
12373
|
dashboardDeclareArgs({ ...next, blocks }, tableId)
|
|
@@ -12250,7 +12413,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
12250
12413
|
]
|
|
12251
12414
|
);
|
|
12252
12415
|
}
|
|
12253
|
-
const refresh = (0,
|
|
12416
|
+
const refresh = (0, import_react87.useCallback)(async () => {
|
|
12254
12417
|
if (!activeId) return;
|
|
12255
12418
|
setRunning(true);
|
|
12256
12419
|
const again = await client.dashboardRun({
|
|
@@ -12406,8 +12569,8 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
12406
12569
|
}
|
|
12407
12570
|
|
|
12408
12571
|
// src/FormsPanel.tsx
|
|
12409
|
-
var
|
|
12410
|
-
var
|
|
12572
|
+
var import_react89 = require("react");
|
|
12573
|
+
var import_react90 = require("@ai-matrx/records/react");
|
|
12411
12574
|
var import_records9 = require("@ai-matrx/records");
|
|
12412
12575
|
var import_design_system44 = require("@ai-matrx/design-system");
|
|
12413
12576
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
@@ -12418,16 +12581,16 @@ function formSuggestion(tableName2) {
|
|
|
12418
12581
|
return `Make me a form that collects new ${subject} entries and tells me when somebody answers.`;
|
|
12419
12582
|
}
|
|
12420
12583
|
function FormsPanel({ tableId, className }) {
|
|
12421
|
-
const client = (0,
|
|
12584
|
+
const client = (0, import_react90.useRecordsClient)();
|
|
12422
12585
|
const host = useRecordsUi();
|
|
12423
|
-
const table = (0,
|
|
12586
|
+
const table = (0, import_react90.useTable)(tableId);
|
|
12424
12587
|
const rights = useTableRights(table.data);
|
|
12425
|
-
const [forms, setForms] = (0,
|
|
12426
|
-
const [error, setError] = (0,
|
|
12427
|
-
const [busy, setBusy] = (0,
|
|
12428
|
-
const [copied, setCopied] = (0,
|
|
12429
|
-
const [building, setBuilding] = (0,
|
|
12430
|
-
const load = (0,
|
|
12588
|
+
const [forms, setForms] = (0, import_react89.useState)(null);
|
|
12589
|
+
const [error, setError] = (0, import_react89.useState)(null);
|
|
12590
|
+
const [busy, setBusy] = (0, import_react89.useState)(null);
|
|
12591
|
+
const [copied, setCopied] = (0, import_react89.useState)(null);
|
|
12592
|
+
const [building, setBuilding] = (0, import_react89.useState)(false);
|
|
12593
|
+
const load = (0, import_react89.useCallback)(async () => {
|
|
12431
12594
|
const answered = await client.forms({ table_id: tableId });
|
|
12432
12595
|
if (!answered.ok) {
|
|
12433
12596
|
setError(answered.error);
|
|
@@ -12437,10 +12600,10 @@ function FormsPanel({ tableId, className }) {
|
|
|
12437
12600
|
setError(null);
|
|
12438
12601
|
setForms(answered.data);
|
|
12439
12602
|
}, [client, tableId]);
|
|
12440
|
-
(0,
|
|
12603
|
+
(0, import_react89.useEffect)(() => {
|
|
12441
12604
|
void load();
|
|
12442
12605
|
}, [load]);
|
|
12443
|
-
const toggle = (0,
|
|
12606
|
+
const toggle = (0, import_react89.useCallback)(
|
|
12444
12607
|
async (form) => {
|
|
12445
12608
|
setBusy(form.form_id);
|
|
12446
12609
|
const wanted = form.published_at === null || form.closed_at !== null;
|
|
@@ -12454,8 +12617,8 @@ function FormsPanel({ tableId, className }) {
|
|
|
12454
12617
|
},
|
|
12455
12618
|
[client, load]
|
|
12456
12619
|
);
|
|
12457
|
-
const [shown, setShown] = (0,
|
|
12458
|
-
const copy = (0,
|
|
12620
|
+
const [shown, setShown] = (0, import_react89.useState)(null);
|
|
12621
|
+
const copy = (0, import_react89.useCallback)(async (url, formId) => {
|
|
12459
12622
|
try {
|
|
12460
12623
|
await navigator.clipboard.writeText(url);
|
|
12461
12624
|
setCopied(formId);
|
|
@@ -12553,8 +12716,8 @@ function FormsPanel({ tableId, className }) {
|
|
|
12553
12716
|
}
|
|
12554
12717
|
|
|
12555
12718
|
// src/BookingBuilder.tsx
|
|
12556
|
-
var
|
|
12557
|
-
var
|
|
12719
|
+
var import_react91 = require("react");
|
|
12720
|
+
var import_react92 = require("@ai-matrx/records/react");
|
|
12558
12721
|
var import_records10 = require("@ai-matrx/records");
|
|
12559
12722
|
var import_design_system45 = require("@ai-matrx/design-system");
|
|
12560
12723
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
@@ -12582,38 +12745,38 @@ function draftWindows(availability) {
|
|
|
12582
12745
|
});
|
|
12583
12746
|
}
|
|
12584
12747
|
function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
12585
|
-
const client = (0,
|
|
12748
|
+
const client = (0, import_react92.useRecordsClient)();
|
|
12586
12749
|
const host = useRecordsUi();
|
|
12587
|
-
const table = (0,
|
|
12750
|
+
const table = (0, import_react92.useTable)(tableId);
|
|
12588
12751
|
const rights = useTableRights(table.data);
|
|
12589
|
-
const fields = (0,
|
|
12590
|
-
const [existing, setExisting] = (0,
|
|
12591
|
-
const [loaded, setLoaded] = (0,
|
|
12592
|
-
const [error, setError] = (0,
|
|
12593
|
-
const [saving, setSaving] = (0,
|
|
12594
|
-
const [publishing, setPublishing] = (0,
|
|
12595
|
-
const [copied, setCopied] = (0,
|
|
12596
|
-
const [title, setTitle] = (0,
|
|
12597
|
-
const [minutes, setMinutes] = (0,
|
|
12598
|
-
const [buffer, setBuffer] = (0,
|
|
12599
|
-
const [lead, setLead] = (0,
|
|
12600
|
-
const [perDay, setPerDay] = (0,
|
|
12601
|
-
const [days, setDays] = (0,
|
|
12602
|
-
const [windows, setWindows] = (0,
|
|
12603
|
-
const [asked, setAsked] = (0,
|
|
12604
|
-
const [confirmation, setConfirmation] = (0,
|
|
12605
|
-
const [offer, setOffer] = (0,
|
|
12606
|
-
const [formId, setFormId] = (0,
|
|
12752
|
+
const fields = (0, import_react92.useFields)(tableId);
|
|
12753
|
+
const [existing, setExisting] = (0, import_react91.useState)(null);
|
|
12754
|
+
const [loaded, setLoaded] = (0, import_react91.useState)(false);
|
|
12755
|
+
const [error, setError] = (0, import_react91.useState)(null);
|
|
12756
|
+
const [saving, setSaving] = (0, import_react91.useState)(false);
|
|
12757
|
+
const [publishing, setPublishing] = (0, import_react91.useState)(false);
|
|
12758
|
+
const [copied, setCopied] = (0, import_react91.useState)(false);
|
|
12759
|
+
const [title, setTitle] = (0, import_react91.useState)("");
|
|
12760
|
+
const [minutes, setMinutes] = (0, import_react91.useState)(30);
|
|
12761
|
+
const [buffer, setBuffer] = (0, import_react91.useState)(0);
|
|
12762
|
+
const [lead, setLead] = (0, import_react91.useState)(120);
|
|
12763
|
+
const [perDay, setPerDay] = (0, import_react91.useState)(8);
|
|
12764
|
+
const [days, setDays] = (0, import_react91.useState)(30);
|
|
12765
|
+
const [windows, setWindows] = (0, import_react91.useState)(() => draftWindows(null));
|
|
12766
|
+
const [asked, setAsked] = (0, import_react91.useState)([]);
|
|
12767
|
+
const [confirmation, setConfirmation] = (0, import_react91.useState)("");
|
|
12768
|
+
const [offer, setOffer] = (0, import_react91.useState)(null);
|
|
12769
|
+
const [formId, setFormId] = (0, import_react91.useState)(bookingId ?? null);
|
|
12607
12770
|
const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
|
|
12608
|
-
const askable = (0,
|
|
12771
|
+
const askable = (0, import_react91.useMemo)(
|
|
12609
12772
|
() => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
|
|
12610
12773
|
[fields.data]
|
|
12611
12774
|
);
|
|
12612
|
-
const leftOut = (0,
|
|
12775
|
+
const leftOut = (0, import_react91.useMemo)(
|
|
12613
12776
|
() => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
|
|
12614
12777
|
[fields.data]
|
|
12615
12778
|
);
|
|
12616
|
-
const load = (0,
|
|
12779
|
+
const load = (0, import_react91.useCallback)(async () => {
|
|
12617
12780
|
const answered = await client.bookings({ table_id: tableId });
|
|
12618
12781
|
if (!answered.ok) {
|
|
12619
12782
|
setError(answered.error);
|
|
@@ -12625,18 +12788,18 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
12625
12788
|
setLoaded(true);
|
|
12626
12789
|
if (mine) setFormId(mine.form_id);
|
|
12627
12790
|
}, [client, tableId, bookingId]);
|
|
12628
|
-
(0,
|
|
12791
|
+
(0, import_react91.useEffect)(() => {
|
|
12629
12792
|
void load();
|
|
12630
12793
|
}, [load]);
|
|
12631
|
-
(0,
|
|
12794
|
+
(0, import_react91.useEffect)(() => {
|
|
12632
12795
|
if (title !== "" || !table.data) return;
|
|
12633
12796
|
setTitle(existing?.title ?? `Book a ${minutes}-minute ${table.data.name} appointment`);
|
|
12634
12797
|
}, [table.data, existing]);
|
|
12635
|
-
(0,
|
|
12798
|
+
(0, import_react91.useEffect)(() => {
|
|
12636
12799
|
if (!existing) return;
|
|
12637
12800
|
setMinutes(existing.slot_minutes);
|
|
12638
12801
|
}, [existing]);
|
|
12639
|
-
(0,
|
|
12802
|
+
(0, import_react91.useEffect)(() => {
|
|
12640
12803
|
if (!offer) return;
|
|
12641
12804
|
setWindows(draftWindows(offer));
|
|
12642
12805
|
setMinutes(offer.slot_minutes);
|
|
@@ -12645,7 +12808,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
12645
12808
|
setPerDay(offer.max_per_day);
|
|
12646
12809
|
setDays(offer.days);
|
|
12647
12810
|
}, [offer]);
|
|
12648
|
-
const availability = (0,
|
|
12811
|
+
const availability = (0, import_react91.useCallback)(
|
|
12649
12812
|
() => ({
|
|
12650
12813
|
slot_minutes: minutes,
|
|
12651
12814
|
buffer_minutes: buffer,
|
|
@@ -12898,8 +13061,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
12898
13061
|
}
|
|
12899
13062
|
|
|
12900
13063
|
// src/BookingSlots.tsx
|
|
12901
|
-
var
|
|
12902
|
-
var
|
|
13064
|
+
var import_react93 = require("react");
|
|
13065
|
+
var import_react94 = require("@ai-matrx/records/react");
|
|
12903
13066
|
var import_records11 = require("@ai-matrx/records");
|
|
12904
13067
|
var import_design_system46 = require("@ai-matrx/design-system");
|
|
12905
13068
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
@@ -12916,15 +13079,15 @@ var STATE_WORDS = {
|
|
|
12916
13079
|
full: "Every time you offered is taken."
|
|
12917
13080
|
};
|
|
12918
13081
|
function BookingSlots({ tableId, className }) {
|
|
12919
|
-
const client = (0,
|
|
13082
|
+
const client = (0, import_react94.useRecordsClient)();
|
|
12920
13083
|
const host = useRecordsUi();
|
|
12921
|
-
const [pages, setPages] = (0,
|
|
12922
|
-
const [error, setError] = (0,
|
|
12923
|
-
const [busy, setBusy] = (0,
|
|
12924
|
-
const [copied, setCopied] = (0,
|
|
12925
|
-
const [shown, setShown] = (0,
|
|
12926
|
-
const [building, setBuilding] = (0,
|
|
12927
|
-
const load = (0,
|
|
13084
|
+
const [pages, setPages] = (0, import_react93.useState)(null);
|
|
13085
|
+
const [error, setError] = (0, import_react93.useState)(null);
|
|
13086
|
+
const [busy, setBusy] = (0, import_react93.useState)(null);
|
|
13087
|
+
const [copied, setCopied] = (0, import_react93.useState)(null);
|
|
13088
|
+
const [shown, setShown] = (0, import_react93.useState)(null);
|
|
13089
|
+
const [building, setBuilding] = (0, import_react93.useState)(false);
|
|
13090
|
+
const load = (0, import_react93.useCallback)(async () => {
|
|
12928
13091
|
const answered = await client.bookings(tableId ? { table_id: tableId } : {});
|
|
12929
13092
|
if (!answered.ok) {
|
|
12930
13093
|
setError(answered.error);
|
|
@@ -12934,15 +13097,15 @@ function BookingSlots({ tableId, className }) {
|
|
|
12934
13097
|
setError(null);
|
|
12935
13098
|
setPages(answered.data);
|
|
12936
13099
|
}, [client, tableId]);
|
|
12937
|
-
(0,
|
|
13100
|
+
(0, import_react93.useEffect)(() => {
|
|
12938
13101
|
void load();
|
|
12939
13102
|
}, [load]);
|
|
12940
|
-
const subjectIds = (0,
|
|
13103
|
+
const subjectIds = (0, import_react93.useMemo)(
|
|
12941
13104
|
() => Array.from(new Set((pages ?? []).map((p) => p.table_id))),
|
|
12942
13105
|
[pages]
|
|
12943
13106
|
);
|
|
12944
|
-
const levels = (0,
|
|
12945
|
-
const toggle = (0,
|
|
13107
|
+
const levels = (0, import_react94.useMyLevels)(subjectIds);
|
|
13108
|
+
const toggle = (0, import_react93.useCallback)(
|
|
12946
13109
|
async (page) => {
|
|
12947
13110
|
setBusy(page.form_id);
|
|
12948
13111
|
const wanted = page.published_at === null || page.closed_at !== null;
|
|
@@ -12956,7 +13119,7 @@ function BookingSlots({ tableId, className }) {
|
|
|
12956
13119
|
},
|
|
12957
13120
|
[client, load]
|
|
12958
13121
|
);
|
|
12959
|
-
const copy = (0,
|
|
13122
|
+
const copy = (0, import_react93.useCallback)(async (url, formId) => {
|
|
12960
13123
|
try {
|
|
12961
13124
|
await navigator.clipboard.writeText(url);
|
|
12962
13125
|
setCopied(formId);
|
|
@@ -13091,14 +13254,14 @@ function nextInWords(page) {
|
|
|
13091
13254
|
}
|
|
13092
13255
|
|
|
13093
13256
|
// src/CaptureSheet.tsx
|
|
13094
|
-
var
|
|
13095
|
-
var
|
|
13257
|
+
var import_react97 = require("react");
|
|
13258
|
+
var import_react98 = require("@ai-matrx/records/react");
|
|
13096
13259
|
var import_design_system48 = require("@ai-matrx/design-system");
|
|
13097
13260
|
|
|
13098
13261
|
// src/CaptureRun.tsx
|
|
13099
|
-
var
|
|
13262
|
+
var import_react95 = require("react");
|
|
13100
13263
|
var import_records12 = require("@ai-matrx/records");
|
|
13101
|
-
var
|
|
13264
|
+
var import_react96 = require("@ai-matrx/records/react");
|
|
13102
13265
|
var import_design_system47 = require("@ai-matrx/design-system");
|
|
13103
13266
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
13104
13267
|
function controlFor(field) {
|
|
@@ -13137,21 +13300,21 @@ function whereWeAre(timeoutMs = 4e3) {
|
|
|
13137
13300
|
});
|
|
13138
13301
|
}
|
|
13139
13302
|
function CaptureRun({ sheetId, face: given, className }) {
|
|
13140
|
-
const client = (0,
|
|
13303
|
+
const client = (0, import_react96.useRecordsClient)();
|
|
13141
13304
|
const host = useRecordsUi();
|
|
13142
|
-
const [face, setFace] = (0,
|
|
13143
|
-
const [loadFailed, setLoadFailed] = (0,
|
|
13144
|
-
const [at, setAt] = (0,
|
|
13145
|
-
const [answers, setAnswers] = (0,
|
|
13146
|
-
const [files, setFiles] = (0,
|
|
13147
|
-
const [missing, setMissing] = (0,
|
|
13148
|
-
const [done, setDone] = (0,
|
|
13149
|
-
const [counts, setCounts] = (0,
|
|
13150
|
-
const [items, setItems] = (0,
|
|
13151
|
-
const [lastSynced, setLastSynced] = (0,
|
|
13152
|
-
const [sending, setSending] = (0,
|
|
13153
|
-
const queueRef = (0,
|
|
13154
|
-
(0,
|
|
13305
|
+
const [face, setFace] = (0, import_react95.useState)(given);
|
|
13306
|
+
const [loadFailed, setLoadFailed] = (0, import_react95.useState)(null);
|
|
13307
|
+
const [at, setAt] = (0, import_react95.useState)(0);
|
|
13308
|
+
const [answers, setAnswers] = (0, import_react95.useState)({});
|
|
13309
|
+
const [files, setFiles] = (0, import_react95.useState)({});
|
|
13310
|
+
const [missing, setMissing] = (0, import_react95.useState)(null);
|
|
13311
|
+
const [done, setDone] = (0, import_react95.useState)(null);
|
|
13312
|
+
const [counts, setCounts] = (0, import_react95.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
|
|
13313
|
+
const [items, setItems] = (0, import_react95.useState)([]);
|
|
13314
|
+
const [lastSynced, setLastSynced] = (0, import_react95.useState)(null);
|
|
13315
|
+
const [sending, setSending] = (0, import_react95.useState)(false);
|
|
13316
|
+
const queueRef = (0, import_react95.useRef)(null);
|
|
13317
|
+
(0, import_react95.useEffect)(() => {
|
|
13155
13318
|
const q2 = (0, import_records12.openCaptureQueue)({
|
|
13156
13319
|
onChange: (c, all) => {
|
|
13157
13320
|
setCounts(c);
|
|
@@ -13189,7 +13352,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
13189
13352
|
void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
|
|
13190
13353
|
return () => q2.dispose();
|
|
13191
13354
|
}, [client, host]);
|
|
13192
|
-
(0,
|
|
13355
|
+
(0, import_react95.useEffect)(() => {
|
|
13193
13356
|
if (given !== void 0) return;
|
|
13194
13357
|
let cancelled = false;
|
|
13195
13358
|
void client.captureOpen({ sheet_id: sheetId }).then((res) => {
|
|
@@ -13201,7 +13364,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
13201
13364
|
cancelled = true;
|
|
13202
13365
|
};
|
|
13203
13366
|
}, [client, given, sheetId]);
|
|
13204
|
-
const questions = (0,
|
|
13367
|
+
const questions = (0, import_react95.useMemo)(() => {
|
|
13205
13368
|
const asked = face?.presentation?.questions ?? [];
|
|
13206
13369
|
if (asked.length > 0) return asked;
|
|
13207
13370
|
return (face?.fields ?? []).map((f) => ({
|
|
@@ -13211,11 +13374,11 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
13211
13374
|
required: f.required
|
|
13212
13375
|
}));
|
|
13213
13376
|
}, [face]);
|
|
13214
|
-
const fieldOf = (0,
|
|
13377
|
+
const fieldOf = (0, import_react95.useCallback)(
|
|
13215
13378
|
(key) => (face?.fields ?? []).find((f) => f.key === key),
|
|
13216
13379
|
[face]
|
|
13217
13380
|
);
|
|
13218
|
-
const sync = (0,
|
|
13381
|
+
const sync = (0, import_react95.useCallback)(async () => {
|
|
13219
13382
|
const q2 = queueRef.current;
|
|
13220
13383
|
if (!q2) return;
|
|
13221
13384
|
setSending(true);
|
|
@@ -13228,7 +13391,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
13228
13391
|
setSending(false);
|
|
13229
13392
|
}
|
|
13230
13393
|
}, []);
|
|
13231
|
-
const answered = (0,
|
|
13394
|
+
const answered = (0, import_react95.useCallback)(
|
|
13232
13395
|
(key) => {
|
|
13233
13396
|
if (files[key]) return true;
|
|
13234
13397
|
const v = answers[key];
|
|
@@ -13495,21 +13658,21 @@ function AdHocCaptureSheet({
|
|
|
13495
13658
|
attachmentField,
|
|
13496
13659
|
className
|
|
13497
13660
|
}) {
|
|
13498
|
-
const client = (0,
|
|
13661
|
+
const client = (0, import_react98.useRecordsClient)();
|
|
13499
13662
|
const host = useRecordsUi();
|
|
13500
|
-
const table = (0,
|
|
13501
|
-
const fields = (0,
|
|
13502
|
-
const [mode, setMode] = (0,
|
|
13503
|
-
const [reading, setReading] = (0,
|
|
13504
|
-
const [note, setNote] = (0,
|
|
13505
|
-
const [fileId, setFileId] = (0,
|
|
13506
|
-
const [pending, setPending] = (0,
|
|
13507
|
-
const [saved, setSaved] = (0,
|
|
13508
|
-
const [error, setError] = (0,
|
|
13509
|
-
const [uploadError, setUploadError] = (0,
|
|
13510
|
-
const [flushing, setFlushing] = (0,
|
|
13511
|
-
const queue = (0,
|
|
13512
|
-
const keep = (0,
|
|
13663
|
+
const table = (0, import_react98.useTable)(tableId);
|
|
13664
|
+
const fields = (0, import_react98.useFields)(tableId);
|
|
13665
|
+
const [mode, setMode] = (0, import_react97.useState)("reading");
|
|
13666
|
+
const [reading, setReading] = (0, import_react97.useState)("");
|
|
13667
|
+
const [note, setNote] = (0, import_react97.useState)("");
|
|
13668
|
+
const [fileId, setFileId] = (0, import_react97.useState)(null);
|
|
13669
|
+
const [pending, setPending] = (0, import_react97.useState)(null);
|
|
13670
|
+
const [saved, setSaved] = (0, import_react97.useState)([]);
|
|
13671
|
+
const [error, setError] = (0, import_react97.useState)(null);
|
|
13672
|
+
const [uploadError, setUploadError] = (0, import_react97.useState)(null);
|
|
13673
|
+
const [flushing, setFlushing] = (0, import_react97.useState)(false);
|
|
13674
|
+
const queue = (0, import_react97.useRef)([]);
|
|
13675
|
+
const keep = (0, import_react97.useCallback)(
|
|
13513
13676
|
async (next) => {
|
|
13514
13677
|
queue.current = next;
|
|
13515
13678
|
setPending(next);
|
|
@@ -13517,7 +13680,7 @@ function AdHocCaptureSheet({
|
|
|
13517
13680
|
},
|
|
13518
13681
|
[host]
|
|
13519
13682
|
);
|
|
13520
|
-
(0,
|
|
13683
|
+
(0, import_react97.useEffect)(() => {
|
|
13521
13684
|
let cancelled = false;
|
|
13522
13685
|
void (async () => {
|
|
13523
13686
|
const held = host.captureQueue ? await host.captureQueue.load() : [];
|
|
@@ -13529,7 +13692,7 @@ function AdHocCaptureSheet({
|
|
|
13529
13692
|
cancelled = true;
|
|
13530
13693
|
};
|
|
13531
13694
|
}, [host]);
|
|
13532
|
-
const resolved = (0,
|
|
13695
|
+
const resolved = (0, import_react97.useCallback)(() => {
|
|
13533
13696
|
const all = fields.data ?? [];
|
|
13534
13697
|
return {
|
|
13535
13698
|
reading: readingField ?? all.find((f) => f.type === "range")?.key ?? null,
|
|
@@ -13537,7 +13700,7 @@ function AdHocCaptureSheet({
|
|
|
13537
13700
|
attachment: attachmentField ?? all.find((f) => f.format === "file" || f.format === "image")?.key ?? null
|
|
13538
13701
|
};
|
|
13539
13702
|
}, [attachmentField, fields.data, noteField, readingField, table.data]);
|
|
13540
|
-
const flush = (0,
|
|
13703
|
+
const flush = (0, import_react97.useCallback)(async () => {
|
|
13541
13704
|
if (flushing || queue.current.length === 0) return;
|
|
13542
13705
|
setFlushing(true);
|
|
13543
13706
|
const left = [];
|
|
@@ -13696,18 +13859,18 @@ function AdHocCaptureSheet({
|
|
|
13696
13859
|
}
|
|
13697
13860
|
|
|
13698
13861
|
// src/PortalShell.tsx
|
|
13699
|
-
var
|
|
13700
|
-
var
|
|
13862
|
+
var import_react99 = require("react");
|
|
13863
|
+
var import_react100 = require("@ai-matrx/records/react");
|
|
13701
13864
|
var import_design_system49 = require("@ai-matrx/design-system");
|
|
13702
13865
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
13703
13866
|
function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
13704
|
-
const client = (0,
|
|
13705
|
-
const [card, setCard] = (0,
|
|
13706
|
-
const [reach, setReach] = (0,
|
|
13707
|
-
const [error, setError] = (0,
|
|
13708
|
-
const [open, setOpen] = (0,
|
|
13709
|
-
const [sending, setSending] = (0,
|
|
13710
|
-
const load = (0,
|
|
13867
|
+
const client = (0, import_react100.useRecordsClient)();
|
|
13868
|
+
const [card, setCard] = (0, import_react99.useState)(null);
|
|
13869
|
+
const [reach, setReach] = (0, import_react99.useState)(null);
|
|
13870
|
+
const [error, setError] = (0, import_react99.useState)(null);
|
|
13871
|
+
const [open, setOpen] = (0, import_react99.useState)(null);
|
|
13872
|
+
const [sending, setSending] = (0, import_react99.useState)(false);
|
|
13873
|
+
const load = (0, import_react99.useCallback)(async () => {
|
|
13711
13874
|
const who = await client.externalPrincipalCard();
|
|
13712
13875
|
if (!who.ok) {
|
|
13713
13876
|
setError(who.error);
|
|
@@ -13722,7 +13885,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
|
13722
13885
|
}
|
|
13723
13886
|
setReach(reached.data.map((row) => row.resource_id));
|
|
13724
13887
|
}, [client, resourceType]);
|
|
13725
|
-
(0,
|
|
13888
|
+
(0, import_react99.useEffect)(() => {
|
|
13726
13889
|
void load();
|
|
13727
13890
|
}, [load]);
|
|
13728
13891
|
if (error) {
|
|
@@ -13780,9 +13943,9 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
|
13780
13943
|
] });
|
|
13781
13944
|
}
|
|
13782
13945
|
function PortalRow({ tableId, recordId }) {
|
|
13783
|
-
const client = (0,
|
|
13784
|
-
const [title, setTitle] = (0,
|
|
13785
|
-
(0,
|
|
13946
|
+
const client = (0, import_react100.useRecordsClient)();
|
|
13947
|
+
const [title, setTitle] = (0, import_react99.useState)(null);
|
|
13948
|
+
(0, import_react99.useEffect)(() => {
|
|
13786
13949
|
let cancelled = false;
|
|
13787
13950
|
void client.recordRead({ record_id: recordId }).then((answered) => {
|
|
13788
13951
|
if (cancelled) return;
|
|
@@ -13802,18 +13965,18 @@ function PortalRow({ tableId, recordId }) {
|
|
|
13802
13965
|
}
|
|
13803
13966
|
|
|
13804
13967
|
// src/PublicViewPage.tsx
|
|
13805
|
-
var
|
|
13806
|
-
var
|
|
13968
|
+
var import_react101 = require("react");
|
|
13969
|
+
var import_react102 = require("@ai-matrx/records/react");
|
|
13807
13970
|
var import_design_system50 = require("@ai-matrx/design-system");
|
|
13808
13971
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
13809
13972
|
function PublicViewPage({ slug, className }) {
|
|
13810
|
-
const client = (0,
|
|
13811
|
-
const [binding, setBinding] = (0,
|
|
13812
|
-
const [rows, setRows] = (0,
|
|
13813
|
-
const [fields, setFields] = (0,
|
|
13814
|
-
const [error, setError] = (0,
|
|
13815
|
-
const [gap, setGap] = (0,
|
|
13816
|
-
const load = (0,
|
|
13973
|
+
const client = (0, import_react102.useRecordsClient)();
|
|
13974
|
+
const [binding, setBinding] = (0, import_react101.useState)(null);
|
|
13975
|
+
const [rows, setRows] = (0, import_react101.useState)(null);
|
|
13976
|
+
const [fields, setFields] = (0, import_react101.useState)(null);
|
|
13977
|
+
const [error, setError] = (0, import_react101.useState)(null);
|
|
13978
|
+
const [gap, setGap] = (0, import_react101.useState)(null);
|
|
13979
|
+
const load = (0, import_react101.useCallback)(async () => {
|
|
13817
13980
|
const notice = await client.worldPublishGapNotice();
|
|
13818
13981
|
if (notice.ok) setGap(notice.data);
|
|
13819
13982
|
const resolved = await client.resolvePublishBinding({ slug });
|
|
@@ -13846,7 +14009,7 @@ function PublicViewPage({ slug, className }) {
|
|
|
13846
14009
|
}
|
|
13847
14010
|
setRows([{ id: found.resource_id, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
|
|
13848
14011
|
}, [client, slug]);
|
|
13849
|
-
(0,
|
|
14012
|
+
(0, import_react101.useEffect)(() => {
|
|
13850
14013
|
void load();
|
|
13851
14014
|
}, [load]);
|
|
13852
14015
|
if (error) return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(RefusalNotice, { error, className });
|
|
@@ -13883,10 +14046,10 @@ function PublicRow({ row, fields }) {
|
|
|
13883
14046
|
}
|
|
13884
14047
|
|
|
13885
14048
|
// src/EmbedFrame.tsx
|
|
13886
|
-
var
|
|
13887
|
-
var import_react103 = require("@ai-matrx/records/react");
|
|
13888
|
-
var import_design_system51 = require("@ai-matrx/design-system");
|
|
14049
|
+
var import_react103 = require("react");
|
|
13889
14050
|
var import_react104 = require("@ai-matrx/records/react");
|
|
14051
|
+
var import_design_system51 = require("@ai-matrx/design-system");
|
|
14052
|
+
var import_react105 = require("@ai-matrx/records/react");
|
|
13890
14053
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
13891
14054
|
function EmbedFrame({
|
|
13892
14055
|
tableId,
|
|
@@ -13896,18 +14059,18 @@ function EmbedFrame({
|
|
|
13896
14059
|
embedUrl,
|
|
13897
14060
|
className
|
|
13898
14061
|
}) {
|
|
13899
|
-
const client = (0,
|
|
14062
|
+
const client = (0, import_react104.useRecordsClient)();
|
|
13900
14063
|
const host = useRecordsUi();
|
|
13901
|
-
const table = (0,
|
|
14064
|
+
const table = (0, import_react105.useTable)(tableId);
|
|
13902
14065
|
const rights = useTableRights(table.data);
|
|
13903
|
-
const [origins, setOrigins] = (0,
|
|
13904
|
-
const [secret, setSecret] = (0,
|
|
13905
|
-
const [tokenId, setTokenId] = (0,
|
|
13906
|
-
const [error, setError] = (0,
|
|
13907
|
-
const [busy, setBusy] = (0,
|
|
14066
|
+
const [origins, setOrigins] = (0, import_react103.useState)("");
|
|
14067
|
+
const [secret, setSecret] = (0, import_react103.useState)(null);
|
|
14068
|
+
const [tokenId, setTokenId] = (0, import_react103.useState)(null);
|
|
14069
|
+
const [error, setError] = (0, import_react103.useState)(null);
|
|
14070
|
+
const [busy, setBusy] = (0, import_react103.useState)(false);
|
|
13908
14071
|
const mode = formId ? "write" : "read";
|
|
13909
14072
|
const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
|
|
13910
|
-
const issue = (0,
|
|
14073
|
+
const issue = (0, import_react103.useCallback)(async () => {
|
|
13911
14074
|
setBusy(true);
|
|
13912
14075
|
setError(null);
|
|
13913
14076
|
const minted = await client.anonTokenIssue({
|
|
@@ -13926,7 +14089,7 @@ function EmbedFrame({
|
|
|
13926
14089
|
setTokenId(minted.data.token_id);
|
|
13927
14090
|
host.notify?.success("Embed token issued. Copy it now \u2014 it is never shown again.");
|
|
13928
14091
|
}, [client, formId, host, mode, parsed, recordId, savedViewId]);
|
|
13929
|
-
const revoke = (0,
|
|
14092
|
+
const revoke = (0, import_react103.useCallback)(async () => {
|
|
13930
14093
|
if (!tokenId) return;
|
|
13931
14094
|
setBusy(true);
|
|
13932
14095
|
const done = await client.anonTokenRevoke({ token_id: tokenId });
|
|
@@ -13990,13 +14153,13 @@ function EmbedFrame({
|
|
|
13990
14153
|
] });
|
|
13991
14154
|
}
|
|
13992
14155
|
function useEmbedHandshake(args) {
|
|
13993
|
-
const client = (0,
|
|
13994
|
-
const [binding, setBinding] = (0,
|
|
13995
|
-
const [error, setError] = (0,
|
|
13996
|
-
const [loading, setLoading] = (0,
|
|
14156
|
+
const client = (0, import_react104.useRecordsClient)();
|
|
14157
|
+
const [binding, setBinding] = (0, import_react103.useState)(null);
|
|
14158
|
+
const [error, setError] = (0, import_react103.useState)(null);
|
|
14159
|
+
const [loading, setLoading] = (0, import_react103.useState)(true);
|
|
13997
14160
|
const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
|
|
13998
14161
|
const { secret, requiredMode } = args;
|
|
13999
|
-
(0,
|
|
14162
|
+
(0, import_react103.useEffect)(() => {
|
|
14000
14163
|
let cancelled = false;
|
|
14001
14164
|
setLoading(true);
|
|
14002
14165
|
setError(null);
|
|
@@ -14018,7 +14181,7 @@ function useEmbedHandshake(args) {
|
|
|
14018
14181
|
}
|
|
14019
14182
|
|
|
14020
14183
|
// src/RecordsMount.tsx
|
|
14021
|
-
var
|
|
14184
|
+
var import_react106 = require("@ai-matrx/records/react");
|
|
14022
14185
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
14023
14186
|
var STORE_DECIDES_REASON = "This host offers exactly what the record store says this person may do: the level comes back with the table on the read door, so a control they cannot use is never drawn in the first place.";
|
|
14024
14187
|
function storeDecidesRights(_table) {
|
|
@@ -14032,7 +14195,7 @@ function RecordsMount({
|
|
|
14032
14195
|
}) {
|
|
14033
14196
|
const bound = { ...host ?? {} };
|
|
14034
14197
|
void letTheStoreDecideRights;
|
|
14035
|
-
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react106.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordsUiProvider, { value: bound, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordLabelProvider, { children }) }) });
|
|
14036
14199
|
}
|
|
14037
14200
|
function personActor(userId) {
|
|
14038
14201
|
return userId ? { actor: "user", user_id: userId } : { actor: "user" };
|
|
@@ -14051,8 +14214,8 @@ function recordsDataSource(client, fallbackSchema = "custom") {
|
|
|
14051
14214
|
}
|
|
14052
14215
|
|
|
14053
14216
|
// src/TablesHome.tsx
|
|
14054
|
-
var
|
|
14055
|
-
var
|
|
14217
|
+
var import_react107 = require("react");
|
|
14218
|
+
var import_react108 = require("@ai-matrx/records/react");
|
|
14056
14219
|
var import_design_system52 = require("@ai-matrx/design-system");
|
|
14057
14220
|
|
|
14058
14221
|
// src/createTable.ts
|
|
@@ -14188,15 +14351,15 @@ function laneFor(table) {
|
|
|
14188
14351
|
return "organization";
|
|
14189
14352
|
}
|
|
14190
14353
|
function TablesHome({ onOpenTable, className }) {
|
|
14191
|
-
const client = (0,
|
|
14192
|
-
const tables = (0,
|
|
14193
|
-
const [creating, setCreating] = (0,
|
|
14194
|
-
const [name, setName] = (0,
|
|
14195
|
-
const [busy, setBusy] = (0,
|
|
14196
|
-
const [error, setError] = (0,
|
|
14197
|
-
const [importInto, setImportInto] = (0,
|
|
14198
|
-
const [boards, setBoards] = (0,
|
|
14199
|
-
(0,
|
|
14354
|
+
const client = (0, import_react108.useRecordsClient)();
|
|
14355
|
+
const tables = (0, import_react108.useTables)();
|
|
14356
|
+
const [creating, setCreating] = (0, import_react107.useState)(false);
|
|
14357
|
+
const [name, setName] = (0, import_react107.useState)("");
|
|
14358
|
+
const [busy, setBusy] = (0, import_react107.useState)(false);
|
|
14359
|
+
const [error, setError] = (0, import_react107.useState)(null);
|
|
14360
|
+
const [importInto, setImportInto] = (0, import_react107.useState)(null);
|
|
14361
|
+
const [boards, setBoards] = (0, import_react107.useState)(null);
|
|
14362
|
+
(0, import_react107.useEffect)(() => {
|
|
14200
14363
|
let cancelled = false;
|
|
14201
14364
|
void client.dashboards({}).then((result) => {
|
|
14202
14365
|
if (cancelled) return;
|
|
@@ -14206,7 +14369,7 @@ function TablesHome({ onOpenTable, className }) {
|
|
|
14206
14369
|
cancelled = true;
|
|
14207
14370
|
};
|
|
14208
14371
|
}, [client]);
|
|
14209
|
-
const create = (0,
|
|
14372
|
+
const create = (0, import_react107.useCallback)(
|
|
14210
14373
|
async (mode) => {
|
|
14211
14374
|
const trimmed = name.trim();
|
|
14212
14375
|
if (!trimmed) return;
|
|
@@ -14330,8 +14493,8 @@ function TablesHome({ onOpenTable, className }) {
|
|
|
14330
14493
|
}
|
|
14331
14494
|
|
|
14332
14495
|
// src/TablePage.tsx
|
|
14333
|
-
var
|
|
14334
|
-
var
|
|
14496
|
+
var import_react109 = require("react");
|
|
14497
|
+
var import_react110 = require("@ai-matrx/records/react");
|
|
14335
14498
|
var import_design_system53 = require("@ai-matrx/design-system");
|
|
14336
14499
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
14337
14500
|
var TABLE_NOT_REACHABLE = "This table is not in the organization you are working in, so there is nothing here to show. Switch to the organization that owns it and open it again \u2014 or it may have been deleted.";
|
|
@@ -14364,29 +14527,29 @@ function TablePage({
|
|
|
14364
14527
|
activeRecordId,
|
|
14365
14528
|
className
|
|
14366
14529
|
}) {
|
|
14367
|
-
const client = (0,
|
|
14368
|
-
const table = (0,
|
|
14530
|
+
const client = (0, import_react110.useRecordsClient)();
|
|
14531
|
+
const table = (0, import_react110.useTable)(tableId);
|
|
14369
14532
|
const rights = useTableRights(table.data);
|
|
14370
|
-
const organizationId = (0,
|
|
14371
|
-
const [view, setView] = (0,
|
|
14533
|
+
const organizationId = (0, import_react110.useRecordsClient)().config.organizationId;
|
|
14534
|
+
const [view, setView] = (0, import_react109.useState)(null);
|
|
14372
14535
|
const opening = openingRail(activeRecordId);
|
|
14373
|
-
const [asking, setAsking] = (0,
|
|
14374
|
-
const [surface, setSurface] = (0,
|
|
14536
|
+
const [asking, setAsking] = (0, import_react109.useState)(null);
|
|
14537
|
+
const [surface, setSurface] = (0, import_react109.useState)({
|
|
14375
14538
|
main: activeDashboardId ? "dashboards" : "records",
|
|
14376
14539
|
rail: opening.rail
|
|
14377
14540
|
});
|
|
14378
14541
|
const { main, rail } = surface;
|
|
14379
14542
|
const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
|
|
14380
|
-
const [openRecord, setOpenRecord] = (0,
|
|
14543
|
+
const [openRecord, setOpenRecord] = (0, import_react109.useState)(opening.record);
|
|
14381
14544
|
const viewVersion = useRecordVersion(view?.id ?? null);
|
|
14382
14545
|
const press = (pressed) => setSurface((now) => chooseSurface(now, pressed));
|
|
14383
14546
|
const show = (next) => press({ rail: next });
|
|
14384
|
-
(0,
|
|
14547
|
+
(0, import_react109.useEffect)(() => {
|
|
14385
14548
|
if (!activeRecordId) return;
|
|
14386
14549
|
setOpenRecord(activeRecordId);
|
|
14387
14550
|
setSurface((now) => ({ ...now, rail: "record" }));
|
|
14388
14551
|
}, [activeRecordId]);
|
|
14389
|
-
const patchView = (0,
|
|
14552
|
+
const patchView = (0, import_react109.useCallback)(
|
|
14390
14553
|
async (patch) => {
|
|
14391
14554
|
const current = view;
|
|
14392
14555
|
if (!current) return;
|