@synertech/ui 0.46.2 → 0.46.3

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.
Files changed (64) hide show
  1. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  2. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  3. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  4. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  5. package/dist/components/calendar/Calendar.cjs +1 -1
  6. package/dist/components/calendar/Calendar.js +1 -1
  7. package/dist/components/chart/ChartLegend.cjs +1 -1
  8. package/dist/components/chart/ChartLegend.js +1 -1
  9. package/dist/components/datagrid/DataGrid.cjs +1 -1
  10. package/dist/components/datagrid/DataGrid.js +1 -1
  11. package/dist/components/drawer/Drawer.cjs +1 -1
  12. package/dist/components/drawer/Drawer.js +1 -1
  13. package/dist/components/dropdown/DropdownItem.cjs +1 -1
  14. package/dist/components/dropdown/DropdownItem.js +1 -1
  15. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  16. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  17. package/dist/components/dropdown/DropdownTrigger.cjs +1 -1
  18. package/dist/components/dropdown/DropdownTrigger.js +1 -1
  19. package/dist/components/file-selector/FileSelector.cjs +1 -1
  20. package/dist/components/file-selector/FileSelector.js +1 -1
  21. package/dist/components/form/mention-input/MentionInput.cjs +1 -1
  22. package/dist/components/form/mention-input/MentionInput.js +1 -1
  23. package/dist/components/form/shared/inputStyles.cjs +1 -1
  24. package/dist/components/form/shared/inputStyles.js +1 -1
  25. package/dist/components/header/Header.cjs +1 -1
  26. package/dist/components/header/Header.js +1 -1
  27. package/dist/components/help-button/HelpButton.cjs +2 -2
  28. package/dist/components/help-button/HelpButton.js +3 -3
  29. package/dist/components/label/Label.cjs +1 -1
  30. package/dist/components/label/Label.js +1 -1
  31. package/dist/components/modal/Modal.cjs +1 -1
  32. package/dist/components/modal/Modal.js +1 -1
  33. package/dist/components/pagination/Pagination.cjs +1 -1
  34. package/dist/components/pagination/Pagination.js +1 -1
  35. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  36. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  37. package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
  38. package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
  39. package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
  40. package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
  41. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  42. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  43. package/dist/components/schema-editor/utils/foreign-keys.cjs +1 -0
  44. package/dist/components/schema-editor/utils/foreign-keys.js +1 -0
  45. package/dist/components/schema-editor/utils/geometry.cjs +1 -1
  46. package/dist/components/schema-editor/utils/geometry.js +1 -1
  47. package/dist/components/schema-editor/utils/sql-export.cjs +5 -5
  48. package/dist/components/schema-editor/utils/sql-export.js +5 -5
  49. package/dist/components/select/Select.cjs +1 -1
  50. package/dist/components/select/Select.js +1 -1
  51. package/dist/components/sidebar/Sidebar.cjs +1 -1
  52. package/dist/components/sidebar/Sidebar.js +1 -1
  53. package/dist/components/stat-card/StatCard.cjs +1 -1
  54. package/dist/components/stat-card/StatCard.js +1 -1
  55. package/dist/components/wizard/Wizard.cjs +1 -1
  56. package/dist/components/wizard/Wizard.js +1 -1
  57. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  58. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  59. package/dist/index.d.cts +12 -0
  60. package/dist/index.d.ts +12 -0
  61. package/dist/lib/editable-target.cjs +1 -0
  62. package/dist/lib/editable-target.js +1 -0
  63. package/dist/styles.css +26 -26
  64. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var R=(t,r)=>{for(var o in r)m(t,o,{get:r[o],enumerable:!0})},P=(t,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of N(r))!k.call(t,i)&&i!==o&&m(t,i,{get:()=>r[i],enumerable:!(a=D(r,i))||a.enumerable});return t};var L=t=>P(m({},"__esModule",{value:!0}),t);var j={};R(j,{StatCard:()=>Z});module.exports=L(j);var s=require("../../lib/cn.cjs"),l=require("../chart/utils/format.cjs"),h=require("../circular-progress/CircularProgress.cjs"),f=require("../sparkline/Sparkline.cjs"),e=require("react/jsx-runtime"),z={sm:"p-3",md:"p-4",lg:"p-5"},T={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},W={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},g={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function A(t){return t.direction?t.direction:t.value>0?"up":t.value<0?"down":"flat"}function B(t,r){return t==="flat"||r==="neutral"?"text-gray-500 dark:text-gray-400":t===r?"text-green-700 dark:text-green-400":"text-red-600 dark:text-red-400"}function M({direction:t}){return t==="flat"?(0,e.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):(0,e.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:t==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function Z({label:t,value:r,format:o,delta:a,trend:i,trendColor:x,icon:c,size:n="md",loading:d=!1,variant:C="card",footer:u,className:v,...y}){let S=typeof r=="number"?(o??l.formatAuto)(r):r,p=a?A(a):"flat",b=a?(a.format??(w=>(0,l.formatPercent)(w,{signed:!0})))(a.value):null;return(0,e.jsxs)("div",{className:(0,s.cn)("flex flex-col gap-2",C==="card"&&(0,s.cn)("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",z[n]),v),...y,children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:(0,s.cn)("font-medium text-gray-500 dark:text-gray-400",T[n]),children:t}),c?(0,e.jsx)("span",{className:"shrink-0 text-gray-400",children:c}):null]}),(0,e.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[d?(0,e.jsx)("div",{className:"flex items-center",style:{height:n==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:(0,e.jsx)(h.CircularProgress,{indeterminate:!0,size:n==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):(0,e.jsx)("span",{className:(0,s.cn)("leading-none font-semibold text-gray-900 dark:text-gray-100",W[n]),children:S}),a&&!d?(0,e.jsxs)("span",{className:(0,s.cn)("flex items-center gap-1 text-xs font-medium",B(p,a.goodWhen??"up")),children:[(0,e.jsx)(M,{direction:p}),b,a.period?(0,e.jsx)("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:a.period}):null]}):null]}),i&&i.length>0&&!d?(0,e.jsx)(f.Sparkline,{data:i,color:x,emphasizeLast:!0,area:!0,width:g[n].width,height:g[n].height,className:"shrink-0"}):null]}),u?(0,e.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:u}):null]})}0&&(module.exports={StatCard});
1
+ "use strict";var m=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var R=(t,r)=>{for(var o in r)m(t,o,{get:r[o],enumerable:!0})},P=(t,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of N(r))!k.call(t,i)&&i!==o&&m(t,i,{get:()=>r[i],enumerable:!(a=D(r,i))||a.enumerable});return t};var L=t=>P(m({},"__esModule",{value:!0}),t);var j={};R(j,{StatCard:()=>Z});module.exports=L(j);var s=require("../../lib/cn.cjs"),d=require("../chart/utils/format.cjs"),h=require("../circular-progress/CircularProgress.cjs"),f=require("../sparkline/Sparkline.cjs"),e=require("react/jsx-runtime"),z={sm:"p-3",md:"p-4",lg:"p-5"},T={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},W={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},p={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function A(t){return t.direction?t.direction:t.value>0?"up":t.value<0?"down":"flat"}function B(t,r){return t==="flat"||r==="neutral"?"text-gray-500 dark:text-gray-400":t===r?"text-green-700 dark:text-green-400":"text-red-600 dark:text-red-400"}function M({direction:t}){return t==="flat"?(0,e.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):(0,e.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:t==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function Z({label:t,value:r,format:o,delta:a,trend:i,trendColor:x,icon:c,size:n="md",loading:l=!1,variant:C="card",footer:u,className:v,...y}){let S=typeof r=="number"?(o??d.formatAuto)(r):r,g=a?A(a):"flat",b=a?(a.format??(w=>(0,d.formatPercent)(w,{signed:!0})))(a.value):null;return(0,e.jsxs)("div",{className:(0,s.cn)("flex flex-col gap-2",C==="card"&&(0,s.cn)("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",z[n]),v),...y,children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:(0,s.cn)("font-medium text-gray-500 dark:text-gray-400",T[n]),children:t}),c?(0,e.jsx)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:c}):null]}),(0,e.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[l?(0,e.jsx)("div",{className:"flex items-center",style:{height:n==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:(0,e.jsx)(h.CircularProgress,{indeterminate:!0,size:n==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):(0,e.jsx)("span",{className:(0,s.cn)("leading-none font-semibold text-gray-900 dark:text-gray-100",W[n]),children:S}),a&&!l?(0,e.jsxs)("span",{className:(0,s.cn)("flex items-center gap-1 text-xs font-medium",B(g,a.goodWhen??"up")),children:[(0,e.jsx)(M,{direction:g}),b,a.period?(0,e.jsx)("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:a.period}):null]}):null]}),i&&i.length>0&&!l?(0,e.jsx)(f.Sparkline,{data:i,color:x,emphasizeLast:!0,area:!0,width:p[n].width,height:p[n].height,className:"shrink-0"}):null]}),u?(0,e.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:u}):null]})}0&&(module.exports={StatCard});
@@ -1 +1 @@
1
- import{cn as n}from"../../lib/cn.js";import{formatAuto as S,formatPercent as b}from"../chart/utils/format.js";import{CircularProgress as w}from"../circular-progress/CircularProgress.js";import{Sparkline as D}from"../sparkline/Sparkline.js";import{jsx as t,jsxs as o}from"react/jsx-runtime";var N={sm:"p-3",md:"p-4",lg:"p-5"},k={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},R={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},u={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function P(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function L(e,i){return e==="flat"||i==="neutral"?"text-gray-500 dark:text-gray-400":e===i?"text-green-700 dark:text-green-400":"text-red-600 dark:text-red-400"}function z({direction:e}){return e==="flat"?t("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:t("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):t("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:t("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function M({label:e,value:i,format:p,delta:r,trend:s,trendColor:g,icon:d,size:a="md",loading:l=!1,variant:h="card",footer:m,className:f,...x}){let C=typeof i=="number"?(p??S)(i):i,c=r?P(r):"flat",v=r?(r.format??(y=>b(y,{signed:!0})))(r.value):null;return o("div",{className:n("flex flex-col gap-2",h==="card"&&n("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",N[a]),f),...x,children:[o("div",{className:"flex items-start justify-between gap-2",children:[t("span",{className:n("font-medium text-gray-500 dark:text-gray-400",k[a]),children:e}),d?t("span",{className:"shrink-0 text-gray-400",children:d}):null]}),o("div",{className:"flex items-end justify-between gap-3",children:[o("div",{className:"flex min-w-0 flex-col gap-1",children:[l?t("div",{className:"flex items-center",style:{height:a==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:t(w,{indeterminate:!0,size:a==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):t("span",{className:n("leading-none font-semibold text-gray-900 dark:text-gray-100",R[a]),children:C}),r&&!l?o("span",{className:n("flex items-center gap-1 text-xs font-medium",L(c,r.goodWhen??"up")),children:[t(z,{direction:c}),v,r.period?t("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:r.period}):null]}):null]}),s&&s.length>0&&!l?t(D,{data:s,color:g,emphasizeLast:!0,area:!0,width:u[a].width,height:u[a].height,className:"shrink-0"}):null]}),m?t("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null]})}export{M as StatCard};
1
+ import{cn as n}from"../../lib/cn.js";import{formatAuto as S,formatPercent as b}from"../chart/utils/format.js";import{CircularProgress as w}from"../circular-progress/CircularProgress.js";import{Sparkline as D}from"../sparkline/Sparkline.js";import{jsx as t,jsxs as o}from"react/jsx-runtime";var N={sm:"p-3",md:"p-4",lg:"p-5"},k={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},R={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},u={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function P(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function L(e,i){return e==="flat"||i==="neutral"?"text-gray-500 dark:text-gray-400":e===i?"text-green-700 dark:text-green-400":"text-red-600 dark:text-red-400"}function z({direction:e}){return e==="flat"?t("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:t("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):t("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:t("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function M({label:e,value:i,format:g,delta:r,trend:s,trendColor:p,icon:l,size:a="md",loading:d=!1,variant:h="card",footer:m,className:f,...x}){let C=typeof i=="number"?(g??S)(i):i,c=r?P(r):"flat",v=r?(r.format??(y=>b(y,{signed:!0})))(r.value):null;return o("div",{className:n("flex flex-col gap-2",h==="card"&&n("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",N[a]),f),...x,children:[o("div",{className:"flex items-start justify-between gap-2",children:[t("span",{className:n("font-medium text-gray-500 dark:text-gray-400",k[a]),children:e}),l?t("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:l}):null]}),o("div",{className:"flex items-end justify-between gap-3",children:[o("div",{className:"flex min-w-0 flex-col gap-1",children:[d?t("div",{className:"flex items-center",style:{height:a==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:t(w,{indeterminate:!0,size:a==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):t("span",{className:n("leading-none font-semibold text-gray-900 dark:text-gray-100",R[a]),children:C}),r&&!d?o("span",{className:n("flex items-center gap-1 text-xs font-medium",L(c,r.goodWhen??"up")),children:[t(z,{direction:c}),v,r.period?t("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:r.period}):null]}):null]}),s&&s.length>0&&!d?t(D,{data:s,color:p,emphasizeLast:!0,area:!0,width:u[a].width,height:u[a].height,className:"shrink-0"}):null]}),m?t("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null]})}export{M as StatCard};
@@ -1 +1 @@
1
- "use strict";"use client";var V=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var re=(t,e)=>{for(var n in e)V(t,n,{get:e[n],enumerable:!0})},ae=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ee(e))!te.call(t,i)&&i!==n&&V(t,i,{get:()=>e[i],enumerable:!(s=$(e,i))||s.enumerable});return t};var ie=t=>ae(V({},"__esModule",{value:!0}),t);var oe={};re(oe,{Wizard:()=>I,WizardActions:()=>J,WizardContent:()=>q,WizardNext:()=>D,WizardPanel:()=>U,WizardPrevious:()=>E,WizardSteps:()=>H,useWizard:()=>W});module.exports=ie(oe);var u=require("react"),o=require("../../lib/cn.cjs"),A=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),F=(0,u.createContext)(null);function W(){let t=(0,u.useContext)(F);if(!t)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return t}var B=(t,e,n)=>Math.max(e,Math.min(t,n)),j={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},x={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-700 text-white",bg:"bg-green-700",text:"text-green-700 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-gray-900",bg:"bg-amber-500",text:"text-amber-700 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function ne({className:t}){return(0,r.jsx)("svg",{className:t,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function I({steps:t,step:e,defaultStep:n=0,onStepChange:s,onComplete:i,orientation:c="horizontal",variant:l="default",size:p="md",color:d="primary",linear:g=!0,className:m,children:z}){let C=t.length,h=Math.max(0,C-1),N=e!==void 0,[P,R]=(0,u.useState)(()=>B(n,0,h)),a=B(N?e:P,0,h),[f,w]=(0,u.useState)(a);f<a&&w(a);let v=a<=0,y=a>=h,S=(0,u.useCallback)((b,M)=>{let L=B(b,0,h);L!==a&&(N||R(L),w(_=>Math.max(_,L)),s?.(L,{previous:a,direction:M}))},[a,N,h,s]),k=(0,u.useCallback)(b=>{let M=t[b];return!M||M.disabled?!1:g?b<=f:!0},[t,g,f]),K=(0,u.useCallback)(b=>{k(b)&&S(b,b>a?"jump":"backward")},[k,S,a]),Q=(0,u.useCallback)(()=>{if(y){i?.();return}S(a+1,"forward")},[y,i,S,a]),X=(0,u.useCallback)(()=>{v||S(a-1,"backward")},[v,S,a]),Y=(0,u.useCallback)(b=>t[b]?.error?"error":b===a?"active":b<a?"completed":"upcoming",[t,a]),Z={steps:t,activeStep:a,totalSteps:C,isFirstStep:v,isLastStep:y,orientation:c,variant:l,size:p,color:d,linear:g,goToStep:K,goNext:Q,goBack:X,getStepStatus:Y,isStepAccessible:k};return(0,r.jsx)(F.Provider,{value:Z,children:(0,r.jsx)("div",{className:(0,o.cn)("flex w-full flex-col gap-6",m),"data-testid":"wizard","data-orientation":c,children:z})})}function O({index:t,status:e}){let{variant:n,size:s,color:i,steps:c}=W(),l=j[s],p=c[t];if(n==="dots"){let m=e==="upcoming"?"bg-gray-300 dark:bg-gray-600":e==="error"?"bg-red-600":x[i].bg;return(0,r.jsx)("span",{className:(0,o.cn)("shrink-0 rounded-full transition-colors",l.dot,m),"aria-hidden":"true"})}let d=e==="completed"?(0,o.cn)(x[i].solid,"border-transparent"):e==="active"?(0,o.cn)(x[i].solid,"border-transparent ring-4",x[i].ringSoft):e==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",g=e==="completed"?(0,r.jsx)(ne,{className:l.icon}):e==="error"?(0,r.jsx)("span",{className:"font-semibold leading-none",children:"!"}):p.icon??(0,r.jsx)("span",{className:"font-medium leading-none",children:t+1});return(0,r.jsx)("span",{className:(0,o.cn)("flex shrink-0 items-center justify-center rounded-full transition-all",l.circle,d),"aria-hidden":"true",children:g})}function T({index:t,status:e,optionalLabel:n}){let{steps:s,size:i,color:c,variant:l}=W(),p=j[i],d=s[t],m=e==="active"?x[c].text:e==="completed"?"text-gray-900 dark:text-gray-100":e==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return(0,r.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,r.jsxs)("span",{className:(0,o.cn)("font-medium leading-tight",p.title,m),children:[l==="simple"&&(0,r.jsxs)("span",{className:"mr-1 tabular-nums",children:[t+1,"."]}),d.title,d.optional&&(0,r.jsx)("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:n})]}),d.description&&(0,r.jsx)("span",{className:(0,o.cn)("mt-0.5 text-gray-400 dark:text-gray-500",p.desc),children:d.description})]})}function H({className:t,hideConnector:e=!1,hideLabels:n=!1,optionalLabel:s}){let i=W(),c=(0,A.useUILabels)(),l=s??c.wizardOptional,{steps:p,orientation:d,size:g,variant:m,color:z,activeStep:C}=i,h=j[g],N=d==="vertical",P=m!=="simple";return(0,r.jsx)("ol",{className:(0,o.cn)("flex w-full",N?"flex-col":"items-start",t),"data-testid":"wizard-steps","data-orientation":d,children:p.map((R,a)=>{let f=i.getStepStatus(a),w=a===C,v=i.isStepAccessible(a)&&!w,y=a===p.length-1,k=a<C?x[z].bg:"bg-gray-200 dark:bg-gray-700";return N?(0,r.jsx)("li",{className:"flex","aria-current":w?"step":void 0,"data-status":f,"data-testid":"wizard-step",children:(0,r.jsxs)("button",{type:"button",disabled:!v,onClick:()=>i.goToStep(a),className:(0,o.cn)("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",x[z].ring,v?"cursor-pointer":"cursor-default"),children:[(0,r.jsxs)("span",{className:"flex flex-col items-center",children:[P&&(0,r.jsx)(O,{index:a,status:f}),!e&&!y&&(0,r.jsx)("span",{className:(0,o.cn)("my-1 w-0.5 flex-1 rounded",k),"aria-hidden":"true"})]}),!n&&(0,r.jsx)("span",{className:(0,o.cn)(y?"pb-0":"pb-6"),children:(0,r.jsx)(T,{index:a,status:f,optionalLabel:l})})]})},R.id??a):(0,r.jsxs)("li",{className:(0,o.cn)("flex items-center",!y&&"flex-1"),"aria-current":w?"step":void 0,"data-status":f,"data-testid":"wizard-step",children:[(0,r.jsxs)("button",{type:"button",disabled:!v,onClick:()=>i.goToStep(a),className:(0,o.cn)("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",x[z].ring,v?"cursor-pointer":"cursor-default"),children:[P&&(0,r.jsx)(O,{index:a,status:f}),!n&&(0,r.jsx)(T,{index:a,status:f,optionalLabel:l})]}),!e&&!y&&(0,r.jsx)("span",{className:(0,o.cn)("mx-2 flex-1 rounded",h.connector,k),"aria-hidden":"true"})]},R.id??a)})})}function U({index:t,keepMounted:e=!1,className:n,children:s}){let{activeStep:i}=W(),c=t===i;return!c&&!e?null:(0,r.jsx)("div",{role:"tabpanel",hidden:!c,"data-testid":"wizard-panel","data-active":c,"data-step":t,className:(0,o.cn)("w-full",n),children:s})}function q({className:t,children:e}){let n=W();return(0,r.jsx)("div",{className:(0,o.cn)("w-full",t),"data-testid":"wizard-content",children:typeof e=="function"?e(n):e})}var G="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function E({children:t,label:e,className:n,onClick:s,disabled:i,...c}){let{goBack:l,isFirstStep:p}=W(),d=(0,A.useUILabels)();return(0,r.jsx)("button",{type:"button",onClick:m=>{s?.(m),m.defaultPrevented||l()},disabled:i??p,"data-testid":"wizard-previous",className:(0,o.cn)(G,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",n),...c,children:t??e??d.wizardPrevious})}function D({children:t,label:e,finishLabel:n,className:s,onClick:i,...c}){let{goNext:l,isLastStep:p,color:d}=W(),g=(0,A.useUILabels)();return(0,r.jsx)("button",{type:"button",onClick:z=>{i?.(z),z.defaultPrevented||l()},"data-testid":"wizard-next",className:(0,o.cn)(G,x[d].solid,x[d].ring,"hover:opacity-90",s),...c,children:t??(p?n??g.wizardFinish:e??g.wizardNext)})}function J({className:t,children:e,align:n="between"}){let s={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[n];return(0,r.jsx)("div",{className:(0,o.cn)("flex items-center gap-3",s,t),"data-testid":"wizard-actions",children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{}),(0,r.jsx)(D,{})]})})}I.displayName="Wizard";H.displayName="WizardSteps";U.displayName="WizardPanel";q.displayName="WizardContent";J.displayName="WizardActions";E.displayName="WizardPrevious";D.displayName="WizardNext";0&&(module.exports={Wizard,WizardActions,WizardContent,WizardNext,WizardPanel,WizardPrevious,WizardSteps,useWizard});
1
+ "use strict";"use client";var V=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var re=(t,e)=>{for(var n in e)V(t,n,{get:e[n],enumerable:!0})},ae=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ee(e))!te.call(t,i)&&i!==n&&V(t,i,{get:()=>e[i],enumerable:!(s=$(e,i))||s.enumerable});return t};var ie=t=>ae(V({},"__esModule",{value:!0}),t);var oe={};re(oe,{Wizard:()=>I,WizardActions:()=>J,WizardContent:()=>q,WizardNext:()=>D,WizardPanel:()=>U,WizardPrevious:()=>E,WizardSteps:()=>H,useWizard:()=>W});module.exports=ie(oe);var u=require("react"),o=require("../../lib/cn.cjs"),A=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),F=(0,u.createContext)(null);function W(){let t=(0,u.useContext)(F);if(!t)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return t}var B=(t,e,n)=>Math.max(e,Math.min(t,n)),j={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},x={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-700 text-white",bg:"bg-green-700",text:"text-green-700 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-gray-900",bg:"bg-amber-500",text:"text-amber-700 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function ne({className:t}){return(0,r.jsx)("svg",{className:t,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function I({steps:t,step:e,defaultStep:n=0,onStepChange:s,onComplete:i,orientation:c="horizontal",variant:l="default",size:p="md",color:d="primary",linear:g=!0,className:m,children:z}){let C=t.length,h=Math.max(0,C-1),N=e!==void 0,[P,R]=(0,u.useState)(()=>B(n,0,h)),a=B(N?e:P,0,h),[f,w]=(0,u.useState)(a);f<a&&w(a);let v=a<=0,y=a>=h,S=(0,u.useCallback)((b,M)=>{let L=B(b,0,h);L!==a&&(N||R(L),w(_=>Math.max(_,L)),s?.(L,{previous:a,direction:M}))},[a,N,h,s]),k=(0,u.useCallback)(b=>{let M=t[b];return!M||M.disabled?!1:g?b<=f:!0},[t,g,f]),K=(0,u.useCallback)(b=>{k(b)&&S(b,b>a?"jump":"backward")},[k,S,a]),Q=(0,u.useCallback)(()=>{if(y){i?.();return}S(a+1,"forward")},[y,i,S,a]),X=(0,u.useCallback)(()=>{v||S(a-1,"backward")},[v,S,a]),Y=(0,u.useCallback)(b=>t[b]?.error?"error":b===a?"active":b<a?"completed":"upcoming",[t,a]),Z={steps:t,activeStep:a,totalSteps:C,isFirstStep:v,isLastStep:y,orientation:c,variant:l,size:p,color:d,linear:g,goToStep:K,goNext:Q,goBack:X,getStepStatus:Y,isStepAccessible:k};return(0,r.jsx)(F.Provider,{value:Z,children:(0,r.jsx)("div",{className:(0,o.cn)("flex w-full flex-col gap-6",m),"data-testid":"wizard","data-orientation":c,children:z})})}function O({index:t,status:e}){let{variant:n,size:s,color:i,steps:c}=W(),l=j[s],p=c[t];if(n==="dots"){let m=e==="upcoming"?"bg-gray-300 dark:bg-gray-600":e==="error"?"bg-red-600":x[i].bg;return(0,r.jsx)("span",{className:(0,o.cn)("shrink-0 rounded-full transition-colors",l.dot,m),"aria-hidden":"true"})}let d=e==="completed"?(0,o.cn)(x[i].solid,"border-transparent"):e==="active"?(0,o.cn)(x[i].solid,"border-transparent ring-4",x[i].ringSoft):e==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",g=e==="completed"?(0,r.jsx)(ne,{className:l.icon}):e==="error"?(0,r.jsx)("span",{className:"font-semibold leading-none",children:"!"}):p.icon??(0,r.jsx)("span",{className:"font-medium leading-none",children:t+1});return(0,r.jsx)("span",{className:(0,o.cn)("flex shrink-0 items-center justify-center rounded-full transition-all",l.circle,d),"aria-hidden":"true",children:g})}function T({index:t,status:e,optionalLabel:n}){let{steps:s,size:i,color:c,variant:l}=W(),p=j[i],d=s[t],m=e==="active"?x[c].text:e==="completed"?"text-gray-900 dark:text-gray-100":e==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return(0,r.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,r.jsxs)("span",{className:(0,o.cn)("font-medium leading-tight",p.title,m),children:[l==="simple"&&(0,r.jsxs)("span",{className:"mr-1 tabular-nums",children:[t+1,"."]}),d.title,d.optional&&(0,r.jsx)("span",{className:"ml-1 text-xs font-normal text-gray-500 dark:text-gray-400",children:n})]}),d.description&&(0,r.jsx)("span",{className:(0,o.cn)("mt-0.5 text-gray-500 dark:text-gray-400",p.desc),children:d.description})]})}function H({className:t,hideConnector:e=!1,hideLabels:n=!1,optionalLabel:s}){let i=W(),c=(0,A.useUILabels)(),l=s??c.wizardOptional,{steps:p,orientation:d,size:g,variant:m,color:z,activeStep:C}=i,h=j[g],N=d==="vertical",P=m!=="simple";return(0,r.jsx)("ol",{className:(0,o.cn)("flex w-full",N?"flex-col":"items-start",t),"data-testid":"wizard-steps","data-orientation":d,children:p.map((R,a)=>{let f=i.getStepStatus(a),w=a===C,v=i.isStepAccessible(a)&&!w,y=a===p.length-1,k=a<C?x[z].bg:"bg-gray-200 dark:bg-gray-700";return N?(0,r.jsx)("li",{className:"flex","aria-current":w?"step":void 0,"data-status":f,"data-testid":"wizard-step",children:(0,r.jsxs)("button",{type:"button",disabled:!v,onClick:()=>i.goToStep(a),className:(0,o.cn)("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",x[z].ring,v?"cursor-pointer":"cursor-default"),children:[(0,r.jsxs)("span",{className:"flex flex-col items-center",children:[P&&(0,r.jsx)(O,{index:a,status:f}),!e&&!y&&(0,r.jsx)("span",{className:(0,o.cn)("my-1 w-0.5 flex-1 rounded",k),"aria-hidden":"true"})]}),!n&&(0,r.jsx)("span",{className:(0,o.cn)(y?"pb-0":"pb-6"),children:(0,r.jsx)(T,{index:a,status:f,optionalLabel:l})})]})},R.id??a):(0,r.jsxs)("li",{className:(0,o.cn)("flex items-center",!y&&"flex-1"),"aria-current":w?"step":void 0,"data-status":f,"data-testid":"wizard-step",children:[(0,r.jsxs)("button",{type:"button",disabled:!v,onClick:()=>i.goToStep(a),className:(0,o.cn)("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",x[z].ring,v?"cursor-pointer":"cursor-default"),children:[P&&(0,r.jsx)(O,{index:a,status:f}),!n&&(0,r.jsx)(T,{index:a,status:f,optionalLabel:l})]}),!e&&!y&&(0,r.jsx)("span",{className:(0,o.cn)("mx-2 flex-1 rounded",h.connector,k),"aria-hidden":"true"})]},R.id??a)})})}function U({index:t,keepMounted:e=!1,className:n,children:s}){let{activeStep:i}=W(),c=t===i;return!c&&!e?null:(0,r.jsx)("div",{role:"tabpanel",hidden:!c,"data-testid":"wizard-panel","data-active":c,"data-step":t,className:(0,o.cn)("w-full",n),children:s})}function q({className:t,children:e}){let n=W();return(0,r.jsx)("div",{className:(0,o.cn)("w-full",t),"data-testid":"wizard-content",children:typeof e=="function"?e(n):e})}var G="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function E({children:t,label:e,className:n,onClick:s,disabled:i,...c}){let{goBack:l,isFirstStep:p}=W(),d=(0,A.useUILabels)();return(0,r.jsx)("button",{type:"button",onClick:m=>{s?.(m),m.defaultPrevented||l()},disabled:i??p,"data-testid":"wizard-previous",className:(0,o.cn)(G,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",n),...c,children:t??e??d.wizardPrevious})}function D({children:t,label:e,finishLabel:n,className:s,onClick:i,...c}){let{goNext:l,isLastStep:p,color:d}=W(),g=(0,A.useUILabels)();return(0,r.jsx)("button",{type:"button",onClick:z=>{i?.(z),z.defaultPrevented||l()},"data-testid":"wizard-next",className:(0,o.cn)(G,x[d].solid,x[d].ring,"hover:opacity-90",s),...c,children:t??(p?n??g.wizardFinish:e??g.wizardNext)})}function J({className:t,children:e,align:n="between"}){let s={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[n];return(0,r.jsx)("div",{className:(0,o.cn)("flex items-center gap-3",s,t),"data-testid":"wizard-actions",children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{}),(0,r.jsx)(D,{})]})})}I.displayName="Wizard";H.displayName="WizardSteps";U.displayName="WizardPanel";q.displayName="WizardContent";J.displayName="WizardActions";E.displayName="WizardPrevious";D.displayName="WizardNext";0&&(module.exports={Wizard,WizardActions,WizardContent,WizardNext,WizardPanel,WizardPrevious,WizardSteps,useWizard});
@@ -1 +1 @@
1
- "use client";import{createContext as X,useCallback as C,useContext as Y,useState as E}from"react";import{cn as o}from"../../lib/cn.js";import{useUILabels as B}from"../../lib/i18n.js";import{Fragment as ae,jsx as a,jsxs as y}from"react/jsx-runtime";var T=X(null);function S(){let e=Y(T);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var V=(e,r,n)=>Math.max(r,Math.min(e,n)),j={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},f={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-700 text-white",bg:"bg-green-700",text:"text-green-700 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-gray-900",bg:"bg-amber-500",text:"text-amber-700 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function Z({className:e}){return a("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:a("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function _({steps:e,step:r,defaultStep:n=0,onStepChange:s,onComplete:i,orientation:c="horizontal",variant:l="default",size:u="md",color:d="primary",linear:p=!0,className:b,children:x}){let P=e.length,W=Math.max(0,P-1),N=r!==void 0,[R,M]=E(()=>V(n,0,W)),t=V(N?r:R,0,W),[m,w]=E(t);m<t&&w(t);let z=t<=0,v=t>=W,h=C((g,L)=>{let A=V(g,0,W);A!==t&&(N||M(A),w(Q=>Math.max(Q,A)),s?.(A,{previous:t,direction:L}))},[t,N,W,s]),k=C(g=>{let L=e[g];return!L||L.disabled?!1:p?g<=m:!0},[e,p,m]),U=C(g=>{k(g)&&h(g,g>t?"jump":"backward")},[k,h,t]),q=C(()=>{if(v){i?.();return}h(t+1,"forward")},[v,i,h,t]),G=C(()=>{z||h(t-1,"backward")},[z,h,t]),J=C(g=>e[g]?.error?"error":g===t?"active":g<t?"completed":"upcoming",[e,t]),K={steps:e,activeStep:t,totalSteps:P,isFirstStep:z,isLastStep:v,orientation:c,variant:l,size:u,color:d,linear:p,goToStep:U,goNext:q,goBack:G,getStepStatus:J,isStepAccessible:k};return a(T.Provider,{value:K,children:a("div",{className:o("flex w-full flex-col gap-6",b),"data-testid":"wizard","data-orientation":c,children:x})})}function D({index:e,status:r}){let{variant:n,size:s,color:i,steps:c}=S(),l=j[s],u=c[e];if(n==="dots"){let b=r==="upcoming"?"bg-gray-300 dark:bg-gray-600":r==="error"?"bg-red-600":f[i].bg;return a("span",{className:o("shrink-0 rounded-full transition-colors",l.dot,b),"aria-hidden":"true"})}let d=r==="completed"?o(f[i].solid,"border-transparent"):r==="active"?o(f[i].solid,"border-transparent ring-4",f[i].ringSoft):r==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",p=r==="completed"?a(Z,{className:l.icon}):r==="error"?a("span",{className:"font-semibold leading-none",children:"!"}):u.icon??a("span",{className:"font-medium leading-none",children:e+1});return a("span",{className:o("flex shrink-0 items-center justify-center rounded-full transition-all",l.circle,d),"aria-hidden":"true",children:p})}function O({index:e,status:r,optionalLabel:n}){let{steps:s,size:i,color:c,variant:l}=S(),u=j[i],d=s[e],b=r==="active"?f[c].text:r==="completed"?"text-gray-900 dark:text-gray-100":r==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return y("span",{className:"flex min-w-0 flex-col",children:[y("span",{className:o("font-medium leading-tight",u.title,b),children:[l==="simple"&&y("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),d.title,d.optional&&a("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:n})]}),d.description&&a("span",{className:o("mt-0.5 text-gray-400 dark:text-gray-500",u.desc),children:d.description})]})}function $({className:e,hideConnector:r=!1,hideLabels:n=!1,optionalLabel:s}){let i=S(),c=B(),l=s??c.wizardOptional,{steps:u,orientation:d,size:p,variant:b,color:x,activeStep:P}=i,W=j[p],N=d==="vertical",R=b!=="simple";return a("ol",{className:o("flex w-full",N?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":d,children:u.map((M,t)=>{let m=i.getStepStatus(t),w=t===P,z=i.isStepAccessible(t)&&!w,v=t===u.length-1,k=t<P?f[x].bg:"bg-gray-200 dark:bg-gray-700";return N?a("li",{className:"flex","aria-current":w?"step":void 0,"data-status":m,"data-testid":"wizard-step",children:y("button",{type:"button",disabled:!z,onClick:()=>i.goToStep(t),className:o("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",f[x].ring,z?"cursor-pointer":"cursor-default"),children:[y("span",{className:"flex flex-col items-center",children:[R&&a(D,{index:t,status:m}),!r&&!v&&a("span",{className:o("my-1 w-0.5 flex-1 rounded",k),"aria-hidden":"true"})]}),!n&&a("span",{className:o(v?"pb-0":"pb-6"),children:a(O,{index:t,status:m,optionalLabel:l})})]})},M.id??t):y("li",{className:o("flex items-center",!v&&"flex-1"),"aria-current":w?"step":void 0,"data-status":m,"data-testid":"wizard-step",children:[y("button",{type:"button",disabled:!z,onClick:()=>i.goToStep(t),className:o("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",f[x].ring,z?"cursor-pointer":"cursor-default"),children:[R&&a(D,{index:t,status:m}),!n&&a(O,{index:t,status:m,optionalLabel:l})]}),!r&&!v&&a("span",{className:o("mx-2 flex-1 rounded",W.connector,k),"aria-hidden":"true"})]},M.id??t)})})}function ee({index:e,keepMounted:r=!1,className:n,children:s}){let{activeStep:i}=S(),c=e===i;return!c&&!r?null:a("div",{role:"tabpanel",hidden:!c,"data-testid":"wizard-panel","data-active":c,"data-step":e,className:o("w-full",n),children:s})}function te({className:e,children:r}){let n=S();return a("div",{className:o("w-full",e),"data-testid":"wizard-content",children:typeof r=="function"?r(n):r})}var F="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function I({children:e,label:r,className:n,onClick:s,disabled:i,...c}){let{goBack:l,isFirstStep:u}=S(),d=B();return a("button",{type:"button",onClick:b=>{s?.(b),b.defaultPrevented||l()},disabled:i??u,"data-testid":"wizard-previous",className:o(F,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",n),...c,children:e??r??d.wizardPrevious})}function H({children:e,label:r,finishLabel:n,className:s,onClick:i,...c}){let{goNext:l,isLastStep:u,color:d}=S(),p=B();return a("button",{type:"button",onClick:x=>{i?.(x),x.defaultPrevented||l()},"data-testid":"wizard-next",className:o(F,f[d].solid,f[d].ring,"hover:opacity-90",s),...c,children:e??(u?n??p.wizardFinish:r??p.wizardNext)})}function re({className:e,children:r,align:n="between"}){let s={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[n];return a("div",{className:o("flex items-center gap-3",s,e),"data-testid":"wizard-actions",children:r??y(ae,{children:[a(I,{}),a(H,{})]})})}_.displayName="Wizard";$.displayName="WizardSteps";ee.displayName="WizardPanel";te.displayName="WizardContent";re.displayName="WizardActions";I.displayName="WizardPrevious";H.displayName="WizardNext";export{_ as Wizard,re as WizardActions,te as WizardContent,H as WizardNext,ee as WizardPanel,I as WizardPrevious,$ as WizardSteps,S as useWizard};
1
+ "use client";import{createContext as X,useCallback as C,useContext as Y,useState as E}from"react";import{cn as o}from"../../lib/cn.js";import{useUILabels as B}from"../../lib/i18n.js";import{Fragment as ae,jsx as a,jsxs as y}from"react/jsx-runtime";var T=X(null);function S(){let e=Y(T);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var V=(e,r,n)=>Math.max(r,Math.min(e,n)),j={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},f={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-700 text-white",bg:"bg-green-700",text:"text-green-700 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-gray-900",bg:"bg-amber-500",text:"text-amber-700 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function Z({className:e}){return a("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:a("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function _({steps:e,step:r,defaultStep:n=0,onStepChange:s,onComplete:i,orientation:c="horizontal",variant:l="default",size:u="md",color:d="primary",linear:p=!0,className:b,children:x}){let P=e.length,W=Math.max(0,P-1),N=r!==void 0,[R,M]=E(()=>V(n,0,W)),t=V(N?r:R,0,W),[m,w]=E(t);m<t&&w(t);let z=t<=0,v=t>=W,h=C((g,L)=>{let A=V(g,0,W);A!==t&&(N||M(A),w(Q=>Math.max(Q,A)),s?.(A,{previous:t,direction:L}))},[t,N,W,s]),k=C(g=>{let L=e[g];return!L||L.disabled?!1:p?g<=m:!0},[e,p,m]),U=C(g=>{k(g)&&h(g,g>t?"jump":"backward")},[k,h,t]),q=C(()=>{if(v){i?.();return}h(t+1,"forward")},[v,i,h,t]),G=C(()=>{z||h(t-1,"backward")},[z,h,t]),J=C(g=>e[g]?.error?"error":g===t?"active":g<t?"completed":"upcoming",[e,t]),K={steps:e,activeStep:t,totalSteps:P,isFirstStep:z,isLastStep:v,orientation:c,variant:l,size:u,color:d,linear:p,goToStep:U,goNext:q,goBack:G,getStepStatus:J,isStepAccessible:k};return a(T.Provider,{value:K,children:a("div",{className:o("flex w-full flex-col gap-6",b),"data-testid":"wizard","data-orientation":c,children:x})})}function D({index:e,status:r}){let{variant:n,size:s,color:i,steps:c}=S(),l=j[s],u=c[e];if(n==="dots"){let b=r==="upcoming"?"bg-gray-300 dark:bg-gray-600":r==="error"?"bg-red-600":f[i].bg;return a("span",{className:o("shrink-0 rounded-full transition-colors",l.dot,b),"aria-hidden":"true"})}let d=r==="completed"?o(f[i].solid,"border-transparent"):r==="active"?o(f[i].solid,"border-transparent ring-4",f[i].ringSoft):r==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",p=r==="completed"?a(Z,{className:l.icon}):r==="error"?a("span",{className:"font-semibold leading-none",children:"!"}):u.icon??a("span",{className:"font-medium leading-none",children:e+1});return a("span",{className:o("flex shrink-0 items-center justify-center rounded-full transition-all",l.circle,d),"aria-hidden":"true",children:p})}function O({index:e,status:r,optionalLabel:n}){let{steps:s,size:i,color:c,variant:l}=S(),u=j[i],d=s[e],b=r==="active"?f[c].text:r==="completed"?"text-gray-900 dark:text-gray-100":r==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return y("span",{className:"flex min-w-0 flex-col",children:[y("span",{className:o("font-medium leading-tight",u.title,b),children:[l==="simple"&&y("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),d.title,d.optional&&a("span",{className:"ml-1 text-xs font-normal text-gray-500 dark:text-gray-400",children:n})]}),d.description&&a("span",{className:o("mt-0.5 text-gray-500 dark:text-gray-400",u.desc),children:d.description})]})}function $({className:e,hideConnector:r=!1,hideLabels:n=!1,optionalLabel:s}){let i=S(),c=B(),l=s??c.wizardOptional,{steps:u,orientation:d,size:p,variant:b,color:x,activeStep:P}=i,W=j[p],N=d==="vertical",R=b!=="simple";return a("ol",{className:o("flex w-full",N?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":d,children:u.map((M,t)=>{let m=i.getStepStatus(t),w=t===P,z=i.isStepAccessible(t)&&!w,v=t===u.length-1,k=t<P?f[x].bg:"bg-gray-200 dark:bg-gray-700";return N?a("li",{className:"flex","aria-current":w?"step":void 0,"data-status":m,"data-testid":"wizard-step",children:y("button",{type:"button",disabled:!z,onClick:()=>i.goToStep(t),className:o("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",f[x].ring,z?"cursor-pointer":"cursor-default"),children:[y("span",{className:"flex flex-col items-center",children:[R&&a(D,{index:t,status:m}),!r&&!v&&a("span",{className:o("my-1 w-0.5 flex-1 rounded",k),"aria-hidden":"true"})]}),!n&&a("span",{className:o(v?"pb-0":"pb-6"),children:a(O,{index:t,status:m,optionalLabel:l})})]})},M.id??t):y("li",{className:o("flex items-center",!v&&"flex-1"),"aria-current":w?"step":void 0,"data-status":m,"data-testid":"wizard-step",children:[y("button",{type:"button",disabled:!z,onClick:()=>i.goToStep(t),className:o("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",f[x].ring,z?"cursor-pointer":"cursor-default"),children:[R&&a(D,{index:t,status:m}),!n&&a(O,{index:t,status:m,optionalLabel:l})]}),!r&&!v&&a("span",{className:o("mx-2 flex-1 rounded",W.connector,k),"aria-hidden":"true"})]},M.id??t)})})}function ee({index:e,keepMounted:r=!1,className:n,children:s}){let{activeStep:i}=S(),c=e===i;return!c&&!r?null:a("div",{role:"tabpanel",hidden:!c,"data-testid":"wizard-panel","data-active":c,"data-step":e,className:o("w-full",n),children:s})}function te({className:e,children:r}){let n=S();return a("div",{className:o("w-full",e),"data-testid":"wizard-content",children:typeof r=="function"?r(n):r})}var F="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function I({children:e,label:r,className:n,onClick:s,disabled:i,...c}){let{goBack:l,isFirstStep:u}=S(),d=B();return a("button",{type:"button",onClick:b=>{s?.(b),b.defaultPrevented||l()},disabled:i??u,"data-testid":"wizard-previous",className:o(F,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",n),...c,children:e??r??d.wizardPrevious})}function H({children:e,label:r,finishLabel:n,className:s,onClick:i,...c}){let{goNext:l,isLastStep:u,color:d}=S(),p=B();return a("button",{type:"button",onClick:x=>{i?.(x),x.defaultPrevented||l()},"data-testid":"wizard-next",className:o(F,f[d].solid,f[d].ring,"hover:opacity-90",s),...c,children:e??(u?n??p.wizardFinish:r??p.wizardNext)})}function re({className:e,children:r,align:n="between"}){let s={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[n];return a("div",{className:o("flex items-center gap-3",s,e),"data-testid":"wizard-actions",children:r??y(ae,{children:[a(I,{}),a(H,{})]})})}_.displayName="Wizard";$.displayName="WizardSteps";ee.displayName="WizardPanel";te.displayName="WizardContent";re.displayName="WizardActions";I.displayName="WizardPrevious";H.displayName="WizardNext";export{_ as Wizard,re as WizardActions,te as WizardContent,H as WizardNext,ee as WizardPanel,I as WizardPrevious,$ as WizardSteps,S as useWizard};
@@ -1 +1 @@
1
- "use strict";"use client";var lt=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ce=(v,R)=>{for(var N in R)lt(v,N,{get:R[N],enumerable:!0})},ie=(v,R,N,P)=>{if(R&&typeof R=="object"||typeof R=="function")for(let k of re(R))!se.call(v,k)&&k!==N&&lt(v,k,{get:()=>R[k],enumerable:!(P=ne(R,k))||P.enumerable});return v};var de=v=>ie(lt({},"__esModule",{value:!0}),v);var pe={};ce(pe,{WorkflowEditor:()=>Lt});module.exports=de(pe);var o=require("react"),Xt=require("../../lib/cn.cjs"),Yt=require("../../lib/i18n.cjs"),xt=require("./canvas/GridLayer.cjs"),zt=require("./nodes/WorkflowNodeRenderer.cjs"),St=require("./edges/WorkflowEdgeRenderer.cjs"),Vt=require("./toolbar/WorkflowToolbar.cjs"),l=require("./utils/geometry.cjs"),W=require("react/jsx-runtime"),at={x:0,y:0,zoom:1},pt=.1,fe=.1,ue=3,le=20;function Pt(){return`edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function ae({value:v,defaultValue:R,onValueChange:N,nodeRegistry:P,direction:k="horizontal",onDirectionChange:Ct,onNodeClick:$,onNodeDoubleClick:q,onNodeContextMenu:G,onNodeAction:U,readOnly:M=!1,disabled:a=!1,draggableNodes:Q=!0,connectable:mt=!0,selectable:C=!0,multiSelect:gt=!1,panOnDrag:wt=!0,zoomOnWheel:Et=!0,minZoom:X=fe,maxZoom:Y=ue,snapToGrid:yt=!1,gridSize:j=le,showGrid:At=!0,toolbar:bt=!0,autoFit:vt=!1,labels:_t,className:Ht},Ot){let Ut=(0,Yt.useUILabels)(_t),Z=v!==void 0,[Bt,Ft]=(0,o.useState)(()=>R??{nodes:[],edges:[],viewport:{...at}}),A=Z?v:Bt,E=A.nodes,b=A.edges,r=A.viewport??at,x=(0,o.useRef)(null),T=(0,o.useRef)(null),[S,V]=(0,o.useState)(new Set),[B,_]=(0,o.useState)(null),[h,H]=(0,o.useState)(null),tt=(0,o.useRef)(r);tt.current=r;let et=(0,o.useRef)(E);et.current=E;let kt=(0,o.useRef)(b);kt.current=b;let It=(0,o.useRef)(yt);It.current=yt;let ot=(0,o.useRef)(j);ot.current=j;let Dt=(0,o.useRef)(P);Dt.current=P;let F=(0,o.useRef)(k);F.current=k;let y=(0,o.useCallback)(t=>{Z?N?.(t(v)):Ft(e=>{let n=t(e);return N?.(n),n})},[Z,v,N]),nt=(0,o.useRef)(y);nt.current=y;let I=(0,o.useCallback)(t=>{y(e=>({...e,viewport:t}))},[y]),Wt=(0,o.useRef)(I);Wt.current=I;let z=(0,o.useCallback)(t=>{let e=P[t.type];return e?.getPorts?e.getPorts(t):t.ports??[]},[P]),J=(0,o.useRef)(z);J.current=z;let K=(0,o.useCallback)((t,e,n)=>{let s=et.current,p=kt.current,i=s.find(w=>w.id===t.fromNodeId),c=s.find(w=>w.id===e);if(!i||!c)return;let d=J.current(i),u=J.current(c),m=d.find(w=>w.id===t.fromPortId),g=u.find(w=>w.id===n);if(!m||!g||g.kind!=="in"||t.fromNodeId===e)return;let f=Dt.current[i.type];if(f?.canConnect&&!f.canConnect({fromNode:i,toNode:c,fromPort:m,toPort:g}))return;p.some(w=>w.from.nodeId===t.fromNodeId&&w.from.portId===t.fromPortId&&w.to.nodeId===e&&w.to.portId===n)||nt.current(w=>({...w,edges:[...w.edges,{id:Pt(),from:{nodeId:t.fromNodeId,portId:t.fromPortId},to:{nodeId:e,portId:n}}]}))},[]);(0,o.useEffect)(()=>{function t(n){let s=T.current;if(!s)return;let p=x.current?.getBoundingClientRect();if(!p)return;let i=tt.current;if(s.type==="pan"){let c=n.clientX-s.startX,d=n.clientY-s.startY;Wt.current({...i,x:s.startViewportX+c,y:s.startViewportY+d})}if(s.type==="node"){let c=(0,l.screenToCanvas)(n.clientX,n.clientY,i,p),d=c.x-s.offsetX,u=c.y-s.offsetY;It.current&&(d=(0,l.snapValue)(d,ot.current),u=(0,l.snapValue)(u,ot.current)),nt.current(m=>({...m,nodes:m.nodes.map(g=>g.id===s.nodeId?{...g,x:d,y:u}:g)}))}if(s.type==="edge"){let c=(0,l.screenToCanvas)(n.clientX,n.clientY,i,p);T.current={...s,currentX:c.x,currentY:c.y},H({fromX:s.fromX,fromY:s.fromY,currentX:c.x,currentY:c.y})}}function e(n){let s=T.current;if(s){if(s.type==="edge"){let p=x.current?.getBoundingClientRect();if(p){let i=tt.current,c=(0,l.screenToCanvas)(n.clientX,n.clientY,i,p),d=25,u=et.current,m=1/0,g=null,f=null;for(let D of u){let w=J.current(D);for(let ft of w){if(ft.kind!=="in")continue;let Nt=(0,l.getPortAbsolutePosition)(D,ft,w,F.current),ut=Math.sqrt((c.x-Nt.x)**2+(c.y-Nt.y)**2);ut<d&&ut<m&&(m=ut,g=D.id,f=ft.id)}}g&&f&&K(s,g,f)}H(null)}T.current=null}}return document.addEventListener("mousemove",t),document.addEventListener("mouseup",e),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",e)}},[K]);let Jt=(0,o.useCallback)(t=>{if(!Et||a)return;t.preventDefault();let e=x.current?.getBoundingClientRect();if(!e)return;let n=t.clientX-e.left,s=t.clientY-e.top,p=t.deltaY<0?1:-1,i=(0,l.clampZoom)(r.zoom+p*pt,X,Y),c=i/r.zoom;I({x:n-(n-r.x)*c,y:s-(s-r.y)*c,zoom:i})},[Et,a,r,X,Y,I]),Kt=(0,o.useCallback)(t=>{if(a)return;let e=t.target;if(e.closest("[data-action-id]"))return;let s=e.closest("[data-port-id]");if(s){if(!mt||M)return;t.preventDefault();let i=s.getAttribute("data-node-id"),c=s.getAttribute("data-port-id"),d=s.getAttribute("data-port-kind");if(!i||!c||d!=="out")return;let u=E.find(D=>D.id===i);if(!u)return;let m=z(u),g=m.find(D=>D.id===c);if(!g)return;let f=(0,l.getPortAbsolutePosition)(u,g,m,F.current);T.current={type:"edge",fromNodeId:i,fromPortId:c,fromX:f.x,fromY:f.y,currentX:f.x,currentY:f.y},H({fromX:f.x,fromY:f.y,currentX:f.x,currentY:f.y});return}let p=e.closest("[data-node-id]");if(p){if(M)return;let i=p.getAttribute("data-node-id");if(C&&(_(null),gt&&t.shiftKey?V(c=>{let d=new Set(c);return d.has(i)?d.delete(i):d.add(i),d}):V(new Set([i]))),Q){let c=x.current?.getBoundingClientRect();if(!c)return;let d=E.find(m=>m.id===i);if(!d||d.locked)return;let u=(0,l.screenToCanvas)(t.clientX,t.clientY,r,c);T.current={type:"node",nodeId:i,startX:u.x,startY:u.y,offsetX:u.x-d.x,offsetY:u.y-d.y}}return}C&&(V(new Set),_(null)),wt&&t.button===0&&(T.current={type:"pan",startX:t.clientX,startY:t.clientY,startViewportX:r.x,startViewportY:r.y})},[a,mt,M,C,gt,Q,wt,r,E,z]),$t=(0,o.useCallback)(t=>{let e=T.current;if(!e||e.type!=="edge")return;let n=x.current?.getBoundingClientRect();if(n){let s=(0,l.screenToCanvas)(t.clientX,t.clientY,r,n),p=30,i=1/0,c=null,d=null;for(let u of E){let m=z(u);for(let g of m){if(g.kind!=="in")continue;let f=(0,l.getPortAbsolutePosition)(u,g,m,F.current),D=Math.sqrt((s.x-f.x)**2+(s.y-f.y)**2);D<p&&D<i&&(i=D,c=u.id,d=g.id)}}if(c&&d){let u=e.fromNodeId,m=e.fromPortId;u!==c&&(b.some(f=>f.from.nodeId===u&&f.from.portId===m&&f.to.nodeId===c&&f.to.portId===d)||y(f=>({...f,edges:[...f.edges,{id:Pt(),from:{nodeId:u,portId:m},to:{nodeId:c,portId:d}}]})))}}T.current=null,H(null)},[r,E,b,z,y]),qt=(0,o.useCallback)((t,e)=>{let n=T.current;!n||n.type!=="edge"||(K(n,t,e),T.current=null,H(null))},[K]),L=(0,o.useCallback)(t=>{let e=t.target;if(e.closest("[data-port-id]")||e.closest("[data-action-id]"))return null;let p=e.closest("[data-node-id]");if(!p)return null;let i=p.getAttribute("data-node-id");return E.find(c=>c.id===i)??null},[E]),Gt=(0,o.useCallback)(t=>{if(!$||a)return;let e=L(t);e&&$({node:e,nativeEvent:t.nativeEvent})},[$,a,L]),Qt=(0,o.useCallback)(t=>{if(!q||a)return;let e=L(t);e&&q({node:e,nativeEvent:t.nativeEvent})},[q,a,L]),jt=(0,o.useCallback)(t=>{if(!G||a)return;let e=L(t);e&&(t.preventDefault(),G({node:e,nativeEvent:t.nativeEvent}))},[G,a,L]),Zt=(0,o.useCallback)((t,e,n)=>{if(!U||a)return;let s=E.find(p=>p.id===t);s&&U({node:s,actionId:e,nativeEvent:n})},[U,a,E]),te=(0,o.useCallback)((t,e)=>{!C||a||(e.stopPropagation(),V(new Set),_(t))},[C,a]),ee=(0,o.useCallback)(t=>{M||a||((t.key==="Delete"||t.key==="Backspace")&&(S.size>0&&(y(e=>({...e,nodes:e.nodes.filter(n=>!S.has(n.id)),edges:e.edges.filter(n=>!S.has(n.from.nodeId)&&!S.has(n.to.nodeId))})),V(new Set)),B&&(y(e=>({...e,edges:e.edges.filter(n=>n.id!==B)})),_(null))),t.key==="Escape"&&(V(new Set),_(null)))},[M,a,S,B,y]),rt=(0,o.useCallback)(()=>{let t=(0,l.clampZoom)(r.zoom+pt,X,Y);I({...r,zoom:t})},[r,X,Y,I]),st=(0,o.useCallback)(()=>{let t=(0,l.clampZoom)(r.zoom-pt,X,Y);I({...r,zoom:t})},[r,X,Y,I]),ct=(0,o.useCallback)(()=>{I({...at})},[I]),O=(0,o.useCallback)(()=>{let t=x.current?.getBoundingClientRect();if(!t)return;let e=(0,l.fitViewport)(E,t.width,t.height),n=(0,l.clampZoom)(e.zoom,X,Y);I({...e,zoom:n})},[E,X,Y,I]),Rt=(0,o.useCallback)(t=>{y(e=>({...e,nodes:[...e.nodes,t]}))},[y]),Tt=(0,o.useCallback)(t=>{y(e=>({...e,nodes:e.nodes.filter(n=>n.id!==t),edges:e.edges.filter(n=>n.from.nodeId!==t&&n.to.nodeId!==t)}))},[y]),it=(0,o.useCallback)(()=>JSON.stringify(A,null,2),[A]),dt=(0,o.useCallback)(t=>{try{let e=JSON.parse(t);e&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&y(()=>e)}catch{}},[y]);(0,o.useImperativeHandle)(Ot,()=>({zoomIn:rt,zoomOut:st,resetView:ct,fitToContent:O,addNode:Rt,removeNode:Tt,toJSON:it,loadJSON:dt}),[rt,st,ct,O,Rt,Tt,it,dt]);let Mt=(0,o.useRef)(!1);(0,o.useEffect)(()=>{vt&&!Mt.current&&x.current&&(Mt.current=!0,O())},[vt,O]);let ht=(0,o.useMemo)(()=>{let t=new Map;for(let e of E)t.set(e.id,z(e));return t},[E,z]),oe=(0,o.useMemo)(()=>({transform:`translate(${r.x}px, ${r.y}px) scale(${r.zoom})`,transformOrigin:"0 0"}),[r.x,r.y,r.zoom]);return(0,W.jsxs)("div",{ref:x,"data-testid":"workflow-editor",className:(0,Xt.cn)("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",a&&"opacity-60 pointer-events-none",Ht),tabIndex:0,onWheel:Jt,onMouseDown:Kt,onMouseUp:$t,onClick:Gt,onDoubleClick:Qt,onContextMenu:jt,onKeyDown:ee,children:[At&&(0,W.jsx)(xt.GridLayer,{gridSize:j,zoom:r.zoom}),bt&&!M&&(0,W.jsx)(Vt.WorkflowToolbar,{zoom:r.zoom,direction:k,onDirectionChange:Ct,onZoomIn:rt,onZoomOut:st,onResetView:ct,onFitToContent:O,onExportJSON:it,onImportJSON:dt,disabled:a,labels:Ut}),(0,W.jsxs)("div",{style:oe,children:[(0,W.jsx)(St.WorkflowEdgeRenderer,{edges:b,nodes:E,selectedEdgeId:B,disabled:a||M,direction:k,onEdgeClick:te,getNodePorts:t=>ht.get(t.id)??[]}),E.map(t=>{let e=P[t.type];if(!e)return null;let n=ht.get(t.id)??[];return(0,W.jsx)(zt.WorkflowNodeRenderer,{node:t,registry:e,ports:n,selected:S.has(t.id),disabled:a||M,draggable:Q&&!M,direction:k,onPortMouseUp:qt,onActionClick:U?Zt:void 0},t.id)})]}),h&&(0,W.jsxs)("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[(0,W.jsx)("path",{d:(0,l.computeBezierPath)(h.fromX*r.zoom+r.x,h.fromY*r.zoom+r.y,h.currentX*r.zoom+r.x,h.currentY*r.zoom+r.y,k),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),(0,W.jsx)("circle",{cx:h.fromX*r.zoom+r.x,cy:h.fromY*r.zoom+r.y,r:5,fill:"#3b82f6"}),(0,W.jsx)("circle",{cx:h.currentX*r.zoom+r.x,cy:h.currentY*r.zoom+r.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var Lt=(0,o.forwardRef)(ae);Lt.displayName="WorkflowEditor";0&&(module.exports={WorkflowEditor});
1
+ "use strict";"use client";var lt=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var ie=(v,T)=>{for(var N in T)lt(v,N,{get:T[N],enumerable:!0})},de=(v,T,N,P)=>{if(T&&typeof T=="object"||typeof T=="function")for(let k of se(T))!ce.call(v,k)&&k!==N&&lt(v,k,{get:()=>T[k],enumerable:!(P=re(T,k))||P.enumerable});return v};var fe=v=>de(lt({},"__esModule",{value:!0}),v);var me={};ie(me,{WorkflowEditor:()=>Ct});module.exports=fe(me);var o=require("react"),Yt=require("../../lib/cn.cjs"),mt=require("../../lib/editable-target.cjs"),xt=require("../../lib/i18n.cjs"),zt=require("./canvas/GridLayer.cjs"),St=require("./nodes/WorkflowNodeRenderer.cjs"),Vt=require("./edges/WorkflowEdgeRenderer.cjs"),Lt=require("./toolbar/WorkflowToolbar.cjs"),l=require("./utils/geometry.cjs"),W=require("react/jsx-runtime"),at={x:0,y:0,zoom:1},pt=.1,ue=.1,le=3,ae=20;function Xt(){return`edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function pe({value:v,defaultValue:T,onValueChange:N,nodeRegistry:P,direction:k="horizontal",onDirectionChange:At,onNodeClick:$,onNodeDoubleClick:q,onNodeContextMenu:G,onNodeAction:U,readOnly:M=!1,disabled:a=!1,draggableNodes:Q=!0,connectable:gt=!0,selectable:C=!0,multiSelect:wt=!1,panOnDrag:Et=!0,zoomOnWheel:yt=!0,minZoom:X=ue,maxZoom:Y=le,snapToGrid:vt=!1,gridSize:j=ae,showGrid:bt=!0,toolbar:_t=!0,autoFit:kt=!1,labels:Ht,className:Ot},Ut){let Bt=(0,xt.useUILabels)(Ht),Z=v!==void 0,[Ft,Jt]=(0,o.useState)(()=>T??{nodes:[],edges:[],viewport:{...at}}),A=Z?v:Ft,E=A.nodes,b=A.edges,r=A.viewport??at,x=(0,o.useRef)(null),R=(0,o.useRef)(null),[S,V]=(0,o.useState)(new Set),[B,_]=(0,o.useState)(null),[h,H]=(0,o.useState)(null),tt=(0,o.useRef)(r);tt.current=r;let et=(0,o.useRef)(E);et.current=E;let It=(0,o.useRef)(b);It.current=b;let Dt=(0,o.useRef)(vt);Dt.current=vt;let ot=(0,o.useRef)(j);ot.current=j;let Wt=(0,o.useRef)(P);Wt.current=P;let F=(0,o.useRef)(k);F.current=k;let y=(0,o.useCallback)(t=>{Z?N?.(t(v)):Jt(e=>{let n=t(e);return N?.(n),n})},[Z,v,N]),nt=(0,o.useRef)(y);nt.current=y;let I=(0,o.useCallback)(t=>{y(e=>({...e,viewport:t}))},[y]),Tt=(0,o.useRef)(I);Tt.current=I;let z=(0,o.useCallback)(t=>{let e=P[t.type];return e?.getPorts?e.getPorts(t):t.ports??[]},[P]),J=(0,o.useRef)(z);J.current=z;let K=(0,o.useCallback)((t,e,n)=>{let s=et.current,p=It.current,i=s.find(w=>w.id===t.fromNodeId),c=s.find(w=>w.id===e);if(!i||!c)return;let d=J.current(i),u=J.current(c),m=d.find(w=>w.id===t.fromPortId),g=u.find(w=>w.id===n);if(!m||!g||g.kind!=="in"||t.fromNodeId===e)return;let f=Wt.current[i.type];if(f?.canConnect&&!f.canConnect({fromNode:i,toNode:c,fromPort:m,toPort:g}))return;p.some(w=>w.from.nodeId===t.fromNodeId&&w.from.portId===t.fromPortId&&w.to.nodeId===e&&w.to.portId===n)||nt.current(w=>({...w,edges:[...w.edges,{id:Xt(),from:{nodeId:t.fromNodeId,portId:t.fromPortId},to:{nodeId:e,portId:n}}]}))},[]);(0,o.useEffect)(()=>{function t(n){let s=R.current;if(!s)return;let p=x.current?.getBoundingClientRect();if(!p)return;let i=tt.current;if(s.type==="pan"){let c=n.clientX-s.startX,d=n.clientY-s.startY;Tt.current({...i,x:s.startViewportX+c,y:s.startViewportY+d})}if(s.type==="node"){let c=(0,l.screenToCanvas)(n.clientX,n.clientY,i,p),d=c.x-s.offsetX,u=c.y-s.offsetY;Dt.current&&(d=(0,l.snapValue)(d,ot.current),u=(0,l.snapValue)(u,ot.current)),nt.current(m=>({...m,nodes:m.nodes.map(g=>g.id===s.nodeId?{...g,x:d,y:u}:g)}))}if(s.type==="edge"){let c=(0,l.screenToCanvas)(n.clientX,n.clientY,i,p);R.current={...s,currentX:c.x,currentY:c.y},H({fromX:s.fromX,fromY:s.fromY,currentX:c.x,currentY:c.y})}}function e(n){let s=R.current;if(s){if(s.type==="edge"){let p=x.current?.getBoundingClientRect();if(p){let i=tt.current,c=(0,l.screenToCanvas)(n.clientX,n.clientY,i,p),d=25,u=et.current,m=1/0,g=null,f=null;for(let D of u){let w=J.current(D);for(let ft of w){if(ft.kind!=="in")continue;let Pt=(0,l.getPortAbsolutePosition)(D,ft,w,F.current),ut=Math.sqrt((c.x-Pt.x)**2+(c.y-Pt.y)**2);ut<d&&ut<m&&(m=ut,g=D.id,f=ft.id)}}g&&f&&K(s,g,f)}H(null)}R.current=null}}return document.addEventListener("mousemove",t),document.addEventListener("mouseup",e),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",e)}},[K]);let Kt=(0,o.useCallback)(t=>{if(!yt||a)return;t.preventDefault();let e=x.current?.getBoundingClientRect();if(!e)return;let n=t.clientX-e.left,s=t.clientY-e.top,p=t.deltaY<0?1:-1,i=(0,l.clampZoom)(r.zoom+p*pt,X,Y),c=i/r.zoom;I({x:n-(n-r.x)*c,y:s-(s-r.y)*c,zoom:i})},[yt,a,r,X,Y,I]),$t=(0,o.useCallback)(t=>{if(a)return;let e=t.target;if(e.closest("[data-action-id]"))return;let s=e.closest("[data-port-id]");if(s){if(!gt||M)return;t.preventDefault();let i=s.getAttribute("data-node-id"),c=s.getAttribute("data-port-id"),d=s.getAttribute("data-port-kind");if(!i||!c||d!=="out")return;let u=E.find(D=>D.id===i);if(!u)return;let m=z(u),g=m.find(D=>D.id===c);if(!g)return;let f=(0,l.getPortAbsolutePosition)(u,g,m,F.current);R.current={type:"edge",fromNodeId:i,fromPortId:c,fromX:f.x,fromY:f.y,currentX:f.x,currentY:f.y},H({fromX:f.x,fromY:f.y,currentX:f.x,currentY:f.y});return}let p=e.closest("[data-node-id]");if(p){if(M)return;let i=p.getAttribute("data-node-id");if(C&&(_(null),wt&&t.shiftKey?V(c=>{let d=new Set(c);return d.has(i)?d.delete(i):d.add(i),d}):V(new Set([i]))),Q&&!(0,mt.isEditableTarget)(e)){let c=x.current?.getBoundingClientRect();if(!c)return;let d=E.find(m=>m.id===i);if(!d||d.locked)return;let u=(0,l.screenToCanvas)(t.clientX,t.clientY,r,c);R.current={type:"node",nodeId:i,startX:u.x,startY:u.y,offsetX:u.x-d.x,offsetY:u.y-d.y}}return}C&&(V(new Set),_(null)),Et&&t.button===0&&(R.current={type:"pan",startX:t.clientX,startY:t.clientY,startViewportX:r.x,startViewportY:r.y})},[a,gt,M,C,wt,Q,Et,r,E,z]),qt=(0,o.useCallback)(t=>{let e=R.current;if(!e||e.type!=="edge")return;let n=x.current?.getBoundingClientRect();if(n){let s=(0,l.screenToCanvas)(t.clientX,t.clientY,r,n),p=30,i=1/0,c=null,d=null;for(let u of E){let m=z(u);for(let g of m){if(g.kind!=="in")continue;let f=(0,l.getPortAbsolutePosition)(u,g,m,F.current),D=Math.sqrt((s.x-f.x)**2+(s.y-f.y)**2);D<p&&D<i&&(i=D,c=u.id,d=g.id)}}if(c&&d){let u=e.fromNodeId,m=e.fromPortId;u!==c&&(b.some(f=>f.from.nodeId===u&&f.from.portId===m&&f.to.nodeId===c&&f.to.portId===d)||y(f=>({...f,edges:[...f.edges,{id:Xt(),from:{nodeId:u,portId:m},to:{nodeId:c,portId:d}}]})))}}R.current=null,H(null)},[r,E,b,z,y]),Gt=(0,o.useCallback)((t,e)=>{let n=R.current;!n||n.type!=="edge"||(K(n,t,e),R.current=null,H(null))},[K]),L=(0,o.useCallback)(t=>{let e=t.target;if(e.closest("[data-port-id]")||e.closest("[data-action-id]"))return null;let p=e.closest("[data-node-id]");if(!p)return null;let i=p.getAttribute("data-node-id");return E.find(c=>c.id===i)??null},[E]),Qt=(0,o.useCallback)(t=>{if(!$||a)return;let e=L(t);e&&$({node:e,nativeEvent:t.nativeEvent})},[$,a,L]),jt=(0,o.useCallback)(t=>{if(!q||a)return;let e=L(t);e&&q({node:e,nativeEvent:t.nativeEvent})},[q,a,L]),Zt=(0,o.useCallback)(t=>{if(!G||a)return;let e=L(t);e&&(t.preventDefault(),G({node:e,nativeEvent:t.nativeEvent}))},[G,a,L]),te=(0,o.useCallback)((t,e,n)=>{if(!U||a)return;let s=E.find(p=>p.id===t);s&&U({node:s,actionId:e,nativeEvent:n})},[U,a,E]),ee=(0,o.useCallback)((t,e)=>{!C||a||(e.stopPropagation(),V(new Set),_(t))},[C,a]),oe=(0,o.useCallback)(t=>{if(!(M||a)){if(t.key==="Delete"||t.key==="Backspace"){if((0,mt.isEditableTarget)(t.target))return;S.size>0&&(y(e=>({...e,nodes:e.nodes.filter(n=>!S.has(n.id)),edges:e.edges.filter(n=>!S.has(n.from.nodeId)&&!S.has(n.to.nodeId))})),V(new Set)),B&&(y(e=>({...e,edges:e.edges.filter(n=>n.id!==B)})),_(null))}t.key==="Escape"&&(V(new Set),_(null))}},[M,a,S,B,y]),rt=(0,o.useCallback)(()=>{let t=(0,l.clampZoom)(r.zoom+pt,X,Y);I({...r,zoom:t})},[r,X,Y,I]),st=(0,o.useCallback)(()=>{let t=(0,l.clampZoom)(r.zoom-pt,X,Y);I({...r,zoom:t})},[r,X,Y,I]),ct=(0,o.useCallback)(()=>{I({...at})},[I]),O=(0,o.useCallback)(()=>{let t=x.current?.getBoundingClientRect();if(!t)return;let e=(0,l.fitViewport)(E,t.width,t.height),n=(0,l.clampZoom)(e.zoom,X,Y);I({...e,zoom:n})},[E,X,Y,I]),Rt=(0,o.useCallback)(t=>{y(e=>({...e,nodes:[...e.nodes,t]}))},[y]),Mt=(0,o.useCallback)(t=>{y(e=>({...e,nodes:e.nodes.filter(n=>n.id!==t),edges:e.edges.filter(n=>n.from.nodeId!==t&&n.to.nodeId!==t)}))},[y]),it=(0,o.useCallback)(()=>JSON.stringify(A,null,2),[A]),dt=(0,o.useCallback)(t=>{try{let e=JSON.parse(t);e&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&y(()=>e)}catch{}},[y]);(0,o.useImperativeHandle)(Ut,()=>({zoomIn:rt,zoomOut:st,resetView:ct,fitToContent:O,addNode:Rt,removeNode:Mt,toJSON:it,loadJSON:dt}),[rt,st,ct,O,Rt,Mt,it,dt]);let ht=(0,o.useRef)(!1);(0,o.useEffect)(()=>{kt&&!ht.current&&x.current&&(ht.current=!0,O())},[kt,O]);let Nt=(0,o.useMemo)(()=>{let t=new Map;for(let e of E)t.set(e.id,z(e));return t},[E,z]),ne=(0,o.useMemo)(()=>({transform:`translate(${r.x}px, ${r.y}px) scale(${r.zoom})`,transformOrigin:"0 0"}),[r.x,r.y,r.zoom]);return(0,W.jsxs)("div",{ref:x,"data-testid":"workflow-editor",className:(0,Yt.cn)("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",a&&"opacity-60 pointer-events-none",Ot),tabIndex:0,onWheel:Kt,onMouseDown:$t,onMouseUp:qt,onClick:Qt,onDoubleClick:jt,onContextMenu:Zt,onKeyDown:oe,children:[bt&&(0,W.jsx)(zt.GridLayer,{gridSize:j,zoom:r.zoom}),_t&&!M&&(0,W.jsx)(Lt.WorkflowToolbar,{zoom:r.zoom,direction:k,onDirectionChange:At,onZoomIn:rt,onZoomOut:st,onResetView:ct,onFitToContent:O,onExportJSON:it,onImportJSON:dt,disabled:a,labels:Bt}),(0,W.jsxs)("div",{style:ne,children:[(0,W.jsx)(Vt.WorkflowEdgeRenderer,{edges:b,nodes:E,selectedEdgeId:B,disabled:a||M,direction:k,onEdgeClick:ee,getNodePorts:t=>Nt.get(t.id)??[]}),E.map(t=>{let e=P[t.type];if(!e)return null;let n=Nt.get(t.id)??[];return(0,W.jsx)(St.WorkflowNodeRenderer,{node:t,registry:e,ports:n,selected:S.has(t.id),disabled:a||M,draggable:Q&&!M,direction:k,onPortMouseUp:Gt,onActionClick:U?te:void 0},t.id)})]}),h&&(0,W.jsxs)("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[(0,W.jsx)("path",{d:(0,l.computeBezierPath)(h.fromX*r.zoom+r.x,h.fromY*r.zoom+r.y,h.currentX*r.zoom+r.x,h.currentY*r.zoom+r.y,k),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),(0,W.jsx)("circle",{cx:h.fromX*r.zoom+r.x,cy:h.fromY*r.zoom+r.y,r:5,fill:"#3b82f6"}),(0,W.jsx)("circle",{cx:h.currentX*r.zoom+r.x,cy:h.currentY*r.zoom+r.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var Ct=(0,o.forwardRef)(pe);Ct.displayName="WorkflowEditor";0&&(module.exports={WorkflowEditor});
@@ -1 +1 @@
1
- "use client";import{forwardRef as ne,useCallback as u,useEffect as xt,useImperativeHandle as re,useMemo as zt,useRef as y,useState as K}from"react";import{cn as se}from"../../lib/cn.js";import{useUILabels as ce}from"../../lib/i18n.js";import{GridLayer as ie}from"./canvas/GridLayer.js";import{WorkflowNodeRenderer as de}from"./nodes/WorkflowNodeRenderer.js";import{WorkflowEdgeRenderer as fe}from"./edges/WorkflowEdgeRenderer.js";import{WorkflowToolbar as ue}from"./toolbar/WorkflowToolbar.js";import{clampZoom as $,computeBezierPath as le,fitViewport as ae,getPortAbsolutePosition as pt,screenToCanvas as _,snapValue as St}from"./utils/geometry.js";import{jsx as N,jsxs as wt}from"react/jsx-runtime";var mt={x:0,y:0,zoom:1},gt=.1,pe=.1,me=3,ge=20;function Vt(){return`edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function we({value:H,defaultValue:Lt,onValueChange:q,nodeRegistry:z,direction:P="horizontal",onDirectionChange:Ct,onNodeClick:G,onNodeDoubleClick:Q,onNodeContextMenu:j,onNodeAction:O,readOnly:D=!1,disabled:l=!1,draggableNodes:Z=!0,connectable:Et=!0,selectable:S=!0,multiSelect:yt=!1,panOnDrag:vt=!0,zoomOnWheel:kt=!0,minZoom:R=pe,maxZoom:T=me,snapToGrid:It=!1,gridSize:tt=ge,showGrid:At=!0,toolbar:bt=!0,autoFit:Dt=!1,labels:_t,className:Ht},Ot){let Ut=ce(_t),et=H!==void 0,[Bt,Ft]=K(()=>Lt??{nodes:[],edges:[],viewport:{...mt}}),V=et?H:Bt,w=V.nodes,L=V.edges,n=V.viewport??mt,M=y(null),I=y(null),[X,Y]=K(new Set),[U,C]=K(null),[W,A]=K(null),ot=y(n);ot.current=n;let nt=y(w);nt.current=w;let Wt=y(L);Wt.current=L;let Rt=y(It);Rt.current=It;let rt=y(tt);rt.current=tt;let Tt=y(z);Tt.current=z;let B=y(P);B.current=P;let E=u(t=>{et?q?.(t(H)):Ft(e=>{let o=t(e);return q?.(o),o})},[et,H,q]),st=y(E);st.current=E;let v=u(t=>{E(e=>({...e,viewport:t}))},[E]),Mt=y(v);Mt.current=v;let h=u(t=>{let e=z[t.type];return e?.getPorts?e.getPorts(t):t.ports??[]},[z]),F=y(h);F.current=h;let J=u((t,e,o)=>{let r=nt.current,a=Wt.current,c=r.find(g=>g.id===t.fromNodeId),s=r.find(g=>g.id===e);if(!c||!s)return;let i=F.current(c),f=F.current(s),p=i.find(g=>g.id===t.fromPortId),m=f.find(g=>g.id===o);if(!p||!m||m.kind!=="in"||t.fromNodeId===e)return;let d=Tt.current[c.type];if(d?.canConnect&&!d.canConnect({fromNode:c,toNode:s,fromPort:p,toPort:m}))return;a.some(g=>g.from.nodeId===t.fromNodeId&&g.from.portId===t.fromPortId&&g.to.nodeId===e&&g.to.portId===o)||st.current(g=>({...g,edges:[...g.edges,{id:Vt(),from:{nodeId:t.fromNodeId,portId:t.fromPortId},to:{nodeId:e,portId:o}}]}))},[]);xt(()=>{function t(o){let r=I.current;if(!r)return;let a=M.current?.getBoundingClientRect();if(!a)return;let c=ot.current;if(r.type==="pan"){let s=o.clientX-r.startX,i=o.clientY-r.startY;Mt.current({...c,x:r.startViewportX+s,y:r.startViewportY+i})}if(r.type==="node"){let s=_(o.clientX,o.clientY,c,a),i=s.x-r.offsetX,f=s.y-r.offsetY;Rt.current&&(i=St(i,rt.current),f=St(f,rt.current)),st.current(p=>({...p,nodes:p.nodes.map(m=>m.id===r.nodeId?{...m,x:i,y:f}:m)}))}if(r.type==="edge"){let s=_(o.clientX,o.clientY,c,a);I.current={...r,currentX:s.x,currentY:s.y},A({fromX:r.fromX,fromY:r.fromY,currentX:s.x,currentY:s.y})}}function e(o){let r=I.current;if(r){if(r.type==="edge"){let a=M.current?.getBoundingClientRect();if(a){let c=ot.current,s=_(o.clientX,o.clientY,c,a),i=25,f=nt.current,p=1/0,m=null,d=null;for(let k of f){let g=F.current(k);for(let lt of g){if(lt.kind!=="in")continue;let Yt=pt(k,lt,g,B.current),at=Math.sqrt((s.x-Yt.x)**2+(s.y-Yt.y)**2);at<i&&at<p&&(p=at,m=k.id,d=lt.id)}}m&&d&&J(r,m,d)}A(null)}I.current=null}}return document.addEventListener("mousemove",t),document.addEventListener("mouseup",e),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",e)}},[J]);let Jt=u(t=>{if(!kt||l)return;t.preventDefault();let e=M.current?.getBoundingClientRect();if(!e)return;let o=t.clientX-e.left,r=t.clientY-e.top,a=t.deltaY<0?1:-1,c=$(n.zoom+a*gt,R,T),s=c/n.zoom;v({x:o-(o-n.x)*s,y:r-(r-n.y)*s,zoom:c})},[kt,l,n,R,T,v]),Kt=u(t=>{if(l)return;let e=t.target;if(e.closest("[data-action-id]"))return;let r=e.closest("[data-port-id]");if(r){if(!Et||D)return;t.preventDefault();let c=r.getAttribute("data-node-id"),s=r.getAttribute("data-port-id"),i=r.getAttribute("data-port-kind");if(!c||!s||i!=="out")return;let f=w.find(k=>k.id===c);if(!f)return;let p=h(f),m=p.find(k=>k.id===s);if(!m)return;let d=pt(f,m,p,B.current);I.current={type:"edge",fromNodeId:c,fromPortId:s,fromX:d.x,fromY:d.y,currentX:d.x,currentY:d.y},A({fromX:d.x,fromY:d.y,currentX:d.x,currentY:d.y});return}let a=e.closest("[data-node-id]");if(a){if(D)return;let c=a.getAttribute("data-node-id");if(S&&(C(null),yt&&t.shiftKey?Y(s=>{let i=new Set(s);return i.has(c)?i.delete(c):i.add(c),i}):Y(new Set([c]))),Z){let s=M.current?.getBoundingClientRect();if(!s)return;let i=w.find(p=>p.id===c);if(!i||i.locked)return;let f=_(t.clientX,t.clientY,n,s);I.current={type:"node",nodeId:c,startX:f.x,startY:f.y,offsetX:f.x-i.x,offsetY:f.y-i.y}}return}S&&(Y(new Set),C(null)),vt&&t.button===0&&(I.current={type:"pan",startX:t.clientX,startY:t.clientY,startViewportX:n.x,startViewportY:n.y})},[l,Et,D,S,yt,Z,vt,n,w,h]),$t=u(t=>{let e=I.current;if(!e||e.type!=="edge")return;let o=M.current?.getBoundingClientRect();if(o){let r=_(t.clientX,t.clientY,n,o),a=30,c=1/0,s=null,i=null;for(let f of w){let p=h(f);for(let m of p){if(m.kind!=="in")continue;let d=pt(f,m,p,B.current),k=Math.sqrt((r.x-d.x)**2+(r.y-d.y)**2);k<a&&k<c&&(c=k,s=f.id,i=m.id)}}if(s&&i){let f=e.fromNodeId,p=e.fromPortId;f!==s&&(L.some(d=>d.from.nodeId===f&&d.from.portId===p&&d.to.nodeId===s&&d.to.portId===i)||E(d=>({...d,edges:[...d.edges,{id:Vt(),from:{nodeId:f,portId:p},to:{nodeId:s,portId:i}}]})))}}I.current=null,A(null)},[n,w,L,h,E]),qt=u((t,e)=>{let o=I.current;!o||o.type!=="edge"||(J(o,t,e),I.current=null,A(null))},[J]),x=u(t=>{let e=t.target;if(e.closest("[data-port-id]")||e.closest("[data-action-id]"))return null;let a=e.closest("[data-node-id]");if(!a)return null;let c=a.getAttribute("data-node-id");return w.find(s=>s.id===c)??null},[w]),Gt=u(t=>{if(!G||l)return;let e=x(t);e&&G({node:e,nativeEvent:t.nativeEvent})},[G,l,x]),Qt=u(t=>{if(!Q||l)return;let e=x(t);e&&Q({node:e,nativeEvent:t.nativeEvent})},[Q,l,x]),jt=u(t=>{if(!j||l)return;let e=x(t);e&&(t.preventDefault(),j({node:e,nativeEvent:t.nativeEvent}))},[j,l,x]),Zt=u((t,e,o)=>{if(!O||l)return;let r=w.find(a=>a.id===t);r&&O({node:r,actionId:e,nativeEvent:o})},[O,l,w]),te=u((t,e)=>{!S||l||(e.stopPropagation(),Y(new Set),C(t))},[S,l]),ee=u(t=>{D||l||((t.key==="Delete"||t.key==="Backspace")&&(X.size>0&&(E(e=>({...e,nodes:e.nodes.filter(o=>!X.has(o.id)),edges:e.edges.filter(o=>!X.has(o.from.nodeId)&&!X.has(o.to.nodeId))})),Y(new Set)),U&&(E(e=>({...e,edges:e.edges.filter(o=>o.id!==U)})),C(null))),t.key==="Escape"&&(Y(new Set),C(null)))},[D,l,X,U,E]),ct=u(()=>{let t=$(n.zoom+gt,R,T);v({...n,zoom:t})},[n,R,T,v]),it=u(()=>{let t=$(n.zoom-gt,R,T);v({...n,zoom:t})},[n,R,T,v]),dt=u(()=>{v({...mt})},[v]),b=u(()=>{let t=M.current?.getBoundingClientRect();if(!t)return;let e=ae(w,t.width,t.height),o=$(e.zoom,R,T);v({...e,zoom:o})},[w,R,T,v]),ht=u(t=>{E(e=>({...e,nodes:[...e.nodes,t]}))},[E]),Nt=u(t=>{E(e=>({...e,nodes:e.nodes.filter(o=>o.id!==t),edges:e.edges.filter(o=>o.from.nodeId!==t&&o.to.nodeId!==t)}))},[E]),ft=u(()=>JSON.stringify(V,null,2),[V]),ut=u(t=>{try{let e=JSON.parse(t);e&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&E(()=>e)}catch{}},[E]);re(Ot,()=>({zoomIn:ct,zoomOut:it,resetView:dt,fitToContent:b,addNode:ht,removeNode:Nt,toJSON:ft,loadJSON:ut}),[ct,it,dt,b,ht,Nt,ft,ut]);let Pt=y(!1);xt(()=>{Dt&&!Pt.current&&M.current&&(Pt.current=!0,b())},[Dt,b]);let Xt=zt(()=>{let t=new Map;for(let e of w)t.set(e.id,h(e));return t},[w,h]),oe=zt(()=>({transform:`translate(${n.x}px, ${n.y}px) scale(${n.zoom})`,transformOrigin:"0 0"}),[n.x,n.y,n.zoom]);return wt("div",{ref:M,"data-testid":"workflow-editor",className:se("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",l&&"opacity-60 pointer-events-none",Ht),tabIndex:0,onWheel:Jt,onMouseDown:Kt,onMouseUp:$t,onClick:Gt,onDoubleClick:Qt,onContextMenu:jt,onKeyDown:ee,children:[At&&N(ie,{gridSize:tt,zoom:n.zoom}),bt&&!D&&N(ue,{zoom:n.zoom,direction:P,onDirectionChange:Ct,onZoomIn:ct,onZoomOut:it,onResetView:dt,onFitToContent:b,onExportJSON:ft,onImportJSON:ut,disabled:l,labels:Ut}),wt("div",{style:oe,children:[N(fe,{edges:L,nodes:w,selectedEdgeId:U,disabled:l||D,direction:P,onEdgeClick:te,getNodePorts:t=>Xt.get(t.id)??[]}),w.map(t=>{let e=z[t.type];if(!e)return null;let o=Xt.get(t.id)??[];return N(de,{node:t,registry:e,ports:o,selected:X.has(t.id),disabled:l||D,draggable:Z&&!D,direction:P,onPortMouseUp:qt,onActionClick:O?Zt:void 0},t.id)})]}),W&&wt("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[N("path",{d:le(W.fromX*n.zoom+n.x,W.fromY*n.zoom+n.y,W.currentX*n.zoom+n.x,W.currentY*n.zoom+n.y,P),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),N("circle",{cx:W.fromX*n.zoom+n.x,cy:W.fromY*n.zoom+n.y,r:5,fill:"#3b82f6"}),N("circle",{cx:W.currentX*n.zoom+n.x,cy:W.currentY*n.zoom+n.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var Ee=ne(we);Ee.displayName="WorkflowEditor";export{Ee as WorkflowEditor};
1
+ "use client";import{forwardRef as re,useCallback as u,useEffect as xt,useImperativeHandle as se,useMemo as zt,useRef as y,useState as K}from"react";import{cn as ce}from"../../lib/cn.js";import{isEditableTarget as St}from"../../lib/editable-target.js";import{useUILabels as ie}from"../../lib/i18n.js";import{GridLayer as de}from"./canvas/GridLayer.js";import{WorkflowNodeRenderer as fe}from"./nodes/WorkflowNodeRenderer.js";import{WorkflowEdgeRenderer as ue}from"./edges/WorkflowEdgeRenderer.js";import{WorkflowToolbar as le}from"./toolbar/WorkflowToolbar.js";import{clampZoom as $,computeBezierPath as ae,fitViewport as pe,getPortAbsolutePosition as pt,screenToCanvas as _,snapValue as Vt}from"./utils/geometry.js";import{jsx as N,jsxs as wt}from"react/jsx-runtime";var mt={x:0,y:0,zoom:1},gt=.1,me=.1,ge=3,we=20;function Lt(){return`edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ee({value:H,defaultValue:Ct,onValueChange:q,nodeRegistry:z,direction:P="horizontal",onDirectionChange:At,onNodeClick:G,onNodeDoubleClick:Q,onNodeContextMenu:j,onNodeAction:O,readOnly:D=!1,disabled:l=!1,draggableNodes:Z=!0,connectable:Et=!0,selectable:S=!0,multiSelect:yt=!1,panOnDrag:vt=!0,zoomOnWheel:kt=!0,minZoom:T=me,maxZoom:R=ge,snapToGrid:It=!1,gridSize:tt=we,showGrid:bt=!0,toolbar:_t=!0,autoFit:Dt=!1,labels:Ht,className:Ot},Ut){let Bt=ie(Ht),et=H!==void 0,[Ft,Jt]=K(()=>Ct??{nodes:[],edges:[],viewport:{...mt}}),V=et?H:Ft,w=V.nodes,L=V.edges,n=V.viewport??mt,M=y(null),I=y(null),[X,Y]=K(new Set),[U,C]=K(null),[W,A]=K(null),ot=y(n);ot.current=n;let nt=y(w);nt.current=w;let Wt=y(L);Wt.current=L;let Tt=y(It);Tt.current=It;let rt=y(tt);rt.current=tt;let Rt=y(z);Rt.current=z;let B=y(P);B.current=P;let E=u(t=>{et?q?.(t(H)):Jt(e=>{let o=t(e);return q?.(o),o})},[et,H,q]),st=y(E);st.current=E;let v=u(t=>{E(e=>({...e,viewport:t}))},[E]),Mt=y(v);Mt.current=v;let h=u(t=>{let e=z[t.type];return e?.getPorts?e.getPorts(t):t.ports??[]},[z]),F=y(h);F.current=h;let J=u((t,e,o)=>{let r=nt.current,a=Wt.current,c=r.find(g=>g.id===t.fromNodeId),s=r.find(g=>g.id===e);if(!c||!s)return;let i=F.current(c),f=F.current(s),p=i.find(g=>g.id===t.fromPortId),m=f.find(g=>g.id===o);if(!p||!m||m.kind!=="in"||t.fromNodeId===e)return;let d=Rt.current[c.type];if(d?.canConnect&&!d.canConnect({fromNode:c,toNode:s,fromPort:p,toPort:m}))return;a.some(g=>g.from.nodeId===t.fromNodeId&&g.from.portId===t.fromPortId&&g.to.nodeId===e&&g.to.portId===o)||st.current(g=>({...g,edges:[...g.edges,{id:Lt(),from:{nodeId:t.fromNodeId,portId:t.fromPortId},to:{nodeId:e,portId:o}}]}))},[]);xt(()=>{function t(o){let r=I.current;if(!r)return;let a=M.current?.getBoundingClientRect();if(!a)return;let c=ot.current;if(r.type==="pan"){let s=o.clientX-r.startX,i=o.clientY-r.startY;Mt.current({...c,x:r.startViewportX+s,y:r.startViewportY+i})}if(r.type==="node"){let s=_(o.clientX,o.clientY,c,a),i=s.x-r.offsetX,f=s.y-r.offsetY;Tt.current&&(i=Vt(i,rt.current),f=Vt(f,rt.current)),st.current(p=>({...p,nodes:p.nodes.map(m=>m.id===r.nodeId?{...m,x:i,y:f}:m)}))}if(r.type==="edge"){let s=_(o.clientX,o.clientY,c,a);I.current={...r,currentX:s.x,currentY:s.y},A({fromX:r.fromX,fromY:r.fromY,currentX:s.x,currentY:s.y})}}function e(o){let r=I.current;if(r){if(r.type==="edge"){let a=M.current?.getBoundingClientRect();if(a){let c=ot.current,s=_(o.clientX,o.clientY,c,a),i=25,f=nt.current,p=1/0,m=null,d=null;for(let k of f){let g=F.current(k);for(let lt of g){if(lt.kind!=="in")continue;let Yt=pt(k,lt,g,B.current),at=Math.sqrt((s.x-Yt.x)**2+(s.y-Yt.y)**2);at<i&&at<p&&(p=at,m=k.id,d=lt.id)}}m&&d&&J(r,m,d)}A(null)}I.current=null}}return document.addEventListener("mousemove",t),document.addEventListener("mouseup",e),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",e)}},[J]);let Kt=u(t=>{if(!kt||l)return;t.preventDefault();let e=M.current?.getBoundingClientRect();if(!e)return;let o=t.clientX-e.left,r=t.clientY-e.top,a=t.deltaY<0?1:-1,c=$(n.zoom+a*gt,T,R),s=c/n.zoom;v({x:o-(o-n.x)*s,y:r-(r-n.y)*s,zoom:c})},[kt,l,n,T,R,v]),$t=u(t=>{if(l)return;let e=t.target;if(e.closest("[data-action-id]"))return;let r=e.closest("[data-port-id]");if(r){if(!Et||D)return;t.preventDefault();let c=r.getAttribute("data-node-id"),s=r.getAttribute("data-port-id"),i=r.getAttribute("data-port-kind");if(!c||!s||i!=="out")return;let f=w.find(k=>k.id===c);if(!f)return;let p=h(f),m=p.find(k=>k.id===s);if(!m)return;let d=pt(f,m,p,B.current);I.current={type:"edge",fromNodeId:c,fromPortId:s,fromX:d.x,fromY:d.y,currentX:d.x,currentY:d.y},A({fromX:d.x,fromY:d.y,currentX:d.x,currentY:d.y});return}let a=e.closest("[data-node-id]");if(a){if(D)return;let c=a.getAttribute("data-node-id");if(S&&(C(null),yt&&t.shiftKey?Y(s=>{let i=new Set(s);return i.has(c)?i.delete(c):i.add(c),i}):Y(new Set([c]))),Z&&!St(e)){let s=M.current?.getBoundingClientRect();if(!s)return;let i=w.find(p=>p.id===c);if(!i||i.locked)return;let f=_(t.clientX,t.clientY,n,s);I.current={type:"node",nodeId:c,startX:f.x,startY:f.y,offsetX:f.x-i.x,offsetY:f.y-i.y}}return}S&&(Y(new Set),C(null)),vt&&t.button===0&&(I.current={type:"pan",startX:t.clientX,startY:t.clientY,startViewportX:n.x,startViewportY:n.y})},[l,Et,D,S,yt,Z,vt,n,w,h]),qt=u(t=>{let e=I.current;if(!e||e.type!=="edge")return;let o=M.current?.getBoundingClientRect();if(o){let r=_(t.clientX,t.clientY,n,o),a=30,c=1/0,s=null,i=null;for(let f of w){let p=h(f);for(let m of p){if(m.kind!=="in")continue;let d=pt(f,m,p,B.current),k=Math.sqrt((r.x-d.x)**2+(r.y-d.y)**2);k<a&&k<c&&(c=k,s=f.id,i=m.id)}}if(s&&i){let f=e.fromNodeId,p=e.fromPortId;f!==s&&(L.some(d=>d.from.nodeId===f&&d.from.portId===p&&d.to.nodeId===s&&d.to.portId===i)||E(d=>({...d,edges:[...d.edges,{id:Lt(),from:{nodeId:f,portId:p},to:{nodeId:s,portId:i}}]})))}}I.current=null,A(null)},[n,w,L,h,E]),Gt=u((t,e)=>{let o=I.current;!o||o.type!=="edge"||(J(o,t,e),I.current=null,A(null))},[J]),x=u(t=>{let e=t.target;if(e.closest("[data-port-id]")||e.closest("[data-action-id]"))return null;let a=e.closest("[data-node-id]");if(!a)return null;let c=a.getAttribute("data-node-id");return w.find(s=>s.id===c)??null},[w]),Qt=u(t=>{if(!G||l)return;let e=x(t);e&&G({node:e,nativeEvent:t.nativeEvent})},[G,l,x]),jt=u(t=>{if(!Q||l)return;let e=x(t);e&&Q({node:e,nativeEvent:t.nativeEvent})},[Q,l,x]),Zt=u(t=>{if(!j||l)return;let e=x(t);e&&(t.preventDefault(),j({node:e,nativeEvent:t.nativeEvent}))},[j,l,x]),te=u((t,e,o)=>{if(!O||l)return;let r=w.find(a=>a.id===t);r&&O({node:r,actionId:e,nativeEvent:o})},[O,l,w]),ee=u((t,e)=>{!S||l||(e.stopPropagation(),Y(new Set),C(t))},[S,l]),oe=u(t=>{if(!(D||l)){if(t.key==="Delete"||t.key==="Backspace"){if(St(t.target))return;X.size>0&&(E(e=>({...e,nodes:e.nodes.filter(o=>!X.has(o.id)),edges:e.edges.filter(o=>!X.has(o.from.nodeId)&&!X.has(o.to.nodeId))})),Y(new Set)),U&&(E(e=>({...e,edges:e.edges.filter(o=>o.id!==U)})),C(null))}t.key==="Escape"&&(Y(new Set),C(null))}},[D,l,X,U,E]),ct=u(()=>{let t=$(n.zoom+gt,T,R);v({...n,zoom:t})},[n,T,R,v]),it=u(()=>{let t=$(n.zoom-gt,T,R);v({...n,zoom:t})},[n,T,R,v]),dt=u(()=>{v({...mt})},[v]),b=u(()=>{let t=M.current?.getBoundingClientRect();if(!t)return;let e=pe(w,t.width,t.height),o=$(e.zoom,T,R);v({...e,zoom:o})},[w,T,R,v]),ht=u(t=>{E(e=>({...e,nodes:[...e.nodes,t]}))},[E]),Nt=u(t=>{E(e=>({...e,nodes:e.nodes.filter(o=>o.id!==t),edges:e.edges.filter(o=>o.from.nodeId!==t&&o.to.nodeId!==t)}))},[E]),ft=u(()=>JSON.stringify(V,null,2),[V]),ut=u(t=>{try{let e=JSON.parse(t);e&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&E(()=>e)}catch{}},[E]);se(Ut,()=>({zoomIn:ct,zoomOut:it,resetView:dt,fitToContent:b,addNode:ht,removeNode:Nt,toJSON:ft,loadJSON:ut}),[ct,it,dt,b,ht,Nt,ft,ut]);let Pt=y(!1);xt(()=>{Dt&&!Pt.current&&M.current&&(Pt.current=!0,b())},[Dt,b]);let Xt=zt(()=>{let t=new Map;for(let e of w)t.set(e.id,h(e));return t},[w,h]),ne=zt(()=>({transform:`translate(${n.x}px, ${n.y}px) scale(${n.zoom})`,transformOrigin:"0 0"}),[n.x,n.y,n.zoom]);return wt("div",{ref:M,"data-testid":"workflow-editor",className:ce("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",l&&"opacity-60 pointer-events-none",Ot),tabIndex:0,onWheel:Kt,onMouseDown:$t,onMouseUp:qt,onClick:Qt,onDoubleClick:jt,onContextMenu:Zt,onKeyDown:oe,children:[bt&&N(de,{gridSize:tt,zoom:n.zoom}),_t&&!D&&N(le,{zoom:n.zoom,direction:P,onDirectionChange:At,onZoomIn:ct,onZoomOut:it,onResetView:dt,onFitToContent:b,onExportJSON:ft,onImportJSON:ut,disabled:l,labels:Bt}),wt("div",{style:ne,children:[N(ue,{edges:L,nodes:w,selectedEdgeId:U,disabled:l||D,direction:P,onEdgeClick:ee,getNodePorts:t=>Xt.get(t.id)??[]}),w.map(t=>{let e=z[t.type];if(!e)return null;let o=Xt.get(t.id)??[];return N(fe,{node:t,registry:e,ports:o,selected:X.has(t.id),disabled:l||D,draggable:Z&&!D,direction:P,onPortMouseUp:Gt,onActionClick:O?te:void 0},t.id)})]}),W&&wt("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[N("path",{d:ae(W.fromX*n.zoom+n.x,W.fromY*n.zoom+n.y,W.currentX*n.zoom+n.x,W.currentY*n.zoom+n.y,P),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),N("circle",{cx:W.fromX*n.zoom+n.x,cy:W.fromY*n.zoom+n.y,r:5,fill:"#3b82f6"}),N("circle",{cx:W.currentX*n.zoom+n.x,cy:W.currentY*n.zoom+n.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var ye=re(Ee);ye.displayName="WorkflowEditor";export{ye as WorkflowEditor};
package/dist/index.d.cts CHANGED
@@ -5568,6 +5568,12 @@ type SchemaField = {
5568
5568
  unique?: boolean;
5569
5569
  indexed?: boolean;
5570
5570
  defaultValue?: string;
5571
+ /**
5572
+ * What the field references. The editor keeps it in step with `relations`:
5573
+ * drawing a relation writes it, and removing the relation, or the table or
5574
+ * the field it names, removes it. A key that names something that is gone
5575
+ * is ignored: no icon in the table, no constraint in the SQL.
5576
+ */
5571
5577
  foreignKey?: {
5572
5578
  tableId: string;
5573
5579
  fieldId: string;
@@ -5587,6 +5593,12 @@ type SchemaTable = {
5587
5593
  notes?: string;
5588
5594
  };
5589
5595
  type SchemaRelationCardinality = "1:1" | "1:n" | "n:1" | "n:n";
5596
+ /**
5597
+ * A line between two fields. The editor draws it from the referenced field
5598
+ * (`from`) to the field that holds the key (`to`). Written the other way
5599
+ * round it is read the same: the end whose `foreignKey` names the other one
5600
+ * holds the key and, when neither says so, the end that is not a primary key.
5601
+ */
5590
5602
  type SchemaRelation = {
5591
5603
  id: string;
5592
5604
  from: {
package/dist/index.d.ts CHANGED
@@ -5568,6 +5568,12 @@ type SchemaField = {
5568
5568
  unique?: boolean;
5569
5569
  indexed?: boolean;
5570
5570
  defaultValue?: string;
5571
+ /**
5572
+ * What the field references. The editor keeps it in step with `relations`:
5573
+ * drawing a relation writes it, and removing the relation, or the table or
5574
+ * the field it names, removes it. A key that names something that is gone
5575
+ * is ignored: no icon in the table, no constraint in the SQL.
5576
+ */
5571
5577
  foreignKey?: {
5572
5578
  tableId: string;
5573
5579
  fieldId: string;
@@ -5587,6 +5593,12 @@ type SchemaTable = {
5587
5593
  notes?: string;
5588
5594
  };
5589
5595
  type SchemaRelationCardinality = "1:1" | "1:n" | "n:1" | "n:n";
5596
+ /**
5597
+ * A line between two fields. The editor draws it from the referenced field
5598
+ * (`from`) to the field that holds the key (`to`). Written the other way
5599
+ * round it is read the same: the end whose `foreignKey` names the other one
5600
+ * holds the key and, when neither says so, the end that is not a primary key.
5601
+ */
5590
5602
  type SchemaRelation = {
5591
5603
  id: string;
5592
5604
  from: {
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var l in t)o(e,l,{get:t[l],enumerable:!0})},u=(e,t,l,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!i.call(e,n)&&n!==l&&o(e,n,{get:()=>t[n],enumerable:!(s=a(t,n))||s.enumerable});return e};var f=e=>u(o({},"__esModule",{value:!0}),e);var T={};E(T,{isEditableTarget:()=>b});module.exports=f(T);var r='input, textarea, select, [contenteditable]:not([contenteditable="false"])';function b(e){return!e||typeof e.closest!="function"?!1:e.closest(r)!==null}0&&(module.exports={isEditableTarget});
@@ -0,0 +1 @@
1
+ var t='input, textarea, select, [contenteditable]:not([contenteditable="false"])';function n(e){return!e||typeof e.closest!="function"?!1:e.closest(t)!==null}export{n as isEditableTarget};
package/dist/styles.css CHANGED
@@ -3584,12 +3584,12 @@
3584
3584
  -webkit-font-smoothing: antialiased;
3585
3585
  -moz-osx-font-smoothing: grayscale;
3586
3586
  }
3587
- .placeholder-gray-400 {
3587
+ .placeholder-gray-500 {
3588
3588
  &::-moz-placeholder {
3589
- color: var(--color-gray-400);
3589
+ color: var(--color-gray-500);
3590
3590
  }
3591
3591
  &::placeholder {
3592
- color: var(--color-gray-400);
3592
+ color: var(--color-gray-500);
3593
3593
  }
3594
3594
  }
3595
3595
  .opacity-0 {
@@ -4012,12 +4012,12 @@
4012
4012
  opacity: 100%;
4013
4013
  }
4014
4014
  }
4015
- .placeholder\:text-gray-400 {
4015
+ .placeholder\:text-gray-500 {
4016
4016
  &::-moz-placeholder {
4017
- color: var(--color-gray-400);
4017
+ color: var(--color-gray-500);
4018
4018
  }
4019
4019
  &::placeholder {
4020
- color: var(--color-gray-400);
4020
+ color: var(--color-gray-500);
4021
4021
  }
4022
4022
  }
4023
4023
  .last\:border-b-0 {
@@ -4026,11 +4026,11 @@
4026
4026
  border-bottom-width: 0px;
4027
4027
  }
4028
4028
  }
4029
- .empty\:before\:text-gray-400 {
4029
+ .empty\:before\:text-gray-500 {
4030
4030
  &:empty {
4031
4031
  &::before {
4032
4032
  content: var(--tw-content);
4033
- color: var(--color-gray-400);
4033
+ color: var(--color-gray-500);
4034
4034
  }
4035
4035
  }
4036
4036
  }
@@ -8356,13 +8356,13 @@
8356
8356
  }
8357
8357
  }
8358
8358
  }
8359
- .dark\:placeholder-gray-400 {
8359
+ .dark\:placeholder-gray-300 {
8360
8360
  &:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
8361
8361
  &::-moz-placeholder {
8362
- color: var(--color-gray-400);
8362
+ color: var(--color-gray-300);
8363
8363
  }
8364
8364
  &::placeholder {
8365
- color: var(--color-gray-400);
8365
+ color: var(--color-gray-300);
8366
8366
  }
8367
8367
  }
8368
8368
  @media (prefers-color-scheme: dark) {
@@ -8371,21 +8371,21 @@
8371
8371
  :root:not(.light):not([data-theme="light"]) *
8372
8372
  ) {
8373
8373
  &::-moz-placeholder {
8374
- color: var(--color-gray-400);
8374
+ color: var(--color-gray-300);
8375
8375
  }
8376
8376
  &::placeholder {
8377
- color: var(--color-gray-400);
8377
+ color: var(--color-gray-300);
8378
8378
  }
8379
8379
  }
8380
8380
  }
8381
8381
  }
8382
- .dark\:placeholder-gray-500 {
8382
+ .dark\:placeholder-gray-400 {
8383
8383
  &:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
8384
8384
  &::-moz-placeholder {
8385
- color: var(--color-gray-500);
8385
+ color: var(--color-gray-400);
8386
8386
  }
8387
8387
  &::placeholder {
8388
- color: var(--color-gray-500);
8388
+ color: var(--color-gray-400);
8389
8389
  }
8390
8390
  }
8391
8391
  @media (prefers-color-scheme: dark) {
@@ -8394,10 +8394,10 @@
8394
8394
  :root:not(.light):not([data-theme="light"]) *
8395
8395
  ) {
8396
8396
  &::-moz-placeholder {
8397
- color: var(--color-gray-500);
8397
+ color: var(--color-gray-400);
8398
8398
  }
8399
8399
  &::placeholder {
8400
- color: var(--color-gray-500);
8400
+ color: var(--color-gray-400);
8401
8401
  }
8402
8402
  }
8403
8403
  }
@@ -8495,13 +8495,13 @@
8495
8495
  }
8496
8496
  }
8497
8497
  }
8498
- .dark\:placeholder\:text-gray-500 {
8498
+ .dark\:placeholder\:text-gray-400 {
8499
8499
  &:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
8500
8500
  &::-moz-placeholder {
8501
- color: var(--color-gray-500);
8501
+ color: var(--color-gray-400);
8502
8502
  }
8503
8503
  &::placeholder {
8504
- color: var(--color-gray-500);
8504
+ color: var(--color-gray-400);
8505
8505
  }
8506
8506
  }
8507
8507
  @media (prefers-color-scheme: dark) {
@@ -8510,27 +8510,27 @@
8510
8510
  :root:not(.light):not([data-theme="light"]) *
8511
8511
  ) {
8512
8512
  &::-moz-placeholder {
8513
- color: var(--color-gray-500);
8513
+ color: var(--color-gray-400);
8514
8514
  }
8515
8515
  &::placeholder {
8516
- color: var(--color-gray-500);
8516
+ color: var(--color-gray-400);
8517
8517
  }
8518
8518
  }
8519
8519
  }
8520
8520
  }
8521
- .empty\:before\:dark\:text-gray-500 {
8521
+ .empty\:before\:dark\:text-gray-400 {
8522
8522
  &:empty {
8523
8523
  &::before {
8524
8524
  content: var(--tw-content);
8525
8525
  &:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
8526
- color: var(--color-gray-500);
8526
+ color: var(--color-gray-400);
8527
8527
  }
8528
8528
  @media (prefers-color-scheme: dark) {
8529
8529
  &:where(
8530
8530
  :root:not(.light):not([data-theme="light"]),
8531
8531
  :root:not(.light):not([data-theme="light"]) *
8532
8532
  ) {
8533
- color: var(--color-gray-500);
8533
+ color: var(--color-gray-400);
8534
8534
  }
8535
8535
  }
8536
8536
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synertech/ui",
3
- "version": "0.46.2",
3
+ "version": "0.46.3",
4
4
  "type": "module",
5
5
  "description": "Synertech UI component library",
6
6
  "main": "./dist/index.cjs",