@vuu-ui/vuu-shell 0.8.21 → 0.8.22-debug
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/cjs/index.js +3111 -2
- package/cjs/index.js.map +2 -2
- package/esm/index.js +3126 -2
- package/esm/index.js.map +2 -2
- package/index.css +1217 -1
- package/index.css.map +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -201
package/esm/index.js
CHANGED
|
@@ -1,3 +1,3127 @@
|
|
|
1
|
-
var ne=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var kt=(t,e,o)=>(ne(t,e,"read from private field"),o?o.call(t):e.get(t)),re=(t,e,o)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,o)},ie=(t,e,o,a)=>(ne(t,e,"write to private field"),a?a.call(t,o):e.set(t,o),o);import{useCallback as Bo}from"react";import{Toolbar as Io}from"@vuu-ui/vuu-layout";import Oo from"clsx";import{useCallback as ue,useEffect as ko,useRef as Ao,useState as le}from"react";import{Button as Vo,FormField as ce,FormFieldLabel as de}from"@salt-ds/core";import{VuuInput as pe}from"@vuu-ui/vuu-ui-controls";import{useMemo as Do}from"react";import{jsx as P,jsxs as _}from"react/jsx-runtime";var se=()=>Do(()=>_("svg",{width:"184",height:"90",viewBox:"0 0 184 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_("g",{clipPath:"url(#clip0_1173_59965)",children:[P("path",{d:"M77.0775 31.1019L69.4572 15.1795L66.3997 13.7093L47.6353 44.165L75.7224 61.2361L81.8124 51.2694L77.0775 31.1019Z",fill:"url(#paint0_linear_1173_59965)"}),P("path",{d:"M82.4101 49.7431C81.0488 51.8314 79.1993 53.648 76.8897 54.9809C74.2954 56.4792 71.4601 57.194 68.6623 57.194C63.3422 57.194 58.1597 54.6188 55.0209 49.971L30.5358 7.8193L30.5232 7.84116C25.8791 0.274825 16.0118 -2.26289 8.27258 2.21011C0.411306 6.74866 -2.26753 16.7872 2.28587 24.625L35.5054 81.8189C36.9856 84.3691 39.0542 86.3668 41.4358 87.7527C41.4545 87.7652 41.4733 87.7777 41.4921 87.7902C41.5015 87.7964 41.514 87.8027 41.5234 87.8089C42.6312 88.4457 43.8079 88.942 45.0253 89.3072C45.116 89.3353 45.2099 89.3634 45.3007 89.3883C45.7388 89.5101 46.1801 89.6193 46.6276 89.7067C46.7121 89.7223 46.7966 89.7317 46.8811 89.7473C47.241 89.8097 47.604 89.8628 47.967 89.9003C48.111 89.9159 48.2549 89.9315 48.3989 89.9408C48.8151 89.9752 49.2313 89.997 49.6507 90.0001C49.6726 90.0001 49.6945 90.0001 49.7132 90.0001C49.7195 90.0001 49.7226 90.0001 49.7289 90.0001C49.7352 90.0001 49.7383 90.0001 49.7445 90.0001C50.1983 90.0001 50.6552 89.9752 51.109 89.9377C51.2123 89.9283 51.3155 89.919 51.422 89.9065C51.8663 89.8597 52.3107 89.8004 52.7551 89.7192C52.7614 89.7192 52.7676 89.7192 52.7739 89.7192C53.2621 89.6287 53.7503 89.5101 54.2322 89.3727C54.2635 89.3634 54.2917 89.354 54.323 89.3446C55.024 89.1418 55.7156 88.8889 56.3978 88.5861C56.4104 88.5799 56.426 88.5736 56.4385 88.5674C56.958 88.3364 57.4712 88.0836 57.9751 87.7933C58.4852 87.4999 58.9703 87.1815 59.4334 86.8413C59.8371 86.5478 60.2252 86.2357 60.6039 85.9048C61.0639 85.499 61.4989 85.0745 61.9026 84.6282C62.2062 84.2942 62.4972 83.9446 62.7757 83.5825C62.8665 83.4639 62.951 83.3421 63.0355 83.2235C63.2264 82.9613 63.4079 82.6929 63.5831 82.4182C63.6739 82.2746 63.7646 82.1342 63.8523 81.9906C63.8867 81.9344 63.9242 81.8813 63.9555 81.8251L82.5854 49.7525H82.4039L82.4101 49.7431Z",fill:"url(#paint1_linear_1173_59965)"}),P("path",{d:"M82.8264 32.8436L81.4181 30.4464L75.3375 19.1687L72.5178 14.3929C71.9858 13.1225 70.7309 12.2266 69.26 12.2266C67.3104 12.2266 65.7331 13.8029 65.7331 15.7445C65.7331 16.4031 65.924 17.0086 66.2401 17.5362L66.2025 17.5611L77.1557 36.1617C78.4764 38.4372 78.83 41.0873 78.1509 43.6281C77.4718 46.169 75.8445 48.2915 73.5631 49.6119C72.0609 50.4797 70.3553 50.9385 68.6341 50.9385C65.1166 50.9385 61.84 49.0563 60.0812 46.0285L44.3368 19.2654H44.3681L37.7179 7.81917L37.7054 7.84102C37.5896 7.65061 37.455 7.47893 37.333 7.29477L37.1452 6.97326C37.1452 6.97326 37.1296 6.98262 37.1233 6.98887C34.0001 2.55332 29.0054 0.0780356 23.8512 0.0187285V0H15.3515V0.0436999C21.2881 -0.368328 27.2247 2.46593 30.5232 7.84102L30.5357 7.81917L55.0177 49.974C58.1566 54.6187 63.3422 57.197 68.6592 57.197C71.4569 57.197 74.2922 56.4853 76.8866 54.9839C79.1961 53.651 81.0425 51.8312 82.407 49.7461H82.5885L82.5259 49.8523C83.399 48.4695 84.0687 46.9462 84.5006 45.3231C85.6304 41.0904 85.042 36.6705 82.8201 32.8467L82.8264 32.8436Z",fill:"#F37880"}),_("g",{opacity:"0.86",children:[P("path",{d:"M66.1994 17.5642L77.1526 36.1648C78.4732 38.4403 78.8269 41.0904 78.1478 43.6313C77.7347 45.1795 76.9648 46.5716 75.9133 47.7234C77.2903 46.4686 78.2823 44.8486 78.7737 43.007C79.4527 40.4661 79.0991 37.816 77.7785 35.5405L66.8253 16.94L66.8628 16.915C66.5467 16.3875 66.3558 15.7819 66.3558 15.1233C66.3558 14.3117 66.6344 13.5657 67.0975 12.9695C66.2651 13.6125 65.7299 14.6176 65.7299 15.7476C65.7299 16.4062 65.9208 17.0118 66.2369 17.5393L66.1994 17.5642Z",fill:"white"}),P("path",{d:"M82.5382 49.8335L82.5291 49.8487C82.5291 49.8487 82.5352 49.8365 82.5413 49.8304C82.5413 49.8304 82.5413 49.8304 82.5413 49.8335H82.5382Z",fill:"white"}),P("path",{d:"M77.5156 54.3596C74.9213 55.8579 72.0859 56.5727 69.2882 56.5727C63.9681 56.5727 58.7856 53.9975 55.6467 49.3497L31.1616 7.19488L31.1491 7.21673C28.9053 3.56154 25.4441 1.08626 21.5917 0H15.3515V0.0436999C21.2881 -0.368328 27.2247 2.46593 30.5232 7.84102L30.5357 7.81917L55.0177 49.974C58.1566 54.6187 63.3422 57.197 68.6592 57.197C71.4569 57.197 74.2922 56.4853 76.8866 54.9839C78.2698 54.1848 79.4809 53.2109 80.5293 52.1122C79.6311 52.9581 78.6266 53.7166 77.5125 54.3596H77.5156Z",fill:"white"})]})]}),P("path",{d:"M117.046 58.661C116.362 58.661 115.792 58.509 115.336 58.205C114.906 57.8757 114.551 57.3943 114.272 56.761L104.354 34.493C104.076 33.8597 104 33.3023 104.126 32.821C104.253 32.3397 104.519 31.9597 104.924 31.681C105.33 31.4023 105.811 31.263 106.368 31.263C107.103 31.263 107.648 31.4277 108.002 31.757C108.382 32.061 108.699 32.5297 108.952 33.163L117.958 54.025H116.324L125.292 33.125C125.571 32.517 125.9 32.061 126.28 31.757C126.66 31.4277 127.192 31.263 127.876 31.263C128.434 31.263 128.89 31.4023 129.244 31.681C129.624 31.9597 129.865 32.3397 129.966 32.821C130.068 33.3023 129.979 33.8597 129.7 34.493L119.782 56.761C119.504 57.3943 119.149 57.8757 118.718 58.205C118.313 58.509 117.756 58.661 117.046 58.661Z",fill:"white"}),P("path",{d:"M144.63 58.737C142.781 58.737 141.147 58.4963 139.728 58.015C138.335 57.5337 137.157 56.8243 136.194 55.887C135.232 54.9243 134.51 53.7337 134.028 52.315C133.547 50.8963 133.306 49.2497 133.306 47.375V33.733C133.306 32.897 133.509 32.2763 133.914 31.871C134.345 31.4657 134.953 31.263 135.738 31.263C136.524 31.263 137.119 31.4657 137.524 31.871C137.955 32.2763 138.17 32.897 138.17 33.733V47.337C138.17 49.7437 138.715 51.555 139.804 52.771C140.919 53.9617 142.528 54.557 144.63 54.557C146.733 54.557 148.329 53.9617 149.418 52.771C150.508 51.555 151.052 49.7437 151.052 47.337V33.733C151.052 32.897 151.255 32.2763 151.66 31.871C152.091 31.4657 152.699 31.263 153.484 31.263C154.244 31.263 154.827 31.4657 155.232 31.871C155.663 32.2763 155.878 32.897 155.878 33.733V47.375C155.878 49.8577 155.448 51.9477 154.586 53.645C153.75 55.3423 152.496 56.6217 150.824 57.483C149.152 58.319 147.088 58.737 144.63 58.737Z",fill:"white"}),P("path",{d:"M172.685 58.737C170.836 58.737 169.202 58.4963 167.783 58.015C166.39 57.5337 165.212 56.8243 164.249 55.887C163.286 54.9243 162.564 53.7337 162.083 52.315C161.602 50.8963 161.361 49.2497 161.361 47.375V33.733C161.361 32.897 161.564 32.2763 161.969 31.871C162.4 31.4657 163.008 31.263 163.793 31.263C164.578 31.263 165.174 31.4657 165.579 31.871C166.01 32.2763 166.225 32.897 166.225 33.733V47.337C166.225 49.7437 166.77 51.555 167.859 52.771C168.974 53.9617 170.582 54.557 172.685 54.557C174.788 54.557 176.384 53.9617 177.473 52.771C178.562 51.555 179.107 49.7437 179.107 47.337V33.733C179.107 32.897 179.31 32.2763 179.715 31.871C180.146 31.4657 180.754 31.263 181.539 31.263C182.299 31.263 182.882 31.4657 183.287 31.871C183.718 32.2763 183.933 32.897 183.933 33.733V47.375C183.933 49.8577 183.502 51.9477 182.641 53.645C181.805 55.3423 180.551 56.6217 178.879 57.483C177.207 58.319 175.142 58.737 172.685 58.737Z",fill:"white"}),_("defs",{children:[_("linearGradient",{id:"paint0_linear_1173_59965",x1:"47.6353",y1:"37.4727",x2:"81.8124",y2:"37.4727",gradientUnits:"userSpaceOnUse",children:[P("stop",{stopColor:"#4906A5"}),P("stop",{offset:"1",stopColor:"#D3423A"})]}),_("linearGradient",{id:"paint1_linear_1173_59965",x1:"0.0670626",y1:"45.0017",x2:"82.5916",y2:"45.0017",gradientUnits:"userSpaceOnUse",children:[P("stop",{stopColor:"#7C06A5"}),P("stop",{offset:"1",stopColor:"#D3423A"})]}),P("clipPath",{id:"clip0_1173_59965",children:P("rect",{width:"85",height:"90",fill:"white",transform:"translate(0.0670471)"})})]})]}),[]);import Fo from"clsx";import{jsx as B,jsxs as et}from"react/jsx-runtime";var J="vuuLoginPanel",Yr=({appName:t="Demo App",className:e,requirePassword:o=!0,onSubmit:a,...n})=>{let[r,i]=le(""),[s,u]=le(""),c=Ao(null),d=()=>{a(r,s)},h=f=>{i(f.target.value)},y=f=>{u(f.target.value)},v=ue(()=>{o||a(r)},[a,o,r]),p=ue(()=>{r&&a(r,s)},[a,s,r]),l=r.trim()!==""&&(o===!1||s.trim()!=="");return ko(()=>{var f;console.log("inputRef",{input:c.current}),(f=c.current)==null||f.focus()},[]),et("div",{...n,className:Fo(J,e),children:[et("div",{className:`${J}-branding`,children:[B(se,{}),B("div",{className:`${J}-appName`,children:t})]}),et("div",{className:`${J}-form`,children:[B("div",{className:`${J}-title`,children:"Welcome Back"}),et(ce,{children:[B(de,{children:"Username"}),B(pe,{value:r,id:"text-username",inputRef:c,onChange:h,onCommit:v})]}),o?et(ce,{children:[B(de,{children:"Password"}),B(pe,{className:`${J}-password`,inputProps:{type:"password"},value:s,id:"text-password",onChange:y,onCommit:p,endAdornment:B("span",{"data-icon":"eye",style:{cursor:"pointer"}})})]}):null,B(Vo,{className:`${J}-login`,disabled:!l,onClick:d,variant:"cta",children:"Login"})]})]})};import{getCookieValue as At}from"@vuu-ui/vuu-utils";var Ho=()=>{let t=At("vuu-auth-mode");return t!=null?t:""},ot=()=>{let t=At("vuu-username"),e=At("vuu-auth-token");return[t,e]},Ro=()=>Ho()==="login"?"login.html":"demo.html",$o=(t=Ro())=>{window.location.href=t},me=t=>{document.cookie="vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",document.cookie="vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",$o(t)};import{Button as ct}from"@salt-ds/core";import{jsx as dt,jsxs as Vt}from"react/jsx-runtime";var at="vuuAppHeader",he=({className:t,layoutId:e,loginUrl:o,onNavigate:a,onSwitchTheme:n,themeMode:r="light",user:i,...s})=>{let u=Oo(at,t),c=Bo(()=>{me(o)},[o]);return Vt(Io,{alignItems:"end",className:u,height:36,showSeparators:!0,...s,children:[dt(ct,{className:`${at}-menuItem`,variant:"secondary",children:"Help"}),Vt(ct,{className:`${at}-menuItem`,variant:"secondary",children:["History ",dt("span",{"data-icon":"history"})]}),Vt(ct,{className:`${at}-menuItem`,variant:"secondary",children:["View ",dt("span",{"data-icon":"settings"})]}),dt(ct,{className:`${at}-menuItem`,onClick:c,variant:"secondary",children:"Log out"})]})};import zo,{useEffect as Uo,useState as Jo}from"react";import Zo from"clsx";import{Fragment as qo,jsx as _o,jsxs as fe}from"react/jsx-runtime";var Si=({connectionStatus:t,className:e,element:o="span",...a})=>{let[n,r]=Jo("vuuConnectingStatus");Uo(()=>{switch(t){case"connected":case"reconnected":r("vuuActiveStatus");break;case"connecting":r("vuuConnectingStatus");break;case"disconnected":r("vuuDisconnectedStatus");break;default:break}},[t]);let i=zo.createElement(o,{...a,className:Zo("vuuStatus vuuIcon",n,e)});return _o(qo,{children:fe("div",{className:"vuuStatus-container salt-theme",children:[i,fe("div",{className:"vuuStatus-text",children:["Status: ",t.toUpperCase()]})]})})};import xe,{Suspense as Ko,useEffect as Yo}from"react";import{registerComponent as jo}from"@vuu-ui/vuu-layout";import Wo from"react";import{Fragment as Go,jsx as ge,jsxs as Qo}from"react/jsx-runtime";var pt=class extends Wo.Component{constructor(e){super(e),this.state={errorMessage:null}}static getDerivedStateFromError(e){return{errorMessage:e.message}}componentDidCatch(e,o){console.log(`error creating component at ${this.props.url}`),console.log(e,o)}render(){return this.state.errorMessage?Qo(Go,{children:[ge("h1",{children:"An error occured while creating component."}),ge("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as Xo}from"react/jsx-runtime";var ve=()=>Xo("div",{className:"hwLoader"});var ye=async t=>{let e=new CSSStyleSheet;return fetch(t).then(o=>o.text()).then(o=>e.replace(o))};import{jsx as ht}from"react/jsx-runtime";var mt=new Map,ta=t=>{Yo(()=>()=>{mt.delete(t)},[t]),mt.has(t)||mt.set(t,xe.lazy(()=>import(t)));let e=mt.get(t);if(e)return e;throw Error(`Unable to load Lazy Feature at url ${t}`)};function ea({url:t,css:e,ComponentProps:o,...a}){e&&ye(e).then(r=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]});let n=ta(t);return ht(pt,{url:t,children:ht(Ko,{fallback:ht(ve,{}),children:ht(n,{...a,...o})})})}var ft=xe.memo(ea);ft.displayName="Feature";jo("Feature",ft,"view");import{Checkbox as $a,ComboBox as Ba,RadioButton as Ia}from"@vuu-ui/vuu-ui-controls";function be(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;let o=document.implementation.createHTMLDocument(),a=o.createElement("base"),n=o.createElement("a");return o.head.appendChild(a),o.body.appendChild(n),e&&(a.href=e),n.href=t,n.href}var we=(()=>{let t=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${e()}${t}`)})();function N(t){let e=[];for(let o=0,a=t.length;o<a;o++)e.push(t[o]);return e}function gt(t,e){let a=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return a?parseFloat(a.replace("px","")):0}function oa(t){let e=gt(t,"border-left-width"),o=gt(t,"border-right-width");return t.clientWidth+e+o}function aa(t){let e=gt(t,"border-top-width"),o=gt(t,"border-bottom-width");return t.clientHeight+e+o}function Ft(t,e={}){let o=e.width||oa(t),a=e.height||aa(t);return{width:o,height:a}}function Le(){let t,e;try{e=process}catch{}let o=e&&e.env?e.env.devicePixelRatio:null;return o&&(t=parseInt(o,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}var E=16384;function Ce(t){(t.width>E||t.height>E)&&(t.width>E&&t.height>E?t.width>t.height?(t.height*=E/t.width,t.width=E):(t.width*=E/t.height,t.height=E):t.width>E?(t.height*=E/t.width,t.width=E):(t.width*=E/t.height,t.height=E))}function W(t){return new Promise((e,o)=>{let a=new Image;a.decode=()=>e(a),a.onload=()=>e(a),a.onerror=o,a.crossOrigin="anonymous",a.decoding="async",a.src=t})}async function na(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function Se(t,e,o){let a="http://www.w3.org/2000/svg",n=document.createElementNS(a,"svg"),r=document.createElementNS(a,"foreignObject");return n.setAttribute("width",`${e}`),n.setAttribute("height",`${o}`),n.setAttribute("viewBox",`0 0 ${e} ${o}`),r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("externalResourcesRequired","true"),n.appendChild(r),r.appendChild(t),na(n)}var C=(t,e)=>{if(t instanceof e)return!0;let o=Object.getPrototypeOf(t);return o===null?!1:o.constructor.name===e.name||C(o,e)};function ra(t){let e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function ia(t){return N(t).map(e=>{let o=t.getPropertyValue(e),a=t.getPropertyPriority(e);return`${e}: ${o}${a?" !important":""};`}).join(" ")}function sa(t,e,o){let a=`.${t}:${e}`,n=o.cssText?ra(o):ia(o);return document.createTextNode(`${a}{${n}}`)}function Pe(t,e,o){let a=window.getComputedStyle(t,o),n=a.getPropertyValue("content");if(n===""||n==="none")return;let r=we();try{e.className=`${e.className} ${r}`}catch{return}let i=document.createElement("style");i.appendChild(sa(r,o,a)),e.appendChild(i)}function Te(t,e){Pe(t,e,":before"),Pe(t,e,":after")}var Me="application/font-woff",Ee="image/jpeg",ua={woff:Me,woff2:Me,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Ee,jpeg:Ee,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function la(t){let e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function G(t){let e=la(t).toLowerCase();return ua[e]||""}function ca(t){return t.split(/,/)[1]}function nt(t){return t.search(/^(data:)/)!==-1}function Rt(t,e){return`data:${e};base64,${t}`}async function $t(t,e,o){let a=await fetch(t,e);if(a.status===404)throw new Error(`Resource "${a.url}" not found`);let n=await a.blob();return new Promise((r,i)=>{let s=new FileReader;s.onerror=i,s.onloadend=()=>{try{r(o({res:a,result:s.result}))}catch(u){i(u)}},s.readAsDataURL(n)})}var Ht={};function da(t,e,o){let a=t.replace(/\?.*/,"");return o&&(a=t),/ttf|otf|eot|woff2?/i.test(a)&&(a=a.replace(/.*\//,"")),e?`[${e}]${a}`:a}async function Q(t,e,o){let a=da(t,e,o.includeQueryParams);if(Ht[a]!=null)return Ht[a];o.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let n;try{let r=await $t(t,o.fetchRequestInit,({res:i,result:s})=>(e||(e=i.headers.get("Content-Type")||""),ca(s)));n=Rt(r,e)}catch(r){n=o.imagePlaceholder||"";let i=`Failed to fetch resource: ${t}`;r&&(i=typeof r=="string"?r:r.message),i&&console.warn(i)}return Ht[a]=n,n}async function pa(t){let e=t.toDataURL();return e==="data:,"?t.cloneNode(!1):W(e)}async function ma(t,e){if(t.currentSrc){let r=document.createElement("canvas"),i=r.getContext("2d");r.width=t.clientWidth,r.height=t.clientHeight,i==null||i.drawImage(t,0,0,r.width,r.height);let s=r.toDataURL();return W(s)}let o=t.poster,a=G(o),n=await Q(o,a,e);return W(n)}async function ha(t){var e;try{if(!((e=t==null?void 0:t.contentDocument)===null||e===void 0)&&e.body)return await rt(t.contentDocument.body,{},!0)}catch{}return t.cloneNode(!1)}async function fa(t,e){return C(t,HTMLCanvasElement)?pa(t):C(t,HTMLVideoElement)?ma(t,e):C(t,HTMLIFrameElement)?ha(t):t.cloneNode(!1)}var ga=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT";async function va(t,e,o){var a,n;let r=[];return ga(t)&&t.assignedNodes?r=N(t.assignedNodes()):C(t,HTMLIFrameElement)&&(!((a=t.contentDocument)===null||a===void 0)&&a.body)?r=N(t.contentDocument.body.childNodes):r=N(((n=t.shadowRoot)!==null&&n!==void 0?n:t).childNodes),r.length===0||C(t,HTMLVideoElement)||await r.reduce((i,s)=>i.then(()=>rt(s,o)).then(u=>{u&&e.appendChild(u)}),Promise.resolve()),e}function ya(t,e){let o=e.style;if(!o)return;let a=window.getComputedStyle(t);a.cssText?(o.cssText=a.cssText,o.transformOrigin=a.transformOrigin):N(a).forEach(n=>{let r=a.getPropertyValue(n);n==="font-size"&&r.endsWith("px")&&(r=`${Math.floor(parseFloat(r.substring(0,r.length-2)))-.1}px`),C(t,HTMLIFrameElement)&&n==="display"&&r==="inline"&&(r="block"),n==="d"&&e.getAttribute("d")&&(r=`path(${e.getAttribute("d")})`),o.setProperty(n,r,a.getPropertyPriority(n))})}function xa(t,e){C(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),C(t,HTMLInputElement)&&e.setAttribute("value",t.value)}function ba(t,e){if(C(t,HTMLSelectElement)){let o=e,a=Array.from(o.children).find(n=>t.value===n.getAttribute("value"));a&&a.setAttribute("selected","")}}function wa(t,e){return C(e,Element)&&(ya(t,e),Te(t,e),xa(t,e),ba(t,e)),e}async function La(t,e){let o=t.querySelectorAll?t.querySelectorAll("use"):[];if(o.length===0)return t;let a={};for(let r=0;r<o.length;r++){let s=o[r].getAttribute("xlink:href");if(s){let u=t.querySelector(s),c=document.querySelector(s);!u&&c&&!a[s]&&(a[s]=await rt(c,e,!0))}}let n=Object.values(a);if(n.length){let r="http://www.w3.org/1999/xhtml",i=document.createElementNS(r,"svg");i.setAttribute("xmlns",r),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";let s=document.createElementNS(r,"defs");i.appendChild(s);for(let u=0;u<n.length;u++)s.appendChild(n[u]);t.appendChild(i)}return t}async function rt(t,e,o){return!o&&e.filter&&!e.filter(t)?null:Promise.resolve(t).then(a=>fa(a,e)).then(a=>va(t,a,e)).then(a=>wa(t,a)).then(a=>La(a,e))}var Ne=/url\((['"]?)([^'"]+?)\1\)/g,Ca=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Sa=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Pa(t){let e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function Ta(t){let e=[];return t.replace(Ne,(o,a,n)=>(e.push(n),o)),e.filter(o=>!nt(o))}async function Ma(t,e,o,a,n){try{let r=o?be(e,o):e,i=G(e),s;if(n){let u=await n(r);s=Rt(u,i)}else s=await Q(r,i,a);return t.replace(Pa(e),`$1${s}$3`)}catch{}return t}function Ea(t,{preferredFontFormat:e}){return e?t.replace(Sa,o=>{for(;;){let[a,,n]=Ca.exec(o)||[];if(!n)return"";if(n===e)return`src: ${a};`}}):t}function Bt(t){return t.search(Ne)!==-1}async function vt(t,e,o){if(!Bt(t))return t;let a=Ea(t,o);return Ta(a).reduce((r,i)=>r.then(s=>Ma(s,i,e,o)),Promise.resolve(a))}async function yt(t,e,o){var a;let n=(a=e.style)===null||a===void 0?void 0:a.getPropertyValue(t);if(n){let r=await vt(n,null,o);return e.style.setProperty(t,r,e.style.getPropertyPriority(t)),!0}return!1}async function Na(t,e){await yt("background",t,e)||await yt("background-image",t,e),await yt("mask",t,e)||await yt("mask-image",t,e)}async function Da(t,e){let o=C(t,HTMLImageElement);if(!(o&&!nt(t.src))&&!(C(t,SVGImageElement)&&!nt(t.href.baseVal)))return;let a=o?t.src:t.href.baseVal,n=await Q(a,G(a),e);await new Promise((r,i)=>{t.onload=r,t.onerror=i;let s=t;s.decode&&(s.decode=r),s.loading==="lazy"&&(s.loading="eager"),o?(t.srcset="",t.src=n):t.href.baseVal=n})}async function ka(t,e){let a=N(t.childNodes).map(n=>It(n,e));await Promise.all(a).then(()=>t)}async function It(t,e){C(t,Element)&&(await Na(t,e),await Da(t,e),await ka(t,e))}function De(t,e){let{style:o}=t;e.backgroundColor&&(o.backgroundColor=e.backgroundColor),e.width&&(o.width=`${e.width}px`),e.height&&(o.height=`${e.height}px`);let a=e.style;return a!=null&&Object.keys(a).forEach(n=>{o[n]=a[n]}),t}var ke={};async function Ae(t){let e=ke[t];if(e!=null)return e;let a=await(await fetch(t)).text();return e={url:t,cssText:a},ke[t]=e,e}async function Ve(t,e){let o=t.cssText,a=/url\(["']?([^"')]+)["']?\)/g,r=(o.match(/url\([^)]+\)/g)||[]).map(async i=>{let s=i.replace(a,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),$t(s,e.fetchRequestInit,({result:u})=>(o=o.replace(i,`url(${u})`),[i,u]))});return Promise.all(r).then(()=>o)}function Fe(t){if(t==null)return[];let e=[],o=/(\/\*[\s\S]*?\*\/)/gi,a=t.replace(o,""),n=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let u=n.exec(a);if(u===null)break;e.push(u[0])}a=a.replace(n,"");let r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(i,"gi");for(;;){let u=r.exec(a);if(u===null){if(u=s.exec(a),u===null)break;r.lastIndex=s.lastIndex}else s.lastIndex=r.lastIndex;e.push(u[0])}return e}async function Aa(t,e){let o=[],a=[];return t.forEach(n=>{if("cssRules"in n)try{N(n.cssRules||[]).forEach((r,i)=>{if(r.type===CSSRule.IMPORT_RULE){let s=i+1,u=r.href,c=Ae(u).then(d=>Ve(d,e)).then(d=>Fe(d).forEach(h=>{try{n.insertRule(h,h.startsWith("@import")?s+=1:n.cssRules.length)}catch(y){console.error("Error inserting rule from remote css",{rule:h,error:y})}})).catch(d=>{console.error("Error loading remote css",d.toString())});a.push(c)}})}catch(r){let i=t.find(s=>s.href==null)||document.styleSheets[0];n.href!=null&&a.push(Ae(n.href).then(s=>Ve(s,e)).then(s=>Fe(s).forEach(u=>{i.insertRule(u,n.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",r)}}),Promise.all(a).then(()=>(t.forEach(n=>{if("cssRules"in n)try{N(n.cssRules||[]).forEach(r=>{o.push(r)})}catch(r){console.error(`Error while reading CSS rules from ${n.href}`,r)}}),o))}function Va(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>Bt(e.style.getPropertyValue("src")))}async function Fa(t,e){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");let o=N(t.ownerDocument.styleSheets),a=await Aa(o,e);return Va(a)}async function He(t,e){let o=await Fa(t,e);return(await Promise.all(o.map(n=>{let r=n.parentStyleSheet?n.parentStyleSheet.href:null;return vt(n.cssText,r,e)}))).join(`
|
|
2
|
-
`)}async function Re(t,e){let o=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await He(t,e);if(o){let a=document.createElement("style"),n=document.createTextNode(o);a.appendChild(n),t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a)}}async function Ha(t,e={}){let{width:o,height:a}=Ft(t,e),n=await rt(t,e,!0);return await Re(n,e),await It(n,e),De(n,e),await Se(n,o,a)}async function Ra(t,e={}){let{width:o,height:a}=Ft(t,e),n=await Ha(t,e),r=await W(n),i=document.createElement("canvas"),s=i.getContext("2d"),u=e.pixelRatio||Le(),c=e.canvasWidth||o,d=e.canvasHeight||a;return i.width=c*u,i.height=d*u,e.skipAutoScale||Ce(i),i.style.width=`${c}`,i.style.height=`${d}`,e.backgroundColor&&(s.fillStyle=e.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(r,0,0,i.width,i.height),i}async function $e(t,e={}){return(await Ra(t,e)).toDataURL()}var Be=t=>new Promise((e,o)=>{$e(t,{cacheBust:!0}).then(a=>{a||o(new Error("No Screenshot available")),e(a)}).catch(a=>{console.error("the following error occurred while taking a screenshot of a DOMNode",a),o(new Error("Error taking screenshot"))})});import{Button as Ie,FormField as xt,FormFieldLabel as bt,Input as Oa,Text as za}from"@salt-ds/core";import{useEffect as Ua,useMemo as Ja,useState as X}from"react";import{jsx as S,jsxs as z}from"react/jsx-runtime";var D="saveLayoutPanel",wt=`${D}-formField`,Za=["Group 1","Group 2","Group 3","Group 4","Group 5"],qa=["Value 1","Value 2","Value 3"],Oe=["Value 1","Value 2","Value 3"],ze=t=>{let{defaultTitle:e="",onCancel:o,onSave:a,componentId:n}=t,[r,i]=X(e),[s,u]=X(""),[c,d]=X([]),[h,y]=X(Oe[0]),[v,p]=X(),[l,f]=X(),[b]=ot();Ua(()=>{n&&Be(document.getElementById(n)).then(g=>{p(g)}).catch(g=>{f(g.message)})},[n]);let A=()=>{a({name:r,group:s,screenshot:v!=null?v:"",user:b})},T=Ja(()=>v?S("img",{className:`${D}-screenshot`,src:v,alt:"screenshot of current layout"}):l?S(za,{children:l}):S("div",{className:"spinner"}),[v,l]);return z("div",{className:`${D}-panelContainer`,children:[z("div",{className:`${D}-panelContent`,children:[z("div",{className:`${D}-formContainer`,children:[z(xt,{className:wt,children:[S(bt,{children:"Group"}),S(Ba,{source:Za,allowFreeText:!0,InputProps:{inputProps:{className:`${D}-inputText`,placeholder:"Select Group or Enter New Name",onChange:g=>u(g.target.value)}},width:"100%",onSelectionChange:(g,M)=>u(M||"")})]}),z(xt,{className:wt,children:[S(bt,{children:"Layout Name"}),S(Oa,{inputProps:{className:`${D}-inputText`,placeholder:"Enter Layout Name"},onChange:g=>i(g.target.value),value:r})]}),z(xt,{className:wt,children:[S(bt,{children:"Some Layout Setting"}),S("div",{className:`${D}-settingsGroup`,children:qa.map((g,M)=>S($a,{onToggle:()=>d(w=>w.includes(g)?w.filter(V=>V!==g):[...w,g]),checked:c.includes(g),label:g},M))})]}),z(xt,{className:wt,children:[S(bt,{children:"Some Layout Setting"}),S("div",{className:`${D}-settingsGroup`,children:Oe.map((g,M)=>S(Ia,{onClick:()=>y(g),checked:h===g,label:g,groupName:"radioGroup"},M))})]})]}),S("div",{className:`${D}-screenshotContainer`,children:T})]}),z("div",{className:`${D}-buttonsContainer`,children:[S(Ie,{className:`${D}-cancelButton`,onClick:o,children:"Cancel"}),S(Ie,{className:`${D}-saveButton`,onClick:A,disabled:r===""||s==="",children:"Save"})]})]})};import{List as An}from"@vuu-ui/vuu-ui-controls";import Pn,{useCallback as U,useContext as Tn,useEffect as Mn,useRef as En,useState as eo}from"react";import{resolveJSONPath as Nn}from"@vuu-ui/vuu-layout";import en from"clsx";import{useThemeAttributes as on}from"@vuu-ui/vuu-utils";import{useCallback as an,useLayoutEffect as nn,useRef as _e}from"react";import{Button as _a,Text as Wa}from"@salt-ds/core";import Ga from"clsx";import{jsx as Ue,jsxs as Xa}from"react/jsx-runtime";var Qa="vuuDialogHeader",Je=({hideCloseButton:t=!1,title:e,onClose:o,...a})=>Xa("div",{...a,className:Ga(Qa,"vuuToolbarProxy"),children:[Ue(Wa,{className:"dialogHeader",children:e}),!t&&Ue(_a,{onClick:o,"data-align":"end","data-icon":"close",variant:"secondary"},"close")]});import{useCallback as Ka,useLayoutEffect as Ya,useRef as ja,useState as tn}from"react";var Ze=(t,e,o,a,n,r)=>{let{bottom:i,height:s,left:u,right:c,top:d,width:h}=t.getBoundingClientRect();switch(e){case"below":return{left:u+o,top:i+a};case"right":return{left:c+o,top:d+a};case"below-center":return{left:u+h/2+o,top:i+a};case"below-right":return{left:u,minWidth:n,top:i+a};case"below-full-width":return{left:u+o,minWidth:n,top:i+a,width:h};case"center":return r?{left:h/2-r.width/2+o,top:s/2-r.height/2+a,visibility:"visible"}:{left:h/2+o,top:s/2+a,visibility:"hidden"};default:throw Error("Popup getPositionRelativeToAnchor only supported placement values are below and right")}},qe=({anchorElement:t,minWidth:e,offsetLeft:o=0,offsetTop:a=0,placement:n,position:r})=>{let i=ja(null),[s,u]=tn(r);Ya(()=>{if(n==="absolute"&&r)u(r);else if(t.current&&n!=="auto"){let d=i.current===null?void 0:i.current.getBoundingClientRect(),h=Ze(t.current,n,o,a,e,d);u(h)}},[t,e,o,a,n,r]);let c=Ka(d=>{if(i.current=d,d&&n==="center"&&t.current){let{height:h,width:y}=d.getBoundingClientRect();u(Ze(t.current,n,o,a,void 0,{height:h,width:y}))}},[t,o,a,n]);return{position:s,popupRef:n==="center"?c:void 0}};import{jsx as Ot,jsxs as un}from"react/jsx-runtime";var We="vuuDialog",rn={current:document.body},sn={},Ge=({PopupProps:t=sn,children:e,className:o,isOpen:a=!1,onClose:n,style:r,title:i,hideCloseButton:s=!1,...u})=>{let{anchorElement:c=rn,offsetLeft:d=0,offsetTop:h=0,placement:y="auto"}=t,v=_e(null),p=_e(null),[l,f,b]=on(),{position:A}=qe({anchorElement:c,offsetLeft:d,offsetTop:h,placement:y}),T=an(()=>{n==null||n()},[n]);return nn(()=>{if(v.current){if(a){v.current.showModal();let{left:g,top:M}=v.current.getBoundingClientRect();p.current&&(p.current.style.cssText=`left:-${g}px;position:absolute;top:-${M}px;`)}else v.current.close();if(y.endsWith("center")){let{width:g}=v.current.getBoundingClientRect();v.current.style.marginLeft=`-${g/2}px`}}},[a,y]),un("dialog",{...u,className:en(We,l),"data-mode":b,onClose:T,id:"vuu-dialog",ref:v,style:{...r,...A},children:[Ot(Je,{hideCloseButton:s,onClose:T,title:i}),Ot("div",{className:`${We}-body`,children:e}),Ot("div",{id:"vuu-dialog-portal-root",ref:p})]})};import{useCallback as ln,useState as cn}from"react";import{jsx as dn}from"react/jsx-runtime";var Qe=()=>{let[t,e]=cn(),o=ln(()=>{e(void 0)},[]);return{dialog:t?dn(Ge,{className:"vuDialog",isOpen:!0,onClose:o,style:{maxHeight:500},title:t.title,hideCloseButton:t.hideCloseButton,children:t.content}):null,setDialogState:e}};import{createContext as pn,useCallback as mn,useMemo as hn}from"react";import{jsx as zt}from"react/jsx-runtime";var Xe=pn(null),fn=({children:t,context:e,menuActionHandler:o,menuBuilder:a})=>{let n=hn(()=>e!=null&&e.menuBuilders&&a?e.menuBuilders.concat(a):a?[a]:(e==null?void 0:e.menuBuilders)||[],[e,a]),r=mn(i=>{var s;if(o!=null&&o(i)||(s=e==null?void 0:e.menuActionHandler)!=null&&s.call(e,i))return!0},[e,o]);return zt(Xe.Provider,{value:{menuActionHandler:r,menuBuilders:n},children:t})},Ke=({children:t,label:e,menuActionHandler:o,menuBuilder:a})=>zt(Xe.Consumer,{children:n=>zt(fn,{context:n,label:e,menuActionHandler:o,menuBuilder:a,children:t})});import gn,{useState as gu,useContext as vn,useCallback as vu,useEffect as yu}from"react";import bu from"clsx";import{getUniqueId as Lu}from"@vuu-ui/vuu-utils";import{jsx as Pu,jsxs as Tu}from"react/jsx-runtime";var yn=gn.createContext({notify:()=>"have you forgotten to provide a NotificationProvider?"});var Ye=()=>vn(yn);var Lt={layout:{type:"Component",id:"loading-main",props:{}}},Ct={layout:{type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowCloseTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",tabClassName:"MainTab"},preserve:!0,active:0},children:[{props:{id:"tab1",title:"Tab 1",className:"vuuShell-Placeholder"},type:"Placeholder"}]}};import{getLocalEntity as Ut,saveLocalEntity as Jt}from"@vuu-ui/vuu-filters";import{formatDate as xn,getUniqueId as bn}from"@vuu-ui/vuu-utils";var wn="layouts/metadata",Ln="layouts/layouts",K,St=class{constructor(e){this.username=ot()[0];this.metadataSaveLocation=`${wn}/${this.username}`;this.layoutsSaveLocation=`${Ln}/${this.username}`;re(this,K,`api/vui/${this.username}`);this.loadLayouts=()=>new Promise(e=>{let o=Ut(this.layoutsSaveLocation);e(o||[])});this.saveLayoutsWithMetadata=(e,o)=>{Jt(this.layoutsSaveLocation,e),Jt(this.metadataSaveLocation,o)};this.validateIds=async e=>Promise.all([this.validateId(e,"metadata").catch(o=>o.message),this.validateId(e,"layout").catch(o=>o.message)]).then(o=>{let a=o.filter(n=>n!==void 0).join("; ");if(a)throw new Error(a)});this.validateId=(e,o)=>new Promise((a,n)=>{(o==="metadata"?()=>this.loadMetadata():()=>this.loadLayouts())().then(i=>{switch(i.filter(u=>u.id===e).length){case 1:{a();break}case 0:{n(new Error(`No ${o} with ID ${e}`));break}default:n(new Error(`Non-unique ${o} with ID ${e}`))}})});e&&ie(this,K,e)}createLayout(e,o){return new Promise(a=>{Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([n,r])=>{let i=bn(),s={...e,id:i,created:xn({date:"dd.mm.yyyy"})(new Date)};this.saveLayoutsWithMetadata([...n,{id:i,json:o}],[...r,s]),a(s)})})}updateLayout(e,o,a){return new Promise((n,r)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([i,s])=>{let u=i.map(d=>d.id===e?{...d,json:a}:d),c=s.map(d=>d.id===e?{...d,...o}:d);this.saveLayoutsWithMetadata(u,c),n()}).catch(i=>r(i))})}deleteLayout(e){return new Promise((o,a)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([n,r])=>{let i=n.filter(u=>u.id!==e),s=r.filter(u=>u.id!==e);this.saveLayoutsWithMetadata(i,s),o()}).catch(n=>a(n))})}loadLayout(e){return new Promise((o,a)=>{this.validateId(e,"layout").then(()=>this.loadLayouts()).then(n=>{let r=n.find(i=>i.id===e);r?o(r.json):a(new Error(`no layout found matching id ${e}`))}).catch(n=>a(n))})}loadMetadata(){return new Promise(e=>{let o=Ut(this.metadataSaveLocation);e(o||[])})}loadApplicationJSON(){return new Promise(e=>{let o=Ut(kt(this,K));e(o||Ct)})}saveApplicationJSON(e){return new Promise((o,a)=>{Jt(kt(this,K),e)?o():a(new Error("Application Json failed to save"))})}};K=new WeakMap;import{useCallback as je,useMemo as Cn}from"react";import{jsx as Sn}from"react/jsx-runtime";var to=t=>{let{saveLayout:e}=Y(),o=je(()=>{t(void 0)},[t]),a=je(i=>{e(i),t(void 0)},[e,t]),[n,r]=Cn(()=>[(i,s)=>{let u=i.split(" "),c=[];return u.includes("main-tab")&&c.push({label:"Save Layout",action:"save-layout",options:s},{label:"Layout Settings",action:"layout-settings",options:s}),c},i=>{var s,u;return console.log("menu action",{action:i}),i.menuId==="save-layout"?(t({content:Sn(ze,{onCancel:o,onSave:a,componentId:(s=i.options)==null?void 0:s.controlledComponentId,defaultTitle:(u=i.options)==null?void 0:u.controlledComponentTitle}),title:"Save Layout",hideCloseButton:!0}),!0):!1}],[o,a,t]);return{buildMenuOptions:n,handleMenuAction:r}};import{jsx as kn}from"react/jsx-runtime";var Zt,it=()=>(Zt===void 0&&(Zt=new St),Zt),oo=Pn.createContext({getApplicationSettings:()=>{},layoutMetadata:[],saveLayout:()=>{},applicationJson:Ct,saveApplicationLayout:()=>{},saveApplicationSettings:()=>{},loadLayoutById:()=>{}}),Dn=(t,e)=>{var o;return((o=t.props)==null?void 0:o.title)!==void 0?t:{...t,props:{...t.props,title:e.name}}},rl=t=>{let[e,o]=eo([]),[,a]=eo({}),{notify:n}=Ye(),r=En(Lt),i=U((p,l=!0)=>{r.current=p,l&&a({})},[]),s=U((p,l=!0)=>{i({...r.current,layout:p},l)},[i]),u=U(p=>{i({...r.current,settings:{...r.current.settings,...p}},!1)},[i]);Mn(()=>{let p=it();p.loadMetadata().then(l=>{o(l)}).catch(l=>{n({type:"error",header:"Failed to Load Layouts",body:"Could not load list of available layouts"}),console.error("Error occurred while retrieving metadata",l)}),p.loadApplicationJSON().then(l=>{i(l)}).catch(l=>{n({type:"error",header:"Failed to Load Layout",body:"Could not load your latest view"}),console.error("Error occurred while retrieving application layout",l)})},[n,i]);let c=U(p=>{s(p,!1),it().saveApplicationJSON(r.current)},[s]),d=U(p=>{let l=Nn(r.current.layout,"#main-tabs.ACTIVE_CHILD");l?it().createLayout(p,Dn(l,p)).then(f=>{n({type:"success",header:"Layout Saved Successfully",body:`${f.name} saved successfully`}),o(b=>[...b,f])}).catch(f=>{n({type:"error",header:"Failed to Save Layout",body:`Failed to save layout ${p.name}`}),console.error("Error occurred while saving layout",f)}):n({type:"error",header:"Failed to Save Layout",body:"Cannot save undefined layout"})},[n]),h=U((p,l)=>{let{settings:f}=r.current;u(l?{...f,[l]:p}:p),it().saveApplicationJSON(r.current)},[u]),y=U(p=>{let{settings:l}=r.current;return p?l==null?void 0:l[p]:l},[]),v=U(p=>{it().loadLayout(p).then(l=>{var b,A;let{layout:f}=r.current;s({...f,children:(f.children||[]).concat(l),props:{...f.props,active:(A=(b=f.children)==null?void 0:b.length)!=null?A:0}})}).catch(l=>{n({type:"error",header:"Failed to Load Layout",body:"Failed to load the requested layout"}),console.error("Error occurred while loading layout",l)})},[n,s]);return kn(oo.Provider,{value:{getApplicationSettings:y,layoutMetadata:e,saveLayout:d,applicationJson:r.current,saveApplicationLayout:c,saveApplicationSettings:h,loadLayoutById:v},children:t.children})},Y=()=>Tn(oo);import{jsx as st,jsxs as ao}from"react/jsx-runtime";var Pt="vuuLayoutTile",no=t=>{let{metadata:e,handleLoadLayout:o}=t;return st("div",{role:"listitem",children:ao("div",{className:`${Pt}-layoutTile`,role:"button",onClick:()=>o(e==null?void 0:e.id),children:[st("img",{className:`${Pt}-screenshot`,src:e==null?void 0:e.screenshot}),ao("div",{children:[st("div",{className:`${Pt}-layoutName`,children:e==null?void 0:e.name}),st("div",{className:`${Pt}-layoutDetails`,children:st("div",{children:`${e==null?void 0:e.user}, ${e==null?void 0:e.created}`})})]})]},e==null?void 0:e.id)})};import{Fragment as Vn,jsx as ut,jsxs as ro}from"react/jsx-runtime";var qt="vuuLayoutList",io=t=>{let{layoutMetadata:e,loadLayoutById:o}=Y(),a=r=>{r&&o(r)},n=e.reduce((r,i)=>r[i.group]?{...r,[i.group]:[...r[i.group],i]}:{...r,[i.group]:[i]},{});return ro("div",{className:qt,...t,role:"listbox","aria-label":"my layouts",children:[ut("div",{className:`${qt}-header`,children:"My Layouts"}),ut(An,{height:"auto",source:Object.entries(n),ListItem:({item:r})=>{if(!r)return ut(Vn,{});let[i,s]=r;return ro("div",{role:"list","aria-label":i,children:[ut("div",{className:`${qt}-groupName`,children:i}),s.map(u=>ut(no,{metadata:u,handleLoadLayout:a},u.id))]})}})]})};import{VuuLogo as $n}from"@vuu-ui/vuu-icons";import{Stack as Bn,useLayoutProviderDispatch as In}from"@vuu-ui/vuu-layout";import{Tab as Tt,Tabstrip as On}from"@vuu-ui/vuu-ui-controls";import{useThemeAttributes as zn}from"@vuu-ui/vuu-utils";import Gt from"clsx";import{useCallback as Qt,useState as Un}from"react";import{Palette as Fn,PaletteItem as Hn}from"@vuu-ui/vuu-layout";import{jsx as lt,jsxs as Rn}from"react/jsx-runtime";var _t="vuuFeatureList",Wt=({features:t,title:e="VUU TABLES",...o})=>{let a={},n={height:"100%"};return Rn("div",{...o,className:_t,children:[lt("div",{className:`${_t}-header`,children:e}),lt("div",{className:`${_t}-content`,children:lt(Fn,{orientation:"vertical",ListProps:n,ViewProps:a,children:t.map((r,i)=>lt(Hn,{closeable:!0,label:r.title,resizeable:!0,resize:"defer",header:!0,children:lt(ft,{...r})},i))})})]})};import{jsx as k,jsxs as Mt}from"react/jsx-runtime";var j="vuuLeftNav",Jn=(t,e)=>t===0?e?"menu-full":"menu-icons":e?"menu-full-content":"menu-icons-content",Ql=t=>{let e=In(),[o]=zn(),{"data-path":a,defaultExpanded:n=!0,defaultActiveTabIndex:r=0,features:i,onActiveChange:s,onTogglePrimaryMenu:u,sizeCollapsed:c=80,sizeContent:d=300,sizeExpanded:h=240,style:y,tableFeatures:v,...p}=t,[l,f]=Un({activeTabIndex:r,expanded:n}),b=Qt((w,V)=>w===0?V?h:c:V?h+d:c+d,[c,d,h]),A=Qt(w=>{let{activeTabIndex:V,expanded:$}=l;if(f({activeTabIndex:w,expanded:$}),w===0||V===0){let x=b(w,$);e({type:"layout-resize",path:"#vuu-side-panel",size:x})}s==null||s(w)},[e,b,l,s]),T=Jn(l.activeTabIndex,l.expanded),g=Qt(()=>{let{activeTabIndex:w,expanded:V}=l,$=!V;f({activeTabIndex:w,expanded:$}),e({type:"layout-resize",path:"#vuu-side-panel",size:b(w,$)}),u==null||u($)},[e,b,l,u]),M={...y,"--nav-menu-collapsed-width":`${c}px`,"--nav-menu-expanded-width":`${h}px`,"--nav-menu-content-width":`${d}px`};return Mt("div",{...p,className:Gt(j,`${j}-${T}`),style:M,children:[Mt("div",{className:Gt(`${j}-menu-primary`,o),"data-mode":"dark",children:[k("div",{className:"vuuLeftNav-logo",children:k($n,{})}),k("div",{className:`${j}-main`,children:Mt(On,{activeTabIndex:l.activeTabIndex,animateSelectionThumb:!1,className:`${j}-Tabstrip`,onActiveChange:A,orientation:"vertical",children:[k(Tt,{"data-icon":"demo",label:"DEMO"}),k(Tt,{"data-icon":"features",label:"VUU FEATURES"}),k(Tt,{"data-icon":"tables",label:"VUU TABLES"}),k(Tt,{"data-icon":"layouts",label:"MY LAYOUTS"})]})}),k("div",{className:"vuuLeftNav-buttonBar",children:k("button",{className:Gt("vuuLeftNav-toggleButton",{"vuuLeftNav-toggleButton-open":T.startsWith("menu-full"),"vuuLeftNav-toggleButton-closed":T.startsWith("menu-icons")}),"data-icon":T.startsWith("menu-full")?"chevron-left":"chevron-right",onClick:g})})]}),Mt(Bn,{active:l.activeTabIndex-1,className:`${j}-menu-secondary`,showTabs:!1,children:[k(Wt,{features:i,title:"VUU FEATURES"}),k(Wt,{features:v,title:"VUU TABLES"}),k("div",{className:"vuuLeftNav-drawer",children:k(io,{})})]})]})};import{VuuDataSource as Zn}from"@vuu-ui/vuu-data-remote";import{buildColumnMap as qn,hasAction as _n,isErrorResponse as Wn,isValidNumber as so,shallowEquals as Gn}from"@vuu-ui/vuu-utils";import{Button as uo,useIdMemo as Qn}from"@salt-ds/core";import lo from"clsx";import{useCallback as tt,useEffect as co,useMemo as Xn,useRef as Xt,useState as po}from"react";import{jsx as Z,jsxs as Kt}from"react/jsx-runtime";var I="vuuSessionEditingForm",mo=(t,e)=>{let o=t.find(a=>a.name===e);if(o)return o;throw Error(`SessionEditingForm, no field '${e}' found`)},ho=t=>{let{dataset:{field:e},value:o}=t.target;if(e===void 0)throw Error("SessionEditingForm, form field has no field name");return[e,o]},O={uninitialised:0,unchanged:1,changed:2,invalid:3};function fo(t,e,o=!1){switch(e){case"int":case"long":{let a=parseInt(t,10);if(so(a))return a;if(o)throw Error("SessionEditingForm getTypedValue");return}case"double":{let a=parseFloat(t);return so(a)?a:void 0}case"boolean":return t==="true";default:return t}}var Kn=(t,e)=>{if(t)return t;if(e)return new Zn({bufferSize:0,table:e.table,columns:e.columns.map(o=>o.name)});throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided")},dc=({className:t,config:{fields:e,key:o},dataSource:a,id:n,onClose:r,schema:i,...s})=>{let[u,c]=po(),[d,h]=po(""),y=Xt(null),v=Xt(),p=Xt(O.uninitialised),l=Xn(()=>{let m=H=>{if(F){let L={};for(let q of l.columns)L[q]=H[F[q]];p.current===O.uninitialised&&(p.current=O.unchanged,v.current=L),c(L)}},x=Kn(a,i),F=qn(x.columns);return x.subscribe({range:{from:0,to:5}},H=>{H.type==="viewport-update"&&H.rows&&(p.current===O.uninitialised?m(H.rows[0]):console.log("what do we do with server updates"))}),x},[a,i]),f=Qn(n),b=tt(m=>{let[x,F]=ho(m),{type:H}=mo(e,x),L=fo(F,H);c((q={})=>{let ae={...q,[x]:L},No=Gn(ae,v.current);return p.current=No?O.unchanged:L!==void 0?O.changed:O.invalid,ae})},[e]),A=tt(m=>{let[x,F]=ho(m),{type:H}=mo(e,x),L=u==null?void 0:u[o],q=fo(F,H,!0);typeof L=="string"&&l.menuRpcCall({rowKey:L,field:x,value:q,type:"VP_EDIT_CELL_RPC"})},[l,e,o,u]),T=tt(m=>{typeof m=="object"&&m!==null&&"type"in m&&m.type==="CLOSE_DIALOG_ACTION"&&r()},[r]),g=tt(async()=>{let m=await l.menuRpcCall({type:"VP_EDIT_SUBMIT_FORM_RPC"});Wn(m)?h(m.error):_n(m)&&T(m.action)},[T,l]),M=tt(m=>{m.key==="Enter"&&p.current===O.changed&&g()},[g]),w=tt(()=>{r()},[r]),V=m=>{var F;let x=String((F=u==null?void 0:u[m.name])!=null?F:"");return m.readonly||m.name===o?Z("div",{className:`${I}-fieldValue vuuReadOnly`,children:x}):Z("input",{className:`${I}-fieldValue`,"data-field":m.name,onBlur:A,onChange:b,type:"text",value:x,id:`${f}-input-${m.name}`})};co(()=>{if(y.current){let m=y.current.querySelector("input");m&&setTimeout(()=>{m.focus(),m.select()},100)}},[]),co(()=>()=>{l&&l.unsubscribe()},[l]);let $=p.current===O.changed;return Kt("div",{...s,className:lo(I,t),children:[d?Z("div",{className:`${I}-errorBanner`,"data-icon":"error",title:d,children:"Error, edit(s) not saved"}):void 0,Z("div",{className:`${I}-content`,ref:y,onKeyDown:M,children:e.map(m=>{var x;return Kt("div",{className:`${I}-field`,children:[Z("label",{className:lo(`${I}-fieldLabel`,{[`${I}-required`]:m.required}),htmlFor:`${f}-input-${m.name}`,children:(x=m==null?void 0:m.label)!=null?x:m.description}),V(m)]},m.name)})}),Kt("div",{className:`${I}-buttonbar salt-theme salt-density-high`,children:[Z(uo,{type:"submit",variant:"cta",disabled:!$,onClick:g,children:"Submit"}),Z(uo,{variant:"secondary",onClick:w,children:"Cancel"})]})]})};import{connectToServer as vr}from"@vuu-ui/vuu-data-remote";import{DraggableLayout as yr,LayoutProvider as xr,StackLayout as br}from"@vuu-ui/vuu-layout";import{logger as wr,ThemeProvider as Lr,useThemeAttributes as Cr}from"@vuu-ui/vuu-utils";import Sr from"clsx";import{useCallback as jt,useEffect as Pr,useRef as To}from"react";import{Button as Yn}from"@salt-ds/core";import go from"clsx";import{useCallback as jn,useMemo as tr}from"react";import{layoutFromJson as er,View as or,useLayoutProviderDispatch as ar}from"@vuu-ui/vuu-layout";import{jsx as Et,jsxs as vo}from"react/jsx-runtime";var R="vuuContextPanel",yo=({className:t,expanded:e=!1,content:o,overlay:a=!1,title:n})=>{let r=ar(),i=jn(()=>{r({path:"#context-panel",propName:"expanded",propValue:!1,type:"set-prop"})},[r]),s=go(R,t,{[`${R}-expanded`]:e,[`${R}-inline`]:a!==!0,[`${R}-overlay`]:a}),u=tr(()=>o&&e?er(o,"context-0"):null,[o,e]);return Et("div",{className:go(R,s,{[`${R}-expanded`]:e}),children:vo(or,{className:`${R}-inner`,header:!1,id:"context-panel",children:[vo("div",{className:`${R}-header`,children:[Et("h2",{className:`${R}-title`,children:n}),Et(Yn,{className:`${R}-close`,"data-icon":"close",onClick:i,variant:"secondary"})]}),Et("div",{className:`${R}-content`,children:u})]})})};import{DraggableLayout as ur,Flexbox as bo}from"@vuu-ui/vuu-layout";import{useMemo as nr}from"react";import rr from"clsx";import{jsx as sr}from"react/jsx-runtime";var ir="vuuShellSidePanel",xo=({children:t,open:e=!0,sizeClosed:o=90,sizeOpen:a=200,style:n,...r})=>{let i=nr(()=>({...n,"--shell-left-nav-size":e?`${a}px`:`${o}px`}),[e,o,a,n]);return sr("div",{...r,className:rr(ir),style:i,children:t})};import{jsx as Yt,jsxs as wo}from"react/jsx-runtime";var Lo=({appHeader:t,LeftSidePanelProps:e})=>wo(bo,{className:"App",style:{flexDirection:"row",height:"100%",width:"100%"},children:[Yt(xo,{...e,id:"vuu-side-panel"}),wo(bo,{className:"vuuShell-content",style:{flex:1,flexDirection:"column"},children:[t,Yt(ur,{dropTarget:!0,style:{flex:1}},"main-content")]}),Yt(yo,{id:"context-panel",overlay:!0})]});import{DockLayout as lr,DraggableLayout as cr,Drawer as dr,Flexbox as pr,View as mr}from"@vuu-ui/vuu-layout";import{useCallback as Co,useRef as hr,useState as fr}from"react";import{jsx as Nt,jsxs as gr}from"react/jsx-runtime";var So=({appHeader:t,LeftSidePanelProps:e})=>{let o=hr(null),[a,n]=fr(!0),r=Co(s=>{var c;let u=s.target;(c=o.current)!=null&&c.contains(u)||n(!a)},[a]),i=Co(s=>{let u=[];return u.push(Nt(dr,{onClick:r,open:a,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:Nt(mr,{className:"vuuShell-palette",id:"vw-app-palette",ref:o,style:{height:"100%"},children:s},"app-palette")},"left-panel")),u},[r,a]);return gr(pr,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[t,Nt(lr,{style:{flex:1},children:i(e==null?void 0:e.children).concat(Nt(cr,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})};var Po=({leftSidePanelLayout:t="inlay",...e})=>(t==="inlay"?So:Lo)(e);import{jsx as Dt,jsxs as Mr}from"react/jsx-runtime";typeof br!="function"&&console.warn("StackLayout module not loaded, will be unsbale to deserialize from layout JSON");var{error:te}=wr("Shell"),Tr={},wd=({LayoutProps:t,LeftSidePanelProps:e=Tr,children:o,className:a,leftSidePanelLayout:n,loginUrl:r,saveLocation:i="remote",saveUrl:s,serverUrl:u,user:c,...d})=>{let h=To(null),{dialog:y,setDialogState:v}=Qe(),p=To("latest"),{applicationJson:l,saveApplicationLayout:f,loadLayoutById:b}=Y(),{buildMenuOptions:A,handleMenuAction:T}=to(v),g=jt(L=>{try{f(L)}catch{te==null||te("Failed to save layout")}},[f]),M=jt(L=>{h.current&&(h.current.dataset.mode=L)},[]),w=jt(L=>{p.current=L,b(L)},[b]);Pr(()=>{u&&c.token&&vr({authToken:c.token,url:u,username:c.username})},[u,c.token,c.username]);let[V,$,m]=Cr(),x=Sr("vuuShell",a,V,$),F=l===Lt,H=Po({LeftSidePanelProps:e,leftSidePanelLayout:n,appHeader:Dt(he,{layoutId:p.current,loginUrl:r,user:c,onNavigate:w,onSwitchTheme:M})});return F?null:Dt(Lr,{children:Mr(Ke,{menuActionHandler:T,menuBuilder:A,children:[Dt(xr,{...t,layout:l.layout,onLayoutChange:g,children:Dt(yr,{className:x,"data-mode":m,ref:h,...d,children:H})}),o||y]})})};var Sd=t=>t==="*",Pd=t=>typeof t=="object"&&typeof t.module=="string"&&typeof t.table=="string";import{createContext as Er,useContext as Nr}from"react";import{jsx as ee}from"react/jsx-runtime";var Dr={},oe=Er(Dr),kr=({children:t,context:e,inheritedContext:o})=>{let a={...o,...e};return ee(oe.Provider,{value:a,children:t})},Dd=({children:t,value:e})=>ee(oe.Consumer,{children:o=>ee(kr,{context:e,inheritedContext:o,children:t})}),kd=()=>Nr(oe);import Ar from"clsx";import{ToggleButton as Mo,ToggleButtonGroup as Vr,useControlled as Fr}from"@salt-ds/core";import{useCallback as Hr}from"react";import{jsx as Eo,jsxs as $r}from"react/jsx-runtime";var Rr="vuuThemeSwitch",Ud=({className:t,defaultMode:e,mode:o,onChange:a,...n})=>{let[r,i]=Fr({controlled:o,default:e!=null?e:"light",name:"ThemeSwitch",state:"mode"}),s=Hr(c=>{let{value:d}=c.target;i(d),a(d)},[a,i]),u=Ar(Rr,t);return $r(Vr,{className:u,...n,onChange:s,value:r,children:[Eo(Mo,{"aria-label":"alert","data-icon":"light",value:"dark"}),Eo(Mo,{"aria-label":"home","data-icon":"dark",value:"light"})]})};export{he as AppHeader,Si as ConnectionStatusIcon,yo as ContextPanel,ft as Feature,Wt as FeatureList,io as LayoutList,oo as LayoutManagementContext,rl as LayoutManagementProvider,Ql as LeftNav,Yr as LoginPanel,ze as SaveLayoutPanel,dc as SessionEditingForm,wd as Shell,Dd as ShellContextProvider,xo as SidePanel,Ud as ThemeSwitch,ot as getAuthDetailsFromCookies,Ho as getAuthModeFromCookies,Pd as isTableSchema,Sd as isWildcardSchema,me as logout,$o as redirectToLogin,Y as useLayoutManager,kd as useShellContext,Po as useShellLayout};
|
|
1
|
+
var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/app-header/AppHeader.tsx
|
|
21
|
+
import { useCallback as useCallback2 } from "react";
|
|
22
|
+
import { Toolbar } from "@vuu-ui/vuu-layout";
|
|
23
|
+
import cx2 from "clsx";
|
|
24
|
+
|
|
25
|
+
// src/login/LoginPanel.tsx
|
|
26
|
+
import {
|
|
27
|
+
useCallback,
|
|
28
|
+
useEffect,
|
|
29
|
+
useRef,
|
|
30
|
+
useState
|
|
31
|
+
} from "react";
|
|
32
|
+
import { Button, FormField, FormFieldLabel } from "@salt-ds/core";
|
|
33
|
+
import { VuuInput } from "@vuu-ui/vuu-ui-controls";
|
|
34
|
+
|
|
35
|
+
// src/login/VuuLogo.tsx
|
|
36
|
+
import { useMemo } from "react";
|
|
37
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
38
|
+
var VuuLogo = () => {
|
|
39
|
+
const logo = useMemo(
|
|
40
|
+
() => /* @__PURE__ */ jsxs(
|
|
41
|
+
"svg",
|
|
42
|
+
{
|
|
43
|
+
width: "184",
|
|
44
|
+
height: "90",
|
|
45
|
+
viewBox: "0 0 184 90",
|
|
46
|
+
fill: "none",
|
|
47
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsxs("g", { clipPath: "url(#clip0_1173_59965)", children: [
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
"path",
|
|
52
|
+
{
|
|
53
|
+
d: "M77.0775 31.1019L69.4572 15.1795L66.3997 13.7093L47.6353 44.165L75.7224 61.2361L81.8124 51.2694L77.0775 31.1019Z",
|
|
54
|
+
fill: "url(#paint0_linear_1173_59965)"
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
"path",
|
|
59
|
+
{
|
|
60
|
+
d: "M82.4101 49.7431C81.0488 51.8314 79.1993 53.648 76.8897 54.9809C74.2954 56.4792 71.4601 57.194 68.6623 57.194C63.3422 57.194 58.1597 54.6188 55.0209 49.971L30.5358 7.8193L30.5232 7.84116C25.8791 0.274825 16.0118 -2.26289 8.27258 2.21011C0.411306 6.74866 -2.26753 16.7872 2.28587 24.625L35.5054 81.8189C36.9856 84.3691 39.0542 86.3668 41.4358 87.7527C41.4545 87.7652 41.4733 87.7777 41.4921 87.7902C41.5015 87.7964 41.514 87.8027 41.5234 87.8089C42.6312 88.4457 43.8079 88.942 45.0253 89.3072C45.116 89.3353 45.2099 89.3634 45.3007 89.3883C45.7388 89.5101 46.1801 89.6193 46.6276 89.7067C46.7121 89.7223 46.7966 89.7317 46.8811 89.7473C47.241 89.8097 47.604 89.8628 47.967 89.9003C48.111 89.9159 48.2549 89.9315 48.3989 89.9408C48.8151 89.9752 49.2313 89.997 49.6507 90.0001C49.6726 90.0001 49.6945 90.0001 49.7132 90.0001C49.7195 90.0001 49.7226 90.0001 49.7289 90.0001C49.7352 90.0001 49.7383 90.0001 49.7445 90.0001C50.1983 90.0001 50.6552 89.9752 51.109 89.9377C51.2123 89.9283 51.3155 89.919 51.422 89.9065C51.8663 89.8597 52.3107 89.8004 52.7551 89.7192C52.7614 89.7192 52.7676 89.7192 52.7739 89.7192C53.2621 89.6287 53.7503 89.5101 54.2322 89.3727C54.2635 89.3634 54.2917 89.354 54.323 89.3446C55.024 89.1418 55.7156 88.8889 56.3978 88.5861C56.4104 88.5799 56.426 88.5736 56.4385 88.5674C56.958 88.3364 57.4712 88.0836 57.9751 87.7933C58.4852 87.4999 58.9703 87.1815 59.4334 86.8413C59.8371 86.5478 60.2252 86.2357 60.6039 85.9048C61.0639 85.499 61.4989 85.0745 61.9026 84.6282C62.2062 84.2942 62.4972 83.9446 62.7757 83.5825C62.8665 83.4639 62.951 83.3421 63.0355 83.2235C63.2264 82.9613 63.4079 82.6929 63.5831 82.4182C63.6739 82.2746 63.7646 82.1342 63.8523 81.9906C63.8867 81.9344 63.9242 81.8813 63.9555 81.8251L82.5854 49.7525H82.4039L82.4101 49.7431Z",
|
|
61
|
+
fill: "url(#paint1_linear_1173_59965)"
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
"path",
|
|
66
|
+
{
|
|
67
|
+
d: "M82.8264 32.8436L81.4181 30.4464L75.3375 19.1687L72.5178 14.3929C71.9858 13.1225 70.7309 12.2266 69.26 12.2266C67.3104 12.2266 65.7331 13.8029 65.7331 15.7445C65.7331 16.4031 65.924 17.0086 66.2401 17.5362L66.2025 17.5611L77.1557 36.1617C78.4764 38.4372 78.83 41.0873 78.1509 43.6281C77.4718 46.169 75.8445 48.2915 73.5631 49.6119C72.0609 50.4797 70.3553 50.9385 68.6341 50.9385C65.1166 50.9385 61.84 49.0563 60.0812 46.0285L44.3368 19.2654H44.3681L37.7179 7.81917L37.7054 7.84102C37.5896 7.65061 37.455 7.47893 37.333 7.29477L37.1452 6.97326C37.1452 6.97326 37.1296 6.98262 37.1233 6.98887C34.0001 2.55332 29.0054 0.0780356 23.8512 0.0187285V0H15.3515V0.0436999C21.2881 -0.368328 27.2247 2.46593 30.5232 7.84102L30.5357 7.81917L55.0177 49.974C58.1566 54.6187 63.3422 57.197 68.6592 57.197C71.4569 57.197 74.2922 56.4853 76.8866 54.9839C79.1961 53.651 81.0425 51.8312 82.407 49.7461H82.5885L82.5259 49.8523C83.399 48.4695 84.0687 46.9462 84.5006 45.3231C85.6304 41.0904 85.042 36.6705 82.8201 32.8467L82.8264 32.8436Z",
|
|
68
|
+
fill: "#F37880"
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ jsxs("g", { opacity: "0.86", children: [
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
"path",
|
|
74
|
+
{
|
|
75
|
+
d: "M66.1994 17.5642L77.1526 36.1648C78.4732 38.4403 78.8269 41.0904 78.1478 43.6313C77.7347 45.1795 76.9648 46.5716 75.9133 47.7234C77.2903 46.4686 78.2823 44.8486 78.7737 43.007C79.4527 40.4661 79.0991 37.816 77.7785 35.5405L66.8253 16.94L66.8628 16.915C66.5467 16.3875 66.3558 15.7819 66.3558 15.1233C66.3558 14.3117 66.6344 13.5657 67.0975 12.9695C66.2651 13.6125 65.7299 14.6176 65.7299 15.7476C65.7299 16.4062 65.9208 17.0118 66.2369 17.5393L66.1994 17.5642Z",
|
|
76
|
+
fill: "white"
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
"path",
|
|
81
|
+
{
|
|
82
|
+
d: "M82.5382 49.8335L82.5291 49.8487C82.5291 49.8487 82.5352 49.8365 82.5413 49.8304C82.5413 49.8304 82.5413 49.8304 82.5413 49.8335H82.5382Z",
|
|
83
|
+
fill: "white"
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"path",
|
|
88
|
+
{
|
|
89
|
+
d: "M77.5156 54.3596C74.9213 55.8579 72.0859 56.5727 69.2882 56.5727C63.9681 56.5727 58.7856 53.9975 55.6467 49.3497L31.1616 7.19488L31.1491 7.21673C28.9053 3.56154 25.4441 1.08626 21.5917 0H15.3515V0.0436999C21.2881 -0.368328 27.2247 2.46593 30.5232 7.84102L30.5357 7.81917L55.0177 49.974C58.1566 54.6187 63.3422 57.197 68.6592 57.197C71.4569 57.197 74.2922 56.4853 76.8866 54.9839C78.2698 54.1848 79.4809 53.2109 80.5293 52.1122C79.6311 52.9581 78.6266 53.7166 77.5125 54.3596H77.5156Z",
|
|
90
|
+
fill: "white"
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] })
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
"path",
|
|
97
|
+
{
|
|
98
|
+
d: "M117.046 58.661C116.362 58.661 115.792 58.509 115.336 58.205C114.906 57.8757 114.551 57.3943 114.272 56.761L104.354 34.493C104.076 33.8597 104 33.3023 104.126 32.821C104.253 32.3397 104.519 31.9597 104.924 31.681C105.33 31.4023 105.811 31.263 106.368 31.263C107.103 31.263 107.648 31.4277 108.002 31.757C108.382 32.061 108.699 32.5297 108.952 33.163L117.958 54.025H116.324L125.292 33.125C125.571 32.517 125.9 32.061 126.28 31.757C126.66 31.4277 127.192 31.263 127.876 31.263C128.434 31.263 128.89 31.4023 129.244 31.681C129.624 31.9597 129.865 32.3397 129.966 32.821C130.068 33.3023 129.979 33.8597 129.7 34.493L119.782 56.761C119.504 57.3943 119.149 57.8757 118.718 58.205C118.313 58.509 117.756 58.661 117.046 58.661Z",
|
|
99
|
+
fill: "white"
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
"path",
|
|
104
|
+
{
|
|
105
|
+
d: "M144.63 58.737C142.781 58.737 141.147 58.4963 139.728 58.015C138.335 57.5337 137.157 56.8243 136.194 55.887C135.232 54.9243 134.51 53.7337 134.028 52.315C133.547 50.8963 133.306 49.2497 133.306 47.375V33.733C133.306 32.897 133.509 32.2763 133.914 31.871C134.345 31.4657 134.953 31.263 135.738 31.263C136.524 31.263 137.119 31.4657 137.524 31.871C137.955 32.2763 138.17 32.897 138.17 33.733V47.337C138.17 49.7437 138.715 51.555 139.804 52.771C140.919 53.9617 142.528 54.557 144.63 54.557C146.733 54.557 148.329 53.9617 149.418 52.771C150.508 51.555 151.052 49.7437 151.052 47.337V33.733C151.052 32.897 151.255 32.2763 151.66 31.871C152.091 31.4657 152.699 31.263 153.484 31.263C154.244 31.263 154.827 31.4657 155.232 31.871C155.663 32.2763 155.878 32.897 155.878 33.733V47.375C155.878 49.8577 155.448 51.9477 154.586 53.645C153.75 55.3423 152.496 56.6217 150.824 57.483C149.152 58.319 147.088 58.737 144.63 58.737Z",
|
|
106
|
+
fill: "white"
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
"path",
|
|
111
|
+
{
|
|
112
|
+
d: "M172.685 58.737C170.836 58.737 169.202 58.4963 167.783 58.015C166.39 57.5337 165.212 56.8243 164.249 55.887C163.286 54.9243 162.564 53.7337 162.083 52.315C161.602 50.8963 161.361 49.2497 161.361 47.375V33.733C161.361 32.897 161.564 32.2763 161.969 31.871C162.4 31.4657 163.008 31.263 163.793 31.263C164.578 31.263 165.174 31.4657 165.579 31.871C166.01 32.2763 166.225 32.897 166.225 33.733V47.337C166.225 49.7437 166.77 51.555 167.859 52.771C168.974 53.9617 170.582 54.557 172.685 54.557C174.788 54.557 176.384 53.9617 177.473 52.771C178.562 51.555 179.107 49.7437 179.107 47.337V33.733C179.107 32.897 179.31 32.2763 179.715 31.871C180.146 31.4657 180.754 31.263 181.539 31.263C182.299 31.263 182.882 31.4657 183.287 31.871C183.718 32.2763 183.933 32.897 183.933 33.733V47.375C183.933 49.8577 183.502 51.9477 182.641 53.645C181.805 55.3423 180.551 56.6217 178.879 57.483C177.207 58.319 175.142 58.737 172.685 58.737Z",
|
|
113
|
+
fill: "white"
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
117
|
+
/* @__PURE__ */ jsxs(
|
|
118
|
+
"linearGradient",
|
|
119
|
+
{
|
|
120
|
+
id: "paint0_linear_1173_59965",
|
|
121
|
+
x1: "47.6353",
|
|
122
|
+
y1: "37.4727",
|
|
123
|
+
x2: "81.8124",
|
|
124
|
+
y2: "37.4727",
|
|
125
|
+
gradientUnits: "userSpaceOnUse",
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ jsx("stop", { stopColor: "#4906A5" }),
|
|
128
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#D3423A" })
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsxs(
|
|
133
|
+
"linearGradient",
|
|
134
|
+
{
|
|
135
|
+
id: "paint1_linear_1173_59965",
|
|
136
|
+
x1: "0.0670626",
|
|
137
|
+
y1: "45.0017",
|
|
138
|
+
x2: "82.5916",
|
|
139
|
+
y2: "45.0017",
|
|
140
|
+
gradientUnits: "userSpaceOnUse",
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsx("stop", { stopColor: "#7C06A5" }),
|
|
143
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#D3423A" })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip0_1173_59965", children: /* @__PURE__ */ jsx(
|
|
148
|
+
"rect",
|
|
149
|
+
{
|
|
150
|
+
width: "85",
|
|
151
|
+
height: "90",
|
|
152
|
+
fill: "white",
|
|
153
|
+
transform: "translate(0.0670471)"
|
|
154
|
+
}
|
|
155
|
+
) })
|
|
156
|
+
] })
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
[]
|
|
161
|
+
);
|
|
162
|
+
return logo;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/login/LoginPanel.tsx
|
|
166
|
+
import cx from "clsx";
|
|
167
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
168
|
+
var classBase = "vuuLoginPanel";
|
|
169
|
+
var LoginPanel = ({
|
|
170
|
+
appName = "Demo App",
|
|
171
|
+
className,
|
|
172
|
+
requirePassword = true,
|
|
173
|
+
onSubmit,
|
|
174
|
+
...htmlAttributes
|
|
175
|
+
}) => {
|
|
176
|
+
const [username, setUserName] = useState("");
|
|
177
|
+
const [password, setPassword] = useState("");
|
|
178
|
+
const inputRef = useRef(null);
|
|
179
|
+
const login = () => {
|
|
180
|
+
onSubmit(username, password);
|
|
181
|
+
};
|
|
182
|
+
const handleUsername = (evt) => {
|
|
183
|
+
setUserName(evt.target.value);
|
|
184
|
+
};
|
|
185
|
+
const handlePassword = (evt) => {
|
|
186
|
+
setPassword(evt.target.value);
|
|
187
|
+
};
|
|
188
|
+
const handleCommitName = useCallback(() => {
|
|
189
|
+
if (!requirePassword) {
|
|
190
|
+
onSubmit(username);
|
|
191
|
+
}
|
|
192
|
+
}, [onSubmit, requirePassword, username]);
|
|
193
|
+
const handleCommitPassword = useCallback(() => {
|
|
194
|
+
if (username) {
|
|
195
|
+
onSubmit(username, password);
|
|
196
|
+
}
|
|
197
|
+
}, [onSubmit, password, username]);
|
|
198
|
+
const dataIsValid = username.trim() !== "" && (requirePassword === false || password.trim() !== "");
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
var _a;
|
|
201
|
+
console.log(`inputRef`, {
|
|
202
|
+
input: inputRef.current
|
|
203
|
+
});
|
|
204
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
205
|
+
}, []);
|
|
206
|
+
return /* @__PURE__ */ jsxs2("div", { ...htmlAttributes, className: cx(classBase, className), children: [
|
|
207
|
+
/* @__PURE__ */ jsxs2("div", { className: `${classBase}-branding`, children: [
|
|
208
|
+
/* @__PURE__ */ jsx2(VuuLogo, {}),
|
|
209
|
+
/* @__PURE__ */ jsx2("div", { className: `${classBase}-appName`, children: appName })
|
|
210
|
+
] }),
|
|
211
|
+
/* @__PURE__ */ jsxs2("div", { className: `${classBase}-form`, children: [
|
|
212
|
+
/* @__PURE__ */ jsx2("div", { className: `${classBase}-title`, children: "Welcome Back" }),
|
|
213
|
+
/* @__PURE__ */ jsxs2(FormField, { children: [
|
|
214
|
+
/* @__PURE__ */ jsx2(FormFieldLabel, { children: "Username" }),
|
|
215
|
+
/* @__PURE__ */ jsx2(
|
|
216
|
+
VuuInput,
|
|
217
|
+
{
|
|
218
|
+
value: username,
|
|
219
|
+
id: "text-username",
|
|
220
|
+
inputRef,
|
|
221
|
+
onChange: handleUsername,
|
|
222
|
+
onCommit: handleCommitName
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] }),
|
|
226
|
+
requirePassword ? /* @__PURE__ */ jsxs2(FormField, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx2(FormFieldLabel, { children: "Password" }),
|
|
228
|
+
/* @__PURE__ */ jsx2(
|
|
229
|
+
VuuInput,
|
|
230
|
+
{
|
|
231
|
+
className: `${classBase}-password`,
|
|
232
|
+
inputProps: {
|
|
233
|
+
type: "password"
|
|
234
|
+
},
|
|
235
|
+
value: password,
|
|
236
|
+
id: "text-password",
|
|
237
|
+
onChange: handlePassword,
|
|
238
|
+
onCommit: handleCommitPassword,
|
|
239
|
+
endAdornment: /* @__PURE__ */ jsx2("span", { "data-icon": "eye", style: { cursor: "pointer" } })
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
] }) : null,
|
|
243
|
+
/* @__PURE__ */ jsx2(
|
|
244
|
+
Button,
|
|
245
|
+
{
|
|
246
|
+
className: `${classBase}-login`,
|
|
247
|
+
disabled: !dataIsValid,
|
|
248
|
+
onClick: login,
|
|
249
|
+
variant: "cta",
|
|
250
|
+
children: "Login"
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
] })
|
|
254
|
+
] });
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// src/login/login-utils.ts
|
|
258
|
+
import { getCookieValue } from "@vuu-ui/vuu-utils";
|
|
259
|
+
var getAuthModeFromCookies = () => {
|
|
260
|
+
const mode = getCookieValue("vuu-auth-mode");
|
|
261
|
+
return mode != null ? mode : "";
|
|
262
|
+
};
|
|
263
|
+
var getAuthDetailsFromCookies = () => {
|
|
264
|
+
const username = getCookieValue("vuu-username");
|
|
265
|
+
const token = getCookieValue("vuu-auth-token");
|
|
266
|
+
return [username, token];
|
|
267
|
+
};
|
|
268
|
+
var getDefaultLoginUrl = () => {
|
|
269
|
+
const authMode = getAuthModeFromCookies();
|
|
270
|
+
return authMode === "login" ? "login.html" : "demo.html";
|
|
271
|
+
};
|
|
272
|
+
var redirectToLogin = (loginUrl = getDefaultLoginUrl()) => {
|
|
273
|
+
window.location.href = loginUrl;
|
|
274
|
+
};
|
|
275
|
+
var logout = (loginUrl) => {
|
|
276
|
+
document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
277
|
+
document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
278
|
+
redirectToLogin(loginUrl);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// src/app-header/AppHeader.tsx
|
|
282
|
+
import { Button as Button2 } from "@salt-ds/core";
|
|
283
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
284
|
+
var classBase2 = "vuuAppHeader";
|
|
285
|
+
var AppHeader = ({
|
|
286
|
+
className: classNameProp,
|
|
287
|
+
layoutId,
|
|
288
|
+
loginUrl,
|
|
289
|
+
onNavigate,
|
|
290
|
+
onSwitchTheme,
|
|
291
|
+
themeMode = "light",
|
|
292
|
+
user,
|
|
293
|
+
...htmlAttributes
|
|
294
|
+
}) => {
|
|
295
|
+
const className = cx2(classBase2, classNameProp);
|
|
296
|
+
const handleLogout = useCallback2(() => {
|
|
297
|
+
logout(loginUrl);
|
|
298
|
+
}, [loginUrl]);
|
|
299
|
+
return /* @__PURE__ */ jsxs3(
|
|
300
|
+
Toolbar,
|
|
301
|
+
{
|
|
302
|
+
alignItems: "end",
|
|
303
|
+
className,
|
|
304
|
+
height: 36,
|
|
305
|
+
showSeparators: true,
|
|
306
|
+
...htmlAttributes,
|
|
307
|
+
children: [
|
|
308
|
+
/* @__PURE__ */ jsx3(Button2, { className: `${classBase2}-menuItem`, variant: "secondary", children: "Help" }),
|
|
309
|
+
/* @__PURE__ */ jsxs3(Button2, { className: `${classBase2}-menuItem`, variant: "secondary", children: [
|
|
310
|
+
"History ",
|
|
311
|
+
/* @__PURE__ */ jsx3("span", { "data-icon": "history" })
|
|
312
|
+
] }),
|
|
313
|
+
/* @__PURE__ */ jsxs3(Button2, { className: `${classBase2}-menuItem`, variant: "secondary", children: [
|
|
314
|
+
"View ",
|
|
315
|
+
/* @__PURE__ */ jsx3("span", { "data-icon": "settings" })
|
|
316
|
+
] }),
|
|
317
|
+
/* @__PURE__ */ jsx3(
|
|
318
|
+
Button2,
|
|
319
|
+
{
|
|
320
|
+
className: `${classBase2}-menuItem`,
|
|
321
|
+
onClick: handleLogout,
|
|
322
|
+
variant: "secondary",
|
|
323
|
+
children: "Log out"
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/connection-status/ConnectionStatusIcon.tsx
|
|
332
|
+
import React, { useEffect as useEffect2, useState as useState2 } from "react";
|
|
333
|
+
import cx3 from "clsx";
|
|
334
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
335
|
+
var ConnectionStatusIcon = ({
|
|
336
|
+
connectionStatus,
|
|
337
|
+
className,
|
|
338
|
+
element = "span",
|
|
339
|
+
...props
|
|
340
|
+
}) => {
|
|
341
|
+
const [classBase14, setClassBase] = useState2("vuuConnectingStatus");
|
|
342
|
+
useEffect2(() => {
|
|
343
|
+
switch (connectionStatus) {
|
|
344
|
+
case "connected":
|
|
345
|
+
case "reconnected":
|
|
346
|
+
setClassBase("vuuActiveStatus");
|
|
347
|
+
break;
|
|
348
|
+
case "connecting":
|
|
349
|
+
setClassBase("vuuConnectingStatus");
|
|
350
|
+
break;
|
|
351
|
+
case "disconnected":
|
|
352
|
+
setClassBase("vuuDisconnectedStatus");
|
|
353
|
+
break;
|
|
354
|
+
default:
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}, [connectionStatus]);
|
|
358
|
+
const statusIcon = React.createElement(element, {
|
|
359
|
+
...props,
|
|
360
|
+
className: cx3("vuuStatus vuuIcon", classBase14, className)
|
|
361
|
+
});
|
|
362
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: /* @__PURE__ */ jsxs4("div", { className: "vuuStatus-container salt-theme", children: [
|
|
363
|
+
statusIcon,
|
|
364
|
+
/* @__PURE__ */ jsxs4("div", { className: "vuuStatus-text", children: [
|
|
365
|
+
"Status: ",
|
|
366
|
+
connectionStatus.toUpperCase()
|
|
367
|
+
] })
|
|
368
|
+
] }) });
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// src/feature/Feature.tsx
|
|
372
|
+
import React3, { Suspense, useEffect as useEffect3 } from "react";
|
|
373
|
+
import { registerComponent } from "@vuu-ui/vuu-layout";
|
|
374
|
+
|
|
375
|
+
// src/feature/FeatureErrorBoundary.tsx
|
|
376
|
+
import React2 from "react";
|
|
377
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
378
|
+
var FeatureErrorBoundary = class extends React2.Component {
|
|
379
|
+
constructor(props) {
|
|
380
|
+
super(props);
|
|
381
|
+
this.state = { errorMessage: null };
|
|
382
|
+
}
|
|
383
|
+
static getDerivedStateFromError(error2) {
|
|
384
|
+
return { errorMessage: error2.message };
|
|
385
|
+
}
|
|
386
|
+
componentDidCatch(error2, errorInfo) {
|
|
387
|
+
console.log(`error creating component at ${this.props.url}`);
|
|
388
|
+
console.log(error2, errorInfo);
|
|
389
|
+
}
|
|
390
|
+
render() {
|
|
391
|
+
if (this.state.errorMessage) {
|
|
392
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
393
|
+
/* @__PURE__ */ jsx5("h1", { children: "An error occured while creating component." }),
|
|
394
|
+
/* @__PURE__ */ jsx5("p", { children: this.state.errorMessage })
|
|
395
|
+
] });
|
|
396
|
+
}
|
|
397
|
+
return this.props.children;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// src/feature/Loader.tsx
|
|
402
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
403
|
+
var Loader = () => /* @__PURE__ */ jsx6("div", { className: "hwLoader" });
|
|
404
|
+
|
|
405
|
+
// src/feature/css-module-loader.ts
|
|
406
|
+
var importCSS = async (path) => {
|
|
407
|
+
const container = new CSSStyleSheet();
|
|
408
|
+
return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/feature/Feature.tsx
|
|
412
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
413
|
+
var componentsMap = /* @__PURE__ */ new Map();
|
|
414
|
+
var useCachedFeature = (url) => {
|
|
415
|
+
useEffect3(
|
|
416
|
+
() => () => {
|
|
417
|
+
componentsMap.delete(url);
|
|
418
|
+
},
|
|
419
|
+
[url]
|
|
420
|
+
);
|
|
421
|
+
if (!componentsMap.has(url)) {
|
|
422
|
+
componentsMap.set(
|
|
423
|
+
url,
|
|
424
|
+
React3.lazy(() => import(
|
|
425
|
+
/* @vite-ignore */
|
|
426
|
+
url
|
|
427
|
+
))
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
const lazyFeature = componentsMap.get(url);
|
|
431
|
+
if (!lazyFeature) {
|
|
432
|
+
throw Error(`Unable to load Lazy Feature at url ${url}`);
|
|
433
|
+
} else {
|
|
434
|
+
return lazyFeature;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
function RawFeature({
|
|
438
|
+
url,
|
|
439
|
+
css,
|
|
440
|
+
ComponentProps: params,
|
|
441
|
+
...props
|
|
442
|
+
}) {
|
|
443
|
+
if (css) {
|
|
444
|
+
importCSS(css).then((styleSheet) => {
|
|
445
|
+
document.adoptedStyleSheets = [
|
|
446
|
+
...document.adoptedStyleSheets,
|
|
447
|
+
styleSheet
|
|
448
|
+
];
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
const LazyFeature = useCachedFeature(url);
|
|
452
|
+
return /* @__PURE__ */ jsx7(FeatureErrorBoundary, { url, children: /* @__PURE__ */ jsx7(Suspense, { fallback: /* @__PURE__ */ jsx7(Loader, {}), children: /* @__PURE__ */ jsx7(LazyFeature, { ...props, ...params }) }) });
|
|
453
|
+
}
|
|
454
|
+
var Feature = React3.memo(RawFeature);
|
|
455
|
+
Feature.displayName = "Feature";
|
|
456
|
+
registerComponent("Feature", Feature, "view");
|
|
457
|
+
|
|
458
|
+
// src/layout-management/SaveLayoutPanel.tsx
|
|
459
|
+
import { Checkbox, ComboBox, RadioButton } from "@vuu-ui/vuu-ui-controls";
|
|
460
|
+
|
|
461
|
+
// ../../node_modules/html-to-image/es/util.js
|
|
462
|
+
function resolveUrl(url, baseUrl) {
|
|
463
|
+
if (url.match(/^[a-z]+:\/\//i)) {
|
|
464
|
+
return url;
|
|
465
|
+
}
|
|
466
|
+
if (url.match(/^\/\//)) {
|
|
467
|
+
return window.location.protocol + url;
|
|
468
|
+
}
|
|
469
|
+
if (url.match(/^[a-z]+:/i)) {
|
|
470
|
+
return url;
|
|
471
|
+
}
|
|
472
|
+
const doc = document.implementation.createHTMLDocument();
|
|
473
|
+
const base = doc.createElement("base");
|
|
474
|
+
const a = doc.createElement("a");
|
|
475
|
+
doc.head.appendChild(base);
|
|
476
|
+
doc.body.appendChild(a);
|
|
477
|
+
if (baseUrl) {
|
|
478
|
+
base.href = baseUrl;
|
|
479
|
+
}
|
|
480
|
+
a.href = url;
|
|
481
|
+
return a.href;
|
|
482
|
+
}
|
|
483
|
+
var uuid = /* @__PURE__ */ (() => {
|
|
484
|
+
let counter = 0;
|
|
485
|
+
const random = () => (
|
|
486
|
+
// eslint-disable-next-line no-bitwise
|
|
487
|
+
`0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4)
|
|
488
|
+
);
|
|
489
|
+
return () => {
|
|
490
|
+
counter += 1;
|
|
491
|
+
return `u${random()}${counter}`;
|
|
492
|
+
};
|
|
493
|
+
})();
|
|
494
|
+
function toArray(arrayLike) {
|
|
495
|
+
const arr = [];
|
|
496
|
+
for (let i = 0, l = arrayLike.length; i < l; i++) {
|
|
497
|
+
arr.push(arrayLike[i]);
|
|
498
|
+
}
|
|
499
|
+
return arr;
|
|
500
|
+
}
|
|
501
|
+
function px(node, styleProperty) {
|
|
502
|
+
const win = node.ownerDocument.defaultView || window;
|
|
503
|
+
const val = win.getComputedStyle(node).getPropertyValue(styleProperty);
|
|
504
|
+
return val ? parseFloat(val.replace("px", "")) : 0;
|
|
505
|
+
}
|
|
506
|
+
function getNodeWidth(node) {
|
|
507
|
+
const leftBorder = px(node, "border-left-width");
|
|
508
|
+
const rightBorder = px(node, "border-right-width");
|
|
509
|
+
return node.clientWidth + leftBorder + rightBorder;
|
|
510
|
+
}
|
|
511
|
+
function getNodeHeight(node) {
|
|
512
|
+
const topBorder = px(node, "border-top-width");
|
|
513
|
+
const bottomBorder = px(node, "border-bottom-width");
|
|
514
|
+
return node.clientHeight + topBorder + bottomBorder;
|
|
515
|
+
}
|
|
516
|
+
function getImageSize(targetNode, options = {}) {
|
|
517
|
+
const width = options.width || getNodeWidth(targetNode);
|
|
518
|
+
const height = options.height || getNodeHeight(targetNode);
|
|
519
|
+
return { width, height };
|
|
520
|
+
}
|
|
521
|
+
function getPixelRatio() {
|
|
522
|
+
let ratio;
|
|
523
|
+
let FINAL_PROCESS;
|
|
524
|
+
try {
|
|
525
|
+
FINAL_PROCESS = process;
|
|
526
|
+
} catch (e) {
|
|
527
|
+
}
|
|
528
|
+
const val = FINAL_PROCESS && FINAL_PROCESS.env ? FINAL_PROCESS.env.devicePixelRatio : null;
|
|
529
|
+
if (val) {
|
|
530
|
+
ratio = parseInt(val, 10);
|
|
531
|
+
if (Number.isNaN(ratio)) {
|
|
532
|
+
ratio = 1;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return ratio || window.devicePixelRatio || 1;
|
|
536
|
+
}
|
|
537
|
+
var canvasDimensionLimit = 16384;
|
|
538
|
+
function checkCanvasDimensions(canvas) {
|
|
539
|
+
if (canvas.width > canvasDimensionLimit || canvas.height > canvasDimensionLimit) {
|
|
540
|
+
if (canvas.width > canvasDimensionLimit && canvas.height > canvasDimensionLimit) {
|
|
541
|
+
if (canvas.width > canvas.height) {
|
|
542
|
+
canvas.height *= canvasDimensionLimit / canvas.width;
|
|
543
|
+
canvas.width = canvasDimensionLimit;
|
|
544
|
+
} else {
|
|
545
|
+
canvas.width *= canvasDimensionLimit / canvas.height;
|
|
546
|
+
canvas.height = canvasDimensionLimit;
|
|
547
|
+
}
|
|
548
|
+
} else if (canvas.width > canvasDimensionLimit) {
|
|
549
|
+
canvas.height *= canvasDimensionLimit / canvas.width;
|
|
550
|
+
canvas.width = canvasDimensionLimit;
|
|
551
|
+
} else {
|
|
552
|
+
canvas.width *= canvasDimensionLimit / canvas.height;
|
|
553
|
+
canvas.height = canvasDimensionLimit;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function createImage(url) {
|
|
558
|
+
return new Promise((resolve, reject) => {
|
|
559
|
+
const img = new Image();
|
|
560
|
+
img.decode = () => resolve(img);
|
|
561
|
+
img.onload = () => resolve(img);
|
|
562
|
+
img.onerror = reject;
|
|
563
|
+
img.crossOrigin = "anonymous";
|
|
564
|
+
img.decoding = "async";
|
|
565
|
+
img.src = url;
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
async function svgToDataURL(svg) {
|
|
569
|
+
return Promise.resolve().then(() => new XMLSerializer().serializeToString(svg)).then(encodeURIComponent).then((html) => `data:image/svg+xml;charset=utf-8,${html}`);
|
|
570
|
+
}
|
|
571
|
+
async function nodeToDataURL(node, width, height) {
|
|
572
|
+
const xmlns = "http://www.w3.org/2000/svg";
|
|
573
|
+
const svg = document.createElementNS(xmlns, "svg");
|
|
574
|
+
const foreignObject = document.createElementNS(xmlns, "foreignObject");
|
|
575
|
+
svg.setAttribute("width", `${width}`);
|
|
576
|
+
svg.setAttribute("height", `${height}`);
|
|
577
|
+
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
578
|
+
foreignObject.setAttribute("width", "100%");
|
|
579
|
+
foreignObject.setAttribute("height", "100%");
|
|
580
|
+
foreignObject.setAttribute("x", "0");
|
|
581
|
+
foreignObject.setAttribute("y", "0");
|
|
582
|
+
foreignObject.setAttribute("externalResourcesRequired", "true");
|
|
583
|
+
svg.appendChild(foreignObject);
|
|
584
|
+
foreignObject.appendChild(node);
|
|
585
|
+
return svgToDataURL(svg);
|
|
586
|
+
}
|
|
587
|
+
var isInstanceOfElement = (node, instance) => {
|
|
588
|
+
if (node instanceof instance)
|
|
589
|
+
return true;
|
|
590
|
+
const nodePrototype = Object.getPrototypeOf(node);
|
|
591
|
+
if (nodePrototype === null)
|
|
592
|
+
return false;
|
|
593
|
+
return nodePrototype.constructor.name === instance.name || isInstanceOfElement(nodePrototype, instance);
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
// ../../node_modules/html-to-image/es/clone-pseudos.js
|
|
597
|
+
function formatCSSText(style) {
|
|
598
|
+
const content = style.getPropertyValue("content");
|
|
599
|
+
return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
|
|
600
|
+
}
|
|
601
|
+
function formatCSSProperties(style) {
|
|
602
|
+
return toArray(style).map((name) => {
|
|
603
|
+
const value = style.getPropertyValue(name);
|
|
604
|
+
const priority = style.getPropertyPriority(name);
|
|
605
|
+
return `${name}: ${value}${priority ? " !important" : ""};`;
|
|
606
|
+
}).join(" ");
|
|
607
|
+
}
|
|
608
|
+
function getPseudoElementStyle(className, pseudo, style) {
|
|
609
|
+
const selector = `.${className}:${pseudo}`;
|
|
610
|
+
const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style);
|
|
611
|
+
return document.createTextNode(`${selector}{${cssText}}`);
|
|
612
|
+
}
|
|
613
|
+
function clonePseudoElement(nativeNode, clonedNode, pseudo) {
|
|
614
|
+
const style = window.getComputedStyle(nativeNode, pseudo);
|
|
615
|
+
const content = style.getPropertyValue("content");
|
|
616
|
+
if (content === "" || content === "none") {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const className = uuid();
|
|
620
|
+
try {
|
|
621
|
+
clonedNode.className = `${clonedNode.className} ${className}`;
|
|
622
|
+
} catch (err) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const styleElement = document.createElement("style");
|
|
626
|
+
styleElement.appendChild(getPseudoElementStyle(className, pseudo, style));
|
|
627
|
+
clonedNode.appendChild(styleElement);
|
|
628
|
+
}
|
|
629
|
+
function clonePseudoElements(nativeNode, clonedNode) {
|
|
630
|
+
clonePseudoElement(nativeNode, clonedNode, ":before");
|
|
631
|
+
clonePseudoElement(nativeNode, clonedNode, ":after");
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// ../../node_modules/html-to-image/es/mimes.js
|
|
635
|
+
var WOFF = "application/font-woff";
|
|
636
|
+
var JPEG = "image/jpeg";
|
|
637
|
+
var mimes = {
|
|
638
|
+
woff: WOFF,
|
|
639
|
+
woff2: WOFF,
|
|
640
|
+
ttf: "application/font-truetype",
|
|
641
|
+
eot: "application/vnd.ms-fontobject",
|
|
642
|
+
png: "image/png",
|
|
643
|
+
jpg: JPEG,
|
|
644
|
+
jpeg: JPEG,
|
|
645
|
+
gif: "image/gif",
|
|
646
|
+
tiff: "image/tiff",
|
|
647
|
+
svg: "image/svg+xml",
|
|
648
|
+
webp: "image/webp"
|
|
649
|
+
};
|
|
650
|
+
function getExtension(url) {
|
|
651
|
+
const match = /\.([^./]*?)$/g.exec(url);
|
|
652
|
+
return match ? match[1] : "";
|
|
653
|
+
}
|
|
654
|
+
function getMimeType(url) {
|
|
655
|
+
const extension = getExtension(url).toLowerCase();
|
|
656
|
+
return mimes[extension] || "";
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// ../../node_modules/html-to-image/es/dataurl.js
|
|
660
|
+
function getContentFromDataUrl(dataURL) {
|
|
661
|
+
return dataURL.split(/,/)[1];
|
|
662
|
+
}
|
|
663
|
+
function isDataUrl(url) {
|
|
664
|
+
return url.search(/^(data:)/) !== -1;
|
|
665
|
+
}
|
|
666
|
+
function makeDataUrl(content, mimeType) {
|
|
667
|
+
return `data:${mimeType};base64,${content}`;
|
|
668
|
+
}
|
|
669
|
+
async function fetchAsDataURL(url, init, process2) {
|
|
670
|
+
const res = await fetch(url, init);
|
|
671
|
+
if (res.status === 404) {
|
|
672
|
+
throw new Error(`Resource "${res.url}" not found`);
|
|
673
|
+
}
|
|
674
|
+
const blob = await res.blob();
|
|
675
|
+
return new Promise((resolve, reject) => {
|
|
676
|
+
const reader = new FileReader();
|
|
677
|
+
reader.onerror = reject;
|
|
678
|
+
reader.onloadend = () => {
|
|
679
|
+
try {
|
|
680
|
+
resolve(process2({ res, result: reader.result }));
|
|
681
|
+
} catch (error2) {
|
|
682
|
+
reject(error2);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
reader.readAsDataURL(blob);
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
var cache = {};
|
|
689
|
+
function getCacheKey(url, contentType, includeQueryParams) {
|
|
690
|
+
let key = url.replace(/\?.*/, "");
|
|
691
|
+
if (includeQueryParams) {
|
|
692
|
+
key = url;
|
|
693
|
+
}
|
|
694
|
+
if (/ttf|otf|eot|woff2?/i.test(key)) {
|
|
695
|
+
key = key.replace(/.*\//, "");
|
|
696
|
+
}
|
|
697
|
+
return contentType ? `[${contentType}]${key}` : key;
|
|
698
|
+
}
|
|
699
|
+
async function resourceToDataURL(resourceUrl, contentType, options) {
|
|
700
|
+
const cacheKey = getCacheKey(resourceUrl, contentType, options.includeQueryParams);
|
|
701
|
+
if (cache[cacheKey] != null) {
|
|
702
|
+
return cache[cacheKey];
|
|
703
|
+
}
|
|
704
|
+
if (options.cacheBust) {
|
|
705
|
+
resourceUrl += (/\?/.test(resourceUrl) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
|
|
706
|
+
}
|
|
707
|
+
let dataURL;
|
|
708
|
+
try {
|
|
709
|
+
const content = await fetchAsDataURL(resourceUrl, options.fetchRequestInit, ({ res, result }) => {
|
|
710
|
+
if (!contentType) {
|
|
711
|
+
contentType = res.headers.get("Content-Type") || "";
|
|
712
|
+
}
|
|
713
|
+
return getContentFromDataUrl(result);
|
|
714
|
+
});
|
|
715
|
+
dataURL = makeDataUrl(content, contentType);
|
|
716
|
+
} catch (error2) {
|
|
717
|
+
dataURL = options.imagePlaceholder || "";
|
|
718
|
+
let msg = `Failed to fetch resource: ${resourceUrl}`;
|
|
719
|
+
if (error2) {
|
|
720
|
+
msg = typeof error2 === "string" ? error2 : error2.message;
|
|
721
|
+
}
|
|
722
|
+
if (msg) {
|
|
723
|
+
console.warn(msg);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
cache[cacheKey] = dataURL;
|
|
727
|
+
return dataURL;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// ../../node_modules/html-to-image/es/clone-node.js
|
|
731
|
+
async function cloneCanvasElement(canvas) {
|
|
732
|
+
const dataURL = canvas.toDataURL();
|
|
733
|
+
if (dataURL === "data:,") {
|
|
734
|
+
return canvas.cloneNode(false);
|
|
735
|
+
}
|
|
736
|
+
return createImage(dataURL);
|
|
737
|
+
}
|
|
738
|
+
async function cloneVideoElement(video, options) {
|
|
739
|
+
if (video.currentSrc) {
|
|
740
|
+
const canvas = document.createElement("canvas");
|
|
741
|
+
const ctx = canvas.getContext("2d");
|
|
742
|
+
canvas.width = video.clientWidth;
|
|
743
|
+
canvas.height = video.clientHeight;
|
|
744
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
745
|
+
const dataURL2 = canvas.toDataURL();
|
|
746
|
+
return createImage(dataURL2);
|
|
747
|
+
}
|
|
748
|
+
const poster = video.poster;
|
|
749
|
+
const contentType = getMimeType(poster);
|
|
750
|
+
const dataURL = await resourceToDataURL(poster, contentType, options);
|
|
751
|
+
return createImage(dataURL);
|
|
752
|
+
}
|
|
753
|
+
async function cloneIFrameElement(iframe) {
|
|
754
|
+
var _a;
|
|
755
|
+
try {
|
|
756
|
+
if ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.body) {
|
|
757
|
+
return await cloneNode(iframe.contentDocument.body, {}, true);
|
|
758
|
+
}
|
|
759
|
+
} catch (_b) {
|
|
760
|
+
}
|
|
761
|
+
return iframe.cloneNode(false);
|
|
762
|
+
}
|
|
763
|
+
async function cloneSingleNode(node, options) {
|
|
764
|
+
if (isInstanceOfElement(node, HTMLCanvasElement)) {
|
|
765
|
+
return cloneCanvasElement(node);
|
|
766
|
+
}
|
|
767
|
+
if (isInstanceOfElement(node, HTMLVideoElement)) {
|
|
768
|
+
return cloneVideoElement(node, options);
|
|
769
|
+
}
|
|
770
|
+
if (isInstanceOfElement(node, HTMLIFrameElement)) {
|
|
771
|
+
return cloneIFrameElement(node);
|
|
772
|
+
}
|
|
773
|
+
return node.cloneNode(false);
|
|
774
|
+
}
|
|
775
|
+
var isSlotElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SLOT";
|
|
776
|
+
async function cloneChildren(nativeNode, clonedNode, options) {
|
|
777
|
+
var _a, _b;
|
|
778
|
+
let children = [];
|
|
779
|
+
if (isSlotElement(nativeNode) && nativeNode.assignedNodes) {
|
|
780
|
+
children = toArray(nativeNode.assignedNodes());
|
|
781
|
+
} else if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && ((_a = nativeNode.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
|
|
782
|
+
children = toArray(nativeNode.contentDocument.body.childNodes);
|
|
783
|
+
} else {
|
|
784
|
+
children = toArray(((_b = nativeNode.shadowRoot) !== null && _b !== void 0 ? _b : nativeNode).childNodes);
|
|
785
|
+
}
|
|
786
|
+
if (children.length === 0 || isInstanceOfElement(nativeNode, HTMLVideoElement)) {
|
|
787
|
+
return clonedNode;
|
|
788
|
+
}
|
|
789
|
+
await children.reduce((deferred, child) => deferred.then(() => cloneNode(child, options)).then((clonedChild) => {
|
|
790
|
+
if (clonedChild) {
|
|
791
|
+
clonedNode.appendChild(clonedChild);
|
|
792
|
+
}
|
|
793
|
+
}), Promise.resolve());
|
|
794
|
+
return clonedNode;
|
|
795
|
+
}
|
|
796
|
+
function cloneCSSStyle(nativeNode, clonedNode) {
|
|
797
|
+
const targetStyle = clonedNode.style;
|
|
798
|
+
if (!targetStyle) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const sourceStyle = window.getComputedStyle(nativeNode);
|
|
802
|
+
if (sourceStyle.cssText) {
|
|
803
|
+
targetStyle.cssText = sourceStyle.cssText;
|
|
804
|
+
targetStyle.transformOrigin = sourceStyle.transformOrigin;
|
|
805
|
+
} else {
|
|
806
|
+
toArray(sourceStyle).forEach((name) => {
|
|
807
|
+
let value = sourceStyle.getPropertyValue(name);
|
|
808
|
+
if (name === "font-size" && value.endsWith("px")) {
|
|
809
|
+
const reducedFont = Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1;
|
|
810
|
+
value = `${reducedFont}px`;
|
|
811
|
+
}
|
|
812
|
+
if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && name === "display" && value === "inline") {
|
|
813
|
+
value = "block";
|
|
814
|
+
}
|
|
815
|
+
if (name === "d" && clonedNode.getAttribute("d")) {
|
|
816
|
+
value = `path(${clonedNode.getAttribute("d")})`;
|
|
817
|
+
}
|
|
818
|
+
targetStyle.setProperty(name, value, sourceStyle.getPropertyPriority(name));
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
function cloneInputValue(nativeNode, clonedNode) {
|
|
823
|
+
if (isInstanceOfElement(nativeNode, HTMLTextAreaElement)) {
|
|
824
|
+
clonedNode.innerHTML = nativeNode.value;
|
|
825
|
+
}
|
|
826
|
+
if (isInstanceOfElement(nativeNode, HTMLInputElement)) {
|
|
827
|
+
clonedNode.setAttribute("value", nativeNode.value);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
function cloneSelectValue(nativeNode, clonedNode) {
|
|
831
|
+
if (isInstanceOfElement(nativeNode, HTMLSelectElement)) {
|
|
832
|
+
const clonedSelect = clonedNode;
|
|
833
|
+
const selectedOption = Array.from(clonedSelect.children).find((child) => nativeNode.value === child.getAttribute("value"));
|
|
834
|
+
if (selectedOption) {
|
|
835
|
+
selectedOption.setAttribute("selected", "");
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
function decorate(nativeNode, clonedNode) {
|
|
840
|
+
if (isInstanceOfElement(clonedNode, Element)) {
|
|
841
|
+
cloneCSSStyle(nativeNode, clonedNode);
|
|
842
|
+
clonePseudoElements(nativeNode, clonedNode);
|
|
843
|
+
cloneInputValue(nativeNode, clonedNode);
|
|
844
|
+
cloneSelectValue(nativeNode, clonedNode);
|
|
845
|
+
}
|
|
846
|
+
return clonedNode;
|
|
847
|
+
}
|
|
848
|
+
async function ensureSVGSymbols(clone, options) {
|
|
849
|
+
const uses = clone.querySelectorAll ? clone.querySelectorAll("use") : [];
|
|
850
|
+
if (uses.length === 0) {
|
|
851
|
+
return clone;
|
|
852
|
+
}
|
|
853
|
+
const processedDefs = {};
|
|
854
|
+
for (let i = 0; i < uses.length; i++) {
|
|
855
|
+
const use = uses[i];
|
|
856
|
+
const id = use.getAttribute("xlink:href");
|
|
857
|
+
if (id) {
|
|
858
|
+
const exist = clone.querySelector(id);
|
|
859
|
+
const definition = document.querySelector(id);
|
|
860
|
+
if (!exist && definition && !processedDefs[id]) {
|
|
861
|
+
processedDefs[id] = await cloneNode(definition, options, true);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
const nodes = Object.values(processedDefs);
|
|
866
|
+
if (nodes.length) {
|
|
867
|
+
const ns = "http://www.w3.org/1999/xhtml";
|
|
868
|
+
const svg = document.createElementNS(ns, "svg");
|
|
869
|
+
svg.setAttribute("xmlns", ns);
|
|
870
|
+
svg.style.position = "absolute";
|
|
871
|
+
svg.style.width = "0";
|
|
872
|
+
svg.style.height = "0";
|
|
873
|
+
svg.style.overflow = "hidden";
|
|
874
|
+
svg.style.display = "none";
|
|
875
|
+
const defs = document.createElementNS(ns, "defs");
|
|
876
|
+
svg.appendChild(defs);
|
|
877
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
878
|
+
defs.appendChild(nodes[i]);
|
|
879
|
+
}
|
|
880
|
+
clone.appendChild(svg);
|
|
881
|
+
}
|
|
882
|
+
return clone;
|
|
883
|
+
}
|
|
884
|
+
async function cloneNode(node, options, isRoot) {
|
|
885
|
+
if (!isRoot && options.filter && !options.filter(node)) {
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// ../../node_modules/html-to-image/es/embed-resources.js
|
|
892
|
+
var URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
|
|
893
|
+
var URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
|
|
894
|
+
var FONT_SRC_REGEX = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
|
|
895
|
+
function toRegex(url) {
|
|
896
|
+
const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
|
|
897
|
+
return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
|
|
898
|
+
}
|
|
899
|
+
function parseURLs(cssText) {
|
|
900
|
+
const urls = [];
|
|
901
|
+
cssText.replace(URL_REGEX, (raw, quotation, url) => {
|
|
902
|
+
urls.push(url);
|
|
903
|
+
return raw;
|
|
904
|
+
});
|
|
905
|
+
return urls.filter((url) => !isDataUrl(url));
|
|
906
|
+
}
|
|
907
|
+
async function embed(cssText, resourceURL, baseURL, options, getContentFromUrl) {
|
|
908
|
+
try {
|
|
909
|
+
const resolvedURL = baseURL ? resolveUrl(resourceURL, baseURL) : resourceURL;
|
|
910
|
+
const contentType = getMimeType(resourceURL);
|
|
911
|
+
let dataURL;
|
|
912
|
+
if (getContentFromUrl) {
|
|
913
|
+
const content = await getContentFromUrl(resolvedURL);
|
|
914
|
+
dataURL = makeDataUrl(content, contentType);
|
|
915
|
+
} else {
|
|
916
|
+
dataURL = await resourceToDataURL(resolvedURL, contentType, options);
|
|
917
|
+
}
|
|
918
|
+
return cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
|
|
919
|
+
} catch (error2) {
|
|
920
|
+
}
|
|
921
|
+
return cssText;
|
|
922
|
+
}
|
|
923
|
+
function filterPreferredFontFormat(str, { preferredFontFormat }) {
|
|
924
|
+
return !preferredFontFormat ? str : str.replace(FONT_SRC_REGEX, (match) => {
|
|
925
|
+
while (true) {
|
|
926
|
+
const [src, , format] = URL_WITH_FORMAT_REGEX.exec(match) || [];
|
|
927
|
+
if (!format) {
|
|
928
|
+
return "";
|
|
929
|
+
}
|
|
930
|
+
if (format === preferredFontFormat) {
|
|
931
|
+
return `src: ${src};`;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
function shouldEmbed(url) {
|
|
937
|
+
return url.search(URL_REGEX) !== -1;
|
|
938
|
+
}
|
|
939
|
+
async function embedResources(cssText, baseUrl, options) {
|
|
940
|
+
if (!shouldEmbed(cssText)) {
|
|
941
|
+
return cssText;
|
|
942
|
+
}
|
|
943
|
+
const filteredCSSText = filterPreferredFontFormat(cssText, options);
|
|
944
|
+
const urls = parseURLs(filteredCSSText);
|
|
945
|
+
return urls.reduce((deferred, url) => deferred.then((css) => embed(css, url, baseUrl, options)), Promise.resolve(filteredCSSText));
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// ../../node_modules/html-to-image/es/embed-images.js
|
|
949
|
+
async function embedProp(propName, node, options) {
|
|
950
|
+
var _a;
|
|
951
|
+
const propValue = (_a = node.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue(propName);
|
|
952
|
+
if (propValue) {
|
|
953
|
+
const cssString = await embedResources(propValue, null, options);
|
|
954
|
+
node.style.setProperty(propName, cssString, node.style.getPropertyPriority(propName));
|
|
955
|
+
return true;
|
|
956
|
+
}
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
async function embedBackground(clonedNode, options) {
|
|
960
|
+
if (!await embedProp("background", clonedNode, options)) {
|
|
961
|
+
await embedProp("background-image", clonedNode, options);
|
|
962
|
+
}
|
|
963
|
+
if (!await embedProp("mask", clonedNode, options)) {
|
|
964
|
+
await embedProp("mask-image", clonedNode, options);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
async function embedImageNode(clonedNode, options) {
|
|
968
|
+
const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
|
|
969
|
+
if (!(isImageElement && !isDataUrl(clonedNode.src)) && !(isInstanceOfElement(clonedNode, SVGImageElement) && !isDataUrl(clonedNode.href.baseVal))) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const url = isImageElement ? clonedNode.src : clonedNode.href.baseVal;
|
|
973
|
+
const dataURL = await resourceToDataURL(url, getMimeType(url), options);
|
|
974
|
+
await new Promise((resolve, reject) => {
|
|
975
|
+
clonedNode.onload = resolve;
|
|
976
|
+
clonedNode.onerror = reject;
|
|
977
|
+
const image = clonedNode;
|
|
978
|
+
if (image.decode) {
|
|
979
|
+
image.decode = resolve;
|
|
980
|
+
}
|
|
981
|
+
if (image.loading === "lazy") {
|
|
982
|
+
image.loading = "eager";
|
|
983
|
+
}
|
|
984
|
+
if (isImageElement) {
|
|
985
|
+
clonedNode.srcset = "";
|
|
986
|
+
clonedNode.src = dataURL;
|
|
987
|
+
} else {
|
|
988
|
+
clonedNode.href.baseVal = dataURL;
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
async function embedChildren(clonedNode, options) {
|
|
993
|
+
const children = toArray(clonedNode.childNodes);
|
|
994
|
+
const deferreds = children.map((child) => embedImages(child, options));
|
|
995
|
+
await Promise.all(deferreds).then(() => clonedNode);
|
|
996
|
+
}
|
|
997
|
+
async function embedImages(clonedNode, options) {
|
|
998
|
+
if (isInstanceOfElement(clonedNode, Element)) {
|
|
999
|
+
await embedBackground(clonedNode, options);
|
|
1000
|
+
await embedImageNode(clonedNode, options);
|
|
1001
|
+
await embedChildren(clonedNode, options);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// ../../node_modules/html-to-image/es/apply-style.js
|
|
1006
|
+
function applyStyle(node, options) {
|
|
1007
|
+
const { style } = node;
|
|
1008
|
+
if (options.backgroundColor) {
|
|
1009
|
+
style.backgroundColor = options.backgroundColor;
|
|
1010
|
+
}
|
|
1011
|
+
if (options.width) {
|
|
1012
|
+
style.width = `${options.width}px`;
|
|
1013
|
+
}
|
|
1014
|
+
if (options.height) {
|
|
1015
|
+
style.height = `${options.height}px`;
|
|
1016
|
+
}
|
|
1017
|
+
const manual = options.style;
|
|
1018
|
+
if (manual != null) {
|
|
1019
|
+
Object.keys(manual).forEach((key) => {
|
|
1020
|
+
style[key] = manual[key];
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
return node;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// ../../node_modules/html-to-image/es/embed-webfonts.js
|
|
1027
|
+
var cssFetchCache = {};
|
|
1028
|
+
async function fetchCSS(url) {
|
|
1029
|
+
let cache2 = cssFetchCache[url];
|
|
1030
|
+
if (cache2 != null) {
|
|
1031
|
+
return cache2;
|
|
1032
|
+
}
|
|
1033
|
+
const res = await fetch(url);
|
|
1034
|
+
const cssText = await res.text();
|
|
1035
|
+
cache2 = { url, cssText };
|
|
1036
|
+
cssFetchCache[url] = cache2;
|
|
1037
|
+
return cache2;
|
|
1038
|
+
}
|
|
1039
|
+
async function embedFonts(data, options) {
|
|
1040
|
+
let cssText = data.cssText;
|
|
1041
|
+
const regexUrl = /url\(["']?([^"')]+)["']?\)/g;
|
|
1042
|
+
const fontLocs = cssText.match(/url\([^)]+\)/g) || [];
|
|
1043
|
+
const loadFonts = fontLocs.map(async (loc) => {
|
|
1044
|
+
let url = loc.replace(regexUrl, "$1");
|
|
1045
|
+
if (!url.startsWith("https://")) {
|
|
1046
|
+
url = new URL(url, data.url).href;
|
|
1047
|
+
}
|
|
1048
|
+
return fetchAsDataURL(url, options.fetchRequestInit, ({ result }) => {
|
|
1049
|
+
cssText = cssText.replace(loc, `url(${result})`);
|
|
1050
|
+
return [loc, result];
|
|
1051
|
+
});
|
|
1052
|
+
});
|
|
1053
|
+
return Promise.all(loadFonts).then(() => cssText);
|
|
1054
|
+
}
|
|
1055
|
+
function parseCSS(source) {
|
|
1056
|
+
if (source == null) {
|
|
1057
|
+
return [];
|
|
1058
|
+
}
|
|
1059
|
+
const result = [];
|
|
1060
|
+
const commentsRegex = /(\/\*[\s\S]*?\*\/)/gi;
|
|
1061
|
+
let cssText = source.replace(commentsRegex, "");
|
|
1062
|
+
const keyframesRegex = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
|
|
1063
|
+
while (true) {
|
|
1064
|
+
const matches = keyframesRegex.exec(cssText);
|
|
1065
|
+
if (matches === null) {
|
|
1066
|
+
break;
|
|
1067
|
+
}
|
|
1068
|
+
result.push(matches[0]);
|
|
1069
|
+
}
|
|
1070
|
+
cssText = cssText.replace(keyframesRegex, "");
|
|
1071
|
+
const importRegex = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
|
|
1072
|
+
const combinedCSSRegex = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})";
|
|
1073
|
+
const unifiedRegex = new RegExp(combinedCSSRegex, "gi");
|
|
1074
|
+
while (true) {
|
|
1075
|
+
let matches = importRegex.exec(cssText);
|
|
1076
|
+
if (matches === null) {
|
|
1077
|
+
matches = unifiedRegex.exec(cssText);
|
|
1078
|
+
if (matches === null) {
|
|
1079
|
+
break;
|
|
1080
|
+
} else {
|
|
1081
|
+
importRegex.lastIndex = unifiedRegex.lastIndex;
|
|
1082
|
+
}
|
|
1083
|
+
} else {
|
|
1084
|
+
unifiedRegex.lastIndex = importRegex.lastIndex;
|
|
1085
|
+
}
|
|
1086
|
+
result.push(matches[0]);
|
|
1087
|
+
}
|
|
1088
|
+
return result;
|
|
1089
|
+
}
|
|
1090
|
+
async function getCSSRules(styleSheets, options) {
|
|
1091
|
+
const ret = [];
|
|
1092
|
+
const deferreds = [];
|
|
1093
|
+
styleSheets.forEach((sheet) => {
|
|
1094
|
+
if ("cssRules" in sheet) {
|
|
1095
|
+
try {
|
|
1096
|
+
toArray(sheet.cssRules || []).forEach((item, index) => {
|
|
1097
|
+
if (item.type === CSSRule.IMPORT_RULE) {
|
|
1098
|
+
let importIndex = index + 1;
|
|
1099
|
+
const url = item.href;
|
|
1100
|
+
const deferred = fetchCSS(url).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
|
|
1101
|
+
try {
|
|
1102
|
+
sheet.insertRule(rule, rule.startsWith("@import") ? importIndex += 1 : sheet.cssRules.length);
|
|
1103
|
+
} catch (error2) {
|
|
1104
|
+
console.error("Error inserting rule from remote css", {
|
|
1105
|
+
rule,
|
|
1106
|
+
error: error2
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
})).catch((e) => {
|
|
1110
|
+
console.error("Error loading remote css", e.toString());
|
|
1111
|
+
});
|
|
1112
|
+
deferreds.push(deferred);
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
} catch (e) {
|
|
1116
|
+
const inline = styleSheets.find((a) => a.href == null) || document.styleSheets[0];
|
|
1117
|
+
if (sheet.href != null) {
|
|
1118
|
+
deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
|
|
1119
|
+
inline.insertRule(rule, sheet.cssRules.length);
|
|
1120
|
+
})).catch((err) => {
|
|
1121
|
+
console.error("Error loading remote stylesheet", err);
|
|
1122
|
+
}));
|
|
1123
|
+
}
|
|
1124
|
+
console.error("Error inlining remote css file", e);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
return Promise.all(deferreds).then(() => {
|
|
1129
|
+
styleSheets.forEach((sheet) => {
|
|
1130
|
+
if ("cssRules" in sheet) {
|
|
1131
|
+
try {
|
|
1132
|
+
toArray(sheet.cssRules || []).forEach((item) => {
|
|
1133
|
+
ret.push(item);
|
|
1134
|
+
});
|
|
1135
|
+
} catch (e) {
|
|
1136
|
+
console.error(`Error while reading CSS rules from ${sheet.href}`, e);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
return ret;
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
function getWebFontRules(cssRules) {
|
|
1144
|
+
return cssRules.filter((rule) => rule.type === CSSRule.FONT_FACE_RULE).filter((rule) => shouldEmbed(rule.style.getPropertyValue("src")));
|
|
1145
|
+
}
|
|
1146
|
+
async function parseWebFontRules(node, options) {
|
|
1147
|
+
if (node.ownerDocument == null) {
|
|
1148
|
+
throw new Error("Provided element is not within a Document");
|
|
1149
|
+
}
|
|
1150
|
+
const styleSheets = toArray(node.ownerDocument.styleSheets);
|
|
1151
|
+
const cssRules = await getCSSRules(styleSheets, options);
|
|
1152
|
+
return getWebFontRules(cssRules);
|
|
1153
|
+
}
|
|
1154
|
+
async function getWebFontCSS(node, options) {
|
|
1155
|
+
const rules = await parseWebFontRules(node, options);
|
|
1156
|
+
const cssTexts = await Promise.all(rules.map((rule) => {
|
|
1157
|
+
const baseUrl = rule.parentStyleSheet ? rule.parentStyleSheet.href : null;
|
|
1158
|
+
return embedResources(rule.cssText, baseUrl, options);
|
|
1159
|
+
}));
|
|
1160
|
+
return cssTexts.join("\n");
|
|
1161
|
+
}
|
|
1162
|
+
async function embedWebFonts(clonedNode, options) {
|
|
1163
|
+
const cssText = options.fontEmbedCSS != null ? options.fontEmbedCSS : options.skipFonts ? null : await getWebFontCSS(clonedNode, options);
|
|
1164
|
+
if (cssText) {
|
|
1165
|
+
const styleNode = document.createElement("style");
|
|
1166
|
+
const sytleContent = document.createTextNode(cssText);
|
|
1167
|
+
styleNode.appendChild(sytleContent);
|
|
1168
|
+
if (clonedNode.firstChild) {
|
|
1169
|
+
clonedNode.insertBefore(styleNode, clonedNode.firstChild);
|
|
1170
|
+
} else {
|
|
1171
|
+
clonedNode.appendChild(styleNode);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// ../../node_modules/html-to-image/es/index.js
|
|
1177
|
+
async function toSvg(node, options = {}) {
|
|
1178
|
+
const { width, height } = getImageSize(node, options);
|
|
1179
|
+
const clonedNode = await cloneNode(node, options, true);
|
|
1180
|
+
await embedWebFonts(clonedNode, options);
|
|
1181
|
+
await embedImages(clonedNode, options);
|
|
1182
|
+
applyStyle(clonedNode, options);
|
|
1183
|
+
const datauri = await nodeToDataURL(clonedNode, width, height);
|
|
1184
|
+
return datauri;
|
|
1185
|
+
}
|
|
1186
|
+
async function toCanvas(node, options = {}) {
|
|
1187
|
+
const { width, height } = getImageSize(node, options);
|
|
1188
|
+
const svg = await toSvg(node, options);
|
|
1189
|
+
const img = await createImage(svg);
|
|
1190
|
+
const canvas = document.createElement("canvas");
|
|
1191
|
+
const context = canvas.getContext("2d");
|
|
1192
|
+
const ratio = options.pixelRatio || getPixelRatio();
|
|
1193
|
+
const canvasWidth = options.canvasWidth || width;
|
|
1194
|
+
const canvasHeight = options.canvasHeight || height;
|
|
1195
|
+
canvas.width = canvasWidth * ratio;
|
|
1196
|
+
canvas.height = canvasHeight * ratio;
|
|
1197
|
+
if (!options.skipAutoScale) {
|
|
1198
|
+
checkCanvasDimensions(canvas);
|
|
1199
|
+
}
|
|
1200
|
+
canvas.style.width = `${canvasWidth}`;
|
|
1201
|
+
canvas.style.height = `${canvasHeight}`;
|
|
1202
|
+
if (options.backgroundColor) {
|
|
1203
|
+
context.fillStyle = options.backgroundColor;
|
|
1204
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
1205
|
+
}
|
|
1206
|
+
context.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
1207
|
+
return canvas;
|
|
1208
|
+
}
|
|
1209
|
+
async function toPng(node, options = {}) {
|
|
1210
|
+
const canvas = await toCanvas(node, options);
|
|
1211
|
+
return canvas.toDataURL();
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// src/layout-management/screenshot-utils.ts
|
|
1215
|
+
var takeScreenshot = (node) => {
|
|
1216
|
+
return new Promise((resolve, reject) => {
|
|
1217
|
+
toPng(node, {
|
|
1218
|
+
cacheBust: true
|
|
1219
|
+
}).then((screenshot) => {
|
|
1220
|
+
if (!screenshot) {
|
|
1221
|
+
reject(new Error("No Screenshot available"));
|
|
1222
|
+
}
|
|
1223
|
+
resolve(screenshot);
|
|
1224
|
+
}).catch((error2) => {
|
|
1225
|
+
console.error(
|
|
1226
|
+
"the following error occurred while taking a screenshot of a DOMNode",
|
|
1227
|
+
error2
|
|
1228
|
+
);
|
|
1229
|
+
reject(new Error("Error taking screenshot"));
|
|
1230
|
+
});
|
|
1231
|
+
});
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
// src/layout-management/SaveLayoutPanel.tsx
|
|
1235
|
+
import { Button as Button3, FormField as FormField2, FormFieldLabel as FormFieldLabel2, Input, Text } from "@salt-ds/core";
|
|
1236
|
+
import { useEffect as useEffect4, useMemo as useMemo2, useState as useState3 } from "react";
|
|
1237
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1238
|
+
var classBase3 = "saveLayoutPanel";
|
|
1239
|
+
var formField = `${classBase3}-formField`;
|
|
1240
|
+
var groups = ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5"];
|
|
1241
|
+
var checkboxValues = ["Value 1", "Value 2", "Value 3"];
|
|
1242
|
+
var radioValues = ["Value 1", "Value 2", "Value 3"];
|
|
1243
|
+
var SaveLayoutPanel = (props) => {
|
|
1244
|
+
const { defaultTitle = "", onCancel, onSave, componentId } = props;
|
|
1245
|
+
const [layoutName, setLayoutName] = useState3(defaultTitle);
|
|
1246
|
+
const [group, setGroup] = useState3("");
|
|
1247
|
+
const [checkValues, setCheckValues] = useState3([]);
|
|
1248
|
+
const [radioValue, setRadioValue] = useState3(radioValues[0]);
|
|
1249
|
+
const [screenshot, setScreenshot] = useState3();
|
|
1250
|
+
const [screenshotErrorMessage, setScreenshotErrorMessage] = useState3();
|
|
1251
|
+
const [username] = getAuthDetailsFromCookies();
|
|
1252
|
+
useEffect4(() => {
|
|
1253
|
+
if (componentId) {
|
|
1254
|
+
takeScreenshot(document.getElementById(componentId)).then((screenshot2) => {
|
|
1255
|
+
setScreenshot(screenshot2);
|
|
1256
|
+
}).catch((error2) => {
|
|
1257
|
+
setScreenshotErrorMessage(error2.message);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
}, [componentId]);
|
|
1261
|
+
const handleSubmit = () => {
|
|
1262
|
+
onSave({
|
|
1263
|
+
name: layoutName,
|
|
1264
|
+
group,
|
|
1265
|
+
screenshot: screenshot != null ? screenshot : "",
|
|
1266
|
+
user: username
|
|
1267
|
+
});
|
|
1268
|
+
};
|
|
1269
|
+
const screenshotContent = useMemo2(() => {
|
|
1270
|
+
if (screenshot) {
|
|
1271
|
+
return /* @__PURE__ */ jsx8(
|
|
1272
|
+
"img",
|
|
1273
|
+
{
|
|
1274
|
+
className: `${classBase3}-screenshot`,
|
|
1275
|
+
src: screenshot,
|
|
1276
|
+
alt: "screenshot of current layout"
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
if (screenshotErrorMessage) {
|
|
1281
|
+
return /* @__PURE__ */ jsx8(Text, { children: screenshotErrorMessage });
|
|
1282
|
+
}
|
|
1283
|
+
return /* @__PURE__ */ jsx8("div", { className: "spinner" });
|
|
1284
|
+
}, [screenshot, screenshotErrorMessage]);
|
|
1285
|
+
return /* @__PURE__ */ jsxs6("div", { className: `${classBase3}-panelContainer`, children: [
|
|
1286
|
+
/* @__PURE__ */ jsxs6("div", { className: `${classBase3}-panelContent`, children: [
|
|
1287
|
+
/* @__PURE__ */ jsxs6("div", { className: `${classBase3}-formContainer`, children: [
|
|
1288
|
+
/* @__PURE__ */ jsxs6(FormField2, { className: formField, children: [
|
|
1289
|
+
/* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Group" }),
|
|
1290
|
+
/* @__PURE__ */ jsx8(
|
|
1291
|
+
ComboBox,
|
|
1292
|
+
{
|
|
1293
|
+
source: groups,
|
|
1294
|
+
allowFreeText: true,
|
|
1295
|
+
InputProps: {
|
|
1296
|
+
inputProps: {
|
|
1297
|
+
className: `${classBase3}-inputText`,
|
|
1298
|
+
placeholder: "Select Group or Enter New Name",
|
|
1299
|
+
onChange: (event) => setGroup(event.target.value)
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
width: "100%",
|
|
1303
|
+
onSelectionChange: (_, value) => setGroup(value || "")
|
|
1304
|
+
}
|
|
1305
|
+
)
|
|
1306
|
+
] }),
|
|
1307
|
+
/* @__PURE__ */ jsxs6(FormField2, { className: formField, children: [
|
|
1308
|
+
/* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Layout Name" }),
|
|
1309
|
+
/* @__PURE__ */ jsx8(
|
|
1310
|
+
Input,
|
|
1311
|
+
{
|
|
1312
|
+
inputProps: {
|
|
1313
|
+
className: `${classBase3}-inputText`,
|
|
1314
|
+
placeholder: "Enter Layout Name"
|
|
1315
|
+
},
|
|
1316
|
+
onChange: (event) => setLayoutName(event.target.value),
|
|
1317
|
+
value: layoutName
|
|
1318
|
+
}
|
|
1319
|
+
)
|
|
1320
|
+
] }),
|
|
1321
|
+
/* @__PURE__ */ jsxs6(FormField2, { className: formField, children: [
|
|
1322
|
+
/* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Some Layout Setting" }),
|
|
1323
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-settingsGroup`, children: checkboxValues.map((value, i) => /* @__PURE__ */ jsx8(
|
|
1324
|
+
Checkbox,
|
|
1325
|
+
{
|
|
1326
|
+
onToggle: () => setCheckValues(
|
|
1327
|
+
(prev) => prev.includes(value) ? prev.filter((entry) => entry !== value) : [...prev, value]
|
|
1328
|
+
),
|
|
1329
|
+
checked: checkValues.includes(value),
|
|
1330
|
+
label: value
|
|
1331
|
+
},
|
|
1332
|
+
i
|
|
1333
|
+
)) })
|
|
1334
|
+
] }),
|
|
1335
|
+
/* @__PURE__ */ jsxs6(FormField2, { className: formField, children: [
|
|
1336
|
+
/* @__PURE__ */ jsx8(FormFieldLabel2, { children: "Some Layout Setting" }),
|
|
1337
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-settingsGroup`, children: radioValues.map((value, i) => /* @__PURE__ */ jsx8(
|
|
1338
|
+
RadioButton,
|
|
1339
|
+
{
|
|
1340
|
+
onClick: () => setRadioValue(value),
|
|
1341
|
+
checked: radioValue === value,
|
|
1342
|
+
label: value,
|
|
1343
|
+
groupName: "radioGroup"
|
|
1344
|
+
},
|
|
1345
|
+
i
|
|
1346
|
+
)) })
|
|
1347
|
+
] })
|
|
1348
|
+
] }),
|
|
1349
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-screenshotContainer`, children: screenshotContent })
|
|
1350
|
+
] }),
|
|
1351
|
+
/* @__PURE__ */ jsxs6("div", { className: `${classBase3}-buttonsContainer`, children: [
|
|
1352
|
+
/* @__PURE__ */ jsx8(Button3, { className: `${classBase3}-cancelButton`, onClick: onCancel, children: "Cancel" }),
|
|
1353
|
+
/* @__PURE__ */ jsx8(
|
|
1354
|
+
Button3,
|
|
1355
|
+
{
|
|
1356
|
+
className: `${classBase3}-saveButton`,
|
|
1357
|
+
onClick: handleSubmit,
|
|
1358
|
+
disabled: layoutName === "" || group === "",
|
|
1359
|
+
children: "Save"
|
|
1360
|
+
}
|
|
1361
|
+
)
|
|
1362
|
+
] })
|
|
1363
|
+
] });
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
// src/layout-management/LayoutList.tsx
|
|
1367
|
+
import { List } from "@vuu-ui/vuu-ui-controls";
|
|
1368
|
+
|
|
1369
|
+
// src/layout-management/useLayoutManager.tsx
|
|
1370
|
+
import React5, {
|
|
1371
|
+
useCallback as useCallback9,
|
|
1372
|
+
useContext as useContext2,
|
|
1373
|
+
useEffect as useEffect6,
|
|
1374
|
+
useRef as useRef4,
|
|
1375
|
+
useState as useState7
|
|
1376
|
+
} from "react";
|
|
1377
|
+
import {
|
|
1378
|
+
resolveJSONPath
|
|
1379
|
+
} from "@vuu-ui/vuu-layout";
|
|
1380
|
+
|
|
1381
|
+
// ../vuu-popups/src/dialog/Dialog.tsx
|
|
1382
|
+
import cx5 from "clsx";
|
|
1383
|
+
import { useThemeAttributes } from "@vuu-ui/vuu-utils";
|
|
1384
|
+
import { useCallback as useCallback4, useLayoutEffect as useLayoutEffect2, useRef as useRef3 } from "react";
|
|
1385
|
+
|
|
1386
|
+
// ../vuu-popups/src/dialog-header/DialogHeader.tsx
|
|
1387
|
+
import { Button as Button4, Text as Text2 } from "@salt-ds/core";
|
|
1388
|
+
import cx4 from "clsx";
|
|
1389
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1390
|
+
var classBase4 = "vuuDialogHeader";
|
|
1391
|
+
var DialogHeader = ({
|
|
1392
|
+
hideCloseButton = false,
|
|
1393
|
+
title,
|
|
1394
|
+
onClose,
|
|
1395
|
+
...htmlAttributes
|
|
1396
|
+
}) => {
|
|
1397
|
+
return /* @__PURE__ */ jsxs7("div", { ...htmlAttributes, className: cx4(classBase4, "vuuToolbarProxy"), children: [
|
|
1398
|
+
/* @__PURE__ */ jsx9(Text2, { className: "dialogHeader", children: title }),
|
|
1399
|
+
!hideCloseButton && /* @__PURE__ */ jsx9(
|
|
1400
|
+
Button4,
|
|
1401
|
+
{
|
|
1402
|
+
onClick: onClose,
|
|
1403
|
+
"data-align": "end",
|
|
1404
|
+
"data-icon": "close",
|
|
1405
|
+
variant: "secondary"
|
|
1406
|
+
},
|
|
1407
|
+
"close"
|
|
1408
|
+
)
|
|
1409
|
+
] });
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
// ../vuu-popups/src/popup/useAnchoredPosition.ts
|
|
1413
|
+
import { useCallback as useCallback3, useLayoutEffect, useRef as useRef2, useState as useState4 } from "react";
|
|
1414
|
+
var getPositionRelativeToAnchor = (anchorElement, placement, offsetLeft, offsetTop, minWidth, dimensions) => {
|
|
1415
|
+
const { bottom, height, left, right, top, width } = anchorElement.getBoundingClientRect();
|
|
1416
|
+
switch (placement) {
|
|
1417
|
+
case "below":
|
|
1418
|
+
return { left: left + offsetLeft, top: bottom + offsetTop };
|
|
1419
|
+
case "right":
|
|
1420
|
+
return { left: right + offsetLeft, top: top + offsetTop };
|
|
1421
|
+
case "below-center":
|
|
1422
|
+
return { left: left + width / 2 + offsetLeft, top: bottom + offsetTop };
|
|
1423
|
+
case "below-right":
|
|
1424
|
+
return { left, minWidth, top: bottom + offsetTop };
|
|
1425
|
+
case "below-full-width":
|
|
1426
|
+
return {
|
|
1427
|
+
left: left + offsetLeft,
|
|
1428
|
+
minWidth,
|
|
1429
|
+
top: bottom + offsetTop,
|
|
1430
|
+
width
|
|
1431
|
+
};
|
|
1432
|
+
case "center":
|
|
1433
|
+
if (dimensions) {
|
|
1434
|
+
return {
|
|
1435
|
+
left: width / 2 - dimensions.width / 2 + offsetLeft,
|
|
1436
|
+
top: height / 2 - dimensions.height / 2 + offsetTop,
|
|
1437
|
+
visibility: "visible"
|
|
1438
|
+
};
|
|
1439
|
+
} else {
|
|
1440
|
+
return {
|
|
1441
|
+
left: width / 2 + offsetLeft,
|
|
1442
|
+
top: height / 2 + offsetTop,
|
|
1443
|
+
visibility: "hidden"
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
default:
|
|
1447
|
+
throw Error(
|
|
1448
|
+
"Popup getPositionRelativeToAnchor only supported placement values are below and right"
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
var useAnchoredPosition = ({
|
|
1453
|
+
anchorElement,
|
|
1454
|
+
minWidth,
|
|
1455
|
+
offsetLeft = 0,
|
|
1456
|
+
offsetTop = 0,
|
|
1457
|
+
placement,
|
|
1458
|
+
position: positionProp
|
|
1459
|
+
}) => {
|
|
1460
|
+
const popupRef = useRef2(null);
|
|
1461
|
+
const [position, setPosition] = useState4(positionProp);
|
|
1462
|
+
useLayoutEffect(() => {
|
|
1463
|
+
if (placement === "absolute" && positionProp) {
|
|
1464
|
+
setPosition(positionProp);
|
|
1465
|
+
} else if (anchorElement.current && placement !== "auto") {
|
|
1466
|
+
const dimensions = popupRef.current === null ? void 0 : popupRef.current.getBoundingClientRect();
|
|
1467
|
+
const position2 = getPositionRelativeToAnchor(
|
|
1468
|
+
anchorElement.current,
|
|
1469
|
+
placement,
|
|
1470
|
+
offsetLeft,
|
|
1471
|
+
offsetTop,
|
|
1472
|
+
minWidth,
|
|
1473
|
+
dimensions
|
|
1474
|
+
);
|
|
1475
|
+
setPosition(position2);
|
|
1476
|
+
}
|
|
1477
|
+
}, [anchorElement, minWidth, offsetLeft, offsetTop, placement, positionProp]);
|
|
1478
|
+
const popupCallbackRef = useCallback3(
|
|
1479
|
+
(el) => {
|
|
1480
|
+
popupRef.current = el;
|
|
1481
|
+
if (el && placement === "center" && anchorElement.current) {
|
|
1482
|
+
const { height, width } = el.getBoundingClientRect();
|
|
1483
|
+
setPosition(
|
|
1484
|
+
getPositionRelativeToAnchor(
|
|
1485
|
+
anchorElement.current,
|
|
1486
|
+
placement,
|
|
1487
|
+
offsetLeft,
|
|
1488
|
+
offsetTop,
|
|
1489
|
+
void 0,
|
|
1490
|
+
{ height, width }
|
|
1491
|
+
)
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
},
|
|
1495
|
+
[anchorElement, offsetLeft, offsetTop, placement]
|
|
1496
|
+
);
|
|
1497
|
+
return {
|
|
1498
|
+
position,
|
|
1499
|
+
popupRef: placement === "center" ? popupCallbackRef : void 0
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
// ../vuu-popups/src/dialog/Dialog.tsx
|
|
1504
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1505
|
+
var classBase5 = "vuuDialog";
|
|
1506
|
+
var AnchorBody = { current: document.body };
|
|
1507
|
+
var EMPTY_PROPS = {};
|
|
1508
|
+
var Dialog = ({
|
|
1509
|
+
PopupProps = EMPTY_PROPS,
|
|
1510
|
+
children,
|
|
1511
|
+
className,
|
|
1512
|
+
isOpen = false,
|
|
1513
|
+
onClose,
|
|
1514
|
+
style,
|
|
1515
|
+
title,
|
|
1516
|
+
hideCloseButton = false,
|
|
1517
|
+
...htmlAttributes
|
|
1518
|
+
}) => {
|
|
1519
|
+
const {
|
|
1520
|
+
anchorElement = AnchorBody,
|
|
1521
|
+
offsetLeft = 0,
|
|
1522
|
+
offsetTop = 0,
|
|
1523
|
+
placement = "auto"
|
|
1524
|
+
} = PopupProps;
|
|
1525
|
+
const rootRef = useRef3(null);
|
|
1526
|
+
const portalRef = useRef3(null);
|
|
1527
|
+
const [themeClass, densityClass, dataMode] = useThemeAttributes();
|
|
1528
|
+
const { position } = useAnchoredPosition({
|
|
1529
|
+
anchorElement,
|
|
1530
|
+
offsetLeft,
|
|
1531
|
+
offsetTop,
|
|
1532
|
+
placement
|
|
1533
|
+
});
|
|
1534
|
+
const close = useCallback4(() => {
|
|
1535
|
+
onClose == null ? void 0 : onClose();
|
|
1536
|
+
}, [onClose]);
|
|
1537
|
+
useLayoutEffect2(() => {
|
|
1538
|
+
if (rootRef.current) {
|
|
1539
|
+
if (isOpen) {
|
|
1540
|
+
rootRef.current.showModal();
|
|
1541
|
+
const { left, top } = rootRef.current.getBoundingClientRect();
|
|
1542
|
+
if (portalRef.current) {
|
|
1543
|
+
portalRef.current.style.cssText = `left:-${left}px;position:absolute;top:-${top}px;`;
|
|
1544
|
+
}
|
|
1545
|
+
} else {
|
|
1546
|
+
rootRef.current.close();
|
|
1547
|
+
}
|
|
1548
|
+
if (placement.endsWith("center")) {
|
|
1549
|
+
const { width } = rootRef.current.getBoundingClientRect();
|
|
1550
|
+
rootRef.current.style.marginLeft = `-${width / 2}px`;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}, [isOpen, placement]);
|
|
1554
|
+
return /* @__PURE__ */ jsxs8(
|
|
1555
|
+
"dialog",
|
|
1556
|
+
{
|
|
1557
|
+
...htmlAttributes,
|
|
1558
|
+
className: cx5(classBase5, themeClass),
|
|
1559
|
+
"data-mode": dataMode,
|
|
1560
|
+
onClose: close,
|
|
1561
|
+
id: "vuu-dialog",
|
|
1562
|
+
ref: rootRef,
|
|
1563
|
+
style: { ...style, ...position },
|
|
1564
|
+
children: [
|
|
1565
|
+
/* @__PURE__ */ jsx10(
|
|
1566
|
+
DialogHeader,
|
|
1567
|
+
{
|
|
1568
|
+
hideCloseButton,
|
|
1569
|
+
onClose: close,
|
|
1570
|
+
title
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
1573
|
+
/* @__PURE__ */ jsx10("div", { className: `${classBase5}-body`, children }),
|
|
1574
|
+
/* @__PURE__ */ jsx10("div", { id: "vuu-dialog-portal-root", ref: portalRef })
|
|
1575
|
+
]
|
|
1576
|
+
}
|
|
1577
|
+
);
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
// ../vuu-popups/src/dialog/useDialog.tsx
|
|
1581
|
+
import { useCallback as useCallback5, useState as useState5 } from "react";
|
|
1582
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1583
|
+
var useDialog = () => {
|
|
1584
|
+
const [dialogState, setDialogState] = useState5();
|
|
1585
|
+
const handleClose = useCallback5(() => {
|
|
1586
|
+
setDialogState(void 0);
|
|
1587
|
+
}, []);
|
|
1588
|
+
const dialog = dialogState ? /* @__PURE__ */ jsx11(
|
|
1589
|
+
Dialog,
|
|
1590
|
+
{
|
|
1591
|
+
className: "vuDialog",
|
|
1592
|
+
isOpen: true,
|
|
1593
|
+
onClose: handleClose,
|
|
1594
|
+
style: { maxHeight: 500 },
|
|
1595
|
+
title: dialogState.title,
|
|
1596
|
+
hideCloseButton: dialogState.hideCloseButton,
|
|
1597
|
+
children: dialogState.content
|
|
1598
|
+
}
|
|
1599
|
+
) : null;
|
|
1600
|
+
return {
|
|
1601
|
+
dialog,
|
|
1602
|
+
setDialogState
|
|
1603
|
+
};
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
// ../vuu-popups/src/menu/context-menu-provider.tsx
|
|
1607
|
+
import { createContext, useCallback as useCallback6, useMemo as useMemo3 } from "react";
|
|
1608
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1609
|
+
var ContextMenuContext = createContext(
|
|
1610
|
+
null
|
|
1611
|
+
);
|
|
1612
|
+
var Provider = ({
|
|
1613
|
+
children,
|
|
1614
|
+
context,
|
|
1615
|
+
menuActionHandler,
|
|
1616
|
+
menuBuilder
|
|
1617
|
+
}) => {
|
|
1618
|
+
const menuBuilders = useMemo3(() => {
|
|
1619
|
+
if ((context == null ? void 0 : context.menuBuilders) && menuBuilder) {
|
|
1620
|
+
return context.menuBuilders.concat(menuBuilder);
|
|
1621
|
+
} else if (menuBuilder) {
|
|
1622
|
+
return [menuBuilder];
|
|
1623
|
+
} else {
|
|
1624
|
+
return (context == null ? void 0 : context.menuBuilders) || [];
|
|
1625
|
+
}
|
|
1626
|
+
}, [context, menuBuilder]);
|
|
1627
|
+
const handleMenuAction = useCallback6(
|
|
1628
|
+
(reason) => {
|
|
1629
|
+
var _a;
|
|
1630
|
+
if (menuActionHandler == null ? void 0 : menuActionHandler(reason)) {
|
|
1631
|
+
return true;
|
|
1632
|
+
}
|
|
1633
|
+
if ((_a = context == null ? void 0 : context.menuActionHandler) == null ? void 0 : _a.call(context, reason)) {
|
|
1634
|
+
return true;
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
[context, menuActionHandler]
|
|
1638
|
+
);
|
|
1639
|
+
return /* @__PURE__ */ jsx12(
|
|
1640
|
+
ContextMenuContext.Provider,
|
|
1641
|
+
{
|
|
1642
|
+
value: {
|
|
1643
|
+
menuActionHandler: handleMenuAction,
|
|
1644
|
+
menuBuilders
|
|
1645
|
+
},
|
|
1646
|
+
children
|
|
1647
|
+
}
|
|
1648
|
+
);
|
|
1649
|
+
};
|
|
1650
|
+
var ContextMenuProvider = ({
|
|
1651
|
+
children,
|
|
1652
|
+
label,
|
|
1653
|
+
menuActionHandler,
|
|
1654
|
+
menuBuilder
|
|
1655
|
+
}) => {
|
|
1656
|
+
return /* @__PURE__ */ jsx12(ContextMenuContext.Consumer, { children: (parentContext) => /* @__PURE__ */ jsx12(
|
|
1657
|
+
Provider,
|
|
1658
|
+
{
|
|
1659
|
+
context: parentContext,
|
|
1660
|
+
label,
|
|
1661
|
+
menuActionHandler,
|
|
1662
|
+
menuBuilder,
|
|
1663
|
+
children
|
|
1664
|
+
}
|
|
1665
|
+
) });
|
|
1666
|
+
};
|
|
1667
|
+
|
|
1668
|
+
// ../vuu-popups/src/notifications/NotificationsProvider.tsx
|
|
1669
|
+
import React4, { useState as useState6, useContext, useCallback as useCallback7, useEffect as useEffect5 } from "react";
|
|
1670
|
+
import classNames from "clsx";
|
|
1671
|
+
import { getUniqueId } from "@vuu-ui/vuu-utils";
|
|
1672
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1673
|
+
var NotificationsContext = React4.createContext({
|
|
1674
|
+
notify: () => "have you forgotten to provide a NotificationProvider?"
|
|
1675
|
+
});
|
|
1676
|
+
var useNotifications = () => useContext(NotificationsContext);
|
|
1677
|
+
|
|
1678
|
+
// src/persistence-management/defaultApplicationJson.ts
|
|
1679
|
+
var loadingApplicationJson = {
|
|
1680
|
+
layout: {
|
|
1681
|
+
type: "Component",
|
|
1682
|
+
id: "loading-main",
|
|
1683
|
+
props: {}
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
var defaultApplicationJson = {
|
|
1687
|
+
layout: {
|
|
1688
|
+
type: "Stack",
|
|
1689
|
+
id: "main-tabs",
|
|
1690
|
+
props: {
|
|
1691
|
+
className: "vuuShell-mainTabs",
|
|
1692
|
+
TabstripProps: {
|
|
1693
|
+
allowAddTab: true,
|
|
1694
|
+
allowCloseTab: true,
|
|
1695
|
+
allowRenameTab: true,
|
|
1696
|
+
animateSelectionThumb: false,
|
|
1697
|
+
location: "main-tab",
|
|
1698
|
+
tabClassName: "MainTab"
|
|
1699
|
+
},
|
|
1700
|
+
preserve: true,
|
|
1701
|
+
active: 0
|
|
1702
|
+
},
|
|
1703
|
+
children: [
|
|
1704
|
+
{
|
|
1705
|
+
props: {
|
|
1706
|
+
id: "tab1",
|
|
1707
|
+
title: "Tab 1",
|
|
1708
|
+
className: "vuuShell-Placeholder"
|
|
1709
|
+
},
|
|
1710
|
+
type: "Placeholder"
|
|
1711
|
+
}
|
|
1712
|
+
]
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
// src/persistence-management/LocalPersistenceManager.ts
|
|
1717
|
+
import { getLocalEntity, saveLocalEntity } from "@vuu-ui/vuu-filters";
|
|
1718
|
+
import { formatDate, getUniqueId as getUniqueId2 } from "@vuu-ui/vuu-utils";
|
|
1719
|
+
var baseMetadataSaveLocation = "layouts/metadata";
|
|
1720
|
+
var baseLayoutsSaveLocation = "layouts/layouts";
|
|
1721
|
+
var _urlKey;
|
|
1722
|
+
var LocalPersistenceManager = class {
|
|
1723
|
+
constructor(urlKey) {
|
|
1724
|
+
this.username = getAuthDetailsFromCookies()[0];
|
|
1725
|
+
this.metadataSaveLocation = `${baseMetadataSaveLocation}/${this.username}`;
|
|
1726
|
+
this.layoutsSaveLocation = `${baseLayoutsSaveLocation}/${this.username}`;
|
|
1727
|
+
__privateAdd(this, _urlKey, `api/vui/${this.username}`);
|
|
1728
|
+
this.loadLayouts = () => {
|
|
1729
|
+
return new Promise((resolve) => {
|
|
1730
|
+
const layouts = getLocalEntity(this.layoutsSaveLocation);
|
|
1731
|
+
resolve(layouts || []);
|
|
1732
|
+
});
|
|
1733
|
+
};
|
|
1734
|
+
this.saveLayoutsWithMetadata = (layouts, metadata) => {
|
|
1735
|
+
saveLocalEntity(this.layoutsSaveLocation, layouts);
|
|
1736
|
+
saveLocalEntity(this.metadataSaveLocation, metadata);
|
|
1737
|
+
};
|
|
1738
|
+
// Ensures that there is exactly one Layout entry and exactly one Metadata
|
|
1739
|
+
// entry in local storage corresponding to the provided ID.
|
|
1740
|
+
this.validateIds = async (id) => {
|
|
1741
|
+
return Promise.all([
|
|
1742
|
+
this.validateId(id, "metadata").catch((error2) => error2.message),
|
|
1743
|
+
this.validateId(id, "layout").catch((error2) => error2.message)
|
|
1744
|
+
]).then((errorMessages) => {
|
|
1745
|
+
const combinedMessage = errorMessages.filter((msg) => msg !== void 0).join("; ");
|
|
1746
|
+
if (combinedMessage) {
|
|
1747
|
+
throw new Error(combinedMessage);
|
|
1748
|
+
}
|
|
1749
|
+
});
|
|
1750
|
+
};
|
|
1751
|
+
// Ensures that there is exactly one element (Layout or Metadata) in local
|
|
1752
|
+
// storage corresponding to the provided ID.
|
|
1753
|
+
this.validateId = (id, dataType) => {
|
|
1754
|
+
return new Promise((resolve, reject) => {
|
|
1755
|
+
const loadFunc = dataType === "metadata" ? () => this.loadMetadata() : () => this.loadLayouts();
|
|
1756
|
+
loadFunc().then((array) => {
|
|
1757
|
+
const count = array.filter((element) => element.id === id).length;
|
|
1758
|
+
switch (count) {
|
|
1759
|
+
case 1: {
|
|
1760
|
+
resolve();
|
|
1761
|
+
break;
|
|
1762
|
+
}
|
|
1763
|
+
case 0: {
|
|
1764
|
+
reject(new Error(`No ${dataType} with ID ${id}`));
|
|
1765
|
+
break;
|
|
1766
|
+
}
|
|
1767
|
+
default:
|
|
1768
|
+
reject(new Error(`Non-unique ${dataType} with ID ${id}`));
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
});
|
|
1772
|
+
};
|
|
1773
|
+
if (urlKey) {
|
|
1774
|
+
__privateSet(this, _urlKey, urlKey);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
createLayout(metadata, layout) {
|
|
1778
|
+
return new Promise((resolve) => {
|
|
1779
|
+
Promise.all([this.loadLayouts(), this.loadMetadata()]).then(
|
|
1780
|
+
([existingLayouts, existingMetadata]) => {
|
|
1781
|
+
const id = getUniqueId2();
|
|
1782
|
+
const newMetadata = {
|
|
1783
|
+
...metadata,
|
|
1784
|
+
id,
|
|
1785
|
+
created: formatDate({ date: "dd.mm.yyyy" })(/* @__PURE__ */ new Date())
|
|
1786
|
+
};
|
|
1787
|
+
this.saveLayoutsWithMetadata(
|
|
1788
|
+
[...existingLayouts, { id, json: layout }],
|
|
1789
|
+
[...existingMetadata, newMetadata]
|
|
1790
|
+
);
|
|
1791
|
+
resolve(newMetadata);
|
|
1792
|
+
}
|
|
1793
|
+
);
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
updateLayout(id, newMetadata, newLayout) {
|
|
1797
|
+
return new Promise((resolve, reject) => {
|
|
1798
|
+
this.validateIds(id).then(() => Promise.all([this.loadLayouts(), this.loadMetadata()])).then(([existingLayouts, existingMetadata]) => {
|
|
1799
|
+
const updatedLayouts = existingLayouts.map(
|
|
1800
|
+
(layout) => layout.id === id ? { ...layout, json: newLayout } : layout
|
|
1801
|
+
);
|
|
1802
|
+
const updatedMetadata = existingMetadata.map(
|
|
1803
|
+
(metadata) => metadata.id === id ? { ...metadata, ...newMetadata } : metadata
|
|
1804
|
+
);
|
|
1805
|
+
this.saveLayoutsWithMetadata(updatedLayouts, updatedMetadata);
|
|
1806
|
+
resolve();
|
|
1807
|
+
}).catch((e) => reject(e));
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
deleteLayout(id) {
|
|
1811
|
+
return new Promise((resolve, reject) => {
|
|
1812
|
+
this.validateIds(id).then(() => Promise.all([this.loadLayouts(), this.loadMetadata()])).then(([existingLayouts, existingMetadata]) => {
|
|
1813
|
+
const layouts = existingLayouts.filter((layout) => layout.id !== id);
|
|
1814
|
+
const metadata = existingMetadata.filter(
|
|
1815
|
+
(metadata2) => metadata2.id !== id
|
|
1816
|
+
);
|
|
1817
|
+
this.saveLayoutsWithMetadata(layouts, metadata);
|
|
1818
|
+
resolve();
|
|
1819
|
+
}).catch((e) => reject(e));
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
loadLayout(id) {
|
|
1823
|
+
return new Promise((resolve, reject) => {
|
|
1824
|
+
this.validateId(id, "layout").then(() => this.loadLayouts()).then((existingLayouts) => {
|
|
1825
|
+
const foundLayout = existingLayouts.find(
|
|
1826
|
+
(layout) => layout.id === id
|
|
1827
|
+
);
|
|
1828
|
+
if (foundLayout) {
|
|
1829
|
+
resolve(foundLayout.json);
|
|
1830
|
+
} else {
|
|
1831
|
+
reject(new Error(`no layout found matching id ${id}`));
|
|
1832
|
+
}
|
|
1833
|
+
}).catch((e) => reject(e));
|
|
1834
|
+
});
|
|
1835
|
+
}
|
|
1836
|
+
loadMetadata() {
|
|
1837
|
+
return new Promise((resolve) => {
|
|
1838
|
+
const metadata = getLocalEntity(
|
|
1839
|
+
this.metadataSaveLocation
|
|
1840
|
+
);
|
|
1841
|
+
resolve(metadata || []);
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
loadApplicationJSON() {
|
|
1845
|
+
return new Promise((resolve) => {
|
|
1846
|
+
const applicationJSON = getLocalEntity(__privateGet(this, _urlKey));
|
|
1847
|
+
if (applicationJSON) {
|
|
1848
|
+
resolve(applicationJSON);
|
|
1849
|
+
} else {
|
|
1850
|
+
resolve(defaultApplicationJson);
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
saveApplicationJSON(applicationJSON) {
|
|
1855
|
+
return new Promise((resolve, reject) => {
|
|
1856
|
+
const savedLayout = saveLocalEntity(
|
|
1857
|
+
__privateGet(this, _urlKey),
|
|
1858
|
+
applicationJSON
|
|
1859
|
+
);
|
|
1860
|
+
if (savedLayout) {
|
|
1861
|
+
resolve();
|
|
1862
|
+
} else {
|
|
1863
|
+
reject(new Error("Application Json failed to save"));
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
};
|
|
1868
|
+
_urlKey = new WeakMap();
|
|
1869
|
+
|
|
1870
|
+
// src/persistence-management/useLayoutContextMenuItems.tsx
|
|
1871
|
+
import { useCallback as useCallback8, useMemo as useMemo4 } from "react";
|
|
1872
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1873
|
+
var useLayoutContextMenuItems = (setDialogState) => {
|
|
1874
|
+
const { saveLayout } = useLayoutManager();
|
|
1875
|
+
const handleCloseDialog = useCallback8(() => {
|
|
1876
|
+
setDialogState(void 0);
|
|
1877
|
+
}, [setDialogState]);
|
|
1878
|
+
const handleSave = useCallback8(
|
|
1879
|
+
(layoutMetadata) => {
|
|
1880
|
+
saveLayout(layoutMetadata);
|
|
1881
|
+
setDialogState(void 0);
|
|
1882
|
+
},
|
|
1883
|
+
[saveLayout, setDialogState]
|
|
1884
|
+
);
|
|
1885
|
+
const [buildMenuOptions, handleMenuAction] = useMemo4(() => {
|
|
1886
|
+
return [
|
|
1887
|
+
(location, options) => {
|
|
1888
|
+
const locations = location.split(" ");
|
|
1889
|
+
const menuDescriptors = [];
|
|
1890
|
+
if (locations.includes("main-tab")) {
|
|
1891
|
+
menuDescriptors.push(
|
|
1892
|
+
{
|
|
1893
|
+
label: "Save Layout",
|
|
1894
|
+
action: "save-layout",
|
|
1895
|
+
options
|
|
1896
|
+
},
|
|
1897
|
+
{
|
|
1898
|
+
label: "Layout Settings",
|
|
1899
|
+
action: "layout-settings",
|
|
1900
|
+
options
|
|
1901
|
+
}
|
|
1902
|
+
);
|
|
1903
|
+
}
|
|
1904
|
+
return menuDescriptors;
|
|
1905
|
+
},
|
|
1906
|
+
(action) => {
|
|
1907
|
+
var _a, _b;
|
|
1908
|
+
console.log("menu action", {
|
|
1909
|
+
action
|
|
1910
|
+
});
|
|
1911
|
+
if (action.menuId === "save-layout") {
|
|
1912
|
+
setDialogState({
|
|
1913
|
+
content: /* @__PURE__ */ jsx14(
|
|
1914
|
+
SaveLayoutPanel,
|
|
1915
|
+
{
|
|
1916
|
+
onCancel: handleCloseDialog,
|
|
1917
|
+
onSave: handleSave,
|
|
1918
|
+
componentId: (_a = action.options) == null ? void 0 : _a.controlledComponentId,
|
|
1919
|
+
defaultTitle: (_b = action.options) == null ? void 0 : _b.controlledComponentTitle
|
|
1920
|
+
}
|
|
1921
|
+
),
|
|
1922
|
+
title: "Save Layout",
|
|
1923
|
+
hideCloseButton: true
|
|
1924
|
+
});
|
|
1925
|
+
return true;
|
|
1926
|
+
}
|
|
1927
|
+
return false;
|
|
1928
|
+
}
|
|
1929
|
+
];
|
|
1930
|
+
}, [handleCloseDialog, handleSave, setDialogState]);
|
|
1931
|
+
return {
|
|
1932
|
+
buildMenuOptions,
|
|
1933
|
+
handleMenuAction
|
|
1934
|
+
};
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1937
|
+
// src/layout-management/useLayoutManager.tsx
|
|
1938
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1939
|
+
var _persistenceManager;
|
|
1940
|
+
var getPersistenceManager = () => {
|
|
1941
|
+
if (_persistenceManager === void 0) {
|
|
1942
|
+
_persistenceManager = true ? new LocalPersistenceManager() : new RemotePersistenceManager();
|
|
1943
|
+
}
|
|
1944
|
+
return _persistenceManager;
|
|
1945
|
+
};
|
|
1946
|
+
var LayoutManagementContext = React5.createContext({
|
|
1947
|
+
getApplicationSettings: () => void 0,
|
|
1948
|
+
layoutMetadata: [],
|
|
1949
|
+
saveLayout: () => void 0,
|
|
1950
|
+
// The default Application JSON will be served if no LayoutManagementProvider
|
|
1951
|
+
applicationJson: defaultApplicationJson,
|
|
1952
|
+
saveApplicationLayout: () => void 0,
|
|
1953
|
+
saveApplicationSettings: () => void 0,
|
|
1954
|
+
loadLayoutById: () => void 0
|
|
1955
|
+
});
|
|
1956
|
+
var ensureLayoutHasTitle = (layout, layoutMetadata) => {
|
|
1957
|
+
var _a;
|
|
1958
|
+
if (((_a = layout.props) == null ? void 0 : _a.title) !== void 0) {
|
|
1959
|
+
return layout;
|
|
1960
|
+
} else {
|
|
1961
|
+
return {
|
|
1962
|
+
...layout,
|
|
1963
|
+
props: {
|
|
1964
|
+
...layout.props,
|
|
1965
|
+
title: layoutMetadata.name
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
var LayoutManagementProvider = (props) => {
|
|
1971
|
+
const [layoutMetadata, setLayoutMetadata] = useState7([]);
|
|
1972
|
+
const [, forceRefresh] = useState7({});
|
|
1973
|
+
const { notify } = useNotifications();
|
|
1974
|
+
const applicationJSONRef = useRef4(loadingApplicationJson);
|
|
1975
|
+
const setApplicationJSON = useCallback9(
|
|
1976
|
+
(applicationJSON, rerender = true) => {
|
|
1977
|
+
applicationJSONRef.current = applicationJSON;
|
|
1978
|
+
if (rerender) {
|
|
1979
|
+
forceRefresh({});
|
|
1980
|
+
}
|
|
1981
|
+
},
|
|
1982
|
+
[]
|
|
1983
|
+
);
|
|
1984
|
+
const setApplicationLayout = useCallback9(
|
|
1985
|
+
(layout, rerender = true) => {
|
|
1986
|
+
setApplicationJSON(
|
|
1987
|
+
{
|
|
1988
|
+
...applicationJSONRef.current,
|
|
1989
|
+
layout
|
|
1990
|
+
},
|
|
1991
|
+
rerender
|
|
1992
|
+
);
|
|
1993
|
+
},
|
|
1994
|
+
[setApplicationJSON]
|
|
1995
|
+
);
|
|
1996
|
+
const setApplicationSettings = useCallback9(
|
|
1997
|
+
(settings) => {
|
|
1998
|
+
setApplicationJSON(
|
|
1999
|
+
{
|
|
2000
|
+
...applicationJSONRef.current,
|
|
2001
|
+
settings: {
|
|
2002
|
+
...applicationJSONRef.current.settings,
|
|
2003
|
+
...settings
|
|
2004
|
+
}
|
|
2005
|
+
},
|
|
2006
|
+
false
|
|
2007
|
+
);
|
|
2008
|
+
},
|
|
2009
|
+
[setApplicationJSON]
|
|
2010
|
+
);
|
|
2011
|
+
useEffect6(() => {
|
|
2012
|
+
const persistenceManager = getPersistenceManager();
|
|
2013
|
+
persistenceManager.loadMetadata().then((metadata) => {
|
|
2014
|
+
setLayoutMetadata(metadata);
|
|
2015
|
+
}).catch((error2) => {
|
|
2016
|
+
notify({
|
|
2017
|
+
type: "error" /* Error */,
|
|
2018
|
+
header: "Failed to Load Layouts",
|
|
2019
|
+
body: "Could not load list of available layouts"
|
|
2020
|
+
});
|
|
2021
|
+
console.error("Error occurred while retrieving metadata", error2);
|
|
2022
|
+
});
|
|
2023
|
+
persistenceManager.loadApplicationJSON().then((applicationJSON) => {
|
|
2024
|
+
setApplicationJSON(applicationJSON);
|
|
2025
|
+
}).catch((error2) => {
|
|
2026
|
+
notify({
|
|
2027
|
+
type: "error" /* Error */,
|
|
2028
|
+
header: "Failed to Load Layout",
|
|
2029
|
+
body: "Could not load your latest view"
|
|
2030
|
+
});
|
|
2031
|
+
console.error(
|
|
2032
|
+
"Error occurred while retrieving application layout",
|
|
2033
|
+
error2
|
|
2034
|
+
);
|
|
2035
|
+
});
|
|
2036
|
+
}, [notify, setApplicationJSON]);
|
|
2037
|
+
const saveApplicationLayout = useCallback9(
|
|
2038
|
+
(layout) => {
|
|
2039
|
+
setApplicationLayout(layout, false);
|
|
2040
|
+
getPersistenceManager().saveApplicationJSON(applicationJSONRef.current);
|
|
2041
|
+
},
|
|
2042
|
+
[setApplicationLayout]
|
|
2043
|
+
);
|
|
2044
|
+
const saveLayout = useCallback9(
|
|
2045
|
+
(metadata) => {
|
|
2046
|
+
const layoutToSave = resolveJSONPath(
|
|
2047
|
+
applicationJSONRef.current.layout,
|
|
2048
|
+
"#main-tabs.ACTIVE_CHILD"
|
|
2049
|
+
);
|
|
2050
|
+
if (layoutToSave) {
|
|
2051
|
+
getPersistenceManager().createLayout(metadata, ensureLayoutHasTitle(layoutToSave, metadata)).then((metadata2) => {
|
|
2052
|
+
notify({
|
|
2053
|
+
type: "success" /* Success */,
|
|
2054
|
+
header: "Layout Saved Successfully",
|
|
2055
|
+
body: `${metadata2.name} saved successfully`
|
|
2056
|
+
});
|
|
2057
|
+
setLayoutMetadata((prev) => [...prev, metadata2]);
|
|
2058
|
+
}).catch((error2) => {
|
|
2059
|
+
notify({
|
|
2060
|
+
type: "error" /* Error */,
|
|
2061
|
+
header: "Failed to Save Layout",
|
|
2062
|
+
body: `Failed to save layout ${metadata.name}`
|
|
2063
|
+
});
|
|
2064
|
+
console.error("Error occurred while saving layout", error2);
|
|
2065
|
+
});
|
|
2066
|
+
} else {
|
|
2067
|
+
notify({
|
|
2068
|
+
type: "error" /* Error */,
|
|
2069
|
+
header: "Failed to Save Layout",
|
|
2070
|
+
body: "Cannot save undefined layout"
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
},
|
|
2074
|
+
[notify]
|
|
2075
|
+
);
|
|
2076
|
+
const saveApplicationSettings = useCallback9(
|
|
2077
|
+
(settings, key) => {
|
|
2078
|
+
const { settings: applicationSettings } = applicationJSONRef.current;
|
|
2079
|
+
if (key) {
|
|
2080
|
+
setApplicationSettings({
|
|
2081
|
+
...applicationSettings,
|
|
2082
|
+
[key]: settings
|
|
2083
|
+
});
|
|
2084
|
+
} else {
|
|
2085
|
+
setApplicationSettings(settings);
|
|
2086
|
+
}
|
|
2087
|
+
getPersistenceManager().saveApplicationJSON(applicationJSONRef.current);
|
|
2088
|
+
},
|
|
2089
|
+
[setApplicationSettings]
|
|
2090
|
+
);
|
|
2091
|
+
const getApplicationSettings = useCallback9(
|
|
2092
|
+
(key) => {
|
|
2093
|
+
const { settings } = applicationJSONRef.current;
|
|
2094
|
+
return key ? settings == null ? void 0 : settings[key] : settings;
|
|
2095
|
+
},
|
|
2096
|
+
[]
|
|
2097
|
+
);
|
|
2098
|
+
const loadLayoutById = useCallback9(
|
|
2099
|
+
(id) => {
|
|
2100
|
+
getPersistenceManager().loadLayout(id).then((layoutJson) => {
|
|
2101
|
+
var _a, _b;
|
|
2102
|
+
const { layout: currentLayout } = applicationJSONRef.current;
|
|
2103
|
+
setApplicationLayout({
|
|
2104
|
+
...currentLayout,
|
|
2105
|
+
children: (currentLayout.children || []).concat(layoutJson),
|
|
2106
|
+
props: {
|
|
2107
|
+
...currentLayout.props,
|
|
2108
|
+
active: (_b = (_a = currentLayout.children) == null ? void 0 : _a.length) != null ? _b : 0
|
|
2109
|
+
}
|
|
2110
|
+
});
|
|
2111
|
+
}).catch((error2) => {
|
|
2112
|
+
notify({
|
|
2113
|
+
type: "error" /* Error */,
|
|
2114
|
+
header: "Failed to Load Layout",
|
|
2115
|
+
body: "Failed to load the requested layout"
|
|
2116
|
+
});
|
|
2117
|
+
console.error("Error occurred while loading layout", error2);
|
|
2118
|
+
});
|
|
2119
|
+
},
|
|
2120
|
+
[notify, setApplicationLayout]
|
|
2121
|
+
);
|
|
2122
|
+
return /* @__PURE__ */ jsx15(
|
|
2123
|
+
LayoutManagementContext.Provider,
|
|
2124
|
+
{
|
|
2125
|
+
value: {
|
|
2126
|
+
getApplicationSettings,
|
|
2127
|
+
layoutMetadata,
|
|
2128
|
+
saveLayout,
|
|
2129
|
+
applicationJson: applicationJSONRef.current,
|
|
2130
|
+
saveApplicationLayout,
|
|
2131
|
+
saveApplicationSettings,
|
|
2132
|
+
loadLayoutById
|
|
2133
|
+
},
|
|
2134
|
+
children: props.children
|
|
2135
|
+
}
|
|
2136
|
+
);
|
|
2137
|
+
};
|
|
2138
|
+
var useLayoutManager = () => useContext2(LayoutManagementContext);
|
|
2139
|
+
|
|
2140
|
+
// src/layout-management/LayoutTile.tsx
|
|
2141
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2142
|
+
var classBase6 = "vuuLayoutTile";
|
|
2143
|
+
var LayoutTile = (props) => {
|
|
2144
|
+
const { metadata, handleLoadLayout } = props;
|
|
2145
|
+
return /* @__PURE__ */ jsx16("div", { role: "listitem", children: /* @__PURE__ */ jsxs10(
|
|
2146
|
+
"div",
|
|
2147
|
+
{
|
|
2148
|
+
className: `${classBase6}-layoutTile`,
|
|
2149
|
+
role: "button",
|
|
2150
|
+
onClick: () => handleLoadLayout(metadata == null ? void 0 : metadata.id),
|
|
2151
|
+
children: [
|
|
2152
|
+
/* @__PURE__ */ jsx16("img", { className: `${classBase6}-screenshot`, src: metadata == null ? void 0 : metadata.screenshot }),
|
|
2153
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
2154
|
+
/* @__PURE__ */ jsx16("div", { className: `${classBase6}-layoutName`, children: metadata == null ? void 0 : metadata.name }),
|
|
2155
|
+
/* @__PURE__ */ jsx16("div", { className: `${classBase6}-layoutDetails`, children: /* @__PURE__ */ jsx16("div", { children: `${metadata == null ? void 0 : metadata.user}, ${metadata == null ? void 0 : metadata.created}` }) })
|
|
2156
|
+
] })
|
|
2157
|
+
]
|
|
2158
|
+
},
|
|
2159
|
+
metadata == null ? void 0 : metadata.id
|
|
2160
|
+
) });
|
|
2161
|
+
};
|
|
2162
|
+
|
|
2163
|
+
// src/layout-management/LayoutList.tsx
|
|
2164
|
+
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2165
|
+
var classBase7 = "vuuLayoutList";
|
|
2166
|
+
var LayoutList = (props) => {
|
|
2167
|
+
const { layoutMetadata, loadLayoutById } = useLayoutManager();
|
|
2168
|
+
const handleLoadLayout = (layoutId) => {
|
|
2169
|
+
if (layoutId) {
|
|
2170
|
+
loadLayoutById(layoutId);
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
const layoutsByGroup = layoutMetadata.reduce((acc, cur) => {
|
|
2174
|
+
if (acc[cur.group]) {
|
|
2175
|
+
return {
|
|
2176
|
+
...acc,
|
|
2177
|
+
[cur.group]: [...acc[cur.group], cur]
|
|
2178
|
+
};
|
|
2179
|
+
}
|
|
2180
|
+
return {
|
|
2181
|
+
...acc,
|
|
2182
|
+
[cur.group]: [cur]
|
|
2183
|
+
};
|
|
2184
|
+
}, {});
|
|
2185
|
+
return /* @__PURE__ */ jsxs11(
|
|
2186
|
+
"div",
|
|
2187
|
+
{
|
|
2188
|
+
className: classBase7,
|
|
2189
|
+
...props,
|
|
2190
|
+
role: "listbox",
|
|
2191
|
+
"aria-label": "my layouts",
|
|
2192
|
+
children: [
|
|
2193
|
+
/* @__PURE__ */ jsx17("div", { className: `${classBase7}-header`, children: "My Layouts" }),
|
|
2194
|
+
/* @__PURE__ */ jsx17(
|
|
2195
|
+
List,
|
|
2196
|
+
{
|
|
2197
|
+
height: "auto",
|
|
2198
|
+
source: Object.entries(layoutsByGroup),
|
|
2199
|
+
ListItem: ({ item }) => {
|
|
2200
|
+
if (!item)
|
|
2201
|
+
return /* @__PURE__ */ jsx17(Fragment3, {});
|
|
2202
|
+
const [groupName, layoutMetadata2] = item;
|
|
2203
|
+
return /* @__PURE__ */ jsxs11("div", { role: "list", "aria-label": groupName, children: [
|
|
2204
|
+
/* @__PURE__ */ jsx17("div", { className: `${classBase7}-groupName`, children: groupName }),
|
|
2205
|
+
layoutMetadata2.map((metadata) => /* @__PURE__ */ jsx17(
|
|
2206
|
+
LayoutTile,
|
|
2207
|
+
{
|
|
2208
|
+
metadata,
|
|
2209
|
+
handleLoadLayout
|
|
2210
|
+
},
|
|
2211
|
+
metadata.id
|
|
2212
|
+
))
|
|
2213
|
+
] });
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
)
|
|
2217
|
+
]
|
|
2218
|
+
}
|
|
2219
|
+
);
|
|
2220
|
+
};
|
|
2221
|
+
|
|
2222
|
+
// src/left-nav/LeftNav.tsx
|
|
2223
|
+
import { VuuLogo as VuuLogo2 } from "@vuu-ui/vuu-icons";
|
|
2224
|
+
import { Stack, useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
|
|
2225
|
+
import { Tab, Tabstrip } from "@vuu-ui/vuu-ui-controls";
|
|
2226
|
+
import { useThemeAttributes as useThemeAttributes2 } from "@vuu-ui/vuu-utils";
|
|
2227
|
+
import cx6 from "clsx";
|
|
2228
|
+
import { useCallback as useCallback10, useState as useState8 } from "react";
|
|
2229
|
+
|
|
2230
|
+
// src/feature-list/FeatureList.tsx
|
|
2231
|
+
import { Palette, PaletteItem } from "@vuu-ui/vuu-layout";
|
|
2232
|
+
import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2233
|
+
var classBase8 = "vuuFeatureList";
|
|
2234
|
+
var FeatureList = ({
|
|
2235
|
+
features,
|
|
2236
|
+
title = "VUU TABLES",
|
|
2237
|
+
...htmlAttributes
|
|
2238
|
+
}) => {
|
|
2239
|
+
const ViewProps2 = {};
|
|
2240
|
+
const listProps = {
|
|
2241
|
+
height: "100%"
|
|
2242
|
+
};
|
|
2243
|
+
return /* @__PURE__ */ jsxs12("div", { ...htmlAttributes, className: classBase8, children: [
|
|
2244
|
+
/* @__PURE__ */ jsx18("div", { className: `${classBase8}-header`, children: title }),
|
|
2245
|
+
/* @__PURE__ */ jsx18("div", { className: `${classBase8}-content`, children: /* @__PURE__ */ jsx18(
|
|
2246
|
+
Palette,
|
|
2247
|
+
{
|
|
2248
|
+
orientation: "vertical",
|
|
2249
|
+
ListProps: listProps,
|
|
2250
|
+
ViewProps: ViewProps2,
|
|
2251
|
+
children: features.map((featureProps, i) => /* @__PURE__ */ jsx18(
|
|
2252
|
+
PaletteItem,
|
|
2253
|
+
{
|
|
2254
|
+
closeable: true,
|
|
2255
|
+
label: featureProps.title,
|
|
2256
|
+
resizeable: true,
|
|
2257
|
+
resize: "defer",
|
|
2258
|
+
header: true,
|
|
2259
|
+
children: /* @__PURE__ */ jsx18(Feature, { ...featureProps })
|
|
2260
|
+
},
|
|
2261
|
+
i
|
|
2262
|
+
))
|
|
2263
|
+
}
|
|
2264
|
+
) })
|
|
2265
|
+
] });
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
// src/left-nav/LeftNav.tsx
|
|
2269
|
+
import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2270
|
+
var classBase9 = "vuuLeftNav";
|
|
2271
|
+
var getDisplayStatus = (activeTabIndex, expanded) => {
|
|
2272
|
+
if (activeTabIndex === 0) {
|
|
2273
|
+
return expanded ? "menu-full" : "menu-icons";
|
|
2274
|
+
} else {
|
|
2275
|
+
return expanded ? "menu-full-content" : "menu-icons-content";
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
var LeftNav = (props) => {
|
|
2279
|
+
const dispatch = useLayoutProviderDispatch();
|
|
2280
|
+
const [themeClass] = useThemeAttributes2();
|
|
2281
|
+
const {
|
|
2282
|
+
"data-path": path,
|
|
2283
|
+
defaultExpanded = true,
|
|
2284
|
+
defaultActiveTabIndex = 0,
|
|
2285
|
+
features,
|
|
2286
|
+
onActiveChange,
|
|
2287
|
+
onTogglePrimaryMenu,
|
|
2288
|
+
sizeCollapsed = 80,
|
|
2289
|
+
sizeContent = 300,
|
|
2290
|
+
sizeExpanded = 240,
|
|
2291
|
+
style: styleProp,
|
|
2292
|
+
tableFeatures,
|
|
2293
|
+
...htmlAttributes
|
|
2294
|
+
} = props;
|
|
2295
|
+
const [navState, setNavState] = useState8({
|
|
2296
|
+
activeTabIndex: defaultActiveTabIndex,
|
|
2297
|
+
expanded: defaultExpanded
|
|
2298
|
+
});
|
|
2299
|
+
const getFullWidth = useCallback10(
|
|
2300
|
+
(tabIndex, expanded) => {
|
|
2301
|
+
if (tabIndex === 0) {
|
|
2302
|
+
return expanded ? sizeExpanded : sizeCollapsed;
|
|
2303
|
+
} else {
|
|
2304
|
+
return expanded ? sizeExpanded + sizeContent : sizeCollapsed + sizeContent;
|
|
2305
|
+
}
|
|
2306
|
+
},
|
|
2307
|
+
[sizeCollapsed, sizeContent, sizeExpanded]
|
|
2308
|
+
);
|
|
2309
|
+
const handleTabSelection = useCallback10(
|
|
2310
|
+
(activeTabIndex) => {
|
|
2311
|
+
const { activeTabIndex: currentIndex, expanded } = navState;
|
|
2312
|
+
const newState = { activeTabIndex, expanded };
|
|
2313
|
+
setNavState(newState);
|
|
2314
|
+
if (activeTabIndex === 0 || currentIndex === 0) {
|
|
2315
|
+
const width = getFullWidth(activeTabIndex, expanded);
|
|
2316
|
+
dispatch({
|
|
2317
|
+
type: "layout-resize",
|
|
2318
|
+
path: "#vuu-side-panel",
|
|
2319
|
+
size: width
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
onActiveChange == null ? void 0 : onActiveChange(activeTabIndex);
|
|
2323
|
+
},
|
|
2324
|
+
[dispatch, getFullWidth, navState, onActiveChange]
|
|
2325
|
+
);
|
|
2326
|
+
const displayStatus = getDisplayStatus(
|
|
2327
|
+
navState.activeTabIndex,
|
|
2328
|
+
navState.expanded
|
|
2329
|
+
);
|
|
2330
|
+
const toggleExpanded = useCallback10(() => {
|
|
2331
|
+
const { activeTabIndex, expanded } = navState;
|
|
2332
|
+
const primaryMenuExpanded = !expanded;
|
|
2333
|
+
const newState = { activeTabIndex, expanded: primaryMenuExpanded };
|
|
2334
|
+
setNavState(newState);
|
|
2335
|
+
dispatch({
|
|
2336
|
+
type: "layout-resize",
|
|
2337
|
+
path: "#vuu-side-panel",
|
|
2338
|
+
size: getFullWidth(activeTabIndex, primaryMenuExpanded)
|
|
2339
|
+
});
|
|
2340
|
+
onTogglePrimaryMenu == null ? void 0 : onTogglePrimaryMenu(primaryMenuExpanded);
|
|
2341
|
+
}, [dispatch, getFullWidth, navState, onTogglePrimaryMenu]);
|
|
2342
|
+
const style = {
|
|
2343
|
+
...styleProp,
|
|
2344
|
+
"--nav-menu-collapsed-width": `${sizeCollapsed}px`,
|
|
2345
|
+
"--nav-menu-expanded-width": `${sizeExpanded}px`,
|
|
2346
|
+
"--nav-menu-content-width": `${sizeContent}px`
|
|
2347
|
+
};
|
|
2348
|
+
return /* @__PURE__ */ jsxs13(
|
|
2349
|
+
"div",
|
|
2350
|
+
{
|
|
2351
|
+
...htmlAttributes,
|
|
2352
|
+
className: cx6(classBase9, `${classBase9}-${displayStatus}`),
|
|
2353
|
+
style,
|
|
2354
|
+
children: [
|
|
2355
|
+
/* @__PURE__ */ jsxs13(
|
|
2356
|
+
"div",
|
|
2357
|
+
{
|
|
2358
|
+
className: cx6(`${classBase9}-menu-primary`, themeClass),
|
|
2359
|
+
"data-mode": "dark",
|
|
2360
|
+
children: [
|
|
2361
|
+
/* @__PURE__ */ jsx19("div", { className: "vuuLeftNav-logo", children: /* @__PURE__ */ jsx19(VuuLogo2, {}) }),
|
|
2362
|
+
/* @__PURE__ */ jsx19("div", { className: `${classBase9}-main`, children: /* @__PURE__ */ jsxs13(
|
|
2363
|
+
Tabstrip,
|
|
2364
|
+
{
|
|
2365
|
+
activeTabIndex: navState.activeTabIndex,
|
|
2366
|
+
animateSelectionThumb: false,
|
|
2367
|
+
className: `${classBase9}-Tabstrip`,
|
|
2368
|
+
onActiveChange: handleTabSelection,
|
|
2369
|
+
orientation: "vertical",
|
|
2370
|
+
children: [
|
|
2371
|
+
/* @__PURE__ */ jsx19(Tab, { "data-icon": "demo", label: "DEMO" }),
|
|
2372
|
+
/* @__PURE__ */ jsx19(Tab, { "data-icon": "features", label: "VUU FEATURES" }),
|
|
2373
|
+
/* @__PURE__ */ jsx19(Tab, { "data-icon": "tables", label: "VUU TABLES" }),
|
|
2374
|
+
/* @__PURE__ */ jsx19(Tab, { "data-icon": "layouts", label: "MY LAYOUTS" })
|
|
2375
|
+
]
|
|
2376
|
+
}
|
|
2377
|
+
) }),
|
|
2378
|
+
/* @__PURE__ */ jsx19("div", { className: "vuuLeftNav-buttonBar", children: /* @__PURE__ */ jsx19(
|
|
2379
|
+
"button",
|
|
2380
|
+
{
|
|
2381
|
+
className: cx6("vuuLeftNav-toggleButton", {
|
|
2382
|
+
"vuuLeftNav-toggleButton-open": displayStatus.startsWith("menu-full"),
|
|
2383
|
+
"vuuLeftNav-toggleButton-closed": displayStatus.startsWith("menu-icons")
|
|
2384
|
+
}),
|
|
2385
|
+
"data-icon": displayStatus.startsWith("menu-full") ? "chevron-left" : "chevron-right",
|
|
2386
|
+
onClick: toggleExpanded
|
|
2387
|
+
}
|
|
2388
|
+
) })
|
|
2389
|
+
]
|
|
2390
|
+
}
|
|
2391
|
+
),
|
|
2392
|
+
/* @__PURE__ */ jsxs13(
|
|
2393
|
+
Stack,
|
|
2394
|
+
{
|
|
2395
|
+
active: navState.activeTabIndex - 1,
|
|
2396
|
+
className: `${classBase9}-menu-secondary`,
|
|
2397
|
+
showTabs: false,
|
|
2398
|
+
children: [
|
|
2399
|
+
/* @__PURE__ */ jsx19(FeatureList, { features, title: "VUU FEATURES" }),
|
|
2400
|
+
/* @__PURE__ */ jsx19(FeatureList, { features: tableFeatures, title: "VUU TABLES" }),
|
|
2401
|
+
/* @__PURE__ */ jsx19("div", { className: "vuuLeftNav-drawer", children: /* @__PURE__ */ jsx19(LayoutList, {}) })
|
|
2402
|
+
]
|
|
2403
|
+
}
|
|
2404
|
+
)
|
|
2405
|
+
]
|
|
2406
|
+
}
|
|
2407
|
+
);
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2410
|
+
// src/session-editing-form/SessionEditingForm.tsx
|
|
2411
|
+
import { VuuDataSource } from "@vuu-ui/vuu-data-remote";
|
|
2412
|
+
import {
|
|
2413
|
+
buildColumnMap,
|
|
2414
|
+
hasAction,
|
|
2415
|
+
isErrorResponse,
|
|
2416
|
+
isValidNumber,
|
|
2417
|
+
shallowEquals
|
|
2418
|
+
} from "@vuu-ui/vuu-utils";
|
|
2419
|
+
import { Button as Button5, useIdMemo } from "@salt-ds/core";
|
|
2420
|
+
import cx7 from "clsx";
|
|
2421
|
+
import {
|
|
2422
|
+
useCallback as useCallback11,
|
|
2423
|
+
useEffect as useEffect7,
|
|
2424
|
+
useMemo as useMemo5,
|
|
2425
|
+
useRef as useRef5,
|
|
2426
|
+
useState as useState9
|
|
2427
|
+
} from "react";
|
|
2428
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2429
|
+
var classBase10 = "vuuSessionEditingForm";
|
|
2430
|
+
var getField = (fields, name) => {
|
|
2431
|
+
const field = fields.find((f) => f.name === name);
|
|
2432
|
+
if (field) {
|
|
2433
|
+
return field;
|
|
2434
|
+
} else {
|
|
2435
|
+
throw Error(`SessionEditingForm, no field '${name}' found`);
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
var getFieldNameAndValue = (evt) => {
|
|
2439
|
+
const {
|
|
2440
|
+
dataset: { field },
|
|
2441
|
+
value
|
|
2442
|
+
} = evt.target;
|
|
2443
|
+
if (field === void 0) {
|
|
2444
|
+
throw Error("SessionEditingForm, form field has no field name");
|
|
2445
|
+
}
|
|
2446
|
+
return [field, value];
|
|
2447
|
+
};
|
|
2448
|
+
var Status = {
|
|
2449
|
+
uninitialised: 0,
|
|
2450
|
+
unchanged: 1,
|
|
2451
|
+
changed: 2,
|
|
2452
|
+
invalid: 3
|
|
2453
|
+
};
|
|
2454
|
+
function getTypedValue(value, type, throwIfUndefined = false) {
|
|
2455
|
+
switch (type) {
|
|
2456
|
+
case "int":
|
|
2457
|
+
case "long": {
|
|
2458
|
+
const typedValue = parseInt(value, 10);
|
|
2459
|
+
if (isValidNumber(typedValue)) {
|
|
2460
|
+
return typedValue;
|
|
2461
|
+
} else if (throwIfUndefined) {
|
|
2462
|
+
throw Error("SessionEditingForm getTypedValue");
|
|
2463
|
+
} else {
|
|
2464
|
+
return void 0;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
case "double": {
|
|
2468
|
+
const typedValue = parseFloat(value);
|
|
2469
|
+
if (isValidNumber(typedValue)) {
|
|
2470
|
+
return typedValue;
|
|
2471
|
+
}
|
|
2472
|
+
return void 0;
|
|
2473
|
+
}
|
|
2474
|
+
case "boolean":
|
|
2475
|
+
return value === "true" ? true : false;
|
|
2476
|
+
default:
|
|
2477
|
+
return value;
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
var getDataSource = (dataSource, schema) => {
|
|
2481
|
+
if (dataSource) {
|
|
2482
|
+
return dataSource;
|
|
2483
|
+
} else if (schema) {
|
|
2484
|
+
return new VuuDataSource({
|
|
2485
|
+
bufferSize: 0,
|
|
2486
|
+
table: schema.table,
|
|
2487
|
+
columns: schema.columns.map((col) => col.name)
|
|
2488
|
+
});
|
|
2489
|
+
} else {
|
|
2490
|
+
throw Error(
|
|
2491
|
+
"SessionEditingForm: either a DataSource or a TableSchema must be provided"
|
|
2492
|
+
);
|
|
2493
|
+
}
|
|
2494
|
+
};
|
|
2495
|
+
var SessionEditingForm = ({
|
|
2496
|
+
className,
|
|
2497
|
+
config: { fields, key: keyField },
|
|
2498
|
+
dataSource: dataSourceProp,
|
|
2499
|
+
id: idProp,
|
|
2500
|
+
onClose,
|
|
2501
|
+
schema,
|
|
2502
|
+
...htmlAttributes
|
|
2503
|
+
}) => {
|
|
2504
|
+
const [values, setValues] = useState9();
|
|
2505
|
+
const [errorMessage, setErrorMessage] = useState9("");
|
|
2506
|
+
const formContentRef = useRef5(null);
|
|
2507
|
+
const initialDataRef = useRef5();
|
|
2508
|
+
const dataStatusRef = useRef5(Status.uninitialised);
|
|
2509
|
+
const dataSource = useMemo5(() => {
|
|
2510
|
+
const applyServerData = (data) => {
|
|
2511
|
+
if (columnMap) {
|
|
2512
|
+
const values2 = {};
|
|
2513
|
+
for (const column of dataSource.columns) {
|
|
2514
|
+
values2[column] = data[columnMap[column]];
|
|
2515
|
+
}
|
|
2516
|
+
if (dataStatusRef.current === Status.uninitialised) {
|
|
2517
|
+
dataStatusRef.current = Status.unchanged;
|
|
2518
|
+
initialDataRef.current = values2;
|
|
2519
|
+
}
|
|
2520
|
+
setValues(values2);
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
const ds = getDataSource(dataSourceProp, schema);
|
|
2524
|
+
const columnMap = buildColumnMap(ds.columns);
|
|
2525
|
+
ds.subscribe({ range: { from: 0, to: 5 } }, (message) => {
|
|
2526
|
+
if (message.type === "viewport-update" && message.rows) {
|
|
2527
|
+
if (dataStatusRef.current === Status.uninitialised) {
|
|
2528
|
+
applyServerData(message.rows[0]);
|
|
2529
|
+
} else {
|
|
2530
|
+
console.log("what do we do with server updates");
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
return ds;
|
|
2535
|
+
}, [dataSourceProp, schema]);
|
|
2536
|
+
const id = useIdMemo(idProp);
|
|
2537
|
+
const handleChange = useCallback11(
|
|
2538
|
+
(evt) => {
|
|
2539
|
+
const [field, value] = getFieldNameAndValue(evt);
|
|
2540
|
+
const { type } = getField(fields, field);
|
|
2541
|
+
const typedValue = getTypedValue(value, type);
|
|
2542
|
+
setValues((values2 = {}) => {
|
|
2543
|
+
const newValues = {
|
|
2544
|
+
...values2,
|
|
2545
|
+
[field]: typedValue
|
|
2546
|
+
};
|
|
2547
|
+
const notUpdated = shallowEquals(newValues, initialDataRef.current);
|
|
2548
|
+
dataStatusRef.current = notUpdated ? Status.unchanged : typedValue !== void 0 ? Status.changed : Status.invalid;
|
|
2549
|
+
return newValues;
|
|
2550
|
+
});
|
|
2551
|
+
},
|
|
2552
|
+
[fields]
|
|
2553
|
+
);
|
|
2554
|
+
const handleBlur = useCallback11(
|
|
2555
|
+
(evt) => {
|
|
2556
|
+
const [field, value] = getFieldNameAndValue(evt);
|
|
2557
|
+
const { type } = getField(fields, field);
|
|
2558
|
+
const rowKey = values == null ? void 0 : values[keyField];
|
|
2559
|
+
const typedValue = getTypedValue(value, type, true);
|
|
2560
|
+
if (typeof rowKey === "string") {
|
|
2561
|
+
dataSource.menuRpcCall({
|
|
2562
|
+
rowKey,
|
|
2563
|
+
field,
|
|
2564
|
+
value: typedValue,
|
|
2565
|
+
type: "VP_EDIT_CELL_RPC"
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
},
|
|
2569
|
+
[dataSource, fields, keyField, values]
|
|
2570
|
+
);
|
|
2571
|
+
const applyAction = useCallback11(
|
|
2572
|
+
(action) => {
|
|
2573
|
+
if (typeof action === "object" && action !== null) {
|
|
2574
|
+
if ("type" in action && action.type === "CLOSE_DIALOG_ACTION") {
|
|
2575
|
+
onClose();
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
},
|
|
2579
|
+
[onClose]
|
|
2580
|
+
);
|
|
2581
|
+
const handleSubmit = useCallback11(async () => {
|
|
2582
|
+
const response = await dataSource.menuRpcCall({
|
|
2583
|
+
type: "VP_EDIT_SUBMIT_FORM_RPC"
|
|
2584
|
+
});
|
|
2585
|
+
if (isErrorResponse(response)) {
|
|
2586
|
+
setErrorMessage(response.error);
|
|
2587
|
+
} else if (hasAction(response)) {
|
|
2588
|
+
applyAction(response.action);
|
|
2589
|
+
}
|
|
2590
|
+
}, [applyAction, dataSource]);
|
|
2591
|
+
const handleKeyDown = useCallback11(
|
|
2592
|
+
(evt) => {
|
|
2593
|
+
if (evt.key === "Enter" && dataStatusRef.current === Status.changed) {
|
|
2594
|
+
handleSubmit();
|
|
2595
|
+
}
|
|
2596
|
+
},
|
|
2597
|
+
[handleSubmit]
|
|
2598
|
+
);
|
|
2599
|
+
const handleCancel = useCallback11(() => {
|
|
2600
|
+
onClose();
|
|
2601
|
+
}, [onClose]);
|
|
2602
|
+
const getFormControl = (field) => {
|
|
2603
|
+
var _a;
|
|
2604
|
+
const value = String((_a = values == null ? void 0 : values[field.name]) != null ? _a : "");
|
|
2605
|
+
if (field.readonly || field.name === keyField) {
|
|
2606
|
+
return /* @__PURE__ */ jsx20("div", { className: `${classBase10}-fieldValue vuuReadOnly`, children: value });
|
|
2607
|
+
} else {
|
|
2608
|
+
return /* @__PURE__ */ jsx20(
|
|
2609
|
+
"input",
|
|
2610
|
+
{
|
|
2611
|
+
className: `${classBase10}-fieldValue`,
|
|
2612
|
+
"data-field": field.name,
|
|
2613
|
+
onBlur: handleBlur,
|
|
2614
|
+
onChange: handleChange,
|
|
2615
|
+
type: "text",
|
|
2616
|
+
value,
|
|
2617
|
+
id: `${id}-input-${field.name}`
|
|
2618
|
+
}
|
|
2619
|
+
);
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
useEffect7(() => {
|
|
2623
|
+
if (formContentRef.current) {
|
|
2624
|
+
const firstInput = formContentRef.current.querySelector(
|
|
2625
|
+
"input"
|
|
2626
|
+
);
|
|
2627
|
+
if (firstInput) {
|
|
2628
|
+
setTimeout(() => {
|
|
2629
|
+
firstInput.focus();
|
|
2630
|
+
firstInput.select();
|
|
2631
|
+
}, 100);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
}, []);
|
|
2635
|
+
useEffect7(() => {
|
|
2636
|
+
return () => {
|
|
2637
|
+
if (dataSource) {
|
|
2638
|
+
dataSource.unsubscribe();
|
|
2639
|
+
}
|
|
2640
|
+
};
|
|
2641
|
+
}, [dataSource]);
|
|
2642
|
+
const isDirty = dataStatusRef.current === Status.changed;
|
|
2643
|
+
return /* @__PURE__ */ jsxs14("div", { ...htmlAttributes, className: cx7(classBase10, className), children: [
|
|
2644
|
+
errorMessage ? /* @__PURE__ */ jsx20(
|
|
2645
|
+
"div",
|
|
2646
|
+
{
|
|
2647
|
+
className: `${classBase10}-errorBanner`,
|
|
2648
|
+
"data-icon": "error",
|
|
2649
|
+
title: errorMessage,
|
|
2650
|
+
children: "Error, edit(s) not saved"
|
|
2651
|
+
}
|
|
2652
|
+
) : void 0,
|
|
2653
|
+
/* @__PURE__ */ jsx20(
|
|
2654
|
+
"div",
|
|
2655
|
+
{
|
|
2656
|
+
className: `${classBase10}-content`,
|
|
2657
|
+
ref: formContentRef,
|
|
2658
|
+
onKeyDown: handleKeyDown,
|
|
2659
|
+
children: fields.map((field) => {
|
|
2660
|
+
var _a;
|
|
2661
|
+
return /* @__PURE__ */ jsxs14("div", { className: `${classBase10}-field`, children: [
|
|
2662
|
+
/* @__PURE__ */ jsx20(
|
|
2663
|
+
"label",
|
|
2664
|
+
{
|
|
2665
|
+
className: cx7(`${classBase10}-fieldLabel`, {
|
|
2666
|
+
[`${classBase10}-required`]: field.required
|
|
2667
|
+
}),
|
|
2668
|
+
htmlFor: `${id}-input-${field.name}`,
|
|
2669
|
+
children: (_a = field == null ? void 0 : field.label) != null ? _a : field.description
|
|
2670
|
+
}
|
|
2671
|
+
),
|
|
2672
|
+
getFormControl(field)
|
|
2673
|
+
] }, field.name);
|
|
2674
|
+
})
|
|
2675
|
+
}
|
|
2676
|
+
),
|
|
2677
|
+
/* @__PURE__ */ jsxs14("div", { className: `${classBase10}-buttonbar salt-theme salt-density-high`, children: [
|
|
2678
|
+
/* @__PURE__ */ jsx20(
|
|
2679
|
+
Button5,
|
|
2680
|
+
{
|
|
2681
|
+
type: "submit",
|
|
2682
|
+
variant: "cta",
|
|
2683
|
+
disabled: !isDirty,
|
|
2684
|
+
onClick: handleSubmit,
|
|
2685
|
+
children: "Submit"
|
|
2686
|
+
}
|
|
2687
|
+
),
|
|
2688
|
+
/* @__PURE__ */ jsx20(Button5, { variant: "secondary", onClick: handleCancel, children: "Cancel" })
|
|
2689
|
+
] })
|
|
2690
|
+
] });
|
|
2691
|
+
};
|
|
2692
|
+
|
|
2693
|
+
// src/shell.tsx
|
|
2694
|
+
import { connectToServer } from "@vuu-ui/vuu-data-remote";
|
|
2695
|
+
import {
|
|
2696
|
+
DraggableLayout as DraggableLayout3,
|
|
2697
|
+
LayoutProvider,
|
|
2698
|
+
StackLayout
|
|
2699
|
+
} from "@vuu-ui/vuu-layout";
|
|
2700
|
+
import {
|
|
2701
|
+
logger,
|
|
2702
|
+
ThemeProvider,
|
|
2703
|
+
useThemeAttributes as useThemeAttributes3
|
|
2704
|
+
} from "@vuu-ui/vuu-utils";
|
|
2705
|
+
import cx10 from "clsx";
|
|
2706
|
+
import {
|
|
2707
|
+
useCallback as useCallback14,
|
|
2708
|
+
useEffect as useEffect8,
|
|
2709
|
+
useRef as useRef7
|
|
2710
|
+
} from "react";
|
|
2711
|
+
|
|
2712
|
+
// src/shell-layouts/context-panel/ContextPanel.tsx
|
|
2713
|
+
import { Button as Button6 } from "@salt-ds/core";
|
|
2714
|
+
import cx8 from "clsx";
|
|
2715
|
+
import { useCallback as useCallback12, useMemo as useMemo6 } from "react";
|
|
2716
|
+
import {
|
|
2717
|
+
layoutFromJson,
|
|
2718
|
+
View,
|
|
2719
|
+
useLayoutProviderDispatch as useLayoutProviderDispatch2
|
|
2720
|
+
} from "@vuu-ui/vuu-layout";
|
|
2721
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2722
|
+
var classBase11 = "vuuContextPanel";
|
|
2723
|
+
var ContextPanel = ({
|
|
2724
|
+
className: classNameProp,
|
|
2725
|
+
expanded = false,
|
|
2726
|
+
content: contentProp,
|
|
2727
|
+
overlay = false,
|
|
2728
|
+
title
|
|
2729
|
+
}) => {
|
|
2730
|
+
const dispatchLayoutAction = useLayoutProviderDispatch2();
|
|
2731
|
+
const handleClose = useCallback12(() => {
|
|
2732
|
+
dispatchLayoutAction({
|
|
2733
|
+
path: "#context-panel",
|
|
2734
|
+
propName: "expanded",
|
|
2735
|
+
propValue: false,
|
|
2736
|
+
type: "set-prop"
|
|
2737
|
+
});
|
|
2738
|
+
}, [dispatchLayoutAction]);
|
|
2739
|
+
const className = cx8(classBase11, classNameProp, {
|
|
2740
|
+
[`${classBase11}-expanded`]: expanded,
|
|
2741
|
+
[`${classBase11}-inline`]: overlay !== true,
|
|
2742
|
+
[`${classBase11}-overlay`]: overlay
|
|
2743
|
+
});
|
|
2744
|
+
const content = useMemo6(
|
|
2745
|
+
() => contentProp && expanded ? layoutFromJson(contentProp, "context-0") : null,
|
|
2746
|
+
[contentProp, expanded]
|
|
2747
|
+
);
|
|
2748
|
+
return /* @__PURE__ */ jsx21(
|
|
2749
|
+
"div",
|
|
2750
|
+
{
|
|
2751
|
+
className: cx8(classBase11, className, {
|
|
2752
|
+
[`${classBase11}-expanded`]: expanded
|
|
2753
|
+
}),
|
|
2754
|
+
children: /* @__PURE__ */ jsxs15(View, { className: `${classBase11}-inner`, header: false, id: "context-panel", children: [
|
|
2755
|
+
/* @__PURE__ */ jsxs15("div", { className: `${classBase11}-header`, children: [
|
|
2756
|
+
/* @__PURE__ */ jsx21("h2", { className: `${classBase11}-title`, children: title }),
|
|
2757
|
+
/* @__PURE__ */ jsx21(
|
|
2758
|
+
Button6,
|
|
2759
|
+
{
|
|
2760
|
+
className: `${classBase11}-close`,
|
|
2761
|
+
"data-icon": "close",
|
|
2762
|
+
onClick: handleClose,
|
|
2763
|
+
variant: "secondary"
|
|
2764
|
+
}
|
|
2765
|
+
)
|
|
2766
|
+
] }),
|
|
2767
|
+
/* @__PURE__ */ jsx21("div", { className: `${classBase11}-content`, children: content })
|
|
2768
|
+
] })
|
|
2769
|
+
}
|
|
2770
|
+
);
|
|
2771
|
+
};
|
|
2772
|
+
|
|
2773
|
+
// src/shell-layouts/useFullHeightLeftPanel.tsx
|
|
2774
|
+
import { DraggableLayout, Flexbox } from "@vuu-ui/vuu-layout";
|
|
2775
|
+
|
|
2776
|
+
// src/shell-layouts/side-panel/SidePanel.tsx
|
|
2777
|
+
import { useMemo as useMemo7 } from "react";
|
|
2778
|
+
import cx9 from "clsx";
|
|
2779
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
2780
|
+
var classBase12 = "vuuShellSidePanel";
|
|
2781
|
+
var SidePanel = ({
|
|
2782
|
+
children,
|
|
2783
|
+
open = true,
|
|
2784
|
+
sizeClosed = 90,
|
|
2785
|
+
sizeOpen = 200,
|
|
2786
|
+
style: styleProp,
|
|
2787
|
+
...htmlAttributes
|
|
2788
|
+
}) => {
|
|
2789
|
+
const style = useMemo7(
|
|
2790
|
+
() => ({
|
|
2791
|
+
...styleProp,
|
|
2792
|
+
"--shell-left-nav-size": open ? `${sizeOpen}px` : `${sizeClosed}px`
|
|
2793
|
+
}),
|
|
2794
|
+
[open, sizeClosed, sizeOpen, styleProp]
|
|
2795
|
+
);
|
|
2796
|
+
return /* @__PURE__ */ jsx22("div", { ...htmlAttributes, className: cx9(classBase12), style, children });
|
|
2797
|
+
};
|
|
2798
|
+
|
|
2799
|
+
// src/shell-layouts/useFullHeightLeftPanel.tsx
|
|
2800
|
+
import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2801
|
+
var useFullHeightLeftPanel = ({
|
|
2802
|
+
appHeader,
|
|
2803
|
+
LeftSidePanelProps
|
|
2804
|
+
}) => {
|
|
2805
|
+
return /* @__PURE__ */ jsxs16(
|
|
2806
|
+
Flexbox,
|
|
2807
|
+
{
|
|
2808
|
+
className: "App",
|
|
2809
|
+
style: {
|
|
2810
|
+
flexDirection: "row",
|
|
2811
|
+
height: "100%",
|
|
2812
|
+
width: "100%"
|
|
2813
|
+
},
|
|
2814
|
+
children: [
|
|
2815
|
+
/* @__PURE__ */ jsx23(SidePanel, { ...LeftSidePanelProps, id: "vuu-side-panel" }),
|
|
2816
|
+
/* @__PURE__ */ jsxs16(
|
|
2817
|
+
Flexbox,
|
|
2818
|
+
{
|
|
2819
|
+
className: "vuuShell-content",
|
|
2820
|
+
style: { flex: 1, flexDirection: "column" },
|
|
2821
|
+
children: [
|
|
2822
|
+
appHeader,
|
|
2823
|
+
/* @__PURE__ */ jsx23(DraggableLayout, { dropTarget: true, style: { flex: 1 } }, "main-content")
|
|
2824
|
+
]
|
|
2825
|
+
}
|
|
2826
|
+
),
|
|
2827
|
+
/* @__PURE__ */ jsx23(ContextPanel, { id: "context-panel", overlay: true })
|
|
2828
|
+
]
|
|
2829
|
+
}
|
|
2830
|
+
);
|
|
2831
|
+
};
|
|
2832
|
+
|
|
2833
|
+
// src/shell-layouts/useInlayLeftPanel.tsx
|
|
2834
|
+
import {
|
|
2835
|
+
DockLayout,
|
|
2836
|
+
DraggableLayout as DraggableLayout2,
|
|
2837
|
+
Drawer,
|
|
2838
|
+
Flexbox as Flexbox2,
|
|
2839
|
+
View as View2
|
|
2840
|
+
} from "@vuu-ui/vuu-layout";
|
|
2841
|
+
import { useCallback as useCallback13, useRef as useRef6, useState as useState10 } from "react";
|
|
2842
|
+
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2843
|
+
var useInlayLeftPanel = ({
|
|
2844
|
+
appHeader,
|
|
2845
|
+
LeftSidePanelProps
|
|
2846
|
+
}) => {
|
|
2847
|
+
const paletteView = useRef6(null);
|
|
2848
|
+
const [open, setOpen] = useState10(true);
|
|
2849
|
+
const handleDrawerClick = useCallback13(
|
|
2850
|
+
(e) => {
|
|
2851
|
+
var _a;
|
|
2852
|
+
const target = e.target;
|
|
2853
|
+
if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
|
|
2854
|
+
setOpen(!open);
|
|
2855
|
+
}
|
|
2856
|
+
},
|
|
2857
|
+
[open]
|
|
2858
|
+
);
|
|
2859
|
+
const getDrawers = useCallback13(
|
|
2860
|
+
(leftSidePanel) => {
|
|
2861
|
+
const drawers = [];
|
|
2862
|
+
drawers.push(
|
|
2863
|
+
/* @__PURE__ */ jsx24(
|
|
2864
|
+
Drawer,
|
|
2865
|
+
{
|
|
2866
|
+
onClick: handleDrawerClick,
|
|
2867
|
+
open,
|
|
2868
|
+
position: "left",
|
|
2869
|
+
inline: true,
|
|
2870
|
+
peekaboo: true,
|
|
2871
|
+
sizeOpen: 200,
|
|
2872
|
+
toggleButton: "end",
|
|
2873
|
+
children: /* @__PURE__ */ jsx24(
|
|
2874
|
+
View2,
|
|
2875
|
+
{
|
|
2876
|
+
className: "vuuShell-palette",
|
|
2877
|
+
id: "vw-app-palette",
|
|
2878
|
+
ref: paletteView,
|
|
2879
|
+
style: { height: "100%" },
|
|
2880
|
+
children: leftSidePanel
|
|
2881
|
+
},
|
|
2882
|
+
"app-palette"
|
|
2883
|
+
)
|
|
2884
|
+
},
|
|
2885
|
+
"left-panel"
|
|
2886
|
+
)
|
|
2887
|
+
);
|
|
2888
|
+
return drawers;
|
|
2889
|
+
},
|
|
2890
|
+
[handleDrawerClick, open]
|
|
2891
|
+
);
|
|
2892
|
+
return /* @__PURE__ */ jsxs17(
|
|
2893
|
+
Flexbox2,
|
|
2894
|
+
{
|
|
2895
|
+
className: "App",
|
|
2896
|
+
style: { flexDirection: "column", height: "100%", width: "100%" },
|
|
2897
|
+
children: [
|
|
2898
|
+
appHeader,
|
|
2899
|
+
/* @__PURE__ */ jsx24(DockLayout, { style: { flex: 1 }, children: getDrawers(LeftSidePanelProps == null ? void 0 : LeftSidePanelProps.children).concat(
|
|
2900
|
+
/* @__PURE__ */ jsx24(
|
|
2901
|
+
DraggableLayout2,
|
|
2902
|
+
{
|
|
2903
|
+
dropTarget: true,
|
|
2904
|
+
style: { width: "100%", height: "100%" }
|
|
2905
|
+
},
|
|
2906
|
+
"main-content"
|
|
2907
|
+
)
|
|
2908
|
+
) })
|
|
2909
|
+
]
|
|
2910
|
+
}
|
|
2911
|
+
);
|
|
2912
|
+
};
|
|
2913
|
+
|
|
2914
|
+
// src/shell-layouts/useShellLayout.ts
|
|
2915
|
+
var useShellLayout = ({
|
|
2916
|
+
leftSidePanelLayout = "inlay",
|
|
2917
|
+
...props
|
|
2918
|
+
}) => {
|
|
2919
|
+
const useLayoutHook = leftSidePanelLayout === "inlay" ? useInlayLeftPanel : useFullHeightLeftPanel;
|
|
2920
|
+
return useLayoutHook(props);
|
|
2921
|
+
};
|
|
2922
|
+
|
|
2923
|
+
// src/shell.tsx
|
|
2924
|
+
import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2925
|
+
if (typeof StackLayout !== "function") {
|
|
2926
|
+
console.warn(
|
|
2927
|
+
"StackLayout module not loaded, will be unsbale to deserialize from layout JSON"
|
|
2928
|
+
);
|
|
2929
|
+
}
|
|
2930
|
+
var { error } = logger("Shell");
|
|
2931
|
+
var defaultLeftSidePanel = {};
|
|
2932
|
+
var Shell = ({
|
|
2933
|
+
LayoutProps,
|
|
2934
|
+
LeftSidePanelProps = defaultLeftSidePanel,
|
|
2935
|
+
children,
|
|
2936
|
+
className: classNameProp,
|
|
2937
|
+
leftSidePanelLayout,
|
|
2938
|
+
loginUrl,
|
|
2939
|
+
saveLocation = "remote",
|
|
2940
|
+
saveUrl,
|
|
2941
|
+
serverUrl,
|
|
2942
|
+
user,
|
|
2943
|
+
...htmlAttributes
|
|
2944
|
+
}) => {
|
|
2945
|
+
const rootRef = useRef7(null);
|
|
2946
|
+
const { dialog, setDialogState } = useDialog();
|
|
2947
|
+
const layoutId = useRef7("latest");
|
|
2948
|
+
const { applicationJson, saveApplicationLayout, loadLayoutById } = useLayoutManager();
|
|
2949
|
+
const { buildMenuOptions, handleMenuAction } = useLayoutContextMenuItems(setDialogState);
|
|
2950
|
+
const handleLayoutChange = useCallback14(
|
|
2951
|
+
(layout) => {
|
|
2952
|
+
try {
|
|
2953
|
+
saveApplicationLayout(layout);
|
|
2954
|
+
} catch {
|
|
2955
|
+
error == null ? void 0 : error("Failed to save layout");
|
|
2956
|
+
}
|
|
2957
|
+
},
|
|
2958
|
+
[saveApplicationLayout]
|
|
2959
|
+
);
|
|
2960
|
+
const handleSwitchTheme = useCallback14((mode) => {
|
|
2961
|
+
if (rootRef.current) {
|
|
2962
|
+
rootRef.current.dataset.mode = mode;
|
|
2963
|
+
}
|
|
2964
|
+
}, []);
|
|
2965
|
+
const handleNavigate = useCallback14(
|
|
2966
|
+
(id) => {
|
|
2967
|
+
layoutId.current = id;
|
|
2968
|
+
loadLayoutById(id);
|
|
2969
|
+
},
|
|
2970
|
+
[loadLayoutById]
|
|
2971
|
+
);
|
|
2972
|
+
useEffect8(() => {
|
|
2973
|
+
if (serverUrl && user.token) {
|
|
2974
|
+
connectToServer({
|
|
2975
|
+
authToken: user.token,
|
|
2976
|
+
url: serverUrl,
|
|
2977
|
+
username: user.username
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
}, [serverUrl, user.token, user.username]);
|
|
2981
|
+
const [themeClass, densityClass, dataMode] = useThemeAttributes3();
|
|
2982
|
+
const className = cx10("vuuShell", classNameProp, themeClass, densityClass);
|
|
2983
|
+
const isLoading = applicationJson === loadingApplicationJson;
|
|
2984
|
+
const shellLayout = useShellLayout({
|
|
2985
|
+
LeftSidePanelProps,
|
|
2986
|
+
leftSidePanelLayout,
|
|
2987
|
+
appHeader: /* @__PURE__ */ jsx25(
|
|
2988
|
+
AppHeader,
|
|
2989
|
+
{
|
|
2990
|
+
layoutId: layoutId.current,
|
|
2991
|
+
loginUrl,
|
|
2992
|
+
user,
|
|
2993
|
+
onNavigate: handleNavigate,
|
|
2994
|
+
onSwitchTheme: handleSwitchTheme
|
|
2995
|
+
}
|
|
2996
|
+
)
|
|
2997
|
+
});
|
|
2998
|
+
return isLoading ? null : /* @__PURE__ */ jsx25(ThemeProvider, { children: /* @__PURE__ */ jsxs18(
|
|
2999
|
+
ContextMenuProvider,
|
|
3000
|
+
{
|
|
3001
|
+
menuActionHandler: handleMenuAction,
|
|
3002
|
+
menuBuilder: buildMenuOptions,
|
|
3003
|
+
children: [
|
|
3004
|
+
/* @__PURE__ */ jsx25(
|
|
3005
|
+
LayoutProvider,
|
|
3006
|
+
{
|
|
3007
|
+
...LayoutProps,
|
|
3008
|
+
layout: applicationJson.layout,
|
|
3009
|
+
onLayoutChange: handleLayoutChange,
|
|
3010
|
+
children: /* @__PURE__ */ jsx25(
|
|
3011
|
+
DraggableLayout3,
|
|
3012
|
+
{
|
|
3013
|
+
className,
|
|
3014
|
+
"data-mode": dataMode,
|
|
3015
|
+
ref: rootRef,
|
|
3016
|
+
...htmlAttributes,
|
|
3017
|
+
children: shellLayout
|
|
3018
|
+
}
|
|
3019
|
+
)
|
|
3020
|
+
}
|
|
3021
|
+
),
|
|
3022
|
+
children || dialog
|
|
3023
|
+
]
|
|
3024
|
+
}
|
|
3025
|
+
) });
|
|
3026
|
+
};
|
|
3027
|
+
|
|
3028
|
+
// src/shellTypes.ts
|
|
3029
|
+
var isWildcardSchema = (schema) => schema === "*";
|
|
3030
|
+
var isTableSchema = (schema) => typeof schema === "object" && typeof schema.module === "string" && typeof schema.table === "string";
|
|
3031
|
+
|
|
3032
|
+
// src/ShellContextProvider.tsx
|
|
3033
|
+
import { createContext as createContext2, useContext as useContext3 } from "react";
|
|
3034
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3035
|
+
var defaultConfig = {};
|
|
3036
|
+
var ShellContext = createContext2(defaultConfig);
|
|
3037
|
+
var Provider2 = ({
|
|
3038
|
+
children,
|
|
3039
|
+
context,
|
|
3040
|
+
inheritedContext
|
|
3041
|
+
}) => {
|
|
3042
|
+
const mergedContext = {
|
|
3043
|
+
...inheritedContext,
|
|
3044
|
+
...context
|
|
3045
|
+
};
|
|
3046
|
+
return /* @__PURE__ */ jsx26(ShellContext.Provider, { value: mergedContext, children });
|
|
3047
|
+
};
|
|
3048
|
+
var ShellContextProvider = ({
|
|
3049
|
+
children,
|
|
3050
|
+
value
|
|
3051
|
+
}) => {
|
|
3052
|
+
return /* @__PURE__ */ jsx26(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx26(Provider2, { context: value, inheritedContext: context, children }) });
|
|
3053
|
+
};
|
|
3054
|
+
var useShellContext = () => {
|
|
3055
|
+
return useContext3(ShellContext);
|
|
3056
|
+
};
|
|
3057
|
+
|
|
3058
|
+
// src/theme-switch/ThemeSwitch.tsx
|
|
3059
|
+
import cx11 from "clsx";
|
|
3060
|
+
import { ToggleButton, ToggleButtonGroup, useControlled } from "@salt-ds/core";
|
|
3061
|
+
import { useCallback as useCallback15 } from "react";
|
|
3062
|
+
import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3063
|
+
var classBase13 = "vuuThemeSwitch";
|
|
3064
|
+
var ThemeSwitch = ({
|
|
3065
|
+
className: classNameProp,
|
|
3066
|
+
defaultMode: defaultModeProp,
|
|
3067
|
+
mode: modeProp,
|
|
3068
|
+
onChange,
|
|
3069
|
+
...htmlAttributes
|
|
3070
|
+
}) => {
|
|
3071
|
+
const [mode, setMode] = useControlled({
|
|
3072
|
+
controlled: modeProp,
|
|
3073
|
+
default: defaultModeProp != null ? defaultModeProp : "light",
|
|
3074
|
+
name: "ThemeSwitch",
|
|
3075
|
+
state: "mode"
|
|
3076
|
+
});
|
|
3077
|
+
const handleChangeSecondary = useCallback15(
|
|
3078
|
+
(evt) => {
|
|
3079
|
+
const { value } = evt.target;
|
|
3080
|
+
setMode(value);
|
|
3081
|
+
onChange(value);
|
|
3082
|
+
},
|
|
3083
|
+
[onChange, setMode]
|
|
3084
|
+
);
|
|
3085
|
+
const className = cx11(classBase13, classNameProp);
|
|
3086
|
+
return /* @__PURE__ */ jsxs19(
|
|
3087
|
+
ToggleButtonGroup,
|
|
3088
|
+
{
|
|
3089
|
+
className,
|
|
3090
|
+
...htmlAttributes,
|
|
3091
|
+
onChange: handleChangeSecondary,
|
|
3092
|
+
value: mode,
|
|
3093
|
+
children: [
|
|
3094
|
+
/* @__PURE__ */ jsx27(ToggleButton, { "aria-label": "alert", "data-icon": "light", value: "dark" }),
|
|
3095
|
+
/* @__PURE__ */ jsx27(ToggleButton, { "aria-label": "home", "data-icon": "dark", value: "light" })
|
|
3096
|
+
]
|
|
3097
|
+
}
|
|
3098
|
+
);
|
|
3099
|
+
};
|
|
3100
|
+
export {
|
|
3101
|
+
AppHeader,
|
|
3102
|
+
ConnectionStatusIcon,
|
|
3103
|
+
ContextPanel,
|
|
3104
|
+
Feature,
|
|
3105
|
+
FeatureList,
|
|
3106
|
+
LayoutList,
|
|
3107
|
+
LayoutManagementContext,
|
|
3108
|
+
LayoutManagementProvider,
|
|
3109
|
+
LeftNav,
|
|
3110
|
+
LoginPanel,
|
|
3111
|
+
SaveLayoutPanel,
|
|
3112
|
+
SessionEditingForm,
|
|
3113
|
+
Shell,
|
|
3114
|
+
ShellContextProvider,
|
|
3115
|
+
SidePanel,
|
|
3116
|
+
ThemeSwitch,
|
|
3117
|
+
getAuthDetailsFromCookies,
|
|
3118
|
+
getAuthModeFromCookies,
|
|
3119
|
+
isTableSchema,
|
|
3120
|
+
isWildcardSchema,
|
|
3121
|
+
logout,
|
|
3122
|
+
redirectToLogin,
|
|
3123
|
+
useLayoutManager,
|
|
3124
|
+
useShellContext,
|
|
3125
|
+
useShellLayout
|
|
3126
|
+
};
|
|
3
3127
|
//# sourceMappingURL=index.js.map
|