@ai-matrx/records-ui 0.116.22 → 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/{chunk-KKOLRE2M.js → chunk-WQGFKNE2.js} +3 -2
- package/dist/chunk-WQGFKNE2.js.map +1 -0
- package/dist/index.cjs +472 -150
- 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 +472 -137
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +2 -1
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-KKOLRE2M.js.map +0 -1
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,
|
|
@@ -9358,7 +9362,8 @@ function ColorWell({
|
|
|
9358
9362
|
{
|
|
9359
9363
|
id,
|
|
9360
9364
|
"aria-label": label,
|
|
9361
|
-
className: "h-7
|
|
9365
|
+
className: "h-7 shrink-0 font-mono text-xs uppercase",
|
|
9366
|
+
style: { width: "calc(9ch + 1.25rem)" },
|
|
9362
9367
|
value: text,
|
|
9363
9368
|
placeholder,
|
|
9364
9369
|
disabled,
|
|
@@ -38309,10 +38314,16 @@ function editTypeOf(column) {
|
|
|
38309
38314
|
if (column.type === "checkbox" || column.type === "boolean") return "boolean";
|
|
38310
38315
|
return false;
|
|
38311
38316
|
}
|
|
38317
|
+
function entityFilterWhere(filter) {
|
|
38318
|
+
if (!filter) return [];
|
|
38319
|
+
return Object.keys(filter).sort().map((column) => ({ column, op: "eq", value: filter[column] }));
|
|
38320
|
+
}
|
|
38312
38321
|
function useEntitySourceTable(token2, options = {}) {
|
|
38313
38322
|
const type = (0, import_react214.useEntityType)(token2);
|
|
38314
38323
|
const columns = (0, import_react214.useEntityColumns)(token2);
|
|
38315
|
-
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);
|
|
38316
38327
|
const write = (0, import_react214.useEntityWrite)(token2);
|
|
38317
38328
|
const shown5 = (0, import_react212.useMemo)(() => entityShownColumns(columns.data ?? []), [columns.data]);
|
|
38318
38329
|
const refused = list.error ?? columns.error ?? type.error;
|
|
@@ -38338,7 +38349,7 @@ function useEntitySourceTable(token2, options = {}) {
|
|
|
38338
38349
|
return answer.ok ? null : refusalSentence(answer.error) || "That change was not saved.";
|
|
38339
38350
|
},
|
|
38340
38351
|
async create(values) {
|
|
38341
|
-
const answer = await write.create(values);
|
|
38352
|
+
const answer = await write.create(options.filter ? { ...values, ...options.filter } : values);
|
|
38342
38353
|
return answer.ok ? { id: answer.data._id } : { refused: refusalSentence(answer.error) || "That row was not added." };
|
|
38343
38354
|
}
|
|
38344
38355
|
};
|
|
@@ -38432,7 +38443,7 @@ function EntityTableCardBody({
|
|
|
38432
38443
|
className
|
|
38433
38444
|
}) {
|
|
38434
38445
|
const batch = initialRows ?? import_data_table16.TABLE_CARD_DEFAULT_INITIAL_ROWS;
|
|
38435
|
-
const entity = useEntitySourceTable(source.token, { pageSize: batch });
|
|
38446
|
+
const entity = useEntitySourceTable(source.token, { pageSize: batch, filter: source.filter ?? null });
|
|
38436
38447
|
const label = entity.label ?? (entity.loading ? "Loading\u2026" : "Table");
|
|
38437
38448
|
return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
|
|
38438
38449
|
import_data_table16.MatrxTableCard,
|
|
@@ -47912,7 +47923,7 @@ function ArchivedPortals({
|
|
|
47912
47923
|
}
|
|
47913
47924
|
|
|
47914
47925
|
// src/index.ts
|
|
47915
|
-
var
|
|
47926
|
+
var import_design_system182 = require("@ai-matrx/design-system");
|
|
47916
47927
|
|
|
47917
47928
|
// src/ViewBar.tsx
|
|
47918
47929
|
var import_react276 = require("react");
|
|
@@ -62994,20 +63005,327 @@ function PreviewForms({ preview, booking }) {
|
|
|
62994
63005
|
}
|
|
62995
63006
|
|
|
62996
63007
|
// src/SectionCard.tsx
|
|
62997
|
-
var
|
|
63008
|
+
var import_react360 = require("react");
|
|
62998
63009
|
var import_field_kinds9 = require("@ai-matrx/records/field-kinds");
|
|
62999
|
-
var
|
|
63000
|
-
var
|
|
63001
|
-
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");
|
|
63002
63013
|
var import_field_formats12 = require("@ai-matrx/design-system/field-formats");
|
|
63003
63014
|
init_names();
|
|
63004
63015
|
init_plainWords();
|
|
63005
|
-
|
|
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
|
|
63006
63024
|
var NAME_KEYS4 = ["name", "title", "token", "label"];
|
|
63007
63025
|
var GROUP_KEYS = ["group", "set", "section", "category"];
|
|
63008
63026
|
var NOTE_KEYS = ["usage_note", "note", "notes", "usage"];
|
|
63009
|
-
|
|
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"]);
|
|
63010
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 = "";
|
|
63011
63329
|
function findKey(fields, wanted) {
|
|
63012
63330
|
for (const key of wanted) if (fields.some((f) => f.key === key)) return key;
|
|
63013
63331
|
return void 0;
|
|
@@ -63022,7 +63340,7 @@ function sectionColumns(fields, titleField, props) {
|
|
|
63022
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));
|
|
63023
63341
|
return { name, group, note, readsOn, values };
|
|
63024
63342
|
}
|
|
63025
|
-
var
|
|
63343
|
+
var NATURAL2 = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
63026
63344
|
function orderedRows(rows, nameKey) {
|
|
63027
63345
|
if (!nameKey) return [...rows];
|
|
63028
63346
|
const nameOf3 = (r) => String((r.document ?? {})[nameKey] ?? "");
|
|
@@ -63030,20 +63348,20 @@ function orderedRows(rows, nameKey) {
|
|
|
63030
63348
|
const x = nameOf3(a);
|
|
63031
63349
|
const y = nameOf3(b);
|
|
63032
63350
|
if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
|
|
63033
|
-
return
|
|
63351
|
+
return NATURAL2.compare(x, y);
|
|
63034
63352
|
});
|
|
63035
63353
|
}
|
|
63036
63354
|
function sectionGroups(rows, groupKey) {
|
|
63037
|
-
if (!groupKey) return [{ key:
|
|
63355
|
+
if (!groupKey) return [{ key: UNGROUPED2, rows: [...rows] }];
|
|
63038
63356
|
const map = /* @__PURE__ */ new Map();
|
|
63039
63357
|
for (const row of rows) {
|
|
63040
63358
|
const raw = (row.document ?? {})[groupKey];
|
|
63041
|
-
const key = raw === null || raw === void 0 ?
|
|
63359
|
+
const key = raw === null || raw === void 0 ? UNGROUPED2 : String(raw);
|
|
63042
63360
|
const held = map.get(key);
|
|
63043
63361
|
if (held) held.push(row);
|
|
63044
63362
|
else map.set(key, [row]);
|
|
63045
63363
|
}
|
|
63046
|
-
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));
|
|
63047
63365
|
}
|
|
63048
63366
|
function columnsOf(values) {
|
|
63049
63367
|
const out = [];
|
|
@@ -63058,12 +63376,12 @@ function columnsOf(values) {
|
|
|
63058
63376
|
}
|
|
63059
63377
|
var same4 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
|
|
63060
63378
|
function useDraft(stored, save) {
|
|
63061
|
-
const [draft, setDraft] = (0,
|
|
63062
|
-
const latest = (0,
|
|
63063
|
-
(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)(() => {
|
|
63064
63382
|
latest.current = { draft, save, stored };
|
|
63065
63383
|
});
|
|
63066
|
-
(0,
|
|
63384
|
+
(0, import_react360.useEffect)(() => {
|
|
63067
63385
|
if (!draft || draft.phase !== "typing") return;
|
|
63068
63386
|
const timer = setTimeout(() => {
|
|
63069
63387
|
const sending = draft.value;
|
|
@@ -63075,7 +63393,7 @@ function useDraft(stored, save) {
|
|
|
63075
63393
|
}, SAVE_AFTER_MS);
|
|
63076
63394
|
return () => clearTimeout(timer);
|
|
63077
63395
|
}, [draft]);
|
|
63078
|
-
(0,
|
|
63396
|
+
(0, import_react360.useEffect)(
|
|
63079
63397
|
() => () => {
|
|
63080
63398
|
const held = latest.current;
|
|
63081
63399
|
if (held.draft && held.draft.phase === "typing") void held.save(held.draft.value);
|
|
@@ -63087,9 +63405,9 @@ function useDraft(stored, save) {
|
|
|
63087
63405
|
}
|
|
63088
63406
|
function ChecksLine({ checks, onFix }) {
|
|
63089
63407
|
if (checks.length === 0) return null;
|
|
63090
|
-
return /* @__PURE__ */ (0,
|
|
63091
|
-
/* @__PURE__ */ (0,
|
|
63092
|
-
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
|
|
63093
63411
|
] }, i)) });
|
|
63094
63412
|
}
|
|
63095
63413
|
function ValueCell({
|
|
@@ -63107,16 +63425,16 @@ function ValueCell({
|
|
|
63107
63425
|
const fix = onFix ? (check) => onFix({ check, row, field: field2 }) : void 0;
|
|
63108
63426
|
const id = `section-${row.id}-${field2.key}`;
|
|
63109
63427
|
const withheld = row.hidden?.[field2.key] ?? null;
|
|
63110
|
-
if (withheld) return /* @__PURE__ */ (0,
|
|
63428
|
+
if (withheld) return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(RecordValue, { field: field2, value: null, withheld });
|
|
63111
63429
|
if (format?.id === "color_pair") {
|
|
63112
63430
|
const pair = (0, import_field_formats12.readColorPair)(value) ?? null;
|
|
63113
63431
|
const contrast = pair ? colorPairContrast(pair, format, context) : {};
|
|
63114
|
-
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) => {
|
|
63115
63433
|
const side = part === "light" ? pair?.light : pair?.dark ?? void 0;
|
|
63116
63434
|
const ratio = contrast[part];
|
|
63117
|
-
return /* @__PURE__ */ (0,
|
|
63118
|
-
/* @__PURE__ */ (0,
|
|
63119
|
-
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)(
|
|
63120
63438
|
ColorWell,
|
|
63121
63439
|
{
|
|
63122
63440
|
id: `${id}-${part}`,
|
|
@@ -63130,10 +63448,10 @@ function ValueCell({
|
|
|
63130
63448
|
change(updated.light ? JSON.stringify(updated) : null);
|
|
63131
63449
|
}
|
|
63132
63450
|
}
|
|
63133
|
-
) : /* @__PURE__ */ (0,
|
|
63134
|
-
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
|
|
63135
63453
|
] }),
|
|
63136
|
-
/* @__PURE__ */ (0,
|
|
63454
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ChecksLine, { checks: checks.filter((c) => c.part === part), onFix: fix })
|
|
63137
63455
|
] }, part);
|
|
63138
63456
|
}) });
|
|
63139
63457
|
}
|
|
@@ -63142,16 +63460,16 @@ function ValueCell({
|
|
|
63142
63460
|
const ownDark = typeof value === "string" && value.includes('"dark"');
|
|
63143
63461
|
const pack = (l) => l.length === 1 ? l[0] : { layers: l };
|
|
63144
63462
|
const write = (light, dark) => change(JSON.stringify(dark ? { light: pack(light), dark: pack(dark) } : pack(light)));
|
|
63145
|
-
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) => {
|
|
63146
63464
|
const layers = pair ? pair[part] : null;
|
|
63147
63465
|
const words2 = !layers ? "Set" : part === "dark" && !ownDark ? "Same as light" : (0, import_field_formats12.shadowWords)(layers);
|
|
63148
|
-
const inner2 = /* @__PURE__ */ (0,
|
|
63149
|
-
layers ? /* @__PURE__ */ (0,
|
|
63150
|
-
/* @__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 })
|
|
63151
63469
|
] });
|
|
63152
|
-
return /* @__PURE__ */ (0,
|
|
63153
|
-
/* @__PURE__ */ (0,
|
|
63154
|
-
/* @__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)(
|
|
63155
63473
|
ShadowLayersEditor,
|
|
63156
63474
|
{
|
|
63157
63475
|
layers: layers ?? [{ x: 0, y: 4, blur: 12, spread: 0, color: "#0000001f" }],
|
|
@@ -63167,21 +63485,21 @@ function ValueCell({
|
|
|
63167
63485
|
const pictureFirst = format?.id === "type_style" || format?.id === "motion";
|
|
63168
63486
|
if (look && pictureFirst) {
|
|
63169
63487
|
const { Editor, Preview: Preview2 } = look;
|
|
63170
|
-
const view = /* @__PURE__ */ (0,
|
|
63171
|
-
return /* @__PURE__ */ (0,
|
|
63172
|
-
editable && Editor ? /* @__PURE__ */ (0,
|
|
63173
|
-
/* @__PURE__ */ (0,
|
|
63174
|
-
/* @__PURE__ */ (0,
|
|
63175
|
-
Preview2 ? /* @__PURE__ */ (0,
|
|
63176
|
-
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
|
|
63177
63495
|
] })
|
|
63178
63496
|
] }) : view,
|
|
63179
|
-
/* @__PURE__ */ (0,
|
|
63497
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsx)(ChecksLine, { checks, onFix: fix })
|
|
63180
63498
|
] });
|
|
63181
63499
|
}
|
|
63182
|
-
return /* @__PURE__ */ (0,
|
|
63183
|
-
editable ? /* @__PURE__ */ (0,
|
|
63184
|
-
/* @__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 })
|
|
63185
63503
|
] });
|
|
63186
63504
|
}
|
|
63187
63505
|
var NOTHING2 = "__nothing";
|
|
@@ -63196,20 +63514,20 @@ function ReadsOnPicker({
|
|
|
63196
63514
|
const stored = (row.document ?? {})[field2.key];
|
|
63197
63515
|
const [value, change] = useDraft(stored, (next) => save(field2, next));
|
|
63198
63516
|
const on = typeof value === "string" && value.trim() !== "" ? value : null;
|
|
63199
|
-
const said2 = problem ? /* @__PURE__ */ (0,
|
|
63200
|
-
if (!editable) return on ? /* @__PURE__ */ (0,
|
|
63201
|
-
/* @__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: [
|
|
63202
63520
|
"on ",
|
|
63203
63521
|
on
|
|
63204
63522
|
] }),
|
|
63205
63523
|
said2
|
|
63206
63524
|
] }) : null;
|
|
63207
|
-
return /* @__PURE__ */ (0,
|
|
63208
|
-
/* @__PURE__ */ (0,
|
|
63209
|
-
/* @__PURE__ */ (0,
|
|
63210
|
-
/* @__PURE__ */ (0,
|
|
63211
|
-
/* @__PURE__ */ (0,
|
|
63212
|
-
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))
|
|
63213
63531
|
] })
|
|
63214
63532
|
] }),
|
|
63215
63533
|
said2
|
|
@@ -63244,24 +63562,24 @@ function groundOf(row, rows, keys) {
|
|
|
63244
63562
|
return pair ? { ground: { light: pair.light, dark: pair.dark ?? pair.light, label: on } } : { ground: null };
|
|
63245
63563
|
}
|
|
63246
63564
|
function RowComments({ tableId, row, count, onClosed }) {
|
|
63247
|
-
return /* @__PURE__ */ (0,
|
|
63248
|
-
/* @__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)(
|
|
63249
63567
|
"button",
|
|
63250
63568
|
{
|
|
63251
63569
|
type: "button",
|
|
63252
63570
|
"aria-label": count > 0 ? `${count} open comment${count === 1 ? "" : "s"}` : "Comment",
|
|
63253
63571
|
"data-records-row-comments": count,
|
|
63254
|
-
className: (0,
|
|
63572
|
+
className: (0, import_design_system181.cn)(
|
|
63255
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",
|
|
63256
63574
|
count > 0 ? "text-foreground" : "text-muted-foreground"
|
|
63257
63575
|
),
|
|
63258
63576
|
children: [
|
|
63259
|
-
/* @__PURE__ */ (0,
|
|
63260
|
-
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
|
|
63261
63579
|
]
|
|
63262
63580
|
}
|
|
63263
63581
|
) }),
|
|
63264
|
-
/* @__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" }) })
|
|
63265
63583
|
] });
|
|
63266
63584
|
}
|
|
63267
63585
|
function NoteButton({ row, noteField, editable, save }) {
|
|
@@ -63269,22 +63587,22 @@ function NoteButton({ row, noteField, editable, save }) {
|
|
|
63269
63587
|
const [value, change] = useDraft(stored, (next) => save(noteField, next));
|
|
63270
63588
|
const text = typeof value === "string" ? value : "";
|
|
63271
63589
|
const has = text.trim() !== "";
|
|
63272
|
-
return /* @__PURE__ */ (0,
|
|
63273
|
-
/* @__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)(
|
|
63274
63592
|
"button",
|
|
63275
63593
|
{
|
|
63276
63594
|
type: "button",
|
|
63277
63595
|
"aria-label": has ? `${fieldName(noteField)}: ${text}` : `Add ${fieldName(noteField).toLowerCase()}`,
|
|
63278
63596
|
title: has ? text : fieldName(noteField),
|
|
63279
|
-
className: (0,
|
|
63597
|
+
className: (0, import_design_system181.cn)(
|
|
63280
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",
|
|
63281
63599
|
has ? "text-foreground" : "text-muted-foreground"
|
|
63282
63600
|
),
|
|
63283
|
-
children: /* @__PURE__ */ (0,
|
|
63601
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.StickyNoteIcon, { className: "h-4 w-4" })
|
|
63284
63602
|
}
|
|
63285
63603
|
) }),
|
|
63286
|
-
/* @__PURE__ */ (0,
|
|
63287
|
-
|
|
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,
|
|
63288
63606
|
{
|
|
63289
63607
|
"aria-label": fieldName(noteField),
|
|
63290
63608
|
rows: 4,
|
|
@@ -63317,13 +63635,13 @@ function AddDialog({
|
|
|
63317
63635
|
}
|
|
63318
63636
|
return out;
|
|
63319
63637
|
};
|
|
63320
|
-
const [data, setData] = (0,
|
|
63321
|
-
const [name, setName] = (0,
|
|
63322
|
-
const [group, setGroup] = (0,
|
|
63323
|
-
const [newGroup, setNewGroup] = (0,
|
|
63324
|
-
const [note, setNote] = (0,
|
|
63325
|
-
const [busy, setBusy] = (0,
|
|
63326
|
-
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);
|
|
63327
63645
|
if (seenOpen !== open) {
|
|
63328
63646
|
setSeenOpen(open);
|
|
63329
63647
|
if (open) {
|
|
@@ -63341,12 +63659,12 @@ function AddDialog({
|
|
|
63341
63659
|
const ready = !busy && name.trim() !== "" && (!groupField || group !== "__new" || newGroup.trim() !== "");
|
|
63342
63660
|
const rowCls = "grid grid-cols-[6.5rem_1fr] items-start gap-3";
|
|
63343
63661
|
const labelCls = "pt-2 text-sm text-muted-foreground";
|
|
63344
|
-
return /* @__PURE__ */ (0,
|
|
63345
|
-
/* @__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: [
|
|
63346
63664
|
"New ",
|
|
63347
63665
|
noun
|
|
63348
63666
|
] }) }),
|
|
63349
|
-
/* @__PURE__ */ (0,
|
|
63667
|
+
/* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(
|
|
63350
63668
|
"form",
|
|
63351
63669
|
{
|
|
63352
63670
|
className: "flex flex-col gap-3",
|
|
@@ -63355,47 +63673,47 @@ function AddDialog({
|
|
|
63355
63673
|
if (!ready || !nameField) return;
|
|
63356
63674
|
setBusy(true);
|
|
63357
63675
|
const doc = { ...data, [nameField.key]: name.trim() };
|
|
63358
|
-
if (groupField && chosenGroup !==
|
|
63676
|
+
if (groupField && chosenGroup !== UNGROUPED2) doc[groupField.key] = chosenGroup;
|
|
63359
63677
|
if (noteField && note.trim() !== "") doc[noteField.key] = note.trim();
|
|
63360
63678
|
const ok = await onAdd(doc);
|
|
63361
63679
|
setBusy(false);
|
|
63362
63680
|
if (ok) onOpenChange(false);
|
|
63363
63681
|
},
|
|
63364
63682
|
children: [
|
|
63365
|
-
preview ? /* @__PURE__ */ (0,
|
|
63366
|
-
groupField ? /* @__PURE__ */ (0,
|
|
63367
|
-
/* @__PURE__ */ (0,
|
|
63368
|
-
/* @__PURE__ */ (0,
|
|
63369
|
-
/* @__PURE__ */ (0,
|
|
63370
|
-
/* @__PURE__ */ (0,
|
|
63371
|
-
/* @__PURE__ */ (0,
|
|
63372
|
-
/* @__PURE__ */ (0,
|
|
63373
|
-
groups.filter((g) => g !==
|
|
63374
|
-
/* @__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: [
|
|
63375
63693
|
"New ",
|
|
63376
63694
|
fieldName(groupField).toLowerCase(),
|
|
63377
63695
|
"\u2026"
|
|
63378
63696
|
] })
|
|
63379
63697
|
] })
|
|
63380
63698
|
] }),
|
|
63381
|
-
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
|
|
63382
63700
|
] })
|
|
63383
63701
|
] }) : null,
|
|
63384
|
-
nameField ? /* @__PURE__ */ (0,
|
|
63385
|
-
/* @__PURE__ */ (0,
|
|
63386
|
-
/* @__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) })
|
|
63387
63705
|
] }) : null,
|
|
63388
|
-
values.map((field2) => /* @__PURE__ */ (0,
|
|
63389
|
-
/* @__PURE__ */ (0,
|
|
63390
|
-
/* @__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 })
|
|
63391
63709
|
] }, field2.key)),
|
|
63392
|
-
noteField ? /* @__PURE__ */ (0,
|
|
63393
|
-
/* @__PURE__ */ (0,
|
|
63394
|
-
/* @__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) })
|
|
63395
63713
|
] }) : null,
|
|
63396
|
-
/* @__PURE__ */ (0,
|
|
63397
|
-
/* @__PURE__ */ (0,
|
|
63398
|
-
/* @__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" })
|
|
63399
63717
|
] })
|
|
63400
63718
|
]
|
|
63401
63719
|
}
|
|
@@ -63403,15 +63721,19 @@ function AddDialog({
|
|
|
63403
63721
|
] }) });
|
|
63404
63722
|
}
|
|
63405
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) {
|
|
63406
63728
|
const { tableId, readOnly, noun = "entry", onFix, className } = props;
|
|
63407
|
-
const table = (0,
|
|
63408
|
-
const fieldsRead = (0,
|
|
63729
|
+
const table = (0, import_react361.useTable)(tableId);
|
|
63730
|
+
const fieldsRead = (0, import_react361.useFields)(tableId);
|
|
63409
63731
|
const tableSort = (0, import_first_page3.defaultSortOf)(table.data ?? null, fieldsRead.data ?? []);
|
|
63410
|
-
const page = (0,
|
|
63732
|
+
const page = (0, import_react361.useRecordPage)(fieldsRead.data ? tableId : null, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
|
|
63411
63733
|
const sortedByStore = tableSort !== null;
|
|
63412
|
-
const mutation = (0,
|
|
63413
|
-
const [adding, setAdding] = (0,
|
|
63414
|
-
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);
|
|
63415
63737
|
const fields = fieldsRead.data ?? [];
|
|
63416
63738
|
const cols = sectionColumns(fields, table.data?.title_field, props);
|
|
63417
63739
|
const nameField = fields.find((f) => f.key === cols.name);
|
|
@@ -63432,11 +63754,11 @@ function SectionCard(props) {
|
|
|
63432
63754
|
};
|
|
63433
63755
|
const cells = columns.filter((c) => c.part !== "dark");
|
|
63434
63756
|
const total = page.data?.total ?? null;
|
|
63435
|
-
const client = (0,
|
|
63436
|
-
const [counts, setCounts] = (0,
|
|
63437
|
-
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);
|
|
63438
63760
|
const idsKey = rows.map((r) => r.id).join(",");
|
|
63439
|
-
(0,
|
|
63761
|
+
(0, import_react360.useEffect)(() => {
|
|
63440
63762
|
if (idsKey === "") return;
|
|
63441
63763
|
let alive = true;
|
|
63442
63764
|
void client.commentCounts({ record_ids: idsKey.split(",") }).then((answered) => {
|
|
@@ -63449,44 +63771,44 @@ function SectionCard(props) {
|
|
|
63449
63771
|
const rowNames = nameField ? rows.map((r) => String((r.document ?? {})[nameField.key] ?? "")).filter((n) => n !== "") : [];
|
|
63450
63772
|
const refused = table.error ?? fieldsRead.error ?? page.error;
|
|
63451
63773
|
const gridStyle = { gridTemplateColumns: `minmax(8rem, 12rem) repeat(${Math.max(columns.length, 1)}, minmax(0, 1fr)) 4.5rem` };
|
|
63452
|
-
return /* @__PURE__ */ (0,
|
|
63453
|
-
/* @__PURE__ */ (0,
|
|
63454
|
-
/* @__PURE__ */ (0,
|
|
63455
|
-
/* @__PURE__ */ (0,
|
|
63456
|
-
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
|
|
63457
63779
|
] }),
|
|
63458
|
-
mayWrite && nameField ? /* @__PURE__ */ (0,
|
|
63459
|
-
/* @__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" }),
|
|
63460
63782
|
"Add"
|
|
63461
63783
|
] }) : null
|
|
63462
63784
|
] }),
|
|
63463
|
-
refused ? /* @__PURE__ */ (0,
|
|
63464
|
-
cols.group ? /* @__PURE__ */ (0,
|
|
63465
|
-
/* @__PURE__ */ (0,
|
|
63466
|
-
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)(
|
|
63467
63789
|
"button",
|
|
63468
63790
|
{
|
|
63469
63791
|
type: "button",
|
|
63470
63792
|
"aria-label": `Add to ${group.key || "no group"}`,
|
|
63471
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",
|
|
63472
63794
|
onClick: () => setAdding(group.key),
|
|
63473
|
-
children: /* @__PURE__ */ (0,
|
|
63795
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_icons3.PlusIcon, { className: "h-4 w-4" })
|
|
63474
63796
|
}
|
|
63475
63797
|
) : null
|
|
63476
63798
|
] }) : null,
|
|
63477
|
-
/* @__PURE__ */ (0,
|
|
63478
|
-
/* @__PURE__ */ (0,
|
|
63479
|
-
/* @__PURE__ */ (0,
|
|
63480
|
-
columns.map((c) => /* @__PURE__ */ (0,
|
|
63481
|
-
/* @__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", {})
|
|
63482
63804
|
] }),
|
|
63483
63805
|
group.rows.map((row) => {
|
|
63484
63806
|
const editable = mayWrite && (0, import_field_kinds9.atLeast)(row.level, "edit_content");
|
|
63485
63807
|
const rowSave = save(row);
|
|
63486
|
-
return /* @__PURE__ */ (0,
|
|
63487
|
-
/* @__PURE__ */ (0,
|
|
63488
|
-
/* @__PURE__ */ (0,
|
|
63489
|
-
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)(
|
|
63490
63812
|
ReadsOnPicker,
|
|
63491
63813
|
{
|
|
63492
63814
|
row,
|
|
@@ -63498,13 +63820,13 @@ function SectionCard(props) {
|
|
|
63498
63820
|
}
|
|
63499
63821
|
) : null
|
|
63500
63822
|
] }),
|
|
63501
|
-
cells.map((c) => /* @__PURE__ */ (0,
|
|
63823
|
+
cells.map((c) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
|
|
63502
63824
|
"div",
|
|
63503
63825
|
{
|
|
63504
63826
|
role: "cell",
|
|
63505
63827
|
style: c.part ? { gridColumn: "span 2" } : void 0,
|
|
63506
|
-
className: (0,
|
|
63507
|
-
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)(
|
|
63508
63830
|
ValueCell,
|
|
63509
63831
|
{
|
|
63510
63832
|
row,
|
|
@@ -63518,22 +63840,22 @@ function SectionCard(props) {
|
|
|
63518
63840
|
},
|
|
63519
63841
|
c.field.key
|
|
63520
63842
|
)),
|
|
63521
|
-
/* @__PURE__ */ (0,
|
|
63522
|
-
/* @__PURE__ */ (0,
|
|
63523
|
-
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
|
|
63524
63846
|
] })
|
|
63525
63847
|
] }, row.id);
|
|
63526
63848
|
})
|
|
63527
63849
|
] })
|
|
63528
63850
|
] }, group.key || "__ungrouped")) }),
|
|
63529
|
-
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: [
|
|
63530
63852
|
"Showing ",
|
|
63531
63853
|
rows.length,
|
|
63532
63854
|
" of ",
|
|
63533
63855
|
total
|
|
63534
63856
|
] }) : null,
|
|
63535
|
-
failed ? /* @__PURE__ */ (0,
|
|
63536
|
-
/* @__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)(
|
|
63537
63859
|
AddDialog,
|
|
63538
63860
|
{
|
|
63539
63861
|
open: adding !== null,
|
|
@@ -63544,7 +63866,7 @@ function SectionCard(props) {
|
|
|
63544
63866
|
noteField,
|
|
63545
63867
|
values: cols.values,
|
|
63546
63868
|
groups: groups.map((g) => g.key),
|
|
63547
|
-
startGroup: adding ??
|
|
63869
|
+
startGroup: adding ?? UNGROUPED2,
|
|
63548
63870
|
onAdd: async (data) => {
|
|
63549
63871
|
const id = await mutation.write({ table_id: tableId, data });
|
|
63550
63872
|
if (id === null) {
|