@ai-matrx/records-ui 0.116.102 → 0.116.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -26915,10 +26915,11 @@ var import_field_formats15 = require("@ai-matrx/design-system/field-formats");
26915
26915
  var import_jsx_runtime84 = require("react/jsx-runtime");
26916
26916
  var SHARED_FOR_MS = 5e3;
26917
26917
  var sharedReads = /* @__PURE__ */ new WeakMap();
26918
+ var KEPT_OUT_OF_LISTS = /* @__PURE__ */ new Set(["agent_output", "copying"]);
26918
26919
  function readTablesAnywhere(dataSource) {
26919
26920
  const held = sharedReads.get(dataSource);
26920
26921
  if (held && Date.now() - held.at < SHARED_FOR_MS) return held.read;
26921
- const read = Promise.resolve(dataSource.rpc("data_home_tables", {}, { schema: "custom" })).then(
26922
+ const read = Promise.resolve(dataSource.rpc("data_home", { p_include_platform_tables: true }, { schema: "custom" })).then(
26922
26923
  ({ data, error }) => {
26923
26924
  if (error) {
26924
26925
  return {
@@ -26927,7 +26928,8 @@ function readTablesAnywhere(dataSource) {
26927
26928
  rows: []
26928
26929
  };
26929
26930
  }
26930
- const rows = (Array.isArray(data) ? data : []).slice();
26931
+ const answered = data && typeof data === "object" && !Array.isArray(data) ? data.tables : null;
26932
+ const rows = (Array.isArray(answered) ? answered : []).filter((t) => !KEPT_OUT_OF_LISTS.has(t.kind ?? ""));
26931
26933
  rows.sort((a, b) => a.table_name.localeCompare(b.table_name));
26932
26934
  return { loading: false, error: null, rows };
26933
26935
  },
@@ -29892,6 +29894,29 @@ init_parity();
29892
29894
  init_pasteValues();
29893
29895
  init_host();
29894
29896
  init_plainWords();
29897
+
29898
+ // src/systemFields.ts
29899
+ function isSystemField(field2) {
29900
+ return field2.config?.hidden === true;
29901
+ }
29902
+ function systemFieldKeys(fields) {
29903
+ return (fields ?? []).filter(isSystemField).map((f) => f.key);
29904
+ }
29905
+ function hiddenOrSystemDefault(saved, fields) {
29906
+ if (saved) return [...saved];
29907
+ const system = systemFieldKeys(fields);
29908
+ return system.length > 0 ? system : void 0;
29909
+ }
29910
+ function hiddenFieldsEntry(hidden, fields) {
29911
+ const kept2 = hiddenToWrite(hidden, fields);
29912
+ return kept2 ? { hiddenFields: kept2 } : {};
29913
+ }
29914
+ function hiddenToWrite(hidden, fields) {
29915
+ if (hidden.length > 0) return [...hidden];
29916
+ return systemFieldKeys(fields).length > 0 ? [] : void 0;
29917
+ }
29918
+
29919
+ // src/gridControls.tsx
29895
29920
  init_readRefusals();
29896
29921
  var import_jsx_runtime99 = require("react/jsx-runtime");
29897
29922
  var VALUE_COUNTS_FRESH_MS = 1e4;
@@ -29983,8 +30008,8 @@ function useMergedGridControls(args) {
29983
30008
  }, [held, fieldKeys, keptOrder, frozenKeys]);
29984
30009
  const hidden = (0, import_react158.useMemo)(() => {
29985
30010
  const known = new Set(fieldKeys);
29986
- return (held?.hidden ?? keptHidden ?? []).filter((k) => known.has(k) || k.startsWith(REVERSE_COLUMN_PREFIX));
29987
- }, [held, keptHidden, fieldKeys]);
30011
+ return (held?.hidden ?? hiddenOrSystemDefault(keptHidden, fields) ?? []).filter((k) => known.has(k) || k.startsWith(REVERSE_COLUMN_PREFIX));
30012
+ }, [held, keptHidden, fieldKeys, fields]);
29988
30013
  const naturalOrder = (0, import_react158.useMemo)(
29989
30014
  () => [...fieldKeys.filter((k) => frozenKeys.has(k)), ...fieldKeys.filter((k) => !frozenKeys.has(k))],
29990
30015
  [fieldKeys, frozenKeys]
@@ -29997,10 +30022,10 @@ function useMergedGridControls(args) {
29997
30022
  writeLook({
29998
30023
  ...rest,
29999
30024
  ...moved ? { columnOrder: next.order } : {},
30000
- ...next.hidden.length > 0 ? { hiddenFields: next.hidden } : {}
30025
+ ...hiddenFieldsEntry(next.hidden, fields)
30001
30026
  });
30002
30027
  },
30003
- [presentation, writeLook, naturalOrder]
30028
+ [presentation, writeLook, naturalOrder, fields]
30004
30029
  );
30005
30030
  const pendingInsert = (0, import_react158.useRef)(null);
30006
30031
  (0, import_react158.useEffect)(() => {
@@ -31977,7 +32002,7 @@ function withTypeMark(field2, header) {
31977
32002
  const stamp = stampMarkOf(field2);
31978
32003
  const kind2 = stamp ?? editorKindFor(field2);
31979
32004
  const parts = (stamp ? STAMP_ICON[stamp] : TYPE_ICON[editorKindFor(field2)]) ?? TYPE_ICON.text;
31980
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("span", { className: "inline-flex min-w-0 items-center gap-1.5", "data-records-type-mark": kind2, title: fieldHelpText(field2), children: [
32005
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("span", { className: "flex min-w-0 max-w-full items-center gap-1.5", "data-records-type-mark": kind2, title: fieldHelpText(field2) ?? (typeof header === "string" ? header : void 0), children: [
31981
32006
  /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
31982
32007
  "svg",
31983
32008
  {
@@ -31999,7 +32024,7 @@ function withTypeMark(field2, header) {
31999
32024
  })
32000
32025
  }
32001
32026
  ),
32002
- header
32027
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { "data-records-type-label": "", className: "min-w-0 truncate", children: header })
32003
32028
  ] });
32004
32029
  }
32005
32030
 
@@ -36056,7 +36081,7 @@ function GridBody({
36056
36081
  }),
36057
36082
  [host, tableId, table.data, fields.data]
36058
36083
  );
36059
- const hiddenKeys = presentation.hiddenFields;
36084
+ const hiddenKeys = hiddenOrSystemDefault(presentation.hiddenFields, fields.data);
36060
36085
  const shownKeys = (0, import_react197.useMemo)(
36061
36086
  () => hiddenKeys && hiddenKeys.length > 0 ? columnIds.filter((k) => !hiddenKeys.includes(k)) : columnIds,
36062
36087
  [columnIds, hiddenKeys]
@@ -36538,7 +36563,7 @@ function GridBody({
36538
36563
  // THE CLASSIC GRID OBEYS THE VIEW TOO (CHAIR-GRID-LINKS 07): with no merged controls the kept
36539
36564
  // `presentation.hiddenFields` / `columnOrder` still decide what is drawn.
36540
36565
  order: controls.columns?.order ?? localColumns?.order ?? (presentation.columnOrder?.length ? columnsInKeptOrder(columnIds, presentation.columnOrder) : columnIds),
36541
- hidden: controls.columns?.hidden ?? localColumns?.hidden ?? presentation.hiddenFields ?? [],
36566
+ hidden: controls.columns?.hidden ?? localColumns?.hidden ?? hiddenOrSystemDefault(presentation.hiddenFields, fields.data) ?? [],
36542
36567
  onChange: (drawn) => {
36543
36568
  const next = { order: fieldColumnIds(drawn.order, fields.data ?? []), hidden: fieldColumnIds(drawn.hidden, fields.data ?? []) };
36544
36569
  if (controls.columns) controls.columns.onChange(next);
@@ -43990,7 +44015,7 @@ function isEmptyOnCard(value) {
43990
44015
  return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
43991
44016
  }
43992
44017
  function cardFieldsShown(fields, hiddenFields, exclude) {
43993
- const hidden = new Set(hiddenFields ?? []);
44018
+ const hidden = new Set(hiddenOrSystemDefault(hiddenFields, fields) ?? []);
43994
44019
  const out = new Set(exclude.filter((k) => Boolean(k)));
43995
44020
  return fields.filter((field2) => !hidden.has(field2.key) && !out.has(field2.key));
43996
44021
  }
@@ -44002,7 +44027,7 @@ function CardFieldsPicker({
44002
44027
  remembered,
44003
44028
  layout
44004
44029
  }) {
44005
- const hidden = new Set(hiddenFields ?? []);
44030
+ const hidden = new Set(hiddenOrSystemDefault(hiddenFields, fields) ?? []);
44006
44031
  return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("details", { className: "text-xs text-muted-foreground", "data-records-card-fields": layout, children: [
44007
44032
  /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("summary", { className: "cursor-pointer select-none", children: summary }),
44008
44033
  /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "mt-1 flex flex-wrap gap-2", children: fields.map((field2) => /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("label", { className: "flex items-center gap-1", children: [
@@ -48766,7 +48791,8 @@ function selfLinkFields(fields, tableId) {
48766
48791
  function orgCardFields(fields, hidden, exclude) {
48767
48792
  const skip = new Set(exclude.filter((k) => Boolean(k)));
48768
48793
  const usable = fields.filter((f) => !skip.has(f.key) && !["attachment", "button", "formula"].includes(String(f.type)));
48769
- const shown5 = hidden === void 0 ? usable : usable.filter((f) => !hidden.includes(f.key));
48794
+ const kept2 = hiddenOrSystemDefault(hidden, fields);
48795
+ const shown5 = kept2 === void 0 ? usable : usable.filter((f) => !kept2.includes(f.key));
48770
48796
  return shown5.slice(0, 2);
48771
48797
  }
48772
48798
  function orgNotes(forest, total) {
@@ -50535,7 +50561,7 @@ function Gallery({
50535
50561
  onNew,
50536
50562
  newLabel
50537
50563
  }) {
50538
- const hidden = (0, import_react299.useMemo)(() => new Set(hiddenFields ?? []), [hiddenFields]);
50564
+ const hidden = (0, import_react299.useMemo)(() => new Set(hiddenOrSystemDefault(hiddenFields, fields) ?? []), [hiddenFields, fields]);
50539
50565
  const imageField = imageKey ? fields.find((field2) => field2.key === imageKey) : void 0;
50540
50566
  const shown5 = fields.filter((field2) => !hidden.has(field2.key) && field2.key !== imageKey && field2.key !== titleKey);
50541
50567
  const chose = hiddenFields !== void 0;
@@ -64778,6 +64804,7 @@ function TablePage({
64778
64804
  });
64779
64805
  }, [view, looks]);
64780
64806
  const hiddenNow = shown5?.presentation?.hiddenFields ?? [];
64807
+ const hiddenInList = hiddenOrSystemDefault(shown5?.presentation?.hiddenFields, allFields.data) ?? [];
64781
64808
  const hiddenSaved = view?.presentation?.hiddenFields ?? [];
64782
64809
  const hiddenDiffers = JSON.stringify(hiddenNow) !== JSON.stringify(hiddenSaved);
64783
64810
  const addressNow = {
@@ -65637,12 +65664,12 @@ function TablePage({
65637
65664
  tableId,
65638
65665
  archiveAsked,
65639
65666
  columns: view ? {
65640
- hidden: hiddenNow,
65667
+ hidden: hiddenInList,
65641
65668
  order: shown5?.presentation?.columnOrder ?? null,
65642
65669
  onChange: ({ hidden, order }) => {
65643
65670
  const { hiddenFields: _h, columnOrder: _o, ...rest } = shown5?.presentation ?? {};
65644
65671
  return patchView({
65645
- presentation: { ...rest, ...hidden.length > 0 ? { hiddenFields: hidden } : {}, ...order ? { columnOrder: order } : {} }
65672
+ presentation: { ...rest, ...hiddenFieldsEntry(hidden, allFields.data), ...order ? { columnOrder: order } : {} }
65646
65673
  });
65647
65674
  }
65648
65675
  } : void 0