@ai-matrx/records-ui 0.116.23 → 0.116.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/README.md +3 -3
  3. package/dist/SaveToTable-P3MPRSCW.js +20 -0
  4. package/dist/{chunk-MUK63ANA.js → chunk-4ZS4WEEE.js} +3 -3
  5. package/dist/chunk-4ZS4WEEE.js.map +1 -0
  6. package/dist/{chunk-SYHUPGCU.js → chunk-6Z537SLG.js} +1 -1
  7. package/dist/{chunk-SYHUPGCU.js.map → chunk-6Z537SLG.js.map} +1 -1
  8. package/dist/{chunk-ODABFEHG.js → chunk-7RSMA3NK.js} +3 -3
  9. package/dist/chunk-7RSMA3NK.js.map +1 -0
  10. package/dist/{chunk-VHZKLE63.js → chunk-FLIERNH7.js} +9 -9
  11. package/dist/chunk-FLIERNH7.js.map +1 -0
  12. package/dist/{chunk-ZNIXJ5RY.js → chunk-KQR2RA4V.js} +3 -3
  13. package/dist/{chunk-WQGFKNE2.js → chunk-OJTJ4HJI.js} +26 -26
  14. package/dist/chunk-OJTJ4HJI.js.map +1 -0
  15. package/dist/{chunk-PPWNFIJ5.js → chunk-OV6QBL5R.js} +2 -2
  16. package/dist/{chunk-PPWNFIJ5.js.map → chunk-OV6QBL5R.js.map} +1 -1
  17. package/dist/{chunk-5IX4BL72.js → chunk-QBMUTXTQ.js} +2 -2
  18. package/dist/{chunk-5IX4BL72.js.map → chunk-QBMUTXTQ.js.map} +1 -1
  19. package/dist/{chunk-MCDA6L7E.js → chunk-TC5S4VOW.js} +2 -2
  20. package/dist/chunk-TC5S4VOW.js.map +1 -0
  21. package/dist/{chunk-FECWKOWW.js → chunk-W7GR64CB.js} +1 -1
  22. package/dist/chunk-W7GR64CB.js.map +1 -0
  23. package/dist/{chunk-FHL4GG6R.js → chunk-WCQSJPLS.js} +2 -2
  24. package/dist/chunk-WCQSJPLS.js.map +1 -0
  25. package/dist/data-source.cjs.map +1 -1
  26. package/dist/data-source.d.cts +1 -1
  27. package/dist/data-source.d.ts +1 -1
  28. package/dist/data-source.js.map +1 -1
  29. package/dist/first-page.cjs.map +1 -1
  30. package/dist/first-page.d.cts +1 -1
  31. package/dist/first-page.d.ts +1 -1
  32. package/dist/first-page.js.map +1 -1
  33. package/dist/helpers.cjs +4 -4
  34. package/dist/helpers.cjs.map +1 -1
  35. package/dist/helpers.d.cts +9 -9
  36. package/dist/helpers.d.ts +9 -9
  37. package/dist/helpers.js +4 -4
  38. package/dist/helpers.js.map +1 -1
  39. package/dist/html-frame.cjs.map +1 -1
  40. package/dist/html-frame.d.cts +1 -1
  41. package/dist/html-frame.d.ts +1 -1
  42. package/dist/html-frame.js +1 -1
  43. package/dist/index.cjs +603 -251
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.cts +162 -115
  46. package/dist/index.d.ts +162 -115
  47. package/dist/index.js +590 -224
  48. package/dist/index.js.map +1 -1
  49. package/dist/object-actions.cjs +2 -2
  50. package/dist/object-actions.cjs.map +1 -1
  51. package/dist/object-actions.js +3 -3
  52. package/dist/pickers.cjs +23 -23
  53. package/dist/pickers.cjs.map +1 -1
  54. package/dist/pickers.js +8 -8
  55. package/dist/skeleton.cjs.map +1 -1
  56. package/dist/skeleton.js +4 -4
  57. package/dist/table-shape.cjs.map +1 -1
  58. package/dist/table-shape.js +1 -1
  59. package/package.json +3 -3
  60. package/dist/SaveToTable-PGOQVYVS.js +0 -20
  61. package/dist/chunk-FECWKOWW.js.map +0 -1
  62. package/dist/chunk-FHL4GG6R.js.map +0 -1
  63. package/dist/chunk-MCDA6L7E.js.map +0 -1
  64. package/dist/chunk-MUK63ANA.js.map +0 -1
  65. package/dist/chunk-ODABFEHG.js.map +0 -1
  66. package/dist/chunk-VHZKLE63.js.map +0 -1
  67. package/dist/chunk-WQGFKNE2.js.map +0 -1
  68. /package/dist/{SaveToTable-PGOQVYVS.js.map → SaveToTable-P3MPRSCW.js.map} +0 -0
  69. /package/dist/{chunk-ZNIXJ5RY.js.map → chunk-KQR2RA4V.js.map} +0 -0
package/dist/index.js CHANGED
@@ -182,7 +182,7 @@ import {
182
182
  withoutAddition,
183
183
  withoutLeadingBlank,
184
184
  workedOutErrorFor
185
- } from "./chunk-WQGFKNE2.js";
185
+ } from "./chunk-OJTJ4HJI.js";
186
186
  import {
187
187
  CHART_PLOT_PX,
188
188
  EMBEDDED_ROW_PX,
@@ -198,7 +198,7 @@ import {
198
198
  skeletonLayoutFor,
199
199
  useExpectedRows,
200
200
  useRememberedLayout
201
- } from "./chunk-5IX4BL72.js";
201
+ } from "./chunk-QBMUTXTQ.js";
202
202
  import {
203
203
  DEFAULT_FOOTER,
204
204
  EMBEDDED_LOOK,
@@ -226,7 +226,7 @@ import {
226
226
  viewSettings,
227
227
  viewSettingsFor,
228
228
  viewSettingsPatch
229
- } from "./chunk-MCDA6L7E.js";
229
+ } from "./chunk-TC5S4VOW.js";
230
230
  import {
231
231
  HTML_SAMPLE_CSP,
232
232
  HTML_SAMPLE_SANDBOX,
@@ -234,7 +234,7 @@ import {
234
234
  HtmlSampleTokensProvider,
235
235
  SAMPLE_TOKEN_NAMES,
236
236
  sampleDocument
237
- } from "./chunk-FECWKOWW.js";
237
+ } from "./chunk-W7GR64CB.js";
238
238
  import {
239
239
  ArchiveItemMenu,
240
240
  ArchivedBuiltOn,
@@ -293,7 +293,7 @@ import {
293
293
  visibilityLaneFor,
294
294
  whyNotAskable,
295
295
  writeOnTheWinningVersion_exports
296
- } from "./chunk-VHZKLE63.js";
296
+ } from "./chunk-FLIERNH7.js";
297
297
  import {
298
298
  ACTION_CHECKING_ACCESS_REASON,
299
299
  ACTION_NOT_HERE_REASON,
@@ -313,7 +313,7 @@ import {
313
313
  toDropdownEntries,
314
314
  toStripAndRows,
315
315
  withExtensions
316
- } from "./chunk-ZNIXJ5RY.js";
316
+ } from "./chunk-KQR2RA4V.js";
317
317
  import {
318
318
  ABSENCE_WORD_LABEL,
319
319
  ABSENCE_WORD_VALUES,
@@ -400,7 +400,7 @@ import {
400
400
  useRowRights,
401
401
  useTableRights,
402
402
  withoutInternalCodes
403
- } from "./chunk-ODABFEHG.js";
403
+ } from "./chunk-7RSMA3NK.js";
404
404
  import {
405
405
  FEWEST_KEY_VALUE_PAIRS,
406
406
  FEWEST_LIST_ITEMS,
@@ -413,7 +413,7 @@ import {
413
413
  shapeOfGrid,
414
414
  shapeOfValue,
415
415
  shapeTextOfNode
416
- } from "./chunk-SYHUPGCU.js";
416
+ } from "./chunk-6Z537SLG.js";
417
417
  import {
418
418
  DATABASE_LOCKED_REASON,
419
419
  KERNEL_REASON,
@@ -423,7 +423,7 @@ import {
423
423
  tableIsLocked,
424
424
  whatYouMayDo,
425
425
  whatYouMayDoWithTable
426
- } from "./chunk-PPWNFIJ5.js";
426
+ } from "./chunk-OV6QBL5R.js";
427
427
  import {
428
428
  PARITY_LABEL,
429
429
  PARITY_MADE_OF,
@@ -450,7 +450,7 @@ import {
450
450
  storedChoiceColor,
451
451
  storedChoiceColorLookup,
452
452
  timeOfDayWords
453
- } from "./chunk-MUK63ANA.js";
453
+ } from "./chunk-4ZS4WEEE.js";
454
454
  import {
455
455
  ADD_FIELD_OPEN_LABEL,
456
456
  FIELD_TYPE_CATALOGUE,
@@ -463,7 +463,7 @@ import {
463
463
  kindsWithNoChoice,
464
464
  parityTypesWithNoExplanation,
465
465
  storePublishesKind
466
- } from "./chunk-FHL4GG6R.js";
466
+ } from "./chunk-WCQSJPLS.js";
467
467
  import {
468
468
  __reExport
469
469
  } from "./chunk-HKYEHBQT.js";
