@ai-matrx/records-ui 0.109.4 → 0.109.6

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
@@ -3698,7 +3698,7 @@ function ReferenceBuilder({
3698
3698
  ] }) }),
3699
3699
  target && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-0.5", children: [
3700
3700
  /* @__PURE__ */ jsx12(Label2, { className: "text-xs", children: "It will read" }),
3701
- preview.loading ? /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-muted-foreground", children: "Reading a few of its records\u2026" }) : (preview.data?.rows.length ?? 0) === 0 ? /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-muted-foreground", children: "That table has no records yet, so there is nothing to show here \u2014 this column will still work, and the first record added is the first thing it offers." }) : /* @__PURE__ */ jsx12("ul", { className: "flex flex-col gap-0.5", children: (preview.data?.rows ?? []).map((row) => /* @__PURE__ */ jsx12("li", { className: "truncate text-[11px] text-foreground", children: previewWords(
3701
+ preview.loading ? /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-muted-foreground", children: "Reading a few of its records\u2026" }) : (preview.data?.rows?.length ?? 0) === 0 ? /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-muted-foreground", children: "That table has no records yet, so there is nothing to show here \u2014 this column will still work, and the first record added is the first thing it offers." }) : /* @__PURE__ */ jsx12("ul", { className: "flex flex-col gap-0.5", children: (preview.data?.rows ?? []).map((row) => /* @__PURE__ */ jsx12("li", { className: "truncate text-[11px] text-foreground", children: previewWords(
3702
3702
  row.document,
3703
3703
  display,
3704
3704
  titleField
@@ -21897,7 +21897,7 @@ function useRowFollowsItsMove(args) {
21897
21897
  const lastIds = useRef34(args.rowIds);
21898
21898
  const frame = useRef34(0);
21899
21899
  useEffect49(() => () => cancelAnimationFrame(frame.current), []);
21900
- const noteWrite = useCallback25((rowId) => {
21900
+ const noteWrite = useCallback25((rowId, key) => {
21901
21901
  const box = latest.current.box.current;
21902
21902
  if (!box) return;
21903
21903
  const el = rowEl(box, rowId);
@@ -21906,7 +21906,7 @@ function useRowFollowsItsMove(args) {
21906
21906
  held.current = null;
21907
21907
  return;
21908
21908
  }
21909
- held.current = { rowId, top: el.getBoundingClientRect().top, index, at: Date.now() };
21909
+ held.current = { rowId, key, top: el.getBoundingClientRect().top, index, at: Date.now() };
21910
21910
  }, []);
21911
21911
  useLayoutEffect5(() => {
21912
21912
  if (args.rowIds === lastIds.current) return;
@@ -21926,6 +21926,7 @@ function useRowFollowsItsMove(args) {
21926
21926
  }
21927
21927
  if (index === pending.index) return;
21928
21928
  held.current = null;
21929
+ latest.current.onMoved?.(pending.rowId, pending.key);
21929
21930
  const el = rowEl(box, pending.rowId);
21930
21931
  if (!el) {
21931
21932
  bringIntoView(box, pending.rowId, index, args.rowIds);
@@ -22945,6 +22946,9 @@ function GridBody({
22945
22946
  const openingKey = openingSort ? `${openingSort.id}:${openingSort.direction}` : "none";
22946
22947
  const address = useViewAddress();
22947
22948
  const addressSeed = useRef37(address?.initial ?? null);
22949
+ const addressSort = useRef37(
22950
+ address?.initial?.sort ? { id: address.initial.sort.field, direction: address.initial.sort.direction } : null
22951
+ );
22948
22952
  const [query, setQuery] = useState61(() => ({
22949
22953
  page: addressSeed.current?.page ?? 1,
22950
22954
  pageSize,
@@ -22959,11 +22963,15 @@ function GridBody({
22959
22963
  if (seed && fields.data) addressSeed.current = null;
22960
22964
  setQuery((held) => ({
22961
22965
  ...held,
22962
- sort: seed?.sort ? { id: seed.sort.field, direction: seed.sort.direction } : openingSort,
22966
+ sort: addressSort.current ?? openingSort,
22963
22967
  page: seed?.page ?? 1
22964
22968
  }));
22965
22969
  setSeatedOn(openingKey);
22966
22970
  }, [openingKey]);
22971
+ useEffect52(() => {
22972
+ const held = addressSort.current;
22973
+ if (held && (query.sort?.id !== held.id || query.sort?.direction !== held.direction)) addressSort.current = null;
22974
+ }, [query.sort]);
22967
22975
  const columnSort = query.sort;
22968
22976
  const overrideKey = sortOverride ? `${sortOverride.field}:${sortOverride.direction}` : "";
22969
22977
  const overrideSeen = useRef37(overrideKey);
@@ -23006,6 +23014,7 @@ function GridBody({
23006
23014
  if (resetSeen.current === resetEpoch) return;
23007
23015
  resetSeen.current = resetEpoch;
23008
23016
  addressSeed.current = null;
23017
+ addressSort.current = null;
23009
23018
  setQuery((held) => ({ ...held, sort: openingSort, search: "", anyOf: "", columnFilters: {}, page: 1 }));
23010
23019
  }, [resetEpoch]);
23011
23020
  const [page, setPage] = useState61(0);
@@ -23137,6 +23146,7 @@ function GridBody({
23137
23146
  const canWrite = Boolean(editable) && (rights.write || askPerRow && rowIds.some(mayWriteRow));
23138
23147
  const readOnly = !editable || Boolean(host.rights) && !rights.write && !rights.structure;
23139
23148
  const gridBox = useRef37(null);
23149
+ const lastExit = useRef37(null);
23140
23150
  const pushWritten = useRef37(null);
23141
23151
  const sheetController = useRef37(null);
23142
23152
  const versions = useRecordVersions(client, rows);
@@ -23157,7 +23167,10 @@ function GridBody({
23157
23167
  * Enter or Cmd-Z works without a click. Sheets and Airtable.
23158
23168
  */
23159
23169
  ...merged ? {
23160
- onEnded: (exit, from, how) => sheetController.current?.endEdit(exit, { rowId: from.rowId, columnId: from.key }, how)
23170
+ onEnded: (exit, from, how) => {
23171
+ lastExit.current = { rowId: from.rowId, key: from.key, exit };
23172
+ sheetController.current?.endEdit(exit, { rowId: from.rowId, columnId: from.key }, how);
23173
+ }
23161
23174
  } : {}
23162
23175
  });
23163
23176
  const editingNow = useRef37(editing);
@@ -23185,7 +23198,15 @@ function GridBody({
23185
23198
  sort: sortedField ? { key: sortedField.key, name: fieldName(sortedField) } : null,
23186
23199
  say: (line) => undo.say(line, false, true)
23187
23200
  });
23188
- const rowMove = useRowFollowsItsMove({ box: gridBox, rowIds });
23201
+ const rowMove = useRowFollowsItsMove({
23202
+ box: gridBox,
23203
+ rowIds,
23204
+ onMoved: (rowId, key) => {
23205
+ const exit = lastExit.current;
23206
+ if (!exit || exit.rowId !== rowId || exit.key !== key) return;
23207
+ if (exit.exit === "down" || exit.exit === "stay") sheetController.current?.select({ rowId, columnId: key });
23208
+ }
23209
+ });
23189
23210
  pushWritten.current = (write) => {
23190
23211
  const field2 = (fields.data ?? []).find((f) => f.key === write.key);
23191
23212
  const name = changedRecordName(table.data, rows.find((r) => r.id === write.rowId)?.document ?? {}, write.key, write.after);
@@ -23193,7 +23214,7 @@ function GridBody({
23193
23214
  label: `Changed ${field2 ? fieldName(field2) : humanizeIdentifier10(write.key)} on ${name}`,
23194
23215
  cells: [{ rowId: write.rowId, key: write.key, before: write.before ?? null, after: write.after ?? null, version: write.version }]
23195
23216
  });
23196
- rowMove.noteWrite(write.rowId);
23217
+ rowMove.noteWrite(write.rowId, write.key);
23197
23218
  noteWriteForView(write, name);
23198
23219
  };
23199
23220
  const storeLayout = useStoreGridLayout(tableId);
@@ -24615,7 +24636,7 @@ function GridBody({
24615
24636
  }
24616
24637
  ) : null,
24617
24638
  question.refused.length > 0 ? /* @__PURE__ */ jsx72("p", { role: "status", "data-records-filter-refused": "", className: "text-xs text-muted-foreground", children: question.refused.join(" ") }) : null,
24618
- storePaged && (serverRead.data?.sortIgnored.length ?? 0) > 0 ? /* @__PURE__ */ jsx72("p", { role: "status", "data-records-sort-ignored": serverRead.data?.sortIgnored.join(" "), className: "text-xs text-muted-foreground", children: "Sort skipped: column not available" }) : null,
24639
+ storePaged && sortIgnoredOf(serverRead.data).length > 0 ? /* @__PURE__ */ jsx72("p", { role: "status", "data-records-sort-ignored": sortIgnoredOf(serverRead.data).join(" "), className: "text-xs text-muted-foreground", children: "Sort skipped: column not available" }) : null,
24619
24640
  runner.outcome && !(merged && runner.outcome.kind === "ran" && runner.outcome.undo !== null) ? /* @__PURE__ */ jsx72(ActionOutcomeNotice, { outcome: runner.outcome, onUndo: () => void runner.undo(), onDismiss: runner.dismiss }) : null,
24620
24641
  duplicated ? /* @__PURE__ */ jsxs65("p", { role: "status", "data-records-duplicated": "", className: "flex items-center gap-2 rounded border border-border bg-muted/40 px-2 py-1 text-xs", children: [
24621
24642
  /* @__PURE__ */ jsx72("span", { children: duplicated }),
@@ -25017,6 +25038,9 @@ function withoutGoneColumns(query, liveKeys, openingSort) {
25017
25038
  const fallback = openingSort && liveKeys.has(openingSort.id) ? openingSort : null;
25018
25039
  return { ...query, sort: sortGone ? fallback : query.sort, columnFilters, page: 1 };
25019
25040
  }
25041
+ function sortIgnoredOf(answer) {
25042
+ return Array.isArray(answer?.sortIgnored) ? answer.sortIgnored : [];
25043
+ }
25020
25044
 
25021
25045
  // src/RecordsTableCard.tsx
25022
25046
  import { MatrxTableCard, MatrxTableCardEmpty, MatrxTableCardShowMore as MatrxTableCardShowMore2, TABLE_CARD_DEFAULT_INITIAL_ROWS } from "@ai-matrx/design-system/data-table";
@@ -26474,7 +26498,7 @@ function columnFromName(label) {
26474
26498
  if (has(/\b(type|category|kind|tier|plan|platform|channel|source|level)\b/)) return { label, type: "select" };
26475
26499
  if (has(/\b(time|at|scheduled|starts|ends|appointment)\b/) && !has(/\b(date|day)\b/)) return { label, type: "datetime" };
26476
26500
  if (has(/\b(date|day|birthday|deadline|due|dob|born|joined|since|until|start|end|published|posted)\b/)) return { label, type: "date" };
26477
- if (has(/\b(price|cost|amount|revenue|budget|fee|fees|salary|paid|invoice|total|spend|value|rate card|mrr|arr)\b|\$/)) return { label, type: "currency" };
26501
+ if (has(/\b(price|cost|amount|revenue|budget|fee|fees|salary|paid|total|spend|value|rate card|mrr|arr)\b|\$/)) return { label, type: "currency" };
26478
26502
  if (has(/%|\b(percent|percentage|rate|ratio|margin|completion)\b/)) return { label, type: "percent" };
26479
26503
  if (has(/\b(count|qty|quantity|number of|age|score|hours|minutes|units|followers|views|likes|stars|rating|points|#)\b|^#|^no\.? /)) return { label, type: "number" };
26480
26504
  if (has(/\b(done|completed|approved|active|signed|confirmed)\b/)) return { label, type: "checkbox" };