@ai-matrx/records-ui 0.116.27 → 0.116.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.cjs CHANGED
@@ -11455,6 +11455,11 @@ async function forgetWrittenWords(client, tableId, key, written) {
11455
11455
 
11456
11456
  // src/FieldRetype.tsx
11457
11457
  var import_jsx_runtime14 = require("react/jsx-runtime");
11458
+ var RETYPE_PREVIEW_DEBOUNCE_MS = 300;
11459
+ function scheduleRetypePreview(ask2, ms = RETYPE_PREVIEW_DEBOUNCE_MS) {
11460
+ const timer = setTimeout(ask2, ms);
11461
+ return () => clearTimeout(timer);
11462
+ }
11458
11463
  var RETYPE_TARGETS = [
11459
11464
  { id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
11460
11465
  { id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
@@ -11555,23 +11560,26 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
11555
11560
  cancelled = true;
11556
11561
  };
11557
11562
  }
11558
- void client.fieldRetypePreview({ field_id: field2.id, patch: retypePatch(to) }).then((answer) => {
11559
- if (cancelled) return;
11560
- setAsking(false);
11561
- if (!answer.ok) {
11562
- setRefusal(answer.error);
11563
- return;
11564
- }
11565
- if (answer.data.limited || answer.data.converts === null || answer.data.kept_aside === null) {
11566
- setLimitedHeld(answer.data.held_before);
11567
- setPreview({ converts: answer.data.held_before, keptAside: 0, examples: [], partial: false });
11568
- return;
11569
- }
11570
- setLimitedHeld(null);
11571
- setPreview({ converts: answer.data.converts, keptAside: answer.data.kept_aside, examples: answer.data.examples, partial: false });
11563
+ const cancelAsk = scheduleRetypePreview(() => {
11564
+ void client.fieldRetypePreview({ field_id: field2.id, patch: retypePatch(to) }).then((answer) => {
11565
+ if (cancelled) return;
11566
+ setAsking(false);
11567
+ if (!answer.ok) {
11568
+ setRefusal(answer.error);
11569
+ return;
11570
+ }
11571
+ if (answer.data.limited || answer.data.converts === null || answer.data.kept_aside === null) {
11572
+ setLimitedHeld(answer.data.held_before);
11573
+ setPreview({ converts: answer.data.held_before, keptAside: 0, examples: [], partial: false });
11574
+ return;
11575
+ }
11576
+ setLimitedHeld(null);
11577
+ setPreview({ converts: answer.data.converts, keptAside: answer.data.kept_aside, examples: answer.data.examples, partial: false });
11578
+ });
11572
11579
  });
11573
11580
  return () => {
11574
11581
  cancelled = true;
11582
+ cancelAsk();
11575
11583
  };
11576
11584
  }, [client, tableId, field2.key, to, person, roster]);
11577
11585
  if (!retypeableFrom(field2)) {
@@ -16604,6 +16612,16 @@ var LIST_TERMS = [
16604
16612
  { op: "is_empty", label: "is empty" },
16605
16613
  { op: "is_not_empty", label: "is not empty" }
16606
16614
  ];
16615
+ var CHOICE_LIST_TERMS = [
16616
+ { op: "has_any", label: "is any of" },
16617
+ { op: "has_none", label: "is none of" }
16618
+ ];
16619
+ var ChoiceListTermsContext = (0, import_react79.createContext)(false);
16620
+ var CHOICE_LIST_OPS = /* @__PURE__ */ new Set(["has_any", "has_none"]);
16621
+ function wordsOfValue(value) {
16622
+ if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
16623
+ return typeof value === "string" && value !== "" ? [value] : [];
16624
+ }
16607
16625
  var VALUELESS_OPS = /* @__PURE__ */ new Set(["present", "is_empty", "is_not_empty"]);
16608
16626
  var LINK_SEP = ">";
16609
16627
  function linkedNode(viaId, innerId, op2, value) {
@@ -16675,6 +16693,59 @@ function isChoiceColumn(f) {
16675
16693
  const kind2 = String(editorKindFor(f.field));
16676
16694
  return kind2 === "select" || kind2 === "multi_select";
16677
16695
  }
16696
+ function ChoiceValues({ field: field2, value, onChange }) {
16697
+ const client = (0, import_react80.useOptionalRecordsClient)();
16698
+ const [choices, setChoices] = (0, import_react79.useState)(null);
16699
+ (0, import_react79.useEffect)(() => {
16700
+ if (!client) return;
16701
+ let cancelled = false;
16702
+ void (0, askOnce_exports.fieldOptionsOnce)(client, field2.id).then((got) => {
16703
+ if (cancelled) return;
16704
+ setChoices(got.ok ? (got.data ?? []).map((o) => ({ key: (0, import_records27.optionKey)(o), label: (0, import_records27.optionLabel)(o) ?? "" })).filter((c) => c.label !== "") : []);
16705
+ });
16706
+ return () => {
16707
+ cancelled = true;
16708
+ };
16709
+ }, [client, field2.id]);
16710
+ const lower = value.map((w) => w.toLowerCase());
16711
+ const isOn = (c) => lower.includes(c.key.toLowerCase()) || lower.includes(c.label.toLowerCase());
16712
+ const known = (choices ?? []).flatMap((c) => [c.key.toLowerCase(), c.label.toLowerCase()]);
16713
+ const strays = value.filter((w) => !known.includes(w.toLowerCase()));
16714
+ const toggle = (c) => {
16715
+ const rest = value.filter((w) => w.toLowerCase() !== c.key.toLowerCase() && w.toLowerCase() !== c.label.toLowerCase());
16716
+ const next = isOn(c) ? rest : [...rest, c.label];
16717
+ const order = (choices ?? []).map((x) => x.label);
16718
+ onChange([...next].sort((a, b) => (order.indexOf(a) === -1 ? 1e6 : order.indexOf(a)) - (order.indexOf(b) === -1 ? 1e6 : order.indexOf(b))));
16719
+ };
16720
+ if (!choices || choices.length === 0) {
16721
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
16722
+ import_design_system46.BasicInput,
16723
+ {
16724
+ className: "h-8 w-40 text-xs",
16725
+ "aria-label": "Condition values, separated by commas",
16726
+ value: value.join(", "),
16727
+ onChange: (e) => onChange(e.target.value.split(",").map((w) => w.trim()).filter((w) => w !== ""))
16728
+ }
16729
+ );
16730
+ }
16731
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "inline-flex flex-wrap items-center gap-1", "data-records-condition-choices": "", "data-pick-values": value.join("|"), children: [
16732
+ choices.map((c) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
16733
+ import_design_system46.Button,
16734
+ {
16735
+ type: "button",
16736
+ size: "sm",
16737
+ variant: isOn(c) ? "default" : "outline",
16738
+ className: "h-7 px-2 text-xs",
16739
+ "aria-pressed": isOn(c),
16740
+ "aria-label": `${c.label} for ${field2.label || field2.key}`,
16741
+ onClick: () => toggle(c),
16742
+ children: c.label
16743
+ },
16744
+ c.key
16745
+ )),
16746
+ strays.map((w) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_design_system46.Button, { type: "button", size: "sm", variant: "default", className: "h-7 px-2 text-xs", "aria-pressed": true, "aria-label": `${w} (not a choice of this column)`, onClick: () => onChange(value.filter((x) => x !== w)), children: w }, `stray-${w}`))
16747
+ ] });
16748
+ }
16678
16749
  function ChoiceValue({ field: field2, value, onChange }) {
16679
16750
  const client = (0, import_react80.useOptionalRecordsClient)();
16680
16751
  const [choices, setChoices] = (0, import_react79.useState)(null);
@@ -16739,7 +16810,7 @@ function conditionIsSimple(expr) {
16739
16810
  if (expr === null || expr === void 0) return true;
16740
16811
  if (relativeDayOf(expr) !== null || meOf(expr) !== null || linkedOf(expr) !== null) return true;
16741
16812
  const node = expr;
16742
- if (typeof node.op !== "string" || !(CONDITION_OPS.some((c) => c.op === node.op) || LIST_TERMS.some((c) => c.op === node.op))) {
16813
+ if (typeof node.op !== "string" || !(CONDITION_OPS.some((c) => c.op === node.op) || LIST_TERMS.some((c) => c.op === node.op) || CHOICE_LIST_OPS.has(node.op))) {
16743
16814
  return false;
16744
16815
  }
16745
16816
  if (!Array.isArray(node.args)) return false;
@@ -16826,6 +16897,7 @@ function conditionValue(typed2) {
16826
16897
  function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
16827
16898
  const node = expr ?? null;
16828
16899
  const filterTerms = (0, import_react79.useContext)(FilterTermsContext);
16900
+ const choiceListTerms = (0, import_react79.useContext)(ChoiceListTermsContext) || filterTerms;
16829
16901
  const relative = relativeDayOf(expr);
16830
16902
  const reader = meOf(expr);
16831
16903
  const linked = linkedOf(expr);
@@ -16834,7 +16906,11 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
16834
16906
  const value = relative || reader ? "" : linked ? linked.value : node?.args?.[1]?.const ?? "";
16835
16907
  const chosen = fields.find((f) => f.id === onField);
16836
16908
  const chosenKind = chosen?.field ? String(editorKindFor(chosen.field)) : "";
16837
- const extraTerms = !filterTerms || chosen?.via ? [] : chosenKind === "datetime" ? RELATIVE_DAY_TERMS.map((t) => ({ op: `rel:${t.kind}`, label: t.label })) : chosenKind === "member" ? [{ op: "me", label: "is me" }, { op: "not_me", label: "is not me" }] : chosenKind === "multi_select" ? LIST_TERMS : [];
16909
+ const choiceTerms = choiceListTerms && !chosen?.via && (chosenKind === "select" || chosenKind === "multi_select") ? CHOICE_LIST_TERMS : [];
16910
+ const extraTerms = [
16911
+ ...!filterTerms || chosen?.via ? [] : chosenKind === "datetime" ? RELATIVE_DAY_TERMS.map((t) => ({ op: `rel:${t.kind}`, label: t.label })) : chosenKind === "member" ? [{ op: "me", label: "is me" }, { op: "not_me", label: "is not me" }] : chosenKind === "multi_select" ? LIST_TERMS : [],
16912
+ ...choiceTerms
16913
+ ];
16838
16914
  const baseTerms = chosen?.via ? CONDITION_OPS.filter((c) => c.op === "eq" || c.op === "ne") : CONDITION_OPS;
16839
16915
  const relativeTerm = relative ? RELATIVE_DAY_TERMS.find((t) => t.kind === relative.kind) : void 0;
16840
16916
  function write(next) {
@@ -16857,7 +16933,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
16857
16933
  }
16858
16934
  const chosenOp = next.op ?? (op2 || (next.field ? CONDITION_OPS[0].op : ""));
16859
16935
  const chosenField = next.field ?? onField;
16860
- const chosenValue = next.value ?? value;
16936
+ let chosenValue = next.value ?? value;
16937
+ if (CHOICE_LIST_OPS.has(chosenOp)) chosenValue = wordsOfValue(chosenValue);
16938
+ else if (Array.isArray(chosenValue)) chosenValue = wordsOfValue(chosenValue)[0] ?? "";
16861
16939
  if (!chosenOp || !chosenField) {
16862
16940
  onChange(null);
16863
16941
  return;
@@ -16933,7 +17011,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
16933
17011
  allowCreate: false
16934
17012
  }
16935
17013
  )
16936
- ) : isChoiceColumn(chosen) && (op2 === "eq" || op2 === "ne" || op2 === "contains" || op2 === "not_contains") ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
17014
+ ) : isChoiceColumn(chosen) && CHOICE_LIST_OPS.has(op2) ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ChoiceValues, { field: chosen.field, value: wordsOfValue(value), onChange: (words2) => write({ value: words2 }) }) : isChoiceColumn(chosen) && (op2 === "eq" || op2 === "ne" || op2 === "contains" || op2 === "not_contains") ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
16937
17015
  import_design_system46.BasicInput,
