wimui 0.23.14 → 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.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs");;/* empty css */const t=require("./node-graph.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime"),a=require("@xyflow/react");var o=n.default.forwardRef(({nodes:e,edges:n,onNodesChange:o,onEdgesChange:s,onConnect:c,nodeTypes:l,edgeTypes:u,nodesDraggable:d=!0,nodesConnectable:f=!0,deleteKeyCode:p=`Backspace`,showMiniMap:m=!1,showControls:h=!0,backgroundVariant:g=a.BackgroundVariant.Dots,fitView:_=!0,fitViewOptions:v,defaultEdgeOptions:y,className:b,"aria-label":x=`Node graph`,...S},C)=>(0,i.jsx)(`div`,{ref:C,className:(0,r.default)(`wim-node-graph`,t.default.root,b),role:`region`,"aria-label":x,...S,children:(0,i.jsxs)(a.ReactFlow,{nodes:e,edges:n,onNodesChange:o,onEdgesChange:s,onConnect:c,nodeTypes:l,edgeTypes:u,nodesDraggable:d,nodesConnectable:f,deleteKeyCode:p,fitView:_,fitViewOptions:v,defaultEdgeOptions:y,className:t.default.flow,children:[(0,i.jsx)(a.Background,{variant:g,className:t.default.background}),h&&(0,i.jsx)(a.Controls,{className:t.default.controls}),m&&(0,i.jsx)(a.MiniMap,{className:t.default.miniMap})]})}));o.displayName=`NodeGraph`,exports.NodeGraph=o;
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
- /** Whether elements can be deleted with Backspace/Delete */
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 e from "./node-graph.module.js";
4
- import t from "react";
5
- import n from "classnames";
6
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
7
- import { Background as a, BackgroundVariant as o, Controls as s, MiniMap as c, ReactFlow as l } from "@xyflow/react";
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 u = t.forwardRef(({ nodes: t, edges: u, onNodesChange: d, onEdgesChange: f, onConnect: p, nodeTypes: m, edgeTypes: h, nodesDraggable: g = !0, nodesConnectable: _ = !0, deleteKeyCode: v = "Backspace", showMiniMap: y = !1, showControls: b = !0, backgroundVariant: x = o.Dots, fitView: S = !0, fitViewOptions: C, defaultEdgeOptions: w, className: T, "aria-label": E = "Node graph", ...D }, O) => /* @__PURE__ */ r("div", {
10
- ref: O,
11
- className: n("wim-node-graph", e.root, T),
12
- role: "region",
13
- "aria-label": E,
14
- ...D,
15
- children: /* @__PURE__ */ i(l, {
16
- nodes: t,
17
- edges: u,
18
- onNodesChange: d,
19
- onEdgesChange: f,
20
- onConnect: p,
21
- nodeTypes: m,
22
- edgeTypes: h,
23
- nodesDraggable: g,
24
- nodesConnectable: _,
25
- deleteKeyCode: v,
26
- fitView: S,
27
- fitViewOptions: C,
28
- defaultEdgeOptions: w,
29
- className: e.flow,
30
- children: [
31
- /* @__PURE__ */ r(a, {
32
- variant: x,
33
- className: e.background
34
- }),
35
- b && /* @__PURE__ */ r(s, { className: e.controls }),
36
- y && /* @__PURE__ */ r(c, { className: e.miniMap })
37
- ]
38
- })
39
- }));
40
- u.displayName = "NodeGraph";
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 { u as NodeGraph };
161
+ export { x as NodeGraph };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_root_1le7n_2`,t=`_flow_1le7n_52`,n=`_background_1le7n_57`,r=`_controls_1le7n_72`,i=`_miniMap_1le7n_82`,a={root:e,flow:t,background:n,controls:r,miniMap:i};exports.background=n,exports.controls=r,exports.default=a,exports.flow=t,exports.miniMap=i,exports.root=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 = "_root_1le7n_2", t = "_flow_1le7n_52", n = "_background_1le7n_57", r = "_controls_1le7n_72", i = "_miniMap_1le7n_82", a = {
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, a as default, t as flow, i as miniMap, e as root };
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 };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_root_1eoto_1`,t=`_dashed_1eoto_18`,n=`_solid_1eoto_21`,r=`_none_1eoto_24`,i=`_transparent_1eoto_30`,a=`_muted_1eoto_33`,o=`_sm_1eoto_36`,s=`_md_1eoto_42`,c=`_lg_1eoto_48`,l=`_dragging_1eoto_54`,u=`_clickable_1eoto_58`,d=`_disabled_1eoto_69`,f=`_inner_1eoto_74`,p=`_text_1eoto_84`,m=`_icon_1eoto_91`,h=`_title_1eoto_99`,g=`_description_1eoto_105`,_=`_content_1eoto_110`,v=`_actions_1eoto_114`,y={root:e,dashed:t,solid:n,none:r,default:`_default_1eoto_27`,transparent:i,muted:a,sm:o,md:s,lg:c,dragging:l,clickable:u,disabled:d,inner:f,text:p,icon:m,title:h,description:g,content:_,actions:v};exports.actions=v,exports.clickable=u,exports.content=_,exports.dashed=t,exports.default=y,exports.description=g,exports.disabled=d,exports.dragging=l,exports.icon=m,exports.inner=f,exports.lg=c,exports.md=s,exports.muted=a,exports.none=r,exports.root=e,exports.sm=o,exports.solid=n,exports.text=p,exports.title=h,exports.transparent=i;
2
+ var e=`_root_1ljn8_2`,t=`_dashed_1ljn8_19`,n=`_solid_1ljn8_22`,r=`_none_1ljn8_25`,i=`_transparent_1ljn8_31`,a=`_muted_1ljn8_34`,o=`_sm_1ljn8_37`,s=`_md_1ljn8_43`,c=`_lg_1ljn8_49`,l=`_dragging_1ljn8_55`,u=`_clickable_1ljn8_59`,d=`_disabled_1ljn8_70`,f=`_inner_1ljn8_74`,p=`_text_1ljn8_83`,m=`_icon_1ljn8_89`,h=`_title_1ljn8_100`,g=`_description_1ljn8_105`,_=`_content_1ljn8_109`,v=`_actions_1ljn8_112`,y={root:e,dashed:t,solid:n,none:r,default:`_default_1ljn8_28`,transparent:i,muted:a,sm:o,md:s,lg:c,dragging:l,clickable:u,disabled:d,inner:f,text:p,icon:m,title:h,description:g,content:_,actions:v};exports.actions=v,exports.clickable=u,exports.content=_,exports.dashed=t,exports.default=y,exports.description=g,exports.disabled=d,exports.dragging=l,exports.icon=m,exports.inner=f,exports.lg=c,exports.md=s,exports.muted=a,exports.none=r,exports.root=e,exports.sm=o,exports.solid=n,exports.text=p,exports.title=h,exports.transparent=i;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  //#region src/components/layout/InteractiveArea/interactive-area.module.scss
3
- var e = "_root_1eoto_1", t = "_dashed_1eoto_18", n = "_solid_1eoto_21", r = "_none_1eoto_24", i = "_transparent_1eoto_30", a = "_muted_1eoto_33", o = "_sm_1eoto_36", s = "_md_1eoto_42", c = "_lg_1eoto_48", l = "_dragging_1eoto_54", u = "_clickable_1eoto_58", d = "_disabled_1eoto_69", f = "_inner_1eoto_74", p = "_text_1eoto_84", m = "_icon_1eoto_91", h = "_title_1eoto_99", g = "_description_1eoto_105", _ = "_content_1eoto_110", v = "_actions_1eoto_114", y = {
3
+ var e = "_root_1ljn8_2", t = "_dashed_1ljn8_19", n = "_solid_1ljn8_22", r = "_none_1ljn8_25", i = "_transparent_1ljn8_31", a = "_muted_1ljn8_34", o = "_sm_1ljn8_37", s = "_md_1ljn8_43", c = "_lg_1ljn8_49", l = "_dragging_1ljn8_55", u = "_clickable_1ljn8_59", d = "_disabled_1ljn8_70", f = "_inner_1ljn8_74", p = "_text_1ljn8_83", m = "_icon_1ljn8_89", h = "_title_1ljn8_100", g = "_description_1ljn8_105", _ = "_content_1ljn8_109", v = "_actions_1ljn8_112", y = {
4
4
  root: e,
5
5
  dashed: t,
6
6
  solid: n,
7
7
  none: r,
8
- default: "_default_1eoto_27",
8
+ default: "_default_1ljn8_28",
9
9
  transparent: i,
10
10
  muted: a,
11
11
  sm: o,