@ai-matrx/content-ir-react 0.20.2 → 0.22.0

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/react.js CHANGED
@@ -98,8 +98,8 @@ import { useEffect as useEffect2, useRef, useState as useState2, useSyncExternal
98
98
  import { nounLabel } from "@ai-matrx/content-ir";
99
99
 
100
100
  // directives/item-changes.ts
101
- import { isUuidShape } from "@ai-matrx/kit/uuid";
102
101
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
102
+ import { itemTitle } from "@ai-matrx/content-ir";
103
103
  var TARGETING_CLASSES = /* @__PURE__ */ new Set(["update", "delete"]);
104
104
  var NOT_A_CHANGE = /* @__PURE__ */ new Set(["__kind", "id"]);
105
105
  var CHANGE_VALUE_MAX = 280;
@@ -115,10 +115,14 @@ function fieldLabel(key) {
115
115
  function directiveFieldLabel(key, titleColumn) {
116
116
  return titleColumn && key === titleColumn ? "Title" : fieldLabel(key);
117
117
  }
118
+ function itemOwnName(item, titleColumn) {
119
+ const probe = itemTitle(item, titleColumn, 0, 2);
120
+ return probe === "Item 1 of 2" ? null : probe;
121
+ }
122
+ var NO_TITLE_WORD = "No title";
118
123
  var EMPTY_VALUE_WORD = "None";
119
- function recordFallbackName(nounLabel3, id) {
120
- const short = isUuidShape(id) ? id.slice(0, 8) : id.length > 12 ? `${id.slice(0, 12)}\u2026` : id;
121
- return `${nounLabel3} ${short}`;
124
+ function recordFallbackName(nounLabel3) {
125
+ return nounLabel3.trim() || "Record";
122
126
  }
123
127
  var EMPTY = { value: EMPTY_VALUE_WORD, full: EMPTY_VALUE_WORD, clears: true };
124
128
  function describeValue(value, word) {
@@ -617,7 +621,7 @@ function ApplyDirectiveButton({
617
621
  ) : null,
618
622
  records.map((record) => /* @__PURE__ */ jsx4("span", { className: "inline-flex min-w-0 items-center", children: host.renderRecord?.({
619
623
  ...record,
620
- fallback: recordFallbackName(label2, record.id),
624
+ fallback: recordFallbackName(label2),
621
625
  context: "applied",
622
626
  trashed
623
627
  }) }, `${record.noun}:${record.id}`)),
@@ -665,6 +669,14 @@ function ApplyDirectiveButton({
665
669
  }
666
670
  );
667
671
  }
672
+ const warm = () => {
673
+ const read2 = host.readRecord;
674
+ if (!read2 || !TARGETING_CLASSES.has(directive.directiveClass)) return;
675
+ for (const item of items) {
676
+ const id = itemRecordId(item);
677
+ if (id) void read2({ noun: directive.noun, id }).catch(() => null);
678
+ }
679
+ };
668
680
  const destructive = directive.directiveClass === "delete";
669
681
  const muted = nothingToChange && view.status === "idle";
670
682
  return /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1", children: [
@@ -674,6 +686,8 @@ function ApplyDirectiveButton({
674
686
  {
675
687
  type: "button",
676
688
  onClick: () => void handleApply(),
689
+ onPointerEnter: warm,
690
+ onFocus: warm,
677
691
  disabled: view.status === "applying" || view.status === "asking" || items.length === 0,
678
692
  "data-apply-tone": muted ? "muted" : destructive ? "destructive" : "default",
679
693
  title: muted ? "It sets no fields, so applying it changes nothing." : void 0,
@@ -832,7 +846,6 @@ import {
832
846
  directiveDisplay as directiveDisplay3,
833
847
  itemFacts,
834
848
  itemSubtitle,
835
- itemTitle,
836
849
  nounLabel as nounLabel2,
837
850
  nounTitleColumn
838
851
  } from "@ai-matrx/content-ir";
@@ -859,7 +872,8 @@ function ItemRow({
859
872
  return /* @__PURE__ */ jsx7(TargetRow, { directive, item, recordId, index, phase });
860
873
  }
861
874
  const titleColumn = nounTitleColumn(directive.noun, host.nouns);
862
- const title = itemTitle(item, titleColumn, index, total);
875
+ const ownName = itemOwnName(item, titleColumn);
876
+ const title = ownName ?? NO_TITLE_WORD;
863
877
  const subtitle = itemSubtitle(item);
864
878
  const valueWord = directiveValueWord(host, directive.noun);
865
879
  const facts = itemFacts(titleColumn ? omitKey(item, titleColumn) : item).map((fact) => ({
@@ -871,7 +885,14 @@ function ItemRow({
871
885
  const display = directiveDisplay3(directive.directiveClass, directive.noun, host.nouns);
872
886
  const openItem = host.openItem;
873
887
  const body = /* @__PURE__ */ jsxs5(Fragment, { children: [
874
- /* @__PURE__ */ jsx7("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
888
+ /* @__PURE__ */ jsx7(
889
+ "span",
890
+ {
891
+ className: `min-w-0 shrink-0 truncate font-medium ${ownName ? "text-foreground" : "italic text-muted-foreground"}`,
892
+ "data-item-untitled": ownName ? void 0 : "",
893
+ children: title
894
+ }
895
+ ),
875
896
  /* @__PURE__ */ jsx7("span", { className: "hidden min-w-0 flex-1 items-baseline gap-2 overflow-hidden sm:flex", children: facts.map((fact) => /* @__PURE__ */ jsxs5("span", { className: "truncate text-[11px] text-muted-foreground", "data-item-fact": fact.key, children: [
876
897
  fact.label,
877
898
  " ",
@@ -900,7 +921,12 @@ function ItemRow({
900
921
  children: body
901
922
  }
902
923
  ) : /* @__PURE__ */ jsx7("span", { className: "flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5", children: body }),
903
- host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
924
+ host.renderCopy?.({
925
+ label: ownName ?? `this ${nounLabel2(directive.noun, host.nouns)}`,
926
+ value: item,
927
+ kind,
928
+ size: "xs"
929
+ })
904
930
  ] });
905
931
  }
906
932
  function DirectiveChangeList({
@@ -954,7 +980,7 @@ function TargetRow({
954
980
  phase
955
981
  }) {
956
982
  const host = useDirectiveHost();
957
- const fallback = recordFallbackName(nounLabel2(directive.noun, host.nouns), recordId);
983
+ const fallback = recordFallbackName(nounLabel2(directive.noun, host.nouns));
958
984
  const isUpdate = directive.directiveClass === "update";
959
985
  const readsLive = isUpdate && phase.phase === "open";
960
986
  const live = useRecordValues(