16938
17016
  {
16939
17017
  className: "h-8 w-28 text-xs",
@@ -19335,7 +19413,7 @@ function RollupFilterQuestion({
19335
19413
  "."
19336
19414
  ] }),
19337
19415
  /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_design_system52.Button, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onChange(null), children: "Clear" })
19338
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
19416
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(ChoiceListTermsContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
19339
19417
  ConditionGroup,
19340
19418
  {
19341
19419
  lead: rollupFilterLead(agg),
@@ -19344,7 +19422,7 @@ function RollupFilterQuestion({
19344
19422
  fields: conditionFields,
19345
19423
  onChange
19346
19424
  }
19347
- ) });
19425
+ ) }) });
19348
19426
  }
19349
19427
  function ValueOnTheOtherSide({
19350
19428
  label,
@@ -44042,7 +44120,7 @@ function ListView({
44042
44120
  layout: "list",
44043
44121
  fields,
44044
44122
  hiddenFields,
44045
- summary: chose ? `Fields shown (${shown5.length} of ${fields.length})` : `Fields shown (first ${LIST_DEFAULT_FIELDS} filled)`,
44123
+ summary: chose ? `Fields shown (${shown5.length} of ${fields.length})` : "Fields",
44046
44124
  onChange: onHiddenFieldsChange,
44047
44125
  remembered
44048
44126
  }
@@ -44498,10 +44576,11 @@ function useCompactWith(plain2) {
44498
44576
  var import_react261 = require("react");
44499
44577
  var import_design_system125 = require("@ai-matrx/design-system");
44500
44578
  var import_jsx_runtime149 = require("react/jsx-runtime");
44579
+ var useBeforePaint = typeof document === "undefined" ? import_react261.useEffect : import_react261.useLayoutEffect;
44501
44580
  function useMeasuredWidth(fallback = 480) {
44502
44581
  const ref = (0, import_react261.useRef)(null);
44503
44582
  const [width, setWidth] = (0, import_react261.useState)(fallback);
44504
- (0, import_react261.useEffect)(() => {
44583
+ useBeforePaint(() => {
44505
44584
  const node = ref.current;
44506
44585
  if (!node) return;
44507
44586
  const apply = () => {
@@ -44590,7 +44669,7 @@ function ChartLegendContent({
44590
44669
  if (!payload || payload.length === 0) return null;
44591
44670
  return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("div", { className: (0, import_design_system125.cn)("flex flex-wrap items-center justify-center gap-3 pt-2", className), children: payload.map((entry, index) => {
44592
44671
  const key = String(entry.dataKey ?? entry.value ?? index);
44593
- return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)("span", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
44672
+ return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)("span", { className: "flex max-w-full items-center gap-1.5 text-xs text-muted-foreground", children: [
44594
44673
  /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
44595
44674
  "span",
44596
44675
  {
@@ -44598,7 +44677,7 @@ function ChartLegendContent({
44598
44677
  style: { "--color-swatch": entry.color }
44599
44678
  }
44600
44679
  ),
44601
- config[key]?.label ?? key
44680
+ /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("span", { className: "min-w-0 truncate", title: String(config[key]?.label ?? key), children: config[key]?.label ?? key })
44602
44681
  ] }, key);
44603
44682
  }) });
44604
44683
  }
@@ -44680,6 +44759,8 @@ function colorOfGroup(groups, colors) {
44680
44759
  var NO_GROUPS = { title: "", kind: "bar", group_by: [], rows: [] };
44681
44760
  function ChartBlock({ block, subject, tableName: tableName2, className, centerValue, centerTotal, dataLabels, legend = true, groupColors, variant = "card", source, shape }) {
44682
44761
  const bare = variant === "bare";
44762
+ const [figureRef, figureWidth] = useMeasuredWidth(480);
44763
+ const narrow = figureWidth < 400;
44683
44764
  const host = useRecordsUi();
44684
44765
  const drawn = shape ?? block.kind;
44685
44766
  const kind2 = shape ? BASE_KIND_OF_SHAPE[shape] : block.kind;
@@ -44794,18 +44875,19 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
44794
44875
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFormatContext.Provider, { value: numberFormat, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
44795
44876
  "figure",
44796
44877
  {
44878
+ ref: figureRef,
44797
44879
  className: (0, import_design_system126.cn)("flex min-w-0 flex-col gap-1.5", bare ? null : "rounded border p-2", className),
44798
44880
  ...bare ? { "aria-label": block.title || CHART_KIND_LABEL[kind2] } : {},
44799
44881
  ...typeof block.ms === "number" ? { "data-store-ms": pretty(block.ms) } : {},
44800
44882
  children: [
44801
- bare ? null : /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)("figcaption", { className: "flex items-baseline gap-2 text-xs", children: [
44802
- tableName2 ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: "shrink-0 text-muted-foreground", "data-records-chart-table": "", children: tableName2 }) : null,
44803
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: "truncate font-medium", children: block.title || CHART_KIND_LABEL[kind2] }),
44883
+ bare ? null : /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)("figcaption", { className: (0, import_design_system126.cn)("flex min-w-0 items-baseline gap-x-2 text-xs", narrow ? "flex-wrap" : null), "data-records-chart-caption": "", children: [
44884
+ tableName2 ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: "max-w-[40%] shrink-0 truncate text-muted-foreground", title: tableName2, "data-records-chart-table": "", children: tableName2 }) : null,
44885
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: (0, import_design_system126.cn)("truncate font-medium", narrow ? "min-w-0 max-w-full flex-[1_1_100%]" : "min-w-[6ch] shrink"), title: block.title || CHART_KIND_LABEL[kind2], "data-records-chart-title": "", children: block.title || CHART_KIND_LABEL[kind2] }),
44804
44886
  kind2 !== "number" && compared && block.totals && typeof block.totals.current === "number" ? /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)("span", { className: "flex shrink-0 items-baseline gap-1 tabular-nums", children: [
44805
44887
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { children: pretty(block.totals.current) }),
44806
44888
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Trend, { pct: block.totals.change_pct, aimingUp: !!target })
44807
44889
  ] }) : null,
44808
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: "ml-auto shrink-0 text-muted-foreground", children: kind2 === "stuck" ? `${block.days ?? 14} days` : measureName })
44890
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: (0, import_design_system126.cn)("min-w-0 truncate text-muted-foreground", narrow ? "max-w-full" : "ml-auto max-w-[45%] shrink-0"), title: kind2 === "stuck" ? void 0 : measureName, children: kind2 === "stuck" ? `${block.days ?? 14} days` : measureName })
44809
44891
  ] }),
44810
44892
  block.compare_refused ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: block.compare_refused }) : null,
