@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.js CHANGED
@@ -199,7 +199,7 @@ import {
199
199
  withoutLeadingBlank,
200
200
  workedOutErrorFor,
201
201
  workedOutHoldsNumbers
202
- } from "./chunk-VQDHNYJQ.js";
202
+ } from "./chunk-TZ2KUSHH.js";
203
203
  import {
204
204
  CHART_PLOT_PX,
205
205
  EMBEDDED_ROW_PX,
@@ -6751,6 +6751,27 @@ function WholeTextDialog({
6751
6751
  ] }) });
6752
6752
  }
6753
6753
 
6754
+ // src/systemFields.ts
6755
+ function isSystemField(field) {
6756
+ return field.config?.hidden === true;
6757
+ }
6758
+ function systemFieldKeys(fields) {
6759
+ return (fields ?? []).filter(isSystemField).map((f) => f.key);
6760
+ }
6761
+ function hiddenOrSystemDefault(saved, fields) {
6762
+ if (saved) return [...saved];
6763
+ const system = systemFieldKeys(fields);
6764
+ return system.length > 0 ? system : void 0;
6765
+ }
6766
+ function hiddenFieldsEntry(hidden, fields) {
6767
+ const kept = hiddenToWrite(hidden, fields);
6768
+ return kept ? { hiddenFields: kept } : {};
6769
+ }
6770
+ function hiddenToWrite(hidden, fields) {
6771
+ if (hidden.length > 0) return [...hidden];
6772
+ return systemFieldKeys(fields).length > 0 ? [] : void 0;
6773
+ }
6774
+
6754
6775
  // src/gridControls.tsx
6755
6776
  import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
6756
6777
  var VALUE_COUNTS_FRESH_MS = 1e4;
@@ -6842,8 +6863,8 @@ function useMergedGridControls(args) {
6842
6863
  }, [held, fieldKeys, keptOrder, frozenKeys]);
6843
6864
  const hidden = useMemo14(() => {
6844
6865
  const known = new Set(fieldKeys);
6845
- return (held?.hidden ?? keptHidden ?? []).filter((k) => known.has(k) || k.startsWith(REVERSE_COLUMN_PREFIX));
6846
- }, [held, keptHidden, fieldKeys]);
6866
+ return (held?.hidden ?? hiddenOrSystemDefault(keptHidden, fields) ?? []).filter((k) => known.has(k) || k.startsWith(REVERSE_COLUMN_PREFIX));
6867
+ }, [held, keptHidden, fieldKeys, fields]);
6847
6868
  const naturalOrder = useMemo14(
6848
6869
  () => [...fieldKeys.filter((k) => frozenKeys.has(k)), ...fieldKeys.filter((k) => !frozenKeys.has(k))],
6849
6870
  [fieldKeys, frozenKeys]
@@ -6856,10 +6877,10 @@ function useMergedGridControls(args) {
6856
6877
  writeLook({
6857
6878
  ...rest,
6858
6879
  ...moved ? { columnOrder: next.order } : {},
6859
- ...next.hidden.length > 0 ? { hiddenFields: next.hidden } : {}
6880
+ ...hiddenFieldsEntry(next.hidden, fields)
6860
6881
  });
6861
6882
  },
6862
- [presentation, writeLook, naturalOrder]
6883
+ [presentation, writeLook, naturalOrder, fields]
6863
6884
  );
6864
6885
  const pendingInsert = useRef9(null);
