treege 3.0.0-beta.3 → 3.0.0-beta.30
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 +305 -49
- package/dist/ThemeContext-D49eu_oE.js +1472 -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/nodeSpacing.d.ts +20 -0
- package/dist/editor/constants/nodeTypes.d.ts +5 -5
- package/dist/editor/context/TreegeEditorContext.d.ts +24 -1
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- 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/NodeLabelInput.d.ts +9 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +8 -0
- package/dist/editor/features/TreegeEditor/nodes/components/OpenSheetButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/SubTypeBadge.d.ts +8 -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/useFlowActions.d.ts +2 -0
- 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/image.d.ts +7 -0
- package/dist/editor-DnrJgSrC.js +3567 -0
- package/dist/editor.js +3 -7
- package/dist/main.js +5 -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 +26 -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 +9 -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-MCPhNlp1.js +1157 -0
- package/dist/renderer-native.d.ts +2 -0
- package/dist/renderer-native.js +3408 -0
- package/dist/renderer.js +4 -45
- package/dist/separator-gO82kpxa.js +350 -0
- package/dist/shared/components/ui/alert-dialog.d.ts +14 -0
- package/dist/shared/components/ui/badge.d.ts +2 -2
- package/dist/shared/components/ui/button.d.ts +1 -1
- package/dist/shared/components/ui/popover.d.ts +3 -1
- package/dist/shared/components/ui/select.d.ts +3 -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 +102 -9
- package/dist/shared/locales/de.json.d.ts +102 -9
- package/dist/shared/locales/en.json.d.ts +103 -10
- package/dist/shared/locales/es.json.d.ts +102 -9
- package/dist/shared/locales/fr.json.d.ts +102 -9
- package/dist/shared/locales/it.json.d.ts +102 -9
- package/dist/shared/locales/pt.json.d.ts +102 -9
- package/dist/shared/types/node.d.ts +56 -0
- package/dist/useRenderNode-B_GPMTPf.js +774 -0
- package/package.json +36 -9
- package/dist/ThemeContext-BIvs8Kw-.js +0 -758
- package/dist/TreegeEditor-BSPfQQk3.js +0 -2151
- package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
- package/dist/_name_.css +0 -1
- 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,3567 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, r as o, t as s, u as c } from "./ThemeContext-D49eu_oE.js";
|
|
2
|
+
import { C as l, D as u, E as d, F as f, M as p, N as m, O as h, P as g, S as _, T as v, _ as y, a as b, b as x, c as S, d as C, f as ee, g as te, h as w, i as ne, j as T, k as E, l as D, m as O, n as k, o as re, p as ie, r as A, s as ae, t as oe, u as se, v as j, w as ce, x as le, y as M } from "./separator-gO82kpxa.js";
|
|
3
|
+
import { Background as ue, BackgroundVariant as de, BaseEdge as fe, Controls as pe, EdgeLabelRenderer as me, Handle as he, MiniMap as ge, NodeResizer as _e, Panel as ve, Position as ye, ReactFlow as be, ReactFlowProvider as xe, addEdge as Se, getBezierPath as Ce, useEdges as we, useNodes as Te, useReactFlow as Ee } from "@xyflow/react";
|
|
4
|
+
import { createContext as De, memo as Oe, useCallback as N, useContext as ke, useEffect as Ae, useId as je, useMemo as P, useRef as Me, useState as F } from "react";
|
|
5
|
+
import { useForm as I } from "@tanstack/react-form";
|
|
6
|
+
import { ArrowRightFromLine as Ne, Boxes as Pe, Check as Fe, ChevronsUpDown as L, Cog as Ie, Copy as Le, Download as Re, EllipsisVertical as ze, ImagePlus as Be, Link2 as Ve, Loader2 as He, LucidePencilRuler as Ue, MessageCircleQuestion as We, Network as Ge, Plus as R, PlusCircle as Ke, RectangleEllipsis as qe, Save as Je, Trash2 as Ye, Upload as Xe, Variable as Ze, WandSparkles as Qe, Waypoints as $e, X as z, XIcon as et } from "lucide-react";
|
|
7
|
+
import { Slot as tt } from "@radix-ui/react-slot";
|
|
8
|
+
import { cva as nt } from "class-variance-authority";
|
|
9
|
+
import * as rt from "@radix-ui/react-scroll-area";
|
|
10
|
+
import * as B from "@radix-ui/react-dropdown-menu";
|
|
11
|
+
import { Toaster as it, toast as V } from "sonner";
|
|
12
|
+
import * as H from "@radix-ui/react-dialog";
|
|
13
|
+
import * as at from "@radix-ui/react-collapsible";
|
|
14
|
+
import * as U from "@radix-ui/react-alert-dialog";
|
|
15
|
+
import { useTheme as ot } from "next-themes";
|
|
16
|
+
//#region src/editor/assets/img/treege-black.svg
|
|
17
|
+
var st = "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", ct = "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", W = r(), lt = ({ theme: e = "dark" }) => /* @__PURE__ */ (0, W.jsx)("div", {
|
|
18
|
+
className: "absolute top-5 left-5 z-50 select-none",
|
|
19
|
+
children: /* @__PURE__ */ (0, W.jsx)("img", {
|
|
20
|
+
src: e === "dark" ? ct : st,
|
|
21
|
+
alt: "Treege",
|
|
22
|
+
className: "relative h-14 w-auto drop-shadow-[0_0px_35px] drop-shadow-blue-600"
|
|
23
|
+
})
|
|
24
|
+
}), ut = (e) => {
|
|
25
|
+
let t = Te(), n = we();
|
|
26
|
+
return P(() => {
|
|
27
|
+
if (!e) return [];
|
|
28
|
+
let r = (e, t = /* @__PURE__ */ new Set()) => {
|
|
29
|
+
if (t.has(e)) return [];
|
|
30
|
+
let i = new Set(t).add(e);
|
|
31
|
+
return n.filter((t) => t.target === e).flatMap((e) => [e.source, ...r(e.source, i)]);
|
|
32
|
+
}, i = r(e);
|
|
33
|
+
return t.filter((e) => i.includes(e.id) && c(e)).map((e) => {
|
|
34
|
+
let t = e.data;
|
|
35
|
+
return {
|
|
36
|
+
label: (typeof t.label == "object" ? t.label.en : t.label) || t.name || e.id,
|
|
37
|
+
name: t.name,
|
|
38
|
+
nodeId: e.id,
|
|
39
|
+
type: t.type || "text"
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}, [
|
|
43
|
+
e,
|
|
44
|
+
t,
|
|
45
|
+
n
|
|
46
|
+
]);
|
|
47
|
+
}, dt = De(null), ft = ({ children: e, value: t }) => {
|
|
48
|
+
let [n, r] = F(t?.flowId), [i, a] = F(!1), o = P(() => ({
|
|
49
|
+
...t,
|
|
50
|
+
...t?.aiConfig && { aiConfig: {
|
|
51
|
+
...t.aiConfig,
|
|
52
|
+
provider: t?.aiConfig.provider ?? "gemini"
|
|
53
|
+
} },
|
|
54
|
+
flowId: n,
|
|
55
|
+
isNodeSheetOpen: i,
|
|
56
|
+
setFlowId: r,
|
|
57
|
+
setIsNodeSheetOpen: a
|
|
58
|
+
}), [
|
|
59
|
+
n,
|
|
60
|
+
t,
|
|
61
|
+
i
|
|
62
|
+
]);
|
|
63
|
+
return /* @__PURE__ */ (0, W.jsx)(dt.Provider, {
|
|
64
|
+
value: o,
|
|
65
|
+
children: e
|
|
66
|
+
});
|
|
67
|
+
}, pt = () => ke(dt) ?? {
|
|
68
|
+
flowId: void 0,
|
|
69
|
+
isNodeSheetOpen: !1,
|
|
70
|
+
language: "en",
|
|
71
|
+
setFlowId: () => {},
|
|
72
|
+
setIsNodeSheetOpen: () => {}
|
|
73
|
+
}, G = (t) => {
|
|
74
|
+
let n = pt();
|
|
75
|
+
return e(t ?? n.language);
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/shared/components/ui/scroll-area.tsx
|
|
79
|
+
function mt({ className: e, children: t, ...n }) {
|
|
80
|
+
return /* @__PURE__ */ (0, W.jsxs)(rt.Root, {
|
|
81
|
+
"data-slot": "scroll-area",
|
|
82
|
+
className: f("relative", e),
|
|
83
|
+
...n,
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ (0, W.jsx)(rt.Viewport, {
|
|
86
|
+
"data-slot": "scroll-area-viewport",
|
|
87
|
+
className: "size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
88
|
+
children: t
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ (0, W.jsx)(ht, {}),
|
|
91
|
+
/* @__PURE__ */ (0, W.jsx)(rt.Corner, {})
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function ht({ className: e, orientation: t = "vertical", ...n }) {
|
|
96
|
+
return /* @__PURE__ */ (0, W.jsx)(rt.ScrollAreaScrollbar, {
|
|
97
|
+
"data-slot": "scroll-area-scrollbar",
|
|
98
|
+
orientation: t,
|
|
99
|
+
className: f("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),
|
|
100
|
+
...n,
|
|
101
|
+
children: /* @__PURE__ */ (0, W.jsx)(rt.ScrollAreaThumb, {
|
|
102
|
+
"data-slot": "scroll-area-thumb",
|
|
103
|
+
className: "relative flex-1 rounded-full bg-border"
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/editor/constants/edgeTypes.ts
|
|
109
|
+
var gt = {
|
|
110
|
+
conditional: Oe(({ id: e, target: t, sourceX: n, sourceY: r, targetX: a, targetY: o, sourcePosition: s, targetPosition: c, markerEnd: f, style: g, data: b }) => {
|
|
111
|
+
let [S, C, ee] = Ce({
|
|
112
|
+
sourcePosition: s,
|
|
113
|
+
sourceX: n,
|
|
114
|
+
sourceY: r,
|
|
115
|
+
targetPosition: c,
|
|
116
|
+
targetX: a,
|
|
117
|
+
targetY: o
|
|
118
|
+
}), [te, w] = F(!1), { updateEdgeData: ne } = Ee(), D = ut(t), O = b?.conditions && b.conditions.length > 0, k = G(), { handleSubmit: re, reset: ie, Field: A } = I({
|
|
119
|
+
defaultValues: {
|
|
120
|
+
conditions: b?.conditions || [{
|
|
121
|
+
field: D[0]?.nodeId ?? "",
|
|
122
|
+
operator: "===",
|
|
123
|
+
value: ""
|
|
124
|
+
}],
|
|
125
|
+
isFallback: !!b?.isFallback,
|
|
126
|
+
label: b?.label || ""
|
|
127
|
+
},
|
|
128
|
+
listeners: {
|
|
129
|
+
onChange: ({ formApi: e }) => {
|
|
130
|
+
e.handleSubmit().then();
|
|
131
|
+
},
|
|
132
|
+
onChangeDebounceMs: 150
|
|
133
|
+
},
|
|
134
|
+
onSubmit: ({ value: t }) => {
|
|
135
|
+
ne(e, t);
|
|
136
|
+
}
|
|
137
|
+
}), ae = (e) => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
}, oe = () => {
|
|
140
|
+
ie({
|
|
141
|
+
conditions: [],
|
|
142
|
+
isFallback: !1,
|
|
143
|
+
label: ""
|
|
144
|
+
}), ne(e, {
|
|
145
|
+
conditions: void 0,
|
|
146
|
+
isFallback: void 0,
|
|
147
|
+
label: void 0
|
|
148
|
+
});
|
|
149
|
+
}, se = () => {
|
|
150
|
+
if (b?.isFallback) return b.label || k("editor.conditionalEdge.fallback");
|
|
151
|
+
if (!O) return null;
|
|
152
|
+
if (b.label) return b.label;
|
|
153
|
+
let e = b.conditions;
|
|
154
|
+
if (e.length === 1) return `${D.find((t) => t.nodeId === e[0].field)?.label || e[0].field} ${e[0].operator} ${e[0].value}`;
|
|
155
|
+
let t = e.filter((e) => e.logicalOperator === i.AND).length, n = e.filter((e) => e.logicalOperator === i.OR).length;
|
|
156
|
+
return t > 0 && n === 0 ? `${e.length} ${k("editor.conditionalEdge.conditionsAnd")}` : n > 0 && t === 0 ? `${e.length} ${k("editor.conditionalEdge.conditionsOr")}` : `${e.length} ${k("editor.conditionalEdge.conditionsMixed")}`;
|
|
157
|
+
}, le = () => b?.isFallback ? "var(--color-chart-4)" : O ? "var(--color-chart-2)" : "var(--color-chart-3)";
|
|
158
|
+
return /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(fe, {
|
|
159
|
+
path: S,
|
|
160
|
+
markerEnd: f,
|
|
161
|
+
style: {
|
|
162
|
+
...g,
|
|
163
|
+
stroke: le(),
|
|
164
|
+
strokeDasharray: b?.isFallback ? "5,5" : void 0,
|
|
165
|
+
strokeWidth: O || b?.isFallback ? 2 : g?.strokeWidth
|
|
166
|
+
}
|
|
167
|
+
}), /* @__PURE__ */ (0, W.jsx)(me, { children: /* @__PURE__ */ (0, W.jsx)("div", {
|
|
168
|
+
className: "nodrag nopan absolute",
|
|
169
|
+
style: {
|
|
170
|
+
pointerEvents: "all",
|
|
171
|
+
transform: `translate(-50%, -50%) translate(${C}px,${ee}px)`
|
|
172
|
+
},
|
|
173
|
+
children: /* @__PURE__ */ (0, W.jsxs)(ce, {
|
|
174
|
+
open: te,
|
|
175
|
+
onOpenChange: w,
|
|
176
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
177
|
+
asChild: !0,
|
|
178
|
+
children: /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
179
|
+
variant: O || b?.isFallback ? "default" : "secondary",
|
|
180
|
+
className: "h-8 px-2 text-xs",
|
|
181
|
+
onClick: ae,
|
|
182
|
+
children: [/* @__PURE__ */ (0, W.jsx)($e, { className: "mr-1 h-3 w-3" }), O || b?.isFallback ? se() : k("editor.conditionalEdge.condition")]
|
|
183
|
+
})
|
|
184
|
+
}), /* @__PURE__ */ (0, W.jsx)(v, {
|
|
185
|
+
className: "w-96 p-1",
|
|
186
|
+
align: "center",
|
|
187
|
+
onClick: (e) => e.stopPropagation(),
|
|
188
|
+
children: /* @__PURE__ */ (0, W.jsx)(mt, {
|
|
189
|
+
className: "flex max-h-150 flex-col p-3",
|
|
190
|
+
children: /* @__PURE__ */ (0, W.jsx)("form", {
|
|
191
|
+
onSubmit: (e) => {
|
|
192
|
+
e.preventDefault(), e.stopPropagation();
|
|
193
|
+
},
|
|
194
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
195
|
+
className: "grid gap-5",
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
198
|
+
className: "space-y-2",
|
|
199
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
200
|
+
className: "font-medium leading-none",
|
|
201
|
+
children: k("editor.conditionalEdge.displayConditions")
|
|
202
|
+
}), /* @__PURE__ */ (0, W.jsx)("p", {
|
|
203
|
+
className: "text-muted-foreground text-sm",
|
|
204
|
+
children: k("editor.conditionalEdge.displayConditionsDesc")
|
|
205
|
+
})]
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
208
|
+
className: "grid gap-4",
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ (0, W.jsx)(A, {
|
|
211
|
+
name: "label",
|
|
212
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
213
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
214
|
+
htmlFor: e.name,
|
|
215
|
+
children: k("editor.conditionalEdge.labelOptional")
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
218
|
+
id: e.name,
|
|
219
|
+
placeholder: k("editor.conditionalEdge.labelPlaceholder"),
|
|
220
|
+
value: e.state.value,
|
|
221
|
+
onChange: (t) => e.handleChange(t.target.value)
|
|
222
|
+
}),
|
|
223
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: k("editor.conditionalEdge.labelDesc") })
|
|
224
|
+
] })
|
|
225
|
+
}),
|
|
226
|
+
/* @__PURE__ */ (0, W.jsx)(A, {
|
|
227
|
+
name: "isFallback",
|
|
228
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(T, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
229
|
+
className: "flex items-center gap-3 rounded-lg border bg-muted/20 p-3",
|
|
230
|
+
children: [/* @__PURE__ */ (0, W.jsx)(p, {
|
|
231
|
+
id: e.name,
|
|
232
|
+
checked: e.state.value,
|
|
233
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
234
|
+
}), /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
235
|
+
className: "flex flex-col gap-1",
|
|
236
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
237
|
+
htmlFor: e.name,
|
|
238
|
+
className: "cursor-pointer font-medium",
|
|
239
|
+
children: k("editor.conditionalEdge.fallbackPath")
|
|
240
|
+
}), /* @__PURE__ */ (0, W.jsx)(E, {
|
|
241
|
+
className: "text-xs",
|
|
242
|
+
children: k("editor.conditionalEdge.fallbackPathDesc")
|
|
243
|
+
})]
|
|
244
|
+
})]
|
|
245
|
+
}) })
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ (0, W.jsx)(A, {
|
|
248
|
+
name: "conditions",
|
|
249
|
+
mode: "array",
|
|
250
|
+
children: (e) => {
|
|
251
|
+
let t = e.form.getFieldValue("isFallback");
|
|
252
|
+
return /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
253
|
+
className: "space-y-3",
|
|
254
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
255
|
+
className: t ? "text-muted-foreground" : "",
|
|
256
|
+
children: k("editor.conditionalEdge.conditions")
|
|
257
|
+
}), /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
258
|
+
className: "space-y-2",
|
|
259
|
+
children: [e.state.value?.map((n, r) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
260
|
+
className: "space-y-2",
|
|
261
|
+
children: [/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
262
|
+
className: "space-y-2 rounded-lg border bg-muted/30 p-3",
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ (0, W.jsx)(A, {
|
|
265
|
+
name: `conditions[${r}].field`,
|
|
266
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
267
|
+
htmlFor: `field-${r}`,
|
|
268
|
+
children: k("editor.conditionalEdge.field")
|
|
269
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
270
|
+
disabled: t,
|
|
271
|
+
value: e.state.value || "",
|
|
272
|
+
onValueChange: (t) => e.handleChange(t),
|
|
273
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
274
|
+
id: `field-${r}`,
|
|
275
|
+
className: "w-full",
|
|
276
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: k("editor.conditionalEdge.selectField") })
|
|
277
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: D.length === 0 ? /* @__PURE__ */ (0, W.jsx)(x, {
|
|
278
|
+
value: "none",
|
|
279
|
+
disabled: !0,
|
|
280
|
+
children: k("editor.conditionalEdge.noFieldsAvailable")
|
|
281
|
+
}) : D.map((e) => /* @__PURE__ */ (0, W.jsxs)(x, {
|
|
282
|
+
value: e.nodeId,
|
|
283
|
+
children: [
|
|
284
|
+
e.label,
|
|
285
|
+
" (",
|
|
286
|
+
e.type,
|
|
287
|
+
")"
|
|
288
|
+
]
|
|
289
|
+
}, e.nodeId)) })]
|
|
290
|
+
})] })
|
|
291
|
+
}),
|
|
292
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
293
|
+
className: "flex gap-2",
|
|
294
|
+
children: [/* @__PURE__ */ (0, W.jsx)(A, {
|
|
295
|
+
name: `conditions[${r}].operator`,
|
|
296
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
297
|
+
htmlFor: `operator-${r}`,
|
|
298
|
+
children: k("editor.conditionalEdge.operator")
|
|
299
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
300
|
+
disabled: t,
|
|
301
|
+
value: e.state.value || "===",
|
|
302
|
+
onValueChange: (t) => e.handleChange(t),
|
|
303
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
304
|
+
id: `operator-${r}`,
|
|
305
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, {})
|
|
306
|
+
}), /* @__PURE__ */ (0, W.jsxs)(j, { children: [
|
|
307
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
308
|
+
value: "===",
|
|
309
|
+
children: "="
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
312
|
+
value: "!==",
|
|
313
|
+
children: "≠"
|
|
314
|
+
}),
|
|
315
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
316
|
+
value: ">",
|
|
317
|
+
children: ">"
|
|
318
|
+
}),
|
|
319
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
320
|
+
value: "<",
|
|
321
|
+
children: "<"
|
|
322
|
+
}),
|
|
323
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
324
|
+
value: ">=",
|
|
325
|
+
children: ">="
|
|
326
|
+
}),
|
|
327
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
328
|
+
value: "<=",
|
|
329
|
+
children: "<="
|
|
330
|
+
})
|
|
331
|
+
] })]
|
|
332
|
+
})] })
|
|
333
|
+
}), /* @__PURE__ */ (0, W.jsx)(A, {
|
|
334
|
+
name: `conditions[${r}].value`,
|
|
335
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
336
|
+
className: "w-full",
|
|
337
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
338
|
+
htmlFor: `value-${r}`,
|
|
339
|
+
children: k("editor.conditionalEdge.value")
|
|
340
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
341
|
+
disabled: t,
|
|
342
|
+
id: `value-${r}`,
|
|
343
|
+
placeholder: k("editor.conditionalEdge.valuePlaceholder"),
|
|
344
|
+
value: e.state.value || "",
|
|
345
|
+
onChange: (t) => e.handleChange(t.target.value)
|
|
346
|
+
})]
|
|
347
|
+
})
|
|
348
|
+
})]
|
|
349
|
+
}),
|
|
350
|
+
e.state.value && e.state.value.length > 1 && /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
351
|
+
disabled: t,
|
|
352
|
+
type: "button",
|
|
353
|
+
variant: "ghost",
|
|
354
|
+
size: "sm",
|
|
355
|
+
className: "w-full",
|
|
356
|
+
onClick: () => {
|
|
357
|
+
e.removeValue(r), re().then();
|
|
358
|
+
},
|
|
359
|
+
children: [/* @__PURE__ */ (0, W.jsx)(z, { className: "mr-1 h-4 w-4" }), k("editor.conditionalEdge.removeCondition")]
|
|
360
|
+
})
|
|
361
|
+
]
|
|
362
|
+
}), e.state.value && r < e.state.value.length - 1 && /* @__PURE__ */ (0, W.jsx)(A, {
|
|
363
|
+
name: `conditions[${r}].logicalOperator`,
|
|
364
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)("div", {
|
|
365
|
+
className: "flex justify-center",
|
|
366
|
+
children: /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
367
|
+
disabled: t,
|
|
368
|
+
value: e.state.value || i.AND,
|
|
369
|
+
onValueChange: (t) => e.handleChange(t),
|
|
370
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
371
|
+
className: "h-9 w-32 font-semibold",
|
|
372
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, {})
|
|
373
|
+
}), /* @__PURE__ */ (0, W.jsxs)(j, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
|
|
374
|
+
value: i.AND,
|
|
375
|
+
children: "AND"
|
|
376
|
+
}), /* @__PURE__ */ (0, W.jsx)(x, {
|
|
377
|
+
value: i.OR,
|
|
378
|
+
children: "OR"
|
|
379
|
+
})] })]
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
})]
|
|
383
|
+
}, `condition-${r}`)), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
384
|
+
disabled: t,
|
|
385
|
+
type: "button",
|
|
386
|
+
variant: "outline",
|
|
387
|
+
size: "sm",
|
|
388
|
+
className: "w-full",
|
|
389
|
+
onClick: () => {
|
|
390
|
+
e.pushValue({
|
|
391
|
+
field: D[0]?.nodeId ?? "",
|
|
392
|
+
logicalOperator: i.AND,
|
|
393
|
+
operator: "===",
|
|
394
|
+
value: ""
|
|
395
|
+
}), re().then();
|
|
396
|
+
},
|
|
397
|
+
children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), k("editor.conditionalEdge.addCondition")]
|
|
398
|
+
})]
|
|
399
|
+
})]
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
})
|
|
403
|
+
]
|
|
404
|
+
}),
|
|
405
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
406
|
+
className: "flex justify-end gap-2 pt-2",
|
|
407
|
+
children: [/* @__PURE__ */ (0, W.jsxs)(m, {
|
|
408
|
+
type: "button",
|
|
409
|
+
size: "sm",
|
|
410
|
+
variant: "outline",
|
|
411
|
+
onClick: oe,
|
|
412
|
+
children: [/* @__PURE__ */ (0, W.jsx)(z, { className: "mr-1 h-4 w-4" }), k("common.clear")]
|
|
413
|
+
}), /* @__PURE__ */ (0, W.jsx)(m, {
|
|
414
|
+
type: "button",
|
|
415
|
+
size: "sm",
|
|
416
|
+
onClick: () => w(!1),
|
|
417
|
+
children: k("common.close")
|
|
418
|
+
})]
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
})
|
|
423
|
+
})
|
|
424
|
+
})]
|
|
425
|
+
})
|
|
426
|
+
}) })] });
|
|
427
|
+
}),
|
|
428
|
+
default: Oe(({ id: e, sourceX: t, sourceY: n, targetX: r, targetY: i, sourcePosition: a, targetPosition: o, style: s, markerEnd: c, selected: l }) => {
|
|
429
|
+
let [u, d, f] = Ce({
|
|
430
|
+
sourcePosition: a,
|
|
431
|
+
sourceX: t,
|
|
432
|
+
sourceY: n,
|
|
433
|
+
targetPosition: o,
|
|
434
|
+
targetX: r,
|
|
435
|
+
targetY: i
|
|
436
|
+
}), { setEdges: p } = Ee();
|
|
437
|
+
return /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(fe, {
|
|
438
|
+
path: u,
|
|
439
|
+
markerEnd: c,
|
|
440
|
+
style: s
|
|
441
|
+
}), /* @__PURE__ */ (0, W.jsx)(me, { children: l && /* @__PURE__ */ (0, W.jsx)("div", {
|
|
442
|
+
className: "button-edge__label nodrag nopan",
|
|
443
|
+
style: { transform: `translate(-50%, -50%) translate(${d}px,${f}px)` },
|
|
444
|
+
children: /* @__PURE__ */ (0, W.jsx)("button", {
|
|
445
|
+
type: "button",
|
|
446
|
+
className: "button-edge__button",
|
|
447
|
+
onClick: () => {
|
|
448
|
+
p((t) => t.filter((t) => t.id !== e));
|
|
449
|
+
},
|
|
450
|
+
"aria-label": "Remove edge",
|
|
451
|
+
children: "×"
|
|
452
|
+
})
|
|
453
|
+
}) })] });
|
|
454
|
+
})
|
|
455
|
+
}, _t = {
|
|
456
|
+
address: "address",
|
|
457
|
+
autocomplete: "autocomplete",
|
|
458
|
+
checkbox: "checkbox",
|
|
459
|
+
date: "date",
|
|
460
|
+
daterange: "daterange",
|
|
461
|
+
file: "file",
|
|
462
|
+
hidden: "hidden",
|
|
463
|
+
http: "http",
|
|
464
|
+
number: "number",
|
|
465
|
+
password: "password",
|
|
466
|
+
radio: "radio",
|
|
467
|
+
select: "select",
|
|
468
|
+
submit: "submit",
|
|
469
|
+
switch: "switch",
|
|
470
|
+
text: "text",
|
|
471
|
+
textarea: "textarea",
|
|
472
|
+
time: "time",
|
|
473
|
+
timerange: "timerange"
|
|
474
|
+
}, vt = { [o.input]: { type: _t.text } }, K = () => {
|
|
475
|
+
let { setNodes: e, setEdges: t, getNodes: n } = Ee(), r = N(() => {
|
|
476
|
+
e((e) => e.map(({ selected: e, ...t }) => t)), t((e) => e.map(({ selected: e, ...t }) => t));
|
|
477
|
+
}, [t, e]), i = N((n) => {
|
|
478
|
+
e((e) => e.map((e) => ({
|
|
479
|
+
...e,
|
|
480
|
+
selected: e.id === n
|
|
481
|
+
}))), t((e) => e.map(({ selected: e, ...t }) => t));
|
|
482
|
+
}, [t, e]), a = N((t, n) => {
|
|
483
|
+
e((e) => e.map((e) => e.id === t ? {
|
|
484
|
+
...e,
|
|
485
|
+
data: {
|
|
486
|
+
...e.data,
|
|
487
|
+
...n
|
|
488
|
+
}
|
|
489
|
+
} : e));
|
|
490
|
+
}, [e]), o = N((t, n) => {
|
|
491
|
+
e((e) => e.map((e) => e.id === t ? {
|
|
492
|
+
...e,
|
|
493
|
+
data: vt[n] ?? {},
|
|
494
|
+
type: n
|
|
495
|
+
} : e));
|
|
496
|
+
}, [e]), s = N((e) => {
|
|
497
|
+
let t = n().find((e) => e.selected);
|
|
498
|
+
t && o(t.id, e);
|
|
499
|
+
}, [n, o]), c = N((e) => {
|
|
500
|
+
let t = n().find((e) => e.selected);
|
|
501
|
+
t && a(t.id, e);
|
|
502
|
+
}, [n, a]);
|
|
503
|
+
return {
|
|
504
|
+
clearSelection: r,
|
|
505
|
+
deleteSelectedNode: N(() => {
|
|
506
|
+
let r = n().find((e) => e.selected);
|
|
507
|
+
r && (e((e) => e.filter((e) => e.id !== r.id)), t((e) => e.filter((e) => e.source !== r.id && e.target !== r.id)));
|
|
508
|
+
}, [
|
|
509
|
+
n,
|
|
510
|
+
e,
|
|
511
|
+
t
|
|
512
|
+
]),
|
|
513
|
+
selectNode: i,
|
|
514
|
+
updateNodeData: a,
|
|
515
|
+
updateNodeType: o,
|
|
516
|
+
updateSelectedNodeData: c,
|
|
517
|
+
updateSelectedNodeType: s
|
|
518
|
+
};
|
|
519
|
+
}, yt = ({ nodeId: e, label: t, placeholder: n, className: r }) => {
|
|
520
|
+
let { language: i } = pt(), { updateNodeData: a } = K(), o = G(), s = t?.[i] ?? "", c = n || o("editor.treegeNode.labelPlaceholder"), l = (n) => {
|
|
521
|
+
a(e, { label: {
|
|
522
|
+
...t,
|
|
523
|
+
[i]: n.target.value
|
|
524
|
+
} });
|
|
525
|
+
}, u = (e) => e.stopPropagation();
|
|
526
|
+
return /* @__PURE__ */ (0, W.jsx)("input", {
|
|
527
|
+
type: "text",
|
|
528
|
+
value: s,
|
|
529
|
+
placeholder: c,
|
|
530
|
+
onChange: l,
|
|
531
|
+
onClick: u,
|
|
532
|
+
onMouseDown: u,
|
|
533
|
+
onPointerDown: u,
|
|
534
|
+
className: f("nodrag nopan w-full truncate bg-transparent outline-none placeholder:text-muted-foreground/40", r)
|
|
535
|
+
});
|
|
536
|
+
}, bt = ({ nodeId: e, className: t }) => {
|
|
537
|
+
let { selectNode: n } = K(), { setIsNodeSheetOpen: r } = pt(), i = G();
|
|
538
|
+
return /* @__PURE__ */ (0, W.jsx)("button", {
|
|
539
|
+
type: "button",
|
|
540
|
+
onClick: (t) => {
|
|
541
|
+
t.stopPropagation(), n(e), r(!0);
|
|
542
|
+
},
|
|
543
|
+
"aria-label": i("editor.nodeActionsSheet.editNode"),
|
|
544
|
+
className: f("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),
|
|
545
|
+
children: /* @__PURE__ */ (0, W.jsx)(Ie, { className: "h-3.5 w-3.5" })
|
|
546
|
+
});
|
|
547
|
+
}, xt = nt("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", {
|
|
548
|
+
defaultVariants: { variant: "default" },
|
|
549
|
+
variants: { variant: {
|
|
550
|
+
blue: "bg-blue-500 text-white dark:bg-blue-600",
|
|
551
|
+
default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
552
|
+
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",
|
|
553
|
+
outline: "border-foreground/30 text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
554
|
+
purple: "bg-purple-600 hover:bg-purple-700 text-white",
|
|
555
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90"
|
|
556
|
+
} }
|
|
557
|
+
});
|
|
558
|
+
function St({ className: e, variant: t, asChild: n = !1, ...r }) {
|
|
559
|
+
return /* @__PURE__ */ (0, W.jsx)(n ? tt : "span", {
|
|
560
|
+
"data-slot": "badge",
|
|
561
|
+
className: f(xt({ variant: t }), e),
|
|
562
|
+
...r
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
var Ct = Oe(({ data: e, id: t }) => /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [
|
|
566
|
+
/* @__PURE__ */ (0, W.jsx)(_e, {}),
|
|
567
|
+
/* @__PURE__ */ (0, W.jsx)("div", {
|
|
568
|
+
className: "-top-3.5 absolute left-6",
|
|
569
|
+
children: /* @__PURE__ */ (0, W.jsxs)(St, {
|
|
570
|
+
className: "max-w-50 bg-chart-2",
|
|
571
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Pe, { className: "!w-3 !h-3" }), /* @__PURE__ */ (0, W.jsx)(yt, {
|
|
572
|
+
nodeId: t,
|
|
573
|
+
label: e?.label,
|
|
574
|
+
className: "min-w-0 flex-1 text-xs text-white placeholder:text-white/60"
|
|
575
|
+
})]
|
|
576
|
+
})
|
|
577
|
+
}),
|
|
578
|
+
/* @__PURE__ */ (0, W.jsx)(bt, { nodeId: t })
|
|
579
|
+
] })), wt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", q = (e = 21) => {
|
|
580
|
+
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
581
|
+
for (; e--;) t += wt[n[e] & 63];
|
|
582
|
+
return t;
|
|
583
|
+
}, Tt = {
|
|
584
|
+
data: { type: "text" },
|
|
585
|
+
id: q(),
|
|
586
|
+
position: {
|
|
587
|
+
x: 0,
|
|
588
|
+
y: 0
|
|
589
|
+
},
|
|
590
|
+
type: "input"
|
|
591
|
+
}, Et = () => {
|
|
592
|
+
let { setNodes: e, setEdges: t, screenToFlowPosition: n, getNode: r, getNodes: i, getEdges: a } = Ee(), o = N((n, r, i = !1, o) => {
|
|
593
|
+
let s = n.id, l = a().filter((e) => e.source === s), u = c(n);
|
|
594
|
+
if (l.length > 0 && !u) return;
|
|
595
|
+
let d = q(), f = {
|
|
596
|
+
...Tt,
|
|
597
|
+
...o && {
|
|
598
|
+
data: o.data ?? {},
|
|
599
|
+
type: o.type
|
|
600
|
+
},
|
|
601
|
+
id: d,
|
|
602
|
+
position: r,
|
|
603
|
+
selected: i
|
|
604
|
+
};
|
|
605
|
+
n?.parentId && (f.parentId = n.parentId, f.extent = "parent"), e((e) => e.concat(f)), t((e) => {
|
|
606
|
+
let t = e.filter((e) => e.source === s).length > 0, n = {
|
|
607
|
+
data: t && u ? { conditions: [{
|
|
608
|
+
field: s,
|
|
609
|
+
operator: "===",
|
|
610
|
+
value: ""
|
|
611
|
+
}] } : void 0,
|
|
612
|
+
id: q(),
|
|
613
|
+
source: s,
|
|
614
|
+
target: d,
|
|
615
|
+
type: t && u ? "conditional" : "default"
|
|
616
|
+
};
|
|
617
|
+
return t && u ? e.map((e) => e.source === s ? {
|
|
618
|
+
...e,
|
|
619
|
+
data: {
|
|
620
|
+
...e.data,
|
|
621
|
+
conditions: e.data?.conditions || [{
|
|
622
|
+
field: s,
|
|
623
|
+
operator: "===",
|
|
624
|
+
value: ""
|
|
625
|
+
}]
|
|
626
|
+
},
|
|
627
|
+
type: "conditional"
|
|
628
|
+
} : e).concat(n) : e.concat(n);
|
|
629
|
+
}), i && (e((e) => e.map((e) => ({
|
|
630
|
+
...e,
|
|
631
|
+
selected: e.id === d
|
|
632
|
+
}))), t((e) => e.map((e) => ({
|
|
633
|
+
...e,
|
|
634
|
+
selected: !1
|
|
635
|
+
}))));
|
|
636
|
+
}, [
|
|
637
|
+
a,
|
|
638
|
+
e,
|
|
639
|
+
t
|
|
640
|
+
]), s = N((e) => {
|
|
641
|
+
t((t) => {
|
|
642
|
+
let n = Se(e, t), i = e.source, a = r(i);
|
|
643
|
+
return n.filter((e) => e.source === i).length > 1 && a && c(a) ? n.map((e) => e.source === i ? {
|
|
644
|
+
...e,
|
|
645
|
+
data: {
|
|
646
|
+
...e.data,
|
|
647
|
+
conditions: e.data?.conditions || [{
|
|
648
|
+
field: i,
|
|
649
|
+
operator: "===",
|
|
650
|
+
value: ""
|
|
651
|
+
}]
|
|
652
|
+
},
|
|
653
|
+
type: "conditional"
|
|
654
|
+
} : e) : n;
|
|
655
|
+
});
|
|
656
|
+
}, [t, r]), l = N((e, t) => {
|
|
657
|
+
let n = r(e);
|
|
658
|
+
if (!n) return;
|
|
659
|
+
let s = getComputedStyle(document.documentElement).getPropertyValue("--node-height"), c = getComputedStyle(document.documentElement).getPropertyValue("--node-width"), l = parseFloat(s) || 100, u = parseFloat(c) || 100, d = n.position.y + l + 100, f = i(), p = a(), m = f.filter((t) => p.some((n) => n.source === e && n.target === t.id));
|
|
660
|
+
o(n, {
|
|
661
|
+
x: m.length > 0 ? m.reduce((e, t) => t.position.x > e.position.x ? t : e, m[0]).position.x + u + 50 : n.position.x,
|
|
662
|
+
y: d
|
|
663
|
+
}, !0, t);
|
|
664
|
+
}, [
|
|
665
|
+
r,
|
|
666
|
+
i,
|
|
667
|
+
a,
|
|
668
|
+
o
|
|
669
|
+
]), u = N((e, t) => {
|
|
670
|
+
if (!t.isValid) {
|
|
671
|
+
let { clientX: i, clientY: a } = "changedTouches" in e ? e.changedTouches[0] : e, s = t.fromNode;
|
|
672
|
+
if (!s) return;
|
|
673
|
+
let c = n({
|
|
674
|
+
x: i,
|
|
675
|
+
y: a
|
|
676
|
+
}), l = s.parentId ? r(s.parentId) : void 0, u = l?.position ?? {
|
|
677
|
+
x: 0,
|
|
678
|
+
y: 0
|
|
679
|
+
};
|
|
680
|
+
o(s, l ? {
|
|
681
|
+
x: c.x - u.x,
|
|
682
|
+
y: c.y - u.y
|
|
683
|
+
} : c);
|
|
684
|
+
}
|
|
685
|
+
}, [
|
|
686
|
+
o,
|
|
687
|
+
r,
|
|
688
|
+
n
|
|
689
|
+
]), d = N((e) => {
|
|
690
|
+
t((t) => {
|
|
691
|
+
let n = t.filter((t) => !e.find((e) => e.id === t.id)), r = new Set(e.map((e) => e.source)), i = /* @__PURE__ */ new Map();
|
|
692
|
+
return n.forEach((e) => {
|
|
693
|
+
i.set(e.source, (i.get(e.source) ?? 0) + 1);
|
|
694
|
+
}), n.map((e) => {
|
|
695
|
+
if (r.has(e.source) && (i.get(e.source) ?? 0) === 1) {
|
|
696
|
+
let { conditions: t, isFallback: n, ...r } = e.data ?? {}, i = r && Object.keys(r).length > 0 ? r : void 0;
|
|
697
|
+
return {
|
|
698
|
+
...e,
|
|
699
|
+
data: i,
|
|
700
|
+
type: "default"
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
return e;
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
}, [t]);
|
|
707
|
+
return {
|
|
708
|
+
isValidConnection: N((e) => {
|
|
709
|
+
if (e.source === e.target) return !1;
|
|
710
|
+
let t = r(e.source);
|
|
711
|
+
return t ? !(a().filter((t) => t.source === e.source).length > 0 && !c(t)) : !1;
|
|
712
|
+
}, [r, a]),
|
|
713
|
+
onAddFromHandle: l,
|
|
714
|
+
onConnect: s,
|
|
715
|
+
onConnectEnd: u,
|
|
716
|
+
onEdgesDelete: d
|
|
717
|
+
};
|
|
718
|
+
};
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region src/shared/components/ui/dropdown-menu.tsx
|
|
721
|
+
function J({ ...e }) {
|
|
722
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Root, {
|
|
723
|
+
"data-slot": "dropdown-menu",
|
|
724
|
+
...e
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
function Y({ ...e }) {
|
|
728
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Trigger, {
|
|
729
|
+
"data-slot": "dropdown-menu-trigger",
|
|
730
|
+
...e
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
function X({ className: e, sideOffset: t = 4, ...n }) {
|
|
734
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Portal, { children: /* @__PURE__ */ (0, W.jsx)(B.Content, {
|
|
735
|
+
"data-slot": "dropdown-menu-content",
|
|
736
|
+
sideOffset: t,
|
|
737
|
+
className: f("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),
|
|
738
|
+
...n
|
|
739
|
+
}) });
|
|
740
|
+
}
|
|
741
|
+
function Dt({ ...e }) {
|
|
742
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Group, {
|
|
743
|
+
"data-slot": "dropdown-menu-group",
|
|
744
|
+
...e
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
function Z({ className: e, inset: t, variant: n = "default", ...r }) {
|
|
748
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Item, {
|
|
749
|
+
"data-slot": "dropdown-menu-item",
|
|
750
|
+
"data-inset": t,
|
|
751
|
+
"data-variant": n,
|
|
752
|
+
className: f("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),
|
|
753
|
+
...r
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function Ot({ className: e, inset: t, ...n }) {
|
|
757
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Label, {
|
|
758
|
+
"data-slot": "dropdown-menu-label",
|
|
759
|
+
"data-inset": t,
|
|
760
|
+
className: f("px-1.5 py-1 font-medium text-muted-foreground text-xs data-[inset]:pl-7", e),
|
|
761
|
+
...n
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
function kt({ className: e, ...t }) {
|
|
765
|
+
return /* @__PURE__ */ (0, W.jsx)(B.Separator, {
|
|
766
|
+
"data-slot": "dropdown-menu-separator",
|
|
767
|
+
className: f("-mx-1 my-1 h-px bg-border", e),
|
|
768
|
+
...t
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region src/shared/constants/uiType.ts
|
|
773
|
+
var At = {
|
|
774
|
+
divider: "divider",
|
|
775
|
+
title: "title"
|
|
776
|
+
}, jt = ({ nodeId: e, isConnectable: t }) => {
|
|
777
|
+
let { onAddFromHandle: n } = Et(), r = G();
|
|
778
|
+
return /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
779
|
+
asChild: !0,
|
|
780
|
+
children: /* @__PURE__ */ (0, W.jsx)(he, {
|
|
781
|
+
type: "source",
|
|
782
|
+
position: ye.Bottom,
|
|
783
|
+
isConnectable: t,
|
|
784
|
+
className: "flex h-6! w-6! cursor-pointer items-center justify-center rounded-sm transition-colors hover:bg-primary/80!",
|
|
785
|
+
children: /* @__PURE__ */ (0, W.jsx)(R, { className: "h-4 w-4 text-primary-foreground" })
|
|
786
|
+
})
|
|
787
|
+
}), /* @__PURE__ */ (0, W.jsxs)(X, {
|
|
788
|
+
align: "center",
|
|
789
|
+
side: "bottom",
|
|
790
|
+
className: "treege-scrollbar max-h-80",
|
|
791
|
+
children: [
|
|
792
|
+
/* @__PURE__ */ (0, W.jsxs)(Dt, { children: [/* @__PURE__ */ (0, W.jsx)(Ot, { children: r("editor.selectNodeType.options.input") }), Object.values(_t).map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
793
|
+
onClick: () => n(e, {
|
|
794
|
+
data: { type: t },
|
|
795
|
+
type: o.input
|
|
796
|
+
}),
|
|
797
|
+
className: "capitalize",
|
|
798
|
+
children: t
|
|
799
|
+
}, t))] }),
|
|
800
|
+
/* @__PURE__ */ (0, W.jsx)(kt, {}),
|
|
801
|
+
/* @__PURE__ */ (0, W.jsxs)(Dt, { children: [/* @__PURE__ */ (0, W.jsx)(Ot, { children: r("editor.selectNodeType.options.ui") }), Object.values(At).map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
802
|
+
onClick: () => n(e, {
|
|
803
|
+
data: { type: t },
|
|
804
|
+
type: o.ui
|
|
805
|
+
}),
|
|
806
|
+
className: "capitalize",
|
|
807
|
+
children: t
|
|
808
|
+
}, t))] }),
|
|
809
|
+
/* @__PURE__ */ (0, W.jsx)(kt, {}),
|
|
810
|
+
/* @__PURE__ */ (0, W.jsxs)(Dt, { children: [/* @__PURE__ */ (0, W.jsx)(Ot, { children: r("common.other") }), /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
811
|
+
onClick: () => n(e, {
|
|
812
|
+
data: {},
|
|
813
|
+
type: o.flow
|
|
814
|
+
}),
|
|
815
|
+
children: r("editor.selectNodeType.options.flow")
|
|
816
|
+
})] })
|
|
817
|
+
]
|
|
818
|
+
})] });
|
|
819
|
+
}, Mt = {
|
|
820
|
+
[o.flow]: Ge,
|
|
821
|
+
[o.group]: Pe,
|
|
822
|
+
[o.input]: We,
|
|
823
|
+
[o.ui]: Ue
|
|
824
|
+
}, Nt = {
|
|
825
|
+
[o.flow]: "destructive",
|
|
826
|
+
[o.group]: "default",
|
|
827
|
+
[o.input]: "blue",
|
|
828
|
+
[o.ui]: "purple"
|
|
829
|
+
}, Pt = ({ nodeId: e, type: t }) => {
|
|
830
|
+
let { updateNodeType: n } = K(), r = G(), i = Mt[t], a = Object.keys(zt).filter((e) => e !== o.group), s = (e) => e.stopPropagation();
|
|
831
|
+
return /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
832
|
+
asChild: !0,
|
|
833
|
+
onClick: s,
|
|
834
|
+
children: /* @__PURE__ */ (0, W.jsxs)(St, {
|
|
835
|
+
variant: Nt[t],
|
|
836
|
+
className: "nodrag nopan cursor-pointer px-1.5 py-0 text-[10px] capitalize [&>svg]:size-2.5",
|
|
837
|
+
children: [/* @__PURE__ */ (0, W.jsx)(i, {}), r(`editor.selectNodeType.options.${t}`)]
|
|
838
|
+
})
|
|
839
|
+
}), /* @__PURE__ */ (0, W.jsx)(X, {
|
|
840
|
+
align: "start",
|
|
841
|
+
onClick: s,
|
|
842
|
+
children: a.map((i) => {
|
|
843
|
+
let a = Mt[i];
|
|
844
|
+
return /* @__PURE__ */ (0, W.jsxs)(Z, {
|
|
845
|
+
onClick: () => n(e, i),
|
|
846
|
+
className: i === t ? "bg-accent" : void 0,
|
|
847
|
+
children: [/* @__PURE__ */ (0, W.jsx)(a, {}), r(`editor.selectNodeType.options.${i}`)]
|
|
848
|
+
}, i);
|
|
849
|
+
})
|
|
850
|
+
})] });
|
|
851
|
+
}, Ft = {
|
|
852
|
+
input: Object.values(_t),
|
|
853
|
+
ui: Object.values(At)
|
|
854
|
+
}, It = ({ nodeId: e, type: t, subType: n }) => {
|
|
855
|
+
let { updateNodeData: r } = K(), i = G(), a = Ft[t], o = (e) => e.stopPropagation();
|
|
856
|
+
return /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
857
|
+
asChild: !0,
|
|
858
|
+
onClick: o,
|
|
859
|
+
children: /* @__PURE__ */ (0, W.jsxs)(St, {
|
|
860
|
+
variant: "default",
|
|
861
|
+
className: "nodrag nopan cursor-pointer px-1.5 py-0 text-[10px] capitalize [&>svg]:size-2.5",
|
|
862
|
+
children: [/* @__PURE__ */ (0, W.jsx)(qe, {}), n || i("editor.selectInputType.type")]
|
|
863
|
+
})
|
|
864
|
+
}), /* @__PURE__ */ (0, W.jsx)(X, {
|
|
865
|
+
align: "start",
|
|
866
|
+
className: "treege-scrollbar max-h-60",
|
|
867
|
+
onClick: o,
|
|
868
|
+
children: a.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
869
|
+
onClick: () => r(e, { type: t }),
|
|
870
|
+
className: f("capitalize", t === n && "bg-accent"),
|
|
871
|
+
children: t
|
|
872
|
+
}, t))
|
|
873
|
+
})] });
|
|
874
|
+
}, Lt = ({ children: e, inGroup: t, isSubmit: n }) => /* @__PURE__ */ (0, W.jsx)("div", {
|
|
875
|
+
className: f("react-flow__node__wrapper relative", t && "in-group", n && "submit-type"),
|
|
876
|
+
children: e
|
|
877
|
+
}), Rt = Oe(({ data: e, isConnectable: t, parentId: n, type: r, id: i }) => {
|
|
878
|
+
let a = r === "input" || r === "ui" ? e?.type : void 0, o = r === "input" && e?.type === "submit", s = r === "input" ? e?.name : void 0;
|
|
879
|
+
return /* @__PURE__ */ (0, W.jsxs)(Lt, {
|
|
880
|
+
inGroup: !!n,
|
|
881
|
+
isSubmit: o,
|
|
882
|
+
children: [
|
|
883
|
+
/* @__PURE__ */ (0, W.jsx)(bt, { nodeId: i }),
|
|
884
|
+
/* @__PURE__ */ (0, W.jsx)(he, {
|
|
885
|
+
type: "target",
|
|
886
|
+
position: ye.Top,
|
|
887
|
+
isConnectable: t,
|
|
888
|
+
isConnectableStart: r === "ui"
|
|
889
|
+
}),
|
|
890
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
891
|
+
className: "mb-1 flex gap-1",
|
|
892
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Pt, {
|
|
893
|
+
nodeId: i,
|
|
894
|
+
type: r
|
|
895
|
+
}), (r === "input" || r === "ui") && /* @__PURE__ */ (0, W.jsx)(It, {
|
|
896
|
+
nodeId: i,
|
|
897
|
+
type: r,
|
|
898
|
+
subType: a
|
|
899
|
+
})]
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ (0, W.jsx)(yt, {
|
|
902
|
+
nodeId: i,
|
|
903
|
+
label: e?.label,
|
|
904
|
+
placeholder: s,
|
|
905
|
+
className: f("py-1", r === "ui" && "capitalize")
|
|
906
|
+
}),
|
|
907
|
+
/* @__PURE__ */ (0, W.jsx)(jt, {
|
|
908
|
+
nodeId: i,
|
|
909
|
+
isConnectable: t
|
|
910
|
+
})
|
|
911
|
+
]
|
|
912
|
+
});
|
|
913
|
+
}), zt = {
|
|
914
|
+
[o.flow]: Rt,
|
|
915
|
+
[o.group]: Ct,
|
|
916
|
+
[o.input]: Rt,
|
|
917
|
+
[o.ui]: Rt
|
|
918
|
+
}, Bt = "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", Vt = {
|
|
919
|
+
claude: "claude-3-5-haiku-20241022",
|
|
920
|
+
deepseek: "deepseek-chat",
|
|
921
|
+
gemini: "gemini-2.5-flash",
|
|
922
|
+
openai: "gpt-4o-mini"
|
|
923
|
+
}, Ht = .3;
|
|
924
|
+
function Ut(e) {
|
|
925
|
+
try {
|
|
926
|
+
return JSON.parse(e);
|
|
927
|
+
} catch (t) {
|
|
928
|
+
let n = e.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
|
|
929
|
+
try {
|
|
930
|
+
return JSON.parse(n);
|
|
931
|
+
} catch {
|
|
932
|
+
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"}`);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
async function Wt(e) {
|
|
937
|
+
let t = e.config.model || Vt.gemini, n = e.config.temperature ?? Ht, r = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${t}:generateContent?key=${e.config.apiKey}`, {
|
|
938
|
+
body: JSON.stringify({
|
|
939
|
+
contents: [{ parts: [{ text: `${Bt}\n\nUser request: ${e.prompt}` }] }],
|
|
940
|
+
generationConfig: {
|
|
941
|
+
responseMimeType: "application/json",
|
|
942
|
+
temperature: n
|
|
943
|
+
}
|
|
944
|
+
}),
|
|
945
|
+
headers: { "Content-Type": "application/json" },
|
|
946
|
+
method: "POST"
|
|
947
|
+
});
|
|
948
|
+
if (!r.ok) {
|
|
949
|
+
let e = await r.text();
|
|
950
|
+
throw Error(`Gemini API error: ${e}`);
|
|
951
|
+
}
|
|
952
|
+
let i = (await r.json()).candidates?.[0]?.content?.parts?.[0]?.text;
|
|
953
|
+
if (!i) throw Error("No response from Gemini");
|
|
954
|
+
return Ut(i);
|
|
955
|
+
}
|
|
956
|
+
async function Gt(e) {
|
|
957
|
+
let t = e.config.model || Vt.openai, n = e.config.temperature ?? Ht, r = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
958
|
+
body: JSON.stringify({
|
|
959
|
+
messages: [{
|
|
960
|
+
content: Bt,
|
|
961
|
+
role: "system"
|
|
962
|
+
}, {
|
|
963
|
+
content: e.prompt,
|
|
964
|
+
role: "user"
|
|
965
|
+
}],
|
|
966
|
+
model: t,
|
|
967
|
+
response_format: { type: "json_object" },
|
|
968
|
+
temperature: n
|
|
969
|
+
}),
|
|
970
|
+
headers: {
|
|
971
|
+
Authorization: `Bearer ${e.config.apiKey}`,
|
|
972
|
+
"Content-Type": "application/json"
|
|
973
|
+
},
|
|
974
|
+
method: "POST"
|
|
975
|
+
});
|
|
976
|
+
if (!r.ok) {
|
|
977
|
+
let e = await r.text();
|
|
978
|
+
throw Error(`OpenAI API error: ${e}`);
|
|
979
|
+
}
|
|
980
|
+
let i = (await r.json()).choices?.[0]?.message?.content;
|
|
981
|
+
if (!i) throw Error("No response from OpenAI");
|
|
982
|
+
return Ut(i);
|
|
983
|
+
}
|
|
984
|
+
async function Kt(e) {
|
|
985
|
+
let t = e.config.model || Vt.deepseek, n = e.config.temperature ?? Ht, r = await fetch("https://api.deepseek.com/v1/chat/completions", {
|
|
986
|
+
body: JSON.stringify({
|
|
987
|
+
messages: [{
|
|
988
|
+
content: Bt,
|
|
989
|
+
role: "system"
|
|
990
|
+
}, {
|
|
991
|
+
content: e.prompt,
|
|
992
|
+
role: "user"
|
|
993
|
+
}],
|
|
994
|
+
model: t,
|
|
995
|
+
response_format: { type: "json_object" },
|
|
996
|
+
temperature: n
|
|
997
|
+
}),
|
|
998
|
+
headers: {
|
|
999
|
+
Authorization: `Bearer ${e.config.apiKey}`,
|
|
1000
|
+
"Content-Type": "application/json"
|
|
1001
|
+
},
|
|
1002
|
+
method: "POST"
|
|
1003
|
+
});
|
|
1004
|
+
if (!r.ok) {
|
|
1005
|
+
let e = await r.text();
|
|
1006
|
+
throw Error(`DeepSeek API error: ${e}`);
|
|
1007
|
+
}
|
|
1008
|
+
let i = (await r.json()).choices?.[0]?.message?.content;
|
|
1009
|
+
if (!i) throw Error("No response from DeepSeek");
|
|
1010
|
+
return Ut(i);
|
|
1011
|
+
}
|
|
1012
|
+
async function qt(e) {
|
|
1013
|
+
let t = e.config.model || Vt.claude, n = e.config.temperature ?? Ht, r = await fetch("https://api.anthropic.com/v1/messages", {
|
|
1014
|
+
body: JSON.stringify({
|
|
1015
|
+
max_tokens: 4096,
|
|
1016
|
+
messages: [{
|
|
1017
|
+
content: e.prompt,
|
|
1018
|
+
role: "user"
|
|
1019
|
+
}],
|
|
1020
|
+
model: t,
|
|
1021
|
+
system: Bt,
|
|
1022
|
+
temperature: n
|
|
1023
|
+
}),
|
|
1024
|
+
headers: {
|
|
1025
|
+
"anthropic-version": "2023-06-01",
|
|
1026
|
+
"Content-Type": "application/json",
|
|
1027
|
+
"x-api-key": e.config.apiKey
|
|
1028
|
+
},
|
|
1029
|
+
method: "POST"
|
|
1030
|
+
});
|
|
1031
|
+
if (!r.ok) {
|
|
1032
|
+
let e = await r.text();
|
|
1033
|
+
throw Error(`Claude API error: ${e}`);
|
|
1034
|
+
}
|
|
1035
|
+
let i = (await r.json()).content?.[0]?.text;
|
|
1036
|
+
if (!i) throw Error("No response from Claude");
|
|
1037
|
+
return Ut(i);
|
|
1038
|
+
}
|
|
1039
|
+
function Jt(e) {
|
|
1040
|
+
switch (e.config.provider) {
|
|
1041
|
+
case "gemini": return Wt(e);
|
|
1042
|
+
case "openai": return Gt(e);
|
|
1043
|
+
case "deepseek": return Kt(e);
|
|
1044
|
+
case "claude": return qt(e);
|
|
1045
|
+
default: throw Error(`Unsupported AI provider: ${e.config.provider}`);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region src/editor/features/TreegeEditor/panel/AIGeneratorDialog.tsx
|
|
1050
|
+
var Yt = ({ aiConfig: e, onGenerate: t }) => {
|
|
1051
|
+
let [n, r] = F(!1), [i, a] = F(""), [o, s] = F(!1), c = G(), l = async () => {
|
|
1052
|
+
if (!i.trim()) {
|
|
1053
|
+
V.error(c("editor.aiGenerator.enterDescription"));
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (!e?.apiKey) {
|
|
1057
|
+
V.error(c("editor.aiGenerator.missingApiKey"), { description: c("editor.aiGenerator.missingApiKeyDesc") });
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
s(!0);
|
|
1061
|
+
try {
|
|
1062
|
+
let n = await Jt({
|
|
1063
|
+
config: e,
|
|
1064
|
+
prompt: i.trim()
|
|
1065
|
+
});
|
|
1066
|
+
t({
|
|
1067
|
+
edges: n.edges,
|
|
1068
|
+
nodes: n.nodes
|
|
1069
|
+
}), 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);
|
|
1070
|
+
} catch (e) {
|
|
1071
|
+
console.error("AI generation error:", e), V.error(c("editor.aiGenerator.failedToGenerate"), { description: e instanceof Error ? e.message : c("editor.aiGenerator.unknownError") });
|
|
1072
|
+
} finally {
|
|
1073
|
+
s(!1);
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
return /* @__PURE__ */ (0, W.jsxs)(se, {
|
|
1077
|
+
open: n,
|
|
1078
|
+
onOpenChange: r,
|
|
1079
|
+
children: [/* @__PURE__ */ (0, W.jsx)(te, {
|
|
1080
|
+
asChild: !0,
|
|
1081
|
+
children: /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
1082
|
+
variant: "outline",
|
|
1083
|
+
size: "sm",
|
|
1084
|
+
disabled: !e?.apiKey,
|
|
1085
|
+
children: [
|
|
1086
|
+
/* @__PURE__ */ (0, W.jsx)(Qe, { className: "h-4 w-4 text-[#13d3b4]" }),
|
|
1087
|
+
" ",
|
|
1088
|
+
c("editor.aiGenerator.buttonLabel")
|
|
1089
|
+
]
|
|
1090
|
+
})
|
|
1091
|
+
}), /* @__PURE__ */ (0, W.jsxs)(C, {
|
|
1092
|
+
className: "sm:max-w-[550px]",
|
|
1093
|
+
children: [
|
|
1094
|
+
/* @__PURE__ */ (0, W.jsxs)(O, { children: [/* @__PURE__ */ (0, W.jsx)(w, { children: c("editor.aiGenerator.title") }), /* @__PURE__ */ (0, W.jsx)(ee, { children: c("editor.aiGenerator.titleDescription") })] }),
|
|
1095
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1096
|
+
className: "grid gap-4 py-4",
|
|
1097
|
+
children: [/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1098
|
+
className: "grid gap-2",
|
|
1099
|
+
children: [
|
|
1100
|
+
/* @__PURE__ */ (0, W.jsx)("label", {
|
|
1101
|
+
htmlFor: "ai-prompt",
|
|
1102
|
+
className: "font-medium text-sm",
|
|
1103
|
+
children: c("editor.aiGenerator.description")
|
|
1104
|
+
}),
|
|
1105
|
+
/* @__PURE__ */ (0, W.jsx)(D, {
|
|
1106
|
+
placeholder: c("editor.aiGenerator.descriptionPlaceholder"),
|
|
1107
|
+
value: i,
|
|
1108
|
+
onChange: (e) => a(e.target.value),
|
|
1109
|
+
onKeyDown: (e) => {
|
|
1110
|
+
(e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), l());
|
|
1111
|
+
},
|
|
1112
|
+
rows: 6,
|
|
1113
|
+
disabled: o,
|
|
1114
|
+
className: "resize-none"
|
|
1115
|
+
}),
|
|
1116
|
+
/* @__PURE__ */ (0, W.jsx)("p", {
|
|
1117
|
+
className: "text-muted-foreground text-xs",
|
|
1118
|
+
children: c("editor.aiGenerator.keyboardShortcut").replace("{cmdEnter}", "⌘ Enter").replace("{ctrlEnter}", "Ctrl Enter")
|
|
1119
|
+
})
|
|
1120
|
+
]
|
|
1121
|
+
}), !e?.apiKey && /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1122
|
+
className: "rounded-md bg-muted p-3 text-sm",
|
|
1123
|
+
children: [/* @__PURE__ */ (0, W.jsx)("p", {
|
|
1124
|
+
className: "font-medium",
|
|
1125
|
+
children: c("editor.aiGenerator.aiNotConfigured")
|
|
1126
|
+
}), /* @__PURE__ */ (0, W.jsxs)("p", {
|
|
1127
|
+
className: "mt-1 text-muted-foreground text-xs",
|
|
1128
|
+
children: [
|
|
1129
|
+
c("editor.aiGenerator.aiNotConfiguredDesc").replace("{code}", ""),
|
|
1130
|
+
" ",
|
|
1131
|
+
/* @__PURE__ */ (0, W.jsx)("code", {
|
|
1132
|
+
className: "rounded bg-background px-1 py-0.5",
|
|
1133
|
+
children: "aiConfig"
|
|
1134
|
+
})
|
|
1135
|
+
]
|
|
1136
|
+
})]
|
|
1137
|
+
})]
|
|
1138
|
+
}),
|
|
1139
|
+
/* @__PURE__ */ (0, W.jsxs)(ie, { children: [/* @__PURE__ */ (0, W.jsx)(m, {
|
|
1140
|
+
variant: "outline",
|
|
1141
|
+
onClick: () => r(!1),
|
|
1142
|
+
disabled: o,
|
|
1143
|
+
children: c("editor.aiGenerator.cancel")
|
|
1144
|
+
}), /* @__PURE__ */ (0, W.jsx)(m, {
|
|
1145
|
+
onClick: l,
|
|
1146
|
+
disabled: o || !i.trim() || !e?.apiKey,
|
|
1147
|
+
children: o ? /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(He, { className: "h-4 w-4 animate-spin" }), c("editor.aiGenerator.generating")] }) : /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(Qe, { className: "h-4 w-4 text-[--treege-color-primary]" }), c("editor.aiGenerator.generate")] })
|
|
1148
|
+
})] })
|
|
1149
|
+
]
|
|
1150
|
+
})]
|
|
1151
|
+
});
|
|
1152
|
+
}, Xt = q(), Zt = ({ onExportJson: e, onSave: t }) => {
|
|
1153
|
+
let { flowId: n, setFlowId: r, aiConfig: i } = pt(), { setNodes: a, setEdges: o, addNodes: s, screenToFlowPosition: c } = Ee(), l = n || Xt, u = Te(), d = we(), f = Me(null), p = G(), h = () => {
|
|
1154
|
+
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({
|
|
1155
|
+
x: e - n,
|
|
1156
|
+
y: t - r
|
|
1157
|
+
});
|
|
1158
|
+
s([{
|
|
1159
|
+
...Tt,
|
|
1160
|
+
id: q(),
|
|
1161
|
+
position: i,
|
|
1162
|
+
selected: !0
|
|
1163
|
+
}]);
|
|
1164
|
+
}, g = ({ target: e }) => {
|
|
1165
|
+
let t = e.files?.[0];
|
|
1166
|
+
if (!t) return;
|
|
1167
|
+
let n = new FileReader();
|
|
1168
|
+
n.onload = (e) => {
|
|
1169
|
+
try {
|
|
1170
|
+
let t = JSON.parse(e.target?.result);
|
|
1171
|
+
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") });
|
|
1172
|
+
} catch (e) {
|
|
1173
|
+
console.warn(e), V.error(p("editor.actionsPanel.parseError"), { description: p("editor.actionsPanel.parseErrorDesc") });
|
|
1174
|
+
}
|
|
1175
|
+
f.current && (f.current.value = "");
|
|
1176
|
+
}, n.readAsText(t);
|
|
1177
|
+
}, _ = () => {
|
|
1178
|
+
let t = {
|
|
1179
|
+
edges: d,
|
|
1180
|
+
id: l,
|
|
1181
|
+
nodes: u
|
|
1182
|
+
}, i = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
1183
|
+
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);
|
|
1184
|
+
}, v = N(() => {
|
|
1185
|
+
n || r?.(l), t?.({
|
|
1186
|
+
edges: d,
|
|
1187
|
+
id: l,
|
|
1188
|
+
nodes: u
|
|
1189
|
+
});
|
|
1190
|
+
}, [
|
|
1191
|
+
d,
|
|
1192
|
+
n,
|
|
1193
|
+
l,
|
|
1194
|
+
u,
|
|
1195
|
+
t,
|
|
1196
|
+
r
|
|
1197
|
+
]);
|
|
1198
|
+
return Ae(() => {
|
|
1199
|
+
let e = (e) => {
|
|
1200
|
+
(e.ctrlKey || e.metaKey) && e.key === "s" && (e.preventDefault(), v());
|
|
1201
|
+
};
|
|
1202
|
+
return window.addEventListener("keydown", e), () => {
|
|
1203
|
+
window.removeEventListener("keydown", e);
|
|
1204
|
+
};
|
|
1205
|
+
}, [v]), /* @__PURE__ */ (0, W.jsxs)(ve, {
|
|
1206
|
+
position: "top-right",
|
|
1207
|
+
className: "flex gap-2",
|
|
1208
|
+
children: [
|
|
1209
|
+
/* @__PURE__ */ (0, W.jsx)(Yt, {
|
|
1210
|
+
aiConfig: i,
|
|
1211
|
+
onGenerate: (e) => {
|
|
1212
|
+
a(e.nodes), o(e.edges);
|
|
1213
|
+
}
|
|
1214
|
+
}),
|
|
1215
|
+
/* @__PURE__ */ (0, W.jsxs)(m, {
|
|
1216
|
+
variant: "outline",
|
|
1217
|
+
size: "sm",
|
|
1218
|
+
onClick: h,
|
|
1219
|
+
children: [
|
|
1220
|
+
/* @__PURE__ */ (0, W.jsx)(R, {}),
|
|
1221
|
+
" ",
|
|
1222
|
+
p("editor.actionsPanel.addNode")
|
|
1223
|
+
]
|
|
1224
|
+
}),
|
|
1225
|
+
/* @__PURE__ */ (0, W.jsxs)(m, {
|
|
1226
|
+
variant: "outline",
|
|
1227
|
+
size: "sm",
|
|
1228
|
+
onClick: v,
|
|
1229
|
+
children: [
|
|
1230
|
+
/* @__PURE__ */ (0, W.jsx)(Je, {}),
|
|
1231
|
+
" ",
|
|
1232
|
+
p("common.save")
|
|
1233
|
+
]
|
|
1234
|
+
}),
|
|
1235
|
+
/* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
1236
|
+
asChild: !0,
|
|
1237
|
+
children: /* @__PURE__ */ (0, W.jsx)(m, {
|
|
1238
|
+
variant: "outline",
|
|
1239
|
+
size: "sm",
|
|
1240
|
+
children: /* @__PURE__ */ (0, W.jsx)(ze, {})
|
|
1241
|
+
})
|
|
1242
|
+
}), /* @__PURE__ */ (0, W.jsxs)(X, {
|
|
1243
|
+
align: "start",
|
|
1244
|
+
children: [
|
|
1245
|
+
/* @__PURE__ */ (0, W.jsx)(Ot, {
|
|
1246
|
+
className: "font-normal",
|
|
1247
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1248
|
+
className: "flex flex-col gap-1",
|
|
1249
|
+
children: [/* @__PURE__ */ (0, W.jsx)("span", {
|
|
1250
|
+
className: "text-muted-foreground text-xs",
|
|
1251
|
+
children: "Flow ID"
|
|
1252
|
+
}), /* @__PURE__ */ (0, W.jsxs)("button", {
|
|
1253
|
+
onClick: async () => {
|
|
1254
|
+
try {
|
|
1255
|
+
await navigator.clipboard.writeText(l), V.success(p("editor.actionsPanel.idCopied"), { description: l });
|
|
1256
|
+
} catch {
|
|
1257
|
+
V.error(p("editor.actionsPanel.copyFailed"));
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
className: "flex items-center gap-2 font-mono text-muted-foreground transition-colors hover:text-primary",
|
|
1261
|
+
type: "button",
|
|
1262
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Le, { className: "h-3 w-3" }), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
1263
|
+
className: "truncate text-xs",
|
|
1264
|
+
children: l
|
|
1265
|
+
})]
|
|
1266
|
+
})]
|
|
1267
|
+
})
|
|
1268
|
+
}),
|
|
1269
|
+
/* @__PURE__ */ (0, W.jsx)(kt, {}),
|
|
1270
|
+
/* @__PURE__ */ (0, W.jsxs)(Dt, { children: [/* @__PURE__ */ (0, W.jsxs)(Z, {
|
|
1271
|
+
onClick: () => f?.current?.click(),
|
|
1272
|
+
children: [
|
|
1273
|
+
/* @__PURE__ */ (0, W.jsx)(Re, {}),
|
|
1274
|
+
" ",
|
|
1275
|
+
p("editor.actionsPanel.importJson")
|
|
1276
|
+
]
|
|
1277
|
+
}), /* @__PURE__ */ (0, W.jsxs)(Z, {
|
|
1278
|
+
onClick: _,
|
|
1279
|
+
children: [
|
|
1280
|
+
/* @__PURE__ */ (0, W.jsx)(Ne, {}),
|
|
1281
|
+
" ",
|
|
1282
|
+
p("editor.actionsPanel.exportJson")
|
|
1283
|
+
]
|
|
1284
|
+
})] }),
|
|
1285
|
+
/* @__PURE__ */ (0, W.jsx)(kt, {}),
|
|
1286
|
+
/* @__PURE__ */ (0, W.jsx)(Dt, { children: /* @__PURE__ */ (0, W.jsxs)(Z, {
|
|
1287
|
+
onClick: () => {
|
|
1288
|
+
a([]), o([]), V.success(p("editor.actionsPanel.clearSuccess"), { description: p("editor.actionsPanel.clearSuccessDesc") });
|
|
1289
|
+
},
|
|
1290
|
+
className: "text-destructive focus:text-destructive",
|
|
1291
|
+
children: [
|
|
1292
|
+
/* @__PURE__ */ (0, W.jsx)(Ye, { className: "text-destructive" }),
|
|
1293
|
+
" ",
|
|
1294
|
+
p("editor.actionsPanel.clear")
|
|
1295
|
+
]
|
|
1296
|
+
}) })
|
|
1297
|
+
]
|
|
1298
|
+
})] }),
|
|
1299
|
+
/* @__PURE__ */ (0, W.jsx)("input", {
|
|
1300
|
+
type: "file",
|
|
1301
|
+
accept: "application/json,.json",
|
|
1302
|
+
className: "hidden",
|
|
1303
|
+
ref: f,
|
|
1304
|
+
onChange: g
|
|
1305
|
+
})
|
|
1306
|
+
]
|
|
1307
|
+
});
|
|
1308
|
+
}, Qt = {
|
|
1309
|
+
ar: "ar",
|
|
1310
|
+
de: "de",
|
|
1311
|
+
en: "en",
|
|
1312
|
+
es: "es",
|
|
1313
|
+
fr: "fr",
|
|
1314
|
+
it: "it",
|
|
1315
|
+
pt: "pt"
|
|
1316
|
+
}, Q = ({ value: e = "en", onValueChange: t }) => /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
1317
|
+
value: e,
|
|
1318
|
+
onValueChange: t,
|
|
1319
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
1320
|
+
className: "uppercase",
|
|
1321
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: "" })
|
|
1322
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: /* @__PURE__ */ (0, W.jsx)(M, { children: Object.values(Qt).map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
|
|
1323
|
+
value: e,
|
|
1324
|
+
className: "uppercase",
|
|
1325
|
+
children: e
|
|
1326
|
+
}, e)) }) })]
|
|
1327
|
+
}), $ = () => {
|
|
1328
|
+
let e = Te(), t = P(() => e.filter(a), [e]), n = P(() => e.filter((e) => e.selected), [e]), r = P(() => e.find((e) => e.selected), [e]);
|
|
1329
|
+
return {
|
|
1330
|
+
groupNodes: t,
|
|
1331
|
+
hasSelectedNodes: n.length > 0,
|
|
1332
|
+
nodes: e,
|
|
1333
|
+
selectedNode: r,
|
|
1334
|
+
selectedNodes: n
|
|
1335
|
+
};
|
|
1336
|
+
}, $t = () => {
|
|
1337
|
+
let [e, t] = F("en"), { updateSelectedNodeData: n } = K(), { selectedNode: r } = $(), i = G(), { Field: a } = I({
|
|
1338
|
+
defaultValues: {
|
|
1339
|
+
label: r?.data?.label || { en: "" },
|
|
1340
|
+
targetId: r?.data?.targetId || ""
|
|
1341
|
+
},
|
|
1342
|
+
listeners: {
|
|
1343
|
+
onChange: ({ formApi: e }) => {
|
|
1344
|
+
e.handleSubmit().then();
|
|
1345
|
+
},
|
|
1346
|
+
onChangeDebounceMs: 150
|
|
1347
|
+
},
|
|
1348
|
+
onSubmit: ({ value: e }) => {
|
|
1349
|
+
n(e);
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
return /* @__PURE__ */ (0, W.jsx)("form", {
|
|
1353
|
+
onSubmit: (e) => {
|
|
1354
|
+
e.preventDefault(), e.stopPropagation();
|
|
1355
|
+
},
|
|
1356
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1357
|
+
className: "grid gap-6",
|
|
1358
|
+
children: [/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1359
|
+
className: "flex items-end gap-2",
|
|
1360
|
+
children: [/* @__PURE__ */ (0, W.jsx)(a, {
|
|
1361
|
+
name: "label",
|
|
1362
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
1363
|
+
className: "flex-1",
|
|
1364
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1365
|
+
htmlFor: t.name,
|
|
1366
|
+
children: i("editor.flowNodeForm.label")
|
|
1367
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
1368
|
+
id: t.name,
|
|
1369
|
+
name: t.name,
|
|
1370
|
+
value: t.state.value?.[e] || "",
|
|
1371
|
+
onBlur: t.handleBlur,
|
|
1372
|
+
onChange: ({ target: n }) => {
|
|
1373
|
+
t.handleChange({
|
|
1374
|
+
...t.state.value,
|
|
1375
|
+
[e]: n.value
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
})]
|
|
1379
|
+
})
|
|
1380
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
1381
|
+
value: e,
|
|
1382
|
+
onValueChange: t
|
|
1383
|
+
})]
|
|
1384
|
+
}), /* @__PURE__ */ (0, W.jsx)(a, {
|
|
1385
|
+
name: "targetId",
|
|
1386
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1387
|
+
/* @__PURE__ */ (0, W.jsxs)(u, {
|
|
1388
|
+
htmlFor: e.name,
|
|
1389
|
+
children: [i("editor.flowNodeForm.targetId"), " (Flow ID)"]
|
|
1390
|
+
}),
|
|
1391
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1392
|
+
id: e.name,
|
|
1393
|
+
name: e.name,
|
|
1394
|
+
value: e.state.value,
|
|
1395
|
+
onBlur: e.handleBlur,
|
|
1396
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1397
|
+
}),
|
|
1398
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: "Unique identifier of the target flow." })
|
|
1399
|
+
] })
|
|
1400
|
+
})]
|
|
1401
|
+
})
|
|
1402
|
+
});
|
|
1403
|
+
}, en = () => {
|
|
1404
|
+
let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = K(), { Field: i } = I({
|
|
1405
|
+
defaultValues: { label: n?.data?.label || { en: "" } },
|
|
1406
|
+
listeners: {
|
|
1407
|
+
onChange: ({ formApi: e }) => {
|
|
1408
|
+
e.handleSubmit().then();
|
|
1409
|
+
},
|
|
1410
|
+
onChangeDebounceMs: 150
|
|
1411
|
+
},
|
|
1412
|
+
onSubmit: ({ value: e }) => {
|
|
1413
|
+
r(e);
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
return /* @__PURE__ */ (0, W.jsx)("form", {
|
|
1417
|
+
onSubmit: (e) => {
|
|
1418
|
+
e.preventDefault(), e.stopPropagation();
|
|
1419
|
+
},
|
|
1420
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1421
|
+
className: "flex items-end gap-2",
|
|
1422
|
+
children: [/* @__PURE__ */ (0, W.jsx)(i, {
|
|
1423
|
+
name: "label",
|
|
1424
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
1425
|
+
className: "flex-1",
|
|
1426
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1427
|
+
htmlFor: t.name,
|
|
1428
|
+
children: "Label"
|
|
1429
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
1430
|
+
id: t.name,
|
|
1431
|
+
name: t.name,
|
|
1432
|
+
value: t.state.value?.[e] || "",
|
|
1433
|
+
onBlur: t.handleBlur,
|
|
1434
|
+
onChange: ({ target: n }) => {
|
|
1435
|
+
t.handleChange({
|
|
1436
|
+
...t.state.value,
|
|
1437
|
+
[e]: n.value
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
})]
|
|
1441
|
+
})
|
|
1442
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
1443
|
+
value: e,
|
|
1444
|
+
onValueChange: t
|
|
1445
|
+
})]
|
|
1446
|
+
})
|
|
1447
|
+
});
|
|
1448
|
+
}, tn = [
|
|
1449
|
+
"POST",
|
|
1450
|
+
"PUT",
|
|
1451
|
+
"PATCH"
|
|
1452
|
+
], nn = ({ value: e, onChange: t }) => {
|
|
1453
|
+
let { selectedNode: n } = $(), r = G(), i = ut(n?.id), { handleSubmit: a, Field: o, Subscribe: s } = I({
|
|
1454
|
+
defaultValues: {
|
|
1455
|
+
body: e?.body || "",
|
|
1456
|
+
fetchOnMount: e?.fetchOnMount ?? !e?.searchParam,
|
|
1457
|
+
headers: e?.headers || [],
|
|
1458
|
+
method: e?.method || "GET",
|
|
1459
|
+
responseMapping: e?.responseMapping || {
|
|
1460
|
+
labelField: "",
|
|
1461
|
+
valueField: ""
|
|
1462
|
+
},
|
|
1463
|
+
responsePath: e?.responsePath || "",
|
|
1464
|
+
searchParam: e?.searchParam || "",
|
|
1465
|
+
sendAllFormValues: !!e?.sendAllFormValues,
|
|
1466
|
+
showLoading: e?.showLoading !== !1,
|
|
1467
|
+
url: e?.url || ""
|
|
1468
|
+
},
|
|
1469
|
+
listeners: {
|
|
1470
|
+
onChange: ({ formApi: e }) => {
|
|
1471
|
+
e.handleSubmit().then();
|
|
1472
|
+
},
|
|
1473
|
+
onChangeDebounceMs: 150
|
|
1474
|
+
},
|
|
1475
|
+
onSubmit: ({ value: e }) => {
|
|
1476
|
+
t(e);
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
return /* @__PURE__ */ (0, W.jsx)("div", { children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1480
|
+
className: "grid gap-6",
|
|
1481
|
+
children: [
|
|
1482
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1483
|
+
name: "url",
|
|
1484
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1485
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1486
|
+
htmlFor: e.name,
|
|
1487
|
+
children: r("editor.httpConfigForm.apiUrl")
|
|
1488
|
+
}),
|
|
1489
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1490
|
+
className: "flex gap-2",
|
|
1491
|
+
children: [/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1492
|
+
id: e.name,
|
|
1493
|
+
name: e.name,
|
|
1494
|
+
value: e.state.value,
|
|
1495
|
+
onBlur: e.handleBlur,
|
|
1496
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1497
|
+
placeholder: r("editor.httpConfigForm.apiUrlPlaceholder"),
|
|
1498
|
+
className: "flex-1"
|
|
1499
|
+
}), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
1500
|
+
asChild: !0,
|
|
1501
|
+
children: /* @__PURE__ */ (0, W.jsx)(m, {
|
|
1502
|
+
type: "button",
|
|
1503
|
+
variant: "outline",
|
|
1504
|
+
size: "icon",
|
|
1505
|
+
children: /* @__PURE__ */ (0, W.jsx)(Ze, { className: "h-4 w-4" })
|
|
1506
|
+
})
|
|
1507
|
+
}), /* @__PURE__ */ (0, W.jsx)(X, {
|
|
1508
|
+
align: "end",
|
|
1509
|
+
children: i.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
1510
|
+
disabled: !0,
|
|
1511
|
+
children: r("editor.httpConfigForm.noFieldsAvailable")
|
|
1512
|
+
}) : i.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
1513
|
+
onClick: () => {
|
|
1514
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
1515
|
+
e.handleChange(r + n);
|
|
1516
|
+
},
|
|
1517
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1518
|
+
className: "flex flex-col",
|
|
1519
|
+
children: [/* @__PURE__ */ (0, W.jsx)("span", {
|
|
1520
|
+
className: "font-medium",
|
|
1521
|
+
children: t.label
|
|
1522
|
+
}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
1523
|
+
className: "text-muted-foreground text-xs",
|
|
1524
|
+
children: `{{${t.nodeId}}}`
|
|
1525
|
+
})]
|
|
1526
|
+
})
|
|
1527
|
+
}, t.nodeId))
|
|
1528
|
+
})] })]
|
|
1529
|
+
}),
|
|
1530
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: r("editor.httpConfigForm.apiUrlDesc") })
|
|
1531
|
+
] })
|
|
1532
|
+
}),
|
|
1533
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1534
|
+
name: "method",
|
|
1535
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1536
|
+
htmlFor: e.name,
|
|
1537
|
+
children: r("editor.httpConfigForm.httpMethod")
|
|
1538
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
1539
|
+
value: e.state.value,
|
|
1540
|
+
onValueChange: (t) => e.handleChange(t),
|
|
1541
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
1542
|
+
id: e.name,
|
|
1543
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: r("editor.httpConfigForm.selectMethod") })
|
|
1544
|
+
}), /* @__PURE__ */ (0, W.jsxs)(j, { children: [
|
|
1545
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1546
|
+
value: "GET",
|
|
1547
|
+
children: r("editor.httpConfigForm.methodGet")
|
|
1548
|
+
}),
|
|
1549
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1550
|
+
value: "POST",
|
|
1551
|
+
children: r("editor.httpConfigForm.methodPost")
|
|
1552
|
+
}),
|
|
1553
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1554
|
+
value: "PUT",
|
|
1555
|
+
children: r("editor.httpConfigForm.methodPut")
|
|
1556
|
+
}),
|
|
1557
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1558
|
+
value: "DELETE",
|
|
1559
|
+
children: r("editor.httpConfigForm.methodDelete")
|
|
1560
|
+
}),
|
|
1561
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1562
|
+
value: "PATCH",
|
|
1563
|
+
children: r("editor.httpConfigForm.methodPatch")
|
|
1564
|
+
})
|
|
1565
|
+
] })]
|
|
1566
|
+
})] })
|
|
1567
|
+
}),
|
|
1568
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1569
|
+
className: "space-y-4",
|
|
1570
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
1571
|
+
className: "font-semibold text-sm",
|
|
1572
|
+
children: r("editor.httpConfigForm.headers")
|
|
1573
|
+
}), /* @__PURE__ */ (0, W.jsx)(o, {
|
|
1574
|
+
name: "headers",
|
|
1575
|
+
mode: "array",
|
|
1576
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1577
|
+
className: "space-y-2",
|
|
1578
|
+
children: [e.state.value?.map((t, n) => {
|
|
1579
|
+
let i = `headers[${n}]`;
|
|
1580
|
+
return /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1581
|
+
className: "flex items-start gap-2",
|
|
1582
|
+
children: [
|
|
1583
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1584
|
+
name: `headers[${n}].key`,
|
|
1585
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
1586
|
+
placeholder: r("editor.httpConfigForm.headerName"),
|
|
1587
|
+
value: e.state.value || "",
|
|
1588
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1589
|
+
})
|
|
1590
|
+
}),
|
|
1591
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1592
|
+
name: `headers[${n}].value`,
|
|
1593
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
1594
|
+
placeholder: r("editor.httpConfigForm.headerValue"),
|
|
1595
|
+
value: e.state.value || "",
|
|
1596
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1597
|
+
})
|
|
1598
|
+
}),
|
|
1599
|
+
/* @__PURE__ */ (0, W.jsx)(m, {
|
|
1600
|
+
type: "button",
|
|
1601
|
+
variant: "ghost",
|
|
1602
|
+
size: "icon",
|
|
1603
|
+
onClick: () => {
|
|
1604
|
+
e.removeValue(n);
|
|
1605
|
+
},
|
|
1606
|
+
children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
|
|
1607
|
+
})
|
|
1608
|
+
]
|
|
1609
|
+
}, i);
|
|
1610
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
1611
|
+
type: "button",
|
|
1612
|
+
variant: "outline",
|
|
1613
|
+
size: "sm",
|
|
1614
|
+
onClick: () => {
|
|
1615
|
+
e.pushValue({
|
|
1616
|
+
key: "",
|
|
1617
|
+
value: ""
|
|
1618
|
+
});
|
|
1619
|
+
},
|
|
1620
|
+
children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), r("editor.httpConfigForm.addHeader")]
|
|
1621
|
+
})]
|
|
1622
|
+
})
|
|
1623
|
+
})]
|
|
1624
|
+
}),
|
|
1625
|
+
/* @__PURE__ */ (0, W.jsx)(s, {
|
|
1626
|
+
selector: (e) => ({
|
|
1627
|
+
method: e.values.method,
|
|
1628
|
+
sendAllFormValues: e.values.sendAllFormValues
|
|
1629
|
+
}),
|
|
1630
|
+
children: ({ method: e, sendAllFormValues: t }) => tn.includes(e || "") && /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1631
|
+
className: "space-y-4",
|
|
1632
|
+
children: [/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1633
|
+
name: "sendAllFormValues",
|
|
1634
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1635
|
+
className: "flex items-center space-x-2",
|
|
1636
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
1637
|
+
id: e.name,
|
|
1638
|
+
checked: e.state.value,
|
|
1639
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
1640
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
1641
|
+
htmlFor: e.name,
|
|
1642
|
+
children: r("editor.httpConfigForm.sendAllFormValues")
|
|
1643
|
+
})]
|
|
1644
|
+
})
|
|
1645
|
+
}), /* @__PURE__ */ (0, W.jsx)(o, {
|
|
1646
|
+
name: "body",
|
|
1647
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1648
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1649
|
+
className: "mb-2 flex items-center justify-between",
|
|
1650
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1651
|
+
htmlFor: e.name,
|
|
1652
|
+
children: r("editor.httpConfigForm.requestBody")
|
|
1653
|
+
}), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
1654
|
+
asChild: !0,
|
|
1655
|
+
children: /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
1656
|
+
type: "button",
|
|
1657
|
+
variant: "ghost",
|
|
1658
|
+
size: "sm",
|
|
1659
|
+
disabled: t,
|
|
1660
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Ze, { className: "mr-2 h-4 w-4" }), r("editor.httpConfigForm.insertVariable")]
|
|
1661
|
+
})
|
|
1662
|
+
}), /* @__PURE__ */ (0, W.jsx)(X, {
|
|
1663
|
+
align: "end",
|
|
1664
|
+
children: i.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
1665
|
+
disabled: !0,
|
|
1666
|
+
children: r("editor.httpConfigForm.noFieldsAvailable")
|
|
1667
|
+
}) : i.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
1668
|
+
onClick: () => {
|
|
1669
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
1670
|
+
e.handleChange(r + n), a().then();
|
|
1671
|
+
},
|
|
1672
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1673
|
+
className: "flex flex-col",
|
|
1674
|
+
children: [/* @__PURE__ */ (0, W.jsx)("span", {
|
|
1675
|
+
className: "font-medium",
|
|
1676
|
+
children: t.label
|
|
1677
|
+
}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
1678
|
+
className: "text-muted-foreground text-xs",
|
|
1679
|
+
children: `{{${t.nodeId}}}`
|
|
1680
|
+
})]
|
|
1681
|
+
})
|
|
1682
|
+
}, t.nodeId))
|
|
1683
|
+
})] })]
|
|
1684
|
+
}),
|
|
1685
|
+
/* @__PURE__ */ (0, W.jsx)(D, {
|
|
1686
|
+
id: e.name,
|
|
1687
|
+
name: e.name,
|
|
1688
|
+
value: e.state.value,
|
|
1689
|
+
onBlur: e.handleBlur,
|
|
1690
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1691
|
+
placeholder: r("editor.httpConfigForm.requestBodyPlaceholder"),
|
|
1692
|
+
rows: 4,
|
|
1693
|
+
disabled: t
|
|
1694
|
+
}),
|
|
1695
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: r(t ? "editor.httpConfigForm.sendAllFormValuesDesc" : "editor.httpConfigForm.requestBodyDesc") })
|
|
1696
|
+
] })
|
|
1697
|
+
})]
|
|
1698
|
+
})
|
|
1699
|
+
}),
|
|
1700
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1701
|
+
className: "space-y-4",
|
|
1702
|
+
children: [
|
|
1703
|
+
/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
1704
|
+
className: "font-semibold text-sm",
|
|
1705
|
+
children: r("editor.httpConfigForm.responseConfiguration")
|
|
1706
|
+
}),
|
|
1707
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1708
|
+
name: "responsePath",
|
|
1709
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1710
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1711
|
+
htmlFor: e.name,
|
|
1712
|
+
children: r("editor.httpConfigForm.responsePath")
|
|
1713
|
+
}),
|
|
1714
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1715
|
+
id: e.name,
|
|
1716
|
+
name: e.name,
|
|
1717
|
+
value: e.state.value,
|
|
1718
|
+
onBlur: e.handleBlur,
|
|
1719
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1720
|
+
placeholder: r("editor.httpConfigForm.responsePathPlaceholder")
|
|
1721
|
+
}),
|
|
1722
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: r("editor.httpConfigForm.responsePathDesc") })
|
|
1723
|
+
] })
|
|
1724
|
+
}),
|
|
1725
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1726
|
+
className: "space-y-4",
|
|
1727
|
+
children: [
|
|
1728
|
+
/* @__PURE__ */ (0, W.jsx)("h5", {
|
|
1729
|
+
className: "font-medium text-sm",
|
|
1730
|
+
children: r("editor.httpConfigForm.mapToOptions")
|
|
1731
|
+
}),
|
|
1732
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1733
|
+
name: "responseMapping.valueField",
|
|
1734
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1735
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1736
|
+
htmlFor: e.name,
|
|
1737
|
+
children: r("editor.httpConfigForm.valueField")
|
|
1738
|
+
}),
|
|
1739
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1740
|
+
id: e.name,
|
|
1741
|
+
name: e.name,
|
|
1742
|
+
value: e.state.value,
|
|
1743
|
+
onBlur: e.handleBlur,
|
|
1744
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1745
|
+
placeholder: r("editor.httpConfigForm.valueFieldPlaceholder")
|
|
1746
|
+
}),
|
|
1747
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: r("editor.httpConfigForm.valueFieldDesc") })
|
|
1748
|
+
] })
|
|
1749
|
+
}),
|
|
1750
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1751
|
+
name: "responseMapping.labelField",
|
|
1752
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1753
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1754
|
+
htmlFor: e.name,
|
|
1755
|
+
children: r("editor.httpConfigForm.labelField")
|
|
1756
|
+
}),
|
|
1757
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1758
|
+
id: e.name,
|
|
1759
|
+
name: e.name,
|
|
1760
|
+
value: e.state.value,
|
|
1761
|
+
onBlur: e.handleBlur,
|
|
1762
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1763
|
+
placeholder: r("editor.httpConfigForm.labelFieldPlaceholder")
|
|
1764
|
+
}),
|
|
1765
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: r("editor.httpConfigForm.labelFieldDesc") })
|
|
1766
|
+
] })
|
|
1767
|
+
})
|
|
1768
|
+
]
|
|
1769
|
+
}),
|
|
1770
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1771
|
+
name: "searchParam",
|
|
1772
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1773
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1774
|
+
htmlFor: e.name,
|
|
1775
|
+
children: r("editor.httpConfigForm.searchParameter")
|
|
1776
|
+
}),
|
|
1777
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1778
|
+
id: e.name,
|
|
1779
|
+
name: e.name,
|
|
1780
|
+
value: e.state.value,
|
|
1781
|
+
onBlur: e.handleBlur,
|
|
1782
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1783
|
+
placeholder: r("editor.httpConfigForm.searchParameterPlaceholder")
|
|
1784
|
+
}),
|
|
1785
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: r("editor.httpConfigForm.searchParameterDesc") })
|
|
1786
|
+
] })
|
|
1787
|
+
})
|
|
1788
|
+
]
|
|
1789
|
+
}),
|
|
1790
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1791
|
+
className: "space-y-4",
|
|
1792
|
+
children: [
|
|
1793
|
+
/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
1794
|
+
className: "font-semibold text-sm",
|
|
1795
|
+
children: r("editor.httpConfigForm.behavior")
|
|
1796
|
+
}),
|
|
1797
|
+
/* @__PURE__ */ (0, W.jsx)(s, {
|
|
1798
|
+
selector: (e) => e.values.searchParam,
|
|
1799
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(o, {
|
|
1800
|
+
name: "fetchOnMount",
|
|
1801
|
+
children: (t) => {
|
|
1802
|
+
let n = !!e?.trim(), i = n ? t.state.value : !0;
|
|
1803
|
+
return !n && t.state.value !== !0 && t.handleChange(!0), /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1804
|
+
className: "flex items-center space-x-2",
|
|
1805
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
1806
|
+
id: t.name,
|
|
1807
|
+
checked: i,
|
|
1808
|
+
disabled: !n,
|
|
1809
|
+
onCheckedChange: (e) => t.handleChange(e)
|
|
1810
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
1811
|
+
htmlFor: t.name,
|
|
1812
|
+
className: n ? "" : "text-muted-foreground",
|
|
1813
|
+
children: r("editor.httpConfigForm.fetchOnMount")
|
|
1814
|
+
})]
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
})
|
|
1818
|
+
}),
|
|
1819
|
+
/* @__PURE__ */ (0, W.jsx)(o, {
|
|
1820
|
+
name: "showLoading",
|
|
1821
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1822
|
+
className: "flex items-center space-x-2",
|
|
1823
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
1824
|
+
id: e.name,
|
|
1825
|
+
checked: e.state.value,
|
|
1826
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
1827
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
1828
|
+
htmlFor: e.name,
|
|
1829
|
+
children: r("editor.httpConfigForm.showLoadingState")
|
|
1830
|
+
})]
|
|
1831
|
+
})
|
|
1832
|
+
})
|
|
1833
|
+
]
|
|
1834
|
+
})
|
|
1835
|
+
]
|
|
1836
|
+
}) });
|
|
1837
|
+
}, rn = [
|
|
1838
|
+
"POST",
|
|
1839
|
+
"PUT",
|
|
1840
|
+
"PATCH"
|
|
1841
|
+
], an = ({ value: e, onChange: t }) => {
|
|
1842
|
+
let [n, r] = F("en"), { selectedNode: i } = $(), a = G(), o = ut(i?.id), { handleSubmit: s, Field: c, Subscribe: d } = I({
|
|
1843
|
+
defaultValues: {
|
|
1844
|
+
body: e?.body || "",
|
|
1845
|
+
errorMessage: e?.errorMessage || { en: "" },
|
|
1846
|
+
headers: e?.headers || [],
|
|
1847
|
+
method: e?.method || "POST",
|
|
1848
|
+
redirectUrl: e?.redirectUrl || "",
|
|
1849
|
+
sendAllFormValues: !!e?.sendAllFormValues,
|
|
1850
|
+
showLoading: e?.showLoading !== !1,
|
|
1851
|
+
successMessage: e?.successMessage || { en: "" },
|
|
1852
|
+
url: e?.url || ""
|
|
1853
|
+
},
|
|
1854
|
+
listeners: {
|
|
1855
|
+
onChange: ({ formApi: e }) => {
|
|
1856
|
+
e.handleSubmit().then();
|
|
1857
|
+
},
|
|
1858
|
+
onChangeDebounceMs: 150
|
|
1859
|
+
},
|
|
1860
|
+
onSubmit: ({ value: e }) => {
|
|
1861
|
+
t(e);
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
return /* @__PURE__ */ (0, W.jsx)("div", { children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1865
|
+
className: "grid gap-6",
|
|
1866
|
+
children: [
|
|
1867
|
+
/* @__PURE__ */ (0, W.jsx)(c, {
|
|
1868
|
+
name: "url",
|
|
1869
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
1870
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1871
|
+
htmlFor: e.name,
|
|
1872
|
+
children: a("editor.submitConfigForm.apiUrl")
|
|
1873
|
+
}),
|
|
1874
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1875
|
+
className: "flex gap-2",
|
|
1876
|
+
children: [/* @__PURE__ */ (0, W.jsx)(h, {
|
|
1877
|
+
id: e.name,
|
|
1878
|
+
name: e.name,
|
|
1879
|
+
value: e.state.value,
|
|
1880
|
+
onBlur: e.handleBlur,
|
|
1881
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
1882
|
+
placeholder: a("editor.submitConfigForm.apiUrlPlaceholder"),
|
|
1883
|
+
className: "flex-1"
|
|
1884
|
+
}), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
1885
|
+
asChild: !0,
|
|
1886
|
+
children: /* @__PURE__ */ (0, W.jsx)(m, {
|
|
1887
|
+
type: "button",
|
|
1888
|
+
variant: "outline",
|
|
1889
|
+
size: "icon",
|
|
1890
|
+
children: /* @__PURE__ */ (0, W.jsx)(Ze, { className: "h-4 w-4" })
|
|
1891
|
+
})
|
|
1892
|
+
}), /* @__PURE__ */ (0, W.jsx)(X, {
|
|
1893
|
+
align: "end",
|
|
1894
|
+
children: o.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
1895
|
+
disabled: !0,
|
|
1896
|
+
children: a("editor.submitConfigForm.noFieldsAvailable")
|
|
1897
|
+
}) : o.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
1898
|
+
onClick: () => {
|
|
1899
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
1900
|
+
e.handleChange(r + n);
|
|
1901
|
+
},
|
|
1902
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1903
|
+
className: "flex flex-col",
|
|
1904
|
+
children: [/* @__PURE__ */ (0, W.jsx)("span", {
|
|
1905
|
+
className: "font-medium",
|
|
1906
|
+
children: t.label
|
|
1907
|
+
}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
1908
|
+
className: "text-muted-foreground text-xs",
|
|
1909
|
+
children: `{{${t.nodeId}}}`
|
|
1910
|
+
})]
|
|
1911
|
+
})
|
|
1912
|
+
}, t.nodeId))
|
|
1913
|
+
})] })]
|
|
1914
|
+
}),
|
|
1915
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: a("editor.submitConfigForm.apiUrlDesc") })
|
|
1916
|
+
] })
|
|
1917
|
+
}),
|
|
1918
|
+
/* @__PURE__ */ (0, W.jsx)(c, {
|
|
1919
|
+
name: "method",
|
|
1920
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
1921
|
+
htmlFor: e.name,
|
|
1922
|
+
children: a("editor.submitConfigForm.httpMethod")
|
|
1923
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
1924
|
+
value: e.state.value,
|
|
1925
|
+
onValueChange: (t) => e.handleChange(t),
|
|
1926
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
1927
|
+
id: e.name,
|
|
1928
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: a("editor.submitConfigForm.selectMethod") })
|
|
1929
|
+
}), /* @__PURE__ */ (0, W.jsxs)(j, { children: [
|
|
1930
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1931
|
+
value: "POST",
|
|
1932
|
+
children: a("editor.submitConfigForm.methodPost")
|
|
1933
|
+
}),
|
|
1934
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1935
|
+
value: "PUT",
|
|
1936
|
+
children: a("editor.submitConfigForm.methodPut")
|
|
1937
|
+
}),
|
|
1938
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1939
|
+
value: "DELETE",
|
|
1940
|
+
children: a("editor.submitConfigForm.methodDelete")
|
|
1941
|
+
}),
|
|
1942
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
1943
|
+
value: "PATCH",
|
|
1944
|
+
children: a("editor.submitConfigForm.methodPatch")
|
|
1945
|
+
})
|
|
1946
|
+
] })]
|
|
1947
|
+
})] })
|
|
1948
|
+
}),
|
|
1949
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1950
|
+
className: "space-y-4",
|
|
1951
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
1952
|
+
className: "font-semibold text-sm",
|
|
1953
|
+
children: a("editor.submitConfigForm.headers")
|
|
1954
|
+
}), /* @__PURE__ */ (0, W.jsx)(c, {
|
|
1955
|
+
name: "headers",
|
|
1956
|
+
mode: "array",
|
|
1957
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1958
|
+
className: "space-y-2",
|
|
1959
|
+
children: [e.state.value?.map((t, n) => {
|
|
1960
|
+
let r = `headers[${n}]`;
|
|
1961
|
+
return /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
1962
|
+
className: "flex items-start gap-2",
|
|
1963
|
+
children: [
|
|
1964
|
+
/* @__PURE__ */ (0, W.jsx)(c, {
|
|
1965
|
+
name: `headers[${n}].key`,
|
|
1966
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
1967
|
+
placeholder: a("editor.submitConfigForm.headerName"),
|
|
1968
|
+
value: e.state.value || "",
|
|
1969
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1970
|
+
})
|
|
1971
|
+
}),
|
|
1972
|
+
/* @__PURE__ */ (0, W.jsx)(c, {
|
|
1973
|
+
name: `headers[${n}].value`,
|
|
1974
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
1975
|
+
placeholder: a("editor.submitConfigForm.headerValue"),
|
|
1976
|
+
value: e.state.value || "",
|
|
1977
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
1978
|
+
})
|
|
1979
|
+
}),
|
|
1980
|
+
/* @__PURE__ */ (0, W.jsx)(m, {
|
|
1981
|
+
type: "button",
|
|
1982
|
+
variant: "ghost",
|
|
1983
|
+
size: "icon",
|
|
1984
|
+
onClick: () => {
|
|
1985
|
+
e.removeValue(n);
|
|
1986
|
+
},
|
|
1987
|
+
children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
|
|
1988
|
+
})
|
|
1989
|
+
]
|
|
1990
|
+
}, r);
|
|
1991
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
1992
|
+
type: "button",
|
|
1993
|
+
variant: "outline",
|
|
1994
|
+
size: "sm",
|
|
1995
|
+
onClick: () => {
|
|
1996
|
+
e.pushValue({
|
|
1997
|
+
key: "",
|
|
1998
|
+
value: ""
|
|
1999
|
+
});
|
|
2000
|
+
},
|
|
2001
|
+
children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), a("editor.submitConfigForm.addHeader")]
|
|
2002
|
+
})]
|
|
2003
|
+
})
|
|
2004
|
+
})]
|
|
2005
|
+
}),
|
|
2006
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2007
|
+
selector: (e) => ({
|
|
2008
|
+
method: e.values.method,
|
|
2009
|
+
sendAllFormValues: e.values.sendAllFormValues
|
|
2010
|
+
}),
|
|
2011
|
+
children: ({ method: e, sendAllFormValues: t }) => rn.includes(e || "") && /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2012
|
+
className: "space-y-4",
|
|
2013
|
+
children: [/* @__PURE__ */ (0, W.jsx)(c, {
|
|
2014
|
+
name: "sendAllFormValues",
|
|
2015
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2016
|
+
className: "flex items-center space-x-2",
|
|
2017
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2018
|
+
id: e.name,
|
|
2019
|
+
checked: e.state.value,
|
|
2020
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2021
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2022
|
+
htmlFor: e.name,
|
|
2023
|
+
children: a("editor.submitConfigForm.sendAllFormValues")
|
|
2024
|
+
})]
|
|
2025
|
+
})
|
|
2026
|
+
}), /* @__PURE__ */ (0, W.jsx)(c, {
|
|
2027
|
+
name: "body",
|
|
2028
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
2029
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2030
|
+
className: "mb-2 flex items-center justify-between",
|
|
2031
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2032
|
+
htmlFor: e.name,
|
|
2033
|
+
children: a("editor.submitConfigForm.requestBody")
|
|
2034
|
+
}), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
|
|
2035
|
+
asChild: !0,
|
|
2036
|
+
children: /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2037
|
+
type: "button",
|
|
2038
|
+
variant: "ghost",
|
|
2039
|
+
size: "sm",
|
|
2040
|
+
disabled: t,
|
|
2041
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Ze, { className: "mr-2 h-4 w-4" }), a("editor.submitConfigForm.insertVariable")]
|
|
2042
|
+
})
|
|
2043
|
+
}), /* @__PURE__ */ (0, W.jsx)(X, {
|
|
2044
|
+
align: "end",
|
|
2045
|
+
children: o.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
2046
|
+
disabled: !0,
|
|
2047
|
+
children: a("editor.submitConfigForm.noFieldsAvailable")
|
|
2048
|
+
}) : o.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
|
|
2049
|
+
onClick: () => {
|
|
2050
|
+
let n = `{{${t.nodeId}}}`, r = e.state.value || "";
|
|
2051
|
+
e.handleChange(r + n), s().then();
|
|
2052
|
+
},
|
|
2053
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2054
|
+
className: "flex flex-col",
|
|
2055
|
+
children: [/* @__PURE__ */ (0, W.jsx)("span", {
|
|
2056
|
+
className: "font-medium",
|
|
2057
|
+
children: t.label
|
|
2058
|
+
}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
2059
|
+
className: "text-muted-foreground text-xs",
|
|
2060
|
+
children: `{{${t.nodeId}}}`
|
|
2061
|
+
})]
|
|
2062
|
+
})
|
|
2063
|
+
}, t.nodeId))
|
|
2064
|
+
})] })]
|
|
2065
|
+
}),
|
|
2066
|
+
/* @__PURE__ */ (0, W.jsx)(D, {
|
|
2067
|
+
id: e.name,
|
|
2068
|
+
name: e.name,
|
|
2069
|
+
value: e.state.value,
|
|
2070
|
+
onBlur: e.handleBlur,
|
|
2071
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2072
|
+
placeholder: a("editor.submitConfigForm.requestBodyPlaceholder"),
|
|
2073
|
+
rows: 4,
|
|
2074
|
+
disabled: t
|
|
2075
|
+
}),
|
|
2076
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: a(t ? "editor.submitConfigForm.sendAllFormValuesDesc" : "editor.submitConfigForm.requestBodyDesc") })
|
|
2077
|
+
] })
|
|
2078
|
+
})]
|
|
2079
|
+
})
|
|
2080
|
+
}),
|
|
2081
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2082
|
+
className: "space-y-4",
|
|
2083
|
+
children: [
|
|
2084
|
+
/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2085
|
+
className: "font-semibold text-sm",
|
|
2086
|
+
children: a("editor.submitConfigForm.postSubmission")
|
|
2087
|
+
}),
|
|
2088
|
+
/* @__PURE__ */ (0, W.jsx)(c, {
|
|
2089
|
+
name: "redirectUrl",
|
|
2090
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
2091
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2092
|
+
htmlFor: e.name,
|
|
2093
|
+
children: a("editor.submitConfigForm.redirectUrl")
|
|
2094
|
+
}),
|
|
2095
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
2096
|
+
id: e.name,
|
|
2097
|
+
name: e.name,
|
|
2098
|
+
value: e.state.value,
|
|
2099
|
+
onBlur: e.handleBlur,
|
|
2100
|
+
onChange: ({ target: t }) => e.handleChange(t.value),
|
|
2101
|
+
placeholder: a("editor.submitConfigForm.redirectUrlPlaceholder")
|
|
2102
|
+
}),
|
|
2103
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: a("editor.submitConfigForm.redirectUrlDesc") })
|
|
2104
|
+
] })
|
|
2105
|
+
}),
|
|
2106
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2107
|
+
className: "flex items-center gap-2",
|
|
2108
|
+
children: [/* @__PURE__ */ (0, W.jsx)(c, {
|
|
2109
|
+
name: "successMessage",
|
|
2110
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
2111
|
+
className: "flex-1",
|
|
2112
|
+
children: [
|
|
2113
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2114
|
+
htmlFor: e.name,
|
|
2115
|
+
children: a("editor.submitConfigForm.successMessage")
|
|
2116
|
+
}),
|
|
2117
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
2118
|
+
id: e.name,
|
|
2119
|
+
name: e.name,
|
|
2120
|
+
value: e.state.value?.[n] || "",
|
|
2121
|
+
onBlur: e.handleBlur,
|
|
2122
|
+
onChange: ({ target: t }) => {
|
|
2123
|
+
e.handleChange({
|
|
2124
|
+
...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
|
|
2125
|
+
[n]: t.value
|
|
2126
|
+
});
|
|
2127
|
+
},
|
|
2128
|
+
placeholder: a("editor.submitConfigForm.successMessagePlaceholder")
|
|
2129
|
+
}),
|
|
2130
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: a("editor.submitConfigForm.successMessageDesc") })
|
|
2131
|
+
]
|
|
2132
|
+
})
|
|
2133
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
2134
|
+
value: n,
|
|
2135
|
+
onValueChange: r
|
|
2136
|
+
})]
|
|
2137
|
+
}),
|
|
2138
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2139
|
+
className: "flex items-center gap-2",
|
|
2140
|
+
children: [/* @__PURE__ */ (0, W.jsx)(c, {
|
|
2141
|
+
name: "errorMessage",
|
|
2142
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
2143
|
+
className: "flex-1",
|
|
2144
|
+
children: [
|
|
2145
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2146
|
+
htmlFor: e.name,
|
|
2147
|
+
children: a("editor.submitConfigForm.errorMessage")
|
|
2148
|
+
}),
|
|
2149
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
2150
|
+
id: e.name,
|
|
2151
|
+
name: e.name,
|
|
2152
|
+
value: e.state.value?.[n] || "",
|
|
2153
|
+
onBlur: e.handleBlur,
|
|
2154
|
+
onChange: ({ target: t }) => {
|
|
2155
|
+
e.handleChange({
|
|
2156
|
+
...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
|
|
2157
|
+
[n]: t.value
|
|
2158
|
+
});
|
|
2159
|
+
},
|
|
2160
|
+
placeholder: a("editor.submitConfigForm.errorMessagePlaceholder")
|
|
2161
|
+
}),
|
|
2162
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: a("editor.submitConfigForm.errorMessageDesc") })
|
|
2163
|
+
]
|
|
2164
|
+
})
|
|
2165
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
2166
|
+
value: n,
|
|
2167
|
+
onValueChange: r
|
|
2168
|
+
})]
|
|
2169
|
+
})
|
|
2170
|
+
]
|
|
2171
|
+
}),
|
|
2172
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2173
|
+
className: "space-y-4",
|
|
2174
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2175
|
+
className: "font-semibold text-sm",
|
|
2176
|
+
children: a("editor.submitConfigForm.behavior")
|
|
2177
|
+
}), /* @__PURE__ */ (0, W.jsx)(c, {
|
|
2178
|
+
name: "showLoading",
|
|
2179
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2180
|
+
className: "flex items-center space-x-2",
|
|
2181
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2182
|
+
id: e.name,
|
|
2183
|
+
checked: e.state.value,
|
|
2184
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2185
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2186
|
+
htmlFor: e.name,
|
|
2187
|
+
children: a("editor.submitConfigForm.showLoadingState")
|
|
2188
|
+
})]
|
|
2189
|
+
})
|
|
2190
|
+
})]
|
|
2191
|
+
})
|
|
2192
|
+
]
|
|
2193
|
+
}) });
|
|
2194
|
+
}, on = ({ 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: p = !0 }) => {
|
|
2195
|
+
let [h, g] = F(!1), [_, y] = F(""), x = (e) => e ?? "", S = (e) => e.trim().toLowerCase(), C = x(n), ee = n !== null && n !== "", te = ee ? e.find((e) => x(e.value) === C) : void 0, w = S(_), T = p && w !== "" && !e.some((e) => S(e.label) === w || S(e.value ?? "") === w), E = (e) => {
|
|
2196
|
+
e === C ? u && r?.("") : r?.(e), g(!1), y("");
|
|
2197
|
+
}, D = () => {
|
|
2198
|
+
_.trim() && (r?.(_.trim()), g(!1), y(""));
|
|
2199
|
+
}, O = () => {
|
|
2200
|
+
r?.(""), g(!1), y("");
|
|
2201
|
+
};
|
|
2202
|
+
return /* @__PURE__ */ (0, W.jsxs)(ce, {
|
|
2203
|
+
open: h,
|
|
2204
|
+
onOpenChange: g,
|
|
2205
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2206
|
+
asChild: !0,
|
|
2207
|
+
id: t,
|
|
2208
|
+
children: /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2209
|
+
type: "button",
|
|
2210
|
+
variant: "outline",
|
|
2211
|
+
role: "combobox",
|
|
2212
|
+
"aria-expanded": h,
|
|
2213
|
+
className: f("w-full justify-between font-normal", l),
|
|
2214
|
+
children: [/* @__PURE__ */ (0, W.jsx)("span", {
|
|
2215
|
+
className: "truncate",
|
|
2216
|
+
children: ee && te ? te.label : i
|
|
2217
|
+
}), /* @__PURE__ */ (0, W.jsx)(L, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
|
|
2218
|
+
})
|
|
2219
|
+
}), /* @__PURE__ */ (0, W.jsx)(v, {
|
|
2220
|
+
className: "w-full p-0",
|
|
2221
|
+
align: "start",
|
|
2222
|
+
children: /* @__PURE__ */ (0, W.jsxs)(k, {
|
|
2223
|
+
shouldFilter: !1,
|
|
2224
|
+
children: [/* @__PURE__ */ (0, W.jsx)(b, {
|
|
2225
|
+
placeholder: a,
|
|
2226
|
+
value: _,
|
|
2227
|
+
onValueChange: y
|
|
2228
|
+
}), /* @__PURE__ */ (0, W.jsxs)(ae, { children: [
|
|
2229
|
+
/* @__PURE__ */ (0, W.jsx)(A, { children: c }),
|
|
2230
|
+
u && ee && /* @__PURE__ */ (0, W.jsx)(ne, { children: /* @__PURE__ */ (0, W.jsxs)(re, {
|
|
2231
|
+
value: "__clear__",
|
|
2232
|
+
onSelect: O,
|
|
2233
|
+
className: "mt-1 text-muted-foreground",
|
|
2234
|
+
children: [/* @__PURE__ */ (0, W.jsx)(z, { className: "mr-2 h-4 w-4" }), s]
|
|
2235
|
+
}) }),
|
|
2236
|
+
/* @__PURE__ */ (0, W.jsxs)(ne, { children: [T && /* @__PURE__ */ (0, W.jsxs)(re, {
|
|
2237
|
+
value: `__create__${_}`,
|
|
2238
|
+
onSelect: D,
|
|
2239
|
+
className: "text-primary",
|
|
2240
|
+
children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), o(_)]
|
|
2241
|
+
}), e.filter((e) => {
|
|
2242
|
+
let t = _.toLowerCase();
|
|
2243
|
+
return e.label.toLowerCase().includes(t) || (e.value?.toLowerCase() ?? "").includes(t);
|
|
2244
|
+
}).map((e, t) => /* @__PURE__ */ (0, W.jsxs)(re, {
|
|
2245
|
+
value: e.label,
|
|
2246
|
+
onSelect: () => E(e?.value || ""),
|
|
2247
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Fe, {
|
|
2248
|
+
"aria-hidden": "true",
|
|
2249
|
+
className: f("mr-2 h-4 w-4", ee && x(e.value) === C ? "opacity-100" : "opacity-0")
|
|
2250
|
+
}), e.label]
|
|
2251
|
+
}, e.value ?? e.label ?? t))] })
|
|
2252
|
+
] })]
|
|
2253
|
+
})
|
|
2254
|
+
})]
|
|
2255
|
+
});
|
|
2256
|
+
}, sn = Object.entries({
|
|
2257
|
+
alphanumeric: "^[a-zA-Z0-9]+$",
|
|
2258
|
+
email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
|
|
2259
|
+
letters: "^[a-zA-Z]+$",
|
|
2260
|
+
number: "^[0-9]+$",
|
|
2261
|
+
url: "^https?:\\/\\/.+$"
|
|
2262
|
+
}).map(([e, t]) => ({
|
|
2263
|
+
label: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
|
|
2264
|
+
value: t
|
|
2265
|
+
})), cn = ({ id: e, value: t, onValueChange: n }) => /* @__PURE__ */ (0, W.jsx)(on, {
|
|
2266
|
+
id: e,
|
|
2267
|
+
options: P(() => t && !sn.some((e) => e.value === t) ? [...sn, {
|
|
2268
|
+
label: `Custom: ${t}`,
|
|
2269
|
+
value: t
|
|
2270
|
+
}] : sn, [t]),
|
|
2271
|
+
value: t,
|
|
2272
|
+
onValueChange: n,
|
|
2273
|
+
placeholder: "Select or create a pattern",
|
|
2274
|
+
searchPlaceholder: "Search patterns...",
|
|
2275
|
+
createLabel: (e) => `Use pattern: ${e}`
|
|
2276
|
+
}), ln = 400, un = .8, dn = (e) => new Promise((t, n) => {
|
|
2277
|
+
let r = new FileReader();
|
|
2278
|
+
r.onerror = () => n(/* @__PURE__ */ Error("read_failed")), r.onload = () => {
|
|
2279
|
+
let e = new Image();
|
|
2280
|
+
e.onload = () => t(e), e.onerror = () => n(/* @__PURE__ */ Error("decode_failed")), e.src = r.result;
|
|
2281
|
+
}, r.readAsDataURL(e);
|
|
2282
|
+
}), fn = async (e) => {
|
|
2283
|
+
if (!e.type.startsWith("image/")) throw Error("invalid_type");
|
|
2284
|
+
if (e.size > 5242880) throw Error("too_large");
|
|
2285
|
+
let t = await dn(e), n = Math.min(1, ln / Math.max(t.width, t.height)), r = document.createElement("canvas");
|
|
2286
|
+
r.width = Math.round(t.width * n), r.height = Math.round(t.height * n);
|
|
2287
|
+
let i = r.getContext("2d");
|
|
2288
|
+
if (!i) throw Error("canvas_unavailable");
|
|
2289
|
+
return i.drawImage(t, 0, 0, r.width, r.height), r.toDataURL("image/jpeg", un);
|
|
2290
|
+
}, pn = 400, mn = (e) => {
|
|
2291
|
+
if (!/^https?:\/\//i.test(e)) return !1;
|
|
2292
|
+
try {
|
|
2293
|
+
return !!new URL(e).hostname;
|
|
2294
|
+
} catch {
|
|
2295
|
+
return !1;
|
|
2296
|
+
}
|
|
2297
|
+
}, hn = ({ value: e, onChange: t }) => {
|
|
2298
|
+
let n = Me(null), r = Me(null), [i, a] = F(!1), [o, s] = F(e && /^https?:\/\//i.test(e) ? e : ""), c = G();
|
|
2299
|
+
Ae(() => {
|
|
2300
|
+
i || s(e && /^https?:\/\//i.test(e) ? e : "");
|
|
2301
|
+
}, [i, e]), Ae(() => () => {
|
|
2302
|
+
r.current && clearTimeout(r.current);
|
|
2303
|
+
}, []);
|
|
2304
|
+
let l = async (e) => {
|
|
2305
|
+
let r = e.target.files?.[0];
|
|
2306
|
+
if (r) try {
|
|
2307
|
+
t(await fn(r)), a(!1);
|
|
2308
|
+
} catch (e) {
|
|
2309
|
+
let t = e.message;
|
|
2310
|
+
t === "too_large" ? V.error(c("editor.inputNodeForm.optionImageTooLarge")) : t === "invalid_type" ? V.error(c("editor.inputNodeForm.optionImageInvalid")) : V.error(c("editor.inputNodeForm.optionImageError"));
|
|
2311
|
+
} finally {
|
|
2312
|
+
n.current && (n.current.value = "");
|
|
2313
|
+
}
|
|
2314
|
+
}, u = () => {
|
|
2315
|
+
let e = o.trim();
|
|
2316
|
+
e && (t(e), a(!1));
|
|
2317
|
+
}, f = (n) => {
|
|
2318
|
+
let i = n.target.value;
|
|
2319
|
+
s(i), r.current && clearTimeout(r.current);
|
|
2320
|
+
let a = i.trim();
|
|
2321
|
+
!mn(a) || a === e || (r.current = setTimeout(() => {
|
|
2322
|
+
t(a);
|
|
2323
|
+
}, pn));
|
|
2324
|
+
};
|
|
2325
|
+
return /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2326
|
+
className: "relative",
|
|
2327
|
+
children: [
|
|
2328
|
+
/* @__PURE__ */ (0, W.jsx)("input", {
|
|
2329
|
+
ref: n,
|
|
2330
|
+
type: "file",
|
|
2331
|
+
accept: "image/*",
|
|
2332
|
+
className: "hidden",
|
|
2333
|
+
onChange: l
|
|
2334
|
+
}),
|
|
2335
|
+
/* @__PURE__ */ (0, W.jsxs)(ce, {
|
|
2336
|
+
open: i,
|
|
2337
|
+
onOpenChange: a,
|
|
2338
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2339
|
+
asChild: !0,
|
|
2340
|
+
children: e ? /* @__PURE__ */ (0, W.jsx)("button", {
|
|
2341
|
+
type: "button",
|
|
2342
|
+
className: "h-9 w-9 cursor-pointer overflow-hidden rounded-md border border-input",
|
|
2343
|
+
"aria-label": c("editor.inputNodeForm.optionImageReplace"),
|
|
2344
|
+
children: /* @__PURE__ */ (0, W.jsx)("img", {
|
|
2345
|
+
src: e,
|
|
2346
|
+
alt: "",
|
|
2347
|
+
className: "h-full w-full object-cover"
|
|
2348
|
+
})
|
|
2349
|
+
}) : /* @__PURE__ */ (0, W.jsx)(m, {
|
|
2350
|
+
type: "button",
|
|
2351
|
+
variant: "outline",
|
|
2352
|
+
size: "icon",
|
|
2353
|
+
"aria-label": c("editor.inputNodeForm.optionImageAdd"),
|
|
2354
|
+
children: /* @__PURE__ */ (0, W.jsx)(Be, { className: "h-4 w-4" })
|
|
2355
|
+
})
|
|
2356
|
+
}), /* @__PURE__ */ (0, W.jsxs)(v, {
|
|
2357
|
+
align: "start",
|
|
2358
|
+
className: "w-64 space-y-3 p-3",
|
|
2359
|
+
children: [
|
|
2360
|
+
/* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2361
|
+
type: "button",
|
|
2362
|
+
variant: "outline",
|
|
2363
|
+
size: "sm",
|
|
2364
|
+
className: "w-full",
|
|
2365
|
+
onClick: () => n.current?.click(),
|
|
2366
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Xe, { className: "mr-2 h-4 w-4" }), c("editor.inputNodeForm.optionImageUpload")]
|
|
2367
|
+
}),
|
|
2368
|
+
/* @__PURE__ */ (0, W.jsx)(oe, {}),
|
|
2369
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2370
|
+
className: "flex items-center gap-2",
|
|
2371
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Ve, { className: "h-4 w-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2372
|
+
placeholder: c("editor.inputNodeForm.optionImageUrlPlaceholder"),
|
|
2373
|
+
value: o,
|
|
2374
|
+
onChange: f,
|
|
2375
|
+
onKeyDown: (e) => {
|
|
2376
|
+
e.key === "Enter" && (e.preventDefault(), u());
|
|
2377
|
+
},
|
|
2378
|
+
onBlur: u
|
|
2379
|
+
})]
|
|
2380
|
+
})
|
|
2381
|
+
]
|
|
2382
|
+
})]
|
|
2383
|
+
}),
|
|
2384
|
+
e && /* @__PURE__ */ (0, W.jsx)("button", {
|
|
2385
|
+
type: "button",
|
|
2386
|
+
onClick: (e) => {
|
|
2387
|
+
e.stopPropagation(), t("");
|
|
2388
|
+
},
|
|
2389
|
+
className: "-top-1 -right-1 absolute flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-destructive text-destructive-foreground",
|
|
2390
|
+
"aria-label": c("editor.inputNodeForm.optionImageRemove"),
|
|
2391
|
+
children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-3 w-3" })
|
|
2392
|
+
})
|
|
2393
|
+
]
|
|
2394
|
+
});
|
|
2395
|
+
}, gn = ({ value: e, onValueChange: t }) => {
|
|
2396
|
+
let n = G(), r = je();
|
|
2397
|
+
return /* @__PURE__ */ (0, W.jsxs)(M, { children: [/* @__PURE__ */ (0, W.jsx)(le, {
|
|
2398
|
+
htmlFor: r,
|
|
2399
|
+
children: n("editor.selectInputType.type")
|
|
2400
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
2401
|
+
value: e,
|
|
2402
|
+
onValueChange: t,
|
|
2403
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
2404
|
+
id: r,
|
|
2405
|
+
className: "w-full capitalize",
|
|
2406
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: "" })
|
|
2407
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: /* @__PURE__ */ (0, W.jsx)(M, { children: Object.values(_t).map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
|
|
2408
|
+
value: e,
|
|
2409
|
+
className: "capitalize",
|
|
2410
|
+
children: e
|
|
2411
|
+
}, e)) }) })]
|
|
2412
|
+
})] });
|
|
2413
|
+
};
|
|
2414
|
+
//#endregion
|
|
2415
|
+
//#region src/shared/components/ui/collapsible.tsx
|
|
2416
|
+
function _n({ ...e }) {
|
|
2417
|
+
return /* @__PURE__ */ (0, W.jsx)(at.Root, {
|
|
2418
|
+
"data-slot": "collapsible",
|
|
2419
|
+
...e
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
function vn({ ...e }) {
|
|
2423
|
+
return /* @__PURE__ */ (0, W.jsx)(at.CollapsibleTrigger, {
|
|
2424
|
+
"data-slot": "collapsible-trigger",
|
|
2425
|
+
...e
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
function yn({ ...e }) {
|
|
2429
|
+
return /* @__PURE__ */ (0, W.jsx)(at.CollapsibleContent, {
|
|
2430
|
+
"data-slot": "collapsible-content",
|
|
2431
|
+
...e
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
//#endregion
|
|
2435
|
+
//#region src/editor/features/TreegeEditor/forms/InputNodeForm.tsx
|
|
2436
|
+
var bn = () => {
|
|
2437
|
+
let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = K(), i = [
|
|
2438
|
+
"select",
|
|
2439
|
+
"radio",
|
|
2440
|
+
"autocomplete",
|
|
2441
|
+
"checkbox"
|
|
2442
|
+
].includes(n?.data?.type || ""), a = ut(n?.id), o = G(), s = n?.data?.type === "submit", { handleSubmit: c, Field: d } = I({
|
|
2443
|
+
defaultValues: {
|
|
2444
|
+
defaultValue: n?.data?.defaultValue,
|
|
2445
|
+
disablePast: n?.data?.disablePast,
|
|
2446
|
+
errorMessage: n?.data?.errorMessage || { en: "" },
|
|
2447
|
+
helperText: n?.data?.helperText || { en: "" },
|
|
2448
|
+
httpConfig: n?.data?.httpConfig,
|
|
2449
|
+
label: n?.data?.label || { en: "" },
|
|
2450
|
+
multiple: n?.data?.multiple,
|
|
2451
|
+
name: n?.data?.name || "",
|
|
2452
|
+
options: n?.data?.options || [],
|
|
2453
|
+
pattern: n?.data?.pattern || "",
|
|
2454
|
+
placeholder: n?.data?.placeholder || { en: "" },
|
|
2455
|
+
required: n?.data?.required,
|
|
2456
|
+
submitConfig: n?.data?.submitConfig,
|
|
2457
|
+
type: n?.data?.type || ""
|
|
2458
|
+
},
|
|
2459
|
+
listeners: {
|
|
2460
|
+
onChange: ({ formApi: e }) => {
|
|
2461
|
+
e.handleSubmit().then();
|
|
2462
|
+
},
|
|
2463
|
+
onChangeDebounceMs: 150
|
|
2464
|
+
},
|
|
2465
|
+
onSubmit: ({ value: e }) => {
|
|
2466
|
+
r(e);
|
|
2467
|
+
}
|
|
2468
|
+
});
|
|
2469
|
+
return /* @__PURE__ */ (0, W.jsx)("form", {
|
|
2470
|
+
onSubmit: (e) => {
|
|
2471
|
+
e.preventDefault(), e.stopPropagation();
|
|
2472
|
+
},
|
|
2473
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2474
|
+
className: "grid gap-6",
|
|
2475
|
+
children: [
|
|
2476
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2477
|
+
name: "type",
|
|
2478
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(T, { children: /* @__PURE__ */ (0, W.jsx)(gn, {
|
|
2479
|
+
value: e.state.value,
|
|
2480
|
+
onValueChange: (t) => e.handleChange(t)
|
|
2481
|
+
}) })
|
|
2482
|
+
}),
|
|
2483
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2484
|
+
className: "flex items-end gap-2",
|
|
2485
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2486
|
+
name: "label",
|
|
2487
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
2488
|
+
className: "flex-1",
|
|
2489
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2490
|
+
htmlFor: t.name,
|
|
2491
|
+
children: o("editor.inputNodeForm.label")
|
|
2492
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2493
|
+
autoFocus: !0,
|
|
2494
|
+
id: t.name,
|
|
2495
|
+
name: t.name,
|
|
2496
|
+
value: t.state.value?.[e] || "",
|
|
2497
|
+
onBlur: t.handleBlur,
|
|
2498
|
+
onChange: ({ target: n }) => {
|
|
2499
|
+
t.handleChange({
|
|
2500
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2501
|
+
[e]: n.value
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
})]
|
|
2505
|
+
})
|
|
2506
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
2507
|
+
value: e,
|
|
2508
|
+
onValueChange: t
|
|
2509
|
+
})]
|
|
2510
|
+
}),
|
|
2511
|
+
!s && n?.data?.type !== "file" && /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2512
|
+
className: "flex items-end gap-2",
|
|
2513
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2514
|
+
name: "placeholder",
|
|
2515
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
2516
|
+
className: "flex-1",
|
|
2517
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2518
|
+
htmlFor: t.name,
|
|
2519
|
+
children: o("editor.inputNodeForm.placeholder")
|
|
2520
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2521
|
+
id: t.name,
|
|
2522
|
+
name: t.name,
|
|
2523
|
+
value: t.state.value?.[e] || "",
|
|
2524
|
+
onBlur: t.handleBlur,
|
|
2525
|
+
onChange: ({ target: n }) => {
|
|
2526
|
+
t.handleChange({
|
|
2527
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2528
|
+
[e]: n.value
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
})]
|
|
2532
|
+
})
|
|
2533
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
2534
|
+
value: e,
|
|
2535
|
+
onValueChange: t
|
|
2536
|
+
})]
|
|
2537
|
+
}),
|
|
2538
|
+
!s && /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2539
|
+
className: "flex items-end gap-2",
|
|
2540
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2541
|
+
name: "helperText",
|
|
2542
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
2543
|
+
className: "flex-1",
|
|
2544
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2545
|
+
htmlFor: t.name,
|
|
2546
|
+
children: o("editor.inputNodeForm.helperText")
|
|
2547
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2548
|
+
id: t.name,
|
|
2549
|
+
name: t.name,
|
|
2550
|
+
value: t.state.value?.[e] || "",
|
|
2551
|
+
onBlur: t.handleBlur,
|
|
2552
|
+
onChange: ({ target: n }) => {
|
|
2553
|
+
t.handleChange({
|
|
2554
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2555
|
+
[e]: n.value
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
})]
|
|
2559
|
+
})
|
|
2560
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
2561
|
+
value: e,
|
|
2562
|
+
onValueChange: t
|
|
2563
|
+
})]
|
|
2564
|
+
}),
|
|
2565
|
+
n?.data?.type === "http" && /* @__PURE__ */ (0, W.jsxs)(_n, {
|
|
2566
|
+
defaultOpen: !0,
|
|
2567
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2568
|
+
children: [/* @__PURE__ */ (0, W.jsx)(vn, {
|
|
2569
|
+
asChild: !0,
|
|
2570
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2571
|
+
className: "flex items-center justify-between gap-4",
|
|
2572
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2573
|
+
className: "font-semibold text-sm",
|
|
2574
|
+
children: o("editor.inputNodeForm.httpConfiguration")
|
|
2575
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2576
|
+
variant: "ghost",
|
|
2577
|
+
size: "icon",
|
|
2578
|
+
className: "size-8",
|
|
2579
|
+
children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
2580
|
+
className: "sr-only",
|
|
2581
|
+
children: o("common.toggle")
|
|
2582
|
+
})]
|
|
2583
|
+
})]
|
|
2584
|
+
})
|
|
2585
|
+
}), /* @__PURE__ */ (0, W.jsx)(yn, {
|
|
2586
|
+
className: "flex flex-col gap-4",
|
|
2587
|
+
children: /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2588
|
+
name: "httpConfig",
|
|
2589
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(nn, {
|
|
2590
|
+
value: e.state.value,
|
|
2591
|
+
onChange: (t) => {
|
|
2592
|
+
e.handleChange(t), c().then();
|
|
2593
|
+
}
|
|
2594
|
+
})
|
|
2595
|
+
})
|
|
2596
|
+
})]
|
|
2597
|
+
}),
|
|
2598
|
+
s && /* @__PURE__ */ (0, W.jsxs)(_n, {
|
|
2599
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2600
|
+
children: [/* @__PURE__ */ (0, W.jsx)(vn, {
|
|
2601
|
+
asChild: !0,
|
|
2602
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2603
|
+
className: "flex items-center justify-between gap-4",
|
|
2604
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2605
|
+
className: "font-semibold text-sm",
|
|
2606
|
+
children: o("editor.inputNodeForm.submitConfiguration")
|
|
2607
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2608
|
+
variant: "ghost",
|
|
2609
|
+
size: "icon",
|
|
2610
|
+
className: "size-8",
|
|
2611
|
+
children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
2612
|
+
className: "sr-only",
|
|
2613
|
+
children: o("common.toggle")
|
|
2614
|
+
})]
|
|
2615
|
+
})]
|
|
2616
|
+
})
|
|
2617
|
+
}), /* @__PURE__ */ (0, W.jsx)(yn, {
|
|
2618
|
+
className: "flex flex-col gap-4",
|
|
2619
|
+
children: /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2620
|
+
name: "submitConfig",
|
|
2621
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(an, {
|
|
2622
|
+
value: e.state.value,
|
|
2623
|
+
onChange: (t) => {
|
|
2624
|
+
e.handleChange(t), c().then();
|
|
2625
|
+
}
|
|
2626
|
+
})
|
|
2627
|
+
})
|
|
2628
|
+
})]
|
|
2629
|
+
}),
|
|
2630
|
+
n?.data?.type === "file" && /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2631
|
+
name: "multiple",
|
|
2632
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2633
|
+
className: "flex items-center space-x-2",
|
|
2634
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2635
|
+
id: e.name,
|
|
2636
|
+
checked: e.state.value,
|
|
2637
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2638
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2639
|
+
htmlFor: e.name,
|
|
2640
|
+
children: o("editor.inputNodeForm.multipleFiles")
|
|
2641
|
+
})]
|
|
2642
|
+
})
|
|
2643
|
+
}),
|
|
2644
|
+
i && /* @__PURE__ */ (0, W.jsxs)(_n, {
|
|
2645
|
+
defaultOpen: !0,
|
|
2646
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2647
|
+
children: [/* @__PURE__ */ (0, W.jsx)(vn, {
|
|
2648
|
+
asChild: !0,
|
|
2649
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2650
|
+
className: "flex items-center justify-between gap-4",
|
|
2651
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2652
|
+
className: "font-semibold text-sm",
|
|
2653
|
+
children: o("editor.inputNodeForm.options")
|
|
2654
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2655
|
+
variant: "ghost",
|
|
2656
|
+
size: "icon",
|
|
2657
|
+
className: "size-8",
|
|
2658
|
+
children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
2659
|
+
className: "sr-only",
|
|
2660
|
+
children: o("common.toggle")
|
|
2661
|
+
})]
|
|
2662
|
+
})]
|
|
2663
|
+
})
|
|
2664
|
+
}), /* @__PURE__ */ (0, W.jsxs)(yn, {
|
|
2665
|
+
className: "flex flex-col gap-4",
|
|
2666
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2667
|
+
name: "options",
|
|
2668
|
+
mode: "array",
|
|
2669
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2670
|
+
className: "space-y-2",
|
|
2671
|
+
children: [t.state.value?.map((r, i) => {
|
|
2672
|
+
let a = `options[${i}]`;
|
|
2673
|
+
return /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2674
|
+
className: "flex items-start gap-2",
|
|
2675
|
+
children: [
|
|
2676
|
+
n?.data?.type === "radio" && /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2677
|
+
name: `options[${i}].image`,
|
|
2678
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(hn, {
|
|
2679
|
+
value: e.state.value,
|
|
2680
|
+
onChange: (t) => e.handleChange(t)
|
|
2681
|
+
})
|
|
2682
|
+
}),
|
|
2683
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2684
|
+
name: `options[${i}].label`,
|
|
2685
|
+
children: (t) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2686
|
+
placeholder: o("editor.inputNodeForm.optionLabel"),
|
|
2687
|
+
value: t.state.value?.[e] || "",
|
|
2688
|
+
onChange: ({ target: n }) => {
|
|
2689
|
+
t.handleChange({
|
|
2690
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2691
|
+
[e]: n.value
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
})
|
|
2695
|
+
}),
|
|
2696
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2697
|
+
name: `options[${i}].value`,
|
|
2698
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2699
|
+
placeholder: o("editor.inputNodeForm.optionValue"),
|
|
2700
|
+
value: e.state.value || "",
|
|
2701
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
2702
|
+
})
|
|
2703
|
+
}),
|
|
2704
|
+
/* @__PURE__ */ (0, W.jsx)(m, {
|
|
2705
|
+
type: "button",
|
|
2706
|
+
variant: "ghost",
|
|
2707
|
+
size: "icon",
|
|
2708
|
+
onClick: () => {
|
|
2709
|
+
t.removeValue(i), c().then();
|
|
2710
|
+
},
|
|
2711
|
+
children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
|
|
2712
|
+
})
|
|
2713
|
+
]
|
|
2714
|
+
}, a);
|
|
2715
|
+
}), /* @__PURE__ */ (0, W.jsx)(m, {
|
|
2716
|
+
type: "button",
|
|
2717
|
+
variant: "outline",
|
|
2718
|
+
size: "sm",
|
|
2719
|
+
onClick: () => {
|
|
2720
|
+
t.pushValue({
|
|
2721
|
+
label: { en: "" },
|
|
2722
|
+
value: ""
|
|
2723
|
+
}), c().then();
|
|
2724
|
+
},
|
|
2725
|
+
children: o("editor.inputNodeForm.addOption")
|
|
2726
|
+
})]
|
|
2727
|
+
})
|
|
2728
|
+
}), n?.data?.type === "select" && /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2729
|
+
name: "multiple",
|
|
2730
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2731
|
+
className: "flex items-center space-x-2",
|
|
2732
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2733
|
+
id: e.name,
|
|
2734
|
+
checked: e.state.value,
|
|
2735
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2736
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2737
|
+
htmlFor: e.name,
|
|
2738
|
+
children: o("editor.inputNodeForm.multipleSelection")
|
|
2739
|
+
})]
|
|
2740
|
+
})
|
|
2741
|
+
})]
|
|
2742
|
+
})]
|
|
2743
|
+
}),
|
|
2744
|
+
!s && /* @__PURE__ */ (0, W.jsxs)(_n, {
|
|
2745
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2746
|
+
children: [/* @__PURE__ */ (0, W.jsx)(vn, {
|
|
2747
|
+
asChild: !0,
|
|
2748
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2749
|
+
className: "flex items-center justify-between gap-4",
|
|
2750
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2751
|
+
className: "font-semibold text-sm",
|
|
2752
|
+
children: o("editor.inputNodeForm.validation")
|
|
2753
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2754
|
+
variant: "ghost",
|
|
2755
|
+
size: "icon",
|
|
2756
|
+
className: "size-8",
|
|
2757
|
+
children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
2758
|
+
className: "sr-only",
|
|
2759
|
+
children: o("common.toggle")
|
|
2760
|
+
})]
|
|
2761
|
+
})]
|
|
2762
|
+
})
|
|
2763
|
+
}), /* @__PURE__ */ (0, W.jsxs)(yn, {
|
|
2764
|
+
className: "flex flex-col gap-6",
|
|
2765
|
+
children: [
|
|
2766
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2767
|
+
name: "required",
|
|
2768
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(T, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2769
|
+
className: "flex items-center space-x-2",
|
|
2770
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2771
|
+
id: e.name,
|
|
2772
|
+
checked: e.state.value,
|
|
2773
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2774
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2775
|
+
htmlFor: e.name,
|
|
2776
|
+
children: o("editor.inputNodeForm.required")
|
|
2777
|
+
})]
|
|
2778
|
+
}) })
|
|
2779
|
+
}),
|
|
2780
|
+
(n?.data?.type === "date" || n?.data?.type === "daterange") && /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2781
|
+
name: "disablePast",
|
|
2782
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(T, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2783
|
+
className: "flex items-center space-x-2",
|
|
2784
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2785
|
+
id: e.name,
|
|
2786
|
+
checked: e.state.value,
|
|
2787
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2788
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2789
|
+
htmlFor: e.name,
|
|
2790
|
+
children: o("editor.inputNodeForm.disablePast")
|
|
2791
|
+
})]
|
|
2792
|
+
}) })
|
|
2793
|
+
}),
|
|
2794
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2795
|
+
name: "pattern",
|
|
2796
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2797
|
+
htmlFor: e.name,
|
|
2798
|
+
children: o("editor.inputNodeForm.pattern")
|
|
2799
|
+
}), /* @__PURE__ */ (0, W.jsx)(cn, {
|
|
2800
|
+
id: e.name,
|
|
2801
|
+
value: e.state.value,
|
|
2802
|
+
onValueChange: e.handleChange
|
|
2803
|
+
})] })
|
|
2804
|
+
}),
|
|
2805
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2806
|
+
className: "flex items-end gap-2",
|
|
2807
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2808
|
+
name: "errorMessage",
|
|
2809
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
2810
|
+
className: "flex-1",
|
|
2811
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2812
|
+
htmlFor: t.name,
|
|
2813
|
+
children: o("editor.inputNodeForm.errorMessage")
|
|
2814
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2815
|
+
id: t.name,
|
|
2816
|
+
name: t.name,
|
|
2817
|
+
value: t.state.value?.[e] || "",
|
|
2818
|
+
onBlur: t.handleBlur,
|
|
2819
|
+
onChange: ({ target: n }) => {
|
|
2820
|
+
t.handleChange({
|
|
2821
|
+
...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
|
|
2822
|
+
[e]: n.value
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
})]
|
|
2826
|
+
})
|
|
2827
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
2828
|
+
value: e,
|
|
2829
|
+
onValueChange: t
|
|
2830
|
+
})]
|
|
2831
|
+
})
|
|
2832
|
+
]
|
|
2833
|
+
})]
|
|
2834
|
+
}),
|
|
2835
|
+
!s && /* @__PURE__ */ (0, W.jsxs)(_n, {
|
|
2836
|
+
className: "flex w-full max-w-[350px] flex-col gap-2",
|
|
2837
|
+
children: [/* @__PURE__ */ (0, W.jsx)(vn, {
|
|
2838
|
+
asChild: !0,
|
|
2839
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2840
|
+
className: "flex items-center justify-between gap-4",
|
|
2841
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
2842
|
+
className: "font-semibold text-sm",
|
|
2843
|
+
children: o("editor.inputNodeForm.advancedConfiguration")
|
|
2844
|
+
}), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
2845
|
+
variant: "ghost",
|
|
2846
|
+
size: "icon",
|
|
2847
|
+
className: "size-8",
|
|
2848
|
+
children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
2849
|
+
className: "sr-only",
|
|
2850
|
+
children: o("common.toggle")
|
|
2851
|
+
})]
|
|
2852
|
+
})]
|
|
2853
|
+
})
|
|
2854
|
+
}), /* @__PURE__ */ (0, W.jsxs)(yn, {
|
|
2855
|
+
className: "flex flex-col gap-6",
|
|
2856
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2857
|
+
name: "name",
|
|
2858
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
2859
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2860
|
+
htmlFor: e.name,
|
|
2861
|
+
children: o("editor.inputNodeForm.name")
|
|
2862
|
+
}),
|
|
2863
|
+
/* @__PURE__ */ (0, W.jsx)(h, {
|
|
2864
|
+
id: e.name,
|
|
2865
|
+
name: e.name,
|
|
2866
|
+
value: e.state.value,
|
|
2867
|
+
onBlur: e.handleBlur,
|
|
2868
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
2869
|
+
}),
|
|
2870
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: o("editor.inputNodeForm.nameDescription") })
|
|
2871
|
+
] })
|
|
2872
|
+
}), /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2873
|
+
name: "defaultValue",
|
|
2874
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [
|
|
2875
|
+
/* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2876
|
+
htmlFor: e.name,
|
|
2877
|
+
children: o("editor.inputNodeForm.defaultValueType")
|
|
2878
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
2879
|
+
value: e.state.value?.type || "none",
|
|
2880
|
+
onValueChange: (t) => {
|
|
2881
|
+
e.handleChange(t === "none" ? null : { type: t });
|
|
2882
|
+
},
|
|
2883
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
2884
|
+
id: e.name,
|
|
2885
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: o("editor.inputNodeForm.selectType") })
|
|
2886
|
+
}), /* @__PURE__ */ (0, W.jsxs)(j, { children: [
|
|
2887
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
2888
|
+
value: "none",
|
|
2889
|
+
children: o("editor.inputNodeForm.defaultValueTypeNone")
|
|
2890
|
+
}),
|
|
2891
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
2892
|
+
value: "static",
|
|
2893
|
+
children: o("editor.inputNodeForm.defaultValueTypeStatic")
|
|
2894
|
+
}),
|
|
2895
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
2896
|
+
value: "reference",
|
|
2897
|
+
children: o("editor.inputNodeForm.defaultValueTypeReference")
|
|
2898
|
+
})
|
|
2899
|
+
] })]
|
|
2900
|
+
})] }),
|
|
2901
|
+
e.state.value?.type === "static" && /* @__PURE__ */ (0, W.jsx)(d, {
|
|
2902
|
+
name: "defaultValue.staticValue",
|
|
2903
|
+
children: (e) => {
|
|
2904
|
+
let t = n?.data?.type;
|
|
2905
|
+
return (t === "select" || t === "checkbox") && n?.data?.multiple ? /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2906
|
+
htmlFor: e.name,
|
|
2907
|
+
children: o("editor.inputNodeForm.defaultValuesCommaSeparated")
|
|
2908
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2909
|
+
id: e.name,
|
|
2910
|
+
placeholder: o("editor.inputNodeForm.defaultValuesPlaceholder"),
|
|
2911
|
+
value: Array.isArray(e.state.value) ? e.state.value.join(", ") : "",
|
|
2912
|
+
onChange: ({ target: t }) => {
|
|
2913
|
+
let n = t.value.split(",").map((e) => e.trim()).filter(Boolean);
|
|
2914
|
+
e.handleChange(n.length > 0 ? n : null);
|
|
2915
|
+
}
|
|
2916
|
+
})] }) : t === "checkbox" ? /* @__PURE__ */ (0, W.jsx)(T, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
2917
|
+
className: "flex items-center space-x-2",
|
|
2918
|
+
children: [/* @__PURE__ */ (0, W.jsx)(S, {
|
|
2919
|
+
id: e.name,
|
|
2920
|
+
checked: !!e.state.value,
|
|
2921
|
+
onCheckedChange: (t) => e.handleChange(t)
|
|
2922
|
+
}), /* @__PURE__ */ (0, W.jsx)(u, {
|
|
2923
|
+
htmlFor: e.name,
|
|
2924
|
+
children: o("editor.inputNodeForm.defaultChecked")
|
|
2925
|
+
})]
|
|
2926
|
+
}) }) : /* @__PURE__ */ (0, W.jsxs)(T, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2927
|
+
htmlFor: e.name,
|
|
2928
|
+
children: o("editor.inputNodeForm.staticValue")
|
|
2929
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
2930
|
+
id: e.name,
|
|
2931
|
+
placeholder: o("editor.inputNodeForm.staticValuePlaceholder"),
|
|
2932
|
+
value: typeof e.state.value == "string" ? e.state.value : "",
|
|
2933
|
+
onChange: ({ target: t }) => e.handleChange(t.value || "")
|
|
2934
|
+
})] });
|
|
2935
|
+
}
|
|
2936
|
+
}),
|
|
2937
|
+
e.state.value?.type === "reference" && /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [
|
|
2938
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2939
|
+
name: "defaultValue.referenceField",
|
|
2940
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
2941
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2942
|
+
htmlFor: e.name,
|
|
2943
|
+
children: o("editor.inputNodeForm.referenceField")
|
|
2944
|
+
}),
|
|
2945
|
+
/* @__PURE__ */ (0, W.jsxs)(y, {
|
|
2946
|
+
value: e.state.value || "",
|
|
2947
|
+
onValueChange: (t) => {
|
|
2948
|
+
e.handleChange(t);
|
|
2949
|
+
},
|
|
2950
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
2951
|
+
id: e.name,
|
|
2952
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: o("editor.inputNodeForm.selectReferenceField") })
|
|
2953
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: a.length === 0 ? /* @__PURE__ */ (0, W.jsx)(x, {
|
|
2954
|
+
value: "none",
|
|
2955
|
+
disabled: !0,
|
|
2956
|
+
children: o("editor.inputNodeForm.noParentFieldsAvailable")
|
|
2957
|
+
}) : a.map((e) => /* @__PURE__ */ (0, W.jsxs)(x, {
|
|
2958
|
+
value: e.nodeId,
|
|
2959
|
+
children: [
|
|
2960
|
+
e.label,
|
|
2961
|
+
" (",
|
|
2962
|
+
e.type,
|
|
2963
|
+
")"
|
|
2964
|
+
]
|
|
2965
|
+
}, e.nodeId)) })]
|
|
2966
|
+
}),
|
|
2967
|
+
a.length === 0 && /* @__PURE__ */ (0, W.jsx)(E, { children: o("editor.inputNodeForm.addInputFieldsBeforeReference") })
|
|
2968
|
+
] })
|
|
2969
|
+
}),
|
|
2970
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
2971
|
+
name: "defaultValue.transformFunction",
|
|
2972
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
2973
|
+
/* @__PURE__ */ (0, W.jsx)(u, {
|
|
2974
|
+
htmlFor: t.name,
|
|
2975
|
+
children: o("editor.inputNodeForm.transformType")
|
|
2976
|
+
}),
|
|
2977
|
+
/* @__PURE__ */ (0, W.jsxs)(y, {
|
|
2978
|
+
value: t.state.value || "none",
|
|
2979
|
+
onValueChange: (n) => {
|
|
2980
|
+
let r = n === "none" ? null : n;
|
|
2981
|
+
if (t.handleChange(r), n === "toObject") {
|
|
2982
|
+
let t = e.state.value;
|
|
2983
|
+
e.handleChange({
|
|
2984
|
+
...t,
|
|
2985
|
+
objectMapping: []
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
},
|
|
2989
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
2990
|
+
id: t.name,
|
|
2991
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: o("editor.inputNodeForm.selectTransformation") })
|
|
2992
|
+
}), /* @__PURE__ */ (0, W.jsxs)(j, { children: [
|
|
2993
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
2994
|
+
value: "none",
|
|
2995
|
+
children: o("editor.inputNodeForm.transformNone")
|
|
2996
|
+
}),
|
|
2997
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
2998
|
+
value: "toString",
|
|
2999
|
+
children: o("editor.inputNodeForm.transformString")
|
|
3000
|
+
}),
|
|
3001
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
3002
|
+
value: "toNumber",
|
|
3003
|
+
children: o("editor.inputNodeForm.transformNumber")
|
|
3004
|
+
}),
|
|
3005
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
3006
|
+
value: "toBoolean",
|
|
3007
|
+
children: o("editor.inputNodeForm.transformBoolean")
|
|
3008
|
+
}),
|
|
3009
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
3010
|
+
value: "toArray",
|
|
3011
|
+
children: o("editor.inputNodeForm.transformArray")
|
|
3012
|
+
}),
|
|
3013
|
+
/* @__PURE__ */ (0, W.jsx)(x, {
|
|
3014
|
+
value: "toObject",
|
|
3015
|
+
children: o("editor.inputNodeForm.transformMapToObject")
|
|
3016
|
+
})
|
|
3017
|
+
] })]
|
|
3018
|
+
}),
|
|
3019
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: o("editor.inputNodeForm.transformDesc") })
|
|
3020
|
+
] })
|
|
3021
|
+
}),
|
|
3022
|
+
e.state.value?.transformFunction === "toObject" && /* @__PURE__ */ (0, W.jsx)(d, {
|
|
3023
|
+
name: "defaultValue.objectMapping",
|
|
3024
|
+
mode: "array",
|
|
3025
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(T, { children: [
|
|
3026
|
+
/* @__PURE__ */ (0, W.jsx)(u, { children: o("editor.inputNodeForm.objectMapping") }),
|
|
3027
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3028
|
+
className: "space-y-2",
|
|
3029
|
+
children: [e.state.value?.map((t, n) => /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3030
|
+
className: "flex items-center gap-2",
|
|
3031
|
+
children: [
|
|
3032
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
3033
|
+
name: `defaultValue.objectMapping[${n}].sourceKey`,
|
|
3034
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
3035
|
+
placeholder: o("editor.inputNodeForm.sourceKey"),
|
|
3036
|
+
value: e.state.value || "",
|
|
3037
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
3038
|
+
})
|
|
3039
|
+
}),
|
|
3040
|
+
/* @__PURE__ */ (0, W.jsx)("span", {
|
|
3041
|
+
className: "text-muted-foreground",
|
|
3042
|
+
children: "→"
|
|
3043
|
+
}),
|
|
3044
|
+
/* @__PURE__ */ (0, W.jsx)(d, {
|
|
3045
|
+
name: `defaultValue.objectMapping[${n}].targetKey`,
|
|
3046
|
+
children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
|
|
3047
|
+
placeholder: o("editor.inputNodeForm.targetKey"),
|
|
3048
|
+
value: e.state.value || "",
|
|
3049
|
+
onChange: ({ target: t }) => e.handleChange(t.value)
|
|
3050
|
+
})
|
|
3051
|
+
}),
|
|
3052
|
+
/* @__PURE__ */ (0, W.jsx)(m, {
|
|
3053
|
+
type: "button",
|
|
3054
|
+
variant: "ghost",
|
|
3055
|
+
size: "icon",
|
|
3056
|
+
onClick: () => {
|
|
3057
|
+
e.removeValue(n), c().then();
|
|
3058
|
+
},
|
|
3059
|
+
children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
|
|
3060
|
+
})
|
|
3061
|
+
]
|
|
3062
|
+
}, `mapping-${n}`)), /* @__PURE__ */ (0, W.jsxs)(m, {
|
|
3063
|
+
type: "button",
|
|
3064
|
+
variant: "outline",
|
|
3065
|
+
size: "sm",
|
|
3066
|
+
className: "w-full",
|
|
3067
|
+
onClick: () => {
|
|
3068
|
+
e.pushValue({
|
|
3069
|
+
sourceKey: "",
|
|
3070
|
+
targetKey: ""
|
|
3071
|
+
}), c().then();
|
|
3072
|
+
},
|
|
3073
|
+
children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), o("editor.inputNodeForm.addMapping")]
|
|
3074
|
+
})]
|
|
3075
|
+
}),
|
|
3076
|
+
/* @__PURE__ */ (0, W.jsx)(E, { children: o("editor.inputNodeForm.objectMappingDesc") })
|
|
3077
|
+
] })
|
|
3078
|
+
})
|
|
3079
|
+
] })
|
|
3080
|
+
] })
|
|
3081
|
+
})]
|
|
3082
|
+
})]
|
|
3083
|
+
})
|
|
3084
|
+
]
|
|
3085
|
+
})
|
|
3086
|
+
});
|
|
3087
|
+
}, xn = () => {
|
|
3088
|
+
let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = K(), { Field: i } = I({
|
|
3089
|
+
defaultValues: {
|
|
3090
|
+
label: n?.data?.label || { en: "" },
|
|
3091
|
+
type: n?.data?.type || ""
|
|
3092
|
+
},
|
|
3093
|
+
listeners: {
|
|
3094
|
+
onChange: ({ formApi: e }) => {
|
|
3095
|
+
e.handleSubmit().then();
|
|
3096
|
+
},
|
|
3097
|
+
onChangeDebounceMs: 150
|
|
3098
|
+
},
|
|
3099
|
+
onSubmit: ({ value: e }) => {
|
|
3100
|
+
r(e);
|
|
3101
|
+
}
|
|
3102
|
+
});
|
|
3103
|
+
return /* @__PURE__ */ (0, W.jsx)("form", {
|
|
3104
|
+
onSubmit: (e) => {
|
|
3105
|
+
e.preventDefault(), e.stopPropagation();
|
|
3106
|
+
},
|
|
3107
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3108
|
+
className: "grid gap-6",
|
|
3109
|
+
children: [/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3110
|
+
className: "flex items-end gap-2",
|
|
3111
|
+
children: [/* @__PURE__ */ (0, W.jsx)(i, {
|
|
3112
|
+
name: "label",
|
|
3113
|
+
children: (t) => /* @__PURE__ */ (0, W.jsxs)(T, {
|
|
3114
|
+
className: "flex-1",
|
|
3115
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
3116
|
+
htmlFor: t.name,
|
|
3117
|
+
children: "Label"
|
|
3118
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
3119
|
+
id: t.name,
|
|
3120
|
+
name: t.name,
|
|
3121
|
+
value: t.state.value?.[e] || "",
|
|
3122
|
+
onBlur: t.handleBlur,
|
|
3123
|
+
onChange: ({ target: n }) => {
|
|
3124
|
+
t.handleChange({
|
|
3125
|
+
...t.state.value,
|
|
3126
|
+
[e]: n.value
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
})]
|
|
3130
|
+
})
|
|
3131
|
+
}), /* @__PURE__ */ (0, W.jsx)(Q, {
|
|
3132
|
+
value: e,
|
|
3133
|
+
onValueChange: t
|
|
3134
|
+
})]
|
|
3135
|
+
}), /* @__PURE__ */ (0, W.jsx)(i, {
|
|
3136
|
+
name: "type",
|
|
3137
|
+
children: (e) => /* @__PURE__ */ (0, W.jsxs)(M, { children: [/* @__PURE__ */ (0, W.jsx)(le, {
|
|
3138
|
+
htmlFor: e.name,
|
|
3139
|
+
children: "Type"
|
|
3140
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
3141
|
+
value: e.state.value,
|
|
3142
|
+
onValueChange: (t) => e.handleChange(t),
|
|
3143
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
3144
|
+
id: e.name,
|
|
3145
|
+
className: "w-full",
|
|
3146
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: "" })
|
|
3147
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: /* @__PURE__ */ (0, W.jsxs)(M, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
|
|
3148
|
+
value: At.title,
|
|
3149
|
+
children: "Title"
|
|
3150
|
+
}), /* @__PURE__ */ (0, W.jsx)(x, {
|
|
3151
|
+
value: At.divider,
|
|
3152
|
+
children: "Divider"
|
|
3153
|
+
})] }) })]
|
|
3154
|
+
})] })
|
|
3155
|
+
})]
|
|
3156
|
+
})
|
|
3157
|
+
});
|
|
3158
|
+
}, Sn = () => {
|
|
3159
|
+
let [e, t] = F(""), [n, r] = F(!1), { selectedNode: i, groupNodes: o } = $(), { setNodes: s } = Ee(), c = i?.parentId || "none", f = a(i), p = G(), g = je(), b = je();
|
|
3160
|
+
if (f) return null;
|
|
3161
|
+
let S = (e) => {
|
|
3162
|
+
i && s((t) => e === "none" ? t.map((e) => {
|
|
3163
|
+
if (e.id === i.id) {
|
|
3164
|
+
let { parentId: t, extent: n, ...r } = e;
|
|
3165
|
+
return r;
|
|
3166
|
+
}
|
|
3167
|
+
return e;
|
|
3168
|
+
}) : t.find((t) => t.id === e) ? t.map((t) => t.id === i.id ? {
|
|
3169
|
+
...t,
|
|
3170
|
+
extent: "parent",
|
|
3171
|
+
parentId: e,
|
|
3172
|
+
position: {
|
|
3173
|
+
x: 50,
|
|
3174
|
+
y: 80
|
|
3175
|
+
}
|
|
3176
|
+
} : t) : t);
|
|
3177
|
+
}, C = () => {
|
|
3178
|
+
if (!(e.trim() && i)) return;
|
|
3179
|
+
if (o.find((t) => {
|
|
3180
|
+
let n = t.data?.label?.en || t.data?.label;
|
|
3181
|
+
return String(n).toLowerCase() === e.trim().toLowerCase();
|
|
3182
|
+
})) {
|
|
3183
|
+
V.error("This group already exists", { description: "Use the selector to add the node to an existing group." });
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
let n = q();
|
|
3187
|
+
s((t) => [{
|
|
3188
|
+
data: { label: { en: e.trim() } },
|
|
3189
|
+
id: n,
|
|
3190
|
+
position: {
|
|
3191
|
+
x: i.position.x - 300,
|
|
3192
|
+
y: i.position.y
|
|
3193
|
+
},
|
|
3194
|
+
style: {
|
|
3195
|
+
height: 400,
|
|
3196
|
+
width: 600
|
|
3197
|
+
},
|
|
3198
|
+
type: "group"
|
|
3199
|
+
}, ...t.map((e) => e.id === i.id ? {
|
|
3200
|
+
...e,
|
|
3201
|
+
extent: "parent",
|
|
3202
|
+
parentId: n,
|
|
3203
|
+
position: {
|
|
3204
|
+
x: 175,
|
|
3205
|
+
y: 30
|
|
3206
|
+
}
|
|
3207
|
+
} : e)]), t(""), r(!1), V.success("Group created", { description: `The group "${e.trim()}" has been created successfully.` });
|
|
3208
|
+
};
|
|
3209
|
+
return /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3210
|
+
className: "space-y-2",
|
|
3211
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
3212
|
+
htmlFor: g,
|
|
3213
|
+
children: p("editor.selectNodeGroup.group")
|
|
3214
|
+
}), /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3215
|
+
className: "flex gap-2",
|
|
3216
|
+
children: [/* @__PURE__ */ (0, W.jsxs)(y, {
|
|
3217
|
+
value: c,
|
|
3218
|
+
onValueChange: S,
|
|
3219
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
3220
|
+
id: g,
|
|
3221
|
+
className: "flex-1",
|
|
3222
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: p("editor.selectNodeGroup.noGroup") })
|
|
3223
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: /* @__PURE__ */ (0, W.jsxs)(M, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
|
|
3224
|
+
value: "none",
|
|
3225
|
+
children: p("editor.selectNodeGroup.noGroup")
|
|
3226
|
+
}), o.map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
|
|
3227
|
+
value: e.id,
|
|
3228
|
+
children: e.data.label?.en ? String(e.data.label?.en) : e.id
|
|
3229
|
+
}, e.id))] }) })]
|
|
3230
|
+
}), /* @__PURE__ */ (0, W.jsxs)(ce, {
|
|
3231
|
+
open: n,
|
|
3232
|
+
onOpenChange: r,
|
|
3233
|
+
children: [/* @__PURE__ */ (0, W.jsx)(d, {
|
|
3234
|
+
asChild: !0,
|
|
3235
|
+
children: /* @__PURE__ */ (0, W.jsx)(m, {
|
|
3236
|
+
variant: "outline",
|
|
3237
|
+
size: "icon",
|
|
3238
|
+
title: "Create a new group",
|
|
3239
|
+
children: /* @__PURE__ */ (0, W.jsx)(Ke, { className: "h-4 w-4" })
|
|
3240
|
+
})
|
|
3241
|
+
}), /* @__PURE__ */ (0, W.jsx)(v, {
|
|
3242
|
+
className: "w-80",
|
|
3243
|
+
align: "end",
|
|
3244
|
+
disablePortal: !0,
|
|
3245
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3246
|
+
className: "space-y-4",
|
|
3247
|
+
children: [
|
|
3248
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3249
|
+
className: "space-y-2",
|
|
3250
|
+
children: [/* @__PURE__ */ (0, W.jsx)("h4", {
|
|
3251
|
+
className: "font-medium leading-none",
|
|
3252
|
+
children: p("editor.selectNodeGroup.newGroup")
|
|
3253
|
+
}), /* @__PURE__ */ (0, W.jsx)("p", {
|
|
3254
|
+
className: "text-muted-foreground text-sm",
|
|
3255
|
+
children: p("editor.selectNodeGroup.newGroupDescription")
|
|
3256
|
+
})]
|
|
3257
|
+
}),
|
|
3258
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3259
|
+
className: "space-y-2",
|
|
3260
|
+
children: [/* @__PURE__ */ (0, W.jsx)(u, {
|
|
3261
|
+
htmlFor: b,
|
|
3262
|
+
children: p("editor.selectNodeGroup.groupName")
|
|
3263
|
+
}), /* @__PURE__ */ (0, W.jsx)(h, {
|
|
3264
|
+
autoFocus: !0,
|
|
3265
|
+
id: b,
|
|
3266
|
+
value: e,
|
|
3267
|
+
onChange: (e) => t(e.target.value),
|
|
3268
|
+
placeholder: "Ex: Step 1 - Personal info",
|
|
3269
|
+
onKeyDown: (e) => {
|
|
3270
|
+
e.key === "Enter" && (e.preventDefault(), C());
|
|
3271
|
+
}
|
|
3272
|
+
})]
|
|
3273
|
+
}),
|
|
3274
|
+
/* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3275
|
+
className: "flex justify-end gap-2",
|
|
3276
|
+
children: [/* @__PURE__ */ (0, W.jsx)(m, {
|
|
3277
|
+
variant: "outline",
|
|
3278
|
+
size: "sm",
|
|
3279
|
+
onClick: () => r(!1),
|
|
3280
|
+
children: "Cancel"
|
|
3281
|
+
}), /* @__PURE__ */ (0, W.jsx)(m, {
|
|
3282
|
+
size: "sm",
|
|
3283
|
+
onClick: C,
|
|
3284
|
+
disabled: !e.trim(),
|
|
3285
|
+
children: "Create"
|
|
3286
|
+
})]
|
|
3287
|
+
})
|
|
3288
|
+
]
|
|
3289
|
+
})
|
|
3290
|
+
})]
|
|
3291
|
+
})]
|
|
3292
|
+
})]
|
|
3293
|
+
});
|
|
3294
|
+
}, Cn = () => {
|
|
3295
|
+
let { selectedNode: e } = $(), { updateSelectedNodeType: t } = K(), n = e?.type || "", r = a(e), i = G(), o = je();
|
|
3296
|
+
return /* @__PURE__ */ (0, W.jsxs)(M, { children: [/* @__PURE__ */ (0, W.jsx)(le, {
|
|
3297
|
+
htmlFor: o,
|
|
3298
|
+
children: i("editor.selectNodeType.nodeType")
|
|
3299
|
+
}), /* @__PURE__ */ (0, W.jsxs)(y, {
|
|
3300
|
+
value: n,
|
|
3301
|
+
onValueChange: (e) => t(e),
|
|
3302
|
+
disabled: r,
|
|
3303
|
+
children: [/* @__PURE__ */ (0, W.jsx)(_, {
|
|
3304
|
+
className: "w-full",
|
|
3305
|
+
id: o,
|
|
3306
|
+
children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: i("editor.selectNodeType.nodeType") })
|
|
3307
|
+
}), /* @__PURE__ */ (0, W.jsx)(j, { children: /* @__PURE__ */ (0, W.jsx)(M, { children: Object.keys(zt).filter((e) => r ? e === "group" : e !== "group").map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
|
|
3308
|
+
value: e,
|
|
3309
|
+
children: i(`editor.selectNodeType.options.${e}`)
|
|
3310
|
+
}, e)) }) })]
|
|
3311
|
+
})] });
|
|
3312
|
+
};
|
|
3313
|
+
//#endregion
|
|
3314
|
+
//#region src/shared/components/ui/alert-dialog.tsx
|
|
3315
|
+
function wn({ ...e }) {
|
|
3316
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Root, {
|
|
3317
|
+
"data-slot": "alert-dialog",
|
|
3318
|
+
...e
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
function Tn({ ...e }) {
|
|
3322
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Trigger, {
|
|
3323
|
+
"data-slot": "alert-dialog-trigger",
|
|
3324
|
+
...e
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
function En({ ...e }) {
|
|
3328
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Portal, {
|
|
3329
|
+
"data-slot": "alert-dialog-portal",
|
|
3330
|
+
...e
|
|
3331
|
+
});
|
|
3332
|
+
}
|
|
3333
|
+
function Dn({ className: e, ...t }) {
|
|
3334
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Overlay, {
|
|
3335
|
+
"data-slot": "alert-dialog-overlay",
|
|
3336
|
+
className: f("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),
|
|
3337
|
+
...t
|
|
3338
|
+
});
|
|
3339
|
+
}
|
|
3340
|
+
function On({ className: e, ...t }) {
|
|
3341
|
+
return /* @__PURE__ */ (0, W.jsxs)(En, { children: [/* @__PURE__ */ (0, W.jsx)(Dn, {}), /* @__PURE__ */ (0, W.jsx)(U.Content, {
|
|
3342
|
+
"data-slot": "alert-dialog-content",
|
|
3343
|
+
className: f("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg", e),
|
|
3344
|
+
...t
|
|
3345
|
+
})] });
|
|
3346
|
+
}
|
|
3347
|
+
function kn({ className: e, ...t }) {
|
|
3348
|
+
return /* @__PURE__ */ (0, W.jsx)("div", {
|
|
3349
|
+
"data-slot": "alert-dialog-header",
|
|
3350
|
+
className: f("flex flex-col gap-2 text-center sm:text-left", e),
|
|
3351
|
+
...t
|
|
3352
|
+
});
|
|
3353
|
+
}
|
|
3354
|
+
function An({ className: e, ...t }) {
|
|
3355
|
+
return /* @__PURE__ */ (0, W.jsx)("div", {
|
|
3356
|
+
"data-slot": "alert-dialog-footer",
|
|
3357
|
+
className: f("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", e),
|
|
3358
|
+
...t
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
function jn({ className: e, ...t }) {
|
|
3362
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Title, {
|
|
3363
|
+
"data-slot": "alert-dialog-title",
|
|
3364
|
+
className: f("font-semibold text-lg", e),
|
|
3365
|
+
...t
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
function Mn({ className: e, ...t }) {
|
|
3369
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Description, {
|
|
3370
|
+
"data-slot": "alert-dialog-description",
|
|
3371
|
+
className: f("text-muted-foreground text-sm", e),
|
|
3372
|
+
...t
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3375
|
+
function Nn({ className: e, ...t }) {
|
|
3376
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Action, {
|
|
3377
|
+
className: f(g(), e),
|
|
3378
|
+
...t
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3381
|
+
function Pn({ className: e, ...t }) {
|
|
3382
|
+
return /* @__PURE__ */ (0, W.jsx)(U.Cancel, {
|
|
3383
|
+
className: f(g({ variant: "outline" }), e),
|
|
3384
|
+
...t
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
//#endregion
|
|
3388
|
+
//#region src/shared/components/ui/sheet.tsx
|
|
3389
|
+
function Fn({ ...e }) {
|
|
3390
|
+
return /* @__PURE__ */ (0, W.jsx)(H.Root, {
|
|
3391
|
+
"data-slot": "sheet",
|
|
3392
|
+
...e
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
function In({ ...e }) {
|
|
3396
|
+
return /* @__PURE__ */ (0, W.jsx)(H.Portal, {
|
|
3397
|
+
"data-slot": "sheet-portal",
|
|
3398
|
+
...e
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
function Ln({ className: e, ...t }) {
|
|
3402
|
+
return /* @__PURE__ */ (0, W.jsx)(H.Overlay, {
|
|
3403
|
+
"data-slot": "sheet-overlay",
|
|
3404
|
+
className: f("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),
|
|
3405
|
+
...t
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
function Rn({ className: e, children: t, side: n = "right", ...r }) {
|
|
3409
|
+
return /* @__PURE__ */ (0, W.jsxs)(In, { children: [/* @__PURE__ */ (0, W.jsx)(Ln, {}), /* @__PURE__ */ (0, W.jsxs)(H.Content, {
|
|
3410
|
+
"data-slot": "sheet-content",
|
|
3411
|
+
className: f("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),
|
|
3412
|
+
...r,
|
|
3413
|
+
children: [t, /* @__PURE__ */ (0, W.jsxs)(H.Close, {
|
|
3414
|
+
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",
|
|
3415
|
+
children: [/* @__PURE__ */ (0, W.jsx)(et, { className: "size-4" }), /* @__PURE__ */ (0, W.jsx)("span", {
|
|
3416
|
+
className: "sr-only",
|
|
3417
|
+
children: "Close"
|
|
3418
|
+
})]
|
|
3419
|
+
})]
|
|
3420
|
+
})] });
|
|
3421
|
+
}
|
|
3422
|
+
function zn({ className: e, ...t }) {
|
|
3423
|
+
return /* @__PURE__ */ (0, W.jsx)("div", {
|
|
3424
|
+
"data-slot": "sheet-header",
|
|
3425
|
+
className: f("flex flex-col gap-1.5 p-4", e),
|
|
3426
|
+
...t
|
|
3427
|
+
});
|
|
3428
|
+
}
|
|
3429
|
+
function Bn({ className: e, ...t }) {
|
|
3430
|
+
return /* @__PURE__ */ (0, W.jsx)("div", {
|
|
3431
|
+
"data-slot": "sheet-footer",
|
|
3432
|
+
className: f("mt-auto flex flex-col gap-2 p-4", e),
|
|
3433
|
+
...t
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
function Vn({ className: e, ...t }) {
|
|
3437
|
+
return /* @__PURE__ */ (0, W.jsx)(H.Title, {
|
|
3438
|
+
"data-slot": "sheet-title",
|
|
3439
|
+
className: f("font-semibold text-foreground", e),
|
|
3440
|
+
...t
|
|
3441
|
+
});
|
|
3442
|
+
}
|
|
3443
|
+
function Hn({ className: e, ...t }) {
|
|
3444
|
+
return /* @__PURE__ */ (0, W.jsx)(H.Description, {
|
|
3445
|
+
"data-slot": "sheet-description",
|
|
3446
|
+
className: f("text-muted-foreground text-sm", e),
|
|
3447
|
+
...t
|
|
3448
|
+
});
|
|
3449
|
+
}
|
|
3450
|
+
//#endregion
|
|
3451
|
+
//#region src/editor/features/TreegeEditor/sheets/NodeActionsSheet.tsx
|
|
3452
|
+
var Un = () => {
|
|
3453
|
+
let { selectedNode: e } = $(), { clearSelection: r, deleteSelectedNode: i } = K(), { isNodeSheetOpen: o, setIsNodeSheetOpen: s } = pt(), l = G(), u = l(e?.data?.label), d = () => {
|
|
3454
|
+
s(!1), r();
|
|
3455
|
+
};
|
|
3456
|
+
return /* @__PURE__ */ (0, W.jsx)(Fn, {
|
|
3457
|
+
open: o && !!e,
|
|
3458
|
+
onOpenChange: (e) => {
|
|
3459
|
+
e || d();
|
|
3460
|
+
},
|
|
3461
|
+
children: /* @__PURE__ */ (0, W.jsxs)(Rn, {
|
|
3462
|
+
className: "flex flex-col gap-0",
|
|
3463
|
+
children: [
|
|
3464
|
+
/* @__PURE__ */ (0, W.jsxs)(zn, { children: [/* @__PURE__ */ (0, W.jsxs)(Vn, { children: [
|
|
3465
|
+
l("editor.nodeActionsSheet.editNode"),
|
|
3466
|
+
" ",
|
|
3467
|
+
/* @__PURE__ */ (0, W.jsx)("span", {
|
|
3468
|
+
className: "font-light text-muted-foreground text-xs",
|
|
3469
|
+
children: e?.id
|
|
3470
|
+
})
|
|
3471
|
+
] }), /* @__PURE__ */ (0, W.jsx)(Hn, { children: u || "\xA0" })] }),
|
|
3472
|
+
/* @__PURE__ */ (0, W.jsx)(mt, {
|
|
3473
|
+
className: "flex min-h-0 flex-1 flex-col px-4",
|
|
3474
|
+
children: /* @__PURE__ */ (0, W.jsxs)("div", {
|
|
3475
|
+
className: "space-y-6 py-4",
|
|
3476
|
+
children: [
|
|
3477
|
+
/* @__PURE__ */ (0, W.jsx)(Cn, {}),
|
|
3478
|
+
/* @__PURE__ */ (0, W.jsx)(Sn, {}),
|
|
3479
|
+
/* @__PURE__ */ (0, W.jsx)(oe, {}),
|
|
3480
|
+
c(e) && /* @__PURE__ */ (0, W.jsx)(bn, {}),
|
|
3481
|
+
n(e) && /* @__PURE__ */ (0, W.jsx)(xn, {}),
|
|
3482
|
+
t(e) && /* @__PURE__ */ (0, W.jsx)($t, {}),
|
|
3483
|
+
a(e) && /* @__PURE__ */ (0, W.jsx)(en, {})
|
|
3484
|
+
]
|
|
3485
|
+
})
|
|
3486
|
+
}),
|
|
3487
|
+
/* @__PURE__ */ (0, W.jsx)(Bn, {
|
|
3488
|
+
className: "flex items-end border-t",
|
|
3489
|
+
children: /* @__PURE__ */ (0, W.jsxs)(wn, { children: [/* @__PURE__ */ (0, W.jsx)(Tn, {
|
|
3490
|
+
asChild: !0,
|
|
3491
|
+
children: /* @__PURE__ */ (0, W.jsx)(m, {
|
|
3492
|
+
variant: "ghost",
|
|
3493
|
+
size: "icon",
|
|
3494
|
+
children: /* @__PURE__ */ (0, W.jsx)(Ye, {})
|
|
3495
|
+
})
|
|
3496
|
+
}), /* @__PURE__ */ (0, W.jsxs)(On, { children: [/* @__PURE__ */ (0, W.jsxs)(kn, { children: [/* @__PURE__ */ (0, W.jsx)(jn, { children: l("editor.nodeActionsSheet.deleteNode") }), /* @__PURE__ */ (0, W.jsx)(Mn, { children: l("editor.nodeActionsSheet.deleteNodeConfirm") })] }), /* @__PURE__ */ (0, W.jsxs)(An, { children: [/* @__PURE__ */ (0, W.jsx)(Pn, { children: l("common.cancel") }), /* @__PURE__ */ (0, W.jsx)(Nn, {
|
|
3497
|
+
onClick: () => {
|
|
3498
|
+
i(), d();
|
|
3499
|
+
},
|
|
3500
|
+
children: l("common.delete")
|
|
3501
|
+
})] })] })] })
|
|
3502
|
+
})
|
|
3503
|
+
]
|
|
3504
|
+
})
|
|
3505
|
+
});
|
|
3506
|
+
}, Wn = ({ ...e }) => {
|
|
3507
|
+
let { theme: t = "system" } = ot();
|
|
3508
|
+
return /* @__PURE__ */ (0, W.jsx)(it, {
|
|
3509
|
+
theme: t,
|
|
3510
|
+
className: "toaster group",
|
|
3511
|
+
style: {
|
|
3512
|
+
"--normal-bg": "var(--treege-popover)",
|
|
3513
|
+
"--normal-border": "var(--treege-border)",
|
|
3514
|
+
"--normal-text": "var(--treege-popover-foreground)"
|
|
3515
|
+
},
|
|
3516
|
+
...e
|
|
3517
|
+
});
|
|
3518
|
+
}, Gn = ({ flow: e, onExportJson: t, onSave: n, theme: r, className: i }) => {
|
|
3519
|
+
let { onConnect: a, onConnectEnd: o, onEdgesDelete: s, isValidConnection: c } = Et();
|
|
3520
|
+
return /* @__PURE__ */ (0, W.jsxs)(be, {
|
|
3521
|
+
fitView: !0,
|
|
3522
|
+
colorMode: r,
|
|
3523
|
+
selectNodesOnDrag: !1,
|
|
3524
|
+
nodeTypes: zt,
|
|
3525
|
+
edgeTypes: gt,
|
|
3526
|
+
defaultEdges: e?.edges || [],
|
|
3527
|
+
defaultNodes: e?.nodes || [],
|
|
3528
|
+
onConnect: a,
|
|
3529
|
+
onConnectEnd: o,
|
|
3530
|
+
onEdgesDelete: s,
|
|
3531
|
+
isValidConnection: c,
|
|
3532
|
+
className: f(i, "treege"),
|
|
3533
|
+
children: [
|
|
3534
|
+
/* @__PURE__ */ (0, W.jsx)(ue, {
|
|
3535
|
+
gap: 10,
|
|
3536
|
+
variant: de.Dots
|
|
3537
|
+
}),
|
|
3538
|
+
/* @__PURE__ */ (0, W.jsx)(Zt, {
|
|
3539
|
+
onExportJson: t,
|
|
3540
|
+
onSave: n
|
|
3541
|
+
}),
|
|
3542
|
+
/* @__PURE__ */ (0, W.jsx)(lt, { theme: r }),
|
|
3543
|
+
/* @__PURE__ */ (0, W.jsx)(ge, {}),
|
|
3544
|
+
/* @__PURE__ */ (0, W.jsx)(pe, {}),
|
|
3545
|
+
/* @__PURE__ */ (0, W.jsx)(Un, {})
|
|
3546
|
+
]
|
|
3547
|
+
});
|
|
3548
|
+
}, Kn = ({ flow: e, onExportJson: t, onSave: n, theme: r = "dark", language: i = "en", aiConfig: a }) => /* @__PURE__ */ (0, W.jsx)(s, {
|
|
3549
|
+
defaultTheme: r,
|
|
3550
|
+
storageKey: "treege-editor-theme",
|
|
3551
|
+
theme: r,
|
|
3552
|
+
children: /* @__PURE__ */ (0, W.jsxs)(ft, {
|
|
3553
|
+
value: {
|
|
3554
|
+
aiConfig: a,
|
|
3555
|
+
flowId: e?.id,
|
|
3556
|
+
language: i
|
|
3557
|
+
},
|
|
3558
|
+
children: [/* @__PURE__ */ (0, W.jsx)(Wn, { position: "bottom-center" }), /* @__PURE__ */ (0, W.jsx)(xe, { children: /* @__PURE__ */ (0, W.jsx)(Gn, {
|
|
3559
|
+
onExportJson: t,
|
|
3560
|
+
onSave: n,
|
|
3561
|
+
flow: e,
|
|
3562
|
+
theme: r
|
|
3563
|
+
}) })]
|
|
3564
|
+
})
|
|
3565
|
+
});
|
|
3566
|
+
//#endregion
|
|
3567
|
+
export { Kn as t };
|