44811
44893
  !block.refused && targetNote(target) ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: targetNote(target) }) : null,
@@ -44997,11 +45079,27 @@ function wrapTickWords(label, perLine, maxLines = 3) {
44997
45079
  kept[maxLines - 1] = `${last.length >= perLine ? last.slice(0, perLine - 1) : last}\u2026`;
44998
45080
  return kept;
44999
45081
  }
45082
+ var TICK_CHAR_PX = 5.6;
45083
+ var TICK_MIN_CHARS = 6;
45084
+ function planCategoryTicks(slotPx, charPx = TICK_CHAR_PX, minChars = TICK_MIN_CHARS) {
45085
+ const slot = Math.max(1, slotPx);
45086
+ const fit = Math.floor((slot - 4) / charPx);
45087
+ if (fit >= minChars) return { step: 1, perLine: fit };
45088
+ const step2 = Math.max(1, Math.ceil((minChars * charPx + 4) / slot));
45089
+ return { step: step2, perLine: Math.max(3, Math.floor((slot * step2 - 4) / charPx)) };
45090
+ }
45091
+ function lineAxis(width, count) {
45092
+ const plan = planCategoryTicks((width - 56) / Math.max(count, 1));
45093
+ const pad4 = Math.min(30, Math.ceil(plan.perLine * TICK_CHAR_PX / 2));
45094
+ return { interval: 0, height: 40, padding: { left: pad4, right: pad4 }, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { ...plan }) };
45095
+ }
45000
45096
  function WrappedTick(props) {
45001
- const { x = 0, y = 0, payload, across, perLine } = props;
45002
- const lines = wrapTickWords(String(payload?.value ?? ""), perLine);
45097
+ const { x = 0, y = 0, index = 0, payload, across, perLine, step: step2 = 1, maxLines = 3 } = props;
45098
+ if (step2 > 1 && index % step2 !== 0) return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("g", {});
45099
+ const full = String(payload?.value ?? "");
45100
+ const lines = wrapTickWords(full, perLine, maxLines);
45003
45101
  const lineHeight = 11;
45004
- return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45102
+ return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45005
45103
  "text",
45006
45104
  {
45007
45105
  x,
@@ -45010,15 +45108,18 @@ function WrappedTick(props) {
45010
45108
  fill: "currentColor",
45011
45109
  textAnchor: across ? "end" : "middle",
45012
45110
  "data-records-chart-tick": "",
45013
- children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45014
- "tspan",
45015
- {
45016
- x: across ? x - 4 : x,
45017
- dy: i === 0 ? across ? -((lines.length - 1) * lineHeight) / 2 + 3 : 10 : lineHeight,
45018
- children: line
45019
- },
45020
- i
45021
- ))
45111
+ children: [
45112
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("title", { children: full }),
45113
+ lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45114
+ "tspan",
45115
+ {
45116
+ x: across ? x - 4 : x,
45117
+ dy: i === 0 ? across ? -((lines.length - 1) * lineHeight) / 2 + 3 : 10 : lineHeight,
45118
+ children: line
45119
+ },
45120
+ i
45121
+ ))
45122
+ ]
45022
45123
  }
