@republicroad/seal-editor 1.1.0 → 1.2.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/README.md +5 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +39 -18
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# `@republicroad/
|
|
1
|
+
# `@republicroad/seal-editor`
|
|
2
2
|
|
|
3
3
|
React components for authoring [JDM](https://gorules.io/docs) (JSON Decision
|
|
4
4
|
Model) documents: a decision graph canvas, decision tables, expression and
|
|
@@ -9,12 +9,12 @@ end-to-end with shadcn/ReUI + Tailwind.
|
|
|
9
9
|
> significant divergence (ReactFlow 12, shadcn/ReUI stack, seed-derived
|
|
10
10
|
> theming, i18n, pooled editors). Will not track upstream merges.
|
|
11
11
|
>
|
|
12
|
-
> **Live storybook:** https://republicroad.github.io/
|
|
12
|
+
> **Live storybook:** https://republicroad.github.io/seal-editor/storybook/
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm i @republicroad/
|
|
17
|
+
npm i @republicroad/seal-editor
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
**Heads-up (0.3.0+):** `monaco-editor` is a peer dependency — install it
|
|
@@ -23,8 +23,8 @@ explicitly: `npm i monaco-editor`.
|
|
|
23
23
|
## Quick start
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
|
-
import { DecisionGraph, JdmConfigProvider } from '@republicroad/
|
|
27
|
-
import '@republicroad/
|
|
26
|
+
import { DecisionGraph, JdmConfigProvider } from '@republicroad/seal-editor';
|
|
27
|
+
import '@republicroad/seal-editor/dist/style.css';
|
|
28
28
|
|
|
29
29
|
<JdmConfigProvider
|
|
30
30
|
seeds={{ primary: '#6366f1' }} // one seed → full light + dark palettes
|
package/dist/index.d.ts
CHANGED
|
@@ -1398,6 +1398,11 @@ export declare type GraphDecisionNodeProps = {
|
|
|
1398
1398
|
micros?: number;
|
|
1399
1399
|
code?: string;
|
|
1400
1400
|
} | null;
|
|
1401
|
+
traceError?: {
|
|
1402
|
+
code?: string | null;
|
|
1403
|
+
title?: string | null;
|
|
1404
|
+
message?: string | null;
|
|
1405
|
+
} | null;
|
|
1401
1406
|
diffStatus?: 'removed' | 'added' | 'modified' | 'moved';
|
|
1402
1407
|
noBodyPadding?: boolean;
|
|
1403
1408
|
color?: 'primary' | 'secondary' | string;
|
|
@@ -2129,6 +2134,7 @@ export declare type Simulation = {
|
|
|
2129
2134
|
export declare type SimulationError = {
|
|
2130
2135
|
title?: string;
|
|
2131
2136
|
message?: string;
|
|
2137
|
+
code?: string;
|
|
2132
2138
|
data: {
|
|
2133
2139
|
nodeId?: string;
|
|
2134
2140
|
};
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,14 @@ var Br = Object.create, Vr = Object.defineProperty, Hr = Object.getOwnPropertyDe
|
|
|
69
69
|
}, Yr = (e, t, n) => (n = e == null ? {} : Br(Wr(e)), Jr(t || !e || !e.__esModule || !Gr.call(e, "default") ? Vr(n, "default", {
|
|
70
70
|
value: e,
|
|
71
71
|
enumerable: !0
|
|
72
|
-
}) : n, e))
|
|
72
|
+
}) : n, e));
|
|
73
|
+
(() => {
|
|
74
|
+
let e = globalThis.crypto;
|
|
75
|
+
e && typeof e.randomUUID != "function" && typeof e.getRandomValues == "function" && (e.randomUUID = () => "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (t) => (Number(t) ^ e.getRandomValues(/* @__PURE__ */ new Uint8Array(1))[0] & 15 >> Number(t) / 4).toString(16)));
|
|
76
|
+
})();
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/helpers/dnd-overlay.tsx
|
|
79
|
+
var Xr = {
|
|
73
80
|
display: "inline-flex",
|
|
74
81
|
alignItems: "center",
|
|
75
82
|
gap: 8,
|
|
@@ -2419,6 +2426,7 @@ var Io = {
|
|
|
2419
2426
|
"simulator.readyTitle": "准备就绪,可以开始模拟!",
|
|
2420
2427
|
"simulator.readyHint": "运行一次请求即可查看节点执行轨迹。",
|
|
2421
2428
|
"simulator.learnMore": "了解更多",
|
|
2429
|
+
"common.clear": "清空",
|
|
2422
2430
|
"misc.delete": "删除"
|
|
2423
2431
|
}
|
|
2424
2432
|
}, Ro = M.createContext(void 0);
|
|
@@ -8391,21 +8399,21 @@ var xd = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
|
|
|
8391
8399
|
...t
|
|
8392
8400
|
}), Sd = /* @__PURE__ */ function(e) {
|
|
8393
8401
|
return e.Blue = "var(--node-color-blue)", e.Purple = "var(--node-color-purple)", e.Orange = "var(--node-color-orange)", e.Green = "var(--node-color-green)", e;
|
|
8394
|
-
}({}), Cd = ({ icon: e, name: t, type: n, children: r, actions: i = [], disabled: a = !1, isSelected: o = !1, noBodyPadding: s = !1, color: c = "primary", onNameChange: l, menuItems: u = [], status: d, trace: f,
|
|
8395
|
-
let
|
|
8402
|
+
}({}), Cd = ({ icon: e, name: t, type: n, children: r, actions: i = [], disabled: a = !1, isSelected: o = !1, noBodyPadding: s = !1, color: c = "primary", onNameChange: l, menuItems: u = [], status: d, trace: f, traceError: p, diffStatus: m, compactMode: h, listMode: g, helper: _, details: v, detailsOpen: y = !1, detailsTitle: b = "Details", onDetailsClose: x }) => {
|
|
8403
|
+
let S = G(c).with("primary", () => Sd.Blue).otherwise((e) => e), C = m === "added" ? "border-[var(--seal-color-success)] group-hover/dn:border-[var(--seal-color-success)]" : m === "moved" ? "border-[var(--seal-color-info)] group-hover/dn:border-[var(--seal-color-info)]" : m === "modified" ? "border-[var(--seal-color-warning)] group-hover/dn:border-[var(--seal-color-warning)]" : m === "removed" ? "border-[var(--destructive)] group-hover/dn:border-[var(--destructive)]" : o ? "border-[var(--seal-color-primary-active)] group-hover/dn:border-[var(--seal-color-primary-active)]" : "", w = g ? "rounded-none border-0 border-b border-b-[var(--seal-color-border-fade)]" : "";
|
|
8396
8404
|
return /* @__PURE__ */ B("div", {
|
|
8397
8405
|
className: H("group/dn flex flex-col gap-2", "[--node-border-radius:8px] [--node-horizontal-padding:8px] [--node-small-text:12px]", "[--node-color:var(--primary)] [--node-background:var(--seal-color-bg-container)]", d === "success" ? "[--node-background:var(--seal-color-success-bg)]" : d === "error" ? "[--node-background:var(--seal-color-error-bg)]" : d === "warning" ? "[--node-background:var(--seal-color-warning-bg)]" : ""),
|
|
8398
|
-
style: { "--node-color":
|
|
8406
|
+
style: { "--node-color": S },
|
|
8399
8407
|
onKeyDown: (e) => e.stopPropagation(),
|
|
8400
|
-
"data-diff":
|
|
8401
|
-
"data-compact":
|
|
8408
|
+
"data-diff": m,
|
|
8409
|
+
"data-compact": h || void 0,
|
|
8402
8410
|
children: [/* @__PURE__ */ B(xd, {
|
|
8403
|
-
className: H(
|
|
8411
|
+
className: H(C, w),
|
|
8404
8412
|
children: [
|
|
8405
8413
|
/* @__PURE__ */ B("div", {
|
|
8406
8414
|
className: "absolute -top-5 w-full h-4 text-[10px] font-bold flex justify-end items-center gap-1",
|
|
8407
8415
|
children: [
|
|
8408
|
-
Array.isArray(
|
|
8416
|
+
Array.isArray(_) && _.filter((e) => !!e).map((e, t) => /* @__PURE__ */ z("div", {
|
|
8409
8417
|
className: "flex justify-center items-center rounded-2xl w-4 h-4 text-[10px] font-bold text-[var(--muted-foreground)]",
|
|
8410
8418
|
children: e
|
|
8411
8419
|
}, t)),
|
|
@@ -8414,7 +8422,7 @@ var xd = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
|
|
|
8414
8422
|
children: /* @__PURE__ */ z(gs, {})
|
|
8415
8423
|
}),
|
|
8416
8424
|
/* @__PURE__ */ z(iu, {
|
|
8417
|
-
status:
|
|
8425
|
+
status: m,
|
|
8418
8426
|
style: { fontSize: 16 }
|
|
8419
8427
|
})
|
|
8420
8428
|
]
|
|
@@ -8468,14 +8476,22 @@ var xd = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
|
|
|
8468
8476
|
children: i
|
|
8469
8477
|
})
|
|
8470
8478
|
}),
|
|
8471
|
-
f && /* @__PURE__ */ B("div", {
|
|
8479
|
+
(f || p) && /* @__PURE__ */ B("div", {
|
|
8472
8480
|
"data-slot": "node-run-strip",
|
|
8473
8481
|
className: "nodrag flex items-center justify-between gap-2 px-2 py-0.5 text-[10px] font-medium border-t border-t-[var(--grl-color-border-fade)] bg-[var(--grl-color-primary-bg-fade)] text-[var(--muted-foreground)]",
|
|
8474
|
-
children: [/* @__PURE__ */ z("span", { children: "TRACE" }),
|
|
8482
|
+
children: [/* @__PURE__ */ z("span", { children: "TRACE" }), /* @__PURE__ */ B("span", {
|
|
8483
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
8484
|
+
children: [p && /* @__PURE__ */ z("span", {
|
|
8485
|
+
"data-slot": "node-run-strip-error",
|
|
8486
|
+
className: "max-w-36 truncate rounded-sm bg-[var(--seal-color-error)] px-1 py-px font-semibold text-white",
|
|
8487
|
+
title: [p.title, p.message].filter(Boolean).join("\n") || void 0,
|
|
8488
|
+
children: p.code || p.title
|
|
8489
|
+
}), f?.performance != null && /* @__PURE__ */ z("span", { children: f.performance })]
|
|
8490
|
+
})]
|
|
8475
8491
|
})
|
|
8476
8492
|
]
|
|
8477
8493
|
}), /* @__PURE__ */ z(Td, {
|
|
8478
|
-
state:
|
|
8494
|
+
state: y,
|
|
8479
8495
|
timeout: 100,
|
|
8480
8496
|
children: (e, t) => t && /* @__PURE__ */ z(xd, {
|
|
8481
8497
|
className: "nodrag",
|
|
@@ -8490,17 +8506,17 @@ var xd = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
|
|
|
8490
8506
|
className: "flex items-center justify-between pl-2.5 bg-[var(--seal-color-primary-bg-fade)] rounded-t-[var(--node-border-radius)] border-b border-b-[var(--border)]",
|
|
8491
8507
|
children: [/* @__PURE__ */ z(X.Text, {
|
|
8492
8508
|
className: "text-xs! text-[var(--muted-foreground)]",
|
|
8493
|
-
children:
|
|
8509
|
+
children: b
|
|
8494
8510
|
}), /* @__PURE__ */ z(J, {
|
|
8495
8511
|
type: "text",
|
|
8496
8512
|
size: "small",
|
|
8497
8513
|
className: "text-[var(--muted-foreground)] [font-size:0]!",
|
|
8498
8514
|
icon: /* @__PURE__ */ z(gs, { style: { fontSize: 8 } }),
|
|
8499
|
-
onClick:
|
|
8515
|
+
onClick: x
|
|
8500
8516
|
})]
|
|
8501
8517
|
}), /* @__PURE__ */ z("div", {
|
|
8502
8518
|
className: "flex flex-col p-2.5 gap-0.5 [&_.settings-form_.seal-ce]:text-xs",
|
|
8503
|
-
children:
|
|
8519
|
+
children: v
|
|
8504
8520
|
})]
|
|
8505
8521
|
})
|
|
8506
8522
|
})
|
|
@@ -8522,7 +8538,7 @@ var xd = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
|
|
|
8522
8538
|
let f = Z(), [p, m] = N.useState(!1), [h, g] = gd(`node:details:${e}`, 0), [_, v] = gd(`node:detailsOpen:${e}`, !1), y = Ju(), { modal: b } = Ci.useApp(), { nodeError: x, nodeTrace: S, disabled: C, compactMode: w } = $(({ simulate: t, disabled: n, compactMode: r }) => ({
|
|
8523
8539
|
disabled: n,
|
|
8524
8540
|
nodeTrace: G(t).with({ result: W._ }, ({ result: t }) => t?.trace?.[e]).otherwise(() => null),
|
|
8525
|
-
nodeError:
|
|
8541
|
+
nodeError: t?.error?.data?.nodeId === e ? t.error : null,
|
|
8526
8542
|
compactMode: r
|
|
8527
8543
|
})), { diff: T } = Xu(e), E = i.renderSettings, D = () => {
|
|
8528
8544
|
v(h !== 0 || !_), g(0);
|
|
@@ -8685,6 +8701,11 @@ var xd = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
|
|
|
8685
8701
|
W._
|
|
8686
8702
|
], () => "success").otherwise(() => void 0),
|
|
8687
8703
|
trace: S,
|
|
8704
|
+
traceError: x ? {
|
|
8705
|
+
code: x.code ?? null,
|
|
8706
|
+
title: x.title ?? null,
|
|
8707
|
+
message: x.message ?? null
|
|
8708
|
+
} : null,
|
|
8688
8709
|
diffStatus: G([T]).with([{ status: "added" }], () => "added").with([{ status: "modified" }], () => "modified").with([{ status: "removed" }], () => "removed").with([{ status: "moved" }], () => "moved").otherwise(() => void 0),
|
|
8689
8710
|
onNameChange: (t) => {
|
|
8690
8711
|
y.updateNode(e, (e) => (e.name = t, e));
|
|
@@ -14524,7 +14545,7 @@ var im = () => N.useContext(em), am = () => {
|
|
|
14524
14545
|
className: "mx-1 h-4 w-px bg-[var(--border)]"
|
|
14525
14546
|
}), n.filter((t) => (t.group ?? "") === e).map((e) => /* @__PURE__ */ z(Yo, {
|
|
14526
14547
|
fallback: null,
|
|
14527
|
-
onError: (t) => console.error(`[
|
|
14548
|
+
onError: (t) => console.error(`[seal-editor] toolbar item "${e.id}" crashed:`, t),
|
|
14528
14549
|
children: /* @__PURE__ */ z(Dm, {
|
|
14529
14550
|
item: e,
|
|
14530
14551
|
disabled: t
|
|
@@ -14541,7 +14562,7 @@ var im = () => N.useContext(em), am = () => {
|
|
|
14541
14562
|
let r = await e();
|
|
14542
14563
|
!n && r && t.setState({ user: r.user ?? "" });
|
|
14543
14564
|
} catch (e) {
|
|
14544
|
-
console.warn("[
|
|
14565
|
+
console.warn("[seal-editor] userResolver failed:", e), n || t.setState({ user: "" });
|
|
14545
14566
|
}
|
|
14546
14567
|
})(), () => {
|
|
14547
14568
|
n = !0;
|