@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/CHANGELOG.md CHANGED
@@ -24,11 +24,25 @@
24
24
  - Tests: `vitest.setup.ts` gives jsdom a no-op `performance.mark` / `measure`.
25
25
  - **New subpath `@ai-matrx/records-ui/data-source`:** `recordsDataSource`, `personActor` and the who-changed words (`whenWords`, `actorWords`, `actorBadge`, `lastChangeSentence`, `SOMEBODY`, `THE_SYSTEM`) alone. `/helpers` also carries the field-type words, the colour resolver and the table builders, which read `@ai-matrx/records/core`; this entry reaches `@ai-matrx/kit` only, and shares the one data-source cache with `/helpers` and the root. Additive. Consumer action: a shell-reachable service that only binds its supabase client or says when imports from `/data-source`.
26
26
 
27
- ## 0.116.26
27
+ ## 0.116.28
28
28
 
29
29
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
30
30
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
31
31
 
32
+ ## 0.116.26
33
+
34
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
35
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
36
+ Diff: `git diff bc2243b756 0eb2f8603b -- apps/shared/records-ui/src`
37
+
38
+ Changed shipped source files (6):
39
+ - `apps/shared/records-ui/src/FloatingRefusal.tsx`
40
+ - `apps/shared/records-ui/src/FormRunner.tsx`
41
+ - `apps/shared/records-ui/src/embeddedLook.tsx`
42
+ - `apps/shared/records-ui/src/gridColumns.tsx`
43
+ - `apps/shared/records-ui/src/gridEditing.tsx`
44
+ - `apps/shared/records-ui/src/orgTree.ts`
45
+
32
46
  ## 0.116.25
33
47
 
34
48
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
@@ -2762,6 +2762,15 @@ function RelationPicker({ field: field2, value, onChange, disabled, id, classNam
2762
2762
  );
2763
2763
  }
2764
2764
 
2765
+ // src/readableLink.ts
2766
+ function readableLink(raw) {
2767
+ try {
2768
+ return decodeURI(raw).replace(/%40/gi, "@");
2769
+ } catch {
2770
+ return raw;
2771
+ }
2772
+ }
2773
+
2765
2774
  // src/buttonCell.tsx
2766
2775
  import { useContext as useContext3, useEffect as useEffect20, useRef as useRef14, useState as useState28 } from "react";
2767
2776
  import { Button as Button16, Dialog as Dialog3, ErrorBox as ErrorBox2, DialogContent as DialogContent3, DialogDescription, DialogHeader as DialogHeader3, DialogTitle as DialogTitle3, Popover as Popover4, PopoverContent as PopoverContent4, PopoverTrigger as PopoverTrigger4, cn as cn18 } from "@ai-matrx/design-system";
