@vuu-ui/vuu-shell 0.8.30 → 0.8.31-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 +2825 -2
- package/cjs/index.js.map +2 -2
- package/esm/index.js +2845 -2
- package/esm/index.js.map +2 -2
- package/index.css +720 -1
- package/index.css.map +1 -1
- package/package.json +11 -11
- package/LICENSE +0 -201
package/cjs/index.js
CHANGED
|
@@ -1,3 +1,2826 @@
|
|
|
1
|
-
"use strict";var Bo=Object.create;var Ue=Object.defineProperty;var Oo=Object.getOwnPropertyDescriptor;var Uo=Object.getOwnPropertyNames;var Zo=Object.getPrototypeOf,qo=Object.prototype.hasOwnProperty;var zo=(e,t)=>{for(var o in t)Ue(e,o,{get:t[o],enumerable:!0})},Ft=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Uo(t))!qo.call(e,r)&&r!==o&&Ue(e,r,{get:()=>t[r],enumerable:!(a=Oo(t,r))||a.enumerable});return e};var V=(e,t,o)=>(o=e!=null?Bo(Zo(e)):{},Ft(t||!e||!e.__esModule?Ue(o,"default",{value:e,enumerable:!0}):o,e)),Jo=e=>Ft(Ue({},"__esModule",{value:!0}),e);var kt=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var lt=(e,t,o)=>(kt(e,t,"read from private field"),o?o.call(e):t.get(e)),Dt=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},At=(e,t,o,a)=>(kt(e,t,"write to private field"),a?a.call(e,o):t.set(e,o),o);var Ya={};zo(Ya,{AppHeader:()=>dt,ConnectionStatusIcon:()=>Go,ContextPanel:()=>Pt,Feature:()=>ke,FeatureList:()=>tt,LayoutList:()=>wt,LayoutManagementContext:()=>Lt,LayoutManagementProvider:()=>Ia,LeftNav:()=>Ba,LoginPanel:()=>_o,SaveLayoutPanel:()=>yt,SessionEditingForm:()=>Ua,Shell:()=>za,ShellContextProvider:()=>Qa,SidePanel:()=>Mt,ThemeSwitch:()=>Xa,getAuthDetailsFromCookies:()=>Ee,getAuthModeFromCookies:()=>$t,isTableSchema:()=>_a,isWildcardSchema:()=>Ja,logout:()=>ct,redirectToLogin:()=>Bt,useLayoutManager:()=>ce,useShellContext:()=>ja,useShellLayout:()=>Et});module.exports=Jo(Ya);var Ot=require("react"),Ut=require("@vuu-ui/vuu-ui-controls"),Zt=V(require("clsx"));var Q=require("react"),oe=require("@salt-ds/core"),ut=require("@vuu-ui/vuu-ui-controls");var Ht=require("react"),v=require("react/jsx-runtime"),Rt=()=>(0,Ht.useMemo)(()=>(0,v.jsxs)("svg",{width:"184",height:"90",viewBox:"0 0 184 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,v.jsxs)("g",{clipPath:"url(#clip0_1173_59965)",children:[(0,v.jsx)("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)"}),(0,v.jsx)("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)"}),(0,v.jsx)("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"}),(0,v.jsxs)("g",{opacity:"0.86",children:[(0,v.jsx)("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"}),(0,v.jsx)("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"}),(0,v.jsx)("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"})]})]}),(0,v.jsx)("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"}),(0,v.jsx)("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"}),(0,v.jsx)("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"}),(0,v.jsxs)("defs",{children:[(0,v.jsxs)("linearGradient",{id:"paint0_linear_1173_59965",x1:"47.6353",y1:"37.4727",x2:"81.8124",y2:"37.4727",gradientUnits:"userSpaceOnUse",children:[(0,v.jsx)("stop",{stopColor:"#4906A5"}),(0,v.jsx)("stop",{offset:"1",stopColor:"#D3423A"})]}),(0,v.jsxs)("linearGradient",{id:"paint1_linear_1173_59965",x1:"0.0670626",y1:"45.0017",x2:"82.5916",y2:"45.0017",gradientUnits:"userSpaceOnUse",children:[(0,v.jsx)("stop",{stopColor:"#7C06A5"}),(0,v.jsx)("stop",{offset:"1",stopColor:"#D3423A"})]}),(0,v.jsx)("clipPath",{id:"clip0_1173_59965",children:(0,v.jsx)("rect",{width:"85",height:"90",fill:"white",transform:"translate(0.0670471)"})})]})]}),[]);var It=V(require("clsx"));var M=require("react/jsx-runtime"),ie="vuuLoginPanel",_o=({appName:e="Demo App",className:t,requirePassword:o=!0,onSubmit:a,...r})=>{let[n,i]=(0,Q.useState)(""),[s,l]=(0,Q.useState)(""),c=(0,Q.useRef)(null),m=()=>{a(n,s)},y=h=>{i(h.target.value)},N=h=>{l(h.target.value)},C=(0,Q.useCallback)(()=>{o||a(n)},[a,o,n]),d=(0,Q.useCallback)(()=>{n&&a(n,s)},[a,s,n]),u=n.trim()!==""&&(o===!1||s.trim()!=="");return(0,Q.useEffect)(()=>{var h;console.log("inputRef",{input:c.current}),(h=c.current)==null||h.focus()},[]),(0,M.jsxs)("div",{...r,className:(0,It.default)(ie,t),children:[(0,M.jsxs)("div",{className:`${ie}-branding`,children:[(0,M.jsx)(Rt,{}),(0,M.jsx)("div",{className:`${ie}-appName`,children:e})]}),(0,M.jsxs)("div",{className:`${ie}-form`,children:[(0,M.jsx)("div",{className:`${ie}-title`,children:"Welcome Back"}),(0,M.jsxs)(oe.FormField,{children:[(0,M.jsx)(oe.FormFieldLabel,{children:"Username"}),(0,M.jsx)(ut.VuuInput,{value:n,id:"text-username",inputRef:c,onChange:y,onCommit:C})]}),o?(0,M.jsxs)(oe.FormField,{children:[(0,M.jsx)(oe.FormFieldLabel,{children:"Password"}),(0,M.jsx)(ut.VuuInput,{className:`${ie}-password`,inputProps:{type:"password"},value:s,id:"text-password",onChange:N,onCommit:d,endAdornment:(0,M.jsx)("span",{"data-icon":"eye",style:{cursor:"pointer"}})})]}):null,(0,M.jsx)(oe.Button,{className:`${ie}-login`,disabled:!u,onClick:m,variant:"cta",children:"Login"})]})]})};var Ze=require("@vuu-ui/vuu-utils"),$t=()=>{let e=(0,Ze.getCookieValue)("vuu-auth-mode");return e!=null?e:""},Ee=()=>{let e=(0,Ze.getCookieValue)("vuu-username"),t=(0,Ze.getCookieValue)("vuu-auth-token");return[e,t]},Wo=()=>$t()==="login"?"login.html":"demo.html",Bt=(e=Wo())=>{window.location.href=e},ct=e=>{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",Bt(e)};var Ve=require("@salt-ds/core");var K=require("react/jsx-runtime"),Ne="vuuAppHeader",dt=({className:e,layoutId:t,loginUrl:o,onNavigate:a,onSwitchTheme:r,themeMode:n,user:i,...s})=>{let l=(0,Zt.default)(Ne,e),c=(0,Ot.useCallback)(()=>{ct(o)},[o]);return(0,K.jsxs)(Ut.Toolbar,{alignItems:"end",className:l,showSeparators:!0,...s,children:[(0,K.jsx)(Ve.Button,{className:`${Ne}-menuItem`,variant:"secondary",children:"Help"}),(0,K.jsxs)(Ve.Button,{className:`${Ne}-menuItem`,variant:"secondary",children:["History ",(0,K.jsx)("span",{"data-icon":"history"})]}),(0,K.jsxs)(Ve.Button,{className:`${Ne}-menuItem`,variant:"secondary",children:["View ",(0,K.jsx)("span",{"data-icon":"settings"})]}),(0,K.jsx)(Ve.Button,{className:`${Ne}-menuItem`,onClick:c,variant:"secondary",children:"Log out"})]})};var ve=V(require("react")),qt=V(require("clsx"));var se=require("react/jsx-runtime"),Go=({connectionStatus:e,className:t,element:o="span",...a})=>{let[r,n]=(0,ve.useState)("vuuConnectingStatus");(0,ve.useEffect)(()=>{switch(e){case"connected":case"reconnected":n("vuuActiveStatus");break;case"connecting":n("vuuConnectingStatus");break;case"disconnected":n("vuuDisconnectedStatus");break;default:break}},[e]);let i=ve.default.createElement(o,{...a,className:(0,qt.default)("vuuStatus vuuIcon",r,t)});return(0,se.jsx)(se.Fragment,{children:(0,se.jsxs)("div",{className:"vuuStatus-container salt-theme",children:[i,(0,se.jsxs)("div",{className:"vuuStatus-text",children:["Status: ",e.toUpperCase()]})]})})};var ue=V(require("react")),Gt=require("@vuu-ui/vuu-layout");var zt=V(require("react")),le=require("react/jsx-runtime"),qe=class extends zt.default.Component{constructor(t){super(t),this.state={errorMessage:null}}static getDerivedStateFromError(t){return{errorMessage:t.message}}componentDidCatch(t,o){console.log(`error creating component at ${this.props.url}`),console.log(t,o)}render(){return this.state.errorMessage?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)("h1",{children:"An error occured while creating component."}),(0,le.jsx)("p",{children:this.state.errorMessage})]}):this.props.children}};var _t=require("react/jsx-runtime"),Jt=()=>(0,_t.jsx)("div",{className:"hwLoader"});var Wt=async e=>{let t=new CSSStyleSheet;return fetch(e).then(o=>o.text()).then(o=>t.replace(o))};var Fe=require("react/jsx-runtime"),ze=new Map,Qo=e=>{(0,ue.useEffect)(()=>()=>{ze.delete(e)},[e]),ze.has(e)||ze.set(e,ue.default.lazy(()=>import(e)));let t=ze.get(e);if(t)return t;throw Error(`Unable to load Lazy Feature at url ${e}`)};function jo({url:e,css:t,ComponentProps:o,...a}){t&&Wt(t).then(n=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,n]});let r=Qo(e);return(0,Fe.jsx)(qe,{url:e,children:(0,Fe.jsx)(ue.Suspense,{fallback:(0,Fe.jsx)(Jt,{}),children:(0,Fe.jsx)(r,{...a,...o})})})}var ke=ue.default.memo(jo);ke.displayName="Feature";(0,Gt.registerComponent)("Feature",ke,"view");var be=require("@vuu-ui/vuu-ui-controls");function Qt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let o=document.implementation.createHTMLDocument(),a=o.createElement("base"),r=o.createElement("a");return o.head.appendChild(a),o.body.appendChild(r),t&&(a.href=t),r.href=e,r.href}var jt=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function k(e){let t=[];for(let o=0,a=e.length;o<a;o++)t.push(e[o]);return t}function Je(e,t){let a=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return a?parseFloat(a.replace("px","")):0}function Ko(e){let t=Je(e,"border-left-width"),o=Je(e,"border-right-width");return e.clientWidth+t+o}function Xo(e){let t=Je(e,"border-top-width"),o=Je(e,"border-bottom-width");return e.clientHeight+t+o}function pt(e,t={}){let o=t.width||Ko(e),a=t.height||Xo(e);return{width:o,height:a}}function Kt(){let e,t;try{t=process}catch{}let o=t&&t.env?t.env.devicePixelRatio:null;return o&&(e=parseInt(o,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var F=16384;function Xt(e){(e.width>F||e.height>F)&&(e.width>F&&e.height>F?e.width>e.height?(e.height*=F/e.width,e.width=F):(e.width*=F/e.height,e.height=F):e.width>F?(e.height*=F/e.width,e.width=F):(e.width*=F/e.height,e.height=F))}function ye(e){return new Promise((t,o)=>{let a=new Image;a.decode=()=>t(a),a.onload=()=>t(a),a.onerror=o,a.crossOrigin="anonymous",a.decoding="async",a.src=e})}async function Yo(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Yt(e,t,o){let a="http://www.w3.org/2000/svg",r=document.createElementNS(a,"svg"),n=document.createElementNS(a,"foreignObject");return r.setAttribute("width",`${t}`),r.setAttribute("height",`${o}`),r.setAttribute("viewBox",`0 0 ${t} ${o}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),r.appendChild(n),n.appendChild(e),Yo(r)}var E=(e,t)=>{if(e instanceof t)return!0;let o=Object.getPrototypeOf(e);return o===null?!1:o.constructor.name===t.name||E(o,t)};function ea(e){let t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function ta(e){return k(e).map(t=>{let o=e.getPropertyValue(t),a=e.getPropertyPriority(t);return`${t}: ${o}${a?" !important":""};`}).join(" ")}function oa(e,t,o){let a=`.${e}:${t}`,r=o.cssText?ea(o):ta(o);return document.createTextNode(`${a}{${r}}`)}function eo(e,t,o){let a=window.getComputedStyle(e,o),r=a.getPropertyValue("content");if(r===""||r==="none")return;let n=jt();try{t.className=`${t.className} ${n}`}catch{return}let i=document.createElement("style");i.appendChild(oa(n,o,a)),t.appendChild(i)}function to(e,t){eo(e,t,":before"),eo(e,t,":after")}var oo="application/font-woff",ao="image/jpeg",aa={woff:oo,woff2:oo,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:ao,jpeg:ao,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function na(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function xe(e){let t=na(e).toLowerCase();return aa[t]||""}function ra(e){return e.split(/,/)[1]}function De(e){return e.search(/^(data:)/)!==-1}function ht(e,t){return`data:${t};base64,${e}`}async function ft(e,t,o){let a=await fetch(e,t);if(a.status===404)throw new Error(`Resource "${a.url}" not found`);let r=await a.blob();return new Promise((n,i)=>{let s=new FileReader;s.onerror=i,s.onloadend=()=>{try{n(o({res:a,result:s.result}))}catch(l){i(l)}},s.readAsDataURL(r)})}var mt={};function ia(e,t,o){let a=e.replace(/\?.*/,"");return o&&(a=e),/ttf|otf|eot|woff2?/i.test(a)&&(a=a.replace(/.*\//,"")),t?`[${t}]${a}`:a}async function Le(e,t,o){let a=ia(e,t,o.includeQueryParams);if(mt[a]!=null)return mt[a];o.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let r;try{let n=await ft(e,o.fetchRequestInit,({res:i,result:s})=>(t||(t=i.headers.get("Content-Type")||""),ra(s)));r=ht(n,t)}catch(n){r=o.imagePlaceholder||"";let i=`Failed to fetch resource: ${e}`;n&&(i=typeof n=="string"?n:n.message),i&&console.warn(i)}return mt[a]=r,r}async function sa(e){let t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):ye(t)}async function la(e,t){if(e.currentSrc){let n=document.createElement("canvas"),i=n.getContext("2d");n.width=e.clientWidth,n.height=e.clientHeight,i==null||i.drawImage(e,0,0,n.width,n.height);let s=n.toDataURL();return ye(s)}let o=e.poster,a=xe(o),r=await Le(o,a,t);return ye(r)}async function ua(e){var t;try{if(!((t=e==null?void 0:e.contentDocument)===null||t===void 0)&&t.body)return await Ae(e.contentDocument.body,{},!0)}catch{}return e.cloneNode(!1)}async function ca(e,t){return E(e,HTMLCanvasElement)?sa(e):E(e,HTMLVideoElement)?la(e,t):E(e,HTMLIFrameElement)?ua(e):e.cloneNode(!1)}var da=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT";async function pa(e,t,o){var a,r;let n=[];return da(e)&&e.assignedNodes?n=k(e.assignedNodes()):E(e,HTMLIFrameElement)&&(!((a=e.contentDocument)===null||a===void 0)&&a.body)?n=k(e.contentDocument.body.childNodes):n=k(((r=e.shadowRoot)!==null&&r!==void 0?r:e).childNodes),n.length===0||E(e,HTMLVideoElement)||await n.reduce((i,s)=>i.then(()=>Ae(s,o)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function ma(e,t){let o=t.style;if(!o)return;let a=window.getComputedStyle(e);a.cssText?(o.cssText=a.cssText,o.transformOrigin=a.transformOrigin):k(a).forEach(r=>{let n=a.getPropertyValue(r);r==="font-size"&&n.endsWith("px")&&(n=`${Math.floor(parseFloat(n.substring(0,n.length-2)))-.1}px`),E(e,HTMLIFrameElement)&&r==="display"&&n==="inline"&&(n="block"),r==="d"&&t.getAttribute("d")&&(n=`path(${t.getAttribute("d")})`),o.setProperty(r,n,a.getPropertyPriority(r))})}function ha(e,t){E(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),E(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function fa(e,t){if(E(e,HTMLSelectElement)){let o=t,a=Array.from(o.children).find(r=>e.value===r.getAttribute("value"));a&&a.setAttribute("selected","")}}function ga(e,t){return E(t,Element)&&(ma(e,t),to(e,t),ha(e,t),fa(e,t)),t}async function va(e,t){let o=e.querySelectorAll?e.querySelectorAll("use"):[];if(o.length===0)return e;let a={};for(let n=0;n<o.length;n++){let s=o[n].getAttribute("xlink:href");if(s){let l=e.querySelector(s),c=document.querySelector(s);!l&&c&&!a[s]&&(a[s]=await Ae(c,t,!0))}}let r=Object.values(a);if(r.length){let n="http://www.w3.org/1999/xhtml",i=document.createElementNS(n,"svg");i.setAttribute("xmlns",n),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";let s=document.createElementNS(n,"defs");i.appendChild(s);for(let l=0;l<r.length;l++)s.appendChild(r[l]);e.appendChild(i)}return e}async function Ae(e,t,o){return!o&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(a=>ca(a,t)).then(a=>pa(e,a,t)).then(a=>ga(e,a)).then(a=>va(a,t))}var no=/url\((['"]?)([^'"]+?)\1\)/g,ya=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,xa=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function La(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function ba(e){let t=[];return e.replace(no,(o,a,r)=>(t.push(r),o)),t.filter(o=>!De(o))}async function wa(e,t,o,a,r){try{let n=o?Qt(t,o):t,i=xe(t),s;if(r){let l=await r(n);s=ht(l,i)}else s=await Le(n,i,a);return e.replace(La(t),`$1${s}$3`)}catch{}return e}function Ca(e,{preferredFontFormat:t}){return t?e.replace(xa,o=>{for(;;){let[a,,r]=ya.exec(o)||[];if(!r)return"";if(r===t)return`src: ${a};`}}):e}function gt(e){return e.search(no)!==-1}async function _e(e,t,o){if(!gt(e))return e;let a=Ca(e,o);return ba(a).reduce((n,i)=>n.then(s=>wa(s,i,t,o)),Promise.resolve(a))}async function We(e,t,o){var a;let r=(a=t.style)===null||a===void 0?void 0:a.getPropertyValue(e);if(r){let n=await _e(r,null,o);return t.style.setProperty(e,n,t.style.getPropertyPriority(e)),!0}return!1}async function Sa(e,t){await We("background",e,t)||await We("background-image",e,t),await We("mask",e,t)||await We("mask-image",e,t)}async function Ta(e,t){let o=E(e,HTMLImageElement);if(!(o&&!De(e.src))&&!(E(e,SVGImageElement)&&!De(e.href.baseVal)))return;let a=o?e.src:e.href.baseVal,r=await Le(a,xe(a),t);await new Promise((n,i)=>{e.onload=n,e.onerror=i;let s=e;s.decode&&(s.decode=n),s.loading==="lazy"&&(s.loading="eager"),o?(e.srcset="",e.src=r):e.href.baseVal=r})}async function Pa(e,t){let a=k(e.childNodes).map(r=>vt(r,t));await Promise.all(a).then(()=>e)}async function vt(e,t){E(e,Element)&&(await Sa(e,t),await Ta(e,t),await Pa(e,t))}function ro(e,t){let{style:o}=e;t.backgroundColor&&(o.backgroundColor=t.backgroundColor),t.width&&(o.width=`${t.width}px`),t.height&&(o.height=`${t.height}px`);let a=t.style;return a!=null&&Object.keys(a).forEach(r=>{o[r]=a[r]}),e}var io={};async function so(e){let t=io[e];if(t!=null)return t;let a=await(await fetch(e)).text();return t={url:e,cssText:a},io[e]=t,t}async function lo(e,t){let o=e.cssText,a=/url\(["']?([^"')]+)["']?\)/g,n=(o.match(/url\([^)]+\)/g)||[]).map(async i=>{let s=i.replace(a,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),ft(s,t.fetchRequestInit,({result:l})=>(o=o.replace(i,`url(${l})`),[i,l]))});return Promise.all(n).then(()=>o)}function uo(e){if(e==null)return[];let t=[],o=/(\/\*[\s\S]*?\*\/)/gi,a=e.replace(o,""),r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let l=r.exec(a);if(l===null)break;t.push(l[0])}a=a.replace(r,"");let n=/@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 l=n.exec(a);if(l===null){if(l=s.exec(a),l===null)break;n.lastIndex=s.lastIndex}else s.lastIndex=n.lastIndex;t.push(l[0])}return t}async function Ma(e,t){let o=[],a=[];return e.forEach(r=>{if("cssRules"in r)try{k(r.cssRules||[]).forEach((n,i)=>{if(n.type===CSSRule.IMPORT_RULE){let s=i+1,l=n.href,c=so(l).then(m=>lo(m,t)).then(m=>uo(m).forEach(y=>{try{r.insertRule(y,y.startsWith("@import")?s+=1:r.cssRules.length)}catch(N){console.error("Error inserting rule from remote css",{rule:y,error:N})}})).catch(m=>{console.error("Error loading remote css",m.toString())});a.push(c)}})}catch(n){let i=e.find(s=>s.href==null)||document.styleSheets[0];r.href!=null&&a.push(so(r.href).then(s=>lo(s,t)).then(s=>uo(s).forEach(l=>{i.insertRule(l,r.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",n)}}),Promise.all(a).then(()=>(e.forEach(r=>{if("cssRules"in r)try{k(r.cssRules||[]).forEach(n=>{o.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${r.href}`,n)}}),o))}function Ea(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>gt(t.style.getPropertyValue("src")))}async function Na(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");let o=k(e.ownerDocument.styleSheets),a=await Ma(o,t);return Ea(a)}async function co(e,t){let o=await Na(e,t);return(await Promise.all(o.map(r=>{let n=r.parentStyleSheet?r.parentStyleSheet.href:null;return _e(r.cssText,n,t)}))).join(`
|
|
2
|
-
`)}async function po(e,t){let o=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await co(e,t);if(o){let a=document.createElement("style"),r=document.createTextNode(o);a.appendChild(r),e.firstChild?e.insertBefore(a,e.firstChild):e.appendChild(a)}}async function Va(e,t={}){let{width:o,height:a}=pt(e,t),r=await Ae(e,t,!0);return await po(r,t),await vt(r,t),ro(r,t),await Yt(r,o,a)}async function Fa(e,t={}){let{width:o,height:a}=pt(e,t),r=await Va(e,t),n=await ye(r),i=document.createElement("canvas"),s=i.getContext("2d"),l=t.pixelRatio||Kt(),c=t.canvasWidth||o,m=t.canvasHeight||a;return i.width=c*l,i.height=m*l,t.skipAutoScale||Xt(i),i.style.width=`${c}`,i.style.height=`${m}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(n,0,0,i.width,i.height),i}async function mo(e,t={}){return(await Fa(e,t)).toDataURL()}var ho=e=>new Promise((t,o)=>{mo(e,{cacheBust:!0}).then(a=>{a||o(new Error("No Screenshot available")),t(a)}).catch(a=>{console.error("the following error occurred while taking a screenshot of a DOMNode",a),o(new Error("Error taking screenshot"))})});var T=require("@salt-ds/core"),Z=require("react");var g=require("react/jsx-runtime"),D="saveLayoutPanel",Ge=`${D}-formField`,ka=["Group 1","Group 2","Group 3","Group 4","Group 5"],Da=["Value 1","Value 2","Value 3"],fo=["Value 1","Value 2","Value 3"],yt=e=>{let{defaultTitle:t="",onCancel:o,onSave:a,componentId:r}=e,[n,i]=(0,Z.useState)(t),[s,l]=(0,Z.useState)(""),[c,m]=(0,Z.useState)([]),[y,N]=(0,Z.useState)(fo[0]),[C,d]=(0,Z.useState)(),[u,h]=(0,Z.useState)(),[P]=Ee();(0,Z.useEffect)(()=>{r&&ho(document.getElementById(r)).then(f=>{d(f)}).catch(f=>{h(f.message)})},[r]);let W=()=>{a({name:n,group:s,screenshot:C!=null?C:"",user:P})},R=(0,Z.useMemo)(()=>C?(0,g.jsx)("img",{className:`${D}-screenshot`,src:C,alt:"screenshot of current layout"}):u?(0,g.jsx)(T.Text,{children:u}):(0,g.jsx)("div",{className:"spinner"}),[C,u]);return(0,g.jsxs)("div",{className:`${D}-panelContainer`,children:[(0,g.jsxs)("div",{className:`${D}-panelContent`,children:[(0,g.jsxs)("div",{className:`${D}-formContainer`,children:[(0,g.jsxs)(T.FormField,{className:Ge,children:[(0,g.jsx)(T.FormFieldLabel,{children:"Group"}),(0,g.jsx)(be.ComboBox,{source:ka,allowFreeText:!0,InputProps:{inputProps:{className:`${D}-inputText`,placeholder:"Select Group or Enter New Name",onChange:f=>l(f.target.value)}},width:"100%",onSelectionChange:(f,I)=>l(I||"")})]}),(0,g.jsxs)(T.FormField,{className:Ge,children:[(0,g.jsx)(T.FormFieldLabel,{children:"Layout Name"}),(0,g.jsx)(T.Input,{inputProps:{className:`${D}-inputText`,placeholder:"Enter Layout Name"},onChange:f=>i(f.target.value),value:n})]}),(0,g.jsxs)(T.FormField,{className:Ge,children:[(0,g.jsx)(T.FormFieldLabel,{children:"Some Layout Setting"}),(0,g.jsx)("div",{className:`${D}-settingsGroup`,children:Da.map((f,I)=>(0,g.jsx)(be.Checkbox,{onToggle:()=>m(S=>S.includes(f)?S.filter(A=>A!==f):[...S,f]),checked:c.includes(f),label:f},I))})]}),(0,g.jsxs)(T.FormField,{className:Ge,children:[(0,g.jsx)(T.FormFieldLabel,{children:"Some Layout Setting"}),(0,g.jsx)("div",{className:`${D}-settingsGroup`,children:fo.map((f,I)=>(0,g.jsx)(be.RadioButton,{onClick:()=>N(f),checked:y===f,label:f,groupName:"radioGroup"},I))})]})]}),(0,g.jsx)("div",{className:`${D}-screenshotContainer`,children:R})]}),(0,g.jsxs)("div",{className:`${D}-buttonsContainer`,children:[(0,g.jsx)(T.Button,{className:`${D}-cancelButton`,onClick:o,children:"Cancel"}),(0,g.jsx)(T.Button,{className:`${D}-saveButton`,onClick:W,disabled:n===""||s==="",children:"Save"})]})]})};var bo=require("@vuu-ui/vuu-ui-controls");var x=V(require("react")),Ie=require("@vuu-ui/vuu-layout"),yo=require("@vuu-ui/vuu-popups");var Qe={layout:{type:"Component",id:"loading-main",props:{}}},je={layout:{type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowCloseTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",variant:"primary"},preserve:!0,active:0},children:[{props:{id:"tab1",title:"Tab 1",className:"vuuShell-Placeholder"},type:"Placeholder"}]}};var ae=require("@vuu-ui/vuu-utils");var Xe=require("@vuu-ui/vuu-utils");var Aa="layouts/metadata",Ha="layouts/layouts",we,Ke=class{constructor(t){this.username=Ee()[0];this.metadataSaveLocation=`${Aa}/${this.username}`;this.layoutsSaveLocation=`${Ha}/${this.username}`;Dt(this,we,`api/vui/${this.username}`);this.loadLayouts=()=>new Promise(t=>{let o=(0,ae.getLocalEntity)(this.layoutsSaveLocation);t(o||[])});this.saveLayoutsWithMetadata=(t,o)=>{(0,ae.saveLocalEntity)(this.layoutsSaveLocation,t),(0,ae.saveLocalEntity)(this.metadataSaveLocation,o)};this.validateIds=async t=>Promise.all([this.validateId(t,"metadata").catch(o=>o.message),this.validateId(t,"layout").catch(o=>o.message)]).then(o=>{let a=o.filter(r=>r!==void 0).join("; ");if(a)throw new Error(a)});this.validateId=(t,o)=>new Promise((a,r)=>{(o==="metadata"?()=>this.loadMetadata():()=>this.loadLayouts())().then(i=>{switch(i.filter(l=>l.id===t).length){case 1:{a();break}case 0:{r(new Error(`No ${o} with ID ${t}`));break}default:r(new Error(`Non-unique ${o} with ID ${t}`))}})});t&&At(this,we,t)}createLayout(t,o){return new Promise(a=>{Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([r,n])=>{let i=(0,Xe.getUniqueId)(),s={...t,id:i,created:(0,Xe.formatDate)({date:"dd.mm.yyyy"})(new Date)};this.saveLayoutsWithMetadata([...r,{id:i,json:o}],[...n,s]),a(s)})})}updateLayout(t,o,a){return new Promise((r,n)=>{this.validateIds(t).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([i,s])=>{let l=i.map(m=>m.id===t?{...m,json:a}:m),c=s.map(m=>m.id===t?{...m,...o}:m);this.saveLayoutsWithMetadata(l,c),r()}).catch(i=>n(i))})}deleteLayout(t){return new Promise((o,a)=>{this.validateIds(t).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([r,n])=>{let i=r.filter(l=>l.id!==t),s=n.filter(l=>l.id!==t);this.saveLayoutsWithMetadata(i,s),o()}).catch(r=>a(r))})}loadLayout(t){return new Promise((o,a)=>{this.validateId(t,"layout").then(()=>this.loadLayouts()).then(r=>{let n=r.find(i=>i.id===t);n?o(n.json):a(new Error(`no layout found matching id ${t}`))}).catch(r=>a(r))})}loadMetadata(){return new Promise(t=>{let o=(0,ae.getLocalEntity)(this.metadataSaveLocation);t(o||[])})}loadApplicationJSON(){return new Promise(t=>{let o=(0,ae.getLocalEntity)(lt(this,we));t(o||je)})}saveApplicationJSON(t){return new Promise((o,a)=>{(0,ae.saveLocalEntity)(lt(this,we),t)?o():a(new Error("Application Json failed to save"))})}};we=new WeakMap;var He=require("react");var vo=require("react/jsx-runtime"),go=e=>{let{saveLayout:t}=ce(),o=(0,He.useCallback)(()=>{e(void 0)},[e]),a=(0,He.useCallback)(i=>{t(i),e(void 0)},[t,e]),[r,n]=(0,He.useMemo)(()=>[(i,s)=>{let l=i.split(" "),c=[];return l.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,l;return console.log("menu action",{action:i}),i.menuId==="save-layout"?(e({content:(0,vo.jsx)(yt,{onCancel:o,onSave:a,componentId:(s=i.options)==null?void 0:s.controlledComponentId,defaultTitle:(l=i.options)==null?void 0:l.controlledComponentTitle}),title:"Save Layout",hideCloseButton:!0}),!0):!1}],[o,a,e]);return{buildMenuOptions:r,handleMenuAction:n}};var xo=require("react/jsx-runtime"),xt,Re=()=>(xt===void 0&&(xt=new Ke),xt),Lt=x.default.createContext({getApplicationSettings:()=>{},layoutMetadata:[],saveLayout:()=>{},applicationJson:je,saveApplicationLayout:()=>{},saveApplicationSettings:()=>{},loadLayoutById:()=>{}}),Ra=(e,t)=>{var o;return((o=e.props)==null?void 0:o.title)!==void 0?e:{...e,props:{...e.props,title:t.name}}},Ia=e=>{let[t,o]=(0,x.useState)([]),[,a]=(0,x.useState)({}),r=(0,yo.useNotifications)(),n=(0,x.useRef)(Qe),i=(0,x.useCallback)((d,u=!0)=>{n.current=d,u&&a({})},[]),s=(0,x.useCallback)((d,u=!0)=>{i({...n.current,layout:d},u)},[i]),l=(0,x.useCallback)(d=>{i({...n.current,settings:{...n.current.settings,...d}},!1)},[i]);(0,x.useEffect)(()=>{let d=Re();d.loadMetadata().then(u=>{o(u)}).catch(u=>{r({type:"error",header:"Failed to Load Layouts",body:"Could not load list of available layouts"}),console.error("Error occurred while retrieving metadata",u)}),d.loadApplicationJSON().then(u=>{i(u)}).catch(u=>{r({type:"error",header:"Failed to Load Layout",body:"Could not load your latest view"}),console.error("Error occurred while retrieving application layout",u)})},[r,i]);let c=(0,x.useCallback)(d=>{(0,Ie.isLayoutJSON)(d)?(s(d,!1),Re().saveApplicationJSON(n.current)):console.error("Tried to save invalid application layout",d)},[s]),m=(0,x.useCallback)(d=>{let u=(0,Ie.resolveJSONPath)(n.current.layout,"#main-tabs.ACTIVE_CHILD");u&&(0,Ie.isLayoutJSON)(u)?Re().createLayout(d,Ra(u,d)).then(h=>{r({type:"success",header:"Layout Saved Successfully",body:`${h.name} saved successfully`}),o(P=>[...P,h])}).catch(h=>{r({type:"error",header:"Failed to Save Layout",body:`Failed to save layout ${d.name}`}),console.error("Error occurred while saving layout",h)}):(console.error("Tried to save invalid layout",u),r({type:"error",header:"Failed to Save Layout",body:"Cannot save invalid layout"}))},[r]),y=(0,x.useCallback)((d,u)=>{let{settings:h}=n.current;l(u?{...h,[u]:d}:d),Re().saveApplicationJSON(n.current)},[l]),N=(0,x.useCallback)(d=>{let{settings:u}=n.current;return d?u==null?void 0:u[d]:u},[]),C=(0,x.useCallback)(d=>{Re().loadLayout(d).then(u=>{var P,W;let{layout:h}=n.current;s({...h,children:(h.children||[]).concat(u),props:{...h.props,active:(W=(P=h.children)==null?void 0:P.length)!=null?W:0}})}).catch(u=>{r({type:"error",header:"Failed to Load Layout",body:"Failed to load the requested layout"}),console.error("Error occurred while loading layout",u)})},[r,s]);return(0,xo.jsx)(Lt.Provider,{value:{getApplicationSettings:N,layoutMetadata:t,saveLayout:m,applicationJson:n.current,saveApplicationLayout:c,saveApplicationSettings:y,loadLayoutById:C},children:e.children})},ce=()=>(0,x.useContext)(Lt);var X=require("react/jsx-runtime"),Ye="vuuLayoutTile",Lo=e=>{let{metadata:t,handleLoadLayout:o}=e;return(0,X.jsx)("div",{role:"listitem",children:(0,X.jsxs)("div",{className:`${Ye}-layoutTile`,role:"button",onClick:()=>o(t==null?void 0:t.id),children:[(0,X.jsx)("img",{className:`${Ye}-screenshot`,src:t==null?void 0:t.screenshot}),(0,X.jsxs)("div",{children:[(0,X.jsx)("div",{className:`${Ye}-layoutName`,children:t==null?void 0:t.name}),(0,X.jsx)("div",{className:`${Ye}-layoutDetails`,children:(0,X.jsx)("div",{children:`${t==null?void 0:t.user}, ${t==null?void 0:t.created}`})})]})]},t==null?void 0:t.id)})};var q=require("react/jsx-runtime"),bt="vuuLayoutList",wt=e=>{let{layoutMetadata:t,loadLayoutById:o}=ce(),a=n=>{n&&o(n)},r=t.reduce((n,i)=>n[i.group]?{...n,[i.group]:[...n[i.group],i]}:{...n,[i.group]:[i]},{});return(0,q.jsxs)("div",{className:bt,...e,role:"listbox","aria-label":"my layouts",children:[(0,q.jsx)("div",{className:`${bt}-header`,children:"My Layouts"}),(0,q.jsx)(bo.List,{height:"auto",source:Object.entries(r),ListItem:({item:n})=>{if(!n)return(0,q.jsx)(q.Fragment,{});let[i,s]=n;return(0,q.jsxs)("div",{role:"list","aria-label":i,children:[(0,q.jsx)("div",{className:`${bt}-groupName`,children:i}),s.map(l=>(0,q.jsx)(Lo,{metadata:l,handleLoadLayout:a},l.id))]})}})]})};var wo=require("@vuu-ui/vuu-icons"),at=require("@vuu-ui/vuu-layout"),de=require("@vuu-ui/vuu-ui-controls"),Co=require("@vuu-ui/vuu-utils"),ot=V(require("clsx")),Se=require("react");var et=require("@vuu-ui/vuu-layout");var ne=require("react/jsx-runtime"),Ct="vuuFeatureList",tt=({features:e,title:t="VUU TABLES",...o})=>{let a={},r={height:"100%"};return(0,ne.jsxs)("div",{...o,className:Ct,children:[(0,ne.jsx)("div",{className:`${Ct}-header`,children:t}),(0,ne.jsx)("div",{className:`${Ct}-content`,children:(0,ne.jsx)(et.Palette,{orientation:"vertical",ListProps:r,ViewProps:a,children:e.map((n,i)=>(0,ne.jsx)(et.PaletteItem,{closeable:!0,label:n.title,resizeable:!0,resize:"defer",header:!0,children:(0,ne.jsx)(ke,{...n})},i))})})]})};var b=require("react/jsx-runtime"),Ce="vuuLeftNav",$a=(e,t)=>e===0?t?"menu-full":"menu-icons":t?"menu-full-content":"menu-icons-content",Ba=e=>{let t=(0,at.useLayoutProviderDispatch)(),[o]=(0,Co.useThemeAttributes)(),{"data-path":a,defaultExpanded:r=!0,defaultActiveTabIndex:n=0,features:i,onActiveChange:s,onTogglePrimaryMenu:l,sizeCollapsed:c=80,sizeContent:m=300,sizeExpanded:y=240,style:N,tableFeatures:C,...d}=e,[u,h]=(0,Se.useState)({activeTabIndex:n,expanded:r}),P=(0,Se.useCallback)((S,A)=>S===0?A?y:c:A?y+m:c+m,[c,m,y]),W=(0,Se.useCallback)(S=>{let{activeTabIndex:A,expanded:G}=u;if(h({activeTabIndex:S,expanded:G}),S===0||A===0){let L=P(S,G);t({type:"layout-resize",path:"#vuu-side-panel",size:L})}s==null||s(S)},[t,P,u,s]),R=$a(u.activeTabIndex,u.expanded),f=(0,Se.useCallback)(()=>{let{activeTabIndex:S,expanded:A}=u,G=!A;h({activeTabIndex:S,expanded:G}),t({type:"layout-resize",path:"#vuu-side-panel",size:P(S,G)}),l==null||l(G)},[t,P,u,l]),I={...N,"--nav-menu-collapsed-width":`${c}px`,"--nav-menu-expanded-width":`${y}px`,"--nav-menu-content-width":`${m}px`};return(0,b.jsxs)("div",{...d,className:(0,ot.default)(Ce,`${Ce}-${R}`),style:I,children:[(0,b.jsxs)("div",{className:(0,ot.default)(`${Ce}-menu-primary`,o),"data-mode":"dark",children:[(0,b.jsx)("div",{className:"vuuLeftNav-logo",children:(0,b.jsx)(wo.VuuLogo,{})}),(0,b.jsx)("div",{className:`${Ce}-main`,children:(0,b.jsxs)(de.Tabstrip,{activeTabIndex:u.activeTabIndex,animateSelectionThumb:!1,className:`${Ce}-Tabstrip`,onActiveChange:W,orientation:"vertical",children:[(0,b.jsx)(de.Tab,{"data-icon":"demo",label:"DEMO"}),(0,b.jsx)(de.Tab,{"data-icon":"features",label:"VUU FEATURES"}),(0,b.jsx)(de.Tab,{"data-icon":"tables",label:"VUU TABLES"}),(0,b.jsx)(de.Tab,{"data-icon":"layouts",label:"MY LAYOUTS"})]})}),(0,b.jsx)("div",{className:"vuuLeftNav-buttonBar",children:(0,b.jsx)("button",{className:(0,ot.default)("vuuLeftNav-toggleButton",{"vuuLeftNav-toggleButton-open":R.startsWith("menu-full"),"vuuLeftNav-toggleButton-closed":R.startsWith("menu-icons")}),"data-icon":R.startsWith("menu-full")?"chevron-left":"chevron-right",onClick:f})})]}),(0,b.jsxs)(at.Stack,{active:u.activeTabIndex-1,className:`${Ce}-menu-secondary`,showTabs:!1,children:[(0,b.jsx)(tt,{features:i,title:"VUU FEATURES"}),(0,b.jsx)(tt,{features:C,title:"VUU TABLES"}),(0,b.jsx)("div",{className:"vuuLeftNav-drawer",children:(0,b.jsx)(wt,{})})]})]})};var Mo=require("@vuu-ui/vuu-data-remote"),z=require("@vuu-ui/vuu-utils"),$e=require("@salt-ds/core"),St=V(require("clsx")),w=require("react");var H=require("react/jsx-runtime"),Y="vuuSessionEditingForm",So=(e,t)=>{let o=e.find(a=>a.name===t);if(o)return o;throw Error(`SessionEditingForm, no field '${t}' found`)},To=e=>{let{dataset:{field:t},value:o}=e.target;if(t===void 0)throw Error("SessionEditingForm, form field has no field name");return[t,o]},ee={uninitialised:0,unchanged:1,changed:2,invalid:3};function Po(e,t,o=!1){switch(t){case"int":case"long":{let a=parseInt(e,10);if((0,z.isValidNumber)(a))return a;if(o)throw Error("SessionEditingForm getTypedValue");return}case"double":{let a=parseFloat(e);return(0,z.isValidNumber)(a)?a:void 0}case"boolean":return e==="true";default:return e}}var Oa=(e,t)=>{if(e)return e;if(t)return new Mo.VuuDataSource({bufferSize:0,table:t.table,columns:t.columns.map(o=>o.name)});throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided")},Ua=({className:e,config:{fields:t,key:o},dataSource:a,id:r,onClose:n,schema:i,...s})=>{let[l,c]=(0,w.useState)(),[m,y]=(0,w.useState)(""),N=(0,w.useRef)(null),C=(0,w.useRef)(),d=(0,w.useRef)(ee.uninitialised),u=(0,w.useMemo)(()=>{let p=B=>{if($){let O={};for(let te of u.columns)O[te]=B[$[te]];d.current===ee.uninitialised&&(d.current=ee.unchanged,C.current=O),c(O)}},L=Oa(a,i),$=(0,z.buildColumnMap)(L.columns);return L.subscribe({range:{from:0,to:5}},B=>{B.type==="viewport-update"&&B.rows&&(d.current===ee.uninitialised?p(B.rows[0]):console.log("what do we do with server updates"))}),L},[a,i]),h=(0,$e.useIdMemo)(r),P=(0,w.useCallback)(p=>{let[L,$]=To(p),{type:B}=So(t,L),O=Po($,B);c((te={})=>{let U={...te,[L]:O},$o=(0,z.shallowEquals)(U,C.current);return d.current=$o?ee.unchanged:O!==void 0?ee.changed:ee.invalid,U})},[t]),W=(0,w.useCallback)(p=>{let[L,$]=To(p),{type:B}=So(t,L),O=l==null?void 0:l[o],te=Po($,B,!0);typeof O=="string"&&u.menuRpcCall({rowKey:O,field:L,value:te,type:"VP_EDIT_CELL_RPC"})},[u,t,o,l]),R=(0,w.useCallback)(p=>{typeof p=="object"&&p!==null&&"type"in p&&p.type==="CLOSE_DIALOG_ACTION"&&n()},[n]),f=(0,w.useCallback)(async()=>{let p=await u.menuRpcCall({type:"VP_EDIT_SUBMIT_FORM_RPC"});(0,z.isErrorResponse)(p)?y(p.error):(0,z.hasAction)(p)&&R(p.action)},[R,u]),I=(0,w.useCallback)(p=>{p.key==="Enter"&&d.current===ee.changed&&f()},[f]),S=(0,w.useCallback)(()=>{n()},[n]),A=p=>{var $;let L=String(($=l==null?void 0:l[p.name])!=null?$:"");return p.readonly||p.name===o?(0,H.jsx)("div",{className:`${Y}-fieldValue vuuReadOnly`,children:L}):(0,H.jsx)("input",{className:`${Y}-fieldValue`,"data-field":p.name,onBlur:W,onChange:P,type:"text",value:L,id:`${h}-input-${p.name}`})};(0,w.useEffect)(()=>{if(N.current){let p=N.current.querySelector("input");p&&setTimeout(()=>{p.focus(),p.select()},100)}},[]),(0,w.useEffect)(()=>()=>{u&&u.unsubscribe()},[u]);let G=d.current===ee.changed;return(0,H.jsxs)("div",{...s,className:(0,St.default)(Y,e),children:[m?(0,H.jsx)("div",{className:`${Y}-errorBanner`,"data-icon":"error",title:m,children:"Error, edit(s) not saved"}):void 0,(0,H.jsx)("div",{className:`${Y}-content`,ref:N,onKeyDown:I,children:t.map(p=>{var L;return(0,H.jsxs)("div",{className:`${Y}-field`,children:[(0,H.jsx)("label",{className:(0,St.default)(`${Y}-fieldLabel`,{[`${Y}-required`]:p.required}),htmlFor:`${h}-input-${p.name}`,children:(L=p==null?void 0:p.label)!=null?L:p.description}),A(p)]},p.name)})}),(0,H.jsxs)("div",{className:`${Y}-buttonbar salt-theme salt-density-high`,children:[(0,H.jsx)($e.Button,{type:"submit",variant:"cta",disabled:!G,onClick:f,children:"Submit"}),(0,H.jsx)($e.Button,{variant:"secondary",onClick:S,children:"Cancel"})]})]})};var Ao=require("@vuu-ui/vuu-data-remote"),Pe=require("@vuu-ui/vuu-layout"),rt=require("@vuu-ui/vuu-popups"),Me=require("@vuu-ui/vuu-utils"),Ho=V(require("clsx")),_=require("react");var Eo=require("@salt-ds/core"),Tt=V(require("clsx")),nt=require("react"),Te=require("@vuu-ui/vuu-layout");var re=require("react/jsx-runtime"),J="vuuContextPanel",Pt=({className:e,expanded:t=!1,content:o,overlay:a=!1,title:r})=>{let n=(0,Te.useLayoutProviderDispatch)(),i=(0,nt.useCallback)(()=>{n({path:"#context-panel",propName:"expanded",propValue:!1,type:"set-prop"})},[n]),s=(0,Tt.default)(J,e,{[`${J}-expanded`]:t,[`${J}-inline`]:a!==!0,[`${J}-overlay`]:a}),l=(0,nt.useMemo)(()=>o&&t?(0,Te.layoutFromJson)(o,"context-0"):null,[o,t]);return(0,re.jsx)("div",{className:(0,Tt.default)(J,s,{[`${J}-expanded`]:t}),children:(0,re.jsxs)(Te.View,{className:`${J}-inner`,header:!1,id:"context-panel",children:[(0,re.jsxs)("div",{className:`${J}-header`,children:[(0,re.jsx)("h2",{className:`${J}-title`,children:r}),(0,re.jsx)(Eo.Button,{className:`${J}-close`,"data-icon":"close",onClick:i,variant:"secondary"})]}),(0,re.jsx)("div",{className:`${J}-content`,children:l})]})})};var Be=require("@vuu-ui/vuu-layout");var No=require("react"),Vo=V(require("clsx"));var Fo=require("react/jsx-runtime"),Za="vuuShellSidePanel",Mt=({children:e,open:t=!0,sizeClosed:o=90,sizeOpen:a=200,style:r,...n})=>{let i=(0,No.useMemo)(()=>({...r,"--shell-left-nav-size":t?`${a}px`:`${o}px`}),[t,o,a,r]);return(0,Fo.jsx)("div",{...n,className:(0,Vo.default)(Za),style:i,children:e})};var pe=require("react/jsx-runtime"),ko=({appHeader:e,LeftSidePanelProps:t})=>(0,pe.jsxs)(Be.Flexbox,{className:"App",style:{flexDirection:"row",height:"100%",width:"100%"},children:[(0,pe.jsx)(Mt,{...t,id:"vuu-side-panel"}),(0,pe.jsxs)(Be.Flexbox,{className:"vuuShell-content",style:{flex:1,flexDirection:"column"},children:[e,(0,pe.jsx)(Be.DraggableLayout,{dropTarget:!0,style:{flex:1}},"main-content")]}),(0,pe.jsx)(Pt,{id:"context-panel",overlay:!0})]});var j=require("@vuu-ui/vuu-layout"),he=require("react"),me=require("react/jsx-runtime"),Do=({appHeader:e,LeftSidePanelProps:t})=>{let o=(0,he.useRef)(null),[a,r]=(0,he.useState)(!0),n=(0,he.useCallback)(s=>{var c;let l=s.target;(c=o.current)!=null&&c.contains(l)||r(!a)},[a]),i=(0,he.useCallback)(s=>{let l=[];return l.push((0,me.jsx)(j.Drawer,{onClick:n,open:a,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:(0,me.jsx)(j.View,{className:"vuuShell-palette",id:"vw-app-palette",ref:o,style:{height:"100%"},children:s},"app-palette")},"left-panel")),l},[n,a]);return(0,me.jsxs)(j.Flexbox,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[e,(0,me.jsx)(j.DockLayout,{style:{flex:1},children:i(t==null?void 0:t.children).concat((0,me.jsx)(j.DraggableLayout,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})};var Et=({leftSidePanelLayout:e="inlay",...t})=>(e==="inlay"?Do:ko)(t);var fe=require("react/jsx-runtime");typeof Pe.StackLayout!="function"&&console.warn("StackLayout module not loaded, will be unsbale to deserialize from layout JSON");var{error:Nt}=(0,Me.logger)("Shell"),qa={},za=({LayoutProps:e,LeftSidePanelProps:t=qa,children:o,className:a,leftSidePanelLayout:r,loginUrl:n,saveLocation:i,saveUrl:s,serverUrl:l,user:c,...m})=>{let y=(0,_.useRef)(null),{dialog:N,setDialogState:C}=(0,rt.useDialog)(),d=(0,_.useRef)("latest"),{applicationJson:u,saveApplicationLayout:h,loadLayoutById:P}=ce(),{buildMenuOptions:W,handleMenuAction:R}=go(C),[f,I]=(0,_.useState)("connected"),S=(0,_.useCallback)(U=>{try{h(U)}catch{Nt==null||Nt("Failed to save layout")}},[h]),A=(0,_.useCallback)(U=>{y.current&&(y.current.dataset.mode=U)},[]),G=(0,_.useCallback)(U=>{d.current=U,P(U)},[P]);(0,_.useMemo)(async()=>{if(l&&c.token){let U=await(0,Ao.connectToServer)({authToken:c.token,url:l,username:c.username});I(U)}},[l,c.token,c.username]);let[p,L,$]=(0,Me.useThemeAttributes)(),B=(0,Ho.default)("vuuShell",a,p,L),O=u===Qe,te=Et({LeftSidePanelProps:t,leftSidePanelLayout:r,appHeader:(0,fe.jsx)(dt,{layoutId:d.current,loginUrl:n,user:c,onNavigate:G,onSwitchTheme:A})});return f==="rejected"&&console.log("game over, no connection to server"),O?null:(0,fe.jsx)(Me.ThemeProvider,{children:(0,fe.jsxs)(rt.ContextMenuProvider,{menuActionHandler:R,menuBuilder:W,children:[(0,fe.jsx)(Pe.LayoutProvider,{...e,layout:u.layout,onLayoutChange:S,children:(0,fe.jsx)(Pe.DraggableLayout,{className:B,"data-mode":$,ref:y,...m,children:te})}),o||N]})})};var Ja=e=>e==="*",_a=e=>typeof e=="object"&&typeof e.module=="string"&&typeof e.table=="string";var st=require("react"),it=require("react/jsx-runtime"),Wa={},Vt=(0,st.createContext)(Wa),Ga=({children:e,context:t,inheritedContext:o})=>{let a={...o,...t};return(0,it.jsx)(Vt.Provider,{value:a,children:e})},Qa=({children:e,value:t})=>(0,it.jsx)(Vt.Consumer,{children:o=>(0,it.jsx)(Ga,{context:t,inheritedContext:o,children:e})}),ja=()=>(0,st.useContext)(Vt);var Ro=V(require("clsx")),ge=require("@salt-ds/core"),Io=require("react");var Oe=require("react/jsx-runtime"),Ka="vuuThemeSwitch",Xa=({className:e,defaultMode:t,mode:o,onChange:a,...r})=>{let[n,i]=(0,ge.useControlled)({controlled:o,default:t!=null?t:"light",name:"ThemeSwitch",state:"mode"}),s=(0,Io.useCallback)(c=>{let{value:m}=c.target;i(m),a(m)},[a,i]),l=(0,Ro.default)(Ka,e);return(0,Oe.jsxs)(ge.ToggleButtonGroup,{className:l,...r,onChange:s,value:n,children:[(0,Oe.jsx)(ge.ToggleButton,{"aria-label":"alert","data-icon":"light",value:"light"}),(0,Oe.jsx)(ge.ToggleButton,{"aria-label":"home","data-icon":"dark",value:"dark"})]})};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __accessCheck = (obj, member, msg) => {
|
|
30
|
+
if (!member.has(obj))
|
|
31
|
+
throw TypeError("Cannot " + msg);
|
|
32
|
+
};
|
|
33
|
+
var __privateGet = (obj, member, getter) => {
|
|
34
|
+
__accessCheck(obj, member, "read from private field");
|
|
35
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
36
|
+
};
|
|
37
|
+
var __privateAdd = (obj, member, value) => {
|
|
38
|
+
if (member.has(obj))
|
|
39
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
40
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
41
|
+
};
|
|
42
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
43
|
+
__accessCheck(obj, member, "write to private field");
|
|
44
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
45
|
+
return value;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/index.ts
|
|
49
|
+
var src_exports = {};
|
|
50
|
+
__export(src_exports, {
|
|
51
|
+
AppHeader: () => AppHeader,
|
|
52
|
+
ConnectionStatusIcon: () => ConnectionStatusIcon,
|
|
53
|
+
ContextPanel: () => ContextPanel,
|
|
54
|
+
Feature: () => Feature,
|
|
55
|
+
FeatureList: () => FeatureList,
|
|
56
|
+
LayoutList: () => LayoutList,
|
|
57
|
+
LayoutManagementContext: () => LayoutManagementContext,
|
|
58
|
+
LayoutManagementProvider: () => LayoutManagementProvider,
|
|
59
|
+
LeftNav: () => LeftNav,
|
|
60
|
+
LoginPanel: () => LoginPanel,
|
|
61
|
+
SaveLayoutPanel: () => SaveLayoutPanel,
|
|
62
|
+
SessionEditingForm: () => SessionEditingForm,
|
|
63
|
+
Shell: () => Shell,
|
|
64
|
+
ShellContextProvider: () => ShellContextProvider,
|
|
65
|
+
SidePanel: () => SidePanel,
|
|
66
|
+
ThemeSwitch: () => ThemeSwitch,
|
|
67
|
+
getAuthDetailsFromCookies: () => getAuthDetailsFromCookies,
|
|
68
|
+
getAuthModeFromCookies: () => getAuthModeFromCookies,
|
|
69
|
+
isTableSchema: () => isTableSchema,
|
|
70
|
+
isWildcardSchema: () => isWildcardSchema,
|
|
71
|
+
logout: () => logout,
|
|
72
|
+
redirectToLogin: () => redirectToLogin,
|
|
73
|
+
useLayoutManager: () => useLayoutManager,
|
|
74
|
+
useShellContext: () => useShellContext,
|
|
75
|
+
useShellLayout: () => useShellLayout
|
|
76
|
+
});
|
|
77
|
+
module.exports = __toCommonJS(src_exports);
|
|
78
|
+
|
|
79
|
+
// src/app-header/AppHeader.tsx
|
|
80
|
+
var import_react3 = require("react");
|
|
81
|
+
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
82
|
+
var import_clsx2 = __toESM(require("clsx"));
|
|
83
|
+
|
|
84
|
+
// src/login/LoginPanel.tsx
|
|
85
|
+
var import_react2 = require("react");
|
|
86
|
+
var import_core = require("@salt-ds/core");
|
|
87
|
+
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
88
|
+
|
|
89
|
+
// src/login/VuuLogo.tsx
|
|
90
|
+
var import_react = require("react");
|
|
91
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
92
|
+
var VuuLogo = () => {
|
|
93
|
+
const logo = (0, import_react.useMemo)(
|
|
94
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
95
|
+
"svg",
|
|
96
|
+
{
|
|
97
|
+
width: "184",
|
|
98
|
+
height: "90",
|
|
99
|
+
viewBox: "0 0 184 90",
|
|
100
|
+
fill: "none",
|
|
101
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { clipPath: "url(#clip0_1173_59965)", children: [
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
"path",
|
|
106
|
+
{
|
|
107
|
+
d: "M77.0775 31.1019L69.4572 15.1795L66.3997 13.7093L47.6353 44.165L75.7224 61.2361L81.8124 51.2694L77.0775 31.1019Z",
|
|
108
|
+
fill: "url(#paint0_linear_1173_59965)"
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
+
"path",
|
|
113
|
+
{
|
|
114
|
+
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",
|
|
115
|
+
fill: "url(#paint1_linear_1173_59965)"
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
|
+
"path",
|
|
120
|
+
{
|
|
121
|
+
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",
|
|
122
|
+
fill: "#F37880"
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { opacity: "0.86", children: [
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
+
"path",
|
|
128
|
+
{
|
|
129
|
+
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",
|
|
130
|
+
fill: "white"
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
|
+
"path",
|
|
135
|
+
{
|
|
136
|
+
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",
|
|
137
|
+
fill: "white"
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
141
|
+
"path",
|
|
142
|
+
{
|
|
143
|
+
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",
|
|
144
|
+
fill: "white"
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] })
|
|
148
|
+
] }),
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
+
"path",
|
|
151
|
+
{
|
|
152
|
+
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",
|
|
153
|
+
fill: "white"
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
157
|
+
"path",
|
|
158
|
+
{
|
|
159
|
+
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",
|
|
160
|
+
fill: "white"
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
164
|
+
"path",
|
|
165
|
+
{
|
|
166
|
+
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",
|
|
167
|
+
fill: "white"
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("defs", { children: [
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
172
|
+
"linearGradient",
|
|
173
|
+
{
|
|
174
|
+
id: "paint0_linear_1173_59965",
|
|
175
|
+
x1: "47.6353",
|
|
176
|
+
y1: "37.4727",
|
|
177
|
+
x2: "81.8124",
|
|
178
|
+
y2: "37.4727",
|
|
179
|
+
gradientUnits: "userSpaceOnUse",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { stopColor: "#4906A5" }),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { offset: "1", stopColor: "#D3423A" })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
187
|
+
"linearGradient",
|
|
188
|
+
{
|
|
189
|
+
id: "paint1_linear_1173_59965",
|
|
190
|
+
x1: "0.0670626",
|
|
191
|
+
y1: "45.0017",
|
|
192
|
+
x2: "82.5916",
|
|
193
|
+
y2: "45.0017",
|
|
194
|
+
gradientUnits: "userSpaceOnUse",
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { stopColor: "#7C06A5" }),
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { offset: "1", stopColor: "#D3423A" })
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("clipPath", { id: "clip0_1173_59965", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
202
|
+
"rect",
|
|
203
|
+
{
|
|
204
|
+
width: "85",
|
|
205
|
+
height: "90",
|
|
206
|
+
fill: "white",
|
|
207
|
+
transform: "translate(0.0670471)"
|
|
208
|
+
}
|
|
209
|
+
) })
|
|
210
|
+
] })
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
[]
|
|
215
|
+
);
|
|
216
|
+
return logo;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/login/LoginPanel.tsx
|
|
220
|
+
var import_clsx = __toESM(require("clsx"));
|
|
221
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
222
|
+
var classBase = "vuuLoginPanel";
|
|
223
|
+
var LoginPanel = ({
|
|
224
|
+
appName = "Demo App",
|
|
225
|
+
className,
|
|
226
|
+
requirePassword = true,
|
|
227
|
+
onSubmit,
|
|
228
|
+
...htmlAttributes
|
|
229
|
+
}) => {
|
|
230
|
+
const [username, setUserName] = (0, import_react2.useState)("");
|
|
231
|
+
const [password, setPassword] = (0, import_react2.useState)("");
|
|
232
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
233
|
+
const login = () => {
|
|
234
|
+
onSubmit(username, password);
|
|
235
|
+
};
|
|
236
|
+
const handleUsername = (evt) => {
|
|
237
|
+
setUserName(evt.target.value);
|
|
238
|
+
};
|
|
239
|
+
const handlePassword = (evt) => {
|
|
240
|
+
setPassword(evt.target.value);
|
|
241
|
+
};
|
|
242
|
+
const handleCommitName = (0, import_react2.useCallback)(() => {
|
|
243
|
+
if (!requirePassword) {
|
|
244
|
+
onSubmit(username);
|
|
245
|
+
}
|
|
246
|
+
}, [onSubmit, requirePassword, username]);
|
|
247
|
+
const handleCommitPassword = (0, import_react2.useCallback)(() => {
|
|
248
|
+
if (username) {
|
|
249
|
+
onSubmit(username, password);
|
|
250
|
+
}
|
|
251
|
+
}, [onSubmit, password, username]);
|
|
252
|
+
const dataIsValid = username.trim() !== "" && (requirePassword === false || password.trim() !== "");
|
|
253
|
+
(0, import_react2.useEffect)(() => {
|
|
254
|
+
var _a;
|
|
255
|
+
console.log(`inputRef`, {
|
|
256
|
+
input: inputRef.current
|
|
257
|
+
});
|
|
258
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
259
|
+
}, []);
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ...htmlAttributes, className: (0, import_clsx.default)(classBase, className), children: [
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `${classBase}-branding`, children: [
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(VuuLogo, {}),
|
|
263
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `${classBase}-appName`, children: appName })
|
|
264
|
+
] }),
|
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `${classBase}-form`, children: [
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `${classBase}-title`, children: "Welcome Back" }),
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core.FormField, { children: [
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.FormFieldLabel, { children: "Username" }),
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
270
|
+
import_vuu_ui_controls.VuuInput,
|
|
271
|
+
{
|
|
272
|
+
value: username,
|
|
273
|
+
id: "text-username",
|
|
274
|
+
inputRef,
|
|
275
|
+
onChange: handleUsername,
|
|
276
|
+
onCommit: handleCommitName
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] }),
|
|
280
|
+
requirePassword ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core.FormField, { children: [
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.FormFieldLabel, { children: "Password" }),
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
283
|
+
import_vuu_ui_controls.VuuInput,
|
|
284
|
+
{
|
|
285
|
+
className: `${classBase}-password`,
|
|
286
|
+
inputProps: {
|
|
287
|
+
type: "password"
|
|
288
|
+
},
|
|
289
|
+
value: password,
|
|
290
|
+
id: "text-password",
|
|
291
|
+
onChange: handlePassword,
|
|
292
|
+
onCommit: handleCommitPassword,
|
|
293
|
+
endAdornment: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-icon": "eye", style: { cursor: "pointer" } })
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
] }) : null,
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
298
|
+
import_core.Button,
|
|
299
|
+
{
|
|
300
|
+
className: `${classBase}-login`,
|
|
301
|
+
disabled: !dataIsValid,
|
|
302
|
+
onClick: login,
|
|
303
|
+
variant: "cta",
|
|
304
|
+
children: "Login"
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
] })
|
|
308
|
+
] });
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// src/login/login-utils.ts
|
|
312
|
+
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
313
|
+
var getAuthModeFromCookies = () => {
|
|
314
|
+
const mode = (0, import_vuu_utils.getCookieValue)("vuu-auth-mode");
|
|
315
|
+
return mode != null ? mode : "";
|
|
316
|
+
};
|
|
317
|
+
var getAuthDetailsFromCookies = () => {
|
|
318
|
+
const username = (0, import_vuu_utils.getCookieValue)("vuu-username");
|
|
319
|
+
const token = (0, import_vuu_utils.getCookieValue)("vuu-auth-token");
|
|
320
|
+
return [username, token];
|
|
321
|
+
};
|
|
322
|
+
var getDefaultLoginUrl = () => {
|
|
323
|
+
const authMode = getAuthModeFromCookies();
|
|
324
|
+
return authMode === "login" ? "login.html" : "demo.html";
|
|
325
|
+
};
|
|
326
|
+
var redirectToLogin = (loginUrl = getDefaultLoginUrl()) => {
|
|
327
|
+
window.location.href = loginUrl;
|
|
328
|
+
};
|
|
329
|
+
var logout = (loginUrl) => {
|
|
330
|
+
document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
331
|
+
document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
332
|
+
redirectToLogin(loginUrl);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/app-header/AppHeader.tsx
|
|
336
|
+
var import_core2 = require("@salt-ds/core");
|
|
337
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
338
|
+
var classBase2 = "vuuAppHeader";
|
|
339
|
+
var AppHeader = ({
|
|
340
|
+
className: classNameProp,
|
|
341
|
+
layoutId,
|
|
342
|
+
loginUrl,
|
|
343
|
+
onNavigate,
|
|
344
|
+
onSwitchTheme,
|
|
345
|
+
themeMode: _,
|
|
346
|
+
user,
|
|
347
|
+
...htmlAttributes
|
|
348
|
+
}) => {
|
|
349
|
+
const className = (0, import_clsx2.default)(classBase2, classNameProp);
|
|
350
|
+
const handleLogout = (0, import_react3.useCallback)(() => {
|
|
351
|
+
logout(loginUrl);
|
|
352
|
+
}, [loginUrl]);
|
|
353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
354
|
+
import_vuu_ui_controls2.Toolbar,
|
|
355
|
+
{
|
|
356
|
+
alignItems: "end",
|
|
357
|
+
className,
|
|
358
|
+
showSeparators: true,
|
|
359
|
+
...htmlAttributes,
|
|
360
|
+
children: [
|
|
361
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Button, { className: `${classBase2}-menuItem`, variant: "secondary", children: "Help" }),
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core2.Button, { className: `${classBase2}-menuItem`, variant: "secondary", children: [
|
|
363
|
+
"History ",
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-icon": "history" })
|
|
365
|
+
] }),
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core2.Button, { className: `${classBase2}-menuItem`, variant: "secondary", children: [
|
|
367
|
+
"View ",
|
|
368
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-icon": "settings" })
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
371
|
+
import_core2.Button,
|
|
372
|
+
{
|
|
373
|
+
className: `${classBase2}-menuItem`,
|
|
374
|
+
onClick: handleLogout,
|
|
375
|
+
variant: "secondary",
|
|
376
|
+
children: "Log out"
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
]
|
|
380
|
+
}
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// src/connection-status/ConnectionStatusIcon.tsx
|
|
385
|
+
var import_react4 = __toESM(require("react"));
|
|
386
|
+
var import_clsx3 = __toESM(require("clsx"));
|
|
387
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
388
|
+
var ConnectionStatusIcon = ({
|
|
389
|
+
connectionStatus,
|
|
390
|
+
className,
|
|
391
|
+
element = "span",
|
|
392
|
+
...props
|
|
393
|
+
}) => {
|
|
394
|
+
const [classBase12, setClassBase] = (0, import_react4.useState)("vuuConnectingStatus");
|
|
395
|
+
(0, import_react4.useEffect)(() => {
|
|
396
|
+
switch (connectionStatus) {
|
|
397
|
+
case "connected":
|
|
398
|
+
case "reconnected":
|
|
399
|
+
setClassBase("vuuActiveStatus");
|
|
400
|
+
break;
|
|
401
|
+
case "connecting":
|
|
402
|
+
setClassBase("vuuConnectingStatus");
|
|
403
|
+
break;
|
|
404
|
+
case "disconnected":
|
|
405
|
+
setClassBase("vuuDisconnectedStatus");
|
|
406
|
+
break;
|
|
407
|
+
default:
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}, [connectionStatus]);
|
|
411
|
+
const statusIcon = import_react4.default.createElement(element, {
|
|
412
|
+
...props,
|
|
413
|
+
className: (0, import_clsx3.default)("vuuStatus vuuIcon", classBase12, className)
|
|
414
|
+
});
|
|
415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "vuuStatus-container salt-theme", children: [
|
|
416
|
+
statusIcon,
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "vuuStatus-text", children: [
|
|
418
|
+
"Status: ",
|
|
419
|
+
connectionStatus.toUpperCase()
|
|
420
|
+
] })
|
|
421
|
+
] }) });
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// src/feature/Feature.tsx
|
|
425
|
+
var import_react6 = __toESM(require("react"));
|
|
426
|
+
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
427
|
+
|
|
428
|
+
// src/feature/FeatureErrorBoundary.tsx
|
|
429
|
+
var import_react5 = __toESM(require("react"));
|
|
430
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
431
|
+
var FeatureErrorBoundary = class extends import_react5.default.Component {
|
|
432
|
+
constructor(props) {
|
|
433
|
+
super(props);
|
|
434
|
+
this.state = { errorMessage: null };
|
|
435
|
+
}
|
|
436
|
+
static getDerivedStateFromError(error2) {
|
|
437
|
+
return { errorMessage: error2.message };
|
|
438
|
+
}
|
|
439
|
+
componentDidCatch(error2, errorInfo) {
|
|
440
|
+
console.log(`error creating component at ${this.props.url}`);
|
|
441
|
+
console.log(error2, errorInfo);
|
|
442
|
+
}
|
|
443
|
+
render() {
|
|
444
|
+
if (this.state.errorMessage) {
|
|
445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h1", { children: "An error occured while creating component." }),
|
|
447
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: this.state.errorMessage })
|
|
448
|
+
] });
|
|
449
|
+
}
|
|
450
|
+
return this.props.children;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// src/feature/Loader.tsx
|
|
455
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
456
|
+
var Loader = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hwLoader" });
|
|
457
|
+
|
|
458
|
+
// src/feature/css-module-loader.ts
|
|
459
|
+
var importCSS = async (path) => {
|
|
460
|
+
const container = new CSSStyleSheet();
|
|
461
|
+
return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// src/feature/Feature.tsx
|
|
465
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
466
|
+
var componentsMap = /* @__PURE__ */ new Map();
|
|
467
|
+
var useCachedFeature = (url) => {
|
|
468
|
+
(0, import_react6.useEffect)(
|
|
469
|
+
() => () => {
|
|
470
|
+
componentsMap.delete(url);
|
|
471
|
+
},
|
|
472
|
+
[url]
|
|
473
|
+
);
|
|
474
|
+
if (!componentsMap.has(url)) {
|
|
475
|
+
componentsMap.set(
|
|
476
|
+
url,
|
|
477
|
+
import_react6.default.lazy(() => import(
|
|
478
|
+
/* @vite-ignore */
|
|
479
|
+
url
|
|
480
|
+
))
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
const lazyFeature = componentsMap.get(url);
|
|
484
|
+
if (!lazyFeature) {
|
|
485
|
+
throw Error(`Unable to load Lazy Feature at url ${url}`);
|
|
486
|
+
} else {
|
|
487
|
+
return lazyFeature;
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
function RawFeature({
|
|
491
|
+
url,
|
|
492
|
+
css,
|
|
493
|
+
ComponentProps: params,
|
|
494
|
+
...props
|
|
495
|
+
}) {
|
|
496
|
+
if (css) {
|
|
497
|
+
importCSS(css).then((styleSheet) => {
|
|
498
|
+
document.adoptedStyleSheets = [
|
|
499
|
+
...document.adoptedStyleSheets,
|
|
500
|
+
styleSheet
|
|
501
|
+
];
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
const LazyFeature = useCachedFeature(url);
|
|
505
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeatureErrorBoundary, { url, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react6.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Loader, {}), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LazyFeature, { ...props, ...params }) }) });
|
|
506
|
+
}
|
|
507
|
+
var Feature = import_react6.default.memo(RawFeature);
|
|
508
|
+
Feature.displayName = "Feature";
|
|
509
|
+
(0, import_vuu_layout.registerComponent)("Feature", Feature, "view");
|
|
510
|
+
|
|
511
|
+
// src/layout-management/SaveLayoutPanel.tsx
|
|
512
|
+
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
513
|
+
|
|
514
|
+
// ../../node_modules/html-to-image/es/util.js
|
|
515
|
+
function resolveUrl(url, baseUrl) {
|
|
516
|
+
if (url.match(/^[a-z]+:\/\//i)) {
|
|
517
|
+
return url;
|
|
518
|
+
}
|
|
519
|
+
if (url.match(/^\/\//)) {
|
|
520
|
+
return window.location.protocol + url;
|
|
521
|
+
}
|
|
522
|
+
if (url.match(/^[a-z]+:/i)) {
|
|
523
|
+
return url;
|
|
524
|
+
}
|
|
525
|
+
const doc = document.implementation.createHTMLDocument();
|
|
526
|
+
const base = doc.createElement("base");
|
|
527
|
+
const a = doc.createElement("a");
|
|
528
|
+
doc.head.appendChild(base);
|
|
529
|
+
doc.body.appendChild(a);
|
|
530
|
+
if (baseUrl) {
|
|
531
|
+
base.href = baseUrl;
|
|
532
|
+
}
|
|
533
|
+
a.href = url;
|
|
534
|
+
return a.href;
|
|
535
|
+
}
|
|
536
|
+
var uuid = /* @__PURE__ */ (() => {
|
|
537
|
+
let counter = 0;
|
|
538
|
+
const random = () => (
|
|
539
|
+
// eslint-disable-next-line no-bitwise
|
|
540
|
+
`0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4)
|
|
541
|
+
);
|
|
542
|
+
return () => {
|
|
543
|
+
counter += 1;
|
|
544
|
+
return `u${random()}${counter}`;
|
|
545
|
+
};
|
|
546
|
+
})();
|
|
547
|
+
function toArray(arrayLike) {
|
|
548
|
+
const arr = [];
|
|
549
|
+
for (let i = 0, l = arrayLike.length; i < l; i++) {
|
|
550
|
+
arr.push(arrayLike[i]);
|
|
551
|
+
}
|
|
552
|
+
return arr;
|
|
553
|
+
}
|
|
554
|
+
function px(node, styleProperty) {
|
|
555
|
+
const win = node.ownerDocument.defaultView || window;
|
|
556
|
+
const val = win.getComputedStyle(node).getPropertyValue(styleProperty);
|
|
557
|
+
return val ? parseFloat(val.replace("px", "")) : 0;
|
|
558
|
+
}
|
|
559
|
+
function getNodeWidth(node) {
|
|
560
|
+
const leftBorder = px(node, "border-left-width");
|
|
561
|
+
const rightBorder = px(node, "border-right-width");
|
|
562
|
+
return node.clientWidth + leftBorder + rightBorder;
|
|
563
|
+
}
|
|
564
|
+
function getNodeHeight(node) {
|
|
565
|
+
const topBorder = px(node, "border-top-width");
|
|
566
|
+
const bottomBorder = px(node, "border-bottom-width");
|
|
567
|
+
return node.clientHeight + topBorder + bottomBorder;
|
|
568
|
+
}
|
|
569
|
+
function getImageSize(targetNode, options = {}) {
|
|
570
|
+
const width = options.width || getNodeWidth(targetNode);
|
|
571
|
+
const height = options.height || getNodeHeight(targetNode);
|
|
572
|
+
return { width, height };
|
|
573
|
+
}
|
|
574
|
+
function getPixelRatio() {
|
|
575
|
+
let ratio;
|
|
576
|
+
let FINAL_PROCESS;
|
|
577
|
+
try {
|
|
578
|
+
FINAL_PROCESS = process;
|
|
579
|
+
} catch (e) {
|
|
580
|
+
}
|
|
581
|
+
const val = FINAL_PROCESS && FINAL_PROCESS.env ? FINAL_PROCESS.env.devicePixelRatio : null;
|
|
582
|
+
if (val) {
|
|
583
|
+
ratio = parseInt(val, 10);
|
|
584
|
+
if (Number.isNaN(ratio)) {
|
|
585
|
+
ratio = 1;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return ratio || window.devicePixelRatio || 1;
|
|
589
|
+
}
|
|
590
|
+
var canvasDimensionLimit = 16384;
|
|
591
|
+
function checkCanvasDimensions(canvas) {
|
|
592
|
+
if (canvas.width > canvasDimensionLimit || canvas.height > canvasDimensionLimit) {
|
|
593
|
+
if (canvas.width > canvasDimensionLimit && canvas.height > canvasDimensionLimit) {
|
|
594
|
+
if (canvas.width > canvas.height) {
|
|
595
|
+
canvas.height *= canvasDimensionLimit / canvas.width;
|
|
596
|
+
canvas.width = canvasDimensionLimit;
|
|
597
|
+
} else {
|
|
598
|
+
canvas.width *= canvasDimensionLimit / canvas.height;
|
|
599
|
+
canvas.height = canvasDimensionLimit;
|
|
600
|
+
}
|
|
601
|
+
} else if (canvas.width > canvasDimensionLimit) {
|
|
602
|
+
canvas.height *= canvasDimensionLimit / canvas.width;
|
|
603
|
+
canvas.width = canvasDimensionLimit;
|
|
604
|
+
} else {
|
|
605
|
+
canvas.width *= canvasDimensionLimit / canvas.height;
|
|
606
|
+
canvas.height = canvasDimensionLimit;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function createImage(url) {
|
|
611
|
+
return new Promise((resolve, reject) => {
|
|
612
|
+
const img = new Image();
|
|
613
|
+
img.decode = () => resolve(img);
|
|
614
|
+
img.onload = () => resolve(img);
|
|
615
|
+
img.onerror = reject;
|
|
616
|
+
img.crossOrigin = "anonymous";
|
|
617
|
+
img.decoding = "async";
|
|
618
|
+
img.src = url;
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
async function svgToDataURL(svg) {
|
|
622
|
+
return Promise.resolve().then(() => new XMLSerializer().serializeToString(svg)).then(encodeURIComponent).then((html) => `data:image/svg+xml;charset=utf-8,${html}`);
|
|
623
|
+
}
|
|
624
|
+
async function nodeToDataURL(node, width, height) {
|
|
625
|
+
const xmlns = "http://www.w3.org/2000/svg";
|
|
626
|
+
const svg = document.createElementNS(xmlns, "svg");
|
|
627
|
+
const foreignObject = document.createElementNS(xmlns, "foreignObject");
|
|
628
|
+
svg.setAttribute("width", `${width}`);
|
|
629
|
+
svg.setAttribute("height", `${height}`);
|
|
630
|
+
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
631
|
+
foreignObject.setAttribute("width", "100%");
|
|
632
|
+
foreignObject.setAttribute("height", "100%");
|
|
633
|
+
foreignObject.setAttribute("x", "0");
|
|
634
|
+
foreignObject.setAttribute("y", "0");
|
|
635
|
+
foreignObject.setAttribute("externalResourcesRequired", "true");
|
|
636
|
+
svg.appendChild(foreignObject);
|
|
637
|
+
foreignObject.appendChild(node);
|
|
638
|
+
return svgToDataURL(svg);
|
|
639
|
+
}
|
|
640
|
+
var isInstanceOfElement = (node, instance) => {
|
|
641
|
+
if (node instanceof instance)
|
|
642
|
+
return true;
|
|
643
|
+
const nodePrototype = Object.getPrototypeOf(node);
|
|
644
|
+
if (nodePrototype === null)
|
|
645
|
+
return false;
|
|
646
|
+
return nodePrototype.constructor.name === instance.name || isInstanceOfElement(nodePrototype, instance);
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
// ../../node_modules/html-to-image/es/clone-pseudos.js
|
|
650
|
+
function formatCSSText(style) {
|
|
651
|
+
const content = style.getPropertyValue("content");
|
|
652
|
+
return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
|
|
653
|
+
}
|
|
654
|
+
function formatCSSProperties(style) {
|
|
655
|
+
return toArray(style).map((name) => {
|
|
656
|
+
const value = style.getPropertyValue(name);
|
|
657
|
+
const priority = style.getPropertyPriority(name);
|
|
658
|
+
return `${name}: ${value}${priority ? " !important" : ""};`;
|
|
659
|
+
}).join(" ");
|
|
660
|
+
}
|
|
661
|
+
function getPseudoElementStyle(className, pseudo, style) {
|
|
662
|
+
const selector = `.${className}:${pseudo}`;
|
|
663
|
+
const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style);
|
|
664
|
+
return document.createTextNode(`${selector}{${cssText}}`);
|
|
665
|
+
}
|
|
666
|
+
function clonePseudoElement(nativeNode, clonedNode, pseudo) {
|
|
667
|
+
const style = window.getComputedStyle(nativeNode, pseudo);
|
|
668
|
+
const content = style.getPropertyValue("content");
|
|
669
|
+
if (content === "" || content === "none") {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const className = uuid();
|
|
673
|
+
try {
|
|
674
|
+
clonedNode.className = `${clonedNode.className} ${className}`;
|
|
675
|
+
} catch (err) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
const styleElement = document.createElement("style");
|
|
679
|
+
styleElement.appendChild(getPseudoElementStyle(className, pseudo, style));
|
|
680
|
+
clonedNode.appendChild(styleElement);
|
|
681
|
+
}
|
|
682
|
+
function clonePseudoElements(nativeNode, clonedNode) {
|
|
683
|
+
clonePseudoElement(nativeNode, clonedNode, ":before");
|
|
684
|
+
clonePseudoElement(nativeNode, clonedNode, ":after");
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// ../../node_modules/html-to-image/es/mimes.js
|
|
688
|
+
var WOFF = "application/font-woff";
|
|
689
|
+
var JPEG = "image/jpeg";
|
|
690
|
+
var mimes = {
|
|
691
|
+
woff: WOFF,
|
|
692
|
+
woff2: WOFF,
|
|
693
|
+
ttf: "application/font-truetype",
|
|
694
|
+
eot: "application/vnd.ms-fontobject",
|
|
695
|
+
png: "image/png",
|
|
696
|
+
jpg: JPEG,
|
|
697
|
+
jpeg: JPEG,
|
|
698
|
+
gif: "image/gif",
|
|
699
|
+
tiff: "image/tiff",
|
|
700
|
+
svg: "image/svg+xml",
|
|
701
|
+
webp: "image/webp"
|
|
702
|
+
};
|
|
703
|
+
function getExtension(url) {
|
|
704
|
+
const match = /\.([^./]*?)$/g.exec(url);
|
|
705
|
+
return match ? match[1] : "";
|
|
706
|
+
}
|
|
707
|
+
function getMimeType(url) {
|
|
708
|
+
const extension = getExtension(url).toLowerCase();
|
|
709
|
+
return mimes[extension] || "";
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// ../../node_modules/html-to-image/es/dataurl.js
|
|
713
|
+
function getContentFromDataUrl(dataURL) {
|
|
714
|
+
return dataURL.split(/,/)[1];
|
|
715
|
+
}
|
|
716
|
+
function isDataUrl(url) {
|
|
717
|
+
return url.search(/^(data:)/) !== -1;
|
|
718
|
+
}
|
|
719
|
+
function makeDataUrl(content, mimeType) {
|
|
720
|
+
return `data:${mimeType};base64,${content}`;
|
|
721
|
+
}
|
|
722
|
+
async function fetchAsDataURL(url, init, process2) {
|
|
723
|
+
const res = await fetch(url, init);
|
|
724
|
+
if (res.status === 404) {
|
|
725
|
+
throw new Error(`Resource "${res.url}" not found`);
|
|
726
|
+
}
|
|
727
|
+
const blob = await res.blob();
|
|
728
|
+
return new Promise((resolve, reject) => {
|
|
729
|
+
const reader = new FileReader();
|
|
730
|
+
reader.onerror = reject;
|
|
731
|
+
reader.onloadend = () => {
|
|
732
|
+
try {
|
|
733
|
+
resolve(process2({ res, result: reader.result }));
|
|
734
|
+
} catch (error2) {
|
|
735
|
+
reject(error2);
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
reader.readAsDataURL(blob);
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
var cache = {};
|
|
742
|
+
function getCacheKey(url, contentType, includeQueryParams) {
|
|
743
|
+
let key = url.replace(/\?.*/, "");
|
|
744
|
+
if (includeQueryParams) {
|
|
745
|
+
key = url;
|
|
746
|
+
}
|
|
747
|
+
if (/ttf|otf|eot|woff2?/i.test(key)) {
|
|
748
|
+
key = key.replace(/.*\//, "");
|
|
749
|
+
}
|
|
750
|
+
return contentType ? `[${contentType}]${key}` : key;
|
|
751
|
+
}
|
|
752
|
+
async function resourceToDataURL(resourceUrl, contentType, options) {
|
|
753
|
+
const cacheKey = getCacheKey(resourceUrl, contentType, options.includeQueryParams);
|
|
754
|
+
if (cache[cacheKey] != null) {
|
|
755
|
+
return cache[cacheKey];
|
|
756
|
+
}
|
|
757
|
+
if (options.cacheBust) {
|
|
758
|
+
resourceUrl += (/\?/.test(resourceUrl) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
|
|
759
|
+
}
|
|
760
|
+
let dataURL;
|
|
761
|
+
try {
|
|
762
|
+
const content = await fetchAsDataURL(resourceUrl, options.fetchRequestInit, ({ res, result }) => {
|
|
763
|
+
if (!contentType) {
|
|
764
|
+
contentType = res.headers.get("Content-Type") || "";
|
|
765
|
+
}
|
|
766
|
+
return getContentFromDataUrl(result);
|
|
767
|
+
});
|
|
768
|
+
dataURL = makeDataUrl(content, contentType);
|
|
769
|
+
} catch (error2) {
|
|
770
|
+
dataURL = options.imagePlaceholder || "";
|
|
771
|
+
let msg = `Failed to fetch resource: ${resourceUrl}`;
|
|
772
|
+
if (error2) {
|
|
773
|
+
msg = typeof error2 === "string" ? error2 : error2.message;
|
|
774
|
+
}
|
|
775
|
+
if (msg) {
|
|
776
|
+
console.warn(msg);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
cache[cacheKey] = dataURL;
|
|
780
|
+
return dataURL;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// ../../node_modules/html-to-image/es/clone-node.js
|
|
784
|
+
async function cloneCanvasElement(canvas) {
|
|
785
|
+
const dataURL = canvas.toDataURL();
|
|
786
|
+
if (dataURL === "data:,") {
|
|
787
|
+
return canvas.cloneNode(false);
|
|
788
|
+
}
|
|
789
|
+
return createImage(dataURL);
|
|
790
|
+
}
|
|
791
|
+
async function cloneVideoElement(video, options) {
|
|
792
|
+
if (video.currentSrc) {
|
|
793
|
+
const canvas = document.createElement("canvas");
|
|
794
|
+
const ctx = canvas.getContext("2d");
|
|
795
|
+
canvas.width = video.clientWidth;
|
|
796
|
+
canvas.height = video.clientHeight;
|
|
797
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
798
|
+
const dataURL2 = canvas.toDataURL();
|
|
799
|
+
return createImage(dataURL2);
|
|
800
|
+
}
|
|
801
|
+
const poster = video.poster;
|
|
802
|
+
const contentType = getMimeType(poster);
|
|
803
|
+
const dataURL = await resourceToDataURL(poster, contentType, options);
|
|
804
|
+
return createImage(dataURL);
|
|
805
|
+
}
|
|
806
|
+
async function cloneIFrameElement(iframe) {
|
|
807
|
+
var _a;
|
|
808
|
+
try {
|
|
809
|
+
if ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.body) {
|
|
810
|
+
return await cloneNode(iframe.contentDocument.body, {}, true);
|
|
811
|
+
}
|
|
812
|
+
} catch (_b) {
|
|
813
|
+
}
|
|
814
|
+
return iframe.cloneNode(false);
|
|
815
|
+
}
|
|
816
|
+
async function cloneSingleNode(node, options) {
|
|
817
|
+
if (isInstanceOfElement(node, HTMLCanvasElement)) {
|
|
818
|
+
return cloneCanvasElement(node);
|
|
819
|
+
}
|
|
820
|
+
if (isInstanceOfElement(node, HTMLVideoElement)) {
|
|
821
|
+
return cloneVideoElement(node, options);
|
|
822
|
+
}
|
|
823
|
+
if (isInstanceOfElement(node, HTMLIFrameElement)) {
|
|
824
|
+
return cloneIFrameElement(node);
|
|
825
|
+
}
|
|
826
|
+
return node.cloneNode(false);
|
|
827
|
+
}
|
|
828
|
+
var isSlotElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SLOT";
|
|
829
|
+
async function cloneChildren(nativeNode, clonedNode, options) {
|
|
830
|
+
var _a, _b;
|
|
831
|
+
let children = [];
|
|
832
|
+
if (isSlotElement(nativeNode) && nativeNode.assignedNodes) {
|
|
833
|
+
children = toArray(nativeNode.assignedNodes());
|
|
834
|
+
} else if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && ((_a = nativeNode.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
|
|
835
|
+
children = toArray(nativeNode.contentDocument.body.childNodes);
|
|
836
|
+
} else {
|
|
837
|
+
children = toArray(((_b = nativeNode.shadowRoot) !== null && _b !== void 0 ? _b : nativeNode).childNodes);
|
|
838
|
+
}
|
|
839
|
+
if (children.length === 0 || isInstanceOfElement(nativeNode, HTMLVideoElement)) {
|
|
840
|
+
return clonedNode;
|
|
841
|
+
}
|
|
842
|
+
await children.reduce((deferred, child) => deferred.then(() => cloneNode(child, options)).then((clonedChild) => {
|
|
843
|
+
if (clonedChild) {
|
|
844
|
+
clonedNode.appendChild(clonedChild);
|
|
845
|
+
}
|
|
846
|
+
}), Promise.resolve());
|
|
847
|
+
return clonedNode;
|
|
848
|
+
}
|
|
849
|
+
function cloneCSSStyle(nativeNode, clonedNode) {
|
|
850
|
+
const targetStyle = clonedNode.style;
|
|
851
|
+
if (!targetStyle) {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const sourceStyle = window.getComputedStyle(nativeNode);
|
|
855
|
+
if (sourceStyle.cssText) {
|
|
856
|
+
targetStyle.cssText = sourceStyle.cssText;
|
|
857
|
+
targetStyle.transformOrigin = sourceStyle.transformOrigin;
|
|
858
|
+
} else {
|
|
859
|
+
toArray(sourceStyle).forEach((name) => {
|
|
860
|
+
let value = sourceStyle.getPropertyValue(name);
|
|
861
|
+
if (name === "font-size" && value.endsWith("px")) {
|
|
862
|
+
const reducedFont = Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1;
|
|
863
|
+
value = `${reducedFont}px`;
|
|
864
|
+
}
|
|
865
|
+
if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && name === "display" && value === "inline") {
|
|
866
|
+
value = "block";
|
|
867
|
+
}
|
|
868
|
+
if (name === "d" && clonedNode.getAttribute("d")) {
|
|
869
|
+
value = `path(${clonedNode.getAttribute("d")})`;
|
|
870
|
+
}
|
|
871
|
+
targetStyle.setProperty(name, value, sourceStyle.getPropertyPriority(name));
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function cloneInputValue(nativeNode, clonedNode) {
|
|
876
|
+
if (isInstanceOfElement(nativeNode, HTMLTextAreaElement)) {
|
|
877
|
+
clonedNode.innerHTML = nativeNode.value;
|
|
878
|
+
}
|
|
879
|
+
if (isInstanceOfElement(nativeNode, HTMLInputElement)) {
|
|
880
|
+
clonedNode.setAttribute("value", nativeNode.value);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
function cloneSelectValue(nativeNode, clonedNode) {
|
|
884
|
+
if (isInstanceOfElement(nativeNode, HTMLSelectElement)) {
|
|
885
|
+
const clonedSelect = clonedNode;
|
|
886
|
+
const selectedOption = Array.from(clonedSelect.children).find((child) => nativeNode.value === child.getAttribute("value"));
|
|
887
|
+
if (selectedOption) {
|
|
888
|
+
selectedOption.setAttribute("selected", "");
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
function decorate(nativeNode, clonedNode) {
|
|
893
|
+
if (isInstanceOfElement(clonedNode, Element)) {
|
|
894
|
+
cloneCSSStyle(nativeNode, clonedNode);
|
|
895
|
+
clonePseudoElements(nativeNode, clonedNode);
|
|
896
|
+
cloneInputValue(nativeNode, clonedNode);
|
|
897
|
+
cloneSelectValue(nativeNode, clonedNode);
|
|
898
|
+
}
|
|
899
|
+
return clonedNode;
|
|
900
|
+
}
|
|
901
|
+
async function ensureSVGSymbols(clone, options) {
|
|
902
|
+
const uses = clone.querySelectorAll ? clone.querySelectorAll("use") : [];
|
|
903
|
+
if (uses.length === 0) {
|
|
904
|
+
return clone;
|
|
905
|
+
}
|
|
906
|
+
const processedDefs = {};
|
|
907
|
+
for (let i = 0; i < uses.length; i++) {
|
|
908
|
+
const use = uses[i];
|
|
909
|
+
const id = use.getAttribute("xlink:href");
|
|
910
|
+
if (id) {
|
|
911
|
+
const exist = clone.querySelector(id);
|
|
912
|
+
const definition = document.querySelector(id);
|
|
913
|
+
if (!exist && definition && !processedDefs[id]) {
|
|
914
|
+
processedDefs[id] = await cloneNode(definition, options, true);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
const nodes = Object.values(processedDefs);
|
|
919
|
+
if (nodes.length) {
|
|
920
|
+
const ns = "http://www.w3.org/1999/xhtml";
|
|
921
|
+
const svg = document.createElementNS(ns, "svg");
|
|
922
|
+
svg.setAttribute("xmlns", ns);
|
|
923
|
+
svg.style.position = "absolute";
|
|
924
|
+
svg.style.width = "0";
|
|
925
|
+
svg.style.height = "0";
|
|
926
|
+
svg.style.overflow = "hidden";
|
|
927
|
+
svg.style.display = "none";
|
|
928
|
+
const defs = document.createElementNS(ns, "defs");
|
|
929
|
+
svg.appendChild(defs);
|
|
930
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
931
|
+
defs.appendChild(nodes[i]);
|
|
932
|
+
}
|
|
933
|
+
clone.appendChild(svg);
|
|
934
|
+
}
|
|
935
|
+
return clone;
|
|
936
|
+
}
|
|
937
|
+
async function cloneNode(node, options, isRoot) {
|
|
938
|
+
if (!isRoot && options.filter && !options.filter(node)) {
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
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));
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// ../../node_modules/html-to-image/es/embed-resources.js
|
|
945
|
+
var URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
|
|
946
|
+
var URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
|
|
947
|
+
var FONT_SRC_REGEX = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
|
|
948
|
+
function toRegex(url) {
|
|
949
|
+
const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
|
|
950
|
+
return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
|
|
951
|
+
}
|
|
952
|
+
function parseURLs(cssText) {
|
|
953
|
+
const urls = [];
|
|
954
|
+
cssText.replace(URL_REGEX, (raw, quotation, url) => {
|
|
955
|
+
urls.push(url);
|
|
956
|
+
return raw;
|
|
957
|
+
});
|
|
958
|
+
return urls.filter((url) => !isDataUrl(url));
|
|
959
|
+
}
|
|
960
|
+
async function embed(cssText, resourceURL, baseURL, options, getContentFromUrl) {
|
|
961
|
+
try {
|
|
962
|
+
const resolvedURL = baseURL ? resolveUrl(resourceURL, baseURL) : resourceURL;
|
|
963
|
+
const contentType = getMimeType(resourceURL);
|
|
964
|
+
let dataURL;
|
|
965
|
+
if (getContentFromUrl) {
|
|
966
|
+
const content = await getContentFromUrl(resolvedURL);
|
|
967
|
+
dataURL = makeDataUrl(content, contentType);
|
|
968
|
+
} else {
|
|
969
|
+
dataURL = await resourceToDataURL(resolvedURL, contentType, options);
|
|
970
|
+
}
|
|
971
|
+
return cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
|
|
972
|
+
} catch (error2) {
|
|
973
|
+
}
|
|
974
|
+
return cssText;
|
|
975
|
+
}
|
|
976
|
+
function filterPreferredFontFormat(str, { preferredFontFormat }) {
|
|
977
|
+
return !preferredFontFormat ? str : str.replace(FONT_SRC_REGEX, (match) => {
|
|
978
|
+
while (true) {
|
|
979
|
+
const [src, , format] = URL_WITH_FORMAT_REGEX.exec(match) || [];
|
|
980
|
+
if (!format) {
|
|
981
|
+
return "";
|
|
982
|
+
}
|
|
983
|
+
if (format === preferredFontFormat) {
|
|
984
|
+
return `src: ${src};`;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function shouldEmbed(url) {
|
|
990
|
+
return url.search(URL_REGEX) !== -1;
|
|
991
|
+
}
|
|
992
|
+
async function embedResources(cssText, baseUrl, options) {
|
|
993
|
+
if (!shouldEmbed(cssText)) {
|
|
994
|
+
return cssText;
|
|
995
|
+
}
|
|
996
|
+
const filteredCSSText = filterPreferredFontFormat(cssText, options);
|
|
997
|
+
const urls = parseURLs(filteredCSSText);
|
|
998
|
+
return urls.reduce((deferred, url) => deferred.then((css) => embed(css, url, baseUrl, options)), Promise.resolve(filteredCSSText));
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// ../../node_modules/html-to-image/es/embed-images.js
|
|
1002
|
+
async function embedProp(propName, node, options) {
|
|
1003
|
+
var _a;
|
|
1004
|
+
const propValue = (_a = node.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue(propName);
|
|
1005
|
+
if (propValue) {
|
|
1006
|
+
const cssString = await embedResources(propValue, null, options);
|
|
1007
|
+
node.style.setProperty(propName, cssString, node.style.getPropertyPriority(propName));
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
async function embedBackground(clonedNode, options) {
|
|
1013
|
+
if (!await embedProp("background", clonedNode, options)) {
|
|
1014
|
+
await embedProp("background-image", clonedNode, options);
|
|
1015
|
+
}
|
|
1016
|
+
if (!await embedProp("mask", clonedNode, options)) {
|
|
1017
|
+
await embedProp("mask-image", clonedNode, options);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
async function embedImageNode(clonedNode, options) {
|
|
1021
|
+
const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
|
|
1022
|
+
if (!(isImageElement && !isDataUrl(clonedNode.src)) && !(isInstanceOfElement(clonedNode, SVGImageElement) && !isDataUrl(clonedNode.href.baseVal))) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
const url = isImageElement ? clonedNode.src : clonedNode.href.baseVal;
|
|
1026
|
+
const dataURL = await resourceToDataURL(url, getMimeType(url), options);
|
|
1027
|
+
await new Promise((resolve, reject) => {
|
|
1028
|
+
clonedNode.onload = resolve;
|
|
1029
|
+
clonedNode.onerror = reject;
|
|
1030
|
+
const image = clonedNode;
|
|
1031
|
+
if (image.decode) {
|
|
1032
|
+
image.decode = resolve;
|
|
1033
|
+
}
|
|
1034
|
+
if (image.loading === "lazy") {
|
|
1035
|
+
image.loading = "eager";
|
|
1036
|
+
}
|
|
1037
|
+
if (isImageElement) {
|
|
1038
|
+
clonedNode.srcset = "";
|
|
1039
|
+
clonedNode.src = dataURL;
|
|
1040
|
+
} else {
|
|
1041
|
+
clonedNode.href.baseVal = dataURL;
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
async function embedChildren(clonedNode, options) {
|
|
1046
|
+
const children = toArray(clonedNode.childNodes);
|
|
1047
|
+
const deferreds = children.map((child) => embedImages(child, options));
|
|
1048
|
+
await Promise.all(deferreds).then(() => clonedNode);
|
|
1049
|
+
}
|
|
1050
|
+
async function embedImages(clonedNode, options) {
|
|
1051
|
+
if (isInstanceOfElement(clonedNode, Element)) {
|
|
1052
|
+
await embedBackground(clonedNode, options);
|
|
1053
|
+
await embedImageNode(clonedNode, options);
|
|
1054
|
+
await embedChildren(clonedNode, options);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// ../../node_modules/html-to-image/es/apply-style.js
|
|
1059
|
+
function applyStyle(node, options) {
|
|
1060
|
+
const { style } = node;
|
|
1061
|
+
if (options.backgroundColor) {
|
|
1062
|
+
style.backgroundColor = options.backgroundColor;
|
|
1063
|
+
}
|
|
1064
|
+
if (options.width) {
|
|
1065
|
+
style.width = `${options.width}px`;
|
|
1066
|
+
}
|
|
1067
|
+
if (options.height) {
|
|
1068
|
+
style.height = `${options.height}px`;
|
|
1069
|
+
}
|
|
1070
|
+
const manual = options.style;
|
|
1071
|
+
if (manual != null) {
|
|
1072
|
+
Object.keys(manual).forEach((key) => {
|
|
1073
|
+
style[key] = manual[key];
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
return node;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// ../../node_modules/html-to-image/es/embed-webfonts.js
|
|
1080
|
+
var cssFetchCache = {};
|
|
1081
|
+
async function fetchCSS(url) {
|
|
1082
|
+
let cache2 = cssFetchCache[url];
|
|
1083
|
+
if (cache2 != null) {
|
|
1084
|
+
return cache2;
|
|
1085
|
+
}
|
|
1086
|
+
const res = await fetch(url);
|
|
1087
|
+
const cssText = await res.text();
|
|
1088
|
+
cache2 = { url, cssText };
|
|
1089
|
+
cssFetchCache[url] = cache2;
|
|
1090
|
+
return cache2;
|
|
1091
|
+
}
|
|
1092
|
+
async function embedFonts(data, options) {
|
|
1093
|
+
let cssText = data.cssText;
|
|
1094
|
+
const regexUrl = /url\(["']?([^"')]+)["']?\)/g;
|
|
1095
|
+
const fontLocs = cssText.match(/url\([^)]+\)/g) || [];
|
|
1096
|
+
const loadFonts = fontLocs.map(async (loc) => {
|
|
1097
|
+
let url = loc.replace(regexUrl, "$1");
|
|
1098
|
+
if (!url.startsWith("https://")) {
|
|
1099
|
+
url = new URL(url, data.url).href;
|
|
1100
|
+
}
|
|
1101
|
+
return fetchAsDataURL(url, options.fetchRequestInit, ({ result }) => {
|
|
1102
|
+
cssText = cssText.replace(loc, `url(${result})`);
|
|
1103
|
+
return [loc, result];
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
return Promise.all(loadFonts).then(() => cssText);
|
|
1107
|
+
}
|
|
1108
|
+
function parseCSS(source) {
|
|
1109
|
+
if (source == null) {
|
|
1110
|
+
return [];
|
|
1111
|
+
}
|
|
1112
|
+
const result = [];
|
|
1113
|
+
const commentsRegex = /(\/\*[\s\S]*?\*\/)/gi;
|
|
1114
|
+
let cssText = source.replace(commentsRegex, "");
|
|
1115
|
+
const keyframesRegex = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
|
|
1116
|
+
while (true) {
|
|
1117
|
+
const matches = keyframesRegex.exec(cssText);
|
|
1118
|
+
if (matches === null) {
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
result.push(matches[0]);
|
|
1122
|
+
}
|
|
1123
|
+
cssText = cssText.replace(keyframesRegex, "");
|
|
1124
|
+
const importRegex = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
|
|
1125
|
+
const combinedCSSRegex = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})";
|
|
1126
|
+
const unifiedRegex = new RegExp(combinedCSSRegex, "gi");
|
|
1127
|
+
while (true) {
|
|
1128
|
+
let matches = importRegex.exec(cssText);
|
|
1129
|
+
if (matches === null) {
|
|
1130
|
+
matches = unifiedRegex.exec(cssText);
|
|
1131
|
+
if (matches === null) {
|
|
1132
|
+
break;
|
|
1133
|
+
} else {
|
|
1134
|
+
importRegex.lastIndex = unifiedRegex.lastIndex;
|
|
1135
|
+
}
|
|
1136
|
+
} else {
|
|
1137
|
+
unifiedRegex.lastIndex = importRegex.lastIndex;
|
|
1138
|
+
}
|
|
1139
|
+
result.push(matches[0]);
|
|
1140
|
+
}
|
|
1141
|
+
return result;
|
|
1142
|
+
}
|
|
1143
|
+
async function getCSSRules(styleSheets, options) {
|
|
1144
|
+
const ret = [];
|
|
1145
|
+
const deferreds = [];
|
|
1146
|
+
styleSheets.forEach((sheet) => {
|
|
1147
|
+
if ("cssRules" in sheet) {
|
|
1148
|
+
try {
|
|
1149
|
+
toArray(sheet.cssRules || []).forEach((item, index) => {
|
|
1150
|
+
if (item.type === CSSRule.IMPORT_RULE) {
|
|
1151
|
+
let importIndex = index + 1;
|
|
1152
|
+
const url = item.href;
|
|
1153
|
+
const deferred = fetchCSS(url).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
|
|
1154
|
+
try {
|
|
1155
|
+
sheet.insertRule(rule, rule.startsWith("@import") ? importIndex += 1 : sheet.cssRules.length);
|
|
1156
|
+
} catch (error2) {
|
|
1157
|
+
console.error("Error inserting rule from remote css", {
|
|
1158
|
+
rule,
|
|
1159
|
+
error: error2
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
})).catch((e) => {
|
|
1163
|
+
console.error("Error loading remote css", e.toString());
|
|
1164
|
+
});
|
|
1165
|
+
deferreds.push(deferred);
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
} catch (e) {
|
|
1169
|
+
const inline = styleSheets.find((a) => a.href == null) || document.styleSheets[0];
|
|
1170
|
+
if (sheet.href != null) {
|
|
1171
|
+
deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
|
|
1172
|
+
inline.insertRule(rule, sheet.cssRules.length);
|
|
1173
|
+
})).catch((err) => {
|
|
1174
|
+
console.error("Error loading remote stylesheet", err);
|
|
1175
|
+
}));
|
|
1176
|
+
}
|
|
1177
|
+
console.error("Error inlining remote css file", e);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
return Promise.all(deferreds).then(() => {
|
|
1182
|
+
styleSheets.forEach((sheet) => {
|
|
1183
|
+
if ("cssRules" in sheet) {
|
|
1184
|
+
try {
|
|
1185
|
+
toArray(sheet.cssRules || []).forEach((item) => {
|
|
1186
|
+
ret.push(item);
|
|
1187
|
+
});
|
|
1188
|
+
} catch (e) {
|
|
1189
|
+
console.error(`Error while reading CSS rules from ${sheet.href}`, e);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
return ret;
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
function getWebFontRules(cssRules) {
|
|
1197
|
+
return cssRules.filter((rule) => rule.type === CSSRule.FONT_FACE_RULE).filter((rule) => shouldEmbed(rule.style.getPropertyValue("src")));
|
|
1198
|
+
}
|
|
1199
|
+
async function parseWebFontRules(node, options) {
|
|
1200
|
+
if (node.ownerDocument == null) {
|
|
1201
|
+
throw new Error("Provided element is not within a Document");
|
|
1202
|
+
}
|
|
1203
|
+
const styleSheets = toArray(node.ownerDocument.styleSheets);
|
|
1204
|
+
const cssRules = await getCSSRules(styleSheets, options);
|
|
1205
|
+
return getWebFontRules(cssRules);
|
|
1206
|
+
}
|
|
1207
|
+
async function getWebFontCSS(node, options) {
|
|
1208
|
+
const rules = await parseWebFontRules(node, options);
|
|
1209
|
+
const cssTexts = await Promise.all(rules.map((rule) => {
|
|
1210
|
+
const baseUrl = rule.parentStyleSheet ? rule.parentStyleSheet.href : null;
|
|
1211
|
+
return embedResources(rule.cssText, baseUrl, options);
|
|
1212
|
+
}));
|
|
1213
|
+
return cssTexts.join("\n");
|
|
1214
|
+
}
|
|
1215
|
+
async function embedWebFonts(clonedNode, options) {
|
|
1216
|
+
const cssText = options.fontEmbedCSS != null ? options.fontEmbedCSS : options.skipFonts ? null : await getWebFontCSS(clonedNode, options);
|
|
1217
|
+
if (cssText) {
|
|
1218
|
+
const styleNode = document.createElement("style");
|
|
1219
|
+
const sytleContent = document.createTextNode(cssText);
|
|
1220
|
+
styleNode.appendChild(sytleContent);
|
|
1221
|
+
if (clonedNode.firstChild) {
|
|
1222
|
+
clonedNode.insertBefore(styleNode, clonedNode.firstChild);
|
|
1223
|
+
} else {
|
|
1224
|
+
clonedNode.appendChild(styleNode);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// ../../node_modules/html-to-image/es/index.js
|
|
1230
|
+
async function toSvg(node, options = {}) {
|
|
1231
|
+
const { width, height } = getImageSize(node, options);
|
|
1232
|
+
const clonedNode = await cloneNode(node, options, true);
|
|
1233
|
+
await embedWebFonts(clonedNode, options);
|
|
1234
|
+
await embedImages(clonedNode, options);
|
|
1235
|
+
applyStyle(clonedNode, options);
|
|
1236
|
+
const datauri = await nodeToDataURL(clonedNode, width, height);
|
|
1237
|
+
return datauri;
|
|
1238
|
+
}
|
|
1239
|
+
async function toCanvas(node, options = {}) {
|
|
1240
|
+
const { width, height } = getImageSize(node, options);
|
|
1241
|
+
const svg = await toSvg(node, options);
|
|
1242
|
+
const img = await createImage(svg);
|
|
1243
|
+
const canvas = document.createElement("canvas");
|
|
1244
|
+
const context = canvas.getContext("2d");
|
|
1245
|
+
const ratio = options.pixelRatio || getPixelRatio();
|
|
1246
|
+
const canvasWidth = options.canvasWidth || width;
|
|
1247
|
+
const canvasHeight = options.canvasHeight || height;
|
|
1248
|
+
canvas.width = canvasWidth * ratio;
|
|
1249
|
+
canvas.height = canvasHeight * ratio;
|
|
1250
|
+
if (!options.skipAutoScale) {
|
|
1251
|
+
checkCanvasDimensions(canvas);
|
|
1252
|
+
}
|
|
1253
|
+
canvas.style.width = `${canvasWidth}`;
|
|
1254
|
+
canvas.style.height = `${canvasHeight}`;
|
|
1255
|
+
if (options.backgroundColor) {
|
|
1256
|
+
context.fillStyle = options.backgroundColor;
|
|
1257
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
1258
|
+
}
|
|
1259
|
+
context.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
1260
|
+
return canvas;
|
|
1261
|
+
}
|
|
1262
|
+
async function toPng(node, options = {}) {
|
|
1263
|
+
const canvas = await toCanvas(node, options);
|
|
1264
|
+
return canvas.toDataURL();
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// src/layout-management/screenshot-utils.ts
|
|
1268
|
+
var takeScreenshot = (node) => {
|
|
1269
|
+
return new Promise((resolve, reject) => {
|
|
1270
|
+
toPng(node, {
|
|
1271
|
+
cacheBust: true
|
|
1272
|
+
}).then((screenshot) => {
|
|
1273
|
+
if (!screenshot) {
|
|
1274
|
+
reject(new Error("No Screenshot available"));
|
|
1275
|
+
}
|
|
1276
|
+
resolve(screenshot);
|
|
1277
|
+
}).catch((error2) => {
|
|
1278
|
+
console.error(
|
|
1279
|
+
"the following error occurred while taking a screenshot of a DOMNode",
|
|
1280
|
+
error2
|
|
1281
|
+
);
|
|
1282
|
+
reject(new Error("Error taking screenshot"));
|
|
1283
|
+
});
|
|
1284
|
+
});
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
// src/layout-management/SaveLayoutPanel.tsx
|
|
1288
|
+
var import_core3 = require("@salt-ds/core");
|
|
1289
|
+
var import_react7 = require("react");
|
|
1290
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1291
|
+
var classBase3 = "saveLayoutPanel";
|
|
1292
|
+
var formField = `${classBase3}-formField`;
|
|
1293
|
+
var groups = ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5"];
|
|
1294
|
+
var checkboxValues = ["Value 1", "Value 2", "Value 3"];
|
|
1295
|
+
var radioValues = ["Value 1", "Value 2", "Value 3"];
|
|
1296
|
+
var SaveLayoutPanel = (props) => {
|
|
1297
|
+
const { defaultTitle = "", onCancel, onSave, componentId } = props;
|
|
1298
|
+
const [layoutName, setLayoutName] = (0, import_react7.useState)(defaultTitle);
|
|
1299
|
+
const [group, setGroup] = (0, import_react7.useState)("");
|
|
1300
|
+
const [checkValues, setCheckValues] = (0, import_react7.useState)([]);
|
|
1301
|
+
const [radioValue, setRadioValue] = (0, import_react7.useState)(radioValues[0]);
|
|
1302
|
+
const [screenshot, setScreenshot] = (0, import_react7.useState)();
|
|
1303
|
+
const [screenshotErrorMessage, setScreenshotErrorMessage] = (0, import_react7.useState)();
|
|
1304
|
+
const [username] = getAuthDetailsFromCookies();
|
|
1305
|
+
(0, import_react7.useEffect)(() => {
|
|
1306
|
+
if (componentId) {
|
|
1307
|
+
takeScreenshot(document.getElementById(componentId)).then((screenshot2) => {
|
|
1308
|
+
setScreenshot(screenshot2);
|
|
1309
|
+
}).catch((error2) => {
|
|
1310
|
+
setScreenshotErrorMessage(error2.message);
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
}, [componentId]);
|
|
1314
|
+
const handleSubmit = () => {
|
|
1315
|
+
onSave({
|
|
1316
|
+
name: layoutName,
|
|
1317
|
+
group,
|
|
1318
|
+
screenshot: screenshot != null ? screenshot : "",
|
|
1319
|
+
user: username
|
|
1320
|
+
});
|
|
1321
|
+
};
|
|
1322
|
+
const screenshotContent = (0, import_react7.useMemo)(() => {
|
|
1323
|
+
if (screenshot) {
|
|
1324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1325
|
+
"img",
|
|
1326
|
+
{
|
|
1327
|
+
className: `${classBase3}-screenshot`,
|
|
1328
|
+
src: screenshot,
|
|
1329
|
+
alt: "screenshot of current layout"
|
|
1330
|
+
}
|
|
1331
|
+
);
|
|
1332
|
+
}
|
|
1333
|
+
if (screenshotErrorMessage) {
|
|
1334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core3.Text, { children: screenshotErrorMessage });
|
|
1335
|
+
}
|
|
1336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "spinner" });
|
|
1337
|
+
}, [screenshot, screenshotErrorMessage]);
|
|
1338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${classBase3}-panelContainer`, children: [
|
|
1339
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${classBase3}-panelContent`, children: [
|
|
1340
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${classBase3}-formContainer`, children: [
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core3.FormField, { className: formField, children: [
|
|
1342
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core3.FormFieldLabel, { children: "Group" }),
|
|
1343
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1344
|
+
import_vuu_ui_controls3.ComboBox,
|
|
1345
|
+
{
|
|
1346
|
+
source: groups,
|
|
1347
|
+
allowFreeText: true,
|
|
1348
|
+
InputProps: {
|
|
1349
|
+
inputProps: {
|
|
1350
|
+
className: `${classBase3}-inputText`,
|
|
1351
|
+
placeholder: "Select Group or Enter New Name",
|
|
1352
|
+
onChange: (event) => setGroup(event.target.value)
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
width: "100%",
|
|
1356
|
+
onSelectionChange: (_, value) => setGroup(value || "")
|
|
1357
|
+
}
|
|
1358
|
+
)
|
|
1359
|
+
] }),
|
|
1360
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core3.FormField, { className: formField, children: [
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core3.FormFieldLabel, { children: "Layout Name" }),
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1363
|
+
import_core3.Input,
|
|
1364
|
+
{
|
|
1365
|
+
inputProps: {
|
|
1366
|
+
className: `${classBase3}-inputText`,
|
|
1367
|
+
placeholder: "Enter Layout Name"
|
|
1368
|
+
},
|
|
1369
|
+
onChange: (event) => setLayoutName(event.target.value),
|
|
1370
|
+
value: layoutName
|
|
1371
|
+
}
|
|
1372
|
+
)
|
|
1373
|
+
] }),
|
|
1374
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core3.FormField, { className: formField, children: [
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core3.FormFieldLabel, { children: "Some Layout Setting" }),
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${classBase3}-settingsGroup`, children: checkboxValues.map((value, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1377
|
+
import_vuu_ui_controls3.Checkbox,
|
|
1378
|
+
{
|
|
1379
|
+
onToggle: () => setCheckValues(
|
|
1380
|
+
(prev) => prev.includes(value) ? prev.filter((entry) => entry !== value) : [...prev, value]
|
|
1381
|
+
),
|
|
1382
|
+
checked: checkValues.includes(value),
|
|
1383
|
+
label: value
|
|
1384
|
+
},
|
|
1385
|
+
i
|
|
1386
|
+
)) })
|
|
1387
|
+
] }),
|
|
1388
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core3.FormField, { className: formField, children: [
|
|
1389
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core3.FormFieldLabel, { children: "Some Layout Setting" }),
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${classBase3}-settingsGroup`, children: radioValues.map((value, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1391
|
+
import_vuu_ui_controls3.RadioButton,
|
|
1392
|
+
{
|
|
1393
|
+
onClick: () => setRadioValue(value),
|
|
1394
|
+
checked: radioValue === value,
|
|
1395
|
+
label: value,
|
|
1396
|
+
groupName: "radioGroup"
|
|
1397
|
+
},
|
|
1398
|
+
i
|
|
1399
|
+
)) })
|
|
1400
|
+
] })
|
|
1401
|
+
] }),
|
|
1402
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${classBase3}-screenshotContainer`, children: screenshotContent })
|
|
1403
|
+
] }),
|
|
1404
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${classBase3}-buttonsContainer`, children: [
|
|
1405
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core3.Button, { className: `${classBase3}-cancelButton`, onClick: onCancel, children: "Cancel" }),
|
|
1406
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1407
|
+
import_core3.Button,
|
|
1408
|
+
{
|
|
1409
|
+
className: `${classBase3}-saveButton`,
|
|
1410
|
+
onClick: handleSubmit,
|
|
1411
|
+
disabled: layoutName === "" || group === "",
|
|
1412
|
+
children: "Save"
|
|
1413
|
+
}
|
|
1414
|
+
)
|
|
1415
|
+
] })
|
|
1416
|
+
] });
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
// src/layout-management/LayoutList.tsx
|
|
1420
|
+
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
1421
|
+
|
|
1422
|
+
// src/layout-management/useLayoutManager.tsx
|
|
1423
|
+
var import_react9 = __toESM(require("react"));
|
|
1424
|
+
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
1425
|
+
var import_vuu_popups = require("@vuu-ui/vuu-popups");
|
|
1426
|
+
|
|
1427
|
+
// src/persistence-management/defaultApplicationJson.ts
|
|
1428
|
+
var loadingApplicationJson = {
|
|
1429
|
+
layout: {
|
|
1430
|
+
type: "Component",
|
|
1431
|
+
id: "loading-main",
|
|
1432
|
+
props: {}
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
var defaultApplicationJson = {
|
|
1436
|
+
layout: {
|
|
1437
|
+
type: "Stack",
|
|
1438
|
+
id: "main-tabs",
|
|
1439
|
+
props: {
|
|
1440
|
+
className: "vuuShell-mainTabs",
|
|
1441
|
+
TabstripProps: {
|
|
1442
|
+
allowAddTab: true,
|
|
1443
|
+
allowCloseTab: true,
|
|
1444
|
+
allowRenameTab: true,
|
|
1445
|
+
animateSelectionThumb: false,
|
|
1446
|
+
location: "main-tab",
|
|
1447
|
+
variant: "primary"
|
|
1448
|
+
},
|
|
1449
|
+
preserve: true,
|
|
1450
|
+
active: 0
|
|
1451
|
+
},
|
|
1452
|
+
children: [
|
|
1453
|
+
{
|
|
1454
|
+
props: {
|
|
1455
|
+
id: "tab1",
|
|
1456
|
+
title: "Tab 1",
|
|
1457
|
+
className: "vuuShell-Placeholder"
|
|
1458
|
+
},
|
|
1459
|
+
type: "Placeholder"
|
|
1460
|
+
}
|
|
1461
|
+
]
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
|
|
1465
|
+
// src/persistence-management/LocalPersistenceManager.ts
|
|
1466
|
+
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
1467
|
+
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
1468
|
+
var baseMetadataSaveLocation = "layouts/metadata";
|
|
1469
|
+
var baseLayoutsSaveLocation = "layouts/layouts";
|
|
1470
|
+
var _urlKey;
|
|
1471
|
+
var LocalPersistenceManager = class {
|
|
1472
|
+
constructor(urlKey) {
|
|
1473
|
+
this.username = getAuthDetailsFromCookies()[0];
|
|
1474
|
+
this.metadataSaveLocation = `${baseMetadataSaveLocation}/${this.username}`;
|
|
1475
|
+
this.layoutsSaveLocation = `${baseLayoutsSaveLocation}/${this.username}`;
|
|
1476
|
+
__privateAdd(this, _urlKey, `api/vui/${this.username}`);
|
|
1477
|
+
this.loadLayouts = () => {
|
|
1478
|
+
return new Promise((resolve) => {
|
|
1479
|
+
const layouts = (0, import_vuu_utils2.getLocalEntity)(this.layoutsSaveLocation);
|
|
1480
|
+
resolve(layouts || []);
|
|
1481
|
+
});
|
|
1482
|
+
};
|
|
1483
|
+
this.saveLayoutsWithMetadata = (layouts, metadata) => {
|
|
1484
|
+
(0, import_vuu_utils2.saveLocalEntity)(this.layoutsSaveLocation, layouts);
|
|
1485
|
+
(0, import_vuu_utils2.saveLocalEntity)(this.metadataSaveLocation, metadata);
|
|
1486
|
+
};
|
|
1487
|
+
// Ensures that there is exactly one Layout entry and exactly one Metadata
|
|
1488
|
+
// entry in local storage corresponding to the provided ID.
|
|
1489
|
+
this.validateIds = async (id) => {
|
|
1490
|
+
return Promise.all([
|
|
1491
|
+
this.validateId(id, "metadata").catch((error2) => error2.message),
|
|
1492
|
+
this.validateId(id, "layout").catch((error2) => error2.message)
|
|
1493
|
+
]).then((errorMessages) => {
|
|
1494
|
+
const combinedMessage = errorMessages.filter((msg) => msg !== void 0).join("; ");
|
|
1495
|
+
if (combinedMessage) {
|
|
1496
|
+
throw new Error(combinedMessage);
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
};
|
|
1500
|
+
// Ensures that there is exactly one element (Layout or Metadata) in local
|
|
1501
|
+
// storage corresponding to the provided ID.
|
|
1502
|
+
this.validateId = (id, dataType) => {
|
|
1503
|
+
return new Promise((resolve, reject) => {
|
|
1504
|
+
const loadFunc = dataType === "metadata" ? () => this.loadMetadata() : () => this.loadLayouts();
|
|
1505
|
+
loadFunc().then((array) => {
|
|
1506
|
+
const count = array.filter((element) => element.id === id).length;
|
|
1507
|
+
switch (count) {
|
|
1508
|
+
case 1: {
|
|
1509
|
+
resolve();
|
|
1510
|
+
break;
|
|
1511
|
+
}
|
|
1512
|
+
case 0: {
|
|
1513
|
+
reject(new Error(`No ${dataType} with ID ${id}`));
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
default:
|
|
1517
|
+
reject(new Error(`Non-unique ${dataType} with ID ${id}`));
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
});
|
|
1521
|
+
};
|
|
1522
|
+
if (urlKey) {
|
|
1523
|
+
__privateSet(this, _urlKey, urlKey);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
createLayout(metadata, layout) {
|
|
1527
|
+
return new Promise((resolve) => {
|
|
1528
|
+
Promise.all([this.loadLayouts(), this.loadMetadata()]).then(
|
|
1529
|
+
([existingLayouts, existingMetadata]) => {
|
|
1530
|
+
const id = (0, import_vuu_utils3.getUniqueId)();
|
|
1531
|
+
const newMetadata = {
|
|
1532
|
+
...metadata,
|
|
1533
|
+
id,
|
|
1534
|
+
created: (0, import_vuu_utils3.formatDate)({ date: "dd.mm.yyyy" })(/* @__PURE__ */ new Date())
|
|
1535
|
+
};
|
|
1536
|
+
this.saveLayoutsWithMetadata(
|
|
1537
|
+
[...existingLayouts, { id, json: layout }],
|
|
1538
|
+
[...existingMetadata, newMetadata]
|
|
1539
|
+
);
|
|
1540
|
+
resolve(newMetadata);
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
updateLayout(id, newMetadata, newLayout) {
|
|
1546
|
+
return new Promise((resolve, reject) => {
|
|
1547
|
+
this.validateIds(id).then(() => Promise.all([this.loadLayouts(), this.loadMetadata()])).then(([existingLayouts, existingMetadata]) => {
|
|
1548
|
+
const updatedLayouts = existingLayouts.map(
|
|
1549
|
+
(layout) => layout.id === id ? { ...layout, json: newLayout } : layout
|
|
1550
|
+
);
|
|
1551
|
+
const updatedMetadata = existingMetadata.map(
|
|
1552
|
+
(metadata) => metadata.id === id ? { ...metadata, ...newMetadata } : metadata
|
|
1553
|
+
);
|
|
1554
|
+
this.saveLayoutsWithMetadata(updatedLayouts, updatedMetadata);
|
|
1555
|
+
resolve();
|
|
1556
|
+
}).catch((e) => reject(e));
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
deleteLayout(id) {
|
|
1560
|
+
return new Promise((resolve, reject) => {
|
|
1561
|
+
this.validateIds(id).then(() => Promise.all([this.loadLayouts(), this.loadMetadata()])).then(([existingLayouts, existingMetadata]) => {
|
|
1562
|
+
const layouts = existingLayouts.filter((layout) => layout.id !== id);
|
|
1563
|
+
const metadata = existingMetadata.filter(
|
|
1564
|
+
(metadata2) => metadata2.id !== id
|
|
1565
|
+
);
|
|
1566
|
+
this.saveLayoutsWithMetadata(layouts, metadata);
|
|
1567
|
+
resolve();
|
|
1568
|
+
}).catch((e) => reject(e));
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
loadLayout(id) {
|
|
1572
|
+
return new Promise((resolve, reject) => {
|
|
1573
|
+
this.validateId(id, "layout").then(() => this.loadLayouts()).then((existingLayouts) => {
|
|
1574
|
+
const foundLayout = existingLayouts.find(
|
|
1575
|
+
(layout) => layout.id === id
|
|
1576
|
+
);
|
|
1577
|
+
if (foundLayout) {
|
|
1578
|
+
resolve(foundLayout.json);
|
|
1579
|
+
} else {
|
|
1580
|
+
reject(new Error(`no layout found matching id ${id}`));
|
|
1581
|
+
}
|
|
1582
|
+
}).catch((e) => reject(e));
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
loadMetadata() {
|
|
1586
|
+
return new Promise((resolve) => {
|
|
1587
|
+
const metadata = (0, import_vuu_utils2.getLocalEntity)(
|
|
1588
|
+
this.metadataSaveLocation
|
|
1589
|
+
);
|
|
1590
|
+
resolve(metadata || []);
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
loadApplicationJSON() {
|
|
1594
|
+
return new Promise((resolve) => {
|
|
1595
|
+
const applicationJSON = (0, import_vuu_utils2.getLocalEntity)(__privateGet(this, _urlKey));
|
|
1596
|
+
if (applicationJSON) {
|
|
1597
|
+
resolve(applicationJSON);
|
|
1598
|
+
} else {
|
|
1599
|
+
resolve(defaultApplicationJson);
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
saveApplicationJSON(applicationJSON) {
|
|
1604
|
+
return new Promise((resolve, reject) => {
|
|
1605
|
+
const savedLayout = (0, import_vuu_utils2.saveLocalEntity)(
|
|
1606
|
+
__privateGet(this, _urlKey),
|
|
1607
|
+
applicationJSON
|
|
1608
|
+
);
|
|
1609
|
+
if (savedLayout) {
|
|
1610
|
+
resolve();
|
|
1611
|
+
} else {
|
|
1612
|
+
reject(new Error("Application Json failed to save"));
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
_urlKey = new WeakMap();
|
|
1618
|
+
|
|
1619
|
+
// src/persistence-management/useLayoutContextMenuItems.tsx
|
|
1620
|
+
var import_react8 = require("react");
|
|
1621
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1622
|
+
var useLayoutContextMenuItems = (setDialogState) => {
|
|
1623
|
+
const { saveLayout } = useLayoutManager();
|
|
1624
|
+
const handleCloseDialog = (0, import_react8.useCallback)(() => {
|
|
1625
|
+
setDialogState(void 0);
|
|
1626
|
+
}, [setDialogState]);
|
|
1627
|
+
const handleSave = (0, import_react8.useCallback)(
|
|
1628
|
+
(layoutMetadata) => {
|
|
1629
|
+
saveLayout(layoutMetadata);
|
|
1630
|
+
setDialogState(void 0);
|
|
1631
|
+
},
|
|
1632
|
+
[saveLayout, setDialogState]
|
|
1633
|
+
);
|
|
1634
|
+
const [buildMenuOptions, handleMenuAction] = (0, import_react8.useMemo)(() => {
|
|
1635
|
+
return [
|
|
1636
|
+
(location, options) => {
|
|
1637
|
+
const locations = location.split(" ");
|
|
1638
|
+
const menuDescriptors = [];
|
|
1639
|
+
if (locations.includes("main-tab")) {
|
|
1640
|
+
menuDescriptors.push(
|
|
1641
|
+
{
|
|
1642
|
+
label: "Save Layout",
|
|
1643
|
+
action: "save-layout",
|
|
1644
|
+
options
|
|
1645
|
+
},
|
|
1646
|
+
{
|
|
1647
|
+
label: "Layout Settings",
|
|
1648
|
+
action: "layout-settings",
|
|
1649
|
+
options
|
|
1650
|
+
}
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
return menuDescriptors;
|
|
1654
|
+
},
|
|
1655
|
+
(action) => {
|
|
1656
|
+
var _a, _b;
|
|
1657
|
+
console.log("menu action", {
|
|
1658
|
+
action
|
|
1659
|
+
});
|
|
1660
|
+
if (action.menuId === "save-layout") {
|
|
1661
|
+
setDialogState({
|
|
1662
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1663
|
+
SaveLayoutPanel,
|
|
1664
|
+
{
|
|
1665
|
+
onCancel: handleCloseDialog,
|
|
1666
|
+
onSave: handleSave,
|
|
1667
|
+
componentId: (_a = action.options) == null ? void 0 : _a.controlledComponentId,
|
|
1668
|
+
defaultTitle: (_b = action.options) == null ? void 0 : _b.controlledComponentTitle
|
|
1669
|
+
}
|
|
1670
|
+
),
|
|
1671
|
+
title: "Save Layout",
|
|
1672
|
+
hideCloseButton: true
|
|
1673
|
+
});
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
return false;
|
|
1677
|
+
}
|
|
1678
|
+
];
|
|
1679
|
+
}, [handleCloseDialog, handleSave, setDialogState]);
|
|
1680
|
+
return {
|
|
1681
|
+
buildMenuOptions,
|
|
1682
|
+
handleMenuAction
|
|
1683
|
+
};
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
// src/layout-management/useLayoutManager.tsx
|
|
1687
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1688
|
+
var _persistenceManager;
|
|
1689
|
+
var getPersistenceManager = () => {
|
|
1690
|
+
if (_persistenceManager === void 0) {
|
|
1691
|
+
_persistenceManager = true ? new LocalPersistenceManager() : new RemotePersistenceManager();
|
|
1692
|
+
}
|
|
1693
|
+
return _persistenceManager;
|
|
1694
|
+
};
|
|
1695
|
+
var LayoutManagementContext = import_react9.default.createContext({
|
|
1696
|
+
getApplicationSettings: () => void 0,
|
|
1697
|
+
layoutMetadata: [],
|
|
1698
|
+
saveLayout: () => void 0,
|
|
1699
|
+
// The default Application JSON will be served if no LayoutManagementProvider
|
|
1700
|
+
applicationJson: defaultApplicationJson,
|
|
1701
|
+
saveApplicationLayout: () => void 0,
|
|
1702
|
+
saveApplicationSettings: () => void 0,
|
|
1703
|
+
loadLayoutById: () => void 0
|
|
1704
|
+
});
|
|
1705
|
+
var ensureLayoutHasTitle = (layout, layoutMetadata) => {
|
|
1706
|
+
var _a;
|
|
1707
|
+
if (((_a = layout.props) == null ? void 0 : _a.title) !== void 0) {
|
|
1708
|
+
return layout;
|
|
1709
|
+
} else {
|
|
1710
|
+
return {
|
|
1711
|
+
...layout,
|
|
1712
|
+
props: {
|
|
1713
|
+
...layout.props,
|
|
1714
|
+
title: layoutMetadata.name
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
var LayoutManagementProvider = (props) => {
|
|
1720
|
+
const [layoutMetadata, setLayoutMetadata] = (0, import_react9.useState)([]);
|
|
1721
|
+
const [, forceRefresh] = (0, import_react9.useState)({});
|
|
1722
|
+
const notify = (0, import_vuu_popups.useNotifications)();
|
|
1723
|
+
const applicationJSONRef = (0, import_react9.useRef)(loadingApplicationJson);
|
|
1724
|
+
const setApplicationJSON = (0, import_react9.useCallback)(
|
|
1725
|
+
(applicationJSON, rerender = true) => {
|
|
1726
|
+
applicationJSONRef.current = applicationJSON;
|
|
1727
|
+
if (rerender) {
|
|
1728
|
+
forceRefresh({});
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
[]
|
|
1732
|
+
);
|
|
1733
|
+
const setApplicationLayout = (0, import_react9.useCallback)(
|
|
1734
|
+
(layout, rerender = true) => {
|
|
1735
|
+
setApplicationJSON(
|
|
1736
|
+
{
|
|
1737
|
+
...applicationJSONRef.current,
|
|
1738
|
+
layout
|
|
1739
|
+
},
|
|
1740
|
+
rerender
|
|
1741
|
+
);
|
|
1742
|
+
},
|
|
1743
|
+
[setApplicationJSON]
|
|
1744
|
+
);
|
|
1745
|
+
const setApplicationSettings = (0, import_react9.useCallback)(
|
|
1746
|
+
(settings) => {
|
|
1747
|
+
setApplicationJSON(
|
|
1748
|
+
{
|
|
1749
|
+
...applicationJSONRef.current,
|
|
1750
|
+
settings: {
|
|
1751
|
+
...applicationJSONRef.current.settings,
|
|
1752
|
+
...settings
|
|
1753
|
+
}
|
|
1754
|
+
},
|
|
1755
|
+
false
|
|
1756
|
+
);
|
|
1757
|
+
},
|
|
1758
|
+
[setApplicationJSON]
|
|
1759
|
+
);
|
|
1760
|
+
(0, import_react9.useEffect)(() => {
|
|
1761
|
+
const persistenceManager = getPersistenceManager();
|
|
1762
|
+
persistenceManager.loadMetadata().then((metadata) => {
|
|
1763
|
+
setLayoutMetadata(metadata);
|
|
1764
|
+
}).catch((error2) => {
|
|
1765
|
+
notify({
|
|
1766
|
+
type: "error",
|
|
1767
|
+
header: "Failed to Load Layouts",
|
|
1768
|
+
body: "Could not load list of available layouts"
|
|
1769
|
+
});
|
|
1770
|
+
console.error("Error occurred while retrieving metadata", error2);
|
|
1771
|
+
});
|
|
1772
|
+
persistenceManager.loadApplicationJSON().then((applicationJSON) => {
|
|
1773
|
+
setApplicationJSON(applicationJSON);
|
|
1774
|
+
}).catch((error2) => {
|
|
1775
|
+
notify({
|
|
1776
|
+
type: "error",
|
|
1777
|
+
header: "Failed to Load Layout",
|
|
1778
|
+
body: "Could not load your latest view"
|
|
1779
|
+
});
|
|
1780
|
+
console.error(
|
|
1781
|
+
"Error occurred while retrieving application layout",
|
|
1782
|
+
error2
|
|
1783
|
+
);
|
|
1784
|
+
});
|
|
1785
|
+
}, [notify, setApplicationJSON]);
|
|
1786
|
+
const saveApplicationLayout = (0, import_react9.useCallback)(
|
|
1787
|
+
(layout) => {
|
|
1788
|
+
if ((0, import_vuu_layout2.isLayoutJSON)(layout)) {
|
|
1789
|
+
setApplicationLayout(layout, false);
|
|
1790
|
+
getPersistenceManager().saveApplicationJSON(applicationJSONRef.current);
|
|
1791
|
+
} else {
|
|
1792
|
+
console.error("Tried to save invalid application layout", layout);
|
|
1793
|
+
}
|
|
1794
|
+
},
|
|
1795
|
+
[setApplicationLayout]
|
|
1796
|
+
);
|
|
1797
|
+
const saveLayout = (0, import_react9.useCallback)(
|
|
1798
|
+
(metadata) => {
|
|
1799
|
+
const layoutToSave = (0, import_vuu_layout2.resolveJSONPath)(
|
|
1800
|
+
applicationJSONRef.current.layout,
|
|
1801
|
+
"#main-tabs.ACTIVE_CHILD"
|
|
1802
|
+
);
|
|
1803
|
+
if (layoutToSave && (0, import_vuu_layout2.isLayoutJSON)(layoutToSave)) {
|
|
1804
|
+
getPersistenceManager().createLayout(metadata, ensureLayoutHasTitle(layoutToSave, metadata)).then((metadata2) => {
|
|
1805
|
+
notify({
|
|
1806
|
+
type: "success",
|
|
1807
|
+
header: "Layout Saved Successfully",
|
|
1808
|
+
body: `${metadata2.name} saved successfully`
|
|
1809
|
+
});
|
|
1810
|
+
setLayoutMetadata((prev) => [...prev, metadata2]);
|
|
1811
|
+
}).catch((error2) => {
|
|
1812
|
+
notify({
|
|
1813
|
+
type: "error",
|
|
1814
|
+
header: "Failed to Save Layout",
|
|
1815
|
+
body: `Failed to save layout ${metadata.name}`
|
|
1816
|
+
});
|
|
1817
|
+
console.error("Error occurred while saving layout", error2);
|
|
1818
|
+
});
|
|
1819
|
+
} else {
|
|
1820
|
+
console.error("Tried to save invalid layout", layoutToSave);
|
|
1821
|
+
notify({
|
|
1822
|
+
type: "error",
|
|
1823
|
+
header: "Failed to Save Layout",
|
|
1824
|
+
body: "Cannot save invalid layout"
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
},
|
|
1828
|
+
[notify]
|
|
1829
|
+
);
|
|
1830
|
+
const saveApplicationSettings = (0, import_react9.useCallback)(
|
|
1831
|
+
(settings, key) => {
|
|
1832
|
+
const { settings: applicationSettings } = applicationJSONRef.current;
|
|
1833
|
+
if (key) {
|
|
1834
|
+
setApplicationSettings({
|
|
1835
|
+
...applicationSettings,
|
|
1836
|
+
[key]: settings
|
|
1837
|
+
});
|
|
1838
|
+
} else {
|
|
1839
|
+
setApplicationSettings(settings);
|
|
1840
|
+
}
|
|
1841
|
+
getPersistenceManager().saveApplicationJSON(applicationJSONRef.current);
|
|
1842
|
+
},
|
|
1843
|
+
[setApplicationSettings]
|
|
1844
|
+
);
|
|
1845
|
+
const getApplicationSettings = (0, import_react9.useCallback)(
|
|
1846
|
+
(key) => {
|
|
1847
|
+
const { settings } = applicationJSONRef.current;
|
|
1848
|
+
return key ? settings == null ? void 0 : settings[key] : settings;
|
|
1849
|
+
},
|
|
1850
|
+
[]
|
|
1851
|
+
);
|
|
1852
|
+
const loadLayoutById = (0, import_react9.useCallback)(
|
|
1853
|
+
(id) => {
|
|
1854
|
+
getPersistenceManager().loadLayout(id).then((layoutJson) => {
|
|
1855
|
+
var _a, _b;
|
|
1856
|
+
const { layout: currentLayout } = applicationJSONRef.current;
|
|
1857
|
+
setApplicationLayout({
|
|
1858
|
+
...currentLayout,
|
|
1859
|
+
children: (currentLayout.children || []).concat(layoutJson),
|
|
1860
|
+
props: {
|
|
1861
|
+
...currentLayout.props,
|
|
1862
|
+
active: (_b = (_a = currentLayout.children) == null ? void 0 : _a.length) != null ? _b : 0
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
}).catch((error2) => {
|
|
1866
|
+
notify({
|
|
1867
|
+
type: "error",
|
|
1868
|
+
header: "Failed to Load Layout",
|
|
1869
|
+
body: "Failed to load the requested layout"
|
|
1870
|
+
});
|
|
1871
|
+
console.error("Error occurred while loading layout", error2);
|
|
1872
|
+
});
|
|
1873
|
+
},
|
|
1874
|
+
[notify, setApplicationLayout]
|
|
1875
|
+
);
|
|
1876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1877
|
+
LayoutManagementContext.Provider,
|
|
1878
|
+
{
|
|
1879
|
+
value: {
|
|
1880
|
+
getApplicationSettings,
|
|
1881
|
+
layoutMetadata,
|
|
1882
|
+
saveLayout,
|
|
1883
|
+
applicationJson: applicationJSONRef.current,
|
|
1884
|
+
saveApplicationLayout,
|
|
1885
|
+
saveApplicationSettings,
|
|
1886
|
+
loadLayoutById
|
|
1887
|
+
},
|
|
1888
|
+
children: props.children
|
|
1889
|
+
}
|
|
1890
|
+
);
|
|
1891
|
+
};
|
|
1892
|
+
var useLayoutManager = () => (0, import_react9.useContext)(LayoutManagementContext);
|
|
1893
|
+
|
|
1894
|
+
// src/layout-management/LayoutTile.tsx
|
|
1895
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1896
|
+
var classBase4 = "vuuLayoutTile";
|
|
1897
|
+
var LayoutTile = (props) => {
|
|
1898
|
+
const { metadata, handleLoadLayout } = props;
|
|
1899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { role: "listitem", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1900
|
+
"div",
|
|
1901
|
+
{
|
|
1902
|
+
className: `${classBase4}-layoutTile`,
|
|
1903
|
+
role: "button",
|
|
1904
|
+
onClick: () => handleLoadLayout(metadata == null ? void 0 : metadata.id),
|
|
1905
|
+
children: [
|
|
1906
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { className: `${classBase4}-screenshot`, src: metadata == null ? void 0 : metadata.screenshot }),
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
|
|
1908
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `${classBase4}-layoutName`, children: metadata == null ? void 0 : metadata.name }),
|
|
1909
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `${classBase4}-layoutDetails`, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: `${metadata == null ? void 0 : metadata.user}, ${metadata == null ? void 0 : metadata.created}` }) })
|
|
1910
|
+
] })
|
|
1911
|
+
]
|
|
1912
|
+
},
|
|
1913
|
+
metadata == null ? void 0 : metadata.id
|
|
1914
|
+
) });
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1917
|
+
// src/layout-management/LayoutList.tsx
|
|
1918
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1919
|
+
var classBase5 = "vuuLayoutList";
|
|
1920
|
+
var LayoutList = (props) => {
|
|
1921
|
+
const { layoutMetadata, loadLayoutById } = useLayoutManager();
|
|
1922
|
+
const handleLoadLayout = (layoutId) => {
|
|
1923
|
+
if (layoutId) {
|
|
1924
|
+
loadLayoutById(layoutId);
|
|
1925
|
+
}
|
|
1926
|
+
};
|
|
1927
|
+
const layoutsByGroup = layoutMetadata.reduce((acc, cur) => {
|
|
1928
|
+
if (acc[cur.group]) {
|
|
1929
|
+
return {
|
|
1930
|
+
...acc,
|
|
1931
|
+
[cur.group]: [...acc[cur.group], cur]
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
return {
|
|
1935
|
+
...acc,
|
|
1936
|
+
[cur.group]: [cur]
|
|
1937
|
+
};
|
|
1938
|
+
}, {});
|
|
1939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1940
|
+
"div",
|
|
1941
|
+
{
|
|
1942
|
+
className: classBase5,
|
|
1943
|
+
...props,
|
|
1944
|
+
role: "listbox",
|
|
1945
|
+
"aria-label": "my layouts",
|
|
1946
|
+
children: [
|
|
1947
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase5}-header`, children: "My Layouts" }),
|
|
1948
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1949
|
+
import_vuu_ui_controls4.List,
|
|
1950
|
+
{
|
|
1951
|
+
height: "auto",
|
|
1952
|
+
source: Object.entries(layoutsByGroup),
|
|
1953
|
+
ListItem: ({ item }) => {
|
|
1954
|
+
if (!item)
|
|
1955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {});
|
|
1956
|
+
const [groupName, layoutMetadata2] = item;
|
|
1957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "list", "aria-label": groupName, children: [
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase5}-groupName`, children: groupName }),
|
|
1959
|
+
layoutMetadata2.map((metadata) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1960
|
+
LayoutTile,
|
|
1961
|
+
{
|
|
1962
|
+
metadata,
|
|
1963
|
+
handleLoadLayout
|
|
1964
|
+
},
|
|
1965
|
+
metadata.id
|
|
1966
|
+
))
|
|
1967
|
+
] });
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
)
|
|
1971
|
+
]
|
|
1972
|
+
}
|
|
1973
|
+
);
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
// src/left-nav/LeftNav.tsx
|
|
1977
|
+
var import_vuu_icons = require("@vuu-ui/vuu-icons");
|
|
1978
|
+
var import_vuu_layout4 = require("@vuu-ui/vuu-layout");
|
|
1979
|
+
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
1980
|
+
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
1981
|
+
var import_clsx4 = __toESM(require("clsx"));
|
|
1982
|
+
var import_react10 = require("react");
|
|
1983
|
+
|
|
1984
|
+
// src/feature-list/FeatureList.tsx
|
|
1985
|
+
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
1986
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1987
|
+
var classBase6 = "vuuFeatureList";
|
|
1988
|
+
var FeatureList = ({
|
|
1989
|
+
features,
|
|
1990
|
+
title = "VUU TABLES",
|
|
1991
|
+
...htmlAttributes
|
|
1992
|
+
}) => {
|
|
1993
|
+
const ViewProps2 = {};
|
|
1994
|
+
const listProps = {
|
|
1995
|
+
height: "100%"
|
|
1996
|
+
};
|
|
1997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ...htmlAttributes, className: classBase6, children: [
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `${classBase6}-header`, children: title }),
|
|
1999
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `${classBase6}-content`, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2000
|
+
import_vuu_layout3.Palette,
|
|
2001
|
+
{
|
|
2002
|
+
orientation: "vertical",
|
|
2003
|
+
ListProps: listProps,
|
|
2004
|
+
ViewProps: ViewProps2,
|
|
2005
|
+
children: features.map((featureProps, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2006
|
+
import_vuu_layout3.PaletteItem,
|
|
2007
|
+
{
|
|
2008
|
+
closeable: true,
|
|
2009
|
+
label: featureProps.title,
|
|
2010
|
+
resizeable: true,
|
|
2011
|
+
resize: "defer",
|
|
2012
|
+
header: true,
|
|
2013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Feature, { ...featureProps })
|
|
2014
|
+
},
|
|
2015
|
+
i
|
|
2016
|
+
))
|
|
2017
|
+
}
|
|
2018
|
+
) })
|
|
2019
|
+
] });
|
|
2020
|
+
};
|
|
2021
|
+
|
|
2022
|
+
// src/left-nav/LeftNav.tsx
|
|
2023
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2024
|
+
var classBase7 = "vuuLeftNav";
|
|
2025
|
+
var getDisplayStatus = (activeTabIndex, expanded) => {
|
|
2026
|
+
if (activeTabIndex === 0) {
|
|
2027
|
+
return expanded ? "menu-full" : "menu-icons";
|
|
2028
|
+
} else {
|
|
2029
|
+
return expanded ? "menu-full-content" : "menu-icons-content";
|
|
2030
|
+
}
|
|
2031
|
+
};
|
|
2032
|
+
var LeftNav = (props) => {
|
|
2033
|
+
const dispatch = (0, import_vuu_layout4.useLayoutProviderDispatch)();
|
|
2034
|
+
const [themeClass] = (0, import_vuu_utils4.useThemeAttributes)();
|
|
2035
|
+
const {
|
|
2036
|
+
"data-path": path,
|
|
2037
|
+
defaultExpanded = true,
|
|
2038
|
+
defaultActiveTabIndex = 0,
|
|
2039
|
+
features,
|
|
2040
|
+
onActiveChange,
|
|
2041
|
+
onTogglePrimaryMenu,
|
|
2042
|
+
sizeCollapsed = 80,
|
|
2043
|
+
sizeContent = 300,
|
|
2044
|
+
sizeExpanded = 240,
|
|
2045
|
+
style: styleProp,
|
|
2046
|
+
tableFeatures,
|
|
2047
|
+
...htmlAttributes
|
|
2048
|
+
} = props;
|
|
2049
|
+
const [navState, setNavState] = (0, import_react10.useState)({
|
|
2050
|
+
activeTabIndex: defaultActiveTabIndex,
|
|
2051
|
+
expanded: defaultExpanded
|
|
2052
|
+
});
|
|
2053
|
+
const getFullWidth = (0, import_react10.useCallback)(
|
|
2054
|
+
(tabIndex, expanded) => {
|
|
2055
|
+
if (tabIndex === 0) {
|
|
2056
|
+
return expanded ? sizeExpanded : sizeCollapsed;
|
|
2057
|
+
} else {
|
|
2058
|
+
return expanded ? sizeExpanded + sizeContent : sizeCollapsed + sizeContent;
|
|
2059
|
+
}
|
|
2060
|
+
},
|
|
2061
|
+
[sizeCollapsed, sizeContent, sizeExpanded]
|
|
2062
|
+
);
|
|
2063
|
+
const handleTabSelection = (0, import_react10.useCallback)(
|
|
2064
|
+
(activeTabIndex) => {
|
|
2065
|
+
const { activeTabIndex: currentIndex, expanded } = navState;
|
|
2066
|
+
const newState = { activeTabIndex, expanded };
|
|
2067
|
+
setNavState(newState);
|
|
2068
|
+
if (activeTabIndex === 0 || currentIndex === 0) {
|
|
2069
|
+
const width = getFullWidth(activeTabIndex, expanded);
|
|
2070
|
+
dispatch({
|
|
2071
|
+
type: "layout-resize",
|
|
2072
|
+
path: "#vuu-side-panel",
|
|
2073
|
+
size: width
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
onActiveChange == null ? void 0 : onActiveChange(activeTabIndex);
|
|
2077
|
+
},
|
|
2078
|
+
[dispatch, getFullWidth, navState, onActiveChange]
|
|
2079
|
+
);
|
|
2080
|
+
const displayStatus = getDisplayStatus(
|
|
2081
|
+
navState.activeTabIndex,
|
|
2082
|
+
navState.expanded
|
|
2083
|
+
);
|
|
2084
|
+
const toggleExpanded = (0, import_react10.useCallback)(() => {
|
|
2085
|
+
const { activeTabIndex, expanded } = navState;
|
|
2086
|
+
const primaryMenuExpanded = !expanded;
|
|
2087
|
+
const newState = { activeTabIndex, expanded: primaryMenuExpanded };
|
|
2088
|
+
setNavState(newState);
|
|
2089
|
+
dispatch({
|
|
2090
|
+
type: "layout-resize",
|
|
2091
|
+
path: "#vuu-side-panel",
|
|
2092
|
+
size: getFullWidth(activeTabIndex, primaryMenuExpanded)
|
|
2093
|
+
});
|
|
2094
|
+
onTogglePrimaryMenu == null ? void 0 : onTogglePrimaryMenu(primaryMenuExpanded);
|
|
2095
|
+
}, [dispatch, getFullWidth, navState, onTogglePrimaryMenu]);
|
|
2096
|
+
const style = {
|
|
2097
|
+
...styleProp,
|
|
2098
|
+
"--nav-menu-collapsed-width": `${sizeCollapsed}px`,
|
|
2099
|
+
"--nav-menu-expanded-width": `${sizeExpanded}px`,
|
|
2100
|
+
"--nav-menu-content-width": `${sizeContent}px`
|
|
2101
|
+
};
|
|
2102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2103
|
+
"div",
|
|
2104
|
+
{
|
|
2105
|
+
...htmlAttributes,
|
|
2106
|
+
className: (0, import_clsx4.default)(classBase7, `${classBase7}-${displayStatus}`),
|
|
2107
|
+
style,
|
|
2108
|
+
children: [
|
|
2109
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2110
|
+
"div",
|
|
2111
|
+
{
|
|
2112
|
+
className: (0, import_clsx4.default)(`${classBase7}-menu-primary`, themeClass),
|
|
2113
|
+
"data-mode": "dark",
|
|
2114
|
+
children: [
|
|
2115
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "vuuLeftNav-logo", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_vuu_icons.VuuLogo, {}) }),
|
|
2116
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: `${classBase7}-main`, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2117
|
+
import_vuu_ui_controls5.Tabstrip,
|
|
2118
|
+
{
|
|
2119
|
+
activeTabIndex: navState.activeTabIndex,
|
|
2120
|
+
animateSelectionThumb: false,
|
|
2121
|
+
className: `${classBase7}-Tabstrip`,
|
|
2122
|
+
onActiveChange: handleTabSelection,
|
|
2123
|
+
orientation: "vertical",
|
|
2124
|
+
children: [
|
|
2125
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_vuu_ui_controls5.Tab, { "data-icon": "demo", label: "DEMO" }),
|
|
2126
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_vuu_ui_controls5.Tab, { "data-icon": "features", label: "VUU FEATURES" }),
|
|
2127
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_vuu_ui_controls5.Tab, { "data-icon": "tables", label: "VUU TABLES" }),
|
|
2128
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_vuu_ui_controls5.Tab, { "data-icon": "layouts", label: "MY LAYOUTS" })
|
|
2129
|
+
]
|
|
2130
|
+
}
|
|
2131
|
+
) }),
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "vuuLeftNav-buttonBar", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2133
|
+
"button",
|
|
2134
|
+
{
|
|
2135
|
+
className: (0, import_clsx4.default)("vuuLeftNav-toggleButton", {
|
|
2136
|
+
"vuuLeftNav-toggleButton-open": displayStatus.startsWith("menu-full"),
|
|
2137
|
+
"vuuLeftNav-toggleButton-closed": displayStatus.startsWith("menu-icons")
|
|
2138
|
+
}),
|
|
2139
|
+
"data-icon": displayStatus.startsWith("menu-full") ? "chevron-left" : "chevron-right",
|
|
2140
|
+
onClick: toggleExpanded
|
|
2141
|
+
}
|
|
2142
|
+
) })
|
|
2143
|
+
]
|
|
2144
|
+
}
|
|
2145
|
+
),
|
|
2146
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2147
|
+
import_vuu_layout4.Stack,
|
|
2148
|
+
{
|
|
2149
|
+
active: navState.activeTabIndex - 1,
|
|
2150
|
+
className: `${classBase7}-menu-secondary`,
|
|
2151
|
+
showTabs: false,
|
|
2152
|
+
children: [
|
|
2153
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FeatureList, { features, title: "VUU FEATURES" }),
|
|
2154
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FeatureList, { features: tableFeatures, title: "VUU TABLES" }),
|
|
2155
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "vuuLeftNav-drawer", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LayoutList, {}) })
|
|
2156
|
+
]
|
|
2157
|
+
}
|
|
2158
|
+
)
|
|
2159
|
+
]
|
|
2160
|
+
}
|
|
2161
|
+
);
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
// src/session-editing-form/SessionEditingForm.tsx
|
|
2165
|
+
var import_vuu_data_remote = require("@vuu-ui/vuu-data-remote");
|
|
2166
|
+
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
2167
|
+
var import_core4 = require("@salt-ds/core");
|
|
2168
|
+
var import_clsx5 = __toESM(require("clsx"));
|
|
2169
|
+
var import_react11 = require("react");
|
|
2170
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2171
|
+
var classBase8 = "vuuSessionEditingForm";
|
|
2172
|
+
var getField = (fields, name) => {
|
|
2173
|
+
const field = fields.find((f) => f.name === name);
|
|
2174
|
+
if (field) {
|
|
2175
|
+
return field;
|
|
2176
|
+
} else {
|
|
2177
|
+
throw Error(`SessionEditingForm, no field '${name}' found`);
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
var getFieldNameAndValue = (evt) => {
|
|
2181
|
+
const {
|
|
2182
|
+
dataset: { field },
|
|
2183
|
+
value
|
|
2184
|
+
} = evt.target;
|
|
2185
|
+
if (field === void 0) {
|
|
2186
|
+
throw Error("SessionEditingForm, form field has no field name");
|
|
2187
|
+
}
|
|
2188
|
+
return [field, value];
|
|
2189
|
+
};
|
|
2190
|
+
var Status = {
|
|
2191
|
+
uninitialised: 0,
|
|
2192
|
+
unchanged: 1,
|
|
2193
|
+
changed: 2,
|
|
2194
|
+
invalid: 3
|
|
2195
|
+
};
|
|
2196
|
+
function getTypedValue(value, type, throwIfUndefined = false) {
|
|
2197
|
+
switch (type) {
|
|
2198
|
+
case "int":
|
|
2199
|
+
case "long": {
|
|
2200
|
+
const typedValue = parseInt(value, 10);
|
|
2201
|
+
if ((0, import_vuu_utils5.isValidNumber)(typedValue)) {
|
|
2202
|
+
return typedValue;
|
|
2203
|
+
} else if (throwIfUndefined) {
|
|
2204
|
+
throw Error("SessionEditingForm getTypedValue");
|
|
2205
|
+
} else {
|
|
2206
|
+
return void 0;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
case "double": {
|
|
2210
|
+
const typedValue = parseFloat(value);
|
|
2211
|
+
if ((0, import_vuu_utils5.isValidNumber)(typedValue)) {
|
|
2212
|
+
return typedValue;
|
|
2213
|
+
}
|
|
2214
|
+
return void 0;
|
|
2215
|
+
}
|
|
2216
|
+
case "boolean":
|
|
2217
|
+
return value === "true" ? true : false;
|
|
2218
|
+
default:
|
|
2219
|
+
return value;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
var getDataSource = (dataSource, schema) => {
|
|
2223
|
+
if (dataSource) {
|
|
2224
|
+
return dataSource;
|
|
2225
|
+
} else if (schema) {
|
|
2226
|
+
return new import_vuu_data_remote.VuuDataSource({
|
|
2227
|
+
bufferSize: 0,
|
|
2228
|
+
table: schema.table,
|
|
2229
|
+
columns: schema.columns.map((col) => col.name)
|
|
2230
|
+
});
|
|
2231
|
+
} else {
|
|
2232
|
+
throw Error(
|
|
2233
|
+
"SessionEditingForm: either a DataSource or a TableSchema must be provided"
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
var SessionEditingForm = ({
|
|
2238
|
+
className,
|
|
2239
|
+
config: { fields, key: keyField },
|
|
2240
|
+
dataSource: dataSourceProp,
|
|
2241
|
+
id: idProp,
|
|
2242
|
+
onClose,
|
|
2243
|
+
schema,
|
|
2244
|
+
...htmlAttributes
|
|
2245
|
+
}) => {
|
|
2246
|
+
const [values, setValues] = (0, import_react11.useState)();
|
|
2247
|
+
const [errorMessage, setErrorMessage] = (0, import_react11.useState)("");
|
|
2248
|
+
const formContentRef = (0, import_react11.useRef)(null);
|
|
2249
|
+
const initialDataRef = (0, import_react11.useRef)();
|
|
2250
|
+
const dataStatusRef = (0, import_react11.useRef)(Status.uninitialised);
|
|
2251
|
+
const dataSource = (0, import_react11.useMemo)(() => {
|
|
2252
|
+
const applyServerData = (data) => {
|
|
2253
|
+
if (columnMap) {
|
|
2254
|
+
const values2 = {};
|
|
2255
|
+
for (const column of dataSource.columns) {
|
|
2256
|
+
values2[column] = data[columnMap[column]];
|
|
2257
|
+
}
|
|
2258
|
+
if (dataStatusRef.current === Status.uninitialised) {
|
|
2259
|
+
dataStatusRef.current = Status.unchanged;
|
|
2260
|
+
initialDataRef.current = values2;
|
|
2261
|
+
}
|
|
2262
|
+
setValues(values2);
|
|
2263
|
+
}
|
|
2264
|
+
};
|
|
2265
|
+
const ds = getDataSource(dataSourceProp, schema);
|
|
2266
|
+
const columnMap = (0, import_vuu_utils5.buildColumnMap)(ds.columns);
|
|
2267
|
+
ds.subscribe({ range: { from: 0, to: 5 } }, (message) => {
|
|
2268
|
+
if (message.type === "viewport-update" && message.rows) {
|
|
2269
|
+
if (dataStatusRef.current === Status.uninitialised) {
|
|
2270
|
+
applyServerData(message.rows[0]);
|
|
2271
|
+
} else {
|
|
2272
|
+
console.log("what do we do with server updates");
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
return ds;
|
|
2277
|
+
}, [dataSourceProp, schema]);
|
|
2278
|
+
const id = (0, import_core4.useIdMemo)(idProp);
|
|
2279
|
+
const handleChange = (0, import_react11.useCallback)(
|
|
2280
|
+
(evt) => {
|
|
2281
|
+
const [field, value] = getFieldNameAndValue(evt);
|
|
2282
|
+
const { type } = getField(fields, field);
|
|
2283
|
+
const typedValue = getTypedValue(value, type);
|
|
2284
|
+
setValues((values2 = {}) => {
|
|
2285
|
+
const newValues = {
|
|
2286
|
+
...values2,
|
|
2287
|
+
[field]: typedValue
|
|
2288
|
+
};
|
|
2289
|
+
const notUpdated = (0, import_vuu_utils5.shallowEquals)(newValues, initialDataRef.current);
|
|
2290
|
+
dataStatusRef.current = notUpdated ? Status.unchanged : typedValue !== void 0 ? Status.changed : Status.invalid;
|
|
2291
|
+
return newValues;
|
|
2292
|
+
});
|
|
2293
|
+
},
|
|
2294
|
+
[fields]
|
|
2295
|
+
);
|
|
2296
|
+
const handleBlur = (0, import_react11.useCallback)(
|
|
2297
|
+
(evt) => {
|
|
2298
|
+
const [field, value] = getFieldNameAndValue(evt);
|
|
2299
|
+
const { type } = getField(fields, field);
|
|
2300
|
+
const rowKey = values == null ? void 0 : values[keyField];
|
|
2301
|
+
const typedValue = getTypedValue(value, type, true);
|
|
2302
|
+
if (typeof rowKey === "string") {
|
|
2303
|
+
dataSource.menuRpcCall({
|
|
2304
|
+
rowKey,
|
|
2305
|
+
field,
|
|
2306
|
+
value: typedValue,
|
|
2307
|
+
type: "VP_EDIT_CELL_RPC"
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
},
|
|
2311
|
+
[dataSource, fields, keyField, values]
|
|
2312
|
+
);
|
|
2313
|
+
const applyAction = (0, import_react11.useCallback)(
|
|
2314
|
+
(action) => {
|
|
2315
|
+
if (typeof action === "object" && action !== null) {
|
|
2316
|
+
if ("type" in action && action.type === "CLOSE_DIALOG_ACTION") {
|
|
2317
|
+
onClose();
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
},
|
|
2321
|
+
[onClose]
|
|
2322
|
+
);
|
|
2323
|
+
const handleSubmit = (0, import_react11.useCallback)(async () => {
|
|
2324
|
+
const response = await dataSource.menuRpcCall({
|
|
2325
|
+
type: "VP_EDIT_SUBMIT_FORM_RPC"
|
|
2326
|
+
});
|
|
2327
|
+
if ((0, import_vuu_utils5.isErrorResponse)(response)) {
|
|
2328
|
+
setErrorMessage(response.error);
|
|
2329
|
+
} else if ((0, import_vuu_utils5.hasAction)(response)) {
|
|
2330
|
+
applyAction(response.action);
|
|
2331
|
+
}
|
|
2332
|
+
}, [applyAction, dataSource]);
|
|
2333
|
+
const handleKeyDown = (0, import_react11.useCallback)(
|
|
2334
|
+
(evt) => {
|
|
2335
|
+
if (evt.key === "Enter" && dataStatusRef.current === Status.changed) {
|
|
2336
|
+
handleSubmit();
|
|
2337
|
+
}
|
|
2338
|
+
},
|
|
2339
|
+
[handleSubmit]
|
|
2340
|
+
);
|
|
2341
|
+
const handleCancel = (0, import_react11.useCallback)(() => {
|
|
2342
|
+
onClose();
|
|
2343
|
+
}, [onClose]);
|
|
2344
|
+
const getFormControl = (field) => {
|
|
2345
|
+
var _a;
|
|
2346
|
+
const value = String((_a = values == null ? void 0 : values[field.name]) != null ? _a : "");
|
|
2347
|
+
if (field.readonly || field.name === keyField) {
|
|
2348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `${classBase8}-fieldValue vuuReadOnly`, children: value });
|
|
2349
|
+
} else {
|
|
2350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2351
|
+
"input",
|
|
2352
|
+
{
|
|
2353
|
+
className: `${classBase8}-fieldValue`,
|
|
2354
|
+
"data-field": field.name,
|
|
2355
|
+
onBlur: handleBlur,
|
|
2356
|
+
onChange: handleChange,
|
|
2357
|
+
type: "text",
|
|
2358
|
+
value,
|
|
2359
|
+
id: `${id}-input-${field.name}`
|
|
2360
|
+
}
|
|
2361
|
+
);
|
|
2362
|
+
}
|
|
2363
|
+
};
|
|
2364
|
+
(0, import_react11.useEffect)(() => {
|
|
2365
|
+
if (formContentRef.current) {
|
|
2366
|
+
const firstInput = formContentRef.current.querySelector(
|
|
2367
|
+
"input"
|
|
2368
|
+
);
|
|
2369
|
+
if (firstInput) {
|
|
2370
|
+
setTimeout(() => {
|
|
2371
|
+
firstInput.focus();
|
|
2372
|
+
firstInput.select();
|
|
2373
|
+
}, 100);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}, []);
|
|
2377
|
+
(0, import_react11.useEffect)(() => {
|
|
2378
|
+
return () => {
|
|
2379
|
+
if (dataSource) {
|
|
2380
|
+
dataSource.unsubscribe();
|
|
2381
|
+
}
|
|
2382
|
+
};
|
|
2383
|
+
}, [dataSource]);
|
|
2384
|
+
const isDirty = dataStatusRef.current === Status.changed;
|
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ...htmlAttributes, className: (0, import_clsx5.default)(classBase8, className), children: [
|
|
2386
|
+
errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2387
|
+
"div",
|
|
2388
|
+
{
|
|
2389
|
+
className: `${classBase8}-errorBanner`,
|
|
2390
|
+
"data-icon": "error",
|
|
2391
|
+
title: errorMessage,
|
|
2392
|
+
children: "Error, edit(s) not saved"
|
|
2393
|
+
}
|
|
2394
|
+
) : void 0,
|
|
2395
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2396
|
+
"div",
|
|
2397
|
+
{
|
|
2398
|
+
className: `${classBase8}-content`,
|
|
2399
|
+
ref: formContentRef,
|
|
2400
|
+
onKeyDown: handleKeyDown,
|
|
2401
|
+
children: fields.map((field) => {
|
|
2402
|
+
var _a;
|
|
2403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `${classBase8}-field`, children: [
|
|
2404
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2405
|
+
"label",
|
|
2406
|
+
{
|
|
2407
|
+
className: (0, import_clsx5.default)(`${classBase8}-fieldLabel`, {
|
|
2408
|
+
[`${classBase8}-required`]: field.required
|
|
2409
|
+
}),
|
|
2410
|
+
htmlFor: `${id}-input-${field.name}`,
|
|
2411
|
+
children: (_a = field == null ? void 0 : field.label) != null ? _a : field.description
|
|
2412
|
+
}
|
|
2413
|
+
),
|
|
2414
|
+
getFormControl(field)
|
|
2415
|
+
] }, field.name);
|
|
2416
|
+
})
|
|
2417
|
+
}
|
|
2418
|
+
),
|
|
2419
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `${classBase8}-buttonbar salt-theme salt-density-high`, children: [
|
|
2420
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2421
|
+
import_core4.Button,
|
|
2422
|
+
{
|
|
2423
|
+
type: "submit",
|
|
2424
|
+
variant: "cta",
|
|
2425
|
+
disabled: !isDirty,
|
|
2426
|
+
onClick: handleSubmit,
|
|
2427
|
+
children: "Submit"
|
|
2428
|
+
}
|
|
2429
|
+
),
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core4.Button, { variant: "secondary", onClick: handleCancel, children: "Cancel" })
|
|
2431
|
+
] })
|
|
2432
|
+
] });
|
|
2433
|
+
};
|
|
2434
|
+
|
|
2435
|
+
// src/shell.tsx
|
|
2436
|
+
var import_vuu_data_remote2 = require("@vuu-ui/vuu-data-remote");
|
|
2437
|
+
var import_vuu_layout8 = require("@vuu-ui/vuu-layout");
|
|
2438
|
+
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
2439
|
+
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
2440
|
+
var import_clsx8 = __toESM(require("clsx"));
|
|
2441
|
+
var import_react15 = require("react");
|
|
2442
|
+
|
|
2443
|
+
// src/shell-layouts/context-panel/ContextPanel.tsx
|
|
2444
|
+
var import_core5 = require("@salt-ds/core");
|
|
2445
|
+
var import_clsx6 = __toESM(require("clsx"));
|
|
2446
|
+
var import_react12 = require("react");
|
|
2447
|
+
var import_vuu_layout5 = require("@vuu-ui/vuu-layout");
|
|
2448
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2449
|
+
var classBase9 = "vuuContextPanel";
|
|
2450
|
+
var ContextPanel = ({
|
|
2451
|
+
className: classNameProp,
|
|
2452
|
+
expanded = false,
|
|
2453
|
+
content: contentProp,
|
|
2454
|
+
overlay = false,
|
|
2455
|
+
title
|
|
2456
|
+
}) => {
|
|
2457
|
+
const dispatchLayoutAction = (0, import_vuu_layout5.useLayoutProviderDispatch)();
|
|
2458
|
+
const handleClose = (0, import_react12.useCallback)(() => {
|
|
2459
|
+
dispatchLayoutAction({
|
|
2460
|
+
path: "#context-panel",
|
|
2461
|
+
propName: "expanded",
|
|
2462
|
+
propValue: false,
|
|
2463
|
+
type: "set-prop"
|
|
2464
|
+
});
|
|
2465
|
+
}, [dispatchLayoutAction]);
|
|
2466
|
+
const className = (0, import_clsx6.default)(classBase9, classNameProp, {
|
|
2467
|
+
[`${classBase9}-expanded`]: expanded,
|
|
2468
|
+
[`${classBase9}-inline`]: overlay !== true,
|
|
2469
|
+
[`${classBase9}-overlay`]: overlay
|
|
2470
|
+
});
|
|
2471
|
+
const content = (0, import_react12.useMemo)(
|
|
2472
|
+
() => contentProp && expanded ? (0, import_vuu_layout5.layoutFromJson)(contentProp, "context-0") : null,
|
|
2473
|
+
[contentProp, expanded]
|
|
2474
|
+
);
|
|
2475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2476
|
+
"div",
|
|
2477
|
+
{
|
|
2478
|
+
className: (0, import_clsx6.default)(classBase9, className, {
|
|
2479
|
+
[`${classBase9}-expanded`]: expanded
|
|
2480
|
+
}),
|
|
2481
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_vuu_layout5.View, { className: `${classBase9}-inner`, header: false, id: "context-panel", children: [
|
|
2482
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `${classBase9}-header`, children: [
|
|
2483
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h2", { className: `${classBase9}-title`, children: title }),
|
|
2484
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2485
|
+
import_core5.Button,
|
|
2486
|
+
{
|
|
2487
|
+
className: `${classBase9}-close`,
|
|
2488
|
+
"data-icon": "close",
|
|
2489
|
+
onClick: handleClose,
|
|
2490
|
+
variant: "secondary"
|
|
2491
|
+
}
|
|
2492
|
+
)
|
|
2493
|
+
] }),
|
|
2494
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `${classBase9}-content`, children: content })
|
|
2495
|
+
] })
|
|
2496
|
+
}
|
|
2497
|
+
);
|
|
2498
|
+
};
|
|
2499
|
+
|
|
2500
|
+
// src/shell-layouts/useFullHeightLeftPanel.tsx
|
|
2501
|
+
var import_vuu_layout6 = require("@vuu-ui/vuu-layout");
|
|
2502
|
+
|
|
2503
|
+
// src/shell-layouts/side-panel/SidePanel.tsx
|
|
2504
|
+
var import_react13 = require("react");
|
|
2505
|
+
var import_clsx7 = __toESM(require("clsx"));
|
|
2506
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2507
|
+
var classBase10 = "vuuShellSidePanel";
|
|
2508
|
+
var SidePanel = ({
|
|
2509
|
+
children,
|
|
2510
|
+
open = true,
|
|
2511
|
+
sizeClosed = 90,
|
|
2512
|
+
sizeOpen = 200,
|
|
2513
|
+
style: styleProp,
|
|
2514
|
+
...htmlAttributes
|
|
2515
|
+
}) => {
|
|
2516
|
+
const style = (0, import_react13.useMemo)(
|
|
2517
|
+
() => ({
|
|
2518
|
+
...styleProp,
|
|
2519
|
+
"--shell-left-nav-size": open ? `${sizeOpen}px` : `${sizeClosed}px`
|
|
2520
|
+
}),
|
|
2521
|
+
[open, sizeClosed, sizeOpen, styleProp]
|
|
2522
|
+
);
|
|
2523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { ...htmlAttributes, className: (0, import_clsx7.default)(classBase10), style, children });
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
// src/shell-layouts/useFullHeightLeftPanel.tsx
|
|
2527
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2528
|
+
var useFullHeightLeftPanel = ({
|
|
2529
|
+
appHeader,
|
|
2530
|
+
LeftSidePanelProps
|
|
2531
|
+
}) => {
|
|
2532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2533
|
+
import_vuu_layout6.Flexbox,
|
|
2534
|
+
{
|
|
2535
|
+
className: "App",
|
|
2536
|
+
style: {
|
|
2537
|
+
flexDirection: "row",
|
|
2538
|
+
height: "100%",
|
|
2539
|
+
width: "100%"
|
|
2540
|
+
},
|
|
2541
|
+
children: [
|
|
2542
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SidePanel, { ...LeftSidePanelProps, id: "vuu-side-panel" }),
|
|
2543
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2544
|
+
import_vuu_layout6.Flexbox,
|
|
2545
|
+
{
|
|
2546
|
+
className: "vuuShell-content",
|
|
2547
|
+
style: { flex: 1, flexDirection: "column" },
|
|
2548
|
+
children: [
|
|
2549
|
+
appHeader,
|
|
2550
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_vuu_layout6.DraggableLayout, { dropTarget: true, style: { flex: 1 } }, "main-content")
|
|
2551
|
+
]
|
|
2552
|
+
}
|
|
2553
|
+
),
|
|
2554
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ContextPanel, { id: "context-panel", overlay: true })
|
|
2555
|
+
]
|
|
2556
|
+
}
|
|
2557
|
+
);
|
|
2558
|
+
};
|
|
2559
|
+
|
|
2560
|
+
// src/shell-layouts/useInlayLeftPanel.tsx
|
|
2561
|
+
var import_vuu_layout7 = require("@vuu-ui/vuu-layout");
|
|
2562
|
+
var import_react14 = require("react");
|
|
2563
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2564
|
+
var useInlayLeftPanel = ({
|
|
2565
|
+
appHeader,
|
|
2566
|
+
LeftSidePanelProps
|
|
2567
|
+
}) => {
|
|
2568
|
+
const paletteView = (0, import_react14.useRef)(null);
|
|
2569
|
+
const [open, setOpen] = (0, import_react14.useState)(true);
|
|
2570
|
+
const handleDrawerClick = (0, import_react14.useCallback)(
|
|
2571
|
+
(e) => {
|
|
2572
|
+
var _a;
|
|
2573
|
+
const target = e.target;
|
|
2574
|
+
if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
|
|
2575
|
+
setOpen(!open);
|
|
2576
|
+
}
|
|
2577
|
+
},
|
|
2578
|
+
[open]
|
|
2579
|
+
);
|
|
2580
|
+
const getDrawers = (0, import_react14.useCallback)(
|
|
2581
|
+
(leftSidePanel) => {
|
|
2582
|
+
const drawers = [];
|
|
2583
|
+
drawers.push(
|
|
2584
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2585
|
+
import_vuu_layout7.Drawer,
|
|
2586
|
+
{
|
|
2587
|
+
onClick: handleDrawerClick,
|
|
2588
|
+
open,
|
|
2589
|
+
position: "left",
|
|
2590
|
+
inline: true,
|
|
2591
|
+
peekaboo: true,
|
|
2592
|
+
sizeOpen: 200,
|
|
2593
|
+
toggleButton: "end",
|
|
2594
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2595
|
+
import_vuu_layout7.View,
|
|
2596
|
+
{
|
|
2597
|
+
className: "vuuShell-palette",
|
|
2598
|
+
id: "vw-app-palette",
|
|
2599
|
+
ref: paletteView,
|
|
2600
|
+
style: { height: "100%" },
|
|
2601
|
+
children: leftSidePanel
|
|
2602
|
+
},
|
|
2603
|
+
"app-palette"
|
|
2604
|
+
)
|
|
2605
|
+
},
|
|
2606
|
+
"left-panel"
|
|
2607
|
+
)
|
|
2608
|
+
);
|
|
2609
|
+
return drawers;
|
|
2610
|
+
},
|
|
2611
|
+
[handleDrawerClick, open]
|
|
2612
|
+
);
|
|
2613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2614
|
+
import_vuu_layout7.Flexbox,
|
|
2615
|
+
{
|
|
2616
|
+
className: "App",
|
|
2617
|
+
style: { flexDirection: "column", height: "100%", width: "100%" },
|
|
2618
|
+
children: [
|
|
2619
|
+
appHeader,
|
|
2620
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_vuu_layout7.DockLayout, { style: { flex: 1 }, children: getDrawers(LeftSidePanelProps == null ? void 0 : LeftSidePanelProps.children).concat(
|
|
2621
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2622
|
+
import_vuu_layout7.DraggableLayout,
|
|
2623
|
+
{
|
|
2624
|
+
dropTarget: true,
|
|
2625
|
+
style: { width: "100%", height: "100%" }
|
|
2626
|
+
},
|
|
2627
|
+
"main-content"
|
|
2628
|
+
)
|
|
2629
|
+
) })
|
|
2630
|
+
]
|
|
2631
|
+
}
|
|
2632
|
+
);
|
|
2633
|
+
};
|
|
2634
|
+
|
|
2635
|
+
// src/shell-layouts/useShellLayout.ts
|
|
2636
|
+
var useShellLayout = ({
|
|
2637
|
+
leftSidePanelLayout = "inlay",
|
|
2638
|
+
...props
|
|
2639
|
+
}) => {
|
|
2640
|
+
const useLayoutHook = leftSidePanelLayout === "inlay" ? useInlayLeftPanel : useFullHeightLeftPanel;
|
|
2641
|
+
return useLayoutHook(props);
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
// src/shell.tsx
|
|
2645
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2646
|
+
if (typeof import_vuu_layout8.StackLayout !== "function") {
|
|
2647
|
+
console.warn(
|
|
2648
|
+
"StackLayout module not loaded, will be unsbale to deserialize from layout JSON"
|
|
2649
|
+
);
|
|
2650
|
+
}
|
|
2651
|
+
var { error } = (0, import_vuu_utils6.logger)("Shell");
|
|
2652
|
+
var defaultLeftSidePanel = {};
|
|
2653
|
+
var Shell = ({
|
|
2654
|
+
LayoutProps,
|
|
2655
|
+
LeftSidePanelProps = defaultLeftSidePanel,
|
|
2656
|
+
children,
|
|
2657
|
+
className: classNameProp,
|
|
2658
|
+
leftSidePanelLayout,
|
|
2659
|
+
loginUrl,
|
|
2660
|
+
saveLocation: _,
|
|
2661
|
+
saveUrl,
|
|
2662
|
+
serverUrl,
|
|
2663
|
+
user,
|
|
2664
|
+
...htmlAttributes
|
|
2665
|
+
}) => {
|
|
2666
|
+
const rootRef = (0, import_react15.useRef)(null);
|
|
2667
|
+
const { dialog, setDialogState } = (0, import_vuu_popups2.useDialog)();
|
|
2668
|
+
const layoutId = (0, import_react15.useRef)("latest");
|
|
2669
|
+
const { applicationJson, saveApplicationLayout, loadLayoutById } = useLayoutManager();
|
|
2670
|
+
const { buildMenuOptions, handleMenuAction } = useLayoutContextMenuItems(setDialogState);
|
|
2671
|
+
const [connectionStatus, setConnectionStatus] = (0, import_react15.useState)("connected");
|
|
2672
|
+
const handleLayoutChange = (0, import_react15.useCallback)(
|
|
2673
|
+
(layout) => {
|
|
2674
|
+
try {
|
|
2675
|
+
saveApplicationLayout(layout);
|
|
2676
|
+
} catch {
|
|
2677
|
+
error == null ? void 0 : error("Failed to save layout");
|
|
2678
|
+
}
|
|
2679
|
+
},
|
|
2680
|
+
[saveApplicationLayout]
|
|
2681
|
+
);
|
|
2682
|
+
const handleSwitchTheme = (0, import_react15.useCallback)((mode) => {
|
|
2683
|
+
if (rootRef.current) {
|
|
2684
|
+
rootRef.current.dataset.mode = mode;
|
|
2685
|
+
}
|
|
2686
|
+
}, []);
|
|
2687
|
+
const handleNavigate = (0, import_react15.useCallback)(
|
|
2688
|
+
(id) => {
|
|
2689
|
+
layoutId.current = id;
|
|
2690
|
+
loadLayoutById(id);
|
|
2691
|
+
},
|
|
2692
|
+
[loadLayoutById]
|
|
2693
|
+
);
|
|
2694
|
+
(0, import_react15.useMemo)(async () => {
|
|
2695
|
+
if (serverUrl && user.token) {
|
|
2696
|
+
const connectionStatus2 = await (0, import_vuu_data_remote2.connectToServer)({
|
|
2697
|
+
authToken: user.token,
|
|
2698
|
+
url: serverUrl,
|
|
2699
|
+
username: user.username
|
|
2700
|
+
});
|
|
2701
|
+
setConnectionStatus(connectionStatus2);
|
|
2702
|
+
}
|
|
2703
|
+
}, [serverUrl, user.token, user.username]);
|
|
2704
|
+
const [themeClass, densityClass, dataMode] = (0, import_vuu_utils6.useThemeAttributes)();
|
|
2705
|
+
const className = (0, import_clsx8.default)("vuuShell", classNameProp, themeClass, densityClass);
|
|
2706
|
+
const isLoading = applicationJson === loadingApplicationJson;
|
|
2707
|
+
const shellLayout = useShellLayout({
|
|
2708
|
+
LeftSidePanelProps,
|
|
2709
|
+
leftSidePanelLayout,
|
|
2710
|
+
appHeader: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2711
|
+
AppHeader,
|
|
2712
|
+
{
|
|
2713
|
+
layoutId: layoutId.current,
|
|
2714
|
+
loginUrl,
|
|
2715
|
+
user,
|
|
2716
|
+
onNavigate: handleNavigate,
|
|
2717
|
+
onSwitchTheme: handleSwitchTheme
|
|
2718
|
+
}
|
|
2719
|
+
)
|
|
2720
|
+
});
|
|
2721
|
+
if (connectionStatus === "rejected") {
|
|
2722
|
+
console.log("game over, no connection to server");
|
|
2723
|
+
}
|
|
2724
|
+
return isLoading ? null : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_vuu_utils6.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2725
|
+
import_vuu_popups2.ContextMenuProvider,
|
|
2726
|
+
{
|
|
2727
|
+
menuActionHandler: handleMenuAction,
|
|
2728
|
+
menuBuilder: buildMenuOptions,
|
|
2729
|
+
children: [
|
|
2730
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2731
|
+
import_vuu_layout8.LayoutProvider,
|
|
2732
|
+
{
|
|
2733
|
+
...LayoutProps,
|
|
2734
|
+
layout: applicationJson.layout,
|
|
2735
|
+
onLayoutChange: handleLayoutChange,
|
|
2736
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2737
|
+
import_vuu_layout8.DraggableLayout,
|
|
2738
|
+
{
|
|
2739
|
+
className,
|
|
2740
|
+
"data-mode": dataMode,
|
|
2741
|
+
ref: rootRef,
|
|
2742
|
+
...htmlAttributes,
|
|
2743
|
+
children: shellLayout
|
|
2744
|
+
}
|
|
2745
|
+
)
|
|
2746
|
+
}
|
|
2747
|
+
),
|
|
2748
|
+
children || dialog
|
|
2749
|
+
]
|
|
2750
|
+
}
|
|
2751
|
+
) });
|
|
2752
|
+
};
|
|
2753
|
+
|
|
2754
|
+
// src/shellTypes.ts
|
|
2755
|
+
var isWildcardSchema = (schema) => schema === "*";
|
|
2756
|
+
var isTableSchema = (schema) => typeof schema === "object" && typeof schema.module === "string" && typeof schema.table === "string";
|
|
2757
|
+
|
|
2758
|
+
// src/ShellContextProvider.tsx
|
|
2759
|
+
var import_react16 = require("react");
|
|
2760
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2761
|
+
var defaultConfig = {};
|
|
2762
|
+
var ShellContext = (0, import_react16.createContext)(defaultConfig);
|
|
2763
|
+
var Provider = ({
|
|
2764
|
+
children,
|
|
2765
|
+
context,
|
|
2766
|
+
inheritedContext
|
|
2767
|
+
}) => {
|
|
2768
|
+
const mergedContext = {
|
|
2769
|
+
...inheritedContext,
|
|
2770
|
+
...context
|
|
2771
|
+
};
|
|
2772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ShellContext.Provider, { value: mergedContext, children });
|
|
2773
|
+
};
|
|
2774
|
+
var ShellContextProvider = ({
|
|
2775
|
+
children,
|
|
2776
|
+
value
|
|
2777
|
+
}) => {
|
|
2778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Provider, { context: value, inheritedContext: context, children }) });
|
|
2779
|
+
};
|
|
2780
|
+
var useShellContext = () => {
|
|
2781
|
+
return (0, import_react16.useContext)(ShellContext);
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2784
|
+
// src/theme-switch/ThemeSwitch.tsx
|
|
2785
|
+
var import_clsx9 = __toESM(require("clsx"));
|
|
2786
|
+
var import_core6 = require("@salt-ds/core");
|
|
2787
|
+
var import_react17 = require("react");
|
|
2788
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2789
|
+
var classBase11 = "vuuThemeSwitch";
|
|
2790
|
+
var ThemeSwitch = ({
|
|
2791
|
+
className: classNameProp,
|
|
2792
|
+
defaultMode: defaultModeProp,
|
|
2793
|
+
mode: modeProp,
|
|
2794
|
+
onChange,
|
|
2795
|
+
...htmlAttributes
|
|
2796
|
+
}) => {
|
|
2797
|
+
const [mode, setMode] = (0, import_core6.useControlled)({
|
|
2798
|
+
controlled: modeProp,
|
|
2799
|
+
default: defaultModeProp != null ? defaultModeProp : "light",
|
|
2800
|
+
name: "ThemeSwitch",
|
|
2801
|
+
state: "mode"
|
|
2802
|
+
});
|
|
2803
|
+
const handleChangeSecondary = (0, import_react17.useCallback)(
|
|
2804
|
+
(evt) => {
|
|
2805
|
+
const { value } = evt.target;
|
|
2806
|
+
setMode(value);
|
|
2807
|
+
onChange(value);
|
|
2808
|
+
},
|
|
2809
|
+
[onChange, setMode]
|
|
2810
|
+
);
|
|
2811
|
+
const className = (0, import_clsx9.default)(classBase11, classNameProp);
|
|
2812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2813
|
+
import_core6.ToggleButtonGroup,
|
|
2814
|
+
{
|
|
2815
|
+
className,
|
|
2816
|
+
...htmlAttributes,
|
|
2817
|
+
onChange: handleChangeSecondary,
|
|
2818
|
+
value: mode,
|
|
2819
|
+
children: [
|
|
2820
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_core6.ToggleButton, { "aria-label": "alert", "data-icon": "light", value: "light" }),
|
|
2821
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_core6.ToggleButton, { "aria-label": "home", "data-icon": "dark", value: "dark" })
|
|
2822
|
+
]
|
|
2823
|
+
}
|
|
2824
|
+
);
|
|
2825
|
+
};
|
|
3
2826
|
//# sourceMappingURL=index.js.map
|