@ai-matrx/records-ui 0.116.23 → 0.116.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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,
@@ -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
@@ -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,10 @@ 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
+ function TableSectionCard(props) {
42504
42835
  const { tableId, readOnly, noun = "entry", onFix, className } = props;
42505
42836
  const table = useTable37(tableId);
42506
42837
  const fieldsRead = useFields35(tableId);
@@ -42508,8 +42839,8 @@ function SectionCard(props) {
42508
42839
  const page = useRecordPage4(fieldsRead.data ? tableId : null, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
42509
42840
  const sortedByStore = tableSort !== null;
42510
42841
  const mutation = useRecordMutation3();
42511
- const [adding, setAdding] = useState124(null);
42512
- const [failed, setFailed] = useState124(null);
42842
+ const [adding, setAdding] = useState125(null);
42843
+ const [failed, setFailed] = useState125(null);
42513
42844
  const fields = fieldsRead.data ?? [];
42514
42845
  const cols = sectionColumns(fields, table.data?.title_field, props);
42515
42846
  const nameField = fields.find((f) => f.key === cols.name);
@@ -42531,8 +42862,8 @@ function SectionCard(props) {
42531
42862
  const cells = columns.filter((c) => c.part !== "dark");
42532
42863
  const total = page.data?.total ?? null;
42533
42864
  const client = useRecordsClient95();
42534
- const [counts, setCounts] = useState124({});
42535
- const [countsAsked, setCountsAsked] = useState124(0);
42865
+ const [counts, setCounts] = useState125({});
42866
+ const [countsAsked, setCountsAsked] = useState125(0);
42536
42867
  const idsKey = rows.map((r) => r.id).join(",");
42537
42868
  useEffect109(() => {
42538
42869
  if (idsKey === "") return;
@@ -42547,44 +42878,44 @@ function SectionCard(props) {
42547
42878
  const rowNames = nameField ? rows.map((r) => String((r.document ?? {})[nameField.key] ?? "")).filter((n) => n !== "") : [];
42548
42879
  const refused = table.error ?? fieldsRead.error ?? page.error;
42549
42880
  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
42881
+ return /* @__PURE__ */ jsxs129("section", { "data-records-section-card": "", className: cn75("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
42882
+ /* @__PURE__ */ jsxs129("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
42883
+ /* @__PURE__ */ jsxs129("div", { className: "min-w-0", children: [
42884
+ /* @__PURE__ */ jsx137("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || "\xA0" }),
42885
+ props.description ? /* @__PURE__ */ jsx137("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
42555
42886
  ] }),
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" }),
42887
+ mayWrite && nameField ? /* @__PURE__ */ jsxs129(Button103, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: [
42888
+ /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-3.5 w-3.5" }),
42558
42889
  "Add"
42559
42890
  ] }) : null
42560
42891
  ] }),
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(
42892
+ 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: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ jsxs129("div", { "data-records-section-group": group.key, className: "", children: [
42893
+ cols.group ? /* @__PURE__ */ jsxs129("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
42894
+ /* @__PURE__ */ jsx137("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
42895
+ mayWrite ? /* @__PURE__ */ jsx137(
42565
42896
  "button",
42566
42897
  {
42567
42898
  type: "button",
42568
42899
  "aria-label": `Add to ${group.key || "no group"}`,
42569
42900
  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
42901
  onClick: () => setAdding(group.key),
42571
- children: /* @__PURE__ */ jsx136(PlusIcon, { className: "h-4 w-4" })
42902
+ children: /* @__PURE__ */ jsx137(PlusIcon2, { className: "h-4 w-4" })
42572
42903
  }
42573
42904
  ) : null
42574
42905
  ] }) : 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", {})
42906
+ /* @__PURE__ */ jsxs129("div", { role: "table", "aria-label": group.key || title, className: "min-w-[36rem]", children: [
42907
+ /* @__PURE__ */ jsxs129("div", { role: "row", style: gridStyle, className: "grid border-b border-border text-xs text-muted-foreground", children: [
42908
+ /* @__PURE__ */ jsx137("span", { role: "columnheader", className: "border-r border-border px-5 py-1.5 sm:px-6", children: nameField ? fieldName(nameField) : "Name" }),
42909
+ columns.map((c) => /* @__PURE__ */ jsx137("span", { role: "columnheader", className: "truncate px-3 py-1.5", children: c.header }, `${c.field.key}-${c.part ?? ""}`)),
42910
+ /* @__PURE__ */ jsx137("span", {})
42580
42911
  ] }),
42581
42912
  group.rows.map((row) => {
42582
42913
  const editable = mayWrite && atLeast(row.level, "edit_content");
42583
42914
  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(
42915
+ return /* @__PURE__ */ jsxs129("div", { role: "row", "data-records-section-row": row.id, style: gridStyle, className: "grid items-center border-b border-border", children: [
42916
+ /* @__PURE__ */ jsxs129("span", { role: "cell", className: "min-w-0 self-stretch border-r border-border px-5 py-1.5 sm:px-6", children: [
42917
+ /* @__PURE__ */ jsx137("span", { className: "block truncate font-mono text-sm text-foreground", children: nameField ? String((row.document ?? {})[nameField.key] ?? "") : row.id }),
42918
+ readsOnField ? /* @__PURE__ */ jsx137(
42588
42919
  ReadsOnPicker,
42589
42920
  {
42590
42921
  row,
@@ -42596,13 +42927,13 @@ function SectionCard(props) {
42596
42927
  }
42597
42928
  ) : null
42598
42929
  ] }),
42599
- cells.map((c) => /* @__PURE__ */ jsx136(
42930
+ cells.map((c) => /* @__PURE__ */ jsx137(
42600
42931
  "div",
42601
42932
  {
42602
42933
  role: "cell",
42603
42934
  style: c.part ? { gridColumn: "span 2" } : void 0,
42604
- className: cn74("min-w-0 py-1", c.part ? "" : "px-3"),
42605
- children: /* @__PURE__ */ jsx136(
42935
+ className: cn75("min-w-0 py-1", c.part ? "" : "px-3"),
42936
+ children: /* @__PURE__ */ jsx137(
42606
42937
  ValueCell,
42607
42938
  {
42608
42939
  row,
@@ -42616,22 +42947,22 @@ function SectionCard(props) {
42616
42947
  },
42617
42948
  c.field.key
42618
42949
  )),
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
42950
+ /* @__PURE__ */ jsxs129("span", { role: "cell", className: "flex items-center justify-end gap-0.5 pr-2", children: [
42951
+ /* @__PURE__ */ jsx137(RowComments, { tableId, row, count: counts[row.id] ?? 0, onClosed: () => setCountsAsked((n) => n + 1) }),
42952
+ noteField ? /* @__PURE__ */ jsx137(NoteButton, { row, noteField, editable, save: rowSave }) : null
42622
42953
  ] })
42623
42954
  ] }, row.id);
42624
42955
  })
42625
42956
  ] })
42626
42957
  ] }, 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: [
42958
+ total !== null && total > rows.length ? /* @__PURE__ */ jsxs129("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: [
42628
42959
  "Showing ",
42629
42960
  rows.length,
42630
42961
  " of ",
42631
42962
  total
42632
42963
  ] }) : 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(
42964
+ 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,
42965
+ /* @__PURE__ */ jsx137(
42635
42966
  AddDialog,
42636
42967
  {
42637
42968
  open: adding !== null,
@@ -42642,7 +42973,7 @@ function SectionCard(props) {
42642
42973
  noteField,
42643
42974
  values: cols.values,
42644
42975
  groups: groups.map((g) => g.key),
42645
- startGroup: adding ?? UNGROUPED,
42976
+ startGroup: adding ?? UNGROUPED2,
42646
42977
  onAdd: async (data) => {
42647
42978
  const id = await mutation.write({ table_id: tableId, data });
42648
42979
  if (id === null) {
@@ -42757,6 +43088,7 @@ export {
42757
43088
  EntityDataScope,
42758
43089
  EntityGrid,
42759
43090
  EntityReferenceKindPicker,
43091
+ EntitySectionCard,
42760
43092
  EntityTablePage,
42761
43093
  ExportMenu,
42762
43094
  FEWEST_KEY_VALUE_PAIRS,
@@ -43083,8 +43415,11 @@ export {
43083
43415
  entityCellValue,
43084
43416
  entityChartQuestion,
43085
43417
  entityChoiceColumns,
43418
+ entityFilterWhere,
43086
43419
  entityNameColumn,
43087
43420
  entityReferenceSpec,
43421
+ entitySectionColumns,
43422
+ entitySectionGroups,
43088
43423
  entityShownColumns,
43089
43424
  entityTableColumns,
43090
43425
  entityTableQuery,