@ai-matrx/records-ui 0.116.10 → 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/CHANGELOG.md CHANGED
@@ -12,11 +12,36 @@
12
12
  - Tests: `vitest.setup.ts` gives jsdom a no-op `performance.mark` / `measure`.
13
13
  - **New subpath `@ai-matrx/records-ui/data-source`:** `recordsDataSource`, `personActor` and the who-changed words (`whenWords`, `actorWords`, `actorBadge`, `lastChangeSentence`, `SOMEBODY`, `THE_SYSTEM`) alone. `/helpers` also carries the field-type words, the colour resolver and the table builders, which read `@ai-matrx/records/core`; this entry reaches `@ai-matrx/kit` only, and shares the one data-source cache with `/helpers` and the root. Additive. Consumer action: a shell-reachable service that only binds its supabase client or says when imports from `/data-source`.
14
14
 
15
- ## 0.116.10
15
+ ## 0.116.11
16
16
 
17
17
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
18
18
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
19
19
 
20
+ ## 0.116.10
21
+
22
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
23
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
24
+ Diff: `git diff 3efc627e11 29df753701 -- apps/shared/records-ui/src`
25
+
26
+ Changed shipped source files (2):
27
+ - `apps/shared/records-ui/src/Grid.tsx`
28
+ - `apps/shared/records-ui/src/gridEditing.tsx`
29
+
30
+ ## 0.116.9
31
+
32
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
33
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
34
+ Diff: `git diff eab7a68c6e 3efc627e11 -- apps/shared/records-ui/src`
35
+
36
+ Changed shipped source files (7):
37
+ - `apps/shared/records-ui/src/CalendarView.tsx`
38
+ - `apps/shared/records-ui/src/Enrich.tsx`
39
+ - `apps/shared/records-ui/src/TablePage.tsx`
40
+ - `apps/shared/records-ui/src/ViewSwitcher.tsx`
41
+ - `apps/shared/records-ui/src/buttonCell.tsx`
42
+ - `apps/shared/records-ui/src/charts.ts`
43
+ - `apps/shared/records-ui/src/gridOpen.tsx`
44
+
20
45
  ## 0.116.8
21
46
 
22
47
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
package/dist/index.cjs CHANGED
@@ -40033,6 +40033,25 @@ function useNarrow() {
40033
40033
  }, []);
40034
40034
  return narrow;
40035
40035
  }
40036
+ var READABLE_CELL_PX = 72;
40037
+ function useGridWidth(grid, mode) {
40038
+ const [width, setWidth] = (0, import_react235.useState)(null);
40039
+ const useIsoLayoutEffect2 = typeof window === "undefined" ? import_react235.useEffect : import_react235.useLayoutEffect;
40040
+ useIsoLayoutEffect2(() => {
40041
+ const el = grid.current;
40042
+ if (!el) {
40043
+ setWidth(null);
40044
+ return;
40045
+ }
40046
+ const read = () => setWidth(el.clientWidth);
40047
+ read();
40048
+ if (typeof ResizeObserver === "undefined") return;
40049
+ const watcher = new ResizeObserver(read);
40050
+ watcher.observe(el);
40051
+ return () => watcher.disconnect();
40052
+ }, [grid, mode]);
40053
+ return width;
40054
+ }
40036
40055
  function byTime(a, b) {
40037
40056
  const allDayOn = (p) => !p.at || p.lastDay > p.firstDay;
40038
40057
  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);