45023
45124
  );
45024
45125
  }
@@ -45131,7 +45232,7 @@ function Drawing({
45131
45232
  if (kind2 === "area") {
45132
45233
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_recharts.AreaChart, { width, height: HEIGHT, data, margin: { top: dataLabels ? 16 : 6, right: dataLabels ? 14 : 6, bottom: 0, left: 0 }, children: [
45133
45234
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: false }),
45134
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis }),
45235
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis, ...lineAxis(width, points.length) }),
45135
45236
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis }),
45136
45237
  tooltip,
45137
45238
  legend,
@@ -45160,7 +45261,7 @@ function Drawing({
45160
45261
  const tallest = Math.max(1, ...stack.data.map((row) => keys.reduce((sum, k) => sum + (typeof row[k] === "number" ? row[k] : 0), 0)));
45161
45262
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_recharts.BarChart, { width, height: HEIGHT, data: stack.data, margin: { top: dataLabels ? 16 : 6, right: 6, bottom: 0, left: 0 }, "data-records-stacked": "", children: [
45162
45263
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: false }),
45163
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis, interval: 0, height: 40, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { perLine: Math.max(6, Math.floor(width / Math.max(stack.data.length, 1) / 6)) }) }),
45264
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis, interval: 0, height: 40, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { ...planCategoryTicks((width - 56) / Math.max(stack.data.length, 1)) }) }),
45164
45265
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis, allowDecimals: !onlyWholeNumbers(stack.data) }),
45165
45266
  tooltip,