6865
6886
  useEffect19(() => {
@@ -8845,7 +8866,7 @@ function withTypeMark(field, header) {
8845
8866
  const stamp = stampMarkOf(field);
8846
8867
  const kind2 = stamp ?? editorKindFor(field);
8847
8868
  const parts = (stamp ? STAMP_ICON[stamp] : TYPE_ICON[editorKindFor(field)]) ?? TYPE_ICON.text;
8848
- return /* @__PURE__ */ jsxs24("span", { className: "inline-flex min-w-0 items-center gap-1.5", "data-records-type-mark": kind2, title: fieldHelpText(field), children: [
8869
+ return /* @__PURE__ */ jsxs24("span", { className: "flex min-w-0 max-w-full items-center gap-1.5", "data-records-type-mark": kind2, title: fieldHelpText(field) ?? (typeof header === "string" ? header : void 0), children: [
8849
8870
  /* @__PURE__ */ jsx26(
8850
8871
  "svg",
8851
8872
  {
@@ -8867,7 +8888,7 @@ function withTypeMark(field, header) {
8867
8888
  })
8868
8889
  }
8869
8890
  ),
8870
- header
8891
+ /* @__PURE__ */ jsx26("span", { "data-records-type-label": "", className: "min-w-0 truncate", children: header })
8871
8892
  ] });
8872
8893
  }
8873
8894
 
@@ -12947,7 +12968,7 @@ function GridBody({
12947
12968
  }),
12948
12969
  [host, tableId, table.data, fields.data]
12949
12970
  );
12950
- const hiddenKeys = presentation.hiddenFields;
12971
+ const hiddenKeys = hiddenOrSystemDefault(presentation.hiddenFields, fields.data);
12951
12972
  const shownKeys = useMemo27(
12952
12973
  () => hiddenKeys && hiddenKeys.length > 0 ? columnIds.filter((k) => !hiddenKeys.includes(k)) : columnIds,
12953
12974
  [columnIds, hiddenKeys]
@@ -13429,7 +13450,7 @@ function GridBody({
13429
13450
  // THE CLASSIC GRID OBEYS THE VIEW TOO (CHAIR-GRID-LINKS 07): with no merged controls the kept
13430
13451
  // `presentation.hiddenFields` / `columnOrder` still decide what is drawn.
13431
13452
  order: controls.columns?.order ?? localColumns?.order ?? (presentation.columnOrder?.length ? columnsInKeptOrder(columnIds, presentation.columnOrder) : columnIds),
13432
- hidden: controls.columns?.hidden ?? localColumns?.hidden ?? presentation.hiddenFields ?? [],
13453
+ hidden: controls.columns?.hidden ?? localColumns?.hidden ?? hiddenOrSystemDefault(presentation.hiddenFields, fields.data) ?? [],
13433
13454
  onChange: (drawn) => {
13434
13455
  const next = { order: fieldColumnIds(drawn.order, fields.data ?? []), hidden: fieldColumnIds(drawn.hidden, fields.data ?? []) };
13435
13456
  if (controls.columns) controls.columns.onChange(next);
@@ -20836,7 +20857,7 @@ function isEmptyOnCard(value) {
20836
20857
  return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
20837
20858
  }
20838
20859
  function cardFieldsShown(fields, hiddenFields, exclude) {
20839
- const hidden = new Set(hiddenFields ?? []);
20860
+ const hidden = new Set(hiddenOrSystemDefault(hiddenFields, fields) ?? []);
20840
20861
  const out = new Set(exclude.filter((k) => Boolean(k)));
20841
20862
  return fields.filter((field) => !hidden.has(field.key) && !out.has(field.key));
20842
20863
  }
@@ -20848,7 +20869,7 @@ function CardFieldsPicker({
20848
20869
  remembered,
20849
20870
  layout
20850
20871
  }) {
20851
- const hidden = new Set(hiddenFields ?? []);
20872
+ const hidden = new Set(hiddenOrSystemDefault(hiddenFields, fields) ?? []);
20852
20873
  return /* @__PURE__ */ jsxs73("details", { className: "text-xs text-muted-foreground", "data-records-card-fields": layout, children: [
20853
20874
  /* @__PURE__ */ jsx81("summary", { className: "cursor-pointer select-none", children: summary }),
20854
20875
  /* @__PURE__ */ jsx81("div", { className: "mt-1 flex flex-wrap gap-2", children: fields.map((field) => /* @__PURE__ */ jsxs73("label", { className: "flex items-center gap-1", children: [
@@ -25603,7 +25624,8 @@ function selfLinkFields(fields, tableId) {
25603
25624
  function orgCardFields(fields, hidden, exclude) {
25604
25625
  const skip = new Set(exclude.filter((k) => Boolean(k)));
25605
25626
  const usable = fields.filter((f) => !skip.has(f.key) && !["attachment", "button", "formula"].includes(String(f.type)));
25606
- const shown4 = hidden === void 0 ? usable : usable.filter((f) => !hidden.includes(f.key));
25627
+ const kept = hiddenOrSystemDefault(hidden, fields);
25628
+ const shown4 = kept === void 0 ? usable : usable.filter((f) => !kept.includes(f.key));
25607
25629
  return shown4.slice(0, 2);
25608
25630
  }
25609
25631
  function orgNotes(forest, total) {
@@ -27369,7 +27391,7 @@ function Gallery({
27369
27391
  onNew,
27370
27392
  newLabel
27371
27393
  }) {
27372
- const hidden = useMemo53(() => new Set(hiddenFields ?? []), [hiddenFields]);
27394
+ const hidden = useMemo53(() => new Set(hiddenOrSystemDefault(hiddenFields, fields) ?? []), [hiddenFields, fields]);
27373
27395
  const imageField = imageKey ? fields.find((field) => field.key === imageKey) : void 0;
27374
27396
  const shown4 = fields.filter((field) => !hidden.has(field.key) && field.key !== imageKey && field.key !== titleKey);
27375
27397
  const chose = hiddenFields !== void 0;
@@ -41553,6 +41575,7 @@ function TablePage({
41553
41575
  });
41554
41576
  }, [view, looks]);
41555
41577
  const hiddenNow = shown4?.presentation?.hiddenFields ?? [];
41578
+ const hiddenInList = hiddenOrSystemDefault(shown4?.presentation?.hiddenFields, allFields.data) ?? [];
41556
41579
  const hiddenSaved = view?.presentation?.hiddenFields ?? [];
41557
41580
  const hiddenDiffers = JSON.stringify(hiddenNow) !== JSON.stringify(hiddenSaved);
41558
41581
  const addressNow = {
@@ -42412,12 +42435,12 @@ function TablePage({
42412
42435
  tableId,
42413
42436
  archiveAsked,
42414
42437
  columns: view ? {
42415
- hidden: hiddenNow,
42438
+ hidden: hiddenInList,
42416
42439
  order: shown4?.presentation?.columnOrder ?? null,
42417
42440
  onChange: ({ hidden, order }) => {
42418
42441
  const { hiddenFields: _h, columnOrder: _o, ...rest } = shown4?.presentation ?? {};
42419
42442
  return patchView({
42420
- presentation: { ...rest, ...hidden.length > 0 ? { hiddenFields: hidden } : {}, ...order ? { columnOrder: order } : {} }
42443
+ presentation: { ...rest, ...hiddenFieldsEntry(hidden, allFields.data), ...order ? { columnOrder: order } : {} }
42421
42444
  });
42422
42445
  }
42423
42446
  } : void 0