@ai-matrx/records-ui 0.76.0 → 0.77.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/CHANGELOG.md +63 -0
- package/dist/index.cjs +322 -291
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +248 -217
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -11622,14 +11622,41 @@ function SubscriptionsPanel({ tableId, className }) {
|
|
|
11622
11622
|
}
|
|
11623
11623
|
|
|
11624
11624
|
// src/FormBuilder.tsx
|
|
11625
|
-
var
|
|
11626
|
-
var
|
|
11625
|
+
var import_react83 = require("react");
|
|
11626
|
+
var import_react84 = require("@ai-matrx/records/react");
|
|
11627
|
+
|
|
11628
|
+
// src/publish-gate.ts
|
|
11629
|
+
var import_react79 = require("react");
|
|
11630
|
+
var import_react80 = require("@ai-matrx/records/react");
|
|
11631
|
+
var PUBLISH_NEEDS_THE_STORE_ON = "This organization has its record store switched off, so publishing would hand you a link that opens nothing. An owner or an administrator turns it on under Database settings, on the unified data screen \u2014 everything you have already built here is kept and starts working the moment they do.";
|
|
11632
|
+
function usePublishGate() {
|
|
11633
|
+
const client = (0, import_react80.useRecordsClient)();
|
|
11634
|
+
const [storeOpen, setStoreOpen] = (0, import_react79.useState)(null);
|
|
11635
|
+
(0, import_react79.useEffect)(() => {
|
|
11636
|
+
let alive = true;
|
|
11637
|
+
void (async () => {
|
|
11638
|
+
const answered = await client.storeIsOpen();
|
|
11639
|
+
if (!alive) return;
|
|
11640
|
+
setStoreOpen(answered.ok ? answered.data : null);
|
|
11641
|
+
})();
|
|
11642
|
+
return () => {
|
|
11643
|
+
alive = false;
|
|
11644
|
+
};
|
|
11645
|
+
}, [client]);
|
|
11646
|
+
return {
|
|
11647
|
+
storeOpen,
|
|
11648
|
+
blocked: storeOpen === false,
|
|
11649
|
+
why: storeOpen === false ? PUBLISH_NEEDS_THE_STORE_ON : null
|
|
11650
|
+
};
|
|
11651
|
+
}
|
|
11652
|
+
|
|
11653
|
+
// src/FormBuilder.tsx
|
|
11627
11654
|
var import_records10 = require("@ai-matrx/records");
|
|
11628
11655
|
var import_design_system40 = require("@ai-matrx/design-system");
|
|
11629
11656
|
|
|
11630
11657
|
// src/FormRunner.tsx
|
|
11631
|
-
var
|
|
11632
|
-
var
|
|
11658
|
+
var import_react81 = require("react");
|
|
11659
|
+
var import_react82 = require("@ai-matrx/records/react");
|
|
11633
11660
|
var import_design_system39 = require("@ai-matrx/design-system");
|
|
11634
11661
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
11635
11662
|
function FormRunner(props) {
|
|
@@ -11639,10 +11666,10 @@ function FormRunner(props) {
|
|
|
11639
11666
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ConnectedFormRunner, { ...props });
|
|
11640
11667
|
}
|
|
11641
11668
|
function ConnectedFormRunner(props) {
|
|
11642
|
-
const client = (0,
|
|
11643
|
-
const fields = (0,
|
|
11669
|
+
const client = (0, import_react82.useOptionalRecordsClient)();
|
|
11670
|
+
const fields = (0, import_react82.useFields)(props.form.subject);
|
|
11644
11671
|
const { form, className } = props;
|
|
11645
|
-
const submit = (0,
|
|
11672
|
+
const submit = (0, import_react81.useCallback)(
|
|
11646
11673
|
async (values) => {
|
|
11647
11674
|
if (!client) {
|
|
11648
11675
|
return {
|
|
@@ -11665,7 +11692,7 @@ function ConnectedFormRunner(props) {
|
|
|
11665
11692
|
},
|
|
11666
11693
|
[client, form]
|
|
11667
11694
|
);
|
|
11668
|
-
const evaluate = (0,
|
|
11695
|
+
const evaluate = (0, import_react81.useCallback)(
|
|
11669
11696
|
async (expr, values) => {
|
|
11670
11697
|
if (!client) return null;
|
|
11671
11698
|
const answered = await client.ruleEval({ expr, values });
|
|
@@ -11699,16 +11726,16 @@ function FormStage({
|
|
|
11699
11726
|
connected = false
|
|
11700
11727
|
}) {
|
|
11701
11728
|
const host = useRecordsUi();
|
|
11702
|
-
const [answers, setAnswers] = (0,
|
|
11703
|
-
const [at, setAt] = (0,
|
|
11704
|
-
const [error, setError] = (0,
|
|
11705
|
-
const [refusal, setRefusal] = (0,
|
|
11706
|
-
const [writing, setWriting] = (0,
|
|
11707
|
-
const [done, setDone] = (0,
|
|
11708
|
-
const [hidden, setHidden] = (0,
|
|
11709
|
-
const decoy = (0,
|
|
11710
|
-
const stage = (0,
|
|
11711
|
-
const questions = (0,
|
|
11729
|
+
const [answers, setAnswers] = (0, import_react81.useState)({});
|
|
11730
|
+
const [at, setAt] = (0, import_react81.useState)(0);
|
|
11731
|
+
const [error, setError] = (0, import_react81.useState)(null);
|
|
11732
|
+
const [refusal, setRefusal] = (0, import_react81.useState)(null);
|
|
11733
|
+
const [writing, setWriting] = (0, import_react81.useState)(false);
|
|
11734
|
+
const [done, setDone] = (0, import_react81.useState)(null);
|
|
11735
|
+
const [hidden, setHidden] = (0, import_react81.useState)({});
|
|
11736
|
+
const decoy = (0, import_react81.useRef)("");
|
|
11737
|
+
const stage = (0, import_react81.useRef)(null);
|
|
11738
|
+
const questions = (0, import_react81.useMemo)(() => {
|
|
11712
11739
|
const byKey = new Map((fields ?? []).map((f) => [f.key, f]));
|
|
11713
11740
|
return (form.questions ?? []).map((q) => {
|
|
11714
11741
|
const field = byKey.get(q.field) ?? null;
|
|
@@ -11722,7 +11749,7 @@ function FormStage({
|
|
|
11722
11749
|
};
|
|
11723
11750
|
});
|
|
11724
11751
|
}, [fields, form.questions]);
|
|
11725
|
-
(0,
|
|
11752
|
+
(0, import_react81.useEffect)(() => {
|
|
11726
11753
|
let cancelled = false;
|
|
11727
11754
|
const conditional = questions.filter((q) => q.showIf);
|
|
11728
11755
|
if (conditional.length === 0 || !evaluate) return;
|
|
@@ -11756,7 +11783,7 @@ function FormStage({
|
|
|
11756
11783
|
const v = answers[q.key];
|
|
11757
11784
|
return q.required && (v === void 0 || v === null || v === "");
|
|
11758
11785
|
});
|
|
11759
|
-
const submit = (0,
|
|
11786
|
+
const submit = (0, import_react81.useCallback)(async () => {
|
|
11760
11787
|
if (preview) {
|
|
11761
11788
|
setDone("preview");
|
|
11762
11789
|
return;
|
|
@@ -11793,7 +11820,7 @@ function FormStage({
|
|
|
11793
11820
|
if (event.shiftKey) retreat();
|
|
11794
11821
|
else advance();
|
|
11795
11822
|
}
|
|
11796
|
-
(0,
|
|
11823
|
+
(0, import_react81.useEffect)(() => {
|
|
11797
11824
|
const input = stage.current?.querySelector(
|
|
11798
11825
|
"input:not([tabindex='-1']), textarea, select, [role='combobox']"
|
|
11799
11826
|
);
|
|
@@ -11887,7 +11914,7 @@ function Question({
|
|
|
11887
11914
|
onChange,
|
|
11888
11915
|
upload
|
|
11889
11916
|
}) {
|
|
11890
|
-
const [uploadError, setUploadError] = (0,
|
|
11917
|
+
const [uploadError, setUploadError] = (0, import_react81.useState)(null);
|
|
11891
11918
|
const field = question.field;
|
|
11892
11919
|
if (!field) return null;
|
|
11893
11920
|
const id = `form-${field.key}`;
|
|
@@ -11944,23 +11971,24 @@ function whyNotAskable(fields, hidden = []) {
|
|
|
11944
11971
|
// src/FormBuilder.tsx
|
|
11945
11972
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
11946
11973
|
function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
|
|
11947
|
-
const client = (0,
|
|
11974
|
+
const client = (0, import_react84.useRecordsClient)();
|
|
11975
|
+
const publishGate = usePublishGate();
|
|
11948
11976
|
const host = useRecordsUi();
|
|
11949
11977
|
const claimSeed = useSeedGuard();
|
|
11950
|
-
const table = (0,
|
|
11978
|
+
const table = (0, import_react84.useTable)(tableId);
|
|
11951
11979
|
const rights = useTableRights(table.data);
|
|
11952
|
-
const fields = (0,
|
|
11953
|
-
const [forms, setForms] = (0,
|
|
11954
|
-
const [error, setError] = (0,
|
|
11955
|
-
const [activeId, setActiveId] = (0,
|
|
11956
|
-
const [draft, setDraft] = (0,
|
|
11957
|
-
const [saving, setSaving] = (0,
|
|
11958
|
-
const [saved, setSaved] = (0,
|
|
11959
|
-
const [publishing, setPublishing] = (0,
|
|
11960
|
-
const [copied, setCopied] = (0,
|
|
11961
|
-
const [shownUrl, setShownUrl] = (0,
|
|
11980
|
+
const fields = (0, import_react84.useFields)(tableId);
|
|
11981
|
+
const [forms, setForms] = (0, import_react83.useState)(null);
|
|
11982
|
+
const [error, setError] = (0, import_react83.useState)(null);
|
|
11983
|
+
const [activeId, setActiveId] = (0, import_react83.useState)(activeFormId ?? null);
|
|
11984
|
+
const [draft, setDraft] = (0, import_react83.useState)(null);
|
|
11985
|
+
const [saving, setSaving] = (0, import_react83.useState)(false);
|
|
11986
|
+
const [saved, setSaved] = (0, import_react83.useState)(null);
|
|
11987
|
+
const [publishing, setPublishing] = (0, import_react83.useState)(false);
|
|
11988
|
+
const [copied, setCopied] = (0, import_react83.useState)(false);
|
|
11989
|
+
const [shownUrl, setShownUrl] = (0, import_react83.useState)(null);
|
|
11962
11990
|
const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
|
|
11963
|
-
const load = (0,
|
|
11991
|
+
const load = (0, import_react83.useCallback)(async () => {
|
|
11964
11992
|
const answered = await client.forms({ table_id: tableId });
|
|
11965
11993
|
if (!answered.ok) {
|
|
11966
11994
|
setError(answered.error);
|
|
@@ -11987,17 +12015,17 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
|
|
|
11987
12015
|
setError(null);
|
|
11988
12016
|
setForms(mine);
|
|
11989
12017
|
}, [client, tableId, seed, claimSeed]);
|
|
11990
|
-
(0,
|
|
12018
|
+
(0, import_react83.useEffect)(() => {
|
|
11991
12019
|
void load();
|
|
11992
12020
|
}, [load]);
|
|
11993
|
-
(0,
|
|
12021
|
+
(0, import_react83.useEffect)(() => {
|
|
11994
12022
|
if (!forms || forms.length === 0) return;
|
|
11995
12023
|
const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
|
|
11996
12024
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
11997
12025
|
setDraft(chosen);
|
|
11998
12026
|
onActiveForm?.(chosen);
|
|
11999
12027
|
}, [forms, activeFormId]);
|
|
12000
|
-
const byKey = (0,
|
|
12028
|
+
const byKey = (0, import_react83.useMemo)(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
|
|
12001
12029
|
function patch(change) {
|
|
12002
12030
|
setDraft((prev) => prev ? { ...prev, ...change } : prev);
|
|
12003
12031
|
setSaved(null);
|
|
@@ -12101,8 +12129,8 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
|
|
|
12101
12129
|
{
|
|
12102
12130
|
url: `${publicOrigin}${(0, import_records10.publicFormPath)(draft.id)}`,
|
|
12103
12131
|
state: draft.state,
|
|
12104
|
-
mayPublish: rights.structure,
|
|
12105
|
-
why: rights.why("structure"),
|
|
12132
|
+
mayPublish: rights.structure && !publishGate.blocked,
|
|
12133
|
+
why: publishGate.why ?? rights.why("structure"),
|
|
12106
12134
|
busy: publishing,
|
|
12107
12135
|
copied,
|
|
12108
12136
|
shownUrl,
|
|
@@ -12400,13 +12428,13 @@ function groupLabel(groups) {
|
|
|
12400
12428
|
}
|
|
12401
12429
|
|
|
12402
12430
|
// src/chartFrame.tsx
|
|
12403
|
-
var
|
|
12431
|
+
var import_react85 = require("react");
|
|
12404
12432
|
var import_design_system41 = require("@ai-matrx/design-system");
|
|
12405
12433
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
12406
12434
|
function useMeasuredWidth(fallback = 480) {
|
|
12407
|
-
const ref = (0,
|
|
12408
|
-
const [width, setWidth] = (0,
|
|
12409
|
-
(0,
|
|
12435
|
+
const ref = (0, import_react85.useRef)(null);
|
|
12436
|
+
const [width, setWidth] = (0, import_react85.useState)(fallback);
|
|
12437
|
+
(0, import_react85.useEffect)(() => {
|
|
12410
12438
|
const node = ref.current;
|
|
12411
12439
|
if (!node) return;
|
|
12412
12440
|
const apply = () => {
|
|
@@ -12436,7 +12464,7 @@ function ChartFrame({
|
|
|
12436
12464
|
children
|
|
12437
12465
|
}) {
|
|
12438
12466
|
const [ref, width] = useMeasuredWidth();
|
|
12439
|
-
const chartId = `records-chart-${(0,
|
|
12467
|
+
const chartId = `records-chart-${(0, import_react85.useId)().replace(/:/g, "")}`;
|
|
12440
12468
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
12441
12469
|
"div",
|
|
12442
12470
|
{
|
|
@@ -12530,24 +12558,24 @@ function isSignatureField(field) {
|
|
|
12530
12558
|
}
|
|
12531
12559
|
|
|
12532
12560
|
// src/DocTemplate.tsx
|
|
12533
|
-
var
|
|
12534
|
-
var
|
|
12561
|
+
var import_react86 = require("react");
|
|
12562
|
+
var import_react87 = require("@ai-matrx/records/react");
|
|
12535
12563
|
var import_design_system42 = require("@ai-matrx/design-system");
|
|
12536
12564
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
12537
12565
|
function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, className }) {
|
|
12538
|
-
const client = (0,
|
|
12566
|
+
const client = (0, import_react87.useRecordsClient)();
|
|
12539
12567
|
const claimSeed = useSeedGuard();
|
|
12540
|
-
const table = (0,
|
|
12568
|
+
const table = (0, import_react87.useTable)(tableId);
|
|
12541
12569
|
const rights = useTableRights(table.data);
|
|
12542
|
-
const fields = (0,
|
|
12543
|
-
const [templates, setTemplates] = (0,
|
|
12544
|
-
const [error, setError] = (0,
|
|
12545
|
-
const [activeId, setActiveId] = (0,
|
|
12546
|
-
const [draftName, setDraftName] = (0,
|
|
12547
|
-
const [draftBody, setDraftBody] = (0,
|
|
12548
|
-
const [unresolved, setUnresolved] = (0,
|
|
12549
|
-
const [saving, setSaving] = (0,
|
|
12550
|
-
const load = (0,
|
|
12570
|
+
const fields = (0, import_react87.useFields)(tableId);
|
|
12571
|
+
const [templates, setTemplates] = (0, import_react86.useState)(null);
|
|
12572
|
+
const [error, setError] = (0, import_react86.useState)(null);
|
|
12573
|
+
const [activeId, setActiveId] = (0, import_react86.useState)(activeTemplateId ?? null);
|
|
12574
|
+
const [draftName, setDraftName] = (0, import_react86.useState)("");
|
|
12575
|
+
const [draftBody, setDraftBody] = (0, import_react86.useState)("");
|
|
12576
|
+
const [unresolved, setUnresolved] = (0, import_react86.useState)([]);
|
|
12577
|
+
const [saving, setSaving] = (0, import_react86.useState)(false);
|
|
12578
|
+
const load = (0, import_react86.useCallback)(async () => {
|
|
12551
12579
|
const held = await client.docTemplates({ table_id: tableId });
|
|
12552
12580
|
if (!held.ok) {
|
|
12553
12581
|
setError(held.error);
|
|
@@ -12578,10 +12606,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
|
|
|
12578
12606
|
setError(null);
|
|
12579
12607
|
setTemplates(rows);
|
|
12580
12608
|
}, [client, tableId, seed, fields.data]);
|
|
12581
|
-
(0,
|
|
12609
|
+
(0, import_react86.useEffect)(() => {
|
|
12582
12610
|
void load();
|
|
12583
12611
|
}, [load]);
|
|
12584
|
-
(0,
|
|
12612
|
+
(0, import_react86.useEffect)(() => {
|
|
12585
12613
|
if (!templates || templates.length === 0) return;
|
|
12586
12614
|
const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
|
|
12587
12615
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
@@ -12589,7 +12617,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
|
|
|
12589
12617
|
setDraftBody(chosen.body);
|
|
12590
12618
|
onActiveTemplate?.(chosen);
|
|
12591
12619
|
}, [templates, activeTemplateId]);
|
|
12592
|
-
(0,
|
|
12620
|
+
(0, import_react86.useEffect)(() => {
|
|
12593
12621
|
let cancelled = false;
|
|
12594
12622
|
if (draftBody.trim() === "") {
|
|
12595
12623
|
setUnresolved([]);
|
|
@@ -12709,19 +12737,19 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
|
|
|
12709
12737
|
}
|
|
12710
12738
|
|
|
12711
12739
|
// src/DocRender.tsx
|
|
12712
|
-
var
|
|
12713
|
-
var
|
|
12740
|
+
var import_react88 = require("react");
|
|
12741
|
+
var import_react89 = require("@ai-matrx/records/react");
|
|
12714
12742
|
var import_design_system43 = require("@ai-matrx/design-system");
|
|
12715
12743
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
12716
12744
|
function DocRender({ templateId, recordId, filename, onRendered, className }) {
|
|
12717
|
-
const client = (0,
|
|
12718
|
-
const [preview, setPreview] = (0,
|
|
12719
|
-
const [renders, setRenders] = (0,
|
|
12720
|
-
const [showing, setShowing] = (0,
|
|
12721
|
-
const [error, setError] = (0,
|
|
12722
|
-
const [busy, setBusy] = (0,
|
|
12723
|
-
const paper = (0,
|
|
12724
|
-
const load = (0,
|
|
12745
|
+
const client = (0, import_react89.useRecordsClient)();
|
|
12746
|
+
const [preview, setPreview] = (0, import_react88.useState)(null);
|
|
12747
|
+
const [renders, setRenders] = (0, import_react88.useState)(null);
|
|
12748
|
+
const [showing, setShowing] = (0, import_react88.useState)(null);
|
|
12749
|
+
const [error, setError] = (0, import_react88.useState)(null);
|
|
12750
|
+
const [busy, setBusy] = (0, import_react88.useState)(null);
|
|
12751
|
+
const paper = (0, import_react88.useRef)(null);
|
|
12752
|
+
const load = (0, import_react88.useCallback)(async () => {
|
|
12725
12753
|
const [body, held] = await Promise.all([
|
|
12726
12754
|
client.docRenderBody({ template_id: templateId, record_id: recordId }),
|
|
12727
12755
|
client.docRenders({ record_id: recordId })
|
|
@@ -12738,7 +12766,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
|
|
|
12738
12766
|
setPreview(body.data);
|
|
12739
12767
|
setRenders(held.data.filter((r) => r.template_id === templateId));
|
|
12740
12768
|
}, [client, templateId, recordId]);
|
|
12741
|
-
(0,
|
|
12769
|
+
(0, import_react88.useEffect)(() => {
|
|
12742
12770
|
void load();
|
|
12743
12771
|
}, [load]);
|
|
12744
12772
|
async function freeze() {
|
|
@@ -12822,22 +12850,22 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
|
|
|
12822
12850
|
}
|
|
12823
12851
|
|
|
12824
12852
|
// src/SignBlock.tsx
|
|
12825
|
-
var
|
|
12826
|
-
var
|
|
12853
|
+
var import_react90 = require("react");
|
|
12854
|
+
var import_react91 = require("@ai-matrx/records/react");
|
|
12827
12855
|
var import_design_system44 = require("@ai-matrx/design-system");
|
|
12828
|
-
var
|
|
12856
|
+
var import_react92 = require("@ai-matrx/records/react");
|
|
12829
12857
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
12830
12858
|
function SignBlock({ tableId, recordId, render, className }) {
|
|
12831
|
-
const client = (0,
|
|
12832
|
-
const table = (0,
|
|
12859
|
+
const client = (0, import_react91.useRecordsClient)();
|
|
12860
|
+
const table = (0, import_react92.useTable)(tableId);
|
|
12833
12861
|
const rights = useTableRights(table.data);
|
|
12834
|
-
const fields = (0,
|
|
12835
|
-
const [signatures, setSignatures] = (0,
|
|
12836
|
-
const [verdicts, setVerdicts] = (0,
|
|
12837
|
-
const [error, setError] = (0,
|
|
12838
|
-
const [name, setName] = (0,
|
|
12839
|
-
const [busy, setBusy] = (0,
|
|
12840
|
-
const load = (0,
|
|
12862
|
+
const fields = (0, import_react91.useFields)(tableId);
|
|
12863
|
+
const [signatures, setSignatures] = (0, import_react90.useState)(null);
|
|
12864
|
+
const [verdicts, setVerdicts] = (0, import_react90.useState)({});
|
|
12865
|
+
const [error, setError] = (0, import_react90.useState)(null);
|
|
12866
|
+
const [name, setName] = (0, import_react90.useState)("");
|
|
12867
|
+
const [busy, setBusy] = (0, import_react90.useState)(false);
|
|
12868
|
+
const load = (0, import_react90.useCallback)(async () => {
|
|
12841
12869
|
const held = await client.docSignatures({ record_id: recordId });
|
|
12842
12870
|
if (!held.ok) {
|
|
12843
12871
|
setError(held.error);
|
|
@@ -12852,7 +12880,7 @@ function SignBlock({ tableId, recordId, render, className }) {
|
|
|
12852
12880
|
}
|
|
12853
12881
|
setVerdicts(answers);
|
|
12854
12882
|
}, [client, recordId]);
|
|
12855
|
-
(0,
|
|
12883
|
+
(0, import_react90.useEffect)(() => {
|
|
12856
12884
|
void load();
|
|
12857
12885
|
}, [load]);
|
|
12858
12886
|
async function sign(field) {
|
|
@@ -12959,23 +12987,23 @@ function SignBlock({ tableId, recordId, render, className }) {
|
|
|
12959
12987
|
}
|
|
12960
12988
|
|
|
12961
12989
|
// src/NotifyRuleEditor.tsx
|
|
12962
|
-
var
|
|
12963
|
-
var
|
|
12990
|
+
var import_react93 = require("react");
|
|
12991
|
+
var import_react94 = require("@ai-matrx/records/react");
|
|
12964
12992
|
var import_design_system45 = require("@ai-matrx/design-system");
|
|
12965
12993
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
12966
12994
|
var CADENCE_WORDS2 = SUBSCRIPTION_CADENCE_LABEL;
|
|
12967
12995
|
var CHANNEL_WORDS3 = SUBSCRIPTION_CHANNEL_LABEL;
|
|
12968
12996
|
function NotifyRuleEditor({ tableId, seed, className }) {
|
|
12969
|
-
const client = (0,
|
|
12997
|
+
const client = (0, import_react94.useRecordsClient)();
|
|
12970
12998
|
const host = useRecordsUi();
|
|
12971
|
-
const table = (0,
|
|
12999
|
+
const table = (0, import_react94.useTable)(tableId);
|
|
12972
13000
|
const rights = useTableRights(table.data);
|
|
12973
|
-
const [subscriptions, setSubscriptions] = (0,
|
|
12974
|
-
const [cadences, setCadences] = (0,
|
|
12975
|
-
const [views, setViews] = (0,
|
|
12976
|
-
const [error, setError] = (0,
|
|
12977
|
-
const [busy, setBusy] = (0,
|
|
12978
|
-
const load = (0,
|
|
13001
|
+
const [subscriptions, setSubscriptions] = (0, import_react93.useState)(null);
|
|
13002
|
+
const [cadences, setCadences] = (0, import_react93.useState)([]);
|
|
13003
|
+
const [views, setViews] = (0, import_react93.useState)(null);
|
|
13004
|
+
const [error, setError] = (0, import_react93.useState)(null);
|
|
13005
|
+
const [busy, setBusy] = (0, import_react93.useState)(false);
|
|
13006
|
+
const load = (0, import_react93.useCallback)(async () => {
|
|
12979
13007
|
const [held, offered] = await Promise.all([
|
|
12980
13008
|
// THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
|
|
12981
13009
|
// to them plus — only where they hold admin on this Table — anyone's over
|
|
@@ -12995,10 +13023,10 @@ function NotifyRuleEditor({ tableId, seed, className }) {
|
|
|
12995
13023
|
if (host.savedViews) setViews(await host.savedViews());
|
|
12996
13024
|
else setViews(null);
|
|
12997
13025
|
}, [client, host, tableId]);
|
|
12998
|
-
(0,
|
|
13026
|
+
(0, import_react93.useEffect)(() => {
|
|
12999
13027
|
void load();
|
|
13000
13028
|
}, [load]);
|
|
13001
|
-
const write = (0,
|
|
13029
|
+
const write = (0, import_react93.useCallback)(
|
|
13002
13030
|
async (spec) => {
|
|
13003
13031
|
const declared = await client.subscriptionDeclare({
|
|
13004
13032
|
table_id: tableId,
|
|
@@ -13023,7 +13051,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
|
|
|
13023
13051
|
},
|
|
13024
13052
|
[client, tableId]
|
|
13025
13053
|
);
|
|
13026
|
-
(0,
|
|
13054
|
+
(0, import_react93.useEffect)(() => {
|
|
13027
13055
|
if (!subscriptions || !seed || seed.length === 0) return;
|
|
13028
13056
|
const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
|
|
13029
13057
|
if (missing.length === 0) return;
|
|
@@ -13166,7 +13194,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
|
|
|
13166
13194
|
}
|
|
13167
13195
|
|
|
13168
13196
|
// src/ChartBlock.tsx
|
|
13169
|
-
var
|
|
13197
|
+
var import_react95 = require("react");
|
|
13170
13198
|
var import_recharts = require("recharts");
|
|
13171
13199
|
var import_records11 = require("@ai-matrx/records");
|
|
13172
13200
|
var import_core6 = require("@ai-matrx/records/core");
|
|
@@ -13191,7 +13219,7 @@ function ChartBlock({ block, subject, className }) {
|
|
|
13191
13219
|
const measures = block.measures && block.measures.length > 0 ? block.measures : [{ op: "count" }];
|
|
13192
13220
|
const primary = (0, import_records11.measureKey)(measures[0]);
|
|
13193
13221
|
const series = [primary];
|
|
13194
|
-
const points = (0,
|
|
13222
|
+
const points = (0, import_react95.useMemo)(() => {
|
|
13195
13223
|
if (kind === "stuck") return [];
|
|
13196
13224
|
const rows = block.rows ?? [];
|
|
13197
13225
|
return rows.map((row) => ({
|
|
@@ -13203,7 +13231,7 @@ function ChartBlock({ block, subject, className }) {
|
|
|
13203
13231
|
n: row.row_count
|
|
13204
13232
|
}));
|
|
13205
13233
|
}, [block.rows, kind, series.join("|")]);
|
|
13206
|
-
const config = (0,
|
|
13234
|
+
const config = (0, import_react95.useMemo)(() => {
|
|
13207
13235
|
const out = {};
|
|
13208
13236
|
series.forEach((key, index) => {
|
|
13209
13237
|
out[key] = {
|
|
@@ -13464,25 +13492,25 @@ function Drawing({
|
|
|
13464
13492
|
}
|
|
13465
13493
|
|
|
13466
13494
|
// src/DashboardCanvas.tsx
|
|
13467
|
-
var
|
|
13468
|
-
var
|
|
13495
|
+
var import_react96 = require("react");
|
|
13496
|
+
var import_react97 = require("@ai-matrx/records/react");
|
|
13469
13497
|
var import_design_system47 = require("@ai-matrx/design-system");
|
|
13470
13498
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
13471
13499
|
function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
13472
|
-
const client = (0,
|
|
13500
|
+
const client = (0, import_react97.useRecordsClient)();
|
|
13473
13501
|
const host = useRecordsUi();
|
|
13474
|
-
const table = (0,
|
|
13502
|
+
const table = (0, import_react97.useTable)(tableId);
|
|
13475
13503
|
const rights = useTableRights(table.data);
|
|
13476
|
-
const fields = (0,
|
|
13477
|
-
const [boards, setBoards] = (0,
|
|
13478
|
-
const [error, setError] = (0,
|
|
13479
|
-
const [activeId, setActiveId] = (0,
|
|
13480
|
-
const [run, setRun] = (0,
|
|
13481
|
-
const [running, setRunning] = (0,
|
|
13482
|
-
const [question, setQuestion] = (0,
|
|
13483
|
-
const [asking, setAsking] = (0,
|
|
13484
|
-
const [scheduling, setScheduling] = (0,
|
|
13485
|
-
const load = (0,
|
|
13504
|
+
const fields = (0, import_react97.useFields)(tableId);
|
|
13505
|
+
const [boards, setBoards] = (0, import_react96.useState)(null);
|
|
13506
|
+
const [error, setError] = (0, import_react96.useState)(null);
|
|
13507
|
+
const [activeId, setActiveId] = (0, import_react96.useState)(activeDashboardId ?? null);
|
|
13508
|
+
const [run, setRun] = (0, import_react96.useState)(null);
|
|
13509
|
+
const [running, setRunning] = (0, import_react96.useState)(false);
|
|
13510
|
+
const [question, setQuestion] = (0, import_react96.useState)("");
|
|
13511
|
+
const [asking, setAsking] = (0, import_react96.useState)(false);
|
|
13512
|
+
const [scheduling, setScheduling] = (0, import_react96.useState)(false);
|
|
13513
|
+
const load = (0, import_react96.useCallback)(async () => {
|
|
13486
13514
|
const answered = await client.dashboards({ table_id: tableId });
|
|
13487
13515
|
if (!answered.ok) {
|
|
13488
13516
|
setError(answered.error);
|
|
@@ -13491,17 +13519,17 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
13491
13519
|
setError(null);
|
|
13492
13520
|
setBoards(answered.data.map(dashboardFromSummary));
|
|
13493
13521
|
}, [client, tableId]);
|
|
13494
|
-
(0,
|
|
13522
|
+
(0, import_react96.useEffect)(() => {
|
|
13495
13523
|
void load();
|
|
13496
13524
|
}, [load]);
|
|
13497
|
-
(0,
|
|
13525
|
+
(0, import_react96.useEffect)(() => {
|
|
13498
13526
|
if (!boards || boards.length === 0) return;
|
|
13499
13527
|
const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
|
|
13500
13528
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
13501
13529
|
}, [boards, activeDashboardId]);
|
|
13502
|
-
const board = (0,
|
|
13530
|
+
const board = (0, import_react96.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
|
|
13503
13531
|
const filterKey = JSON.stringify(filter ?? {});
|
|
13504
|
-
(0,
|
|
13532
|
+
(0, import_react96.useEffect)(() => {
|
|
13505
13533
|
if (!activeId) {
|
|
13506
13534
|
setRun(null);
|
|
13507
13535
|
return;
|
|
@@ -13519,7 +13547,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
13519
13547
|
cancelled = true;
|
|
13520
13548
|
};
|
|
13521
13549
|
}, [client, activeId, filterKey]);
|
|
13522
|
-
const declare2 = (0,
|
|
13550
|
+
const declare2 = (0, import_react96.useCallback)(
|
|
13523
13551
|
async (next, blocks) => {
|
|
13524
13552
|
const written = await client.dashboardDeclare(
|
|
13525
13553
|
dashboardDeclareArgs({ ...next, blocks }, tableId)
|
|
@@ -13570,7 +13598,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
13570
13598
|
]
|
|
13571
13599
|
);
|
|
13572
13600
|
}
|
|
13573
|
-
const refresh = (0,
|
|
13601
|
+
const refresh = (0, import_react96.useCallback)(async () => {
|
|
13574
13602
|
if (!activeId) return;
|
|
13575
13603
|
setRunning(true);
|
|
13576
13604
|
const again = await client.dashboardRun({
|
|
@@ -13732,8 +13760,8 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
|
|
|
13732
13760
|
}
|
|
13733
13761
|
|
|
13734
13762
|
// src/FormsPanel.tsx
|
|
13735
|
-
var
|
|
13736
|
-
var
|
|
13763
|
+
var import_react98 = require("react");
|
|
13764
|
+
var import_react99 = require("@ai-matrx/records/react");
|
|
13737
13765
|
var import_records12 = require("@ai-matrx/records");
|
|
13738
13766
|
var import_design_system48 = require("@ai-matrx/design-system");
|
|
13739
13767
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
@@ -13744,16 +13772,17 @@ function formSuggestion(tableName2) {
|
|
|
13744
13772
|
return `Make me a form that collects new ${subject} entries and tells me when somebody answers.`;
|
|
13745
13773
|
}
|
|
13746
13774
|
function FormsPanel({ tableId, className }) {
|
|
13747
|
-
const client = (0,
|
|
13775
|
+
const client = (0, import_react99.useRecordsClient)();
|
|
13776
|
+
const publishGate = usePublishGate();
|
|
13748
13777
|
const host = useRecordsUi();
|
|
13749
|
-
const table = (0,
|
|
13778
|
+
const table = (0, import_react99.useTable)(tableId);
|
|
13750
13779
|
const rights = useTableRights(table.data);
|
|
13751
|
-
const [forms, setForms] = (0,
|
|
13752
|
-
const [error, setError] = (0,
|
|
13753
|
-
const [busy, setBusy] = (0,
|
|
13754
|
-
const [copied, setCopied] = (0,
|
|
13755
|
-
const [building, setBuilding] = (0,
|
|
13756
|
-
const load = (0,
|
|
13780
|
+
const [forms, setForms] = (0, import_react98.useState)(null);
|
|
13781
|
+
const [error, setError] = (0, import_react98.useState)(null);
|
|
13782
|
+
const [busy, setBusy] = (0, import_react98.useState)(null);
|
|
13783
|
+
const [copied, setCopied] = (0, import_react98.useState)(null);
|
|
13784
|
+
const [building, setBuilding] = (0, import_react98.useState)(false);
|
|
13785
|
+
const load = (0, import_react98.useCallback)(async () => {
|
|
13757
13786
|
const answered = await client.forms({ table_id: tableId });
|
|
13758
13787
|
if (!answered.ok) {
|
|
13759
13788
|
setError(answered.error);
|
|
@@ -13763,10 +13792,10 @@ function FormsPanel({ tableId, className }) {
|
|
|
13763
13792
|
setError(null);
|
|
13764
13793
|
setForms(answered.data);
|
|
13765
13794
|
}, [client, tableId]);
|
|
13766
|
-
(0,
|
|
13795
|
+
(0, import_react98.useEffect)(() => {
|
|
13767
13796
|
void load();
|
|
13768
13797
|
}, [load]);
|
|
13769
|
-
const toggle = (0,
|
|
13798
|
+
const toggle = (0, import_react98.useCallback)(
|
|
13770
13799
|
async (form) => {
|
|
13771
13800
|
setBusy(form.form_id);
|
|
13772
13801
|
const wanted = form.published_at === null || form.closed_at !== null;
|
|
@@ -13780,8 +13809,8 @@ function FormsPanel({ tableId, className }) {
|
|
|
13780
13809
|
},
|
|
13781
13810
|
[client, load]
|
|
13782
13811
|
);
|
|
13783
|
-
const [shown, setShown] = (0,
|
|
13784
|
-
const copy = (0,
|
|
13812
|
+
const [shown, setShown] = (0, import_react98.useState)(null);
|
|
13813
|
+
const copy = (0, import_react98.useCallback)(async (url, formId) => {
|
|
13785
13814
|
try {
|
|
13786
13815
|
await navigator.clipboard.writeText(url);
|
|
13787
13816
|
setCopied(formId);
|
|
@@ -13856,7 +13885,7 @@ function FormsPanel({ tableId, className }) {
|
|
|
13856
13885
|
] }),
|
|
13857
13886
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "mt-2 flex flex-wrap items-center gap-1.5", children: [
|
|
13858
13887
|
form.published_at ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_design_system48.Button, { size: "sm", variant: "outline", onClick: () => void copy(url, form.form_id), children: copied === form.form_id ? "Copied" : "Copy link" }) : null,
|
|
13859
|
-
rights.structure ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
13888
|
+
rights.structure && !publishGate.blocked ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
13860
13889
|
import_design_system48.Button,
|
|
13861
13890
|
{
|
|
13862
13891
|
size: "sm",
|
|
@@ -13867,6 +13896,7 @@ function FormsPanel({ tableId, className }) {
|
|
|
13867
13896
|
}
|
|
13868
13897
|
) : null
|
|
13869
13898
|
] }),
|
|
13899
|
+
rights.structure && publishGate.why ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "mt-1.5 text-xs text-muted-foreground", children: publishGate.why }) : null,
|
|
13870
13900
|
shown && shown === url ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "mt-1.5 break-all rounded border border-dashed px-2 py-1 text-xs", children: [
|
|
13871
13901
|
"This browser would not let the page copy for you, so here it is to copy by hand:",
|
|
13872
13902
|
" ",
|
|
@@ -13879,8 +13909,8 @@ function FormsPanel({ tableId, className }) {
|
|
|
13879
13909
|
}
|
|
13880
13910
|
|
|
13881
13911
|
// src/BookingBuilder.tsx
|
|
13882
|
-
var
|
|
13883
|
-
var
|
|
13912
|
+
var import_react100 = require("react");
|
|
13913
|
+
var import_react101 = require("@ai-matrx/records/react");
|
|
13884
13914
|
var import_records13 = require("@ai-matrx/records");
|
|
13885
13915
|
var import_design_system49 = require("@ai-matrx/design-system");
|
|
13886
13916
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
@@ -13908,38 +13938,39 @@ function draftWindows(availability) {
|
|
|
13908
13938
|
});
|
|
13909
13939
|
}
|
|
13910
13940
|
function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
13911
|
-
const client = (0,
|
|
13941
|
+
const client = (0, import_react101.useRecordsClient)();
|
|
13942
|
+
const publishGate = usePublishGate();
|
|
13912
13943
|
const host = useRecordsUi();
|
|
13913
|
-
const table = (0,
|
|
13944
|
+
const table = (0, import_react101.useTable)(tableId);
|
|
13914
13945
|
const rights = useTableRights(table.data);
|
|
13915
|
-
const fields = (0,
|
|
13916
|
-
const [existing, setExisting] = (0,
|
|
13917
|
-
const [loaded, setLoaded] = (0,
|
|
13918
|
-
const [error, setError] = (0,
|
|
13919
|
-
const [saving, setSaving] = (0,
|
|
13920
|
-
const [publishing, setPublishing] = (0,
|
|
13921
|
-
const [copied, setCopied] = (0,
|
|
13922
|
-
const [title, setTitle] = (0,
|
|
13923
|
-
const [minutes, setMinutes] = (0,
|
|
13924
|
-
const [buffer, setBuffer] = (0,
|
|
13925
|
-
const [lead, setLead] = (0,
|
|
13926
|
-
const [perDay, setPerDay] = (0,
|
|
13927
|
-
const [days, setDays] = (0,
|
|
13928
|
-
const [windows, setWindows] = (0,
|
|
13929
|
-
const [asked, setAsked] = (0,
|
|
13930
|
-
const [confirmation, setConfirmation] = (0,
|
|
13931
|
-
const [offer, setOffer] = (0,
|
|
13932
|
-
const [formId, setFormId] = (0,
|
|
13946
|
+
const fields = (0, import_react101.useFields)(tableId);
|
|
13947
|
+
const [existing, setExisting] = (0, import_react100.useState)(null);
|
|
13948
|
+
const [loaded, setLoaded] = (0, import_react100.useState)(false);
|
|
13949
|
+
const [error, setError] = (0, import_react100.useState)(null);
|
|
13950
|
+
const [saving, setSaving] = (0, import_react100.useState)(false);
|
|
13951
|
+
const [publishing, setPublishing] = (0, import_react100.useState)(false);
|
|
13952
|
+
const [copied, setCopied] = (0, import_react100.useState)(false);
|
|
13953
|
+
const [title, setTitle] = (0, import_react100.useState)("");
|
|
13954
|
+
const [minutes, setMinutes] = (0, import_react100.useState)(30);
|
|
13955
|
+
const [buffer, setBuffer] = (0, import_react100.useState)(0);
|
|
13956
|
+
const [lead, setLead] = (0, import_react100.useState)(120);
|
|
13957
|
+
const [perDay, setPerDay] = (0, import_react100.useState)(8);
|
|
13958
|
+
const [days, setDays] = (0, import_react100.useState)(30);
|
|
13959
|
+
const [windows, setWindows] = (0, import_react100.useState)(() => draftWindows(null));
|
|
13960
|
+
const [asked, setAsked] = (0, import_react100.useState)([]);
|
|
13961
|
+
const [confirmation, setConfirmation] = (0, import_react100.useState)("");
|
|
13962
|
+
const [offer, setOffer] = (0, import_react100.useState)(null);
|
|
13963
|
+
const [formId, setFormId] = (0, import_react100.useState)(bookingId ?? null);
|
|
13933
13964
|
const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
|
|
13934
|
-
const askable = (0,
|
|
13965
|
+
const askable = (0, import_react100.useMemo)(
|
|
13935
13966
|
() => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
|
|
13936
13967
|
[fields.data]
|
|
13937
13968
|
);
|
|
13938
|
-
const leftOut = (0,
|
|
13969
|
+
const leftOut = (0, import_react100.useMemo)(
|
|
13939
13970
|
() => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
|
|
13940
13971
|
[fields.data]
|
|
13941
13972
|
);
|
|
13942
|
-
const load = (0,
|
|
13973
|
+
const load = (0, import_react100.useCallback)(async () => {
|
|
13943
13974
|
const answered = await client.bookings({ table_id: tableId });
|
|
13944
13975
|
if (!answered.ok) {
|
|
13945
13976
|
setError(answered.error);
|
|
@@ -13951,18 +13982,18 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
13951
13982
|
setLoaded(true);
|
|
13952
13983
|
if (mine) setFormId(mine.form_id);
|
|
13953
13984
|
}, [client, tableId, bookingId]);
|
|
13954
|
-
(0,
|
|
13985
|
+
(0, import_react100.useEffect)(() => {
|
|
13955
13986
|
void load();
|
|
13956
13987
|
}, [load]);
|
|
13957
|
-
(0,
|
|
13988
|
+
(0, import_react100.useEffect)(() => {
|
|
13958
13989
|
if (title !== "" || !table.data) return;
|
|
13959
13990
|
setTitle(existing?.title ?? `Book a ${minutes}-minute ${table.data.name} appointment`);
|
|
13960
13991
|
}, [table.data, existing]);
|
|
13961
|
-
(0,
|
|
13992
|
+
(0, import_react100.useEffect)(() => {
|
|
13962
13993
|
if (!existing) return;
|
|
13963
13994
|
setMinutes(existing.slot_minutes);
|
|
13964
13995
|
}, [existing]);
|
|
13965
|
-
(0,
|
|
13996
|
+
(0, import_react100.useEffect)(() => {
|
|
13966
13997
|
if (!offer) return;
|
|
13967
13998
|
setWindows(draftWindows(offer));
|
|
13968
13999
|
setMinutes(offer.slot_minutes);
|
|
@@ -13971,7 +14002,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
13971
14002
|
setPerDay(offer.max_per_day);
|
|
13972
14003
|
setDays(offer.days);
|
|
13973
14004
|
}, [offer]);
|
|
13974
|
-
const availability = (0,
|
|
14005
|
+
const availability = (0, import_react100.useCallback)(
|
|
13975
14006
|
() => ({
|
|
13976
14007
|
slot_minutes: minutes,
|
|
13977
14008
|
buffer_minutes: buffer,
|
|
@@ -14208,7 +14239,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
14208
14239
|
children: copied ? "Copied" : "Copy link"
|
|
14209
14240
|
}
|
|
14210
14241
|
),
|
|
14211
|
-
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
14242
|
+
publishGate.blocked ? null : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
14212
14243
|
import_design_system49.Button,
|
|
14213
14244
|
{
|
|
14214
14245
|
size: "sm",
|
|
@@ -14217,15 +14248,15 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
|
|
|
14217
14248
|
children: publishing ? "\u2026" : existing?.published_at && !existing.closed_at ? "Unpublish" : "Publish"
|
|
14218
14249
|
}
|
|
14219
14250
|
),
|
|
14220
|
-
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "w-full text-xs text-muted-foreground", children: existing?.published_at && !existing.closed_at ? "Open. Anyone with this link can book a time." : "Not open yet \u2014 the link does not take bookings until you publish it." })
|
|
14251
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "w-full text-xs text-muted-foreground", children: publishGate.why ?? (existing?.published_at && !existing.closed_at ? "Open. Anyone with this link can book a time." : "Not open yet \u2014 the link does not take bookings until you publish it.") })
|
|
14221
14252
|
] }) : null
|
|
14222
14253
|
] })
|
|
14223
14254
|
);
|
|
14224
14255
|
}
|
|
14225
14256
|
|
|
14226
14257
|
// src/BookingSlots.tsx
|
|
14227
|
-
var
|
|
14228
|
-
var
|
|
14258
|
+
var import_react102 = require("react");
|
|
14259
|
+
var import_react103 = require("@ai-matrx/records/react");
|
|
14229
14260
|
var import_records14 = require("@ai-matrx/records");
|
|
14230
14261
|
var import_design_system50 = require("@ai-matrx/design-system");
|
|
14231
14262
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
@@ -14237,15 +14268,15 @@ function bookingSuggestion(tableName2) {
|
|
|
14237
14268
|
var NO_ADMIN2 = "Opening a booking page lets people with no account take time in your calendar, so it needs the admin level on the table the appointments land in.";
|
|
14238
14269
|
var STATE_WORDS = BOOKING_PAGE_STATE_LABEL;
|
|
14239
14270
|
function BookingSlots({ tableId, className }) {
|
|
14240
|
-
const client = (0,
|
|
14271
|
+
const client = (0, import_react103.useRecordsClient)();
|
|
14241
14272
|
const host = useRecordsUi();
|
|
14242
|
-
const [pages, setPages] = (0,
|
|
14243
|
-
const [error, setError] = (0,
|
|
14244
|
-
const [busy, setBusy] = (0,
|
|
14245
|
-
const [copied, setCopied] = (0,
|
|
14246
|
-
const [shown, setShown] = (0,
|
|
14247
|
-
const [building, setBuilding] = (0,
|
|
14248
|
-
const load = (0,
|
|
14273
|
+
const [pages, setPages] = (0, import_react102.useState)(null);
|
|
14274
|
+
const [error, setError] = (0, import_react102.useState)(null);
|
|
14275
|
+
const [busy, setBusy] = (0, import_react102.useState)(null);
|
|
14276
|
+
const [copied, setCopied] = (0, import_react102.useState)(null);
|
|
14277
|
+
const [shown, setShown] = (0, import_react102.useState)(null);
|
|
14278
|
+
const [building, setBuilding] = (0, import_react102.useState)(false);
|
|
14279
|
+
const load = (0, import_react102.useCallback)(async () => {
|
|
14249
14280
|
const answered = await client.bookings(tableId ? { table_id: tableId } : {});
|
|
14250
14281
|
if (!answered.ok) {
|
|
14251
14282
|
setError(answered.error);
|
|
@@ -14255,10 +14286,10 @@ function BookingSlots({ tableId, className }) {
|
|
|
14255
14286
|
setError(null);
|
|
14256
14287
|
setPages(answered.data);
|
|
14257
14288
|
}, [client, tableId]);
|
|
14258
|
-
(0,
|
|
14289
|
+
(0, import_react102.useEffect)(() => {
|
|
14259
14290
|
void load();
|
|
14260
14291
|
}, [load]);
|
|
14261
|
-
const subjectIds = (0,
|
|
14292
|
+
const subjectIds = (0, import_react102.useMemo)(
|
|
14262
14293
|
() => Array.from(
|
|
14263
14294
|
/* @__PURE__ */ new Set([
|
|
14264
14295
|
...(pages ?? []).map((p) => p.table_id),
|
|
@@ -14271,10 +14302,10 @@ function BookingSlots({ tableId, className }) {
|
|
|
14271
14302
|
),
|
|
14272
14303
|
[pages, tableId]
|
|
14273
14304
|
);
|
|
14274
|
-
const levels = (0,
|
|
14305
|
+
const levels = (0, import_react103.useMyLevels)(subjectIds);
|
|
14275
14306
|
const levelsKnown = !levels.loading && Boolean(levels.data);
|
|
14276
14307
|
const mayBuildHere = levelsKnown && Boolean(tableId) && levels.data?.[tableId] === "admin";
|
|
14277
|
-
const toggle = (0,
|
|
14308
|
+
const toggle = (0, import_react102.useCallback)(
|
|
14278
14309
|
async (page) => {
|
|
14279
14310
|
setBusy(page.form_id);
|
|
14280
14311
|
const wanted = page.published_at === null || page.closed_at !== null;
|
|
@@ -14288,7 +14319,7 @@ function BookingSlots({ tableId, className }) {
|
|
|
14288
14319
|
},
|
|
14289
14320
|
[client, load]
|
|
14290
14321
|
);
|
|
14291
|
-
const copy = (0,
|
|
14322
|
+
const copy = (0, import_react102.useCallback)(async (url, formId) => {
|
|
14292
14323
|
try {
|
|
14293
14324
|
await navigator.clipboard.writeText(url);
|
|
14294
14325
|
setCopied(formId);
|
|
@@ -14424,14 +14455,14 @@ function nextInWords(page) {
|
|
|
14424
14455
|
}
|
|
14425
14456
|
|
|
14426
14457
|
// src/CaptureSheet.tsx
|
|
14427
|
-
var
|
|
14428
|
-
var
|
|
14458
|
+
var import_react106 = require("react");
|
|
14459
|
+
var import_react107 = require("@ai-matrx/records/react");
|
|
14429
14460
|
var import_design_system52 = require("@ai-matrx/design-system");
|
|
14430
14461
|
|
|
14431
14462
|
// src/CaptureRun.tsx
|
|
14432
|
-
var
|
|
14463
|
+
var import_react104 = require("react");
|
|
14433
14464
|
var import_records15 = require("@ai-matrx/records");
|
|
14434
|
-
var
|
|
14465
|
+
var import_react105 = require("@ai-matrx/records/react");
|
|
14435
14466
|
var import_design_system51 = require("@ai-matrx/design-system");
|
|
14436
14467
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
14437
14468
|
function controlFor(field) {
|
|
@@ -14470,21 +14501,21 @@ function whereWeAre(timeoutMs = 4e3) {
|
|
|
14470
14501
|
});
|
|
14471
14502
|
}
|
|
14472
14503
|
function CaptureRun({ sheetId, face: given, className }) {
|
|
14473
|
-
const client = (0,
|
|
14504
|
+
const client = (0, import_react105.useRecordsClient)();
|
|
14474
14505
|
const host = useRecordsUi();
|
|
14475
|
-
const [face, setFace] = (0,
|
|
14476
|
-
const [loadFailed, setLoadFailed] = (0,
|
|
14477
|
-
const [at, setAt] = (0,
|
|
14478
|
-
const [answers, setAnswers] = (0,
|
|
14479
|
-
const [files, setFiles] = (0,
|
|
14480
|
-
const [missing, setMissing] = (0,
|
|
14481
|
-
const [done, setDone] = (0,
|
|
14482
|
-
const [counts, setCounts] = (0,
|
|
14483
|
-
const [items, setItems] = (0,
|
|
14484
|
-
const [lastSynced, setLastSynced] = (0,
|
|
14485
|
-
const [sending, setSending] = (0,
|
|
14486
|
-
const queueRef = (0,
|
|
14487
|
-
(0,
|
|
14506
|
+
const [face, setFace] = (0, import_react104.useState)(given);
|
|
14507
|
+
const [loadFailed, setLoadFailed] = (0, import_react104.useState)(null);
|
|
14508
|
+
const [at, setAt] = (0, import_react104.useState)(0);
|
|
14509
|
+
const [answers, setAnswers] = (0, import_react104.useState)({});
|
|
14510
|
+
const [files, setFiles] = (0, import_react104.useState)({});
|
|
14511
|
+
const [missing, setMissing] = (0, import_react104.useState)(null);
|
|
14512
|
+
const [done, setDone] = (0, import_react104.useState)(null);
|
|
14513
|
+
const [counts, setCounts] = (0, import_react104.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
|
|
14514
|
+
const [items, setItems] = (0, import_react104.useState)([]);
|
|
14515
|
+
const [lastSynced, setLastSynced] = (0, import_react104.useState)(null);
|
|
14516
|
+
const [sending, setSending] = (0, import_react104.useState)(false);
|
|
14517
|
+
const queueRef = (0, import_react104.useRef)(null);
|
|
14518
|
+
(0, import_react104.useEffect)(() => {
|
|
14488
14519
|
const q2 = (0, import_records15.openCaptureQueue)({
|
|
14489
14520
|
onChange: (c, all) => {
|
|
14490
14521
|
setCounts(c);
|
|
@@ -14522,7 +14553,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
14522
14553
|
void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
|
|
14523
14554
|
return () => q2.dispose();
|
|
14524
14555
|
}, [client, host]);
|
|
14525
|
-
(0,
|
|
14556
|
+
(0, import_react104.useEffect)(() => {
|
|
14526
14557
|
if (given !== void 0) return;
|
|
14527
14558
|
let cancelled = false;
|
|
14528
14559
|
void client.captureOpen({ sheet_id: sheetId }).then((res) => {
|
|
@@ -14534,7 +14565,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
14534
14565
|
cancelled = true;
|
|
14535
14566
|
};
|
|
14536
14567
|
}, [client, given, sheetId]);
|
|
14537
|
-
const questions = (0,
|
|
14568
|
+
const questions = (0, import_react104.useMemo)(() => {
|
|
14538
14569
|
const asked = face?.presentation?.questions ?? [];
|
|
14539
14570
|
if (asked.length > 0) return asked;
|
|
14540
14571
|
return (face?.fields ?? []).map((f) => ({
|
|
@@ -14544,11 +14575,11 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
14544
14575
|
required: f.required
|
|
14545
14576
|
}));
|
|
14546
14577
|
}, [face]);
|
|
14547
|
-
const fieldOf = (0,
|
|
14578
|
+
const fieldOf = (0, import_react104.useCallback)(
|
|
14548
14579
|
(key) => (face?.fields ?? []).find((f) => f.key === key),
|
|
14549
14580
|
[face]
|
|
14550
14581
|
);
|
|
14551
|
-
const sync = (0,
|
|
14582
|
+
const sync = (0, import_react104.useCallback)(async () => {
|
|
14552
14583
|
const q2 = queueRef.current;
|
|
14553
14584
|
if (!q2) return;
|
|
14554
14585
|
setSending(true);
|
|
@@ -14561,7 +14592,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
14561
14592
|
setSending(false);
|
|
14562
14593
|
}
|
|
14563
14594
|
}, []);
|
|
14564
|
-
const answered = (0,
|
|
14595
|
+
const answered = (0, import_react104.useCallback)(
|
|
14565
14596
|
(key) => {
|
|
14566
14597
|
if (files[key]) return true;
|
|
14567
14598
|
const v = answers[key];
|
|
@@ -14832,21 +14863,21 @@ function AdHocCaptureSheet({
|
|
|
14832
14863
|
attachmentField,
|
|
14833
14864
|
className
|
|
14834
14865
|
}) {
|
|
14835
|
-
const client = (0,
|
|
14866
|
+
const client = (0, import_react107.useRecordsClient)();
|
|
14836
14867
|
const host = useRecordsUi();
|
|
14837
|
-
const table = (0,
|
|
14838
|
-
const fields = (0,
|
|
14839
|
-
const [mode, setMode] = (0,
|
|
14840
|
-
const [reading, setReading] = (0,
|
|
14841
|
-
const [note, setNote] = (0,
|
|
14842
|
-
const [fileId, setFileId] = (0,
|
|
14843
|
-
const [pending, setPending] = (0,
|
|
14844
|
-
const [saved, setSaved] = (0,
|
|
14845
|
-
const [error, setError] = (0,
|
|
14846
|
-
const [uploadError, setUploadError] = (0,
|
|
14847
|
-
const [flushing, setFlushing] = (0,
|
|
14848
|
-
const queue = (0,
|
|
14849
|
-
const keep = (0,
|
|
14868
|
+
const table = (0, import_react107.useTable)(tableId);
|
|
14869
|
+
const fields = (0, import_react107.useFields)(tableId);
|
|
14870
|
+
const [mode, setMode] = (0, import_react106.useState)("reading");
|
|
14871
|
+
const [reading, setReading] = (0, import_react106.useState)("");
|
|
14872
|
+
const [note, setNote] = (0, import_react106.useState)("");
|
|
14873
|
+
const [fileId, setFileId] = (0, import_react106.useState)(null);
|
|
14874
|
+
const [pending, setPending] = (0, import_react106.useState)(null);
|
|
14875
|
+
const [saved, setSaved] = (0, import_react106.useState)([]);
|
|
14876
|
+
const [error, setError] = (0, import_react106.useState)(null);
|
|
14877
|
+
const [uploadError, setUploadError] = (0, import_react106.useState)(null);
|
|
14878
|
+
const [flushing, setFlushing] = (0, import_react106.useState)(false);
|
|
14879
|
+
const queue = (0, import_react106.useRef)([]);
|
|
14880
|
+
const keep = (0, import_react106.useCallback)(
|
|
14850
14881
|
async (next) => {
|
|
14851
14882
|
queue.current = next;
|
|
14852
14883
|
setPending(next);
|
|
@@ -14854,7 +14885,7 @@ function AdHocCaptureSheet({
|
|
|
14854
14885
|
},
|
|
14855
14886
|
[host]
|
|
14856
14887
|
);
|
|
14857
|
-
(0,
|
|
14888
|
+
(0, import_react106.useEffect)(() => {
|
|
14858
14889
|
let cancelled = false;
|
|
14859
14890
|
void (async () => {
|
|
14860
14891
|
const held = host.captureQueue ? await host.captureQueue.load() : [];
|
|
@@ -14866,7 +14897,7 @@ function AdHocCaptureSheet({
|
|
|
14866
14897
|
cancelled = true;
|
|
14867
14898
|
};
|
|
14868
14899
|
}, [host]);
|
|
14869
|
-
const resolved = (0,
|
|
14900
|
+
const resolved = (0, import_react106.useCallback)(() => {
|
|
14870
14901
|
const all = fields.data ?? [];
|
|
14871
14902
|
return {
|
|
14872
14903
|
reading: readingField ?? all.find((f) => f.type === "range")?.key ?? null,
|
|
@@ -14874,7 +14905,7 @@ function AdHocCaptureSheet({
|
|
|
14874
14905
|
attachment: attachmentField ?? all.find((f) => f.format === "file" || f.format === "image")?.key ?? null
|
|
14875
14906
|
};
|
|
14876
14907
|
}, [attachmentField, fields.data, noteField, readingField, table.data]);
|
|
14877
|
-
const flush = (0,
|
|
14908
|
+
const flush = (0, import_react106.useCallback)(async () => {
|
|
14878
14909
|
if (flushing || queue.current.length === 0) return;
|
|
14879
14910
|
setFlushing(true);
|
|
14880
14911
|
const left = [];
|
|
@@ -15033,18 +15064,18 @@ function AdHocCaptureSheet({
|
|
|
15033
15064
|
}
|
|
15034
15065
|
|
|
15035
15066
|
// src/PortalShell.tsx
|
|
15036
|
-
var
|
|
15037
|
-
var
|
|
15067
|
+
var import_react108 = require("react");
|
|
15068
|
+
var import_react109 = require("@ai-matrx/records/react");
|
|
15038
15069
|
var import_design_system53 = require("@ai-matrx/design-system");
|
|
15039
15070
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
15040
15071
|
function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
15041
|
-
const client = (0,
|
|
15042
|
-
const [card, setCard] = (0,
|
|
15043
|
-
const [reach, setReach] = (0,
|
|
15044
|
-
const [error, setError] = (0,
|
|
15045
|
-
const [open, setOpen] = (0,
|
|
15046
|
-
const [sending, setSending] = (0,
|
|
15047
|
-
const load = (0,
|
|
15072
|
+
const client = (0, import_react109.useRecordsClient)();
|
|
15073
|
+
const [card, setCard] = (0, import_react108.useState)(null);
|
|
15074
|
+
const [reach, setReach] = (0, import_react108.useState)(null);
|
|
15075
|
+
const [error, setError] = (0, import_react108.useState)(null);
|
|
15076
|
+
const [open, setOpen] = (0, import_react108.useState)(null);
|
|
15077
|
+
const [sending, setSending] = (0, import_react108.useState)(false);
|
|
15078
|
+
const load = (0, import_react108.useCallback)(async () => {
|
|
15048
15079
|
const who = await client.externalPrincipalCard();
|
|
15049
15080
|
if (!who.ok) {
|
|
15050
15081
|
setError(who.error);
|
|
@@ -15059,7 +15090,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
|
15059
15090
|
}
|
|
15060
15091
|
setReach(reached.data.map((row) => row.resource_id));
|
|
15061
15092
|
}, [client, resourceType]);
|
|
15062
|
-
(0,
|
|
15093
|
+
(0, import_react108.useEffect)(() => {
|
|
15063
15094
|
void load();
|
|
15064
15095
|
}, [load]);
|
|
15065
15096
|
if (error) {
|
|
@@ -15117,9 +15148,9 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
|
15117
15148
|
] });
|
|
15118
15149
|
}
|
|
15119
15150
|
function PortalRow({ tableId, recordId }) {
|
|
15120
|
-
const client = (0,
|
|
15121
|
-
const [title, setTitle] = (0,
|
|
15122
|
-
(0,
|
|
15151
|
+
const client = (0, import_react109.useRecordsClient)();
|
|
15152
|
+
const [title, setTitle] = (0, import_react108.useState)(null);
|
|
15153
|
+
(0, import_react108.useEffect)(() => {
|
|
15123
15154
|
let cancelled = false;
|
|
15124
15155
|
void client.recordRead({ record_id: recordId }).then((answered) => {
|
|
15125
15156
|
if (cancelled) return;
|
|
@@ -15139,18 +15170,18 @@ function PortalRow({ tableId, recordId }) {
|
|
|
15139
15170
|
}
|
|
15140
15171
|
|
|
15141
15172
|
// src/PublicViewPage.tsx
|
|
15142
|
-
var
|
|
15143
|
-
var
|
|
15173
|
+
var import_react110 = require("react");
|
|
15174
|
+
var import_react111 = require("@ai-matrx/records/react");
|
|
15144
15175
|
var import_design_system54 = require("@ai-matrx/design-system");
|
|
15145
15176
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
15146
15177
|
function PublicViewPage({ slug, className }) {
|
|
15147
|
-
const client = (0,
|
|
15148
|
-
const [binding, setBinding] = (0,
|
|
15149
|
-
const [rows, setRows] = (0,
|
|
15150
|
-
const [fields, setFields] = (0,
|
|
15151
|
-
const [error, setError] = (0,
|
|
15152
|
-
const [gap, setGap] = (0,
|
|
15153
|
-
const load = (0,
|
|
15178
|
+
const client = (0, import_react111.useRecordsClient)();
|
|
15179
|
+
const [binding, setBinding] = (0, import_react110.useState)(null);
|
|
15180
|
+
const [rows, setRows] = (0, import_react110.useState)(null);
|
|
15181
|
+
const [fields, setFields] = (0, import_react110.useState)(null);
|
|
15182
|
+
const [error, setError] = (0, import_react110.useState)(null);
|
|
15183
|
+
const [gap, setGap] = (0, import_react110.useState)(null);
|
|
15184
|
+
const load = (0, import_react110.useCallback)(async () => {
|
|
15154
15185
|
const notice = await client.worldPublishGapNotice();
|
|
15155
15186
|
if (notice.ok) setGap(notice.data);
|
|
15156
15187
|
const resolved = await client.resolvePublishBinding({ slug });
|
|
@@ -15183,7 +15214,7 @@ function PublicViewPage({ slug, className }) {
|
|
|
15183
15214
|
}
|
|
15184
15215
|
setRows([{ id: found.resource_id, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
|
|
15185
15216
|
}, [client, slug]);
|
|
15186
|
-
(0,
|
|
15217
|
+
(0, import_react110.useEffect)(() => {
|
|
15187
15218
|
void load();
|
|
15188
15219
|
}, [load]);
|
|
15189
15220
|
if (error) return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(RefusalNotice, { error, className });
|
|
@@ -15220,10 +15251,10 @@ function PublicRow({ row, fields }) {
|
|
|
15220
15251
|
}
|
|
15221
15252
|
|
|
15222
15253
|
// src/EmbedFrame.tsx
|
|
15223
|
-
var
|
|
15224
|
-
var
|
|
15254
|
+
var import_react112 = require("react");
|
|
15255
|
+
var import_react113 = require("@ai-matrx/records/react");
|
|
15225
15256
|
var import_design_system55 = require("@ai-matrx/design-system");
|
|
15226
|
-
var
|
|
15257
|
+
var import_react114 = require("@ai-matrx/records/react");
|
|
15227
15258
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
15228
15259
|
function EmbedFrame({
|
|
15229
15260
|
tableId,
|
|
@@ -15233,18 +15264,18 @@ function EmbedFrame({
|
|
|
15233
15264
|
embedUrl,
|
|
15234
15265
|
className
|
|
15235
15266
|
}) {
|
|
15236
|
-
const client = (0,
|
|
15267
|
+
const client = (0, import_react113.useRecordsClient)();
|
|
15237
15268
|
const host = useRecordsUi();
|
|
15238
|
-
const table = (0,
|
|
15269
|
+
const table = (0, import_react114.useTable)(tableId);
|
|
15239
15270
|
const rights = useTableRights(table.data);
|
|
15240
|
-
const [origins, setOrigins] = (0,
|
|
15241
|
-
const [secret, setSecret] = (0,
|
|
15242
|
-
const [tokenId, setTokenId] = (0,
|
|
15243
|
-
const [error, setError] = (0,
|
|
15244
|
-
const [busy, setBusy] = (0,
|
|
15271
|
+
const [origins, setOrigins] = (0, import_react112.useState)("");
|
|
15272
|
+
const [secret, setSecret] = (0, import_react112.useState)(null);
|
|
15273
|
+
const [tokenId, setTokenId] = (0, import_react112.useState)(null);
|
|
15274
|
+
const [error, setError] = (0, import_react112.useState)(null);
|
|
15275
|
+
const [busy, setBusy] = (0, import_react112.useState)(false);
|
|
15245
15276
|
const mode = formId ? "write" : "read";
|
|
15246
15277
|
const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
|
|
15247
|
-
const issue = (0,
|
|
15278
|
+
const issue = (0, import_react112.useCallback)(async () => {
|
|
15248
15279
|
setBusy(true);
|
|
15249
15280
|
setError(null);
|
|
15250
15281
|
const minted = await client.anonTokenIssue({
|
|
@@ -15263,7 +15294,7 @@ function EmbedFrame({
|
|
|
15263
15294
|
setTokenId(minted.data.token_id);
|
|
15264
15295
|
host.notify?.success("Embed token issued. Copy it now \u2014 it is never shown again.");
|
|
15265
15296
|
}, [client, formId, host, mode, parsed, recordId, savedViewId]);
|
|
15266
|
-
const revoke = (0,
|
|
15297
|
+
const revoke = (0, import_react112.useCallback)(async () => {
|
|
15267
15298
|
if (!tokenId) return;
|
|
15268
15299
|
setBusy(true);
|
|
15269
15300
|
const done = await client.anonTokenRevoke({ token_id: tokenId });
|
|
@@ -15327,13 +15358,13 @@ function EmbedFrame({
|
|
|
15327
15358
|
] });
|
|
15328
15359
|
}
|
|
15329
15360
|
function useEmbedHandshake(args) {
|
|
15330
|
-
const client = (0,
|
|
15331
|
-
const [binding, setBinding] = (0,
|
|
15332
|
-
const [error, setError] = (0,
|
|
15333
|
-
const [loading, setLoading] = (0,
|
|
15361
|
+
const client = (0, import_react113.useRecordsClient)();
|
|
15362
|
+
const [binding, setBinding] = (0, import_react112.useState)(null);
|
|
15363
|
+
const [error, setError] = (0, import_react112.useState)(null);
|
|
15364
|
+
const [loading, setLoading] = (0, import_react112.useState)(true);
|
|
15334
15365
|
const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
|
|
15335
15366
|
const { secret, requiredMode } = args;
|
|
15336
|
-
(0,
|
|
15367
|
+
(0, import_react112.useEffect)(() => {
|
|
15337
15368
|
let cancelled = false;
|
|
15338
15369
|
setLoading(true);
|
|
15339
15370
|
setError(null);
|
|
@@ -15355,7 +15386,7 @@ function useEmbedHandshake(args) {
|
|
|
15355
15386
|
}
|
|
15356
15387
|
|
|
15357
15388
|
// src/RecordsMount.tsx
|
|
15358
|
-
var
|
|
15389
|
+
var import_react115 = require("@ai-matrx/records/react");
|
|
15359
15390
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
15360
15391
|
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.";
|
|
15361
15392
|
function storeDecidesRights(_table) {
|
|
@@ -15369,7 +15400,7 @@ function RecordsMount({
|
|
|
15369
15400
|
}) {
|
|
15370
15401
|
const bound = { ...host ?? {} };
|
|
15371
15402
|
void letTheStoreDecideRights;
|
|
15372
|
-
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
15403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_react115.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(RecordsUiProvider, { value: bound, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(RecordLabelProvider, { children }) }) });
|
|
15373
15404
|
}
|
|
15374
15405
|
function personActor(userId) {
|
|
15375
15406
|
return userId ? { actor: "user", user_id: userId } : { actor: "user" };
|
|
@@ -15388,8 +15419,8 @@ function recordsDataSource(client, fallbackSchema = "custom") {
|
|
|
15388
15419
|
}
|
|
15389
15420
|
|
|
15390
15421
|
// src/TablesHome.tsx
|
|
15391
|
-
var
|
|
15392
|
-
var
|
|
15422
|
+
var import_react116 = require("react");
|
|
15423
|
+
var import_react117 = require("@ai-matrx/records/react");
|
|
15393
15424
|
var import_design_system56 = require("@ai-matrx/design-system");
|
|
15394
15425
|
|
|
15395
15426
|
// src/createTable.ts
|
|
@@ -15525,15 +15556,15 @@ function laneFor(table) {
|
|
|
15525
15556
|
return "organization";
|
|
15526
15557
|
}
|
|
15527
15558
|
function TablesHome({ onOpenTable, className }) {
|
|
15528
|
-
const client = (0,
|
|
15529
|
-
const tables = (0,
|
|
15530
|
-
const [creating, setCreating] = (0,
|
|
15531
|
-
const [name, setName] = (0,
|
|
15532
|
-
const [busy, setBusy] = (0,
|
|
15533
|
-
const [error, setError] = (0,
|
|
15534
|
-
const [importInto, setImportInto] = (0,
|
|
15535
|
-
const [boards, setBoards] = (0,
|
|
15536
|
-
(0,
|
|
15559
|
+
const client = (0, import_react117.useRecordsClient)();
|
|
15560
|
+
const tables = (0, import_react117.useTables)();
|
|
15561
|
+
const [creating, setCreating] = (0, import_react116.useState)(false);
|
|
15562
|
+
const [name, setName] = (0, import_react116.useState)("");
|
|
15563
|
+
const [busy, setBusy] = (0, import_react116.useState)(false);
|
|
15564
|
+
const [error, setError] = (0, import_react116.useState)(null);
|
|
15565
|
+
const [importInto, setImportInto] = (0, import_react116.useState)(null);
|
|
15566
|
+
const [boards, setBoards] = (0, import_react116.useState)(null);
|
|
15567
|
+
(0, import_react116.useEffect)(() => {
|
|
15537
15568
|
let cancelled = false;
|
|
15538
15569
|
void client.dashboards({}).then((result) => {
|
|
15539
15570
|
if (cancelled) return;
|
|
@@ -15543,7 +15574,7 @@ function TablesHome({ onOpenTable, className }) {
|
|
|
15543
15574
|
cancelled = true;
|
|
15544
15575
|
};
|
|
15545
15576
|
}, [client]);
|
|
15546
|
-
const create = (0,
|
|
15577
|
+
const create = (0, import_react116.useCallback)(
|
|
15547
15578
|
async (mode) => {
|
|
15548
15579
|
const trimmed = name.trim();
|
|
15549
15580
|
if (!trimmed) return;
|
|
@@ -15667,8 +15698,8 @@ function TablesHome({ onOpenTable, className }) {
|
|
|
15667
15698
|
}
|
|
15668
15699
|
|
|
15669
15700
|
// src/TablePage.tsx
|
|
15670
|
-
var
|
|
15671
|
-
var
|
|
15701
|
+
var import_react118 = require("react");
|
|
15702
|
+
var import_react119 = require("@ai-matrx/records/react");
|
|
15672
15703
|
var import_design_system57 = require("@ai-matrx/design-system");
|
|
15673
15704
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
15674
15705
|
function filterInWords(filter, fields) {
|
|
@@ -15750,24 +15781,24 @@ function TablePage({
|
|
|
15750
15781
|
filter,
|
|
15751
15782
|
className
|
|
15752
15783
|
}) {
|
|
15753
|
-
const client = (0,
|
|
15754
|
-
const table = (0,
|
|
15784
|
+
const client = (0, import_react119.useRecordsClient)();
|
|
15785
|
+
const table = (0, import_react119.useTable)(tableId);
|
|
15755
15786
|
const rights = useTableRights(table.data);
|
|
15756
|
-
const pageFields = (0,
|
|
15787
|
+
const pageFields = (0, import_react119.useFields)(filter ? tableId : null);
|
|
15757
15788
|
const askedInWords = filter ? filterInWords(filter, pageFields.data ?? []) : null;
|
|
15758
|
-
const organizationId = (0,
|
|
15759
|
-
const [view, setView] = (0,
|
|
15789
|
+
const organizationId = (0, import_react119.useRecordsClient)().config.organizationId;
|
|
15790
|
+
const [view, setView] = (0, import_react118.useState)(null);
|
|
15760
15791
|
const opening = openingRail(activeRecordId);
|
|
15761
15792
|
const opened = openingView(activeView, activeDashboardId);
|
|
15762
|
-
const [asking, setAsking] = (0,
|
|
15763
|
-
const [layoutFromLink, setLayoutFromLink] = (0,
|
|
15764
|
-
const [surface, setSurface] = (0,
|
|
15793
|
+
const [asking, setAsking] = (0, import_react118.useState)(null);
|
|
15794
|
+
const [layoutFromLink, setLayoutFromLink] = (0, import_react118.useState)(opened.layout);
|
|
15795
|
+
const [surface, setSurface] = (0, import_react118.useState)({
|
|
15765
15796
|
main: opened.main,
|
|
15766
15797
|
rail: opening.rail
|
|
15767
15798
|
});
|
|
15768
15799
|
const { main, rail } = surface;
|
|
15769
15800
|
const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
|
|
15770
|
-
const [openRecord, setOpenRecord] = (0,
|
|
15801
|
+
const [openRecord, setOpenRecord] = (0, import_react118.useState)(opening.record);
|
|
15771
15802
|
const viewVersion = useRecordVersion(view?.id ?? null);
|
|
15772
15803
|
const shownLayout = layoutFromLink ?? view?.layout ?? "grid";
|
|
15773
15804
|
const press = (pressed) => {
|
|
@@ -15778,19 +15809,19 @@ function TablePage({
|
|
|
15778
15809
|
}
|
|
15779
15810
|
};
|
|
15780
15811
|
const show = (next) => press({ rail: next });
|
|
15781
|
-
(0,
|
|
15812
|
+
(0, import_react118.useEffect)(() => {
|
|
15782
15813
|
if (!activeRecordId) return;
|
|
15783
15814
|
setOpenRecord(activeRecordId);
|
|
15784
15815
|
setSurface((now) => ({ ...now, rail: "record" }));
|
|
15785
15816
|
}, [activeRecordId]);
|
|
15786
|
-
(0,
|
|
15817
|
+
(0, import_react118.useEffect)(() => {
|
|
15787
15818
|
const named = pageViewFromParam(activeView);
|
|
15788
15819
|
if (named === null) return;
|
|
15789
15820
|
const isLayout = named !== "dashboards" && named !== "archived";
|
|
15790
15821
|
setLayoutFromLink(isLayout ? named : null);
|
|
15791
15822
|
setSurface((now) => ({ ...now, main: isLayout ? "records" : named }));
|
|
15792
15823
|
}, [activeView]);
|
|
15793
|
-
const patchView = (0,
|
|
15824
|
+
const patchView = (0, import_react118.useCallback)(
|
|
15794
15825
|
async (patch) => {
|
|
15795
15826
|
const current = view;
|
|
15796
15827
|
if (!current) return;
|