wimui 0.23.15 → 0.23.16
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/components/data-display/NodeGraph/NodeGraph.cjs +1 -1
- package/dist/components/data-display/NodeGraph/NodeGraph.d.ts +6 -2
- package/dist/components/data-display/NodeGraph/NodeGraph.js +157 -38
- package/dist/components/data-display/NodeGraph/node-graph.module.cjs +1 -1
- package/dist/components/data-display/NodeGraph/node-graph.module.js +7 -3
- package/dist/i18n/generated/keys.d.ts +1 -1
- package/dist/i18n/generated/resources.cjs +1 -1
- package/dist/i18n/generated/resources.js +15 -0
- package/dist/llms-full.txt +5 -3
- package/dist/llms.txt +1 -1
- package/dist/locales/en/common.json +5 -0
- package/dist/locales/ja/common.json +5 -0
- package/dist/locales/pt/common.json +5 -0
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs");;/* empty css */const
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../icon/plus.cjs"),r=require("../../../icon/trash.cjs"),i=require("../../media/Icon/Icon.cjs");;/* empty css */const a=require("./node-graph.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime"),l=require("@xyflow/react");var u=[`Backspace`,`Delete`],d=180,f=80;function p(e){let t=1,n=new Set(e.map(e=>e.id));for(;n.has(`node-${t}`);)t+=1;return`node-${t}`}function m(e){if(e.length===0)return{x:f,y:f};let t=Math.max(...e.map(e=>e.position.x)),n=e[e.length-1]?.position.y??f;return{x:t+d,y:n}}var h=o.default.forwardRef(({nodes:e,edges:d,onNodesChange:f,onEdgesChange:h,onConnect:g,nodeTypes:_,edgeTypes:v,nodesDraggable:y=!0,nodesConnectable:b=!0,deleteKeyCode:x,showMiniMap:S=!1,showControls:C=!0,backgroundVariant:w=l.BackgroundVariant.Dots,fitView:T=!0,fitViewOptions:E,defaultEdgeOptions:D,className:O,"aria-label":k=`Node graph`,...A},j)=>{let{t:M}=t.useWimTranslation(`common`),N=M(`nodeGraph.add_node`),P=M(`nodeGraph.node_name`),F=M(`nodeGraph.new_node`),I=M(`a11y.delete`),L=x===void 0?[...u]:x,R=L!=null,[z,B]=(0,o.useState)(!1),[V,H]=(0,o.useState)(``),U=(0,o.useRef)(null),W=(0,o.useMemo)(()=>e.filter(e=>e.selected),[e]),G=(0,o.useMemo)(()=>d.filter(e=>e.selected),[d]),K=W.length>0||G.length>0,q=V.trim(),J=L==null?void 0:Array.isArray(L)?L.join(` `):L;(0,o.useEffect)(()=>{z&&U.current?.focus()},[z]);let Y=(0,o.useCallback)(()=>{!R||!q||(f([{type:`add`,item:{id:p(e),position:m(e),data:{label:q}}}]),B(!1),H(``))},[R,q,e,f]),X=(0,o.useCallback)(()=>{if(R){if(!z){B(!0);return}Y()}},[R,z,Y]),Z=(0,o.useCallback)(e=>{e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),Y()),e.key===`Escape`&&(e.preventDefault(),B(!1),H(``))},[Y]),Q=(0,o.useCallback)(()=>{if(!R||!K)return;let e=new Set(W.map(e=>e.id)),t=new Set(G.map(e=>e.id));for(let n of d)(e.has(n.source)||e.has(n.target))&&t.add(n.id);t.size>0&&h([...t].map(e=>({type:`remove`,id:e}))),e.size>0&&f([...e].map(e=>({type:`remove`,id:e})))},[R,K,W,G,d,h,f]),$=(0,o.useCallback)(e=>{e.stopPropagation()},[]);return(0,c.jsxs)(`div`,{ref:j,className:(0,s.default)(`wim-node-graph`,a.default.root,O),role:`region`,"aria-label":k,...A,children:[(0,c.jsxs)(l.ReactFlow,{nodes:e,edges:d,onNodesChange:f,onEdgesChange:h,onConnect:g,nodeTypes:_,edgeTypes:v,nodesDraggable:y,nodesConnectable:b,deleteKeyCode:L,fitView:T,fitViewOptions:E,defaultEdgeOptions:D,className:a.default.flow,children:[(0,c.jsx)(l.Background,{variant:w,className:a.default.background}),C&&(0,c.jsx)(l.Controls,{className:a.default.controls}),S&&(0,c.jsx)(l.MiniMap,{className:a.default.miniMap})]}),R&&(0,c.jsxs)(`div`,{className:a.default.tools,children:[z&&(0,c.jsx)(`input`,{ref:U,className:(0,s.default)(`nodrag`,`nopan`,a.default.name),value:V,onChange:e=>H(e.target.value),onKeyDown:Z,onPointerDown:$,onMouseDown:$,"aria-label":P,placeholder:F}),(0,c.jsxs)(`div`,{className:a.default.toolRow,children:[(0,c.jsxs)(`button`,{type:`button`,className:(0,s.default)(`nodrag`,`nopan`,a.default.tool),disabled:z&&!q,onClick:X,onPointerDown:$,onMouseDown:$,"aria-label":N,"aria-expanded":z,children:[(0,c.jsx)(i.Icon,{component:n.default,size:`sm`}),N]}),(0,c.jsxs)(`button`,{type:`button`,className:(0,s.default)(`nodrag`,`nopan`,a.default.tool),disabled:!K,onClick:Q,onPointerDown:$,onMouseDown:$,"aria-label":I,"aria-keyshortcuts":J,children:[(0,c.jsx)(i.Icon,{component:r.default,size:`sm`}),I]})]})]})]})});h.displayName=`NodeGraph`,exports.NodeGraph=h;
|
|
@@ -6,7 +6,7 @@ export interface NodeGraphProps {
|
|
|
6
6
|
nodes: Node[];
|
|
7
7
|
/** Controlled edges */
|
|
8
8
|
edges: Edge[];
|
|
9
|
-
/** Called when nodes change (position, selection, removal) */
|
|
9
|
+
/** Called when nodes change (position, selection, add, removal) */
|
|
10
10
|
onNodesChange: OnNodesChange;
|
|
11
11
|
/** Called when edges change */
|
|
12
12
|
onEdgesChange: OnEdgesChange;
|
|
@@ -20,7 +20,11 @@ export interface NodeGraphProps {
|
|
|
20
20
|
nodesDraggable?: boolean;
|
|
21
21
|
/** Whether nodes can be connected */
|
|
22
22
|
nodesConnectable?: boolean;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Keys that delete the selection, and whether the on-canvas add/delete controls are shown.
|
|
25
|
+
* `null` hides the controls and disables key deletion (read-only).
|
|
26
|
+
* When omitted, both Backspace and Delete work.
|
|
27
|
+
*/
|
|
24
28
|
deleteKeyCode?: string | null;
|
|
25
29
|
/** Show the minimap panel */
|
|
26
30
|
showMiniMap?: boolean;
|
|
@@ -1,42 +1,161 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
|
|
3
|
+
import t from "../../../icon/plus.js";
|
|
4
|
+
import n from "../../../icon/trash.js";
|
|
5
|
+
import { Icon as r } from "../../media/Icon/Icon.js";
|
|
2
6
|
/* empty css */
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { Background as
|
|
7
|
+
import i from "./node-graph.module.js";
|
|
8
|
+
import a, { useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
9
|
+
import d from "classnames";
|
|
10
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
|
+
import { Background as m, BackgroundVariant as h, Controls as g, MiniMap as ee, ReactFlow as te } from "@xyflow/react";
|
|
8
12
|
//#region src/components/data-display/NodeGraph/NodeGraph.tsx
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}));
|
|
40
|
-
|
|
13
|
+
var ne = ["Backspace", "Delete"], _ = 180, v = 80;
|
|
14
|
+
function y(e) {
|
|
15
|
+
let t = 1, n = new Set(e.map((e) => e.id));
|
|
16
|
+
for (; n.has(`node-${t}`);) t += 1;
|
|
17
|
+
return `node-${t}`;
|
|
18
|
+
}
|
|
19
|
+
function b(e) {
|
|
20
|
+
if (e.length === 0) return {
|
|
21
|
+
x: v,
|
|
22
|
+
y: v
|
|
23
|
+
};
|
|
24
|
+
let t = Math.max(...e.map((e) => e.position.x)), n = e[e.length - 1]?.position.y ?? v;
|
|
25
|
+
return {
|
|
26
|
+
x: t + _,
|
|
27
|
+
y: n
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var x = a.forwardRef(({ nodes: a, edges: _, onNodesChange: v, onEdgesChange: x, onConnect: S, nodeTypes: C, edgeTypes: w, nodesDraggable: T = !0, nodesConnectable: E = !0, deleteKeyCode: D, showMiniMap: re = !1, showControls: ie = !0, backgroundVariant: O = h.Dots, fitView: k = !0, fitViewOptions: A, defaultEdgeOptions: j, className: M, "aria-label": N = "Node graph", ...P }, F) => {
|
|
31
|
+
let { t: I } = e("common"), L = I("nodeGraph.add_node"), R = I("nodeGraph.node_name"), z = I("nodeGraph.new_node"), B = I("a11y.delete"), V = D === void 0 ? [...ne] : D, H = V != null, [U, W] = u(!1), [G, K] = u(""), q = l(null), J = c(() => a.filter((e) => e.selected), [a]), Y = c(() => _.filter((e) => e.selected), [_]), X = J.length > 0 || Y.length > 0, Z = G.trim(), ae = V == null ? void 0 : Array.isArray(V) ? V.join(" ") : V;
|
|
32
|
+
s(() => {
|
|
33
|
+
U && q.current?.focus();
|
|
34
|
+
}, [U]);
|
|
35
|
+
let Q = o(() => {
|
|
36
|
+
!H || !Z || (v([{
|
|
37
|
+
type: "add",
|
|
38
|
+
item: {
|
|
39
|
+
id: y(a),
|
|
40
|
+
position: b(a),
|
|
41
|
+
data: { label: Z }
|
|
42
|
+
}
|
|
43
|
+
}]), W(!1), K(""));
|
|
44
|
+
}, [
|
|
45
|
+
H,
|
|
46
|
+
Z,
|
|
47
|
+
a,
|
|
48
|
+
v
|
|
49
|
+
]), oe = o(() => {
|
|
50
|
+
if (H) {
|
|
51
|
+
if (!U) {
|
|
52
|
+
W(!0);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
Q();
|
|
56
|
+
}
|
|
57
|
+
}, [
|
|
58
|
+
H,
|
|
59
|
+
U,
|
|
60
|
+
Q
|
|
61
|
+
]), se = o((e) => {
|
|
62
|
+
e.stopPropagation(), e.key === "Enter" && (e.preventDefault(), Q()), e.key === "Escape" && (e.preventDefault(), W(!1), K(""));
|
|
63
|
+
}, [Q]), ce = o(() => {
|
|
64
|
+
if (!H || !X) return;
|
|
65
|
+
let e = new Set(J.map((e) => e.id)), t = new Set(Y.map((e) => e.id));
|
|
66
|
+
for (let n of _) (e.has(n.source) || e.has(n.target)) && t.add(n.id);
|
|
67
|
+
t.size > 0 && x([...t].map((e) => ({
|
|
68
|
+
type: "remove",
|
|
69
|
+
id: e
|
|
70
|
+
}))), e.size > 0 && v([...e].map((e) => ({
|
|
71
|
+
type: "remove",
|
|
72
|
+
id: e
|
|
73
|
+
})));
|
|
74
|
+
}, [
|
|
75
|
+
H,
|
|
76
|
+
X,
|
|
77
|
+
J,
|
|
78
|
+
Y,
|
|
79
|
+
_,
|
|
80
|
+
x,
|
|
81
|
+
v
|
|
82
|
+
]), $ = o((e) => {
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
}, []);
|
|
85
|
+
return /* @__PURE__ */ p("div", {
|
|
86
|
+
ref: F,
|
|
87
|
+
className: d("wim-node-graph", i.root, M),
|
|
88
|
+
role: "region",
|
|
89
|
+
"aria-label": N,
|
|
90
|
+
...P,
|
|
91
|
+
children: [/* @__PURE__ */ p(te, {
|
|
92
|
+
nodes: a,
|
|
93
|
+
edges: _,
|
|
94
|
+
onNodesChange: v,
|
|
95
|
+
onEdgesChange: x,
|
|
96
|
+
onConnect: S,
|
|
97
|
+
nodeTypes: C,
|
|
98
|
+
edgeTypes: w,
|
|
99
|
+
nodesDraggable: T,
|
|
100
|
+
nodesConnectable: E,
|
|
101
|
+
deleteKeyCode: V,
|
|
102
|
+
fitView: k,
|
|
103
|
+
fitViewOptions: A,
|
|
104
|
+
defaultEdgeOptions: j,
|
|
105
|
+
className: i.flow,
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ f(m, {
|
|
108
|
+
variant: O,
|
|
109
|
+
className: i.background
|
|
110
|
+
}),
|
|
111
|
+
ie && /* @__PURE__ */ f(g, { className: i.controls }),
|
|
112
|
+
re && /* @__PURE__ */ f(ee, { className: i.miniMap })
|
|
113
|
+
]
|
|
114
|
+
}), H && /* @__PURE__ */ p("div", {
|
|
115
|
+
className: i.tools,
|
|
116
|
+
children: [U && /* @__PURE__ */ f("input", {
|
|
117
|
+
ref: q,
|
|
118
|
+
className: d("nodrag", "nopan", i.name),
|
|
119
|
+
value: G,
|
|
120
|
+
onChange: (e) => K(e.target.value),
|
|
121
|
+
onKeyDown: se,
|
|
122
|
+
onPointerDown: $,
|
|
123
|
+
onMouseDown: $,
|
|
124
|
+
"aria-label": R,
|
|
125
|
+
placeholder: z
|
|
126
|
+
}), /* @__PURE__ */ p("div", {
|
|
127
|
+
className: i.toolRow,
|
|
128
|
+
children: [/* @__PURE__ */ p("button", {
|
|
129
|
+
type: "button",
|
|
130
|
+
className: d("nodrag", "nopan", i.tool),
|
|
131
|
+
disabled: U && !Z,
|
|
132
|
+
onClick: oe,
|
|
133
|
+
onPointerDown: $,
|
|
134
|
+
onMouseDown: $,
|
|
135
|
+
"aria-label": L,
|
|
136
|
+
"aria-expanded": U,
|
|
137
|
+
children: [/* @__PURE__ */ f(r, {
|
|
138
|
+
component: t,
|
|
139
|
+
size: "sm"
|
|
140
|
+
}), L]
|
|
141
|
+
}), /* @__PURE__ */ p("button", {
|
|
142
|
+
type: "button",
|
|
143
|
+
className: d("nodrag", "nopan", i.tool),
|
|
144
|
+
disabled: !X,
|
|
145
|
+
onClick: ce,
|
|
146
|
+
onPointerDown: $,
|
|
147
|
+
onMouseDown: $,
|
|
148
|
+
"aria-label": B,
|
|
149
|
+
"aria-keyshortcuts": ae,
|
|
150
|
+
children: [/* @__PURE__ */ f(r, {
|
|
151
|
+
component: n,
|
|
152
|
+
size: "sm"
|
|
153
|
+
}), B]
|
|
154
|
+
})]
|
|
155
|
+
})]
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
x.displayName = "NodeGraph";
|
|
41
160
|
//#endregion
|
|
42
|
-
export {
|
|
161
|
+
export { x as NodeGraph };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_1pnfy_2`,t=`_flow_1pnfy_52`,n=`_background_1pnfy_57`,r=`_controls_1pnfy_72`,i=`_miniMap_1pnfy_82`,a=`_tools_1pnfy_87`,o=`_toolRow_1pnfy_99`,s=`_name_1pnfy_104`,c=`_tool_1pnfy_87`,l={root:e,flow:t,background:n,controls:r,miniMap:i,tools:a,toolRow:o,name:s,tool:c};exports.background=n,exports.controls=r,exports.default=l,exports.flow=t,exports.miniMap=i,exports.name=s,exports.root=e,exports.tool=c,exports.toolRow=o,exports.tools=a;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/data-display/NodeGraph/node-graph.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_1pnfy_2", t = "_flow_1pnfy_52", n = "_background_1pnfy_57", r = "_controls_1pnfy_72", i = "_miniMap_1pnfy_82", a = "_tools_1pnfy_87", o = "_toolRow_1pnfy_99", s = "_name_1pnfy_104", c = "_tool_1pnfy_87", l = {
|
|
4
4
|
root: e,
|
|
5
5
|
flow: t,
|
|
6
6
|
background: n,
|
|
7
7
|
controls: r,
|
|
8
|
-
miniMap: i
|
|
8
|
+
miniMap: i,
|
|
9
|
+
tools: a,
|
|
10
|
+
toolRow: o,
|
|
11
|
+
name: s,
|
|
12
|
+
tool: c
|
|
9
13
|
};
|
|
10
14
|
//#endregion
|
|
11
|
-
export { n as background, r as controls,
|
|
15
|
+
export { n as background, r as controls, l as default, t as flow, i as miniMap, s as name, e as root, c as tool, o as toolRow, a as tools };
|