45166
45267
  showLegend ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.Legend, { content: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartLegendContent, { config }) }) : null,
@@ -45194,7 +45295,7 @@ function Drawing({
45194
45295
  const dots = points.map((point) => ({ label: point.label, x: point.values[xKey] ?? 0, y: point.values[yKey] ?? 0 }));
45195
45296
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_recharts.ScatterChart, { width, height: HEIGHT, margin: { top: dataLabels ? 16 : 6, right: 14, bottom: 0, left: 0 }, "data-records-scatter": "", children: [
45196
45297
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, {}),
45197
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { type: "number", dataKey: "x", name: String(config[xKey]?.label ?? ""), ...axis, allowDecimals: !onlyWholeNumbers(dots) }),
45298
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { type: "number", dataKey: "x", name: String(config[xKey]?.label ?? ""), ...axis, tickCount: Math.max(2, Math.floor((width - 56) / 52)), interval: "preserveStartEnd", allowDecimals: !onlyWholeNumbers(dots) }),
45198
45299
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { type: "number", dataKey: "y", name: String(config[yKey]?.label ?? ""), width: 44, ...axis, allowDecimals: !onlyWholeNumbers(dots) }),
45199
45300
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45200
45301
  import_recharts.Tooltip,
@@ -45223,7 +45324,7 @@ function Drawing({
45223
45324
  if (kind2 === "line") {
45224
45325
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_recharts.LineChart, { width, height: HEIGHT, data, margin: { top: dataLabels ? 16 : 6, right: dataLabels ? 14 : 6, bottom: 0, left: 0 }, children: [
45225
45326
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: false }),
45226
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis }),
45327
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis, ...lineAxis(width, points.length) }),
45227
45328
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis }),
45228
45329
  tooltip,
