@ai-matrx/content-ir-react 0.16.0 → 0.17.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/CHANGELOG.md +24 -0
- package/dist/{directive-host-C4TcPpxX.d.cts → directive-host-BOML4BQ7.d.cts} +27 -1
- package/dist/{directive-host-C4TcPpxX.d.ts → directive-host-BOML4BQ7.d.ts} +27 -1
- package/dist/directives.cjs +106 -11
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +29 -4
- package/dist/directives.d.ts +29 -4
- package/dist/directives.js +106 -11
- package/dist/directives.js.map +1 -1
- package/dist/{host-types-a0XEr5b3.d.cts → host-types-Dxzs0C3f.d.cts} +1 -1
- package/dist/{host-types-CEc86R-v.d.ts → host-types-uKO1zZo3.d.ts} +1 -1
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts +3 -3
- package/dist/host.d.ts +3 -3
- package/dist/host.js.map +1 -1
- package/dist/index.cjs +106 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +106 -11
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +104 -11
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +104 -11
- package/dist/react.js.map +1 -1
- package/dist/{route-De9c5YgW.d.ts → route-CfKxIEdj.d.ts} +27 -1
- package/dist/{route-YcoyR3Fj.d.cts → route-DjGv9skd.d.cts} +27 -1
- package/dist/route.d.cts +1 -1
- package/dist/route.d.ts +1 -1
- package/package.json +3 -3
package/dist/react.cjs
CHANGED
|
@@ -194,11 +194,13 @@ function sameValue(a, b) {
|
|
|
194
194
|
if (typeof a === "object" || typeof b === "object") return safeJson(a) === safeJson(b);
|
|
195
195
|
return false;
|
|
196
196
|
}
|
|
197
|
-
function itemChanges(item, current) {
|
|
197
|
+
function itemChanges(item, current, options = {}) {
|
|
198
198
|
const out = [];
|
|
199
|
+
const titleColumn = options.titleColumn ?? null;
|
|
199
200
|
for (const [key, raw] of Object.entries(item)) {
|
|
200
201
|
if (NOT_A_CHANGE.has(key)) continue;
|
|
201
|
-
const
|
|
202
|
+
const label = key === titleColumn ? "Title" : fieldLabel(key);
|
|
203
|
+
const change = { key, label, ...describeValue(raw) };
|
|
202
204
|
if (current && Object.prototype.hasOwnProperty.call(current, key)) {
|
|
203
205
|
change.before = describeValue(current[key]);
|
|
204
206
|
change.same = sameValue(current[key], raw);
|
|
@@ -208,6 +210,30 @@ function itemChanges(item, current) {
|
|
|
208
210
|
return out;
|
|
209
211
|
}
|
|
210
212
|
|
|
213
|
+
// directives/failure-words.ts
|
|
214
|
+
var PAST = {
|
|
215
|
+
create: "created",
|
|
216
|
+
update: "updated",
|
|
217
|
+
delete: "deleted"
|
|
218
|
+
};
|
|
219
|
+
function defaultFailureWords(failure) {
|
|
220
|
+
const verbed = PAST[failure.directiveClass] ?? "applied";
|
|
221
|
+
const noun = failure.nounLabel.trim().toLowerCase() || "item";
|
|
222
|
+
if (failure.failed && failure.total && failure.total > 1) {
|
|
223
|
+
return {
|
|
224
|
+
what: `${failure.failed} of ${failure.total} weren't ${verbed}.`,
|
|
225
|
+
next: "Retry to try those again."
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
what: `The ${noun} wasn't ${verbed}.`,
|
|
230
|
+
next: "Try again in a moment."
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function failureWords(failure, explain) {
|
|
234
|
+
return explain?.(failure) ?? defaultFailureWords(failure);
|
|
235
|
+
}
|
|
236
|
+
|
|
211
237
|
// directives/icons.tsx
|
|
212
238
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
213
239
|
function Svg({ children, ...props }) {
|
|
@@ -465,10 +491,23 @@ function ApplyDirectiveButton({
|
|
|
465
491
|
children: [
|
|
466
492
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "inline-flex min-w-0 items-start gap-1", children: [
|
|
467
493
|
bad ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "mt-px h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckCircleIcon, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
|
|
468
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
494
|
+
bad ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
495
|
+
FailureNotice,
|
|
496
|
+
{
|
|
497
|
+
words: failureWords(
|
|
498
|
+
{
|
|
499
|
+
raw: state.message ?? `${state.failed} failed`,
|
|
500
|
+
directiveClass: directive.directiveClass,
|
|
501
|
+
noun: directive.noun,
|
|
502
|
+
nounLabel: nounText,
|
|
503
|
+
failed: state.failed,
|
|
504
|
+
total: state.applied + state.failed
|
|
505
|
+
},
|
|
506
|
+
host.explainFailure
|
|
507
|
+
),
|
|
508
|
+
raw: state.message
|
|
509
|
+
}
|
|
510
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0", children: state.message ?? `Applied ${state.applied}` })
|
|
472
511
|
] }),
|
|
473
512
|
state.copies > 1 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
474
513
|
"span",
|
|
@@ -545,10 +584,64 @@ function ApplyDirectiveButton({
|
|
|
545
584
|
]
|
|
546
585
|
}
|
|
547
586
|
),
|
|
548
|
-
state.status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
587
|
+
state.status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
588
|
+
"span",
|
|
589
|
+
{
|
|
590
|
+
className: "inline-flex max-w-sm items-start gap-1 text-xs text-destructive",
|
|
591
|
+
"data-apply-state": "error",
|
|
592
|
+
children: [
|
|
593
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
594
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
595
|
+
FailureNotice,
|
|
596
|
+
{
|
|
597
|
+
words: failureWords(
|
|
598
|
+
{
|
|
599
|
+
raw: state.message,
|
|
600
|
+
directiveClass: directive.directiveClass,
|
|
601
|
+
noun: directive.noun,
|
|
602
|
+
nounLabel: nounText
|
|
603
|
+
},
|
|
604
|
+
host.explainFailure
|
|
605
|
+
),
|
|
606
|
+
raw: state.message
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
]
|
|
610
|
+
}
|
|
611
|
+
) : null
|
|
612
|
+
] });
|
|
613
|
+
}
|
|
614
|
+
function FailureNotice({
|
|
615
|
+
words,
|
|
616
|
+
raw
|
|
617
|
+
}) {
|
|
618
|
+
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
619
|
+
const detail = raw?.trim() ?? "";
|
|
620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex min-w-0 flex-col gap-0.5", "data-apply-failure": true, children: [
|
|
621
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "min-w-0", children: [
|
|
622
|
+
words.what,
|
|
623
|
+
" ",
|
|
624
|
+
words.next,
|
|
625
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
626
|
+
"button",
|
|
627
|
+
{
|
|
628
|
+
type: "button",
|
|
629
|
+
onClick: () => setOpen((v) => !v),
|
|
630
|
+
"aria-expanded": open,
|
|
631
|
+
className: "ml-1 underline underline-offset-2 hover:no-underline",
|
|
632
|
+
"data-apply-failure-details-toggle": true,
|
|
633
|
+
children: open ? "Hide details" : "Details"
|
|
634
|
+
}
|
|
635
|
+
) : null
|
|
636
|
+
] }),
|
|
637
|
+
open && detail ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
638
|
+
"span",
|
|
639
|
+
{
|
|
640
|
+
className: "block max-w-sm select-text break-words font-mono text-[11px] text-muted-foreground",
|
|
641
|
+
"data-apply-failure-details": true,
|
|
642
|
+
children: detail
|
|
643
|
+
}
|
|
644
|
+
) : null
|
|
552
645
|
] });
|
|
553
646
|
}
|
|
554
647
|
|
|
@@ -773,7 +866,7 @@ function TargetRow({
|
|
|
773
866
|
isUpdate ? host.readRecord : void 0,
|
|
774
867
|
isUpdate ? { noun: directive.noun, id: recordId } : null
|
|
775
868
|
);
|
|
776
|
-
const changes = isUpdate ? itemChanges(item, current.values) : [];
|
|
869
|
+
const changes = isUpdate ? itemChanges(item, current.values, { titleColumn: (0, import_content_ir5.nounTitleColumn)(directive.noun, host.nouns) }) : [];
|
|
777
870
|
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 });
|
|
778
871
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "py-1 text-xs", "data-directive-target": recordId, children: [
|
|
779
872
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
|