@ai-matrx/content-ir-react 0.24.5 → 0.25.1

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.cjs CHANGED
@@ -222,6 +222,9 @@ function itemChanges(item, current, options = {}) {
222
222
  }
223
223
  return out;
224
224
  }
225
+ function changesNothing(changes) {
226
+ return changes.every((change) => change.same === true);
227
+ }
225
228
 
226
229
  // directives/record-values.ts
227
230
  var import_react4 = require("react");
@@ -730,7 +733,7 @@ function ApplyDirectiveButton({
730
733
  onFocus: warm,
731
734
  disabled: view.status === "applying" || view.status === "asking" || items.length === 0,
732
735
  "data-apply-tone": muted ? "muted" : destructive ? "destructive" : "default",
733
- title: muted ? "It sets no fields, so applying it changes nothing." : void 0,
736
+ title: muted ? "Applying it changes nothing." : void 0,
734
737
  className: `inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 py-1 text-xs font-medium disabled:opacity-50 ${muted ? "border-border/60 bg-background text-muted-foreground hover:bg-accent" : destructive ? "border-destructive/50 bg-background text-destructive hover:bg-destructive/10" : "border-border bg-background hover:bg-accent"}`,
735
738
  children: [
736
739
  view.status === "applying" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PlayIcon, { className: "h-3.5 w-3.5" }),
@@ -770,7 +773,7 @@ function FailureNotice({
770
773
  raw
771
774
  }) {
772
775
  const [open, setOpen] = (0, import_react5.useState)(false);
773
- const detail = raw?.trim() ?? "";
776
+ const detail = raw?.trim() ? words.details?.trim() || raw.trim() : "";
774
777
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex min-w-0 flex-col gap-0.5", "data-apply-failure": true, children: [
775
778
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "min-w-0", children: [
776
779
  words.what,
@@ -895,12 +898,23 @@ function ItemRow({
895
898
  item,
896
899
  index,
897
900
  total,
898
- phase
901
+ phase,
902
+ onNothing
899
903
  }) {
900
904
  const host = useDirectiveHost();
901
905
  const recordId = TARGETING_CLASSES.has(directive.directiveClass) ? itemRecordId(item) : null;
902
906
  if (recordId) {
903
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TargetRow, { directive, item, recordId, index, phase });
907
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
908
+ TargetRow,
909
+ {
910
+ directive,
911
+ item,
912
+ recordId,
913
+ index,
914
+ phase,
915
+ onNothing
916
+ }
917
+ );
904
918
  }
905
919
  const titleColumn = (0, import_content_ir6.nounTitleColumn)(directive.noun, host.nouns);
906
920
  const ownName = itemOwnName(item, titleColumn);
@@ -919,7 +933,8 @@ function ItemRow({
919
933
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
920
934
  "span",
921
935
  {
922
- className: `min-w-0 shrink-0 truncate font-medium ${ownName ? "text-foreground" : "italic text-muted-foreground"}`,
936
+ className: `min-w-0 line-clamp-2 font-medium [overflow-wrap:anywhere] sm:shrink-0 sm:truncate ${ownName ? "text-foreground" : "italic text-muted-foreground"}`,
937
+ "data-item-name": "",
923
938
  "data-item-untitled": ownName ? void 0 : "",
924
939
  children: title
925
940
  }
@@ -1008,7 +1023,8 @@ function TargetRow({
1008
1023
  item,
1009
1024
  recordId,
1010
1025
  index,
1011
- phase
1026
+ phase,
1027
+ onNothing
1012
1028
  }) {
1013
1029
  const host = useDirectiveHost();
1014
1030
  const fallback = recordFallbackName((0, import_content_ir6.nounLabel)(directive.noun, host.nouns));
@@ -1023,7 +1039,11 @@ function TargetRow({
1023
1039
  titleColumn: (0, import_content_ir6.nounTitleColumn)(directive.noun, host.nouns),
1024
1040
  valueWord: directiveValueWord(host, directive.noun)
1025
1041
  }) : [];
1026
- const name = host.renderRecord ? host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: "row" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate font-medium text-foreground", children: fallback });
1042
+ const nothing = readsLive && live.values !== null && changesNothing(changes);
1043
+ (0, import_react6.useEffect)(() => {
1044
+ onNothing?.(index, nothing);
1045
+ }, [onNothing, index, nothing]);
1046
+ const name = host.renderRecord ? host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: "row" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "line-clamp-2 min-w-0 font-medium text-foreground [overflow-wrap:anywhere]", children: fallback });
1027
1047
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "py-1 text-xs", "data-directive-target": recordId, children: [
1028
1048
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
1029
1049
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-1 px-1", children: name }),
@@ -1047,7 +1067,9 @@ function SideEffectDirectiveCard({ directive }) {
1047
1067
  const [phase, setPhase] = (0, import_react6.useState)(
1048
1068
  () => readsApplyLedger(host, directive) ? { phase: "pending" } : { phase: "open" }
1049
1069
  );
1050
- const nothingToChange = directive.directiveClass === "update" && total > 0 && items.every((item) => itemChanges(item).length === 0);
1070
+ const [nothingAt, setNothingAt] = (0, import_react6.useState)({});
1071
+ const noteNothing = (index, nothing) => setNothingAt((prev) => prev[index] === nothing ? prev : { ...prev, [index]: nothing });
1072
+ const nothingToChange = directive.directiveClass === "update" && total > 0 && items.every((item, index) => itemChanges(item).length === 0 || nothingAt[index] === true);
1051
1073
  const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
1052
1074
  const hidden = total - shown.length;
1053
1075
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "my-3 rounded-md border border-border bg-card px-2.5 py-1.5", "data-directive": directive.slug, children: [
@@ -1076,7 +1098,18 @@ function SideEffectDirectiveCard({ directive }) {
1076
1098
  total === 0 ? (
1077
1099
  // Stated, never silent: an empty batch is a real (and suspicious) state.
1078
1100
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
1079
- ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemRow, { directive, item, index: i, total, phase }, i)) }),
1101
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1102
+ ItemRow,
1103
+ {
1104
+ directive,
1105
+ item,
1106
+ index: i,
1107
+ total,
1108
+ phase,
1109
+ onNothing: noteNothing
1110
+ },
1111
+ i
1112
+ )) }),
1080
1113
  hidden > 0 || expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1081
1114
  "button",
1082
1115
  {