@ai-matrx/records-ui 0.102.15 → 0.102.16
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 +6 -0
- package/dist/index.cjs +580 -512
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +437 -369
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +57 -30
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +57 -30
- package/dist/pickers.js.map +1 -1
- package/dist/table-shape.cjs +2 -32
- package/dist/table-shape.cjs.map +1 -1
- package/dist/table-shape.d.cts +1 -1
- package/dist/table-shape.d.ts +1 -1
- package/dist/table-shape.js +2 -32
- package/dist/table-shape.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1715,12 +1715,12 @@ function PickOrAdd({
|
|
|
1715
1715
|
children,
|
|
1716
1716
|
chips,
|
|
1717
1717
|
multi,
|
|
1718
|
-
|
|
1718
|
+
onEscape
|
|
1719
1719
|
}) {
|
|
1720
1720
|
const addRow = add && !foot ? add : null;
|
|
1721
1721
|
const count = items.length + (addRow ? 1 : 0);
|
|
1722
|
-
const addAt = addRow ?
|
|
1723
|
-
const itemAt = (index) =>
|
|
1722
|
+
const addAt = addRow ? items.length : -1;
|
|
1723
|
+
const itemAt = (index) => index;
|
|
1724
1724
|
const removable = (chips ?? []).filter((c) => c.onRemove);
|
|
1725
1725
|
const keys = useListKeys({
|
|
1726
1726
|
count,
|
|
@@ -1734,7 +1734,7 @@ function PickOrAdd({
|
|
|
1734
1734
|
if (item && !item.disabled) onPick(item.id);
|
|
1735
1735
|
},
|
|
1736
1736
|
onNothing: onEnterWithNoMatch ?? (add && !add.disabled ? add.onAdd : void 0),
|
|
1737
|
-
onClose: () => onOpenChange(false),
|
|
1737
|
+
onClose: () => onEscape ? onEscape() : onOpenChange(false),
|
|
1738
1738
|
...multi ? { onFinish: () => onOpenChange(false) } : {},
|
|
1739
1739
|
...removable.length > 0 ? { onBackspaceEmpty: () => removable[removable.length - 1]?.onRemove?.() } : {},
|
|
1740
1740
|
searchEmpty: search === ""
|
|
@@ -1768,6 +1768,11 @@ function PickOrAdd({
|
|
|
1768
1768
|
onKeyDown: (event) => {
|
|
1769
1769
|
if (event.key !== "Tab") event.stopPropagation();
|
|
1770
1770
|
},
|
|
1771
|
+
onEscapeKeyDown: (event) => {
|
|
1772
|
+
if (!onEscape) return;
|
|
1773
|
+
event.preventDefault();
|
|
1774
|
+
onEscape();
|
|
1775
|
+
},
|
|
1771
1776
|
onCloseAutoFocus: (event) => {
|
|
1772
1777
|
if (anchored) event.preventDefault();
|
|
1773
1778
|
},
|
|
@@ -1789,7 +1794,6 @@ function PickOrAdd({
|
|
|
1789
1794
|
notice,
|
|
1790
1795
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_design_system5.ScrollArea, { className: "max-h-64", children: [
|
|
1791
1796
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "listbox", "aria-label": triggerLabel, "aria-multiselectable": multi ? true : void 0, children: [
|
|
1792
|
-
addFirst ? addRowNode : null,
|
|
1793
1797
|
items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1794
1798
|
PickRow,
|
|
1795
1799
|
{
|
|
@@ -1801,13 +1805,13 @@ function PickOrAdd({
|
|
|
1801
1805
|
disabled: item.disabled,
|
|
1802
1806
|
attrs: item.attrs,
|
|
1803
1807
|
person: item.person,
|
|
1804
|
-
highlighted:
|
|
1808
|
+
highlighted: index === keys.highlight,
|
|
1805
1809
|
onPick: () => onPick(item.id),
|
|
1806
|
-
onPoint: () => keys.setHighlight(
|
|
1810
|
+
onPoint: () => keys.setHighlight(index)
|
|
1807
1811
|
},
|
|
1808
1812
|
item.id
|
|
1809
1813
|
)),
|
|
1810
|
-
|
|
1814
|
+
addRowNode
|
|
1811
1815
|
] }),
|
|
1812
1816
|
items.length === 0 && empty ? empty : null
|
|
1813
1817
|
] }),
|
|
@@ -1852,7 +1856,7 @@ async function personRecordForMember(client, personTableId, people, member) {
|
|
|
1852
1856
|
});
|
|
1853
1857
|
return written;
|
|
1854
1858
|
}
|
|
1855
|
-
function PersonPicker({ field: field2, value, onChange, disabled, id, className, autoOpen, onClose, initialSearch }) {
|
|
1859
|
+
function PersonPicker({ field: field2, value, onChange, disabled, id, className, autoOpen, onClose, onCancel, initialSearch }) {
|
|
1856
1860
|
const client = (0, import_react9.useOptionalRecordsClient)();
|
|
1857
1861
|
const host = useRecordsUi();
|
|
1858
1862
|
const [members, setMembers] = (0, import_react8.useState)(null);
|
|
@@ -1966,6 +1970,7 @@ function PersonPicker({ field: field2, value, onChange, disabled, id, className,
|
|
|
1966
1970
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1967
1971
|
PickOrAdd,
|
|
1968
1972
|
{
|
|
1973
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
1969
1974
|
anchored,
|
|
1970
1975
|
multi: field2.multi,
|
|
1971
1976
|
triggerId: id,
|
|
@@ -3073,7 +3078,7 @@ var import_jsx_runtime9 = (
|
|
|
3073
3078
|
require("react/jsx-runtime")
|
|
3074
3079
|
);
|
|
3075
3080
|
var NO_STORE_ON_THIS_SCREEN_REASON = "This question points at a record in somebody's own data, and a page answered without an account is never allowed to search that. Leave it blank \u2014 whoever receives your answer will fill it in.";
|
|
3076
|
-
function RelationPicker({ field: field2, value, onChange, disabled, id, className, allowCreate = true, onPicked, autoOpen, onClose }) {
|
|
3081
|
+
function RelationPicker({ field: field2, value, onChange, disabled, id, className, allowCreate = true, onPicked, autoOpen, onClose, onCancel }) {
|
|
3077
3082
|
const client = (0, import_react12.useOptionalRecordsClient)();
|
|
3078
3083
|
const [rows, setRows] = (0, import_react11.useState)(null);
|
|
3079
3084
|
const [words2, setWords] = (0, import_react11.useState)({});
|
|
@@ -3237,6 +3242,7 @@ function RelationPicker({ field: field2, value, onChange, disabled, id, classNam
|
|
|
3237
3242
|
PickOrAdd,
|
|
3238
3243
|
{
|
|
3239
3244
|
anchored,
|
|
3245
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
3240
3246
|
multi: field2.multi,
|
|
3241
3247
|
chips: picked.map((recordId) => ({ id: recordId, label: titleOf(recordId), onRemove: () => toggle(recordId) })),
|
|
3242
3248
|
triggerId: id,
|
|
@@ -4809,7 +4815,7 @@ function ChoiceAskButtons({
|
|
|
4809
4815
|
onCancel,
|
|
4810
4816
|
busy
|
|
4811
4817
|
}) {
|
|
4812
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { "data-records-choice-ask": "", role: "group", "aria-label": choiceAskSentence(field2, words2), className: "flex flex-col gap-1", children: [
|
|
4818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { "data-records-choice-ask": "", "data-records-cell-note": "", role: "group", "aria-label": choiceAskSentence(field2, words2), className: "flex flex-col gap-1", children: [
|
|
4813
4819
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[11px] leading-snug", children: choiceAskSentence(field2, words2) }),
|
|
4814
4820
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "flex flex-wrap items-center gap-1", children: [
|
|
4815
4821
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_design_system17.Button, { type: "button", size: "sm", className: "h-6 px-2 text-xs", disabled: busy ?? false, onClick: onAdd, children: "Add" }),
|
|
@@ -4846,7 +4852,11 @@ function typingOpens(field2) {
|
|
|
4846
4852
|
var SHORT_REFUSAL = {
|
|
4847
4853
|
email: "Enter a valid email",
|
|
4848
4854
|
url: "Enter a valid link",
|
|
4849
|
-
phone: "Enter a valid phone number"
|
|
4855
|
+
phone: "Enter a valid phone number",
|
|
4856
|
+
time: "Enter a time, like 2:30 PM",
|
|
4857
|
+
date: "Enter a date",
|
|
4858
|
+
number: "Enter a number",
|
|
4859
|
+
value: "Not a valid value"
|
|
4850
4860
|
};
|
|
4851
4861
|
function judgeTyped(field2, text, choices, nudge) {
|
|
4852
4862
|
const trimmed = text.trim();
|
|
@@ -4855,7 +4865,7 @@ function judgeTyped(field2, text, choices, nudge) {
|
|
|
4855
4865
|
if (trimmed === "") return { value: null };
|
|
4856
4866
|
if (format && format.id === "time") {
|
|
4857
4867
|
const read2 = (0, import_records12.readTypedTime)(trimmed);
|
|
4858
|
-
return read2.ok ? { value: read2.value } : { refusal: `${fieldName(field2)} holds a time of day, and ${read2.why}` };
|
|
4868
|
+
return read2.ok ? { value: read2.value } : { refusal: SHORT_REFUSAL.time, why: `${fieldName(field2)} holds a time of day, and ${read2.why}` };
|
|
4859
4869
|
}
|
|
4860
4870
|
if (kind === "select" || kind === "multi_select") {
|
|
4861
4871
|
if (!choices || nudge === null) return null;
|
|
@@ -4893,7 +4903,7 @@ function judgeTyped(field2, text, choices, nudge) {
|
|
|
4893
4903
|
if (format && format.id === "rating") {
|
|
4894
4904
|
const n = Number(trimmed);
|
|
4895
4905
|
const max = format.options?.ratingMax ?? 5;
|
|
4896
|
-
return Number.isInteger(n) && n >= 0 && n <= max ? { value: n === 0 ? null : n } : { refusal: `${fieldName(field2)} is a rating from 1 to ${max}
|
|
4906
|
+
return Number.isInteger(n) && n >= 0 && n <= max ? { value: n === 0 ? null : n } : { refusal: `Enter 1 to ${max}`, why: `${fieldName(field2)} is a rating from 1 to ${max}.` };
|
|
4897
4907
|
}
|
|
4898
4908
|
if (kind === "phone" || format && format.id === "phone") {
|
|
4899
4909
|
const digits = trimmed.replace(/\D/g, "");
|
|
@@ -4902,7 +4912,11 @@ function judgeTyped(field2, text, choices, nudge) {
|
|
|
4902
4912
|
}
|
|
4903
4913
|
const showsAsPercent = Boolean(format && (format.id === "percent" || format.id === "progress"));
|
|
4904
4914
|
const read = (0, import_records12.coerceTypedAnswer)(field2, text, { label: fieldName(field2), showsAsPercent });
|
|
4905
|
-
if ("refusal" in read)
|
|
4915
|
+
if ("refusal" in read) {
|
|
4916
|
+
if (kind === "email" || kind === "url") return { refusal: SHORT_REFUSAL[kind] };
|
|
4917
|
+
const short = kind === "datetime" ? SHORT_REFUSAL.date : kind === "number" || kind === "currency" || kind === "percent" || showsAsPercent ? SHORT_REFUSAL.number : read.refusal.length <= 32 ? read.refusal : SHORT_REFUSAL.value;
|
|
4918
|
+
return short === read.refusal ? { refusal: short } : { refusal: short, why: read.refusal };
|
|
4919
|
+
}
|
|
4906
4920
|
if (typeof read.value === "number" && format && (format.id === "percent" || format.id === "progress") && format.options?.percentScale === "fraction") {
|
|
4907
4921
|
return { value: Math.round(read.value / 100 * 1e9) / 1e9 };
|
|
4908
4922
|
}
|
|
@@ -4987,7 +5001,7 @@ function TypedTextControl({ field: field2, value, onChange, disabled, id, onComm
|
|
|
4987
5001
|
box,
|
|
4988
5002
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypedDateHelper, { kind: helper, text: value.text, onText: retype, label: fieldName(field2) })
|
|
4989
5003
|
] }) : box,
|
|
4990
|
-
judged === null ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
5004
|
+
judged === null ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children: [
|
|
4991
5005
|
"Reading ",
|
|
4992
5006
|
fieldName(field2),
|
|
4993
5007
|
"'s choices\u2026"
|
|
@@ -5007,10 +5021,19 @@ function TypedTextControl({ field: field2, value, onChange, disabled, id, onComm
|
|
|
5007
5021
|
},
|
|
5008
5022
|
onCancel: () => onCancel?.()
|
|
5009
5023
|
}
|
|
5010
|
-
) : "refusal" in judged ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "flex flex-col gap-1", children: [
|
|
5011
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5024
|
+
) : "refusal" in judged ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { "data-records-cell-note": "", className: "flex flex-col gap-1", children: [
|
|
5025
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5026
|
+
"span",
|
|
5027
|
+
{
|
|
5028
|
+
"data-records-typed-refusal": "",
|
|
5029
|
+
role: "status",
|
|
5030
|
+
title: "why" in judged ? judged.why : void 0,
|
|
5031
|
+
className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400",
|
|
5032
|
+
children: judged.refusal
|
|
5033
|
+
}
|
|
5034
|
+
),
|
|
5012
5035
|
judged.cancelOnly && onCancel ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-records-choice-ask": "", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_design_system17.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onCancel(), children: "Cancel" }) }) : null
|
|
5013
|
-
] }) : judged.value === null || judged.value === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { "data-records-typed-reads-as": "", className: "text-[10px] text-muted-foreground", children: [
|
|
5036
|
+
] }) : judged.value === null || judged.value === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { "data-records-typed-reads-as": "", "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children: [
|
|
5014
5037
|
isChoiceAddition(judged.value) ? `Adds ${quoted(judged.value.add)} to the choices for ${fieldName(field2)}. ` : null,
|
|
5015
5038
|
"Reads as",
|
|
5016
5039
|
" ",
|
|
@@ -5104,9 +5127,9 @@ function FieldControl({ field: field2, value, onChange, disabled, id, autoOpen,
|
|
|
5104
5127
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CheckboxControl, { field: field2, value, onChange, disabled, id: inputId });
|
|
5105
5128
|
case "select":
|
|
5106
5129
|
case "multi_select":
|
|
5107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionControl, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose, addsChoices, initialSearch, asForm });
|
|
5130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionControl, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm });
|
|
5108
5131
|
case "member":
|
|
5109
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PersonPicker, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose, initialSearch });
|
|
5132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PersonPicker, { field: field2, value, onChange, disabled, id: inputId, autoOpen, onClose, onCancel, initialSearch });
|
|
5110
5133
|
case "entity_reference":
|
|
5111
5134
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EntityReferenceControl, { field: field2, value, onChange, disabled, id: inputId });
|
|
5112
5135
|
case "attachment":
|
|
@@ -5115,7 +5138,7 @@ function FieldControl({ field: field2, value, onChange, disabled, id, autoOpen,
|
|
|
5115
5138
|
}
|
|
5116
5139
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RelationPicker, { field: field2, value, onChange, disabled, id: inputId });
|
|
5117
5140
|
case "relation":
|
|
5118
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RelationPicker, { field: field2, value, onChange, disabled, id: inputId, onPicked: onCommit, autoOpen, onClose });
|
|
5141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RelationPicker, { field: field2, value, onChange, disabled, id: inputId, onPicked: onCommit, autoOpen, onClose, onCancel });
|
|
5119
5142
|
default:
|
|
5120
5143
|
if (typeof value === "boolean" || field2.config?.["kind"] === "boolean") {
|
|
5121
5144
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
@@ -5143,6 +5166,7 @@ function FieldControl({ field: field2, value, onChange, disabled, id, autoOpen,
|
|
|
5143
5166
|
function TypedWordsControl({ field: field2, value, onChange, disabled, id }) {
|
|
5144
5167
|
const [text, setText] = (0, import_react28.useState)(() => openingText(field2, value));
|
|
5145
5168
|
const [refusal4, setRefusal] = (0, import_react28.useState)(null);
|
|
5169
|
+
const [why, setWhy] = (0, import_react28.useState)(void 0);
|
|
5146
5170
|
const sent = (0, import_react28.useRef)(value);
|
|
5147
5171
|
(0, import_react28.useEffect)(() => {
|
|
5148
5172
|
if (value === sent.current) return;
|
|
@@ -5160,6 +5184,7 @@ function TypedWordsControl({ field: field2, value, onChange, disabled, id }) {
|
|
|
5160
5184
|
onChange(judged.value);
|
|
5161
5185
|
} else if (judged && "refusal" in judged) {
|
|
5162
5186
|
setRefusal(judged.refusal);
|
|
5187
|
+
setWhy("why" in judged ? judged.why : void 0);
|
|
5163
5188
|
}
|
|
5164
5189
|
};
|
|
5165
5190
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "flex flex-col gap-0.5", children: [
|
|
@@ -5183,7 +5208,7 @@ function TypedWordsControl({ field: field2, value, onChange, disabled, id }) {
|
|
|
5183
5208
|
),
|
|
5184
5209
|
helper && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypedDateHelper, { kind: helper, text, onText: retype, label: fieldName(field2) }) : null
|
|
5185
5210
|
] }),
|
|
5186
|
-
refusal4 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-records-typed-refusal": "", role: "status", className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: refusal4 }) : null
|
|
5211
|
+
refusal4 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-records-typed-refusal": "", "data-records-cell-note": "", role: "status", title: why, className: "text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: refusal4 }) : null
|
|
5187
5212
|
] });
|
|
5188
5213
|
}
|
|
5189
5214
|
function CheckboxControl({ field: field2, value, onChange, disabled, id }) {
|
|
@@ -5253,8 +5278,9 @@ function JsonControl({ field: field2, value, onChange, disabled, id }) {
|
|
|
5253
5278
|
}
|
|
5254
5279
|
),
|
|
5255
5280
|
broken ? (
|
|
5256
|
-
// The typed text is still in the box: the notice owns the two doors out.
|
|
5257
|
-
|
|
5281
|
+
// The typed text is still in the box: the notice owns the two doors out. In a grid cell it
|
|
5282
|
+
// floats over the table (`data-records-cell-note`), so the row never grows.
|
|
5283
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-records-cell-note": "", className: "block", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5258
5284
|
RefusalNotice,
|
|
5259
5285
|
{
|
|
5260
5286
|
error: broken,
|
|
@@ -5264,7 +5290,7 @@ function JsonControl({ field: field2, value, onChange, disabled, id }) {
|
|
|
5264
5290
|
setBroken(null);
|
|
5265
5291
|
}
|
|
5266
5292
|
}
|
|
5267
|
-
)
|
|
5293
|
+
) })
|
|
5268
5294
|
) : null
|
|
5269
5295
|
] });
|
|
5270
5296
|
}
|
|
@@ -5277,7 +5303,7 @@ function inTheStoresOrder(options) {
|
|
|
5277
5303
|
const made = (o) => String(o.created_at ?? "");
|
|
5278
5304
|
return [...options].sort((a, b) => position(a) - position(b) || made(a).localeCompare(made(b)));
|
|
5279
5305
|
}
|
|
5280
|
-
function OptionControl({ field: field2, value, onChange, disabled, id, autoOpen, onClose, addsChoices, initialSearch, asForm }) {
|
|
5306
|
+
function OptionControl({ field: field2, value, onChange, disabled, id, autoOpen, onClose, onCancel, addsChoices, initialSearch, asForm }) {
|
|
5281
5307
|
const client = (0, import_react29.useOptionalRecordsClient)();
|
|
5282
5308
|
const [options, setOptions] = (0, import_react28.useState)(null);
|
|
5283
5309
|
const [refusal4, setRefusal] = (0, import_react28.useState)(null);
|
|
@@ -5345,6 +5371,7 @@ function OptionControl({ field: field2, value, onChange, disabled, id, autoOpen,
|
|
|
5345
5371
|
id,
|
|
5346
5372
|
autoOpen,
|
|
5347
5373
|
onClose,
|
|
5374
|
+
onCancel,
|
|
5348
5375
|
initialSearch,
|
|
5349
5376
|
addsChoices,
|
|
5350
5377
|
allowOther: (0, import_records12.allowsOtherValues)(field2),
|
|
@@ -5425,6 +5452,7 @@ function OpenChoicePicker({
|
|
|
5425
5452
|
addsChoices,
|
|
5426
5453
|
autoOpen,
|
|
5427
5454
|
onClose,
|
|
5455
|
+
onCancel,
|
|
5428
5456
|
initialSearch,
|
|
5429
5457
|
allowOther = true,
|
|
5430
5458
|
onChoicesChanged
|
|
@@ -5492,10 +5520,9 @@ function OpenChoicePicker({
|
|
|
5492
5520
|
});
|
|
5493
5521
|
};
|
|
5494
5522
|
const offList = q !== "" && decided.decision !== "chosen" && decided.decision !== "empty";
|
|
5495
|
-
const nothingMatches = q !== "" && visible.length === 0;
|
|
5496
5523
|
const foot = null;
|
|
5497
5524
|
const add = offList && (decided.decision === "ask" || decided.decision === "add") ? { label: `Create \u201C${q}\u201D`, onAdd: addTyped, disabled: adding } : offList && decided.decision === "keep_as_typed" ? { label: `Use \u201C${q}\u201D`, onAdd: () => choose(q) } : null;
|
|
5498
|
-
const listed =
|
|
5525
|
+
const listed = visible;
|
|
5499
5526
|
const pickedOptions = current.map((v) => options.find((o) => (0, import_records12.isTheChosen)(o, v)));
|
|
5500
5527
|
const cellChips = pickedWords.map((word, i) => {
|
|
5501
5528
|
const chip = chipOf(pickedOptions[i], word);
|
|
@@ -5523,6 +5550,7 @@ function OpenChoicePicker({
|
|
|
5523
5550
|
PickOrAdd,
|
|
5524
5551
|
{
|
|
5525
5552
|
anchored,
|
|
5553
|
+
...anchored && onCancel ? { onEscape: onCancel } : {},
|
|
5526
5554
|
chips: headChips,
|
|
5527
5555
|
multi: field2.multi,
|
|
5528
5556
|
triggerLabel: `Pick for ${fieldName(field2)}`,
|
|
@@ -5534,7 +5562,6 @@ function OpenChoicePicker({
|
|
|
5534
5562
|
setSearch(next);
|
|
5535
5563
|
setAddRefused(null);
|
|
5536
5564
|
},
|
|
5537
|
-
addFirst: nothingMatches,
|
|
5538
5565
|
items: listed.map((option) => ({
|
|
5539
5566
|
id: option.id,
|
|
5540
5567
|
label: titleOf(option),
|
|
@@ -7137,8 +7164,9 @@ function cardWords(record, field2, labels) {
|
|
|
7137
7164
|
|
|
7138
7165
|
// src/gridEditing.tsx
|
|
7139
7166
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
7140
|
-
var
|
|
7141
|
-
var
|
|
7167
|
+
var FLOATING_CELL_NOTE_CLASS = "[&_[data-records-cell-note]]:absolute [&_[data-records-cell-note]]:bottom-full [&_[data-records-cell-note]]:left-0 [&_[data-records-cell-note]]:z-[26] [&_[data-records-cell-note]]:mb-1 [&_[data-records-cell-note]]:w-max [&_[data-records-cell-note]]:max-w-[24rem] [&_[data-records-cell-note]]:rounded-md [&_[data-records-cell-note]]:border [&_[data-records-cell-note]]:bg-popover [&_[data-records-cell-note]]:px-1.5 [&_[data-records-cell-note]]:py-0.5 [&_[data-records-cell-note]]:shadow-md";
|
|
7168
|
+
var FLOATING_CELL_TRAY_CLASS = "absolute left-0 top-full z-[26] mt-1 flex w-max max-w-[24rem] flex-col items-start gap-1";
|
|
7169
|
+
var FLOATING_CELL_TRAY_PIECE_CLASS = "rounded-md border bg-popover px-1.5 py-0.5 shadow-md";
|
|
7142
7170
|
var NO_ROWS = [];
|
|
7143
7171
|
function asksWhoChanged(event) {
|
|
7144
7172
|
return event.altKey && event.shiftKey && !event.metaKey && !event.ctrlKey && (event.code === "KeyH" || event.key.toLowerCase() === "h");
|
|
@@ -7714,8 +7742,18 @@ function GridCell({
|
|
|
7714
7742
|
const onLinkClickCapture = (event) => {
|
|
7715
7743
|
const link = event.target instanceof Element ? event.target.closest("a[href]") : null;
|
|
7716
7744
|
if (!(link instanceof HTMLElement) || !event.currentTarget.contains(link) || event.detail === 0) return;
|
|
7745
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey) {
|
|
7746
|
+
cancelSinglePress();
|
|
7747
|
+
event.stopPropagation();
|
|
7748
|
+
return;
|
|
7749
|
+
}
|
|
7717
7750
|
event.preventDefault();
|
|
7718
7751
|
const cellTakesIt = editable && (clickOpens || opensAsAList(field2, hostTakesFiles(ui)));
|
|
7752
|
+
if (cellTakesIt && event.detail === 1 && (clickOpens || wasActive.current)) {
|
|
7753
|
+
cancelSinglePress();
|
|
7754
|
+
openThisCell(event);
|
|
7755
|
+
return;
|
|
7756
|
+
}
|
|
7719
7757
|
if (event.detail === 1 && wasActive.current && !cellTakesIt) afterSinglePress(() => link.click());
|
|
7720
7758
|
else cancelSinglePress();
|
|
7721
7759
|
};
|
|
@@ -7724,32 +7762,46 @@ function GridCell({
|
|
|
7724
7762
|
const refusal4 = editing ? editing.refusalOf(row.id, field2.key) : null;
|
|
7725
7763
|
const editable = Boolean(editing) && canWrite && fieldIsEditable(field2);
|
|
7726
7764
|
if (open && editing) {
|
|
7727
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { "data-records-open-cell": "", className: "relative block w-full min-w-0", children: [
|
|
7766
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", "data-records-cell-ghost": "", className: "pointer-events-none invisible block select-none truncate px-1 py-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
7767
|
+
RecordValue,
|
|
7768
|
+
{
|
|
7769
|
+
inCell: true,
|
|
7770
|
+
field: field2,
|
|
7771
|
+
value: row.document?.[field2.key],
|
|
7772
|
+
document: row.document,
|
|
7773
|
+
recordId: row.id,
|
|
7774
|
+
withheld: withheldNoticeOf(row.hidden, field2.key),
|
|
7775
|
+
...format ? { format } : {}
|
|
7776
|
+
}
|
|
7777
|
+
) }),
|
|
7778
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
7779
|
+
OpenCell,
|
|
7780
|
+
{
|
|
7781
|
+
field: field2,
|
|
7782
|
+
draft: editing.draft,
|
|
7783
|
+
initialSearch: editing.searchSeed,
|
|
7784
|
+
onType: editing.type,
|
|
7785
|
+
onCommit: (move, via) => editing.commit(move, via),
|
|
7786
|
+
onCancel: (via) => editing.cancel(via),
|
|
7787
|
+
below: (
|
|
7788
|
+
// KEPT EDITING: the refusal stays beside the value it is about, so the
|
|
7789
|
+
// person reads what to change while changing it. Keep editing is the
|
|
7790
|
+
// state they are in, so only Discard is offered. It is INSIDE the open
|
|
7791
|
+
// cell, so pressing Discard is not "focus left the cell" — which would
|
|
7792
|
+
// commit the refused value one more time on its way out.
|
|
7793
|
+
refusal4 && !refusal4.conflict ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
7794
|
+
RefusalNotice,
|
|
7795
|
+
{
|
|
7796
|
+
error: refusal4.error,
|
|
7797
|
+
className: "py-1.5 text-left",
|
|
7798
|
+
onDiscard: () => editing.discard(row.id, field2.key)
|
|
7799
|
+
}
|
|
7800
|
+
) : null
|
|
7801
|
+
)
|
|
7802
|
+
}
|
|
7803
|
+
)
|
|
7804
|
+
] });
|
|
7753
7805
|
}
|
|
7754
7806
|
if (editorKindFor(field2) === "checkbox") {
|
|
7755
7807
|
const answered = value === true || value === false;
|
|
@@ -8099,8 +8151,9 @@ function OpenCell({
|
|
|
8099
8151
|
"data-matrx-cell-editor": "",
|
|
8100
8152
|
tabIndex: -1,
|
|
8101
8153
|
className: (0, import_design_system23.cn)(
|
|
8102
|
-
|
|
8103
|
-
|
|
8154
|
+
// OVER the cell's ghost (see `data-records-open-cell`), never in the table's measuring.
|
|
8155
|
+
"absolute inset-x-0 top-1/2 z-[25] flex w-full min-w-0 max-w-full -translate-y-1/2 flex-col gap-1 outline-none",
|
|
8156
|
+
FLOATING_CELL_NOTE_CLASS,
|
|
8104
8157
|
// A field's own input is 36px (h-9); in a 35px row it grew the row 4px. In the cell it is
|
|
8105
8158
|
// the row action strip's 32px, so opening a cell never changes the row (STABLE-TABLES).
|
|
8106
8159
|
"[&_input:not([type=checkbox]):not([type=radio])]:h-8 [&_input:not([type=checkbox]):not([type=radio])]:py-0"
|
|
@@ -8159,11 +8212,13 @@ function OpenCell({
|
|
|
8159
8212
|
addsChoices: true
|
|
8160
8213
|
}
|
|
8161
8214
|
),
|
|
8162
|
-
|
|
8163
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system23.
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8215
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { "data-records-cell-tray": "", className: FLOATING_CELL_TRAY_CLASS, children: [
|
|
8216
|
+
picker || asksAboutAChoice(draft) ? null : blurCommits ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: (0, import_design_system23.cn)("pointer-events-none text-[10px] text-muted-foreground", FLOATING_CELL_TRAY_PIECE_CLASS), "data-records-editor-hint": "", children: multiline ? "\u23CE saves \xB7 \u21E7\u23CE new line \xB7 Esc cancels \xB7 Tab next" : "\u23CE saves \xB7 Esc cancels \xB7 Tab next" }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: (0, import_design_system23.cn)("flex items-center gap-1", FLOATING_CELL_TRAY_PIECE_CLASS), children: [
|
|
8217
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system23.Button, { size: "sm", onClick: () => once(() => onCommit(null, "pick")), children: "Save" }),
|
|
8218
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system23.Button, { size: "sm", variant: "ghost", onClick: () => once(() => onCancel("pick")), children: "Cancel" })
|
|
8219
|
+
] }),
|
|
8220
|
+
below ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "block bg-popover shadow-md", children: below }) : null
|
|
8221
|
+
] })
|
|
8167
8222
|
]
|
|
8168
8223
|
}
|
|
8169
8224
|
);
|
|
@@ -11364,11 +11419,11 @@ function FieldEditor(props) {
|
|
|
11364
11419
|
import_design_system34.Checkbox,
|
|
11365
11420
|
{
|
|
11366
11421
|
checked: required,
|
|
11367
|
-
"aria-label": "
|
|
11422
|
+
"aria-label": "Required",
|
|
11368
11423
|
onCheckedChange: (v) => setRequired(v === true)
|
|
11369
11424
|
}
|
|
11370
11425
|
),
|
|
11371
|
-
"Every record has to have one"
|
|
11426
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { title: "Every record has to have one", children: "Required" })
|
|
11372
11427
|
] }),
|
|
11373
11428
|
offersMany ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
11374
11429
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
@@ -14894,7 +14949,7 @@ function useMergedGridControls(args) {
|
|
|
14894
14949
|
children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_design_system46.DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-2xl", children: [
|
|
14895
14950
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_design_system46.DialogHeader, { children: [
|
|
14896
14951
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_design_system46.DialogTitle, { children: dialog?.kind === "settings" ? `Column settings \xB7 ${fieldName(dialog.field)}` : dialog?.kind === "insert" && dialog.anchor ? `Add column ${dialog.side === "left" ? "left" : "right"} of ${fieldOf2(dialog.anchor) ? fieldName(fieldOf2(dialog.anchor)) : dialog.anchor}` : ADD_FIELD_OPEN_LABEL }),
|
|
14897
|
-
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_design_system46.DialogDescription, { className: "sr-only", children: "
|
|
14952
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_design_system46.DialogDescription, { className: "sr-only", children: "Name, type and look" })
|
|
14898
14953
|
] }),
|
|
14899
14954
|
dialog?.kind === "settings" ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
14900
14955
|
FieldEditor,
|
|
@@ -19356,6 +19411,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
|
|
|
19356
19411
|
// src/tableShape.ts
|
|
19357
19412
|
var import_source2 = require("@ai-matrx/content-ir/source");
|
|
19358
19413
|
var import_text_case9 = require("@ai-matrx/kit/text-case");
|
|
19414
|
+
var import_delimited2 = require("@ai-matrx/kit/delimited");
|
|
19359
19415
|
var FEWEST_LIST_ITEMS = 2;
|
|
19360
19416
|
var FEWEST_KEY_VALUE_PAIRS = 2;
|
|
19361
19417
|
var LONGEST_TEXT_READ = 2e6;
|
|
@@ -19533,38 +19589,7 @@ function shapeFromList(items, name, at) {
|
|
|
19533
19589
|
};
|
|
19534
19590
|
}
|
|
19535
19591
|
function parseDelimited(text, delimiter) {
|
|
19536
|
-
|
|
19537
|
-
let row = [];
|
|
19538
|
-
let cell2 = "";
|
|
19539
|
-
let quoted2 = false;
|
|
19540
|
-
for (let i = 0; i < text.length; i += 1) {
|
|
19541
|
-
const ch = text[i];
|
|
19542
|
-
if (quoted2) {
|
|
19543
|
-
if (ch === '"') {
|
|
19544
|
-
if (text[i + 1] === '"') {
|
|
19545
|
-
cell2 += '"';
|
|
19546
|
-
i += 1;
|
|
19547
|
-
} else quoted2 = false;
|
|
19548
|
-
} else cell2 += ch;
|
|
19549
|
-
continue;
|
|
19550
|
-
}
|
|
19551
|
-
if (ch === '"' && cell2.trim() === "") quoted2 = true;
|
|
19552
|
-
else if (ch === delimiter) {
|
|
19553
|
-
row.push(cell2);
|
|
19554
|
-
cell2 = "";
|
|
19555
|
-
} else if (ch === "\n" || ch === "\r") {
|
|
19556
|
-
if (ch === "\r" && text[i + 1] === "\n") i += 1;
|
|
19557
|
-
row.push(cell2);
|
|
19558
|
-
rows.push(row);
|
|
19559
|
-
row = [];
|
|
19560
|
-
cell2 = "";
|
|
19561
|
-
} else cell2 += ch;
|
|
19562
|
-
}
|
|
19563
|
-
if (cell2.length > 0 || row.length > 0) {
|
|
19564
|
-
row.push(cell2);
|
|
19565
|
-
rows.push(row);
|
|
19566
|
-
}
|
|
19567
|
-
return rows.filter((r) => r.some((c) => c.trim() !== ""));
|
|
19592
|
+
return (0, import_delimited2.parseDelimited)(text, { delimiter, skipEmptyLines: "greedy" }).data;
|
|
19568
19593
|
}
|
|
19569
19594
|
function delimitedShape(text, delimiter, fenced, at, name) {
|
|
19570
19595
|
const matrix = parseDelimited(text.trim(), delimiter);
|
|
@@ -23517,7 +23542,7 @@ function GridBody({
|
|
|
23517
23542
|
{
|
|
23518
23543
|
...fills ? { className: "min-h-0 flex-1" } : {},
|
|
23519
23544
|
frameHeight: fills ? "fill" : "content",
|
|
23520
|
-
loadingRows: fills ? "fill" :
|
|
23545
|
+
loadingRows: rememberedRowCount(rowMemoryKey, pageSize, fills ? "fill" : 5),
|
|
23521
23546
|
...!look.rowHeight ? { loadingRowHeight: RECORDS_GRID_ROW_PX } : {},
|
|
23522
23547
|
data: rows,
|
|
23523
23548
|
columns: tableColumns,
|
|
@@ -27456,7 +27481,7 @@ function SaveToTable({ source, shapeIndex = 0, onOpenTable, onSaved, onClose, cl
|
|
|
27456
27481
|
},
|
|
27457
27482
|
variant: "destructive",
|
|
27458
27483
|
title: `Move every row of \u201C${writable.find((t) => t.id === tableId)?.name ?? "this table"}\u201D to the archive?`,
|
|
27459
|
-
description: "
|
|
27484
|
+
description: "Restorable from Archived items",
|
|
27460
27485
|
confirmLabel: replacing ? "Archiving\u2026" : "Archive them",
|
|
27461
27486
|
cancelLabel: "Keep them",
|
|
27462
27487
|
busy: replacing,
|
|
@@ -28943,18 +28968,25 @@ function RecordFieldsInPlace({
|
|
|
28943
28968
|
const format = formatForField(field2);
|
|
28944
28969
|
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "contents", children: [
|
|
28945
28970
|
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("dt", { className: "flex items-baseline gap-1 truncate py-1 text-muted-foreground", children: renderLabel(field2) }),
|
|
28946
|
-
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
28947
|
-
|
|
28971
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
28972
|
+
"dd",
|
|
28948
28973
|
{
|
|
28949
|
-
|
|
28950
|
-
|
|
28951
|
-
|
|
28952
|
-
|
|
28953
|
-
|
|
28954
|
-
|
|
28955
|
-
|
|
28974
|
+
className: "min-w-0 rounded hover:bg-muted/50 [&_[data-matrx-cell-editor]_input:not([type=checkbox]):not([type=radio])]:!h-7",
|
|
28975
|
+
"data-records-in-place-field": field2.key,
|
|
28976
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
28977
|
+
GridCell,
|
|
28978
|
+
{
|
|
28979
|
+
field: field2,
|
|
28980
|
+
row,
|
|
28981
|
+
editing: canWrite ? editing : null,
|
|
28982
|
+
canWrite,
|
|
28983
|
+
whyNot,
|
|
28984
|
+
clickOpens: true,
|
|
28985
|
+
...format ? { format } : {}
|
|
28986
|
+
}
|
|
28987
|
+
)
|
|
28956
28988
|
}
|
|
28957
|
-
)
|
|
28989
|
+
)
|
|
28958
28990
|
] }, field2.id);
|
|
28959
28991
|
}) }),
|
|
28960
28992
|
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(UndoNotice, { undo })
|
|
@@ -29151,7 +29183,7 @@ function AddBody({ tableId }) {
|
|
|
29151
29183
|
const made = await mutation.declare({ table_id: tableId, spec: { label: BODY_COLUMN_NAME, type: "rich_text" } });
|
|
29152
29184
|
if (made) (0, import_react160.tableShapeChanged)(tableId);
|
|
29153
29185
|
},
|
|
29154
|
-
children: "
|
|
29186
|
+
children: "Add notes"
|
|
29155
29187
|
}
|
|
29156
29188
|
),
|
|
29157
29189
|
mutation.error ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(RefusalNotice, { error: mutation.error }) : null
|
|
@@ -29296,7 +29328,7 @@ function computedInPlainWords(row, field2) {
|
|
|
29296
29328
|
const shown4 = row.value === null || row.value === void 0 || row.value === "" ? "nothing" : field2 ? scalarText(field2, row.value) : String(row.value);
|
|
29297
29329
|
const when = new Date(row.computed_at);
|
|
29298
29330
|
const at = Number.isNaN(when.getTime()) ? "" : ` on ${when.toLocaleDateString()}`;
|
|
29299
|
-
return `${name}
|
|
29331
|
+
return `${name}: ${shown4}${at}`;
|
|
29300
29332
|
}
|
|
29301
29333
|
|
|
29302
29334
|
// src/systemTable.ts
|
|
@@ -29526,7 +29558,10 @@ async function keepLook(client, tableId, viewId, look) {
|
|
|
29526
29558
|
return client.viewLookSet({ table_id: tableId, view_id: viewId, look: doc && Object.keys(doc).length > 0 ? doc : null });
|
|
29527
29559
|
}
|
|
29528
29560
|
var LOOK_WORDS = {
|
|
29561
|
+
/** The reason, for a tooltip or a screen reader — never a line on the page (interface-text). */
|
|
29529
29562
|
yours: "You changed how this view looks. Only you see it.",
|
|
29563
|
+
/** The visible label for the same fact. */
|
|
29564
|
+
yoursLabel: "Only you see this",
|
|
29530
29565
|
saveToView: "Save to view",
|
|
29531
29566
|
saveAsNew: "Save as new view",
|
|
29532
29567
|
reset: "Reset to view",
|
|
@@ -39196,7 +39231,7 @@ function WebhooksPanel({ tableId, className }) {
|
|
|
39196
39231
|
if (!next && !busy) setStopping(null);
|
|
39197
39232
|
},
|
|
39198
39233
|
title: `Stop sending to ${stopping?.description ?? stopping?.target_url ?? "this address"}?`,
|
|
39199
|
-
description: "
|
|
39234
|
+
description: "Kept, switched off",
|
|
39200
39235
|
confirmLabel: "Switch off",
|
|
39201
39236
|
cancelLabel: "Keep sending",
|
|
39202
39237
|
busy,
|
|
@@ -41590,7 +41625,7 @@ function SignBlock({ tableId, recordId, render, className }) {
|
|
|
41590
41625
|
}
|
|
41591
41626
|
|
|
41592
41627
|
// src/ChartBlock.tsx
|
|
41593
|
-
var
|
|
41628
|
+
var import_react234 = require("react");
|
|
41594
41629
|
var import_recharts = require("recharts");
|
|
41595
41630
|
var import_records57 = require("@ai-matrx/records");
|
|
41596
41631
|
var import_core21 = require("@ai-matrx/records/core");
|
|
@@ -41650,6 +41685,39 @@ function useLinkGroupNamer(block, tableId) {
|
|
|
41650
41685
|
}, [named, choices, labels]);
|
|
41651
41686
|
}
|
|
41652
41687
|
|
|
41688
|
+
// src/measureWords.ts
|
|
41689
|
+
var import_react232 = require("react");
|
|
41690
|
+
var import_react233 = require("@ai-matrx/records/react");
|
|
41691
|
+
var import_text_case18 = require("@ai-matrx/kit/text-case");
|
|
41692
|
+
var OP_WORD = { sum: "Total", avg: "Average", min: "Lowest", max: "Highest" };
|
|
41693
|
+
function measureWords(key, fields) {
|
|
41694
|
+
if (key === "count") return "How many";
|
|
41695
|
+
const at = key.indexOf("_");
|
|
41696
|
+
if (at < 0) return (0, import_text_case18.humanizeIdentifier)(key);
|
|
41697
|
+
const op2 = key.slice(0, at);
|
|
41698
|
+
const column = key.slice(at + 1);
|
|
41699
|
+
const field2 = fields?.find((f) => f.key === column);
|
|
41700
|
+
const name = field2 ? fieldName(field2) : (0, import_text_case18.humanizeIdentifier)(column);
|
|
41701
|
+
const word = OP_WORD[op2];
|
|
41702
|
+
return word ? `${word} ${name.charAt(0).toLowerCase()}${name.slice(1)}` : `${(0, import_text_case18.humanizeIdentifier)(op2)} ${name}`;
|
|
41703
|
+
}
|
|
41704
|
+
function useMeasureWords(key, tableId) {
|
|
41705
|
+
const client = (0, import_react233.useOptionalRecordsClient)();
|
|
41706
|
+
const [fields, setFields] = (0, import_react232.useState)(null);
|
|
41707
|
+
const needs = key !== "count";
|
|
41708
|
+
(0, import_react232.useEffect)(() => {
|
|
41709
|
+
if (!client || !tableId || !needs) return;
|
|
41710
|
+
let cancelled = false;
|
|
41711
|
+
void client.fields({ table_id: tableId }).then((result) => {
|
|
41712
|
+
if (!cancelled && result.ok) setFields(result.data);
|
|
41713
|
+
});
|
|
41714
|
+
return () => {
|
|
41715
|
+
cancelled = true;
|
|
41716
|
+
};
|
|
41717
|
+
}, [client, tableId, needs]);
|
|
41718
|
+
return measureWords(key, fields);
|
|
41719
|
+
}
|
|
41720
|
+
|
|
41653
41721
|
// src/ChartBlock.tsx
|
|
41654
41722
|
var import_jsx_runtime134 = require("react/jsx-runtime");
|
|
41655
41723
|
var priorKey = (key) => `prior__${key}`;
|
|
@@ -41728,7 +41796,8 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
41728
41796
|
const series = compared ? [primary, priorKey(primary)] : [primary];
|
|
41729
41797
|
const target = kind === "stuck" ? null : block.target ?? null;
|
|
41730
41798
|
const named = useLinkGroupNamer(source ? NO_GROUPS : block, tableId);
|
|
41731
|
-
const
|
|
41799
|
+
const measureName = useMeasureWords(primary, tableId);
|
|
41800
|
+
const points = (0, import_react234.useMemo)(() => {
|
|
41732
41801
|
if (kind === "stuck") return [];
|
|
41733
41802
|
const rows = block.rows ?? [];
|
|
41734
41803
|
return rows.map((row, index) => {
|
|
@@ -41752,10 +41821,10 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
41752
41821
|
};
|
|
41753
41822
|
});
|
|
41754
41823
|
}, [block.rows, kind, primary, compared, grain, windows, named]);
|
|
41755
|
-
const config = (0,
|
|
41824
|
+
const config = (0, import_react234.useMemo)(() => {
|
|
41756
41825
|
const out = {};
|
|
41757
41826
|
out[primary] = {
|
|
41758
|
-
label: windows ? windowName(windows.window, windows.period) :
|
|
41827
|
+
label: windows ? windowName(windows.window, windows.period) : measureName,
|
|
41759
41828
|
color: SERIES_COLORS[0]
|
|
41760
41829
|
};
|
|
41761
41830
|
if (windows) {
|
|
@@ -41768,7 +41837,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
41768
41837
|
out[point.label] ??= { label: point.label, color: SERIES_COLORS[index % SERIES_COLORS.length] };
|
|
41769
41838
|
});
|
|
41770
41839
|
return out;
|
|
41771
|
-
}, [primary, windows, points]);
|
|
41840
|
+
}, [primary, measureName, windows, points]);
|
|
41772
41841
|
const goal = target && typeof target.value === "number" ? {
|
|
41773
41842
|
value: typeof target.pace === "number" ? target.pace : block.bucket ? null : target.value,
|
|
41774
41843
|
label: typeof target.pace === "number" && target.per !== "bucket" ? `${target.label} pace` : target.label
|
|
@@ -41813,7 +41882,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
41813
41882
|
/* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { children: pretty(block.totals.current) }),
|
|
41814
41883
|
/* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Trend, { pct: block.totals.change_pct, aimingUp: !!target })
|
|
41815
41884
|
] }) : null,
|
|
41816
|
-
/* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { className: "ml-auto shrink-0 text-muted-foreground", children: kind === "stuck" ? `${block.days ?? 14} days` :
|
|
41885
|
+
/* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { className: "ml-auto shrink-0 text-muted-foreground", children: kind === "stuck" ? `${block.days ?? 14} days` : measureName })
|
|
41817
41886
|
] }),
|
|
41818
41887
|
block.compare_refused ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: block.compare_refused }) : null,
|
|
41819
41888
|
!block.refused && targetNote(target) ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: targetNote(target) }) : null,
|
|
@@ -42110,8 +42179,8 @@ function onlyWholeNumbers(rows) {
|
|
|
42110
42179
|
}
|
|
42111
42180
|
|
|
42112
42181
|
// src/DashboardCanvas.tsx
|
|
42113
|
-
var
|
|
42114
|
-
var
|
|
42182
|
+
var import_react241 = require("react");
|
|
42183
|
+
var import_react242 = require("@ai-matrx/records/react");
|
|
42115
42184
|
var import_design_system124 = require("@ai-matrx/design-system");
|
|
42116
42185
|
|
|
42117
42186
|
// src/DashboardGrid.tsx
|
|
@@ -42253,18 +42322,18 @@ function GridCell2({
|
|
|
42253
42322
|
}
|
|
42254
42323
|
|
|
42255
42324
|
// src/AddChart.tsx
|
|
42256
|
-
var
|
|
42257
|
-
var
|
|
42325
|
+
var import_react239 = require("react");
|
|
42326
|
+
var import_react240 = require("@ai-matrx/records/react");
|
|
42258
42327
|
var import_design_system123 = require("@ai-matrx/design-system");
|
|
42259
42328
|
|
|
42260
42329
|
// src/TablePickers.tsx
|
|
42261
|
-
var
|
|
42262
|
-
var
|
|
42330
|
+
var import_react237 = require("react");
|
|
42331
|
+
var import_react238 = require("@ai-matrx/records/react");
|
|
42263
42332
|
var import_design_system122 = require("@ai-matrx/design-system");
|
|
42264
42333
|
|
|
42265
42334
|
// src/RecordsMount.tsx
|
|
42266
|
-
var
|
|
42267
|
-
var
|
|
42335
|
+
var import_react235 = require("react");
|
|
42336
|
+
var import_react236 = require("@ai-matrx/records/react");
|
|
42268
42337
|
var import_jsx_runtime136 = require("react/jsx-runtime");
|
|
42269
42338
|
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.";
|
|
42270
42339
|
function storeDecidesRights(_table) {
|
|
@@ -42278,10 +42347,10 @@ function RecordsMount({
|
|
|
42278
42347
|
}) {
|
|
42279
42348
|
const bound2 = useShallowStableHost(host);
|
|
42280
42349
|
void letTheStoreDecideRights;
|
|
42281
|
-
return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
|
|
42350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_react236.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(RecordsUiProvider, { value: bound2, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(RecordLabelProvider, { children }) }) });
|
|
42282
42351
|
}
|
|
42283
42352
|
function useShallowStableHost(host) {
|
|
42284
|
-
const held = (0,
|
|
42353
|
+
const held = (0, import_react235.useRef)(null);
|
|
42285
42354
|
const next = host ?? {};
|
|
42286
42355
|
const previous = held.current;
|
|
42287
42356
|
if (previous !== null && sameParts(previous, next)) return previous;
|
|
@@ -42376,8 +42445,8 @@ function readTablesAnywhere(dataSource) {
|
|
|
42376
42445
|
return read;
|
|
42377
42446
|
}
|
|
42378
42447
|
function useTablesAnywhere(dataSource) {
|
|
42379
|
-
const [state, setState] = (0,
|
|
42380
|
-
(0,
|
|
42448
|
+
const [state, setState] = (0, import_react237.useState)({ loading: true, error: null, rows: [] });
|
|
42449
|
+
(0, import_react237.useEffect)(() => {
|
|
42381
42450
|
let live = true;
|
|
42382
42451
|
void readTablesAnywhere(dataSource).then((result) => {
|
|
42383
42452
|
if (live) setState(result);
|
|
@@ -42447,14 +42516,14 @@ function TableScope({ dataSource, userId, tableId, children, fallback = null, un
|
|
|
42447
42516
|
const organizationId = list.rows.find((t) => t.table_id === tableId)?.organization_id ?? null;
|
|
42448
42517
|
if (tableId && !organizationId && !list.loading) return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_jsx_runtime137.Fragment, { children: unavailable ?? fallback });
|
|
42449
42518
|
if (!tableId || !organizationId) return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_jsx_runtime137.Fragment, { children: fallback });
|
|
42450
|
-
return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
|
|
42519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_react238.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children });
|
|
42451
42520
|
}
|
|
42452
42521
|
function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
|
|
42453
|
-
const fields = (0,
|
|
42454
|
-
const all = (0,
|
|
42455
|
-
const byKey = (0,
|
|
42522
|
+
const fields = (0, import_react238.useFields)(tableId);
|
|
42523
|
+
const all = (0, import_react237.useMemo)(() => fields.data ?? [], [fields.data]);
|
|
42524
|
+
const byKey = (0, import_react237.useMemo)(() => new Map(all.map((f) => [f.key, f])), [all]);
|
|
42456
42525
|
const keys = Object.keys(value);
|
|
42457
|
-
const [adding, setAdding] = (0,
|
|
42526
|
+
const [adding, setAdding] = (0, import_react237.useState)(false);
|
|
42458
42527
|
const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
|
|
42459
42528
|
const rename = (from, to) => {
|
|
42460
42529
|
if (from === to) return;
|
|
@@ -42542,8 +42611,8 @@ function ColumnValueRow({
|
|
|
42542
42611
|
] });
|
|
42543
42612
|
}
|
|
42544
42613
|
function RecordPicker({ tableId, value, onChange, disabled }) {
|
|
42545
|
-
const table = (0,
|
|
42546
|
-
const records = (0,
|
|
42614
|
+
const table = (0, import_react238.useTable)(tableId);
|
|
42615
|
+
const records = (0, import_react238.useRecords)(tableId, { pageSize: 200 });
|
|
42547
42616
|
const rows = records.data?.rows ?? [];
|
|
42548
42617
|
const options = rows.map((row) => ({
|
|
42549
42618
|
value: row.id,
|
|
@@ -42609,20 +42678,20 @@ function chartSpecFrom(args) {
|
|
|
42609
42678
|
};
|
|
42610
42679
|
}
|
|
42611
42680
|
function AddChart({ subject, onAdd, onClose }) {
|
|
42612
|
-
const client = (0,
|
|
42613
|
-
const [tableId, setTableId] = (0,
|
|
42614
|
-
const fields = (0,
|
|
42615
|
-
const all = (0,
|
|
42681
|
+
const client = (0, import_react240.useRecordsClient)();
|
|
42682
|
+
const [tableId, setTableId] = (0, import_react239.useState)(subject);
|
|
42683
|
+
const fields = (0, import_react240.useFields)(tableId);
|
|
42684
|
+
const all = (0, import_react239.useMemo)(() => onePerKey(fields.data ?? []), [fields.data]);
|
|
42616
42685
|
const labels = useRecordLabels(all);
|
|
42617
42686
|
const wordsFor2 = (key, value) => {
|
|
42618
42687
|
const field2 = all.find((f) => f.key === key);
|
|
42619
42688
|
return field2 ? scalarText(field2, value, labels) : String(value);
|
|
42620
42689
|
};
|
|
42621
|
-
const [measureKey5, setMeasureKey] = (0,
|
|
42622
|
-
const [splitKey, setSplitKey] = (0,
|
|
42623
|
-
const [kind, setKind] = (0,
|
|
42624
|
-
const [filter, setFilter] = (0,
|
|
42625
|
-
const [saving, setSaving] = (0,
|
|
42690
|
+
const [measureKey5, setMeasureKey] = (0, import_react239.useState)("count");
|
|
42691
|
+
const [splitKey, setSplitKey] = (0, import_react239.useState)("none");
|
|
42692
|
+
const [kind, setKind] = (0, import_react239.useState)("auto");
|
|
42693
|
+
const [filter, setFilter] = (0, import_react239.useState)({});
|
|
42694
|
+
const [saving, setSaving] = (0, import_react239.useState)(false);
|
|
42626
42695
|
const numbers = numberColumns(all);
|
|
42627
42696
|
const choices = offerableFields(all, "choice");
|
|
42628
42697
|
const dates = offerableFields(all, "date");
|
|
@@ -42764,31 +42833,31 @@ function combineFilter(base, extra, fieldIdOf) {
|
|
|
42764
42833
|
// src/DashboardCanvas.tsx
|
|
42765
42834
|
var import_jsx_runtime139 = require("react/jsx-runtime");
|
|
42766
42835
|
function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, onCreated, className }) {
|
|
42767
|
-
const client = (0,
|
|
42836
|
+
const client = (0, import_react242.useRecordsClient)();
|
|
42768
42837
|
const host = useRecordsUi();
|
|
42769
|
-
const table = (0,
|
|
42838
|
+
const table = (0, import_react242.useTable)(tableId);
|
|
42770
42839
|
const rights = useTableRights(table.data);
|
|
42771
|
-
const fields = (0,
|
|
42772
|
-
const [boards, setBoards] = (0,
|
|
42773
|
-
const [pages, setPages] = (0,
|
|
42774
|
-
const [error, setError] = (0,
|
|
42775
|
-
const [activeId, setActiveId] = (0,
|
|
42776
|
-
const [madeOnMount, setMadeOnMount] = (0,
|
|
42777
|
-
const [askingToRemove, setAskingToRemove] = (0,
|
|
42778
|
-
const [run, setRun] = (0,
|
|
42779
|
-
const [running, setRunning] = (0,
|
|
42780
|
-
const [question, setQuestion] = (0,
|
|
42781
|
-
const [asking, setAsking] = (0,
|
|
42782
|
-
const [scheduling, setScheduling] = (0,
|
|
42783
|
-
const [arranging, setArranging] = (0,
|
|
42784
|
-
const [adding, setAdding] = (0,
|
|
42785
|
-
const [grain, setGrain] = (0,
|
|
42840
|
+
const fields = (0, import_react242.useFields)(tableId);
|
|
42841
|
+
const [boards, setBoards] = (0, import_react241.useState)(null);
|
|
42842
|
+
const [pages, setPages] = (0, import_react241.useState)([]);
|
|
42843
|
+
const [error, setError] = (0, import_react241.useState)(null);
|
|
42844
|
+
const [activeId, setActiveId] = (0, import_react241.useState)(activeDashboardId ?? null);
|
|
42845
|
+
const [madeOnMount, setMadeOnMount] = (0, import_react241.useState)("waiting");
|
|
42846
|
+
const [askingToRemove, setAskingToRemove] = (0, import_react241.useState)(null);
|
|
42847
|
+
const [run, setRun] = (0, import_react241.useState)(null);
|
|
42848
|
+
const [running, setRunning] = (0, import_react241.useState)(false);
|
|
42849
|
+
const [question, setQuestion] = (0, import_react241.useState)("");
|
|
42850
|
+
const [asking, setAsking] = (0, import_react241.useState)(false);
|
|
42851
|
+
const [scheduling, setScheduling] = (0, import_react241.useState)(false);
|
|
42852
|
+
const [arranging, setArranging] = (0, import_react241.useState)(false);
|
|
42853
|
+
const [adding, setAdding] = (0, import_react241.useState)(false);
|
|
42854
|
+
const [grain, setGrain] = (0, import_react241.useState)(null);
|
|
42786
42855
|
const runArgs = (dashboard_id) => ({
|
|
42787
42856
|
dashboard_id,
|
|
42788
42857
|
...filter ? { filter } : {},
|
|
42789
42858
|
...grain ? { grain } : {}
|
|
42790
42859
|
});
|
|
42791
|
-
const load = (0,
|
|
42860
|
+
const load = (0, import_react241.useCallback)(async () => {
|
|
42792
42861
|
const answered = await client.dashboards({ table_id: tableId });
|
|
42793
42862
|
if (!answered.ok) {
|
|
42794
42863
|
setError(answered.error);
|
|
@@ -42800,19 +42869,19 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
|
|
|
42800
42869
|
setBoards(read);
|
|
42801
42870
|
return read;
|
|
42802
42871
|
}, [client, tableId]);
|
|
42803
|
-
const [notKept, setNotKept] = (0,
|
|
42804
|
-
(0,
|
|
42872
|
+
const [notKept, setNotKept] = (0, import_react241.useState)(null);
|
|
42873
|
+
(0, import_react241.useEffect)(() => {
|
|
42805
42874
|
void load();
|
|
42806
42875
|
}, [load]);
|
|
42807
|
-
(0,
|
|
42876
|
+
(0, import_react241.useEffect)(() => {
|
|
42808
42877
|
if (!boards || boards.length === 0) return;
|
|
42809
42878
|
if (createOnMount && madeOnMount !== "done") return;
|
|
42810
42879
|
const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
|
|
42811
42880
|
if (chosen.id !== activeId) setActiveId(chosen.id);
|
|
42812
42881
|
}, [boards, activeDashboardId, madeOnMount]);
|
|
42813
|
-
const board = (0,
|
|
42882
|
+
const board = (0, import_react241.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
|
|
42814
42883
|
const filterKey = JSON.stringify(filter ?? {});
|
|
42815
|
-
(0,
|
|
42884
|
+
(0, import_react241.useEffect)(() => {
|
|
42816
42885
|
if (!activeId) {
|
|
42817
42886
|
setRun(null);
|
|
42818
42887
|
return;
|
|
@@ -42830,7 +42899,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
|
|
|
42830
42899
|
cancelled = true;
|
|
42831
42900
|
};
|
|
42832
42901
|
}, [client, activeId, filterKey, grain]);
|
|
42833
|
-
const declare2 = (0,
|
|
42902
|
+
const declare2 = (0, import_react241.useCallback)(
|
|
42834
42903
|
async (next, blocks) => {
|
|
42835
42904
|
const written = await client.dashboardDeclare(
|
|
42836
42905
|
// Every block leaves with its own id — kept, or minted here (v6 lane 11).
|
|
@@ -42882,12 +42951,12 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
|
|
|
42882
42951
|
]
|
|
42883
42952
|
);
|
|
42884
42953
|
}
|
|
42885
|
-
(0,
|
|
42954
|
+
(0, import_react241.useEffect)(() => {
|
|
42886
42955
|
if (!createOnMount || madeOnMount !== "waiting" || boards === null || !fields.data) return;
|
|
42887
42956
|
setMadeOnMount("making");
|
|
42888
42957
|
void create().then(() => setMadeOnMount("done"));
|
|
42889
42958
|
}, [createOnMount, madeOnMount, boards, fields.data]);
|
|
42890
|
-
const refresh = (0,
|
|
42959
|
+
const refresh = (0, import_react241.useCallback)(async () => {
|
|
42891
42960
|
if (!activeId) return;
|
|
42892
42961
|
setRunning(true);
|
|
42893
42962
|
const again = await client.dashboardRun(runArgs(activeId));
|
|
@@ -43099,7 +43168,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
|
|
|
43099
43168
|
] });
|
|
43100
43169
|
}
|
|
43101
43170
|
function ChartOfTable({ block, subject, table }) {
|
|
43102
|
-
const named = (0,
|
|
43171
|
+
const named = (0, import_react242.useTable)(table);
|
|
43103
43172
|
return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(ChartBlock, { block, subject, tableName: named.data?.name ?? "\u2014" });
|
|
43104
43173
|
}
|
|
43105
43174
|
function BlockSettingsMenu({
|
|
@@ -43129,7 +43198,7 @@ function BlockSettings({
|
|
|
43129
43198
|
title,
|
|
43130
43199
|
onChange
|
|
43131
43200
|
}) {
|
|
43132
|
-
const own3 = (0,
|
|
43201
|
+
const own3 = (0, import_react242.useFields)(spec.subject);
|
|
43133
43202
|
const fields = own3.data ?? [];
|
|
43134
43203
|
return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("div", { className: "flex flex-col items-stretch gap-1.5 text-xs", children: [
|
|
43135
43204
|
/* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
|
|
@@ -43327,10 +43396,10 @@ function TargetControl({
|
|
|
43327
43396
|
onChange
|
|
43328
43397
|
}) {
|
|
43329
43398
|
const saved = !block.target ? "none" : "field" in block.target && block.target.field ? "field" : "value";
|
|
43330
|
-
const [mode, setMode] = (0,
|
|
43399
|
+
const [mode, setMode] = (0, import_react241.useState)(saved);
|
|
43331
43400
|
const savedValue = block.target && "value" in block.target && typeof block.target.value === "number" ? block.target.value : null;
|
|
43332
|
-
const [draft, setDraft] = (0,
|
|
43333
|
-
(0,
|
|
43401
|
+
const [draft, setDraft] = (0, import_react241.useState)(savedValue === null ? "" : String(savedValue));
|
|
43402
|
+
(0, import_react241.useEffect)(() => {
|
|
43334
43403
|
setMode(saved);
|
|
43335
43404
|
setDraft(savedValue === null ? "" : String(savedValue));
|
|
43336
43405
|
}, [saved, savedValue]);
|
|
@@ -43398,9 +43467,9 @@ function TargetControl({
|
|
|
43398
43467
|
|
|
43399
43468
|
// src/QuestionPanel.tsx
|
|
43400
43469
|
var import_clipboard9 = require("@ai-matrx/kit/clipboard");
|
|
43401
|
-
var
|
|
43470
|
+
var import_react243 = require("react");
|
|
43402
43471
|
var import_design_system125 = require("@ai-matrx/design-system");
|
|
43403
|
-
var
|
|
43472
|
+
var import_react244 = require("@ai-matrx/records/react");
|
|
43404
43473
|
|
|
43405
43474
|
// src/question.ts
|
|
43406
43475
|
var import_records59 = require("@ai-matrx/records");
|
|
@@ -43811,13 +43880,13 @@ function fromLocalInput(value) {
|
|
|
43811
43880
|
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
43812
43881
|
}
|
|
43813
43882
|
function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
|
|
43814
|
-
const client = (0,
|
|
43815
|
-
const fields = (0,
|
|
43816
|
-
const all = (0,
|
|
43883
|
+
const client = (0, import_react244.useRecordsClient)();
|
|
43884
|
+
const fields = (0, import_react244.useFields)(tableId);
|
|
43885
|
+
const all = (0, import_react243.useMemo)(() => fields.data ?? [], [fields.data]);
|
|
43817
43886
|
const me = client.config.actor?.user_id ?? null;
|
|
43818
|
-
const [hidden, setHidden] = (0,
|
|
43819
|
-
const [related, setRelated] = (0,
|
|
43820
|
-
(0,
|
|
43887
|
+
const [hidden, setHidden] = (0, import_react243.useState)(null);
|
|
43888
|
+
const [related, setRelated] = (0, import_react243.useState)({});
|
|
43889
|
+
(0, import_react243.useEffect)(() => {
|
|
43821
43890
|
if (all.length === 0) {
|
|
43822
43891
|
if (!fields.loading) setHidden(/* @__PURE__ */ new Set());
|
|
43823
43892
|
return;
|
|
@@ -43840,18 +43909,18 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
|
|
|
43840
43909
|
live = false;
|
|
43841
43910
|
};
|
|
43842
43911
|
}, [client, tableId, all, fields.loading]);
|
|
43843
|
-
const offered = (0,
|
|
43844
|
-
const [saved, setSaved] = (0,
|
|
43845
|
-
const [savedEpoch, setSavedEpoch] = (0,
|
|
43846
|
-
const [current, setCurrent] = (0,
|
|
43847
|
-
const [spec, setSpec] = (0,
|
|
43848
|
-
const [name, setName] = (0,
|
|
43849
|
-
const [shared, setShared] = (0,
|
|
43850
|
-
const [saveError, setSaveError] = (0,
|
|
43851
|
-
const [saving, setSaving] = (0,
|
|
43852
|
-
const [linkMissed, setLinkMissed] = (0,
|
|
43853
|
-
const openedFromLink = (0,
|
|
43854
|
-
(0,
|
|
43912
|
+
const offered = (0, import_react243.useMemo)(() => hidden ? all.filter((f) => !hidden.has(f.key)) : [], [all, hidden]);
|
|
43913
|
+
const [saved, setSaved] = (0, import_react243.useState)(null);
|
|
43914
|
+
const [savedEpoch, setSavedEpoch] = (0, import_react243.useState)(0);
|
|
43915
|
+
const [current, setCurrent] = (0, import_react243.useState)(null);
|
|
43916
|
+
const [spec, setSpec] = (0, import_react243.useState)(newQuestion);
|
|
43917
|
+
const [name, setName] = (0, import_react243.useState)("");
|
|
43918
|
+
const [shared, setShared] = (0, import_react243.useState)(true);
|
|
43919
|
+
const [saveError, setSaveError] = (0, import_react243.useState)(null);
|
|
43920
|
+
const [saving, setSaving] = (0, import_react243.useState)(false);
|
|
43921
|
+
const [linkMissed, setLinkMissed] = (0, import_react243.useState)(false);
|
|
43922
|
+
const openedFromLink = (0, import_react243.useRef)(false);
|
|
43923
|
+
(0, import_react243.useEffect)(() => {
|
|
43855
43924
|
let live = true;
|
|
43856
43925
|
void questionsOf(client, tableId).then((answer2) => {
|
|
43857
43926
|
if (!live) return;
|
|
@@ -43874,16 +43943,16 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
|
|
|
43874
43943
|
setShared(q ? q.shared : true);
|
|
43875
43944
|
setSaveError(null);
|
|
43876
43945
|
};
|
|
43877
|
-
(0,
|
|
43946
|
+
(0, import_react243.useEffect)(() => {
|
|
43878
43947
|
if (!draft) return;
|
|
43879
43948
|
open(null);
|
|
43880
43949
|
setSpec(draft);
|
|
43881
43950
|
}, [draft]);
|
|
43882
43951
|
const mine = !current || me !== null && current.createdBy === me;
|
|
43883
|
-
const [answer, setAnswer] = (0,
|
|
43884
|
-
const [asking, setAsking] = (0,
|
|
43952
|
+
const [answer, setAnswer] = (0, import_react243.useState)(null);
|
|
43953
|
+
const [asking, setAsking] = (0, import_react243.useState)(false);
|
|
43885
43954
|
const specKey = JSON.stringify(spec);
|
|
43886
|
-
(0,
|
|
43955
|
+
(0, import_react243.useEffect)(() => {
|
|
43887
43956
|
if (all.length === 0) return;
|
|
43888
43957
|
let live = true;
|
|
43889
43958
|
setAsking(true);
|
|
@@ -44229,7 +44298,7 @@ function formatValue(key, value, fields) {
|
|
|
44229
44298
|
return new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(value);
|
|
44230
44299
|
}
|
|
44231
44300
|
function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATED }) {
|
|
44232
|
-
const block = (0,
|
|
44301
|
+
const block = (0, import_react243.useMemo)(
|
|
44233
44302
|
() => ({
|
|
44234
44303
|
kind: "table",
|
|
44235
44304
|
group_by: answer.groupKey && spec.group?.kind === "field" ? [answer.groupKey] : [],
|
|
@@ -44325,10 +44394,10 @@ function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATE
|
|
|
44325
44394
|
}
|
|
44326
44395
|
|
|
44327
44396
|
// src/TableAsk.tsx
|
|
44328
|
-
var
|
|
44397
|
+
var import_react245 = require("react");
|
|
44329
44398
|
var import_design_system126 = require("@ai-matrx/design-system");
|
|
44330
44399
|
var import_records60 = require("@ai-matrx/records");
|
|
44331
|
-
var
|
|
44400
|
+
var import_react246 = require("@ai-matrx/records/react");
|
|
44332
44401
|
|
|
44333
44402
|
// src/askWords.ts
|
|
44334
44403
|
var ASK_EXAMPLE = "count where Status is Open by Unit";
|
|
@@ -44545,12 +44614,12 @@ function askExampleFor(fields) {
|
|
|
44545
44614
|
return by ? `count by ${fieldName(by)}` : "count";
|
|
44546
44615
|
}
|
|
44547
44616
|
function TableAsk({ tableId, onOpenInQuestions }) {
|
|
44548
|
-
const client = (0,
|
|
44549
|
-
const fields = (0,
|
|
44617
|
+
const client = (0, import_react246.useRecordsClient)();
|
|
44618
|
+
const fields = (0, import_react246.useFields)(tableId);
|
|
44550
44619
|
const all = fields.data ?? [];
|
|
44551
|
-
const [open, setOpen] = (0,
|
|
44552
|
-
const [words2, setWords] = (0,
|
|
44553
|
-
const [said, setSaid] = (0,
|
|
44620
|
+
const [open, setOpen] = (0, import_react245.useState)(false);
|
|
44621
|
+
const [words2, setWords] = (0, import_react245.useState)("");
|
|
44622
|
+
const [said, setSaid] = (0, import_react245.useState)({ kind: "idle" });
|
|
44554
44623
|
const ask = async () => {
|
|
44555
44624
|
if (words2.trim() === "" || all.length === 0) return;
|
|
44556
44625
|
const choices = {};
|
|
@@ -44623,8 +44692,8 @@ function TableAsk({ tableId, onOpenInQuestions }) {
|
|
|
44623
44692
|
}
|
|
44624
44693
|
|
|
44625
44694
|
// src/PageScreen.tsx
|
|
44626
|
-
var
|
|
44627
|
-
var
|
|
44695
|
+
var import_react247 = require("react");
|
|
44696
|
+
var import_react248 = require("@ai-matrx/records/react");
|
|
44628
44697
|
var import_core24 = require("@ai-matrx/records/core");
|
|
44629
44698
|
var import_design_system127 = require("@ai-matrx/design-system");
|
|
44630
44699
|
var import_jsx_runtime142 = require("react/jsx-runtime");
|
|
@@ -44639,23 +44708,23 @@ function PageScreen({
|
|
|
44639
44708
|
header,
|
|
44640
44709
|
className
|
|
44641
44710
|
}) {
|
|
44642
|
-
const client = (0,
|
|
44711
|
+
const client = (0, import_react248.useRecordsClient)();
|
|
44643
44712
|
const host = useRecordsUi();
|
|
44644
44713
|
const organizationId = client.config.organizationId;
|
|
44645
|
-
const [page, setPage] = (0,
|
|
44646
|
-
const [missing, setMissing] = (0,
|
|
44647
|
-
const [error, setError] = (0,
|
|
44648
|
-
const [level, setLevel] = (0,
|
|
44649
|
-
const [editing, setEditing] = (0,
|
|
44650
|
-
const [run, setRun] = (0,
|
|
44651
|
-
const [saveError, setSaveError] = (0,
|
|
44652
|
-
const [askingToArchive, setAskingToArchive] = (0,
|
|
44653
|
-
const [selected, setSelected] = (0,
|
|
44654
|
-
const [filterValues, setFilterValues] = (0,
|
|
44655
|
-
const [mine, setMine] = (0,
|
|
44656
|
-
const [making, setMaking] = (0,
|
|
44714
|
+
const [page, setPage] = (0, import_react247.useState)(null);
|
|
44715
|
+
const [missing, setMissing] = (0, import_react247.useState)(false);
|
|
44716
|
+
const [error, setError] = (0, import_react247.useState)(null);
|
|
44717
|
+
const [level, setLevel] = (0, import_react247.useState)(null);
|
|
44718
|
+
const [editing, setEditing] = (0, import_react247.useState)(startEditing);
|
|
44719
|
+
const [run, setRun] = (0, import_react247.useState)(null);
|
|
44720
|
+
const [saveError, setSaveError] = (0, import_react247.useState)(null);
|
|
44721
|
+
const [askingToArchive, setAskingToArchive] = (0, import_react247.useState)(false);
|
|
44722
|
+
const [selected, setSelected] = (0, import_react247.useState)({});
|
|
44723
|
+
const [filterValues, setFilterValues] = (0, import_react247.useState)({});
|
|
44724
|
+
const [mine, setMine] = (0, import_react247.useState)({});
|
|
44725
|
+
const [making, setMaking] = (0, import_react247.useState)("waiting");
|
|
44657
44726
|
const id = page?.id ?? pageId ?? null;
|
|
44658
|
-
const load = (0,
|
|
44727
|
+
const load = (0, import_react247.useCallback)(
|
|
44659
44728
|
async (want) => {
|
|
44660
44729
|
const answered = await client.dashboards({ table_id: null });
|
|
44661
44730
|
if (!answered.ok) {
|
|
@@ -44674,7 +44743,7 @@ function PageScreen({
|
|
|
44674
44743
|
},
|
|
44675
44744
|
[client]
|
|
44676
44745
|
);
|
|
44677
|
-
(0,
|
|
44746
|
+
(0, import_react247.useEffect)(() => {
|
|
44678
44747
|
if (!newOnTable || pageId || making !== "waiting") return;
|
|
44679
44748
|
setMaking("making");
|
|
44680
44749
|
void client.dashboardDeclare({
|
|
@@ -44694,11 +44763,11 @@ function PageScreen({
|
|
|
44694
44763
|
onCreated?.(made.data);
|
|
44695
44764
|
});
|
|
44696
44765
|
}, [client, newOnTable, pageId, making, load, onCreated]);
|
|
44697
|
-
(0,
|
|
44766
|
+
(0, import_react247.useEffect)(() => {
|
|
44698
44767
|
if (!pageId) return;
|
|
44699
44768
|
void load(pageId);
|
|
44700
44769
|
}, [pageId, load]);
|
|
44701
|
-
(0,
|
|
44770
|
+
(0, import_react247.useEffect)(() => {
|
|
44702
44771
|
if (!id) return;
|
|
44703
44772
|
let live = true;
|
|
44704
44773
|
void client.myLevels({ ids: [id], subject: "record" }).then((answered) => {
|
|
@@ -44710,7 +44779,7 @@ function PageScreen({
|
|
|
44710
44779
|
}, [client, id]);
|
|
44711
44780
|
const canEdit = level !== null && EDIT_LEVELS.has(level);
|
|
44712
44781
|
const chartKey = page ? JSON.stringify(page.blocks.map((b) => b.id)) + page.version : "";
|
|
44713
|
-
(0,
|
|
44782
|
+
(0, import_react247.useEffect)(() => {
|
|
44714
44783
|
if (!page || page.blocks.length === 0) {
|
|
44715
44784
|
setRun(null);
|
|
44716
44785
|
return;
|
|
@@ -44725,11 +44794,11 @@ function PageScreen({
|
|
|
44725
44794
|
live = false;
|
|
44726
44795
|
};
|
|
44727
44796
|
}, [client, chartKey]);
|
|
44728
|
-
const blocks = (0,
|
|
44797
|
+
const blocks = (0, import_react247.useMemo)(
|
|
44729
44798
|
() => page ? pageBlocksOf(page.presentation, page.blocks.map((b) => b.id ?? "").filter(Boolean)) : [],
|
|
44730
44799
|
[page]
|
|
44731
44800
|
);
|
|
44732
|
-
const save = (0,
|
|
44801
|
+
const save = (0, import_react247.useCallback)(
|
|
44733
44802
|
async (next) => {
|
|
44734
44803
|
if (!page) return;
|
|
44735
44804
|
const charts = withBlockIds(next.charts ?? page.blocks);
|
|
@@ -44753,7 +44822,7 @@ function PageScreen({
|
|
|
44753
44822
|
},
|
|
44754
44823
|
[client, page, blocks, load]
|
|
44755
44824
|
);
|
|
44756
|
-
const archive = (0,
|
|
44825
|
+
const archive = (0, import_react247.useCallback)(async () => {
|
|
44757
44826
|
if (!page) return;
|
|
44758
44827
|
setAskingToArchive(false);
|
|
44759
44828
|
const gone = await client.dashboardDelete({ dashboard_id: page.id });
|
|
@@ -44955,8 +45024,8 @@ function AppletBlockView({ block }) {
|
|
|
44955
45024
|
}
|
|
44956
45025
|
function AppletPick({ value, onChange }) {
|
|
44957
45026
|
const host = useRecordsUi();
|
|
44958
|
-
const [options, setOptions] = (0,
|
|
44959
|
-
(0,
|
|
45027
|
+
const [options, setOptions] = (0, import_react247.useState)(null);
|
|
45028
|
+
(0, import_react247.useEffect)(() => {
|
|
44960
45029
|
let live = true;
|
|
44961
45030
|
host.applets?.list().then((apps) => live && setOptions(apps.map((a) => ({ value: a.id, label: a.name })))).catch(() => live && setOptions([]));
|
|
44962
45031
|
return () => {
|
|
@@ -44988,12 +45057,12 @@ function ListBlockView({
|
|
|
44988
45057
|
mine,
|
|
44989
45058
|
onMine
|
|
44990
45059
|
}) {
|
|
44991
|
-
const client = (0,
|
|
44992
|
-
const table = (0,
|
|
44993
|
-
const fields = (0,
|
|
44994
|
-
const all = (0,
|
|
44995
|
-
const [view, setView] = (0,
|
|
44996
|
-
(0,
|
|
45060
|
+
const client = (0, import_react248.useRecordsClient)();
|
|
45061
|
+
const table = (0, import_react248.useTable)(block.table_id);
|
|
45062
|
+
const fields = (0, import_react248.useFields)(block.table_id);
|
|
45063
|
+
const all = (0, import_react247.useMemo)(() => onePerKey3(fields.data ?? []), [fields.data]);
|
|
45064
|
+
const [view, setView] = (0, import_react247.useState)(block.view_id ? "reading" : null);
|
|
45065
|
+
(0, import_react247.useEffect)(() => {
|
|
44997
45066
|
if (!block.view_id) {
|
|
44998
45067
|
setView(null);
|
|
44999
45068
|
return;
|
|
@@ -45010,8 +45079,8 @@ function ListBlockView({
|
|
|
45010
45079
|
};
|
|
45011
45080
|
}, [client, block.table_id, block.view_id]);
|
|
45012
45081
|
const meField = block.me_field ? all.find((f) => f.key === block.me_field) : void 0;
|
|
45013
|
-
const [me, setMe] = (0,
|
|
45014
|
-
(0,
|
|
45082
|
+
const [me, setMe] = (0, import_react247.useState)(null);
|
|
45083
|
+
(0, import_react247.useEffect)(() => {
|
|
45015
45084
|
if (!mine || !meField?.relation_target || !viewerUserId) {
|
|
45016
45085
|
setMe(null);
|
|
45017
45086
|
return;
|
|
@@ -45035,18 +45104,18 @@ function ListBlockView({
|
|
|
45035
45104
|
const sort = view && view !== "reading" ? (view.sorts ?? []).map((s) => ({ field: s.field, direction: s.direction })) : [];
|
|
45036
45105
|
const nobodyIsMe = mine && !!meField && me !== null && me !== "reading" && me.id === null;
|
|
45037
45106
|
const waiting = view === "reading" || mine && !!meField && (me === "reading" || me === null) && !!viewerUserId;
|
|
45038
|
-
const page = (0,
|
|
45107
|
+
const page = (0, import_react248.useRecordPage)(waiting || nobodyIsMe ? null : block.table_id, {
|
|
45039
45108
|
pageSize: block.limit ?? 50,
|
|
45040
45109
|
...filter ? { filter } : {},
|
|
45041
45110
|
...sort.length > 0 ? { sort } : {}
|
|
45042
45111
|
});
|
|
45043
45112
|
const reload = page.reload;
|
|
45044
|
-
(0,
|
|
45113
|
+
(0, import_react247.useEffect)(() => (0, import_core24.onRecordChanged)(() => reload()), [reload]);
|
|
45045
45114
|
const rows = nobodyIsMe ? [] : page.data?.rows ?? [];
|
|
45046
45115
|
const columns = block.columns && block.columns.length > 0 ? block.columns.map((k) => all.find((f) => f.key === k)).filter((f) => !!f) : [...all].sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100)).slice(0, DEFAULT_COLUMNS);
|
|
45047
45116
|
const firstId = rows[0]?.id ?? null;
|
|
45048
45117
|
const stillThere = selected !== null && rows.some((r) => r.id === selected);
|
|
45049
|
-
(0,
|
|
45118
|
+
(0, import_react247.useEffect)(() => {
|
|
45050
45119
|
if (page.loading || waiting) return;
|
|
45051
45120
|
if (!stillThere) onSelect(firstId);
|
|
45052
45121
|
}, [firstId, stillThere, page.loading, waiting]);
|
|
@@ -45106,14 +45175,14 @@ function ListBlockView({
|
|
|
45106
45175
|
] });
|
|
45107
45176
|
}
|
|
45108
45177
|
function ActionButton2({ block, recordId }) {
|
|
45109
|
-
const client = (0,
|
|
45110
|
-
const actionsRead = (0,
|
|
45178
|
+
const client = (0, import_react248.useRecordsClient)();
|
|
45179
|
+
const actionsRead = (0, import_react248.useRowActions)(block.action_id ? block.table_id : null);
|
|
45111
45180
|
const action3 = !block.action_id ? null : actionsRead.data ? actionsRead.data.actions.find((a) => a.id === block.action_id) ?? null : actionsRead.loading ? "reading" : null;
|
|
45112
|
-
const [asking, setAsking] = (0,
|
|
45113
|
-
const [running, setRunning] = (0,
|
|
45114
|
-
const [done, setDone] = (0,
|
|
45115
|
-
const [error, setError] = (0,
|
|
45116
|
-
(0,
|
|
45181
|
+
const [asking, setAsking] = (0, import_react247.useState)(false);
|
|
45182
|
+
const [running, setRunning] = (0, import_react247.useState)(false);
|
|
45183
|
+
const [done, setDone] = (0, import_react247.useState)(null);
|
|
45184
|
+
const [error, setError] = (0, import_react247.useState)(null);
|
|
45185
|
+
(0, import_react247.useEffect)(() => {
|
|
45117
45186
|
setDone(null);
|
|
45118
45187
|
setError(null);
|
|
45119
45188
|
setAsking(false);
|
|
@@ -45151,10 +45220,10 @@ function ActionButton2({ block, recordId }) {
|
|
|
45151
45220
|
] });
|
|
45152
45221
|
}
|
|
45153
45222
|
function FormBlockView({ block }) {
|
|
45154
|
-
const client = (0,
|
|
45155
|
-
const [form, setForm] = (0,
|
|
45156
|
-
const [sent, setSent] = (0,
|
|
45157
|
-
(0,
|
|
45223
|
+
const client = (0, import_react248.useRecordsClient)();
|
|
45224
|
+
const [form, setForm] = (0, import_react247.useState)("reading");
|
|
45225
|
+
const [sent, setSent] = (0, import_react247.useState)(0);
|
|
45226
|
+
(0, import_react247.useEffect)(() => {
|
|
45158
45227
|
if (!block.form_id) {
|
|
45159
45228
|
setForm(null);
|
|
45160
45229
|
return;
|
|
@@ -45172,7 +45241,7 @@ function FormBlockView({ block }) {
|
|
|
45172
45241
|
return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(FormRunner, { form: formFromSummary(form), onSubmitted: () => setSent((n) => n + 1) }, sent);
|
|
45173
45242
|
}
|
|
45174
45243
|
function FilterBlockView({ block, value, onChange }) {
|
|
45175
|
-
const fields = (0,
|
|
45244
|
+
const fields = (0, import_react248.useFields)(block.table_id);
|
|
45176
45245
|
const field2 = (fields.data ?? []).find((f) => f.key === block.field);
|
|
45177
45246
|
if (!block.field) return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(BlockNote, { children: "Choose the column this filter narrows by." });
|
|
45178
45247
|
if (!field2) return fields.loading ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_design_system127.Skeleton, { className: "h-9 w-40" }) : /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(BlockNote, { children: "That column is no longer on the table." });
|
|
@@ -45267,7 +45336,7 @@ function FieldPick({
|
|
|
45267
45336
|
onChange,
|
|
45268
45337
|
allowNone
|
|
45269
45338
|
}) {
|
|
45270
|
-
const fields = (0,
|
|
45339
|
+
const fields = (0, import_react248.useFields)(tableId);
|
|
45271
45340
|
const all = onePerKey3(fields.data ?? []);
|
|
45272
45341
|
const picked = want === "member" ? all.filter((f) => editorKindFor(f) === "member") : want === "choice" ? [...offerableFields(all, "choice"), ...all.filter((f) => editorKindFor(f) === "checkbox" || editorKindFor(f) === "member")] : all;
|
|
45273
45342
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -45278,11 +45347,11 @@ function FieldPick({
|
|
|
45278
45347
|
return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(PickOne, { label, placeholder: label, value, options, onChange, className: "h-7 w-40" });
|
|
45279
45348
|
}
|
|
45280
45349
|
function ListSettings({ block, onChange }) {
|
|
45281
|
-
const client = (0,
|
|
45282
|
-
const [views, setViews] = (0,
|
|
45283
|
-
const fields = (0,
|
|
45350
|
+
const client = (0, import_react248.useRecordsClient)();
|
|
45351
|
+
const [views, setViews] = (0, import_react247.useState)([]);
|
|
45352
|
+
const fields = (0, import_react248.useFields)(block.table_id);
|
|
45284
45353
|
const all = onePerKey3(fields.data ?? []);
|
|
45285
|
-
(0,
|
|
45354
|
+
(0, import_react247.useEffect)(() => {
|
|
45286
45355
|
let live = true;
|
|
45287
45356
|
void client.views({ table_id: block.table_id }).then((answered) => {
|
|
45288
45357
|
if (live) setViews(answered.ok ? answered.data : []);
|
|
@@ -45352,14 +45421,14 @@ function ListSettings({ block, onChange }) {
|
|
|
45352
45421
|
] });
|
|
45353
45422
|
}
|
|
45354
45423
|
function ActionPicker({ tableId, value, onChange }) {
|
|
45355
|
-
const actions = (0,
|
|
45424
|
+
const actions = (0, import_react248.useRowActions)(tableId).data?.actions ?? [];
|
|
45356
45425
|
const options = actions.filter((a) => a.id && a.kind !== "agent").map((a) => ({ value: a.id, label: a.name }));
|
|
45357
45426
|
return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(PickOne, { label: "Action", placeholder: "Choose an action", value, options, onChange: (v) => onChange(v), className: "h-7 w-40" });
|
|
45358
45427
|
}
|
|
45359
45428
|
function FormPicker({ tableId, value, onChange }) {
|
|
45360
|
-
const client = (0,
|
|
45361
|
-
const [forms, setForms] = (0,
|
|
45362
|
-
(0,
|
|
45429
|
+
const client = (0, import_react248.useRecordsClient)();
|
|
45430
|
+
const [forms, setForms] = (0, import_react247.useState)([]);
|
|
45431
|
+
(0, import_react247.useEffect)(() => {
|
|
45363
45432
|
let live = true;
|
|
45364
45433
|
void client.forms({ table_id: tableId }).then((answered) => {
|
|
45365
45434
|
if (live) setForms(answered.ok ? answered.data : []);
|
|
@@ -45405,8 +45474,8 @@ function onePerKey3(all) {
|
|
|
45405
45474
|
|
|
45406
45475
|
// src/FormsPanel.tsx
|
|
45407
45476
|
var import_clipboard10 = require("@ai-matrx/kit/clipboard");
|
|
45408
|
-
var
|
|
45409
|
-
var
|
|
45477
|
+
var import_react249 = require("react");
|
|
45478
|
+
var import_react250 = require("@ai-matrx/records/react");
|
|
45410
45479
|
var import_records61 = require("@ai-matrx/records");
|
|
45411
45480
|
var import_design_system128 = require("@ai-matrx/design-system");
|
|
45412
45481
|
var import_jsx_runtime143 = require("react/jsx-runtime");
|
|
@@ -45418,22 +45487,22 @@ function formSuggestion(tableName2) {
|
|
|
45418
45487
|
return `Make me a form that collects new ${subject} entries and tells me when somebody answers.`;
|
|
45419
45488
|
}
|
|
45420
45489
|
function FormsPanel({ tableId, activeFormId, className }) {
|
|
45421
|
-
const client = (0,
|
|
45490
|
+
const client = (0, import_react250.useRecordsClient)();
|
|
45422
45491
|
const host = useRecordsUi();
|
|
45423
|
-
const table = (0,
|
|
45492
|
+
const table = (0, import_react250.useTable)(tableId);
|
|
45424
45493
|
const rights = useTableRights(table.data);
|
|
45425
|
-
const [forms, setForms] = (0,
|
|
45426
|
-
const [error, setError] = (0,
|
|
45427
|
-
const [busy, setBusy] = (0,
|
|
45428
|
-
const [copied, setCopied] = (0,
|
|
45429
|
-
const [building, setBuilding] = (0,
|
|
45430
|
-
const [archivedSaid, setArchivedSaid] = (0,
|
|
45494
|
+
const [forms, setForms] = (0, import_react249.useState)(null);
|
|
45495
|
+
const [error, setError] = (0, import_react249.useState)(null);
|
|
45496
|
+
const [busy, setBusy] = (0, import_react249.useState)(null);
|
|
45497
|
+
const [copied, setCopied] = (0, import_react249.useState)(null);
|
|
45498
|
+
const [building, setBuilding] = (0, import_react249.useState)(false);
|
|
45499
|
+
const [archivedSaid, setArchivedSaid] = (0, import_react249.useState)(null);
|
|
45431
45500
|
const linked = activeFormId && forms !== null ? forms.find((f) => f.form_id === activeFormId) ?? null : null;
|
|
45432
45501
|
const linkedMissing = Boolean(activeFormId) && forms !== null && linked === null;
|
|
45433
|
-
(0,
|
|
45502
|
+
(0, import_react249.useEffect)(() => {
|
|
45434
45503
|
if (linked && rights.structure) setBuilding(true);
|
|
45435
45504
|
}, [linked, rights.structure]);
|
|
45436
|
-
const load = (0,
|
|
45505
|
+
const load = (0, import_react249.useCallback)(async () => {
|
|
45437
45506
|
const answered = await client.forms({ table_id: tableId });
|
|
45438
45507
|
if (!answered.ok) {
|
|
45439
45508
|
setError(answered.error);
|
|
@@ -45443,10 +45512,10 @@ function FormsPanel({ tableId, activeFormId, className }) {
|
|
|
45443
45512
|
setError(null);
|
|
45444
45513
|
setForms(answered.data);
|
|
45445
45514
|
}, [client, tableId]);
|
|
45446
|
-
(0,
|
|
45515
|
+
(0, import_react249.useEffect)(() => {
|
|
45447
45516
|
void load();
|
|
45448
45517
|
}, [load]);
|
|
45449
|
-
const toggle = (0,
|
|
45518
|
+
const toggle = (0, import_react249.useCallback)(
|
|
45450
45519
|
async (form) => {
|
|
45451
45520
|
setBusy(form.form_id);
|
|
45452
45521
|
const wanted = form.published_at === null || form.closed_at !== null;
|
|
@@ -45460,8 +45529,8 @@ function FormsPanel({ tableId, activeFormId, className }) {
|
|
|
45460
45529
|
},
|
|
45461
45530
|
[client, load]
|
|
45462
45531
|
);
|
|
45463
|
-
const [shown4, setShown] = (0,
|
|
45464
|
-
const copy = (0,
|
|
45532
|
+
const [shown4, setShown] = (0, import_react249.useState)(null);
|
|
45533
|
+
const copy = (0, import_react249.useCallback)(async (url, formId) => {
|
|
45465
45534
|
if (await (0, import_clipboard10.copyText)(url)) {
|
|
45466
45535
|
setCopied(formId);
|
|
45467
45536
|
setShown(null);
|
|
@@ -45588,14 +45657,14 @@ function FormsPanel({ tableId, activeFormId, className }) {
|
|
|
45588
45657
|
}
|
|
45589
45658
|
|
|
45590
45659
|
// src/CaptureSheet.tsx
|
|
45591
|
-
var
|
|
45592
|
-
var
|
|
45660
|
+
var import_react253 = require("react");
|
|
45661
|
+
var import_react254 = require("@ai-matrx/records/react");
|
|
45593
45662
|
var import_design_system130 = require("@ai-matrx/design-system");
|
|
45594
45663
|
|
|
45595
45664
|
// src/CaptureRun.tsx
|
|
45596
|
-
var
|
|
45665
|
+
var import_react251 = require("react");
|
|
45597
45666
|
var import_records62 = require("@ai-matrx/records");
|
|
45598
|
-
var
|
|
45667
|
+
var import_react252 = require("@ai-matrx/records/react");
|
|
45599
45668
|
var import_design_system129 = require("@ai-matrx/design-system");
|
|
45600
45669
|
var import_jsx_runtime144 = require("react/jsx-runtime");
|
|
45601
45670
|
function controlFor(field2) {
|
|
@@ -45634,21 +45703,21 @@ function whereWeAre(timeoutMs = 4e3) {
|
|
|
45634
45703
|
});
|
|
45635
45704
|
}
|
|
45636
45705
|
function CaptureRun({ sheetId, face: given, className }) {
|
|
45637
|
-
const client = (0,
|
|
45706
|
+
const client = (0, import_react252.useRecordsClient)();
|
|
45638
45707
|
const host = useRecordsUi();
|
|
45639
|
-
const [face, setFace] = (0,
|
|
45640
|
-
const [loadFailed, setLoadFailed] = (0,
|
|
45641
|
-
const [at, setAt] = (0,
|
|
45642
|
-
const [answers, setAnswers] = (0,
|
|
45643
|
-
const [files, setFiles] = (0,
|
|
45644
|
-
const [missing, setMissing] = (0,
|
|
45645
|
-
const [done, setDone] = (0,
|
|
45646
|
-
const [counts, setCounts] = (0,
|
|
45647
|
-
const [items, setItems] = (0,
|
|
45648
|
-
const [lastSynced, setLastSynced] = (0,
|
|
45649
|
-
const [sending, setSending] = (0,
|
|
45650
|
-
const queueRef = (0,
|
|
45651
|
-
(0,
|
|
45708
|
+
const [face, setFace] = (0, import_react251.useState)(given);
|
|
45709
|
+
const [loadFailed, setLoadFailed] = (0, import_react251.useState)(null);
|
|
45710
|
+
const [at, setAt] = (0, import_react251.useState)(0);
|
|
45711
|
+
const [answers, setAnswers] = (0, import_react251.useState)({});
|
|
45712
|
+
const [files, setFiles] = (0, import_react251.useState)({});
|
|
45713
|
+
const [missing, setMissing] = (0, import_react251.useState)(null);
|
|
45714
|
+
const [done, setDone] = (0, import_react251.useState)(null);
|
|
45715
|
+
const [counts, setCounts] = (0, import_react251.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
|
|
45716
|
+
const [items, setItems] = (0, import_react251.useState)([]);
|
|
45717
|
+
const [lastSynced, setLastSynced] = (0, import_react251.useState)(null);
|
|
45718
|
+
const [sending, setSending] = (0, import_react251.useState)(false);
|
|
45719
|
+
const queueRef = (0, import_react251.useRef)(null);
|
|
45720
|
+
(0, import_react251.useEffect)(() => {
|
|
45652
45721
|
const q2 = (0, import_records62.openCaptureQueue)({
|
|
45653
45722
|
onChange: (c, all) => {
|
|
45654
45723
|
setCounts(c);
|
|
@@ -45686,7 +45755,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
45686
45755
|
void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
|
|
45687
45756
|
return () => q2.dispose();
|
|
45688
45757
|
}, [client, host]);
|
|
45689
|
-
(0,
|
|
45758
|
+
(0, import_react251.useEffect)(() => {
|
|
45690
45759
|
if (given !== void 0) return;
|
|
45691
45760
|
let cancelled = false;
|
|
45692
45761
|
void client.captureOpen({ sheet_id: sheetId }).then((res) => {
|
|
@@ -45698,7 +45767,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
45698
45767
|
cancelled = true;
|
|
45699
45768
|
};
|
|
45700
45769
|
}, [client, given, sheetId]);
|
|
45701
|
-
const questions = (0,
|
|
45770
|
+
const questions = (0, import_react251.useMemo)(() => {
|
|
45702
45771
|
const asked3 = face?.presentation?.questions ?? [];
|
|
45703
45772
|
if (asked3.length > 0) return asked3;
|
|
45704
45773
|
return (face?.fields ?? []).map((f) => ({
|
|
@@ -45708,11 +45777,11 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
45708
45777
|
required: f.required
|
|
45709
45778
|
}));
|
|
45710
45779
|
}, [face]);
|
|
45711
|
-
const fieldOf2 = (0,
|
|
45780
|
+
const fieldOf2 = (0, import_react251.useCallback)(
|
|
45712
45781
|
(key) => (face?.fields ?? []).find((f) => f.key === key),
|
|
45713
45782
|
[face]
|
|
45714
45783
|
);
|
|
45715
|
-
const sync = (0,
|
|
45784
|
+
const sync = (0, import_react251.useCallback)(async () => {
|
|
45716
45785
|
const q2 = queueRef.current;
|
|
45717
45786
|
if (!q2) return;
|
|
45718
45787
|
setSending(true);
|
|
@@ -45725,7 +45794,7 @@ function CaptureRun({ sheetId, face: given, className }) {
|
|
|
45725
45794
|
setSending(false);
|
|
45726
45795
|
}
|
|
45727
45796
|
}, []);
|
|
45728
|
-
const answered = (0,
|
|
45797
|
+
const answered = (0, import_react251.useCallback)(
|
|
45729
45798
|
(key) => {
|
|
45730
45799
|
if (files[key]) return true;
|
|
45731
45800
|
const v = answers[key];
|
|
@@ -46014,21 +46083,21 @@ function AdHocCaptureSheet({
|
|
|
46014
46083
|
attachmentField,
|
|
46015
46084
|
className
|
|
46016
46085
|
}) {
|
|
46017
|
-
const client = (0,
|
|
46086
|
+
const client = (0, import_react254.useRecordsClient)();
|
|
46018
46087
|
const host = useRecordsUi();
|
|
46019
|
-
const table = (0,
|
|
46020
|
-
const fields = (0,
|
|
46021
|
-
const [mode, setMode] = (0,
|
|
46022
|
-
const [reading, setReading] = (0,
|
|
46023
|
-
const [note, setNote] = (0,
|
|
46024
|
-
const [fileId, setFileId] = (0,
|
|
46025
|
-
const [pending, setPending] = (0,
|
|
46026
|
-
const [saved, setSaved] = (0,
|
|
46027
|
-
const [error, setError] = (0,
|
|
46028
|
-
const [uploadError, setUploadError] = (0,
|
|
46029
|
-
const [flushing, setFlushing] = (0,
|
|
46030
|
-
const queue = (0,
|
|
46031
|
-
const keep = (0,
|
|
46088
|
+
const table = (0, import_react254.useTable)(tableId);
|
|
46089
|
+
const fields = (0, import_react254.useFields)(tableId);
|
|
46090
|
+
const [mode, setMode] = (0, import_react253.useState)("reading");
|
|
46091
|
+
const [reading, setReading] = (0, import_react253.useState)("");
|
|
46092
|
+
const [note, setNote] = (0, import_react253.useState)("");
|
|
46093
|
+
const [fileId, setFileId] = (0, import_react253.useState)(null);
|
|
46094
|
+
const [pending, setPending] = (0, import_react253.useState)(null);
|
|
46095
|
+
const [saved, setSaved] = (0, import_react253.useState)([]);
|
|
46096
|
+
const [error, setError] = (0, import_react253.useState)(null);
|
|
46097
|
+
const [uploadError, setUploadError] = (0, import_react253.useState)(null);
|
|
46098
|
+
const [flushing, setFlushing] = (0, import_react253.useState)(false);
|
|
46099
|
+
const queue = (0, import_react253.useRef)([]);
|
|
46100
|
+
const keep = (0, import_react253.useCallback)(
|
|
46032
46101
|
async (next) => {
|
|
46033
46102
|
queue.current = next;
|
|
46034
46103
|
setPending(next);
|
|
@@ -46036,7 +46105,7 @@ function AdHocCaptureSheet({
|
|
|
46036
46105
|
},
|
|
46037
46106
|
[host]
|
|
46038
46107
|
);
|
|
46039
|
-
(0,
|
|
46108
|
+
(0, import_react253.useEffect)(() => {
|
|
46040
46109
|
let cancelled = false;
|
|
46041
46110
|
void (async () => {
|
|
46042
46111
|
const held = host.captureQueue ? await host.captureQueue.load() : [];
|
|
@@ -46048,7 +46117,7 @@ function AdHocCaptureSheet({
|
|
|
46048
46117
|
cancelled = true;
|
|
46049
46118
|
};
|
|
46050
46119
|
}, [host]);
|
|
46051
|
-
const resolved = (0,
|
|
46120
|
+
const resolved = (0, import_react253.useCallback)(() => {
|
|
46052
46121
|
const all = fields.data ?? [];
|
|
46053
46122
|
return {
|
|
46054
46123
|
reading: readingField ?? all.find((f) => f.type === "range")?.key ?? null,
|
|
@@ -46056,7 +46125,7 @@ function AdHocCaptureSheet({
|
|
|
46056
46125
|
attachment: attachmentField ?? all.find((f) => f.format === "file" || f.format === "image")?.key ?? null
|
|
46057
46126
|
};
|
|
46058
46127
|
}, [attachmentField, fields.data, noteField, readingField, table.data]);
|
|
46059
|
-
const flush = (0,
|
|
46128
|
+
const flush = (0, import_react253.useCallback)(async () => {
|
|
46060
46129
|
if (flushing || queue.current.length === 0) return;
|
|
46061
46130
|
setFlushing(true);
|
|
46062
46131
|
const left = [];
|
|
@@ -46215,18 +46284,18 @@ function AdHocCaptureSheet({
|
|
|
46215
46284
|
}
|
|
46216
46285
|
|
|
46217
46286
|
// src/PortalShell.tsx
|
|
46218
|
-
var
|
|
46219
|
-
var
|
|
46287
|
+
var import_react255 = require("react");
|
|
46288
|
+
var import_react256 = require("@ai-matrx/records/react");
|
|
46220
46289
|
var import_design_system131 = require("@ai-matrx/design-system");
|
|
46221
46290
|
var import_jsx_runtime146 = require("react/jsx-runtime");
|
|
46222
46291
|
function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
46223
|
-
const client = (0,
|
|
46224
|
-
const [card, setCard] = (0,
|
|
46225
|
-
const [reach, setReach] = (0,
|
|
46226
|
-
const [error, setError] = (0,
|
|
46227
|
-
const [open, setOpen] = (0,
|
|
46228
|
-
const [sending, setSending] = (0,
|
|
46229
|
-
const load = (0,
|
|
46292
|
+
const client = (0, import_react256.useRecordsClient)();
|
|
46293
|
+
const [card, setCard] = (0, import_react255.useState)(null);
|
|
46294
|
+
const [reach, setReach] = (0, import_react255.useState)(null);
|
|
46295
|
+
const [error, setError] = (0, import_react255.useState)(null);
|
|
46296
|
+
const [open, setOpen] = (0, import_react255.useState)(null);
|
|
46297
|
+
const [sending, setSending] = (0, import_react255.useState)(false);
|
|
46298
|
+
const load = (0, import_react255.useCallback)(async () => {
|
|
46230
46299
|
const who = await client.externalPrincipalCard();
|
|
46231
46300
|
if (!who.ok) {
|
|
46232
46301
|
setError(who.error);
|
|
@@ -46241,7 +46310,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
|
46241
46310
|
}
|
|
46242
46311
|
setReach(reached.data.map((row) => row.resource_id));
|
|
46243
46312
|
}, [client, resourceType]);
|
|
46244
|
-
(0,
|
|
46313
|
+
(0, import_react255.useEffect)(() => {
|
|
46245
46314
|
void load();
|
|
46246
46315
|
}, [load]);
|
|
46247
46316
|
if (error) {
|
|
@@ -46299,9 +46368,9 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
|
|
|
46299
46368
|
] });
|
|
46300
46369
|
}
|
|
46301
46370
|
function PortalRow({ tableId, recordId }) {
|
|
46302
|
-
const client = (0,
|
|
46303
|
-
const [title, setTitle] = (0,
|
|
46304
|
-
(0,
|
|
46371
|
+
const client = (0, import_react256.useRecordsClient)();
|
|
46372
|
+
const [title, setTitle] = (0, import_react255.useState)(null);
|
|
46373
|
+
(0, import_react255.useEffect)(() => {
|
|
46305
46374
|
let cancelled = false;
|
|
46306
46375
|
void client.recordRead({ record_id: recordId }).then((answered) => {
|
|
46307
46376
|
if (cancelled) return;
|
|
@@ -46321,8 +46390,8 @@ function PortalRow({ tableId, recordId }) {
|
|
|
46321
46390
|
}
|
|
46322
46391
|
|
|
46323
46392
|
// src/PublicViewPage.tsx
|
|
46324
|
-
var
|
|
46325
|
-
var
|
|
46393
|
+
var import_react257 = require("react");
|
|
46394
|
+
var import_react258 = require("@ai-matrx/records/react");
|
|
46326
46395
|
var import_design_system132 = require("@ai-matrx/design-system");
|
|
46327
46396
|
|
|
46328
46397
|
// src/publicBinding.ts
|
|
@@ -46338,14 +46407,14 @@ function publicReadOf(binding) {
|
|
|
46338
46407
|
// src/PublicViewPage.tsx
|
|
46339
46408
|
var import_jsx_runtime147 = require("react/jsx-runtime");
|
|
46340
46409
|
function PublicViewPage({ slug, className }) {
|
|
46341
|
-
const client = (0,
|
|
46342
|
-
const [binding, setBinding] = (0,
|
|
46343
|
-
const [rows, setRows] = (0,
|
|
46344
|
-
const [fields, setFields] = (0,
|
|
46345
|
-
const [error, setError] = (0,
|
|
46346
|
-
const [plan, setPlan] = (0,
|
|
46347
|
-
const [gap, setGap] = (0,
|
|
46348
|
-
const load = (0,
|
|
46410
|
+
const client = (0, import_react258.useRecordsClient)();
|
|
46411
|
+
const [binding, setBinding] = (0, import_react257.useState)(null);
|
|
46412
|
+
const [rows, setRows] = (0, import_react257.useState)(null);
|
|
46413
|
+
const [fields, setFields] = (0, import_react257.useState)(null);
|
|
46414
|
+
const [error, setError] = (0, import_react257.useState)(null);
|
|
46415
|
+
const [plan, setPlan] = (0, import_react257.useState)(null);
|
|
46416
|
+
const [gap, setGap] = (0, import_react257.useState)(null);
|
|
46417
|
+
const load = (0, import_react257.useCallback)(async () => {
|
|
46349
46418
|
const notice = await client.worldPublishGapNotice();
|
|
46350
46419
|
if (notice.ok) setGap(notice.data);
|
|
46351
46420
|
const resolved = await client.resolvePublishBindingKind({ slug });
|
|
@@ -46395,7 +46464,7 @@ function PublicViewPage({ slug, className }) {
|
|
|
46395
46464
|
}
|
|
46396
46465
|
setRows([{ id: chosen.recordId, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
|
|
46397
46466
|
}, [client, slug]);
|
|
46398
|
-
(0,
|
|
46467
|
+
(0, import_react257.useEffect)(() => {
|
|
46399
46468
|
void load();
|
|
46400
46469
|
}, [load]);
|
|
46401
46470
|
if (error) return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(RefusalNotice, { error, className });
|
|
@@ -46433,10 +46502,10 @@ function PublicRow({ row, fields }) {
|
|
|
46433
46502
|
|
|
46434
46503
|
// src/EmbedFrame.tsx
|
|
46435
46504
|
var import_clipboard11 = require("@ai-matrx/kit/clipboard");
|
|
46436
|
-
var
|
|
46437
|
-
var
|
|
46505
|
+
var import_react259 = require("react");
|
|
46506
|
+
var import_react260 = require("@ai-matrx/records/react");
|
|
46438
46507
|
var import_design_system133 = require("@ai-matrx/design-system");
|
|
46439
|
-
var
|
|
46508
|
+
var import_react261 = require("@ai-matrx/records/react");
|
|
46440
46509
|
var import_jsx_runtime148 = require("react/jsx-runtime");
|
|
46441
46510
|
function EmbedFrame({
|
|
46442
46511
|
tableId,
|
|
@@ -46446,18 +46515,18 @@ function EmbedFrame({
|
|
|
46446
46515
|
embedUrl,
|
|
46447
46516
|
className
|
|
46448
46517
|
}) {
|
|
46449
|
-
const client = (0,
|
|
46518
|
+
const client = (0, import_react260.useRecordsClient)();
|
|
46450
46519
|
const host = useRecordsUi();
|
|
46451
|
-
const table = (0,
|
|
46520
|
+
const table = (0, import_react261.useTable)(tableId);
|
|
46452
46521
|
const rights = useTableRights(table.data);
|
|
46453
|
-
const [origins, setOrigins] = (0,
|
|
46454
|
-
const [secret, setSecret] = (0,
|
|
46455
|
-
const [tokenId, setTokenId] = (0,
|
|
46456
|
-
const [error, setError] = (0,
|
|
46457
|
-
const [busy, setBusy] = (0,
|
|
46522
|
+
const [origins, setOrigins] = (0, import_react259.useState)("");
|
|
46523
|
+
const [secret, setSecret] = (0, import_react259.useState)(null);
|
|
46524
|
+
const [tokenId, setTokenId] = (0, import_react259.useState)(null);
|
|
46525
|
+
const [error, setError] = (0, import_react259.useState)(null);
|
|
46526
|
+
const [busy, setBusy] = (0, import_react259.useState)(false);
|
|
46458
46527
|
const mode = formId ? "write" : "read";
|
|
46459
46528
|
const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
|
|
46460
|
-
const issue = (0,
|
|
46529
|
+
const issue = (0, import_react259.useCallback)(async () => {
|
|
46461
46530
|
setBusy(true);
|
|
46462
46531
|
setError(null);
|
|
46463
46532
|
const minted = await client.anonTokenIssue({
|
|
@@ -46476,7 +46545,7 @@ function EmbedFrame({
|
|
|
46476
46545
|
setTokenId(minted.data.token_id);
|
|
46477
46546
|
host.notify?.success("Embed token issued. Copy it now \u2014 it is never shown again.");
|
|
46478
46547
|
}, [client, formId, host, mode, parsed, recordId, savedViewId]);
|
|
46479
|
-
const revoke = (0,
|
|
46548
|
+
const revoke = (0, import_react259.useCallback)(async () => {
|
|
46480
46549
|
if (!tokenId) return;
|
|
46481
46550
|
setBusy(true);
|
|
46482
46551
|
const done = await client.anonTokenRevoke({ token_id: tokenId });
|
|
@@ -46540,13 +46609,13 @@ function EmbedFrame({
|
|
|
46540
46609
|
] });
|
|
46541
46610
|
}
|
|
46542
46611
|
function useEmbedHandshake(args) {
|
|
46543
|
-
const client = (0,
|
|
46544
|
-
const [binding, setBinding] = (0,
|
|
46545
|
-
const [error, setError] = (0,
|
|
46546
|
-
const [loading, setLoading] = (0,
|
|
46612
|
+
const client = (0, import_react260.useRecordsClient)();
|
|
46613
|
+
const [binding, setBinding] = (0, import_react259.useState)(null);
|
|
46614
|
+
const [error, setError] = (0, import_react259.useState)(null);
|
|
46615
|
+
const [loading, setLoading] = (0, import_react259.useState)(true);
|
|
46547
46616
|
const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
|
|
46548
46617
|
const { secret, requiredMode } = args;
|
|
46549
|
-
(0,
|
|
46618
|
+
(0, import_react259.useEffect)(() => {
|
|
46550
46619
|
let cancelled = false;
|
|
46551
46620
|
setLoading(true);
|
|
46552
46621
|
setError(null);
|
|
@@ -46569,11 +46638,11 @@ function useEmbedHandshake(args) {
|
|
|
46569
46638
|
|
|
46570
46639
|
// src/TablePage.tsx
|
|
46571
46640
|
var import_clipboard13 = require("@ai-matrx/kit/clipboard");
|
|
46572
|
-
var
|
|
46641
|
+
var import_react271 = require("react");
|
|
46573
46642
|
var import_records63 = require("@ai-matrx/records");
|
|
46574
|
-
var
|
|
46643
|
+
var import_react272 = require("@ai-matrx/records/react");
|
|
46575
46644
|
var import_design_system140 = require("@ai-matrx/design-system");
|
|
46576
|
-
var
|
|
46645
|
+
var import_text_case19 = require("@ai-matrx/kit/text-case");
|
|
46577
46646
|
|
|
46578
46647
|
// src/viewShare.ts
|
|
46579
46648
|
var import_core25 = require("@ai-matrx/records/core");
|
|
@@ -46617,13 +46686,13 @@ async function downloadViewCsv(args) {
|
|
|
46617
46686
|
}
|
|
46618
46687
|
|
|
46619
46688
|
// src/RecordPanel.tsx
|
|
46620
|
-
var
|
|
46689
|
+
var import_react262 = require("react");
|
|
46621
46690
|
var import_design_system134 = require("@ai-matrx/design-system");
|
|
46622
|
-
var
|
|
46691
|
+
var import_react263 = require("@ai-matrx/records/react");
|
|
46623
46692
|
var import_jsx_runtime149 = require("react/jsx-runtime");
|
|
46624
46693
|
function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false }) {
|
|
46625
46694
|
const host = useRecordsUi();
|
|
46626
|
-
const [asking, setAsking] = (0,
|
|
46695
|
+
const [asking, setAsking] = (0, import_react262.useState)(null);
|
|
46627
46696
|
return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)("div", { className: "space-y-3", "data-record-panel": recordId, children: [
|
|
46628
46697
|
/* @__PURE__ */ (0, import_jsx_runtime149.jsx)(Peek, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
|
|
46629
46698
|
onPage ? /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(import_jsx_runtime149.Fragment, { children: [
|
|
@@ -46642,7 +46711,7 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
|
|
|
46642
46711
|
}
|
|
46643
46712
|
),
|
|
46644
46713
|
!onAskAboutField && asking ? /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(FieldHistoryPanel, { tableId, fieldKey: asking, recordId, onClose: () => setAsking(null) }) : null,
|
|
46645
|
-
host.recordSections ? /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(
|
|
46714
|
+
host.recordSections ? /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(import_react262.Fragment, { children: [
|
|
46646
46715
|
/* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_design_system134.Separator, {}),
|
|
46647
46716
|
host.recordSections({ tableId, recordId })
|
|
46648
46717
|
] }) : null,
|
|
@@ -46653,8 +46722,8 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
|
|
|
46653
46722
|
] });
|
|
46654
46723
|
}
|
|
46655
46724
|
function LinkedLists({ tableId, recordId }) {
|
|
46656
|
-
const fields = (0,
|
|
46657
|
-
const record = (0,
|
|
46725
|
+
const fields = (0, import_react263.useFields)(tableId);
|
|
46726
|
+
const record = (0, import_react263.useRecord)(recordId, true, { tableId });
|
|
46658
46727
|
const links = (fields.data ?? []).filter((field2) => editorKindFor(field2) === "relation");
|
|
46659
46728
|
const labels = useRecordLabels(links);
|
|
46660
46729
|
const document2 = record.data?.document;
|
|
@@ -46701,7 +46770,7 @@ function LinkedLists({ tableId, recordId }) {
|
|
|
46701
46770
|
}
|
|
46702
46771
|
function RecordAsk({ tableId, recordId }) {
|
|
46703
46772
|
const host = useRecordsUi();
|
|
46704
|
-
const [open, setOpen] = (0,
|
|
46773
|
+
const [open, setOpen] = (0, import_react262.useState)(false);
|
|
46705
46774
|
if (!host.chat) return null;
|
|
46706
46775
|
return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)("section", { className: "flex min-w-0 flex-col gap-1.5", "data-record-ask": open ? "open" : "", children: [
|
|
46707
46776
|
/* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_design_system134.Separator, {}),
|
|
@@ -46710,7 +46779,7 @@ function RecordAsk({ tableId, recordId }) {
|
|
|
46710
46779
|
}
|
|
46711
46780
|
|
|
46712
46781
|
// src/breakDown.tsx
|
|
46713
|
-
var
|
|
46782
|
+
var import_react264 = require("react");
|
|
46714
46783
|
var import_design_system135 = require("@ai-matrx/design-system");
|
|
46715
46784
|
var import_jsx_runtime150 = require("react/jsx-runtime");
|
|
46716
46785
|
var BREAK_DOWN_ACTION_ID = "break-down";
|
|
@@ -46736,10 +46805,10 @@ function BreakDownDialog({
|
|
|
46736
46805
|
onOpenChange,
|
|
46737
46806
|
onApply
|
|
46738
46807
|
}) {
|
|
46739
|
-
const source = (0,
|
|
46808
|
+
const source = (0, import_react264.useMemo)(() => ({ kind: "table", id: tableId }), [tableId]);
|
|
46740
46809
|
const { def } = useDrillDefinition(open ? source : null);
|
|
46741
|
-
const dimensions = (0,
|
|
46742
|
-
const [picked, setPicked] = (0,
|
|
46810
|
+
const dimensions = (0, import_react264.useMemo)(() => drillDimensionsOf(def, NO_LABELS), [def]);
|
|
46811
|
+
const [picked, setPicked] = (0, import_react264.useState)(null);
|
|
46743
46812
|
const key = picked ?? held?.field ?? dimensions[0]?.key ?? "";
|
|
46744
46813
|
return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_design_system135.Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_design_system135.DialogContent, { "data-break-down": "", className: "max-w-sm", children: [
|
|
46745
46814
|
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_design_system135.DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_design_system135.DialogTitle, { children: "Break down by" }) }),
|
|
@@ -46766,7 +46835,7 @@ function BreakDownDialog({
|
|
|
46766
46835
|
|
|
46767
46836
|
// src/TableReference.tsx
|
|
46768
46837
|
var import_clipboard12 = require("@ai-matrx/kit/clipboard");
|
|
46769
|
-
var
|
|
46838
|
+
var import_react265 = require("react");
|
|
46770
46839
|
var import_workspace2 = require("@ai-matrx/alchemy/react/workspace");
|
|
46771
46840
|
var import_design_system136 = require("@ai-matrx/design-system");
|
|
46772
46841
|
var import_jsx_runtime151 = require("react/jsx-runtime");
|
|
@@ -46794,12 +46863,12 @@ function TableReferenceDialog({
|
|
|
46794
46863
|
}) {
|
|
46795
46864
|
const port = (0, import_workspace2.useContentTransferCapabilities)().reference;
|
|
46796
46865
|
const notify = useRecordsUi().notify;
|
|
46797
|
-
const [copied, setCopied] = (0,
|
|
46798
|
-
const choices = (0,
|
|
46866
|
+
const [copied, setCopied] = (0, import_react265.useState)(null);
|
|
46867
|
+
const choices = (0, import_react265.useMemo)(
|
|
46799
46868
|
() => tableReferenceChoices(table.id, tableName(table)).filter((c) => port?.supports(c.reference)),
|
|
46800
46869
|
[table, port]
|
|
46801
46870
|
);
|
|
46802
|
-
const copy = (0,
|
|
46871
|
+
const copy = (0, import_react265.useCallback)(
|
|
46803
46872
|
async (choice) => {
|
|
46804
46873
|
if (!port) return;
|
|
46805
46874
|
try {
|
|
@@ -46822,8 +46891,8 @@ function TableReferenceDialog({
|
|
|
46822
46891
|
}
|
|
46823
46892
|
|
|
46824
46893
|
// src/TableDuplicate.tsx
|
|
46825
|
-
var
|
|
46826
|
-
var
|
|
46894
|
+
var import_react266 = require("react");
|
|
46895
|
+
var import_react267 = require("@ai-matrx/records/react");
|
|
46827
46896
|
var import_design_system137 = require("@ai-matrx/design-system");
|
|
46828
46897
|
var import_jsx_runtime152 = require("react/jsx-runtime");
|
|
46829
46898
|
function copyNameFor(name) {
|
|
@@ -46835,11 +46904,11 @@ function duplicateProgressWords(p) {
|
|
|
46835
46904
|
return "Copying columns\u2026";
|
|
46836
46905
|
}
|
|
46837
46906
|
function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated }) {
|
|
46838
|
-
const client = (0,
|
|
46907
|
+
const client = (0, import_react267.useRecordsClient)();
|
|
46839
46908
|
const host = useRecordsUi();
|
|
46840
|
-
const [typed2, setTyped] = (0,
|
|
46841
|
-
const [withRecords, setWithRecords] = (0,
|
|
46842
|
-
const [phase, setPhase] = (0,
|
|
46909
|
+
const [typed2, setTyped] = (0, import_react266.useState)(() => copyNameFor(name));
|
|
46910
|
+
const [withRecords, setWithRecords] = (0, import_react266.useState)(true);
|
|
46911
|
+
const [phase, setPhase] = (0, import_react266.useState)({ kind: "asking" });
|
|
46843
46912
|
const problem = tableNameProblem(typed2);
|
|
46844
46913
|
const copying = phase.kind === "copying";
|
|
46845
46914
|
const close = (next) => {
|
|
@@ -46863,7 +46932,7 @@ function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated
|
|
|
46863
46932
|
setPhase({ kind: "refused", sentence: refusalSentence(made.error) });
|
|
46864
46933
|
return;
|
|
46865
46934
|
}
|
|
46866
|
-
(0,
|
|
46935
|
+
(0, import_react267.tableShapeChanged)(made.data.table.id);
|
|
46867
46936
|
setPhase({ kind: "done", copy: made.data });
|
|
46868
46937
|
host.notify?.success(`Made ${made.data.table.name}`);
|
|
46869
46938
|
};
|
|
@@ -46924,9 +46993,9 @@ function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated
|
|
|
46924
46993
|
}
|
|
46925
46994
|
|
|
46926
46995
|
// src/ViewFilter.tsx
|
|
46927
|
-
var
|
|
46996
|
+
var import_react268 = require("react");
|
|
46928
46997
|
var import_design_system138 = require("@ai-matrx/design-system");
|
|
46929
|
-
var
|
|
46998
|
+
var import_react269 = require("@ai-matrx/records/react");
|
|
46930
46999
|
var import_jsx_runtime153 = require("react/jsx-runtime");
|
|
46931
47000
|
function conditionCount(expr) {
|
|
46932
47001
|
if (!expr || typeof expr !== "object" || Array.isArray(expr)) return 0;
|
|
@@ -46937,15 +47006,15 @@ function conditionCount(expr) {
|
|
|
46937
47006
|
return 1;
|
|
46938
47007
|
}
|
|
46939
47008
|
function ViewFilter({ tableId, view, onApply, className }) {
|
|
46940
|
-
const fields = (0,
|
|
46941
|
-
const [open, setOpen] = (0,
|
|
47009
|
+
const fields = (0, import_react269.useFields)(tableId);
|
|
47010
|
+
const [open, setOpen] = (0, import_react268.useState)(false);
|
|
46942
47011
|
const saved = view?.where ?? null;
|
|
46943
|
-
const [draft, setDraft] = (0,
|
|
47012
|
+
const [draft, setDraft] = (0, import_react268.useState)(saved);
|
|
46944
47013
|
const savedKey = JSON.stringify(saved);
|
|
46945
|
-
(0,
|
|
47014
|
+
(0, import_react268.useEffect)(() => {
|
|
46946
47015
|
setDraft(saved);
|
|
46947
47016
|
}, [view?.id, savedKey]);
|
|
46948
|
-
const conditionFields = (0,
|
|
47017
|
+
const conditionFields = (0, import_react268.useMemo)(
|
|
46949
47018
|
() => (fields.data ?? []).map((f) => ({ id: f.id, key: f.key, label: f.label || f.key, field: f })),
|
|
46950
47019
|
[fields.data]
|
|
46951
47020
|
);
|
|
@@ -46990,7 +47059,7 @@ function ViewFilter({ tableId, view, onApply, className }) {
|
|
|
46990
47059
|
ConditionGroup,
|
|
46991
47060
|
{
|
|
46992
47061
|
lead: "Show records where",
|
|
46993
|
-
emptyLabel: "
|
|
47062
|
+
emptyLabel: "Pick a field",
|
|
46994
47063
|
expr: draft,
|
|
46995
47064
|
fields: conditionFields,
|
|
46996
47065
|
onChange: setDraft
|
|
@@ -47026,8 +47095,7 @@ function ViewFilter({ tableId, view, onApply, className }) {
|
|
|
47026
47095
|
/* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_design_system138.Button, { size: "sm", variant: "ghost", onClick: () => {
|
|
47027
47096
|
setDraft(saved);
|
|
47028
47097
|
setOpen(false);
|
|
47029
|
-
}, children: "Cancel" })
|
|
47030
|
-
changed ? /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("span", { className: "text-muted-foreground", children: "Not applied yet." }) : null
|
|
47098
|
+
}, children: "Cancel" })
|
|
47031
47099
|
] })
|
|
47032
47100
|
]
|
|
47033
47101
|
}
|
|
@@ -47118,7 +47186,7 @@ function phoneTableActions(actions) {
|
|
|
47118
47186
|
}
|
|
47119
47187
|
|
|
47120
47188
|
// src/toolbarFit.ts
|
|
47121
|
-
var
|
|
47189
|
+
var import_react270 = require("react");
|
|
47122
47190
|
var FOLDED_GUESS = { look: 104, chooser: 96, tools: 120 };
|
|
47123
47191
|
var SLOT_MIN = 36;
|
|
47124
47192
|
function toolbarFold(input) {
|
|
@@ -47175,8 +47243,8 @@ function rowNeeds(row) {
|
|
|
47175
47243
|
return { needs: needs + gap * Math.max(0, pieces.length - 1), gap };
|
|
47176
47244
|
}
|
|
47177
47245
|
function useToolbarFit(row) {
|
|
47178
|
-
const [fold, setFold] = (0,
|
|
47179
|
-
(0,
|
|
47246
|
+
const [fold, setFold] = (0, import_react270.useState)(0);
|
|
47247
|
+
(0, import_react270.useEffect)(() => {
|
|
47180
47248
|
if (!row) return;
|
|
47181
47249
|
const widths = {
|
|
47182
47250
|
look: { full: null, folded: null },
|
|
@@ -47260,8 +47328,8 @@ function clippedEnds(scrollLeft, clientWidth, scrollWidth) {
|
|
|
47260
47328
|
return start && end ? "both" : start ? "start" : end ? "end" : "none";
|
|
47261
47329
|
}
|
|
47262
47330
|
function useSlotScroll(slot) {
|
|
47263
|
-
const [ends, setEnds] = (0,
|
|
47264
|
-
(0,
|
|
47331
|
+
const [ends, setEnds] = (0, import_react270.useState)("none");
|
|
47332
|
+
(0, import_react270.useEffect)(() => {
|
|
47265
47333
|
if (!slot) return;
|
|
47266
47334
|
let pending = 0;
|
|
47267
47335
|
const read = () => {
|
|
@@ -47344,7 +47412,7 @@ function RailFrame({
|
|
|
47344
47412
|
function filterInWords(filter, fields) {
|
|
47345
47413
|
const nameOf2 = (key) => {
|
|
47346
47414
|
const field2 = fields.find((f) => f.key === key);
|
|
47347
|
-
return field2 ? fieldName(field2) : (0,
|
|
47415
|
+
return field2 ? fieldName(field2) : (0, import_text_case19.humanizeIdentifier)(key);
|
|
47348
47416
|
};
|
|
47349
47417
|
const parts = Object.keys(filter).map((key) => {
|
|
47350
47418
|
const value = filter[key];
|
|
@@ -47378,11 +47446,11 @@ function TableNotHere({
|
|
|
47378
47446
|
leaveLabel,
|
|
47379
47447
|
className
|
|
47380
47448
|
}) {
|
|
47381
|
-
const client = (0,
|
|
47382
|
-
const [archived, setArchived] = (0,
|
|
47383
|
-
const [restoring, setRestoring] = (0,
|
|
47384
|
-
const [refusal4, setRefusal] = (0,
|
|
47385
|
-
(0,
|
|
47449
|
+
const client = (0, import_react272.useRecordsClient)();
|
|
47450
|
+
const [archived, setArchived] = (0, import_react271.useState)({ phase: "asking" });
|
|
47451
|
+
const [restoring, setRestoring] = (0, import_react271.useState)(false);
|
|
47452
|
+
const [refusal4, setRefusal] = (0, import_react271.useState)(null);
|
|
47453
|
+
(0, import_react271.useEffect)(() => {
|
|
47386
47454
|
let alive = true;
|
|
47387
47455
|
void client.tableArchived({ table_id: tableId }).then((answered) => {
|
|
47388
47456
|
if (!alive) return;
|
|
@@ -47580,18 +47648,18 @@ function TablePage({
|
|
|
47580
47648
|
onViewAddressChange,
|
|
47581
47649
|
className
|
|
47582
47650
|
}) {
|
|
47583
|
-
const client = (0,
|
|
47584
|
-
const table = (0,
|
|
47651
|
+
const client = (0, import_react272.useRecordsClient)();
|
|
47652
|
+
const table = (0, import_react272.useTable)(tableId);
|
|
47585
47653
|
const rights = useTableRights(table.data);
|
|
47586
|
-
const pageFields = (0,
|
|
47587
|
-
const allFields = (0,
|
|
47654
|
+
const pageFields = (0, import_react272.useFields)(filter ? tableId : null);
|
|
47655
|
+
const allFields = (0, import_react272.useFields)(tableId);
|
|
47588
47656
|
const viewLabels = useRecordLabels(allFields.data ?? void 0);
|
|
47589
47657
|
const askedInWords = filter ? filterInWords(filter, pageFields.data ?? []) : null;
|
|
47590
|
-
const organizationId = (0,
|
|
47658
|
+
const organizationId = (0, import_react272.useRecordsClient)().config.organizationId;
|
|
47591
47659
|
const publicReadOnly = usePublicReadOnly(client, organizationId, tableId, table.data, rights);
|
|
47592
|
-
const [view, setView] = (0,
|
|
47593
|
-
const [looks, setLooks] = (0,
|
|
47594
|
-
(0,
|
|
47660
|
+
const [view, setView] = (0, import_react271.useState)(null);
|
|
47661
|
+
const [looks, setLooks] = (0, import_react271.useState)(void 0);
|
|
47662
|
+
(0, import_react271.useEffect)(() => {
|
|
47595
47663
|
let live = true;
|
|
47596
47664
|
setLooks(void 0);
|
|
47597
47665
|
void readLooks(client, tableId).then((answered) => {
|
|
@@ -47604,7 +47672,7 @@ function TablePage({
|
|
|
47604
47672
|
}, [client, tableId]);
|
|
47605
47673
|
const look = view && looks ? looks[view.id] : void 0;
|
|
47606
47674
|
const shown4 = view ? applyLook(view, look) : null;
|
|
47607
|
-
const [viewsEpoch, setViewsEpoch] = (0,
|
|
47675
|
+
const [viewsEpoch, setViewsEpoch] = (0, import_react271.useState)(0);
|
|
47608
47676
|
const opening = openingRail(activeRecordId, activeRail);
|
|
47609
47677
|
const recordsUi = useRecordsUi();
|
|
47610
47678
|
const hostLayouts = recordsUi.layouts ?? [];
|
|
@@ -47614,39 +47682,39 @@ function TablePage({
|
|
|
47614
47682
|
const questionsFromLink = questionsFromParam(activeView);
|
|
47615
47683
|
const openedByPackage = openingView(hostFromLink || savedFromLink || questionsFromLink ? null : activeView, activeDashboardId);
|
|
47616
47684
|
const opened = hostFromLink ? { ...openedByPackage, main: "records" } : questionsFromLink ? { ...openedByPackage, main: "questions" } : openedByPackage;
|
|
47617
|
-
const [hostLayout, setHostLayout] = (0,
|
|
47618
|
-
const [views, setViews] = (0,
|
|
47619
|
-
const [pickedViewId, setPickedViewId] = (0,
|
|
47620
|
-
const viewSeen = (0,
|
|
47621
|
-
const [viewLinkMissed, setViewLinkMissed] = (0,
|
|
47622
|
-
const [layoutChosen, setLayoutChosen] = (0,
|
|
47685
|
+
const [hostLayout, setHostLayout] = (0, import_react271.useState)(hostFromLink);
|
|
47686
|
+
const [views, setViews] = (0, import_react271.useState)(void 0);
|
|
47687
|
+
const [pickedViewId, setPickedViewId] = (0, import_react271.useState)(savedFromLink);
|
|
47688
|
+
const viewSeen = (0, import_react271.useRef)(null);
|
|
47689
|
+
const [viewLinkMissed, setViewLinkMissed] = (0, import_react271.useState)(false);
|
|
47690
|
+
const [layoutChosen, setLayoutChosen] = (0, import_react271.useState)(false);
|
|
47623
47691
|
const railAsked = typeof activeRail === "string" ? activeRail.trim() : "";
|
|
47624
47692
|
const railUnknown = railAsked !== "" && railFromParam(railAsked) === null ? railAsked : null;
|
|
47625
47693
|
const shareFromLink = railFromParam(activeRail) === "share";
|
|
47626
47694
|
const canShare = useCanShare();
|
|
47627
47695
|
const itemFor = (which) => railFromParam(activeRail) === which ? activeItemId ?? null : null;
|
|
47628
|
-
const [asking, setAsking] = (0,
|
|
47629
|
-
const [layoutFromLink, setLayoutFromLink] = (0,
|
|
47630
|
-
const [surface, setSurface] = (0,
|
|
47696
|
+
const [asking, setAsking] = (0, import_react271.useState)(null);
|
|
47697
|
+
const [layoutFromLink, setLayoutFromLink] = (0, import_react271.useState)(opened.layout);
|
|
47698
|
+
const [surface, setSurface] = (0, import_react271.useState)({
|
|
47631
47699
|
main: opened.main,
|
|
47632
47700
|
rail: opening.rail
|
|
47633
47701
|
});
|
|
47634
47702
|
const { main, rail } = surface;
|
|
47635
|
-
const [questionDraft, setQuestionDraft] = (0,
|
|
47703
|
+
const [questionDraft, setQuestionDraft] = (0, import_react271.useState)(null);
|
|
47636
47704
|
const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
|
|
47637
|
-
const [importEpoch, setImportEpoch] = (0,
|
|
47638
|
-
const [openRecord, setOpenRecord] = (0,
|
|
47705
|
+
const [importEpoch, setImportEpoch] = (0, import_react271.useState)(0);
|
|
47706
|
+
const [openRecord, setOpenRecord] = (0, import_react271.useState)(opening.record);
|
|
47639
47707
|
const phone = (0, import_design_system140.useIsMobile)();
|
|
47640
|
-
const [shareAsked, setShareAsked] = (0,
|
|
47708
|
+
const [shareAsked, setShareAsked] = (0, import_react271.useState)(0);
|
|
47641
47709
|
const { open: renameOpen, setOpen: setRenameOpen, ask: askRename, menuContentProps: renameMenuProps } = useRenameFromMenu();
|
|
47642
|
-
const [archiveAsked, setArchiveAsked] = (0,
|
|
47643
|
-
const [moveAsked, setMoveAsked] = (0,
|
|
47644
|
-
const [duplicateOpen, setDuplicateOpen] = (0,
|
|
47645
|
-
const [referenceOpen, setReferenceOpen] = (0,
|
|
47646
|
-
const [breakDownOpen, setBreakDownOpen] = (0,
|
|
47710
|
+
const [archiveAsked, setArchiveAsked] = (0, import_react271.useState)(0);
|
|
47711
|
+
const [moveAsked, setMoveAsked] = (0, import_react271.useState)(0);
|
|
47712
|
+
const [duplicateOpen, setDuplicateOpen] = (0, import_react271.useState)(false);
|
|
47713
|
+
const [referenceOpen, setReferenceOpen] = (0, import_react271.useState)(false);
|
|
47714
|
+
const [breakDownOpen, setBreakDownOpen] = (0, import_react271.useState)(false);
|
|
47647
47715
|
const canGetReference = useCanGetReference();
|
|
47648
|
-
const [toolbarSlot, setToolbarSlot] = (0,
|
|
47649
|
-
const [toolbarRow, setToolbarRow] = (0,
|
|
47716
|
+
const [toolbarSlot, setToolbarSlot] = (0, import_react271.useState)(null);
|
|
47717
|
+
const [toolbarRow, setToolbarRow] = (0, import_react271.useState)(null);
|
|
47650
47718
|
const toolbarFold2 = useToolbarFit(toolbarRow);
|
|
47651
47719
|
const slotClipped = useSlotScroll(toolbarSlot);
|
|
47652
47720
|
const face = tableOpening(view, hostLayouts.map((h) => h.id));
|
|
@@ -47657,7 +47725,7 @@ function TablePage({
|
|
|
47657
47725
|
const chooserCompact = !embedded && !designated && !phone && toolbarFold2 >= 2;
|
|
47658
47726
|
const controlsInSheet = phone && !designated;
|
|
47659
47727
|
const shareInMenu = phone || toolbarFold2 >= 4;
|
|
47660
|
-
(0,
|
|
47728
|
+
(0, import_react271.useEffect)(() => {
|
|
47661
47729
|
if (face.kind !== "designated") return;
|
|
47662
47730
|
if (hostFromLink || opened.layout || layoutChosen) return;
|
|
47663
47731
|
setHostLayout(face.hostLayout);
|
|
@@ -47688,9 +47756,9 @@ function TablePage({
|
|
|
47688
47756
|
lookDiffers: view ? lookDiffers(view, look) : false
|
|
47689
47757
|
};
|
|
47690
47758
|
const shownSignature = JSON.stringify(shownReport);
|
|
47691
|
-
const reportRef = (0,
|
|
47759
|
+
const reportRef = (0, import_react271.useRef)(onShownViewChange);
|
|
47692
47760
|
reportRef.current = onShownViewChange;
|
|
47693
|
-
(0,
|
|
47761
|
+
(0, import_react271.useEffect)(() => {
|
|
47694
47762
|
reportRef.current?.(JSON.parse(shownSignature));
|
|
47695
47763
|
}, [shownSignature]);
|
|
47696
47764
|
const pickLayout = (next) => {
|
|
@@ -47707,18 +47775,18 @@ function TablePage({
|
|
|
47707
47775
|
setSurface((now) => ({ ...now, main: "records" }));
|
|
47708
47776
|
onViewChanged?.(id);
|
|
47709
47777
|
};
|
|
47710
|
-
(0,
|
|
47778
|
+
(0, import_react271.useEffect)(() => {
|
|
47711
47779
|
if (!activeRecordId) return;
|
|
47712
47780
|
setOpenRecord(activeRecordId);
|
|
47713
47781
|
setSurface((now) => ({ ...now, rail: "record" }));
|
|
47714
47782
|
}, [activeRecordId]);
|
|
47715
|
-
(0,
|
|
47783
|
+
(0, import_react271.useEffect)(() => {
|
|
47716
47784
|
if (activeRecordId) return;
|
|
47717
47785
|
const named = railFromParam(activeRail);
|
|
47718
47786
|
if (named === null || named === "share") return;
|
|
47719
47787
|
setSurface((now) => ({ ...now, rail: named }));
|
|
47720
47788
|
}, [activeRail, activeRecordId]);
|
|
47721
|
-
(0,
|
|
47789
|
+
(0, import_react271.useEffect)(() => {
|
|
47722
47790
|
const host = hostLayoutFor(activeView);
|
|
47723
47791
|
if (host) {
|
|
47724
47792
|
setHostLayout(host);
|
|
@@ -47732,8 +47800,8 @@ function TablePage({
|
|
|
47732
47800
|
setLayoutFromLink(isLayout ? named : null);
|
|
47733
47801
|
setSurface((now) => ({ ...now, main: isLayout ? "records" : named }));
|
|
47734
47802
|
}, [activeView]);
|
|
47735
|
-
const [viewSaveRefused, setViewSaveRefused] = (0,
|
|
47736
|
-
const patchView = (0,
|
|
47803
|
+
const [viewSaveRefused, setViewSaveRefused] = (0, import_react271.useState)(null);
|
|
47804
|
+
const patchView = (0, import_react271.useCallback)(
|
|
47737
47805
|
async (asked3) => {
|
|
47738
47806
|
const current = view;
|
|
47739
47807
|
if (!current) return;
|
|
@@ -47749,19 +47817,19 @@ function TablePage({
|
|
|
47749
47817
|
},
|
|
47750
47818
|
[client, tableId, view, looks]
|
|
47751
47819
|
);
|
|
47752
|
-
const arrival = (0,
|
|
47753
|
-
const [gridQuery, setGridQuery] = (0,
|
|
47754
|
-
const [addressResetEpoch, setAddressResetEpoch] = (0,
|
|
47755
|
-
const reportGrid = (0,
|
|
47820
|
+
const arrival = (0, import_react271.useRef)(viewAddress ?? null);
|
|
47821
|
+
const [gridQuery, setGridQuery] = (0, import_react271.useState)(null);
|
|
47822
|
+
const [addressResetEpoch, setAddressResetEpoch] = (0, import_react271.useState)(0);
|
|
47823
|
+
const reportGrid = (0, import_react271.useCallback)((q) => {
|
|
47756
47824
|
const next = { sort: q.sort, filters: q.filters, search: q.search, page: q.page };
|
|
47757
47825
|
setGridQuery((held) => sameViewAddress(held, next) ? held : next);
|
|
47758
47826
|
}, []);
|
|
47759
|
-
const addressPort = (0,
|
|
47827
|
+
const addressPort = (0, import_react271.useMemo)(
|
|
47760
47828
|
() => ({ initial: arrival.current, report: reportGrid, resetEpoch: addressResetEpoch }),
|
|
47761
47829
|
[reportGrid, addressResetEpoch]
|
|
47762
47830
|
);
|
|
47763
|
-
const hiddenApplied = (0,
|
|
47764
|
-
(0,
|
|
47831
|
+
const hiddenApplied = (0, import_react271.useRef)(false);
|
|
47832
|
+
(0, import_react271.useEffect)(() => {
|
|
47765
47833
|
const hidden = arrival.current?.hidden;
|
|
47766
47834
|
if (hiddenApplied.current || !view || !looks || !hidden || hidden.length === 0) return;
|
|
47767
47835
|
hiddenApplied.current = true;
|
|
@@ -47781,10 +47849,10 @@ function TablePage({
|
|
|
47781
47849
|
const gridPending = !isViewAddressEmpty({ ...arrival.current ?? {}, hidden: [] });
|
|
47782
47850
|
const addressReady = Boolean(view && looks) && (gridQuery !== null || !gridPending);
|
|
47783
47851
|
const addressSignature = JSON.stringify(viewAddressToParams(addressNow));
|
|
47784
|
-
const addressReportRef = (0,
|
|
47852
|
+
const addressReportRef = (0, import_react271.useRef)(onViewAddressChange);
|
|
47785
47853
|
addressReportRef.current = onViewAddressChange;
|
|
47786
|
-
const addressSent = (0,
|
|
47787
|
-
(0,
|
|
47854
|
+
const addressSent = (0, import_react271.useRef)(null);
|
|
47855
|
+
(0, import_react271.useEffect)(() => {
|
|
47788
47856
|
if (!addressReady) return;
|
|
47789
47857
|
if (addressSent.current === null && addressSignature === JSON.stringify(viewAddressToParams(arrival.current))) {
|
|
47790
47858
|
addressSent.current = addressSignature;
|
|
@@ -47796,9 +47864,9 @@ function TablePage({
|
|
|
47796
47864
|
}, [addressReady, addressSignature]);
|
|
47797
47865
|
const queryShowing = !isViewAddressEmpty({ ...gridQuery ?? {}, hidden: [] });
|
|
47798
47866
|
const lookShowing = Boolean(view && looks && (lookDiffers(view, looks[view.id]) || queryShowing));
|
|
47799
|
-
const [lookRefused, setLookRefused] = (0,
|
|
47800
|
-
const [namingLook, setNamingLook] = (0,
|
|
47801
|
-
const [lookName, setLookName] = (0,
|
|
47867
|
+
const [lookRefused, setLookRefused] = (0, import_react271.useState)(null);
|
|
47868
|
+
const [namingLook, setNamingLook] = (0, import_react271.useState)(false);
|
|
47869
|
+
const [lookName, setLookName] = (0, import_react271.useState)("");
|
|
47802
47870
|
const resetLook = async () => {
|
|
47803
47871
|
const current = view;
|
|
47804
47872
|
setAddressResetEpoch((n) => n + 1);
|
|
@@ -47857,7 +47925,7 @@ function TablePage({
|
|
|
47857
47925
|
setPickedViewId(written.data);
|
|
47858
47926
|
setViewsEpoch((n) => n + 1);
|
|
47859
47927
|
};
|
|
47860
|
-
const [designateRefused, setDesignateRefused] = (0,
|
|
47928
|
+
const [designateRefused, setDesignateRefused] = (0, import_react271.useState)(null);
|
|
47861
47929
|
const opensAs = view?.isDefault ? openingLayoutOf(view) : null;
|
|
47862
47930
|
const canDesignate = Boolean(
|
|
47863
47931
|
rights.write && view && layoutShowing && layoutShowing !== opensAs && (storeKeepsLayout(layoutShowing) || hostLayouts.some((h) => h.id === layoutShowing))
|
|
@@ -48036,14 +48104,14 @@ function TablePage({
|
|
|
48036
48104
|
}
|
|
48037
48105
|
});
|
|
48038
48106
|
const openedEntry = ACTION_PRESS.find((entry) => entry.press.main !== void 0 && entry.press.main === main) ?? ACTION_PRESS.find((entry) => entry.press.rail !== void 0 && entry.press.rail === rail) ?? null;
|
|
48039
|
-
const actionsRef = (0,
|
|
48107
|
+
const actionsRef = (0, import_react271.useRef)(actions);
|
|
48040
48108
|
actionsRef.current = actions;
|
|
48041
|
-
const onActionsRef = (0,
|
|
48109
|
+
const onActionsRef = (0, import_react271.useRef)(onActions);
|
|
48042
48110
|
onActionsRef.current = onActions;
|
|
48043
|
-
(0,
|
|
48111
|
+
(0, import_react271.useEffect)(() => {
|
|
48044
48112
|
onActionsRef.current?.(actionsRef.current);
|
|
48045
48113
|
});
|
|
48046
|
-
(0,
|
|
48114
|
+
(0, import_react271.useEffect)(() => {
|
|
48047
48115
|
const onKey = (event) => {
|
|
48048
48116
|
const asked3 = objectActionForKey(actionsRef.current, event);
|
|
48049
48117
|
if (!asked3) return;
|
|
@@ -48272,7 +48340,7 @@ function TablePage({
|
|
|
48272
48340
|
] })
|
|
48273
48341
|
] }) }),
|
|
48274
48342
|
/* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_design_system140.DropdownMenuContent, { align: "start", className: "w-60", "data-view-look-menu-content": "", children: [
|
|
48275
|
-
/* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_design_system140.DropdownMenuLabel, { className: "text-xs font-normal text-muted-foreground",
|
|
48343
|
+
/* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_design_system140.DropdownMenuLabel, { className: "text-xs font-normal text-muted-foreground", title: LOOK_WORDS.yours, children: LOOK_WORDS.yoursLabel }),
|
|
48276
48344
|
lookSavable ? /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_design_system140.DropdownMenuItem, { onSelect: () => void saveLookToView(), "data-view-look-save": "", children: LOOK_WORDS.saveToView }) : null,
|
|
48277
48345
|
rights.write ? /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_design_system140.DropdownMenuItem, { onSelect: () => setNamingLook(true), "data-view-look-save-new": "", children: LOOK_WORDS.saveAsNew }) : null,
|
|
48278
48346
|
/* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_design_system140.DropdownMenuItem, { onSelect: () => void resetLook(), "data-view-look-reset": "", children: LOOK_WORDS.reset })
|
|
@@ -48584,8 +48652,8 @@ var PUBLIC_READ_ONLY = "Public \xB7 read only";
|
|
|
48584
48652
|
function usePublicReadOnly(client, organizationId, tableId, table, rights) {
|
|
48585
48653
|
const readOnly = rights.known && rights.read && !rights.write;
|
|
48586
48654
|
const marked = table?.published_to_web;
|
|
48587
|
-
const [isPublic, setIsPublic] = (0,
|
|
48588
|
-
(0,
|
|
48655
|
+
const [isPublic, setIsPublic] = (0, import_react271.useState)(false);
|
|
48656
|
+
(0, import_react271.useEffect)(() => {
|
|
48589
48657
|
if (!readOnly || !table) {
|
|
48590
48658
|
setIsPublic(false);
|
|
48591
48659
|
return;
|
|
@@ -48610,9 +48678,9 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
|
|
|
48610
48678
|
// src/entityViews.tsx
|
|
48611
48679
|
var import_design_system141 = require("@ai-matrx/design-system");
|
|
48612
48680
|
var import_data_table23 = require("@ai-matrx/design-system/data-table");
|
|
48613
|
-
var
|
|
48681
|
+
var import_react273 = require("react");
|
|
48614
48682
|
var import_design_system142 = require("@ai-matrx/design-system");
|
|
48615
|
-
var
|
|
48683
|
+
var import_react274 = require("@ai-matrx/records/react");
|
|
48616
48684
|
var import_jsx_runtime156 = require("react/jsx-runtime");
|
|
48617
48685
|
var entityTitleColumn = entityNameColumn;
|
|
48618
48686
|
function shown3(v) {
|
|
@@ -48623,12 +48691,12 @@ function EntityBoard({ entity, groupBy, cardFields, onOpenRecord, className }) {
|
|
|
48623
48691
|
const choiceColumns = entityChoiceColumns(entity.columns);
|
|
48624
48692
|
const column = (groupBy ? choiceColumns.find((c) => c.key === groupBy) : void 0) ?? choiceColumns[0] ?? null;
|
|
48625
48693
|
const title = entityTitleColumn(entity.columns);
|
|
48626
|
-
const extra = (0,
|
|
48694
|
+
const extra = (0, import_react273.useMemo)(
|
|
48627
48695
|
() => cardFields ? entity.columns.filter((c) => cardFields.includes(c.key)) : entity.columns.filter((c) => c !== title && c !== column && c.type !== "choice").slice(0, 2),
|
|
48628
48696
|
[cardFields, entity.columns, title, column]
|
|
48629
48697
|
);
|
|
48630
|
-
const [refused, setRefused] = (0,
|
|
48631
|
-
const [over, setOver] = (0,
|
|
48698
|
+
const [refused, setRefused] = (0, import_react273.useState)(null);
|
|
48699
|
+
const [over, setOver] = (0, import_react273.useState)(null);
|
|
48632
48700
|
if (entity.error) return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This board could not be read: ${entity.error}` });
|
|
48633
48701
|
if (!entity.loading && !column) {
|
|
48634
48702
|
return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `${entity.label ?? "This table"} has no choice column to make a board of.` });
|
|
@@ -48693,11 +48761,11 @@ function EntityBoard({ entity, groupBy, cardFields, onOpenRecord, className }) {
|
|
|
48693
48761
|
}) });
|
|
48694
48762
|
}
|
|
48695
48763
|
function EntityChartBlock({ source, kind, by, measure, title, where, organization, centerValue, variant, className }) {
|
|
48696
|
-
const client = (0,
|
|
48764
|
+
const client = (0, import_react274.useRecordsClient)();
|
|
48697
48765
|
const m = measure ?? { op: "count" };
|
|
48698
48766
|
const ask = JSON.stringify([source.token, by ?? null, m, where ?? null, organization ?? null]);
|
|
48699
|
-
const [block, setBlock] = (0,
|
|
48700
|
-
(0,
|
|
48767
|
+
const [block, setBlock] = (0, import_react273.useState)(null);
|
|
48768
|
+
(0, import_react273.useEffect)(() => {
|
|
48701
48769
|
let cancelled = false;
|
|
48702
48770
|
const question = {
|
|
48703
48771
|
...by ? { by: [by] } : {},
|
|
@@ -48760,20 +48828,20 @@ function EntityTablePageBody({
|
|
|
48760
48828
|
actions,
|
|
48761
48829
|
className
|
|
48762
48830
|
}) {
|
|
48763
|
-
const [typed2, setTyped] = (0,
|
|
48831
|
+
const [typed2, setTyped] = (0, import_react273.useState)("");
|
|
48764
48832
|
const term = searchOverride ?? typed2;
|
|
48765
48833
|
const entity = useEntityTable(source.token, { pageSize, search: term });
|
|
48766
|
-
const [layout, setLayout] = (0,
|
|
48767
|
-
(0,
|
|
48834
|
+
const [layout, setLayout] = (0, import_react273.useState)(opened);
|
|
48835
|
+
(0, import_react273.useEffect)(() => setLayout(opened), [opened]);
|
|
48768
48836
|
const choose = (next) => {
|
|
48769
48837
|
setLayout(next);
|
|
48770
48838
|
onLayoutChange?.(next);
|
|
48771
48839
|
};
|
|
48772
48840
|
const boardable = entityChoiceColumns(entity.columns).length > 0;
|
|
48773
48841
|
const nameColumn = entityNameColumn(entity.columns);
|
|
48774
|
-
const [naming, setNaming] = (0,
|
|
48775
|
-
const [adding, setAdding] = (0,
|
|
48776
|
-
const [addRefused, setAddRefused] = (0,
|
|
48842
|
+
const [naming, setNaming] = (0, import_react273.useState)(null);
|
|
48843
|
+
const [adding, setAdding] = (0, import_react273.useState)(false);
|
|
48844
|
+
const [addRefused, setAddRefused] = (0, import_react273.useState)(null);
|
|
48777
48845
|
const add = async () => {
|
|
48778
48846
|
const name = (naming ?? "").trim();
|
|
48779
48847
|
if (!name || !nameColumn || adding) return;
|
|
@@ -48785,7 +48853,7 @@ function EntityTablePageBody({
|
|
|
48785
48853
|
setNaming(null);
|
|
48786
48854
|
onOpenRecord?.(made.id);
|
|
48787
48855
|
};
|
|
48788
|
-
const [question, setQuestion] = (0,
|
|
48856
|
+
const [question, setQuestion] = (0, import_react273.useState)(() => questionFromGrouping(void 0));
|
|
48789
48857
|
const { config: drill } = useDrill({
|
|
48790
48858
|
source,
|
|
48791
48859
|
question,
|
|
@@ -48888,9 +48956,9 @@ function TablePage2(props) {
|
|
|
48888
48956
|
}
|
|
48889
48957
|
|
|
48890
48958
|
// src/DataBindingPicker.tsx
|
|
48891
|
-
var
|
|
48959
|
+
var import_react275 = require("react");
|
|
48892
48960
|
var import_records64 = require("@ai-matrx/records");
|
|
48893
|
-
var
|
|
48961
|
+
var import_react276 = require("@ai-matrx/records/react");
|
|
48894
48962
|
var import_design_system143 = require("@ai-matrx/design-system");
|
|
48895
48963
|
var import_jsx_runtime158 = require("react/jsx-runtime");
|
|
48896
48964
|
var DATA_BINDING_SHAPES = [
|
|
@@ -48980,11 +49048,11 @@ function BindingDetails({
|
|
|
48980
49048
|
disabled,
|
|
48981
49049
|
defaultRowLimit
|
|
48982
49050
|
}) {
|
|
48983
|
-
const table = (0,
|
|
48984
|
-
const fields = (0,
|
|
48985
|
-
const fieldList = (0,
|
|
49051
|
+
const table = (0, import_react276.useTable)(tableId);
|
|
49052
|
+
const fields = (0, import_react276.useFields)(tableId);
|
|
49053
|
+
const fieldList = (0, import_react275.useMemo)(() => fields.data ?? [], [fields.data]);
|
|
48986
49054
|
const shape = binding.semantic_type;
|
|
48987
|
-
(0,
|
|
49055
|
+
(0, import_react275.useEffect)(() => {
|
|
48988
49056
|
if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
|
|
48989
49057
|
onChange({
|
|
48990
49058
|
...binding,
|
|
@@ -49129,7 +49197,7 @@ function BindingDetails({
|
|
|
49129
49197
|
}
|
|
49130
49198
|
|
|
49131
49199
|
// src/PickedSummaries.tsx
|
|
49132
|
-
var
|
|
49200
|
+
var import_react277 = require("@ai-matrx/records/react");
|
|
49133
49201
|
var import_jsx_runtime159 = require("react/jsx-runtime");
|
|
49134
49202
|
function TableNameText({ dataSource, tableId }) {
|
|
49135
49203
|
const tables = useTablesAnywhere(dataSource);
|
|
@@ -49158,7 +49226,7 @@ function ColumnValuesText({
|
|
|
49158
49226
|
);
|
|
49159
49227
|
}
|
|
49160
49228
|
function ColumnValuesWords({ tableId, value }) {
|
|
49161
|
-
const fields = (0,
|
|
49229
|
+
const fields = (0, import_react277.useFields)(tableId);
|
|
49162
49230
|
const labels = useRecordLabels(fields.data ?? void 0);
|
|
49163
49231
|
if (fields.loading) return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_jsx_runtime159.Fragment, { children: "\u2026" });
|
|
49164
49232
|
if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_jsx_runtime159.Fragment, { children: "Couldn't load this table's columns" });
|
|
@@ -49197,8 +49265,8 @@ function RecordNameText({
|
|
|
49197
49265
|
);
|
|
49198
49266
|
}
|
|
49199
49267
|
function RecordNameWords({ tableId, recordId }) {
|
|
49200
|
-
const table = (0,
|
|
49201
|
-
const record = (0,
|
|
49268
|
+
const table = (0, import_react277.useTable)(tableId);
|
|
49269
|
+
const record = (0, import_react277.useRecord)(recordId);
|
|
49202
49270
|
if (record.loading || table.loading) return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_jsx_runtime159.Fragment, { children: "\u2026" });
|
|
49203
49271
|
if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_jsx_runtime159.Fragment, { children: "Couldn't load this record" });
|
|
49204
49272
|
if (!record.data) return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_jsx_runtime159.Fragment, { children: "A record you cannot open" });
|
|
@@ -49206,19 +49274,19 @@ function RecordNameWords({ tableId, recordId }) {
|
|
|
49206
49274
|
}
|
|
49207
49275
|
|
|
49208
49276
|
// src/HeldChangeDecision.tsx
|
|
49209
|
-
var
|
|
49210
|
-
var
|
|
49277
|
+
var import_react278 = require("react");
|
|
49278
|
+
var import_react279 = require("@ai-matrx/records/react");
|
|
49211
49279
|
var import_design_system144 = require("@ai-matrx/design-system");
|
|
49212
49280
|
var import_jsx_runtime160 = require("react/jsx-runtime");
|
|
49213
49281
|
function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided }) {
|
|
49214
|
-
return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
|
|
49282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_react279.RecordsProvider, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Decision, { approvalId, onDecided }) });
|
|
49215
49283
|
}
|
|
49216
49284
|
function Decision({ approvalId, onDecided }) {
|
|
49217
|
-
const client = (0,
|
|
49218
|
-
const [may, setMay] = (0,
|
|
49219
|
-
const [busy, setBusy] = (0,
|
|
49220
|
-
const [error, setError] = (0,
|
|
49221
|
-
(0,
|
|
49285
|
+
const client = (0, import_react279.useRecordsClient)();
|
|
49286
|
+
const [may, setMay] = (0, import_react278.useState)(null);
|
|
49287
|
+
const [busy, setBusy] = (0, import_react278.useState)(null);
|
|
49288
|
+
const [error, setError] = (0, import_react278.useState)(null);
|
|
49289
|
+
(0, import_react278.useEffect)(() => {
|
|
49222
49290
|
let live = true;
|
|
49223
49291
|
void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
|
|
49224
49292
|
if (!live) return;
|
|
@@ -49251,18 +49319,18 @@ function Decision({ approvalId, onDecided }) {
|
|
|
49251
49319
|
}
|
|
49252
49320
|
|
|
49253
49321
|
// src/TemplatePreview.tsx
|
|
49254
|
-
var
|
|
49322
|
+
var import_react280 = require("react");
|
|
49255
49323
|
var import_memory = require("@ai-matrx/records/memory");
|
|
49256
|
-
var
|
|
49324
|
+
var import_react281 = require("@ai-matrx/records/react");
|
|
49257
49325
|
var import_jsx_runtime161 = require("react/jsx-runtime");
|
|
49258
49326
|
function useTemplatePreview(spec, today) {
|
|
49259
|
-
return (0,
|
|
49327
|
+
return (0, import_react280.useMemo)(() => (0, import_memory.templatePreview)(spec, today ? { today } : {}), [spec, today]);
|
|
49260
49328
|
}
|
|
49261
49329
|
function TemplatePreview({ spec, today, initialTable, host, aside, booking, className }) {
|
|
49262
49330
|
const preview = useTemplatePreview(spec, today);
|
|
49263
|
-
const bound2 = (0,
|
|
49331
|
+
const bound2 = (0, import_react280.useMemo)(() => ({ ...host, sayLevelNeeded: false }), [host]);
|
|
49264
49332
|
const first = preview.tables.find((t) => t.token === initialTable) ?? preview.tables[0];
|
|
49265
|
-
const [active, setActive] = (0,
|
|
49333
|
+
const [active, setActive] = (0, import_react280.useState)(first?.id ?? null);
|
|
49266
49334
|
const table = preview.tables.find((t) => t.id === active) ?? first;
|
|
49267
49335
|
if (!table) return null;
|
|
49268
49336
|
return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)("div", { className: ["flex min-w-0 flex-col gap-3", className].filter(Boolean).join(" "), "data-template-preview": preview.tables.length, children: [
|
|
@@ -49299,10 +49367,10 @@ function TemplatePreview({ spec, today, initialTable, host, aside, booking, clas
|
|
|
49299
49367
|
] });
|
|
49300
49368
|
}
|
|
49301
49369
|
function PreviewForms({ preview, booking }) {
|
|
49302
|
-
const client = (0,
|
|
49303
|
-
const [forms, setForms] = (0,
|
|
49304
|
-
const [pages, setPages] = (0,
|
|
49305
|
-
(0,
|
|
49370
|
+
const client = (0, import_react281.useRecordsClient)();
|
|
49371
|
+
const [forms, setForms] = (0, import_react280.useState)(null);
|
|
49372
|
+
const [pages, setPages] = (0, import_react280.useState)([]);
|
|
49373
|
+
(0, import_react280.useEffect)(() => {
|
|
49306
49374
|
let gone = false;
|
|
49307
49375
|
void client.forms().then((answered) => {
|
|
49308
49376
|
if (!gone) setForms(answered.ok ? answered.data.map(formFromSummary) : []);
|