@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/CHANGELOG.md +21 -1
- package/dist/index.cjs +470 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -69
- package/dist/index.d.ts +116 -69
- package/dist/index.js +471 -136
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2374,7 +2374,7 @@ function shapeTextOfNode(node) {
|
|
|
2374
2374
|
for (const r of rows.slice(1)) out.push(`| ${pad4(r).map(cell2).join(" | ")} |`);
|
|
2375
2375
|
rows = [];
|
|
2376
2376
|
};
|
|
2377
|
-
const
|
|
2377
|
+
const textOf2 = (n) => (n.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
2378
2378
|
const walk = (n, depth) => {
|
|
2379
2379
|
if (n.nodeType === 3) {
|
|
2380
2380
|
line += n.textContent ?? "";
|
|
@@ -2385,7 +2385,7 @@ function shapeTextOfNode(node) {
|
|
|
2385
2385
|
const tag = n.nodeType === 1 ? el.tagName.toUpperCase() : "#fragment";
|
|
2386
2386
|
if (tag === "TR") {
|
|
2387
2387
|
const cells = Array.from(el.children).filter((c) => /^(TD|TH)$/i.test(c.tagName));
|
|
2388
|
-
rows.push(cells.map((c) =>
|
|
2388
|
+
rows.push(cells.map((c) => textOf2(c)));
|
|
2389
2389
|
return;
|
|
2390
2390
|
}
|
|
2391
2391
|
if (tag === "TABLE" || tag === "THEAD" || tag === "TBODY" || tag === "TFOOT") {
|
|
@@ -7857,13 +7857,13 @@ __export(src_exports, {
|
|
|
7857
7857
|
ACTION_NO_ACCESS_REASON: () => ACTION_NO_ACCESS_REASON,
|
|
7858
7858
|
ACTION_PLATFORM_TABLE_REASON: () => ACTION_PLATFORM_TABLE_REASON,
|
|
7859
7859
|
ADD_CHOICES: () => ADD_CHOICES,
|
|
7860
|
-
ARCHIVED_NEVER_DESTROYED: () =>
|
|
7860
|
+
ARCHIVED_NEVER_DESTROYED: () => import_design_system182.ARCHIVED_NEVER_DESTROYED,
|
|
7861
7861
|
ARCHIVE_MEANS: () => ARCHIVE_MEANS,
|
|
7862
7862
|
ASK_EXAMPLE: () => ASK_EXAMPLE,
|
|
7863
7863
|
AccentSwatches: () => AccentSwatches,
|
|
7864
7864
|
ActionInbox: () => ActionInbox,
|
|
7865
7865
|
ArchiveDeliberatelyDialog: () => ArchiveDeliberatelyDialog,
|
|
7866
|
-
ArchivedDisclosure: () =>
|
|
7866
|
+
ArchivedDisclosure: () => import_design_system182.ArchivedDisclosure,
|
|
7867
7867
|
ArchivedPortals: () => ArchivedPortals,
|
|
7868
7868
|
ArchivedView: () => ArchivedView,
|
|
7869
7869
|
BODY_COLUMN_NAME: () => BODY_COLUMN_NAME,
|
|
@@ -7933,6 +7933,7 @@ __export(src_exports, {
|
|
|
7933
7933
|
EntityDataScope: () => EntityDataScope,
|
|
7934
7934
|
EntityGrid: () => EntityGrid,
|
|
7935
7935
|
EntityReferenceKindPicker: () => EntityReferenceKindPicker,
|
|
7936
|
+
EntitySectionCard: () => EntitySectionCard,
|
|
7936
7937
|
EntityTablePage: () => EntityTablePage,
|
|
7937
7938
|
ExportMenu: () => ExportMenu,
|
|
7938
7939
|
FEWEST_KEY_VALUE_PAIRS: () => FEWEST_KEY_VALUE_PAIRS,
|
|
@@ -8259,8 +8260,11 @@ __export(src_exports, {
|
|
|
8259
8260
|
entityCellValue: () => entityCellValue,
|
|
8260
8261
|
entityChartQuestion: () => import_first_page9.entityChartQuestion,
|
|
8261
8262
|
entityChoiceColumns: () => entityChoiceColumns,
|
|
8263
|
+
entityFilterWhere: () => entityFilterWhere,
|
|
8262
8264
|
entityNameColumn: () => entityNameColumn,
|
|
8263
8265
|
entityReferenceSpec: () => entityReferenceSpec,
|
|
8266
|
+
entitySectionColumns: () => entitySectionColumns,
|
|
8267
|
+
entitySectionGroups: () => entitySectionGroups,
|
|
8264
8268
|
entityShownColumns: () => entityShownColumns,
|
|
8265
8269
|
entityTableColumns: () => entityTableColumns,
|
|
8266
8270
|
entityTableQuery: () => import_first_page9.entityTableQuery,
|
|
@@ -38310,10 +38314,16 @@ function editTypeOf(column) {
|
|
|
38310
38314
|
if (column.type === "checkbox" || column.type === "boolean") return "boolean";
|
|
38311
38315
|
return false;
|
|
38312
38316
|
}
|
|
38317
|
+
function entityFilterWhere(filter) {
|
|
38318
|
+
if (!filter) return [];
|
|
38319
|
+
return Object.keys(filter).sort().map((column) => ({ column, op: "eq", value: filter[column] }));
|
|
38320
|
+
}
|
|
38313
38321
|
function useEntitySourceTable(token2, options = {}) {
|
|
38314
38322
|
const type = (0, import_react214.useEntityType)(token2);
|
|
38315
38323
|
const columns = (0, import_react214.useEntityColumns)(token2);
|
|
38316
|
-
const
|
|
38324
|
+
const where = entityFilterWhere(options.filter);
|
|
38325
|
+
const query = { ...(0, import_first_page9.entityTableQuery)({ pageSize: options.pageSize, search: options.search }), ...where.length > 0 ? { where } : {} };
|
|
38326
|
+
const list = (0, import_react214.useEntityList)(token2, query);
|
|
38317
38327
|
const write = (0, import_react214.useEntityWrite)(token2);
|
|
38318
38328
|
const shown5 = (0, import_react212.useMemo)(() => entityShownColumns(columns.data ?? []), [columns.data]);
|
|
38319
38329
|
const refused = list.error ?? columns.error ?? type.error;
|
|
@@ -38339,7 +38349,7 @@ function useEntitySourceTable(token2, options = {}) {
|
|
|
38339
38349
|
return answer.ok ? null : refusalSentence(answer.error) || "That change was not saved.";
|
|
38340
38350
|
},
|
|
38341
38351
|
async create(values) {
|
|
38342
|
-
const answer = await write.create(values);
|
|
38352
|
+
const answer = await write.create(options.filter ? { ...values, ...options.filter } : values);
|
|
38343
38353
|
return answer.ok ? { id: answer.data._id } : { refused: refusalSentence(answer.error) || "That row was not added." };
|
|
38344
38354
|
}
|
|
38345
38355
|
};
|
|
@@ -38433,7 +38443,7 @@ function EntityTableCardBody({
|
|
|
38433
38443
|
className
|
|
38434
38444
|
}) {
|
|
38435
38445
|
const batch = initialRows ?? import_data_table16.TABLE_CARD_DEFAULT_INITIAL_ROWS;
|
|
38436
|
-
const entity = useEntitySourceTable(source.token, { pageSize: batch });
|
|
38446
|
+
const entity = useEntitySourceTable(source.token, { pageSize: batch, filter: source.filter ?? null });
|
|
38437
38447
|
const label = entity.label ?? (entity.loading ? "Loading\u2026" : "Table");
|
|
38438
38448
|
return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
|
|
38439
38449
|
import_data_table16.MatrxTableCard,
|
|
@@ -47913,7 +47923,7 @@ function ArchivedPortals({
|
|
|
47913
47923
|
}
|
|
47914
47924
|
|
|
47915
47925
|
// src/index.ts
|
|
47916
|
-
var
|
|
47926
|
+
var import_design_system182 = require("@ai-matrx/design-system");
|
|
47917
47927
|
|
|
47918
47928
|
// src/ViewBar.tsx
|
|
47919
47929
|
var import_react276 = require("react");
|
|
@@ -62995,20 +63005,327 @@ function PreviewForms({ preview, booking }) {
|
|
|
62995
63005
|
}
|
|
62996
63006
|
|
|
62997
63007
|
// src/SectionCard.tsx
|
|
62998
|
-
var
|
|
63008
|
+
var import_react360 = require("react");
|
|
62999
63009
|
var import_field_kinds9 = require("@ai-matrx/records/field-kinds");
|
|
63000
|
-
var
|
|
63001
|
-
var
|
|
63002
|
-
var
|
|
63010
|
+
var import_react361 = require("@ai-matrx/records/react");
|
|
63011
|
+
var import_design_system181 = require("@ai-matrx/design-system");
|
|
63012
|
+
var import_icons3 = require("@ai-matrx/design-system/icons");
|
|
63003
63013
|
var import_field_formats12 = require("@ai-matrx/design-system/field-formats");
|
|
63004
63014
|
init_names();
|
|
63005
63015
|
init_plainWords();
|
|
63006
|
-
|
|
63016
|
+
|
|
63017
|
+
// src/EntitySectionCard.tsx
|
|
63018
|
+
var import_react358 = require("react");
|
|
63019
|
+
var import_react359 = require("@ai-matrx/records/react");
|
|
63020
|
+
var import_design_system180 = require("@ai-matrx/design-system");
|
|
63021
|
+
var import_icons2 = require("@ai-matrx/design-system/icons");
|
|
63022
|
+
|
|
63023
|
+
// src/sectionKeys.ts
|
|
63007
63024
|
var NAME_KEYS4 = ["name", "title", "token", "label"];
|
|
63008
63025
|
var GROUP_KEYS = ["group", "set", "section", "category"];
|
|
63009
63026
|
var NOTE_KEYS = ["usage_note", "note", "notes", "usage"];
|
|
63010
|
-
|
|
63027
|
+
|
|
63028
|
+
// src/EntitySectionCard.tsx
|
|
63029
|
+
var import_jsx_runtime206 = require("react/jsx-runtime");
|
|
63030
|
+
var SECTION_PAGE = 200;
|
|
63031
|
+
var BOOKKEEPING = /* @__PURE__ */ new Set(["id", "organization_id", "created_by", "updated_by", "created_at", "updated_at", "version", "metadata", "test_run_id", "test_expires_at"]);
|
|
63011
63032
|
var UNGROUPED = "";
|
|
63033
|
+
var NATURAL = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
63034
|
+
function entitySectionColumns(columns, props, filter) {
|
|
63035
|
+
const pinned = new Set(Object.keys(filter ?? {}));
|
|
63036
|
+
const live = columns.filter((c) => c.origin === "custom" || !BOOKKEEPING.has(c.key) && !pinned.has(c.key));
|
|
63037
|
+
const byKey = (key) => key ? live.find((c) => c.key === key) : void 0;
|
|
63038
|
+
const firstOf = (keys) => keys.map((k) => byKey(k)).find((c) => c !== void 0);
|
|
63039
|
+
const name = byKey(props.nameField) ?? firstOf(NAME_KEYS4) ?? live.find((c) => c.title) ?? entityNameColumn(live) ?? void 0;
|
|
63040
|
+
const group = props.groupBy === null ? void 0 : byKey(props.groupBy) ?? firstOf(GROUP_KEYS);
|
|
63041
|
+
const note = props.noteField === null ? void 0 : byKey(props.noteField) ?? firstOf(NOTE_KEYS);
|
|
63042
|
+
const taken = new Set([name?.key, group?.key, note?.key].filter(Boolean));
|
|
63043
|
+
const values = props.valueFields ? props.valueFields.map((k) => byKey(k)).filter((c) => c !== void 0) : live.filter((c) => !taken.has(c.key));
|
|
63044
|
+
return { name, group, note, values };
|
|
63045
|
+
}
|
|
63046
|
+
function textOf(row, column) {
|
|
63047
|
+
return column ? entityValueText(column, entityCellValue(row, column)) : "";
|
|
63048
|
+
}
|
|
63049
|
+
function entitySectionGroups(rows, name, group) {
|
|
63050
|
+
const ordered = [...rows].sort((a, b) => {
|
|
63051
|
+
const x = textOf(a, name);
|
|
63052
|
+
const y = textOf(b, name);
|
|
63053
|
+
if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
|
|
63054
|
+
return NATURAL.compare(x, y);
|
|
63055
|
+
});
|
|
63056
|
+
if (!group) return [{ key: UNGROUPED, rows: ordered }];
|
|
63057
|
+
const map = /* @__PURE__ */ new Map();
|
|
63058
|
+
for (const row of ordered) {
|
|
63059
|
+
const key = textOf(row, group);
|
|
63060
|
+
const held = map.get(key);
|
|
63061
|
+
if (held) held.push(row);
|
|
63062
|
+
else map.set(key, [row]);
|
|
63063
|
+
}
|
|
63064
|
+
return [...map.entries()].map(([key, r]) => ({ key, rows: r })).sort((a, b) => (a.key === UNGROUPED ? -1 : 0) - (b.key === UNGROUPED ? -1 : 0));
|
|
63065
|
+
}
|
|
63066
|
+
function editKindOf(column) {
|
|
63067
|
+
if (column.readOnly) return null;
|
|
63068
|
+
if (column.type === "choice") return column.choices && column.choices.length > 0 ? "choice" : null;
|
|
63069
|
+
if (column.linksTo && column.linksTo.length > 0) return null;
|
|
63070
|
+
if (column.type === "boolean" || column.type === "checkbox") return "boolean";
|
|
63071
|
+
if (column.type === "number" || column.type === "integer") return "number";
|
|
63072
|
+
if (column.type === "date") return "date";
|
|
63073
|
+
if (column.type === "text") return "text";
|
|
63074
|
+
return null;
|
|
63075
|
+
}
|
|
63076
|
+
function draftValue(kind2, draft) {
|
|
63077
|
+
if (draft.trim() === "") return null;
|
|
63078
|
+
if (kind2 === "number") {
|
|
63079
|
+
const n = Number(draft);
|
|
63080
|
+
return Number.isFinite(n) ? n : draft;
|
|
63081
|
+
}
|
|
63082
|
+
return draft;
|
|
63083
|
+
}
|
|
63084
|
+
function storedDraft(kind2, row, column) {
|
|
63085
|
+
const v = entityCellValue(row, column);
|
|
63086
|
+
if (v === null || v === void 0) return "";
|
|
63087
|
+
if (kind2 === "date" && typeof v === "string") return v.slice(0, 10);
|
|
63088
|
+
if (kind2 === "number" && typeof v === "number") return String(v);
|
|
63089
|
+
return entityValueText(column, v);
|
|
63090
|
+
}
|
|
63091
|
+
function EntityValueCell({ row, column, editable, save }) {
|
|
63092
|
+
const kind2 = editable ? editKindOf(column) : null;
|
|
63093
|
+
const stored = storedDraft(kind2, row, column);
|
|
63094
|
+
const [draft, setDraft] = (0, import_react358.useState)(stored);
|
|
63095
|
+
const [seen, setSeen] = (0, import_react358.useState)(stored);
|
|
63096
|
+
if (seen !== stored) {
|
|
63097
|
+
setSeen(stored);
|
|
63098
|
+
setDraft(stored);
|
|
63099
|
+
}
|
|
63100
|
+
if (kind2 === null) {
|
|
63101
|
+
const words2 = textOf(row, column);
|
|
63102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("span", { className: (0, import_design_system180.cn)("block truncate text-sm", words2 ? "text-foreground" : "text-muted-foreground"), children: words2 || "\u2013" });
|
|
63103
|
+
}
|
|
63104
|
+
const label = `${column.label}`;
|
|
63105
|
+
if (kind2 === "choice") {
|
|
63106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(
|
|
63107
|
+
import_design_system180.Select,
|
|
63108
|
+
{
|
|
63109
|
+
value: draft === "" ? "__none" : draft,
|
|
63110
|
+
onValueChange: async (v) => {
|
|
63111
|
+
const next = v === "__none" ? "" : v;
|
|
63112
|
+
setDraft(next);
|
|
63113
|
+
if (!await save(column, next === "" ? null : next)) setDraft(stored);
|
|
63114
|
+
},
|
|
63115
|
+
children: [
|
|
63116
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectTrigger, { "aria-label": label, children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectValue, {}) }),
|
|
63117
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.SelectContent, { children: [
|
|
63118
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectItem, { value: "__none", children: "None" }),
|
|
63119
|
+
(column.choices ?? []).map((w) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectItem, { value: w, children: w }, w))
|
|
63120
|
+
] })
|
|
63121
|
+
]
|
|
63122
|
+
}
|
|
63123
|
+
);
|
|
63124
|
+
}
|
|
63125
|
+
if (kind2 === "boolean") {
|
|
63126
|
+
const on = entityCellValue(row, column) === true;
|
|
63127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Checkbox, { "aria-label": label, checked: on, onCheckedChange: (next) => void save(column, next === true) });
|
|
63128
|
+
}
|
|
63129
|
+
const commit = async () => {
|
|
63130
|
+
if (draft === stored) return;
|
|
63131
|
+
if (!await save(column, draftValue(kind2, draft))) setDraft(stored);
|
|
63132
|
+
};
|
|
63133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(
|
|
63134
|
+
import_design_system180.BasicInput,
|
|
63135
|
+
{
|
|
63136
|
+
"aria-label": label,
|
|
63137
|
+
type: kind2 === "number" ? "number" : kind2 === "date" ? "date" : "text",
|
|
63138
|
+
value: draft,
|
|
63139
|
+
onChange: (e) => setDraft(e.target.value),
|
|
63140
|
+
onBlur: () => void commit(),
|
|
63141
|
+
onKeyDown: (e) => {
|
|
63142
|
+
if (e.key === "Enter") e.target.blur();
|
|
63143
|
+
if (e.key === "Escape") setDraft(stored);
|
|
63144
|
+
}
|
|
63145
|
+
}
|
|
63146
|
+
);
|
|
63147
|
+
}
|
|
63148
|
+
function EntityAddDialog({
|
|
63149
|
+
open,
|
|
63150
|
+
onOpenChange,
|
|
63151
|
+
noun,
|
|
63152
|
+
name,
|
|
63153
|
+
group,
|
|
63154
|
+
values,
|
|
63155
|
+
groups,
|
|
63156
|
+
startGroup,
|
|
63157
|
+
onAdd
|
|
63158
|
+
}) {
|
|
63159
|
+
const writable = values.filter((c) => editKindOf(c) !== null && editKindOf(c) !== "boolean");
|
|
63160
|
+
const [data, setData] = (0, import_react358.useState)({});
|
|
63161
|
+
const [chosen, setChosen] = (0, import_react358.useState)(startGroup);
|
|
63162
|
+
const [busy, setBusy] = (0, import_react358.useState)(false);
|
|
63163
|
+
const [seenOpen, setSeenOpen] = (0, import_react358.useState)(open);
|
|
63164
|
+
if (seenOpen !== open) {
|
|
63165
|
+
setSeenOpen(open);
|
|
63166
|
+
if (open) {
|
|
63167
|
+
setData({});
|
|
63168
|
+
setChosen(startGroup);
|
|
63169
|
+
}
|
|
63170
|
+
}
|
|
63171
|
+
const nameWritable = name && editKindOf(name) !== null;
|
|
63172
|
+
const ready = !busy && (!nameWritable || (data[name.key] ?? "").trim() !== "");
|
|
63173
|
+
const rowCls = "grid grid-cols-[6.5rem_1fr] items-start gap-3";
|
|
63174
|
+
const labelCls = "pt-2 text-sm text-muted-foreground";
|
|
63175
|
+
const fields = [...nameWritable ? [name] : [], ...writable.filter((c) => c.key !== name?.key && c.key !== group?.key)];
|
|
63176
|
+
const groupWritable = group && editKindOf(group) === "choice";
|
|
63177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.DialogContent, { className: "max-w-md", children: [
|
|
63178
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.DialogTitle, { children: [
|
|
63179
|
+
"New ",
|
|
63180
|
+
noun
|
|
63181
|
+
] }) }),
|
|
63182
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(
|
|
63183
|
+
"form",
|
|
63184
|
+
{
|
|
63185
|
+
className: "flex flex-col gap-3",
|
|
63186
|
+
onSubmit: async (e) => {
|
|
63187
|
+
e.preventDefault();
|
|
63188
|
+
if (!ready) return;
|
|
63189
|
+
setBusy(true);
|
|
63190
|
+
const out = {};
|
|
63191
|
+
for (const c of fields) {
|
|
63192
|
+
const v = draftValue(editKindOf(c), data[c.key] ?? "");
|
|
63193
|
+
if (v !== null) out[c.key] = v;
|
|
63194
|
+
}
|
|
63195
|
+
if (group && groupWritable && chosen !== UNGROUPED) out[group.key] = chosen;
|
|
63196
|
+
const ok = await onAdd(out);
|
|
63197
|
+
setBusy(false);
|
|
63198
|
+
if (ok) onOpenChange(false);
|
|
63199
|
+
},
|
|
63200
|
+
children: [
|
|
63201
|
+
group && groupWritable ? /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { className: rowCls, children: [
|
|
63202
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)("span", { className: labelCls, children: group.label }),
|
|
63203
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.Select, { value: chosen === UNGROUPED ? "__none" : chosen, onValueChange: (v) => setChosen(v === "__none" ? UNGROUPED : v), children: [
|
|
63204
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectTrigger, { "aria-label": group.label, children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectValue, {}) }),
|
|
63205
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.SelectContent, { children: [
|
|
63206
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectItem, { value: "__none", children: "None" }),
|
|
63207
|
+
[.../* @__PURE__ */ new Set([...group.choices ?? [], ...groups.filter((g) => g !== UNGROUPED)])].map((g) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectItem, { value: g, children: g }, g))
|
|
63208
|
+
] })
|
|
63209
|
+
] })
|
|
63210
|
+
] }) : null,
|
|
63211
|
+
fields.map((c) => {
|
|
63212
|
+
const kind2 = editKindOf(c);
|
|
63213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { className: rowCls, children: [
|
|
63214
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)("label", { htmlFor: `entity-section-add-${c.key}`, className: labelCls, children: c.label }),
|
|
63215
|
+
kind2 === "choice" ? /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.Select, { value: data[c.key] || "__none", onValueChange: (v) => setData((d) => ({ ...d, [c.key]: v === "__none" ? "" : v })), children: [
|
|
63216
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectTrigger, { id: `entity-section-add-${c.key}`, "aria-label": c.label, children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectValue, {}) }),
|
|
63217
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.SelectContent, { children: [
|
|
63218
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectItem, { value: "__none", children: "None" }),
|
|
63219
|
+
(c.choices ?? []).map((w) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.SelectItem, { value: w, children: w }, w))
|
|
63220
|
+
] })
|
|
63221
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(
|
|
63222
|
+
import_design_system180.BasicInput,
|
|
63223
|
+
{
|
|
63224
|
+
id: `entity-section-add-${c.key}`,
|
|
63225
|
+
type: kind2 === "number" ? "number" : kind2 === "date" ? "date" : "text",
|
|
63226
|
+
value: data[c.key] ?? "",
|
|
63227
|
+
onChange: (e) => setData((d) => ({ ...d, [c.key]: e.target.value }))
|
|
63228
|
+
}
|
|
63229
|
+
)
|
|
63230
|
+
] }, c.key);
|
|
63231
|
+
}),
|
|
63232
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { className: "flex justify-end gap-2 pt-1", children: [
|
|
63233
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
|
|
63234
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Button, { type: "submit", disabled: !ready, children: "Add" })
|
|
63235
|
+
] })
|
|
63236
|
+
]
|
|
63237
|
+
}
|
|
63238
|
+
)
|
|
63239
|
+
] }) });
|
|
63240
|
+
}
|
|
63241
|
+
function EntitySectionCard(props) {
|
|
63242
|
+
if (!(0, import_react359.useOptionalRecordsClient)()) {
|
|
63243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("section", { "data-records-section-card": "", className: (0, import_design_system180.cn)("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." });
|
|
63244
|
+
}
|
|
63245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(EntityDataScope, { children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(EntitySectionBody, { ...props }) });
|
|
63246
|
+
}
|
|
63247
|
+
function EntitySectionBody(props) {
|
|
63248
|
+
const { source, readOnly, noun = "entry", className } = props;
|
|
63249
|
+
const entity = useEntitySourceTable(source.token, { pageSize: SECTION_PAGE, filter: source.filter ?? null });
|
|
63250
|
+
const cols = entitySectionColumns(entity.columns, props, source.filter);
|
|
63251
|
+
const groups = entitySectionGroups(entity.rows, cols.name, cols.group);
|
|
63252
|
+
const mayWrite = !readOnly && entity.canUpdate;
|
|
63253
|
+
const mayAdd = !readOnly && entity.creatable;
|
|
63254
|
+
const [adding, setAdding] = (0, import_react358.useState)(null);
|
|
63255
|
+
const [failed, setFailed] = (0, import_react358.useState)(null);
|
|
63256
|
+
const title = props.title ?? entity.label ?? "";
|
|
63257
|
+
const gridStyle = { gridTemplateColumns: `minmax(8rem, 12rem) repeat(${Math.max(cols.values.length + (cols.note ? 1 : 0), 1)}, minmax(0, 1fr))` };
|
|
63258
|
+
const shownValues = cols.note ? [...cols.values, cols.note] : cols.values;
|
|
63259
|
+
const save = (row) => async (column, value) => {
|
|
63260
|
+
const said2 = await entity.update(String(row._id), column, value);
|
|
63261
|
+
setFailed(said2);
|
|
63262
|
+
return said2 === null;
|
|
63263
|
+
};
|
|
63264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("section", { "data-records-section-card": "", "data-records-section-source": source.token, className: (0, import_design_system180.cn)("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
|
|
63265
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
|
|
63266
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { className: "min-w-0", children: [
|
|
63267
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || " " }),
|
|
63268
|
+
props.description ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
|
|
63269
|
+
] }),
|
|
63270
|
+
mayAdd ? /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(import_design_system180.Button, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED), children: [
|
|
63271
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_icons2.PlusIcon, { className: "h-3.5 w-3.5" }),
|
|
63272
|
+
"Add"
|
|
63273
|
+
] }) : null
|
|
63274
|
+
] }),
|
|
63275
|
+
entity.error ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: entity.error }) : entity.loading && entity.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("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__ */ (0, import_jsx_runtime206.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : entity.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("div", { className: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { "data-records-section-group": group.key, children: [
|
|
63276
|
+
cols.group ? /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
|
|
63277
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
|
|
63278
|
+
mayAdd ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Add to ${group.key || "no group"}`, onClick: () => setAdding(group.key), children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_icons2.PlusIcon, { className: "h-4 w-4" }) }) : null
|
|
63279
|
+
] }) : null,
|
|
63280
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { role: "table", "aria-label": group.key || title, className: "min-w-[36rem]", children: [
|
|
63281
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { role: "row", style: gridStyle, className: "grid border-b border-border text-xs text-muted-foreground", children: [
|
|
63282
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)("span", { role: "columnheader", className: "border-r border-border px-5 py-1.5 sm:px-6", children: cols.name?.label ?? "Name" }),
|
|
63283
|
+
shownValues.map((c) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("span", { role: "columnheader", className: "truncate px-3 py-1.5", children: c.label }, c.key))
|
|
63284
|
+
] }),
|
|
63285
|
+
group.rows.map((row) => {
|
|
63286
|
+
const rowSave = save(row);
|
|
63287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("div", { role: "row", "data-records-section-row": String(row._id), style: gridStyle, className: "grid items-center border-b border-border", children: [
|
|
63288
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)("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__ */ (0, import_jsx_runtime206.jsx)(EntityValueCell, { row, column: cols.name, editable: true, save: rowSave }) : /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("span", { className: "block truncate font-mono text-sm text-foreground", children: textOf(row, cols.name) || String(row._id) }) }),
|
|
63289
|
+
shownValues.map((c) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("div", { role: "cell", className: "min-w-0 px-3 py-1", children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(EntityValueCell, { row, column: c, editable: mayWrite, save: rowSave }) }, c.key))
|
|
63290
|
+
] }, String(row._id));
|
|
63291
|
+
})
|
|
63292
|
+
] })
|
|
63293
|
+
] }, group.key || "__ungrouped")) }),
|
|
63294
|
+
entity.hasMore ? /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: [
|
|
63295
|
+
`Showing ${entity.rows.length} of ${entity.total ?? "more"} \xB7 `,
|
|
63296
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Button, { type: "button", variant: "ghost", size: "sm", disabled: entity.loadingMore, onClick: entity.loadMore, children: "Show more" })
|
|
63297
|
+
] }) : null,
|
|
63298
|
+
entity.newer > 0 ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_design_system180.Button, { type: "button", variant: "ghost", size: "sm", onClick: entity.refresh, children: `${entity.newer.toLocaleString()} new` }) }) : null,
|
|
63299
|
+
failed ? /* @__PURE__ */ (0, import_jsx_runtime206.jsx)("p", { role: "alert", className: "px-5 py-2 text-sm text-warning-ink sm:px-6", children: failed }) : null,
|
|
63300
|
+
/* @__PURE__ */ (0, import_jsx_runtime206.jsx)(
|
|
63301
|
+
EntityAddDialog,
|
|
63302
|
+
{
|
|
63303
|
+
open: adding !== null,
|
|
63304
|
+
onOpenChange: (open) => !open && setAdding(null),
|
|
63305
|
+
noun,
|
|
63306
|
+
name: cols.name,
|
|
63307
|
+
group: cols.group,
|
|
63308
|
+
values: cols.values,
|
|
63309
|
+
groups: groups.map((g) => g.key),
|
|
63310
|
+
startGroup: adding ?? UNGROUPED,
|
|
63311
|
+
onAdd: async (values) => {
|
|
63312
|
+
const made = await entity.create(values);
|
|
63313
|
+
if ("refused" in made) {
|
|
63314
|
+
setFailed(made.refused);
|
|
63315
|
+
return false;
|
|
63316
|
+
}
|
|
63317
|
+
setFailed(null);
|
|
63318
|
+
return true;
|
|
63319
|
+
}
|
|
63320
|
+
}
|
|
63321
|
+
)
|
|
63322
|
+
] });
|
|
63323
|
+
}
|
|
63324
|
+
|
|
63325
|
+
// src/SectionCard.tsx
|
|
63326
|
+
var import_jsx_runtime207 = require("react/jsx-runtime");
|
|
63327
|
+
var SAVE_AFTER_MS = 500;
|
|
63328
|
+
var UNGROUPED2 = "";
|
|
63012
63329
|
function findKey(fields, wanted) {
|
|
63013
63330
|
for (const key of wanted) if (fields.some((f) => f.key === key)) return key;
|
|
63014
63331
|
return void 0;
|
|
@@ -63023,7 +63340,7 @@ function sectionColumns(fields, titleField, props) {
|
|
|
63023
63340
|
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));
|
|
63024
63341
|
return { name, group, note, readsOn, values };
|
|
63025
63342
|
}
|
|
63026
|
-
var
|
|
63343
|
+
var NATURAL2 = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
63027
63344
|
function orderedRows(rows, nameKey) {
|
|
63028
63345
|
if (!nameKey) return [...rows];
|
|
63029
63346
|
const nameOf3 = (r) => String((r.document ?? {})[nameKey] ?? "");
|
|
@@ -63031,20 +63348,20 @@ function orderedRows(rows, nameKey) {
|
|
|
63031
63348
|
const x = nameOf3(a);
|
|
63032
63349
|
const y = nameOf3(b);
|
|
63033
63350
|
if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
|
|
63034
|
-
return
|
|
63351
|
+
return NATURAL2.compare(x, y);
|
|
63035
63352
|
});
|
|
63036
63353
|
}
|
|
63037
63354
|
function sectionGroups(rows, groupKey) {
|
|
63038
|
-
if (!groupKey) return [{ key:
|
|
63355
|
+
if (!groupKey) return [{ key: UNGROUPED2, rows: [...rows] }];
|
|
63039
63356
|
const map = /* @__PURE__ */ new Map();
|
|
63040
63357
|
for (const row of rows) {
|
|
63041
63358
|
const raw = (row.document ?? {})[groupKey];
|
|
63042
|
-
const key = raw === null || raw === void 0 ?
|
|
63359
|
+
const key = raw === null || raw === void 0 ? UNGROUPED2 : String(raw);
|
|
63043
63360
|
const held = map.get(key);
|
|
63044
63361
|
if (held) held.push(row);
|
|
63045
63362
|
else map.set(key, [row]);
|
|
63046
63363
|
}
|
|
63047
|
-
return [...map.entries()].map(([key, r]) => ({ key, rows: r })).sort((a, b) => (a.key ===
|
|
63364
|
+
return [...map.entries()].map(([key, r]) => ({ key, rows: r })).sort((a, b) => (a.key === UNGROUPED2 ? -1 : 0) - (b.key === UNGROUPED2 ? -1 : 0));
|
|
63048
63365
|
}
|
|
63049
63366
|
function columnsOf(values) {
|
|
63050
63367
|
const out = [];
|
|
@@ -63059,12 +63376,12 @@ function columnsOf(values) {
|
|
|
63059
63376
|
}
|
|
63060
63377
|
var same4 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
|
|
63061
63378
|
function useDraft(stored, save) {
|
|
63062
|
-
const [draft, setDraft] = (0,
|
|
63063
|
-
const latest = (0,
|
|
63064
|
-
(0,
|
|
63379
|
+
const [draft, setDraft] = (0, import_react360.useState)(null);
|
|
63380
|
+
const latest = (0, import_react360.useRef)({ draft, save, stored });
|
|
63381
|
+
(0, import_react360.useEffect)(() => {
|
|
63065
63382
|
latest.current = { draft, save, stored };
|
|
63066
63383
|
});
|
|
63067
|
-
(0,
|
|
63384
|
+
(0, import_react360.useEffect)(() => {
|
|
63068
63385
|
if (!draft || draft.phase !== "typing") return;
|
|
63069
63386
|
const timer = setTimeout(() => {
|
|
63070
63387
|
const sending = draft.value;
|
|
@@ -63076,7 +63393,7 @@ function useDraft(stored, save) {
|
|
|
63076
63393
|
}, SAVE_AFTER_MS);
|
|
63077
63394
|
return () => clearTimeout(timer);
|
|
63078
63395
|
}, [draft]);
|
|
63079
|
-
(0,
|
|
63396
|
+
(0, import_react360.useEffect)(
|
|
63080
63397
|
() => () => {
|
|
63081
63398
|
const held = latest.current;
|
|
63082
63399
|
if (held.draft && held.draft.phase === "typing") void held.save(held.draft.value);
|
|
@@ -63088,9 +63405,9 @@ function useDraft(stored, save) {
|
|
|
63088
63405
|
}
|
|
63089
63406
|
function ChecksLine({ checks, onFix }) {
|
|
63090
63407
|
if (checks.length === 0) return null;
|
|
63091
|
-
return /* @__PURE__ */ (0,
|
|
63092
|
-
/* @__PURE__ */ (0,
|
|
63093
|
-
check.fix && onFix ? /* @__PURE__ */ (0,
|
|
63408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "mt-1 flex flex-col items-start gap-1", children: checks.map((check, i) => /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { className: "flex flex-col items-start gap-1", children: [
|
|
63409
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-xs text-warning-ink", children: check.message }),
|
|
63410
|
+
check.fix && onFix ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Button, { type: "button", size: "sm", variant: "outline", className: "h-6 px-2 text-xs", onClick: () => onFix(check), children: check.fix.label }) : null
|
|
63094
63411
|
] }, i)) });
|
|
63095
63412
|
}
|
|
63096
63413
|
function ValueCell({
|
|
@@ -63108,16 +63425,16 @@ function ValueCell({
|
|
|
63108
63425
|
const fix = onFix ? (check) => onFix({ check, row, field: field2 }) : void 0;
|
|
63109
63426
|
const id = `section-${row.id}-${field2.key}`;
|
|
63110
63427
|
const withheld = row.hidden?.[field2.key] ?? null;
|
|
63111
|
-
if (withheld) return /* @__PURE__ */ (0,
|
|
63428
|
+
if (withheld) return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(RecordValue, { field: field2, value: null, withheld });
|
|
63112
63429
|
if (format?.id === "color_pair") {
|
|
63113
63430
|
const pair = (0, import_field_formats12.readColorPair)(value) ?? null;
|
|
63114
63431
|
const contrast = pair ? colorPairContrast(pair, format, context) : {};
|
|
63115
|
-
return /* @__PURE__ */ (0,
|
|
63432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
|
|
63116
63433
|
const side = part === "light" ? pair?.light : pair?.dark ?? void 0;
|
|
63117
63434
|
const ratio = contrast[part];
|
|
63118
|
-
return /* @__PURE__ */ (0,
|
|
63119
|
-
/* @__PURE__ */ (0,
|
|
63120
|
-
editable ? /* @__PURE__ */ (0,
|
|
63435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "min-w-0 px-3", children: [
|
|
63436
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
63437
|
+
editable ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63121
63438
|
ColorWell,
|
|
63122
63439
|
{
|
|
63123
63440
|
id: `${id}-${part}`,
|
|
@@ -63131,10 +63448,10 @@ function ValueCell({
|
|
|
63131
63448
|
change(updated.light ? JSON.stringify(updated) : null);
|
|
63132
63449
|
}
|
|
63133
63450
|
}
|
|
63134
|
-
) : /* @__PURE__ */ (0,
|
|
63135
|
-
ratio !== void 0 ? /* @__PURE__ */ (0,
|
|
63451
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("code", { className: "font-mono text-xs uppercase", children: side ?? (part === "dark" ? "Inherits light" : "\u2014") }),
|
|
63452
|
+
ratio !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ContrastMark, { ratio }) : null
|
|
63136
63453
|
] }),
|
|
63137
|
-
/* @__PURE__ */ (0,
|
|
63454
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
|
|
63138
63455
|
] }, part);
|
|
63139
63456
|
}) });
|
|
63140
63457
|
}
|
|
@@ -63143,16 +63460,16 @@ function ValueCell({
|
|
|
63143
63460
|
const ownDark = typeof value === "string" && value.includes('"dark"');
|
|
63144
63461
|
const pack = (l) => l.length === 1 ? l[0] : { layers: l };
|
|
63145
63462
|
const write = (light, dark) => change(JSON.stringify(dark ? { light: pack(light), dark: pack(dark) } : pack(light)));
|
|
63146
|
-
return /* @__PURE__ */ (0,
|
|
63463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "grid min-w-0 grid-cols-2", children: ["light", "dark"].map((part) => {
|
|
63147
63464
|
const layers = pair ? pair[part] : null;
|
|
63148
63465
|
const words2 = !layers ? "Set" : part === "dark" && !ownDark ? "Same as light" : (0, import_field_formats12.shadowWords)(layers);
|
|
63149
|
-
const inner2 = /* @__PURE__ */ (0,
|
|
63150
|
-
layers ? /* @__PURE__ */ (0,
|
|
63151
|
-
/* @__PURE__ */ (0,
|
|
63466
|
+
const inner2 = /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
63467
|
+
layers ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ShadowSwatch, { layers, theme: part }) : null,
|
|
63468
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: (0, import_design_system181.cn)("truncate text-xs", part === "dark" && !ownDark ? "text-muted-foreground" : "text-foreground"), children: words2 })
|
|
63152
63469
|
] });
|
|
63153
|
-
return /* @__PURE__ */ (0,
|
|
63154
|
-
/* @__PURE__ */ (0,
|
|
63155
|
-
/* @__PURE__ */ (0,
|
|
63470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "min-w-0 px-3", children: editable ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { children: [
|
|
63471
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("button", { type: "button", "aria-label": `${fieldName(field2)} ${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: inner2 }) }),
|
|
63472
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "start", className: "w-80", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63156
63473
|
ShadowLayersEditor,
|
|
63157
63474
|
{
|
|
63158
63475
|
layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
|
|
@@ -63168,21 +63485,21 @@ function ValueCell({
|
|
|
63168
63485
|
const pictureFirst = format?.id === "type_style" || format?.id === "motion";
|
|
63169
63486
|
if (look && pictureFirst) {
|
|
63170
63487
|
const { Editor, Preview: Preview2 } = look;
|
|
63171
|
-
const view = /* @__PURE__ */ (0,
|
|
63172
|
-
return /* @__PURE__ */ (0,
|
|
63173
|
-
editable && Editor ? /* @__PURE__ */ (0,
|
|
63174
|
-
/* @__PURE__ */ (0,
|
|
63175
|
-
/* @__PURE__ */ (0,
|
|
63176
|
-
Preview2 ? /* @__PURE__ */ (0,
|
|
63177
|
-
Editor ? /* @__PURE__ */ (0,
|
|
63488
|
+
const view = /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(RecordValue, { field: field2, value, withheld: null });
|
|
63489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "min-w-0", children: [
|
|
63490
|
+
editable && Editor ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { children: [
|
|
63491
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("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__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-muted-foreground", children: "Set" }) : view }) }),
|
|
63492
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.PopoverContent, { align: "start", className: "w-80", children: [
|
|
63493
|
+
Preview2 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(Preview2, { value, format }) }) : null,
|
|
63494
|
+
Editor ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(Editor, { value, format, onChange: change, id, label: fieldName(field2) }) : null
|
|
63178
63495
|
] })
|
|
63179
63496
|
] }) : view,
|
|
63180
|
-
/* @__PURE__ */ (0,
|
|
63497
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ChecksLine, { checks, onFix: fix })
|
|
63181
63498
|
] });
|
|
63182
63499
|
}
|
|
63183
|
-
return /* @__PURE__ */ (0,
|
|
63184
|
-
editable ? /* @__PURE__ */ (0,
|
|
63185
|
-
/* @__PURE__ */ (0,
|
|
63500
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "min-w-0", children: [
|
|
63501
|
+
editable ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(FieldControl, { field: field2, value, onChange: change, id, recordId: row.id }) : /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(RecordValue, { field: field2, value, withheld: null }),
|
|
63502
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ChecksLine, { checks, onFix: fix })
|
|
63186
63503
|
] });
|
|
63187
63504
|
}
|
|
63188
63505
|
var NOTHING2 = "__nothing";
|
|
@@ -63197,20 +63514,20 @@ function ReadsOnPicker({
|
|
|
63197
63514
|
const stored = (row.document ?? {})[field2.key];
|
|
63198
63515
|
const [value, change] = useDraft(stored, (next) => save(field2, next));
|
|
63199
63516
|
const on = typeof value === "string" && value.trim() !== "" ? value : null;
|
|
63200
|
-
const said2 = problem ? /* @__PURE__ */ (0,
|
|
63201
|
-
if (!editable) return on ? /* @__PURE__ */ (0,
|
|
63202
|
-
/* @__PURE__ */ (0,
|
|
63517
|
+
const said2 = problem ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "block truncate text-xs text-warning-ink", "data-records-reads-on-problem": problem, children: READS_ON_PROBLEM_WORDS[problem] }) : null;
|
|
63518
|
+
if (!editable) return on ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_jsx_runtime207.Fragment, { children: [
|
|
63519
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { className: "block truncate text-xs text-muted-foreground", children: [
|
|
63203
63520
|
"on ",
|
|
63204
63521
|
on
|
|
63205
63522
|
] }),
|
|
63206
63523
|
said2
|
|
63207
63524
|
] }) : null;
|
|
63208
|
-
return /* @__PURE__ */ (0,
|
|
63209
|
-
/* @__PURE__ */ (0,
|
|
63210
|
-
/* @__PURE__ */ (0,
|
|
63211
|
-
/* @__PURE__ */ (0,
|
|
63212
|
-
/* @__PURE__ */ (0,
|
|
63213
|
-
names2.map((n) => /* @__PURE__ */ (0,
|
|
63525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_jsx_runtime207.Fragment, { children: [
|
|
63526
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Select, { value: on ?? NOTHING2, onValueChange: (v) => change(v === NOTHING2 ? null : v), children: [
|
|
63527
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectTrigger, { "aria-label": `${fieldName(field2)} 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__ */ (0, import_jsx_runtime207.jsx)("span", { className: "truncate", children: on ? `on ${on}` : "on nothing" }) }),
|
|
63528
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.SelectContent, { children: [
|
|
63529
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectItem, { value: NOTHING2, children: "Nothing" }),
|
|
63530
|
+
names2.map((n) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectItem, { value: n, children: n }, n))
|
|
63214
63531
|
] })
|
|
63215
63532
|
] }),
|
|
63216
63533
|
said2
|
|
@@ -63245,24 +63562,24 @@ function groundOf(row, rows, keys) {
|
|
|
63245
63562
|
return pair ? { ground: { light: pair.light, dark: pair.dark ?? pair.light, label: on } } : { ground: null };
|
|
63246
63563
|
}
|
|
63247
63564
|
function RowComments({ tableId, row, count, onClosed }) {
|
|
63248
|
-
return /* @__PURE__ */ (0,
|
|
63249
|
-
/* @__PURE__ */ (0,
|
|
63565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { onOpenChange: (open) => !open && onClosed(), children: [
|
|
63566
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(
|
|
63250
63567
|
"button",
|
|
63251
63568
|
{
|
|
63252
63569
|
type: "button",
|
|
63253
63570
|
"aria-label": count > 0 ? `${count} open comment${count === 1 ? "" : "s"}` : "Comment",
|
|
63254
63571
|
"data-records-row-comments": count,
|
|
63255
|
-
className: (0,
|
|
63572
|
+
className: (0, import_design_system181.cn)(
|
|
63256
63573
|
"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",
|
|
63257
63574
|
count > 0 ? "text-foreground" : "text-muted-foreground"
|
|
63258
63575
|
),
|
|
63259
63576
|
children: [
|
|
63260
|
-
/* @__PURE__ */ (0,
|
|
63261
|
-
count > 0 ? /* @__PURE__ */ (0,
|
|
63577
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.MessageSquareIcon, { className: "h-3.5 w-3.5" }),
|
|
63578
|
+
count > 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-xs tabular-nums", children: count }) : null
|
|
63262
63579
|
]
|
|
63263
63580
|
}
|
|
63264
63581
|
) }),
|
|
63265
|
-
/* @__PURE__ */ (0,
|
|
63582
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "end", className: "w-96 p-0", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(CommentThread, { tableId, recordId: row.id, className: "max-h-[70dvh] overflow-y-auto p-3" }) })
|
|
63266
63583
|
] });
|
|
63267
63584
|
}
|
|
63268
63585
|
function NoteButton({ row, noteField, editable, save }) {
|
|
@@ -63270,22 +63587,22 @@ function NoteButton({ row, noteField, editable, save }) {
|
|
|
63270
63587
|
const [value, change] = useDraft(stored, (next) => save(noteField, next));
|
|
63271
63588
|
const text = typeof value === "string" ? value : "";
|
|
63272
63589
|
const has = text.trim() !== "";
|
|
63273
|
-
return /* @__PURE__ */ (0,
|
|
63274
|
-
/* @__PURE__ */ (0,
|
|
63590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Popover, { children: [
|
|
63591
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63275
63592
|
"button",
|
|
63276
63593
|
{
|
|
63277
63594
|
type: "button",
|
|
63278
63595
|
"aria-label": has ? `${fieldName(noteField)}: ${text}` : `Add ${fieldName(noteField).toLowerCase()}`,
|
|
63279
63596
|
title: has ? text : fieldName(noteField),
|
|
63280
|
-
className: (0,
|
|
63597
|
+
className: (0, import_design_system181.cn)(
|
|
63281
63598
|
"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",
|
|
63282
63599
|
has ? "text-foreground" : "text-muted-foreground"
|
|
63283
63600
|
),
|
|
63284
|
-
children: /* @__PURE__ */ (0,
|
|
63601
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.StickyNoteIcon, { className: "h-4 w-4" })
|
|
63285
63602
|
}
|
|
63286
63603
|
) }),
|
|
63287
|
-
/* @__PURE__ */ (0,
|
|
63288
|
-
|
|
63604
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.PopoverContent, { align: "end", className: "w-72", children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63605
|
+
import_design_system181.BasicTextarea,
|
|
63289
63606
|
{
|
|
63290
63607
|
"aria-label": fieldName(noteField),
|
|
63291
63608
|
rows: 4,
|
|
@@ -63318,13 +63635,13 @@ function AddDialog({
|
|
|
63318
63635
|
}
|
|
63319
63636
|
return out;
|
|
63320
63637
|
};
|
|
63321
|
-
const [data, setData] = (0,
|
|
63322
|
-
const [name, setName] = (0,
|
|
63323
|
-
const [group, setGroup] = (0,
|
|
63324
|
-
const [newGroup, setNewGroup] = (0,
|
|
63325
|
-
const [note, setNote] = (0,
|
|
63326
|
-
const [busy, setBusy] = (0,
|
|
63327
|
-
const [seenOpen, setSeenOpen] = (0,
|
|
63638
|
+
const [data, setData] = (0, import_react360.useState)(starters);
|
|
63639
|
+
const [name, setName] = (0, import_react360.useState)("");
|
|
63640
|
+
const [group, setGroup] = (0, import_react360.useState)(startGroup);
|
|
63641
|
+
const [newGroup, setNewGroup] = (0, import_react360.useState)("");
|
|
63642
|
+
const [note, setNote] = (0, import_react360.useState)("");
|
|
63643
|
+
const [busy, setBusy] = (0, import_react360.useState)(false);
|
|
63644
|
+
const [seenOpen, setSeenOpen] = (0, import_react360.useState)(open);
|
|
63328
63645
|
if (seenOpen !== open) {
|
|
63329
63646
|
setSeenOpen(open);
|
|
63330
63647
|
if (open) {
|
|
@@ -63342,12 +63659,12 @@ function AddDialog({
|
|
|
63342
63659
|
const ready = !busy && name.trim() !== "" && (!groupField || group !== "__new" || newGroup.trim() !== "");
|
|
63343
63660
|
const rowCls = "grid grid-cols-[6.5rem_1fr] items-start gap-3";
|
|
63344
63661
|
const labelCls = "pt-2 text-sm text-muted-foreground";
|
|
63345
|
-
return /* @__PURE__ */ (0,
|
|
63346
|
-
/* @__PURE__ */ (0,
|
|
63662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.DialogContent, { className: "max-w-md", children: [
|
|
63663
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.DialogTitle, { children: [
|
|
63347
63664
|
"New ",
|
|
63348
63665
|
noun
|
|
63349
63666
|
] }) }),
|
|
63350
|
-
/* @__PURE__ */ (0,
|
|
63667
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(
|
|
63351
63668
|
"form",
|
|
63352
63669
|
{
|
|
63353
63670
|
className: "flex flex-col gap-3",
|
|
@@ -63356,47 +63673,47 @@ function AddDialog({
|
|
|
63356
63673
|
if (!ready || !nameField) return;
|
|
63357
63674
|
setBusy(true);
|
|
63358
63675
|
const doc = { ...data, [nameField.key]: name.trim() };
|
|
63359
|
-
if (groupField && chosenGroup !==
|
|
63676
|
+
if (groupField && chosenGroup !== UNGROUPED2) doc[groupField.key] = chosenGroup;
|
|
63360
63677
|
if (noteField && note.trim() !== "") doc[noteField.key] = note.trim();
|
|
63361
63678
|
const ok = await onAdd(doc);
|
|
63362
63679
|
setBusy(false);
|
|
63363
63680
|
if (ok) onOpenChange(false);
|
|
63364
63681
|
},
|
|
63365
63682
|
children: [
|
|
63366
|
-
preview ? /* @__PURE__ */ (0,
|
|
63367
|
-
groupField ? /* @__PURE__ */ (0,
|
|
63368
|
-
/* @__PURE__ */ (0,
|
|
63369
|
-
/* @__PURE__ */ (0,
|
|
63370
|
-
/* @__PURE__ */ (0,
|
|
63371
|
-
/* @__PURE__ */ (0,
|
|
63372
|
-
/* @__PURE__ */ (0,
|
|
63373
|
-
/* @__PURE__ */ (0,
|
|
63374
|
-
groups.filter((g) => g !==
|
|
63375
|
-
/* @__PURE__ */ (0,
|
|
63683
|
+
preview ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { children: preview }) : null,
|
|
63684
|
+
groupField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: rowCls, children: [
|
|
63685
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: labelCls, children: fieldName(groupField) }),
|
|
63686
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
63687
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Select, { value: group === UNGROUPED2 ? "__none" : group, onValueChange: (v) => setGroup(v === "__none" ? UNGROUPED2 : v), children: [
|
|
63688
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectTrigger, { "aria-label": fieldName(groupField), children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectValue, {}) }),
|
|
63689
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.SelectContent, { children: [
|
|
63690
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectItem, { value: "__none", children: "None" }),
|
|
63691
|
+
groups.filter((g) => g !== UNGROUPED2).map((g) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.SelectItem, { value: g, children: g }, g)),
|
|
63692
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.SelectItem, { value: "__new", children: [
|
|
63376
63693
|
"New ",
|
|
63377
63694
|
fieldName(groupField).toLowerCase(),
|
|
63378
63695
|
"\u2026"
|
|
63379
63696
|
] })
|
|
63380
63697
|
] })
|
|
63381
63698
|
] }),
|
|
63382
|
-
group === "__new" ? /* @__PURE__ */ (0,
|
|
63699
|
+
group === "__new" ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.BasicInput, { "aria-label": `New ${fieldName(groupField).toLowerCase()} name`, placeholder: "e.g. Display", value: newGroup, onChange: (e) => setNewGroup(e.target.value) }) : null
|
|
63383
63700
|
] })
|
|
63384
63701
|
] }) : null,
|
|
63385
|
-
nameField ? /* @__PURE__ */ (0,
|
|
63386
|
-
/* @__PURE__ */ (0,
|
|
63387
|
-
/* @__PURE__ */ (0,
|
|
63702
|
+
nameField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: rowCls, children: [
|
|
63703
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("label", { htmlFor: "section-add-name", className: labelCls, children: fieldName(nameField) }),
|
|
63704
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.BasicInput, { id: "section-add-name", className: "font-mono", autoFocus: true, value: name, onChange: (e) => setName(e.target.value) })
|
|
63388
63705
|
] }) : null,
|
|
63389
|
-
values.map((field2) => /* @__PURE__ */ (0,
|
|
63390
|
-
/* @__PURE__ */ (0,
|
|
63391
|
-
/* @__PURE__ */ (0,
|
|
63706
|
+
values.map((field2) => /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: rowCls, children: [
|
|
63707
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("label", { htmlFor: `section-add-${field2.key}`, className: labelCls, children: fieldName(field2) }),
|
|
63708
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(FieldControl, { field: field2, value: data[field2.key] ?? null, onChange: (v) => setData((d) => ({ ...d, [field2.key]: v })), id: `section-add-${field2.key}`, asForm: true })
|
|
63392
63709
|
] }, field2.key)),
|
|
63393
|
-
noteField ? /* @__PURE__ */ (0,
|
|
63394
|
-
/* @__PURE__ */ (0,
|
|
63395
|
-
/* @__PURE__ */ (0,
|
|
63710
|
+
noteField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: rowCls, children: [
|
|
63711
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("label", { htmlFor: "section-add-note", className: labelCls, children: fieldName(noteField) }),
|
|
63712
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.BasicTextarea, { 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) })
|
|
63396
63713
|
] }) : null,
|
|
63397
|
-
/* @__PURE__ */ (0,
|
|
63398
|
-
/* @__PURE__ */ (0,
|
|
63399
|
-
/* @__PURE__ */ (0,
|
|
63714
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex justify-end gap-2 pt-1", children: [
|
|
63715
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }),
|
|
63716
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_design_system181.Button, { type: "submit", disabled: !ready, children: "Add" })
|
|
63400
63717
|
] })
|
|
63401
63718
|
]
|
|
63402
63719
|
}
|
|
@@ -63404,15 +63721,19 @@ function AddDialog({
|
|
|
63404
63721
|
] }) });
|
|
63405
63722
|
}
|
|
63406
63723
|
function SectionCard(props) {
|
|
63724
|
+
if (props.source.kind === "entity") return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(EntitySectionCard, { ...props, source: props.source });
|
|
63725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(TableSectionCard, { ...props, tableId: props.source.id });
|
|
63726
|
+
}
|
|
63727
|
+
function TableSectionCard(props) {
|
|
63407
63728
|
const { tableId, readOnly, noun = "entry", onFix, className } = props;
|
|
63408
|
-
const table = (0,
|
|
63409
|
-
const fieldsRead = (0,
|
|
63729
|
+
const table = (0, import_react361.useTable)(tableId);
|
|
63730
|
+
const fieldsRead = (0, import_react361.useFields)(tableId);
|
|
63410
63731
|
const tableSort = (0, import_first_page3.defaultSortOf)(table.data ?? null, fieldsRead.data ?? []);
|
|
63411
|
-
const page = (0,
|
|
63732
|
+
const page = (0, import_react361.useRecordPage)(fieldsRead.data ? tableId : null, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
|
|
63412
63733
|
const sortedByStore = tableSort !== null;
|
|
63413
|
-
const mutation = (0,
|
|
63414
|
-
const [adding, setAdding] = (0,
|
|
63415
|
-
const [failed, setFailed] = (0,
|
|
63734
|
+
const mutation = (0, import_react361.useRecordMutation)();
|
|
63735
|
+
const [adding, setAdding] = (0, import_react360.useState)(null);
|
|
63736
|
+
const [failed, setFailed] = (0, import_react360.useState)(null);
|
|
63416
63737
|
const fields = fieldsRead.data ?? [];
|
|
63417
63738
|
const cols = sectionColumns(fields, table.data?.title_field, props);
|
|
63418
63739
|
const nameField = fields.find((f) => f.key === cols.name);
|
|
@@ -63433,11 +63754,11 @@ function SectionCard(props) {
|
|
|
63433
63754
|
};
|
|
63434
63755
|
const cells = columns.filter((c) => c.part !== "dark");
|
|
63435
63756
|
const total = page.data?.total ?? null;
|
|
63436
|
-
const client = (0,
|
|
63437
|
-
const [counts, setCounts] = (0,
|
|
63438
|
-
const [countsAsked, setCountsAsked] = (0,
|
|
63757
|
+
const client = (0, import_react361.useRecordsClient)();
|
|
63758
|
+
const [counts, setCounts] = (0, import_react360.useState)({});
|
|
63759
|
+
const [countsAsked, setCountsAsked] = (0, import_react360.useState)(0);
|
|
63439
63760
|
const idsKey = rows.map((r) => r.id).join(",");
|
|
63440
|
-
(0,
|
|
63761
|
+
(0, import_react360.useEffect)(() => {
|
|
63441
63762
|
if (idsKey === "") return;
|
|
63442
63763
|
let alive = true;
|
|
63443
63764
|
void client.commentCounts({ record_ids: idsKey.split(",") }).then((answered) => {
|
|
@@ -63450,44 +63771,44 @@ function SectionCard(props) {
|
|
|
63450
63771
|
const rowNames = nameField ? rows.map((r) => String((r.document ?? {})[nameField.key] ?? "")).filter((n) => n !== "") : [];
|
|
63451
63772
|
const refused = table.error ?? fieldsRead.error ?? page.error;
|
|
63452
63773
|
const gridStyle = { gridTemplateColumns: `minmax(8rem, 12rem) repeat(${Math.max(columns.length, 1)}, minmax(0, 1fr)) 4.5rem` };
|
|
63453
|
-
return /* @__PURE__ */ (0,
|
|
63454
|
-
/* @__PURE__ */ (0,
|
|
63455
|
-
/* @__PURE__ */ (0,
|
|
63456
|
-
/* @__PURE__ */ (0,
|
|
63457
|
-
props.description ? /* @__PURE__ */ (0,
|
|
63774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("section", { "data-records-section-card": "", className: (0, import_design_system181.cn)("rounded-2xl border border-border bg-card text-card-foreground", className), children: [
|
|
63775
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("header", { className: "flex items-start justify-between gap-4 px-5 pt-5 pb-3 sm:px-6", children: [
|
|
63776
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "min-w-0", children: [
|
|
63777
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("h2", { className: "truncate font-serif text-2xl tracking-tight text-foreground", children: title || "\xA0" }),
|
|
63778
|
+
props.description ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: props.description }) : null
|
|
63458
63779
|
] }),
|
|
63459
|
-
mayWrite && nameField ? /* @__PURE__ */ (0,
|
|
63460
|
-
/* @__PURE__ */ (0,
|
|
63780
|
+
mayWrite && nameField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(import_design_system181.Button, { type: "button", variant: "outline", size: "sm", onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: [
|
|
63781
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, { className: "h-3.5 w-3.5" }),
|
|
63461
63782
|
"Add"
|
|
63462
63783
|
] }) : null
|
|
63463
63784
|
] }),
|
|
63464
|
-
refused ? /* @__PURE__ */ (0,
|
|
63465
|
-
cols.group ? /* @__PURE__ */ (0,
|
|
63466
|
-
/* @__PURE__ */ (0,
|
|
63467
|
-
mayWrite ? /* @__PURE__ */ (0,
|
|
63785
|
+
refused ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("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__ */ (0, import_jsx_runtime207.jsx)("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__ */ (0, import_jsx_runtime207.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { className: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { "data-records-section-group": group.key, className: "", children: [
|
|
63786
|
+
cols.group ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
|
|
63787
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
|
|
63788
|
+
mayWrite ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63468
63789
|
"button",
|
|
63469
63790
|
{
|
|
63470
63791
|
type: "button",
|
|
63471
63792
|
"aria-label": `Add to ${group.key || "no group"}`,
|
|
63472
63793
|
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",
|
|
63473
63794
|
onClick: () => setAdding(group.key),
|
|
63474
|
-
children: /* @__PURE__ */ (0,
|
|
63795
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, { className: "h-4 w-4" })
|
|
63475
63796
|
}
|
|
63476
63797
|
) : null
|
|
63477
63798
|
] }) : null,
|
|
63478
|
-
/* @__PURE__ */ (0,
|
|
63479
|
-
/* @__PURE__ */ (0,
|
|
63480
|
-
/* @__PURE__ */ (0,
|
|
63481
|
-
columns.map((c) => /* @__PURE__ */ (0,
|
|
63482
|
-
/* @__PURE__ */ (0,
|
|
63799
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { role: "table", "aria-label": group.key || title, className: "min-w-[36rem]", children: [
|
|
63800
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { role: "row", style: gridStyle, className: "grid border-b border-border text-xs text-muted-foreground", children: [
|
|
63801
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { role: "columnheader", className: "border-r border-border px-5 py-1.5 sm:px-6", children: nameField ? fieldName(nameField) : "Name" }),
|
|
63802
|
+
columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { role: "columnheader", className: "truncate px-3 py-1.5", children: c.header }, `${c.field.key}-${c.part ?? ""}`)),
|
|
63803
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", {})
|
|
63483
63804
|
] }),
|
|
63484
63805
|
group.rows.map((row) => {
|
|
63485
63806
|
const editable = mayWrite && (0, import_field_kinds9.atLeast)(row.level, "edit_content");
|
|
63486
63807
|
const rowSave = save(row);
|
|
63487
|
-
return /* @__PURE__ */ (0,
|
|
63488
|
-
/* @__PURE__ */ (0,
|
|
63489
|
-
/* @__PURE__ */ (0,
|
|
63490
|
-
readsOnField ? /* @__PURE__ */ (0,
|
|
63808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("div", { role: "row", "data-records-section-row": row.id, style: gridStyle, className: "grid items-center border-b border-border", children: [
|
|
63809
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { role: "cell", className: "min-w-0 self-stretch border-r border-border px-5 py-1.5 sm:px-6", children: [
|
|
63810
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)("span", { className: "block truncate font-mono text-sm text-foreground", children: nameField ? String((row.document ?? {})[nameField.key] ?? "") : row.id }),
|
|
63811
|
+
readsOnField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63491
63812
|
ReadsOnPicker,
|
|
63492
63813
|
{
|
|
63493
63814
|
row,
|
|
@@ -63499,13 +63820,13 @@ function SectionCard(props) {
|
|
|
63499
63820
|
}
|
|
63500
63821
|
) : null
|
|
63501
63822
|
] }),
|
|
63502
|
-
cells.map((c) => /* @__PURE__ */ (0,
|
|
63823
|
+
cells.map((c) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63503
63824
|
"div",
|
|
63504
63825
|
{
|
|
63505
63826
|
role: "cell",
|
|
63506
63827
|
style: c.part ? { gridColumn: "span 2" } : void 0,
|
|
63507
|
-
className: (0,
|
|
63508
|
-
children: /* @__PURE__ */ (0,
|
|
63828
|
+
className: (0, import_design_system181.cn)("min-w-0 py-1", c.part ? "" : "px-3"),
|
|
63829
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63509
63830
|
ValueCell,
|
|
63510
63831
|
{
|
|
63511
63832
|
row,
|
|
@@ -63519,22 +63840,22 @@ function SectionCard(props) {
|
|
|
63519
63840
|
},
|
|
63520
63841
|
c.field.key
|
|
63521
63842
|
)),
|
|
63522
|
-
/* @__PURE__ */ (0,
|
|
63523
|
-
/* @__PURE__ */ (0,
|
|
63524
|
-
noteField ? /* @__PURE__ */ (0,
|
|
63843
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("span", { role: "cell", className: "flex items-center justify-end gap-0.5 pr-2", children: [
|
|
63844
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(RowComments, { tableId, row, count: counts[row.id] ?? 0, onClosed: () => setCountsAsked((n) => n + 1) }),
|
|
63845
|
+
noteField ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(NoteButton, { row, noteField, editable, save: rowSave }) : null
|
|
63525
63846
|
] })
|
|
63526
63847
|
] }, row.id);
|
|
63527
63848
|
})
|
|
63528
63849
|
] })
|
|
63529
63850
|
] }, group.key || "__ungrouped")) }),
|
|
63530
|
-
total !== null && total > rows.length ? /* @__PURE__ */ (0,
|
|
63851
|
+
total !== null && total > rows.length ? /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)("p", { className: "px-5 py-2 text-sm text-muted-foreground sm:px-6", children: [
|
|
63531
63852
|
"Showing ",
|
|
63532
63853
|
rows.length,
|
|
63533
63854
|
" of ",
|
|
63534
63855
|
total
|
|
63535
63856
|
] }) : null,
|
|
63536
|
-
failed ? /* @__PURE__ */ (0,
|
|
63537
|
-
/* @__PURE__ */ (0,
|
|
63857
|
+
failed ? /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("p", { className: "px-5 py-2 text-sm text-warning-ink sm:px-6", children: mutation.error ? refusalSentence(mutation.error) : failed }) : null,
|
|
63858
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63538
63859
|
AddDialog,
|
|
63539
63860
|
{
|
|
63540
63861
|
open: adding !== null,
|
|
@@ -63545,7 +63866,7 @@ function SectionCard(props) {
|
|
|
63545
63866
|
noteField,
|
|
63546
63867
|
values: cols.values,
|
|
63547
63868
|
groups: groups.map((g) => g.key),
|
|
63548
|
-
startGroup: adding ??
|
|
63869
|
+
startGroup: adding ?? UNGROUPED2,
|
|
63549
63870
|
onAdd: async (data) => {
|
|
63550
63871
|
const id = await mutation.write({ table_id: tableId, data });
|
|
63551
63872
|
if (id === null) {
|