treege 3.0.0-beta.8 → 3.0.0-beta40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -12
- package/README.md +213 -30
- package/dist/DefaultInputs-8yJMEyMh.js +1557 -0
- package/dist/ThemeContext-Ejgu9Mwr.js +1603 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- package/dist/editor/constants/defaultNode.d.ts +1 -1
- package/dist/editor/constants/edgeTypes.d.ts +3 -2
- package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
- package/dist/editor/constants/nodeSpacing.d.ts +33 -0
- package/dist/editor/constants/nodeTypes.d.ts +5 -5
- package/dist/editor/context/TreegeEditorContext.d.ts +53 -1
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
- package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +9 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
- package/dist/editor/hooks/useAutoLayout.d.ts +15 -0
- package/dist/editor/hooks/useFlowActions.d.ts +5 -2
- package/dist/editor/hooks/useFlowConnections.d.ts +4 -0
- package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
- package/dist/editor/types/ai.d.ts +65 -0
- package/dist/editor/types/editor.d.ts +9 -8
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
- package/dist/editor/utils/dagreLayout.d.ts +17 -0
- package/dist/editor/utils/edge.d.ts +14 -0
- package/dist/editor/utils/image.d.ts +7 -0
- package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
- package/dist/editor-DWJ95r4g.js +4001 -0
- package/dist/editor.js +3 -7
- package/dist/main.js +4 -52
- package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
- package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +7 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +84 -24
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
- package/dist/renderer/hooks/useRenderNode.d.ts +55 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
- package/dist/renderer/hooks/useTranslate.d.ts +6 -4
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer/index.native.d.ts +19 -0
- package/dist/renderer/types/renderer.d.ts +60 -6
- package/dist/renderer/utils/form.d.ts +22 -2
- package/dist/renderer/utils/http.d.ts +101 -0
- package/dist/renderer/utils/node.d.ts +18 -1
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer/utils/sanitize.native.d.ts +69 -0
- package/dist/renderer/utils/submit.d.ts +47 -0
- package/dist/renderer-native.d.ts +2 -0
- package/dist/renderer-native.js +3496 -0
- package/dist/renderer.js +3 -45
- package/dist/shared/components/ui/badge.d.ts +2 -2
- package/dist/shared/components/ui/button.d.ts +2 -2
- package/dist/shared/components/ui/collapsible.d.ts +1 -1
- package/dist/shared/components/ui/command.d.ts +1 -1
- package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
- package/dist/shared/components/ui/form.d.ts +1 -1
- package/dist/shared/components/ui/popover.d.ts +4 -2
- package/dist/shared/components/ui/select.d.ts +3 -1
- package/dist/shared/components/ui/sheet.d.ts +1 -1
- package/dist/shared/components/ui/tooltip.d.ts +1 -1
- package/dist/shared/constants/colors.d.ts +45 -0
- package/dist/shared/constants/inputType.d.ts +1 -0
- package/dist/shared/context/ThemeContext.d.ts +2 -0
- package/dist/shared/context/ThemeContext.native.d.ts +22 -0
- package/dist/shared/hooks/useThemeColors.d.ts +37 -0
- package/dist/shared/locales/ar.json.d.ts +117 -10
- package/dist/shared/locales/de.json.d.ts +118 -11
- package/dist/shared/locales/en.json.d.ts +119 -12
- package/dist/shared/locales/es.json.d.ts +118 -11
- package/dist/shared/locales/fr.json.d.ts +118 -11
- package/dist/shared/locales/it.json.d.ts +118 -11
- package/dist/shared/locales/pt.json.d.ts +118 -11
- package/dist/shared/types/edge.d.ts +6 -0
- package/dist/shared/types/node.d.ts +64 -0
- package/package.json +38 -12
- package/dist/ThemeContext-BIvs8Kw-.js +0 -758
- package/dist/TreegeEditor-Lv5Tn9_F.js +0 -2152
- package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
- package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
|
@@ -0,0 +1,4001 @@
|
|
|
1
|
+
import { A as e, E as t, F as n, I as r, L as i, N as a, P as o, T as s, j as c, k as l, t as u } from "./ThemeContext-Ejgu9Mwr.js";
|
|
2
|
+
import { $ as d, A as f, B as p, F as m, G as h, H as g, I as _, J as v, K as y, L as b, M as ee, N as te, P as x, Q as ne, R as S, U as C, V as re, W as w, X as ie, Y as T, Z as ae, _ as oe, at as E, c as D, et as O, it as k, j as se, k as ce, nt as A, o as le, p as ue, q as de, rt as fe, t as pe, tt as j, v as me, z as he } from "./DefaultInputs-8yJMEyMh.js";
|
|
3
|
+
import { Background as ge, BackgroundVariant as _e, BaseEdge as ve, Controls as ye, EdgeLabelRenderer as be, Handle as xe, MiniMap as Se, NodeResizer as Ce, Panel as we, Position as Te, ReactFlow as Ee, ReactFlowProvider as De, addEdge as Oe, getBezierPath as ke, useEdges as Ae, useNodes as je, useNodesInitialized as Me, useReactFlow as M, useStore as Ne } from "@xyflow/react";
|
|
4
|
+
import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
5
|
+
import { useForm as Pe } from "@tanstack/react-form";
|
|
6
|
+
import { AlignLeft as Fe, ArrowRightFromLine as Ie, Boxes as Le, Calendar as Re, CalendarRange as ze, CaseSensitive as Be, Check as Ve, CheckSquare as He, ChevronDown as Ue, ChevronsUpDown as We, CircleDot as Ge, Clock as Ke, ClockFading as qe, Cloud as Je, Copy as Ye, Download as Xe, EllipsisVertical as Ze, EyeOff as Qe, Hash as $e, Heading as et, ImagePlus as tt, KeyRound as nt, Link2 as rt, ListFilter as it, Loader2 as at, MapPin as ot, Minus as st, MoreVertical as ct, Network as lt, Paperclip as ut, Plus as I, PlusCircle as dt, RectangleEllipsis as ft, Save as pt, Search as mt, Send as ht, Settings as gt, ToggleLeft as _t, Trash2 as vt, Upload as yt, Variable as bt, WandSparkles as xt, Waypoints as St, X as L, XIcon as Ct } from "lucide-react";
|
|
7
|
+
import { createContext as wt, memo as Tt, useCallback as R, useContext as Et, useEffect as Dt, useId as Ot, useMemo as kt, useRef as At, useState as z } from "react";
|
|
8
|
+
import { Slot as jt } from "@radix-ui/react-slot";
|
|
9
|
+
import { cva as Mt } from "class-variance-authority";
|
|
10
|
+
import * as Nt from "@radix-ui/react-scroll-area";
|
|
11
|
+
import * as B from "@radix-ui/react-dropdown-menu";
|
|
12
|
+
import * as Pt from "@radix-ui/react-dialog";
|
|
13
|
+
import { Toaster as Ft, toast as V } from "sonner";
|
|
14
|
+
import * as It from "@radix-ui/react-collapsible";
|
|
15
|
+
import Lt from "@dagrejs/dagre";
|
|
16
|
+
import { useTheme as Rt } from "next-themes";
|
|
17
|
+
//#region src/editor/assets/img/treege-black.svg
|
|
18
|
+
var zt = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1809_3434)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1303%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.455%2046.7988C17.0611%2047.1509%2017.7491%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34V41.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.251%20116.58%20138.64L151.39%2078.3401C151.741%2077.7316%20151.926%2077.0413%20151.926%2076.3386C151.926%2075.636%20151.74%2074.9458%20151.389%2074.3375C151.037%2073.7293%20150.531%2073.2244%20149.922%2072.8738C149.313%2072.5231%20148.623%2072.3391%20147.92%2072.3401H92.48C91.4191%2072.3401%2090.4017%2072.7615%2089.6516%2073.5117C88.9014%2074.2618%2088.48%2075.2792%2088.48%2076.3401V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.469C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.3201H3.99999C3.29819%2072.3208%202.60893%2072.5061%202.00143%2072.8575C1.39392%2073.2089%200.88955%2073.7139%200.538962%2074.3218C0.188375%2074.9298%200.00390931%2075.6193%200.00408949%2076.3211C0.00426966%2077.0229%200.189089%2077.7123%200.539989%2078.3201L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.489C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.3101C63.4773%2075.2509%2063.0547%2074.2361%2062.3049%2073.4881C61.555%2072.7401%2060.5391%2072.3201%2059.48%2072.3201V72.3201Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='black'/%3e%3cdefs%3e%3cclipPath%20id='clip0_1809_3434'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Bt = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_2_65)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1302%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.4549%2046.7988C17.061%2047.1509%2017.749%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.25%20116.58%20138.64L151.39%2078.34C151.741%2077.7315%20151.926%2077.0412%20151.926%2076.3385C151.926%2075.6359%20151.74%2074.9457%20151.389%2074.3374C151.037%2073.7292%20150.531%2073.2243%20149.922%2072.8737C149.313%2072.523%20148.623%2072.339%20147.92%2072.34H92.48C91.4191%2072.34%2090.4017%2072.7614%2089.6516%2073.5116C88.9014%2074.2617%2088.48%2075.2791%2088.48%2076.34V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.468C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.32H4C3.2982%2072.3207%202.60894%2072.5061%202.00143%2072.8574C1.39393%2073.2088%200.889558%2073.7138%200.53897%2074.3218C0.188382%2074.9297%200.00391694%2075.6192%200.00409712%2076.321C0.00427729%2077.0228%200.189097%2077.7122%200.539997%2078.32L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.488C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.31C63.4773%2075.2509%2063.0548%2074.236%2062.3049%2073.488C61.555%2072.7401%2060.5391%2072.32%2059.48%2072.32Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='white'/%3e%3cdefs%3e%3cclipPath%20id='clip0_2_65'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Vt = ({ theme: e = "dark" }) => /* @__PURE__ */ P("div", {
|
|
19
|
+
className: "absolute top-5 left-5 z-50 select-none",
|
|
20
|
+
children: /* @__PURE__ */ P("img", {
|
|
21
|
+
src: e === "dark" ? Bt : zt,
|
|
22
|
+
alt: "Treege",
|
|
23
|
+
className: "relative h-14 w-auto drop-shadow-[0_0px_35px] drop-shadow-blue-600"
|
|
24
|
+
})
|
|
25
|
+
}), Ht = (e) => {
|
|
26
|
+
let t = je(), n = Ae();
|
|
27
|
+
return kt(() => {
|
|
28
|
+
if (!e) return [];
|
|
29
|
+
let i = (e, t = /* @__PURE__ */ new Set()) => {
|
|
30
|
+
if (t.has(e)) return [];
|
|
31
|
+
let r = new Set(t).add(e);
|
|
32
|
+
return n.filter((t) => t.target === e).flatMap((e) => [e.source, ...i(e.source, r)]);
|
|
33
|
+
}, a = i(e);
|
|
34
|
+
return t.filter((e) => a.includes(e.id) && r(e)).map((e) => {
|
|
35
|
+
let t = e.data;
|
|
36
|
+
return {
|
|
37
|
+
label: (typeof t.label == "object" ? t.label.en : t.label) || t.name || e.id,
|
|
38
|
+
name: t.name,
|
|
39
|
+
nodeId: e.id,
|
|
40
|
+
type: t.type || "text"
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}, [
|
|
44
|
+
e,
|
|
45
|
+
t,
|
|
46
|
+
n
|
|
47
|
+
]);
|
|
48
|
+
}, Ut = wt(null), Wt = ({ children: e, value: t }) => {
|
|
49
|
+
let [n, r] = z(t?.flowId), [i, a] = z(!1), [o, s] = z(null), [c, l] = z(null), u = kt(() => ({
|
|
50
|
+
...t,
|
|
51
|
+
...t?.aiConfig && { aiConfig: {
|
|
52
|
+
...t.aiConfig,
|
|
53
|
+
provider: t?.aiConfig.provider ?? "gemini"
|
|
54
|
+
} },
|
|
55
|
+
closeDeleteNodeConfirmation: () => s(null),
|
|
56
|
+
closeNodeTypeChangeConfirmation: () => l(null),
|
|
57
|
+
flowId: n,
|
|
58
|
+
isNodeSheetOpen: i,
|
|
59
|
+
openDeleteNodeConfirmation: (e) => s(e),
|
|
60
|
+
openNodeTypeChangeConfirmation: (e) => l(e),
|
|
61
|
+
pendingDeleteNodeId: o,
|
|
62
|
+
pendingNodeTypeChange: c,
|
|
63
|
+
setFlowId: r,
|
|
64
|
+
setIsNodeSheetOpen: a
|
|
65
|
+
}), [
|
|
66
|
+
n,
|
|
67
|
+
t,
|
|
68
|
+
i,
|
|
69
|
+
o,
|
|
70
|
+
c
|
|
71
|
+
]);
|
|
72
|
+
return /* @__PURE__ */ P(Ut.Provider, {
|
|
73
|
+
value: u,
|
|
74
|
+
children: e
|
|
75
|
+
});
|
|
76
|
+
}, H = () => Et(Ut) ?? {
|
|
77
|
+
closeDeleteNodeConfirmation: () => {},
|
|
78
|
+
closeNodeTypeChangeConfirmation: () => {},
|
|
79
|
+
flowId: void 0,
|
|
80
|
+
isNodeSheetOpen: !1,
|
|
81
|
+
language: "en",
|
|
82
|
+
openDeleteNodeConfirmation: () => {},
|
|
83
|
+
openNodeTypeChangeConfirmation: () => {},
|
|
84
|
+
pendingDeleteNodeId: null,
|
|
85
|
+
pendingNodeTypeChange: null,
|
|
86
|
+
setFlowId: () => {},
|
|
87
|
+
setIsNodeSheetOpen: () => {}
|
|
88
|
+
}, U = (e) => {
|
|
89
|
+
let t = H();
|
|
90
|
+
return c(e ?? t.language);
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/shared/components/ui/scroll-area.tsx
|
|
94
|
+
function Gt({ className: e, children: t, ...n }) {
|
|
95
|
+
return /* @__PURE__ */ F(Nt.Root, {
|
|
96
|
+
"data-slot": "scroll-area",
|
|
97
|
+
className: E("relative", e),
|
|
98
|
+
...n,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ P(Nt.Viewport, {
|
|
101
|
+
"data-slot": "scroll-area-viewport",
|
|
102
|
+
className: "size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
103
|
+
children: t
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ P(Kt, {}),
|
|
106
|
+
/* @__PURE__ */ P(Nt.Corner, {})
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function Kt({ className: e, orientation: t = "vertical", ...n }) {
|
|
111
|
+
return /* @__PURE__ */ P(Nt.ScrollAreaScrollbar, {
|
|
112
|
+
"data-slot": "scroll-area-scrollbar",
|
|
113
|
+
orientation: t,
|
|
114
|
+
className: E("flex touch-none select-none p-px transition-colors", t === "vertical" && "h-full w-2.5 border-l border-l-transparent", t === "horizontal" && "h-2.5 flex-col border-t border-t-transparent", e),
|
|
115
|
+
...n,
|
|
116
|
+
children: /* @__PURE__ */ P(Nt.ScrollAreaThumb, {
|
|
117
|
+
"data-slot": "scroll-area-thumb",
|
|
118
|
+
className: "relative flex-1 rounded-full bg-border"
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/editor/features/TreegeEditor/edges/ConditionalEdge.tsx
|
|
124
|
+
var qt = {
|
|
125
|
+
"!==": "≠",
|
|
126
|
+
"<": "<",
|
|
127
|
+
"<=": "≤",
|
|
128
|
+
"===": "=",
|
|
129
|
+
">": ">",
|
|
130
|
+
">=": "≥"
|
|
131
|
+
}, Jt = (e) => !!e.field && e.value !== void 0 && e.value !== "", Yt = {
|
|
132
|
+
conditional: Tt(({ id: t, target: n, sourceX: r, sourceY: i, targetX: a, targetY: o, sourcePosition: s, targetPosition: c, markerEnd: l, style: u, data: f }) => {
|
|
133
|
+
let [p, m, _] = ke({
|
|
134
|
+
sourcePosition: s,
|
|
135
|
+
sourceX: r,
|
|
136
|
+
sourceY: i,
|
|
137
|
+
targetPosition: c,
|
|
138
|
+
targetX: a,
|
|
139
|
+
targetY: o
|
|
140
|
+
}), [y, b] = z(!1), { updateEdgeData: ee } = M(), te = Ht(n), x = U(), S = !!f?.configured || !!f?.isFallback || !!f?.label || (f?.conditions?.some(Jt) ?? !1), { handleSubmit: re, reset: w, Field: oe } = Pe({
|
|
141
|
+
defaultValues: {
|
|
142
|
+
conditions: f?.conditions || [{
|
|
143
|
+
field: te[0]?.nodeId ?? "",
|
|
144
|
+
operator: "===",
|
|
145
|
+
value: ""
|
|
146
|
+
}],
|
|
147
|
+
isFallback: !!f?.isFallback,
|
|
148
|
+
label: f?.label || ""
|
|
149
|
+
},
|
|
150
|
+
listeners: {
|
|
151
|
+
onChange: ({ formApi: e }) => {
|
|
152
|
+
e.handleSubmit().then();
|
|
153
|
+
},
|
|
154
|
+
onChangeDebounceMs: 150
|
|
155
|
+
},
|
|
156
|
+
onSubmit: ({ value: e }) => {
|
|
157
|
+
ee(t, {
|
|
158
|
+
...e,
|
|
159
|
+
configured: !0
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}), D = (e) => {
|
|
163
|
+
e.stopPropagation();
|
|
164
|
+
}, se = () => {
|
|
165
|
+
w({
|
|
166
|
+
conditions: [],
|
|
167
|
+
isFallback: !1,
|
|
168
|
+
label: ""
|
|
169
|
+
}), ee(t, {
|
|
170
|
+
conditions: void 0,
|
|
171
|
+
configured: void 0,
|
|
172
|
+
isFallback: void 0,
|
|
173
|
+
label: void 0
|
|
174
|
+
});
|
|
175
|
+
}, ce = (e) => {
|
|
176
|
+
b(e), !(e || f?.configured) && (f?.isFallback || f?.label || f?.conditions?.length) && ee(t, { configured: !0 });
|
|
177
|
+
}, le = () => {
|
|
178
|
+
if (f?.isFallback) return f.label || x("editor.conditionalEdge.fallback");
|
|
179
|
+
if (f?.label) return f.label;
|
|
180
|
+
let t = f?.conditions ?? [];
|
|
181
|
+
if (t.length === 0) return null;
|
|
182
|
+
if (t.length === 1) {
|
|
183
|
+
let [e] = t, n = te.find((t) => t.nodeId === e.field)?.label ?? e.field ?? "";
|
|
184
|
+
return `${n === e.field && n.length > 5 ? `${n.slice(0, 5)}…` : n} ${qt[e.operator] ?? e.operator} ${e.value ?? ""}`;
|
|
185
|
+
}
|
|
186
|
+
let n = t.filter((t) => t.logicalOperator === e.AND).length, r = t.filter((t) => t.logicalOperator === e.OR).length;
|
|
187
|
+
return n > 0 && r === 0 ? `${t.length} ${x("editor.conditionalEdge.conditionsAnd")}` : r > 0 && n === 0 ? `${t.length} ${x("editor.conditionalEdge.conditionsOr")}` : `${t.length} ${x("editor.conditionalEdge.conditionsMixed")}`;
|
|
188
|
+
}, ue = () => f?.isFallback ? "var(--color-chart-4)" : S ? "var(--color-chart-2)" : "var(--color-chart-3)";
|
|
189
|
+
return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(ve, {
|
|
190
|
+
path: p,
|
|
191
|
+
markerEnd: l,
|
|
192
|
+
style: {
|
|
193
|
+
...u,
|
|
194
|
+
stroke: ue(),
|
|
195
|
+
strokeDasharray: f?.isFallback ? "5,5" : void 0,
|
|
196
|
+
strokeWidth: S ? 2 : u?.strokeWidth
|
|
197
|
+
}
|
|
198
|
+
}), /* @__PURE__ */ P(be, { children: /* @__PURE__ */ P("div", {
|
|
199
|
+
className: "nodrag nopan absolute",
|
|
200
|
+
style: {
|
|
201
|
+
pointerEvents: "all",
|
|
202
|
+
transform: `translate(-50%, -50%) translate(${m}px,${_}px)`
|
|
203
|
+
},
|
|
204
|
+
children: /* @__PURE__ */ F(ie, {
|
|
205
|
+
open: y,
|
|
206
|
+
onOpenChange: ce,
|
|
207
|
+
children: [/* @__PURE__ */ P(ne, {
|
|
208
|
+
asChild: !0,
|
|
209
|
+
children: /* @__PURE__ */ F(k, {
|
|
210
|
+
variant: S ? "default" : "secondary",
|
|
211
|
+
size: "xs",
|
|
212
|
+
className: E("transition-[filter]", S ? "hover:bg-primary hover:brightness-125" : "hover:bg-secondary hover:brightness-90"),
|
|
213
|
+
onClick: D,
|
|
214
|
+
children: [/* @__PURE__ */ P(St, { className: "h-3 w-3" }), S ? le() : x("editor.conditionalEdge.defineCondition")]
|
|
215
|
+
})
|
|
216
|
+
}), /* @__PURE__ */ P(ae, {
|
|
217
|
+
className: "w-96 p-1",
|
|
218
|
+
align: "center",
|
|
219
|
+
onClick: (e) => e.stopPropagation(),
|
|
220
|
+
children: /* @__PURE__ */ P(Gt, {
|
|
221
|
+
className: "flex max-h-150 flex-col p-3",
|
|
222
|
+
children: /* @__PURE__ */ P("form", {
|
|
223
|
+
onSubmit: (e) => {
|
|
224
|
+
e.preventDefault(), e.stopPropagation();
|
|
225
|
+
},
|
|
226
|
+
children: /* @__PURE__ */ F("div", {
|
|
227
|
+
className: "grid gap-5",
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ F("div", {
|
|
230
|
+
className: "space-y-2",
|
|
231
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
232
|
+
className: "font-medium leading-none",
|
|
233
|
+
children: x("editor.conditionalEdge.displayConditions")
|
|
234
|
+
}), /* @__PURE__ */ P("p", {
|
|
235
|
+
className: "text-muted-foreground text-sm",
|
|
236
|
+
children: x("editor.conditionalEdge.displayConditionsDesc")
|
|
237
|
+
})]
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ F("div", {
|
|
240
|
+
className: "grid gap-4",
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ P(oe, {
|
|
243
|
+
name: "label",
|
|
244
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
245
|
+
/* @__PURE__ */ P(d, {
|
|
246
|
+
htmlFor: e.name,
|
|
247
|
+
children: x("editor.conditionalEdge.labelOptional")
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ P(O, {
|
|
250
|
+
id: e.name,
|
|
251
|
+
placeholder: x("editor.conditionalEdge.labelPlaceholder"),
|
|
252
|
+
value: e.state.value,
|
|
253
|
+
onChange: (t) => e.handleChange(t.target.value)
|
|
254
|
+
}),
|
|
255
|
+
/* @__PURE__ */ P(j, { children: x("editor.conditionalEdge.labelDesc") })
|
|
256
|
+
] })
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ P(oe, {
|
|
259
|
+
name: "isFallback",
|
|
260
|
+
children: (e) => /* @__PURE__ */ P(A, { children: /* @__PURE__ */ F("div", {
|
|
261
|
+
className: "flex items-center gap-3 rounded-lg border bg-muted/20 p-3",
|
|
262
|
+
children: [/* @__PURE__ */ P(fe, {
|
|
263
|
+
id: e.name,
|
|
264
|
+
checked: e.state.value,
|
|
265
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
266
|
+
}), /* @__PURE__ */ F("div", {
|
|
267
|
+
className: "flex flex-col gap-1",
|
|
268
|
+
children: [/* @__PURE__ */ P(d, {
|
|
269
|
+
htmlFor: e.name,
|
|
270
|
+
className: "cursor-pointer font-medium",
|
|
271
|
+
children: x("editor.conditionalEdge.fallbackPath")
|
|
272
|
+
}), /* @__PURE__ */ P(j, {
|
|
273
|
+
className: "text-xs",
|
|
274
|
+
children: x("editor.conditionalEdge.fallbackPathDesc")
|
|
275
|
+
})]
|
|
276
|
+
})]
|
|
277
|
+
}) })
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ P(oe, {
|
|
280
|
+
name: "conditions",
|
|
281
|
+
mode: "array",
|
|
282
|
+
children: (t) => {
|
|
283
|
+
let n = t.form.getFieldValue("isFallback");
|
|
284
|
+
return /* @__PURE__ */ F("div", {
|
|
285
|
+
className: "space-y-3",
|
|
286
|
+
children: [/* @__PURE__ */ P(d, {
|
|
287
|
+
className: n ? "text-muted-foreground" : "",
|
|
288
|
+
children: x("editor.conditionalEdge.conditions")
|
|
289
|
+
}), /* @__PURE__ */ F("div", {
|
|
290
|
+
className: "space-y-2",
|
|
291
|
+
children: [t.state.value?.map((r, i) => /* @__PURE__ */ F("div", {
|
|
292
|
+
className: "space-y-2",
|
|
293
|
+
children: [/* @__PURE__ */ F("div", {
|
|
294
|
+
className: "space-y-2 rounded-lg border bg-muted/30 p-3",
|
|
295
|
+
children: [
|
|
296
|
+
/* @__PURE__ */ P(oe, {
|
|
297
|
+
name: `conditions[${i}].field`,
|
|
298
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
299
|
+
htmlFor: `field-${i}`,
|
|
300
|
+
children: x("editor.conditionalEdge.field")
|
|
301
|
+
}), /* @__PURE__ */ F(g, {
|
|
302
|
+
disabled: n,
|
|
303
|
+
value: e.state.value || "",
|
|
304
|
+
onValueChange: (t) => e.handleChange(t),
|
|
305
|
+
children: [/* @__PURE__ */ P(v, {
|
|
306
|
+
id: `field-${i}`,
|
|
307
|
+
className: "w-full",
|
|
308
|
+
children: /* @__PURE__ */ P(T, { placeholder: x("editor.conditionalEdge.selectField") })
|
|
309
|
+
}), /* @__PURE__ */ P(C, { children: te.length === 0 ? /* @__PURE__ */ P(h, {
|
|
310
|
+
value: "none",
|
|
311
|
+
disabled: !0,
|
|
312
|
+
children: x("editor.conditionalEdge.noFieldsAvailable")
|
|
313
|
+
}) : te.map((e) => /* @__PURE__ */ F(h, {
|
|
314
|
+
value: e.nodeId,
|
|
315
|
+
children: [
|
|
316
|
+
e.label,
|
|
317
|
+
" (",
|
|
318
|
+
e.type,
|
|
319
|
+
")"
|
|
320
|
+
]
|
|
321
|
+
}, e.nodeId)) })]
|
|
322
|
+
})] })
|
|
323
|
+
}),
|
|
324
|
+
/* @__PURE__ */ F("div", {
|
|
325
|
+
className: "flex gap-2",
|
|
326
|
+
children: [/* @__PURE__ */ P(oe, {
|
|
327
|
+
name: `conditions[${i}].operator`,
|
|
328
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
329
|
+
htmlFor: `operator-${i}`,
|
|
330
|
+
children: x("editor.conditionalEdge.operator")
|
|
331
|
+
}), /* @__PURE__ */ F(g, {
|
|
332
|
+
disabled: n,
|
|
333
|
+
value: e.state.value || "===",
|
|
334
|
+
onValueChange: (t) => e.handleChange(t),
|
|
335
|
+
children: [/* @__PURE__ */ P(v, {
|
|
336
|
+
id: `operator-${i}`,
|
|
337
|
+
children: /* @__PURE__ */ P(T, {})
|
|
338
|
+
}), /* @__PURE__ */ F(C, { children: [
|
|
339
|
+
/* @__PURE__ */ P(h, {
|
|
340
|
+
value: "===",
|
|
341
|
+
children: "="
|
|
342
|
+
}),
|
|
343
|
+
/* @__PURE__ */ P(h, {
|
|
344
|
+
value: "!==",
|
|
345
|
+
children: "≠"
|
|
346
|
+
}),
|
|
347
|
+
/* @__PURE__ */ P(h, {
|
|
348
|
+
value: ">",
|
|
349
|
+
children: ">"
|
|
350
|
+
}),
|
|
351
|
+
/* @__PURE__ */ P(h, {
|
|
352
|
+
value: "<",
|
|
353
|
+
children: "<"
|
|
354
|
+
}),
|
|
355
|
+
/* @__PURE__ */ P(h, {
|
|
356
|
+
value: ">=",
|
|
357
|
+
children: ">="
|
|
358
|
+
}),
|
|
359
|
+
/* @__PURE__ */ P(h, {
|
|
360
|
+
value: "<=",
|
|
361
|
+
children: "<="
|
|
362
|
+
})
|
|
363
|
+
] })]
|
|
364
|
+
})] })
|
|
365
|
+
}), /* @__PURE__ */ P(oe, {
|
|
366
|
+
name: `conditions[${i}].value`,
|
|
367
|
+
children: (e) => /* @__PURE__ */ F(A, {
|
|
368
|
+
className: "w-full",
|
|
369
|
+
children: [/* @__PURE__ */ P(d, {
|
|
370
|
+
htmlFor: `value-${i}`,
|
|
371
|
+
children: x("editor.conditionalEdge.value")
|
|
372
|
+
}), /* @__PURE__ */ P(O, {
|
|
373
|
+
disabled: n,
|
|
374
|
+
id: `value-${i}`,
|
|
375
|
+
placeholder: x("editor.conditionalEdge.valuePlaceholder"),
|
|
376
|
+
value: e.state.value || "",
|
|
377
|
+
onChange: (t) => e.handleChange(t.target.value)
|
|
378
|
+
})]
|
|
379
|
+
})
|
|
380
|
+
})]
|
|
381
|
+
}),
|
|
382
|
+
t.state.value && t.state.value.length > 1 && /* @__PURE__ */ F(k, {
|
|
383
|
+
disabled: n,
|
|
384
|
+
type: "button",
|
|
385
|
+
variant: "ghost",
|
|
386
|
+
size: "sm",
|
|
387
|
+
className: "w-full",
|
|
388
|
+
onClick: () => {
|
|
389
|
+
t.removeValue(i), re().then();
|
|
390
|
+
},
|
|
391
|
+
children: [/* @__PURE__ */ P(L, { className: "mr-1 h-4 w-4" }), x("editor.conditionalEdge.removeCondition")]
|
|
392
|
+
})
|
|
393
|
+
]
|
|
394
|
+
}), t.state.value && i < t.state.value.length - 1 && /* @__PURE__ */ P(oe, {
|
|
395
|
+
name: `conditions[${i}].logicalOperator`,
|
|
396
|
+
children: (t) => /* @__PURE__ */ P("div", {
|
|
397
|
+
className: "flex justify-center",
|
|
398
|
+
children: /* @__PURE__ */ F(g, {
|
|
399
|
+
disabled: n,
|
|
400
|
+
value: t.state.value || e.AND,
|
|
401
|
+
onValueChange: (e) => t.handleChange(e),
|
|
402
|
+
children: [/* @__PURE__ */ P(v, {
|
|
403
|
+
className: "h-9 w-32 font-semibold",
|
|
404
|
+
children: /* @__PURE__ */ P(T, {})
|
|
405
|
+
}), /* @__PURE__ */ F(C, { children: [/* @__PURE__ */ P(h, {
|
|
406
|
+
value: e.AND,
|
|
407
|
+
children: "AND"
|
|
408
|
+
}), /* @__PURE__ */ P(h, {
|
|
409
|
+
value: e.OR,
|
|
410
|
+
children: "OR"
|
|
411
|
+
})] })]
|
|
412
|
+
})
|
|
413
|
+
})
|
|
414
|
+
})]
|
|
415
|
+
}, `condition-${i}`)), /* @__PURE__ */ F(k, {
|
|
416
|
+
disabled: n,
|
|
417
|
+
type: "button",
|
|
418
|
+
variant: "outline",
|
|
419
|
+
size: "sm",
|
|
420
|
+
className: "w-full",
|
|
421
|
+
onClick: () => {
|
|
422
|
+
t.pushValue({
|
|
423
|
+
field: te[0]?.nodeId ?? "",
|
|
424
|
+
logicalOperator: e.AND,
|
|
425
|
+
operator: "===",
|
|
426
|
+
value: ""
|
|
427
|
+
}), re().then();
|
|
428
|
+
},
|
|
429
|
+
children: [/* @__PURE__ */ P(I, { className: "mr-2 h-4 w-4" }), x("editor.conditionalEdge.addCondition")]
|
|
430
|
+
})]
|
|
431
|
+
})]
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
]
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ F("div", {
|
|
438
|
+
className: "flex justify-end gap-2 pt-2",
|
|
439
|
+
children: [/* @__PURE__ */ F(k, {
|
|
440
|
+
type: "button",
|
|
441
|
+
size: "sm",
|
|
442
|
+
variant: "outline",
|
|
443
|
+
onClick: se,
|
|
444
|
+
children: [/* @__PURE__ */ P(L, { className: "mr-1 h-4 w-4" }), x("common.clear")]
|
|
445
|
+
}), /* @__PURE__ */ P(k, {
|
|
446
|
+
type: "button",
|
|
447
|
+
size: "sm",
|
|
448
|
+
onClick: () => ce(!1),
|
|
449
|
+
children: x("common.close")
|
|
450
|
+
})]
|
|
451
|
+
})
|
|
452
|
+
]
|
|
453
|
+
})
|
|
454
|
+
})
|
|
455
|
+
})
|
|
456
|
+
})]
|
|
457
|
+
})
|
|
458
|
+
}) })] });
|
|
459
|
+
}),
|
|
460
|
+
default: Tt(({ id: e, sourceX: t, sourceY: n, targetX: r, targetY: i, sourcePosition: a, targetPosition: o, style: s, markerEnd: c, selected: l }) => {
|
|
461
|
+
let [u, d, f] = ke({
|
|
462
|
+
sourcePosition: a,
|
|
463
|
+
sourceX: t,
|
|
464
|
+
sourceY: n,
|
|
465
|
+
targetPosition: o,
|
|
466
|
+
targetX: r,
|
|
467
|
+
targetY: i
|
|
468
|
+
}), { setEdges: p } = M();
|
|
469
|
+
return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(ve, {
|
|
470
|
+
path: u,
|
|
471
|
+
markerEnd: c,
|
|
472
|
+
style: s
|
|
473
|
+
}), /* @__PURE__ */ P(be, { children: l && /* @__PURE__ */ P("div", {
|
|
474
|
+
className: "button-edge__label nodrag nopan",
|
|
475
|
+
style: { transform: `translate(-50%, -50%) translate(${d}px,${f}px)` },
|
|
476
|
+
children: /* @__PURE__ */ P("button", {
|
|
477
|
+
type: "button",
|
|
478
|
+
className: "button-edge__button",
|
|
479
|
+
onClick: () => {
|
|
480
|
+
p((t) => t.filter((t) => t.id !== e));
|
|
481
|
+
},
|
|
482
|
+
"aria-label": "Remove edge",
|
|
483
|
+
children: "×"
|
|
484
|
+
})
|
|
485
|
+
}) })] });
|
|
486
|
+
})
|
|
487
|
+
}, Xt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Zt = (e = 21) => {
|
|
488
|
+
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
489
|
+
for (; e--;) t += Xt[n[e] & 63];
|
|
490
|
+
return t;
|
|
491
|
+
}, Qt = (e, t) => {
|
|
492
|
+
if (t.size === 0) return e;
|
|
493
|
+
let n = /* @__PURE__ */ new Map();
|
|
494
|
+
return e.forEach((e) => {
|
|
495
|
+
n.set(e.source, (n.get(e.source) ?? 0) + 1);
|
|
496
|
+
}), e.map((e) => {
|
|
497
|
+
if (!t.has(e.source) || (n.get(e.source) ?? 0) !== 1) return e;
|
|
498
|
+
let { conditions: r, isFallback: i, ...a } = e.data ?? {}, o = a && Object.keys(a).length > 0 ? a : void 0;
|
|
499
|
+
return {
|
|
500
|
+
...e,
|
|
501
|
+
data: o,
|
|
502
|
+
type: "default"
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
}, W = () => {
|
|
506
|
+
let { setNodes: e, setEdges: t, getNodes: n } = M(), r = R(() => {
|
|
507
|
+
e((e) => e.map(({ selected: e, ...t }) => t)), t((e) => e.map(({ selected: e, ...t }) => t));
|
|
508
|
+
}, [t, e]), i = R((n) => {
|
|
509
|
+
e((e) => e.map((e) => ({
|
|
510
|
+
...e,
|
|
511
|
+
selected: e.id === n
|
|
512
|
+
}))), t((e) => e.map(({ selected: e, ...t }) => t));
|
|
513
|
+
}, [t, e]), a = R((t, n) => {
|
|
514
|
+
e((e) => e.map((e) => e.id === t ? {
|
|
515
|
+
...e,
|
|
516
|
+
data: {
|
|
517
|
+
...e.data,
|
|
518
|
+
...n
|
|
519
|
+
}
|
|
520
|
+
} : e));
|
|
521
|
+
}, [e]), o = R((t, n, r) => {
|
|
522
|
+
e((e) => e.map((e) => {
|
|
523
|
+
if (e.id !== t) return e;
|
|
524
|
+
let i = e.type === n ? e.data : {};
|
|
525
|
+
return {
|
|
526
|
+
...e,
|
|
527
|
+
data: r === void 0 ? i : {
|
|
528
|
+
...i,
|
|
529
|
+
type: r
|
|
530
|
+
},
|
|
531
|
+
type: n
|
|
532
|
+
};
|
|
533
|
+
}));
|
|
534
|
+
}, [e]), s = R((e, t) => {
|
|
535
|
+
let r = n().find((e) => e.selected);
|
|
536
|
+
r && o(r.id, e, t);
|
|
537
|
+
}, [n, o]), c = R((e) => {
|
|
538
|
+
let t = n().find((e) => e.selected);
|
|
539
|
+
t && a(t.id, e);
|
|
540
|
+
}, [n, a]), l = R((n) => {
|
|
541
|
+
e((e) => e.filter((e) => e.id !== n)), t((e) => {
|
|
542
|
+
let t = e.filter((e) => e.target === n), r = e.filter((e) => e.source === n), i = new Set(t.map((e) => e.source)), a = e.filter((e) => e.source !== n && e.target !== n);
|
|
543
|
+
if (t.length === 1 && r.length === 1) {
|
|
544
|
+
let [e] = t, [n] = r, o = {
|
|
545
|
+
data: e.data,
|
|
546
|
+
id: Zt(),
|
|
547
|
+
source: e.source,
|
|
548
|
+
target: n.target,
|
|
549
|
+
type: e.type
|
|
550
|
+
};
|
|
551
|
+
return Qt([...a, o], i);
|
|
552
|
+
}
|
|
553
|
+
return Qt(a, i);
|
|
554
|
+
});
|
|
555
|
+
}, [e, t]);
|
|
556
|
+
return {
|
|
557
|
+
clearSelection: r,
|
|
558
|
+
deleteNode: l,
|
|
559
|
+
deleteSelectedNode: R(() => {
|
|
560
|
+
let e = n().find((e) => e.selected);
|
|
561
|
+
e && l(e.id);
|
|
562
|
+
}, [n, l]),
|
|
563
|
+
selectNode: i,
|
|
564
|
+
updateNodeData: a,
|
|
565
|
+
updateNodeType: o,
|
|
566
|
+
updateSelectedNodeData: c,
|
|
567
|
+
updateSelectedNodeType: s
|
|
568
|
+
};
|
|
569
|
+
}, $t = ({ nodeId: e, label: t, placeholder: n, className: r }) => {
|
|
570
|
+
let { language: i } = H(), { updateNodeData: a, clearSelection: o } = W(), s = U(), c = At(null), l = t?.[i] ?? "", u = n || s("editor.treegeNode.labelPlaceholder"), d = (e) => e.stopPropagation();
|
|
571
|
+
return Dt(() => {
|
|
572
|
+
let e = setTimeout(() => {
|
|
573
|
+
c.current?.focus();
|
|
574
|
+
}, 300);
|
|
575
|
+
return () => clearTimeout(e);
|
|
576
|
+
}, []), /* @__PURE__ */ P("input", {
|
|
577
|
+
ref: c,
|
|
578
|
+
type: "text",
|
|
579
|
+
value: l,
|
|
580
|
+
placeholder: u,
|
|
581
|
+
onChange: (n) => {
|
|
582
|
+
a(e, { label: {
|
|
583
|
+
...t,
|
|
584
|
+
[i]: n.target.value
|
|
585
|
+
} });
|
|
586
|
+
},
|
|
587
|
+
onKeyDown: (e) => {
|
|
588
|
+
e.key === "Enter" && (e.preventDefault(), c.current?.blur(), o());
|
|
589
|
+
},
|
|
590
|
+
onClick: d,
|
|
591
|
+
onMouseDown: d,
|
|
592
|
+
onPointerDown: d,
|
|
593
|
+
className: E("nodrag nopan w-full truncate bg-transparent outline-none placeholder:text-muted-foreground/40", r)
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/shared/components/ui/dropdown-menu.tsx
|
|
598
|
+
function G({ ...e }) {
|
|
599
|
+
return /* @__PURE__ */ P(B.Root, {
|
|
600
|
+
"data-slot": "dropdown-menu",
|
|
601
|
+
...e
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
function K({ ...e }) {
|
|
605
|
+
return /* @__PURE__ */ P(B.Trigger, {
|
|
606
|
+
"data-slot": "dropdown-menu-trigger",
|
|
607
|
+
...e
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
function q({ className: e, sideOffset: t = 4, ...n }) {
|
|
611
|
+
return /* @__PURE__ */ P(B.Portal, { children: /* @__PURE__ */ P(B.Content, {
|
|
612
|
+
"data-slot": "dropdown-menu-content",
|
|
613
|
+
sideOffset: t,
|
|
614
|
+
className: E("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
615
|
+
...n
|
|
616
|
+
}) });
|
|
617
|
+
}
|
|
618
|
+
function J({ ...e }) {
|
|
619
|
+
return /* @__PURE__ */ P(B.Group, {
|
|
620
|
+
"data-slot": "dropdown-menu-group",
|
|
621
|
+
...e
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
function Y({ className: e, inset: t, variant: n = "default", ...r }) {
|
|
625
|
+
return /* @__PURE__ */ P(B.Item, {
|
|
626
|
+
"data-slot": "dropdown-menu-item",
|
|
627
|
+
"data-inset": t,
|
|
628
|
+
"data-variant": n,
|
|
629
|
+
className: E("data-[variant=destructive]:*:[svg]:!text-destructive relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[disabled]:opacity-50 data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0", e),
|
|
630
|
+
...r
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
function en({ className: e, inset: t, ...n }) {
|
|
634
|
+
return /* @__PURE__ */ P(B.Label, {
|
|
635
|
+
"data-slot": "dropdown-menu-label",
|
|
636
|
+
"data-inset": t,
|
|
637
|
+
className: E("px-1.5 py-1 font-medium text-muted-foreground text-xs data-[inset]:pl-7", e),
|
|
638
|
+
...n
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function tn({ className: e, ...t }) {
|
|
642
|
+
return /* @__PURE__ */ P(B.Separator, {
|
|
643
|
+
"data-slot": "dropdown-menu-separator",
|
|
644
|
+
className: E("-mx-1 my-1 h-px bg-border", e),
|
|
645
|
+
...t
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.tsx
|
|
650
|
+
var nn = ({ nodeId: e, className: t }) => {
|
|
651
|
+
let { selectNode: n } = W(), { setIsNodeSheetOpen: r, openDeleteNodeConfirmation: i } = H(), a = U(), o = (e) => e.stopPropagation();
|
|
652
|
+
return /* @__PURE__ */ F(G, {
|
|
653
|
+
modal: !1,
|
|
654
|
+
children: [/* @__PURE__ */ P(K, {
|
|
655
|
+
asChild: !0,
|
|
656
|
+
onClick: o,
|
|
657
|
+
children: /* @__PURE__ */ P("button", {
|
|
658
|
+
type: "button",
|
|
659
|
+
"aria-label": a("editor.nodeActionsSheet.editNode"),
|
|
660
|
+
className: E("nodrag nopan absolute top-2 right-2 flex h-6 w-6 cursor-pointer items-center justify-center rounded-md opacity-60 transition-all hover:text-[--treege-color-primary] hover:opacity-100", t),
|
|
661
|
+
children: /* @__PURE__ */ P(ct, { className: "h-3.5 w-3.5" })
|
|
662
|
+
})
|
|
663
|
+
}), /* @__PURE__ */ F(q, {
|
|
664
|
+
align: "end",
|
|
665
|
+
onClick: o,
|
|
666
|
+
children: [
|
|
667
|
+
/* @__PURE__ */ F(Y, {
|
|
668
|
+
onSelect: () => {
|
|
669
|
+
n(e), r(!0);
|
|
670
|
+
},
|
|
671
|
+
children: [/* @__PURE__ */ P(gt, {}), a("common.settings")]
|
|
672
|
+
}),
|
|
673
|
+
/* @__PURE__ */ P(tn, {}),
|
|
674
|
+
/* @__PURE__ */ F(Y, {
|
|
675
|
+
variant: "destructive",
|
|
676
|
+
onSelect: () => {
|
|
677
|
+
i(e);
|
|
678
|
+
},
|
|
679
|
+
children: [/* @__PURE__ */ P(vt, {}), a("common.delete")]
|
|
680
|
+
})
|
|
681
|
+
]
|
|
682
|
+
})]
|
|
683
|
+
});
|
|
684
|
+
}, rn = Mt("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3", {
|
|
685
|
+
defaultVariants: { variant: "default" },
|
|
686
|
+
variants: { variant: {
|
|
687
|
+
blue: "bg-blue-500 text-white dark:bg-blue-600",
|
|
688
|
+
default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
689
|
+
destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
690
|
+
outline: "border-foreground/30 text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
691
|
+
purple: "bg-purple-600 hover:bg-purple-700 text-white",
|
|
692
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90"
|
|
693
|
+
} }
|
|
694
|
+
});
|
|
695
|
+
function an({ className: e, variant: t, asChild: n = !1, ...r }) {
|
|
696
|
+
return /* @__PURE__ */ P(n ? jt : "span", {
|
|
697
|
+
"data-slot": "badge",
|
|
698
|
+
className: E(rn({ variant: t }), e),
|
|
699
|
+
...r
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
var on = Tt(({ data: e, id: t }) => /* @__PURE__ */ F(N, { children: [
|
|
703
|
+
/* @__PURE__ */ P(Ce, {}),
|
|
704
|
+
/* @__PURE__ */ P("div", {
|
|
705
|
+
className: "-top-3.5 absolute left-6",
|
|
706
|
+
children: /* @__PURE__ */ F(an, {
|
|
707
|
+
className: "max-w-50 bg-chart-2",
|
|
708
|
+
children: [/* @__PURE__ */ P(Le, { className: "!w-3 !h-3" }), /* @__PURE__ */ P($t, {
|
|
709
|
+
nodeId: t,
|
|
710
|
+
label: e?.label,
|
|
711
|
+
className: "min-w-0 flex-1 text-xs text-white placeholder:text-white/60"
|
|
712
|
+
})]
|
|
713
|
+
})
|
|
714
|
+
}),
|
|
715
|
+
/* @__PURE__ */ P(nn, { nodeId: t })
|
|
716
|
+
] })), sn = {
|
|
717
|
+
data: { type: "text" },
|
|
718
|
+
id: Zt(),
|
|
719
|
+
position: {
|
|
720
|
+
x: 0,
|
|
721
|
+
y: 0
|
|
722
|
+
},
|
|
723
|
+
type: "input"
|
|
724
|
+
}, cn = () => {
|
|
725
|
+
let { setNodes: e, setEdges: t, screenToFlowPosition: n, getNode: i, getNodes: a, getEdges: o } = M(), s = R((n, i, a = !1, s) => {
|
|
726
|
+
let c = n.id, l = o().filter((e) => e.source === c), u = r(n);
|
|
727
|
+
if (l.length > 0 && !u) return;
|
|
728
|
+
let d = Zt(), f = {
|
|
729
|
+
...sn,
|
|
730
|
+
...s && {
|
|
731
|
+
data: s.data ?? {},
|
|
732
|
+
type: s.type
|
|
733
|
+
},
|
|
734
|
+
id: d,
|
|
735
|
+
position: i,
|
|
736
|
+
selected: a
|
|
737
|
+
};
|
|
738
|
+
n?.parentId && (f.parentId = n.parentId, f.extent = "parent"), e((e) => e.concat(f)), t((e) => {
|
|
739
|
+
let t = e.filter((e) => e.source === c).length > 0, n = {
|
|
740
|
+
data: t && u ? { conditions: [{
|
|
741
|
+
field: c,
|
|
742
|
+
operator: "===",
|
|
743
|
+
value: ""
|
|
744
|
+
}] } : void 0,
|
|
745
|
+
id: Zt(),
|
|
746
|
+
source: c,
|
|
747
|
+
target: d,
|
|
748
|
+
type: t && u ? "conditional" : "default"
|
|
749
|
+
};
|
|
750
|
+
return t && u ? e.map((e) => e.source === c ? {
|
|
751
|
+
...e,
|
|
752
|
+
data: {
|
|
753
|
+
...e.data,
|
|
754
|
+
conditions: e.data?.conditions || [{
|
|
755
|
+
field: c,
|
|
756
|
+
operator: "===",
|
|
757
|
+
value: ""
|
|
758
|
+
}]
|
|
759
|
+
},
|
|
760
|
+
type: "conditional"
|
|
761
|
+
} : e).concat(n) : e.concat(n);
|
|
762
|
+
}), a && requestAnimationFrame(() => {
|
|
763
|
+
e((e) => e.map((e) => ({
|
|
764
|
+
...e,
|
|
765
|
+
selected: e.id === d
|
|
766
|
+
}))), t((e) => e.map((e) => ({
|
|
767
|
+
...e,
|
|
768
|
+
selected: !1
|
|
769
|
+
})));
|
|
770
|
+
});
|
|
771
|
+
}, [
|
|
772
|
+
o,
|
|
773
|
+
e,
|
|
774
|
+
t
|
|
775
|
+
]), c = R((e) => {
|
|
776
|
+
t((t) => {
|
|
777
|
+
let n = Oe(e, t), a = e.source, o = i(a);
|
|
778
|
+
return n.filter((e) => e.source === a).length > 1 && o && r(o) ? n.map((e) => e.source === a ? {
|
|
779
|
+
...e,
|
|
780
|
+
data: {
|
|
781
|
+
...e.data,
|
|
782
|
+
conditions: e.data?.conditions || [{
|
|
783
|
+
field: a,
|
|
784
|
+
operator: "===",
|
|
785
|
+
value: ""
|
|
786
|
+
}]
|
|
787
|
+
},
|
|
788
|
+
type: "conditional"
|
|
789
|
+
} : e) : n;
|
|
790
|
+
});
|
|
791
|
+
}, [t, i]), l = R((e, t) => {
|
|
792
|
+
let n = i(e);
|
|
793
|
+
if (!n) return;
|
|
794
|
+
let r = getComputedStyle(document.documentElement).getPropertyValue("--node-height"), c = getComputedStyle(document.documentElement).getPropertyValue("--node-width"), l = parseFloat(r) || 100, u = parseFloat(c) || 100, d = n.position.y + l + 100, f = a(), p = o(), m = f.filter((t) => p.some((n) => n.source === e && n.target === t.id)).map((e) => e.position.x);
|
|
795
|
+
s(n, {
|
|
796
|
+
x: m.length === 0 ? n.position.x : m.length % 2 == 1 ? Math.max(...m) + u + 50 : Math.min(...m) - u - 50,
|
|
797
|
+
y: d
|
|
798
|
+
}, !0, t);
|
|
799
|
+
}, [
|
|
800
|
+
i,
|
|
801
|
+
a,
|
|
802
|
+
o,
|
|
803
|
+
s
|
|
804
|
+
]), u = R((e, t) => {
|
|
805
|
+
if (!t.isValid) {
|
|
806
|
+
let { clientX: r, clientY: a } = "changedTouches" in e ? e.changedTouches[0] : e, o = t.fromNode;
|
|
807
|
+
if (!o) return;
|
|
808
|
+
let c = n({
|
|
809
|
+
x: r,
|
|
810
|
+
y: a
|
|
811
|
+
}), l = o.parentId ? i(o.parentId) : void 0, u = l?.position ?? {
|
|
812
|
+
x: 0,
|
|
813
|
+
y: 0
|
|
814
|
+
};
|
|
815
|
+
s(o, l ? {
|
|
816
|
+
x: c.x - u.x,
|
|
817
|
+
y: c.y - u.y
|
|
818
|
+
} : c, !0);
|
|
819
|
+
}
|
|
820
|
+
}, [
|
|
821
|
+
s,
|
|
822
|
+
i,
|
|
823
|
+
n
|
|
824
|
+
]), d = R((e) => {
|
|
825
|
+
t((t) => Qt(t.filter((t) => !e.find((e) => e.id === t.id)), new Set(e.map((e) => e.source))));
|
|
826
|
+
}, [t]);
|
|
827
|
+
return {
|
|
828
|
+
isValidConnection: R((e) => {
|
|
829
|
+
if (e.source === e.target) return !1;
|
|
830
|
+
let t = i(e.source);
|
|
831
|
+
return t ? !(o().filter((t) => t.source === e.source).length > 0 && !r(t)) : !1;
|
|
832
|
+
}, [i, o]),
|
|
833
|
+
onAddFromHandle: l,
|
|
834
|
+
onConnect: c,
|
|
835
|
+
onConnectEnd: u,
|
|
836
|
+
onEdgesDelete: d
|
|
837
|
+
};
|
|
838
|
+
}, X = {
|
|
839
|
+
address: "address",
|
|
840
|
+
autocomplete: "autocomplete",
|
|
841
|
+
checkbox: "checkbox",
|
|
842
|
+
date: "date",
|
|
843
|
+
daterange: "daterange",
|
|
844
|
+
file: "file",
|
|
845
|
+
hidden: "hidden",
|
|
846
|
+
http: "http",
|
|
847
|
+
number: "number",
|
|
848
|
+
password: "password",
|
|
849
|
+
radio: "radio",
|
|
850
|
+
select: "select",
|
|
851
|
+
submit: "submit",
|
|
852
|
+
switch: "switch",
|
|
853
|
+
text: "text",
|
|
854
|
+
textarea: "textarea",
|
|
855
|
+
time: "time",
|
|
856
|
+
timerange: "timerange"
|
|
857
|
+
}, ln = {
|
|
858
|
+
divider: "divider",
|
|
859
|
+
title: "title"
|
|
860
|
+
}, un = {
|
|
861
|
+
[X.address]: ot,
|
|
862
|
+
[X.autocomplete]: mt,
|
|
863
|
+
[X.checkbox]: He,
|
|
864
|
+
[X.date]: Re,
|
|
865
|
+
[X.daterange]: ze,
|
|
866
|
+
[X.file]: ut,
|
|
867
|
+
[X.hidden]: Qe,
|
|
868
|
+
[X.http]: Je,
|
|
869
|
+
[X.number]: $e,
|
|
870
|
+
[X.password]: nt,
|
|
871
|
+
[X.radio]: Ge,
|
|
872
|
+
[X.select]: it,
|
|
873
|
+
[X.submit]: ht,
|
|
874
|
+
[X.switch]: _t,
|
|
875
|
+
[X.text]: Be,
|
|
876
|
+
[X.textarea]: Fe,
|
|
877
|
+
[X.time]: Ke,
|
|
878
|
+
[X.timerange]: qe,
|
|
879
|
+
[ln.divider]: st,
|
|
880
|
+
[ln.title]: et,
|
|
881
|
+
[l.flow]: lt
|
|
882
|
+
}, dn = ft, Z = (e) => e && un[e] || dn, fn = ({ nodeId: e, isConnectable: t }) => {
|
|
883
|
+
let { onAddFromHandle: n } = cn(), r = U(), [i, a] = z(!1), o = Z(l.flow);
|
|
884
|
+
return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(xe, {
|
|
885
|
+
type: "source",
|
|
886
|
+
position: Te.Bottom,
|
|
887
|
+
isConnectable: t,
|
|
888
|
+
onClick: (e) => {
|
|
889
|
+
e.defaultPrevented || a(!0);
|
|
890
|
+
},
|
|
891
|
+
className: "flex h-6! w-6! cursor-pointer items-center justify-center rounded-sm transition-colors hover:bg-primary/80!",
|
|
892
|
+
children: /* @__PURE__ */ P(I, { className: "h-4 w-4 text-primary-foreground" })
|
|
893
|
+
}), /* @__PURE__ */ F(G, {
|
|
894
|
+
open: i,
|
|
895
|
+
onOpenChange: a,
|
|
896
|
+
children: [/* @__PURE__ */ P(K, {
|
|
897
|
+
asChild: !0,
|
|
898
|
+
children: /* @__PURE__ */ P("span", {
|
|
899
|
+
"aria-hidden": !0,
|
|
900
|
+
className: "-translate-x-1/2 pointer-events-none absolute bottom-0 left-1/2 h-0 w-0"
|
|
901
|
+
})
|
|
902
|
+
}), /* @__PURE__ */ F(q, {
|
|
903
|
+
align: "center",
|
|
904
|
+
side: "bottom",
|
|
905
|
+
className: "treege-scrollbar max-h-80",
|
|
906
|
+
children: [
|
|
907
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ P(en, { children: r("editor.selectNodeType.options.input") }), Object.values(X).map((t) => /* @__PURE__ */ F(Y, {
|
|
908
|
+
onClick: () => n(e, {
|
|
909
|
+
data: { type: t },
|
|
910
|
+
type: l.input
|
|
911
|
+
}),
|
|
912
|
+
className: "capitalize",
|
|
913
|
+
children: [/* @__PURE__ */ P(Z(t), {}), t]
|
|
914
|
+
}, t))] }),
|
|
915
|
+
/* @__PURE__ */ P(tn, {}),
|
|
916
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ P(en, { children: r("editor.selectNodeType.options.ui") }), Object.values(ln).map((t) => /* @__PURE__ */ F(Y, {
|
|
917
|
+
onClick: () => n(e, {
|
|
918
|
+
data: { type: t },
|
|
919
|
+
type: l.ui
|
|
920
|
+
}),
|
|
921
|
+
className: "capitalize",
|
|
922
|
+
children: [/* @__PURE__ */ P(Z(t), {}), t]
|
|
923
|
+
}, t))] }),
|
|
924
|
+
/* @__PURE__ */ P(tn, {}),
|
|
925
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ P(en, { children: r("common.other") }), /* @__PURE__ */ F(Y, {
|
|
926
|
+
onClick: () => n(e, {
|
|
927
|
+
data: {},
|
|
928
|
+
type: l.flow
|
|
929
|
+
}),
|
|
930
|
+
children: [/* @__PURE__ */ P(o, {}), r("editor.selectNodeType.options.flow")]
|
|
931
|
+
})] })
|
|
932
|
+
]
|
|
933
|
+
})]
|
|
934
|
+
})] });
|
|
935
|
+
}, pn = (e) => {
|
|
936
|
+
switch (e) {
|
|
937
|
+
case "number":
|
|
938
|
+
case "daterange":
|
|
939
|
+
case "timerange":
|
|
940
|
+
case "file": return null;
|
|
941
|
+
case "switch": return !1;
|
|
942
|
+
case "checkbox": return [];
|
|
943
|
+
default: return "";
|
|
944
|
+
}
|
|
945
|
+
}, mn = ({ nodeId: e, data: n }) => {
|
|
946
|
+
let { language: r } = H(), i = n?.type;
|
|
947
|
+
if (!i) return null;
|
|
948
|
+
let o = {
|
|
949
|
+
data: n,
|
|
950
|
+
id: e,
|
|
951
|
+
position: {
|
|
952
|
+
x: 0,
|
|
953
|
+
y: 0
|
|
954
|
+
},
|
|
955
|
+
type: "input"
|
|
956
|
+
}, c = a(n.label, r), l = t(o), u = /* @__PURE__ */ F("div", {
|
|
957
|
+
className: "flex items-center gap-1 text-[10px] text-muted-foreground capitalize [&>svg]:size-3",
|
|
958
|
+
children: [/* @__PURE__ */ P(Z(i), {}), i]
|
|
959
|
+
});
|
|
960
|
+
if (i === "hidden") {
|
|
961
|
+
let e = n.defaultValue?.type === "static" ? n.defaultValue.staticValue : void 0, t = n.defaultValue?.type === "reference" ? n.defaultValue.referenceField : void 0, r = Array.isArray(e) ? e.join(", ") : typeof e == "boolean" ? String(e) : e ?? (t ? `→ ${t}` : "");
|
|
962
|
+
return /* @__PURE__ */ F("div", {
|
|
963
|
+
className: "pointer-events-none flex select-none flex-col gap-1 text-sm",
|
|
964
|
+
children: [
|
|
965
|
+
u,
|
|
966
|
+
/* @__PURE__ */ P("span", {
|
|
967
|
+
className: "truncate font-medium",
|
|
968
|
+
children: c || l
|
|
969
|
+
}),
|
|
970
|
+
/* @__PURE__ */ P("span", {
|
|
971
|
+
className: "truncate text-muted-foreground text-xs",
|
|
972
|
+
children: r || "—"
|
|
973
|
+
})
|
|
974
|
+
]
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
let d = pe[i];
|
|
978
|
+
if (!d) return null;
|
|
979
|
+
let f = a(n.helperText, r), p = s(n, r);
|
|
980
|
+
return /* @__PURE__ */ F("div", {
|
|
981
|
+
className: E("pointer-events-none flex select-none flex-col gap-1", i === "submit" && "items-center"),
|
|
982
|
+
children: [u, /* @__PURE__ */ P(d, {
|
|
983
|
+
node: o,
|
|
984
|
+
value: pn(i),
|
|
985
|
+
setValue: () => {},
|
|
986
|
+
id: e,
|
|
987
|
+
name: l,
|
|
988
|
+
label: c || void 0,
|
|
989
|
+
placeholder: p || void 0,
|
|
990
|
+
helperText: f || void 0
|
|
991
|
+
})]
|
|
992
|
+
});
|
|
993
|
+
}, hn = Object.values(X), gn = Object.values(ln), _n = ({ nodeId: e, nodeType: t, subType: n }) => {
|
|
994
|
+
let { updateNodeType: r } = W(), { getEdges: i } = M(), { openNodeTypeChangeConfirmation: a } = H(), o = U(), s = (e) => e.stopPropagation(), c = n || t, u = t === l.flow ? o("editor.selectNodeType.options.flow") : c, d = Z(c), f = Z(l.flow), p = (t, n) => {
|
|
995
|
+
let o = i().filter((t) => t.source === e).length;
|
|
996
|
+
if ((t === l.ui || t === l.flow) && o > 1) {
|
|
997
|
+
a({
|
|
998
|
+
nodeId: e,
|
|
999
|
+
subType: n,
|
|
1000
|
+
type: t
|
|
1001
|
+
});
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
r(e, t, n);
|
|
1005
|
+
};
|
|
1006
|
+
return /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ P(K, {
|
|
1007
|
+
asChild: !0,
|
|
1008
|
+
onClick: s,
|
|
1009
|
+
children: /* @__PURE__ */ F(an, {
|
|
1010
|
+
variant: "default",
|
|
1011
|
+
className: "nodrag nopan cursor-pointer px-1.5 py-0 text-[10px] capitalize [&>svg]:size-2.5",
|
|
1012
|
+
children: [
|
|
1013
|
+
/* @__PURE__ */ P(d, { className: "mt-0.5" }),
|
|
1014
|
+
u || o("editor.selectNodeType.nodeType"),
|
|
1015
|
+
/* @__PURE__ */ P(Ue, {})
|
|
1016
|
+
]
|
|
1017
|
+
})
|
|
1018
|
+
}), /* @__PURE__ */ F(q, {
|
|
1019
|
+
align: "start",
|
|
1020
|
+
className: "treege-scrollbar max-h-80",
|
|
1021
|
+
onClick: s,
|
|
1022
|
+
children: [
|
|
1023
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ P(en, { children: o("editor.selectNodeType.options.input") }), hn.map((e) => {
|
|
1024
|
+
let r = Z(e);
|
|
1025
|
+
return /* @__PURE__ */ F(Y, {
|
|
1026
|
+
onClick: () => p(l.input, e),
|
|
1027
|
+
className: E("capitalize", t === l.input && e === n && "bg-accent"),
|
|
1028
|
+
children: [/* @__PURE__ */ P(r, {}), e]
|
|
1029
|
+
}, e);
|
|
1030
|
+
})] }),
|
|
1031
|
+
/* @__PURE__ */ P(tn, {}),
|
|
1032
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ P(en, { children: o("editor.selectNodeType.options.ui") }), gn.map((e) => {
|
|
1033
|
+
let r = Z(e);
|
|
1034
|
+
return /* @__PURE__ */ F(Y, {
|
|
1035
|
+
onClick: () => p(l.ui, e),
|
|
1036
|
+
className: E("capitalize", t === l.ui && e === n && "bg-accent"),
|
|
1037
|
+
children: [/* @__PURE__ */ P(r, {}), e]
|
|
1038
|
+
}, e);
|
|
1039
|
+
})] }),
|
|
1040
|
+
/* @__PURE__ */ P(tn, {}),
|
|
1041
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ P(en, { children: o("common.other") }), /* @__PURE__ */ F(Y, {
|
|
1042
|
+
onClick: () => p(l.flow),
|
|
1043
|
+
className: E(t === l.flow && "bg-accent"),
|
|
1044
|
+
children: [/* @__PURE__ */ P(f, {}), o("editor.selectNodeType.options.flow")]
|
|
1045
|
+
})] })
|
|
1046
|
+
]
|
|
1047
|
+
})] });
|
|
1048
|
+
}, vn = [
|
|
1049
|
+
"radio",
|
|
1050
|
+
"select",
|
|
1051
|
+
"checkbox",
|
|
1052
|
+
"autocomplete"
|
|
1053
|
+
], yn = ({ nodeId: e, data: t }) => {
|
|
1054
|
+
let [n, r] = z(!1), [i, a] = z(""), [o, s] = z(""), { updateNodeData: c } = W(), { language: l } = H(), u = U(), f = t && "type" in t ? t.type : void 0;
|
|
1055
|
+
if (!(f && vn.includes(f))) return null;
|
|
1056
|
+
let p = t.options ?? [], m = () => {
|
|
1057
|
+
a(""), s("");
|
|
1058
|
+
}, h = (t) => {
|
|
1059
|
+
t?.preventDefault();
|
|
1060
|
+
let n = i.trim(), a = o.trim() || n;
|
|
1061
|
+
if (!(n || a)) return;
|
|
1062
|
+
let s = {
|
|
1063
|
+
label: { [l]: n },
|
|
1064
|
+
value: a
|
|
1065
|
+
};
|
|
1066
|
+
c(e, { options: [...p, s] }), m(), r(!1);
|
|
1067
|
+
}, g = (e) => {
|
|
1068
|
+
r(e), e || m();
|
|
1069
|
+
}, _ = (e) => {
|
|
1070
|
+
e.key === "Enter" && (e.preventDefault(), h());
|
|
1071
|
+
}, v = (e) => e.stopPropagation();
|
|
1072
|
+
return /* @__PURE__ */ F("div", {
|
|
1073
|
+
className: "nodrag nopan my-1 flex flex-col gap-0.5",
|
|
1074
|
+
children: [p.map((e, t) => {
|
|
1075
|
+
let n = u(e.label) || e.value || "—", r = `${e.value || "opt"}-${t}`;
|
|
1076
|
+
return /* @__PURE__ */ P("div", {
|
|
1077
|
+
className: "truncate text-muted-foreground text-xs",
|
|
1078
|
+
children: n
|
|
1079
|
+
}, r);
|
|
1080
|
+
}), /* @__PURE__ */ F(ie, {
|
|
1081
|
+
open: n,
|
|
1082
|
+
onOpenChange: g,
|
|
1083
|
+
children: [/* @__PURE__ */ P(ne, {
|
|
1084
|
+
asChild: !0,
|
|
1085
|
+
onClick: v,
|
|
1086
|
+
children: /* @__PURE__ */ F(k, {
|
|
1087
|
+
type: "button",
|
|
1088
|
+
variant: "link",
|
|
1089
|
+
size: "xs",
|
|
1090
|
+
className: "w-fit p-0! focus-visible:border-transparent! focus-visible:ring-0!",
|
|
1091
|
+
children: [/* @__PURE__ */ P(I, { className: "size-3" }), u("editor.inputNodeForm.addOption")]
|
|
1092
|
+
})
|
|
1093
|
+
}), /* @__PURE__ */ P(ae, {
|
|
1094
|
+
align: "start",
|
|
1095
|
+
className: "w-64 p-3",
|
|
1096
|
+
onClick: v,
|
|
1097
|
+
children: /* @__PURE__ */ F("form", {
|
|
1098
|
+
onSubmit: h,
|
|
1099
|
+
className: "flex flex-col gap-2",
|
|
1100
|
+
children: [
|
|
1101
|
+
/* @__PURE__ */ F("div", {
|
|
1102
|
+
className: "flex flex-col gap-1",
|
|
1103
|
+
children: [/* @__PURE__ */ P(d, {
|
|
1104
|
+
htmlFor: `${e}-option-label`,
|
|
1105
|
+
className: "text-xs",
|
|
1106
|
+
children: u("editor.inputNodeForm.optionLabel")
|
|
1107
|
+
}), /* @__PURE__ */ P(O, {
|
|
1108
|
+
id: `${e}-option-label`,
|
|
1109
|
+
autoFocus: !0,
|
|
1110
|
+
value: i,
|
|
1111
|
+
onChange: (e) => a(e.target.value),
|
|
1112
|
+
onKeyDown: _
|
|
1113
|
+
})]
|
|
1114
|
+
}),
|
|
1115
|
+
/* @__PURE__ */ F("div", {
|
|
1116
|
+
className: "flex flex-col gap-1",
|
|
1117
|
+
children: [/* @__PURE__ */ P(d, {
|
|
1118
|
+
htmlFor: `${e}-option-value`,
|
|
1119
|
+
className: "text-xs",
|
|
1120
|
+
children: u("editor.inputNodeForm.optionValue")
|
|
1121
|
+
}), /* @__PURE__ */ P(O, {
|
|
1122
|
+
id: `${e}-option-value`,
|
|
1123
|
+
value: o,
|
|
1124
|
+
onChange: (e) => s(e.target.value),
|
|
1125
|
+
onKeyDown: _
|
|
1126
|
+
})]
|
|
1127
|
+
}),
|
|
1128
|
+
/* @__PURE__ */ P(k, {
|
|
1129
|
+
type: "submit",
|
|
1130
|
+
size: "sm",
|
|
1131
|
+
disabled: !(i.trim() || o.trim()),
|
|
1132
|
+
children: u("common.create")
|
|
1133
|
+
})
|
|
1134
|
+
]
|
|
1135
|
+
})
|
|
1136
|
+
})]
|
|
1137
|
+
})]
|
|
1138
|
+
});
|
|
1139
|
+
}, bn = ({ nodeId: e, required: t }) => {
|
|
1140
|
+
let { updateNodeData: n } = W(), r = U();
|
|
1141
|
+
return /* @__PURE__ */ P(an, {
|
|
1142
|
+
variant: t ? "destructive" : "outline",
|
|
1143
|
+
asChild: !0,
|
|
1144
|
+
className: "nodrag nopan cursor-pointer px-1.5 py-0 text-[10px] capitalize [&>svg]:size-2.5",
|
|
1145
|
+
children: /* @__PURE__ */ P("button", {
|
|
1146
|
+
type: "button",
|
|
1147
|
+
onClick: (r) => {
|
|
1148
|
+
r.stopPropagation(), n(e, { required: !t });
|
|
1149
|
+
},
|
|
1150
|
+
children: r(t ? "editor.inputNodeForm.required" : "editor.inputNodeForm.optional")
|
|
1151
|
+
})
|
|
1152
|
+
});
|
|
1153
|
+
}, xn = ({ children: e, inGroup: t, isSubmit: n }) => /* @__PURE__ */ P("div", {
|
|
1154
|
+
className: E("react-flow__node__wrapper relative", t && "in-group", n && "submit-type"),
|
|
1155
|
+
children: e
|
|
1156
|
+
}), Sn = Tt((e) => {
|
|
1157
|
+
let { id: t, isConnectable: n, parentId: r, selected: i, type: a } = e, o = e.type === "input" ? e.data : void 0, s = e.type === "ui" ? e.data : void 0, c = o?.type ?? s?.type, l = o?.type === "submit", u = !i && !!o?.type;
|
|
1158
|
+
return /* @__PURE__ */ F(xn, {
|
|
1159
|
+
inGroup: !!r,
|
|
1160
|
+
isSubmit: l,
|
|
1161
|
+
children: [
|
|
1162
|
+
/* @__PURE__ */ P(nn, { nodeId: t }),
|
|
1163
|
+
/* @__PURE__ */ P(xe, {
|
|
1164
|
+
type: "target",
|
|
1165
|
+
position: Te.Top,
|
|
1166
|
+
isConnectable: n,
|
|
1167
|
+
isConnectableStart: a === "ui"
|
|
1168
|
+
}),
|
|
1169
|
+
u && o ? /* @__PURE__ */ P(mn, {
|
|
1170
|
+
nodeId: t,
|
|
1171
|
+
data: o
|
|
1172
|
+
}) : /* @__PURE__ */ F(N, { children: [
|
|
1173
|
+
/* @__PURE__ */ P($t, {
|
|
1174
|
+
nodeId: t,
|
|
1175
|
+
label: e.data?.label,
|
|
1176
|
+
placeholder: o?.name,
|
|
1177
|
+
className: E("py-1", a === "ui" && "capitalize")
|
|
1178
|
+
}),
|
|
1179
|
+
/* @__PURE__ */ F("div", {
|
|
1180
|
+
className: "mb-1 flex gap-1",
|
|
1181
|
+
children: [/* @__PURE__ */ P(_n, {
|
|
1182
|
+
nodeId: t,
|
|
1183
|
+
nodeType: a,
|
|
1184
|
+
subType: c
|
|
1185
|
+
}), o && !l && /* @__PURE__ */ P(bn, {
|
|
1186
|
+
nodeId: t,
|
|
1187
|
+
required: o.required
|
|
1188
|
+
})]
|
|
1189
|
+
}),
|
|
1190
|
+
o && /* @__PURE__ */ P(yn, {
|
|
1191
|
+
nodeId: t,
|
|
1192
|
+
data: o
|
|
1193
|
+
})
|
|
1194
|
+
] }),
|
|
1195
|
+
/* @__PURE__ */ P(fn, {
|
|
1196
|
+
nodeId: t,
|
|
1197
|
+
isConnectable: n
|
|
1198
|
+
})
|
|
1199
|
+
]
|
|
1200
|
+
});
|
|
1201
|
+
}), Cn = {
|
|
1202
|
+
[l.flow]: Sn,
|
|
1203
|
+
[l.group]: on,
|
|
1204
|
+
[l.input]: Sn,
|
|
1205
|
+
[l.ui]: Sn
|
|
1206
|
+
}, wn = {
|
|
1207
|
+
"!==": "≠",
|
|
1208
|
+
"<": "<",
|
|
1209
|
+
"<=": "≤",
|
|
1210
|
+
"===": "=",
|
|
1211
|
+
">": ">",
|
|
1212
|
+
">=": "≥"
|
|
1213
|
+
}, Tn = (e, t) => {
|
|
1214
|
+
let n = e?.filter((e) => e.value !== void 0 && e.value !== "") ?? [];
|
|
1215
|
+
return n.length === 0 ? "" : n.map((e, n) => {
|
|
1216
|
+
let r = wn[e.operator ?? ""] ?? e.operator ?? "", i = `${e.field ? t(e.field) : ""} ${r} ${e.value ?? ""}`.trim();
|
|
1217
|
+
return `${n === 0 ? "" : ` ${e.logicalOperator ?? "AND"} `}${i}`;
|
|
1218
|
+
}).join("");
|
|
1219
|
+
}, En = () => {
|
|
1220
|
+
let { pendingNodeTypeChange: e, closeNodeTypeChangeConfirmation: t } = H(), { getEdges: n, getNode: r, setEdges: i, updateEdgeData: a } = M(), { updateNodeType: o } = W(), s = U(), c = kt(() => e ? n().filter((t) => t.source === e.nodeId).sort((e, t) => {
|
|
1221
|
+
let n = r(e.target)?.position ?? {
|
|
1222
|
+
x: 0,
|
|
1223
|
+
y: 0
|
|
1224
|
+
}, i = r(t.target)?.position ?? {
|
|
1225
|
+
x: 0,
|
|
1226
|
+
y: 0
|
|
1227
|
+
};
|
|
1228
|
+
return n.x - i.x || n.y - i.y;
|
|
1229
|
+
}) : [], [
|
|
1230
|
+
e,
|
|
1231
|
+
n,
|
|
1232
|
+
r
|
|
1233
|
+
]), [l, u] = z("");
|
|
1234
|
+
Dt(() => {
|
|
1235
|
+
c.length > 0 && u(c[0].id);
|
|
1236
|
+
}, [c]);
|
|
1237
|
+
let f = (e) => {
|
|
1238
|
+
e || t();
|
|
1239
|
+
}, h = () => {
|
|
1240
|
+
if (!(e && l)) {
|
|
1241
|
+
t();
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
let { nodeId: n, type: r, subType: s } = e;
|
|
1245
|
+
i((e) => e.filter((e) => e.source !== n || e.id === l)), a(l, {
|
|
1246
|
+
conditions: void 0,
|
|
1247
|
+
configured: void 0,
|
|
1248
|
+
isFallback: void 0
|
|
1249
|
+
}), o(n, r, s), t();
|
|
1250
|
+
}, g = (e) => {
|
|
1251
|
+
let t = r(e)?.data;
|
|
1252
|
+
return s(t && "label" in t ? t.label : void 0) || t?.name || (e.length > 5 ? `${e.slice(0, 5)}…` : e);
|
|
1253
|
+
}, v = (e) => {
|
|
1254
|
+
let t = r(e)?.data, n = s(t?.label) || t?.name || e;
|
|
1255
|
+
return n === e && n.length > 5 ? `${n.slice(0, 5)}…` : n;
|
|
1256
|
+
}, y = (e) => e?.isFallback ? s("editor.conditionalEdge.fallback") : e?.label ? e.label : Tn(e?.conditions, v) || s("editor.changeNodeTypeDialog.noConditions");
|
|
1257
|
+
return /* @__PURE__ */ P(m, {
|
|
1258
|
+
open: e !== null,
|
|
1259
|
+
onOpenChange: f,
|
|
1260
|
+
children: /* @__PURE__ */ F(_, {
|
|
1261
|
+
showCloseButton: !1,
|
|
1262
|
+
children: [
|
|
1263
|
+
/* @__PURE__ */ F(he, { children: [/* @__PURE__ */ P(p, { children: s("editor.changeNodeTypeDialog.title") }), /* @__PURE__ */ P(b, { children: s("editor.changeNodeTypeDialog.description") })] }),
|
|
1264
|
+
/* @__PURE__ */ P(Gt, {
|
|
1265
|
+
className: "max-h-80",
|
|
1266
|
+
children: /* @__PURE__ */ P(oe, {
|
|
1267
|
+
value: l,
|
|
1268
|
+
onValueChange: u,
|
|
1269
|
+
className: "gap-2 pr-2",
|
|
1270
|
+
children: c.map((e) => {
|
|
1271
|
+
let t = e.data, n = y(t), r = g(e.target);
|
|
1272
|
+
return /* @__PURE__ */ F(d, {
|
|
1273
|
+
htmlFor: `keep-${e.id}`,
|
|
1274
|
+
className: "flex cursor-pointer items-start gap-3 rounded-lg border bg-muted/20 p-3",
|
|
1275
|
+
children: [/* @__PURE__ */ P(me, {
|
|
1276
|
+
id: `keep-${e.id}`,
|
|
1277
|
+
value: e.id,
|
|
1278
|
+
className: "mt-1"
|
|
1279
|
+
}), /* @__PURE__ */ F("div", {
|
|
1280
|
+
className: "flex flex-col gap-1",
|
|
1281
|
+
children: [/* @__PURE__ */ P("span", {
|
|
1282
|
+
className: "font-medium",
|
|
1283
|
+
children: r
|
|
1284
|
+
}), /* @__PURE__ */ P("span", {
|
|
1285
|
+
className: "text-muted-foreground text-xs",
|
|
1286
|
+
children: n
|
|
1287
|
+
})]
|
|
1288
|
+
})]
|
|
1289
|
+
}, e.id);
|
|
1290
|
+
})
|
|
1291
|
+
})
|
|
1292
|
+
}),
|
|
1293
|
+
/* @__PURE__ */ F(S, { children: [/* @__PURE__ */ P(k, {
|
|
1294
|
+
variant: "outline",
|
|
1295
|
+
onClick: t,
|
|
1296
|
+
children: s("common.cancel")
|
|
1297
|
+
}), /* @__PURE__ */ P(k, {
|
|
1298
|
+
onClick: h,
|
|
1299
|
+
disabled: !l,
|
|
1300
|
+
children: s("editor.changeNodeTypeDialog.keepBranch")
|
|
1301
|
+
})] })
|
|
1302
|
+
]
|
|
1303
|
+
})
|
|
1304
|
+
});
|
|
1305
|
+
}, Dn = () => {
|
|
1306
|
+
let { pendingDeleteNodeId: e, closeDeleteNodeConfirmation: t } = H(), { deleteNode: n } = W(), r = U();
|
|
1307
|
+
return /* @__PURE__ */ P(m, {
|
|
1308
|
+
open: e !== null,
|
|
1309
|
+
onOpenChange: (e) => {
|
|
1310
|
+
e || t();
|
|
1311
|
+
},
|
|
1312
|
+
children: /* @__PURE__ */ F(_, {
|
|
1313
|
+
showCloseButton: !1,
|
|
1314
|
+
children: [/* @__PURE__ */ F(he, { children: [/* @__PURE__ */ P(p, { children: r("editor.nodeActionsSheet.deleteNode") }), /* @__PURE__ */ P(b, { children: r("editor.nodeActionsSheet.deleteNodeConfirm") })] }), /* @__PURE__ */ F(S, { children: [/* @__PURE__ */ P(k, {
|
|
1315
|
+
variant: "outline",
|
|
1316
|
+
onClick: t,
|
|
1317
|
+
children: r("common.cancel")
|
|
1318
|
+
}), /* @__PURE__ */ P(k, {
|
|
1319
|
+
onClick: () => {
|
|
1320
|
+
e && n(e), t();
|
|
1321
|
+
},
|
|
1322
|
+
children: r("common.delete")
|
|
1323
|
+
})] })]
|
|
1324
|
+
})
|
|
1325
|
+
});
|
|
1326
|
+
}, On = "You are a Treege decision tree generator. You must generate valid JSON structures for decision trees.\n\nIMPORTANT RULES:\n1. Always respond with valid JSON only, no markdown, no code blocks, no explanations outside the JSON\n2. The JSON must have this exact structure: { \"nodes\": [...], \"edges\": [...] }\n3. Every node must have: id (string), type (string), position ({ x: number, y: number }), data (object)\n4. Every edge must have: id (string), source (string), target (string)\n5. For regex patterns: ALWAYS use double backslashes (\\\\) for special characters (\\\\s, \\\\d, etc.)\n6. AVOID using \"pattern\" field unless specifically requested - prefer using simple validation\n7. For submit buttons, use type \"input\" with data.type \"submit\", NOT type \"flow\"\n8. For conditional logic, use conditional edges with proper operators (===, !==, >, <, >=, <=)\n\nNODE TYPES:\n- \"input\": Form input fields (text, number, select, checkbox, etc.)\n- \"ui\": UI elements (title, divider)\n- \"flow\": Navigation/flow control nodes\n- \"group\": Container for organizing nodes\n\nINPUT NODE TYPES (data.type):\n- \"text\", \"number\", \"textarea\", \"password\"\n- \"select\", \"radio\", \"checkbox\", \"switch\"\n- \"autocomplete\", \"date\", \"daterange\", \"time\", \"timerange\"\n- \"file\", \"address\", \"http\", \"hidden\", \"submit\"\n\nINPUT NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"Field Label\",\n \"name\": \"fieldName\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"Enter value...\",\n \"helperText\": \"Optional helper text\",\n \"pattern\": \"regex pattern (optional)\",\n \"errorMessage\": \"Error message if validation fails\",\n \"options\": [{ \"value\": \"val\", \"label\": \"Label\" }], // for select/radio/checkbox\n \"multiple\": false // for select/checkbox\n }\n}\n\nUI NODE TYPES (data.type):\n- \"title\": Display a title\n- \"divider\": Display a divider line\n\nUI NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"UI Element Label\",\n \"type\": \"title\" // or \"divider\"\n }\n}\n\nFLOW NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"flow\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"Flow Step Label\",\n \"targetId\": \"next-node-id\" // optional\n }\n}\n\nGROUP NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"group\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"Group Label\"\n }\n}\n\nEDGE STRUCTURE:\n{\n \"id\": \"edge-id\",\n \"source\": \"source-node-id\",\n \"target\": \"target-node-id\",\n \"type\": \"default\" // or \"conditional\" for conditional logic\n}\n\nCONDITIONAL EDGE STRUCTURE:\n{\n \"id\": \"edge-id\",\n \"source\": \"source-node-id\",\n \"target\": \"target-node-id\",\n \"type\": \"conditional\",\n \"data\": {\n \"label\": \"If condition is true\", // optional label for the edge\n \"conditions\": [\n {\n \"field\": \"field-node-id\", // ID of the field to check\n \"operator\": \">=\", // operators: ===, !==, >, <, >=, <=\n \"value\": \"18\" // value to compare (as string)\n }\n ],\n \"operator\": \"AND\" // optional: \"AND\" or \"OR\" for multiple conditions (default: AND)\n }\n}\n\nIMPORTANT: For conditional edges, the value must ALWAYS be a string, even for numbers.\nExample: For \"age >= 18\", use \"value\": \"18\" (not value: 18)\n\nLAYOUT GUIDELINES:\n- Position nodes in a vertical flow (top to bottom)\n- Start at position { x: 0, y: 0 }\n- Space nodes vertically by exactly 250 pixels between each position (node height 150px + 100px spacing)\n- For horizontal spacing, use 350 pixels\n- Create logical flow from top to bottom\n- IMPORTANT: Keep consistent vertical spacing to avoid overlap\n- Each node position Y should increment by 250: first at y:0, second at y:250, third at y:500, etc.\n\nEXAMPLES:\n\nUser: \"Create a simple contact form with name, email and message\"\nResponse:\n{\n \"nodes\": [\n {\n \"id\": \"title-1\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": { \"label\": \"Contact Form\", \"type\": \"title\" }\n },\n {\n \"id\": \"name-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 250 },\n \"data\": {\n \"label\": \"Name\",\n \"name\": \"name\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"Enter your name\"\n }\n },\n {\n \"id\": \"email-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 500 },\n \"data\": {\n \"label\": \"Email\",\n \"name\": \"email\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"your@email.com\"\n }\n },\n {\n \"id\": \"message-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 750 },\n \"data\": {\n \"label\": \"Message\",\n \"name\": \"message\",\n \"type\": \"textarea\",\n \"required\": true,\n \"placeholder\": \"Enter your message\"\n }\n }\n ],\n \"edges\": [\n { \"id\": \"e1\", \"source\": \"title-1\", \"target\": \"name-1\" },\n { \"id\": \"e2\", \"source\": \"name-1\", \"target\": \"email-1\" },\n { \"id\": \"e3\", \"source\": \"email-1\", \"target\": \"message-1\" }\n ]\n}\n\nUser: \"Create a user registration form with age, address and country selector\"\nResponse:\n{\n \"nodes\": [\n {\n \"id\": \"title-1\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": { \"label\": \"User Registration\", \"type\": \"title\" }\n },\n {\n \"id\": \"age-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 250 },\n \"data\": {\n \"label\": \"Age\",\n \"name\": \"age\",\n \"type\": \"number\",\n \"required\": true,\n \"placeholder\": \"Enter your age\"\n }\n },\n {\n \"id\": \"address-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 500 },\n \"data\": {\n \"label\": \"Address\",\n \"name\": \"address\",\n \"type\": \"address\",\n \"required\": true,\n \"placeholder\": \"Enter your address\"\n }\n },\n {\n \"id\": \"country-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 750 },\n \"data\": {\n \"label\": \"Country\",\n \"name\": \"country\",\n \"type\": \"select\",\n \"required\": true,\n \"options\": [\n { \"value\": \"us\", \"label\": \"United States\" },\n { \"value\": \"ca\", \"label\": \"Canada\" },\n { \"value\": \"uk\", \"label\": \"United Kingdom\" },\n { \"value\": \"fr\", \"label\": \"France\" },\n { \"value\": \"de\", \"label\": \"Germany\" }\n ]\n }\n },\n {\n \"id\": \"submit-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 1000 },\n \"data\": {\n \"label\": \"Submit\",\n \"type\": \"submit\"\n }\n }\n ],\n \"edges\": [\n { \"id\": \"e1\", \"source\": \"title-1\", \"target\": \"age-1\" },\n { \"id\": \"e2\", \"source\": \"age-1\", \"target\": \"address-1\" },\n { \"id\": \"e3\", \"source\": \"address-1\", \"target\": \"country-1\" },\n { \"id\": \"e4\", \"source\": \"country-1\", \"target\": \"submit-1\" }\n ]\n}\n\nUser: \"Create a form with name, age, and show different questions based on age (movie for 18+, color for under 18)\"\nResponse:\n{\n \"nodes\": [\n {\n \"id\": \"title-1\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": { \"label\": \"Survey Form\", \"type\": \"title\" }\n },\n {\n \"id\": \"name-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 250 },\n \"data\": {\n \"label\": \"Name\",\n \"name\": \"name\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"Enter your name\"\n }\n },\n {\n \"id\": \"age-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 500 },\n \"data\": {\n \"label\": \"Age\",\n \"name\": \"age\",\n \"type\": \"number\",\n \"required\": true,\n \"placeholder\": \"Enter your age\"\n }\n },\n {\n \"id\": \"movie-1\",\n \"type\": \"input\",\n \"position\": { \"x\": -350, \"y\": 750 },\n \"data\": {\n \"label\": \"Favorite Movie\",\n \"name\": \"favoriteMovie\",\n \"type\": \"text\",\n \"required\": true,\n \"helperText\": \"For adults 18 and over\"\n }\n },\n {\n \"id\": \"color-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 350, \"y\": 750 },\n \"data\": {\n \"label\": \"Favorite Color\",\n \"name\": \"favoriteColor\",\n \"type\": \"text\",\n \"required\": true,\n \"helperText\": \"For those under 18\"\n }\n },\n {\n \"id\": \"submit-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 1000 },\n \"data\": {\n \"label\": \"Submit\",\n \"type\": \"submit\"\n }\n }\n ],\n \"edges\": [\n { \"id\": \"e1\", \"source\": \"title-1\", \"target\": \"name-1\" },\n { \"id\": \"e2\", \"source\": \"name-1\", \"target\": \"age-1\" },\n {\n \"id\": \"e3\",\n \"source\": \"age-1\",\n \"target\": \"movie-1\",\n \"type\": \"conditional\",\n \"data\": {\n \"label\": \"If 18 or older\",\n \"conditions\": [\n {\n \"field\": \"age-1\",\n \"operator\": \">=\",\n \"value\": \"18\"\n }\n ]\n }\n },\n {\n \"id\": \"e4\",\n \"source\": \"age-1\",\n \"target\": \"color-1\",\n \"type\": \"conditional\",\n \"data\": {\n \"label\": \"If under 18\",\n \"conditions\": [\n {\n \"field\": \"age-1\",\n \"operator\": \"<\",\n \"value\": \"18\"\n }\n ]\n }\n },\n { \"id\": \"e5\", \"source\": \"movie-1\", \"target\": \"submit-1\" },\n { \"id\": \"e6\", \"source\": \"color-1\", \"target\": \"submit-1\" }\n ]\n}\n\nRemember:\n- Always respond with ONLY valid JSON\n- No markdown code blocks\n- No explanations outside the JSON\n- Follow the exact structure shown above\n- For submit buttons, ALWAYS use type \"input\" with data.type \"submit\"\n- For conditional edges, ALWAYS specify the value as a string and use proper operators (>=, <, ===, etc.)\n- Never leave condition values empty - always provide the comparison value\n", kn = {
|
|
1327
|
+
claude: "claude-3-5-haiku-20241022",
|
|
1328
|
+
deepseek: "deepseek-chat",
|
|
1329
|
+
gemini: "gemini-2.5-flash",
|
|
1330
|
+
openai: "gpt-4o-mini"
|
|
1331
|
+
}, An = .3;
|
|
1332
|
+
function jn(e) {
|
|
1333
|
+
try {
|
|
1334
|
+
return JSON.parse(e);
|
|
1335
|
+
} catch (t) {
|
|
1336
|
+
let n = e.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
|
|
1337
|
+
try {
|
|
1338
|
+
return JSON.parse(n);
|
|
1339
|
+
} catch {
|
|
1340
|
+
throw console.error("Failed to parse AI response:", e.substring(0, 500)), Error(`Invalid JSON response from AI: ${t instanceof Error ? t.message : "Unknown error"}`);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
async function Mn(e) {
|
|
1345
|
+
let t = e.config.model || kn.gemini, n = e.config.temperature ?? An, r = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${t}:generateContent?key=${e.config.apiKey}`, {
|
|
1346
|
+
body: JSON.stringify({
|
|
1347
|
+
contents: [{ parts: [{ text: `${On}\n\nUser request: ${e.prompt}` }] }],
|
|
1348
|
+
generationConfig: {
|
|
1349
|
+
responseMimeType: "application/json",
|
|
1350
|
+
temperature: n
|
|
1351
|
+
}
|
|
1352
|
+
}),
|
|
1353
|
+
headers: { "Content-Type": "application/json" },
|
|
1354
|
+
method: "POST"
|
|
1355
|
+
});
|
|
1356
|
+
if (!r.ok) {
|
|
1357
|
+
let e = await r.text();
|
|
1358
|
+
throw Error(`Gemini API error: ${e}`);
|
|
1359
|
+
}
|
|
1360
|
+
let i = (await r.json()).candidates?.[0]?.content?.parts?.[0]?.text;
|
|
1361
|
+
if (!i) throw Error("No response from Gemini");
|
|
1362
|
+
return jn(i);
|
|
1363
|
+
}
|
|
1364
|
+
async function Nn(e) {
|
|
1365
|
+
let t = e.config.model || kn.openai, n = e.config.temperature ?? An, r = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
1366
|
+
body: JSON.stringify({
|
|
1367
|
+
messages: [{
|
|
1368
|
+
content: On,
|
|
1369
|
+
role: "system"
|
|
1370
|
+
}, {
|
|
1371
|
+
content: e.prompt,
|
|
1372
|
+
role: "user"
|
|
1373
|
+
}],
|
|
1374
|
+
model: t,
|
|
1375
|
+
response_format: { type: "json_object" },
|
|
1376
|
+
temperature: n
|
|
1377
|
+
}),
|
|
1378
|
+
headers: {
|
|
1379
|
+
Authorization: `Bearer ${e.config.apiKey}`,
|
|
1380
|
+
"Content-Type": "application/json"
|
|
1381
|
+
},
|
|
1382
|
+
method: "POST"
|
|
1383
|
+
});
|
|
1384
|
+
if (!r.ok) {
|
|
1385
|
+
let e = await r.text();
|
|
1386
|
+
throw Error(`OpenAI API error: ${e}`);
|
|
1387
|
+
}
|
|
1388
|
+
let i = (await r.json()).choices?.[0]?.message?.content;
|
|
1389
|
+
if (!i) throw Error("No response from OpenAI");
|
|
1390
|
+
return jn(i);
|
|
1391
|
+
}
|
|
1392
|
+
async function Pn(e) {
|
|
1393
|
+
let t = e.config.model || kn.deepseek, n = e.config.temperature ?? An, r = await fetch("https://api.deepseek.com/v1/chat/completions", {
|
|
1394
|
+
body: JSON.stringify({
|
|
1395
|
+
messages: [{
|
|
1396
|
+
content: On,
|
|
1397
|
+
role: "system"
|
|
1398
|
+
}, {
|
|
1399
|
+
content: e.prompt,
|
|
1400
|
+
role: "user"
|
|
1401
|
+
}],
|
|
1402
|
+
model: t,
|
|
1403
|
+
response_format: { type: "json_object" },
|
|
1404
|
+
temperature: n
|
|
1405
|
+
}),
|
|
1406
|
+
headers: {
|
|
1407
|
+
Authorization: `Bearer ${e.config.apiKey}`,
|
|
1408
|
+
"Content-Type": "application/json"
|
|
1409
|
+
},
|
|
1410
|
+
method: "POST"
|
|
1411
|
+
});
|
|
1412
|
+
if (!r.ok) {
|
|
1413
|
+
let e = await r.text();
|
|
1414
|
+
throw Error(`DeepSeek API error: ${e}`);
|
|
1415
|
+
}
|
|
1416
|
+
let i = (await r.json()).choices?.[0]?.message?.content;
|
|
1417
|
+
if (!i) throw Error("No response from DeepSeek");
|
|
1418
|
+
return jn(i);
|
|
1419
|
+
}
|
|
1420
|
+
async function Fn(e) {
|
|
1421
|
+
let t = e.config.model || kn.claude, n = e.config.temperature ?? An, r = await fetch("https://api.anthropic.com/v1/messages", {
|
|
1422
|
+
body: JSON.stringify({
|
|
1423
|
+
max_tokens: 4096,
|
|
1424
|
+
messages: [{
|
|
1425
|
+
content: e.prompt,
|
|
1426
|
+
role: "user"
|
|
1427
|
+
}],
|
|
1428
|
+
model: t,
|
|
1429
|
+
system: On,
|
|
1430
|
+
temperature: n
|
|
1431
|
+
}),
|
|
1432
|
+
headers: {
|
|
1433
|
+
"anthropic-version": "2023-06-01",
|
|
1434
|
+
"Content-Type": "application/json",
|
|
1435
|
+
"x-api-key": e.config.apiKey
|
|
1436
|
+
},
|
|
1437
|
+
method: "POST"
|
|
1438
|
+
});
|
|
1439
|
+
if (!r.ok) {
|
|
1440
|
+
let e = await r.text();
|
|
1441
|
+
throw Error(`Claude API error: ${e}`);
|
|
1442
|
+
}
|
|
1443
|
+
let i = (await r.json()).content?.[0]?.text;
|
|
1444
|
+
if (!i) throw Error("No response from Claude");
|
|
1445
|
+
return jn(i);
|
|
1446
|
+
}
|
|
1447
|
+
function In(e) {
|
|
1448
|
+
switch (e.config.provider) {
|
|
1449
|
+
case "gemini": return Mn(e);
|
|
1450
|
+
case "openai": return Nn(e);
|
|
1451
|
+
case "deepseek": return Pn(e);
|
|
1452
|
+
case "claude": return Fn(e);
|
|
1453
|
+
default: throw Error(`Unsupported AI provider: ${e.config.provider}`);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
//#endregion
|
|
1457
|
+
//#region src/editor/features/TreegeEditor/panel/AIGeneratorDialog.tsx
|
|
1458
|
+
var Ln = ({ aiConfig: e, onGenerate: t }) => {
|
|
1459
|
+
let [n, r] = z(!1), [i, a] = z(""), [o, s] = z(!1), c = U(), l = async () => {
|
|
1460
|
+
if (!i.trim()) {
|
|
1461
|
+
V.error(c("editor.aiGenerator.enterDescription"));
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (!e?.apiKey) {
|
|
1465
|
+
V.error(c("editor.aiGenerator.missingApiKey"), { description: c("editor.aiGenerator.missingApiKeyDesc") });
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
s(!0);
|
|
1469
|
+
try {
|
|
1470
|
+
let n = await In({
|
|
1471
|
+
config: e,
|
|
1472
|
+
prompt: i.trim()
|
|
1473
|
+
});
|
|
1474
|
+
t({
|
|
1475
|
+
edges: n.edges,
|
|
1476
|
+
nodes: n.nodes
|
|
1477
|
+
}), V.success(c("editor.aiGenerator.successTitle"), { description: c("editor.aiGenerator.successDescription").replace("{nodes}", String(n.nodes.length)).replace("{edges}", String(n.edges.length)) }), a(""), r(!1);
|
|
1478
|
+
} catch (e) {
|
|
1479
|
+
console.error("AI generation error:", e), V.error(c("editor.aiGenerator.failedToGenerate"), { description: e instanceof Error ? e.message : c("editor.aiGenerator.unknownError") });
|
|
1480
|
+
} finally {
|
|
1481
|
+
s(!1);
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
return /* @__PURE__ */ F(m, {
|
|
1485
|
+
open: n,
|
|
1486
|
+
onOpenChange: r,
|
|
1487
|
+
children: [/* @__PURE__ */ P(re, {
|
|
1488
|
+
asChild: !0,
|
|
1489
|
+
children: /* @__PURE__ */ F(k, {
|
|
1490
|
+
variant: "outline",
|
|
1491
|
+
size: "sm",
|
|
1492
|
+
disabled: !e?.apiKey,
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ P(xt, { className: "h-4 w-4 text-[#13d3b4]" }),
|
|
1495
|
+
" ",
|
|
1496
|
+
c("editor.aiGenerator.buttonLabel")
|
|
1497
|
+
]
|
|
1498
|
+
})
|
|
1499
|
+
}), /* @__PURE__ */ F(_, {
|
|
1500
|
+
className: "sm:max-w-[550px]!",
|
|
1501
|
+
children: [
|
|
1502
|
+
/* @__PURE__ */ F(he, { children: [/* @__PURE__ */ P(p, { children: c("editor.aiGenerator.title") }), /* @__PURE__ */ P(b, { children: c("editor.aiGenerator.titleDescription") })] }),
|
|
1503
|
+
/* @__PURE__ */ F("div", {
|
|
1504
|
+
className: "grid gap-4 py-4",
|
|
1505
|
+
children: [/* @__PURE__ */ F("div", {
|
|
1506
|
+
className: "grid gap-2",
|
|
1507
|
+
children: [
|
|
1508
|
+
/* @__PURE__ */ P("label", {
|
|
1509
|
+
htmlFor: "ai-prompt",
|
|
1510
|
+
className: "font-medium text-sm",
|
|
1511
|
+
children: c("editor.aiGenerator.description")
|
|
1512
|
+
}),
|
|
1513
|
+
/* @__PURE__ */ P(le, {
|
|
1514
|
+
placeholder: c("editor.aiGenerator.descriptionPlaceholder"),
|
|
1515
|
+
value: i,
|
|
1516
|
+
onChange: (e) => a(e.target.value),
|
|
1517
|
+
onKeyDown: (e) => {
|
|
1518
|
+
(e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), l());
|
|
1519
|
+
},
|
|
1520
|
+
rows: 6,
|
|
1521
|
+
disabled: o,
|
|
1522
|
+
className: "resize-none"
|
|
1523
|
+
}),
|
|
1524
|
+
/* @__PURE__ */ P("p", {
|
|
1525
|
+
className: "text-muted-foreground text-xs",
|
|
1526
|
+
children: c("editor.aiGenerator.keyboardShortcut").replace("{cmdEnter}", "⌘ Enter").replace("{ctrlEnter}", "Ctrl Enter")
|
|
1527
|
+
})
|
|
1528
|
+
]
|
|
1529
|
+
}), !e?.apiKey && /* @__PURE__ */ F("div", {
|
|
1530
|
+
className: "rounded-md bg-muted p-3 text-sm",
|
|
1531
|
+
children: [/* @__PURE__ */ P("p", {
|
|
1532
|
+
className: "font-medium",
|
|
1533
|
+
children: c("editor.aiGenerator.aiNotConfigured")
|
|
1534
|
+
}), /* @__PURE__ */ F("p", {
|
|
1535
|
+
className: "mt-1 text-muted-foreground text-xs",
|
|
1536
|
+
children: [
|
|
1537
|
+
c("editor.aiGenerator.aiNotConfiguredDesc").replace("{code}", ""),
|
|
1538
|
+
" ",
|
|
1539
|
+
/* @__PURE__ */ P("code", {
|
|
1540
|
+
className: "rounded bg-background px-1 py-0.5",
|
|
1541
|
+
children: "aiConfig"
|
|
1542
|
+
})
|
|
1543
|
+
]
|
|
1544
|
+
})]
|
|
1545
|
+
})]
|
|
1546
|
+
}),
|
|
1547
|
+
/* @__PURE__ */ F(S, { children: [/* @__PURE__ */ P(k, {
|
|
1548
|
+
variant: "outline",
|
|
1549
|
+
onClick: () => r(!1),
|
|
1550
|
+
disabled: o,
|
|
1551
|
+
children: c("editor.aiGenerator.cancel")
|
|
1552
|
+
}), /* @__PURE__ */ P(k, {
|
|
1553
|
+
onClick: l,
|
|
1554
|
+
disabled: o || !i.trim() || !e?.apiKey,
|
|
1555
|
+
children: o ? /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(at, { className: "h-4 w-4 animate-spin" }), c("editor.aiGenerator.generating")] }) : /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(xt, { className: "h-4 w-4 text-[--treege-color-primary]" }), c("editor.aiGenerator.generate")] })
|
|
1556
|
+
})] })
|
|
1557
|
+
]
|
|
1558
|
+
})]
|
|
1559
|
+
});
|
|
1560
|
+
}, Rn = Zt(), zn = ({ onExportJson: e, onSave: t }) => {
|
|
1561
|
+
let { flowId: n, setFlowId: r, aiConfig: i } = H(), { setNodes: a, setEdges: o, addNodes: s, screenToFlowPosition: c } = M(), l = n || Rn, u = je(), d = Ae(), f = At(null), p = U(), m = () => {
|
|
1562
|
+
let e = (window.innerWidth || 0) / 2, t = (window.innerHeight || 0) / 2, n = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-width"), 10), r = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-height"), 10), i = c({
|
|
1563
|
+
x: e - n,
|
|
1564
|
+
y: t - r
|
|
1565
|
+
});
|
|
1566
|
+
s([{
|
|
1567
|
+
...sn,
|
|
1568
|
+
id: Zt(),
|
|
1569
|
+
position: i,
|
|
1570
|
+
selected: !0
|
|
1571
|
+
}]);
|
|
1572
|
+
}, h = ({ target: e }) => {
|
|
1573
|
+
let t = e.files?.[0];
|
|
1574
|
+
if (!t) return;
|
|
1575
|
+
let n = new FileReader();
|
|
1576
|
+
n.onload = (e) => {
|
|
1577
|
+
try {
|
|
1578
|
+
let t = JSON.parse(e.target?.result);
|
|
1579
|
+
t && Array.isArray(t.nodes) && Array.isArray(t.edges) ? (a(t.nodes), o(t.edges), V.success(p("editor.actionsPanel.importSuccess"), { description: p("editor.actionsPanel.importSuccessDesc") })) : V.error(p("editor.actionsPanel.invalidJson"), { description: p("editor.actionsPanel.invalidJsonDesc") });
|
|
1580
|
+
} catch (e) {
|
|
1581
|
+
console.warn(e), V.error(p("editor.actionsPanel.parseError"), { description: p("editor.actionsPanel.parseErrorDesc") });
|
|
1582
|
+
}
|
|
1583
|
+
f.current && (f.current.value = "");
|
|
1584
|
+
}, n.readAsText(t);
|
|
1585
|
+
}, g = () => {
|
|
1586
|
+
let t = {
|
|
1587
|
+
edges: d,
|
|
1588
|
+
id: l,
|
|
1589
|
+
nodes: u
|
|
1590
|
+
}, i = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
1591
|
+
o.href = a, o.download = "treege.json", o.click(), URL.revokeObjectURL(a), V.success(p("editor.actionsPanel.downloadSuccess"), { description: p("editor.actionsPanel.downloadSuccessDesc") }), n || r?.(l), e?.(t);
|
|
1592
|
+
}, _ = R(() => {
|
|
1593
|
+
n || r?.(l), t?.({
|
|
1594
|
+
edges: d,
|
|
1595
|
+
id: l,
|
|
1596
|
+
nodes: u
|
|
1597
|
+
});
|
|
1598
|
+
}, [
|
|
1599
|
+
d,
|
|
1600
|
+
n,
|
|
1601
|
+
l,
|
|
1602
|
+
u,
|
|
1603
|
+
t,
|
|
1604
|
+
r
|
|
1605
|
+
]);
|
|
1606
|
+
return Dt(() => {
|
|
1607
|
+
let e = (e) => {
|
|
1608
|
+
(e.ctrlKey || e.metaKey) && e.key === "s" && (e.preventDefault(), _());
|
|
1609
|
+
};
|
|
1610
|
+
return window.addEventListener("keydown", e), () => {
|
|
1611
|
+
window.removeEventListener("keydown", e);
|
|
1612
|
+
};
|
|
1613
|
+
}, [_]), /* @__PURE__ */ F(we, {
|
|
1614
|
+
position: "top-right",
|
|
1615
|
+
className: "flex gap-2",
|
|
1616
|
+
children: [
|
|
1617
|
+
/* @__PURE__ */ P(Ln, {
|
|
1618
|
+
aiConfig: i,
|
|
1619
|
+
onGenerate: (e) => {
|
|
1620
|
+
a(e.nodes), o(e.edges);
|
|
1621
|
+
}
|
|
1622
|
+
}),
|
|
1623
|
+
/* @__PURE__ */ F(k, {
|
|
1624
|
+
variant: "outline",
|
|
1625
|
+
size: "sm",
|
|
1626
|
+
onClick: m,
|
|
1627
|
+
children: [
|
|
1628
|
+
/* @__PURE__ */ P(I, {}),
|
|
1629
|
+
" ",
|
|
1630
|
+
p("editor.actionsPanel.addNode")
|
|
1631
|
+
]
|
|
1632
|
+
}),
|
|
1633
|
+
/* @__PURE__ */ F(k, {
|
|
1634
|
+
variant: "outline",
|
|
1635
|
+
size: "sm",
|
|
1636
|
+
onClick: _,
|
|
1637
|
+
children: [
|
|
1638
|
+
/* @__PURE__ */ P(pt, {}),
|
|
1639
|
+
" ",
|
|
1640
|
+
p("common.save")
|
|
1641
|
+
]
|
|
1642
|
+
}),
|
|
1643
|
+
/* @__PURE__ */ F(G, { children: [/* @__PURE__ */ P(K, {
|
|
1644
|
+
asChild: !0,
|
|
1645
|
+
children: /* @__PURE__ */ P(k, {
|
|
1646
|
+
variant: "outline",
|
|
1647
|
+
size: "sm",
|
|
1648
|
+
children: /* @__PURE__ */ P(Ze, {})
|
|
1649
|
+
})
|
|
1650
|
+
}), /* @__PURE__ */ F(q, {
|
|
1651
|
+
align: "start",
|
|
1652
|
+
children: [
|
|
1653
|
+
/* @__PURE__ */ P(en, {
|
|
1654
|
+
className: "font-normal",
|
|
1655
|
+
children: /* @__PURE__ */ F("div", {
|
|
1656
|
+
className: "flex flex-col gap-1",
|
|
1657
|
+
children: [/* @__PURE__ */ P("span", {
|
|
1658
|
+
className: "text-muted-foreground text-xs",
|
|
1659
|
+
children: "Flow ID"
|
|
1660
|
+
}), /* @__PURE__ */ F("button", {
|
|
1661
|
+
onClick: async () => {
|
|
1662
|
+
try {
|
|
1663
|
+
await navigator.clipboard.writeText(l), V.success(p("editor.actionsPanel.idCopied"), { description: l });
|
|
1664
|
+
} catch {
|
|
1665
|
+
V.error(p("editor.actionsPanel.copyFailed"));
|
|
1666
|
+
}
|
|
1667
|
+
},
|
|
1668
|
+
className: "flex items-center gap-2 font-mono text-muted-foreground transition-colors hover:text-primary",
|
|
1669
|
+
type: "button",
|
|
1670
|
+
children: [/* @__PURE__ */ P(Ye, { className: "h-3 w-3" }), /* @__PURE__ */ P("span", {
|
|
1671
|
+
className: "truncate text-xs",
|
|
1672
|
+
children: l
|
|
1673
|
+
})]
|
|
1674
|
+
})]
|
|
1675
|
+
})
|
|
1676
|
+
}),
|
|
1677
|
+
/* @__PURE__ */ P(tn, {}),
|
|
1678
|
+
/* @__PURE__ */ F(J, { children: [/* @__PURE__ */ F(Y, {
|
|
1679
|
+
onClick: () => f?.current?.click(),
|
|
1680
|
+
children: [
|
|
1681
|
+
/* @__PURE__ */ P(Xe, {}),
|
|
1682
|
+
" ",
|
|
1683
|
+
p("editor.actionsPanel.importJson")
|
|
1684
|
+
]
|
|
1685
|
+
}), /* @__PURE__ */ F(Y, {
|
|
1686
|
+
onClick: g,
|
|
1687
|
+
children: [
|
|
1688
|
+
/* @__PURE__ */ P(Ie, {}),
|
|
1689
|
+
" ",
|
|
1690
|
+
p("editor.actionsPanel.exportJson")
|
|
1691
|
+
]
|
|
1692
|
+
})] }),
|
|
1693
|
+
/* @__PURE__ */ P(tn, {}),
|
|
1694
|
+
/* @__PURE__ */ P(J, { children: /* @__PURE__ */ F(Y, {
|
|
1695
|
+
onClick: () => {
|
|
1696
|
+
a([]), o([]), V.success(p("editor.actionsPanel.clearSuccess"), { description: p("editor.actionsPanel.clearSuccessDesc") });
|
|
1697
|
+
},
|
|
1698
|
+
className: "text-destructive focus:text-destructive",
|
|
1699
|
+
children: [
|
|
1700
|
+
/* @__PURE__ */ P(vt, { className: "text-destructive" }),
|
|
1701
|
+
" ",
|
|
1702
|
+
p("editor.actionsPanel.clear")
|
|
1703
|
+
]
|
|
1704
|
+
}) })
|
|
1705
|
+
]
|
|
1706
|
+
})] }),
|
|
1707
|
+
/* @__PURE__ */ P("input", {
|
|
1708
|
+
type: "file",
|
|
1709
|
+
accept: "application/json,.json",
|
|
1710
|
+
className: "hidden",
|
|
1711
|
+
ref: f,
|
|
1712
|
+
onChange: h
|
|
1713
|
+
})
|
|
1714
|
+
]
|
|
1715
|
+
});
|
|
1716
|
+
}, Bn = {
|
|
1717
|
+
ar: "ar",
|
|
1718
|
+
de: "de",
|
|
1719
|
+
en: "en",
|
|
1720
|
+
es: "es",
|
|
1721
|
+
fr: "fr",
|
|
1722
|
+
it: "it",
|
|
1723
|
+
pt: "pt"
|
|
1724
|
+
}, Q = ({ value: e = "en", onValueChange: t }) => /* @__PURE__ */ F(g, {
|
|
1725
|
+
value: e,
|
|
1726
|
+
onValueChange: t,
|
|
1727
|
+
children: [/* @__PURE__ */ P(v, {
|
|
1728
|
+
className: "uppercase",
|
|
1729
|
+
children: /* @__PURE__ */ P(T, { placeholder: "" })
|
|
1730
|
+
}), /* @__PURE__ */ P(C, { children: /* @__PURE__ */ P(w, { children: Object.values(Bn).map((e) => /* @__PURE__ */ P(h, {
|
|
1731
|
+
value: e,
|
|
1732
|
+
className: "uppercase",
|
|
1733
|
+
children: e
|
|
1734
|
+
}, e)) }) })]
|
|
1735
|
+
}), $ = () => {
|
|
1736
|
+
let e = je(), t = kt(() => e.filter(n), [e]), r = kt(() => e.filter((e) => e.selected), [e]), i = kt(() => e.find((e) => e.selected), [e]);
|
|
1737
|
+
return {
|
|
1738
|
+
groupNodes: t,
|
|
1739
|
+
hasSelectedNodes: r.length > 0,
|
|
1740
|
+
nodes: e,
|
|
1741
|
+
selectedNode: i,
|
|
1742
|
+
selectedNodes: r
|
|
1743
|
+
};
|
|
1744
|
+
}, Vn = () => {
|
|
1745
|
+
let [e, t] = z("en"), { updateSelectedNodeData: n } = W(), { selectedNode: r } = $(), i = U(), { Field: a } = Pe({
|
|
1746
|
+
defaultValues: {
|
|
1747
|
+
label: r?.data?.label || { en: "" },
|
|
1748
|
+
targetId: r?.data?.targetId || ""
|
|
1749
|
+
},
|
|
1750
|
+
listeners: {
|
|
1751
|
+
onChange: ({ formApi: e }) => {
|
|
1752
|
+
e.handleSubmit().then();
|
|
1753
|
+
},
|
|
1754
|
+
onChangeDebounceMs: 150
|
|
1755
|
+
},
|
|
1756
|
+
onSubmit: ({ value: e }) => {
|
|
1757
|
+
n(e);
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
return /* @__PURE__ */ P("form", {
|
|
1761
|
+
onSubmit: (e) => {
|
|
1762
|
+
e.preventDefault(), e.stopPropagation();
|
|
1763
|
+
},
|
|
1764
|
+
children: /* @__PURE__ */ F("div", {
|
|
1765
|
+
className: "grid gap-6",
|
|
1766
|
+
children: [/* @__PURE__ */ F("div", {
|
|
1767
|
+
className: "flex items-end gap-2",
|
|
1768
|
+
children: [/* @__PURE__ */ P(a, {
|
|
1769
|
+
name: "label",
|
|
1770
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
1771
|
+
className: "flex-1",
|
|
1772
|
+
children: [/* @__PURE__ */ P(d, {
|
|
1773
|
+
htmlFor: t.name,
|
|
1774
|
+
children: i("editor.flowNodeForm.label")
|
|
1775
|
+
}), /* @__PURE__ */ P(O, {
|
|
1776
|
+
id: t.name,
|
|
1777
|
+
name: t.name,
|
|
1778
|
+
value: t.state.value?.[e] || "",
|
|
1779
|
+
onBlur: t.handleBlur,
|
|
1780
|
+
onChange: ({ target: n }) => {
|
|
1781
|
+
t.handleChange({
|
|
1782
|
+
...t.state.value,
|
|
1783
|
+
[e]: n.value
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
})]
|
|
1787
|
+
})
|
|
1788
|
+
}), /* @__PURE__ */ P(Q, {
|
|
1789
|
+
value: e,
|
|
1790
|
+
onValueChange: t
|
|
1791
|
+
})]
|
|
1792
|
+
}), /* @__PURE__ */ P(a, {
|
|
1793
|
+
name: "targetId",
|
|
1794
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
1795
|
+
/* @__PURE__ */ F(d, {
|
|
1796
|
+
htmlFor: e.name,
|
|
1797
|
+
children: [i("editor.flowNodeForm.targetId"), " (Flow ID)"]
|
|
1798
|
+
}),
|
|
1799
|
+
/* @__PURE__ */ P(O, {
|
|
1800
|
+
id: e.name,
|
|
1801
|
+
name: e.name,
|
|
1802
|
+
value: e.state.value,
|
|
1803
|
+
onBlur: e.handleBlur,
|
|
1804
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1805
|
+
}),
|
|
1806
|
+
/* @__PURE__ */ P(j, { children: "Unique identifier of the target flow." })
|
|
1807
|
+
] })
|
|
1808
|
+
})]
|
|
1809
|
+
})
|
|
1810
|
+
});
|
|
1811
|
+
}, Hn = () => {
|
|
1812
|
+
let [e, t] = z("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = W(), { Field: i } = Pe({
|
|
1813
|
+
defaultValues: { label: n?.data?.label || { en: "" } },
|
|
1814
|
+
listeners: {
|
|
1815
|
+
onChange: ({ formApi: e }) => {
|
|
1816
|
+
e.handleSubmit().then();
|
|
1817
|
+
},
|
|
1818
|
+
onChangeDebounceMs: 150
|
|
1819
|
+
},
|
|
1820
|
+
onSubmit: ({ value: e }) => {
|
|
1821
|
+
r(e);
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
return /* @__PURE__ */ P("form", {
|
|
1825
|
+
onSubmit: (e) => {
|
|
1826
|
+
e.preventDefault(), e.stopPropagation();
|
|
1827
|
+
},
|
|
1828
|
+
children: /* @__PURE__ */ F("div", {
|
|
1829
|
+
className: "flex items-end gap-2",
|
|
1830
|
+
children: [/* @__PURE__ */ P(i, {
|
|
1831
|
+
name: "label",
|
|
1832
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
1833
|
+
className: "flex-1",
|
|
1834
|
+
children: [/* @__PURE__ */ P(d, {
|
|
1835
|
+
htmlFor: t.name,
|
|
1836
|
+
children: "Label"
|
|
1837
|
+
}), /* @__PURE__ */ P(O, {
|
|
1838
|
+
id: t.name,
|
|
1839
|
+
name: t.name,
|
|
1840
|
+
value: t.state.value?.[e] || "",
|
|
1841
|
+
onBlur: t.handleBlur,
|
|
1842
|
+
onChange: ({ target: n }) => {
|
|
1843
|
+
t.handleChange({
|
|
1844
|
+
...t.state.value,
|
|
1845
|
+
[e]: n.value
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
})]
|
|
1849
|
+
})
|
|
1850
|
+
}), /* @__PURE__ */ P(Q, {
|
|
1851
|
+
value: e,
|
|
1852
|
+
onValueChange: t
|
|
1853
|
+
})]
|
|
1854
|
+
})
|
|
1855
|
+
});
|
|
1856
|
+
}, Un = [
|
|
1857
|
+
"POST",
|
|
1858
|
+
"PUT",
|
|
1859
|
+
"PATCH"
|
|
1860
|
+
], Wn = ({ value: e, onChange: t }) => {
|
|
1861
|
+
let { selectedNode: n } = $(), r = U(), i = Ht(n?.id), { handleSubmit: a, Field: o, Subscribe: s } = Pe({
|
|
1862
|
+
defaultValues: {
|
|
1863
|
+
body: e?.body || "",
|
|
1864
|
+
fetchOnMount: e?.fetchOnMount ?? !e?.searchParam,
|
|
1865
|
+
headers: e?.headers || [],
|
|
1866
|
+
method: e?.method || "GET",
|
|
1867
|
+
responseMapping: e?.responseMapping || {
|
|
1868
|
+
labelField: "",
|
|
1869
|
+
valueField: ""
|
|
1870
|
+
},
|
|
1871
|
+
responsePath: e?.responsePath || "",
|
|
1872
|
+
searchParam: e?.searchParam || "",
|
|
1873
|
+
sendAllFormValues: !!e?.sendAllFormValues,
|
|
1874
|
+
showLoading: e?.showLoading !== !1,
|
|
1875
|
+
url: e?.url || ""
|
|
1876
|
+
},
|
|
1877
|
+
listeners: {
|
|
1878
|
+
onChange: ({ formApi: e }) => {
|
|
1879
|
+
e.handleSubmit().then();
|
|
1880
|
+
},
|
|
1881
|
+
onChangeDebounceMs: 150
|
|
1882
|
+
},
|
|
1883
|
+
onSubmit: ({ value: e }) => {
|
|
1884
|
+
t(e);
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
return /* @__PURE__ */ P("div", { children: /* @__PURE__ */ F("div", {
|
|
1888
|
+
className: "grid gap-6",
|
|
1889
|
+
children: [
|
|
1890
|
+
/* @__PURE__ */ P(o, {
|
|
1891
|
+
name: "url",
|
|
1892
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
1893
|
+
/* @__PURE__ */ P(d, {
|
|
1894
|
+
htmlFor: e.name,
|
|
1895
|
+
children: r("editor.httpConfigForm.apiUrl")
|
|
1896
|
+
}),
|
|
1897
|
+
/* @__PURE__ */ F("div", {
|
|
1898
|
+
className: "flex gap-2",
|
|
1899
|
+
children: [/* @__PURE__ */ P(O, {
|
|
1900
|
+
id: e.name,
|
|
1901
|
+
name: e.name,
|
|
1902
|
+
value: e.state.value,
|
|
1903
|
+
onBlur: e.handleBlur,
|
|
1904
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1905
|
+
placeholder: r("editor.httpConfigForm.apiUrlPlaceholder"),
|
|
1906
|
+
className: "flex-1"
|
|
1907
|
+
}), /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ P(K, {
|
|
1908
|
+
asChild: !0,
|
|
1909
|
+
children: /* @__PURE__ */ P(k, {
|
|
1910
|
+
type: "button",
|
|
1911
|
+
variant: "outline",
|
|
1912
|
+
size: "icon",
|
|
1913
|
+
children: /* @__PURE__ */ P(bt, { className: "h-4 w-4" })
|
|
1914
|
+
})
|
|
1915
|
+
}), /* @__PURE__ */ P(q, {
|
|
1916
|
+
align: "end",
|
|
1917
|
+
children: i.length === 0 ? /* @__PURE__ */ P(Y, {
|
|
1918
|
+
disabled: !0,
|
|
1919
|
+
children: r("editor.httpConfigForm.noFieldsAvailable")
|
|
1920
|
+
}) : i.map((t) => /* @__PURE__ */ P(Y, {
|
|
1921
|
+
onClick: () => {
|
|
1922
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
1923
|
+
e.handleChange(r + n);
|
|
1924
|
+
},
|
|
1925
|
+
children: /* @__PURE__ */ F("div", {
|
|
1926
|
+
className: "flex flex-col",
|
|
1927
|
+
children: [/* @__PURE__ */ P("span", {
|
|
1928
|
+
className: "font-medium",
|
|
1929
|
+
children: t.label
|
|
1930
|
+
}), /* @__PURE__ */ P("span", {
|
|
1931
|
+
className: "text-muted-foreground text-xs",
|
|
1932
|
+
children: `{{${t.nodeId}}}`
|
|
1933
|
+
})]
|
|
1934
|
+
})
|
|
1935
|
+
}, t.nodeId))
|
|
1936
|
+
})] })]
|
|
1937
|
+
}),
|
|
1938
|
+
/* @__PURE__ */ P(j, { children: r("editor.httpConfigForm.apiUrlDesc") })
|
|
1939
|
+
] })
|
|
1940
|
+
}),
|
|
1941
|
+
/* @__PURE__ */ P(o, {
|
|
1942
|
+
name: "method",
|
|
1943
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
1944
|
+
htmlFor: e.name,
|
|
1945
|
+
children: r("editor.httpConfigForm.httpMethod")
|
|
1946
|
+
}), /* @__PURE__ */ F(g, {
|
|
1947
|
+
value: e.state.value,
|
|
1948
|
+
onValueChange: (t) => e.handleChange(t),
|
|
1949
|
+
children: [/* @__PURE__ */ P(v, {
|
|
1950
|
+
id: e.name,
|
|
1951
|
+
children: /* @__PURE__ */ P(T, { placeholder: r("editor.httpConfigForm.selectMethod") })
|
|
1952
|
+
}), /* @__PURE__ */ F(C, { children: [
|
|
1953
|
+
/* @__PURE__ */ P(h, {
|
|
1954
|
+
value: "GET",
|
|
1955
|
+
children: r("editor.httpConfigForm.methodGet")
|
|
1956
|
+
}),
|
|
1957
|
+
/* @__PURE__ */ P(h, {
|
|
1958
|
+
value: "POST",
|
|
1959
|
+
children: r("editor.httpConfigForm.methodPost")
|
|
1960
|
+
}),
|
|
1961
|
+
/* @__PURE__ */ P(h, {
|
|
1962
|
+
value: "PUT",
|
|
1963
|
+
children: r("editor.httpConfigForm.methodPut")
|
|
1964
|
+
}),
|
|
1965
|
+
/* @__PURE__ */ P(h, {
|
|
1966
|
+
value: "DELETE",
|
|
1967
|
+
children: r("editor.httpConfigForm.methodDelete")
|
|
1968
|
+
}),
|
|
1969
|
+
/* @__PURE__ */ P(h, {
|
|
1970
|
+
value: "PATCH",
|
|
1971
|
+
children: r("editor.httpConfigForm.methodPatch")
|
|
1972
|
+
})
|
|
1973
|
+
] })]
|
|
1974
|
+
})] })
|
|
1975
|
+
}),
|
|
1976
|
+
/* @__PURE__ */ F("div", {
|
|
1977
|
+
className: "space-y-4",
|
|
1978
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
1979
|
+
className: "font-semibold text-sm",
|
|
1980
|
+
children: r("editor.httpConfigForm.headers")
|
|
1981
|
+
}), /* @__PURE__ */ P(o, {
|
|
1982
|
+
name: "headers",
|
|
1983
|
+
mode: "array",
|
|
1984
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
1985
|
+
className: "space-y-2",
|
|
1986
|
+
children: [e.state.value?.map((t, n) => {
|
|
1987
|
+
let i = `headers[${n}]`;
|
|
1988
|
+
return /* @__PURE__ */ F("div", {
|
|
1989
|
+
className: "flex items-start gap-2",
|
|
1990
|
+
children: [
|
|
1991
|
+
/* @__PURE__ */ P(o, {
|
|
1992
|
+
name: `headers[${n}].key`,
|
|
1993
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
1994
|
+
placeholder: r("editor.httpConfigForm.headerName"),
|
|
1995
|
+
value: e.state.value || "",
|
|
1996
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1997
|
+
})
|
|
1998
|
+
}),
|
|
1999
|
+
/* @__PURE__ */ P(o, {
|
|
2000
|
+
name: `headers[${n}].value`,
|
|
2001
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
2002
|
+
placeholder: r("editor.httpConfigForm.headerValue"),
|
|
2003
|
+
value: e.state.value || "",
|
|
2004
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
2005
|
+
})
|
|
2006
|
+
}),
|
|
2007
|
+
/* @__PURE__ */ P(k, {
|
|
2008
|
+
type: "button",
|
|
2009
|
+
variant: "ghost",
|
|
2010
|
+
size: "icon",
|
|
2011
|
+
onClick: () => {
|
|
2012
|
+
e.removeValue(n);
|
|
2013
|
+
},
|
|
2014
|
+
children: /* @__PURE__ */ P(L, { className: "h-4 w-4" })
|
|
2015
|
+
})
|
|
2016
|
+
]
|
|
2017
|
+
}, i);
|
|
2018
|
+
}), /* @__PURE__ */ F(k, {
|
|
2019
|
+
type: "button",
|
|
2020
|
+
variant: "outline",
|
|
2021
|
+
size: "sm",
|
|
2022
|
+
onClick: () => {
|
|
2023
|
+
e.pushValue({
|
|
2024
|
+
key: "",
|
|
2025
|
+
value: ""
|
|
2026
|
+
});
|
|
2027
|
+
},
|
|
2028
|
+
children: [/* @__PURE__ */ P(I, { className: "mr-2 h-4 w-4" }), r("editor.httpConfigForm.addHeader")]
|
|
2029
|
+
})]
|
|
2030
|
+
})
|
|
2031
|
+
})]
|
|
2032
|
+
}),
|
|
2033
|
+
/* @__PURE__ */ P(s, {
|
|
2034
|
+
selector: (e) => ({
|
|
2035
|
+
method: e.values.method,
|
|
2036
|
+
sendAllFormValues: e.values.sendAllFormValues
|
|
2037
|
+
}),
|
|
2038
|
+
children: ({ method: e, sendAllFormValues: t }) => Un.includes(e || "") && /* @__PURE__ */ F("div", {
|
|
2039
|
+
className: "space-y-4",
|
|
2040
|
+
children: [/* @__PURE__ */ P(o, {
|
|
2041
|
+
name: "sendAllFormValues",
|
|
2042
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
2043
|
+
className: "flex items-center space-x-2",
|
|
2044
|
+
children: [/* @__PURE__ */ P(D, {
|
|
2045
|
+
id: e.name,
|
|
2046
|
+
checked: e.state.value,
|
|
2047
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2048
|
+
}), /* @__PURE__ */ P(d, {
|
|
2049
|
+
htmlFor: e.name,
|
|
2050
|
+
children: r("editor.httpConfigForm.sendAllFormValues")
|
|
2051
|
+
})]
|
|
2052
|
+
})
|
|
2053
|
+
}), /* @__PURE__ */ P(o, {
|
|
2054
|
+
name: "body",
|
|
2055
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2056
|
+
/* @__PURE__ */ F("div", {
|
|
2057
|
+
className: "mb-2 flex items-center justify-between",
|
|
2058
|
+
children: [/* @__PURE__ */ P(d, {
|
|
2059
|
+
htmlFor: e.name,
|
|
2060
|
+
children: r("editor.httpConfigForm.requestBody")
|
|
2061
|
+
}), /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ P(K, {
|
|
2062
|
+
asChild: !0,
|
|
2063
|
+
children: /* @__PURE__ */ F(k, {
|
|
2064
|
+
type: "button",
|
|
2065
|
+
variant: "ghost",
|
|
2066
|
+
size: "sm",
|
|
2067
|
+
disabled: t,
|
|
2068
|
+
children: [/* @__PURE__ */ P(bt, { className: "mr-2 h-4 w-4" }), r("editor.httpConfigForm.insertVariable")]
|
|
2069
|
+
})
|
|
2070
|
+
}), /* @__PURE__ */ P(q, {
|
|
2071
|
+
align: "end",
|
|
2072
|
+
children: i.length === 0 ? /* @__PURE__ */ P(Y, {
|
|
2073
|
+
disabled: !0,
|
|
2074
|
+
children: r("editor.httpConfigForm.noFieldsAvailable")
|
|
2075
|
+
}) : i.map((t) => /* @__PURE__ */ P(Y, {
|
|
2076
|
+
onClick: () => {
|
|
2077
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
2078
|
+
e.handleChange(r + n), a().then();
|
|
2079
|
+
},
|
|
2080
|
+
children: /* @__PURE__ */ F("div", {
|
|
2081
|
+
className: "flex flex-col",
|
|
2082
|
+
children: [/* @__PURE__ */ P("span", {
|
|
2083
|
+
className: "font-medium",
|
|
2084
|
+
children: t.label
|
|
2085
|
+
}), /* @__PURE__ */ P("span", {
|
|
2086
|
+
className: "text-muted-foreground text-xs",
|
|
2087
|
+
children: `{{${t.nodeId}}}`
|
|
2088
|
+
})]
|
|
2089
|
+
})
|
|
2090
|
+
}, t.nodeId))
|
|
2091
|
+
})] })]
|
|
2092
|
+
}),
|
|
2093
|
+
/* @__PURE__ */ P(le, {
|
|
2094
|
+
id: e.name,
|
|
2095
|
+
name: e.name,
|
|
2096
|
+
value: e.state.value,
|
|
2097
|
+
onBlur: e.handleBlur,
|
|
2098
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2099
|
+
placeholder: r("editor.httpConfigForm.requestBodyPlaceholder"),
|
|
2100
|
+
rows: 4,
|
|
2101
|
+
disabled: t
|
|
2102
|
+
}),
|
|
2103
|
+
/* @__PURE__ */ P(j, { children: r(t ? "editor.httpConfigForm.sendAllFormValuesDesc" : "editor.httpConfigForm.requestBodyDesc") })
|
|
2104
|
+
] })
|
|
2105
|
+
})]
|
|
2106
|
+
})
|
|
2107
|
+
}),
|
|
2108
|
+
/* @__PURE__ */ F("div", {
|
|
2109
|
+
className: "space-y-4",
|
|
2110
|
+
children: [
|
|
2111
|
+
/* @__PURE__ */ P("h4", {
|
|
2112
|
+
className: "font-semibold text-sm",
|
|
2113
|
+
children: r("editor.httpConfigForm.responseConfiguration")
|
|
2114
|
+
}),
|
|
2115
|
+
/* @__PURE__ */ P(o, {
|
|
2116
|
+
name: "responsePath",
|
|
2117
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2118
|
+
/* @__PURE__ */ P(d, {
|
|
2119
|
+
htmlFor: e.name,
|
|
2120
|
+
children: r("editor.httpConfigForm.responsePath")
|
|
2121
|
+
}),
|
|
2122
|
+
/* @__PURE__ */ P(O, {
|
|
2123
|
+
id: e.name,
|
|
2124
|
+
name: e.name,
|
|
2125
|
+
value: e.state.value,
|
|
2126
|
+
onBlur: e.handleBlur,
|
|
2127
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2128
|
+
placeholder: r("editor.httpConfigForm.responsePathPlaceholder")
|
|
2129
|
+
}),
|
|
2130
|
+
/* @__PURE__ */ P(j, { children: r("editor.httpConfigForm.responsePathDesc") })
|
|
2131
|
+
] })
|
|
2132
|
+
}),
|
|
2133
|
+
/* @__PURE__ */ F("div", {
|
|
2134
|
+
className: "space-y-4",
|
|
2135
|
+
children: [
|
|
2136
|
+
/* @__PURE__ */ P("h5", {
|
|
2137
|
+
className: "font-medium text-sm",
|
|
2138
|
+
children: r("editor.httpConfigForm.mapToOptions")
|
|
2139
|
+
}),
|
|
2140
|
+
/* @__PURE__ */ P(o, {
|
|
2141
|
+
name: "responseMapping.valueField",
|
|
2142
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2143
|
+
/* @__PURE__ */ P(d, {
|
|
2144
|
+
htmlFor: e.name,
|
|
2145
|
+
children: r("editor.httpConfigForm.valueField")
|
|
2146
|
+
}),
|
|
2147
|
+
/* @__PURE__ */ P(O, {
|
|
2148
|
+
id: e.name,
|
|
2149
|
+
name: e.name,
|
|
2150
|
+
value: e.state.value,
|
|
2151
|
+
onBlur: e.handleBlur,
|
|
2152
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2153
|
+
placeholder: r("editor.httpConfigForm.valueFieldPlaceholder")
|
|
2154
|
+
}),
|
|
2155
|
+
/* @__PURE__ */ P(j, { children: r("editor.httpConfigForm.valueFieldDesc") })
|
|
2156
|
+
] })
|
|
2157
|
+
}),
|
|
2158
|
+
/* @__PURE__ */ P(o, {
|
|
2159
|
+
name: "responseMapping.labelField",
|
|
2160
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2161
|
+
/* @__PURE__ */ P(d, {
|
|
2162
|
+
htmlFor: e.name,
|
|
2163
|
+
children: r("editor.httpConfigForm.labelField")
|
|
2164
|
+
}),
|
|
2165
|
+
/* @__PURE__ */ P(O, {
|
|
2166
|
+
id: e.name,
|
|
2167
|
+
name: e.name,
|
|
2168
|
+
value: e.state.value,
|
|
2169
|
+
onBlur: e.handleBlur,
|
|
2170
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2171
|
+
placeholder: r("editor.httpConfigForm.labelFieldPlaceholder")
|
|
2172
|
+
}),
|
|
2173
|
+
/* @__PURE__ */ P(j, { children: r("editor.httpConfigForm.labelFieldDesc") })
|
|
2174
|
+
] })
|
|
2175
|
+
})
|
|
2176
|
+
]
|
|
2177
|
+
}),
|
|
2178
|
+
/* @__PURE__ */ P(o, {
|
|
2179
|
+
name: "searchParam",
|
|
2180
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2181
|
+
/* @__PURE__ */ P(d, {
|
|
2182
|
+
htmlFor: e.name,
|
|
2183
|
+
children: r("editor.httpConfigForm.searchParameter")
|
|
2184
|
+
}),
|
|
2185
|
+
/* @__PURE__ */ P(O, {
|
|
2186
|
+
id: e.name,
|
|
2187
|
+
name: e.name,
|
|
2188
|
+
value: e.state.value,
|
|
2189
|
+
onBlur: e.handleBlur,
|
|
2190
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2191
|
+
placeholder: r("editor.httpConfigForm.searchParameterPlaceholder")
|
|
2192
|
+
}),
|
|
2193
|
+
/* @__PURE__ */ P(j, { children: r("editor.httpConfigForm.searchParameterDesc") })
|
|
2194
|
+
] })
|
|
2195
|
+
})
|
|
2196
|
+
]
|
|
2197
|
+
}),
|
|
2198
|
+
/* @__PURE__ */ F("div", {
|
|
2199
|
+
className: "space-y-4",
|
|
2200
|
+
children: [
|
|
2201
|
+
/* @__PURE__ */ P("h4", {
|
|
2202
|
+
className: "font-semibold text-sm",
|
|
2203
|
+
children: r("editor.httpConfigForm.behavior")
|
|
2204
|
+
}),
|
|
2205
|
+
/* @__PURE__ */ P(s, {
|
|
2206
|
+
selector: (e) => e.values.searchParam,
|
|
2207
|
+
children: (e) => /* @__PURE__ */ P(o, {
|
|
2208
|
+
name: "fetchOnMount",
|
|
2209
|
+
children: (t) => {
|
|
2210
|
+
let n = !!e?.trim(), i = n ? t.state.value : !0;
|
|
2211
|
+
return !n && t.state.value !== !0 && t.handleChange(!0), /* @__PURE__ */ F("div", {
|
|
2212
|
+
className: "flex items-center space-x-2",
|
|
2213
|
+
children: [/* @__PURE__ */ P(D, {
|
|
2214
|
+
id: t.name,
|
|
2215
|
+
checked: i,
|
|
2216
|
+
disabled: !n,
|
|
2217
|
+
onCheckedChange: (e) => t.handleChange(e)
|
|
2218
|
+
}), /* @__PURE__ */ P(d, {
|
|
2219
|
+
htmlFor: t.name,
|
|
2220
|
+
className: n ? "" : "text-muted-foreground",
|
|
2221
|
+
children: r("editor.httpConfigForm.fetchOnMount")
|
|
2222
|
+
})]
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
})
|
|
2226
|
+
}),
|
|
2227
|
+
/* @__PURE__ */ P(o, {
|
|
2228
|
+
name: "showLoading",
|
|
2229
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
2230
|
+
className: "flex items-center space-x-2",
|
|
2231
|
+
children: [/* @__PURE__ */ P(D, {
|
|
2232
|
+
id: e.name,
|
|
2233
|
+
checked: e.state.value,
|
|
2234
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2235
|
+
}), /* @__PURE__ */ P(d, {
|
|
2236
|
+
htmlFor: e.name,
|
|
2237
|
+
children: r("editor.httpConfigForm.showLoadingState")
|
|
2238
|
+
})]
|
|
2239
|
+
})
|
|
2240
|
+
})
|
|
2241
|
+
]
|
|
2242
|
+
})
|
|
2243
|
+
]
|
|
2244
|
+
}) });
|
|
2245
|
+
}, Gn = [
|
|
2246
|
+
"POST",
|
|
2247
|
+
"PUT",
|
|
2248
|
+
"PATCH"
|
|
2249
|
+
], Kn = ({ value: e, onChange: t }) => {
|
|
2250
|
+
let [n, r] = z("en"), { selectedNode: i } = $(), a = U(), o = Ht(i?.id), { handleSubmit: s, Field: c, Subscribe: l } = Pe({
|
|
2251
|
+
defaultValues: {
|
|
2252
|
+
body: e?.body || "",
|
|
2253
|
+
errorMessage: e?.errorMessage || { en: "" },
|
|
2254
|
+
headers: e?.headers || [],
|
|
2255
|
+
method: e?.method || "POST",
|
|
2256
|
+
redirectUrl: e?.redirectUrl || "",
|
|
2257
|
+
sendAllFormValues: !!e?.sendAllFormValues,
|
|
2258
|
+
showLoading: e?.showLoading !== !1,
|
|
2259
|
+
successMessage: e?.successMessage || { en: "" },
|
|
2260
|
+
url: e?.url || ""
|
|
2261
|
+
},
|
|
2262
|
+
listeners: {
|
|
2263
|
+
onChange: ({ formApi: e }) => {
|
|
2264
|
+
e.handleSubmit().then();
|
|
2265
|
+
},
|
|
2266
|
+
onChangeDebounceMs: 150
|
|
2267
|
+
},
|
|
2268
|
+
onSubmit: ({ value: e }) => {
|
|
2269
|
+
t(e);
|
|
2270
|
+
}
|
|
2271
|
+
});
|
|
2272
|
+
return /* @__PURE__ */ P("div", { children: /* @__PURE__ */ F("div", {
|
|
2273
|
+
className: "grid gap-6",
|
|
2274
|
+
children: [
|
|
2275
|
+
/* @__PURE__ */ P(c, {
|
|
2276
|
+
name: "url",
|
|
2277
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2278
|
+
/* @__PURE__ */ P(d, {
|
|
2279
|
+
htmlFor: e.name,
|
|
2280
|
+
children: a("editor.submitConfigForm.apiUrl")
|
|
2281
|
+
}),
|
|
2282
|
+
/* @__PURE__ */ F("div", {
|
|
2283
|
+
className: "flex gap-2",
|
|
2284
|
+
children: [/* @__PURE__ */ P(O, {
|
|
2285
|
+
id: e.name,
|
|
2286
|
+
name: e.name,
|
|
2287
|
+
value: e.state.value,
|
|
2288
|
+
onBlur: e.handleBlur,
|
|
2289
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2290
|
+
placeholder: a("editor.submitConfigForm.apiUrlPlaceholder"),
|
|
2291
|
+
className: "flex-1"
|
|
2292
|
+
}), /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ P(K, {
|
|
2293
|
+
asChild: !0,
|
|
2294
|
+
children: /* @__PURE__ */ P(k, {
|
|
2295
|
+
type: "button",
|
|
2296
|
+
variant: "outline",
|
|
2297
|
+
size: "icon",
|
|
2298
|
+
children: /* @__PURE__ */ P(bt, { className: "h-4 w-4" })
|
|
2299
|
+
})
|
|
2300
|
+
}), /* @__PURE__ */ P(q, {
|
|
2301
|
+
align: "end",
|
|
2302
|
+
children: o.length === 0 ? /* @__PURE__ */ P(Y, {
|
|
2303
|
+
disabled: !0,
|
|
2304
|
+
children: a("editor.submitConfigForm.noFieldsAvailable")
|
|
2305
|
+
}) : o.map((t) => /* @__PURE__ */ P(Y, {
|
|
2306
|
+
onClick: () => {
|
|
2307
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
2308
|
+
e.handleChange(r + n);
|
|
2309
|
+
},
|
|
2310
|
+
children: /* @__PURE__ */ F("div", {
|
|
2311
|
+
className: "flex flex-col",
|
|
2312
|
+
children: [/* @__PURE__ */ P("span", {
|
|
2313
|
+
className: "font-medium",
|
|
2314
|
+
children: t.label
|
|
2315
|
+
}), /* @__PURE__ */ P("span", {
|
|
2316
|
+
className: "text-muted-foreground text-xs",
|
|
2317
|
+
children: `{{${t.nodeId}}}`
|
|
2318
|
+
})]
|
|
2319
|
+
})
|
|
2320
|
+
}, t.nodeId))
|
|
2321
|
+
})] })]
|
|
2322
|
+
}),
|
|
2323
|
+
/* @__PURE__ */ P(j, { children: a("editor.submitConfigForm.apiUrlDesc") })
|
|
2324
|
+
] })
|
|
2325
|
+
}),
|
|
2326
|
+
/* @__PURE__ */ P(c, {
|
|
2327
|
+
name: "method",
|
|
2328
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
2329
|
+
htmlFor: e.name,
|
|
2330
|
+
children: a("editor.submitConfigForm.httpMethod")
|
|
2331
|
+
}), /* @__PURE__ */ F(g, {
|
|
2332
|
+
value: e.state.value,
|
|
2333
|
+
onValueChange: (t) => e.handleChange(t),
|
|
2334
|
+
children: [/* @__PURE__ */ P(v, {
|
|
2335
|
+
id: e.name,
|
|
2336
|
+
children: /* @__PURE__ */ P(T, { placeholder: a("editor.submitConfigForm.selectMethod") })
|
|
2337
|
+
}), /* @__PURE__ */ F(C, { children: [
|
|
2338
|
+
/* @__PURE__ */ P(h, {
|
|
2339
|
+
value: "POST",
|
|
2340
|
+
children: a("editor.submitConfigForm.methodPost")
|
|
2341
|
+
}),
|
|
2342
|
+
/* @__PURE__ */ P(h, {
|
|
2343
|
+
value: "PUT",
|
|
2344
|
+
children: a("editor.submitConfigForm.methodPut")
|
|
2345
|
+
}),
|
|
2346
|
+
/* @__PURE__ */ P(h, {
|
|
2347
|
+
value: "DELETE",
|
|
2348
|
+
children: a("editor.submitConfigForm.methodDelete")
|
|
2349
|
+
}),
|
|
2350
|
+
/* @__PURE__ */ P(h, {
|
|
2351
|
+
value: "PATCH",
|
|
2352
|
+
children: a("editor.submitConfigForm.methodPatch")
|
|
2353
|
+
})
|
|
2354
|
+
] })]
|
|
2355
|
+
})] })
|
|
2356
|
+
}),
|
|
2357
|
+
/* @__PURE__ */ F("div", {
|
|
2358
|
+
className: "space-y-4",
|
|
2359
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
2360
|
+
className: "font-semibold text-sm",
|
|
2361
|
+
children: a("editor.submitConfigForm.headers")
|
|
2362
|
+
}), /* @__PURE__ */ P(c, {
|
|
2363
|
+
name: "headers",
|
|
2364
|
+
mode: "array",
|
|
2365
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
2366
|
+
className: "space-y-2",
|
|
2367
|
+
children: [e.state.value?.map((t, n) => {
|
|
2368
|
+
let r = `headers[${n}]`;
|
|
2369
|
+
return /* @__PURE__ */ F("div", {
|
|
2370
|
+
className: "flex items-start gap-2",
|
|
2371
|
+
children: [
|
|
2372
|
+
/* @__PURE__ */ P(c, {
|
|
2373
|
+
name: `headers[${n}].key`,
|
|
2374
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
2375
|
+
placeholder: a("editor.submitConfigForm.headerName"),
|
|
2376
|
+
value: e.state.value || "",
|
|
2377
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
2378
|
+
})
|
|
2379
|
+
}),
|
|
2380
|
+
/* @__PURE__ */ P(c, {
|
|
2381
|
+
name: `headers[${n}].value`,
|
|
2382
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
2383
|
+
placeholder: a("editor.submitConfigForm.headerValue"),
|
|
2384
|
+
value: e.state.value || "",
|
|
2385
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
2386
|
+
})
|
|
2387
|
+
}),
|
|
2388
|
+
/* @__PURE__ */ P(k, {
|
|
2389
|
+
type: "button",
|
|
2390
|
+
variant: "ghost",
|
|
2391
|
+
size: "icon",
|
|
2392
|
+
onClick: () => {
|
|
2393
|
+
e.removeValue(n);
|
|
2394
|
+
},
|
|
2395
|
+
children: /* @__PURE__ */ P(L, { className: "h-4 w-4" })
|
|
2396
|
+
})
|
|
2397
|
+
]
|
|
2398
|
+
}, r);
|
|
2399
|
+
}), /* @__PURE__ */ F(k, {
|
|
2400
|
+
type: "button",
|
|
2401
|
+
variant: "outline",
|
|
2402
|
+
size: "sm",
|
|
2403
|
+
onClick: () => {
|
|
2404
|
+
e.pushValue({
|
|
2405
|
+
key: "",
|
|
2406
|
+
value: ""
|
|
2407
|
+
});
|
|
2408
|
+
},
|
|
2409
|
+
children: [/* @__PURE__ */ P(I, { className: "mr-2 h-4 w-4" }), a("editor.submitConfigForm.addHeader")]
|
|
2410
|
+
})]
|
|
2411
|
+
})
|
|
2412
|
+
})]
|
|
2413
|
+
}),
|
|
2414
|
+
/* @__PURE__ */ P(l, {
|
|
2415
|
+
selector: (e) => ({
|
|
2416
|
+
method: e.values.method,
|
|
2417
|
+
sendAllFormValues: e.values.sendAllFormValues
|
|
2418
|
+
}),
|
|
2419
|
+
children: ({ method: e, sendAllFormValues: t }) => Gn.includes(e || "") && /* @__PURE__ */ F("div", {
|
|
2420
|
+
className: "space-y-4",
|
|
2421
|
+
children: [/* @__PURE__ */ P(c, {
|
|
2422
|
+
name: "sendAllFormValues",
|
|
2423
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
2424
|
+
className: "flex items-center space-x-2",
|
|
2425
|
+
children: [/* @__PURE__ */ P(D, {
|
|
2426
|
+
id: e.name,
|
|
2427
|
+
checked: e.state.value,
|
|
2428
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2429
|
+
}), /* @__PURE__ */ P(d, {
|
|
2430
|
+
htmlFor: e.name,
|
|
2431
|
+
children: a("editor.submitConfigForm.sendAllFormValues")
|
|
2432
|
+
})]
|
|
2433
|
+
})
|
|
2434
|
+
}), /* @__PURE__ */ P(c, {
|
|
2435
|
+
name: "body",
|
|
2436
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2437
|
+
/* @__PURE__ */ F("div", {
|
|
2438
|
+
className: "mb-2 flex items-center justify-between",
|
|
2439
|
+
children: [/* @__PURE__ */ P(d, {
|
|
2440
|
+
htmlFor: e.name,
|
|
2441
|
+
children: a("editor.submitConfigForm.requestBody")
|
|
2442
|
+
}), /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ P(K, {
|
|
2443
|
+
asChild: !0,
|
|
2444
|
+
children: /* @__PURE__ */ F(k, {
|
|
2445
|
+
type: "button",
|
|
2446
|
+
variant: "ghost",
|
|
2447
|
+
size: "sm",
|
|
2448
|
+
disabled: t,
|
|
2449
|
+
children: [/* @__PURE__ */ P(bt, { className: "mr-2 h-4 w-4" }), a("editor.submitConfigForm.insertVariable")]
|
|
2450
|
+
})
|
|
2451
|
+
}), /* @__PURE__ */ P(q, {
|
|
2452
|
+
align: "end",
|
|
2453
|
+
children: o.length === 0 ? /* @__PURE__ */ P(Y, {
|
|
2454
|
+
disabled: !0,
|
|
2455
|
+
children: a("editor.submitConfigForm.noFieldsAvailable")
|
|
2456
|
+
}) : o.map((t) => /* @__PURE__ */ P(Y, {
|
|
2457
|
+
onClick: () => {
|
|
2458
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
2459
|
+
e.handleChange(r + n), s().then();
|
|
2460
|
+
},
|
|
2461
|
+
children: /* @__PURE__ */ F("div", {
|
|
2462
|
+
className: "flex flex-col",
|
|
2463
|
+
children: [/* @__PURE__ */ P("span", {
|
|
2464
|
+
className: "font-medium",
|
|
2465
|
+
children: t.label
|
|
2466
|
+
}), /* @__PURE__ */ P("span", {
|
|
2467
|
+
className: "text-muted-foreground text-xs",
|
|
2468
|
+
children: `{{${t.nodeId}}}`
|
|
2469
|
+
})]
|
|
2470
|
+
})
|
|
2471
|
+
}, t.nodeId))
|
|
2472
|
+
})] })]
|
|
2473
|
+
}),
|
|
2474
|
+
/* @__PURE__ */ P(le, {
|
|
2475
|
+
id: e.name,
|
|
2476
|
+
name: e.name,
|
|
2477
|
+
value: e.state.value,
|
|
2478
|
+
onBlur: e.handleBlur,
|
|
2479
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2480
|
+
placeholder: a("editor.submitConfigForm.requestBodyPlaceholder"),
|
|
2481
|
+
rows: 4,
|
|
2482
|
+
disabled: t
|
|
2483
|
+
}),
|
|
2484
|
+
/* @__PURE__ */ P(j, { children: a(t ? "editor.submitConfigForm.sendAllFormValuesDesc" : "editor.submitConfigForm.requestBodyDesc") })
|
|
2485
|
+
] })
|
|
2486
|
+
})]
|
|
2487
|
+
})
|
|
2488
|
+
}),
|
|
2489
|
+
/* @__PURE__ */ F("div", {
|
|
2490
|
+
className: "space-y-4",
|
|
2491
|
+
children: [
|
|
2492
|
+
/* @__PURE__ */ P("h4", {
|
|
2493
|
+
className: "font-semibold text-sm",
|
|
2494
|
+
children: a("editor.submitConfigForm.postSubmission")
|
|
2495
|
+
}),
|
|
2496
|
+
/* @__PURE__ */ P(c, {
|
|
2497
|
+
name: "redirectUrl",
|
|
2498
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
2499
|
+
/* @__PURE__ */ P(d, {
|
|
2500
|
+
htmlFor: e.name,
|
|
2501
|
+
children: a("editor.submitConfigForm.redirectUrl")
|
|
2502
|
+
}),
|
|
2503
|
+
/* @__PURE__ */ P(O, {
|
|
2504
|
+
id: e.name,
|
|
2505
|
+
name: e.name,
|
|
2506
|
+
value: e.state.value,
|
|
2507
|
+
onBlur: e.handleBlur,
|
|
2508
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2509
|
+
placeholder: a("editor.submitConfigForm.redirectUrlPlaceholder")
|
|
2510
|
+
}),
|
|
2511
|
+
/* @__PURE__ */ P(j, { children: a("editor.submitConfigForm.redirectUrlDesc") })
|
|
2512
|
+
] })
|
|
2513
|
+
}),
|
|
2514
|
+
/* @__PURE__ */ F("div", {
|
|
2515
|
+
className: "flex items-center gap-2",
|
|
2516
|
+
children: [/* @__PURE__ */ P(c, {
|
|
2517
|
+
name: "successMessage",
|
|
2518
|
+
children: (e) => /* @__PURE__ */ F(A, {
|
|
2519
|
+
className: "flex-1",
|
|
2520
|
+
children: [
|
|
2521
|
+
/* @__PURE__ */ P(d, {
|
|
2522
|
+
htmlFor: e.name,
|
|
2523
|
+
children: a("editor.submitConfigForm.successMessage")
|
|
2524
|
+
}),
|
|
2525
|
+
/* @__PURE__ */ P(O, {
|
|
2526
|
+
id: e.name,
|
|
2527
|
+
name: e.name,
|
|
2528
|
+
value: e.state.value?.[n] || "",
|
|
2529
|
+
onBlur: e.handleBlur,
|
|
2530
|
+
onChange: ({ target: t }) => {
|
|
2531
|
+
e.handleChange({
|
|
2532
|
+
...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
|
|
2533
|
+
[n]: t.value
|
|
2534
|
+
});
|
|
2535
|
+
},
|
|
2536
|
+
placeholder: a("editor.submitConfigForm.successMessagePlaceholder")
|
|
2537
|
+
}),
|
|
2538
|
+
/* @__PURE__ */ P(j, { children: a("editor.submitConfigForm.successMessageDesc") })
|
|
2539
|
+
]
|
|
2540
|
+
})
|
|
2541
|
+
}), /* @__PURE__ */ P(Q, {
|
|
2542
|
+
value: n,
|
|
2543
|
+
onValueChange: r
|
|
2544
|
+
})]
|
|
2545
|
+
}),
|
|
2546
|
+
/* @__PURE__ */ F("div", {
|
|
2547
|
+
className: "flex items-center gap-2",
|
|
2548
|
+
children: [/* @__PURE__ */ P(c, {
|
|
2549
|
+
name: "errorMessage",
|
|
2550
|
+
children: (e) => /* @__PURE__ */ F(A, {
|
|
2551
|
+
className: "flex-1",
|
|
2552
|
+
children: [
|
|
2553
|
+
/* @__PURE__ */ P(d, {
|
|
2554
|
+
htmlFor: e.name,
|
|
2555
|
+
children: a("editor.submitConfigForm.errorMessage")
|
|
2556
|
+
}),
|
|
2557
|
+
/* @__PURE__ */ P(O, {
|
|
2558
|
+
id: e.name,
|
|
2559
|
+
name: e.name,
|
|
2560
|
+
value: e.state.value?.[n] || "",
|
|
2561
|
+
onBlur: e.handleBlur,
|
|
2562
|
+
onChange: ({ target: t }) => {
|
|
2563
|
+
e.handleChange({
|
|
2564
|
+
...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
|
|
2565
|
+
[n]: t.value
|
|
2566
|
+
});
|
|
2567
|
+
},
|
|
2568
|
+
placeholder: a("editor.submitConfigForm.errorMessagePlaceholder")
|
|
2569
|
+
}),
|
|
2570
|
+
/* @__PURE__ */ P(j, { children: a("editor.submitConfigForm.errorMessageDesc") })
|
|
2571
|
+
]
|
|
2572
|
+
})
|
|
2573
|
+
}), /* @__PURE__ */ P(Q, {
|
|
2574
|
+
value: n,
|
|
2575
|
+
onValueChange: r
|
|
2576
|
+
})]
|
|
2577
|
+
})
|
|
2578
|
+
]
|
|
2579
|
+
}),
|
|
2580
|
+
/* @__PURE__ */ F("div", {
|
|
2581
|
+
className: "space-y-4",
|
|
2582
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
2583
|
+
className: "font-semibold text-sm",
|
|
2584
|
+
children: a("editor.submitConfigForm.behavior")
|
|
2585
|
+
}), /* @__PURE__ */ P(c, {
|
|
2586
|
+
name: "showLoading",
|
|
2587
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
2588
|
+
className: "flex items-center space-x-2",
|
|
2589
|
+
children: [/* @__PURE__ */ P(D, {
|
|
2590
|
+
id: e.name,
|
|
2591
|
+
checked: e.state.value,
|
|
2592
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2593
|
+
}), /* @__PURE__ */ P(d, {
|
|
2594
|
+
htmlFor: e.name,
|
|
2595
|
+
children: a("editor.submitConfigForm.showLoadingState")
|
|
2596
|
+
})]
|
|
2597
|
+
})
|
|
2598
|
+
})]
|
|
2599
|
+
})
|
|
2600
|
+
]
|
|
2601
|
+
}) });
|
|
2602
|
+
}, qn = ({ options: e, id: t, value: n, onValueChange: r, placeholder: i = "Select...", searchPlaceholder: a = "Search or create...", createLabel: o = (e) => `Use: ${e}`, clearLabel: s = "Clear selection", emptyLabel: c = "No results found", className: l, allowClear: u = !0, allowCreate: d = !0 }) => {
|
|
2603
|
+
let [p, m] = z(!1), [h, g] = z(""), _ = (e) => e ?? "", v = (e) => e.trim().toLowerCase(), y = _(n), b = n !== null && n !== "", S = b ? e.find((e) => _(e.value) === y) : void 0, C = v(h), re = d && C !== "" && !e.some((e) => v(e.label) === C || v(e.value ?? "") === C), w = (e) => {
|
|
2604
|
+
e === y ? u && r?.("") : r?.(e), m(!1), g("");
|
|
2605
|
+
};
|
|
2606
|
+
return /* @__PURE__ */ F(ie, {
|
|
2607
|
+
open: p,
|
|
2608
|
+
onOpenChange: m,
|
|
2609
|
+
children: [/* @__PURE__ */ P(ne, {
|
|
2610
|
+
asChild: !0,
|
|
2611
|
+
id: t,
|
|
2612
|
+
children: /* @__PURE__ */ F(k, {
|
|
2613
|
+
type: "button",
|
|
2614
|
+
variant: "outline",
|
|
2615
|
+
role: "combobox",
|
|
2616
|
+
"aria-expanded": p,
|
|
2617
|
+
className: E("w-full justify-between font-normal", l),
|
|
2618
|
+
children: [/* @__PURE__ */ P("span", {
|
|
2619
|
+
className: "truncate",
|
|
2620
|
+
children: b && S ? S.label : i
|
|
2621
|
+
}), /* @__PURE__ */ P(We, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
|
|
2622
|
+
})
|
|
2623
|
+
}), /* @__PURE__ */ P(ae, {
|
|
2624
|
+
className: "w-full p-0",
|
|
2625
|
+
align: "start",
|
|
2626
|
+
children: /* @__PURE__ */ F(ce, {
|
|
2627
|
+
shouldFilter: !1,
|
|
2628
|
+
children: [/* @__PURE__ */ P(ee, {
|
|
2629
|
+
placeholder: a,
|
|
2630
|
+
value: h,
|
|
2631
|
+
onValueChange: g
|
|
2632
|
+
}), /* @__PURE__ */ F(x, { children: [
|
|
2633
|
+
/* @__PURE__ */ P(f, { children: c }),
|
|
2634
|
+
u && b && /* @__PURE__ */ P(se, { children: /* @__PURE__ */ F(te, {
|
|
2635
|
+
value: "__clear__",
|
|
2636
|
+
onSelect: () => {
|
|
2637
|
+
r?.(""), m(!1), g("");
|
|
2638
|
+
},
|
|
2639
|
+
className: "mt-1 text-muted-foreground",
|
|
2640
|
+
children: [/* @__PURE__ */ P(L, { className: "mr-2 h-4 w-4" }), s]
|
|
2641
|
+
}) }),
|
|
2642
|
+
/* @__PURE__ */ F(se, { children: [re && /* @__PURE__ */ F(te, {
|
|
2643
|
+
value: `__create__${h}`,
|
|
2644
|
+
onSelect: () => {
|
|
2645
|
+
h.trim() && (r?.(h.trim()), m(!1), g(""));
|
|
2646
|
+
},
|
|
2647
|
+
className: "text-primary",
|
|
2648
|
+
children: [/* @__PURE__ */ P(I, { className: "mr-2 h-4 w-4" }), o(h)]
|
|
2649
|
+
}), e.filter((e) => {
|
|
2650
|
+
let t = h.toLowerCase();
|
|
2651
|
+
return e.label.toLowerCase().includes(t) || (e.value?.toLowerCase() ?? "").includes(t);
|
|
2652
|
+
}).map((e, t) => /* @__PURE__ */ F(te, {
|
|
2653
|
+
value: e.label,
|
|
2654
|
+
onSelect: () => w(e?.value || ""),
|
|
2655
|
+
children: [/* @__PURE__ */ P(Ve, {
|
|
2656
|
+
"aria-hidden": "true",
|
|
2657
|
+
className: E("mr-2 h-4 w-4", b && _(e.value) === y ? "opacity-100" : "opacity-0")
|
|
2658
|
+
}), e.label]
|
|
2659
|
+
}, e.value ?? e.label ?? t))] })
|
|
2660
|
+
] })]
|
|
2661
|
+
})
|
|
2662
|
+
})]
|
|
2663
|
+
});
|
|
2664
|
+
}, Jn = Object.entries({
|
|
2665
|
+
alphanumeric: "^[a-zA-Z0-9]+$",
|
|
2666
|
+
email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
|
|
2667
|
+
letters: "^[a-zA-Z]+$",
|
|
2668
|
+
number: "^[0-9]+$",
|
|
2669
|
+
url: "^https?:\\/\\/.+$"
|
|
2670
|
+
}).map(([e, t]) => ({
|
|
2671
|
+
label: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
|
|
2672
|
+
value: t
|
|
2673
|
+
})), Yn = ({ id: e, value: t, onValueChange: n }) => /* @__PURE__ */ P(qn, {
|
|
2674
|
+
id: e,
|
|
2675
|
+
options: kt(() => t && !Jn.some((e) => e.value === t) ? [...Jn, {
|
|
2676
|
+
label: `Custom: ${t}`,
|
|
2677
|
+
value: t
|
|
2678
|
+
}] : Jn, [t]),
|
|
2679
|
+
value: t,
|
|
2680
|
+
onValueChange: n,
|
|
2681
|
+
placeholder: "Select or create a pattern",
|
|
2682
|
+
searchPlaceholder: "Search patterns...",
|
|
2683
|
+
createLabel: (e) => `Use pattern: ${e}`
|
|
2684
|
+
}), Xn = 400, Zn = .8, Qn = (e) => new Promise((t, n) => {
|
|
2685
|
+
let r = new FileReader();
|
|
2686
|
+
r.onerror = () => n(/* @__PURE__ */ Error("read_failed")), r.onload = () => {
|
|
2687
|
+
let e = new Image();
|
|
2688
|
+
e.onload = () => t(e), e.onerror = () => n(/* @__PURE__ */ Error("decode_failed")), e.src = r.result;
|
|
2689
|
+
}, r.readAsDataURL(e);
|
|
2690
|
+
}), $n = async (e) => {
|
|
2691
|
+
if (!e.type.startsWith("image/")) throw Error("invalid_type");
|
|
2692
|
+
if (e.size > 5242880) throw Error("too_large");
|
|
2693
|
+
let t = await Qn(e), n = Math.min(1, Xn / Math.max(t.width, t.height)), r = document.createElement("canvas");
|
|
2694
|
+
r.width = Math.round(t.width * n), r.height = Math.round(t.height * n);
|
|
2695
|
+
let i = r.getContext("2d");
|
|
2696
|
+
if (!i) throw Error("canvas_unavailable");
|
|
2697
|
+
return i.drawImage(t, 0, 0, r.width, r.height), r.toDataURL("image/jpeg", Zn);
|
|
2698
|
+
}, er = 400, tr = (e) => {
|
|
2699
|
+
if (!/^https?:\/\//i.test(e)) return !1;
|
|
2700
|
+
try {
|
|
2701
|
+
return !!new URL(e).hostname;
|
|
2702
|
+
} catch {
|
|
2703
|
+
return !1;
|
|
2704
|
+
}
|
|
2705
|
+
}, nr = ({ value: e, onChange: t }) => {
|
|
2706
|
+
let n = At(null), r = At(null), [i, a] = z(!1), [o, s] = z(e && /^https?:\/\//i.test(e) ? e : ""), c = U();
|
|
2707
|
+
Dt(() => {
|
|
2708
|
+
i || s(e && /^https?:\/\//i.test(e) ? e : "");
|
|
2709
|
+
}, [i, e]), Dt(() => () => {
|
|
2710
|
+
r.current && clearTimeout(r.current);
|
|
2711
|
+
}, []);
|
|
2712
|
+
let l = async (e) => {
|
|
2713
|
+
let r = e.target.files?.[0];
|
|
2714
|
+
if (r) try {
|
|
2715
|
+
t(await $n(r)), a(!1);
|
|
2716
|
+
} catch (e) {
|
|
2717
|
+
let t = e.message;
|
|
2718
|
+
t === "too_large" ? V.error(c("editor.inputNodeForm.optionImageTooLarge")) : t === "invalid_type" ? V.error(c("editor.inputNodeForm.optionImageInvalid")) : V.error(c("editor.inputNodeForm.optionImageError"));
|
|
2719
|
+
} finally {
|
|
2720
|
+
n.current && (n.current.value = "");
|
|
2721
|
+
}
|
|
2722
|
+
}, u = () => {
|
|
2723
|
+
let e = o.trim();
|
|
2724
|
+
e && (t(e), a(!1));
|
|
2725
|
+
};
|
|
2726
|
+
return /* @__PURE__ */ F("div", {
|
|
2727
|
+
className: "relative",
|
|
2728
|
+
children: [
|
|
2729
|
+
/* @__PURE__ */ P("input", {
|
|
2730
|
+
ref: n,
|
|
2731
|
+
type: "file",
|
|
2732
|
+
accept: "image/*",
|
|
2733
|
+
className: "hidden",
|
|
2734
|
+
onChange: l
|
|
2735
|
+
}),
|
|
2736
|
+
/* @__PURE__ */ F(ie, {
|
|
2737
|
+
open: i,
|
|
2738
|
+
onOpenChange: a,
|
|
2739
|
+
children: [/* @__PURE__ */ P(ne, {
|
|
2740
|
+
asChild: !0,
|
|
2741
|
+
children: e ? /* @__PURE__ */ P("button", {
|
|
2742
|
+
type: "button",
|
|
2743
|
+
className: "h-9 w-9 cursor-pointer overflow-hidden rounded-md border border-input",
|
|
2744
|
+
"aria-label": c("editor.inputNodeForm.optionImageReplace"),
|
|
2745
|
+
children: /* @__PURE__ */ P("img", {
|
|
2746
|
+
src: e,
|
|
2747
|
+
alt: "",
|
|
2748
|
+
className: "h-full w-full object-cover"
|
|
2749
|
+
})
|
|
2750
|
+
}) : /* @__PURE__ */ P(k, {
|
|
2751
|
+
type: "button",
|
|
2752
|
+
variant: "outline",
|
|
2753
|
+
size: "icon",
|
|
2754
|
+
"aria-label": c("editor.inputNodeForm.optionImageAdd"),
|
|
2755
|
+
children: /* @__PURE__ */ P(tt, { className: "h-4 w-4" })
|
|
2756
|
+
})
|
|
2757
|
+
}), /* @__PURE__ */ F(ae, {
|
|
2758
|
+
align: "start",
|
|
2759
|
+
className: "w-64 space-y-3 p-3",
|
|
2760
|
+
children: [
|
|
2761
|
+
/* @__PURE__ */ F(k, {
|
|
2762
|
+
type: "button",
|
|
2763
|
+
variant: "outline",
|
|
2764
|
+
size: "sm",
|
|
2765
|
+
className: "w-full",
|
|
2766
|
+
onClick: () => n.current?.click(),
|
|
2767
|
+
children: [/* @__PURE__ */ P(yt, { className: "mr-2 h-4 w-4" }), c("editor.inputNodeForm.optionImageUpload")]
|
|
2768
|
+
}),
|
|
2769
|
+
/* @__PURE__ */ P(ue, {}),
|
|
2770
|
+
/* @__PURE__ */ F("div", {
|
|
2771
|
+
className: "flex items-center gap-2",
|
|
2772
|
+
children: [/* @__PURE__ */ P(rt, { className: "h-4 w-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ P(O, {
|
|
2773
|
+
placeholder: c("editor.inputNodeForm.optionImageUrlPlaceholder"),
|
|
2774
|
+
value: o,
|
|
2775
|
+
onChange: (n) => {
|
|
2776
|
+
let i = n.target.value;
|
|
2777
|
+
s(i), r.current && clearTimeout(r.current);
|
|
2778
|
+
let a = i.trim();
|
|
2779
|
+
!tr(a) || a === e || (r.current = setTimeout(() => {
|
|
2780
|
+
t(a);
|
|
2781
|
+
}, er));
|
|
2782
|
+
},
|
|
2783
|
+
onKeyDown: (e) => {
|
|
2784
|
+
e.key === "Enter" && (e.preventDefault(), u());
|
|
2785
|
+
},
|
|
2786
|
+
onBlur: u
|
|
2787
|
+
})]
|
|
2788
|
+
})
|
|
2789
|
+
]
|
|
2790
|
+
})]
|
|
2791
|
+
}),
|
|
2792
|
+
e && /* @__PURE__ */ P("button", {
|
|
2793
|
+
type: "button",
|
|
2794
|
+
onClick: (e) => {
|
|
2795
|
+
e.stopPropagation(), t("");
|
|
2796
|
+
},
|
|
2797
|
+
className: "-top-1 -right-1 absolute flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-destructive text-destructive-foreground",
|
|
2798
|
+
"aria-label": c("editor.inputNodeForm.optionImageRemove"),
|
|
2799
|
+
children: /* @__PURE__ */ P(L, { className: "h-3 w-3" })
|
|
2800
|
+
})
|
|
2801
|
+
]
|
|
2802
|
+
});
|
|
2803
|
+
};
|
|
2804
|
+
//#endregion
|
|
2805
|
+
//#region src/shared/components/ui/collapsible.tsx
|
|
2806
|
+
function rr({ ...e }) {
|
|
2807
|
+
return /* @__PURE__ */ P(It.Root, {
|
|
2808
|
+
"data-slot": "collapsible",
|
|
2809
|
+
...e
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
function ir({ ...e }) {
|
|
2813
|
+
return /* @__PURE__ */ P(It.CollapsibleTrigger, {
|
|
2814
|
+
"data-slot": "collapsible-trigger",
|
|
2815
|
+
...e
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
function ar({ ...e }) {
|
|
2819
|
+
return /* @__PURE__ */ P(It.CollapsibleContent, {
|
|
2820
|
+
"data-slot": "collapsible-content",
|
|
2821
|
+
...e
|
|
2822
|
+
});
|
|
2823
|
+
}
|
|
2824
|
+
//#endregion
|
|
2825
|
+
//#region src/editor/features/TreegeEditor/forms/InputNodeForm.tsx
|
|
2826
|
+
var or = () => {
|
|
2827
|
+
let [e, t] = z("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = W(), i = [
|
|
2828
|
+
"select",
|
|
2829
|
+
"radio",
|
|
2830
|
+
"autocomplete",
|
|
2831
|
+
"checkbox"
|
|
2832
|
+
].includes(n?.data?.type || ""), a = Ht(n?.id), o = U(), s = n?.data?.type === "submit", c = n?.data?.type === "hidden", { handleSubmit: l, Field: u } = Pe({
|
|
2833
|
+
defaultValues: {
|
|
2834
|
+
defaultValue: n?.data?.defaultValue,
|
|
2835
|
+
disablePast: n?.data?.disablePast,
|
|
2836
|
+
errorMessage: n?.data?.errorMessage || { en: "" },
|
|
2837
|
+
helperText: n?.data?.helperText || { en: "" },
|
|
2838
|
+
httpConfig: n?.data?.httpConfig,
|
|
2839
|
+
label: n?.data?.label || { en: "" },
|
|
2840
|
+
multiple: n?.data?.multiple,
|
|
2841
|
+
name: n?.data?.name || "",
|
|
2842
|
+
options: n?.data?.options || [],
|
|
2843
|
+
pattern: n?.data?.pattern || "",
|
|
2844
|
+
placeholder: n?.data?.placeholder || { en: "" },
|
|
2845
|
+
required: n?.data?.required,
|
|
2846
|
+
submitConfig: n?.data?.submitConfig,
|
|
2847
|
+
variant: n?.data?.variant || "default"
|
|
2848
|
+
},
|
|
2849
|
+
listeners: {
|
|
2850
|
+
onChange: ({ formApi: e }) => {
|
|
2851
|
+
e.handleSubmit().then();
|
|
2852
|
+
},
|
|
2853
|
+
onChangeDebounceMs: 150
|
|
2854
|
+
},
|
|
2855
|
+
onSubmit: ({ value: e }) => {
|
|
2856
|
+
r(e);
|
|
2857
|
+
}
|
|
2858
|
+
});
|
|
2859
|
+
return /* @__PURE__ */ P("form", {
|
|
2860
|
+
onSubmit: (e) => {
|
|
2861
|
+
e.preventDefault(), e.stopPropagation();
|
|
2862
|
+
},
|
|
2863
|
+
children: /* @__PURE__ */ F("div", {
|
|
2864
|
+
className: "grid gap-6",
|
|
2865
|
+
children: [
|
|
2866
|
+
/* @__PURE__ */ F("div", {
|
|
2867
|
+
className: "flex items-end gap-2",
|
|
2868
|
+
children: [/* @__PURE__ */ P(u, {
|
|
2869
|
+
name: "label",
|
|
2870
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
2871
|
+
className: "flex-1",
|
|
2872
|
+
children: [/* @__PURE__ */ P(d, {
|
|
2873
|
+
htmlFor: t.name,
|
|
2874
|
+
children: o("editor.inputNodeForm.label")
|
|
2875
|
+
}), /* @__PURE__ */ P(O, {
|
|
2876
|
+
autoFocus: !0,
|
|
2877
|
+
id: t.name,
|
|
2878
|
+
name: t.name,
|
|
2879
|
+
value: t.state.value?.[e] || "",
|
|
2880
|
+
onBlur: t.handleBlur,
|
|
2881
|
+
onChange: ({ target: n }) => {
|
|
2882
|
+
t.handleChange({
|
|
2883
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2884
|
+
[e]: n.value
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
})]
|
|
2888
|
+
})
|
|
2889
|
+
}), /* @__PURE__ */ P(Q, {
|
|
2890
|
+
value: e,
|
|
2891
|
+
onValueChange: t
|
|
2892
|
+
})]
|
|
2893
|
+
}),
|
|
2894
|
+
!(s || c) && n?.data?.type !== "file" && /* @__PURE__ */ F("div", {
|
|
2895
|
+
className: "flex items-end gap-2",
|
|
2896
|
+
children: [/* @__PURE__ */ P(u, {
|
|
2897
|
+
name: "placeholder",
|
|
2898
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
2899
|
+
className: "flex-1",
|
|
2900
|
+
children: [/* @__PURE__ */ P(d, {
|
|
2901
|
+
htmlFor: t.name,
|
|
2902
|
+
children: o("editor.inputNodeForm.placeholder")
|
|
2903
|
+
}), /* @__PURE__ */ P(O, {
|
|
2904
|
+
id: t.name,
|
|
2905
|
+
name: t.name,
|
|
2906
|
+
value: t.state.value?.[e] || "",
|
|
2907
|
+
onBlur: t.handleBlur,
|
|
2908
|
+
onChange: ({ target: n }) => {
|
|
2909
|
+
t.handleChange({
|
|
2910
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2911
|
+
[e]: n.value
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
})]
|
|
2915
|
+
})
|
|
2916
|
+
}), /* @__PURE__ */ P(Q, {
|
|
2917
|
+
value: e,
|
|
2918
|
+
onValueChange: t
|
|
2919
|
+
})]
|
|
2920
|
+
}),
|
|
2921
|
+
!(s || c) && /* @__PURE__ */ F("div", {
|
|
2922
|
+
className: "flex items-end gap-2",
|
|
2923
|
+
children: [/* @__PURE__ */ P(u, {
|
|
2924
|
+
name: "helperText",
|
|
2925
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
2926
|
+
className: "flex-1",
|
|
2927
|
+
children: [/* @__PURE__ */ P(d, {
|
|
2928
|
+
htmlFor: t.name,
|
|
2929
|
+
children: o("editor.inputNodeForm.helperText")
|
|
2930
|
+
}), /* @__PURE__ */ P(O, {
|
|
2931
|
+
id: t.name,
|
|
2932
|
+
name: t.name,
|
|
2933
|
+
value: t.state.value?.[e] || "",
|
|
2934
|
+
onBlur: t.handleBlur,
|
|
2935
|
+
onChange: ({ target: n }) => {
|
|
2936
|
+
t.handleChange({
|
|
2937
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2938
|
+
[e]: n.value
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
})]
|
|
2942
|
+
})
|
|
2943
|
+
}), /* @__PURE__ */ P(Q, {
|
|
2944
|
+
value: e,
|
|
2945
|
+
onValueChange: t
|
|
2946
|
+
})]
|
|
2947
|
+
}),
|
|
2948
|
+
n?.data?.type === "http" && /* @__PURE__ */ F(rr, {
|
|
2949
|
+
defaultOpen: !0,
|
|
2950
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2951
|
+
children: [/* @__PURE__ */ P(ir, {
|
|
2952
|
+
asChild: !0,
|
|
2953
|
+
children: /* @__PURE__ */ F("div", {
|
|
2954
|
+
className: "flex items-center justify-between gap-4",
|
|
2955
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
2956
|
+
className: "font-semibold text-sm",
|
|
2957
|
+
children: o("editor.inputNodeForm.httpConfiguration")
|
|
2958
|
+
}), /* @__PURE__ */ F(k, {
|
|
2959
|
+
variant: "ghost",
|
|
2960
|
+
size: "icon",
|
|
2961
|
+
className: "size-8",
|
|
2962
|
+
children: [/* @__PURE__ */ P(We, {}), /* @__PURE__ */ P("span", {
|
|
2963
|
+
className: "sr-only",
|
|
2964
|
+
children: o("common.toggle")
|
|
2965
|
+
})]
|
|
2966
|
+
})]
|
|
2967
|
+
})
|
|
2968
|
+
}), /* @__PURE__ */ P(ar, {
|
|
2969
|
+
className: "flex flex-col gap-4",
|
|
2970
|
+
children: /* @__PURE__ */ P(u, {
|
|
2971
|
+
name: "httpConfig",
|
|
2972
|
+
children: (e) => /* @__PURE__ */ P(Wn, {
|
|
2973
|
+
value: e.state.value,
|
|
2974
|
+
onChange: (t) => {
|
|
2975
|
+
e.handleChange(t), l().then();
|
|
2976
|
+
}
|
|
2977
|
+
})
|
|
2978
|
+
})
|
|
2979
|
+
})]
|
|
2980
|
+
}),
|
|
2981
|
+
s && /* @__PURE__ */ F(rr, {
|
|
2982
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2983
|
+
children: [/* @__PURE__ */ P(ir, {
|
|
2984
|
+
asChild: !0,
|
|
2985
|
+
children: /* @__PURE__ */ F("div", {
|
|
2986
|
+
className: "flex items-center justify-between gap-4",
|
|
2987
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
2988
|
+
className: "font-semibold text-sm",
|
|
2989
|
+
children: o("editor.inputNodeForm.submitConfiguration")
|
|
2990
|
+
}), /* @__PURE__ */ F(k, {
|
|
2991
|
+
variant: "ghost",
|
|
2992
|
+
size: "icon",
|
|
2993
|
+
className: "size-8",
|
|
2994
|
+
children: [/* @__PURE__ */ P(We, {}), /* @__PURE__ */ P("span", {
|
|
2995
|
+
className: "sr-only",
|
|
2996
|
+
children: o("common.toggle")
|
|
2997
|
+
})]
|
|
2998
|
+
})]
|
|
2999
|
+
})
|
|
3000
|
+
}), /* @__PURE__ */ P(ar, {
|
|
3001
|
+
className: "flex flex-col gap-4",
|
|
3002
|
+
children: /* @__PURE__ */ P(u, {
|
|
3003
|
+
name: "submitConfig",
|
|
3004
|
+
children: (e) => /* @__PURE__ */ P(Kn, {
|
|
3005
|
+
value: e.state.value,
|
|
3006
|
+
onChange: (t) => {
|
|
3007
|
+
e.handleChange(t), l().then();
|
|
3008
|
+
}
|
|
3009
|
+
})
|
|
3010
|
+
})
|
|
3011
|
+
})]
|
|
3012
|
+
}),
|
|
3013
|
+
n?.data?.type === "file" && /* @__PURE__ */ P(u, {
|
|
3014
|
+
name: "multiple",
|
|
3015
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
3016
|
+
className: "flex items-center space-x-2",
|
|
3017
|
+
children: [/* @__PURE__ */ P(D, {
|
|
3018
|
+
id: e.name,
|
|
3019
|
+
checked: e.state.value,
|
|
3020
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
3021
|
+
}), /* @__PURE__ */ P(d, {
|
|
3022
|
+
htmlFor: e.name,
|
|
3023
|
+
children: o("editor.inputNodeForm.multipleFiles")
|
|
3024
|
+
})]
|
|
3025
|
+
})
|
|
3026
|
+
}),
|
|
3027
|
+
i && /* @__PURE__ */ F(rr, {
|
|
3028
|
+
defaultOpen: !0,
|
|
3029
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
3030
|
+
children: [/* @__PURE__ */ P(ir, {
|
|
3031
|
+
asChild: !0,
|
|
3032
|
+
children: /* @__PURE__ */ F("div", {
|
|
3033
|
+
className: "flex items-center justify-between gap-4",
|
|
3034
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
3035
|
+
className: "font-semibold text-sm",
|
|
3036
|
+
children: o("editor.inputNodeForm.options")
|
|
3037
|
+
}), /* @__PURE__ */ F(k, {
|
|
3038
|
+
variant: "ghost",
|
|
3039
|
+
size: "icon",
|
|
3040
|
+
className: "size-8",
|
|
3041
|
+
children: [/* @__PURE__ */ P(We, {}), /* @__PURE__ */ P("span", {
|
|
3042
|
+
className: "sr-only",
|
|
3043
|
+
children: o("common.toggle")
|
|
3044
|
+
})]
|
|
3045
|
+
})]
|
|
3046
|
+
})
|
|
3047
|
+
}), /* @__PURE__ */ F(ar, {
|
|
3048
|
+
className: "flex flex-col gap-4",
|
|
3049
|
+
children: [
|
|
3050
|
+
/* @__PURE__ */ P(u, {
|
|
3051
|
+
name: "options",
|
|
3052
|
+
mode: "array",
|
|
3053
|
+
children: (t) => /* @__PURE__ */ F("div", {
|
|
3054
|
+
className: "space-y-2",
|
|
3055
|
+
children: [t.state.value?.map((r, i) => {
|
|
3056
|
+
let a = `options[${i}]`;
|
|
3057
|
+
return /* @__PURE__ */ F("div", {
|
|
3058
|
+
className: "flex flex-col gap-2",
|
|
3059
|
+
children: [/* @__PURE__ */ F("div", {
|
|
3060
|
+
className: "flex items-start gap-2",
|
|
3061
|
+
children: [
|
|
3062
|
+
n?.data?.type === "radio" && /* @__PURE__ */ P(u, {
|
|
3063
|
+
name: `options[${i}].image`,
|
|
3064
|
+
children: (e) => /* @__PURE__ */ P(nr, {
|
|
3065
|
+
value: e.state.value,
|
|
3066
|
+
onChange: (t) => e.handleChange(t)
|
|
3067
|
+
})
|
|
3068
|
+
}),
|
|
3069
|
+
/* @__PURE__ */ P(u, {
|
|
3070
|
+
name: `options[${i}].label`,
|
|
3071
|
+
children: (t) => /* @__PURE__ */ P(O, {
|
|
3072
|
+
placeholder: o("editor.inputNodeForm.optionLabel"),
|
|
3073
|
+
value: t.state.value?.[e] || "",
|
|
3074
|
+
onChange: ({ target: n }) => {
|
|
3075
|
+
t.handleChange({
|
|
3076
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
3077
|
+
[e]: n.value
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
})
|
|
3081
|
+
}),
|
|
3082
|
+
/* @__PURE__ */ P(u, {
|
|
3083
|
+
name: `options[${i}].value`,
|
|
3084
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
3085
|
+
placeholder: o("editor.inputNodeForm.optionValue"),
|
|
3086
|
+
value: e.state.value || "",
|
|
3087
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
3088
|
+
})
|
|
3089
|
+
}),
|
|
3090
|
+
/* @__PURE__ */ P(k, {
|
|
3091
|
+
type: "button",
|
|
3092
|
+
variant: "ghost",
|
|
3093
|
+
size: "icon",
|
|
3094
|
+
onClick: () => {
|
|
3095
|
+
t.removeValue(i), l().then();
|
|
3096
|
+
},
|
|
3097
|
+
children: /* @__PURE__ */ P(L, { className: "h-4 w-4" })
|
|
3098
|
+
})
|
|
3099
|
+
]
|
|
3100
|
+
}), (n?.data?.type === "radio" || n?.data?.type === "checkbox") && /* @__PURE__ */ P(u, {
|
|
3101
|
+
name: `options[${i}].description`,
|
|
3102
|
+
children: (t) => /* @__PURE__ */ P(O, {
|
|
3103
|
+
placeholder: o("editor.inputNodeForm.optionDescription"),
|
|
3104
|
+
value: t.state.value?.[e] || "",
|
|
3105
|
+
onChange: ({ target: n }) => {
|
|
3106
|
+
t.handleChange({
|
|
3107
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
3108
|
+
[e]: n.value
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
})
|
|
3112
|
+
})]
|
|
3113
|
+
}, a);
|
|
3114
|
+
}), /* @__PURE__ */ P(k, {
|
|
3115
|
+
type: "button",
|
|
3116
|
+
variant: "outline",
|
|
3117
|
+
size: "sm",
|
|
3118
|
+
onClick: () => {
|
|
3119
|
+
t.pushValue({
|
|
3120
|
+
label: { en: "" },
|
|
3121
|
+
value: ""
|
|
3122
|
+
}), l().then();
|
|
3123
|
+
},
|
|
3124
|
+
children: o("editor.inputNodeForm.addOption")
|
|
3125
|
+
})]
|
|
3126
|
+
})
|
|
3127
|
+
}),
|
|
3128
|
+
n?.data?.type === "select" && /* @__PURE__ */ P(u, {
|
|
3129
|
+
name: "multiple",
|
|
3130
|
+
children: (e) => /* @__PURE__ */ F("div", {
|
|
3131
|
+
className: "flex items-center space-x-2",
|
|
3132
|
+
children: [/* @__PURE__ */ P(D, {
|
|
3133
|
+
id: e.name,
|
|
3134
|
+
checked: e.state.value,
|
|
3135
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
3136
|
+
}), /* @__PURE__ */ P(d, {
|
|
3137
|
+
htmlFor: e.name,
|
|
3138
|
+
children: o("editor.inputNodeForm.multipleSelection")
|
|
3139
|
+
})]
|
|
3140
|
+
})
|
|
3141
|
+
}),
|
|
3142
|
+
n?.data?.type === "radio" && /* @__PURE__ */ P(u, {
|
|
3143
|
+
name: "variant",
|
|
3144
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
3145
|
+
htmlFor: e.name,
|
|
3146
|
+
children: o("editor.inputNodeForm.variant")
|
|
3147
|
+
}), /* @__PURE__ */ F(g, {
|
|
3148
|
+
value: e.state.value || "default",
|
|
3149
|
+
onValueChange: (t) => e.handleChange(t),
|
|
3150
|
+
children: [/* @__PURE__ */ P(v, {
|
|
3151
|
+
id: e.name,
|
|
3152
|
+
className: "w-full",
|
|
3153
|
+
children: /* @__PURE__ */ P(T, {})
|
|
3154
|
+
}), /* @__PURE__ */ F(C, { children: [/* @__PURE__ */ P(h, {
|
|
3155
|
+
value: "default",
|
|
3156
|
+
children: o("editor.inputNodeForm.variantDefault")
|
|
3157
|
+
}), /* @__PURE__ */ P(h, {
|
|
3158
|
+
value: "card",
|
|
3159
|
+
children: o("editor.inputNodeForm.variantCard")
|
|
3160
|
+
})] })]
|
|
3161
|
+
})] })
|
|
3162
|
+
})
|
|
3163
|
+
]
|
|
3164
|
+
})]
|
|
3165
|
+
}),
|
|
3166
|
+
!s && /* @__PURE__ */ F(rr, {
|
|
3167
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
3168
|
+
children: [/* @__PURE__ */ P(ir, {
|
|
3169
|
+
asChild: !0,
|
|
3170
|
+
children: /* @__PURE__ */ F("div", {
|
|
3171
|
+
className: "flex items-center justify-between gap-4",
|
|
3172
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
3173
|
+
className: "font-semibold text-sm",
|
|
3174
|
+
children: o("editor.inputNodeForm.validation")
|
|
3175
|
+
}), /* @__PURE__ */ F(k, {
|
|
3176
|
+
variant: "ghost",
|
|
3177
|
+
size: "icon",
|
|
3178
|
+
className: "size-8",
|
|
3179
|
+
children: [/* @__PURE__ */ P(We, {}), /* @__PURE__ */ P("span", {
|
|
3180
|
+
className: "sr-only",
|
|
3181
|
+
children: o("common.toggle")
|
|
3182
|
+
})]
|
|
3183
|
+
})]
|
|
3184
|
+
})
|
|
3185
|
+
}), /* @__PURE__ */ F(ar, {
|
|
3186
|
+
className: "flex flex-col gap-6",
|
|
3187
|
+
children: [
|
|
3188
|
+
/* @__PURE__ */ P(u, {
|
|
3189
|
+
name: "required",
|
|
3190
|
+
children: (e) => /* @__PURE__ */ P(A, { children: /* @__PURE__ */ F("div", {
|
|
3191
|
+
className: "flex items-center space-x-2",
|
|
3192
|
+
children: [/* @__PURE__ */ P(D, {
|
|
3193
|
+
id: e.name,
|
|
3194
|
+
checked: e.state.value,
|
|
3195
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
3196
|
+
}), /* @__PURE__ */ P(d, {
|
|
3197
|
+
htmlFor: e.name,
|
|
3198
|
+
children: o("editor.inputNodeForm.required")
|
|
3199
|
+
})]
|
|
3200
|
+
}) })
|
|
3201
|
+
}),
|
|
3202
|
+
(n?.data?.type === "date" || n?.data?.type === "daterange") && /* @__PURE__ */ P(u, {
|
|
3203
|
+
name: "disablePast",
|
|
3204
|
+
children: (e) => /* @__PURE__ */ P(A, { children: /* @__PURE__ */ F("div", {
|
|
3205
|
+
className: "flex items-center space-x-2",
|
|
3206
|
+
children: [/* @__PURE__ */ P(D, {
|
|
3207
|
+
id: e.name,
|
|
3208
|
+
checked: e.state.value,
|
|
3209
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
3210
|
+
}), /* @__PURE__ */ P(d, {
|
|
3211
|
+
htmlFor: e.name,
|
|
3212
|
+
children: o("editor.inputNodeForm.disablePast")
|
|
3213
|
+
})]
|
|
3214
|
+
}) })
|
|
3215
|
+
}),
|
|
3216
|
+
/* @__PURE__ */ P(u, {
|
|
3217
|
+
name: "pattern",
|
|
3218
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
3219
|
+
htmlFor: e.name,
|
|
3220
|
+
children: o("editor.inputNodeForm.pattern")
|
|
3221
|
+
}), /* @__PURE__ */ P(Yn, {
|
|
3222
|
+
id: e.name,
|
|
3223
|
+
value: e.state.value,
|
|
3224
|
+
onValueChange: e.handleChange
|
|
3225
|
+
})] })
|
|
3226
|
+
}),
|
|
3227
|
+
/* @__PURE__ */ F("div", {
|
|
3228
|
+
className: "flex items-end gap-2",
|
|
3229
|
+
children: [/* @__PURE__ */ P(u, {
|
|
3230
|
+
name: "errorMessage",
|
|
3231
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
3232
|
+
className: "flex-1",
|
|
3233
|
+
children: [/* @__PURE__ */ P(d, {
|
|
3234
|
+
htmlFor: t.name,
|
|
3235
|
+
children: o("editor.inputNodeForm.errorMessage")
|
|
3236
|
+
}), /* @__PURE__ */ P(O, {
|
|
3237
|
+
id: t.name,
|
|
3238
|
+
name: t.name,
|
|
3239
|
+
value: t.state.value?.[e] || "",
|
|
3240
|
+
onBlur: t.handleBlur,
|
|
3241
|
+
onChange: ({ target: n }) => {
|
|
3242
|
+
t.handleChange({
|
|
3243
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
3244
|
+
[e]: n.value
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
})]
|
|
3248
|
+
})
|
|
3249
|
+
}), /* @__PURE__ */ P(Q, {
|
|
3250
|
+
value: e,
|
|
3251
|
+
onValueChange: t
|
|
3252
|
+
})]
|
|
3253
|
+
})
|
|
3254
|
+
]
|
|
3255
|
+
})]
|
|
3256
|
+
}),
|
|
3257
|
+
!s && /* @__PURE__ */ F(rr, {
|
|
3258
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
3259
|
+
children: [/* @__PURE__ */ P(ir, {
|
|
3260
|
+
asChild: !0,
|
|
3261
|
+
children: /* @__PURE__ */ F("div", {
|
|
3262
|
+
className: "flex items-center justify-between gap-4",
|
|
3263
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
3264
|
+
className: "font-semibold text-sm",
|
|
3265
|
+
children: o("editor.inputNodeForm.advancedConfiguration")
|
|
3266
|
+
}), /* @__PURE__ */ F(k, {
|
|
3267
|
+
variant: "ghost",
|
|
3268
|
+
size: "icon",
|
|
3269
|
+
className: "size-8",
|
|
3270
|
+
children: [/* @__PURE__ */ P(We, {}), /* @__PURE__ */ P("span", {
|
|
3271
|
+
className: "sr-only",
|
|
3272
|
+
children: o("common.toggle")
|
|
3273
|
+
})]
|
|
3274
|
+
})]
|
|
3275
|
+
})
|
|
3276
|
+
}), /* @__PURE__ */ F(ar, {
|
|
3277
|
+
className: "flex flex-col gap-6",
|
|
3278
|
+
children: [/* @__PURE__ */ P(u, {
|
|
3279
|
+
name: "name",
|
|
3280
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
3281
|
+
/* @__PURE__ */ P(d, {
|
|
3282
|
+
htmlFor: e.name,
|
|
3283
|
+
children: o("editor.inputNodeForm.name")
|
|
3284
|
+
}),
|
|
3285
|
+
/* @__PURE__ */ P(O, {
|
|
3286
|
+
id: e.name,
|
|
3287
|
+
name: e.name,
|
|
3288
|
+
value: e.state.value,
|
|
3289
|
+
onBlur: e.handleBlur,
|
|
3290
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
3291
|
+
}),
|
|
3292
|
+
/* @__PURE__ */ P(j, { children: o("editor.inputNodeForm.nameDescription") })
|
|
3293
|
+
] })
|
|
3294
|
+
}), /* @__PURE__ */ P(u, {
|
|
3295
|
+
name: "defaultValue",
|
|
3296
|
+
children: (e) => /* @__PURE__ */ F(N, { children: [
|
|
3297
|
+
/* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
3298
|
+
htmlFor: e.name,
|
|
3299
|
+
children: o("editor.inputNodeForm.defaultValueType")
|
|
3300
|
+
}), /* @__PURE__ */ F(g, {
|
|
3301
|
+
value: e.state.value?.type || "none",
|
|
3302
|
+
onValueChange: (t) => {
|
|
3303
|
+
e.handleChange(t === "none" ? null : { type: t });
|
|
3304
|
+
},
|
|
3305
|
+
children: [/* @__PURE__ */ P(v, {
|
|
3306
|
+
id: e.name,
|
|
3307
|
+
children: /* @__PURE__ */ P(T, { placeholder: o("editor.inputNodeForm.selectType") })
|
|
3308
|
+
}), /* @__PURE__ */ F(C, { children: [
|
|
3309
|
+
/* @__PURE__ */ P(h, {
|
|
3310
|
+
value: "none",
|
|
3311
|
+
children: o("editor.inputNodeForm.defaultValueTypeNone")
|
|
3312
|
+
}),
|
|
3313
|
+
/* @__PURE__ */ P(h, {
|
|
3314
|
+
value: "static",
|
|
3315
|
+
children: o("editor.inputNodeForm.defaultValueTypeStatic")
|
|
3316
|
+
}),
|
|
3317
|
+
/* @__PURE__ */ P(h, {
|
|
3318
|
+
value: "reference",
|
|
3319
|
+
children: o("editor.inputNodeForm.defaultValueTypeReference")
|
|
3320
|
+
})
|
|
3321
|
+
] })]
|
|
3322
|
+
})] }),
|
|
3323
|
+
e.state.value?.type === "static" && /* @__PURE__ */ P(u, {
|
|
3324
|
+
name: "defaultValue.staticValue",
|
|
3325
|
+
children: (e) => {
|
|
3326
|
+
let t = n?.data?.type;
|
|
3327
|
+
return (t === "select" || t === "checkbox") && n?.data?.multiple ? /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
3328
|
+
htmlFor: e.name,
|
|
3329
|
+
children: o("editor.inputNodeForm.defaultValuesCommaSeparated")
|
|
3330
|
+
}), /* @__PURE__ */ P(O, {
|
|
3331
|
+
id: e.name,
|
|
3332
|
+
placeholder: o("editor.inputNodeForm.defaultValuesPlaceholder"),
|
|
3333
|
+
value: Array.isArray(e.state.value) ? e.state.value.join(", ") : "",
|
|
3334
|
+
onChange: ({ target: t }) => {
|
|
3335
|
+
let n = t.value.split(",").map((e) => e.trim()).filter(Boolean);
|
|
3336
|
+
e.handleChange(n.length > 0 ? n : null);
|
|
3337
|
+
}
|
|
3338
|
+
})] }) : t === "checkbox" ? /* @__PURE__ */ P(A, { children: /* @__PURE__ */ F("div", {
|
|
3339
|
+
className: "flex items-center space-x-2",
|
|
3340
|
+
children: [/* @__PURE__ */ P(D, {
|
|
3341
|
+
id: e.name,
|
|
3342
|
+
checked: !!e.state.value,
|
|
3343
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
3344
|
+
}), /* @__PURE__ */ P(d, {
|
|
3345
|
+
htmlFor: e.name,
|
|
3346
|
+
children: o("editor.inputNodeForm.defaultChecked")
|
|
3347
|
+
})]
|
|
3348
|
+
}) }) : /* @__PURE__ */ F(A, { children: [/* @__PURE__ */ P(d, {
|
|
3349
|
+
htmlFor: e.name,
|
|
3350
|
+
children: o("editor.inputNodeForm.staticValue")
|
|
3351
|
+
}), /* @__PURE__ */ P(O, {
|
|
3352
|
+
id: e.name,
|
|
3353
|
+
placeholder: o("editor.inputNodeForm.staticValuePlaceholder"),
|
|
3354
|
+
value: typeof e.state.value == "string" ? e.state.value : "",
|
|
3355
|
+
onChange: ({ target: t }) => e.handleChange(t.value || "")
|
|
3356
|
+
})] });
|
|
3357
|
+
}
|
|
3358
|
+
}),
|
|
3359
|
+
e.state.value?.type === "reference" && /* @__PURE__ */ F(N, { children: [
|
|
3360
|
+
/* @__PURE__ */ P(u, {
|
|
3361
|
+
name: "defaultValue.referenceField",
|
|
3362
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
3363
|
+
/* @__PURE__ */ P(d, {
|
|
3364
|
+
htmlFor: e.name,
|
|
3365
|
+
children: o("editor.inputNodeForm.referenceField")
|
|
3366
|
+
}),
|
|
3367
|
+
/* @__PURE__ */ F(g, {
|
|
3368
|
+
value: e.state.value || "",
|
|
3369
|
+
onValueChange: (t) => {
|
|
3370
|
+
e.handleChange(t);
|
|
3371
|
+
},
|
|
3372
|
+
children: [/* @__PURE__ */ P(v, {
|
|
3373
|
+
id: e.name,
|
|
3374
|
+
children: /* @__PURE__ */ P(T, { placeholder: o("editor.inputNodeForm.selectReferenceField") })
|
|
3375
|
+
}), /* @__PURE__ */ P(C, { children: a.length === 0 ? /* @__PURE__ */ P(h, {
|
|
3376
|
+
value: "none",
|
|
3377
|
+
disabled: !0,
|
|
3378
|
+
children: o("editor.inputNodeForm.noParentFieldsAvailable")
|
|
3379
|
+
}) : a.map((e) => /* @__PURE__ */ F(h, {
|
|
3380
|
+
value: e.nodeId,
|
|
3381
|
+
children: [
|
|
3382
|
+
e.label,
|
|
3383
|
+
" (",
|
|
3384
|
+
e.type,
|
|
3385
|
+
")"
|
|
3386
|
+
]
|
|
3387
|
+
}, e.nodeId)) })]
|
|
3388
|
+
}),
|
|
3389
|
+
a.length === 0 && /* @__PURE__ */ P(j, { children: o("editor.inputNodeForm.addInputFieldsBeforeReference") })
|
|
3390
|
+
] })
|
|
3391
|
+
}),
|
|
3392
|
+
/* @__PURE__ */ P(u, {
|
|
3393
|
+
name: "defaultValue.transformFunction",
|
|
3394
|
+
children: (t) => /* @__PURE__ */ F(A, { children: [
|
|
3395
|
+
/* @__PURE__ */ P(d, {
|
|
3396
|
+
htmlFor: t.name,
|
|
3397
|
+
children: o("editor.inputNodeForm.transformType")
|
|
3398
|
+
}),
|
|
3399
|
+
/* @__PURE__ */ F(g, {
|
|
3400
|
+
value: t.state.value || "none",
|
|
3401
|
+
onValueChange: (n) => {
|
|
3402
|
+
let r = n === "none" ? null : n;
|
|
3403
|
+
if (t.handleChange(r), n === "toObject") {
|
|
3404
|
+
let t = e.state.value;
|
|
3405
|
+
e.handleChange({
|
|
3406
|
+
...t,
|
|
3407
|
+
objectMapping: []
|
|
3408
|
+
});
|
|
3409
|
+
}
|
|
3410
|
+
},
|
|
3411
|
+
children: [/* @__PURE__ */ P(v, {
|
|
3412
|
+
id: t.name,
|
|
3413
|
+
children: /* @__PURE__ */ P(T, { placeholder: o("editor.inputNodeForm.selectTransformation") })
|
|
3414
|
+
}), /* @__PURE__ */ F(C, { children: [
|
|
3415
|
+
/* @__PURE__ */ P(h, {
|
|
3416
|
+
value: "none",
|
|
3417
|
+
children: o("editor.inputNodeForm.transformNone")
|
|
3418
|
+
}),
|
|
3419
|
+
/* @__PURE__ */ P(h, {
|
|
3420
|
+
value: "toString",
|
|
3421
|
+
children: o("editor.inputNodeForm.transformString")
|
|
3422
|
+
}),
|
|
3423
|
+
/* @__PURE__ */ P(h, {
|
|
3424
|
+
value: "toNumber",
|
|
3425
|
+
children: o("editor.inputNodeForm.transformNumber")
|
|
3426
|
+
}),
|
|
3427
|
+
/* @__PURE__ */ P(h, {
|
|
3428
|
+
value: "toBoolean",
|
|
3429
|
+
children: o("editor.inputNodeForm.transformBoolean")
|
|
3430
|
+
}),
|
|
3431
|
+
/* @__PURE__ */ P(h, {
|
|
3432
|
+
value: "toArray",
|
|
3433
|
+
children: o("editor.inputNodeForm.transformArray")
|
|
3434
|
+
}),
|
|
3435
|
+
/* @__PURE__ */ P(h, {
|
|
3436
|
+
value: "toObject",
|
|
3437
|
+
children: o("editor.inputNodeForm.transformMapToObject")
|
|
3438
|
+
})
|
|
3439
|
+
] })]
|
|
3440
|
+
}),
|
|
3441
|
+
/* @__PURE__ */ P(j, { children: o("editor.inputNodeForm.transformDesc") })
|
|
3442
|
+
] })
|
|
3443
|
+
}),
|
|
3444
|
+
e.state.value?.transformFunction === "toObject" && /* @__PURE__ */ P(u, {
|
|
3445
|
+
name: "defaultValue.objectMapping",
|
|
3446
|
+
mode: "array",
|
|
3447
|
+
children: (e) => /* @__PURE__ */ F(A, { children: [
|
|
3448
|
+
/* @__PURE__ */ P(d, { children: o("editor.inputNodeForm.objectMapping") }),
|
|
3449
|
+
/* @__PURE__ */ F("div", {
|
|
3450
|
+
className: "space-y-2",
|
|
3451
|
+
children: [e.state.value?.map((t, n) => /* @__PURE__ */ F("div", {
|
|
3452
|
+
className: "flex items-center gap-2",
|
|
3453
|
+
children: [
|
|
3454
|
+
/* @__PURE__ */ P(u, {
|
|
3455
|
+
name: `defaultValue.objectMapping[${n}].sourceKey`,
|
|
3456
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
3457
|
+
placeholder: o("editor.inputNodeForm.sourceKey"),
|
|
3458
|
+
value: e.state.value || "",
|
|
3459
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
3460
|
+
})
|
|
3461
|
+
}),
|
|
3462
|
+
/* @__PURE__ */ P("span", {
|
|
3463
|
+
className: "text-muted-foreground",
|
|
3464
|
+
children: "→"
|
|
3465
|
+
}),
|
|
3466
|
+
/* @__PURE__ */ P(u, {
|
|
3467
|
+
name: `defaultValue.objectMapping[${n}].targetKey`,
|
|
3468
|
+
children: (e) => /* @__PURE__ */ P(O, {
|
|
3469
|
+
placeholder: o("editor.inputNodeForm.targetKey"),
|
|
3470
|
+
value: e.state.value || "",
|
|
3471
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
3472
|
+
})
|
|
3473
|
+
}),
|
|
3474
|
+
/* @__PURE__ */ P(k, {
|
|
3475
|
+
type: "button",
|
|
3476
|
+
variant: "ghost",
|
|
3477
|
+
size: "icon",
|
|
3478
|
+
onClick: () => {
|
|
3479
|
+
e.removeValue(n), l().then();
|
|
3480
|
+
},
|
|
3481
|
+
children: /* @__PURE__ */ P(L, { className: "h-4 w-4" })
|
|
3482
|
+
})
|
|
3483
|
+
]
|
|
3484
|
+
}, `mapping-${n}`)), /* @__PURE__ */ F(k, {
|
|
3485
|
+
type: "button",
|
|
3486
|
+
variant: "outline",
|
|
3487
|
+
size: "sm",
|
|
3488
|
+
className: "w-full",
|
|
3489
|
+
onClick: () => {
|
|
3490
|
+
e.pushValue({
|
|
3491
|
+
sourceKey: "",
|
|
3492
|
+
targetKey: ""
|
|
3493
|
+
}), l().then();
|
|
3494
|
+
},
|
|
3495
|
+
children: [/* @__PURE__ */ P(I, { className: "mr-2 h-4 w-4" }), o("editor.inputNodeForm.addMapping")]
|
|
3496
|
+
})]
|
|
3497
|
+
}),
|
|
3498
|
+
/* @__PURE__ */ P(j, { children: o("editor.inputNodeForm.objectMappingDesc") })
|
|
3499
|
+
] })
|
|
3500
|
+
})
|
|
3501
|
+
] })
|
|
3502
|
+
] })
|
|
3503
|
+
})]
|
|
3504
|
+
})]
|
|
3505
|
+
})
|
|
3506
|
+
]
|
|
3507
|
+
})
|
|
3508
|
+
});
|
|
3509
|
+
}, sr = () => {
|
|
3510
|
+
let [e, t] = z("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = W(), { Field: i } = Pe({
|
|
3511
|
+
defaultValues: { label: n?.data?.label || { en: "" } },
|
|
3512
|
+
listeners: {
|
|
3513
|
+
onChange: ({ formApi: e }) => {
|
|
3514
|
+
e.handleSubmit().then();
|
|
3515
|
+
},
|
|
3516
|
+
onChangeDebounceMs: 150
|
|
3517
|
+
},
|
|
3518
|
+
onSubmit: ({ value: e }) => {
|
|
3519
|
+
r(e);
|
|
3520
|
+
}
|
|
3521
|
+
});
|
|
3522
|
+
return /* @__PURE__ */ P("form", {
|
|
3523
|
+
onSubmit: (e) => {
|
|
3524
|
+
e.preventDefault(), e.stopPropagation();
|
|
3525
|
+
},
|
|
3526
|
+
children: /* @__PURE__ */ P("div", {
|
|
3527
|
+
className: "grid gap-6",
|
|
3528
|
+
children: /* @__PURE__ */ F("div", {
|
|
3529
|
+
className: "flex items-end gap-2",
|
|
3530
|
+
children: [/* @__PURE__ */ P(i, {
|
|
3531
|
+
name: "label",
|
|
3532
|
+
children: (t) => /* @__PURE__ */ F(A, {
|
|
3533
|
+
className: "flex-1",
|
|
3534
|
+
children: [/* @__PURE__ */ P(d, {
|
|
3535
|
+
htmlFor: t.name,
|
|
3536
|
+
children: "Label"
|
|
3537
|
+
}), /* @__PURE__ */ P(O, {
|
|
3538
|
+
id: t.name,
|
|
3539
|
+
name: t.name,
|
|
3540
|
+
value: t.state.value?.[e] || "",
|
|
3541
|
+
onBlur: t.handleBlur,
|
|
3542
|
+
onChange: ({ target: n }) => {
|
|
3543
|
+
t.handleChange({
|
|
3544
|
+
...t.state.value,
|
|
3545
|
+
[e]: n.value
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
3548
|
+
})]
|
|
3549
|
+
})
|
|
3550
|
+
}), /* @__PURE__ */ P(Q, {
|
|
3551
|
+
value: e,
|
|
3552
|
+
onValueChange: t
|
|
3553
|
+
})]
|
|
3554
|
+
})
|
|
3555
|
+
})
|
|
3556
|
+
});
|
|
3557
|
+
}, cr = () => {
|
|
3558
|
+
let [e, t] = z(""), [r, i] = z(!1), { selectedNode: a, groupNodes: o } = $(), { setNodes: s } = M(), c = a?.parentId || "none", l = n(a), u = U(), f = Ot(), p = Ot();
|
|
3559
|
+
if (l) return null;
|
|
3560
|
+
let m = (e) => {
|
|
3561
|
+
a && s((t) => e === "none" ? t.map((e) => {
|
|
3562
|
+
if (e.id === a.id) {
|
|
3563
|
+
let { parentId: t, extent: n, ...r } = e;
|
|
3564
|
+
return r;
|
|
3565
|
+
}
|
|
3566
|
+
return e;
|
|
3567
|
+
}) : t.find((t) => t.id === e) ? t.map((t) => t.id === a.id ? {
|
|
3568
|
+
...t,
|
|
3569
|
+
extent: "parent",
|
|
3570
|
+
parentId: e,
|
|
3571
|
+
position: {
|
|
3572
|
+
x: 50,
|
|
3573
|
+
y: 80
|
|
3574
|
+
}
|
|
3575
|
+
} : t) : t);
|
|
3576
|
+
}, _ = () => {
|
|
3577
|
+
if (!(e.trim() && a)) return;
|
|
3578
|
+
if (o.find((t) => {
|
|
3579
|
+
let n = t.data?.label?.en || t.data?.label;
|
|
3580
|
+
return String(n).toLowerCase() === e.trim().toLowerCase();
|
|
3581
|
+
})) {
|
|
3582
|
+
V.error("This group already exists", { description: "Use the selector to add the node to an existing group." });
|
|
3583
|
+
return;
|
|
3584
|
+
}
|
|
3585
|
+
let n = Zt();
|
|
3586
|
+
s((t) => [{
|
|
3587
|
+
data: { label: { en: e.trim() } },
|
|
3588
|
+
id: n,
|
|
3589
|
+
position: {
|
|
3590
|
+
x: a.position.x - 300,
|
|
3591
|
+
y: a.position.y
|
|
3592
|
+
},
|
|
3593
|
+
style: {
|
|
3594
|
+
height: 400,
|
|
3595
|
+
width: 600
|
|
3596
|
+
},
|
|
3597
|
+
type: "group"
|
|
3598
|
+
}, ...t.map((e) => e.id === a.id ? {
|
|
3599
|
+
...e,
|
|
3600
|
+
extent: "parent",
|
|
3601
|
+
parentId: n,
|
|
3602
|
+
position: {
|
|
3603
|
+
x: 175,
|
|
3604
|
+
y: 30
|
|
3605
|
+
}
|
|
3606
|
+
} : e)]), t(""), i(!1), V.success("Group created", { description: `The group "${e.trim()}" has been created successfully.` });
|
|
3607
|
+
};
|
|
3608
|
+
return /* @__PURE__ */ F("div", {
|
|
3609
|
+
className: "space-y-2",
|
|
3610
|
+
children: [/* @__PURE__ */ P(d, {
|
|
3611
|
+
htmlFor: f,
|
|
3612
|
+
children: u("editor.selectNodeGroup.group")
|
|
3613
|
+
}), /* @__PURE__ */ F("div", {
|
|
3614
|
+
className: "flex gap-2",
|
|
3615
|
+
children: [/* @__PURE__ */ F(g, {
|
|
3616
|
+
value: c,
|
|
3617
|
+
onValueChange: m,
|
|
3618
|
+
children: [/* @__PURE__ */ P(v, {
|
|
3619
|
+
id: f,
|
|
3620
|
+
className: "flex-1",
|
|
3621
|
+
children: /* @__PURE__ */ P(T, { placeholder: u("editor.selectNodeGroup.noGroup") })
|
|
3622
|
+
}), /* @__PURE__ */ P(C, { children: /* @__PURE__ */ F(w, { children: [/* @__PURE__ */ P(h, {
|
|
3623
|
+
value: "none",
|
|
3624
|
+
children: u("editor.selectNodeGroup.noGroup")
|
|
3625
|
+
}), o.map((e) => /* @__PURE__ */ P(h, {
|
|
3626
|
+
value: e.id,
|
|
3627
|
+
children: e.data.label?.en ? String(e.data.label?.en) : e.id
|
|
3628
|
+
}, e.id))] }) })]
|
|
3629
|
+
}), /* @__PURE__ */ F(ie, {
|
|
3630
|
+
open: r,
|
|
3631
|
+
onOpenChange: i,
|
|
3632
|
+
children: [/* @__PURE__ */ P(ne, {
|
|
3633
|
+
asChild: !0,
|
|
3634
|
+
children: /* @__PURE__ */ P(k, {
|
|
3635
|
+
variant: "outline",
|
|
3636
|
+
size: "icon",
|
|
3637
|
+
title: "Create a new group",
|
|
3638
|
+
children: /* @__PURE__ */ P(dt, { className: "h-4 w-4" })
|
|
3639
|
+
})
|
|
3640
|
+
}), /* @__PURE__ */ P(ae, {
|
|
3641
|
+
className: "w-80",
|
|
3642
|
+
align: "end",
|
|
3643
|
+
disablePortal: !0,
|
|
3644
|
+
children: /* @__PURE__ */ F("div", {
|
|
3645
|
+
className: "space-y-4",
|
|
3646
|
+
children: [
|
|
3647
|
+
/* @__PURE__ */ F("div", {
|
|
3648
|
+
className: "space-y-2",
|
|
3649
|
+
children: [/* @__PURE__ */ P("h4", {
|
|
3650
|
+
className: "font-medium leading-none",
|
|
3651
|
+
children: u("editor.selectNodeGroup.newGroup")
|
|
3652
|
+
}), /* @__PURE__ */ P("p", {
|
|
3653
|
+
className: "text-muted-foreground text-sm",
|
|
3654
|
+
children: u("editor.selectNodeGroup.newGroupDescription")
|
|
3655
|
+
})]
|
|
3656
|
+
}),
|
|
3657
|
+
/* @__PURE__ */ F("div", {
|
|
3658
|
+
className: "space-y-2",
|
|
3659
|
+
children: [/* @__PURE__ */ P(d, {
|
|
3660
|
+
htmlFor: p,
|
|
3661
|
+
children: u("editor.selectNodeGroup.groupName")
|
|
3662
|
+
}), /* @__PURE__ */ P(O, {
|
|
3663
|
+
autoFocus: !0,
|
|
3664
|
+
id: p,
|
|
3665
|
+
value: e,
|
|
3666
|
+
onChange: (e) => t(e.target.value),
|
|
3667
|
+
placeholder: "Ex: Step 1 - Personal info",
|
|
3668
|
+
onKeyDown: (e) => {
|
|
3669
|
+
e.key === "Enter" && (e.preventDefault(), _());
|
|
3670
|
+
}
|
|
3671
|
+
})]
|
|
3672
|
+
}),
|
|
3673
|
+
/* @__PURE__ */ F("div", {
|
|
3674
|
+
className: "flex justify-end gap-2",
|
|
3675
|
+
children: [/* @__PURE__ */ P(k, {
|
|
3676
|
+
variant: "outline",
|
|
3677
|
+
size: "sm",
|
|
3678
|
+
onClick: () => i(!1),
|
|
3679
|
+
children: "Cancel"
|
|
3680
|
+
}), /* @__PURE__ */ P(k, {
|
|
3681
|
+
size: "sm",
|
|
3682
|
+
onClick: _,
|
|
3683
|
+
disabled: !e.trim(),
|
|
3684
|
+
children: "Create"
|
|
3685
|
+
})]
|
|
3686
|
+
})
|
|
3687
|
+
]
|
|
3688
|
+
})
|
|
3689
|
+
})]
|
|
3690
|
+
})]
|
|
3691
|
+
})]
|
|
3692
|
+
});
|
|
3693
|
+
}, lr = Object.values(X), ur = Object.values(ln), dr = () => {
|
|
3694
|
+
let { selectedNode: e } = $(), { updateSelectedNodeType: t } = W(), { getEdges: a } = M(), { openNodeTypeChangeConfirmation: o } = H(), s = n(e), c = U(), u = Ot(), d = Z(l.flow), f = () => e ? r(e) || i(e) ? e.data?.type || "" : e.type || "" : "", p = (n, r) => {
|
|
3695
|
+
if (!e) return;
|
|
3696
|
+
let i = a().filter((t) => t.source === e.id).length;
|
|
3697
|
+
if ((n === l.ui || n === l.flow) && i > 1) {
|
|
3698
|
+
o({
|
|
3699
|
+
nodeId: e.id,
|
|
3700
|
+
subType: r,
|
|
3701
|
+
type: n
|
|
3702
|
+
});
|
|
3703
|
+
return;
|
|
3704
|
+
}
|
|
3705
|
+
t(n, r);
|
|
3706
|
+
};
|
|
3707
|
+
return /* @__PURE__ */ F(w, { children: [/* @__PURE__ */ P(y, {
|
|
3708
|
+
htmlFor: u,
|
|
3709
|
+
children: c("editor.selectNodeType.nodeType")
|
|
3710
|
+
}), /* @__PURE__ */ F(g, {
|
|
3711
|
+
value: f(),
|
|
3712
|
+
onValueChange: (e) => {
|
|
3713
|
+
if (lr.includes(e)) {
|
|
3714
|
+
p(l.input, e);
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
3717
|
+
if (ur.includes(e)) {
|
|
3718
|
+
p(l.ui, e);
|
|
3719
|
+
return;
|
|
3720
|
+
}
|
|
3721
|
+
p(e);
|
|
3722
|
+
},
|
|
3723
|
+
disabled: s,
|
|
3724
|
+
children: [/* @__PURE__ */ P(v, {
|
|
3725
|
+
className: "w-full capitalize",
|
|
3726
|
+
id: u,
|
|
3727
|
+
children: /* @__PURE__ */ P(T, { placeholder: c("editor.selectNodeType.nodeType") })
|
|
3728
|
+
}), /* @__PURE__ */ P(C, {
|
|
3729
|
+
className: "treege-scrollbar max-h-80",
|
|
3730
|
+
children: s ? /* @__PURE__ */ P(w, { children: /* @__PURE__ */ P(h, {
|
|
3731
|
+
value: l.group,
|
|
3732
|
+
children: c("editor.selectNodeType.options.group")
|
|
3733
|
+
}) }) : /* @__PURE__ */ F(N, { children: [
|
|
3734
|
+
/* @__PURE__ */ F(w, { children: [/* @__PURE__ */ P(y, { children: c("editor.selectNodeType.options.input") }), lr.map((e) => /* @__PURE__ */ F(h, {
|
|
3735
|
+
value: e,
|
|
3736
|
+
className: "capitalize",
|
|
3737
|
+
children: [/* @__PURE__ */ P(Z(e), {}), e]
|
|
3738
|
+
}, e))] }),
|
|
3739
|
+
/* @__PURE__ */ P(de, {}),
|
|
3740
|
+
/* @__PURE__ */ F(w, { children: [/* @__PURE__ */ P(y, { children: c("editor.selectNodeType.options.ui") }), ur.map((e) => /* @__PURE__ */ F(h, {
|
|
3741
|
+
value: e,
|
|
3742
|
+
className: "capitalize",
|
|
3743
|
+
children: [/* @__PURE__ */ P(Z(e), {}), e]
|
|
3744
|
+
}, e))] }),
|
|
3745
|
+
/* @__PURE__ */ P(de, {}),
|
|
3746
|
+
/* @__PURE__ */ F(w, { children: [/* @__PURE__ */ P(y, { children: c("common.other") }), /* @__PURE__ */ F(h, {
|
|
3747
|
+
value: l.flow,
|
|
3748
|
+
children: [/* @__PURE__ */ P(d, {}), c("editor.selectNodeType.options.flow")]
|
|
3749
|
+
})] })
|
|
3750
|
+
] })
|
|
3751
|
+
})]
|
|
3752
|
+
})] });
|
|
3753
|
+
};
|
|
3754
|
+
//#endregion
|
|
3755
|
+
//#region src/shared/components/ui/sheet.tsx
|
|
3756
|
+
function fr({ ...e }) {
|
|
3757
|
+
return /* @__PURE__ */ P(Pt.Root, {
|
|
3758
|
+
"data-slot": "sheet",
|
|
3759
|
+
...e
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3762
|
+
function pr({ ...e }) {
|
|
3763
|
+
return /* @__PURE__ */ P(Pt.Portal, {
|
|
3764
|
+
"data-slot": "sheet-portal",
|
|
3765
|
+
...e
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
function mr({ className: e, ...t }) {
|
|
3769
|
+
return /* @__PURE__ */ P(Pt.Overlay, {
|
|
3770
|
+
"data-slot": "sheet-overlay",
|
|
3771
|
+
className: E("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
3772
|
+
...t
|
|
3773
|
+
});
|
|
3774
|
+
}
|
|
3775
|
+
function hr({ className: e, children: t, side: n = "right", ...r }) {
|
|
3776
|
+
return /* @__PURE__ */ F(pr, { children: [/* @__PURE__ */ P(mr, {}), /* @__PURE__ */ F(Pt.Content, {
|
|
3777
|
+
"data-slot": "sheet-content",
|
|
3778
|
+
className: E("fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:duration-300 data-[state=open]:duration-500", n === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm", n === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm", n === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b", n === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t", e),
|
|
3779
|
+
...r,
|
|
3780
|
+
children: [t, /* @__PURE__ */ F(Pt.Close, {
|
|
3781
|
+
className: "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",
|
|
3782
|
+
children: [/* @__PURE__ */ P(Ct, { className: "size-4" }), /* @__PURE__ */ P("span", {
|
|
3783
|
+
className: "sr-only",
|
|
3784
|
+
children: "Close"
|
|
3785
|
+
})]
|
|
3786
|
+
})]
|
|
3787
|
+
})] });
|
|
3788
|
+
}
|
|
3789
|
+
function gr({ className: e, ...t }) {
|
|
3790
|
+
return /* @__PURE__ */ P("div", {
|
|
3791
|
+
"data-slot": "sheet-header",
|
|
3792
|
+
className: E("flex flex-col gap-1.5 p-4", e),
|
|
3793
|
+
...t
|
|
3794
|
+
});
|
|
3795
|
+
}
|
|
3796
|
+
function _r({ className: e, ...t }) {
|
|
3797
|
+
return /* @__PURE__ */ P("div", {
|
|
3798
|
+
"data-slot": "sheet-footer",
|
|
3799
|
+
className: E("mt-auto flex flex-col gap-2 p-4", e),
|
|
3800
|
+
...t
|
|
3801
|
+
});
|
|
3802
|
+
}
|
|
3803
|
+
function vr({ className: e, ...t }) {
|
|
3804
|
+
return /* @__PURE__ */ P(Pt.Title, {
|
|
3805
|
+
"data-slot": "sheet-title",
|
|
3806
|
+
className: E("font-semibold text-foreground", e),
|
|
3807
|
+
...t
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3810
|
+
function yr({ className: e, ...t }) {
|
|
3811
|
+
return /* @__PURE__ */ P(Pt.Description, {
|
|
3812
|
+
"data-slot": "sheet-description",
|
|
3813
|
+
className: E("text-muted-foreground text-sm", e),
|
|
3814
|
+
...t
|
|
3815
|
+
});
|
|
3816
|
+
}
|
|
3817
|
+
//#endregion
|
|
3818
|
+
//#region src/editor/features/TreegeEditor/sheets/NodeActionsSheet.tsx
|
|
3819
|
+
var br = () => {
|
|
3820
|
+
let { selectedNode: e } = $(), { clearSelection: t } = W(), { isNodeSheetOpen: a, setIsNodeSheetOpen: s, openDeleteNodeConfirmation: c } = H(), l = U(), u = l(e?.data?.label), d = () => {
|
|
3821
|
+
s(!1), t();
|
|
3822
|
+
};
|
|
3823
|
+
return /* @__PURE__ */ P(fr, {
|
|
3824
|
+
open: a && !!e,
|
|
3825
|
+
onOpenChange: (e) => {
|
|
3826
|
+
e || d();
|
|
3827
|
+
},
|
|
3828
|
+
children: /* @__PURE__ */ F(hr, {
|
|
3829
|
+
className: "flex flex-col gap-0",
|
|
3830
|
+
children: [
|
|
3831
|
+
/* @__PURE__ */ F(gr, { children: [/* @__PURE__ */ F(vr, { children: [
|
|
3832
|
+
l("editor.nodeActionsSheet.editNode"),
|
|
3833
|
+
" ",
|
|
3834
|
+
/* @__PURE__ */ P("span", {
|
|
3835
|
+
className: "font-light text-muted-foreground text-xs",
|
|
3836
|
+
children: e?.id
|
|
3837
|
+
})
|
|
3838
|
+
] }), /* @__PURE__ */ P(yr, { children: u || "\xA0" })] }),
|
|
3839
|
+
/* @__PURE__ */ P(Gt, {
|
|
3840
|
+
className: "flex min-h-0 flex-1 flex-col px-4",
|
|
3841
|
+
children: /* @__PURE__ */ F("div", {
|
|
3842
|
+
className: "space-y-6 py-4",
|
|
3843
|
+
children: [
|
|
3844
|
+
/* @__PURE__ */ P(dr, {}),
|
|
3845
|
+
/* @__PURE__ */ P(cr, {}),
|
|
3846
|
+
/* @__PURE__ */ P(ue, {}),
|
|
3847
|
+
r(e) && /* @__PURE__ */ P(or, {}),
|
|
3848
|
+
i(e) && /* @__PURE__ */ P(sr, {}),
|
|
3849
|
+
o(e) && /* @__PURE__ */ P(Vn, {}),
|
|
3850
|
+
n(e) && /* @__PURE__ */ P(Hn, {})
|
|
3851
|
+
]
|
|
3852
|
+
})
|
|
3853
|
+
}),
|
|
3854
|
+
/* @__PURE__ */ P(_r, {
|
|
3855
|
+
className: "flex items-end border-t",
|
|
3856
|
+
children: /* @__PURE__ */ P(k, {
|
|
3857
|
+
variant: "ghost",
|
|
3858
|
+
size: "icon",
|
|
3859
|
+
onClick: () => {
|
|
3860
|
+
e && c(e.id);
|
|
3861
|
+
},
|
|
3862
|
+
"aria-label": l("editor.nodeActionsSheet.deleteNode"),
|
|
3863
|
+
children: /* @__PURE__ */ P(vt, {})
|
|
3864
|
+
})
|
|
3865
|
+
})
|
|
3866
|
+
]
|
|
3867
|
+
})
|
|
3868
|
+
});
|
|
3869
|
+
}, xr = 200, Sr = 100, Cr = (e) => !!(e.measured?.width && e.measured?.height), wr = (e, t, n) => {
|
|
3870
|
+
let r = n === "TB" ? "y" : "x";
|
|
3871
|
+
return e.reduce((e, n) => t.node(n.id)[r] < t.node(e.id)[r] ? n : e, e[0]);
|
|
3872
|
+
}, Tr = (e, t, n) => {
|
|
3873
|
+
let r = new Lt.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
3874
|
+
r.setGraph({
|
|
3875
|
+
nodesep: n.horizontalSpacing,
|
|
3876
|
+
rankdir: n.direction,
|
|
3877
|
+
ranksep: n.verticalSpacing
|
|
3878
|
+
});
|
|
3879
|
+
let i = /* @__PURE__ */ new Set();
|
|
3880
|
+
e.forEach((e) => {
|
|
3881
|
+
i.add(e.id), r.setNode(e.id, {
|
|
3882
|
+
height: e.measured?.height ?? Sr,
|
|
3883
|
+
width: e.measured?.width ?? xr
|
|
3884
|
+
});
|
|
3885
|
+
}), t.forEach((e) => {
|
|
3886
|
+
i.has(e.source) && i.has(e.target) && r.setEdge(e.source, e.target);
|
|
3887
|
+
}), Lt.layout(r);
|
|
3888
|
+
let a = wr(e, r, n.direction), o = a.measured?.width ?? xr, s = a.measured?.height ?? Sr, c = r.node(a.id), l = a.position.x - (c.x - o / 2), u = a.position.y - (c.y - s / 2), d = /* @__PURE__ */ new Map();
|
|
3889
|
+
return e.forEach((e) => {
|
|
3890
|
+
let { x: t, y: n } = r.node(e.id), i = e.measured?.width ?? xr, a = e.measured?.height ?? Sr;
|
|
3891
|
+
d.set(e.id, {
|
|
3892
|
+
x: t - i / 2 + l,
|
|
3893
|
+
y: n - a / 2 + u
|
|
3894
|
+
});
|
|
3895
|
+
}), d;
|
|
3896
|
+
}, Er = (e) => {
|
|
3897
|
+
let t = /* @__PURE__ */ new Map();
|
|
3898
|
+
return e.forEach((e) => {
|
|
3899
|
+
let n = t.get(e.parentId) ?? [];
|
|
3900
|
+
n.push(e), t.set(e.parentId, n);
|
|
3901
|
+
}), t;
|
|
3902
|
+
}, Dr = (e, t, n = {}) => {
|
|
3903
|
+
let r = {
|
|
3904
|
+
direction: n.direction ?? "TB",
|
|
3905
|
+
horizontalSpacing: n.horizontalSpacing ?? 60,
|
|
3906
|
+
verticalSpacing: n.verticalSpacing ?? 80
|
|
3907
|
+
}, i = /* @__PURE__ */ new Map();
|
|
3908
|
+
return Er(e).forEach((e) => {
|
|
3909
|
+
let n = e.filter(Cr);
|
|
3910
|
+
n.length !== 0 && Tr(n, t, r).forEach((e, t) => {
|
|
3911
|
+
i.set(t, e);
|
|
3912
|
+
});
|
|
3913
|
+
}), e.map((e) => {
|
|
3914
|
+
let t = i.get(e.id);
|
|
3915
|
+
return t ? {
|
|
3916
|
+
...e,
|
|
3917
|
+
position: t
|
|
3918
|
+
} : e;
|
|
3919
|
+
});
|
|
3920
|
+
}, Or = (e) => Array.from(e.nodeLookup.values()).map((e) => `${e.id}:${e.measured?.width ?? 0}x${e.measured?.height ?? 0}`).join("|"), kr = ({ direction: e, horizontalSpacing: t, verticalSpacing: n } = {}) => {
|
|
3921
|
+
let { getNodes: r, getEdges: i, setNodes: a } = M(), o = Me(), s = Ne(Or);
|
|
3922
|
+
Dt(() => {
|
|
3923
|
+
o && s && a(Dr(r(), i(), {
|
|
3924
|
+
direction: e,
|
|
3925
|
+
horizontalSpacing: t,
|
|
3926
|
+
verticalSpacing: n
|
|
3927
|
+
}));
|
|
3928
|
+
}, [
|
|
3929
|
+
o,
|
|
3930
|
+
s,
|
|
3931
|
+
e,
|
|
3932
|
+
t,
|
|
3933
|
+
n,
|
|
3934
|
+
r,
|
|
3935
|
+
i,
|
|
3936
|
+
a
|
|
3937
|
+
]);
|
|
3938
|
+
}, Ar = ({ ...e }) => {
|
|
3939
|
+
let { theme: t = "system" } = Rt();
|
|
3940
|
+
return /* @__PURE__ */ P(Ft, {
|
|
3941
|
+
theme: t,
|
|
3942
|
+
className: "toaster group",
|
|
3943
|
+
style: {
|
|
3944
|
+
"--normal-bg": "var(--treege-popover)",
|
|
3945
|
+
"--normal-border": "var(--treege-border)",
|
|
3946
|
+
"--normal-text": "var(--treege-popover-foreground)"
|
|
3947
|
+
},
|
|
3948
|
+
...e
|
|
3949
|
+
});
|
|
3950
|
+
}, jr = ({ flow: e, onExportJson: t, onSave: n, theme: r, className: i }) => {
|
|
3951
|
+
let { onConnect: a, onConnectEnd: o, onEdgesDelete: s, isValidConnection: c } = cn();
|
|
3952
|
+
return kr(), /* @__PURE__ */ F(Ee, {
|
|
3953
|
+
fitView: !0,
|
|
3954
|
+
colorMode: r,
|
|
3955
|
+
selectNodesOnDrag: !1,
|
|
3956
|
+
nodeTypes: Cn,
|
|
3957
|
+
edgeTypes: Yt,
|
|
3958
|
+
defaultEdges: e?.edges || [],
|
|
3959
|
+
defaultNodes: e?.nodes || [],
|
|
3960
|
+
onConnect: a,
|
|
3961
|
+
onConnectEnd: o,
|
|
3962
|
+
onEdgesDelete: s,
|
|
3963
|
+
isValidConnection: c,
|
|
3964
|
+
className: E(i, "treege"),
|
|
3965
|
+
children: [
|
|
3966
|
+
/* @__PURE__ */ P(ge, {
|
|
3967
|
+
gap: 10,
|
|
3968
|
+
variant: _e.Dots
|
|
3969
|
+
}),
|
|
3970
|
+
/* @__PURE__ */ P(zn, {
|
|
3971
|
+
onExportJson: t,
|
|
3972
|
+
onSave: n
|
|
3973
|
+
}),
|
|
3974
|
+
/* @__PURE__ */ P(Vt, { theme: r }),
|
|
3975
|
+
/* @__PURE__ */ P(Se, {}),
|
|
3976
|
+
/* @__PURE__ */ P(ye, {}),
|
|
3977
|
+
/* @__PURE__ */ P(br, {}),
|
|
3978
|
+
/* @__PURE__ */ P(Dn, {}),
|
|
3979
|
+
/* @__PURE__ */ P(En, {})
|
|
3980
|
+
]
|
|
3981
|
+
});
|
|
3982
|
+
}, Mr = ({ flow: e, onExportJson: t, onSave: n, theme: r = "dark", language: i = "en", aiConfig: a }) => /* @__PURE__ */ P(u, {
|
|
3983
|
+
defaultTheme: r,
|
|
3984
|
+
storageKey: "treege-editor-theme",
|
|
3985
|
+
theme: r,
|
|
3986
|
+
children: /* @__PURE__ */ F(Wt, {
|
|
3987
|
+
value: {
|
|
3988
|
+
aiConfig: a,
|
|
3989
|
+
flowId: e?.id,
|
|
3990
|
+
language: i
|
|
3991
|
+
},
|
|
3992
|
+
children: [/* @__PURE__ */ P(Ar, { position: "bottom-center" }), /* @__PURE__ */ P(De, { children: /* @__PURE__ */ P(jr, {
|
|
3993
|
+
onExportJson: t,
|
|
3994
|
+
onSave: n,
|
|
3995
|
+
flow: e,
|
|
3996
|
+
theme: r
|
|
3997
|
+
}) })]
|
|
3998
|
+
})
|
|
3999
|
+
});
|
|
4000
|
+
//#endregion
|
|
4001
|
+
export { Mr as t };
|