@ai-matrx/records-ui 0.116.16 → 0.116.17

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
@@ -173,7 +173,7 @@ import {
173
173
  withoutAddition,
174
174
  withoutLeadingBlank,
175
175
  workedOutErrorFor
176
- } from "./chunk-QVTYE4XU.js";
176
+ } from "./chunk-4GZVOFJJ.js";
177
177
  import {
178
178
  CHART_PLOT_PX,
179
179
  EMBEDDED_ROW_PX,
@@ -276,7 +276,7 @@ import {
276
276
  visibilityLaneFor,
277
277
  whyNotAskable,
278
278
  writeOnTheWinningVersion_exports
279
- } from "./chunk-YIGEIVU7.js";
279
+ } from "./chunk-U3ZEY6BB.js";
280
280
  import {
281
281
  ACTION_CHECKING_ACCESS_REASON,
282
282
  ACTION_NOT_HERE_REASON,
@@ -41300,6 +41300,17 @@ function sectionColumns(fields, titleField, props) {
41300
41300
  const values = props.valueFields ? props.valueFields.map((k) => live.find((f) => f.key === k)).filter((f) => f !== void 0 && f.key !== readsOn) : live.filter((f) => !taken.has(f.key));
41301
41301
  return { name, group, note, readsOn, values };
41302
41302
  }
41303
+ var NATURAL = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
41304
+ function orderedRows(rows, nameKey) {
41305
+ if (!nameKey) return [...rows];
41306
+ const nameOf = (r) => String((r.document ?? {})[nameKey] ?? "");
41307
+ return [...rows].sort((a, b) => {
41308
+ const x = nameOf(a);
41309
+ const y = nameOf(b);
41310
+ if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
41311
+ return NATURAL.compare(x, y);
41312
+ });
41313
+ }
41303
41314
  function sectionGroups(rows, groupKey) {
41304
41315
  if (!groupKey) return [{ key: UNGROUPED, rows: [...rows] }];
41305
41316
  const map = /* @__PURE__ */ new Map();
@@ -41598,7 +41609,9 @@ function SectionCard(props) {
41598
41609
  const { tableId, readOnly, noun = "entry", onFix, className } = props;
41599
41610
  const table = useTable37(tableId);
41600
41611
  const fieldsRead = useFields35(tableId);
41601
- const page = useRecordPage4(tableId, { pageSize: 200 });
41612
+ const tableSort = defaultSortOf(table.data ?? null, fieldsRead.data ?? []);
41613
+ const page = useRecordPage4(tableId, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
41614
+ const sortedByStore = tableSort !== null;
41602
41615
  const mutation = useRecordMutation3();
41603
41616
  const [adding, setAdding] = useState121(null);
41604
41617
  const [failed, setFailed] = useState121(null);
@@ -41609,7 +41622,7 @@ function SectionCard(props) {
41609
41622
  const noteField = cols.note ? fields.find((f) => f.key === cols.note) : void 0;
41610
41623
  const readsOnField = cols.readsOn ? fields.find((f) => f.key === cols.readsOn) : void 0;
41611
41624
  const columns = columnsOf(cols.values);
41612
- const rows = page.data?.rows ?? [];
41625
+ const rows = sortedByStore ? page.data?.rows ?? [] : orderedRows(page.data?.rows ?? [], cols.name);
41613
41626
  const groups = sectionGroups(rows, cols.group);
41614
41627
  const level = rows[0]?.level ?? null;
41615
41628
  const mayWrite = !readOnly && (rows.length === 0 ? !readOnly : atLeast(level, "edit_content"));