45229
45330
  legend,
@@ -45246,57 +45347,62 @@ function Drawing({
45246
45347
  ] }) });
45247
45348
  }
45248
45349
  const horizontal = kind2 === "bar";
45249
- return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45250
- import_recharts.BarChart,
45251
- {
45252
- width,
45253
- height: HEIGHT,
45254
- data,
45255
- layout: horizontal ? "vertical" : "horizontal",
45256
- margin: { top: dataLabels && !horizontal ? 16 : 6, right: dataLabels && horizontal ? 40 : 6, bottom: 0, left: 0 },
45257
- children: [
45258
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: horizontal, horizontal: !horizontal }),
45259
- horizontal ? /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [
45260
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { type: "number", ...axis }),
45261
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { type: "category", dataKey: "label", width: 96, ...axis, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { across: true, perLine: 15 }) })
45262
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [
45263
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis, interval: 0, height: 40, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { perLine: Math.max(6, Math.floor(width / Math.max(points.length, 1) / 6)) }) }),
45264
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis })
45265
- ] }),
45266
- tooltip,
45267
- legend,
45268
- goalLine(horizontal),
45269
- drawOrder.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45270
- import_recharts.Bar,
45271
- {
45272
- dataKey: key,
45273
- radius: 2,
45274
- isAnimationActive: false,
45275
- fill: `var(--color-${key})`,
45276
- ...click ? { onClick: click, className: "cursor-pointer" } : {},
45277
- children: [
45278
- series.length === 1 ? points.map((point, at) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.Cell, { fill: String(config[point.label]?.color ?? SERIES_COLORS[index]) }, `${at}:${point.label}`)) : null,
45279
- dataLabels && key === series[0] ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45280
- import_recharts.LabelList,
45281
- {
45282
- dataKey: key,
45283
- content: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45284
- SpacedLabel,
45285
- {
45286
- show: horizontal ? labelsThatFit(points.map(() => "0"), HEIGHT - 20, 11, true) : labelsThatFit(points.map((p) => labelText(p.values[key])), width - 50),
45287
- text: labelText,
45288
- placement: horizontal ? "end" : "above"
45289
- }
45290
- )
45291
- }
45292
- ) : null
45293
- ]
45294
- },
45295
- key
45296
- ))
45297
- ]
45298
- }
45299
- ) });
45350
+ return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => {
45351
+ const sideWidth = Math.max(56, Math.min(96, Math.floor(width * 0.34)));
45352
+ const rowPx = (HEIGHT - 30) / Math.max(points.length, 1);
45353
+ const sideRows = { maxLines: Math.max(1, Math.min(3, Math.floor(rowPx / 11))), step: rowPx >= 11 ? 1 : Math.ceil(11 / rowPx) };
45354
+ return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45355
+ import_recharts.BarChart,
45356
+ {
45357
+ width,
45358
+ height: HEIGHT,
45359
+ data,
45360
+ layout: horizontal ? "vertical" : "horizontal",
45361
+ margin: { top: dataLabels && !horizontal ? 16 : 6, right: dataLabels && horizontal ? 40 : 6, bottom: 0, left: 0 },
45362
+ children: [
45363
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: horizontal, horizontal: !horizontal }),
45364
+ horizontal ? /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [
45365
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { type: "number", ...axis }),
45366
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { type: "category", dataKey: "label", width: sideWidth, ...axis, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { across: true, perLine: Math.max(4, Math.floor((sideWidth - 8) / TICK_CHAR_PX)), ...sideRows }) })
45367
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [
45368
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { dataKey: "label", ...axis, interval: 0, height: 40, tick: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedTick, { ...planCategoryTicks((width - 56) / Math.max(points.length, 1)) }) }),
45369
+ /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis })
45370
+ ] }),
45371
+ tooltip,
45372
+ legend,
45373
+ goalLine(horizontal),
45374
+ drawOrder.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45375
+ import_recharts.Bar,
45376
+ {
45377
+ dataKey: key,
45378
+ radius: 2,
45379
+ isAnimationActive: false,
45380
+ fill: `var(--color-${key})`,
45381
+ ...click ? { onClick: click, className: "cursor-pointer" } : {},
45382
+ children: [
45383
+ series.length === 1 ? points.map((point, at) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.Cell, { fill: String(config[point.label]?.color ?? SERIES_COLORS[index]) }, `${at}:${point.label}`)) : null,
45384
+ dataLabels && key === series[0] ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45385
+ import_recharts.LabelList,
45386
+ {
45387
+ dataKey: key,
45388
+ content: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45389
+ SpacedLabel,
45390
+ {
45391
+ show: horizontal ? labelsThatFit(points.map(() => "0"), HEIGHT - 20, 11, true) : labelsThatFit(points.map((p) => labelText(p.values[key])), width - 50),
45392
+ text: labelText,
45393
+ placement: horizontal ? "end" : "above"
45394
+ }
45395
+ )
45396
+ }
45397
+ ) : null
45398
+ ]
45399
+ },
45400
+ key
45401
+ ))
45402
+ ]
45403
+ }
45404
+ );
45405
+ } });
45300
45406
  }