@@ -3649,7 +3658,7 @@ function RatingStars({
3649
3658
  function rich(id, text, raw, format) {
3650
3659
  switch (id) {
3651
3660
  case "email":
3652
- return /* @__PURE__ */ jsx19("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ jsx19("span", { className: "truncate", children: text }) });
3661
+ return /* @__PURE__ */ jsx19("a", { href: `mailto:${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ jsx19("span", { className: "truncate", children: readableLink(text) }) });
3653
3662
  case "url":
3654
3663
  return /* @__PURE__ */ jsx19(OutboundLink3, { href: text.includes("://") ? text : `https://${text}`, className: LINK, onClick: own2, children: /* @__PURE__ */ jsx19("span", { className: "truncate", children: text }) });
3655
3664
  case "phone":
@@ -4928,7 +4937,7 @@ function Scalar({ value, keyName, dense }) {
4928
4937
  if (isImageUrl(text, keyName)) return /* @__PURE__ */ jsx26(Thumb, { src: text, size: dense ? "sm" : "md" });
4929
4938
  if (isUrl(text)) return /* @__PURE__ */ jsx26(LinkChip, { href: text, dense });
4930
4939
  if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(text)) {
4931
- return /* @__PURE__ */ jsx26("a", { href: `mailto:${text}`, onClick: stop, className: "text-primary underline-offset-2 hover:underline", children: text });
4940
+ return /* @__PURE__ */ jsx26("a", { href: `mailto:${text}`, onClick: stop, className: "text-primary underline-offset-2 hover:underline", children: readableLink(text) });
4932
4941
  }
4933
4942
  const date = dateWords(text);
4934
4943
  if (date) return /* @__PURE__ */ jsx26("span", { title: text, children: date });
@@ -5237,7 +5246,7 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look, ro
5237
5246
  {
5238
5247
  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",
5239
5248
  href,
5240
- title: value,
5249
+ title: readableLink(value),
5241
5250
  "data-records-link-chip": "",
5242
5251
  onClick: (event) => event.stopPropagation(),
5243
5252
  children: [
@@ -5261,7 +5270,7 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look, ro
5261
5270
  );
5262
5271
  }
5263
5272
  if (kind === "email" && typeof value === "string") {
5264
- return /* @__PURE__ */ jsx27("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: value });
5273
+ return /* @__PURE__ */ jsx27("a", { className: "truncate text-primary underline-offset-2 hover:underline", href: `mailto:${value}`, children: readableLink(value) });
5265
5274
  }
5266
5275
  if (typeof value === "boolean") {
5267
5276
  return /* @__PURE__ */ jsx27("span", { className: kind === "checkbox" ? "text-sm" : "", title: value ? "Yes" : "No", children: value ? "\u2713" : "\u2014" });
@@ -5528,6 +5537,16 @@ var LIST_TERMS = [
5528
5537
  { op: "is_empty", label: "is empty" },
5529
5538
  { op: "is_not_empty", label: "is not empty" }
5530
5539
  ];
5540
+ var CHOICE_LIST_TERMS = [
5541
+ { op: "has_any", label: "is any of" },
5542
+ { op: "has_none", label: "is none of" }
5543
+ ];
5544
+ var ChoiceListTermsContext = createContext3(false);
5545
+ var CHOICE_LIST_OPS = /* @__PURE__ */ new Set(["has_any", "has_none"]);
5546
+ function wordsOfValue(value) {
5547
+ if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
5548
+ return typeof value === "string" && value !== "" ? [value] : [];
5549
+ }
5531
5550
  var VALUELESS_OPS = /* @__PURE__ */ new Set(["present", "is_empty", "is_not_empty"]);
5532
5551
  var LINK_SEP = ">";
5533
5552
  function linkedNode(viaId, innerId, op2, value) {
@@ -5599,6 +5618,59 @@ function isChoiceColumn(f) {
5599
5618
  const kind = String(editorKindFor(f.field));
5600
5619
  return kind === "select" || kind === "multi_select";
5601
5620
  }
5621
+ function ChoiceValues({ field: field2, value, onChange }) {
5622
+ const client = useOptionalRecordsClient8();
5623
+ const [choices, setChoices] = useState22(null);
5624
+ useEffect14(() => {
5625
+ if (!client) return;
5626
+ let cancelled = false;
5627
+ void (0, askOnce_exports.fieldOptionsOnce)(client, field2.id).then((got) => {
5628
+ if (cancelled) return;
5629
+ setChoices(got.ok ? (got.data ?? []).map((o) => ({ key: optionKey2(o), label: optionLabel(o) ?? "" })).filter((c) => c.label !== "") : []);
5630
+ });
5631
+ return () => {
5632
+ cancelled = true;
5633
+ };
5634
+ }, [client, field2.id]);
5635
+ const lower = value.map((w) => w.toLowerCase());
5636
+ const isOn = (c) => lower.includes(c.key.toLowerCase()) || lower.includes(c.label.toLowerCase());
5637
+ const known = (choices ?? []).flatMap((c) => [c.key.toLowerCase(), c.label.toLowerCase()]);
5638
+ const strays = value.filter((w) => !known.includes(w.toLowerCase()));
5639
+ const toggle = (c) => {
5640
+ const rest = value.filter((w) => w.toLowerCase() !== c.key.toLowerCase() && w.toLowerCase() !== c.label.toLowerCase());
5641
+ const next = isOn(c) ? rest : [...rest, c.label];
5642
+ const order = (choices ?? []).map((x) => x.label);
5643
+ onChange([...next].sort((a, b) => (order.indexOf(a) === -1 ? 1e6 : order.indexOf(a)) - (order.indexOf(b) === -1 ? 1e6 : order.indexOf(b))));
5644
+ };
5645
+ if (!choices || choices.length === 0) {
5646
+ return /* @__PURE__ */ jsx29(
5647
+ BasicInput6,
5648
+ {
5649
+ className: "h-8 w-40 text-xs",
5650
+ "aria-label": "Condition values, separated by commas",
5651
+ value: value.join(", "),
5652
+ onChange: (e) => onChange(e.target.value.split(",").map((w) => w.trim()).filter((w) => w !== ""))
5653
+ }
5654
+ );
5655
+ }
5656
+ return /* @__PURE__ */ jsxs25("span", { className: "inline-flex flex-wrap items-center gap-1", "data-records-condition-choices": "", "data-pick-values": value.join("|"), children: [
5657
+ choices.map((c) => /* @__PURE__ */ jsx29(
5658
+ Button12,
5659
+ {
5660
+ type: "button",
5661
+ size: "sm",
5662
+ variant: isOn(c) ? "default" : "outline",
5663
+ className: "h-7 px-2 text-xs",
5664
+ "aria-pressed": isOn(c),
5665
+ "aria-label": `${c.label} for ${field2.label || field2.key}`,
5666
+ onClick: () => toggle(c),
5667
+ children: c.label
5668
+ },
5669
+ c.key
5670
+ )),
5671
+ strays.map((w) => /* @__PURE__ */ jsx29(Button12, { 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}`))
5672
+ ] });
5673
+ }
5602
5674
  function ChoiceValue({ field: field2, value, onChange }) {
5603
5675
  const client = useOptionalRecordsClient8();
5604
5676
  const [choices, setChoices] = useState22(null);
@@ -5663,7 +5735,7 @@ function conditionIsSimple(expr) {
5663
5735
  if (expr === null || expr === void 0) return true;
5664
5736
  if (relativeDayOf(expr) !== null || meOf(expr) !== null || linkedOf(expr) !== null) return true;
5665
5737
  const node = expr;
5666
- if (typeof node.op !== "string" || !(CONDITION_OPS.some((c) => c.op === node.op) || LIST_TERMS.some((c) => c.op === node.op))) {
5738
+ 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))) {
5667
5739
  return false;
5668
5740
  }
5669
5741
  if (!Array.isArray(node.args)) return false;
@@ -5750,6 +5822,7 @@ function conditionValue(typed) {
5750
5822
  function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", className }) {
5751
5823
  const node = expr ?? null;
5752
5824
  const filterTerms = useContext2(FilterTermsContext);
5825
+ const choiceListTerms = useContext2(ChoiceListTermsContext) || filterTerms;
5753
5826
  const relative = relativeDayOf(expr);
5754
5827
  const reader = meOf(expr);
5755
5828
  const linked = linkedOf(expr);
@@ -5758,7 +5831,11 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
5758
5831
  const value = relative || reader ? "" : linked ? linked.value : node?.args?.[1]?.const ?? "";
5759
5832
  const chosen = fields.find((f) => f.id === onField);
5760
5833
  const chosenKind = chosen?.field ? String(editorKindFor(chosen.field)) : "";
5761
- 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 : [];
5834
+ const choiceTerms = choiceListTerms && !chosen?.via && (chosenKind === "select" || chosenKind === "multi_select") ? CHOICE_LIST_TERMS : [];
5835
+ const extraTerms = [
5836
+ ...!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 : [],
5837
+ ...choiceTerms
5838
+ ];
5762
5839
  const baseTerms = chosen?.via ? CONDITION_OPS.filter((c) => c.op === "eq" || c.op === "ne") : CONDITION_OPS;
5763
5840
  const relativeTerm = relative ? RELATIVE_DAY_TERMS.find((t) => t.kind === relative.kind) : void 0;
5764
5841
  function write(next) {
@@ -5781,7 +5858,9 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
5781
5858
  }
5782
5859
  const chosenOp = next.op ?? (op2 || (next.field ? CONDITION_OPS[0].op : ""));
5783
5860
  const chosenField = next.field ?? onField;
5784
- const chosenValue = next.value ?? value;
5861
+ let chosenValue = next.value ?? value;
5862
+ if (CHOICE_LIST_OPS.has(chosenOp)) chosenValue = wordsOfValue(chosenValue);
5863
+ else if (Array.isArray(chosenValue)) chosenValue = wordsOfValue(chosenValue)[0] ?? "";
5785
5864
  if (!chosenOp || !chosenField) {
5786
5865
  onChange(null);
5787
5866
  return;
@@ -5857,7 +5936,7 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
5857
5936
  allowCreate: false
5858
5937
  }
5859
5938
  )
5860
- ) : isChoiceColumn(chosen) && (op2 === "eq" || op2 === "ne" || op2 === "contains" || op2 === "not_contains") ? /* @__PURE__ */ jsx29(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ jsx29(
5939
+ ) : isChoiceColumn(chosen) && CHOICE_LIST_OPS.has(op2) ? /* @__PURE__ */ jsx29(ChoiceValues, { field: chosen.field, value: wordsOfValue(value), onChange: (words) => write({ value: words }) }) : isChoiceColumn(chosen) && (op2 === "eq" || op2 === "ne" || op2 === "contains" || op2 === "not_contains") ? /* @__PURE__ */ jsx29(ChoiceValue, { field: chosen.field, value: String(value ?? ""), onChange: (word) => write({ value: word }) }) : /* @__PURE__ */ jsx29(
5861
5940
  BasicInput6,
5862
5941
  {
5863
5942
  className: "h-8 w-28 text-xs",
@@ -6173,6 +6252,11 @@ async function forgetWrittenWords(client, tableId, key, written) {
6173
6252
 
6174
6253
  // src/FieldRetype.tsx
6175
6254
  import { jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
6255
+ var RETYPE_PREVIEW_DEBOUNCE_MS = 300;
6256
+ function scheduleRetypePreview(ask, ms = RETYPE_PREVIEW_DEBOUNCE_MS) {
6257
+ const timer = setTimeout(ask, ms);
6258
+ return () => clearTimeout(timer);
6259
+ }
6176
6260
  var RETYPE_TARGETS = [
6177
6261
  { id: "text", behaviour: "text", kind: null, label: "Text", holds: "words", via: "behaviour" },
6178
6262
  { id: "number", behaviour: "range", kind: "number", label: "Number", holds: "a number", via: "behaviour" },
@@ -6273,23 +6357,26 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
6273
6357
  cancelled = true;
6274
6358
  };
6275
6359
  }
6276
- void client.fieldRetypePreview({ field_id: field2.id, patch: retypePatch(to) }).then((answer) => {
6277
- if (cancelled) return;
6278
- setAsking(false);
6279
- if (!answer.ok) {
6280
- setRefusal(answer.error);
6281
- return;
6282
- }
6283
- if (answer.data.limited || answer.data.converts === null || answer.data.kept_aside === null) {
6284
- setLimitedHeld(answer.data.held_before);
6285
- setPreview({ converts: answer.data.held_before, keptAside: 0, examples: [], partial: false });
6286
- return;
6287
- }
6288
- setLimitedHeld(null);
6289
- setPreview({ converts: answer.data.converts, keptAside: answer.data.kept_aside, examples: answer.data.examples, partial: false });
6360
+ const cancelAsk = scheduleRetypePreview(() => {
6361
+ void client.fieldRetypePreview({ field_id: field2.id, patch: retypePatch(to) }).then((answer) => {
6362
+ if (cancelled) return;
6363
+ setAsking(false);
6364
+ if (!answer.ok) {
6365
+ setRefusal(answer.error);
6366
+ return;
6367
+ }
6368
+ if (answer.data.limited || answer.data.converts === null || answer.data.kept_aside === null) {
6369
+ setLimitedHeld(answer.data.held_before);
6370
+ setPreview({ converts: answer.data.held_before, keptAside: 0, examples: [], partial: false });
6371
+ return;
6372
+ }
6373
+ setLimitedHeld(null);
6374
+ setPreview({ converts: answer.data.converts, keptAside: answer.data.kept_aside, examples: answer.data.examples, partial: false });
6375
+ });
6290
6376
  });
6291
6377
  return () => {
6292
6378
  cancelled = true;
6379
+ cancelAsk();
6293
6380
  };
6294
6381
  }, [client, tableId, field2.key, to, person, roster]);
6295
6382
  if (!retypeableFrom(field2)) {
@@ -9405,7 +9492,7 @@ function RollupFilterQuestion({
9405
9492
  "."
9406
9493
  ] }),
9407
9494
  /* @__PURE__ */ jsx37(Button15, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onChange(null), children: "Clear" })
9408
- ] }) : /* @__PURE__ */ jsx37(
9495
+ ] }) : /* @__PURE__ */ jsx37(ChoiceListTermsContext.Provider, { value: true, children: /* @__PURE__ */ jsx37(
9409
9496
  ConditionGroup,
9410
9497
  {
9411
9498
  lead: rollupFilterLead(agg),
@@ -9414,7 +9501,7 @@ function RollupFilterQuestion({
9414
9501
  fields: conditionFields,
9415
9502
  onChange
9416
9503
  }
9417
- ) });
9504
+ ) }) });
9418
9505
  }
9419
9506
  function ValueOnTheOtherSide({
9420
9507
  label,
@@ -9491,7 +9578,7 @@ import { OutboundLink as OutboundLink7 } from "@ai-matrx/kit/outbound-react";
9491
9578
  import { openOutbound as openOutbound2 } from "@ai-matrx/kit/outbound";
9492
9579
  import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs34 } from "react/jsx-runtime";
9493
9580
  function buttonPressWords(label, pressed) {
9494
- if (pressed.do === "open_url") return `${label} opened ${pressed.url}`;
9581
+ if (pressed.do === "open_url") return `${label} opened ${readableLink(pressed.url)}`;
9495
9582
  if (pressed.do === "add_row") return `${label}: a row was added.`;
9496
9583
  if (pressed.do === "run_action") {
9497
9584
  const n = Number(pressed.result?.ran ?? 1);
@@ -9705,7 +9792,7 @@ function ButtonValue({ field: field2, recordId, inCell, beforeSave }) {
9705
9792
  said2.value ? /* @__PURE__ */ jsx38(StructuredValueView, { structured: said2.value, label: b.label }) : null,
9706
9793
  said2.says,
9707
9794
  " ",
9708
- said2.link ? /* @__PURE__ */ jsx38(OutboundLink7, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
9795
+ said2.link ? /* @__PURE__ */ jsx38(OutboundLink7, { href: said2.link, className: "text-primary underline", children: readableLink(said2.link) }) : null
9709
9796
  ] }) : null,
9710
9797
  said2?.kind === "needs" ? /* @__PURE__ */ jsxs34(Fragment13, { children: [
9711
9798
  /* @__PURE__ */ jsx38("p", { children: said2.says }),
@@ -12233,4 +12320,4 @@ export {
12233
12320
  RecordNameText,
12234
12321
  HeldChangeDecision
12235
12322
  };
12236
- //# sourceMappingURL=chunk-4NJUW3VM.js.map
12323
+ //# sourceMappingURL=chunk-5EFM2G2O.js.map