@ai-matrx/records-ui 0.101.22 → 0.101.25

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
@@ -3921,7 +3921,7 @@ declare function useViewRecords(view: SavedViewSpec, pageSize?: number, filter?:
3921
3921
  */
3922
3922
  membership: string;
3923
3923
  };
3924
- declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
3924
+ declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize: pageSizeAsked, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
3925
3925
 
3926
3926
  type CalendarMode = "month" | "week" | "day" | "list";
3927
3927
  interface CalendarViewProps {
package/dist/index.d.ts CHANGED
@@ -3921,7 +3921,7 @@ declare function useViewRecords(view: SavedViewSpec, pageSize?: number, filter?:
3921
3921
  */
3922
3922
  membership: string;
3923
3923
  };
3924
- declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
3924
+ declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize: pageSizeAsked, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
3925
3925
 
3926
3926
  type CalendarMode = "month" | "week" | "day" | "list";
3927
3927
  interface CalendarViewProps {
package/dist/index.js CHANGED
@@ -3137,7 +3137,7 @@ function Chips({
3137
3137
 
3138
3138
  // src/presentation.ts
3139
3139
  import {
3140
- STYLE_COLORS as STYLE_COLORS2,
3140
+ COLOR_ROTATION,
3141
3141
  parseTableStyle,
3142
3142
  tableStyleIsEmpty
3143
3143
  } from "@ai-matrx/design-system/data-table";
@@ -3387,7 +3387,7 @@ var colorFromTheValue = (_fieldKey, value) => {
3387
3387
  for (let i = 0; i < text.length; i += 1) {
3388
3388
  hash = hash * 31 + text.charCodeAt(i) >>> 0;
3389
3389
  }
3390
- return STYLE_COLORS2[hash % STYLE_COLORS2.length];
3390
+ return COLOR_ROTATION[hash % COLOR_ROTATION.length];
3391
3391
  };
3392
3392
  function styleFromDecorations(decorations, fields) {
3393
3393
  if (!decorations) return { version: 1 };
@@ -6070,6 +6070,14 @@ function workedOutErrorFor(document2, key) {
6070
6070
  if (said && typeof said === "object" && typeof said.says === "string") return String(said.says).trim() || null;
6071
6071
  return null;
6072
6072
  }
6073
+ function cellMarkSentence(field2, document2, value) {
6074
+ if (value === null || value === void 0) {
6075
+ const failed = workedOutErrorFor(document2, field2.key);
6076
+ if (failed) return failed;
6077
+ }
6078
+ const kept = keptAsideFor(document2, field2.key);
6079
+ return kept ? keptAsideReason(field2, kept) : null;
6080
+ }
6073
6081
  var WORKED_OUT_ERROR_WORD = "#ERROR";
6074
6082
  function WorkedOutError({ field: field2, sentence: sentence2 }) {
6075
6083
  return /* @__PURE__ */ jsx25(
@@ -7014,6 +7022,7 @@ function GridCell({
7014
7022
  }
7015
7023
  if (wasActive.current && opensAsAList(field2, hostTakesFiles(ui))) openThisCell(event);
7016
7024
  };
7025
+ const cellMark = cellMarkSentence(field2, row.document, value);
7017
7026
  return (
7018
7027
  // BOTH MARKERS, ON PURPOSE. `data-matrx-cell-control` is the data table's
7019
7028
  // opt-out from whole-row click, so opening a cell never also opens the
@@ -7034,7 +7043,7 @@ function GridCell({
7034
7043
  {
7035
7044
  role: editable ? "button" : void 0,
7036
7045
  "aria-label": editable ? `Edit ${fieldName(field2)}` : void 0,
7037
- title: editable ? `${fieldName(field2)} \u2014 double-click or press Enter to edit` : fieldIsEditable(field2) ? (
7046
+ title: cellMark ? cellMark : editable ? `${fieldName(field2)} \u2014 double-click or press Enter to edit` : fieldIsEditable(field2) ? (
7038
7047
  // NOT A DEAD CONTROL AND NOT A SILENT ONE: the cell is plain
7039
7048
  // text, and hovering it says exactly why, in the level's own
7040
7049
  // words. The editor was never offered, so nothing is refused
@@ -12522,6 +12531,9 @@ function storedValueAgrees(field2, stored, written, options) {
12522
12531
  }
12523
12532
  return JSON.stringify(stored) === JSON.stringify(written);
12524
12533
  }
12534
+ function refusalsBeyondTheHeader(refusals, headerRowId) {
12535
+ return headerRowId === void 0 ? [...refusals] : refusals.filter((r) => r.rowId !== headerRowId);
12536
+ }
12525
12537
  function columnsTheGridTurnedAway(turnedAway, columnKeys, columnName, already) {
12526
12538
  const said = /* @__PURE__ */ new Map();
12527
12539
  for (const refused of turnedAway) {
@@ -15325,33 +15337,55 @@ function columnForField(field2, editing, mayWriteRow, whyNotRow, look, onAskWhoC
15325
15337
  ...{ title: fieldTypeLabel(field2) }
15326
15338
  };
15327
15339
  }
15328
- var TYPE_GLYPH = {
15329
- text: "Aa",
15330
- longtext: "\xB6",
15331
- number: "#",
15332
- currency: "$",
15333
- percent: "%",
15334
- date: "\u25A6",
15335
- datetime: "\u25A6",
15336
- checkbox: "\u2713",
15337
- select: "\u25BE",
15338
- multiselect: "\u25BE",
15339
- choice: "\u25BE",
15340
- relation: "\u2197",
15341
- entity_reference: "\u2197",
15342
- attachment: "\u2398",
15343
- email: "@",
15344
- url: "\u2197",
15345
- phone: "\u2706",
15346
- formula: "\u0192",
15347
- lookup: "\u0192",
15348
- rollup: "\u0192"
15340
+ var LINK2 = [["path", { d: "M7 7h10v10" }], ["path", { d: "M7 17 17 7" }]];
15341
+ var FORMULA = [["path", { d: "M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" }]];
15342
+ var TYPE_ICON = {
15343
+ text: [["path", { d: "M12 4v16" }], ["path", { d: "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" }], ["path", { d: "M9 20h6" }]],
15344
+ long_text: [["path", { d: "M21 5H3" }], ["path", { d: "M15 12H3" }], ["path", { d: "M17 19H3" }]],
15345
+ number: [["line", { x1: 4, x2: 20, y1: 9, y2: 9 }], ["line", { x1: 4, x2: 20, y1: 15, y2: 15 }], ["line", { x1: 10, x2: 8, y1: 3, y2: 21 }], ["line", { x1: 16, x2: 14, y1: 3, y2: 21 }]],
15346
+ currency: [["line", { x1: 12, x2: 12, y1: 2, y2: 22 }], ["path", { d: "M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" }]],
15347
+ percent: [["line", { x1: 19, x2: 5, y1: 5, y2: 19 }], ["circle", { cx: 6.5, cy: 6.5, r: 2.5 }], ["circle", { cx: 17.5, cy: 17.5, r: 2.5 }]],
15348
+ datetime: [["path", { d: "M8 2v3" }], ["path", { d: "M16 2v3" }], ["rect", { x: 3, y: 3, width: 18, height: 18, rx: 2 }], ["path", { d: "M3 9h18" }]],
15349
+ checkbox: [["rect", { width: 18, height: 18, x: 3, y: 3, rx: 2 }], ["path", { d: "m16 9-5.5 5.5L8 12" }]],
15350
+ select: [["circle", { cx: 12, cy: 12, r: 10 }], ["path", { d: "m16 10-4 4-4-4" }]],
15351
+ multi_select: [["path", { d: "M3 5h.01" }], ["path", { d: "M3 12h.01" }], ["path", { d: "M3 19h.01" }], ["path", { d: "M8 5h13" }], ["path", { d: "M8 12h13" }], ["path", { d: "M8 19h13" }]],
15352
+ member: [["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }], ["circle", { cx: 12, cy: 7, r: 4 }]],
15353
+ relation: LINK2,
15354
+ entity_reference: LINK2,
15355
+ attachment: [["path", { d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551" }]],
15356
+ email: [["path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" }], ["rect", { x: 2, y: 4, width: 20, height: 16, rx: 2 }]],
15357
+ url: [["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]],
15358
+ phone: [["path", { d: "M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" }]],
15359
+ formula: FORMULA,
15360
+ lookup: FORMULA,
15361
+ rollup: FORMULA,
15362
+ json: [["path", { d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" }], ["path", { d: "M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" }]]
15349
15363
  };
15350
15364
  function withTypeMark(field2, header) {
15351
- const kind = String(editorKindFor(field2));
15352
- const glyph = TYPE_GLYPH[kind] ?? "\xB7";
15353
- return /* @__PURE__ */ jsxs47("span", { className: "inline-flex min-w-0 items-center gap-1", "data-records-type-mark": kind, children: [
15354
- /* @__PURE__ */ jsx52("span", { "aria-hidden": "true", className: "shrink-0 text-[10px] font-normal text-muted-foreground", children: glyph }),
15365
+ const kind = editorKindFor(field2);
15366
+ const parts = TYPE_ICON[kind] ?? TYPE_ICON.text;
15367
+ return /* @__PURE__ */ jsxs47("span", { className: "inline-flex min-w-0 items-center gap-1.5", "data-records-type-mark": kind, children: [
15368
+ /* @__PURE__ */ jsx52(
15369
+ "svg",
15370
+ {
15371
+ xmlns: "http://www.w3.org/2000/svg",
15372
+ viewBox: "0 0 24 24",
15373
+ width: 14,
15374
+ height: 14,
15375
+ fill: "none",
15376
+ stroke: "currentColor",
15377
+ strokeWidth: 2,
15378
+ strokeLinecap: "round",
15379
+ strokeLinejoin: "round",
15380
+ "aria-hidden": "true",
15381
+ className: "shrink-0 text-muted-foreground",
15382
+ "data-records-type-icon": kind,
15383
+ children: parts.map(([tag, attrs], i) => {
15384
+ const El = tag;
15385
+ return /* @__PURE__ */ jsx52(El, { ...attrs }, i);
15386
+ })
15387
+ }
15388
+ ),
15355
15389
  header
15356
15390
  ] });
15357
15391
  }
@@ -21480,7 +21514,12 @@ function GridBody({
21480
21514
  ...headed ? { header: { unmatched: headed.unmatched } } : {}
21481
21515
  });
21482
21516
  built.refusals.push(
21483
- ...columnsTheGridTurnedAway(sheetPlan.refusals, columnKeys, (id) => columnLabel(fieldList, id), built.refusals)
21517
+ ...columnsTheGridTurnedAway(
21518
+ refusalsBeyondTheHeader(sheetPlan.refusals, headed ? touched[0] : void 0),
21519
+ columnKeys,
21520
+ (id) => columnLabel(fieldList, id),
21521
+ built.refusals
21522
+ )
21484
21523
  );
21485
21524
  if (merged && built.cells > 0 && built.creates === 0 && built.refusals.length === 0 && built.pastRightEdge === 0 && (built.header?.unmatched.length ?? 0) === 0 && built.unmatchedOptions.length === 0) {
21486
21525
  const outcome = await pasteAtOnce.current(built);
@@ -22377,7 +22416,7 @@ function GridBody({
22377
22416
  ) : null,
22378
22417
  viewId && viewOrder?.onPlaced && hasSeveralRows ? /* @__PURE__ */ jsx68(Button42, { size: "sm", variant: "ghost", onClick: () => setReordering(true), "data-records-reorder-open": "", children: "Reorder" }) : null,
22379
22418
  !readOnly && rights.structure && onAddField ? /* @__PURE__ */ jsx68(AddFieldButton, { onClick: onAddField }) : null,
22380
- /* @__PURE__ */ jsx68(
22419
+ embedded ? null : /* @__PURE__ */ jsx68(
22381
22420
  GridLayoutMenu,
22382
22421
  {
22383
22422
  look,
@@ -22514,7 +22553,8 @@ function GridBody({
22514
22553
  phoneSheetTools,
22515
22554
  sheetExtras,
22516
22555
  tableId,
22517
- noun
22556
+ noun,
22557
+ embedded
22518
22558
  ]
22519
22559
  );
22520
22560
  const labelOfField = useCallback25(
@@ -22721,6 +22761,7 @@ function GridBody({
22721
22761
  query: tableQuery,
22722
22762
  ...valueFacets ? { facets: valueFacets, filterUi: VALUE_FILTER_UI } : {},
22723
22763
  ...classicInCard ? { hidePagination: true } : {},
22764
+ ...embedded ? { appearance: "embedded" } : {},
22724
22765
  tableClassName: cn34(
22725
22766
  !look.wrap && "[&_tbody_td]:max-w-[28rem] [&_tbody_td]:overflow-hidden [&_tbody_td]:text-ellipsis [&_tbody_td]:whitespace-nowrap! [&_tbody_td_*]:whitespace-nowrap!",
22726
22767
  look.fit === "scroll" && "sm:[&>table]:w-max! sm:[&>table]:max-w-none! sm:[&>table]:min-w-full!"
@@ -23045,6 +23086,13 @@ function useEntitySource(token, options = {}) {
23045
23086
  );
23046
23087
  return { ...state, write, create, reload };
23047
23088
  }
23089
+ function entityValueText(column, v) {
23090
+ if (v === null || v === void 0 || v === "") return "";
23091
+ if (typeof v === "number") return v.toLocaleString();
23092
+ if (column.type !== "date" && column.type !== "datetime" && column.type !== "timestamp") return String(v);
23093
+ const kind = column.type === "date" ? "date" : "datetime";
23094
+ return dateText({ type: "range", config: { kind }, format: null }, v) ?? String(v);
23095
+ }
23048
23096
  var NAME_KEYS = ["name", "display_name", "title", "subject"];
23049
23097
  function entityNameColumn(columns) {
23050
23098
  for (const key of NAME_KEYS) {
@@ -23060,9 +23108,7 @@ function entityTableColumns(columns) {
23060
23108
  label: c.name,
23061
23109
  accessorFn: (row) => row[c.api_name] ?? null,
23062
23110
  cell: (row) => {
23063
- const v = row[c.api_name];
23064
- if (v === null || v === void 0 || v === "") return "";
23065
- return typeof v === "number" ? v.toLocaleString() : String(v);
23111
+ return entityValueText(c, row[c.api_name]);
23066
23112
  },
23067
23113
  sortable: !c.lookup,
23068
23114
  ...c.type === "choice" && c.choices ? { filter: "select", filterOptions: c.choices.map((w) => ({ value: w, label: w })) } : {}
@@ -31205,7 +31251,7 @@ function ViewSwitcher({
31205
31251
  onMoved,
31206
31252
  onNewRecordForm,
31207
31253
  onAskWhoChanged,
31208
- pageSize = 200,
31254
+ pageSize: pageSizeAsked,
31209
31255
  titleField = null,
31210
31256
  filter,
31211
31257
  onClearFilter,
@@ -31221,6 +31267,7 @@ function ViewSwitcher({
31221
31267
  newRowLabel,
31222
31268
  className
31223
31269
  }) {
31270
+ const pageSize = pageSizeAsked ?? (embedded ? 50 : 200);
31224
31271
  const toolbarSlot = useTableToolbarSlot();
31225
31272
  const [layout, setLayout] = useState89(view.layout);
31226
31273
  const hostLayouts = useRecordsUi().layouts ?? [];
@@ -31241,7 +31288,7 @@ function ViewSwitcher({
31241
31288
  onViewChange?.(patch);
31242
31289
  };
31243
31290
  return /* @__PURE__ */ jsxs94("div", { className: cn53("flex min-h-0 flex-col gap-2", footer === "sticky" && "flex-1", className), children: [
31244
- chooser ? /* @__PURE__ */ jsxs94("div", { className: "flex items-center gap-2", children: [
31291
+ chooser && !embedded ? /* @__PURE__ */ jsxs94("div", { className: "flex items-center gap-2", children: [
31245
31292
  /* @__PURE__ */ jsx105("span", { className: "truncate text-sm font-medium", children: view.name }),
31246
31293
  /* @__PURE__ */ jsxs94("div", { className: "ml-auto flex items-center gap-0.5", role: "group", "aria-label": "Layout", children: [
31247
31294
  VIEW_LAYOUTS.map((option) => /* @__PURE__ */ jsx105(
@@ -45915,7 +45962,7 @@ function TablePage({
45915
45962
  tableId,
45916
45963
  presentation: pagePresentation2 = "page",
45917
45964
  newRowLabel,
45918
- pageSize = 100,
45965
+ pageSize: pageSizeAsked,
45919
45966
  seedViews,
45920
45967
  onLeave,
45921
45968
  leaveLabel = "Back to your tables",
@@ -46007,6 +46054,7 @@ function TablePage({
46007
46054
  const face = tableOpening(view, hostLayouts.map((h) => h.id));
46008
46055
  const designated = face.kind === "designated";
46009
46056
  const embedded = pagePresentation2 === "embedded";
46057
+ const pageSize = pageSizeAsked ?? (embedded ? 50 : 100);
46010
46058
  const chooserInline = !embedded && !designated && !phone && toolbarFold2 < 2;
46011
46059
  const chooserCompact = !embedded && !designated && !phone && toolbarFold2 >= 2;
46012
46060
  const controlsInSheet = phone && !designated;
@@ -47009,7 +47057,7 @@ function EntityBoard({ entity, groupBy, cardFields, onOpenRecord, className }) {
47009
47057
  "data-records-entity-card": row.id,
47010
47058
  children: [
47011
47059
  onOpenRecord ? /* @__PURE__ */ jsx153("button", { type: "button", className: "truncate text-left font-medium hover:underline", onClick: () => onOpenRecord(row.id), children: shown3(title ? row[title.api_name] : row.id) || "Untitled" }) : /* @__PURE__ */ jsx153("span", { className: "truncate font-medium", children: shown3(title ? row[title.api_name] : row.id) || "Untitled" }),
47012
- extra.map((c) => shown3(row[c.api_name]) ? /* @__PURE__ */ jsx153("span", { className: "truncate text-muted-foreground", children: shown3(row[c.api_name]) }, c.api_name) : null)
47060
+ extra.map((c) => entityValueText(c, row[c.api_name]) ? /* @__PURE__ */ jsx153("span", { className: "truncate text-muted-foreground", children: entityValueText(c, row[c.api_name]) }, c.api_name) : null)
47013
47061
  ]
47014
47062
  },
47015
47063
  row.id