@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.js
CHANGED
|
@@ -6322,12 +6322,25 @@ function shownAsOf(field) {
|
|
|
6322
6322
|
const options = raw.options;
|
|
6323
6323
|
return options && typeof options === "object" && Object.keys(options).length > 0 ? { id, options } : { id };
|
|
6324
6324
|
}
|
|
6325
|
+
var YEAR_NAMES = /(^|[\s_-])(year|founded|established|incorporated|vintage)([\s_-]|$)/i;
|
|
6326
|
+
function isYearField(field) {
|
|
6327
|
+
return YEAR_NAMES.test(String(field.label ?? "")) || YEAR_NAMES.test(field.key);
|
|
6328
|
+
}
|
|
6329
|
+
function isYearValue(value) {
|
|
6330
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1e3 && value <= 2999;
|
|
6331
|
+
}
|
|
6332
|
+
function ungroupedForYears(field, format) {
|
|
6333
|
+
if (format.id !== "number" || !isYearField(field)) return format;
|
|
6334
|
+
const options = format.options ?? {};
|
|
6335
|
+
if (options["useGrouping"] !== void 0) return format;
|
|
6336
|
+
return { ...format, options: { ...options, useGrouping: false } };
|
|
6337
|
+
}
|
|
6325
6338
|
function formatForField(field) {
|
|
6326
6339
|
const shownAs = shownAsOf(field);
|
|
6327
6340
|
if (newerKindOf4(field) === "rating" && (!shownAs || shownAs.id === "rating")) {
|
|
6328
6341
|
return { id: "rating", options: { ...shownAs?.options ?? {}, ratingMax: ratingMaxOf(field) } };
|
|
6329
6342
|
}
|
|
6330
|
-
if (shownAs) return shownAs;
|
|
6343
|
+
if (shownAs) return ungroupedForYears(field, shownAs);
|
|
6331
6344
|
const stamp = dateFormatFor(field);
|
|
6332
6345
|
if (stamp && editorKindFor(field) !== "datetime") return stamp;
|
|
6333
6346
|
switch (editorKindFor(field)) {
|
|
@@ -6347,7 +6360,7 @@ function formatForField(field) {
|
|
|
6347
6360
|
case "phone":
|
|
6348
6361
|
return { id: "phone" };
|
|
6349
6362
|
case "number":
|
|
6350
|
-
return { id: "number" };
|
|
6363
|
+
return ungroupedForYears(field, { id: "number" });
|
|
6351
6364
|
default:
|
|
6352
6365
|
return void 0;
|
|
6353
6366
|
}
|
|
@@ -8231,7 +8244,7 @@ function Scalar({ value, keyName, dense }) {
|
|
|
8231
8244
|
const date = dateWords(text);
|
|
8232
8245
|
if (date) return /* @__PURE__ */ jsx28("span", { title: text, children: date });
|
|
8233
8246
|
if (!dense && ui.renderText && text.length > 40 && MARKDOWN.test(text)) return /* @__PURE__ */ jsx28("div", { className: "min-w-0", children: ui.renderText(text, "cell") });
|
|
8234
|
-
return /* @__PURE__ */ jsx28("span", { className: cn23(dense ? "line-clamp-2" : "whitespace-pre-wrap
|
|
8247
|
+
return /* @__PURE__ */ jsx28("span", { className: cn23(dense ? "line-clamp-2 break-words" : "whitespace-pre-wrap [overflow-wrap:anywhere]"), children: text });
|
|
8235
8248
|
}
|
|
8236
8249
|
var TABLE_ROWS = 8;
|
|
8237
8250
|
var TABLE_COLUMNS = 12;
|
|
@@ -8243,7 +8256,7 @@ function RecordsTable({ items }) {
|
|
|
8243
8256
|
return /* @__PURE__ */ jsxs26("div", { className: "min-w-0", "data-records-structured": "table", children: [
|
|
8244
8257
|
/* @__PURE__ */ jsx28("div", { className: "max-w-full overflow-x-auto rounded-md border border-border", children: /* @__PURE__ */ jsxs26("table", { className: "w-full border-collapse text-xs", children: [
|
|
8245
8258
|
/* @__PURE__ */ jsx28("thead", { className: "bg-muted/60 text-left", children: /* @__PURE__ */ jsx28("tr", { children: pictureFirst.map((k) => /* @__PURE__ */ jsx28("th", { scope: "col", className: "whitespace-nowrap px-2 py-1 font-medium text-muted-foreground", children: keyWords(k) }, k)) }) }),
|
|
8246
|
-
/* @__PURE__ */ jsx28("tbody", { children: shown2.map((item, i) => /* @__PURE__ */ jsx28("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ jsx28("td", { className: "max-w-[18rem] px-2 py-1", children: k in item ? /* @__PURE__ */ jsx28(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ jsx28("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
|
|
8259
|
+
/* @__PURE__ */ jsx28("tbody", { children: shown2.map((item, i) => /* @__PURE__ */ jsx28("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ jsx28("td", { className: "min-w-[7rem] max-w-[18rem] px-2 py-1", children: k in item ? /* @__PURE__ */ jsx28(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ jsx28("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
|
|
8247
8260
|
] }) }),
|
|
8248
8261
|
items.length > TABLE_ROWS ? /* @__PURE__ */ jsx28(Button14, { type: "button", variant: "ghost", size: "sm", className: "mt-1 h-6 px-2 text-xs", onClick: (e) => {
|
|
8249
8262
|
stop(e);
|
|
@@ -8301,6 +8314,9 @@ function Row({ label, keyName, value, depth, gutter }) {
|
|
|
8301
8314
|
}
|
|
8302
8315
|
);
|
|
8303
8316
|
}
|
|
8317
|
+
function recordsCount(data) {
|
|
8318
|
+
return Array.isArray(data) && data.length > 0 && data.every(isPlainObject2) ? plural2(data.length, "item", "items") : "";
|
|
8319
|
+
}
|
|
8304
8320
|
function rawTextOf(s) {
|
|
8305
8321
|
return s.raw ?? JSON.stringify(s.data, null, 2);
|
|
8306
8322
|
}
|
|
@@ -8312,7 +8328,7 @@ function StructuredValueView({ structured, label, className }) {
|
|
|
8312
8328
|
const text = rawTextOf(structured);
|
|
8313
8329
|
return /* @__PURE__ */ jsxs26("div", { className: cn23("flex min-w-0 flex-col gap-1.5 whitespace-normal", className), "data-records-structured-view": "", children: [
|
|
8314
8330
|
/* @__PURE__ */ jsxs26("div", { className: "flex min-w-0 items-center gap-1", onClick: stop, children: [
|
|
8315
|
-
/* @__PURE__ */ jsx28("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children:
|
|
8331
|
+
/* @__PURE__ */ jsx28("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: recordsCount(structured.data) }),
|
|
8316
8332
|
savable ? /* @__PURE__ */ jsx28(Button14, { 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,
|
|
8317
8333
|
/* @__PURE__ */ jsx28(
|
|
8318
8334
|
Button14,
|
|
@@ -8522,6 +8538,9 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look, roo
|
|
|
8522
8538
|
if (Array.isArray(value)) {
|
|
8523
8539
|
return /* @__PURE__ */ jsx29("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ jsx29(Badge7, { variant: "secondary", className: "text-[11px]", children: scalarText(field, item, labels) }, `${String(item)}-${i}`)) });
|
|
8524
8540
|
}
|
|
8541
|
+
if ((kind === "text" || kind === "url") && typeof value === "string" && isImageUrl2(value)) {
|
|
8542
|
+
return /* @__PURE__ */ jsx29(ImageUrlValue, { url: value.trim(), alt: field.label || field.key, room });
|
|
8543
|
+
}
|
|
8525
8544
|
if (kind === "url" && typeof value === "string") {
|
|
8526
8545
|
const href = value.includes("://") ? value : `https://${value}`;
|
|
8527
8546
|
return /* @__PURE__ */ jsx29(LinkPreviewCard, { url: href, children: /* @__PURE__ */ jsxs27(
|
|
@@ -8560,6 +8579,32 @@ function renderValue(field, value, document2, labels, stillWaitingFor, look, roo
|
|
|
8560
8579
|
}
|
|
8561
8580
|
return /* @__PURE__ */ jsx29("span", { className: cn24("truncate", kind === "number" || kind === "currency" || kind === "percent" ? "tabular-nums" : ""), children: scalarText(field, value, labels, stillWaitingFor) });
|
|
8562
8581
|
}
|
|
8582
|
+
function isImageUrl2(value) {
|
|
8583
|
+
const text = value.trim();
|
|
8584
|
+
if (!/^https?:\/\/[^\s]+$/i.test(text)) return false;
|
|
8585
|
+
let url;
|
|
8586
|
+
try {
|
|
8587
|
+
url = new URL(text);
|
|
8588
|
+
} catch {
|
|
8589
|
+
return false;
|
|
8590
|
+
}
|
|
8591
|
+
return /\.(png|jpe?g|gif|webp|avif|svg|bmp|ico)$/i.test(url.pathname) || /\/(images?|img)\//i.test(url.pathname);
|
|
8592
|
+
}
|
|
8593
|
+
function ImageUrlValue({ url, alt, room }) {
|
|
8594
|
+
const host = useRecordsUi();
|
|
8595
|
+
const box = room === "full" ? "size-24" : "size-6";
|
|
8596
|
+
return /* @__PURE__ */ jsx29(
|
|
8597
|
+
OutboundLink6,
|
|
8598
|
+
{
|
|
8599
|
+
className: cn24("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"),
|
|
8600
|
+
href: url,
|
|
8601
|
+
title: url,
|
|
8602
|
+
"data-records-image-url": "",
|
|
8603
|
+
onClick: (event) => event.stopPropagation(),
|
|
8604
|
+
children: host.fileImage ? host.fileImage({ fileId: url, alt }) : /* @__PURE__ */ jsx29("span", { className: "truncate", children: linkChipText(url) })
|
|
8605
|
+
}
|
|
8606
|
+
);
|
|
8607
|
+
}
|
|
8563
8608
|
function LivePersonChip({ id, name }) {
|
|
8564
8609
|
const open = useRecordsUi().openPerson;
|
|
8565
8610
|
return /* @__PURE__ */ jsx29(PersonChip, { name, ...open ? { onOpen: () => void openStoredPerson(id, open) } : {} });
|
|
@@ -8599,13 +8644,14 @@ function scalarText(field, value, labels, stillWaitingFor) {
|
|
|
8599
8644
|
}
|
|
8600
8645
|
const shownAs = shownAsOf(field);
|
|
8601
8646
|
if (shownAs) {
|
|
8602
|
-
const said2 = formatFieldValue3(value, shownAs);
|
|
8647
|
+
const said2 = formatFieldValue3(value, shownAs.id === "number" && isYearField(field) && isYearValue(value) ? formatForField(field) ?? shownAs : shownAs);
|
|
8603
8648
|
if (said2.ok && !said2.empty) return said2.text;
|
|
8604
8649
|
}
|
|
8605
8650
|
if (typeof value === "number") {
|
|
8606
8651
|
if (kind === "percent") return `${value}%`;
|
|
8607
8652
|
if (kind === "currency") return field.unit ? `${field.unit}${value.toLocaleString()}` : value.toLocaleString();
|
|
8608
|
-
|
|
8653
|
+
const plain = isYearField(field) && isYearValue(value) ? String(value) : value.toLocaleString();
|
|
8654
|
+
return field.unit ? `${plain} ${field.unit}` : plain;
|
|
8609
8655
|
}
|
|
8610
8656
|
if (kind === "datetime" || systemStampOf(field) === "created_time" || systemStampOf(field) === "modified_time") {
|
|
8611
8657
|
const said2 = dateText(field, value);
|