@ai-matrx/records-ui 0.116.26 → 0.116.28

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)) {
@@ -14011,6 +14019,15 @@ function RelationPicker({ field: field2, value, onChange, disabled, id, classNam
14011
14019
  );
14012
14020
  }
14013
14021
 
14022
+ // src/readableLink.ts
14023
+ function readableLink(raw) {
14024
+ try {
14025
+ return decodeURI(raw).replace(/%40/gi, "@");
14026
+ } catch {
14027
+ return raw;
14028
+ }
14029
+ }
14030
+
14014
14031
  // src/buttonCell.tsx
14015
14032
  var import_react89 = require("react");
14016
14033
  var import_design_system53 = require("@ai-matrx/design-system");
@@ -14762,7 +14779,7 @@ function RatingStars({
14762
14779
  function rich(id, text, raw, format) {
14763
14780
  switch (id) {
14764
14781
  case "email":
14765
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "truncate", children: text }) });
14782
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "truncate", children: readableLink(text) }) });
14766
14783
  case "url":
14767
14784
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_outbound_react3.OutboundLink, { href: text.includes("://") ? text : `https://${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "truncate", children: text }) });
14768
14785
  case "phone":
@@ -15991,7 +16008,7 @@ function Scalar({ value, keyName, dense }) {
15991
16008
  if (isImageUrl(text, keyName)) return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Thumb, { src: text, size: dense ? "sm" : "md" });
15992
16009
  if (isUrl(text)) return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(LinkChip, { href: text, dense });
15993
16010
  if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(text)) {
15994
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("a", { href: `mailto:${text}`, onClick: stop, className: "text-primary underline-offset-2 hover:underline", children: text });
16011
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("a", { href: `mailto:${text}`, onClick: stop, className: "text-primary underline-offset-2 hover:underline", children: readableLink(text) });
15995
16012
  }
15996
16013
  const date = dateWords(text);
15997
16014
  if (date) return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { title: text, children: date });
@@ -16300,7 +16317,7 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look, ro
16300
16317
  {
16301
16318
  className: "inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border border-border bg-muted/60 px-1.5 py-0.5 text-[11px] text-foreground hover:bg-accent",
16302
16319
  href,
16303
- title: value,
16320
+ title: readableLink(value),
16304
16321
  "data-records-link-chip": "",
16305
16322
  onClick: (event) => event.stopPropagation(),
16306
16323
  children: [
@@ -16324,7 +16341,7 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look, ro
16324
16341
  );
16325
16342
  }
16326
16343
  if (kind2 === "email" && typeof value === "string") {
16327
- return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
16344
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: readableLink(value) });
16328
16345
  }
16329
16346
  if (typeof value === "boolean") {
16330
16347
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: kind2 === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
@@ -16595,6 +16612,16 @@ var LIST_TERMS = [
16595
16612
  { op: "is_empty", label: "is empty" },
16596
16613
  { op: "is_not_empty", label: "is not empty" }
16597
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
+ }
16598
16625
  var VALUELESS_OPS = /* @__PURE__ */ new Set(["present", "is_empty", "is_not_empty"]);
16599
16626
  var LINK_SEP = ">";
16600
16627
  function linkedNode(viaId, innerId, op2, value) {
@@ -16666,6 +16693,59 @@ function isChoiceColumn(f) {
16666
16693
  const kind2 = String(editorKindFor(f.field));
16667
16694
  return kind2 === "select" || kind2 === "multi_select";
16668
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
+ }
16669
16749
  function ChoiceValue({ field: field2, value, onChange }) {
16670
16750
  const client = (0, import_react80.useOptionalRecordsClient)();
16671
16751
  const [choices, setChoices] = (0, import_react79.useState)(null);
@@ -16730,7 +16810,7 @@ function conditionIsSimple(expr) {
16730
16810
  if (expr === null || expr === void 0) return true;
16731
16811
  if (relativeDayOf(expr) !== null || meOf(expr) !== null || linkedOf(expr) !== null) return true;
16732
16812
  const node = expr;
16733
- 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))) {
16734
16814
  return false;
16735
16815
  }
16736
16816
  if (!Array.isArray(node.args)) return false;
@@ -16817,6 +16897,7 @@ function conditionValue(typed2) {
16817
16897
  function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
16818
16898
  const node = expr ?? null;
16819
16899
  const filterTerms = (0, import_react79.useContext)(FilterTermsContext);
16900
+ const choiceListTerms = (0, import_react79.useContext)(ChoiceListTermsContext) || filterTerms;
16820
16901
  const relative = relativeDayOf(expr);
16821
16902
  const reader = meOf(expr);
16822
16903
  const linked = linkedOf(expr);
@@ -16825,7 +16906,11 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
16825
16906
  const value = relative || reader ? "" : linked ? linked.value : node?.args?.[1]?.const ?? "";
16826
16907
  const chosen = fields.find((f) => f.id === onField);
16827
16908
  const chosenKind = chosen?.field ? String(editorKindFor(chosen.field)) : "";
16828
- 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
+ ];
16829
16914
  const baseTerms = chosen?.via ? CONDITION_OPS.filter((c) => c.op === "eq" || c.op === "ne") : CONDITION_OPS;
16830
16915
  const relativeTerm = relative ? RELATIVE_DAY_TERMS.find((t) => t.kind === relative.kind) : void 0;
16831
16916
  function write(next) {
@@ -16848,7 +16933,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
16848
16933
  }
16849
16934
  const chosenOp = next.op ?? (op2 || (next.field ? CONDITION_OPS[0].op : ""));
16850
16935
  const chosenField = next.field ?? onField;
16851
- 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] ?? "";
16852
16939
  if (!chosenOp || !chosenField) {
16853
16940
  onChange(null);
16854
16941
  return;
@@ -16924,7 +17011,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
16924
17011
  allowCreate: false
16925
17012
  }
16926
17013
  )
16927
- ) : 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)(
16928
17015
  import_design_system46.BasicInput,
16929
17016
  {
16930
17017
  className: "h-8 w-28 text-xs",
@@ -19326,7 +19413,7 @@ function RollupFilterQuestion({
19326
19413
  "."
19327
19414
  ] }),
19328
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" })
19329
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
19416
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(ChoiceListTermsContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
19330
19417
  ConditionGroup,
19331
19418
  {
19332
19419
  lead: rollupFilterLead(agg),
@@ -19335,7 +19422,7 @@ function RollupFilterQuestion({
19335
19422
  fields: conditionFields,
19336
19423
  onChange
19337
19424
  }
19338
- ) });
19425
+ ) }) });
19339
19426
  }
19340
19427
  function ValueOnTheOtherSide({
19341
19428
  label,
@@ -19414,7 +19501,7 @@ var import_outbound_react7 = require("@ai-matrx/kit/outbound-react");
19414
19501
  var import_outbound2 = require("@ai-matrx/kit/outbound");
19415
19502
  var import_jsx_runtime62 = require("react/jsx-runtime");
19416
19503
  function buttonPressWords(label, pressed) {
19417
- if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
19504
+ if (pressed.do === "open_url") return `${label} opened ${readableLink(pressed.url)}`;
19418
19505
  if (pressed.do === "add_row") return `${label}: a row was added.`;
19419
19506
  if (pressed.do === "run_action") {
19420
19507
  const n = Number(pressed.result?.ran ?? 1);
@@ -19628,7 +19715,7 @@ function ButtonValue({ field: field2, recordId, inCell, beforeSave }) {
19628
19715
  said2.value ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(StructuredValueView, { structured: said2.value, label: b.label }) : null,
19629
19716
  said2.says,
19630
19717
  " ",
19631
- said2.link ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_outbound_react7.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
19718
+ said2.link ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_outbound_react7.OutboundLink, { href: said2.link, className: "text-primary underline", children: readableLink(said2.link) }) : null
19632
19719
  ] }) : null,
19633
19720
  said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
19634
19721
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: said2.says }),
@@ -44033,7 +44120,7 @@ function ListView({
44033
44120
  layout: "list",
44034
44121
  fields,
44035
44122
  hiddenFields,
44036
- 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",
44037
44124
  onChange: onHiddenFieldsChange,
44038
44125
  remembered
44039
44126
  }
@@ -44489,10 +44576,11 @@ function useCompactWith(plain2) {
44489
44576
  var import_react261 = require("react");
44490
44577
  var import_design_system125 = require("@ai-matrx/design-system");
44491
44578
  var import_jsx_runtime149 = require("react/jsx-runtime");
44579
+ var useBeforePaint = typeof document === "undefined" ? import_react261.useEffect : import_react261.useLayoutEffect;
44492
44580
  function useMeasuredWidth(fallback = 480) {
44493
44581
  const ref = (0, import_react261.useRef)(null);
44494
44582
  const [width, setWidth] = (0, import_react261.useState)(fallback);
44495
- (0, import_react261.useEffect)(() => {
44583
+ useBeforePaint(() => {
44496
44584
  const node = ref.current;
44497
44585
  if (!node) return;
44498
44586
  const apply = () => {
@@ -44581,7 +44669,7 @@ function ChartLegendContent({
44581
44669
  if (!payload || payload.length === 0) return null;
44582
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) => {
44583
44671
  const key = String(entry.dataKey ?? entry.value ?? index);
44584
- 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: [
44585
44673
  /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
44586
44674
  "span",
44587
44675
  {
@@ -44589,7 +44677,7 @@ function ChartLegendContent({
44589
44677
  style: { "--color-swatch": entry.color }
44590
44678
  }
44591
44679
  ),
44592
- 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 })
44593
44681
  ] }, key);
44594
44682
  }) });
44595
44683
  }
@@ -44671,6 +44759,8 @@ function colorOfGroup(groups, colors) {
44671
44759
  var NO_GROUPS = { title: "", kind: "bar", group_by: [], rows: [] };
44672
44760
  function ChartBlock({ block, subject, tableName: tableName2, className, centerValue, centerTotal, dataLabels, legend = true, groupColors, variant = "card", source, shape }) {
44673
44761
  const bare = variant === "bare";
44762
+ const [figureRef, figureWidth] = useMeasuredWidth(480);
44763
+ const narrow = figureWidth < 400;
44674
44764
  const host = useRecordsUi();
44675
44765
  const drawn = shape ?? block.kind;
44676
44766
  const kind2 = shape ? BASE_KIND_OF_SHAPE[shape] : block.kind;
@@ -44785,18 +44875,19 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
44785
44875
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFormatContext.Provider, { value: numberFormat, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
44786
44876
  "figure",
44787
44877
  {
44878
+ ref: figureRef,
44788
44879
  className: (0, import_design_system126.cn)("flex min-w-0 flex-col gap-1.5", bare ? null : "rounded border p-2", className),
44789
44880
  ...bare ? { "aria-label": block.title || CHART_KIND_LABEL[kind2] } : {},
44790
44881
  ...typeof block.ms === "number" ? { "data-store-ms": pretty(block.ms) } : {},
44791
44882
  children: [
44792
- bare ? null : /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)("figcaption", { className: "flex items-baseline gap-2 text-xs", children: [
44793
- tableName2 ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: "shrink-0 text-muted-foreground", "data-records-chart-table": "", children: tableName2 }) : null,
44794
- /* @__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] }),
44795
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: [
44796
44887
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { children: pretty(block.totals.current) }),
44797
44888
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Trend, { pct: block.totals.change_pct, aimingUp: !!target })
44798
44889
  ] }) : null,
44799
- /* @__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 })
44800
44891
  ] }),
44801
44892
  block.compare_refused ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: block.compare_refused }) : null,
44802
44893
  !block.refused && targetNote(target) ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: targetNote(target) }) : null,
@@ -44988,11 +45079,27 @@ function wrapTickWords(label, perLine, maxLines = 3) {
44988
45079
  kept[maxLines - 1] = `${last.length >= perLine ? last.slice(0, perLine - 1) : last}\u2026`;
44989
45080
  return kept;
44990
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
+ }
44991
45096
  function WrappedTick(props) {
44992
- const { x = 0, y = 0, payload, across, perLine } = props;
44993
- 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);
44994
45101
  const lineHeight = 11;
44995
- return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45102
+ return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
44996
45103
  "text",
44997
45104
  {
44998
45105
  x,
@@ -45001,15 +45108,18 @@ function WrappedTick(props) {
45001
45108
  fill: "currentColor",
45002
45109
  textAnchor: across ? "end" : "middle",
45003
45110
  "data-records-chart-tick": "",
45004
- children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45005
- "tspan",
45006
- {
45007
- x: across ? x - 4 : x,
45008
- dy: i === 0 ? across ? -((lines.length - 1) * lineHeight) / 2 + 3 : 10 : lineHeight,
45009
- children: line
45010
- },
45011
- i
45012
- ))
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
+ ]
45013
45123
  }
45014
45124
  );
45015
45125
  }
@@ -45122,7 +45232,7 @@ function Drawing({
45122
45232
  if (kind2 === "area") {
45123
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: [
45124
45234
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: false }),
45125
- /* @__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) }),
45126
45236
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis }),
45127
45237
  tooltip,
45128
45238
  legend,
@@ -45151,7 +45261,7 @@ function Drawing({
45151
45261
  const tallest = Math.max(1, ...stack.data.map((row) => keys.reduce((sum, k) => sum + (typeof row[k] === "number" ? row[k] : 0), 0)));
45152
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: [
45153
45263
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: false }),
45154
- /* @__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)) }) }),
45155
45265
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis, allowDecimals: !onlyWholeNumbers(stack.data) }),
45156
45266
  tooltip,
45157
45267
  showLegend ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.Legend, { content: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartLegendContent, { config }) }) : null,
@@ -45185,7 +45295,7 @@ function Drawing({
45185
45295
  const dots = points.map((point) => ({ label: point.label, x: point.values[xKey] ?? 0, y: point.values[yKey] ?? 0 }));
45186
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: [
45187
45297
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, {}),
45188
- /* @__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) }),
45189
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) }),
45190
45300
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45191
45301
  import_recharts.Tooltip,
@@ -45214,7 +45324,7 @@ function Drawing({
45214
45324
  if (kind2 === "line") {
45215
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: [
45216
45326
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: false }),
45217
- /* @__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) }),
45218
45328
  /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis }),
45219
45329
  tooltip,
45220
45330
  legend,
@@ -45237,57 +45347,62 @@ function Drawing({
45237
45347
  ] }) });
45238
45348
  }
45239
45349
  const horizontal = kind2 === "bar";
45240
- return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45241
- import_recharts.BarChart,
45242
- {
45243
- width,
45244
- height: HEIGHT,
45245
- data,
45246
- layout: horizontal ? "vertical" : "horizontal",
45247
- margin: { top: dataLabels && !horizontal ? 16 : 6, right: dataLabels && horizontal ? 40 : 6, bottom: 0, left: 0 },
45248
- children: [
45249
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.CartesianGrid, { vertical: horizontal, horizontal: !horizontal }),
45250
- horizontal ? /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [
45251
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.XAxis, { type: "number", ...axis }),
45252
- /* @__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 }) })
45253
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_jsx_runtime150.Fragment, { children: [
45254
- /* @__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)) }) }),
45255
- /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.YAxis, { width: 44, ...axis })
45256
- ] }),
45257
- tooltip,
45258
- legend,
45259
- goalLine(horizontal),
45260
- drawOrder.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
45261
- import_recharts.Bar,
45262
- {
45263
- dataKey: key,
45264
- radius: 2,
45265
- isAnimationActive: false,
45266
- fill: `var(--color-${key})`,
45267
- ...click ? { onClick: click, className: "cursor-pointer" } : {},
45268
- children: [
45269
- 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,
45270
- dataLabels && key === series[0] ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45271
- import_recharts.LabelList,
45272
- {
45273
- dataKey: key,
45274
- content: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
45275
- SpacedLabel,
45276
- {
45277
- show: horizontal ? labelsThatFit(points.map(() => "0"), HEIGHT - 20, 11, true) : labelsThatFit(points.map((p) => labelText(p.values[key])), width - 50),
45278
- text: labelText,
45279
- placement: horizontal ? "end" : "above"
45280
- }
45281
- )
45282
- }
45283
- ) : null
45284
- ]
45285
- },
45286
- key
45287
- ))
45288
- ]
45289
- }
45290
- ) });
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
+ } });
45291
45406
  }
45292
45407
  function centerOfGroups(points, key, op2) {
45293
45408
  const vals = points.map((p) => p.values[key]).filter((v) => typeof v === "number" && Number.isFinite(v));
@@ -47513,7 +47628,7 @@ function Gallery({
47513
47628
  layout: "gallery",
47514
47629
  fields,
47515
47630
  hiddenFields,
47516
- summary: chose ? `Fields shown (${shown5.length} of ${fields.length})` : `Fields shown (first ${GALLERY_DEFAULT_FIELDS} filled)`,
47631
+ summary: chose ? `Fields shown (${shown5.length} of ${fields.length})` : "Fields",
47517
47632
  onChange: onHiddenFieldsChange,
47518
47633
  remembered
47519
47634
  }