@ai-matrx/records-ui 0.3.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -521,8 +521,16 @@ declare function ViewBar({ tableId, activeViewId, onActiveView, seed, className
521
521
  interface ProposedChange {
522
522
  id: string;
523
523
  act: "add" | "update" | "remove";
524
- /** The Table the change lands in. */
525
- table: Uuid;
524
+ /**
525
+ * The Table a NEW record lands in. Required for `add` and unused by `update`
526
+ * and `remove`, which name a record instead — and it is optional for exactly
527
+ * that reason: it used to be required for all three, so a proposer wanting to
528
+ * change an existing record had to supply the id of the kernel Table that
529
+ * record lives in, which is a fact the client has no door to ask for. A
530
+ * required field a caller cannot fill is a field that gets filled with
531
+ * something untrue.
532
+ */
533
+ table?: Uuid | undefined;
526
534
  /** The record it changes. Required for `update` and `remove`. */
527
535
  record?: Uuid | undefined;
528
536
  /** The document for `add`, or the patch for `update`. */
@@ -1087,9 +1095,16 @@ interface TablePageProps {
1087
1095
  tableId: Uuid$1;
1088
1096
  /** Rows per page for every layout. */
1089
1097
  pageSize?: number | undefined;
1098
+ /**
1099
+ * The views this table should have. Each one whose NAME the table does not
1100
+ * hold yet is saved the first time the bar loads, and a name a person has
1101
+ * since tweaked is never overwritten. Left out, `DEFAULT_VIEW_NAME` below is
1102
+ * used — see why that default is not optional.
1103
+ */
1104
+ seedViews?: SavedViewSpec[] | undefined;
1090
1105
  className?: string | undefined;
1091
1106
  }
1092
- declare function TablePage({ tableId, pageSize, className }: TablePageProps): react.JSX.Element;
1107
+ declare function TablePage({ tableId, pageSize, seedViews, className }: TablePageProps): react.JSX.Element;
1093
1108
 
1094
1109
  /** One Field a person asked for, in the store's own behaviour words (FLD-1). */
1095
1110
  interface NewFieldSpec {
package/dist/index.d.ts CHANGED
@@ -521,8 +521,16 @@ declare function ViewBar({ tableId, activeViewId, onActiveView, seed, className
521
521
  interface ProposedChange {
522
522
  id: string;
523
523
  act: "add" | "update" | "remove";
524
- /** The Table the change lands in. */
525
- table: Uuid;
524
+ /**
525
+ * The Table a NEW record lands in. Required for `add` and unused by `update`
526
+ * and `remove`, which name a record instead — and it is optional for exactly
527
+ * that reason: it used to be required for all three, so a proposer wanting to
528
+ * change an existing record had to supply the id of the kernel Table that
529
+ * record lives in, which is a fact the client has no door to ask for. A
530
+ * required field a caller cannot fill is a field that gets filled with
531
+ * something untrue.
532
+ */
533
+ table?: Uuid | undefined;
526
534
  /** The record it changes. Required for `update` and `remove`. */
527
535
  record?: Uuid | undefined;
528
536
  /** The document for `add`, or the patch for `update`. */
@@ -1087,9 +1095,16 @@ interface TablePageProps {
1087
1095
  tableId: Uuid$1;
1088
1096
  /** Rows per page for every layout. */
1089
1097
  pageSize?: number | undefined;
1098
+ /**
1099
+ * The views this table should have. Each one whose NAME the table does not
1100
+ * hold yet is saved the first time the bar loads, and a name a person has
1101
+ * since tweaked is never overwritten. Left out, `DEFAULT_VIEW_NAME` below is
1102
+ * used — see why that default is not optional.
1103
+ */
1104
+ seedViews?: SavedViewSpec[] | undefined;
1090
1105
  className?: string | undefined;
1091
1106
  }
1092
- declare function TablePage({ tableId, pageSize, className }: TablePageProps): react.JSX.Element;
1107
+ declare function TablePage({ tableId, pageSize, seedViews, className }: TablePageProps): react.JSX.Element;
1093
1108
 
1094
1109
  /** One Field a person asked for, in the store's own behaviour words (FLD-1). */
1095
1110
  interface NewFieldSpec {
package/dist/index.js CHANGED
@@ -2097,6 +2097,12 @@ function ProposalRow({
2097
2097
  const [confirming, setConfirming] = useState14(false);
2098
2098
  async function applyThroughTheStore() {
2099
2099
  if (change.act === "add") {
2100
+ if (!change.table) {
2101
+ return {
2102
+ settled: "refused",
2103
+ sentence: "This proposal asks to add a record but does not name the table it goes in, so nothing was written."
2104
+ };
2105
+ }
2100
2106
  const written = await client.recordWrite({ table_id: change.table, data: change.data ?? {} });
2101
2107
  return written.ok ? { settled: "accepted", sentence: "Written." } : { settled: "refused", sentence: written.error.message };
2102
2108
  }
@@ -5814,7 +5820,11 @@ import { useState as useState35 } from "react";
5814
5820
  import { useTable as useTable21 } from "@ai-matrx/records/react";
5815
5821
  import { Button as Button31, Separator as Separator7, Skeleton as Skeleton25, cn as cn36 } from "@ai-matrx/design-system";
5816
5822
  import { Fragment as Fragment8, jsx as jsx38, jsxs as jsxs35 } from "react/jsx-runtime";
5817
- function TablePage({ tableId, pageSize = 100, className }) {
5823
+ var DEFAULT_VIEW_NAME = "All records";
5824
+ function defaultView(tableId) {
5825
+ return { name: DEFAULT_VIEW_NAME, subject: tableId, layout: "grid", isDefault: true };
5826
+ }
5827
+ function TablePage({ tableId, pageSize = 100, seedViews, className }) {
5818
5828
  const table = useTable21(tableId);
5819
5829
  const rights = useTableRights(table.data);
5820
5830
  const [view, setView] = useState35(null);
@@ -5826,7 +5836,15 @@ function TablePage({ tableId, pageSize = 100, className }) {
5826
5836
  return /* @__PURE__ */ jsxs35("div", { className: cn36("flex min-h-0 gap-4", className), children: [
5827
5837
  /* @__PURE__ */ jsxs35("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [
5828
5838
  /* @__PURE__ */ jsxs35("div", { className: "flex flex-wrap items-center gap-1.5", children: [
5829
- /* @__PURE__ */ jsx38(ViewBar, { tableId, onActiveView: setView, className: "min-w-0 flex-1" }),
5839
+ /* @__PURE__ */ jsx38(
5840
+ ViewBar,
5841
+ {
5842
+ tableId,
5843
+ onActiveView: setView,
5844
+ seed: seedViews ?? [defaultView(tableId)],
5845
+ className: "min-w-0 flex-1"
5846
+ }
5847
+ ),
5830
5848
  rights.write ? /* @__PURE__ */ jsx38(Button31, { size: "sm", onClick: () => show("new-record"), children: "New record" }) : null,
5831
5849
  rights.admin ? /* @__PURE__ */ jsxs35(Fragment8, { children: [
5832
5850
  /* @__PURE__ */ jsx38(Button31, { size: "sm", variant: "outline", onClick: () => show("field"), children: "Add field" }),