@ai-matrx/records-ui 0.93.142 → 0.93.146
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 +64 -0
- package/dist/index.cjs +2107 -1547
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -33
- package/dist/index.d.ts +71 -33
- package/dist/index.js +2054 -1495
- package/dist/index.js.map +1 -1
- package/dist/object-actions.cjs +127 -28
- package/dist/object-actions.cjs.map +1 -1
- package/dist/object-actions.d.cts +1 -1
- package/dist/object-actions.d.ts +1 -1
- package/dist/object-actions.js +125 -26
- package/dist/object-actions.js.map +1 -1
- package/dist/{objectActions-BSbblgf-.d.cts → objectActions-Dgdr0E4b.d.cts} +52 -11
- package/dist/{objectActions-BSbblgf-.d.ts → objectActions-Dgdr0E4b.d.ts} +52 -11
- package/dist/pickers.cjs +53 -2
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.d.cts +12 -1
- package/dist/pickers.d.ts +12 -1
- package/dist/pickers.js +53 -2
- package/dist/pickers.js.map +1 -1
- package/package.json +2 -2
package/dist/pickers.d.cts
CHANGED
|
@@ -134,4 +134,15 @@ declare function RecordNameText({ dataSource, userId, tableId, recordId, }: {
|
|
|
134
134
|
recordId: string | null;
|
|
135
135
|
}): react.JSX.Element;
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
interface HeldChangeDecisionProps {
|
|
138
|
+
dataSource: RecordsDataSource;
|
|
139
|
+
userId: Uuid | null;
|
|
140
|
+
/** The organization the held change lives in (the marker's `organization_id`). */
|
|
141
|
+
organizationId: Uuid;
|
|
142
|
+
approvalId: Uuid;
|
|
143
|
+
/** Told once the store took the decision; `approved` says which way. */
|
|
144
|
+
onDecided: (approved: boolean) => void;
|
|
145
|
+
}
|
|
146
|
+
declare function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided }: HeldChangeDecisionProps): react.JSX.Element;
|
|
147
|
+
|
|
148
|
+
export { ColumnValuesEditor, type ColumnValuesEditorProps, ColumnValuesText, DATA_BINDING_MISSING, DATA_BINDING_SHAPES, type DataBinding, DataBindingPicker, type DataBindingPickerProps, type DataBindingShape, HeldChangeDecision, type HeldChangeDecisionProps, RecordNameText, RecordPicker, type RecordPickerProps, type TableAnywhere, TableNameText, TablePicker, type TablePickerProps, TableScope, type TableScopeProps, type TablesAnywhere, bindingPlaceholdersFor, defaultBindingTemplate, emptyDataBinding, isCompleteDataBinding, isDataBinding, useTablesAnywhere };
|
package/dist/pickers.d.ts
CHANGED
|
@@ -134,4 +134,15 @@ declare function RecordNameText({ dataSource, userId, tableId, recordId, }: {
|
|
|
134
134
|
recordId: string | null;
|
|
135
135
|
}): react.JSX.Element;
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
interface HeldChangeDecisionProps {
|
|
138
|
+
dataSource: RecordsDataSource;
|
|
139
|
+
userId: Uuid | null;
|
|
140
|
+
/** The organization the held change lives in (the marker's `organization_id`). */
|
|
141
|
+
organizationId: Uuid;
|
|
142
|
+
approvalId: Uuid;
|
|
143
|
+
/** Told once the store took the decision; `approved` says which way. */
|
|
144
|
+
onDecided: (approved: boolean) => void;
|
|
145
|
+
}
|
|
146
|
+
declare function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided }: HeldChangeDecisionProps): react.JSX.Element;
|
|
147
|
+
|
|
148
|
+
export { ColumnValuesEditor, type ColumnValuesEditorProps, ColumnValuesText, DATA_BINDING_MISSING, DATA_BINDING_SHAPES, type DataBinding, DataBindingPicker, type DataBindingPickerProps, type DataBindingShape, HeldChangeDecision, type HeldChangeDecisionProps, RecordNameText, RecordPicker, type RecordPickerProps, type TableAnywhere, TableNameText, TablePicker, type TablePickerProps, TableScope, type TableScopeProps, type TablesAnywhere, bindingPlaceholdersFor, defaultBindingTemplate, emptyDataBinding, isCompleteDataBinding, isDataBinding, useTablesAnywhere };
|
package/dist/pickers.js
CHANGED
|
@@ -451,6 +451,7 @@ function rowNameIn(table, row, fallback = "Untitled") {
|
|
|
451
451
|
return recordName(row?.document, table?.title_field ?? null, fallback);
|
|
452
452
|
}
|
|
453
453
|
var WITHHELD_RECORD_LABEL = "A record you have not been given access to";
|
|
454
|
+
var UNREAD_RECORD_LABEL = "Couldn't load this name";
|
|
454
455
|
|
|
455
456
|
// src/RelationPicker.tsx
|
|
456
457
|
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
@@ -929,7 +930,7 @@ function RelationPicker({ field, value, onChange, disabled, id, className, allow
|
|
|
929
930
|
const learned = {};
|
|
930
931
|
for (const id2 of wanted) {
|
|
931
932
|
const said = result.ok ? result.data[id2] : void 0;
|
|
932
|
-
learned[id2] = typeof said === "string" && said !== "" ? said : WITHHELD_RECORD_LABEL;
|
|
933
|
+
learned[id2] = !result.ok ? UNREAD_RECORD_LABEL : typeof said === "string" && said !== "" ? said : WITHHELD_RECORD_LABEL;
|
|
933
934
|
}
|
|
934
935
|
setWords((current) => ({ ...current, ...learned }));
|
|
935
936
|
});
|
|
@@ -1528,7 +1529,7 @@ function RecordLabelProvider({ children }) {
|
|
|
1528
1529
|
});
|
|
1529
1530
|
for (const id of wanted) {
|
|
1530
1531
|
const words = result.ok ? result.data[id] : void 0;
|
|
1531
|
-
learned[id] = typeof words === "string" && words !== "" ? words : WITHHELD_RECORD_LABEL;
|
|
1532
|
+
learned[id] = !result.ok ? UNREAD_RECORD_LABEL : typeof words === "string" && words !== "" ? words : WITHHELD_RECORD_LABEL;
|
|
1532
1533
|
}
|
|
1533
1534
|
if (result.ok) for (const id of result.archived ?? []) archivedNow[`${field.id}:${id}`] = true;
|
|
1534
1535
|
})
|
|
@@ -4490,6 +4491,7 @@ function TableNameText({ dataSource, tableId }) {
|
|
|
4490
4491
|
const tables = useTablesAnywhere(dataSource);
|
|
4491
4492
|
if (!tableId) return /* @__PURE__ */ jsx23(Fragment7, { children: "\u2014" });
|
|
4492
4493
|
if (tables.loading) return /* @__PURE__ */ jsx23(Fragment7, { children: "\u2026" });
|
|
4494
|
+
if (tables.error) return /* @__PURE__ */ jsx23(Fragment7, { children: "Couldn't load the table's name" });
|
|
4493
4495
|
return /* @__PURE__ */ jsx23(Fragment7, { children: tables.rows.find((t) => t.table_id === tableId)?.table_name ?? "\u2014" });
|
|
4494
4496
|
}
|
|
4495
4497
|
function ColumnValuesText({
|
|
@@ -4505,8 +4507,10 @@ function ColumnValuesWords({ tableId, value }) {
|
|
|
4505
4507
|
const fields = useFields3(tableId);
|
|
4506
4508
|
const labels = useRecordLabels(fields.data ?? void 0);
|
|
4507
4509
|
if (fields.loading) return /* @__PURE__ */ jsx23(Fragment7, { children: "\u2026" });
|
|
4510
|
+
if (fields.error) return /* @__PURE__ */ jsx23(Fragment7, { children: "Couldn't load this table's columns" });
|
|
4508
4511
|
const parts = [];
|
|
4509
4512
|
for (const [key, stored] of Object.entries(value)) {
|
|
4513
|
+
if (key.startsWith("_")) continue;
|
|
4510
4514
|
const field = (fields.data ?? []).find((f) => f.key === key);
|
|
4511
4515
|
if (parts.length) parts.push(/* @__PURE__ */ jsx23("span", { children: ", " }, `${key}-sep`));
|
|
4512
4516
|
parts.push(
|
|
@@ -4532,15 +4536,62 @@ function RecordNameWords({ tableId, recordId }) {
|
|
|
4532
4536
|
const table = useTable3(tableId);
|
|
4533
4537
|
const record = useRecord(recordId);
|
|
4534
4538
|
if (record.loading || table.loading) return /* @__PURE__ */ jsx23(Fragment7, { children: "\u2026" });
|
|
4539
|
+
if (record.error) return /* @__PURE__ */ jsx23(Fragment7, { children: "Couldn't load this record" });
|
|
4535
4540
|
if (!record.data) return /* @__PURE__ */ jsx23(Fragment7, { children: "A record you cannot open" });
|
|
4536
4541
|
return /* @__PURE__ */ jsx23(Fragment7, { children: recordName(record.data.document, table.data?.title_field ?? null) });
|
|
4537
4542
|
}
|
|
4543
|
+
|
|
4544
|
+
// src/HeldChangeDecision.tsx
|
|
4545
|
+
import { useEffect as useEffect15, useState as useState17 } from "react";
|
|
4546
|
+
import { RecordsProvider as RecordsProvider3, useRecordsClient as useRecordsClient3 } from "@ai-matrx/records/react";
|
|
4547
|
+
import { Button as Button11 } from "@ai-matrx/design-system";
|
|
4548
|
+
import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4549
|
+
function HeldChangeDecision({ dataSource, userId, organizationId, approvalId, onDecided }) {
|
|
4550
|
+
return /* @__PURE__ */ jsx24(RecordsProvider3, { config: { dataSource, actor: personActor(userId), organizationId }, children: /* @__PURE__ */ jsx24(Decision, { approvalId, onDecided }) });
|
|
4551
|
+
}
|
|
4552
|
+
function Decision({ approvalId, onDecided }) {
|
|
4553
|
+
const client = useRecordsClient3();
|
|
4554
|
+
const [may, setMay] = useState17(null);
|
|
4555
|
+
const [busy, setBusy] = useState17(null);
|
|
4556
|
+
const [error, setError] = useState17(null);
|
|
4557
|
+
useEffect15(() => {
|
|
4558
|
+
let live = true;
|
|
4559
|
+
void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
|
|
4560
|
+
if (!live) return;
|
|
4561
|
+
if (res.ok) setMay(res.data);
|
|
4562
|
+
else {
|
|
4563
|
+
setMay(false);
|
|
4564
|
+
setError(res.error);
|
|
4565
|
+
}
|
|
4566
|
+
});
|
|
4567
|
+
return () => {
|
|
4568
|
+
live = false;
|
|
4569
|
+
};
|
|
4570
|
+
}, [client, approvalId]);
|
|
4571
|
+
const decide = async (approve) => {
|
|
4572
|
+
setBusy(approve ? "approve" : "refuse");
|
|
4573
|
+
setError(null);
|
|
4574
|
+
const res = await client.workApprovalDecide({ approval_id: approvalId, approve });
|
|
4575
|
+
setBusy(null);
|
|
4576
|
+
if (res.ok) onDecided(approve);
|
|
4577
|
+
else setError(res.error);
|
|
4578
|
+
};
|
|
4579
|
+
if (may === null) return /* @__PURE__ */ jsx24("p", { className: "text-xs text-muted-foreground", children: "Checking who can decide\u2026" });
|
|
4580
|
+
return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-1.5", children: [
|
|
4581
|
+
may ? /* @__PURE__ */ jsxs21("div", { className: "flex gap-2", children: [
|
|
4582
|
+
/* @__PURE__ */ jsx24(Button11, { type: "button", size: "sm", disabled: busy !== null, onClick: () => void decide(true), children: busy === "approve" ? "Approving\u2026" : "Approve" }),
|
|
4583
|
+
/* @__PURE__ */ jsx24(Button11, { type: "button", size: "sm", variant: "outline", disabled: busy !== null, onClick: () => void decide(false), children: busy === "refuse" ? "Refusing\u2026" : "Refuse" })
|
|
4584
|
+
] }) : !error && /* @__PURE__ */ jsx24("p", { className: "text-xs text-muted-foreground", children: "An owner or admin of this organization decides this." }),
|
|
4585
|
+
error ? /* @__PURE__ */ jsx24(RefusalLine, { error }) : null
|
|
4586
|
+
] });
|
|
4587
|
+
}
|
|
4538
4588
|
export {
|
|
4539
4589
|
ColumnValuesEditor,
|
|
4540
4590
|
ColumnValuesText,
|
|
4541
4591
|
DATA_BINDING_MISSING,
|
|
4542
4592
|
DATA_BINDING_SHAPES,
|
|
4543
4593
|
DataBindingPicker,
|
|
4594
|
+
HeldChangeDecision,
|
|
4544
4595
|
RecordNameText,
|
|
4545
4596
|
RecordPicker,
|
|
4546
4597
|
TableNameText,
|