superleap-code-editor 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/layout/editorLayout.d.ts +2 -1
- package/dist/components/layout/editorLayout.d.ts.map +1 -1
- package/dist/components/layout/sidebar.d.ts +2 -1
- package/dist/components/layout/sidebar.d.ts.map +1 -1
- package/dist/index.cjs.js +8 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +383 -380
- package/dist/types/fileTypes.d.ts +7 -0
- package/dist/types/fileTypes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Panels } from "../../types/fileTypes";
|
|
2
3
|
interface EditorLayoutProps {
|
|
3
4
|
leftPanel: React.ReactNode;
|
|
4
5
|
editor: React.ReactNode;
|
|
5
6
|
rightPanel: React.ReactNode | false;
|
|
6
7
|
activePanel: string;
|
|
7
8
|
setActivePanel: (panel: string) => void;
|
|
8
|
-
allowedPannels?:
|
|
9
|
+
allowedPannels?: Panels[];
|
|
9
10
|
}
|
|
10
11
|
export declare const EditorLayout: React.FC<EditorLayoutProps>;
|
|
11
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorLayout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/editorLayout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"editorLayout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/editorLayout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,UAAU,iBAAiB;IACzB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,UAAU,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AACD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4DpD,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Panels } from "../../types/fileTypes";
|
|
2
3
|
interface SidebarProps {
|
|
3
4
|
activePanel: string;
|
|
4
5
|
setActivePanel: (panel: string) => void;
|
|
5
|
-
allowedPannels:
|
|
6
|
+
allowedPannels: Panels[];
|
|
6
7
|
}
|
|
7
8
|
export declare const Sidebar: React.FC<SidebarProps>;
|
|
8
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/sidebar.tsx"],"names":[],"mappings":"AASA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,UAAU,YAAY;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AA4BD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA8B1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/sidebar.tsx"],"names":[],"mappings":"AASA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,UAAU,YAAY;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AA4BD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA8B1C,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),Et=require("@monaco-editor/react"),N=require("antd"),h=require("@tabler/icons-react");var H={exports:{}},$={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var _e;function wt(){if(_e)return $;_e=1;var i=w,r=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g={key:!0,ref:!0,__self:!0,__source:!0};function j(C,v,R){var d,F={},S=null,O=null;R!==void 0&&(S=""+R),v.key!==void 0&&(S=""+v.key),v.ref!==void 0&&(O=v.ref);for(d in v)o.call(v,d)&&!g.hasOwnProperty(d)&&(F[d]=v[d]);if(C&&C.defaultProps)for(d in v=C.defaultProps,v)F[d]===void 0&&(F[d]=v[d]);return{$$typeof:r,type:C,key:S,ref:O,props:F,_owner:c.current}}return $.Fragment=s,$.jsx=j,$.jsxs=j,$}var M={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
17
|
+
*/var Te;function Nt(){return Te||(Te=1,process.env.NODE_ENV!=="production"&&(function(){var i=w,r=Symbol.for("react.element"),s=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),j=Symbol.for("react.provider"),C=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),B=Symbol.iterator,G="@@iterator";function K(e){if(e===null||typeof e!="object")return null;var n=B&&e[B]||e[G];return typeof n=="function"?n:null}var b=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];We("error",e,a)}}function We(e,n,a){{var l=b.ReactDebugCurrentFrame,m=l.getStackAddendum();m!==""&&(n+="%s",a=a.concat([m]));var x=a.map(function(f){return String(f)});x.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,x)}}var Ye=!1,Ue=!1,qe=!1,He=!1,Je=!1,se;se=Symbol.for("react.module.reference");function Ge(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===g||Je||e===c||e===R||e===d||He||e===O||Ye||Ue||qe||typeof e=="object"&&e!==null&&(e.$$typeof===S||e.$$typeof===F||e.$$typeof===j||e.$$typeof===C||e.$$typeof===v||e.$$typeof===se||e.getModuleId!==void 0))}function Ke(e,n,a){var l=e.displayName;if(l)return l;var m=n.displayName||n.name||"";return m!==""?a+"("+m+")":a}function ae(e){return e.displayName||"Context"}function k(e){if(e==null)return null;if(typeof e.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case s:return"Portal";case g:return"Profiler";case c:return"StrictMode";case R:return"Suspense";case d:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case C:var n=e;return ae(n)+".Consumer";case j:var a=e;return ae(a._context)+".Provider";case v:return Ke(e,e.render,"ForwardRef");case F:var l=e.displayName||null;return l!==null?l:k(e.type)||"Memo";case S:{var m=e,x=m._payload,f=m._init;try{return k(f(x))}catch{return null}}}return null}var D=Object.assign,L=0,ie,oe,le,ce,de,ue,fe;function me(){}me.__reactDisabledLog=!0;function Xe(){{if(L===0){ie=console.log,oe=console.info,le=console.warn,ce=console.error,de=console.group,ue=console.groupCollapsed,fe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:me,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function Ze(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:ie}),info:D({},e,{value:oe}),warn:D({},e,{value:le}),error:D({},e,{value:ce}),group:D({},e,{value:de}),groupCollapsed:D({},e,{value:ue}),groupEnd:D({},e,{value:fe})})}L<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var X=b.ReactCurrentDispatcher,Z;function V(e,n,a){{if(Z===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);Z=l&&l[1]||""}return`
|
|
18
|
+
`+Z+e}}var Q=!1,W;{var Qe=typeof WeakMap=="function"?WeakMap:Map;W=new Qe}function he(e,n){if(!e||Q)return"";{var a=W.get(e);if(a!==void 0)return a}var l;Q=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var x;x=X.current,X.current=null,Xe();try{if(n){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(P){l=P}Reflect.construct(e,[],f)}else{try{f.call()}catch(P){l=P}e.call(f.prototype)}}else{try{throw Error()}catch(P){l=P}e()}}catch(P){if(P&&l&&typeof P.stack=="string"){for(var u=P.stack.split(`
|
|
19
19
|
`),_=l.stack.split(`
|
|
20
20
|
`),y=u.length-1,E=_.length-1;y>=1&&E>=0&&u[y]!==_[E];)E--;for(;y>=1&&E>=0;y--,E--)if(u[y]!==_[E]){if(y!==1||E!==1)do if(y--,E--,E<0||u[y]!==_[E]){var T=`
|
|
21
|
-
`+u[y].replace(" at new "," at ");return e.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",e.displayName)),typeof e=="function"&&W.set(e,T),T}while(y>=1&&E>=0);break}}}finally{
|
|
21
|
+
`+u[y].replace(" at new "," at ");return e.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",e.displayName)),typeof e=="function"&&W.set(e,T),T}while(y>=1&&E>=0);break}}}finally{Q=!1,X.current=x,Ze(),Error.prepareStackTrace=m}var z=e?e.displayName||e.name:"",Se=z?V(z):"";return typeof e=="function"&&W.set(e,Se),Se}function et(e,n,a){return he(e,!1)}function tt(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function Y(e,n,a){if(e==null)return"";if(typeof e=="function")return he(e,tt(e));if(typeof e=="string")return V(e);switch(e){case R:return V("Suspense");case d:return V("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return et(e.render);case F:return Y(e.type,n,a);case S:{var l=e,m=l._payload,x=l._init;try{return Y(x(m),n,a)}catch{}}}return""}var U=Object.prototype.hasOwnProperty,pe={},xe=b.ReactDebugCurrentFrame;function q(e){if(e){var n=e._owner,a=Y(e.type,e._source,n?n.type:null);xe.setExtraStackFrame(a)}else xe.setExtraStackFrame(null)}function rt(e,n,a,l,m){{var x=Function.call.bind(U);for(var f in e)if(x(e,f)){var u=void 0;try{if(typeof e[f]!="function"){var _=Error((l||"React class")+": "+a+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _.name="Invariant Violation",_}u=e[f](n,f,l,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){u=y}u&&!(u instanceof Error)&&(q(m),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",l||"React class",a,f,typeof u),q(null)),u instanceof Error&&!(u.message in pe)&&(pe[u.message]=!0,q(m),p("Failed %s type: %s",a,u.message),q(null))}}}var nt=Array.isArray;function ee(e){return nt(e)}function st(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,a=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a}}function at(e){try{return ve(e),!1}catch{return!0}}function ve(e){return""+e}function be(e){if(at(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",st(e)),ve(e)}var ge=b.ReactCurrentOwner,it={key:!0,ref:!0,__self:!0,__source:!0},ye,je;function ot(e){if(U.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function lt(e){if(U.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function ct(e,n){typeof e.ref=="string"&&ge.current}function dt(e,n){{var a=function(){ye||(ye=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}}function ut(e,n){{var a=function(){je||(je=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}}var ft=function(e,n,a,l,m,x,f){var u={$$typeof:r,type:e,key:n,ref:a,props:f,_owner:x};return u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(u,"_self",{configurable:!1,enumerable:!1,writable:!1,value:l}),Object.defineProperty(u,"_source",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u};function mt(e,n,a,l,m){{var x,f={},u=null,_=null;a!==void 0&&(be(a),u=""+a),lt(n)&&(be(n.key),u=""+n.key),ot(n)&&(_=n.ref,ct(n,m));for(x in n)U.call(n,x)&&!it.hasOwnProperty(x)&&(f[x]=n[x]);if(e&&e.defaultProps){var y=e.defaultProps;for(x in y)f[x]===void 0&&(f[x]=y[x])}if(u||_){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;u&&dt(f,E),_&&ut(f,E)}return ft(e,u,_,m,l,ge.current,f)}}var te=b.ReactCurrentOwner,Ee=b.ReactDebugCurrentFrame;function A(e){if(e){var n=e._owner,a=Y(e.type,e._source,n?n.type:null);Ee.setExtraStackFrame(a)}else Ee.setExtraStackFrame(null)}var re;re=!1;function ne(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function we(){{if(te.current){var e=k(te.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function ht(e){return""}var Ne={};function pt(e){{var n=we();if(!n){var a=typeof e=="string"?e:e.displayName||e.name;a&&(n=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+s+">.")}return n}}function Ne(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=ht(n);if(we[s])return;we[s]=!0;var l="";e&&e._owner&&e._owner!==ee.current&&(l=" It was passed a child from "+I(e._owner.type)+"."),D(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,l),D(null)}}function Ce(e,n){{if(typeof e!="object")return;if(Q(e))for(var s=0;s<e.length;s++){var l=e[s];re(l)&&Ne(l,n)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var m=G(e);if(typeof m=="function"&&m!==e.entries)for(var x=m.call(e),f;!(f=x.next()).done;)re(f.value)&&Ne(f.value,n)}}}function pt(e){{var n=e.type;if(n==null||typeof n=="string")return;var s;if(typeof n=="function")s=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===v||n.$$typeof===F))s=n.propTypes;else return;if(s){var l=I(n);tt(s,e.props,"prop",l,e)}else if(n.PropTypes!==void 0&&!te){te=!0;var m=I(n);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(e){{for(var n=Object.keys(e.props),s=0;s<n.length;s++){var l=n[s];if(l!=="children"&&l!=="key"){D(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",l),D(null);break}}e.ref!==null&&(D(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),D(null))}}function Fe(e,n,s,l,m,x){{var f=Je(e);if(!f){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var _=mt();_?u+=_:u+=Ee();var y;e===null?y="null":Q(e)?y="array":e!==void 0&&e.$$typeof===r?(y="<"+(I(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):y=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,u)}var E=ft(e,n,s,m,x);if(E==null)return E;if(f){var T=n.children;if(T!==void 0)if(l)if(Q(T)){for(var A=0;A<T.length;A++)Ce(T[A],e);Object.freeze&&Object.freeze(T)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ce(T,e)}return e===i?xt(E):pt(E),E}}function vt(e,n,s){return Fe(e,n,s,!0)}function bt(e,n,s){return Fe(e,n,s,!1)}var gt=bt,yt=vt;$.Fragment=i,$.jsx=gt,$.jsxs=yt})()),$}var Te;function Nt(){return Te||(Te=1,process.env.NODE_ENV==="production"?q.exports=Et():q.exports=wt()),q.exports}var t=Nt();function Pe(o){const[r,a]=w.useState([]),[i,c]=w.useState(null),[g,j]=w.useState(""),[C,v]=w.useState(!1),[R,d]=w.useState(null),F=w.useCallback(async()=>{try{v(!0),d(null);const b=await o.getFiles();if(a(b),!i&&b.length>0){const p=Oe(b);p&&c(p.id)}}catch(b){d(b instanceof Error?b.message:"Failed to load files")}finally{v(!1)}},[o,i]),S=w.useCallback(async b=>{try{v(!0),d(null);const p=await o.getFileContent(b);j(p)}catch(p){d(p instanceof Error?p.message:"Failed to load file content"),j("")}finally{v(!1)}},[o]),O=w.useCallback(async b=>{if(i)try{d(null),await o.updateFileContent(i,b),j(b),a(p=>ke(p,i,{content:b}))}catch(p){d(p instanceof Error?p.message:"Failed to update file content")}},[i,o]),M=w.useCallback(b=>{c(b),S(b)},[S]),J=w.useCallback(()=>{F()},[F]),G=w.useCallback(b=>Ie(r,b),[r]);return w.useEffect(()=>{F()},[F]),w.useEffect(()=>{i&&S(i)},[i,S]),{files:r,activeFile:i,fileContent:g,loading:C,error:R,setActiveFile:M,updateFileContent:O,refreshFiles:J,getFileById:G}}function Oe(o){for(const r of o){if(r.type==="file")return r;if(r.children){const a=Oe(r.children);if(a)return a}}return null}function Ie(o,r){for(const a of o){if(a.id===r)return a;if(a.children){const i=Ie(a.children,r);if(i)return i}}return null}function ke(o,r,a){return o.map(i=>i.id===r?{...i,...a}:i.children?{...i,children:ke(i.children,r,a)}:i)}class De{config;files=[];constructor(r){this.config=r}async getFiles(){return this.files.length===0&&await this.loadFiles(),this.files}async getFileContent(r){if(r==="main-function")return await this.config.fetchFunction(this.config.functionId,this.config.version);throw new Error(`File ${r} not found`)}async updateFileContent(r,a){const i=this.findFileById(r);i&&(i.content=a),console.log(`Updated file ${r} with content:`,a)}async getFileMetadata(r){return this.findFileById(r)?.metadata||{}}async loadFiles(){this.files=[{id:"main-function",name:"function.js",type:"file",path:"/function.js",metadata:{language:"javascript",lastModified:new Date}},{id:"versions",name:"versions",type:"folder",path:"/versions",children:this.config.versionList.map(r=>({id:`version-${r}`,name:`v${r}.js`,type:"file",path:`/versions/v${r}.js`,metadata:{language:"javascript"}}))}]}findFileById(r){const a=i=>{for(const c of i){if(c.id===r)return c;if(c.children){const g=a(c.children);if(g)return g}}return null};return a(this.files)}}class Ae{config;files=[];constructor(r){this.config=r,this.initializeFiles()}async getFiles(){return this.files}async getFileContent(r){if(r==="form-code")return this.config.codeContent;throw new Error(`File ${r} not found`)}async updateFileContent(r,a){if(r==="form-code"){this.config.codeContent=a;const i=this.files.find(c=>c.id===r);i&&(i.content=a)}}async getFileMetadata(r){return this.findFileById(r)?.metadata||{}}initializeFiles(){this.files=[{id:"form-code",name:this.config.fileName||"code.js",type:"file",path:`/${this.config.fileName||"code.js"}`,content:this.config.codeContent,metadata:{language:this.config.language||"javascript",lastModified:new Date}}]}findFileById(r){return this.files.find(a=>a.id===r)||null}}class ze{config;files=[];constructor(r){this.config=r,this.initializeFiles()}async getFiles(){return this.files}async getFileContent(r){const a=this.findFileById(r);if(!a||!a.metadata?.url)throw new Error(`File ${r} not found`);try{const i=await fetch(a.metadata.url);if(!i.ok)throw new Error(`Failed to fetch file: ${i.statusText}`);return await i.text()}catch(i){throw new Error(`Error fetching file content: ${i}`)}}async updateFileContent(r,a){console.log(`Would save file ${r} content to backend:`,a);const i=this.findFileById(r);i&&(i.content=a)}async getFileMetadata(r){return this.findFileById(r)?.metadata||{}}initializeFiles(){this.files=this.config.fileUrls.map((r,a)=>({id:`url-file-${a}`,name:r.name,type:"file",path:`/${r.name}`,metadata:{language:r.type,url:r.url,lastModified:new Date}}))}findFileById(r){return this.files.find(a=>a.id===r)||null}}function Le(o){if(o.workflowConfig)return new De(o.workflowConfig);if(o.formConfig)return new Ae(o.formConfig);if(o.urlConfig)return new ze(o.urlConfig);throw new Error("No valid configuration provided")}const $e=({value:o,onChange:r,language:a="javascript",filename:i,readOnly:c=!1,loading:g=!1})=>{const j=C=>{C!==void 0&&r(C)};return t.jsx("div",{className:"h-full w-full",children:t.jsx(jt,{height:"100%",defaultLanguage:a,defaultValue:o,onChange:j,theme:"vs-light",options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",automaticLayout:!0,padding:{top:16},scrollBeyondLastLine:!1,readOnly:c}})})},Ct=[{id:"explorer",icon:h.IconFolderOpen,label:"Files"},{id:"data",icon:h.IconDatabase,label:"Data"},{id:"functions",icon:h.IconCode,label:"Functions"},{id:"versions",icon:h.IconHistory,label:"Versions"},{id:"tests",icon:h.IconFlask,label:"Tests"}],Ft=({activePanel:o,setActivePanel:r,allowedPannels:a})=>{const i=w.useMemo(()=>Ct.filter(c=>a.includes(c.id)),[a]);return t.jsxs("div",{className:"w-14 border-r border-slate-200 bg-white flex flex-col gap-4 items-center py-4",children:[i.map(c=>{const g=c.icon;return t.jsx(N.Tooltip,{title:c.label,placement:"right",children:t.jsx(N.Button,{type:o===c.id?"primary":"text",icon:t.jsx(g,{size:16}),onClick:()=>r(c.id)})},c.id)}),t.jsx("div",{className:"mt-auto",children:t.jsx(N.Tooltip,{title:"Settings",placement:"right",children:t.jsx(N.Button,{type:"text",icon:t.jsx(h.IconSettings,{size:20})})})})]})},Me=({leftPanel:o,editor:r,rightPanel:a,activePanel:i,setActivePanel:c,allowedPannels:g=["explorer"]})=>t.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t.jsx(Ft,{activePanel:i,setActivePanel:c,allowedPannels:g}),t.jsx("div",{className:"flex-1",children:a?t.jsxs(N.Splitter,{style:{height:"100%"},onResize:j=>console.log(j),children:[t.jsx(N.Splitter.Panel,{defaultSize:"25%",min:"15%",max:"40%",className:"bg-white border-r border-slate-200",collapsible:!0,children:t.jsx("div",{className:"h-full overflow-y-auto",children:o})}),t.jsx(N.Splitter.Panel,{defaultSize:"50%",min:"30%",children:r}),t.jsx(N.Splitter.Panel,{defaultSize:"25%",min:"20%",max:"50%",className:"bg-white border-l border-slate-200",children:t.jsx("div",{className:"h-full overflow-y-auto",children:a})})]}):t.jsxs(N.Splitter,{style:{height:"100%"},children:[t.jsx(N.Splitter.Panel,{defaultSize:"25%",min:"15%",max:"40%",className:"bg-white border-r border-slate-200",children:t.jsx("div",{className:"h-full overflow-y-auto",children:o})}),t.jsx(N.Splitter.Panel,{defaultSize:"75%",min:"60%",children:r})]})})]}),Be=({files:o,activeFile:r,onFileSelect:a,loading:i=!1,error:c=null,onRefresh:g})=>{const j=R=>R.map(d=>({title:d.name,key:d.id,icon:d.type==="file"?t.jsx(h.IconFile,{size:16,className:"text-slate-500 flex"}):t.jsx(h.IconFolderOpen,{size:16,className:"text-slate-500 flex"}),isLeaf:d.type==="file",children:d.children?j(d.children):void 0,metadata:d.metadata})),C=j(o),v=(R,d)=>{d?.node.isLeaf&&d.node.key&&a(d.node.key)};return t.jsxs("div",{className:"h-full",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:[t.jsx("h2",{className:"font-medium text-sm",children:"Files"}),t.jsx("div",{className:"flex items-center gap-2",children:g&&t.jsx(N.Button,{type:"text",icon:t.jsx(h.IconPlus,{size:16}),onClick:g,loading:i,title:"Refresh files"})})]}),t.jsxs("div",{className:"p-2",children:[c&&t.jsx(N.Alert,{message:"Error loading files",description:c,type:"error",className:"mb-2"}),t.jsx(N.Tree,{treeData:C,onSelect:v,selectedKeys:r?[r]:[],showIcon:!0,defaultExpandAll:!0,showLine:!0,className:"file-explorer-tree"})]})]})},H=({config:o,rightPanel:r=!1})=>{const a=w.useMemo(()=>Le(o),[o]);console.log({config:o});const{files:i,activeFile:c,fileContent:g,loading:j,error:C,setActiveFile:v,updateFileContent:R,refreshFiles:d,getFileById:F}=Pe(a),S=c?F(c):null,O=S?.metadata?.language||"javascript";return t.jsx(Me,{leftPanel:t.jsx(Be,{files:i,activeFile:c,onFileSelect:v,loading:j,error:C,onRefresh:d}),editor:t.jsx($e,{value:g,onChange:R,language:O,filename:S?.name,readOnly:o.settings?.readOnly,loading:j}),rightPanel:r,activePanel:"explorer",setActivePanel:()=>{}})},Rt=({functionId:o,version:r,versionList:a,fetchFunction:i,fetchVersionList:c})=>{const g={workflowConfig:{functionId:o,version:r,versionList:a,fetchFunction:i,fetchVersionList:c}};return t.jsx(H,{config:g})},St=({codeContent:o,fileName:r="code.js",language:a="javascript",readOnly:i=!1})=>{const c={formConfig:{codeContent:o,fileName:r,language:a},settings:{readOnly:i}};return t.jsx(H,{config:c})},_t=({fileUrls:o,rightPanel:r})=>{const a={urlConfig:{fileUrls:o}};return t.jsx(H,{config:a,rightPanel:r})},Tt=({activeFile:o,showPreview:r,setShowPreview:a})=>t.jsxs("div",{className:"h-14 border-b border-slate-200 bg-white px-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("h1",{className:"text-lg font-semibold text-slate-900 mr-4",children:"CRM Code Editor"}),t.jsx("span",{className:"text-sm text-slate-500 px-2 py-1 bg-slate-100 rounded-md",children:o})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",onClick:()=>a(!r),title:r?"Hide Preview":"Show Preview",children:r?t.jsx(h.IconEyeOff,{size:18}):t.jsx(h.IconEye,{size:18})}),t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",title:"Version History",children:t.jsx(h.IconHistory,{size:18})}),t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",title:"Run Code",children:t.jsx(h.IconPlayerPlay,{size:18})}),t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",title:"Export",children:t.jsx(h.IconDownload,{size:18})}),t.jsxs("button",{className:"ml-2 px-3 py-1.5 bg-slate-900 text-white rounded-md flex items-center text-sm hover:bg-slate-800",children:[t.jsx(h.IconDeviceFloppy,{size:16,className:"mr-1.5"})," Save"]}),t.jsxs("div",{className:"ml-2 px-3 py-1.5 bg-emerald-100 text-emerald-800 rounded-md flex items-center text-sm",children:[t.jsx("span",{className:"w-2 h-2 bg-emerald-500 rounded-full mr-1.5"})," ","Draft"]})]})]}),Pt=()=>{const o=[{name:"Lead",fields:["id","name","email","phone","status","createdAt"],expanded:!0},{name:"Contact",fields:["id","firstName","lastName","email","phone"],expanded:!1},{name:"Account",fields:["id","name","industry","website","employees"],expanded:!1},{name:"Opportunity",fields:["id","name","amount","stage","closeDate"],expanded:!1}];return t.jsxs("div",{className:"h-full",children:[t.jsx("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:t.jsx("h2",{className:"font-medium text-sm",children:"Data Explorer"})}),t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"relative mb-3",children:[t.jsx(h.IconSearch,{size:16,className:"absolute left-2.5 top-2.5 text-slate-400"}),t.jsx("input",{type:"text",placeholder:"Search objects...",className:"w-full pl-8 pr-3 py-2 text-sm border border-slate-200 rounded-md focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),t.jsx("div",{children:o.map(r=>t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center p-2 hover:bg-slate-50 rounded-md cursor-pointer",children:[t.jsx(h.IconChevronRight,{size:16,className:`mr-1 text-slate-400 transition-transform ${r.expanded?"rotate-90":""}`}),t.jsx(h.IconDatabase,{size:16,className:"mr-2 text-slate-500"}),t.jsx("span",{className:"text-sm font-medium",children:r.name})]}),r.expanded&&t.jsx("div",{className:"ml-7 border-l border-slate-200 pl-2",children:r.fields.map(a=>t.jsx("div",{className:"flex items-center p-1.5 hover:bg-slate-50 rounded-md cursor-pointer",children:t.jsx("span",{className:"text-xs text-slate-600",children:a})},a))})]},r.name))})]})]})},Ot=()=>{const o=[{name:"formatCurrency",description:"Format a number as currency",category:"Formatting"},{name:"calculateDiscount",description:"Calculate discount based on amount",category:"Calculations"},{name:"getLeadData",description:"Fetch lead data from CRM",category:"Data Access"},{name:"updateContact",description:"Update contact information",category:"Data Modification"},{name:"sendEmail",description:"Send an email to a contact",category:"Communication"},{name:"validateEmail",description:"Validate email format",category:"Validation"}];return t.jsxs("div",{className:"h-full",children:[t.jsx("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:t.jsx("h2",{className:"font-medium text-sm",children:"Function Library"})}),t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"relative mb-3",children:[t.jsx(h.IconSearch,{size:16,className:"absolute left-2.5 top-2.5 text-slate-400"}),t.jsx("input",{type:"text",placeholder:"Search functions...",className:"w-full pl-8 pr-3 py-2 text-sm border border-slate-200 rounded-md focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),t.jsx("div",{children:o.map(r=>t.jsxs("div",{className:"p-2 border border-slate-200 rounded-md mb-2 hover:bg-slate-50 cursor-pointer",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx(h.IconCode,{size:16,className:"mr-2 text-slate-500"}),t.jsx("span",{className:"text-sm font-medium",children:r.name})]}),t.jsx("span",{className:"text-xs bg-slate-100 px-2 py-0.5 rounded text-slate-600",children:r.category})]}),t.jsx("p",{className:"text-xs text-slate-500 mt-1",children:r.description})]},r.name))}),t.jsxs("div",{className:"mt-4 p-3 bg-slate-50 rounded-md border border-slate-200 flex items-center",children:[t.jsx(h.IconBook,{size:16,className:"text-slate-500 mr-2"}),t.jsx("span",{className:"text-xs text-slate-600",children:"Browse documentation for more functions and examples"})]})]})]})},It=({code:o})=>{const[r,a]=w.useState(null),[i,c]=w.useState(!1),g="body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; padding: 1rem; }",C=(d=>d.replace(/import\s+.*axios.*from\s+['"]axios['"];?/g,"// Axios imports removed for preview").replace(/axios\./g,"/* axios. */").replace(/fetch\(/g,"/* fetch( */"))(o),v=`
|
|
25
|
+
Check the top-level render call using <`+a+">.")}return n}}function Ce(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=pt(n);if(Ne[a])return;Ne[a]=!0;var l="";e&&e._owner&&e._owner!==te.current&&(l=" It was passed a child from "+k(e._owner.type)+"."),A(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,l),A(null)}}function Fe(e,n){{if(typeof e!="object")return;if(ee(e))for(var a=0;a<e.length;a++){var l=e[a];ne(l)&&Ce(l,n)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var m=K(e);if(typeof m=="function"&&m!==e.entries)for(var x=m.call(e),f;!(f=x.next()).done;)ne(f.value)&&Ce(f.value,n)}}}function xt(e){{var n=e.type;if(n==null||typeof n=="string")return;var a;if(typeof n=="function")a=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===v||n.$$typeof===F))a=n.propTypes;else return;if(a){var l=k(n);rt(a,e.props,"prop",l,e)}else if(n.PropTypes!==void 0&&!re){re=!0;var m=k(n);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function vt(e){{for(var n=Object.keys(e.props),a=0;a<n.length;a++){var l=n[a];if(l!=="children"&&l!=="key"){A(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",l),A(null);break}}e.ref!==null&&(A(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function Re(e,n,a,l,m,x){{var f=Ge(e);if(!f){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var _=ht();_?u+=_:u+=we();var y;e===null?y="null":ee(e)?y="array":e!==void 0&&e.$$typeof===r?(y="<"+(k(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):y=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,u)}var E=mt(e,n,a,m,x);if(E==null)return E;if(f){var T=n.children;if(T!==void 0)if(l)if(ee(T)){for(var z=0;z<T.length;z++)Fe(T[z],e);Object.freeze&&Object.freeze(T)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Fe(T,e)}return e===o?vt(E):xt(E),E}}function bt(e,n,a){return Re(e,n,a,!0)}function gt(e,n,a){return Re(e,n,a,!1)}var yt=gt,jt=bt;M.Fragment=o,M.jsx=yt,M.jsxs=jt})()),M}var Pe;function Ct(){return Pe||(Pe=1,process.env.NODE_ENV==="production"?H.exports=wt():H.exports=Nt()),H.exports}var t=Ct();function Oe(i){const[r,s]=w.useState([]),[o,c]=w.useState(null),[g,j]=w.useState(""),[C,v]=w.useState(!1),[R,d]=w.useState(null),F=w.useCallback(async()=>{try{v(!0),d(null);const b=await i.getFiles();if(s(b),!o&&b.length>0){const p=Ie(b);p&&c(p.id)}}catch(b){d(b instanceof Error?b.message:"Failed to load files")}finally{v(!1)}},[i,o]),S=w.useCallback(async b=>{try{v(!0),d(null);const p=await i.getFileContent(b);j(p)}catch(p){d(p instanceof Error?p.message:"Failed to load file content"),j("")}finally{v(!1)}},[i]),O=w.useCallback(async b=>{if(o)try{d(null),await i.updateFileContent(o,b),j(b),s(p=>De(p,o,{content:b}))}catch(p){d(p instanceof Error?p.message:"Failed to update file content")}},[o,i]),B=w.useCallback(b=>{c(b),S(b)},[S]),G=w.useCallback(()=>{F()},[F]),K=w.useCallback(b=>ke(r,b),[r]);return w.useEffect(()=>{F()},[F]),w.useEffect(()=>{o&&S(o)},[o,S]),{files:r,activeFile:o,fileContent:g,loading:C,error:R,setActiveFile:B,updateFileContent:O,refreshFiles:G,getFileById:K}}function Ie(i){for(const r of i){if(r.type==="file")return r;if(r.children){const s=Ie(r.children);if(s)return s}}return null}function ke(i,r){for(const s of i){if(s.id===r)return s;if(s.children){const o=ke(s.children,r);if(o)return o}}return null}function De(i,r,s){return i.map(o=>o.id===r?{...o,...s}:o.children?{...o,children:De(o.children,r,s)}:o)}class Ae{config;files=[];constructor(r){this.config=r}async getFiles(){return this.files.length===0&&await this.loadFiles(),this.files}async getFileContent(r){if(r==="main-function")return await this.config.fetchFunction(this.config.functionId,this.config.version);throw new Error(`File ${r} not found`)}async updateFileContent(r,s){const o=this.findFileById(r);o&&(o.content=s),console.log(`Updated file ${r} with content:`,s)}async getFileMetadata(r){return this.findFileById(r)?.metadata||{}}async loadFiles(){this.files=[{id:"main-function",name:"function.js",type:"file",path:"/function.js",metadata:{language:"javascript",lastModified:new Date}},{id:"versions",name:"versions",type:"folder",path:"/versions",children:this.config.versionList.map(r=>({id:`version-${r}`,name:`v${r}.js`,type:"file",path:`/versions/v${r}.js`,metadata:{language:"javascript"}}))}]}findFileById(r){const s=o=>{for(const c of o){if(c.id===r)return c;if(c.children){const g=s(c.children);if(g)return g}}return null};return s(this.files)}}class ze{config;files=[];constructor(r){this.config=r,this.initializeFiles()}async getFiles(){return this.files}async getFileContent(r){if(r==="form-code")return this.config.codeContent;throw new Error(`File ${r} not found`)}async updateFileContent(r,s){if(r==="form-code"){this.config.codeContent=s;const o=this.files.find(c=>c.id===r);o&&(o.content=s)}}async getFileMetadata(r){return this.findFileById(r)?.metadata||{}}initializeFiles(){this.files=[{id:"form-code",name:this.config.fileName||"code.js",type:"file",path:`/${this.config.fileName||"code.js"}`,content:this.config.codeContent,metadata:{language:this.config.language||"javascript",lastModified:new Date}}]}findFileById(r){return this.files.find(s=>s.id===r)||null}}class Le{config;files=[];constructor(r){this.config=r,this.initializeFiles()}async getFiles(){return this.files}async getFileContent(r){const s=this.findFileById(r);if(!s||!s.metadata?.url)throw new Error(`File ${r} not found`);try{const o=await fetch(s.metadata.url);if(!o.ok)throw new Error(`Failed to fetch file: ${o.statusText}`);return await o.text()}catch(o){throw new Error(`Error fetching file content: ${o}`)}}async updateFileContent(r,s){console.log(`Would save file ${r} content to backend:`,s);const o=this.findFileById(r);o&&(o.content=s)}async getFileMetadata(r){return this.findFileById(r)?.metadata||{}}initializeFiles(){this.files=this.config.fileUrls.map((r,s)=>({id:`url-file-${s}`,name:r.name,type:"file",path:`/${r.name}`,metadata:{language:r.type,url:r.url,lastModified:new Date}}))}findFileById(r){return this.files.find(s=>s.id===r)||null}}function $e(i){if(i.workflowConfig)return new Ae(i.workflowConfig);if(i.formConfig)return new ze(i.formConfig);if(i.urlConfig)return new Le(i.urlConfig);throw new Error("No valid configuration provided")}const Me=({value:i,onChange:r,language:s="javascript",filename:o,readOnly:c=!1,loading:g=!1})=>{const j=C=>{C!==void 0&&r(C)};return t.jsx("div",{className:"h-full w-full",children:t.jsx(Et,{height:"100%",defaultLanguage:s,defaultValue:i,onChange:j,theme:"vs-light",options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",automaticLayout:!0,padding:{top:16},scrollBeyondLastLine:!1,readOnly:c}})})};var I=(i=>(i.Explorer="explorer",i.Data="data",i.Functions="functions",i.Versions="versions",i.Tests="tests",i))(I||{});const Ft=[{id:I.Explorer,icon:h.IconFolderOpen,label:"Files"},{id:I.Data,icon:h.IconDatabase,label:"Data"},{id:I.Functions,icon:h.IconCode,label:"Functions"},{id:I.Versions,icon:h.IconHistory,label:"Versions"},{id:I.Tests,icon:h.IconFlask,label:"Tests"}],Rt=({activePanel:i,setActivePanel:r,allowedPannels:s})=>{const o=w.useMemo(()=>Ft.filter(c=>s.includes(c.id)),[s]);return t.jsxs("div",{className:"w-14 border-r border-slate-200 bg-white flex flex-col gap-4 items-center py-4",children:[o.map(c=>{const g=c.icon;return t.jsx(N.Tooltip,{title:c.label,placement:"right",children:t.jsx(N.Button,{type:i===c.id?"primary":"text",icon:t.jsx(g,{size:16}),onClick:()=>r(c.id)})},c.id)}),t.jsx("div",{className:"mt-auto",children:t.jsx(N.Tooltip,{title:"Settings",placement:"right",children:t.jsx(N.Button,{type:"text",icon:t.jsx(h.IconSettings,{size:20})})})})]})},Be=({leftPanel:i,editor:r,rightPanel:s,activePanel:o,setActivePanel:c,allowedPannels:g=[I.Explorer]})=>t.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t.jsx(Rt,{activePanel:o,setActivePanel:c,allowedPannels:g}),t.jsx("div",{className:"flex-1",children:s?t.jsxs(N.Splitter,{style:{height:"100%"},onResize:j=>console.log(j),children:[t.jsx(N.Splitter.Panel,{defaultSize:"25%",min:"15%",max:"40%",className:"bg-white border-r border-slate-200",collapsible:!0,children:t.jsx("div",{className:"h-full overflow-y-auto",children:i})}),t.jsx(N.Splitter.Panel,{defaultSize:"50%",min:"30%",children:r}),t.jsx(N.Splitter.Panel,{defaultSize:"25%",min:"20%",max:"50%",className:"bg-white border-l border-slate-200",children:t.jsx("div",{className:"h-full overflow-y-auto",children:s})})]}):t.jsxs(N.Splitter,{style:{height:"100%"},children:[t.jsx(N.Splitter.Panel,{defaultSize:"25%",min:"15%",max:"40%",className:"bg-white border-r border-slate-200",children:t.jsx("div",{className:"h-full overflow-y-auto",children:i})}),t.jsx(N.Splitter.Panel,{defaultSize:"75%",min:"60%",children:r})]})})]}),Ve=({files:i,activeFile:r,onFileSelect:s,loading:o=!1,error:c=null,onRefresh:g})=>{const j=R=>R.map(d=>({title:d.name,key:d.id,icon:d.type==="file"?t.jsx(h.IconFile,{size:16,className:"text-slate-500 flex"}):t.jsx(h.IconFolderOpen,{size:16,className:"text-slate-500 flex"}),isLeaf:d.type==="file",children:d.children?j(d.children):void 0,metadata:d.metadata})),C=j(i),v=(R,d)=>{d?.node.isLeaf&&d.node.key&&s(d.node.key)};return t.jsxs("div",{className:"h-full",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:[t.jsx("h2",{className:"font-medium text-sm",children:"Files"}),t.jsx("div",{className:"flex items-center gap-2",children:g&&t.jsx(N.Button,{type:"text",icon:t.jsx(h.IconPlus,{size:16}),onClick:g,loading:o,title:"Refresh files"})})]}),t.jsxs("div",{className:"p-2",children:[c&&t.jsx(N.Alert,{message:"Error loading files",description:c,type:"error",className:"mb-2"}),t.jsx(N.Tree,{treeData:C,onSelect:v,selectedKeys:r?[r]:[],showIcon:!0,defaultExpandAll:!0,showLine:!0,className:"file-explorer-tree"})]})]})},J=({config:i,rightPanel:r=!1})=>{const s=w.useMemo(()=>$e(i),[i]);console.log({config:i});const{files:o,activeFile:c,fileContent:g,loading:j,error:C,setActiveFile:v,updateFileContent:R,refreshFiles:d,getFileById:F}=Oe(s),S=c?F(c):null,O=S?.metadata?.language||"javascript";return t.jsx(Be,{leftPanel:t.jsx(Ve,{files:o,activeFile:c,onFileSelect:v,loading:j,error:C,onRefresh:d}),editor:t.jsx(Me,{value:g,onChange:R,language:O,filename:S?.name,readOnly:i.settings?.readOnly,loading:j}),rightPanel:r,activePanel:"explorer",setActivePanel:()=>{}})},St=({functionId:i,version:r,versionList:s,fetchFunction:o,fetchVersionList:c})=>{const g={workflowConfig:{functionId:i,version:r,versionList:s,fetchFunction:o,fetchVersionList:c}};return t.jsx(J,{config:g})},_t=({codeContent:i,fileName:r="code.js",language:s="javascript",readOnly:o=!1})=>{const c={formConfig:{codeContent:i,fileName:r,language:s},settings:{readOnly:o}};return t.jsx(J,{config:c})},Tt=({fileUrls:i,rightPanel:r})=>{const s={urlConfig:{fileUrls:i}};return t.jsx(J,{config:s,rightPanel:r})},Pt=({activeFile:i,showPreview:r,setShowPreview:s})=>t.jsxs("div",{className:"h-14 border-b border-slate-200 bg-white px-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("h1",{className:"text-lg font-semibold text-slate-900 mr-4",children:"CRM Code Editor"}),t.jsx("span",{className:"text-sm text-slate-500 px-2 py-1 bg-slate-100 rounded-md",children:i})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",onClick:()=>s(!r),title:r?"Hide Preview":"Show Preview",children:r?t.jsx(h.IconEyeOff,{size:18}):t.jsx(h.IconEye,{size:18})}),t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",title:"Version History",children:t.jsx(h.IconHistory,{size:18})}),t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",title:"Run Code",children:t.jsx(h.IconPlayerPlay,{size:18})}),t.jsx("button",{className:"p-1.5 hover:bg-slate-100 rounded-md text-slate-600",title:"Export",children:t.jsx(h.IconDownload,{size:18})}),t.jsxs("button",{className:"ml-2 px-3 py-1.5 bg-slate-900 text-white rounded-md flex items-center text-sm hover:bg-slate-800",children:[t.jsx(h.IconDeviceFloppy,{size:16,className:"mr-1.5"})," Save"]}),t.jsxs("div",{className:"ml-2 px-3 py-1.5 bg-emerald-100 text-emerald-800 rounded-md flex items-center text-sm",children:[t.jsx("span",{className:"w-2 h-2 bg-emerald-500 rounded-full mr-1.5"})," ","Draft"]})]})]}),Ot=()=>{const i=[{name:"Lead",fields:["id","name","email","phone","status","createdAt"],expanded:!0},{name:"Contact",fields:["id","firstName","lastName","email","phone"],expanded:!1},{name:"Account",fields:["id","name","industry","website","employees"],expanded:!1},{name:"Opportunity",fields:["id","name","amount","stage","closeDate"],expanded:!1}];return t.jsxs("div",{className:"h-full",children:[t.jsx("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:t.jsx("h2",{className:"font-medium text-sm",children:"Data Explorer"})}),t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"relative mb-3",children:[t.jsx(h.IconSearch,{size:16,className:"absolute left-2.5 top-2.5 text-slate-400"}),t.jsx("input",{type:"text",placeholder:"Search objects...",className:"w-full pl-8 pr-3 py-2 text-sm border border-slate-200 rounded-md focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),t.jsx("div",{children:i.map(r=>t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center p-2 hover:bg-slate-50 rounded-md cursor-pointer",children:[t.jsx(h.IconChevronRight,{size:16,className:`mr-1 text-slate-400 transition-transform ${r.expanded?"rotate-90":""}`}),t.jsx(h.IconDatabase,{size:16,className:"mr-2 text-slate-500"}),t.jsx("span",{className:"text-sm font-medium",children:r.name})]}),r.expanded&&t.jsx("div",{className:"ml-7 border-l border-slate-200 pl-2",children:r.fields.map(s=>t.jsx("div",{className:"flex items-center p-1.5 hover:bg-slate-50 rounded-md cursor-pointer",children:t.jsx("span",{className:"text-xs text-slate-600",children:s})},s))})]},r.name))})]})]})},It=()=>{const i=[{name:"formatCurrency",description:"Format a number as currency",category:"Formatting"},{name:"calculateDiscount",description:"Calculate discount based on amount",category:"Calculations"},{name:"getLeadData",description:"Fetch lead data from CRM",category:"Data Access"},{name:"updateContact",description:"Update contact information",category:"Data Modification"},{name:"sendEmail",description:"Send an email to a contact",category:"Communication"},{name:"validateEmail",description:"Validate email format",category:"Validation"}];return t.jsxs("div",{className:"h-full",children:[t.jsx("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:t.jsx("h2",{className:"font-medium text-sm",children:"Function Library"})}),t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"relative mb-3",children:[t.jsx(h.IconSearch,{size:16,className:"absolute left-2.5 top-2.5 text-slate-400"}),t.jsx("input",{type:"text",placeholder:"Search functions...",className:"w-full pl-8 pr-3 py-2 text-sm border border-slate-200 rounded-md focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),t.jsx("div",{children:i.map(r=>t.jsxs("div",{className:"p-2 border border-slate-200 rounded-md mb-2 hover:bg-slate-50 cursor-pointer",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx(h.IconCode,{size:16,className:"mr-2 text-slate-500"}),t.jsx("span",{className:"text-sm font-medium",children:r.name})]}),t.jsx("span",{className:"text-xs bg-slate-100 px-2 py-0.5 rounded text-slate-600",children:r.category})]}),t.jsx("p",{className:"text-xs text-slate-500 mt-1",children:r.description})]},r.name))}),t.jsxs("div",{className:"mt-4 p-3 bg-slate-50 rounded-md border border-slate-200 flex items-center",children:[t.jsx(h.IconBook,{size:16,className:"text-slate-500 mr-2"}),t.jsx("span",{className:"text-xs text-slate-600",children:"Browse documentation for more functions and examples"})]})]})]})},kt=({code:i})=>{const[r,s]=w.useState(null),[o,c]=w.useState(!1),g="body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; padding: 1rem; }",C=(d=>d.replace(/import\s+.*axios.*from\s+['"]axios['"];?/g,"// Axios imports removed for preview").replace(/axios\./g,"/* axios. */").replace(/fetch\(/g,"/* fetch( */"))(i),v=`
|
|
26
26
|
<!DOCTYPE html>
|
|
27
27
|
<html>
|
|
28
28
|
<head>
|
|
@@ -51,4 +51,4 @@ Check the top-level render call using <`+s+">.")}return n}}function Ne(e,n){{if(
|
|
|
51
51
|
<\/script>
|
|
52
52
|
</body>
|
|
53
53
|
</html>
|
|
54
|
-
`,R=()=>{c(!0),
|
|
54
|
+
`,R=()=>{c(!0),s(null),setTimeout(()=>c(!1),300)};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:[t.jsx("h2",{className:"font-medium text-sm",children:"Preview"}),t.jsx("button",{className:"p-1 hover:bg-slate-100 rounded-md",onClick:R,children:t.jsx(h.IconRefresh,{size:16,className:o?"animate-spin":""})})]}),t.jsx("div",{className:"flex-1 bg-white overflow-auto",children:r?t.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-md flex items-start",children:[t.jsx(h.IconAlertTriangle,{size:16,className:"text-red-500 mr-2 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-red-800",children:"Preview Error"}),t.jsx("p",{className:"text-xs text-red-600",children:r})]})]}):t.jsx("iframe",{title:"Preview",className:"w-full h-full",srcDoc:v,sandbox:"allow-scripts",onError:()=>s("Failed to load preview")})})]})},Dt=()=>{const i=[{id:"1",name:"Should format currency correctly",status:"passed",duration:"12ms"},{id:"2",name:"Should calculate discount",status:"passed",duration:"8ms"},{id:"3",name:"Should validate email format",status:"failed",duration:"5ms",error:"Expected true but received false"},{id:"4",name:"Should handle empty input",status:"passed",duration:"3ms"}];return t.jsxs("div",{className:"h-full",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:[t.jsx("h2",{className:"font-medium text-sm",children:"Test Runner"}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{className:"p-1 hover:bg-slate-100 rounded-md mr-1",children:t.jsx(h.IconSettings,{size:14})}),t.jsxs("button",{className:"bg-slate-900 text-white text-xs px-2 py-1 rounded-md flex items-center",children:[t.jsx(h.IconPlayerPlay,{size:12,className:"mr-1"})," Run Tests"]})]})]}),t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"mb-3 p-2 bg-slate-50 rounded-md border border-slate-200",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-medium",children:"Test Summary"}),t.jsx("span",{className:"text-xs",children:"3 passed, 1 failed, 4 total"})]}),t.jsx("div",{className:"w-full h-2 bg-slate-200 rounded-full mt-2 overflow-hidden",children:t.jsx("div",{className:"h-full bg-emerald-500",style:{width:"75%"}})})]}),t.jsx("div",{children:i.map(r=>t.jsxs("div",{className:`p-2 mb-2 rounded-md ${r.status==="failed"?"bg-red-50 border border-red-100":"bg-slate-50 border border-slate-200"}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[r.status==="passed"?t.jsx(h.IconCircleCheck,{size:16,className:"text-emerald-500 mr-2"}):t.jsx(h.IconCircleX,{size:16,className:"text-red-500 mr-2"}),t.jsx("span",{className:"text-sm",children:r.name})]}),t.jsx("span",{className:"text-xs text-slate-500",children:r.duration})]}),r.error&&t.jsx("div",{className:"mt-2 text-xs text-red-600 bg-red-50 p-2 rounded",children:r.error})]},r.id))}),t.jsx("div",{className:"mt-4",children:t.jsx("button",{className:"w-full py-2 border border-dashed border-slate-300 rounded-md text-sm text-slate-500 hover:bg-slate-50",children:"+ Add New Test Case"})})]})]})},At=()=>{const i=[{id:"v1",name:"Initial version",author:"John Doe",timestamp:"Today, 2:30 PM",current:!0},{id:"v2",name:"Added form validation",author:"John Doe",timestamp:"Today, 1:15 PM",current:!1},{id:"v3",name:"Fixed API integration",author:"Sarah Smith",timestamp:"Yesterday, 4:45 PM",current:!1},{id:"v4",name:"Initial setup",author:"Sarah Smith",timestamp:"Yesterday, 11:30 AM",current:!1}];return t.jsxs("div",{className:"h-full",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200",children:[t.jsx("h2",{className:"font-medium text-sm",children:"Version History"}),t.jsx("button",{className:"text-xs text-slate-500 hover:text-slate-800",children:"Save Version"})]}),t.jsx("div",{className:"p-2",children:i.map(r=>t.jsxs("div",{className:`p-3 mb-2 rounded-md ${r.current?"bg-slate-100 border border-slate-200":"hover:bg-slate-50 cursor-pointer"}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-medium",children:r.name}),r.current&&t.jsx("span",{className:"text-xs bg-emerald-100 text-emerald-800 px-2 py-0.5 rounded",children:"Current"})]}),t.jsxs("div",{className:"flex items-center mt-1 text-xs text-slate-500",children:[t.jsx(h.IconUser,{size:12,className:"mr-1"}),t.jsx("span",{className:"mr-3",children:r.author}),t.jsx(h.IconClock,{size:12,className:"mr-1"}),t.jsx("span",{children:r.timestamp})]}),!r.current&&t.jsx("div",{className:"mt-2",children:t.jsxs("button",{className:"text-xs flex items-center text-slate-600 hover:text-slate-900",children:[t.jsx(h.IconRotate,{size:12,className:"mr-1"})," Restore this version"]})})]},r.id))})]})},zt="1.0.0";Object.defineProperty(exports,"Alert",{enumerable:!0,get:()=>N.Alert});Object.defineProperty(exports,"Button",{enumerable:!0,get:()=>N.Button});Object.defineProperty(exports,"Splitter",{enumerable:!0,get:()=>N.Splitter});Object.defineProperty(exports,"Tooltip",{enumerable:!0,get:()=>N.Tooltip});Object.defineProperty(exports,"Tree",{enumerable:!0,get:()=>N.Tree});exports.CodeEditor=Me;exports.CodeEditorWrapper=J;exports.DataExplorer=Ot;exports.EditorLayout=Be;exports.FileExplorer=Ve;exports.FormCodeEditor=_t;exports.FormFileProvider=ze;exports.FunctionLibrary=It;exports.Header=Pt;exports.Panels=I;exports.PreviewPanel=kt;exports.TestRunner=Dt;exports.URLCodeEditor=Tt;exports.URLFileProvider=Le;exports.VERSION=zt;exports.VersionHistory=At;exports.WorkflowCodeEditor=St;exports.WorkflowFileProvider=Ae;exports.createFileProvider=$e;exports.useFileManager=Oe;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { FunctionLibrary } from "./components/panels/functionLibrary";
|
|
|
8
8
|
export { PreviewPanel } from "./components/panels/previewPanel";
|
|
9
9
|
export { TestRunner } from "./components/panels/testRunner";
|
|
10
10
|
export { VersionHistory } from "./components/panels/versionHistory";
|
|
11
|
+
export { Panels } from "./types/fileTypes";
|
|
11
12
|
export { createFileProvider, FormFileProvider, URLFileProvider, WorkflowFileProvider, } from "./providers/fileProviders";
|
|
12
13
|
export { useFileManager } from "./hooks/useFileManager";
|
|
13
14
|
export type { CodeEditorConfig, FileNode, FileProvider, } from "./types/fileTypes";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,YAAY,EACV,gBAAgB,EAChB,QAAQ,EACR,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EACL,cAAc,EACd,aAAa,EACb,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG9D,eAAO,MAAM,OAAO,UAAU,CAAC"}
|