@@ -2479,9 +2479,9 @@ function OpenCell({
2479
2479
  className: cn(
2480
2480
  // OVER the cell's ghost (see `data-records-open-cell`), never in the table's measuring.
2481
2481
  "absolute inset-x-0 z-[25] flex w-full min-w-0 max-w-full flex-col gap-1 outline-none",
2482
- // A one-line control sits centred on the row; a multi-line box hangs from the cell's top and
2482
+ // A one-line control sits centerd on the row; a multi-line box hangs from the cell's top and
2483
2483
  // grows downward over the rows below (Airtable's expanded long-text cell), never up over the
2484
- // header (D10: centred, its first lines sat 58px above the cell, outside it).
2484
+ // header (D10: centerd, its first lines sat 58px above the cell, outside it).
2485
2485
  // …and its words wrap: the one-line frame sets `white-space: nowrap` on every descendant, so the
2486
2486
  // textarea scrolled sideways on one line (live, after the clip was lifted).
2487
2487
  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",
@@ -3906,9 +3906,9 @@ function paintByOption(style, _fields, index, lookup) {
3906
3906
  }
3907
3907
  return out ?? doc;
3908
3908
  },
3909
- // A CHOICE PAINTS IN ITS OWN COLOUR (DATA-V2-BASICS-2 C1b): an option kept in its own Table
3910
- // carries the colour its owner gave it; coloured by Status, a "Verified" (green) row was tinted
3911
- // pink by the hash. The option's colour first, then the column's stored colours, then the hash.
3909
+ // A CHOICE PAINTS IN ITS OWN COLOR (DATA-V2-BASICS-2 C1b): an option kept in its own Table
3910
+ // carries the color its owner gave it; colored by Status, a "Verified" (green) row was tinted
3911
+ // pink by the hash. The option's color first, then the column's stored colors, then the hash.
3912
3912
  choiceColorFor: (fieldKey, value) => {
3913
3913
  const option = optionFor(index.get(fieldKey), value);
3914
3914
  if (!option) return lookup(fieldKey, value);
@@ -3987,7 +3987,7 @@ function useGridColours(args) {
3987
3987
  async (path, value, said) => {
3988
3988
  const answer = await client.tableDecorate({ table_id: tableId, path, value });
3989
3989
  if (!answer.ok) {
3990
- notify?.error(`The colour was not kept: ${refusalSentence(answer.error)}`);
3990
+ notify?.error(`The color was not kept: ${refusalSentence(answer.error)}`);
3991
3991
  return false;
3992
3992
  }
3993
3993
  decorations.apply(answer.data);
@@ -4006,34 +4006,34 @@ function useGridColours(args) {
4006
4006
  const name = fieldName(field);
4007
4007
  const by = decorations.data?.color_by;
4008
4008
  const byThis = by?.field === field.id;
4009
- const byWhy = colourableBy(field) ? void 0 : `${name} holds free values; rows are coloured by a column of choices or ticks. Use a colour rule instead.`;
4009
+ const byWhy = colourableBy(field) ? void 0 : `${name} holds free values; rows are colored by a column of choices or ticks. Use a color rule instead.`;
4010
4010
  const column = decorations.data?.columns?.[field.id];
4011
4011
  return {
4012
4012
  id: "col-colour",
4013
- label: "Colour by\u2026",
4013
+ label: "Color by\u2026",
4014
4014
  icon: "palette",
4015
4015
  disabledReason: refusal3,
4016
4016
  submenu: [
4017
4017
  byThis ? {
4018
4018
  id: "col-colour-off",
4019
- label: `Stop colouring by ${name}`,
4020
- onSelect: () => void write(["color_by"], null, `Rows are no longer coloured by ${name}.`)
4019
+ label: `Stop coloring by ${name}`,
4020
+ onSelect: () => void write(["color_by"], null, `Rows are no longer colored by ${name}.`)
4021
4021
  } : {
4022
4022
  id: "col-colour-rows",
4023
- label: "Colour rows by this column",
4023
+ label: "Color rows by this column",
4024
4024
  disabledReason: byWhy,
4025
- onSelect: () => void write(["color_by"], { field: field.id, target: "row" }, `Each row wears the colour of its ${name}.`)
4025
+ onSelect: () => void write(["color_by"], { field: field.id, target: "row" }, `Each row wears the color of its ${name}.`)
4026
4026
  },
4027
4027
  ...byThis && by?.target === "row" ? [
4028
4028
  {
4029
4029
  id: "col-colour-cells",
4030
- label: "Colour only this column's cells",
4031
- onSelect: () => void write(["color_by"], { field: field.id, target: "cell" }, `Only ${name}'s cells wear their colour now.`)
4030
+ label: "Color only this column's cells",
4031
+ onSelect: () => void write(["color_by"], { field: field.id, target: "cell" }, `Only ${name}'s cells wear their color now.`)
4032
4032
  }
4033
4033
  ] : [],
4034
4034
  {
4035
4035
  id: "col-colour-rules",
4036
- label: "Colour rules\u2026",
4036
+ label: "Color rules\u2026",
4037
4037
  onSelect: () => setRulesOpen(columnKey)
4038
4038
  },
4039
4039
  {
@@ -4087,7 +4087,7 @@ function useGridColours(args) {
4087
4087
  if (!field) continue;
4088
4088
  const answer = await client.tableDecorate({ table_id: tableId, path: ["cells", cell.rowId, field.id], value: color });
4089
4089
  if (!answer.ok) {
4090
- notify?.error(`The colour was not kept: ${refusalSentence(answer.error)}`);
4090
+ notify?.error(`The color was not kept: ${refusalSentence(answer.error)}`);
4091
4091
  return;
4092
4092
  }
4093
4093
  decorations.apply(answer.data);
@@ -4132,13 +4132,13 @@ function useGridColours(args) {
4132
4132
  drafts: draftsFromView(view.rules, fields),
4133
4133
  onSave: async (drafts) => {
4134
4134
  view.save(viewRulesFrom(drafts));
4135
- notify?.success(drafts.length === 0 ? "This view's colour rules are cleared." : "This view's colour rules are kept.");
4135
+ notify?.success(drafts.length === 0 ? "This view's color rules are cleared." : "This view's color rules are kept.");
4136
4136
  setRulesOpen(null);
4137
4137
  }
4138
4138
  }
4139
4139
  } : {},
4140
4140
  onSave: async (drafts) => {
4141
- const kept = await write(["rules"], rulesLeaf(drafts, fields), drafts.length === 0 ? "The colour rules are cleared." : "The colour rules are kept.");
4141
+ const kept = await write(["rules"], rulesLeaf(drafts, fields), drafts.length === 0 ? "The color rules are cleared." : "The color rules are kept.");
4142
4142
  if (kept) setRulesOpen(null);
4143
4143
  }
4144
4144
  }
@@ -4146,25 +4146,25 @@ function useGridColours(args) {
4146
4146
  const colourable = fields.filter(colourableBy);
4147
4147
  const byId = decorations.data?.color_by?.field ?? null;
4148
4148
  const sheet = enabled ? /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", "data-records-grid-sheet-colours": "", children: [
4149
- /* @__PURE__ */ jsx12("span", { className: "text-xs font-medium text-muted-foreground", children: "Colours" }),
4149
+ /* @__PURE__ */ jsx12("span", { className: "text-xs font-medium text-muted-foreground", children: "Colors" }),
4150
4150
  mayColour ? /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
4151
4151
  /* @__PURE__ */ jsxs11("label", { className: "flex min-w-0 flex-1 items-center gap-2 text-xs text-muted-foreground", children: [
4152
- /* @__PURE__ */ jsx12("span", { className: "shrink-0", children: "Colour rows by" }),
4152
+ /* @__PURE__ */ jsx12("span", { className: "shrink-0", children: "Color rows by" }),
4153
4153
  /* @__PURE__ */ jsx12(
4154
4154
  PickOne,
4155
4155
  {
4156
- label: "Colour rows by",
4156
+ label: "Color rows by",
4157
4157
  className: "h-10 min-w-0 flex-1 text-base",
4158
4158
  value: byId ?? "",
4159
4159
  onChange: (id) => {
4160
4160
  const field = fields.find((f) => f.id === id);
4161
- void (field ? write(["color_by"], { field: field.id, target: "row" }, `Each row wears the colour of its ${fieldName(field)}.`) : write(["color_by"], null, "Rows are no longer coloured by a column."));
4161
+ void (field ? write(["color_by"], { field: field.id, target: "row" }, `Each row wears the color of its ${fieldName(field)}.`) : write(["color_by"], null, "Rows are no longer colored by a column."));
4162
4162
  },
4163
- options: [{ value: "", label: "No colour" }, ...colourable.map((field) => ({ value: field.id, label: fieldName(field) }))]
4163
+ options: [{ value: "", label: "No color" }, ...colourable.map((field) => ({ value: field.id, label: fieldName(field) }))]
4164
4164
  }
4165
4165
  )
4166
4166
  ] }),
4167
- /* @__PURE__ */ jsx12(Button10, { type: "button", size: "sm", variant: "outline", className: "h-10 shrink-0", onClick: () => setRulesOpen(colourable[0]?.key ?? fields[0]?.key ?? ""), children: "Colour rules\u2026" })
4167
+ /* @__PURE__ */ jsx12(Button10, { type: "button", size: "sm", variant: "outline", className: "h-10 shrink-0", onClick: () => setRulesOpen(colourable[0]?.key ?? fields[0]?.key ?? ""), children: "Color rules\u2026" })
4168
4168
  ] }) : /* @__PURE__ */ jsx12("p", { className: "text-xs text-muted-foreground", children: whyNot })
4169
4169
  ] }) : null;
4170
4170
  return { headerItem, cellItem, cellsItem, rowItem, dialogs, sheet };
@@ -4215,7 +4215,7 @@ function ColourRulesDialog({
4215
4215
  const first = startField ?? fields[0]?.key ?? "";
4216
4216
  return /* @__PURE__ */ jsx12(Dialog6, { open, onOpenChange: (next) => !next ? close() : void 0, children: /* @__PURE__ */ jsxs11(DialogContent6, { className: "sm:max-w-2xl", "data-records-colour-rules": "", children: [
4217
4217
  /* @__PURE__ */ jsxs11(DialogHeader6, { children: [
4218
- /* @__PURE__ */ jsx12(DialogTitle6, { children: "Colour rules" }),
4218
+ /* @__PURE__ */ jsx12(DialogTitle6, { children: "Color rules" }),
4219
4219
  /* @__PURE__ */ jsx12(DialogDescription6, { children: scope === "view" ? "The first rule a row matches wins. These rules belong to this view alone, and a date can be tested against today." : "The first rule a row matches wins. A rule tints the whole row, or only the cell it reads. Everyone who opens this table sees them." })
4220
4220
  ] }),
4221
4221
  /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-2", children: [
@@ -4303,7 +4303,7 @@ function ColourRulesDialog({
4303
4303
  /* @__PURE__ */ jsx12(
4304
4304
  PickOne,
4305
4305
  {
4306
- label: "Colour",
4306
+ label: "Color",
4307
4307
  attrs: { "data-records-colour-rule-color": "" },
4308
4308
  className: SELECT,
4309
4309
  value: rule.color,
@@ -9404,8 +9404,8 @@ function columnForField(field, editing, mayWriteRow, whyNotRow, look, onAskWhoCh
9404
9404
  // A column that holds numbers filters as numbers (=, <, >, between) — the record number too,
9405
9405
  // which is worked out but kept (review 2: the autonumber header offered "Contains").
9406
9406
  filter: filterRefusal(field) !== null ? false : editorKindFor(field) === "select" || editorKindFor(field) === "multi_select" ? "select" : holdsNumbers(field) ? "number" : "auto",
9407
- // THE MENU'S VALUE LIST WEARS THE CHOICES' COLOURS (lane CELL-EDITORS, night walk 2026-10-06): the
9408
- // same chip the cell draws, never bare words beside a coloured column.
9407
+ // THE MENU'S VALUE LIST WEARS THE CHOICES' COLORS (lane CELL-EDITORS, night walk 2026-10-06): the
9408
+ // same chip the cell draws, never bare words beside a colored column.
9409
9409
  ...editorKindFor(field) === "select" || editorKindFor(field) === "multi_select" ? { filterValueClass: (value, label) => choiceChipLookOf(field, value, label).className } : {},
9410
9410
  cell: (row) => (
9411
9411
  /*
@@ -9454,7 +9454,7 @@ function columnForField(field, editing, mayWriteRow, whyNotRow, look, onAskWhoCh
9454
9454
  // The type is in the header's tooltip rather than a second header row: one
9455
9455
  // row of headers, always — and it is the parity type's own WORD, not a
9456
9456
  // token (`Long text`, never `long_text`).
9457
- // CENTRED, EVERY WIDTH (Arman 2026-10-08: tick boxes sat on the cell's top edge). A grid row is
9457
+ // CENTERD, EVERY WIDTH (Arman 2026-10-08: tick boxes sat on the cell's top edge). A grid row is
9458
9458
  // ONE line (`cellLines` "one", the table's default), so nothing here wraps and top-aligning only
9459
9459
  // lifted every value — text ~4 px, a 16 px tick box ~8 px — above the row's middle, out of line
9460
9460
  // with the row's own controls. The table's cell is `align-middle`; this column no longer overrides it.
@@ -13565,9 +13565,9 @@ function GridBody({
13565
13565
  () => tableStyleIsEmpty(paint.style) ? null : {
13566
13566
  style: paint.style,
13567
13567
  // A choice is read as its OPTION (`paintByOption`): the rule, the value and the
13568
- // colour a column keeps for it all name the same option, however it is stored.
13568
+ // color a column keeps for it all name the same option, however it is stored.
13569
13569
  documentOf: (row) => paint.documentOf(row.document ?? {}),
13570
- // A value its column keeps a colour for wears THAT colour (`choiceLooks.ts`);
13570
+ // A value its column keeps a color for wears THAT color (`choiceLooks.ts`);
13571
13571
  // any other value still paints from its word.
13572
13572
  choiceColorFor: paint.choiceColorFor
13573
13573
  },
@@ -16273,7 +16273,7 @@ function VersionRow({
16273
16273
  children: mine ? "Working out what would change\u2026" : "Put the record back to this version"
16274
16274
  }
16275
16275
  ) }) : (
16276
- // Absent AND explained: never a greyed button, never silence.
16276
+ // Absent AND explained: never a grayed button, never silence.
16277
16277
  /* @__PURE__ */ jsx55("p", { className: "text-[11px] text-muted-foreground", children: whyNotRestore })
16278
16278
  )
16279
16279
  ] }) : null
@@ -17858,10 +17858,16 @@ function editTypeOf(column) {
17858
17858
  if (column.type === "checkbox" || column.type === "boolean") return "boolean";
17859
17859
  return false;
17860
17860
  }
17861
+ function entityFilterWhere(filter) {
17862
+ if (!filter) return [];
17863
+ return Object.keys(filter).sort().map((column) => ({ column, op: "eq", value: filter[column] }));
17864
+ }
17861
17865
  function useEntitySourceTable(token2, options = {}) {
17862
17866
  const type = useEntityType(token2);
17863
17867
  const columns = useEntityColumns(token2);
17864
- const list = useEntityList(token2, entityTableQuery(options));
17868
+ const where = entityFilterWhere(options.filter);
17869
+ const query = { ...entityTableQuery({ pageSize: options.pageSize, search: options.search }), ...where.length > 0 ? { where } : {} };
17870
+ const list = useEntityList(token2, query);
17865
17871
  const write = useEntityWrite(token2);
17866
17872
  const shown4 = useMemo32(() => entityShownColumns(columns.data ?? []), [columns.data]);
17867
17873
  const refused = list.error ?? columns.error ?? type.error;
@@ -17887,7 +17893,7 @@ function useEntitySourceTable(token2, options = {}) {
17887
17893
  return answer.ok ? null : refusalSentence(answer.error) || "That change was not saved.";
17888
17894
  },
17889
17895
  async create(values) {
17890
- const answer = await write.create(values);
17896
+ const answer = await write.create(options.filter ? { ...values, ...options.filter } : values);
17891
17897
  return answer.ok ? { id: answer.data._id } : { refused: refusalSentence(answer.error) || "That row was not added." };
17892
17898
  }
17893
17899
  };
@@ -17980,7 +17986,7 @@ function EntityTableCardBody({
17980
17986
  className
17981
17987
  }) {
17982
17988
  const batch = initialRows ?? TABLE_CARD_DEFAULT_INITIAL_ROWS;
17983
- const entity = useEntitySourceTable(source.token, { pageSize: batch });
17989
+ const entity = useEntitySourceTable(source.token, { pageSize: batch, filter: source.filter ?? null });
17984
17990
  const label = entity.label ?? (entity.loading ? "Loading\u2026" : "Table");
17985
17991
  return /* @__PURE__ */ jsx61(
17986
17992
  MatrxTableCard,
@@ -21401,7 +21407,7 @@ function CalendarView({
21401
21407
  type: "button",
21402
21408
  className: cn31(
21403
21409
  "@container flex w-full min-w-0 items-center gap-1 truncate rounded border px-1.5 py-0.5 text-left text-xs hover:brightness-95",
21404
- // The chip palette, not the faint row tint: a calendar is read by its colours at a glance.
21410
+ // The chip palette, not the faint row tint: a calendar is read by its colors at a glance.
21405
21411
  color ? CHOICE_CHIP_CLASS[color] : "bg-background",
21406
21412
  may ? "cursor-grab active:cursor-grabbing" : "cursor-default",
21407
21413
  compact ? "min-h-3 px-0" : "",
@@ -21454,7 +21460,7 @@ function CalendarView({
21454
21460
  setEndPick(key);
21455
21461
  onEndFieldChange?.(key);
21456
21462
  }, endKept ?? Boolean(onEndFieldChange), endUnusual) : null,
21457
- choiceFields.length > 0 ? picker("Colour by", colorKey, choiceFields, (key) => {
21463
+ choiceFields.length > 0 ? picker("Color by", colorKey, choiceFields, (key) => {
21458
21464
  setColorPick(key);
21459
21465
  onColorFieldChange?.(key);
21460
21466
  }, true) : null
@@ -22699,7 +22705,7 @@ function TimelineView({
22699
22705
  dates.length > 1 || !startField || !dates.some((f) => f.key === startChosen) ? picker("Start", startChosen, dates, (key) => setting({ startKey: key }), { none: false }) : null,
22700
22706
  endCandidates.length > 0 || endField && !endCandidates.includes(endField) ? picker("End", endChosen, endCandidates, (key) => setting({ endKey: key }), { kept: layoutKept }) : null,
22701
22707
  groupCandidates.length > 0 ? picker("Group by", groupChosen, groupCandidates, (key) => setting({ groupKey: key })) : null,
22702
- choiceFields.length > 0 ? picker("Colour by", colorChosen, choiceFields, (key) => setting({ colorKey: key })) : null
22708
+ choiceFields.length > 0 ? picker("Color by", colorChosen, choiceFields, (key) => setting({ colorKey: key })) : null
22703
22709
  ] });
22704
22710
  const heading = zoom === "quarter" ? `Q${Math.floor(dayAt(anchor).getMonth() / 3) + 1} ${dayAt(anchor).getFullYear()}` : dayAt(anchor).toLocaleDateString(void 0, { month: "long", year: "numeric" });
22705
22711
  const toolbar = /* @__PURE__ */ jsxs70("div", { className: "flex flex-wrap items-center gap-2", children: [
@@ -23339,7 +23345,7 @@ function BoardOptions({
23339
23345
  )
23340
23346
  ] }) : null,
23341
23347
  toggle("Count per column", "boardCounts", look.boardCounts !== false),
23342
- toggle("Colour the columns", "boardColorColumns", look.boardColorColumns !== false),
23348
+ toggle("Color the columns", "boardColorColumns", look.boardColorColumns !== false),
23343
23349
  toggle("Hide empty groups", "boardHideEmpty", look.boardHideEmpty === true),
23344
23350
  remembered ? null : /* @__PURE__ */ jsx79("p", { className: "text-muted-foreground", children: "Kept for this visit only." })
23345
23351
  ] })
@@ -23624,7 +23630,7 @@ var CHART_KIND_LABEL = {
23624
23630
  // (FIX-10C F12, 2026-09-22). The kind key stays `stuck` — it is the store's
23625
23631
  // closed set and renaming it would be a second idea of the same shape — but
23626
23632
  // the WORD in the picker read "Stuck", which is our jargon for a record that
23627
- // has sat on one value too long, not a shape anybody recognises beside
23633
+ // has sat on one value too long, not a shape anybody recognizes beside
23628
23634
  // Number, Bars, Columns, Line, Donut and Table. This block lists the records
23629
23635
  // that have not moved, so that is what it is called.
23630
23636
  stuck: "Not moving"
@@ -23746,7 +23752,7 @@ var SERIES_COLORS = [
23746
23752
  "hsl(var(--warning))",
23747
23753
  "hsl(var(--destructive))",
23748
23754
  "hsl(var(--accent-foreground))",
23749
- // Slices 7-12: the theme's own chart tokens, so a donut of 8-12 slices never repeats a colour.
23755
+ // Slices 7-12: the theme's own chart tokens, so a donut of 8-12 slices never repeats a color.
23750
23756
  "hsl(var(--chart-1))",
23751
23757
  "hsl(var(--chart-2))",
23752
23758
  "hsl(var(--chart-3))",
@@ -28705,7 +28711,7 @@ function ActionInbox({
28705
28711
  item.summary ? /* @__PURE__ */ jsx93("p", { className: "text-xs text-muted-foreground", children: item.summary }) : null,
28706
28712
  snoozing === item.item_id ? (
28707
28713
  // SUPERHUMAN'S CHOICES, then any moment the person names. The picked time's own Snooze is
28708
- // absent until a time is picked — never a greyed button that does nothing.
28714
+ // absent until a time is picked — never a grayed button that does nothing.
28709
28715
  /* @__PURE__ */ jsxs86(
28710
28716
  "div",
28711
28717
  {
@@ -29738,7 +29744,7 @@ function PortalLookEditor({ card, onSaved, className }) {
29738
29744
  )
29739
29745
  ] }),
29740
29746
  /* @__PURE__ */ jsxs90("div", { className: "flex flex-col gap-1 text-xs", children: [
29741
- /* @__PURE__ */ jsx97("span", { children: "Colour" }),
29747
+ /* @__PURE__ */ jsx97("span", { children: "Color" }),
29742
29748
  /* @__PURE__ */ jsx97(AccentSwatches, { value: accent, onChange: setAccent, options: card.accents })
29743
29749
  ] }),
29744
29750
  /* @__PURE__ */ jsxs90("div", { className: "flex flex-col gap-1 text-xs", children: [
@@ -30734,7 +30740,7 @@ function DigestScheduler({
30734
30740
  // Tables this person can already open — never a grant on the table behind it.
30735
30741
  client.views({ table_id: tableId }),
30736
30742
  // The cadences are ASKED, never typed into this file, so a picker can
30737
- // never offer a cadence the digest runner does not honour.
30743
+ // never offer a cadence the digest runner does not honor.
30738
30744
  client.subscriptionCadences()
30739
30745
  ]);
30740
30746
  if (!saved.ok) setError(saved.error);
@@ -30836,11 +30842,11 @@ function DigestScheduler({
30836
30842
  )
30837
30843
  ] }),
30838
30844
  savedViewId ? null : /* @__PURE__ */ jsxs93("label", { className: "flex flex-col gap-1", children: [
30839
- /* @__PURE__ */ jsx100(Label11, { className: "text-xs font-medium", children: "What it summarises" }),
30845
+ /* @__PURE__ */ jsx100(Label11, { className: "text-xs font-medium", children: "What it summarizes" }),
30840
30846
  /* @__PURE__ */ jsx100(
30841
30847
  Select14,
30842
30848
  {
30843
- "aria-label": "What it summarises",
30849
+ "aria-label": "What it summarizes",
30844
30850
  value: viewId,
30845
30851
  onValueChange: setViewId,
30846
30852
  options: [
@@ -32141,7 +32147,7 @@ function FormStage({
32141
32147
  {
32142
32148
  className: cn54(
32143
32149
  "mx-auto flex w-full max-w-2xl flex-col gap-4 py-4",
32144
- // TYPEFORM'S SIZE (TYPEFORM-2): one question at a time fills the screen, centred in it.
32150
+ // TYPEFORM'S SIZE (TYPEFORM-2): one question at a time fills the screen, centerd in it.
32145
32151
  oneAtATime && "min-h-[min(70dvh,640px)]",
32146
32152
  theme.surface,
32147
32153
  theme.background !== "plain" && "rounded-lg px-5 sm:px-8",
@@ -32370,7 +32376,7 @@ function Question({
32370
32376
  ),
32371
32377
  uploadError ? /* @__PURE__ */ jsx104(RefusalLine, { error: uploadError }) : null
32372
32378
  ] }) : (
32373
- // A choice is laid out as lettered rows in the form's colour (`ChoiceAnswer`).
32379
+ // A choice is laid out as lettered rows in the form's color (`ChoiceAnswer`).
32374
32380
  /* @__PURE__ */ jsx104(FieldControl, { field, value, onChange, id, asForm: true, onChosen })
32375
32381
  ),
32376
32382
  /* @__PURE__ */ jsx104("p", { id: sayId, role: "alert", "aria-live": "assertive", className: "min-h-0 empty:hidden", "data-records-form-refused": "", children: refused ? /* @__PURE__ */ jsxs97("span", { className: "inline-flex items-center gap-1.5 rounded bg-destructive px-2 py-1 text-sm font-medium text-destructive-foreground", children: [
@@ -32934,7 +32940,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
32934
32940
  AccentSwatches,
32935
32941
  {
32936
32942
  value: draft.look?.accent ?? "",
32937
- noneLabel: "Organization colour",
32943
+ noneLabel: "Organization color",
32938
32944
  onChange: (accent) => patchLook({ accent: accent || null })
32939
32945
  }
32940
32946
  ),
@@ -37699,7 +37705,7 @@ function InterfaceScreen({
37699
37705
  /* @__PURE__ */ jsx116(
37700
37706
  PickOne,
37701
37707
  {
37702
- label: "Colour",
37708
+ label: "Color",
37703
37709
  value: shape.color,
37704
37710
  options: INTERFACE_COLORS.map((c) => ({ value: c, label: c[0].toUpperCase() + c.slice(1) })),
37705
37711
  onChange: (color) => void save({ ...shape, color }),
@@ -42077,20 +42083,41 @@ function PreviewForms({ preview, booking }) {
42077
42083
  }
42078
42084
 
42079
42085
  // src/SectionCard.tsx
42080
- import { useEffect as useEffect109, useRef as useRef53, useState as useState124 } from "react";
42086
+ import { useEffect as useEffect109, useRef as useRef53, useState as useState125 } from "react";
42081
42087
  import { atLeast } from "@ai-matrx/records/field-kinds";
42082
42088
  import { useFields as useFields35, useRecordMutation as useRecordMutation3, useRecordPage as useRecordPage4, useRecordsClient as useRecordsClient95, useTable as useTable37 } from "@ai-matrx/records/react";
42083
42089
  import {
42084
- BasicInput as BasicInput25,
42090
+ BasicInput as BasicInput26,
42085
42091
  BasicTextarea as BasicTextarea8,
42092
+ Button as Button103,
42093
+ Dialog as Dialog23,
42094
+ DialogContent as DialogContent23,
42095
+ DialogHeader as DialogHeader23,
42096
+ DialogTitle as DialogTitle23,
42097
+ Popover as Popover12,
42098
+ PopoverContent as PopoverContent12,
42099
+ PopoverTrigger as PopoverTrigger12,
42100
+ Select as Select22,
42101
+ SelectContent as SelectContent15,
42102
+ SelectItem as SelectItem15,
42103
+ SelectTrigger as SelectTrigger15,
42104
+ SelectValue as SelectValue15,
42105
+ cn as cn75
42106
+ } from "@ai-matrx/design-system";
42107
+ import { MessageSquareIcon, PlusIcon as PlusIcon2, StickyNoteIcon } from "@ai-matrx/design-system/icons";
42108
+ import { readColorPair, readShadowPair, shadowWords } from "@ai-matrx/design-system/field-formats";
42109
+
42110
+ // src/EntitySectionCard.tsx
42111
+ import { useState as useState124 } from "react";
42112
+ import { useOptionalRecordsClient as useOptionalRecordsClient11 } from "@ai-matrx/records/react";
42113
+ import {
42114
+ BasicInput as BasicInput25,
42086
42115
  Button as Button102,
42116
+ Checkbox as Checkbox13,
42087
42117
  Dialog as Dialog22,
42088
42118
  DialogContent as DialogContent22,
42089
42119
  DialogHeader as DialogHeader22,
42090
42120
  DialogTitle as DialogTitle22,
42091
- Popover as Popover12,
42092
- PopoverContent as PopoverContent12,
42093
- PopoverTrigger as PopoverTrigger12,
42094
42121
  Select as Select21,
42095
42122
  SelectContent as SelectContent14,
42096
42123
  SelectItem as SelectItem14,
@@ -42098,14 +42125,314 @@ import {
42098
42125
  SelectValue as SelectValue14,
42099
42126
  cn as cn74
42100
42127
  } from "@ai-matrx/design-system";
42101
- import { MessageSquareIcon, PlusIcon, StickyNoteIcon } from "@ai-matrx/design-system/icons";
42102
- import { readColorPair, readShadowPair, shadowWords } from "@ai-matrx/design-system/field-formats";
42103
- import { Fragment as Fragment59, jsx as jsx136, jsxs as jsxs128 } from "react/jsx-runtime";
42128
+ import { PlusIcon } from "@ai-matrx/design-system/icons";
42129
+
42130
+ // src/sectionKeys.ts
42104
42131
  var NAME_KEYS2 = ["name", "title", "token", "label"];
42105
42132
  var GROUP_KEYS = ["group", "set", "section", "category"];
42106
42133
  var NOTE_KEYS = ["usage_note", "note", "notes", "usage"];
42107
- var SAVE_AFTER_MS = 500;
42134
+
42135
+ // src/EntitySectionCard.tsx
42136
+ import { jsx as jsx136, jsxs as jsxs128 } from "react/jsx-runtime";
42137
+ var SECTION_PAGE = 200;
42138
+ var BOOKKEEPING = /* @__PURE__ */ new Set(["id", "organization_id", "created_by", "updated_by", "created_at", "updated_at", "version", "metadata", "test_run_id", "test_expires_at"]);
42108
42139
  var UNGROUPED = "";
42140
+ var NATURAL = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
42141
+ function entitySectionColumns(columns, props, filter) {
42142
+ const pinned = new Set(Object.keys(filter ?? {}));
42143
+ const live = columns.filter((c) => c.origin === "custom" || !BOOKKEEPING.has(c.key) && !pinned.has(c.key));
42144
+ const byKey = (key) => key ? live.find((c) => c.key === key) : void 0;
42145
+ const firstOf = (keys) => keys.map((k) => byKey(k)).find((c) => c !== void 0);
42146
+ const name = byKey(props.nameField) ?? firstOf(NAME_KEYS2) ?? live.find((c) => c.title) ?? entityNameColumn(live) ?? void 0;
42147
+ const group = props.groupBy === null ? void 0 : byKey(props.groupBy) ?? firstOf(GROUP_KEYS);
42148
+ const note = props.noteField === null ? void 0 : byKey(props.noteField) ?? firstOf(NOTE_KEYS);
42149
+ const taken = new Set([name?.key, group?.key, note?.key].filter(Boolean));
42150
+ const values = props.valueFields ? props.valueFields.map((k) => byKey(k)).filter((c) => c !== void 0) : live.filter((c) => !taken.has(c.key));
42151
+ return { name, group, note, values };
42152
+ }
42153
+ function textOf(row, column) {
42154
+ return column ? entityValueText(column, entityCellValue(row, column)) : "";
42155
+ }
42156
+ function entitySectionGroups(rows, name, group) {
42157
+ const ordered = [...rows].sort((a, b) => {
42158
+ const x = textOf(a, name);
42159
+ const y = textOf(b, name);
42160
+ if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
42161
+ return NATURAL.compare(x, y);
42162
+ });
42163
+ if (!group) return [{ key: UNGROUPED, rows: ordered }];
42164
+ const map = /* @__PURE__ */ new Map();
42165
+ for (const row of ordered) {
42166
+ const key = textOf(row, group);
42167
+ const held = map.get(key);
42168
+ if (held) held.push(row);
42169
+ else map.set(key, [row]);
42170
+ }
42171
+ return [...map.entries()].map(([key, r]) => ({ key, rows: r })).sort((a, b) => (a.key === UNGROUPED ? -1 : 0) - (b.key === UNGROUPED ? -1 : 0));
42172
+ }
42173
+ function editKindOf(column) {
42174
+ if (column.readOnly) return null;
42175
+ if (column.type === "choice") return column.choices && column.choices.length > 0 ? "choice" : null;
42176
+ if (column.linksTo && column.linksTo.length > 0) return null;
42177
+ if (column.type === "boolean" || column.type === "checkbox") return "boolean";
42178
+ if (column.type === "number" || column.type === "integer") return "number";
42179
+ if (column.type === "date") return "date";
42180
+ if (column.type === "text") return "text";
42181
+ return null;
42182
+ }
42183
+ function draftValue(kind2, draft) {
42184
+ if (draft.trim() === "") return null;
42185
+ if (kind2 === "number") {
42186
+ const n = Number(draft);
42187
+ return Number.isFinite(n) ? n : draft;
42188
+ }
42189
+ return draft;
42190
+ }
42191
+ function storedDraft(kind2, row, column) {
42192
+ const v = entityCellValue(row, column);
42193
+ if (v === null || v === void 0) return "";
42194
+ if (kind2 === "date" && typeof v === "string") return v.slice(0, 10);
42195
+ if (kind2 === "number" && typeof v === "number") return String(v);
42196
+ return entityValueText(column, v);
42197
+ }
42198
+ function EntityValueCell({ row, column, editable, save }) {
42199
+ const kind2 = editable ? editKindOf(column) : null;
42200
+ const stored = storedDraft(kind2, row, column);
42201
+ const [draft, setDraft] = useState124(stored);
42202
+ const [seen, setSeen] = useState124(stored);
42203
+ if (seen !== stored) {
42204
+ setSeen(stored);
42205
+ setDraft(stored);
42206
+ }
42207
+ if (kind2 === null) {
42208
+ const words2 = textOf(row, column);
42209
+ return /* @__PURE__ */ jsx136("span", { className: cn74("block truncate text-sm", words2 ? "text-foreground" : "text-muted-foreground"), children: words2 || "\u2013" });
42210
+ }
42211
+ const label = `${column.label}`;
42212
+ if (kind2 === "choice") {
42213
+ return /* @__PURE__ */ jsxs128(
42214
+ Select21,
42215
+ {
42216
+ value: draft === "" ? "__none" : draft,
42217
+ onValueChange: async (v) => {
42218
+ const next = v === "__none" ? "" : v;
42219
+ setDraft(next);
42220
+ if (!await save(column, next === "" ? null : next)) setDraft(stored);
42221
+ },
42222
+ children: [
42223
+ /* @__PURE__ */ jsx136(SelectTrigger14, { "aria-label": label, children: /* @__PURE__ */ jsx136(SelectValue14, {}) }),
42224
+ /* @__PURE__ */ jsxs128(SelectContent14, { children: [
42225
+ /* @__PURE__ */ jsx136(SelectItem14, { value: "__none", children: "None" }),
42226
+ (column.choices ?? []).map((w) => /* @__PURE__ */ jsx136(SelectItem14, { value: w, children: w }, w))
42227
+ ] })
42228
+ ]
42229
+ }
42230
+ );
42231
+ }
42232
+ if (kind2 === "boolean") {
42233
+ const on = entityCellValue(row, column) === true;
42234
+ return /* @__PURE__ */ jsx136(Checkbox13, { "aria-label": label, checked: on, onCheckedChange: (next) => void save(column, next === true) });
42235
+ }
42236
+ const commit = async () => {
42237
+ if (draft === stored) return;
42238
+ if (!await save(column, draftValue(kind2, draft))) setDraft(stored);
42239
+ };
42240
+ return /* @__PURE__ */ jsx136(
42241
+ BasicInput25,
42242
+ {
42243
+ "aria-label": label,
42244
+ type: kind2 === "number" ? "number" : kind2 === "date" ? "date" : "text",
42245
+ value: draft,
42246
+ onChange: (e) => setDraft(e.target.value),
42247
+ onBlur: () => void commit(),
42248
+ onKeyDown: (e) => {
42249
+ if (e.key === "Enter") e.target.blur();
42250
+ if (e.key === "Escape") setDraft(stored);
42251
+ }
42252
+ }
42253
+ );
42254
+ }
42255
+ function EntityAddDialog({
42256
+ open,
42257
+ onOpenChange,
42258
+ noun,
42259
+ name,
42260
+ group,
42261
+ values,
42262
+ groups,
42263
+ startGroup,
42264
+ onAdd
42265
+ }) {
42266
+ const writable = values.filter((c) => editKindOf(c) !== null && editKindOf(c) !== "boolean");
42267
+ const [data, setData] = useState124({});
42268
+ const [chosen, setChosen] = useState124(startGroup);
42269
+ const [busy, setBusy] = useState124(false);
42270
+ const [seenOpen, setSeenOpen] = useState124(open);
42271
+ if (seenOpen !== open) {
42272
+ setSeenOpen(open);
42273
+ if (open) {
42274
+ setData({});
42275
+ setChosen(startGroup);
42276
+ }
42277
+ }
42278
+ const nameWritable = name && editKindOf(name) !== null;
42279
+ const ready = !busy && (!nameWritable || (data[name.key] ?? "").trim() !== "");
42280
+ const rowCls = "grid grid-cols-[6.5rem_1fr] items-start gap-3";
42281
+ const labelCls = "pt-2 text-sm text-muted-foreground";
42282
+ const fields = [...nameWritable ? [name] : [], ...writable.filter((c) => c.key !== name?.key && c.key !== group?.key)];
42283
+ const groupWritable = group && editKindOf(group) === "choice";
42284
+ return /* @__PURE__ */ jsx136(Dialog22, { open, onOpenChange, children: /* @__PURE__ */ jsxs128(DialogContent22, { className: "max-w-md", children: [
42285
+ /* @__PURE__ */ jsx136(DialogHeader22, { children: /* @__PURE__ */ jsxs128(DialogTitle22, { children: [
42286
+ "New ",
42287
+ noun
42288
+ ] }) }),
42289
+ /* @__PURE__ */ jsxs128(
42290
+ "form",
42291
+ {
42292
+ className: "flex flex-col gap-3",
42293
+ onSubmit: async (e) => {
42294
+ e.preventDefault();
42295
+ if (!ready) return;
42296
+ setBusy(true);
42297
+ const out = {};
42298
+ for (const c of fields) {
42299
+ const v = draftValue(editKindOf(c), data[c.key] ?? "");
42300
+ if (v !== null) out[c.key] = v;
42301
+ }
42302
+ if (group && groupWritable && chosen !== UNGROUPED) out[group.key] = chosen;
42303
+ const ok = await onAdd(out);
42304
+ setBusy(false);
42305
+ if (ok) onOpenChange(false);
42306
+ },
42307
+ children: [
42308
+ group && groupWritable ? /* @__PURE__ */ jsxs128("div", { className: rowCls, children: [
42309
+ /* @__PURE__ */ jsx136("span", { className: labelCls, children: group.label }),
42310
+ /* @__PURE__ */ jsxs128(Select21, { value: chosen === UNGROUPED ? "__none" : chosen, onValueChange: (v) => setChosen(v === "__none" ? UNGROUPED : v), children: [
42311
+ /* @__PURE__ */ jsx136(SelectTrigger14, { "aria-label": group.label, children: /* @__PURE__ */ jsx136(SelectValue14, {}) }),
42312
+ /* @__PURE__ */ jsxs128(SelectContent14, { children: [
42313
+ /* @__PURE__ */ jsx136(SelectItem14, { value: "__none", children: "None" }),
42314
+ [.../* @__PURE__ */ new Set([...group.choices ?? [], ...groups.filter((g) => g !== UNGROUPED)])].map((g) => /* @__PURE__ */ jsx136(SelectItem14, { value: g, children: g }, g))
42315
+ ] })
42316
+ ] })
42317
+ ] }) : null,
42318
+ fields.map((c) => {
42319
+ const kind2 = editKindOf(c);
42320
+ return /* @__PURE__ */ jsxs128("div", { className: rowCls, children: [
42321
+ /* @__PURE__ */ jsx136("label", { htmlFor: `entity-section-add-${c.key}`, className: labelCls, children: c.label }),
42322
+ kind2 === "choice" ? /* @__PURE__ */ jsxs128(Select21, { value: data[c.key] || "__none", onValueChange: (v) => setData((d) => ({ ...d, [c.key]: v === "__none" ? "" : v })), children: [
42323
+ /* @__PURE__ */ jsx136(SelectTrigger14, { id: `entity-section-add-${c.key}`, "aria-label": c.label, children: /* @__PURE__ */ jsx136(SelectValue14, {}) }),
42324
+ /* @__PURE__ */ jsxs128(SelectContent14, { children: [
42325
+ /* @__PURE__ */ jsx136(SelectItem14, { value: "__none", children: "None" }),
42326
+ (c.choices ?? []).map((w) => /* @__PURE__ */ jsx136(SelectItem14, { value: w, children: w }, w))
42327
+ ] })
42328
+ ] }) : /* @__PURE__ */ jsx136(
42329
+ BasicInput25,
42330
+ {
42331
+ id: `entity-section-add-${c.key}`,
42332
+ type: kind2 === "number" ? "number" : kind2 === "date" ? "date" : "text",
42333
+ value: data[c.key] ?? "",
42334
+ onChange: (e) => setData((d) => ({ ...d, [c.key]: e.target.value }))
42335
+ }
42336
+ )
42337
+ ] }, c.key);
42338
+ }),
42339
+ /* @__PURE__ */ jsxs128("div", { className: "flex justify-end gap-2 pt-1", children: [
42340
+ /* @__PURE__ */ jsx136(Button102, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
42341
+ /* @__PURE__ */ jsx136(Button102, { type: "submit", disabled: !ready, children: "Add" })
42342
+ ] })
42343
+ ]
42344
+ }
42345
+ )
42346
+ ] }) });
42347
+ }
42348
+ function EntitySectionCard(props) {
42349
+ if (!useOptionalRecordsClient11()) {
42350
+ return /* @__PURE__ */ jsx136("section", { "data-records-section-card": "", className: cn74("rounded-2xl border border-border bg-card px-5 py-5 text-sm text-muted-foreground sm:px-6", props.className), children: "This section cannot be shown here: the page has no connection to the data." });
42351
+ }
42352
+ return /* @__PURE__ */ jsx136(EntityDataScope, { children: /* @__PURE__ */ jsx136(EntitySectionBody, { ...props }) });
42353
+ }
42354
+ function EntitySectionBody(props) {
42355
+ const { source, readOnly, noun = "entry", className } = props;
42356
+ const entity = useEntitySourceTable(source.token, { pageSize: SECTION_PAGE, filter: source.filter ?? null });
42357
+ const cols = entitySectionColumns(entity.columns, props, source.filter);
42358
+ const groups = entitySectionGroups(entity.rows, cols.name, cols.group);
42359
+ const mayWrite = !readOnly && entity.canUpdate;
42360
+ const mayAdd = !readOnly && entity.creatable;
42361
+ const [adding, setAdding] = useState124(null);
42362
+ const [failed, setFailed] = useState124(null);
42363
+ const title = props.title ?? entity.label ?? "";
42364
+ const gridStyle = { gridTemplateColumns: `minmax(8rem, 12rem) repeat(${Math.max(cols.values.length + (cols.note ? 1 : 0), 1)}, minmax(0, 1fr))` };
42365
+ const shownValues = cols.note ? [...cols.values, cols.note] : cols.values;
42366
+ const save = (row) => async (column, value) => {
42367
+ const said = await entity.update(String(row._id), column, value);
42368
+ setFailed(said);
42369
+ return said === null;
42370
+ };
42371
+ return /* @__PURE__ */ jsxs128("section", { "data-records-section-card": "", "data-records-section-source": source.token, className: cn74("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
42372
+ /* @__PURE__ */ jsxs128("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
42373
+ /* @__PURE__ */ jsxs128("div", { className: "min-w-0", children: [
42374
+ /* @__PURE__ */ jsx136("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || " " }),
42375
+ props.description ? /* @__PURE__ */ jsx136("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
42376
+ ] }),
42377
+ mayAdd ? /* @__PURE__ */ jsxs128(Button102, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED), children: [
42378
+ /* @__PURE__ */ jsx136(PlusIcon, { className: "h-3.5 w-3.5" }),
42379
+ "Add"
42380
+ ] }) : null
42381
+ ] }),
42382
+ entity.error ? /* @__PURE__ */ jsx136("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: entity.error }) : entity.loading && entity.rows.length === 0 ? /* @__PURE__ */ jsx136("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx136("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : entity.rows.length === 0 ? /* @__PURE__ */ jsx136("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ jsx136("div", { className: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ jsxs128("div", { "data-records-section-group": group.key, children: [
42383
+ cols.group ? /* @__PURE__ */ jsxs128("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
42384
+ /* @__PURE__ */ jsx136("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
42385
+ mayAdd ? /* @__PURE__ */ jsx136(Button102, { type: "button", variant: "ghost", size: "sm", "aria-label": `Add to ${group.key || "no group"}`, onClick: () => setAdding(group.key), children: /* @__PURE__ */ jsx136(PlusIcon, { className: "h-4 w-4" }) }) : null
42386
+ ] }) : null,
42387
+ /* @__PURE__ */ jsxs128("div", { role: "table", "aria-label": group.key || title, className: "min-w-[36rem]", children: [
42388
+ /* @__PURE__ */ jsxs128("div", { role: "row", style: gridStyle, className: "grid border-b border-border text-xs text-muted-foreground", children: [
42389
+ /* @__PURE__ */ jsx136("span", { role: "columnheader", className: "border-r border-border px-5 py-1.5 sm:px-6", children: cols.name?.label ?? "Name" }),
42390
+ shownValues.map((c) => /* @__PURE__ */ jsx136("span", { role: "columnheader", className: "truncate px-3 py-1.5", children: c.label }, c.key))
42391
+ ] }),
42392
+ group.rows.map((row) => {
42393
+ const rowSave = save(row);
42394
+ return /* @__PURE__ */ jsxs128("div", { role: "row", "data-records-section-row": String(row._id), style: gridStyle, className: "grid items-center border-b border-border", children: [
42395
+ /* @__PURE__ */ jsx136("span", { role: "cell", className: "min-w-0 self-stretch border-r border-border px-5 py-1.5 sm:px-6", children: cols.name && mayWrite && editKindOf(cols.name) !== null ? /* @__PURE__ */ jsx136(EntityValueCell, { row, column: cols.name, editable: true, save: rowSave }) : /* @__PURE__ */ jsx136("span", { className: "block truncate font-mono text-sm text-foreground", children: textOf(row, cols.name) || String(row._id) }) }),
42396
+ shownValues.map((c) => /* @__PURE__ */ jsx136("div", { role: "cell", className: "min-w-0 px-3 py-1", children: /* @__PURE__ */ jsx136(EntityValueCell, { row, column: c, editable: mayWrite, save: rowSave }) }, c.key))
42397
+ ] }, String(row._id));
42398
+ })
42399
+ ] })
42400
+ ] }, group.key || "__ungrouped")) }),
42401
+ entity.hasMore ? /* @__PURE__ */ jsxs128("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: [
42402
+ `Showing ${entity.rows.length} of ${entity.total ?? "more"} \xB7 `,
42403
+ /* @__PURE__ */ jsx136(Button102, { type: "button", variant: "ghost", size: "sm", disabled: entity.loadingMore, onClick: entity.loadMore, children: "Show more" })
42404
+ ] }) : null,
42405
+ entity.newer > 0 ? /* @__PURE__ */ jsx136("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: /* @__PURE__ */ jsx136(Button102, { type: "button", variant: "ghost", size: "sm", onClick: entity.refresh, children: `${entity.newer.toLocaleString()} new` }) }) : null,
42406
+ failed ? /* @__PURE__ */ jsx136("p", { role: "alert", className: "px-5 py-2 text-sm text-warning-ink sm:px-6", children: failed }) : null,
42407
+ /* @__PURE__ */ jsx136(
42408
+ EntityAddDialog,
42409
+ {
42410
+ open: adding !== null,
42411
+ onOpenChange: (open) => !open && setAdding(null),
42412
+ noun,
42413
+ name: cols.name,
42414
+ group: cols.group,
42415
+ values: cols.values,
42416
+ groups: groups.map((g) => g.key),
42417
+ startGroup: adding ?? UNGROUPED,
42418
+ onAdd: async (values) => {
42419
+ const made = await entity.create(values);
42420
+ if ("refused" in made) {
42421
+ setFailed(made.refused);
42422
+ return false;
42423
+ }
42424
+ setFailed(null);
42425
+ return true;
42426
+ }
42427
+ }
42428
+ )
42429
+ ] });
42430
+ }
42431
+
42432
+ // src/SectionCard.tsx
42433
+ import { Fragment as Fragment59, jsx as jsx137, jsxs as jsxs129 } from "react/jsx-runtime";
42434
+ var SAVE_AFTER_MS = 500;
42435
+ var UNGROUPED2 = "";
42109
42436
  function findKey(fields, wanted) {
42110
42437
  for (const key of wanted) if (fields.some((f) => f.key === key)) return key;
42111
42438
  return void 0;
@@ -42120,7 +42447,7 @@ function sectionColumns(fields, titleField, props) {
42120
42447
  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));
42121
42448
  return { name, group, note, readsOn, values };
42122
42449
  }
42123
- var NATURAL = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
42450
+ var NATURAL2 = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
42124
42451
  function orderedRows(rows, nameKey) {
42125
42452
  if (!nameKey) return [...rows];
42126
42453
  const nameOf = (r) => String((r.document ?? {})[nameKey] ?? "");
@@ -42128,20 +42455,20 @@ function orderedRows(rows, nameKey) {
42128
42455
  const x = nameOf(a);
42129
42456
  const y = nameOf(b);
42130
42457
  if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
42131
- return NATURAL.compare(x, y);
42458
+ return NATURAL2.compare(x, y);
42132
42459
  });
42133
42460
  }
42134
42461
  function sectionGroups(rows, groupKey) {
42135
- if (!groupKey) return [{ key: UNGROUPED, rows: [...rows] }];
42462
+ if (!groupKey) return [{ key: UNGROUPED2, rows: [...rows] }];
42136
42463
  const map = /* @__PURE__ */ new Map();
42137
42464
  for (const row of rows) {
42138
42465
  const raw = (row.document ?? {})[groupKey];
42139
- const key = raw === null || raw === void 0 ? UNGROUPED : String(raw);
42466
+ const key = raw === null || raw === void 0 ? UNGROUPED2 : String(raw);
42140
42467
  const held = map.get(key);
42141
42468
  if (held) held.push(row);
42142
42469
  else map.set(key, [row]);
42143
42470
  }
42144
- return [...map.entries()].map(([key, r]) => ({ key, rows: r })).sort((a, b) => (a.key === UNGROUPED ? -1 : 0) - (b.key === UNGROUPED ? -1 : 0));
42471
+ return [...map.entries()].map(([key, r]) => ({ key, rows: r })).sort((a, b) => (a.key === UNGROUPED2 ? -1 : 0) - (b.key === UNGROUPED2 ? -1 : 0));
42145
42472
  }
42146
42473
  function columnsOf(values) {
42147
42474
  const out = [];
@@ -42156,7 +42483,7 @@ function columnsOf(values) {
42156
42483
  }
42157
42484
  var same3 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
42158
42485
  function useDraft(stored, save) {
42159
- const [draft, setDraft] = useState124(null);
42486
+ const [draft, setDraft] = useState125(null);
42160
42487
  const latest = useRef53({ draft, save, stored });
42161
42488
  useEffect109(() => {
42162
42489
  latest.current = { draft, save, stored };
@@ -42185,9 +42512,9 @@ function useDraft(stored, save) {
42185
42512
  }
42186
42513
  function ChecksLine({ checks, onFix }) {
42187
42514
  if (checks.length === 0) return null;
42188
- return /* @__PURE__ */ jsx136("span", { className: "mt-1 flex flex-col items-start gap-1", children: checks.map((check, i) => /* @__PURE__ */ jsxs128("span", { className: "flex flex-col items-start gap-1", children: [
42189
- /* @__PURE__ */ jsx136("span", { className: "text-xs text-warning-ink", children: check.message }),
42190
- check.fix && onFix ? /* @__PURE__ */ jsx136(Button102, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", onClick: () => onFix(check), children: check.fix.label }) : null
42515
+ return /* @__PURE__ */ jsx137("span", { className: "mt-1 flex flex-col items-start gap-1", children: checks.map((check, i) => /* @__PURE__ */ jsxs129("span", { className: "flex flex-col items-start gap-1", children: [
42516
+ /* @__PURE__ */ jsx137("span", { className: "text-xs text-warning-ink", children: check.message }),
42517
+ check.fix && onFix ? /* @__PURE__ */ jsx137(Button103, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", onClick: () => onFix(check), children: check.fix.label }) : null
42191
42518
  ] }, i)) });
42192
42519
  }
42193
42520
  function ValueCell({
@@ -42205,16 +42532,16 @@ function ValueCell({
42205
42532
  const fix = onFix ? (check) => onFix({ check, row, field }) : void 0;
42206
42533
  const id = `section-${row.id}-${field.key}`;
42207
42534
  const withheld = row.hidden?.[field.key] ?? null;
42208
- if (withheld) return /* @__PURE__ */ jsx136(RecordValue, { field, value: null, withheld });
42535
+ if (withheld) return /* @__PURE__ */ jsx137(RecordValue, { field, value: null, withheld });
42209
42536
  if (format?.id === "color_pair") {
42210
42537
  const pair = readColorPair(value) ?? null;
42211
42538
  const contrast = pair ? colorPairContrast(pair, format, context) : {};
42212
- return /* @__PURE__ */ jsx136("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
42539
+ return /* @__PURE__ */ jsx137("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
42213
42540
  const side = part === "light" ? pair?.light : pair?.dark ?? void 0;
42214
42541
  const ratio = contrast[part];
42215
- return /* @__PURE__ */ jsxs128("div", { className: "min-w-0 px-3", children: [
42216
- /* @__PURE__ */ jsxs128("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
42217
- editable ? /* @__PURE__ */ jsx136(
42542
+ return /* @__PURE__ */ jsxs129("div", { className: "min-w-0 px-3", children: [
42543
+ /* @__PURE__ */ jsxs129("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
42544
+ editable ? /* @__PURE__ */ jsx137(
42218
42545
  ColorWell,
42219
42546
  {
42220
42547
  id: `${id}-${part}`,
@@ -42228,10 +42555,10 @@ function ValueCell({
42228
42555
  change(updated.light ? JSON.stringify(updated) : null);
42229
42556
  }
42230
42557
  }
42231
- ) : /* @__PURE__ */ jsx136("code", { className: "font-mono text-xs uppercase", children: side ?? (part === "dark" ? "Inherits light" : "\u2014") }),
42232
- ratio !== void 0 ? /* @__PURE__ */ jsx136(ContrastMark, { ratio }) : null
42558
+ ) : /* @__PURE__ */ jsx137("code", { className: "font-mono text-xs uppercase", children: side ?? (part === "dark" ? "Inherits light" : "\u2014") }),
42559
+ ratio !== void 0 ? /* @__PURE__ */ jsx137(ContrastMark, { ratio }) : null
42233
42560
  ] }),
42234
- /* @__PURE__ */ jsx136(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
42561
+ /* @__PURE__ */ jsx137(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
42235
42562
  ] }, part);
42236
42563
  }) });
42237
42564
  }
@@ -42240,16 +42567,16 @@ function ValueCell({
42240
42567
  const ownDark = typeof value === "string" && value.includes('"dark"');
42241
42568
  const pack = (l) => l.length === 1 ? l[0] : { layers: l };
42242
42569
  const write = (light, dark) => change(JSON.stringify(dark ? { light: pack(light), dark: pack(dark) } : pack(light)));
42243
- return /* @__PURE__ */ jsx136("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
42570
+ return /* @__PURE__ */ jsx137("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
42244
42571
  const layers = pair ? pair[part] : null;
42245
42572
  const words2 = !layers ? "Set" : part === "dark" && !ownDark ? "Same as light" : shadowWords(layers);
42246
- const inner = /* @__PURE__ */ jsxs128("span", { className: "flex min-w-0 items-center gap-2", children: [
42247
- layers ? /* @__PURE__ */ jsx136(ShadowSwatch, { layers, theme: part }) : null,
42248
- /* @__PURE__ */ jsx136("span", { className: cn74("truncate text-xs", part === "dark" && !ownDark ? "text-muted-foreground" : "text-foreground"), children: words2 })
42573
+ const inner = /* @__PURE__ */ jsxs129("span", { className: "flex min-w-0 items-center gap-2", children: [
42574
+ layers ? /* @__PURE__ */ jsx137(ShadowSwatch, { layers, theme: part }) : null,
42575
+ /* @__PURE__ */ jsx137("span", { className: cn75("truncate text-xs", part === "dark" && !ownDark ? "text-muted-foreground" : "text-foreground"), children: words2 })
42249
42576
  ] });
42250
- return /* @__PURE__ */ jsx136("div", { className: "min-w-0 px-3", children: editable ? /* @__PURE__ */ jsxs128(Popover12, { children: [
42251
- /* @__PURE__ */ jsx136(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx136("button", { type: "button", "aria-label": `${fieldName(field)} ${part}`, className: "block w-full min-w-0 rounded-md px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: inner }) }),
42252
- /* @__PURE__ */ jsx136(PopoverContent12, { align: "start", className: "w-80", children: /* @__PURE__ */ jsx136(
42577
+ return /* @__PURE__ */ jsx137("div", { className: "min-w-0 px-3", children: editable ? /* @__PURE__ */ jsxs129(Popover12, { children: [
42578
+ /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137("button", { type: "button", "aria-label": `${fieldName(field)} ${part}`, className: "block w-full min-w-0 rounded-md px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: inner }) }),
42579
+ /* @__PURE__ */ jsx137(PopoverContent12, { align: "start", className: "w-80", children: /* @__PURE__ */ jsx137(
42253
42580
  ShadowLayersEditor,
42254
42581
  {
42255
42582
  layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
@@ -42265,21 +42592,21 @@ function ValueCell({
42265
42592
  const pictureFirst = format?.id === "type_style" || format?.id === "motion";
42266
42593
  if (look && pictureFirst) {
42267
42594
  const { Editor, Preview: Preview2 } = look;
42268
- const view = /* @__PURE__ */ jsx136(RecordValue, { field, value, withheld: null });
42269
- return /* @__PURE__ */ jsxs128("div", { className: "min-w-0", children: [
42270
- editable && Editor ? /* @__PURE__ */ jsxs128(Popover12, { children: [
42271
- /* @__PURE__ */ jsx136(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx136("button", { type: "button", className: "block w-full min-w-0 rounded-md px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: value === null || value === void 0 || value === "" ? /* @__PURE__ */ jsx136("span", { className: "text-muted-foreground", children: "Set" }) : view }) }),
42272
- /* @__PURE__ */ jsxs128(PopoverContent12, { align: "start", className: "w-80", children: [
42273
- Preview2 ? /* @__PURE__ */ jsx136("div", { className: "mb-3", children: /* @__PURE__ */ jsx136(Preview2, { value, format }) }) : null,
42274
- Editor ? /* @__PURE__ */ jsx136(Editor, { value, format, onChange: change, id, label: fieldName(field) }) : null
42595
+ const view = /* @__PURE__ */ jsx137(RecordValue, { field, value, withheld: null });
42596
+ return /* @__PURE__ */ jsxs129("div", { className: "min-w-0", children: [
42597
+ editable && Editor ? /* @__PURE__ */ jsxs129(Popover12, { children: [
42598
+ /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137("button", { type: "button", className: "block w-full min-w-0 rounded-md px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: value === null || value === void 0 || value === "" ? /* @__PURE__ */ jsx137("span", { className: "text-muted-foreground", children: "Set" }) : view }) }),
42599
+ /* @__PURE__ */ jsxs129(PopoverContent12, { align: "start", className: "w-80", children: [
42600
+ Preview2 ? /* @__PURE__ */ jsx137("div", { className: "mb-3", children: /* @__PURE__ */ jsx137(Preview2, { value, format }) }) : null,
42601
+ Editor ? /* @__PURE__ */ jsx137(Editor, { value, format, onChange: change, id, label: fieldName(field) }) : null
42275
42602
  ] })
42276
42603
  ] }) : view,
42277
- /* @__PURE__ */ jsx136(ChecksLine, { checks, onFix: fix })
42604
+ /* @__PURE__ */ jsx137(ChecksLine, { checks, onFix: fix })
42278
42605
  ] });
42279
42606
  }
42280
- return /* @__PURE__ */ jsxs128("div", { className: "min-w-0", children: [
42281
- editable ? /* @__PURE__ */ jsx136(FieldControl, { field, value, onChange: change, id, recordId: row.id }) : /* @__PURE__ */ jsx136(RecordValue, { field, value, withheld: null }),
42282
- /* @__PURE__ */ jsx136(ChecksLine, { checks, onFix: fix })
42607
+ return /* @__PURE__ */ jsxs129("div", { className: "min-w-0", children: [
42608
+ editable ? /* @__PURE__ */ jsx137(FieldControl, { field, value, onChange: change, id, recordId: row.id }) : /* @__PURE__ */ jsx137(RecordValue, { field, value, withheld: null }),
42609
+ /* @__PURE__ */ jsx137(ChecksLine, { checks, onFix: fix })
42283
42610
  ] });
42284
42611
  }
42285
42612
  var NOTHING = "__nothing";
@@ -42294,20 +42621,20 @@ function ReadsOnPicker({
42294
42621
  const stored = (row.document ?? {})[field.key];
42295
42622
  const [value, change] = useDraft(stored, (next) => save(field, next));
42296
42623
  const on = typeof value === "string" && value.trim() !== "" ? value : null;
42297
- const said = problem ? /* @__PURE__ */ jsx136("span", { className: "block truncate text-xs text-warning-ink", "data-records-reads-on-problem": problem, children: READS_ON_PROBLEM_WORDS[problem] }) : null;
42298
- if (!editable) return on ? /* @__PURE__ */ jsxs128(Fragment59, { children: [
42299
- /* @__PURE__ */ jsxs128("span", { className: "block truncate text-xs text-muted-foreground", children: [
42624
+ const said = problem ? /* @__PURE__ */ jsx137("span", { className: "block truncate text-xs text-warning-ink", "data-records-reads-on-problem": problem, children: READS_ON_PROBLEM_WORDS[problem] }) : null;
42625
+ if (!editable) return on ? /* @__PURE__ */ jsxs129(Fragment59, { children: [
42626
+ /* @__PURE__ */ jsxs129("span", { className: "block truncate text-xs text-muted-foreground", children: [
42300
42627
  "on ",
42301
42628
  on
42302
42629
  ] }),
42303
42630
  said
42304
42631
  ] }) : null;
42305
- return /* @__PURE__ */ jsxs128(Fragment59, { children: [
42306
- /* @__PURE__ */ jsxs128(Select21, { value: on ?? NOTHING, onValueChange: (v) => change(v === NOTHING ? null : v), children: [
42307
- /* @__PURE__ */ jsx136(SelectTrigger14, { "aria-label": `${fieldName(field)} for this row`, className: "mt-1 h-6 w-auto max-w-full gap-1 border-0 bg-transparent px-0 text-xs text-muted-foreground shadow-none", children: /* @__PURE__ */ jsx136("span", { className: "truncate", children: on ? `on ${on}` : "on nothing" }) }),
42308
- /* @__PURE__ */ jsxs128(SelectContent14, { children: [
42309
- /* @__PURE__ */ jsx136(SelectItem14, { value: NOTHING, children: "Nothing" }),
42310
- names.map((n) => /* @__PURE__ */ jsx136(SelectItem14, { value: n, children: n }, n))
42632
+ return /* @__PURE__ */ jsxs129(Fragment59, { children: [
42633
+ /* @__PURE__ */ jsxs129(Select22, { value: on ?? NOTHING, onValueChange: (v) => change(v === NOTHING ? null : v), children: [
42634
+ /* @__PURE__ */ jsx137(SelectTrigger15, { "aria-label": `${fieldName(field)} for this row`, className: "mt-1 h-6 w-auto max-w-full gap-1 border-0 bg-transparent px-0 text-xs text-muted-foreground shadow-none", children: /* @__PURE__ */ jsx137("span", { className: "truncate", children: on ? `on ${on}` : "on nothing" }) }),
42635
+ /* @__PURE__ */ jsxs129(SelectContent15, { children: [
42636
+ /* @__PURE__ */ jsx137(SelectItem15, { value: NOTHING, children: "Nothing" }),
42637
+ names.map((n) => /* @__PURE__ */ jsx137(SelectItem15, { value: n, children: n }, n))
42311
42638
  ] })
42312
42639
  ] }),
42313
42640
  said
@@ -42318,7 +42645,7 @@ var READS_ON_PROBLEM_WORDS = {
42318
42645
  missing: "no row by that name",
42319
42646
  self: "reads on itself",
42320
42647
  duplicate: "two rows share that name",
42321
- "no-colour": "that row has no colour"
42648
+ "no-colour": "that row has no color"
42322
42649
  };
42323
42650
  function resolveReadsOn(row, rows, keys) {
42324
42651
  if (!keys.readsOn || !keys.name) return { on: null, problem: null, target: null };
@@ -42342,24 +42669,24 @@ function groundOf(row, rows, keys) {
42342
42669
  return pair ? { ground: { light: pair.light, dark: pair.dark ?? pair.light, label: on } } : { ground: null };
42343
42670
  }
42344
42671
  function RowComments({ tableId, row, count, onClosed }) {
42345
- return /* @__PURE__ */ jsxs128(Popover12, { onOpenChange: (open) => !open && onClosed(), children: [
42346
- /* @__PURE__ */ jsx136(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsxs128(
42672
+ return /* @__PURE__ */ jsxs129(Popover12, { onOpenChange: (open) => !open && onClosed(), children: [
42673
+ /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsxs129(
42347
42674
  "button",
42348
42675
  {
42349
42676
  type: "button",
42350
42677
  "aria-label": count > 0 ? `${count} open comment${count === 1 ? "" : "s"}` : "Comment",
42351
42678
  "data-records-row-comments": count,
42352
- className: cn74(
42679
+ className: cn75(
42353
42680
  "inline-flex h-7 min-w-7 items-center justify-center gap-0.5 rounded-md px-1 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
42354
42681
  count > 0 ? "text-foreground" : "text-muted-foreground"
42355
42682
  ),
42356
42683
  children: [
42357
- /* @__PURE__ */ jsx136(MessageSquareIcon, { className: "h-3.5 w-3.5" }),
42358
- count > 0 ? /* @__PURE__ */ jsx136("span", { className: "text-xs tabular-nums", children: count }) : null
42684
+ /* @__PURE__ */ jsx137(MessageSquareIcon, { className: "h-3.5 w-3.5" }),
42685
+ count > 0 ? /* @__PURE__ */ jsx137("span", { className: "text-xs tabular-nums", children: count }) : null
42359
42686
  ]
42360
42687
  }
42361
42688
  ) }),
42362
- /* @__PURE__ */ jsx136(PopoverContent12, { align: "end", className: "w-96 p-0", children: /* @__PURE__ */ jsx136(CommentThread, { tableId, recordId: row.id, className: "max-h-[70dvh] overflow-y-auto p-3" }) })
42689
+ /* @__PURE__ */ jsx137(PopoverContent12, { align: "end", className: "w-96 p-0", children: /* @__PURE__ */ jsx137(CommentThread, { tableId, recordId: row.id, className: "max-h-[70dvh] overflow-y-auto p-3" }) })
42363
42690
  ] });
42364
42691
  }
42365
42692
  function NoteButton({ row, noteField, editable, save }) {
@@ -42367,21 +42694,21 @@ function NoteButton({ row, noteField, editable, save }) {
42367
42694
  const [value, change] = useDraft(stored, (next) => save(noteField, next));
42368
42695
  const text = typeof value === "string" ? value : "";
42369
42696
  const has = text.trim() !== "";
42370
- return /* @__PURE__ */ jsxs128(Popover12, { children: [
42371
- /* @__PURE__ */ jsx136(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx136(
42697
+ return /* @__PURE__ */ jsxs129(Popover12, { children: [
42698
+ /* @__PURE__ */ jsx137(PopoverTrigger12, { asChild: true, children: /* @__PURE__ */ jsx137(
42372
42699
  "button",
42373
42700
  {
42374
42701
  type: "button",
42375
42702
  "aria-label": has ? `${fieldName(noteField)}: ${text}` : `Add ${fieldName(noteField).toLowerCase()}`,
42376
42703
  title: has ? text : fieldName(noteField),
42377
- className: cn74(
42704
+ className: cn75(
42378
42705
  "inline-flex h-7 w-7 items-center justify-center rounded-md hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
42379
42706
  has ? "text-foreground" : "text-muted-foreground"
42380
42707
  ),
42381
- children: /* @__PURE__ */ jsx136(StickyNoteIcon, { className: "h-4 w-4" })
42708
+ children: /* @__PURE__ */ jsx137(StickyNoteIcon, { className: "h-4 w-4" })
42382
42709
  }
42383
42710
  ) }),
42384
- /* @__PURE__ */ jsx136(PopoverContent12, { align: "end", className: "w-72", children: /* @__PURE__ */ jsx136(
42711
+ /* @__PURE__ */ jsx137(PopoverContent12, { align: "end", className: "w-72", children: /* @__PURE__ */ jsx137(
42385
42712
  BasicTextarea8,
42386
42713
  {
42387
42714
  "aria-label": fieldName(noteField),
@@ -42415,13 +42742,13 @@ function AddDialog({
42415
42742
  }
42416
42743
  return out;
42417
42744
  };
42418
- const [data, setData] = useState124(starters);
42419
- const [name, setName] = useState124("");
42420
- const [group, setGroup] = useState124(startGroup);
42421
- const [newGroup, setNewGroup] = useState124("");
42422
- const [note, setNote] = useState124("");
42423
- const [busy, setBusy] = useState124(false);
42424
- const [seenOpen, setSeenOpen] = useState124(open);
42745
+ const [data, setData] = useState125(starters);
42746
+ const [name, setName] = useState125("");
42747
+ const [group, setGroup] = useState125(startGroup);
42748
+ const [newGroup, setNewGroup] = useState125("");
42749
+ const [note, setNote] = useState125("");
42750
+ const [busy, setBusy] = useState125(false);
42751
+ const [seenOpen, setSeenOpen] = useState125(open);
42425
42752
  if (seenOpen !== open) {
42426
42753
  setSeenOpen(open);
42427
42754
  if (open) {
@@ -42439,12 +42766,12 @@ function AddDialog({
42439
42766
  const ready = !busy && name.trim() !== "" && (!groupField || group !== "__new" || newGroup.trim() !== "");
42440
42767
  const rowCls = "grid grid-cols-[6.5rem_1fr] items-start gap-3";
42441
42768
  const labelCls = "pt-2 text-sm text-muted-foreground";
42442
- return /* @__PURE__ */ jsx136(Dialog22, { open, onOpenChange, children: /* @__PURE__ */ jsxs128(DialogContent22, { className: "max-w-md", children: [
42443
- /* @__PURE__ */ jsx136(DialogHeader22, { children: /* @__PURE__ */ jsxs128(DialogTitle22, { children: [
42769
+ return /* @__PURE__ */ jsx137(Dialog23, { open, onOpenChange, children: /* @__PURE__ */ jsxs129(DialogContent23, { className: "max-w-md", children: [
42770
+ /* @__PURE__ */ jsx137(DialogHeader23, { children: /* @__PURE__ */ jsxs129(DialogTitle23, { children: [
42444
42771
  "New ",
42445
42772
  noun
42446
42773
  ] }) }),
42447
- /* @__PURE__ */ jsxs128(
42774
+ /* @__PURE__ */ jsxs129(
42448
42775
  "form",
42449
42776
  {
42450
42777
  className: "flex flex-col gap-3",
@@ -42453,47 +42780,47 @@ function AddDialog({
42453
42780
  if (!ready || !nameField) return;
42454
42781
  setBusy(true);
42455
42782
  const doc = { ...data, [nameField.key]: name.trim() };
42456
- if (groupField && chosenGroup !== UNGROUPED) doc[groupField.key] = chosenGroup;
42783
+ if (groupField && chosenGroup !== UNGROUPED2) doc[groupField.key] = chosenGroup;
42457
42784
  if (noteField && note.trim() !== "") doc[noteField.key] = note.trim();
42458
42785
  const ok = await onAdd(doc);
42459
42786
  setBusy(false);
42460
42787
  if (ok) onOpenChange(false);
42461
42788
  },
42462
42789
  children: [
42463
- preview ? /* @__PURE__ */ jsx136("div", { children: preview }) : null,
42464
- groupField ? /* @__PURE__ */ jsxs128("div", { className: rowCls, children: [
42465
- /* @__PURE__ */ jsx136("span", { className: labelCls, children: fieldName(groupField) }),
42466
- /* @__PURE__ */ jsxs128("div", { className: "flex flex-col gap-2", children: [
42467
- /* @__PURE__ */ jsxs128(Select21, { value: group === UNGROUPED ? "__none" : group, onValueChange: (v) => setGroup(v === "__none" ? UNGROUPED : v), children: [
42468
- /* @__PURE__ */ jsx136(SelectTrigger14, { "aria-label": fieldName(groupField), children: /* @__PURE__ */ jsx136(SelectValue14, {}) }),
42469
- /* @__PURE__ */ jsxs128(SelectContent14, { children: [
42470
- /* @__PURE__ */ jsx136(SelectItem14, { value: "__none", children: "None" }),
42471
- groups.filter((g) => g !== UNGROUPED).map((g) => /* @__PURE__ */ jsx136(SelectItem14, { value: g, children: g }, g)),
42472
- /* @__PURE__ */ jsxs128(SelectItem14, { value: "__new", children: [
42790
+ preview ? /* @__PURE__ */ jsx137("div", { children: preview }) : null,
42791
+ groupField ? /* @__PURE__ */ jsxs129("div", { className: rowCls, children: [
42792
+ /* @__PURE__ */ jsx137("span", { className: labelCls, children: fieldName(groupField) }),
42793
+ /* @__PURE__ */ jsxs129("div", { className: "flex flex-col gap-2", children: [
42794
+ /* @__PURE__ */ jsxs129(Select22, { value: group === UNGROUPED2 ? "__none" : group, onValueChange: (v) => setGroup(v === "__none" ? UNGROUPED2 : v), children: [
42795
+ /* @__PURE__ */ jsx137(SelectTrigger15, { "aria-label": fieldName(groupField), children: /* @__PURE__ */ jsx137(SelectValue15, {}) }),
42796
+ /* @__PURE__ */ jsxs129(SelectContent15, { children: [
42797
+ /* @__PURE__ */ jsx137(SelectItem15, { value: "__none", children: "None" }),
42798
+ groups.filter((g) => g !== UNGROUPED2).map((g) => /* @__PURE__ */ jsx137(SelectItem15, { value: g, children: g }, g)),
42799
+ /* @__PURE__ */ jsxs129(SelectItem15, { value: "__new", children: [
42473
42800
  "New ",
42474
42801
  fieldName(groupField).toLowerCase(),
42475
42802
  "\u2026"
42476
42803
  ] })
42477
42804
  ] })
42478
42805
  ] }),
42479
- group === "__new" ? /* @__PURE__ */ jsx136(BasicInput25, { "aria-label": `New ${fieldName(groupField).toLowerCase()} name`, placeholder: "e.g. Display", value: newGroup, onChange: (e) => setNewGroup(e.target.value) }) : null
42806
+ group === "__new" ? /* @__PURE__ */ jsx137(BasicInput26, { "aria-label": `New ${fieldName(groupField).toLowerCase()} name`, placeholder: "e.g. Display", value: newGroup, onChange: (e) => setNewGroup(e.target.value) }) : null
42480
42807
  ] })
42481
42808
  ] }) : null,
42482
- nameField ? /* @__PURE__ */ jsxs128("div", { className: rowCls, children: [
42483
- /* @__PURE__ */ jsx136("label", { htmlFor: "section-add-name", className: labelCls, children: fieldName(nameField) }),
42484
- /* @__PURE__ */ jsx136(BasicInput25, { id: "section-add-name", className: "font-mono", autoFocus: true, value: name, onChange: (e) => setName(e.target.value) })
42809
+ nameField ? /* @__PURE__ */ jsxs129("div", { className: rowCls, children: [
42810
+ /* @__PURE__ */ jsx137("label", { htmlFor: "section-add-name", className: labelCls, children: fieldName(nameField) }),
42811
+ /* @__PURE__ */ jsx137(BasicInput26, { id: "section-add-name", className: "font-mono", autoFocus: true, value: name, onChange: (e) => setName(e.target.value) })
42485
42812
  ] }) : null,
42486
- values.map((field) => /* @__PURE__ */ jsxs128("div", { className: rowCls, children: [
42487
- /* @__PURE__ */ jsx136("label", { htmlFor: `section-add-${field.key}`, className: labelCls, children: fieldName(field) }),
42488
- /* @__PURE__ */ jsx136(FieldControl, { field, value: data[field.key] ?? null, onChange: (v) => setData((d) => ({ ...d, [field.key]: v })), id: `section-add-${field.key}`, asForm: true })
42813
+ values.map((field) => /* @__PURE__ */ jsxs129("div", { className: rowCls, children: [
42814
+ /* @__PURE__ */ jsx137("label", { htmlFor: `section-add-${field.key}`, className: labelCls, children: fieldName(field) }),
42815
+ /* @__PURE__ */ jsx137(FieldControl, { field, value: data[field.key] ?? null, onChange: (v) => setData((d) => ({ ...d, [field.key]: v })), id: `section-add-${field.key}`, asForm: true })
42489
42816
  ] }, field.key)),
42490
- noteField ? /* @__PURE__ */ jsxs128("div", { className: rowCls, children: [
42491
- /* @__PURE__ */ jsx136("label", { htmlFor: "section-add-note", className: labelCls, children: fieldName(noteField) }),
42492
- /* @__PURE__ */ jsx136(BasicTextarea8, { id: "section-add-note", rows: 2, placeholder: name.trim() ? `When should ${name.trim()} be used?` : "When should it be used?", value: note, onChange: (e) => setNote(e.target.value) })
42817
+ noteField ? /* @__PURE__ */ jsxs129("div", { className: rowCls, children: [
42818
+ /* @__PURE__ */ jsx137("label", { htmlFor: "section-add-note", className: labelCls, children: fieldName(noteField) }),
42819
+ /* @__PURE__ */ jsx137(BasicTextarea8, { id: "section-add-note", rows: 2, placeholder: name.trim() ? `When should ${name.trim()} be used?` : "When should it be used?", value: note, onChange: (e) => setNote(e.target.value) })
42493
42820
  ] }) : null,
42494
- /* @__PURE__ */ jsxs128("div", { className: "flex justify-end gap-2 pt-1", children: [
42495
- /* @__PURE__ */ jsx136(Button102, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
42496
- /* @__PURE__ */ jsx136(Button102, { type: "submit", disabled: !ready, children: "Add" })
42821
+ /* @__PURE__ */ jsxs129("div", { className: "flex justify-end gap-2 pt-1", children: [
42822
+ /* @__PURE__ */ jsx137(Button103, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
42823
+ /* @__PURE__ */ jsx137(Button103, { type: "submit", disabled: !ready, children: "Add" })
42497
42824
  ] })
42498
42825
  ]
42499
42826
  }
@@ -42501,6 +42828,25 @@ function AddDialog({
42501
42828
  ] }) });
42502
42829
  }
42503
42830
  function SectionCard(props) {
42831
+ if (props.source.kind === "entity") return /* @__PURE__ */ jsx137(EntitySectionCard, { ...props, source: props.source });
42832
+ return /* @__PURE__ */ jsx137(TableSectionCard, { ...props, tableId: props.source.id });
42833
+ }
42834
+ var SECTION_NARROW_PX = 576;
42835
+ function useNarrow2(ref) {
42836
+ const [narrow, setNarrow] = useState125(false);
42837
+ useEffect109(() => {
42838
+ const el = ref.current;
42839
+ if (!el || typeof ResizeObserver === "undefined") return;
42840
+ const ro = new ResizeObserver(() => {
42841
+ const w = el.getBoundingClientRect().width;
42842
+ if (w > 0) setNarrow(w < SECTION_NARROW_PX);
42843
+ });
42844
+ ro.observe(el);
42845
+ return () => ro.disconnect();
42846
+ }, [ref]);
42847
+ return narrow;
42848
+ }
42849
+ function TableSectionCard(props) {
42504
42850
  const { tableId, readOnly, noun = "entry", onFix, className } = props;
42505
42851
  const table = useTable37(tableId);
42506
42852
  const fieldsRead = useFields35(tableId);
@@ -42508,8 +42854,8 @@ function SectionCard(props) {
42508
42854
  const page = useRecordPage4(fieldsRead.data ? tableId : null, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
42509
42855
  const sortedByStore = tableSort !== null;
42510
42856
  const mutation = useRecordMutation3();
42511
- const [adding, setAdding] = useState124(null);
42512
- const [failed, setFailed] = useState124(null);
42857
+ const [adding, setAdding] = useState125(null);
42858
+ const [failed, setFailed] = useState125(null);
42513
42859
  const fields = fieldsRead.data ?? [];
42514
42860
  const cols = sectionColumns(fields, table.data?.title_field, props);
42515
42861
  const nameField = fields.find((f) => f.key === cols.name);
@@ -42531,8 +42877,8 @@ function SectionCard(props) {
42531
42877
  const cells = columns.filter((c) => c.part !== "dark");
42532
42878
  const total = page.data?.total ?? null;
42533
42879
  const client = useRecordsClient95();
42534
- const [counts, setCounts] = useState124({});
42535
- const [countsAsked, setCountsAsked] = useState124(0);
42880
+ const [counts, setCounts] = useState125({});
42881
+ const [countsAsked, setCountsAsked] = useState125(0);
42536
42882
  const idsKey = rows.map((r) => r.id).join(",");
42537
42883
  useEffect109(() => {
42538
42884
  if (idsKey === "") return;
@@ -42547,91 +42893,107 @@ function SectionCard(props) {
42547
42893
  const rowNames = nameField ? rows.map((r) => String((r.document ?? {})[nameField.key] ?? "")).filter((n) => n !== "") : [];
42548
42894
  const refused = table.error ?? fieldsRead.error ?? page.error;
42549
42895
  const gridStyle = { gridTemplateColumns: `minmax(8rem, 12rem) repeat(${Math.max(columns.length, 1)}, minmax(0, 1fr)) 4.5rem` };
42550
- return /* @__PURE__ */ jsxs128("section", { "data-records-section-card": "", className: cn74("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
42551
- /* @__PURE__ */ jsxs128("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
42552
- /* @__PURE__ */ jsxs128("div", { className: "min-w-0", children: [
42553
- /* @__PURE__ */ jsx136("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || "\xA0" }),
42554
- props.description ? /* @__PURE__ */ jsx136("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
42896
+ const sectionRef = useRef53(null);
42897
+ const narrow = useNarrow2(sectionRef);
42898
+ const cellLabel = (c) => c.part ? columns.filter((x) => x.field.key === c.field.key).map((x) => x.header).join(" \xB7 ") : c.header;
42899
+ return /* @__PURE__ */ jsxs129("section", { ref: sectionRef, "data-records-section-card": "", "data-narrow": narrow ? "" : void 0, className: cn75("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
42900
+ /* @__PURE__ */ jsxs129("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
42901
+ /* @__PURE__ */ jsxs129("div", { className: "min-w-0", children: [
42902
+ /* @__PURE__ */ jsx137("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || "\xA0" }),
42903
+ props.description ? /* @__PURE__ */ jsx137("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
42555
42904
  ] }),
42556
- mayWrite && nameField ? /* @__PURE__ */ jsxs128(Button102, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED), children: [
42557
- /* @__PURE__ */ jsx136(PlusIcon, { className: "h-3.5 w-3.5" }),
42905
+ mayWrite && nameField ? /* @__PURE__ */ jsxs129(Button103, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: [
42906
+ /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-3.5 w-3.5" }),
42558
42907
  "Add"
42559
42908
  ] }) : null
42560
42909
  ] }),
42561
- refused ? /* @__PURE__ */ jsx136("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: refusalSentence(refused) }) : !fieldsRead.data || page.loading && rows.length === 0 ? /* @__PURE__ */ jsx136("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx136("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ jsx136("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ jsx136("div", { className: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ jsxs128("div", { "data-records-section-group": group.key, className: "", children: [
42562
- cols.group ? /* @__PURE__ */ jsxs128("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
42563
- /* @__PURE__ */ jsx136("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
42564
- mayWrite ? /* @__PURE__ */ jsx136(
42910
+ refused ? /* @__PURE__ */ jsx137("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: refusalSentence(refused) }) : !fieldsRead.data || page.loading && rows.length === 0 ? /* @__PURE__ */ jsx137("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx137("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ jsx137("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ jsx137("div", { className: cn75("-mb-px", !narrow && "overflow-x-auto"), children: groups.map((group) => /* @__PURE__ */ jsxs129("div", { "data-records-section-group": group.key, className: "", children: [
42911
+ cols.group ? /* @__PURE__ */ jsxs129("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
42912
+ /* @__PURE__ */ jsx137("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
42913
+ mayWrite ? /* @__PURE__ */ jsx137(
42565
42914
  "button",
42566
42915
  {
42567
42916
  type: "button",
42568
42917
  "aria-label": `Add to ${group.key || "no group"}`,
42569
42918
  className: "inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
42570
42919
  onClick: () => setAdding(group.key),
42571
- children: /* @__PURE__ */ jsx136(PlusIcon, { className: "h-4 w-4" })
42920
+ children: /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-4 w-4" })
42572
42921
  }
42573
42922
  ) : null
42574
42923
  ] }) : null,
42575
- /* @__PURE__ */ jsxs128("div", { role: "table", "aria-label": group.key || title, className: "min-w-[36rem]", children: [
42576
- /* @__PURE__ */ jsxs128("div", { role: "row", style: gridStyle, className: "grid border-b border-border text-xs text-muted-foreground", children: [
42577
- /* @__PURE__ */ jsx136("span", { role: "columnheader", className: "border-r border-border px-5 py-1.5 sm:px-6", children: nameField ? fieldName(nameField) : "Name" }),
42578
- columns.map((c) => /* @__PURE__ */ jsx136("span", { role: "columnheader", className: "truncate px-3 py-1.5", children: c.header }, `${c.field.key}-${c.part ?? ""}`)),
42579
- /* @__PURE__ */ jsx136("span", {})
42924
+ /* @__PURE__ */ jsxs129("div", { role: "table", "aria-label": group.key || title, className: narrow ? "" : "min-w-[36rem]", children: [
42925
+ /* @__PURE__ */ jsxs129("div", { role: "row", style: gridStyle, className: cn75("grid border-b border-border text-xs text-muted-foreground", narrow && "hidden"), children: [
42926
+ /* @__PURE__ */ jsx137("span", { role: "columnheader", className: "border-r border-border px-5 py-1.5 sm:px-6", children: nameField ? fieldName(nameField) : "Name" }),
42927
+ columns.map((c) => /* @__PURE__ */ jsx137("span", { role: "columnheader", className: "truncate px-3 py-1.5", children: c.header }, `${c.field.key}-${c.part ?? ""}`)),
42928
+ /* @__PURE__ */ jsx137("span", {})
42580
42929
  ] }),
42581
42930
  group.rows.map((row) => {
42582
42931
  const editable = mayWrite && atLeast(row.level, "edit_content");
42583
42932
  const rowSave = save(row);
42584
- return /* @__PURE__ */ jsxs128("div", { role: "row", "data-records-section-row": row.id, style: gridStyle, className: "grid items-center border-b border-border", children: [
42585
- /* @__PURE__ */ jsxs128("span", { role: "cell", className: "min-w-0 self-stretch border-r border-border px-5 py-1.5 sm:px-6", children: [
42586
- /* @__PURE__ */ jsx136("span", { className: "block truncate font-mono text-sm text-foreground", children: nameField ? String((row.document ?? {})[nameField.key] ?? "") : row.id }),
42587
- readsOnField ? /* @__PURE__ */ jsx136(
42588
- ReadsOnPicker,
42589
- {
42590
- row,
42591
- field: readsOnField,
42592
- names: [...new Set(rowNames)].filter((n) => !sameName(n, String((row.document ?? {})[nameField?.key ?? ""] ?? ""))),
42593
- editable,
42594
- save: rowSave,
42595
- problem: resolveReadsOn(row, rows, { name: cols.name, readsOn: cols.readsOn, color: readsOnColorKey }).problem
42596
- }
42597
- ) : null
42598
- ] }),
42599
- cells.map((c) => /* @__PURE__ */ jsx136(
42600
- "div",
42601
- {
42602
- role: "cell",
42603
- style: c.part ? { gridColumn: "span 2" } : void 0,
42604
- className: cn74("min-w-0 py-1", c.part ? "" : "px-3"),
42605
- children: /* @__PURE__ */ jsx136(
42606
- ValueCell,
42933
+ return /* @__PURE__ */ jsxs129(
42934
+ "div",
42935
+ {
42936
+ role: "row",
42937
+ "data-records-section-row": row.id,
42938
+ style: narrow ? void 0 : gridStyle,
42939
+ className: narrow ? "relative flex flex-col gap-1.5 border-b border-border px-4 py-2.5" : "grid items-center border-b border-border",
42940
+ children: [
42941
+ /* @__PURE__ */ jsxs129("span", { role: "cell", className: narrow ? "min-w-0 pr-16" : "min-w-0 self-stretch border-r border-border px-5 py-1.5 sm:px-6", children: [
42942
+ /* @__PURE__ */ jsx137("span", { className: "block truncate font-mono text-sm text-foreground", children: nameField ? String((row.document ?? {})[nameField.key] ?? "") : row.id }),
42943
+ readsOnField ? /* @__PURE__ */ jsx137(
42944
+ ReadsOnPicker,
42945
+ {
42946
+ row,
42947
+ field: readsOnField,
42948
+ names: [...new Set(rowNames)].filter((n) => !sameName(n, String((row.document ?? {})[nameField?.key ?? ""] ?? ""))),
42949
+ editable,
42950
+ save: rowSave,
42951
+ problem: resolveReadsOn(row, rows, { name: cols.name, readsOn: cols.readsOn, color: readsOnColorKey }).problem
42952
+ }
42953
+ ) : null
42954
+ ] }),
42955
+ cells.map((c) => /* @__PURE__ */ jsxs129(
42956
+ "div",
42607
42957
  {
42608
- row,
42609
- column: c,
42610
- editable,
42611
- save: rowSave,
42612
- onFix,
42613
- context: c.field.key === readsOnColorKey ? groundOf(row, rows, { name: cols.name, readsOn: cols.readsOn, color: c.field.key }) : void 0
42614
- }
42615
- )
42616
- },
42617
- c.field.key
42618
- )),
42619
- /* @__PURE__ */ jsxs128("span", { role: "cell", className: "flex items-center justify-end gap-0.5 pr-2", children: [
42620
- /* @__PURE__ */ jsx136(RowComments, { tableId, row, count: counts[row.id] ?? 0, onClosed: () => setCountsAsked((n) => n + 1) }),
42621
- noteField ? /* @__PURE__ */ jsx136(NoteButton, { row, noteField, editable, save: rowSave }) : null
42622
- ] })
42623
- ] }, row.id);
42958
+ role: "cell",
42959
+ style: c.part ? { gridColumn: "span 2" } : void 0,
42960
+ className: narrow ? "min-w-0" : cn75("min-w-0 py-1", c.part ? "" : "px-3"),
42961
+ children: [
42962
+ narrow ? /* @__PURE__ */ jsx137("span", { className: "mb-0.5 block text-xs text-muted-foreground", children: cellLabel(c) }) : null,
42963
+ /* @__PURE__ */ jsx137(
42964
+ ValueCell,
42965
+ {
42966
+ row,
42967
+ column: c,
42968
+ editable,
42969
+ save: rowSave,
42970
+ onFix,
42971
+ context: c.field.key === readsOnColorKey ? groundOf(row, rows, { name: cols.name, readsOn: cols.readsOn, color: c.field.key }) : void 0
42972
+ }
42973
+ )
42974
+ ]
42975
+ },
42976
+ c.field.key
42977
+ )),
42978
+ /* @__PURE__ */ jsxs129("span", { role: "cell", className: narrow ? "absolute right-2 top-2 flex items-center gap-0.5" : "flex items-center justify-end gap-0.5 pr-2", children: [
42979
+ /* @__PURE__ */ jsx137(RowComments, { tableId, row, count: counts[row.id] ?? 0, onClosed: () => setCountsAsked((n) => n + 1) }),
42980
+ noteField ? /* @__PURE__ */ jsx137(NoteButton, { row, noteField, editable, save: rowSave }) : null
42981
+ ] })
42982
+ ]
42983
+ },
42984
+ row.id
42985
+ );
42624
42986
  })
42625
42987
  ] })
42626
42988
  ] }, group.key || "__ungrouped")) }),
42627
- total !== null && total > rows.length ? /* @__PURE__ */ jsxs128("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: [
42989
+ total !== null && total > rows.length ? /* @__PURE__ */ jsxs129("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: [
42628
42990
  "Showing ",
42629
42991
  rows.length,
42630
42992
  " of ",
42631
42993
  total
42632
42994
  ] }) : null,
42633
- failed ? /* @__PURE__ */ jsx136("p", { className: "px-5 py-2 text-sm text-warning-ink sm:px-6", children: mutation.error ? refusalSentence(mutation.error) : failed }) : null,
42634
- /* @__PURE__ */ jsx136(
42995
+ failed ? /* @__PURE__ */ jsx137("p", { className: "px-5 py-2 text-sm text-warning-ink sm:px-6", children: mutation.error ? refusalSentence(mutation.error) : failed }) : null,
42996
+ /* @__PURE__ */ jsx137(
42635
42997
  AddDialog,
42636
42998
  {
42637
42999
  open: adding !== null,
@@ -42642,7 +43004,7 @@ function SectionCard(props) {
42642
43004
  noteField,
42643
43005
  values: cols.values,
42644
43006
  groups: groups.map((g) => g.key),
42645
- startGroup: adding ?? UNGROUPED,
43007
+ startGroup: adding ?? UNGROUPED2,
42646
43008
  onAdd: async (data) => {
42647
43009
  const id = await mutation.write({ table_id: tableId, data });
42648
43010
  if (id === null) {
@@ -42757,6 +43119,7 @@ export {
42757
43119
  EntityDataScope,
42758
43120
  EntityGrid,
42759
43121
  EntityReferenceKindPicker,
43122
+ EntitySectionCard,
42760
43123
  EntityTablePage,
42761
43124
  ExportMenu,
42762
43125
  FEWEST_KEY_VALUE_PAIRS,
@@ -43083,8 +43446,11 @@ export {
43083
43446
  entityCellValue,
43084
43447
  entityChartQuestion,
43085
43448
  entityChoiceColumns,
43449
+ entityFilterWhere,
43086
43450
  entityNameColumn,
43087
43451
  entityReferenceSpec,
43452
+ entitySectionColumns,
43453
+ entitySectionGroups,
43088
43454
  entityShownColumns,
43089
43455
  entityTableColumns,
43090
43456
  entityTableQuery,