@ai-matrx/records-ui 0.115.98 → 0.115.100
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 +22 -0
- package/dist/first-page.cjs.map +1 -1
- package/dist/first-page.js.map +1 -1
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +3367 -3247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -9
- package/dist/index.d.ts +7 -9
- package/dist/index.js +1401 -1281
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +53 -7
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +53 -7
- package/dist/pickers.js.map +1 -1
- package/package.json +4 -4
package/dist/pickers.cjs
CHANGED
|
@@ -6237,12 +6237,25 @@ function shownAsOf(field) {
|
|
|
6237
6237
|
const options = raw.options;
|
|
6238
6238
|
return options && typeof options === "object" && Object.keys(options).length > 0 ? { id, options } : { id };
|
|
6239
6239
|
}
|
|
6240
|
+
var YEAR_NAMES = /(^|[\s_-])(year|founded|established|incorporated|vintage)([\s_-]|$)/i;
|
|
6241
|
+
function isYearField(field) {
|
|
6242
|
+
return YEAR_NAMES.test(String(field.label ?? "")) || YEAR_NAMES.test(field.key);
|
|
6243
|
+
}
|
|
6244
|
+
function isYearValue(value) {
|
|
6245
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1e3 && value <= 2999;
|
|
6246
|
+
}
|
|
6247
|
+
function ungroupedForYears(field, format) {
|
|
6248
|
+
if (format.id !== "number" || !isYearField(field)) return format;
|
|
6249
|
+
const options = format.options ?? {};
|
|
6250
|
+
if (options["useGrouping"] !== void 0) return format;
|
|
6251
|
+
return { ...format, options: { ...options, useGrouping: false } };
|
|
6252
|
+
}
|
|
6240
6253
|
function formatForField(field) {
|
|
6241
6254
|
const shownAs = shownAsOf(field);
|
|
6242
6255
|
if ((0, import_records11.newerKindOf)(field) === "rating" && (!shownAs || shownAs.id === "rating")) {
|
|
6243
6256
|
return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: (0, import_records11.ratingMaxOf)(field) } };
|
|
6244
6257
|
}
|
|
6245
|
-
if (shownAs) return shownAs;
|
|
6258
|
+
if (shownAs) return ungroupedForYears(field, shownAs);
|
|
6246
6259
|
const stamp = dateFormatFor(field);
|
|
6247
6260
|
if (stamp && editorKindFor(field) !== "datetime") return stamp;
|
|
6248
6261
|
switch (editorKindFor(field)) {
|
|
@@ -6262,7 +6275,7 @@ function formatForField(field) {
|
|
|
6262
6275
|
case "phone":
|
|
6263
6276
|
return { id: "phone" };
|
|
6264
6277
|
case "number":
|
|
6265
|
-
return { id: "number" };
|
|
6278
|
+
return ungroupedForYears(field, { id: "number" });
|
|
6266
6279
|
default:
|
|
6267
6280
|
return void 0;
|
|
6268
6281
|
}
|
|
@@ -8135,7 +8148,7 @@ function Scalar({ value, keyName, dense }) {
|
|
|
8135
8148
|
const date = dateWords(text);
|
|
8136
8149
|
if (date) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { title: text, children: date });
|
|
8137
8150
|
if (!dense && ui.renderText && text.length > 40 && MARKDOWN.test(text)) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "min-w-0", children: ui.renderText(text, "cell") });
|
|
8138
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: (0, import_design_system26.cn)(dense ? "line-clamp-2" : "whitespace-pre-wrap
|
|
8151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: (0, import_design_system26.cn)(dense ? "line-clamp-2 break-words" : "whitespace-pre-wrap [overflow-wrap:anywhere]"), children: text });
|
|
8139
8152
|
}
|
|
8140
8153
|
var TABLE_ROWS = 8;
|
|
8141
8154
|
var TABLE_COLUMNS = 12;
|
|
@@ -8147,7 +8160,7 @@ function RecordsTable({ items }) {
|
|
|
8147
8160
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "min-w-0", "data-records-structured": "table", children: [
|
|
8148
8161
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "max-w-full overflow-x-auto rounded-md border border-border", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
8149
8162
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("thead", { className: "bg-muted/60 text-left", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tr", { children: pictureFirst.map((k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("th", { scope: "col", className: "whitespace-nowrap px-2 py-1 font-medium text-muted-foreground", children: keyWords(k) }, k)) }) }),
|
|
8150
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tbody", { children: shown2.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("td", { className: "max-w-[18rem] px-2 py-1", children: k in item ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
|
|
8163
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tbody", { children: shown2.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("td", { className: "min-w-[7rem] max-w-[18rem] px-2 py-1", children: k in item ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
|
|
8151
8164
|
] }) }),
|
|
8152
8165
|
items.length > TABLE_ROWS ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system26.Button, { type: "button", variant: "ghost", size: "sm", className: "mt-1 h-6 px-2 text-xs", onClick: (e) => {
|
|
8153
8166
|
stop(e);
|
|
@@ -8205,6 +8218,9 @@ function Row({ label, keyName, value, depth, gutter }) {
|
|
|
8205
8218
|
}
|
|
8206
8219
|
);
|
|
8207
8220
|
}
|
|
8221
|
+
function recordsCount(data) {
|
|
8222
|
+
return Array.isArray(data) && data.length > 0 && data.every(isPlainObject2) ? plural2(data.length, "item", "items") : "";
|
|
8223
|
+
}
|
|
8208
8224
|
function rawTextOf(s) {
|
|
8209
8225
|
return s.raw ?? JSON.stringify(s.data, null, 2);
|
|
8210
8226
|
}
|
|
@@ -8216,7 +8232,7 @@ function StructuredValueView({ structured, label, className }) {
|
|
|
8216
8232
|
const text = rawTextOf(structured);
|
|
8217
8233
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: (0, import_design_system26.cn)("flex min-w-0 flex-col gap-1.5 whitespace-normal", className), "data-records-structured-view": "", children: [
|
|
8218
8234
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex min-w-0 items-center gap-1", onClick: stop, children: [
|
|
8219
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children:
|
|
8235
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: recordsCount(structured.data) }),
|
|
8220
8236
|
savable ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system26.Button, { type: "button", variant: "ghost", size: "sm", className: "h-6 px-2 text-xs", onClick: () => setSaving(true), "data-records-structured-save": "", children: "Save as table" }) : null,
|
|
8221
8237
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
8222
8238
|
import_design_system26.Button,
|
|
@@ -8426,6 +8442,9 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look, roo
|
|
|
8426
8442
|
if (Array.isArray(value)) {
|
|
8427
8443
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_design_system27.Badge, { variant: "secondary", className: "text-[11px]", children: scalarText(field, item, labels) }, `${String(item)}-${i}`)) });
|
|
8428
8444
|
}
|
|
8445
|
+
if ((kind === "text" || kind === "url") && typeof value === "string" && isImageUrl2(value)) {
|
|
8446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ImageUrlValue, { url: value.trim(), alt: field.label || field.key, room });
|
|
8447
|
+
}
|
|
8429
8448
|
if (kind === "url" && typeof value === "string") {
|
|
8430
8449
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
8431
8450
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(LinkPreviewCard, { url: href, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
@@ -8464,6 +8483,32 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look, roo
|
|
|
8464
8483
|
}
|
|
8465
8484
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: (0, import_design_system27.cn)("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
|
|
8466
8485
|
}
|
|
8486
|
+
function isImageUrl2(value) {
|
|
8487
|
+
const text = value.trim();
|
|
8488
|
+
if (!/^https?:\/\/[^\s]+$/i.test(text)) return false;
|
|
8489
|
+
let url;
|
|
8490
|
+
try {
|
|
8491
|
+
url = new URL(text);
|
|
8492
|
+
} catch {
|
|
8493
|
+
return false;
|
|
8494
|
+
}
|
|
8495
|
+
return /\.(png|jpe?g|gif|webp|avif|svg|bmp|ico)$/i.test(url.pathname) || /\/(images?|img)\//i.test(url.pathname);
|
|
8496
|
+
}
|
|
8497
|
+
function ImageUrlValue({ url, alt, room }) {
|
|
8498
|
+
const host = useRecordsUi();
|
|
8499
|
+
const box = room === "full" ? "size-24" : "size-6";
|
|
8500
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
8501
|
+
import_outbound_react6.OutboundLink,
|
|
8502
|
+
{
|
|
8503
|
+
className: (0, import_design_system27.cn)("inline-flex shrink-0 overflow-hidden rounded-md border border-border bg-muted/40", host.fileImage ? box : "min-w-0 max-w-full items-center gap-1 px-1.5 py-0.5 text-[11px] text-foreground hover:bg-accent"),
|
|
8504
|
+
href: url,
|
|
8505
|
+
title: url,
|
|
8506
|
+
"data-records-image-url": "",
|
|
8507
|
+
onClick: (event) => event.stopPropagation(),
|
|
8508
|
+
children: host.fileImage ? host.fileImage({ fileId: url, alt }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "truncate", children: linkChipText(url) })
|
|
8509
|
+
}
|
|
8510
|
+
);
|
|
8511
|
+
}
|
|
8467
8512
|
function LivePersonChip({ id, name }) {
|
|
8468
8513
|
const open = useRecordsUi().openPerson;
|
|
8469
8514
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PersonChip, { name, ...open ? { onOpen: () => void openStoredPerson(id, open) } : {} });
|
|
@@ -8503,13 +8548,14 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
8503
8548
|
}
|
|
8504
8549
|
const shownAs = shownAsOf(field);
|
|
8505
8550
|
if (shownAs) {
|
|
8506
|
-
const said2 = (0, import_field_formats4.formatFieldValue)(value, shownAs);
|
|
8551
|
+
const said2 = (0, import_field_formats4.formatFieldValue)(value, shownAs.id === "number" && isYearField(field) && isYearValue(value) ? formatForField(field) ?? shownAs : shownAs);
|
|
8507
8552
|
if (said2.ok && !said2.empty) return said2.text;
|
|
8508
8553
|
}
|
|
8509
8554
|
if (typeof value === "number") {
|
|
8510
8555
|
if (kind === "percent") return `${value}%`;
|
|
8511
8556
|
if (kind === "currency") return field.unit ? `${field.unit}${value.toLocaleString()}` : value.toLocaleString();
|
|
8512
|
-
|
|
8557
|
+
const plain = isYearField(field) && isYearValue(value) ? String(value) : value.toLocaleString();
|
|
8558
|
+
return field.unit ? `${plain} ${field.unit}` : plain;
|
|
8513
8559
|
}
|
|
8514
8560
|
if (kind === "datetime" || systemStampOf(field) === "created_time" || systemStampOf(field) === "modified_time") {
|
|
8515
8561
|
const said2 = dateText(field, value);
|