@@ -40125,6 +40144,11 @@ function CalendarView({
40125
40144
  const titleOf = (row) => cardWords(row, titleField, labels).text;
40126
40145
  const rowById = (id) => rows.find((r) => r.id === id);
40127
40146
  const frame = (0, import_react235.useRef)(null);
40147
+ const grid = (0, import_react235.useRef)(null);
40148
+ const gridWidth = useGridWidth(grid, mode);
40149
+ const cellColumns = mode === "month" ? 7 : mode === "week" ? 7 : 1;
40150
+ const cellReserve = mode === "month" ? 0 : 44;
40151
+ const tightCells = (mode === "month" || mode === "week") && gridWidth !== null && gridWidth > 0 && (gridWidth - cellReserve) / cellColumns < READABLE_CELL_PX;
40128
40152
  const [focusOn, setFocusOn] = (0, import_react235.useState)(null);
40129
40153
  (0, import_react235.useEffect)(() => {
40130
40154
  if (!focusOn) return;
@@ -40345,7 +40369,7 @@ function CalendarView({
40345
40369
  window.addEventListener("pointermove", onMove);
40346
40370
  window.addEventListener("pointerup", onUp);
40347
40371
  };
40348
- const cardFace = (row, extra, className2) => {
40372
+ const cardFace = (row, extra, className2, compact = false) => {
40349
40373
  const may = canMove(row);
40350
40374
  const lockWords = (0, import_react236.mayDrag)(row.level) ? WORKED_OUT_DATE_LOCK : "View only";
40351
40375
  const color = colorOf(row);
@@ -40359,17 +40383,19 @@ function CalendarView({
40359
40383
  // The chip palette, not the faint row tint: a calendar is read by its colours at a glance.
40360
40384
  color ? import_data_table19.CHOICE_CHIP_CLASS[color] : "bg-background",
40361
40385
  may ? "cursor-grab active:cursor-grabbing" : "cursor-default",
40386
+ compact ? "min-h-3 px-0" : "",
40362
40387
  className2
40363
40388
  ),
40364
40389
  onClick: () => onOpenRecord?.(row.id),
40390
+ ...compact ? { "aria-label": title, "data-calendar-compact": "" } : {},
40365
40391
  title: may ? `${title} \xB7 drag to another day, or Alt + arrow keys` : `${title} \xB7 ${lockWords}`,
40366
40392
  ...color ? { "data-calendar-color": color } : {},
40367
40393
  ...may ? { "aria-keyshortcuts": "Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown" } : { "data-calendar-locked": "" },
40368
40394
  children: [
40369
- may ? null : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { title: lockWords, "aria-label": lockWords, className: "inline-flex", ...(0, import_react236.mayDrag)(row.level) ? { "data-calendar-worked-out": "" } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(LockIcon, {}) }),
40370
- extra,
40371
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "min-w-0 max-w-full shrink-0 truncate", "data-calendar-card-title": "", children: title }),
40372
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(CardFieldsInline, { row, fields: cardFields })
40395
+ compact ? null : may ? null : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { title: lockWords, "aria-label": lockWords, className: "inline-flex", ...(0, import_react236.mayDrag)(row.level) ? { "data-calendar-worked-out": "" } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(LockIcon, {}) }),
40396
+ compact ? null : extra,
40397
+ compact ? null : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "min-w-0 max-w-full shrink-0 truncate", "data-calendar-card-title": "", children: title }),
40398
+ compact ? null : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(CardFieldsInline, { row, fields: cardFields })
40373
40399
  ]
40374
40400
  }
40375
40401
  );
@@ -40379,8 +40405,8 @@ function CalendarView({
40379
40405
  const words2 = timeOfDayWords(startOf(row));
40380
40406
  return words2 ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "hidden shrink-0 tabular-nums text-[10px] opacity-75 @[8rem]:inline", "data-calendar-time": "", children: words2 }) : null;
40381
40407
  };
