@ai-matrx/records-ui 0.115.27 → 0.115.29

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/index.js CHANGED
@@ -35233,10 +35233,14 @@ var NUMBER_TYPES = /* @__PURE__ */ new Set(["number", "integer", "decimal", "mon
35233
35233
  var DATE_TYPES = /* @__PURE__ */ new Set(["date", "datetime", "timestamp"]);
35234
35234
  var isChartKind = (v) => v === "bar" || v === "line" || v === "donut";
35235
35235
  var isChartMeasure = (v) => v === "count" || v === "sum" || v === "avg";
35236
+ function defaultChartGroup(fields) {
35237
+ return fields.find((f) => f.type === "list")?.key ?? null;
35238
+ }
35236
35239
  function chartQuestion(view, fields) {
35237
35240
  const kind = isChartKind(view.chartKind) ? view.chartKind : "bar";
35238
35241
  const asked3 = isChartMeasure(view.chartMeasure) ? view.chartMeasure : "count";
35239
- const group = view.groupField ? fields.find((f) => f.key === view.groupField) : void 0;
35242
+ const groupKey = view.groupField ?? defaultChartGroup(fields);
35243
+ const group = groupKey ? fields.find((f) => f.key === groupKey) : void 0;
35240
35244
  const measureField = view.measure ? fields.find((f) => f.key === view.measure) : void 0;
35241
35245
  const needsField = asked3 !== "count";
35242
35246
  const fellBack = needsField && !measureField;
@@ -35291,7 +35295,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
35291
35295
  return /* @__PURE__ */ jsxs108("div", { className: "flex min-h-0 flex-col gap-2", "data-records-chart-layout": "", "data-records-chart-measure": pickMeasure, children: [
35292
35296
  /* @__PURE__ */ jsxs108("div", { className: "flex flex-wrap items-center gap-2 text-xs", children: [
35293
35297
  /* @__PURE__ */ jsx119("span", { className: "text-muted-foreground", children: "Group by" }),
35294
- /* @__PURE__ */ jsxs108(Select16, { value: view.groupField ?? "__none", onValueChange: (next) => onChange({ groupField: next === "__none" ? null : next }), children: [
35298
+ /* @__PURE__ */ jsxs108(Select16, { value: view.groupField ?? defaultChartGroup(fields) ?? "__none", onValueChange: (next) => onChange({ groupField: next === "__none" ? null : next }), children: [
35295
35299
  /* @__PURE__ */ jsx119(SelectTrigger16, { size: "sm", className: "h-7 w-auto min-w-[8rem] text-xs", "aria-label": "Chart group by", children: /* @__PURE__ */ jsx119(SelectValue16, {}) }),
35296
35300
  /* @__PURE__ */ jsxs108(SelectContent16, { children: [
35297
35301
  /* @__PURE__ */ jsx119(SelectItem16, { value: "__none", children: "Everything together" }),