45301
45407
  function centerOfGroups(points, key, op2) {
45302
45408
  const vals = points.map((p) => p.values[key]).filter((v) => typeof v === "number" && Number.isFinite(v));
@@ -45536,7 +45642,7 @@ var import_records58 = require("@ai-matrx/records");
45536
45642
  var PIVOT_OPS = ["count", "sum", "avg", "min", "max"];
45537
45643
  var isPivotOp = (v) => PIVOT_OPS.includes(v ?? "");
45538
45644
  var PIVOT_OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Min", max: "Max" };
45539
- var PIVOT_CELL_LIMIT = 2e3;
45645
+ var PIVOT_CELL_LIMIT = 1e3;
45540
45646
  var NUMBER_TYPES2 = /* @__PURE__ */ new Set(["number", "integer", "decimal", "money", "currency", "percent", "percentage"]);
45541
45647
  var isNumberField = (f) => NUMBER_TYPES2.has(String(f.type));
45542
45648
  function pivotQuestion(view, fields) {
@@ -45762,9 +45868,9 @@ function PivotLayout({ view, fields, filter, onChange, remembered }) {
45762
45868
  ] }) }) : null
45763
45869
  ] }) }),
45764
45870
  table.cut ? /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)("p", { className: "text-xs text-muted-foreground", "data-records-pivot-cut": "", children: [
45765
- "Showing the first ",
45871
+ "First ",
45766
45872
  PIVOT_CELL_LIMIT.toLocaleString(),
45767
- " cells; narrow the view's filter to see the rest."
45873
+ " cells only. Narrow the filter to see the rest."
45768
45874
  ] }) : null