40382
- const listCard = (p, key) => /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("li", { ...dragSource(p.row), children: [
40383
- cardFace(p.row, timeOn(p.row)),
40408
+ const listCard = (p, key, compact = false) => /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("li", { ...dragSource(p.row), children: [
40409
+ cardFace(p.row, timeOn(p.row), void 0, compact),
40384
40410
  refusalOn(p.row)
40385
40411
  ] }, key);
40386
40412
  const today = dayKey(personWallNow());
@@ -40438,7 +40464,7 @@ function CalendarView({
40438
40464
  if (mode === "month") {
40439
40465
  const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)), firstDay);
40440
40466
  const weeks = Array.from({ length: 6 }, (_, w) => addDays2(first, w * 7));
40441
- body = /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "w-full min-w-0 border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", children: [
40467
+ body = /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("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: [
40442
40468
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "grid grid-cols-7", role: "row", children: Array.from({ length: 7 }, (_, i) => addDays2(first, i)).map((d) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("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}`)) }),
40443
40469
  weeks.map((ws) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
40444
40470
  MonthWeek,
@@ -40454,6 +40480,11 @@ function CalendarView({
40454
40480
  barDrop,
40455
40481
  canCreate: creates,
40456
40482
  onCreate: (d) => void createAt(rescheduledValue(null, d, null, moments), null, calendarDayLabel(d)),
40483
+ tight: tightCells,
40484
+ dotClass: (row) => {
40485
+ const c = colorOf(row);
40486
+ return c ? import_data_table19.CHOICE_CHIP_CLASS[c] : "bg-muted-foreground/40";
40487
+ },
40457
40488
  card: (p, key) => listCard(p, key),
40458
40489
  bar: (p, key) => /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { ...dragSource(p.row), className: "relative h-full", children: [
40459
40490
  cardFace(p.row, null, "h-full"),
@@ -40479,12 +40510,12 @@ function CalendarView({
40479
40510
  })
40480
40511
  );
40481
40512
  const columns = `2.75rem repeat(${days.length}, minmax(0, 1fr))`;
40482
- body = /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "w-full min-w-0 border-l border-t", "data-calendar-week": "", "data-calendar-days": days.length, children: [
40513
+ body = /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("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: [
40483
40514
  /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "grid", style: { gridTemplateColumns: columns }, children: [
40484
40515
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "border-b border-r" }),
40485
40516
  days.map((d) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: (0, import_design_system115.cn)("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}`)),
40486
40517
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { className: "border-b border-r px-1 py-0.5 text-[10px] text-muted-foreground", children: "All day" }),
40487
- days.map((d) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { "data-calendar-day": d, className: (0, import_design_system115.cn)("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__ */ (0, import_jsx_runtime136.jsx)("ul", { className: "flex flex-col gap-0.5", children: allDay(d).map((p) => listCard(p, `${p.row.id}:${d}`)) }) }, `a${d}`))
40518
+ days.map((d) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { "data-calendar-day": d, className: (0, import_design_system115.cn)("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__ */ (0, import_jsx_runtime136.jsx)("ul", { className: "flex flex-col gap-0.5", children: allDay(d).map((p) => listCard(p, `${p.row.id}:${d}`, tightCells)) }) }, `a${d}`))
40488
40519
  ] }),
40489
40520
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
40490
40521
  WeekHours,
@@ -40530,7 +40561,8 @@ function CalendarView({
40530
40561
  p.row,
40531
40562
  tight ? null : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "hidden shrink-0 tabular-nums text-[10px] opacity-75 @[8rem]:inline", "data-calendar-time": "", children: timeLabel(start) }),
40532
40563
  // Taller blocks sharing the width stack the time over the name.
40533
- (0, import_design_system115.cn)("h-full items-start", !tight && end - start >= 45 && cols > 1 ? "flex-col gap-0" : void 0)
40564
+ (0, import_design_system115.cn)("h-full items-start", !tight && end - start >= 45 && cols > 1 ? "flex-col gap-0" : void 0),
40565
+ tightCells
40534
40566
  ),
40535
40567
  endField && !endWorkedOut && canMove(p.row) ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
40536
40568
  "div",
@@ -40599,7 +40631,9 @@ function MonthWeek({
40599
40631
  onCreate,
40600
40632
  card,
40601
40633
  bar,
40602
- refusalOn
40634
+ refusalOn,
40635
+ tight,
40636
+ dotClass
40603
40637
  }) {
40604
40638
  const weekEnd = addDays2(weekStart, 6);
40605
40639
  const days = Array.from({ length: 7 }, (_, i) => addDays2(weekStart, i));
@@ -40611,7 +40645,7 @@ function MonthWeek({
40611
40645
  laneEnds[lane] = s.to;
40612
40646
  return { ...s, lane };
40613
40647
  });
40614
- const lanesShown = Math.min(laneEnds.length, MONTH_ROWS - 1);
40648
+ const lanesShown = tight ? 0 : Math.min(laneEnds.length, MONTH_ROWS - 1);
40615
40649
  const singlesFit = MONTH_ROWS - lanesShown;
40616
40650
  return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "relative grid grid-cols-7", role: "row", "data-calendar-week-row": weekStart, children: [
40617
40651
  days.map((d) => {
@@ -40623,7 +40657,8 @@ function MonthWeek({
40623
40657
  const everything = placed.filter((p) => p.firstDay <= d && p.lastDay >= d).sort(byTime);
40624
40658
  const create = (e) => {
40625
40659
  if (e.target.closest("button, [data-calendar-card], [role=dialog]")) return;
40626
- onCreate(d);
40660
+ if (tight && everything.length > 0) onOpenDay(d);
40661
+ else onCreate(d);
40627
40662
  };
40628
40663
  return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(
40629
40664
  "div",
@@ -40632,7 +40667,8 @@ function MonthWeek({
40632
40667
  "aria-label": calendarDayLabel(d),
40633
40668
  "data-calendar-day": d,
40634
40669
  className: (0, import_design_system115.cn)(
40635
- "group relative flex min-h-24 min-w-0 flex-col gap-0.5 border-b border-r p-0.5",
40670
+ "group relative flex min-w-0 flex-col gap-0.5 border-b border-r p-0.5",
40671
+ tight ? "min-h-14" : "min-h-24",
40636
40672
  inMonth ? "" : "bg-muted/40",
40637
40673
  ghostDay === d ? "bg-primary/10 ring-2 ring-inset ring-primary" : "",
40638
40674
  canCreate ? "cursor-cell" : ""
@@ -40666,8 +40702,18 @@ function MonthWeek({
40666
40702
  )
40667
40703
  ] }),
40668
40704
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { style: { height: lanesShown * BAR_PX }, "aria-hidden": "true" }),
40669
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("ul", { className: "flex flex-col gap-0.5", children: shown5.map((p) => card(p, `${p.row.id}:${d}`)) }),
40670
- more > 0 ? /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("button", { type: "button", className: "self-start px-1 text-xs text-muted-foreground hover:text-foreground", "data-calendar-more": d, onClick: () => onOpenDay(d), children: [
40705
+ tight ? everything.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
40706
+ "button",
40707
+ {
40708
+ type: "button",
40709
+ className: "flex min-w-0 flex-wrap items-center justify-center gap-0.5 self-stretch px-0.5 py-0.5",
40710
+ "aria-label": `${everything.length} ${everything.length === 1 ? "record" : "records"} on ${calendarDayLabel(d)}`,
40711
+ "data-calendar-marks": d,
40712
+ onClick: () => onOpenDay(d),
40713
+ children: everything.length <= 3 ? everything.map((p) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { "aria-hidden": "true", "data-calendar-dot": "", className: (0, import_design_system115.cn)("h-1.5 w-1.5 rounded-full border", dotClass(p.row)) }, p.row.id)) : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "rounded-full bg-muted px-1 text-[10px] tabular-nums leading-4", "data-calendar-count": "", children: everything.length })
40714
+ }
40715
+ ) : null : /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("ul", { className: "flex flex-col gap-0.5", children: shown5.map((p) => card(p, `${p.row.id}:${d}`)) }),
40716
+ more > 0 && !tight ? /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("button", { type: "button", className: "self-start px-1 text-xs text-muted-foreground hover:text-foreground", "data-calendar-more": d, onClick: () => onOpenDay(d), children: [
40671
40717
  "+",
40672
40718
  more,
40673
40719
  " more"
@@ -40678,7 +40724,11 @@ function MonthWeek({
40678
40724
  role: "dialog",
40679
40725
  "aria-label": calendarDayLabel(d),
40680
40726
  "data-calendar-day-open": d,
40681
- className: "absolute left-0 top-0 z-20 flex w-56 flex-col gap-1 rounded-md border bg-popover p-2 shadow-lg",
40727
+ className: (0, import_design_system115.cn)(
40728
+ "z-20 flex flex-col gap-1 rounded-md border bg-popover p-2 shadow-lg",
40729
+ // A narrow cell cannot hold a panel: the day's list opens as a sheet over the page's foot.
40730
+ tight ? "fixed inset-x-3 bottom-3 z-50 max-h-[60vh] overflow-y-auto" : "absolute left-0 top-0 w-56"
40731
+ ),
40682
40732
  onKeyDown: (e) => {
40683
40733
  if (e.key === "Escape") onOpenDay(null);
40684
40734
  },
@@ -40687,7 +40737,8 @@ function MonthWeek({
40687
40737
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { className: "text-xs font-medium", children: calendarDayLabel(d) }),
40688
40738
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_design_system115.Button, { size: "sm", variant: "ghost", className: "ml-auto h-6", "aria-label": "Close", onClick: () => onOpenDay(null), children: "\xD7" })
40689
40739
  ] }),
40690
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("ul", { className: "flex flex-col gap-0.5", children: everything.map((p) => card(p, `open:${p.row.id}:${d}`)) })
40740
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("ul", { className: "flex flex-col gap-0.5", children: everything.map((p) => card(p, `open:${p.row.id}:${d}`)) }),
40741
+ tight && canCreate ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_design_system115.Button, { size: "sm", variant: "outline", className: "h-7 self-start", "data-calendar-add-in-sheet": d, onClick: () => onCreate(d), children: "Add a record" }) : null
40691
40742
  ]
40692
40743
  }
40693
40744
  ) : null