@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.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-
|
|
1
|
+
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-Dxzs0C3f.cjs';
|
|
2
2
|
import { d as ComponentResolutionSource } from './component-resolution.types-C1MzCf2s.cjs';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import react__default, { ReactNode } from 'react';
|
|
5
5
|
import '@ai-matrx/content-ir';
|
|
6
|
-
import './directive-host-
|
|
6
|
+
import './directive-host-BOML4BQ7.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The two registries this hook watches. Passed explicitly by a host whose
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-
|
|
1
|
+
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-uKO1zZo3.js';
|
|
2
2
|
import { d as ComponentResolutionSource } from './component-resolution.types-C1MzCf2s.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import react__default, { ReactNode } from 'react';
|
|
5
5
|
import '@ai-matrx/content-ir';
|
|
6
|
-
import './directive-host-
|
|
6
|
+
import './directive-host-BOML4BQ7.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The two registries this hook watches. Passed explicitly by a host whose
|
package/dist/react.js
CHANGED
|
@@ -154,11 +154,13 @@ function sameValue(a, b) {
|
|
|
154
154
|
if (typeof a === "object" || typeof b === "object") return safeJson(a) === safeJson(b);
|
|
155
155
|
return false;
|
|
156
156
|
}
|
|
157
|
-
function itemChanges(item, current) {
|
|
157
|
+
function itemChanges(item, current, options = {}) {
|
|
158
158
|
const out = [];
|
|
159
|
+
const titleColumn = options.titleColumn ?? null;
|
|
159
160
|
for (const [key, raw] of Object.entries(item)) {
|
|
160
161
|
if (NOT_A_CHANGE.has(key)) continue;
|
|
161
|
-
const
|
|
162
|
+
const label = key === titleColumn ? "Title" : fieldLabel(key);
|
|
163
|
+
const change = { key, label, ...describeValue(raw) };
|
|
162
164
|
if (current && Object.prototype.hasOwnProperty.call(current, key)) {
|
|
163
165
|
change.before = describeValue(current[key]);
|
|
164
166
|
change.same = sameValue(current[key], raw);
|
|
@@ -168,6 +170,30 @@ function itemChanges(item, current) {
|
|
|
168
170
|
return out;
|
|
169
171
|
}
|
|
170
172
|
|
|
173
|
+
// directives/failure-words.ts
|
|
174
|
+
var PAST = {
|
|
175
|
+
create: "created",
|
|
176
|
+
update: "updated",
|
|
177
|
+
delete: "deleted"
|
|
178
|
+
};
|
|
179
|
+
function defaultFailureWords(failure) {
|
|
180
|
+
const verbed = PAST[failure.directiveClass] ?? "applied";
|
|
181
|
+
const noun = failure.nounLabel.trim().toLowerCase() || "item";
|
|
182
|
+
if (failure.failed && failure.total && failure.total > 1) {
|
|
183
|
+
return {
|
|
184
|
+
what: `${failure.failed} of ${failure.total} weren't ${verbed}.`,
|
|
185
|
+
next: "Retry to try those again."
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
what: `The ${noun} wasn't ${verbed}.`,
|
|
190
|
+
next: "Try again in a moment."
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function failureWords(failure, explain) {
|
|
194
|
+
return explain?.(failure) ?? defaultFailureWords(failure);
|
|
195
|
+
}
|
|
196
|
+
|
|
171
197
|
// directives/icons.tsx
|
|
172
198
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
173
199
|
function Svg({ children, ...props }) {
|
|
@@ -425,10 +451,23 @@ function ApplyDirectiveButton({
|
|
|
425
451
|
children: [
|
|
426
452
|
/* @__PURE__ */ jsxs2("span", { className: "inline-flex min-w-0 items-start gap-1", children: [
|
|
427
453
|
bad ? /* @__PURE__ */ jsx4(AlertIcon, { className: "mt-px h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ jsx4(CheckCircleIcon, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
454
|
+
bad ? /* @__PURE__ */ jsx4(
|
|
455
|
+
FailureNotice,
|
|
456
|
+
{
|
|
457
|
+
words: failureWords(
|
|
458
|
+
{
|
|
459
|
+
raw: state.message ?? `${state.failed} failed`,
|
|
460
|
+
directiveClass: directive.directiveClass,
|
|
461
|
+
noun: directive.noun,
|
|
462
|
+
nounLabel: nounText,
|
|
463
|
+
failed: state.failed,
|
|
464
|
+
total: state.applied + state.failed
|
|
465
|
+
},
|
|
466
|
+
host.explainFailure
|
|
467
|
+
),
|
|
468
|
+
raw: state.message
|
|
469
|
+
}
|
|
470
|
+
) : /* @__PURE__ */ jsx4("span", { className: "min-w-0", children: state.message ?? `Applied ${state.applied}` })
|
|
432
471
|
] }),
|
|
433
472
|
state.copies > 1 ? /* @__PURE__ */ jsx4(
|
|
434
473
|
"span",
|
|
@@ -505,10 +544,64 @@ function ApplyDirectiveButton({
|
|
|
505
544
|
]
|
|
506
545
|
}
|
|
507
546
|
),
|
|
508
|
-
state.status === "error" ? /* @__PURE__ */ jsxs2(
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
547
|
+
state.status === "error" ? /* @__PURE__ */ jsxs2(
|
|
548
|
+
"span",
|
|
549
|
+
{
|
|
550
|
+
className: "inline-flex max-w-sm items-start gap-1 text-xs text-destructive",
|
|
551
|
+
"data-apply-state": "error",
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx4(AlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
554
|
+
/* @__PURE__ */ jsx4(
|
|
555
|
+
FailureNotice,
|
|
556
|
+
{
|
|
557
|
+
words: failureWords(
|
|
558
|
+
{
|
|
559
|
+
raw: state.message,
|
|
560
|
+
directiveClass: directive.directiveClass,
|
|
561
|
+
noun: directive.noun,
|
|
562
|
+
nounLabel: nounText
|
|
563
|
+
},
|
|
564
|
+
host.explainFailure
|
|
565
|
+
),
|
|
566
|
+
raw: state.message
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
]
|
|
570
|
+
}
|
|
571
|
+
) : null
|
|
572
|
+
] });
|
|
573
|
+
}
|
|
574
|
+
function FailureNotice({
|
|
575
|
+
words,
|
|
576
|
+
raw
|
|
577
|
+
}) {
|
|
578
|
+
const [open, setOpen] = useState(false);
|
|
579
|
+
const detail = raw?.trim() ?? "";
|
|
580
|
+
return /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 flex-col gap-0.5", "data-apply-failure": true, children: [
|
|
581
|
+
/* @__PURE__ */ jsxs2("span", { className: "min-w-0", children: [
|
|
582
|
+
words.what,
|
|
583
|
+
" ",
|
|
584
|
+
words.next,
|
|
585
|
+
detail ? /* @__PURE__ */ jsx4(
|
|
586
|
+
"button",
|
|
587
|
+
{
|
|
588
|
+
type: "button",
|
|
589
|
+
onClick: () => setOpen((v) => !v),
|
|
590
|
+
"aria-expanded": open,
|
|
591
|
+
className: "ml-1 underline underline-offset-2 hover:no-underline",
|
|
592
|
+
"data-apply-failure-details-toggle": true,
|
|
593
|
+
children: open ? "Hide details" : "Details"
|
|
594
|
+
}
|
|
595
|
+
) : null
|
|
596
|
+
] }),
|
|
597
|
+
open && detail ? /* @__PURE__ */ jsx4(
|
|
598
|
+
"span",
|
|
599
|
+
{
|
|
600
|
+
className: "block max-w-sm select-text break-words font-mono text-[11px] text-muted-foreground",
|
|
601
|
+
"data-apply-failure-details": true,
|
|
602
|
+
children: detail
|
|
603
|
+
}
|
|
604
|
+
) : null
|
|
512
605
|
] });
|
|
513
606
|
}
|
|
514
607
|
|
|
@@ -743,7 +836,7 @@ function TargetRow({
|
|
|
743
836
|
isUpdate ? host.readRecord : void 0,
|
|
744
837
|
isUpdate ? { noun: directive.noun, id: recordId } : null
|
|
745
838
|
);
|
|
746
|
-
const changes = isUpdate ? itemChanges(item, current.values) : [];
|
|
839
|
+
const changes = isUpdate ? itemChanges(item, current.values, { titleColumn: nounTitleColumn(directive.noun, host.nouns) }) : [];
|
|
747
840
|
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 });
|
|
748
841
|
return /* @__PURE__ */ jsxs5("div", { className: "py-1 text-xs", "data-directive-target": recordId, children: [
|
|
749
842
|
/* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 items-center gap-2", children: [
|