@ai-matrx/content-ir-react 0.24.5 → 0.25.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
@@ -80,7 +80,7 @@ function useContentIrKindVersion(kind, sources) {
80
80
  }
81
81
 
82
82
  // react/KindInstanceRender.tsx
83
- import { useEffect as useEffect3, useState as useState4 } from "react";
83
+ import { useEffect as useEffect4, useState as useState4 } from "react";
84
84
  import {
85
85
  envelopeFromCompleteValue as envelopeFromCompleteValue2,
86
86
  IR_ENVELOPE_KEY,
@@ -182,6 +182,9 @@ function itemChanges(item, current, options = {}) {
182
182
  }
183
183
  return out;
184
184
  }
185
+ function changesNothing(changes) {
186
+ return changes.every((change) => change.same === true);
187
+ }
185
188
 
186
189
  // directives/record-values.ts
187
190
  import { useEffect, useState, useSyncExternalStore as useSyncExternalStore2 } from "react";
@@ -690,7 +693,7 @@ function ApplyDirectiveButton({
690
693
  onFocus: warm,
691
694
  disabled: view.status === "applying" || view.status === "asking" || items.length === 0,
692
695
  "data-apply-tone": muted ? "muted" : destructive ? "destructive" : "default",
693
- title: muted ? "It sets no fields, so applying it changes nothing." : void 0,
696
+ title: muted ? "Applying it changes nothing." : void 0,
694
697
  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"}`,
695
698
  children: [
696
699
  view.status === "applying" ? /* @__PURE__ */ jsx4(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsx4(PlayIcon, { className: "h-3.5 w-3.5" }),
@@ -840,7 +843,7 @@ function getDirectiveRenderer(directive) {
840
843
  }
841
844
 
842
845
  // directives/SideEffectDirectiveCard.tsx
843
- import { useState as useState3 } from "react";
846
+ import { useEffect as useEffect3, useState as useState3 } from "react";
844
847
  import {
845
848
  asKindInstance,
846
849
  directiveDisplay as directiveDisplay3,
@@ -864,12 +867,23 @@ function ItemRow({
864
867
  item,
865
868
  index,
866
869
  total,
867
- phase
870
+ phase,
871
+ onNothing
868
872
  }) {
869
873
  const host = useDirectiveHost();
870
874
  const recordId = TARGETING_CLASSES.has(directive.directiveClass) ? itemRecordId(item) : null;
871
875
  if (recordId) {
872
- return /* @__PURE__ */ jsx7(TargetRow, { directive, item, recordId, index, phase });
876
+ return /* @__PURE__ */ jsx7(
877
+ TargetRow,
878
+ {
879
+ directive,
880
+ item,
881
+ recordId,
882
+ index,
883
+ phase,
884
+ onNothing
885
+ }
886
+ );
873
887
  }
874
888
  const titleColumn = nounTitleColumn(directive.noun, host.nouns);
875
889
  const ownName = itemOwnName(item, titleColumn);
@@ -888,7 +902,8 @@ function ItemRow({
888
902
  /* @__PURE__ */ jsx7(
889
903
  "span",
890
904
  {
891
- className: `min-w-0 shrink-0 truncate font-medium ${ownName ? "text-foreground" : "italic text-muted-foreground"}`,
905
+ className: `min-w-0 line-clamp-2 font-medium [overflow-wrap:anywhere] sm:shrink-0 sm:truncate ${ownName ? "text-foreground" : "italic text-muted-foreground"}`,
906
+ "data-item-name": "",
892
907
  "data-item-untitled": ownName ? void 0 : "",
893
908
  children: title
894
909
  }
@@ -977,7 +992,8 @@ function TargetRow({
977
992
  item,
978
993
  recordId,
979
994
  index,
980
- phase
995
+ phase,
996
+ onNothing
981
997
  }) {
982
998
  const host = useDirectiveHost();
983
999
  const fallback = recordFallbackName(nounLabel2(directive.noun, host.nouns));
@@ -992,7 +1008,11 @@ function TargetRow({
992
1008
  titleColumn: nounTitleColumn(directive.noun, host.nouns),
993
1009
  valueWord: directiveValueWord(host, directive.noun)
994
1010
  }) : [];
995
- const name = host.renderRecord ? host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: "row" }) : /* @__PURE__ */ jsx7("span", { className: "truncate font-medium text-foreground", children: fallback });
1011
+ const nothing = readsLive && live.values !== null && changesNothing(changes);
1012
+ useEffect3(() => {
1013
+ onNothing?.(index, nothing);
1014
+ }, [onNothing, index, nothing]);
1015
+ const name = host.renderRecord ? host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: "row" }) : /* @__PURE__ */ jsx7("span", { className: "line-clamp-2 min-w-0 font-medium text-foreground [overflow-wrap:anywhere]", children: fallback });
996
1016
  return /* @__PURE__ */ jsxs5("div", { className: "py-1 text-xs", "data-directive-target": recordId, children: [
997
1017
  /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 items-center gap-2", children: [
998
1018
  /* @__PURE__ */ jsx7("span", { className: "flex min-w-0 flex-1 items-center gap-1 px-1", children: name }),
@@ -1016,7 +1036,9 @@ function SideEffectDirectiveCard({ directive }) {
1016
1036
  const [phase, setPhase] = useState3(
1017
1037
  () => readsApplyLedger(host, directive) ? { phase: "pending" } : { phase: "open" }
1018
1038
  );
1019
- const nothingToChange = directive.directiveClass === "update" && total > 0 && items.every((item) => itemChanges(item).length === 0);
1039
+ const [nothingAt, setNothingAt] = useState3({});
1040
+ const noteNothing = (index, nothing) => setNothingAt((prev) => prev[index] === nothing ? prev : { ...prev, [index]: nothing });
1041
+ const nothingToChange = directive.directiveClass === "update" && total > 0 && items.every((item, index) => itemChanges(item).length === 0 || nothingAt[index] === true);
1020
1042
  const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
1021
1043
  const hidden = total - shown.length;
1022
1044
  return /* @__PURE__ */ jsxs5("div", { className: "my-3 rounded-md border border-border bg-card px-2.5 py-1.5", "data-directive": directive.slug, children: [
@@ -1045,7 +1067,18 @@ function SideEffectDirectiveCard({ directive }) {
1045
1067
  total === 0 ? (
1046
1068
  // Stated, never silent: an empty batch is a real (and suspicious) state.
1047
1069
  /* @__PURE__ */ jsx7("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
1048
- ) : /* @__PURE__ */ jsx7("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ jsx7(ItemRow, { directive, item, index: i, total, phase }, i)) }),
1070
+ ) : /* @__PURE__ */ jsx7("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ jsx7(
1071
+ ItemRow,
1072
+ {
1073
+ directive,
1074
+ item,
1075
+ index: i,
1076
+ total,
1077
+ phase,
1078
+ onNothing: noteNothing
1079
+ },
1080
+ i
1081
+ )) }),
1049
1082
  hidden > 0 || expanded ? /* @__PURE__ */ jsxs5(
1050
1083
  "button",
1051
1084
  {
@@ -1161,7 +1194,7 @@ function KindInstanceRenderInner({
1161
1194
  const [routingStatus, setRoutingStatus] = useState4(
1162
1195
  () => kindIsRoutable(kind, host) ? "routable" : "checking"
1163
1196
  );
1164
- useEffect3(() => {
1197
+ useEffect4(() => {
1165
1198
  let cancelled = false;
1166
1199
  let warmed = false;
1167
1200
  const syncRoutingStatus = () => {