45769
45875
  ] })
45770
45876
  ] });
@@ -46410,8 +46516,6 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
46410
46516
  cancelled = true;
46411
46517
  };
46412
46518
  }, [client, ruleId, pageSize]);
46413
- const asked4 = (0, import_records60.stableFilterKey)(filter ?? null);
46414
- const fromView = asked4 !== "{}" && (asked4 === (0, import_records60.stableFilterKey)(view.where ?? null) || asked4 === (0, import_records60.stableFilterKey)(view.filters ?? null));
46415
46519
  const tableRows = (0, import_react270.useMemo)(() => table.data?.rows ?? [], [table.data]);
46416
46520
  const manual = view.order === "manual" && Boolean(viewId) && !ruleId;
46417
46521
  const hand = useHandOrderRows({
@@ -46463,7 +46567,7 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
46463
46567
  // sat over every board and gallery. A view of the whole table says nothing about it; a narrowed
46464
46568
  // one says how, in words a person uses.
46465
46569
  membership: [
46466
- ruleId ? "Showing the records this view's rule picks." : fromView ? "Showing the records this view's filter matches." : asked4 !== "{}" ? "Showing only the records behind the number you clicked." : "",
46570
+ // A person sees the rows; the screen does not narrate why they are the rows.
46467
46571
  manual ? HAND_ORDER_NOTE : ""
46468
46572
  ].filter(Boolean).join(" ")
46469
46573
  };
@@ -47522,7 +47626,7 @@ function Gallery({
47522
47626
  layout: "gallery",
47523
47627
  fields,
47524
47628
  hiddenFields,
47525
- summary: chose ? `Fields shown (${shown5.length} of ${fields.length})` : `Fields shown (first ${GALLERY_DEFAULT_FIELDS} filled)`,
47629
+ summary: chose ? `Fields shown (${shown5.length} of ${fields.length})` : "Fields",
47526
47630
  onChange: onHiddenFieldsChange,
47527
47631
  remembered
47528
47632
  }