@ai-matrx/records-ui 0.116.9 → 0.116.11

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
@@ -2462,7 +2462,9 @@ function OpenCell({
2462
2462
  // A one-line control sits centred on the row; a multi-line box hangs from the cell's top and
2463
2463
  // grows downward over the rows below (Airtable's expanded long-text cell), never up over the
2464
2464
  // header (D10: centred, its first lines sat 58px above the cell, outside it).
2465
- multiline ? "top-0 rounded-md bg-card shadow-md" : "top-1/2 -translate-y-1/2",
2465
+ // …and its words wrap: the one-line frame sets `white-space: nowrap` on every descendant, so the
2466
+ // textarea scrolled sideways on one line (live, after the clip was lifted).
2467
+ multiline ? "top-0 rounded-md bg-card shadow-md [&_textarea]:![white-space:pre-wrap] [&_textarea]:![overflow-wrap:anywhere]" : "top-1/2 -translate-y-1/2",
2466
2468
  // A box reaching over the next column is opaque, so what it covers never shows through it
2467
2469
  // (the calendar button sat over the Actions cell's copy icon, both drawn).
2468
2470
  widens && "rounded-md bg-card shadow-sm",
@@ -13808,7 +13810,8 @@ function GridBody({
13808
13810
  ...classicInCard || embeddedMore || loadAll.rows ? { hidePagination: true } : {},
13809
13811
  ...embedded ? { appearance: "embedded" } : {},
13810
13812
  tableClassName: cn13(
13811
- !look.wrap && lines === 1 && "[&_tbody_td]:max-w-[28rem] [&_tbody_td]:overflow-hidden [&_tbody_td]:text-ellipsis [&_tbody_td]:whitespace-nowrap! [&_tbody_td_*]:whitespace-nowrap!",
13813
+ !look.wrap && lines === 1 && "[&_tbody_td]:max-w-[28rem] [&_tbody_td]:overflow-hidden [&_tbody_td]:text-ellipsis [&_tbody_td]:whitespace-nowrap! [&_tbody_td_*:not(textarea)]:whitespace-nowrap!",
13814
+ // (A textarea is only ever an OPEN long-text editor, whose words must wrap — records walk D10.)
13812
13815
  embedded && EMBEDDED_TABLE_CLASS,
13813
13816
  embedded && !calculationChosen && EMBEDDED_PLAIN_FOOTER_CLASS
13814
13817
  ),
@@ -20214,7 +20217,7 @@ function structuredWordsFor(field, value) {
20214
20217
  }
20215
20218
 
20216
20219
  // src/CalendarView.tsx
20217
- import { useEffect as useEffect58, useMemo as useMemo43, useRef as useRef31, useState as useState66 } from "react";
20220
+ import { useEffect as useEffect58, useLayoutEffect as useLayoutEffect3, useMemo as useMemo43, useRef as useRef31, useState as useState66 } from "react";
20218
20221
  import { mayDrag as mayDrag2 } from "@ai-matrx/records/react";
20219
20222
  import { Button as Button55, Select as Select5, SelectContent as SelectContent3, SelectItem as SelectItem3, SelectTrigger as SelectTrigger3, SelectValue as SelectValue3, cn as cn30 } from "@ai-matrx/design-system";
20220
20223
  import { CHOICE_CHIP_CLASS } from "@ai-matrx/design-system/data-table";
@@ -20487,6 +20490,25 @@ function useNarrow() {
20487
20490
  }, []);
20488
20491
  return narrow;
20489
20492
  }
20493
+ var READABLE_CELL_PX = 72;
20494
+ function useGridWidth(grid, mode) {
20495
+ const [width, setWidth] = useState66(null);
20496
+ const useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect58 : useLayoutEffect3;
20497
+ useIsoLayoutEffect2(() => {
20498
+ const el = grid.current;
20499
+ if (!el) {
20500
+ setWidth(null);
20501
+ return;
20502
+ }
20503
+ const read = () => setWidth(el.clientWidth);
20504
+ read();
20505
+ if (typeof ResizeObserver === "undefined") return;
20506
+ const watcher = new ResizeObserver(read);
20507
+ watcher.observe(el);
20508
+ return () => watcher.disconnect();
20509
+ }, [grid, mode]);
20510
+ return width;
20511
+ }
20490
20512
  function byTime(a, b) {
20491
20513
  const allDayOn = (p) => !p.at || p.lastDay > p.firstDay;
20492
20514
  return Number(!allDayOn(a)) - Number(!allDayOn(b)) || (a.at && b.at && !allDayOn(a) && !allDayOn(b) ? a.at.getTime() - b.at.getTime() : 0) || a.firstDay.localeCompare(b.firstDay);
@@ -20579,6 +20601,11 @@ function CalendarView({
20579
20601
  const titleOf = (row) => cardWords(row, titleField, labels).text;
20580
20602
  const rowById = (id) => rows.find((r) => r.id === id);
20581
20603
  const frame = useRef31(null);
20604
+ const grid = useRef31(null);
20605
+ const gridWidth = useGridWidth(grid, mode);
20606
+ const cellColumns = mode === "month" ? 7 : mode === "week" ? 7 : 1;
20607
+ const cellReserve = mode === "month" ? 0 : 44;
20608
+ const tightCells = (mode === "month" || mode === "week") && gridWidth !== null && gridWidth > 0 && (gridWidth - cellReserve) / cellColumns < READABLE_CELL_PX;
20582
20609
  const [focusOn, setFocusOn] = useState66(null);
20583
20610
  useEffect58(() => {
20584
20611
  if (!focusOn) return;
@@ -20799,7 +20826,7 @@ function CalendarView({
20799
20826
  window.addEventListener("pointermove", onMove);
20800
20827
  window.addEventListener("pointerup", onUp);
20801
20828
  };
20802
- const cardFace = (row, extra, className2) => {
20829
+ const cardFace = (row, extra, className2, compact = false) => {
20803
20830
  const may = canMove(row);
20804
20831
  const lockWords = mayDrag2(row.level) ? WORKED_OUT_DATE_LOCK : "View only";
20805
20832
  const color = colorOf(row);
@@ -20813,17 +20840,19 @@ function CalendarView({
20813
20840
  // The chip palette, not the faint row tint: a calendar is read by its colours at a glance.
20814
20841
  color ? CHOICE_CHIP_CLASS[color] : "bg-background",
20815
20842
  may ? "cursor-grab active:cursor-grabbing" : "cursor-default",
20843
+ compact ? "min-h-3 px-0" : "",
20816
20844
  className2
20817
20845
  ),
20818
20846
  onClick: () => onOpenRecord?.(row.id),
20847
+ ...compact ? { "aria-label": title, "data-calendar-compact": "" } : {},
20819
20848
  title: may ? `${title} \xB7 drag to another day, or Alt + arrow keys` : `${title} \xB7 ${lockWords}`,
20820
20849
  ...color ? { "data-calendar-color": color } : {},
20821
20850
  ...may ? { "aria-keyshortcuts": "Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown" } : { "data-calendar-locked": "" },
20822
20851
  children: [
20823
- may ? null : /* @__PURE__ */ jsx72("span", { title: lockWords, "aria-label": lockWords, className: "inline-flex", ...mayDrag2(row.level) ? { "data-calendar-worked-out": "" } : {}, children: /* @__PURE__ */ jsx72(LockIcon, {}) }),
20824
- extra,
20825
- /* @__PURE__ */ jsx72("span", { className: "min-w-0 max-w-full shrink-0 truncate", "data-calendar-card-title": "", children: title }),
20826
- /* @__PURE__ */ jsx72(CardFieldsInline, { row, fields: cardFields })
20852
+ compact ? null : may ? null : /* @__PURE__ */ jsx72("span", { title: lockWords, "aria-label": lockWords, className: "inline-flex", ...mayDrag2(row.level) ? { "data-calendar-worked-out": "" } : {}, children: /* @__PURE__ */ jsx72(LockIcon, {}) }),
20853
+ compact ? null : extra,
20854
+ compact ? null : /* @__PURE__ */ jsx72("span", { className: "min-w-0 max-w-full shrink-0 truncate", "data-calendar-card-title": "", children: title }),
20855
+ compact ? null : /* @__PURE__ */ jsx72(CardFieldsInline, { row, fields: cardFields })
20827
20856
  ]
20828
20857
  }
20829
20858
  );
@@ -20833,8 +20862,8 @@ function CalendarView({
20833
20862
  const words2 = timeOfDayWords(startOf(row));
20834
20863
  return words2 ? /* @__PURE__ */ jsx72("span", { className: "hidden shrink-0 tabular-nums text-[10px] opacity-75 @[8rem]:inline", "data-calendar-time": "", children: words2 }) : null;
20835
20864
  };
20836
- const listCard = (p, key) => /* @__PURE__ */ jsxs66("li", { ...dragSource(p.row), children: [
20837
- cardFace(p.row, timeOn(p.row)),
20865
+ const listCard = (p, key, compact = false) => /* @__PURE__ */ jsxs66("li", { ...dragSource(p.row), children: [
20866
+ cardFace(p.row, timeOn(p.row), void 0, compact),
20838
20867
  refusalOn(p.row)
20839
20868
  ] }, key);
20840
20869
  const today = dayKey(personWallNow());
@@ -20892,7 +20921,7 @@ function CalendarView({
20892
20921
  if (mode === "month") {
20893
20922
  const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)), firstDay);
20894
20923
  const weeks = Array.from({ length: 6 }, (_, w) => addDays2(first, w * 7));
20895
- body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { className: "w-full min-w-0 border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", children: [
20924
+ body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { ref: grid, className: "w-full min-w-0 border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", ...tightCells ? { "data-calendar-tight": "" } : {}, children: [
20896
20925
  /* @__PURE__ */ jsx72("div", { className: "grid grid-cols-7", role: "row", children: Array.from({ length: 7 }, (_, i) => addDays2(first, i)).map((d) => /* @__PURE__ */ jsx72("div", { role: "columnheader", className: "border-b border-r px-1 py-0.5 text-center text-xs text-muted-foreground", children: dayDate(d).toLocaleDateString(void 0, { weekday: "short" }) }, `h${d}`)) }),
20897
20926
  weeks.map((ws) => /* @__PURE__ */ jsx72(
20898
20927
  MonthWeek,
@@ -20908,6 +20937,11 @@ function CalendarView({
20908
20937
  barDrop,
20909
20938
  canCreate: creates,
20910
20939
  onCreate: (d) => void createAt(rescheduledValue(null, d, null, moments), null, calendarDayLabel(d)),
20940
+ tight: tightCells,
20941
+ dotClass: (row) => {
20942
+ const c = colorOf(row);
20943
+ return c ? CHOICE_CHIP_CLASS[c] : "bg-muted-foreground/40";
20944
+ },
20911
20945
  card: (p, key) => listCard(p, key),
20912
20946
  bar: (p, key) => /* @__PURE__ */ jsxs66("div", { ...dragSource(p.row), className: "relative h-full", children: [
20913
20947
  cardFace(p.row, null, "h-full"),
@@ -20933,12 +20967,12 @@ function CalendarView({
20933
20967
  })
20934
20968
  );
20935
20969
  const columns = `2.75rem repeat(${days.length}, minmax(0, 1fr))`;
20936
- body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { className: "w-full min-w-0 border-l border-t", "data-calendar-week": "", "data-calendar-days": days.length, children: [
20970
+ body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { ref: grid, className: "w-full min-w-0 border-l border-t", "data-calendar-week": "", "data-calendar-days": days.length, ...tightCells ? { "data-calendar-tight": "" } : {}, children: [
20937
20971
  /* @__PURE__ */ jsxs66("div", { className: "grid", style: { gridTemplateColumns: columns }, children: [
20938
20972
  /* @__PURE__ */ jsx72("div", { className: "border-b border-r" }),
20939
20973
  days.map((d) => /* @__PURE__ */ jsx72("div", { className: cn30("border-b border-r px-1 py-0.5 text-center text-xs", d === today ? "font-semibold text-primary" : "text-muted-foreground"), children: dayDate(d).toLocaleDateString(void 0, { weekday: "short", day: "numeric" }) }, `h${d}`)),
20940
20974
  /* @__PURE__ */ jsx72("div", { className: "border-b border-r px-1 py-0.5 text-[10px] text-muted-foreground", children: "All day" }),
20941
- days.map((d) => /* @__PURE__ */ jsx72("div", { "data-calendar-day": d, className: cn30("min-h-8 border-b border-r p-0.5", ghost?.day === d && ghost.minute === null ? "bg-primary/10" : void 0), ...dayDrop(d), children: /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: allDay(d).map((p) => listCard(p, `${p.row.id}:${d}`)) }) }, `a${d}`))
20975
+ days.map((d) => /* @__PURE__ */ jsx72("div", { "data-calendar-day": d, className: cn30("min-h-8 border-b border-r p-0.5", ghost?.day === d && ghost.minute === null ? "bg-primary/10" : void 0), ...dayDrop(d), children: /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: allDay(d).map((p) => listCard(p, `${p.row.id}:${d}`, tightCells)) }) }, `a${d}`))
20942
20976
  ] }),
20943
20977
  /* @__PURE__ */ jsx72(
20944
20978
  WeekHours,
@@ -20984,7 +21018,8 @@ function CalendarView({
20984
21018
  p.row,
20985
21019
  tight ? null : /* @__PURE__ */ jsx72("span", { className: "hidden shrink-0 tabular-nums text-[10px] opacity-75 @[8rem]:inline", "data-calendar-time": "", children: timeLabel(start) }),
20986
21020
  // Taller blocks sharing the width stack the time over the name.
20987
- cn30("h-full items-start", !tight && end - start >= 45 && cols > 1 ? "flex-col gap-0" : void 0)
21021
+ cn30("h-full items-start", !tight && end - start >= 45 && cols > 1 ? "flex-col gap-0" : void 0),
21022
+ tightCells
20988
21023
  ),
20989
21024
  endField && !endWorkedOut && canMove(p.row) ? /* @__PURE__ */ jsx72(
20990
21025
  "div",
@@ -21053,7 +21088,9 @@ function MonthWeek({
21053
21088
  onCreate,
21054
21089
  card,
21055
21090
  bar,
21056
- refusalOn
21091
+ refusalOn,
21092
+ tight,
21093
+ dotClass
21057
21094
  }) {
21058
21095
  const weekEnd = addDays2(weekStart, 6);
21059
21096
  const days = Array.from({ length: 7 }, (_, i) => addDays2(weekStart, i));
@@ -21065,7 +21102,7 @@ function MonthWeek({
21065
21102
  laneEnds[lane] = s.to;
21066
21103
  return { ...s, lane };
21067
21104
  });
21068
- const lanesShown = Math.min(laneEnds.length, MONTH_ROWS - 1);
21105
+ const lanesShown = tight ? 0 : Math.min(laneEnds.length, MONTH_ROWS - 1);
21069
21106
  const singlesFit = MONTH_ROWS - lanesShown;
21070
21107
  return /* @__PURE__ */ jsxs66("div", { className: "relative grid grid-cols-7", role: "row", "data-calendar-week-row": weekStart, children: [
21071
21108
  days.map((d) => {
@@ -21077,7 +21114,8 @@ function MonthWeek({
21077
21114
  const everything = placed.filter((p) => p.firstDay <= d && p.lastDay >= d).sort(byTime);
21078
21115
  const create = (e) => {
21079
21116
  if (e.target.closest("button, [data-calendar-card], [role=dialog]")) return;
21080
- onCreate(d);
21117
+ if (tight && everything.length > 0) onOpenDay(d);
21118
+ else onCreate(d);
21081
21119
  };
21082
21120
  return /* @__PURE__ */ jsxs66(
21083
21121
  "div",
@@ -21086,7 +21124,8 @@ function MonthWeek({
21086
21124
  "aria-label": calendarDayLabel(d),
21087
21125
  "data-calendar-day": d,
21088
21126
  className: cn30(
21089
- "group relative flex min-h-24 min-w-0 flex-col gap-0.5 border-b border-r p-0.5",
21127
+ "group relative flex min-w-0 flex-col gap-0.5 border-b border-r p-0.5",
21128
+ tight ? "min-h-14" : "min-h-24",
21090
21129
  inMonth ? "" : "bg-muted/40",
21091
21130
  ghostDay === d ? "bg-primary/10 ring-2 ring-inset ring-primary" : "",
21092
21131
  canCreate ? "cursor-cell" : ""
@@ -21120,8 +21159,18 @@ function MonthWeek({
21120
21159
  )
21121
21160
  ] }),
21122
21161
  /* @__PURE__ */ jsx72("div", { style: { height: lanesShown * BAR_PX }, "aria-hidden": "true" }),
21123
- /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: shown4.map((p) => card(p, `${p.row.id}:${d}`)) }),
21124
- more > 0 ? /* @__PURE__ */ jsxs66("button", { type: "button", className: "self-start px-1 text-xs text-muted-foreground hover:text-foreground", "data-calendar-more": d, onClick: () => onOpenDay(d), children: [
21162
+ tight ? everything.length > 0 ? /* @__PURE__ */ jsx72(
21163
+ "button",
21164
+ {
21165
+ type: "button",
21166
+ className: "flex min-w-0 flex-wrap items-center justify-center gap-0.5 self-stretch px-0.5 py-0.5",
21167
+ "aria-label": `${everything.length} ${everything.length === 1 ? "record" : "records"} on ${calendarDayLabel(d)}`,
21168
+ "data-calendar-marks": d,
21169
+ onClick: () => onOpenDay(d),
21170
+ children: everything.length <= 3 ? everything.map((p) => /* @__PURE__ */ jsx72("span", { "aria-hidden": "true", "data-calendar-dot": "", className: cn30("h-1.5 w-1.5 rounded-full border", dotClass(p.row)) }, p.row.id)) : /* @__PURE__ */ jsx72("span", { className: "rounded-full bg-muted px-1 text-[10px] tabular-nums leading-4", "data-calendar-count": "", children: everything.length })
21171
+ }
21172
+ ) : null : /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: shown4.map((p) => card(p, `${p.row.id}:${d}`)) }),
21173
+ more > 0 && !tight ? /* @__PURE__ */ jsxs66("button", { type: "button", className: "self-start px-1 text-xs text-muted-foreground hover:text-foreground", "data-calendar-more": d, onClick: () => onOpenDay(d), children: [
21125
21174
  "+",
21126
21175
  more,
21127
21176
  " more"
@@ -21132,7 +21181,11 @@ function MonthWeek({
21132
21181
  role: "dialog",
21133
21182
  "aria-label": calendarDayLabel(d),
21134
21183
  "data-calendar-day-open": d,
21135
- className: "absolute left-0 top-0 z-20 flex w-56 flex-col gap-1 rounded-md border bg-popover p-2 shadow-lg",
21184
+ className: cn30(
21185
+ "z-20 flex flex-col gap-1 rounded-md border bg-popover p-2 shadow-lg",
21186
+ // A narrow cell cannot hold a panel: the day's list opens as a sheet over the page's foot.
21187
+ tight ? "fixed inset-x-3 bottom-3 z-50 max-h-[60vh] overflow-y-auto" : "absolute left-0 top-0 w-56"
21188
+ ),
21136
21189
  onKeyDown: (e) => {
21137
21190
  if (e.key === "Escape") onOpenDay(null);
21138
21191
  },
@@ -21141,7 +21194,8 @@ function MonthWeek({
21141
21194
  /* @__PURE__ */ jsx72("span", { className: "text-xs font-medium", children: calendarDayLabel(d) }),
21142
21195
  /* @__PURE__ */ jsx72(Button55, { size: "sm", variant: "ghost", className: "ml-auto h-6", "aria-label": "Close", onClick: () => onOpenDay(null), children: "\xD7" })
21143
21196
  ] }),
21144
- /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: everything.map((p) => card(p, `open:${p.row.id}:${d}`)) })
21197
+ /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: everything.map((p) => card(p, `open:${p.row.id}:${d}`)) }),
21198
+ tight && canCreate ? /* @__PURE__ */ jsx72(Button55, { size: "sm", variant: "outline", className: "h-7 self-start", "data-calendar-add-in-sheet": d, onClick: () => onCreate(d), children: "Add a record" }) : null
21145
21199
  ]
21146
21200
  }
21147
21201
  ) : null
@@ -38823,7 +38877,7 @@ function TablePresence({ tableId }) {
38823
38877
  }
38824
38878
 
38825
38879
  // src/toolbarFit.ts
38826
- import { useEffect as useEffect102, useLayoutEffect as useLayoutEffect3, useState as useState116 } from "react";
38880
+ import { useEffect as useEffect102, useLayoutEffect as useLayoutEffect4, useState as useState116 } from "react";
38827
38881
  import { flushSync } from "react-dom";
38828
38882
  function widthAtFold(piece, fold) {
38829
38883
  for (let f = Math.min(fold, (piece.byFold?.length ?? 0) - 1); f >= 0; f -= 1) {
@@ -38915,7 +38969,7 @@ function createFitMemory() {
38915
38969
  }
38916
38970
  };
38917
38971
  }
38918
- var useIsoLayoutEffect = typeof window === "undefined" ? useEffect102 : useLayoutEffect3;
38972
+ var useIsoLayoutEffect = typeof window === "undefined" ? useEffect102 : useLayoutEffect4;
38919
38973
  function useToolbarFit(row) {
38920
38974
  const [fold, setFold] = useState116(0);
38921
38975
  useIsoLayoutEffect(() => {