@ai-matrx/records-ui 0.115.98 → 0.115.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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", "[overflow-wrap:anywhere]"), children: text });
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: structuredSummary(structured.data) }),
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,
@@ -8503,13 +8519,14 @@ function scalarText(field, value, labels, stillWaitingFor) {
8503
8519
  }
8504
8520
  const shownAs = shownAsOf(field);
8505
8521
  if (shownAs) {
8506
- const said2 = (0, import_field_formats4.formatFieldValue)(value, shownAs);
8522
+ const said2 = (0, import_field_formats4.formatFieldValue)(value, shownAs.id === "number" && isYearField(field) && isYearValue(value) ? formatForField(field) ?? shownAs : shownAs);
8507
8523
  if (said2.ok && !said2.empty) return said2.text;
8508
8524
  }
8509
8525
  if (typeof value === "number") {
8510
8526
  if (kind === "percent") return `${value}%`;
8511
8527
  if (kind === "currency") return field.unit ? `${field.unit}${value.toLocaleString()}` : value.toLocaleString();
8512
- return field.unit ? `${value.toLocaleString()} ${field.unit}` : value.toLocaleString();
8528
+ const plain = isYearField(field) && isYearValue(value) ? String(value) : value.toLocaleString();
8529
+ return field.unit ? `${plain} ${field.unit}` : plain;
8513
8530
  }
8514
8531
  if (kind === "datetime" || systemStampOf(field) === "created_time" || systemStampOf(field) === "modified_time") {
8515
8532
  const said2 = dateText(field, value);