@vuu-ui/vuu-shell 0.8.10 → 0.8.11-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/esm/index.js CHANGED
@@ -1,4 +1,1682 @@
1
- import Mt,{useEffect as Ft,useState as Dt}from"react";import Ht from"classnames";import{Fragment as Vt,jsx as kt,jsxs as Pe}from"react/jsx-runtime";var Xr=({connectionStatus:e,className:t,element:o="span",...n})=>{let[a,r]=Dt("vuuConnectingStatus");Ft(()=>{switch(e){case"connected":case"reconnected":r("vuuActiveStatus");break;case"connecting":r("vuuConnectingStatus");break;case"disconnected":r("vuuDisconnectedStatus");break;default:break}},[e]);let s=Mt.createElement(o,{...n,className:Ht("vuuStatus vuuIcon",a,t)});return kt(Vt,{children:Pe("div",{className:"vuuStatus-container salt-theme",children:[s,Pe("div",{className:"vuuStatus-text",children:["Status: ",e.toUpperCase()]})]})})};import{Dropdown as Rt}from"@salt-ds/lab";import{useCallback as It}from"react";import Ut from"classnames";import{jsx as Ot}from"react/jsx-runtime";var $t="vuuDensitySwitch",At=["high","medium","low","touch"],Bt="high",sn=({className:e,defaultDensity:t=Bt,onChange:o})=>{let n=It((r,s)=>{o(s)},[o]),a=Ut($t,e);return Ot(Rt,{className:a,source:At,defaultSelected:t,onSelectionChange:n})};import Fe,{Suspense as Zt,useEffect as qt}from"react";import{registerComponent as zt}from"@vuu-ui/vuu-layout";import _t from"react";import{Fragment as Jt,jsx as Ee,jsxs as Gt}from"react/jsx-runtime";var Y=class extends _t.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?Gt(Jt,{children:[Ee("h1",{children:"An error occured while creating component."}),Ee("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as Yt}from"react/jsx-runtime";var we=()=>Yt("div",{className:"hwLoader",children:"loading"});var Me=async e=>{let t=new CSSStyleSheet;return fetch(e).then(o=>o.text()).then(o=>t.replace(o))};import{jsx as q}from"react/jsx-runtime";var Z=new Map,Wt=e=>{qt(()=>()=>{Z.delete(e)},[e]),Z.has(e)||Z.set(e,Fe.lazy(()=>import(e)));let t=Z.get(e);if(t)return t;throw Error(`Unable to load Lazy Feature at url ${e}`)};function Kt({url:e,css:t,ComponentProps:o,...n}){t&&Me(t).then(r=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]});let a=Wt(e);return q(Y,{url:e,children:q(Zt,{fallback:q(we,{}),children:q(a,{...n,...o})})})}var z=Fe.memo(Kt);z.displayName="Feature";zt("Feature",z,"view");import{useCallback as ue,useEffect as Qt,useState as jt}from"react";import{resolveJSONPath as Xt}from"@vuu-ui/vuu-layout";var De=(e,t,o="latest")=>new Promise((n,a)=>{console.log(`load local config at ${e} for user ${t==null?void 0:t.username}, id ${o}`);let r=localStorage.getItem(e);if(r){let s=JSON.parse(r);n(s)}else a()}),He=(e,t,o)=>new Promise((n,a)=>{try{let r=Xt(o,"#main-tabs.ACTIVE_CHILD");console.log(r),localStorage.setItem(e,JSON.stringify(o)),n(void 0)}catch{a()}});var Ve=(e,t,o="latest")=>new Promise((n,a)=>{if(t===void 0)throw Error("user mustb be provided to load remote config");fetch(`${e}/${t.username}/${o}`,{}).then(r=>{r.ok?n(r.json()):a(void 0)}).catch(()=>{a(void 0)})}),ke=(e,t,o)=>new Promise((n,a)=>{if(t===void 0)throw Error("user mustb be provided to load remote config");fetch(`${e}/${t.username}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then(r=>{r.ok?n(void 0):a()})});var eo={type:"Placeholder"},Re=({saveLocation:e,saveUrl:t="api/vui",user:o,defaultLayout:n=eo})=>{let[a,r]=jt(n),s=e==="remote",p=s?Ve:De,u=s?ke:He,m=ue(async(d="latest")=>{try{let g=await p(t,o,d);r(g)}catch{r(n)}},[n,p,t,o]);Qt(()=>{m()},[m]);let l=ue(d=>{u(t,o,d)},[u,t,o]),y=ue(d=>m(d),[m]);return[a,l,y]};import{useEffect as to,useState as _}from"react";import{Input as oo,Button as Ie,FormField as W,FormFieldLabel as K,Text as ro}from"@salt-ds/core";import{ComboBox as no,Checkbox as ao,RadioButton as so}from"@vuu-ui/vuu-ui-controls";import{formatDate as io,takeScreenshot as lo}from"@vuu-ui/vuu-utils";import{jsx as L,jsxs as V}from"react/jsx-runtime";var T="saveLayoutPanel",X=`${T}-formField`,uo=["Group 1","Group 2","Group 3","Group 4","Group 5"],co=["Value 1","Value 2","Value 3"],Ue=["Value 1","Value 2","Value 3"],Zn=e=>{let{onCancel:t,onSave:o,componentId:n}=e,[a,r]=_(""),[s,p]=_(""),[u,m]=_([]),[l,y]=_(Ue[0]),[d,g]=_();to(()=>{n&&lo(document.getElementById(n)).then(c=>g(c))},[]);let h=()=>{o({name:a,group:s,screenshot:d!=null?d:"",user:"User",date:io(new Date,"dd.mm.yyyy")})};return V("div",{className:`${T}-panelContainer`,children:[V("div",{className:`${T}-panelContent`,children:[V("div",{className:`${T}-formContainer`,children:[V(W,{className:X,children:[L(K,{children:"Group"}),L(no,{ListProps:{style:{zIndex:1e4,border:"1px solid #777C94",borderRadius:10,boxSizing:"border-box"}},source:uo,allowFreeText:!0,InputProps:{inputProps:{className:`${T}-inputText`,placeholder:"Select Group or Enter New Name",onChange:c=>p(c.target.value)}},width:120,onSelectionChange:(c,S)=>p(S||"")})]}),V(W,{className:X,children:[L(K,{children:"Layout Name"}),L(oo,{inputProps:{className:`${T}-inputText`,placeholder:"Enter Layout Name"},onChange:c=>r(c.target.value),value:a})]}),V(W,{className:X,children:[L(K,{children:"Some Layout Setting"}),L("div",{className:`${T}-settingsGroup`,children:co.map((c,S)=>L(ao,{onToggle:()=>m(E=>E.includes(c)?E.filter(R=>R!==c):[...E,c]),checked:u.includes(c),label:c},S))})]}),V(W,{className:X,children:[L(K,{children:"Some Layout Setting"}),L("div",{className:`${T}-settingsGroup`,children:Ue.map((c,S)=>L(so,{onClick:()=>y(c),checked:l===c,label:c,groupName:"radioGroup"},S))})]})]}),L("div",{className:`${T}-screenshotContainer`,children:d?L("img",{className:`${T}-screenshot`,src:d,alt:"screenshot of current layout"}):L(ro,{className:"screenshot",children:"No screenshot available"})})]}),V("div",{className:`${T}-buttonsContainer`,children:[L(Ie,{className:`${T}-cancelButton`,onClick:t,children:"Cancel"}),L(Ie,{className:`${T}-saveButton`,onClick:h,disabled:a===""||s==="",children:"Save"})]})]})};import{List as _e}from"@vuu-ui/vuu-ui-controls";import mo,{useState as po,useCallback as fo,useContext as ho,useEffect as $e}from"react";import{getLocalEntity as Ae,saveLocalEntity as go}from"@vuu-ui/vuu-filters";import{getUniqueId as yo}from"@vuu-ui/vuu-utils";import{jsx as vo}from"react/jsx-runtime";var Be=mo.createContext({layouts:[],saveLayout:()=>{}}),Qn=e=>{let[t,o]=po([]);$e(()=>{let a=Ae("layouts");o(a||[])},[]),$e(()=>{go("layouts",t)},[t]);let n=fo(a=>{let r=Ae("api/vui");r&&o(s=>[...s,{metadata:{...a,id:yo()},json:r}])},[]);return vo(Be.Provider,{value:{layouts:t,saveLayout:n},children:e.children})},Oe=()=>ho(Be);import{Fragment as Lo,jsx as k,jsxs as Q}from"react/jsx-runtime";var I="vuuLayoutList",Je=e=>{let{layouts:t}=Oe(),o=t.map(r=>r.metadata),n=r=>{console.log("loading layout with id",r),console.log("json:",t.find(s=>s.metadata.id===r))},a=o.reduce((r,s)=>r[s.group]?{...r,[s.group]:[...r[s.group],s]}:{...r,[s.group]:[s]},{});return Q("div",{className:I,...e,children:[k("div",{className:`${I}-header`,children:"My Layouts"}),k(_e,{height:"fit-content",source:Object.entries(a),ListItem:({item:r})=>Q(Lo,{children:[k("div",{className:`${I}-groupName`,children:r==null?void 0:r[0]}),k(_e,{height:"fit-content",source:r==null?void 0:r[1],ListItem:({item:s})=>Q("div",{className:`${I}-layoutContainer`,onClick:()=>n(s==null?void 0:s.id),children:[k("img",{className:`${I}-screenshot`,src:s==null?void 0:s.screenshot}),Q("div",{children:[k("div",{className:`${I}-layoutName`,children:s==null?void 0:s.name}),k("div",{className:`${I}-layoutDetails`,children:k("div",{children:`${s==null?void 0:s.user}, ${s==null?void 0:s.date}`})})]})]},s==null?void 0:s.id)})]})})]})};import{memo as Co}from"react";import{jsx as N,jsxs as A}from"react/jsx-runtime";var ce=Co(()=>A("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[A("g",{clipPath:"url(#clip0_217_6990)",children:[N("path",{d:"M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",fill:"url(#paint0_linear_217_6990)"}),N("path",{d:"M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",fill:"url(#paint1_linear_217_6990)"}),N("path",{d:"M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",fill:"#F37880"}),A("g",{opacity:"0.86",children:[N("path",{d:"M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",fill:"white"}),N("path",{d:"M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",fill:"white"}),N("path",{d:"M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",fill:"white"})]})]}),A("defs",{children:[A("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[N("stop",{stopColor:"#4906A5"}),N("stop",{offset:"1",stopColor:"#D3423A"})]}),A("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[N("stop",{stopColor:"#7C06A5"}),N("stop",{offset:"1",stopColor:"#D3423A"})]}),N("clipPath",{id:"clip0_217_6990",children:N("rect",{width:"44",height:"45",fill:"white"})})]})]}));ce.displayName="VuuLogo";import{Action as Ze,Stack as ko,useLayoutProviderDispatch as Ro}from"@vuu-ui/vuu-layout";import{Tab as J,Tabstrip as Io}from"@vuu-ui/vuu-ui-controls";import fe from"classnames";import{useCallback as te,useState as Uo}from"react";import{Palette as So,PaletteItem as xo}from"@vuu-ui/vuu-layout";import{jsx as j,jsxs as To}from"react/jsx-runtime";var Ge="vuuFeatureList",me=({features:e,title:t="VUU TABLES",...o})=>{let n={};return console.log({features:e}),To("div",{...o,className:Ge,children:[j("div",{className:`${Ge}-header`,children:t}),j(So,{orientation:"vertical",ViewProps:n,children:e.map((a,r)=>j(xo,{closeable:!0,label:a.title,resizeable:!0,resize:"defer",header:!0,children:j(z,{...a})},r))})]})};import{createContext as bo,isValidElement as No,cloneElement as Po,useContext as Ye}from"react";import Eo from"classnames";import{jsx as Vo}from"react/jsx-runtime";var wo="medium",Mo="salt-theme",Fo="light",de=bo({density:"high",theme:"vuu",themeMode:"light"}),Do=["vuu","vuu-density-high","light"],ee=()=>{let e=Ye(de);return e?[`${e.theme}-theme`,`${e.theme}-density-${e.density}`,e.themeMode]:Do},Ho=(e,t,o,n)=>{var a;return No(e)?Po(e,{className:Eo((a=e.props)==null?void 0:a.className,`${t}-theme`,`${t}-density-${n}`),"data-mode":o}):(console.warn(`
1
+ // src/connection-status/ConnectionStatusIcon.tsx
2
+ import React, { useEffect, useState } from "react";
3
+ import cx from "classnames";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ var ConnectionStatusIcon = ({ connectionStatus, className, element = "span", ...props }) => {
6
+ const [classBase11, setClassBase] = useState("vuuConnectingStatus");
7
+ useEffect(() => {
8
+ switch (connectionStatus) {
9
+ case "connected":
10
+ case "reconnected":
11
+ setClassBase("vuuActiveStatus");
12
+ break;
13
+ case "connecting":
14
+ setClassBase("vuuConnectingStatus");
15
+ break;
16
+ case "disconnected":
17
+ setClassBase("vuuDisconnectedStatus");
18
+ break;
19
+ default:
20
+ break;
21
+ }
22
+ }, [connectionStatus]);
23
+ const statusIcon = React.createElement(
24
+ element,
25
+ {
26
+ ...props,
27
+ className: cx("vuuStatus vuuIcon", classBase11, className)
28
+ }
29
+ );
30
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "vuuStatus-container salt-theme", children: [
31
+ statusIcon,
32
+ /* @__PURE__ */ jsxs("div", { className: "vuuStatus-text", children: [
33
+ "Status: ",
34
+ connectionStatus.toUpperCase()
35
+ ] })
36
+ ] }) });
37
+ };
38
+
39
+ // src/density-switch/DensitySwitch.tsx
40
+ import { Dropdown } from "@salt-ds/lab";
41
+ import { useCallback } from "react";
42
+ import cx2 from "classnames";
43
+ import { jsx as jsx2 } from "react/jsx-runtime";
44
+ var classBase = "vuuDensitySwitch";
45
+ var densities = ["high", "medium", "low", "touch"];
46
+ var DEFAULT_DENSITY = "high";
47
+ var DensitySwitch = ({
48
+ className: classNameProp,
49
+ defaultDensity = DEFAULT_DENSITY,
50
+ onChange
51
+ }) => {
52
+ const handleSelectionChange = useCallback(
53
+ (_event, selectedItem) => {
54
+ onChange(selectedItem);
55
+ },
56
+ [onChange]
57
+ );
58
+ const className = cx2(classBase, classNameProp);
59
+ return /* @__PURE__ */ jsx2(
60
+ Dropdown,
61
+ {
62
+ className,
63
+ source: densities,
64
+ defaultSelected: defaultDensity,
65
+ onSelectionChange: handleSelectionChange
66
+ }
67
+ );
68
+ };
69
+
70
+ // src/feature/Feature.tsx
71
+ import React3, { Suspense, useEffect as useEffect2 } from "react";
72
+ import { registerComponent } from "@vuu-ui/vuu-layout";
73
+
74
+ // src/feature/FeatureErrorBoundary.tsx
75
+ import React2 from "react";
76
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
77
+ var FeatureErrorBoundary = class extends React2.Component {
78
+ constructor(props) {
79
+ super(props);
80
+ this.state = { errorMessage: null };
81
+ }
82
+ static getDerivedStateFromError(error2) {
83
+ return { errorMessage: error2.message };
84
+ }
85
+ componentDidCatch(error2, errorInfo) {
86
+ console.log(`error creating component at ${this.props.url}`);
87
+ console.log(error2, errorInfo);
88
+ }
89
+ render() {
90
+ if (this.state.errorMessage) {
91
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
92
+ /* @__PURE__ */ jsx3("h1", { children: "An error occured while creating component." }),
93
+ /* @__PURE__ */ jsx3("p", { children: this.state.errorMessage })
94
+ ] });
95
+ }
96
+ return this.props.children;
97
+ }
98
+ };
99
+
100
+ // src/feature/Loader.tsx
101
+ import { jsx as jsx4 } from "react/jsx-runtime";
102
+ var Loader = () => /* @__PURE__ */ jsx4("div", { className: "hwLoader", children: "loading" });
103
+
104
+ // src/feature/css-module-loader.ts
105
+ var importCSS = async (path) => {
106
+ const container = new CSSStyleSheet();
107
+ return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
108
+ };
109
+
110
+ // src/feature/Feature.tsx
111
+ import { jsx as jsx5 } from "react/jsx-runtime";
112
+ var componentsMap = /* @__PURE__ */ new Map();
113
+ var useCachedFeature = (url) => {
114
+ useEffect2(
115
+ () => () => {
116
+ componentsMap.delete(url);
117
+ },
118
+ [url]
119
+ );
120
+ if (!componentsMap.has(url)) {
121
+ componentsMap.set(
122
+ url,
123
+ React3.lazy(() => import(
124
+ /* @vite-ignore */
125
+ url
126
+ ))
127
+ );
128
+ }
129
+ const lazyFeature = componentsMap.get(url);
130
+ if (!lazyFeature) {
131
+ throw Error(`Unable to load Lazy Feature at url ${url}`);
132
+ } else {
133
+ return lazyFeature;
134
+ }
135
+ };
136
+ function RawFeature({
137
+ url,
138
+ css,
139
+ ComponentProps: params,
140
+ ...props
141
+ }) {
142
+ if (css) {
143
+ importCSS(css).then((styleSheet) => {
144
+ document.adoptedStyleSheets = [
145
+ ...document.adoptedStyleSheets,
146
+ styleSheet
147
+ ];
148
+ });
149
+ }
150
+ const LazyFeature = useCachedFeature(url);
151
+ return /* @__PURE__ */ jsx5(FeatureErrorBoundary, { url, children: /* @__PURE__ */ jsx5(Suspense, { fallback: /* @__PURE__ */ jsx5(Loader, {}), children: /* @__PURE__ */ jsx5(LazyFeature, { ...props, ...params }) }) });
152
+ }
153
+ var Feature = React3.memo(RawFeature);
154
+ Feature.displayName = "Feature";
155
+ registerComponent("Feature", Feature, "view");
156
+
157
+ // src/layout-management/SaveLayoutPanel.tsx
158
+ import { useEffect as useEffect3, useState as useState2 } from "react";
159
+ import { Input, Button, FormField, FormFieldLabel, Text } from "@salt-ds/core";
160
+ import { ComboBox, Checkbox, RadioButton } from "@vuu-ui/vuu-ui-controls";
161
+ import { formatDate, takeScreenshot } from "@vuu-ui/vuu-utils";
162
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
163
+ var classBase2 = "saveLayoutPanel";
164
+ var formField = `${classBase2}-formField`;
165
+ var groups = ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5"];
166
+ var checkboxValues = ["Value 1", "Value 2", "Value 3"];
167
+ var radioValues = ["Value 1", "Value 2", "Value 3"];
168
+ var SaveLayoutPanel = (props) => {
169
+ const { onCancel, onSave, componentId } = props;
170
+ const [layoutName, setLayoutName] = useState2("");
171
+ const [group, setGroup] = useState2("");
172
+ const [checkValues, setCheckValues] = useState2([]);
173
+ const [radioValue, setRadioValue] = useState2(radioValues[0]);
174
+ const [screenshot, setScreenshot] = useState2();
175
+ useEffect3(() => {
176
+ if (componentId) {
177
+ takeScreenshot(document.getElementById(componentId)).then(
178
+ (screenshot2) => setScreenshot(screenshot2)
179
+ );
180
+ }
181
+ }, [componentId]);
182
+ const handleSubmit = () => {
183
+ onSave({
184
+ name: layoutName,
185
+ group,
186
+ screenshot: screenshot != null ? screenshot : "",
187
+ user: "User",
188
+ date: formatDate(/* @__PURE__ */ new Date(), "dd.mm.yyyy")
189
+ });
190
+ };
191
+ return /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-panelContainer`, children: [
192
+ /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-panelContent`, children: [
193
+ /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-formContainer`, children: [
194
+ /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
195
+ /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Group" }),
196
+ /* @__PURE__ */ jsx6(
197
+ ComboBox,
198
+ {
199
+ source: groups,
200
+ allowFreeText: true,
201
+ InputProps: {
202
+ inputProps: {
203
+ className: `${classBase2}-inputText`,
204
+ placeholder: "Select Group or Enter New Name",
205
+ onChange: (event) => setGroup(event.target.value)
206
+ }
207
+ },
208
+ width: 120,
209
+ onSelectionChange: (_, value) => setGroup(value || "")
210
+ }
211
+ )
212
+ ] }),
213
+ /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
214
+ /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Layout Name" }),
215
+ /* @__PURE__ */ jsx6(
216
+ Input,
217
+ {
218
+ inputProps: {
219
+ className: `${classBase2}-inputText`,
220
+ placeholder: "Enter Layout Name"
221
+ },
222
+ onChange: (event) => setLayoutName(event.target.value),
223
+ value: layoutName
224
+ }
225
+ )
226
+ ] }),
227
+ /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
228
+ /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Some Layout Setting" }),
229
+ /* @__PURE__ */ jsx6("div", { className: `${classBase2}-settingsGroup`, children: checkboxValues.map((value, i) => /* @__PURE__ */ jsx6(
230
+ Checkbox,
231
+ {
232
+ onToggle: () => setCheckValues(
233
+ (prev) => prev.includes(value) ? prev.filter((entry) => entry !== value) : [...prev, value]
234
+ ),
235
+ checked: checkValues.includes(value),
236
+ label: value
237
+ },
238
+ i
239
+ )) })
240
+ ] }),
241
+ /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
242
+ /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Some Layout Setting" }),
243
+ /* @__PURE__ */ jsx6("div", { className: `${classBase2}-settingsGroup`, children: radioValues.map((value, i) => /* @__PURE__ */ jsx6(
244
+ RadioButton,
245
+ {
246
+ onClick: () => setRadioValue(value),
247
+ checked: radioValue === value,
248
+ label: value,
249
+ groupName: "radioGroup"
250
+ },
251
+ i
252
+ )) })
253
+ ] })
254
+ ] }),
255
+ /* @__PURE__ */ jsx6("div", { className: `${classBase2}-screenshotContainer`, children: screenshot ? /* @__PURE__ */ jsx6(
256
+ "img",
257
+ {
258
+ className: `${classBase2}-screenshot`,
259
+ src: screenshot,
260
+ alt: "screenshot of current layout"
261
+ }
262
+ ) : /* @__PURE__ */ jsx6(Text, { className: "screenshot", children: "No screenshot available" }) })
263
+ ] }),
264
+ /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-buttonsContainer`, children: [
265
+ /* @__PURE__ */ jsx6(Button, { className: `${classBase2}-cancelButton`, onClick: onCancel, children: "Cancel" }),
266
+ /* @__PURE__ */ jsx6(
267
+ Button,
268
+ {
269
+ className: `${classBase2}-saveButton`,
270
+ onClick: handleSubmit,
271
+ disabled: layoutName === "" || group === "",
272
+ children: "Save"
273
+ }
274
+ )
275
+ ] })
276
+ ] });
277
+ };
278
+
279
+ // src/layout-management/LayoutList.tsx
280
+ import { List } from "@vuu-ui/vuu-ui-controls";
281
+
282
+ // src/layout-management/useLayoutManager.tsx
283
+ import React4, { useState as useState3, useCallback as useCallback2, useContext, useEffect as useEffect4 } from "react";
284
+ import {
285
+ LocalLayoutPersistenceManager,
286
+ resolveJSONPath
287
+ } from "@vuu-ui/vuu-layout";
288
+ import { defaultLayout } from "@vuu-ui/vuu-layout/";
289
+ import { jsx as jsx7 } from "react/jsx-runtime";
290
+ var persistenceManager = new LocalLayoutPersistenceManager();
291
+ var LayoutManagementContext = React4.createContext({
292
+ layoutMetadata: [],
293
+ saveLayout: () => {
294
+ },
295
+ applicationLayout: defaultLayout,
296
+ saveApplicationLayout: () => {
297
+ },
298
+ loadLayoutById: () => defaultLayout
299
+ });
300
+ var LayoutManagementProvider = (props) => {
301
+ const [layoutMetadata, setLayoutMetadata] = useState3([]);
302
+ const [applicationLayout, setApplicationLayout] = useState3(defaultLayout);
303
+ useEffect4(() => {
304
+ persistenceManager.loadMetadata().then((metadata) => {
305
+ setLayoutMetadata(metadata);
306
+ });
307
+ persistenceManager.loadApplicationLayout().then((layout) => {
308
+ setApplicationLayout(layout);
309
+ });
310
+ }, []);
311
+ const saveApplicationLayout = useCallback2((layout) => {
312
+ setApplicationLayout(layout);
313
+ persistenceManager.saveApplicationLayout(layout);
314
+ }, []);
315
+ const saveLayout = useCallback2(
316
+ (metadata) => {
317
+ const layoutToSave = resolveJSONPath(
318
+ applicationLayout,
319
+ "#main-tabs.ACTIVE_CHILD"
320
+ );
321
+ if (layoutToSave) {
322
+ persistenceManager.createLayout(metadata, layoutToSave).then((generatedId) => {
323
+ const newMetadata = {
324
+ ...metadata,
325
+ id: generatedId
326
+ };
327
+ setLayoutMetadata((prev) => [...prev, newMetadata]);
328
+ });
329
+ }
330
+ },
331
+ [applicationLayout]
332
+ );
333
+ const loadLayoutById = useCallback2((id) => {
334
+ persistenceManager.loadLayout(id).then((layoutJson) => {
335
+ setApplicationLayout((prev) => ({
336
+ ...prev,
337
+ children: [...prev.children || [], layoutJson]
338
+ }));
339
+ });
340
+ }, []);
341
+ return /* @__PURE__ */ jsx7(
342
+ LayoutManagementContext.Provider,
343
+ {
344
+ value: {
345
+ layoutMetadata,
346
+ saveLayout,
347
+ applicationLayout,
348
+ saveApplicationLayout,
349
+ loadLayoutById
350
+ },
351
+ children: props.children
352
+ }
353
+ );
354
+ };
355
+ var useLayoutManager = () => useContext(LayoutManagementContext);
356
+
357
+ // src/layout-management/LayoutList.tsx
358
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
359
+ var classBase3 = "vuuLayoutList";
360
+ var LayoutsList = (props) => {
361
+ const { layoutMetadata, loadLayoutById } = useLayoutManager();
362
+ const handleLoadLayout = (layoutId) => {
363
+ if (layoutId) {
364
+ loadLayoutById(layoutId);
365
+ }
366
+ };
367
+ const layoutsByGroup = layoutMetadata.reduce((acc, cur) => {
368
+ if (acc[cur.group]) {
369
+ return {
370
+ ...acc,
371
+ [cur.group]: [...acc[cur.group], cur]
372
+ };
373
+ }
374
+ return {
375
+ ...acc,
376
+ [cur.group]: [cur]
377
+ };
378
+ }, {});
379
+ return /* @__PURE__ */ jsxs4("div", { className: classBase3, ...props, children: [
380
+ /* @__PURE__ */ jsx8("div", { className: `${classBase3}-header`, children: "My Layouts" }),
381
+ /* @__PURE__ */ jsx8(
382
+ List,
383
+ {
384
+ height: "fit-content",
385
+ source: Object.entries(layoutsByGroup),
386
+ ListItem: ({ item }) => {
387
+ if (!item)
388
+ return /* @__PURE__ */ jsx8(Fragment3, {});
389
+ const [groupName, layouts] = item;
390
+ return /* @__PURE__ */ jsxs4(Fragment3, { children: [
391
+ /* @__PURE__ */ jsx8("div", { className: `${classBase3}-groupName`, children: groupName }),
392
+ layouts.map((layout) => /* @__PURE__ */ jsxs4(
393
+ "div",
394
+ {
395
+ className: `${classBase3}-layoutContainer`,
396
+ onClick: () => handleLoadLayout(layout == null ? void 0 : layout.id),
397
+ children: [
398
+ /* @__PURE__ */ jsx8(
399
+ "img",
400
+ {
401
+ className: `${classBase3}-screenshot`,
402
+ src: layout == null ? void 0 : layout.screenshot
403
+ }
404
+ ),
405
+ /* @__PURE__ */ jsxs4("div", { children: [
406
+ /* @__PURE__ */ jsx8("div", { className: `${classBase3}-layoutName`, children: layout == null ? void 0 : layout.name }),
407
+ /* @__PURE__ */ jsx8("div", { className: `${classBase3}-layoutDetails`, children: /* @__PURE__ */ jsx8("div", { children: `${layout == null ? void 0 : layout.user}, ${layout == null ? void 0 : layout.date}` }) })
408
+ ] })
409
+ ]
410
+ },
411
+ layout == null ? void 0 : layout.id
412
+ ))
413
+ ] });
414
+ }
415
+ }
416
+ )
417
+ ] });
418
+ };
419
+
420
+ // ../vuu-icons/src/VuuLogo.tsx
421
+ import { memo } from "react";
422
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
423
+ var VuuLogo = memo(() => {
424
+ return /* @__PURE__ */ jsxs5(
425
+ "svg",
426
+ {
427
+ width: "44",
428
+ height: "45",
429
+ viewBox: "0 0 44 45",
430
+ fill: "none",
431
+ xmlns: "http://www.w3.org/2000/svg",
432
+ children: [
433
+ /* @__PURE__ */ jsxs5("g", { clipPath: "url(#clip0_217_6990)", children: [
434
+ /* @__PURE__ */ jsx9(
435
+ "path",
436
+ {
437
+ d: "M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",
438
+ fill: "url(#paint0_linear_217_6990)"
439
+ }
440
+ ),
441
+ /* @__PURE__ */ jsx9(
442
+ "path",
443
+ {
444
+ d: "M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",
445
+ fill: "url(#paint1_linear_217_6990)"
446
+ }
447
+ ),
448
+ /* @__PURE__ */ jsx9(
449
+ "path",
450
+ {
451
+ d: "M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",
452
+ fill: "#F37880"
453
+ }
454
+ ),
455
+ /* @__PURE__ */ jsxs5("g", { opacity: "0.86", children: [
456
+ /* @__PURE__ */ jsx9(
457
+ "path",
458
+ {
459
+ d: "M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",
460
+ fill: "white"
461
+ }
462
+ ),
463
+ /* @__PURE__ */ jsx9(
464
+ "path",
465
+ {
466
+ d: "M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",
467
+ fill: "white"
468
+ }
469
+ ),
470
+ /* @__PURE__ */ jsx9(
471
+ "path",
472
+ {
473
+ d: "M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",
474
+ fill: "white"
475
+ }
476
+ )
477
+ ] })
478
+ ] }),
479
+ /* @__PURE__ */ jsxs5("defs", { children: [
480
+ /* @__PURE__ */ jsxs5(
481
+ "linearGradient",
482
+ {
483
+ id: "paint0_linear_217_6990",
484
+ x1: "24.6235",
485
+ y1: "18.7363",
486
+ x2: "42.3152",
487
+ y2: "18.7363",
488
+ gradientUnits: "userSpaceOnUse",
489
+ children: [
490
+ /* @__PURE__ */ jsx9("stop", { stopColor: "#4906A5" }),
491
+ /* @__PURE__ */ jsx9("stop", { offset: "1", stopColor: "#D3423A" })
492
+ ]
493
+ }
494
+ ),
495
+ /* @__PURE__ */ jsxs5(
496
+ "linearGradient",
497
+ {
498
+ id: "paint1_linear_217_6990",
499
+ x1: "-2.35794e-05",
500
+ y1: "22.5009",
501
+ x2: "42.7186",
502
+ y2: "22.5009",
503
+ gradientUnits: "userSpaceOnUse",
504
+ children: [
505
+ /* @__PURE__ */ jsx9("stop", { stopColor: "#7C06A5" }),
506
+ /* @__PURE__ */ jsx9("stop", { offset: "1", stopColor: "#D3423A" })
507
+ ]
508
+ }
509
+ ),
510
+ /* @__PURE__ */ jsx9("clipPath", { id: "clip0_217_6990", children: /* @__PURE__ */ jsx9("rect", { width: "44", height: "45", fill: "white" }) })
511
+ ] })
512
+ ]
513
+ }
514
+ );
515
+ });
516
+ VuuLogo.displayName = "VuuLogo";
517
+
518
+ // src/left-nav/LeftNav.tsx
519
+ import { Action, Stack, useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
520
+ import { Tab, Tabstrip } from "@vuu-ui/vuu-ui-controls";
521
+ import cx4 from "classnames";
522
+ import { useCallback as useCallback3, useState as useState4 } from "react";
523
+
524
+ // src/feature-list/FeatureList.tsx
525
+ import { Palette, PaletteItem } from "@vuu-ui/vuu-layout";
526
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
527
+ var classBase4 = "vuuFeatureList";
528
+ var FeatureList = ({
529
+ features,
530
+ title = "VUU TABLES",
531
+ ...htmlAttributes
532
+ }) => {
533
+ const ViewProps = {};
534
+ console.log({ features });
535
+ return /* @__PURE__ */ jsxs6("div", { ...htmlAttributes, className: classBase4, children: [
536
+ /* @__PURE__ */ jsx10("div", { className: `${classBase4}-header`, children: title }),
537
+ /* @__PURE__ */ jsx10(Palette, { orientation: "vertical", ViewProps, children: features.map((featureProps, i) => /* @__PURE__ */ jsx10(
538
+ PaletteItem,
539
+ {
540
+ closeable: true,
541
+ label: featureProps.title,
542
+ resizeable: true,
543
+ resize: "defer",
544
+ header: true,
545
+ children: /* @__PURE__ */ jsx10(Feature, { ...featureProps })
546
+ },
547
+ i
548
+ )) })
549
+ ] });
550
+ };
551
+
552
+ // src/theme-provider/ThemeProvider.tsx
553
+ import {
554
+ createContext,
555
+ isValidElement,
556
+ cloneElement,
557
+ useContext as useContext2
558
+ } from "react";
559
+ import cx3 from "classnames";
560
+ import { jsx as jsx11 } from "react/jsx-runtime";
561
+ var DEFAULT_DENSITY2 = "medium";
562
+ var DEFAULT_THEME = "salt-theme";
563
+ var DEFAULT_THEME_MODE = "light";
564
+ var ThemeContext = createContext({
565
+ density: "high",
566
+ theme: "vuu",
567
+ themeMode: "light"
568
+ });
569
+ var DEFAULT_THEME_ATTRIBUTES = [
570
+ "vuu",
571
+ "vuu-density-high",
572
+ "light"
573
+ ];
574
+ var useThemeAttributes = (themeAttributes) => {
575
+ const context = useContext2(ThemeContext);
576
+ if (themeAttributes) {
577
+ return [
578
+ themeAttributes.themeClass,
579
+ themeAttributes.densityClass,
580
+ themeAttributes.dataMode
581
+ ];
582
+ } else if (context) {
583
+ return [
584
+ `${context.theme}-theme`,
585
+ `${context.theme}-density-${context.density}`,
586
+ context.themeMode
587
+ ];
588
+ }
589
+ return DEFAULT_THEME_ATTRIBUTES;
590
+ };
591
+ var createThemedChildren = (children, theme, themeMode, density) => {
592
+ var _a;
593
+ if (isValidElement(children)) {
594
+ return cloneElement(children, {
595
+ className: cx3(
596
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
597
+ (_a = children.props) == null ? void 0 : _a.className,
598
+ `${theme}-theme`,
599
+ `${theme}-density-${density}`
600
+ ),
601
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
602
+ // @ts-expect-error
603
+ "data-mode": themeMode
604
+ });
605
+ } else {
606
+ console.warn(
607
+ `
2
608
  ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
3
- Wrap elements with a single container`),e)},pe=({applyThemeClasses:e=!1,children:t,theme:o,themeMode:n,density:a})=>{var d,g,h;let{density:r,themeMode:s,theme:p}=Ye(de),u=(d=a!=null?a:r)!=null?d:wo,m=(g=n!=null?n:s)!=null?g:Fo,l=(h=o!=null?o:p)!=null?h:Mo,y=e?Ho(t,l,m,u):t;return Vo(de.Provider,{value:{themeMode:m,density:u,theme:l},children:y})};pe.displayName="ThemeProvider";import{jsx as C,jsxs as oe}from"react/jsx-runtime";var B="vuuLeftNav",Ka=({"data-path":e,features:t,onResize:o,sizeCollapsed:n=80,sizeContent:a=240,sizeExpanded:r=240,style:s,tableFeatures:p,...u})=>{let m=Ro(),[l,y]=Uo({activeTabIndex:0,navStatus:"menu-full"}),[d]=ee(),g=te(f=>{switch(f){case"menu-icons":return r;case"menu-full":return n;case"menu-full-content":return n+a;case"menu-icons-content":return r+a}},[n,a,r]),h=f=>{switch(f){case"menu-icons":return"menu-full";case"menu-full":return"menu-icons";case"menu-full-content":return"menu-icons-content";case"menu-icons-content":return"menu-full-content"}},c=te((f,b)=>{if(b===0){let x=f==="menu-full-content"?"menu-full":f==="menu-icons-content"?"menu-icons":f;return x==="menu-icons"?[n,x]:[r,x]}else{let x=f==="menu-full"?"menu-full-content":f==="menu-icons"?"menu-icons-content":f;return x==="menu-icons-content"?[n+a,x]:[r+a,x]}},[n,a,r]),S=te(f=>{let[b,x]=c(l.navStatus,f);y({activeTabIndex:f,navStatus:x}),m({type:Ze.LAYOUT_RESIZE,path:e,size:b})},[m,c,l,e]),E=te(()=>{let{activeTabIndex:f,navStatus:b}=l;y({activeTabIndex:f,navStatus:h(b)}),m({type:Ze.LAYOUT_RESIZE,path:e,size:g(b)})},[m,l,e,g]),R={...s,"--nav-menu-collapsed-width":`${n}px`,"--nav-menu-expanded-width":`${r}px`};return oe("div",{...u,className:fe(B,`${B}-${l.navStatus}`),style:R,children:[oe("div",{className:fe(`${B}-menu-primary`,d),"data-mode":"dark",children:[C("div",{className:"vuuLeftNav-logo",children:C(ce,{})}),C("div",{className:`${B}-main`,children:oe(Io,{activeTabIndex:l.activeTabIndex,animateSelectionThumb:!1,className:`${B}-Tabstrip`,onActiveChange:S,orientation:"vertical",children:[C(J,{"data-icon":"demo",label:"DEMO"}),C(J,{"data-icon":"features",label:"VUU FEATURES"}),C(J,{"data-icon":"tables",label:"VUU TABLES"}),C(J,{"data-icon":"templates",label:"LAYOUT TEMPLATES"}),C(J,{"data-icon":"layouts",label:"MY LAYOUTS"})]})}),C("div",{className:"vuuLeftNav-buttonBar",children:C("button",{className:fe("vuuLeftNav-toggleButton",{"vuuLeftNav-toggleButton-open":l.navStatus.startsWith("menu-full"),"vuuLeftNav-toggleButton-closed":l.navStatus.startsWith("menu-icons")}),"data-icon":l.navStatus.startsWith("menu-full")?"chevron-left":"chevron-right",onClick:E})})]}),oe(ko,{active:l.activeTabIndex-1,className:`${B}-menu-secondary`,showTabs:!1,children:[C(me,{features:t,title:"Vuu Features"}),C(me,{features:p,title:"Vuu Tables"}),C("div",{style:{background:"green",height:"100%"},children:"Layout Templates"}),C("div",{className:"vuuLeftNav-drawer",children:C(Je,{})})]})]})};import{useState as qe}from"react";import{Button as $o,FormField as ze,FormFieldLabel as We,Input as Ke}from"@salt-ds/core";import{jsx as G,jsxs as he}from"react/jsx-runtime";var Xe="vuuLoginPanel",ls=({requirePassword:e=!0,onSubmit:t})=>{let[o,n]=qe(""),[a,r]=qe(""),s=()=>{t(o,a)},p=l=>{n(l.target.value)},u=l=>{r(l.target.value)},m=o.trim()!==""&&(e===!1||a.trim()!=="");return he("div",{className:Xe,children:[he(ze,{style:{width:200},children:[G(We,{children:"Username"}),G(Ke,{value:o,id:"text-username",onChange:p})]}),e?he(ze,{style:{width:200},children:[G(We,{children:"Password"}),G(Ke,{inputProps:{type:"password"},value:a,id:"text-password",onChange:u})]}):null,G($o,{className:`${Xe}-login`,disabled:!m,onClick:s,variant:"cta",children:"Login"})]})};import{getCookieValue as ge}from"@vuu-ui/vuu-utils";var Ao=()=>{let e=ge("vuu-auth-mode");return e!=null?e:""},ds=()=>{let e=ge("vuu-username"),t=ge("vuu-auth-token");return[e,t]},Bo=()=>Ao()==="login"?"login.html":"demo.html",Oo=(e=Bo())=>{window.location.href=e},Qe=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",Oo(e)};import{useCallback as O,useEffect as je,useMemo as _o,useRef as ye,useState as et}from"react";import tt from"classnames";import{useIdMemo as Jo}from"@salt-ds/core";import{Button as ot}from"@salt-ds/core";import{hasAction as Go,isErrorResponse as Yo,RemoteDataSource as Zo}from"@vuu-ui/vuu-data";import{buildColumnMap as qo,isValidNumber as rt,shallowEquals as zo}from"@vuu-ui/vuu-utils";import{jsx as U,jsxs as ve}from"react/jsx-runtime";var D="vuuSessionEditingForm",nt=(e,t)=>{let o=e.find(n=>n.name===t);if(o)return o;throw Error(`SessionEditingForm, no field '${t}' found`)},at=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]},H={uninitialised:0,unchanged:1,changed:2,invalid:3};function st(e,t,o=!1){switch(t){case"int":case"long":{let n=parseInt(e,10);if(rt(n))return n;if(o)throw Error("SessionEditingForm getTypedValue");return}case"double":{let n=parseFloat(e);return rt(n)?n:void 0}case"boolean":return e==="true";default:return e}}var Wo=(e,t)=>{if(e)return e;if(t)return new Zo({bufferSize:0,table:t.table,columns:t.columns.map(o=>o.name)});throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided")},Ds=({className:e,config:{fields:t,key:o},dataSource:n,id:a,onClose:r,schema:s,...p})=>{let[u,m]=et(),[l,y]=et(""),d=ye(null),g=ye(),h=ye(H.uninitialised),c=_o(()=>{let i=M=>{if(w){let F={};for(let $ of c.columns)F[$]=M[w[$]];h.current===H.uninitialised&&(h.current=H.unchanged,g.current=F),m(F)}},v=Wo(n,s),w=qo(v.columns);return v.subscribe({range:{from:0,to:5}},M=>{M.type==="viewport-update"&&M.rows&&(h.current===H.uninitialised?i(M.rows[0]):console.log("what do we do with server updates"))}),v},[n,s]),S=Jo(a),E=O(i=>{let[v,w]=at(i),{type:M}=nt(t,v),F=st(w,M);m(($={})=>{let Ne={...$,[v]:F},wt=zo(Ne,g.current);return h.current=wt?H.unchanged:F!==void 0?H.changed:H.invalid,Ne})},[t]),R=O(i=>{let[v,w]=at(i),{type:M}=nt(t,v),F=u==null?void 0:u[o],$=st(w,M,!0);typeof F=="string"&&c.menuRpcCall({rowKey:F,field:v,value:$,type:"VP_EDIT_CELL_RPC"})},[c,t,o,u]),f=O(i=>{typeof i=="object"&&i!==null&&"type"in i&&i.type==="CLOSE_DIALOG_ACTION"&&r()},[r]),b=O(async()=>{let i=await c.menuRpcCall({type:"VP_EDIT_SUBMIT_FORM_RPC"});Yo(i)?y(i.error):Go(i)&&f(i.action)},[f,c]),x=O(i=>{i.key==="Enter"&&h.current===H.changed&&b()},[b]),se=O(()=>{r()},[r]),ie=i=>{var w;let v=String((w=u==null?void 0:u[i.name])!=null?w:"");return i.readonly||i.name===o?U("div",{className:`${D}-fieldValue vuuReadOnly`,children:v}):U("input",{className:`${D}-fieldValue`,"data-field":i.name,onBlur:R,onChange:E,type:"text",value:v,id:`${S}-input-${i.name}`})};je(()=>{if(d.current){let i=d.current.querySelector("input");i&&setTimeout(()=>{i.focus(),i.select()},100)}},[]),je(()=>()=>{c&&c.unsubscribe()},[c]);let le=h.current===H.changed;return ve("div",{...p,className:tt(D,e),children:[l?U("div",{className:`${D}-errorBanner`,"data-icon":"error",title:l,children:"Error, edit(s) not saved"}):void 0,U("div",{className:`${D}-content`,ref:d,onKeyDown:x,children:t.map(i=>{var v;return ve("div",{className:`${D}-field`,children:[U("label",{className:tt(`${D}-fieldLabel`,{[`${D}-required`]:i.required}),htmlFor:`${S}-input-${i.name}`,children:(v=i==null?void 0:i.label)!=null?v:i.description}),ie(i)]},i.name)})}),ve("div",{className:`${D}-buttonbar salt-theme salt-density-high`,children:[U(ot,{type:"submit",variant:"cta",disabled:!le,onClick:b,children:"Submit"}),U(ot,{variant:"secondary",onClick:se,children:"Cancel"})]})]})};import{connectToServer as kr}from"@vuu-ui/vuu-data";import Rr from"classnames";import{useCallback as Ce,useEffect as Ir,useRef as Et}from"react";import{DraggableLayout as Ur,LayoutProvider as $r}from"@vuu-ui/vuu-layout";import{useCallback as gr}from"react";import{Button as sr}from"@salt-ds/core";import{DropdownBase as ir}from"@salt-ds/lab";import{UserSolidIcon as lr}from"@salt-ds/icons";import{formatDate as Ko}from"@vuu-ui/vuu-utils";import{List as Xo,ListItem as Qo}from"@salt-ds/lab";import{Button as jo}from"@salt-ds/core";import{ExportIcon as er}from"@salt-ds/icons";import{forwardRef as tr,useCallback as lt,useEffect as or,useState as rr}from"react";var it=async e=>await fetch(`api/vui/${e.username}`,{}).then(o=>o.ok?o.json():null).catch(()=>{console.log("error getting history")});import{jsx as re,jsxs as ut}from"react/jsx-runtime";var nr=({lastUpdate:e},{lastUpdate:t})=>t===e?0:t<e?-1:1,ar=e=>re(Qo,{...e}),ct=tr(function({loginUrl:t,onNavigate:o,user:n,layoutId:a="latest"},r){let[s,p]=rr([]);or(()=>{async function y(){let g=(await it(n)).filter(h=>h.id!=="latest").sort(nr).map(({id:h,lastUpdate:c})=>({lastUpdate:c,id:h,label:`Saved at ${Ko(new Date(c),"kk:mm:ss")}`}));console.log({sortedHistory:g}),p(g)}y()},[n]);let u=lt((y,d)=>{d&&o(d.id)},[o]),m=lt(()=>{Qe(t)},[t]),l=s.length===0?null:a==="latest"?s[0]:s.find(y=>y.id===a);return ut("div",{className:"vuuUserPanel",ref:r,children:[re(Xo,{ListItem:ar,className:"vuuUserPanel-history",onSelect:u,selected:l,source:s}),re("div",{className:"vuuUserPanel-buttonBar",children:ut(jo,{"aria-label":"logout",onClick:m,children:[re(er,{})," Logout"]})})]})});import{jsx as Le,jsxs as ur}from"react/jsx-runtime";var mt=({layoutId:e,loginUrl:t,onNavigate:o,user:n})=>ur(ir,{className:"vuuUserProfile",placement:"bottom-end",children:[Le(sr,{variant:"secondary",children:Le(lr,{})}),Le(ct,{layoutId:e,loginUrl:t,onNavigate:r=>{o(r)},user:n})]});import cr from"classnames";import{ToggleButton as dt,ToggleButtonGroup as mr,useControlled as dr}from"@salt-ds/core";import{useCallback as pr}from"react";import{jsx as pt,jsxs as hr}from"react/jsx-runtime";var fr="vuuThemeSwitch",ft=({className:e,defaultMode:t,mode:o,onChange:n,...a})=>{let[r,s]=dr({controlled:o,default:t!=null?t:"light",name:"ThemeSwitch",state:"mode"}),p=pr(m=>{let{value:l}=m.target;s(l),n(l)},[n,s]),u=cr(fr,e);return hr(mr,{className:u,...a,onChange:p,value:r,children:[pt(dt,{"aria-label":"alert","data-icon":"light",value:"dark"}),pt(dt,{"aria-label":"home","data-icon":"dark",value:"light"})]})};import yr from"classnames";import{jsx as ht,jsxs as Lr}from"react/jsx-runtime";var vr="vuuAppHeader",gt=({className:e,layoutId:t,loginUrl:o,onNavigate:n,onSwitchTheme:a,themeMode:r="light",user:s,...p})=>{let u=yr(vr,e),m=gr(l=>a==null?void 0:a(l),[a]);return Lr("header",{className:u,...p,children:[ht(ft,{defaultMode:r,onChange:m}),ht(mt,{layoutId:t,loginUrl:o,onNavigate:n,user:s})]})};import{logger as Ar}from"@vuu-ui/vuu-utils";import{Button as Cr}from"@salt-ds/core";import yt from"classnames";import{useCallback as Sr,useMemo as xr}from"react";import{layoutFromJson as Tr,useLayoutProviderDispatch as br}from"@vuu-ui/vuu-layout";import{jsx as ne,jsxs as vt}from"react/jsx-runtime";var P="vuuContextPanel",Lt=({className:e,expanded:t=!1,content:o,overlay:n=!1,title:a})=>{let r=br(),s=Sr(()=>{r({path:"#context-panel",propName:"expanded",propValue:!1,type:"set-prop"})},[r]),p=yt(P,e,{[`${P}-expanded`]:t,[`${P}-inline`]:n!==!0,[`${P}-overlay`]:n}),u=xr(()=>o?Tr(o,"context-0"):null,[o]);return ne("div",{className:yt(P,p),children:vt("div",{className:`${P}-inner`,children:[vt("div",{className:`${P}-header`,children:[ne("h2",{className:`${P}-title`,children:a}),ne(Cr,{className:`${P}-close`,"data-icon":"close",onClick:s,variant:"secondary"})]}),ne("div",{className:`${P}-content`,children:u})]})})};import{DraggableLayout as Nr,Flexbox as Ct}from"@vuu-ui/vuu-layout";import{jsx as St,jsxs as xt}from"react/jsx-runtime";var Tt=({appHeader:e,leftSidePanel:t})=>xt(Ct,{className:"App",style:{flexDirection:"row",height:"100%",width:"100%"},children:[t,xt(Ct,{className:"vuuShell-content",style:{flex:1,flexDirection:"column"},children:[e,St(Nr,{dropTarget:!0,style:{flex:1}},"main-content")]}),St(Lt,{id:"context-panel",overlay:!0,title:"Column Settings"})]});import{DockLayout as Pr,DraggableLayout as Er,Drawer as wr,Flexbox as Mr,View as Fr}from"@vuu-ui/vuu-layout";import{useCallback as bt,useRef as Dr,useState as Hr}from"react";import{jsx as ae,jsxs as Vr}from"react/jsx-runtime";var Nt=({appHeader:e,leftSidePanel:t})=>{let o=Dr(null),[n,a]=Hr(!0),r=bt(p=>{var m;let u=p.target;(m=o.current)!=null&&m.contains(u)||a(!n)},[n]),s=bt(p=>{let u=[];return u.push(ae(wr,{onClick:r,open:n,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:ae(Fr,{className:"vuuShell-palette",id:"vw-app-palette",ref:o,style:{height:"100%"},children:p},"app-palette")},"left-panel")),u},[r,n]);return Vr(Mr,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[e,ae(Pr,{style:{flex:1},children:s(t).concat(ae(Er,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})};var Pt=({leftSidePanelLayout:e="inlay",...t})=>(e==="inlay"?Nt:Tt)(t);import{jsx as xe,jsxs as Or}from"react/jsx-runtime";var{error:Se}=Ar("Shell"),Br={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Nl=({LayoutProps:e,children:t,className:o,defaultLayout:n=Br,leftSidePanel:a,leftSidePanelLayout:r,loginUrl:s,saveLocation:p="remote",saveUrl:u,serverUrl:m,user:l,...y})=>{let d=Et(null),g=Et("latest"),[h,c,S]=Re({defaultLayout:n,saveLocation:p,saveUrl:u,user:l}),E=Ce((i,v)=>{try{console.log(`handle layout changed ${v}`),c(i)}catch{Se==null||Se("Failed to save layout")}},[c]),R=Ce(i=>{d.current&&(d.current.dataset.mode=i)},[]),f=Ce(i=>{g.current=i,S(i)},[S]);Ir(()=>{m&&l.token&&kr({authToken:l.token,url:m,username:l.username})},[m,l.token,l.username]);let[b,x,se]=ee(),ie=Rr("vuuShell",o,b,x),le=Pt({leftSidePanelLayout:r,appHeader:xe(gt,{layoutId:g.current,loginUrl:s,user:l,onNavigate:f,onSwitchTheme:R}),leftSidePanel:a});return Or(pe,{children:[xe($r,{...e,layout:h,onLayoutChange:E,children:xe(Ur,{className:ie,"data-mode":se,ref:d,...y,children:le})}),t]})};import{createContext as _r,useContext as Jr}from"react";import{jsx as Te}from"react/jsx-runtime";var Gr={},be=_r(Gr),Yr=({children:e,context:t,inheritedContext:o})=>{let n={...o,...t};return Te(be.Provider,{value:n,children:e})},Dl=({children:e,value:t})=>Te(be.Consumer,{children:o=>Te(Yr,{context:t,inheritedContext:o,children:e})}),Hl=()=>Jr(be);export{Xr as ConnectionStatusIcon,Lt as ContextPanel,wo as DEFAULT_DENSITY,Mo as DEFAULT_THEME,Fo as DEFAULT_THEME_MODE,sn as DensitySwitch,z as Feature,me as FeatureList,Be as LayoutManagementContext,Qn as LayoutManagementProvider,Je as LayoutsList,Ka as LeftNav,ls as LoginPanel,Zn as SaveLayoutPanel,Ds as SessionEditingForm,Nl as Shell,Dl as ShellContextProvider,de as ThemeContext,pe as ThemeProvider,ft as ThemeSwitch,ds as getAuthDetailsFromCookies,Ao as getAuthModeFromCookies,Qe as logout,Oo as redirectToLogin,Re as useLayoutConfig,Oe as useLayoutManager,Hl as useShellContext,Pt as useShellLayout,ee as useThemeAttributes};
609
+ Wrap elements with a single container`
610
+ );
611
+ return children;
612
+ }
613
+ };
614
+ var ThemeProvider = ({
615
+ applyThemeClasses = false,
616
+ children,
617
+ theme: themeProp,
618
+ themeMode: themeModeProp,
619
+ density: densityProp
620
+ }) => {
621
+ var _a, _b, _c;
622
+ const {
623
+ density: inheritedDensity,
624
+ themeMode: inheritedThemeMode,
625
+ theme: inheritedTheme
626
+ } = useContext2(ThemeContext);
627
+ const density = (_a = densityProp != null ? densityProp : inheritedDensity) != null ? _a : DEFAULT_DENSITY2;
628
+ const themeMode = (_b = themeModeProp != null ? themeModeProp : inheritedThemeMode) != null ? _b : DEFAULT_THEME_MODE;
629
+ const theme = (_c = themeProp != null ? themeProp : inheritedTheme) != null ? _c : DEFAULT_THEME;
630
+ const themedChildren = applyThemeClasses ? createThemedChildren(children, theme, themeMode, density) : children;
631
+ return /* @__PURE__ */ jsx11(ThemeContext.Provider, { value: { themeMode, density, theme }, children: themedChildren });
632
+ };
633
+ ThemeProvider.displayName = "ThemeProvider";
634
+
635
+ // src/left-nav/LeftNav.tsx
636
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
637
+ var classBase5 = "vuuLeftNav";
638
+ var LeftNav = ({
639
+ "data-path": path,
640
+ features,
641
+ onResize,
642
+ sizeCollapsed = 80,
643
+ sizeContent = 240,
644
+ sizeExpanded = 240,
645
+ style: styleProp,
646
+ tableFeatures,
647
+ ...htmlAttributes
648
+ }) => {
649
+ const dispatch = useLayoutProviderDispatch();
650
+ const [navState, setNavState] = useState4({
651
+ activeTabIndex: 0,
652
+ navStatus: "menu-full"
653
+ });
654
+ const [themeClass] = useThemeAttributes();
655
+ const toggleNavWidth = useCallback3(
656
+ (navStatus) => {
657
+ switch (navStatus) {
658
+ case "menu-icons":
659
+ return sizeExpanded;
660
+ case "menu-full":
661
+ return sizeCollapsed;
662
+ case "menu-full-content":
663
+ return sizeCollapsed + sizeContent;
664
+ case "menu-icons-content":
665
+ return sizeExpanded + sizeContent;
666
+ }
667
+ },
668
+ [sizeCollapsed, sizeContent, sizeExpanded]
669
+ );
670
+ const toggleNavStatus = (navStatus) => {
671
+ switch (navStatus) {
672
+ case "menu-icons":
673
+ return "menu-full";
674
+ case "menu-full":
675
+ return "menu-icons";
676
+ case "menu-full-content":
677
+ return "menu-icons-content";
678
+ case "menu-icons-content":
679
+ return "menu-full-content";
680
+ }
681
+ };
682
+ const getWidthAndStatus = useCallback3(
683
+ (navState2, tabIndex) => {
684
+ if (tabIndex === 0) {
685
+ const newNavState = navState2 === "menu-full-content" ? "menu-full" : navState2 === "menu-icons-content" ? "menu-icons" : navState2;
686
+ return newNavState === "menu-icons" ? [sizeCollapsed, newNavState] : [sizeExpanded, newNavState];
687
+ } else {
688
+ const newNavState = navState2 === "menu-full" ? "menu-full-content" : navState2 === "menu-icons" ? "menu-icons-content" : navState2;
689
+ return newNavState === "menu-icons-content" ? [sizeCollapsed + sizeContent, newNavState] : [sizeExpanded + sizeContent, newNavState];
690
+ }
691
+ },
692
+ [sizeCollapsed, sizeContent, sizeExpanded]
693
+ );
694
+ const handleTabSelection = useCallback3(
695
+ (value) => {
696
+ const [width, navStatus] = getWidthAndStatus(navState.navStatus, value);
697
+ setNavState({
698
+ activeTabIndex: value,
699
+ navStatus
700
+ });
701
+ dispatch({
702
+ type: Action.LAYOUT_RESIZE,
703
+ path,
704
+ size: width
705
+ });
706
+ },
707
+ [dispatch, getWidthAndStatus, navState, path]
708
+ );
709
+ const toggleSize = useCallback3(() => {
710
+ const { activeTabIndex, navStatus: currentNavStatus } = navState;
711
+ setNavState({
712
+ activeTabIndex,
713
+ navStatus: toggleNavStatus(currentNavStatus)
714
+ });
715
+ dispatch({
716
+ type: Action.LAYOUT_RESIZE,
717
+ path,
718
+ size: toggleNavWidth(currentNavStatus)
719
+ });
720
+ }, [dispatch, navState, path, toggleNavWidth]);
721
+ const style = {
722
+ ...styleProp,
723
+ "--nav-menu-collapsed-width": `${sizeCollapsed}px`,
724
+ "--nav-menu-expanded-width": `${sizeExpanded}px`
725
+ };
726
+ return /* @__PURE__ */ jsxs7(
727
+ "div",
728
+ {
729
+ ...htmlAttributes,
730
+ className: cx4(classBase5, `${classBase5}-${navState.navStatus}`),
731
+ style,
732
+ children: [
733
+ /* @__PURE__ */ jsxs7(
734
+ "div",
735
+ {
736
+ className: cx4(`${classBase5}-menu-primary`, themeClass),
737
+ "data-mode": "dark",
738
+ children: [
739
+ /* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-logo", children: /* @__PURE__ */ jsx12(VuuLogo, {}) }),
740
+ /* @__PURE__ */ jsx12("div", { className: `${classBase5}-main`, children: /* @__PURE__ */ jsxs7(
741
+ Tabstrip,
742
+ {
743
+ activeTabIndex: navState.activeTabIndex,
744
+ animateSelectionThumb: false,
745
+ className: `${classBase5}-Tabstrip`,
746
+ onActiveChange: handleTabSelection,
747
+ orientation: "vertical",
748
+ children: [
749
+ /* @__PURE__ */ jsx12(Tab, { "data-icon": "demo", label: "DEMO" }),
750
+ /* @__PURE__ */ jsx12(Tab, { "data-icon": "features", label: "VUU FEATURES" }),
751
+ /* @__PURE__ */ jsx12(Tab, { "data-icon": "tables", label: "VUU TABLES" }),
752
+ /* @__PURE__ */ jsx12(Tab, { "data-icon": "templates", label: "LAYOUT TEMPLATES" }),
753
+ /* @__PURE__ */ jsx12(Tab, { "data-icon": "layouts", label: "MY LAYOUTS" })
754
+ ]
755
+ }
756
+ ) }),
757
+ /* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-buttonBar", children: /* @__PURE__ */ jsx12(
758
+ "button",
759
+ {
760
+ className: cx4("vuuLeftNav-toggleButton", {
761
+ "vuuLeftNav-toggleButton-open": navState.navStatus.startsWith("menu-full"),
762
+ "vuuLeftNav-toggleButton-closed": navState.navStatus.startsWith("menu-icons")
763
+ }),
764
+ "data-icon": navState.navStatus.startsWith("menu-full") ? "chevron-left" : "chevron-right",
765
+ onClick: toggleSize
766
+ }
767
+ ) })
768
+ ]
769
+ }
770
+ ),
771
+ /* @__PURE__ */ jsxs7(
772
+ Stack,
773
+ {
774
+ active: navState.activeTabIndex - 1,
775
+ className: `${classBase5}-menu-secondary`,
776
+ showTabs: false,
777
+ children: [
778
+ /* @__PURE__ */ jsx12(FeatureList, { features, title: "Vuu Features" }),
779
+ /* @__PURE__ */ jsx12(FeatureList, { features: tableFeatures, title: "Vuu Tables" }),
780
+ /* @__PURE__ */ jsx12("div", { style: { background: "green", height: "100%" }, children: "Layout Templates" }),
781
+ /* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-drawer", children: /* @__PURE__ */ jsx12(LayoutsList, {}) })
782
+ ]
783
+ }
784
+ )
785
+ ]
786
+ }
787
+ );
788
+ };
789
+
790
+ // src/login/LoginPanel.tsx
791
+ import { useState as useState5 } from "react";
792
+ import { Button as Button2, FormField as FormField2, FormFieldLabel as FormFieldLabel2, Input as Input2 } from "@salt-ds/core";
793
+ import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
794
+ var classBase6 = "vuuLoginPanel";
795
+ var LoginPanel = ({
796
+ requirePassword = true,
797
+ onSubmit
798
+ }) => {
799
+ const [username, setUserName] = useState5("");
800
+ const [password, setPassword] = useState5("");
801
+ const login = () => {
802
+ onSubmit(username, password);
803
+ };
804
+ const handleUsername = (evt) => {
805
+ setUserName(evt.target.value);
806
+ };
807
+ const handlePassword = (evt) => {
808
+ setPassword(evt.target.value);
809
+ };
810
+ const dataIsValid = username.trim() !== "" && (requirePassword === false || password.trim() !== "");
811
+ return /* @__PURE__ */ jsxs8("div", { className: classBase6, children: [
812
+ /* @__PURE__ */ jsxs8(FormField2, { style: { width: 200 }, children: [
813
+ /* @__PURE__ */ jsx13(FormFieldLabel2, { children: "Username" }),
814
+ /* @__PURE__ */ jsx13(Input2, { value: username, id: "text-username", onChange: handleUsername })
815
+ ] }),
816
+ requirePassword ? /* @__PURE__ */ jsxs8(FormField2, { style: { width: 200 }, children: [
817
+ /* @__PURE__ */ jsx13(FormFieldLabel2, { children: "Password" }),
818
+ /* @__PURE__ */ jsx13(
819
+ Input2,
820
+ {
821
+ inputProps: {
822
+ type: "password"
823
+ },
824
+ value: password,
825
+ id: "text-password",
826
+ onChange: handlePassword
827
+ }
828
+ )
829
+ ] }) : null,
830
+ /* @__PURE__ */ jsx13(
831
+ Button2,
832
+ {
833
+ className: `${classBase6}-login`,
834
+ disabled: !dataIsValid,
835
+ onClick: login,
836
+ variant: "cta",
837
+ children: "Login"
838
+ }
839
+ )
840
+ ] });
841
+ };
842
+
843
+ // src/login/login-utils.ts
844
+ import { getCookieValue } from "@vuu-ui/vuu-utils";
845
+ var getAuthModeFromCookies = () => {
846
+ const mode = getCookieValue("vuu-auth-mode");
847
+ return mode != null ? mode : "";
848
+ };
849
+ var getAuthDetailsFromCookies = () => {
850
+ const username = getCookieValue("vuu-username");
851
+ const token = getCookieValue("vuu-auth-token");
852
+ return [username, token];
853
+ };
854
+ var getDefaultLoginUrl = () => {
855
+ const authMode = getAuthModeFromCookies();
856
+ return authMode === "login" ? "login.html" : "demo.html";
857
+ };
858
+ var redirectToLogin = (loginUrl = getDefaultLoginUrl()) => {
859
+ window.location.href = loginUrl;
860
+ };
861
+ var logout = (loginUrl) => {
862
+ document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
863
+ document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
864
+ redirectToLogin(loginUrl);
865
+ };
866
+
867
+ // src/session-editing-form/SessionEditingForm.tsx
868
+ import {
869
+ useCallback as useCallback4,
870
+ useEffect as useEffect5,
871
+ useMemo,
872
+ useRef,
873
+ useState as useState6
874
+ } from "react";
875
+ import cx5 from "classnames";
876
+ import { useIdMemo } from "@salt-ds/core";
877
+ import { Button as Button3 } from "@salt-ds/core";
878
+ import {
879
+ hasAction,
880
+ isErrorResponse,
881
+ RemoteDataSource
882
+ } from "@vuu-ui/vuu-data";
883
+ import {
884
+ buildColumnMap,
885
+ isValidNumber,
886
+ shallowEquals
887
+ } from "@vuu-ui/vuu-utils";
888
+ import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
889
+ var classBase7 = "vuuSessionEditingForm";
890
+ var getField = (fields, name) => {
891
+ const field = fields.find((f) => f.name === name);
892
+ if (field) {
893
+ return field;
894
+ } else {
895
+ throw Error(`SessionEditingForm, no field '${name}' found`);
896
+ }
897
+ };
898
+ var getFieldNameAndValue = (evt) => {
899
+ const {
900
+ dataset: { field },
901
+ value
902
+ } = evt.target;
903
+ if (field === void 0) {
904
+ throw Error("SessionEditingForm, form field has no field name");
905
+ }
906
+ return [field, value];
907
+ };
908
+ var Status = {
909
+ uninitialised: 0,
910
+ unchanged: 1,
911
+ changed: 2,
912
+ invalid: 3
913
+ };
914
+ function getTypedValue(value, type, throwIfUndefined = false) {
915
+ switch (type) {
916
+ case "int":
917
+ case "long": {
918
+ const typedValue = parseInt(value, 10);
919
+ if (isValidNumber(typedValue)) {
920
+ return typedValue;
921
+ } else if (throwIfUndefined) {
922
+ throw Error("SessionEditingForm getTypedValue");
923
+ } else {
924
+ return void 0;
925
+ }
926
+ }
927
+ case "double": {
928
+ const typedValue = parseFloat(value);
929
+ if (isValidNumber(typedValue)) {
930
+ return typedValue;
931
+ }
932
+ return void 0;
933
+ }
934
+ case "boolean":
935
+ return value === "true" ? true : false;
936
+ default:
937
+ return value;
938
+ }
939
+ }
940
+ var getDataSource = (dataSource, schema) => {
941
+ if (dataSource) {
942
+ return dataSource;
943
+ } else if (schema) {
944
+ return new RemoteDataSource({
945
+ bufferSize: 0,
946
+ table: schema.table,
947
+ columns: schema.columns.map((col) => col.name)
948
+ });
949
+ } else {
950
+ throw Error(
951
+ "SessionEditingForm: either a DataSource or a TableSchema must be provided"
952
+ );
953
+ }
954
+ };
955
+ var SessionEditingForm = ({
956
+ className,
957
+ config: { fields, key: keyField },
958
+ dataSource: dataSourceProp,
959
+ id: idProp,
960
+ onClose,
961
+ schema,
962
+ ...htmlAttributes
963
+ }) => {
964
+ const [values, setValues] = useState6();
965
+ const [errorMessage, setErrorMessage] = useState6("");
966
+ const formContentRef = useRef(null);
967
+ const initialDataRef = useRef();
968
+ const dataStatusRef = useRef(Status.uninitialised);
969
+ const dataSource = useMemo(() => {
970
+ const applyServerData = (data) => {
971
+ if (columnMap) {
972
+ const values2 = {};
973
+ for (const column of dataSource.columns) {
974
+ values2[column] = data[columnMap[column]];
975
+ }
976
+ if (dataStatusRef.current === Status.uninitialised) {
977
+ dataStatusRef.current = Status.unchanged;
978
+ initialDataRef.current = values2;
979
+ }
980
+ setValues(values2);
981
+ }
982
+ };
983
+ const ds = getDataSource(dataSourceProp, schema);
984
+ const columnMap = buildColumnMap(ds.columns);
985
+ ds.subscribe({ range: { from: 0, to: 5 } }, (message) => {
986
+ if (message.type === "viewport-update" && message.rows) {
987
+ if (dataStatusRef.current === Status.uninitialised) {
988
+ applyServerData(message.rows[0]);
989
+ } else {
990
+ console.log("what do we do with server updates");
991
+ }
992
+ }
993
+ });
994
+ return ds;
995
+ }, [dataSourceProp, schema]);
996
+ const id = useIdMemo(idProp);
997
+ const handleChange = useCallback4(
998
+ (evt) => {
999
+ const [field, value] = getFieldNameAndValue(evt);
1000
+ const { type } = getField(fields, field);
1001
+ const typedValue = getTypedValue(value, type);
1002
+ setValues((values2 = {}) => {
1003
+ const newValues = {
1004
+ ...values2,
1005
+ [field]: typedValue
1006
+ };
1007
+ const notUpdated = shallowEquals(newValues, initialDataRef.current);
1008
+ dataStatusRef.current = notUpdated ? Status.unchanged : typedValue !== void 0 ? Status.changed : Status.invalid;
1009
+ return newValues;
1010
+ });
1011
+ },
1012
+ [fields]
1013
+ );
1014
+ const handleBlur = useCallback4(
1015
+ (evt) => {
1016
+ const [field, value] = getFieldNameAndValue(evt);
1017
+ const { type } = getField(fields, field);
1018
+ const rowKey = values == null ? void 0 : values[keyField];
1019
+ const typedValue = getTypedValue(value, type, true);
1020
+ if (typeof rowKey === "string") {
1021
+ dataSource.menuRpcCall({
1022
+ rowKey,
1023
+ field,
1024
+ value: typedValue,
1025
+ type: "VP_EDIT_CELL_RPC"
1026
+ });
1027
+ }
1028
+ },
1029
+ [dataSource, fields, keyField, values]
1030
+ );
1031
+ const applyAction = useCallback4(
1032
+ (action) => {
1033
+ if (typeof action === "object" && action !== null) {
1034
+ if ("type" in action && action.type === "CLOSE_DIALOG_ACTION") {
1035
+ onClose();
1036
+ }
1037
+ }
1038
+ },
1039
+ [onClose]
1040
+ );
1041
+ const handleSubmit = useCallback4(async () => {
1042
+ const response = await dataSource.menuRpcCall({
1043
+ type: "VP_EDIT_SUBMIT_FORM_RPC"
1044
+ });
1045
+ if (isErrorResponse(response)) {
1046
+ setErrorMessage(response.error);
1047
+ } else if (hasAction(response)) {
1048
+ applyAction(response.action);
1049
+ }
1050
+ }, [applyAction, dataSource]);
1051
+ const handleKeyDown = useCallback4(
1052
+ (evt) => {
1053
+ if (evt.key === "Enter" && dataStatusRef.current === Status.changed) {
1054
+ handleSubmit();
1055
+ }
1056
+ },
1057
+ [handleSubmit]
1058
+ );
1059
+ const handleCancel = useCallback4(() => {
1060
+ onClose();
1061
+ }, [onClose]);
1062
+ const getFormControl = (field) => {
1063
+ var _a;
1064
+ const value = String((_a = values == null ? void 0 : values[field.name]) != null ? _a : "");
1065
+ if (field.readonly || field.name === keyField) {
1066
+ return /* @__PURE__ */ jsx14("div", { className: `${classBase7}-fieldValue vuuReadOnly`, children: value });
1067
+ } else {
1068
+ return /* @__PURE__ */ jsx14(
1069
+ "input",
1070
+ {
1071
+ className: `${classBase7}-fieldValue`,
1072
+ "data-field": field.name,
1073
+ onBlur: handleBlur,
1074
+ onChange: handleChange,
1075
+ type: "text",
1076
+ value,
1077
+ id: `${id}-input-${field.name}`
1078
+ }
1079
+ );
1080
+ }
1081
+ };
1082
+ useEffect5(() => {
1083
+ if (formContentRef.current) {
1084
+ const firstInput = formContentRef.current.querySelector(
1085
+ "input"
1086
+ );
1087
+ if (firstInput) {
1088
+ setTimeout(() => {
1089
+ firstInput.focus();
1090
+ firstInput.select();
1091
+ }, 100);
1092
+ }
1093
+ }
1094
+ }, []);
1095
+ useEffect5(() => {
1096
+ return () => {
1097
+ if (dataSource) {
1098
+ dataSource.unsubscribe();
1099
+ }
1100
+ };
1101
+ }, [dataSource]);
1102
+ const isDirty = dataStatusRef.current === Status.changed;
1103
+ return /* @__PURE__ */ jsxs9("div", { ...htmlAttributes, className: cx5(classBase7, className), children: [
1104
+ errorMessage ? /* @__PURE__ */ jsx14(
1105
+ "div",
1106
+ {
1107
+ className: `${classBase7}-errorBanner`,
1108
+ "data-icon": "error",
1109
+ title: errorMessage,
1110
+ children: "Error, edit(s) not saved"
1111
+ }
1112
+ ) : void 0,
1113
+ /* @__PURE__ */ jsx14(
1114
+ "div",
1115
+ {
1116
+ className: `${classBase7}-content`,
1117
+ ref: formContentRef,
1118
+ onKeyDown: handleKeyDown,
1119
+ children: fields.map((field) => {
1120
+ var _a;
1121
+ return /* @__PURE__ */ jsxs9("div", { className: `${classBase7}-field`, children: [
1122
+ /* @__PURE__ */ jsx14(
1123
+ "label",
1124
+ {
1125
+ className: cx5(`${classBase7}-fieldLabel`, {
1126
+ [`${classBase7}-required`]: field.required
1127
+ }),
1128
+ htmlFor: `${id}-input-${field.name}`,
1129
+ children: (_a = field == null ? void 0 : field.label) != null ? _a : field.description
1130
+ }
1131
+ ),
1132
+ getFormControl(field)
1133
+ ] }, field.name);
1134
+ })
1135
+ }
1136
+ ),
1137
+ /* @__PURE__ */ jsxs9("div", { className: `${classBase7}-buttonbar salt-theme salt-density-high`, children: [
1138
+ /* @__PURE__ */ jsx14(
1139
+ Button3,
1140
+ {
1141
+ type: "submit",
1142
+ variant: "cta",
1143
+ disabled: !isDirty,
1144
+ onClick: handleSubmit,
1145
+ children: "Submit"
1146
+ }
1147
+ ),
1148
+ /* @__PURE__ */ jsx14(Button3, { variant: "secondary", onClick: handleCancel, children: "Cancel" })
1149
+ ] })
1150
+ ] });
1151
+ };
1152
+
1153
+ // src/shell.tsx
1154
+ import { connectToServer } from "@vuu-ui/vuu-data";
1155
+ import cx9 from "classnames";
1156
+ import {
1157
+ useCallback as useCallback10,
1158
+ useEffect as useEffect7,
1159
+ useRef as useRef3
1160
+ } from "react";
1161
+ import {
1162
+ DraggableLayout as DraggableLayout3,
1163
+ LayoutProvider
1164
+ } from "@vuu-ui/vuu-layout";
1165
+
1166
+ // src/app-header/AppHeader.tsx
1167
+ import { useCallback as useCallback7 } from "react";
1168
+
1169
+ // src/user-profile/UserProfile.tsx
1170
+ import { Button as Button5 } from "@salt-ds/core";
1171
+ import { DropdownBase } from "@salt-ds/lab";
1172
+ import { UserSolidIcon } from "@salt-ds/icons";
1173
+
1174
+ // src/user-profile/UserPanel.tsx
1175
+ import { formatDate as formatDate2 } from "@vuu-ui/vuu-utils";
1176
+ import { List as List2, ListItem } from "@salt-ds/lab";
1177
+ import { Button as Button4 } from "@salt-ds/core";
1178
+ import { ExportIcon } from "@salt-ds/icons";
1179
+ import {
1180
+ forwardRef,
1181
+ useCallback as useCallback5,
1182
+ useEffect as useEffect6,
1183
+ useState as useState7
1184
+ } from "react";
1185
+
1186
+ // src/get-layout-history.ts
1187
+ var getLayoutHistory = async (user) => {
1188
+ const history = await fetch(`api/vui/${user.username}`, {}).then((response) => {
1189
+ return response.ok ? response.json() : null;
1190
+ }).catch(() => {
1191
+ console.log("error getting history");
1192
+ });
1193
+ return history;
1194
+ };
1195
+
1196
+ // src/user-profile/UserPanel.tsx
1197
+ import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
1198
+ var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
1199
+ return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
1200
+ };
1201
+ var HistoryListItem = (props) => {
1202
+ return /* @__PURE__ */ jsx15(ListItem, { ...props });
1203
+ };
1204
+ var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
1205
+ const [history, setHistory] = useState7([]);
1206
+ useEffect6(() => {
1207
+ async function getHistory() {
1208
+ const history2 = await getLayoutHistory(user);
1209
+ const sortedHistory = history2.filter((item) => item.id !== "latest").sort(byLastUpdate).map(({ id, lastUpdate }) => ({
1210
+ lastUpdate,
1211
+ id,
1212
+ label: `Saved at ${formatDate2(new Date(lastUpdate), "kk:mm:ss")}`
1213
+ }));
1214
+ console.log({ sortedHistory });
1215
+ setHistory(sortedHistory);
1216
+ }
1217
+ getHistory();
1218
+ }, [user]);
1219
+ const handleHisorySelected = useCallback5(
1220
+ (evt, selected2) => {
1221
+ if (selected2) {
1222
+ onNavigate(selected2.id);
1223
+ }
1224
+ },
1225
+ [onNavigate]
1226
+ );
1227
+ const handleLogout = useCallback5(() => {
1228
+ logout(loginUrl);
1229
+ }, [loginUrl]);
1230
+ const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
1231
+ return /* @__PURE__ */ jsxs10("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
1232
+ /* @__PURE__ */ jsx15(
1233
+ List2,
1234
+ {
1235
+ ListItem: HistoryListItem,
1236
+ className: "vuuUserPanel-history",
1237
+ onSelect: handleHisorySelected,
1238
+ selected,
1239
+ source: history
1240
+ }
1241
+ ),
1242
+ /* @__PURE__ */ jsx15("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ jsxs10(Button4, { "aria-label": "logout", onClick: handleLogout, children: [
1243
+ /* @__PURE__ */ jsx15(ExportIcon, {}),
1244
+ " Logout"
1245
+ ] }) })
1246
+ ] });
1247
+ });
1248
+
1249
+ // src/user-profile/UserProfile.tsx
1250
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
1251
+ var UserProfile = ({
1252
+ layoutId,
1253
+ loginUrl,
1254
+ onNavigate,
1255
+ user
1256
+ }) => {
1257
+ const handleNavigate = (id) => {
1258
+ onNavigate(id);
1259
+ };
1260
+ return /* @__PURE__ */ jsxs11(DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
1261
+ /* @__PURE__ */ jsx16(Button5, { variant: "secondary", children: /* @__PURE__ */ jsx16(UserSolidIcon, {}) }),
1262
+ /* @__PURE__ */ jsx16(
1263
+ UserPanel,
1264
+ {
1265
+ layoutId,
1266
+ loginUrl,
1267
+ onNavigate: handleNavigate,
1268
+ user
1269
+ }
1270
+ )
1271
+ ] });
1272
+ };
1273
+
1274
+ // src/theme-switch/ThemeSwitch.tsx
1275
+ import cx6 from "classnames";
1276
+ import { ToggleButton, ToggleButtonGroup, useControlled } from "@salt-ds/core";
1277
+ import { useCallback as useCallback6 } from "react";
1278
+ import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
1279
+ var classBase8 = "vuuThemeSwitch";
1280
+ var ThemeSwitch = ({
1281
+ className: classNameProp,
1282
+ defaultMode: defaultModeProp,
1283
+ mode: modeProp,
1284
+ onChange,
1285
+ ...htmlAttributes
1286
+ }) => {
1287
+ const [mode, setMode] = useControlled({
1288
+ controlled: modeProp,
1289
+ default: defaultModeProp != null ? defaultModeProp : "light",
1290
+ name: "ThemeSwitch",
1291
+ state: "mode"
1292
+ });
1293
+ const handleChangeSecondary = useCallback6(
1294
+ (evt) => {
1295
+ const { value } = evt.target;
1296
+ setMode(value);
1297
+ onChange(value);
1298
+ },
1299
+ [onChange, setMode]
1300
+ );
1301
+ const className = cx6(classBase8, classNameProp);
1302
+ return /* @__PURE__ */ jsxs12(
1303
+ ToggleButtonGroup,
1304
+ {
1305
+ className,
1306
+ ...htmlAttributes,
1307
+ onChange: handleChangeSecondary,
1308
+ value: mode,
1309
+ children: [
1310
+ /* @__PURE__ */ jsx17(ToggleButton, { "aria-label": "alert", "data-icon": "light", value: "dark" }),
1311
+ /* @__PURE__ */ jsx17(ToggleButton, { "aria-label": "home", "data-icon": "dark", value: "light" })
1312
+ ]
1313
+ }
1314
+ );
1315
+ };
1316
+
1317
+ // src/app-header/AppHeader.tsx
1318
+ import cx7 from "classnames";
1319
+ import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
1320
+ var classBase9 = "vuuAppHeader";
1321
+ var AppHeader = ({
1322
+ className: classNameProp,
1323
+ layoutId,
1324
+ loginUrl,
1325
+ onNavigate,
1326
+ onSwitchTheme,
1327
+ themeMode = "light",
1328
+ user,
1329
+ ...htmlAttributes
1330
+ }) => {
1331
+ const className = cx7(classBase9, classNameProp);
1332
+ const handleSwitchTheme = useCallback7(
1333
+ (mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
1334
+ [onSwitchTheme]
1335
+ );
1336
+ return /* @__PURE__ */ jsxs13("header", { className, ...htmlAttributes, children: [
1337
+ /* @__PURE__ */ jsx18(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
1338
+ /* @__PURE__ */ jsx18(
1339
+ UserProfile,
1340
+ {
1341
+ layoutId,
1342
+ loginUrl,
1343
+ onNavigate,
1344
+ user
1345
+ }
1346
+ )
1347
+ ] });
1348
+ };
1349
+
1350
+ // src/shell.tsx
1351
+ import { logger } from "@vuu-ui/vuu-utils";
1352
+
1353
+ // src/shell-layouts/context-panel/ContextPanel.tsx
1354
+ import { Button as Button6 } from "@salt-ds/core";
1355
+ import cx8 from "classnames";
1356
+ import { useCallback as useCallback8, useMemo as useMemo2 } from "react";
1357
+ import {
1358
+ layoutFromJson,
1359
+ useLayoutProviderDispatch as useLayoutProviderDispatch2
1360
+ } from "@vuu-ui/vuu-layout";
1361
+ import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
1362
+ var classBase10 = "vuuContextPanel";
1363
+ var ContextPanel = ({
1364
+ className: classNameProp,
1365
+ expanded = false,
1366
+ content: contentProp,
1367
+ overlay = false,
1368
+ title
1369
+ }) => {
1370
+ const dispatchLayoutAction = useLayoutProviderDispatch2();
1371
+ const handleClose = useCallback8(() => {
1372
+ dispatchLayoutAction({
1373
+ path: "#context-panel",
1374
+ propName: "expanded",
1375
+ propValue: false,
1376
+ type: "set-prop"
1377
+ });
1378
+ }, [dispatchLayoutAction]);
1379
+ const className = cx8(classBase10, classNameProp, {
1380
+ [`${classBase10}-expanded`]: expanded,
1381
+ [`${classBase10}-inline`]: overlay !== true,
1382
+ [`${classBase10}-overlay`]: overlay
1383
+ });
1384
+ const content = useMemo2(
1385
+ () => contentProp ? layoutFromJson(contentProp, "context-0") : null,
1386
+ [contentProp]
1387
+ );
1388
+ return /* @__PURE__ */ jsx19("div", { className: cx8(classBase10, className), children: /* @__PURE__ */ jsxs14("div", { className: `${classBase10}-inner`, children: [
1389
+ /* @__PURE__ */ jsxs14("div", { className: `${classBase10}-header`, children: [
1390
+ /* @__PURE__ */ jsx19("h2", { className: `${classBase10}-title`, children: title }),
1391
+ /* @__PURE__ */ jsx19(
1392
+ Button6,
1393
+ {
1394
+ className: `${classBase10}-close`,
1395
+ "data-icon": "close",
1396
+ onClick: handleClose,
1397
+ variant: "secondary"
1398
+ }
1399
+ )
1400
+ ] }),
1401
+ /* @__PURE__ */ jsx19("div", { className: `${classBase10}-content`, children: content })
1402
+ ] }) });
1403
+ };
1404
+
1405
+ // src/shell-layouts/useFullHeightLeftPanel.tsx
1406
+ import { DraggableLayout, Flexbox } from "@vuu-ui/vuu-layout";
1407
+ import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
1408
+ var useFullHeightLeftPanel = ({
1409
+ appHeader,
1410
+ leftSidePanel
1411
+ }) => {
1412
+ return /* @__PURE__ */ jsxs15(
1413
+ Flexbox,
1414
+ {
1415
+ className: "App",
1416
+ style: {
1417
+ flexDirection: "row",
1418
+ height: "100%",
1419
+ width: "100%"
1420
+ },
1421
+ children: [
1422
+ leftSidePanel,
1423
+ /* @__PURE__ */ jsxs15(
1424
+ Flexbox,
1425
+ {
1426
+ className: "vuuShell-content",
1427
+ style: { flex: 1, flexDirection: "column" },
1428
+ children: [
1429
+ appHeader,
1430
+ /* @__PURE__ */ jsx20(DraggableLayout, { dropTarget: true, style: { flex: 1 } }, "main-content")
1431
+ ]
1432
+ }
1433
+ ),
1434
+ /* @__PURE__ */ jsx20(
1435
+ ContextPanel,
1436
+ {
1437
+ id: "context-panel",
1438
+ overlay: true,
1439
+ title: "Column Settings"
1440
+ }
1441
+ )
1442
+ ]
1443
+ }
1444
+ );
1445
+ };
1446
+
1447
+ // src/shell-layouts/useInlayLeftPanel.tsx
1448
+ import {
1449
+ DockLayout,
1450
+ DraggableLayout as DraggableLayout2,
1451
+ Drawer,
1452
+ Flexbox as Flexbox2,
1453
+ View
1454
+ } from "@vuu-ui/vuu-layout";
1455
+ import { useCallback as useCallback9, useRef as useRef2, useState as useState8 } from "react";
1456
+ import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
1457
+ var useInlayLeftPanel = ({
1458
+ appHeader,
1459
+ leftSidePanel
1460
+ }) => {
1461
+ const paletteView = useRef2(null);
1462
+ const [open, setOpen] = useState8(true);
1463
+ const handleDrawerClick = useCallback9(
1464
+ (e) => {
1465
+ var _a;
1466
+ const target = e.target;
1467
+ if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
1468
+ setOpen(!open);
1469
+ }
1470
+ },
1471
+ [open]
1472
+ );
1473
+ const getDrawers = useCallback9(
1474
+ (leftSidePanel2) => {
1475
+ const drawers = [];
1476
+ drawers.push(
1477
+ /* @__PURE__ */ jsx21(
1478
+ Drawer,
1479
+ {
1480
+ onClick: handleDrawerClick,
1481
+ open,
1482
+ position: "left",
1483
+ inline: true,
1484
+ peekaboo: true,
1485
+ sizeOpen: 200,
1486
+ toggleButton: "end",
1487
+ children: /* @__PURE__ */ jsx21(
1488
+ View,
1489
+ {
1490
+ className: "vuuShell-palette",
1491
+ id: "vw-app-palette",
1492
+ ref: paletteView,
1493
+ style: { height: "100%" },
1494
+ children: leftSidePanel2
1495
+ },
1496
+ "app-palette"
1497
+ )
1498
+ },
1499
+ "left-panel"
1500
+ )
1501
+ );
1502
+ return drawers;
1503
+ },
1504
+ [handleDrawerClick, open]
1505
+ );
1506
+ return /* @__PURE__ */ jsxs16(
1507
+ Flexbox2,
1508
+ {
1509
+ className: "App",
1510
+ style: { flexDirection: "column", height: "100%", width: "100%" },
1511
+ children: [
1512
+ appHeader,
1513
+ /* @__PURE__ */ jsx21(DockLayout, { style: { flex: 1 }, children: getDrawers(leftSidePanel).concat(
1514
+ /* @__PURE__ */ jsx21(
1515
+ DraggableLayout2,
1516
+ {
1517
+ dropTarget: true,
1518
+ style: { width: "100%", height: "100%" }
1519
+ },
1520
+ "main-content"
1521
+ )
1522
+ ) })
1523
+ ]
1524
+ }
1525
+ );
1526
+ };
1527
+
1528
+ // src/shell-layouts/useShellLayout.ts
1529
+ var useShellLayout = ({
1530
+ leftSidePanelLayout = "inlay",
1531
+ ...props
1532
+ }) => {
1533
+ const useLayoutHook = leftSidePanelLayout === "inlay" ? useInlayLeftPanel : useFullHeightLeftPanel;
1534
+ return useLayoutHook(props);
1535
+ };
1536
+
1537
+ // src/shell.tsx
1538
+ import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
1539
+ var { error } = logger("Shell");
1540
+ var Shell = ({
1541
+ LayoutProps,
1542
+ children,
1543
+ className: classNameProp,
1544
+ leftSidePanel,
1545
+ leftSidePanelLayout,
1546
+ loginUrl,
1547
+ saveLocation = "remote",
1548
+ saveUrl,
1549
+ serverUrl,
1550
+ user,
1551
+ ...htmlAttributes
1552
+ }) => {
1553
+ const rootRef = useRef3(null);
1554
+ const layoutId = useRef3("latest");
1555
+ const { applicationLayout, saveApplicationLayout, loadLayoutById } = useLayoutManager();
1556
+ const handleLayoutChange = useCallback10(
1557
+ (layout, layoutChangeReason) => {
1558
+ try {
1559
+ saveApplicationLayout(layout);
1560
+ console.log(`handle layout changed ${layoutChangeReason}`);
1561
+ } catch {
1562
+ error == null ? void 0 : error("Failed to save layout");
1563
+ }
1564
+ },
1565
+ [saveApplicationLayout]
1566
+ );
1567
+ const handleSwitchTheme = useCallback10((mode) => {
1568
+ if (rootRef.current) {
1569
+ rootRef.current.dataset.mode = mode;
1570
+ }
1571
+ }, []);
1572
+ const handleNavigate = useCallback10(
1573
+ (id) => {
1574
+ layoutId.current = id;
1575
+ loadLayoutById(id);
1576
+ },
1577
+ [loadLayoutById]
1578
+ );
1579
+ useEffect7(() => {
1580
+ if (serverUrl && user.token) {
1581
+ connectToServer({
1582
+ authToken: user.token,
1583
+ url: serverUrl,
1584
+ username: user.username
1585
+ });
1586
+ }
1587
+ }, [serverUrl, user.token, user.username]);
1588
+ const [themeClass, densityClass, dataMode] = useThemeAttributes();
1589
+ const className = cx9("vuuShell", classNameProp, themeClass, densityClass);
1590
+ const shellLayout = useShellLayout({
1591
+ leftSidePanelLayout,
1592
+ appHeader: /* @__PURE__ */ jsx22(
1593
+ AppHeader,
1594
+ {
1595
+ layoutId: layoutId.current,
1596
+ loginUrl,
1597
+ user,
1598
+ onNavigate: handleNavigate,
1599
+ onSwitchTheme: handleSwitchTheme
1600
+ }
1601
+ ),
1602
+ leftSidePanel
1603
+ });
1604
+ return /* @__PURE__ */ jsxs17(ThemeProvider, { children: [
1605
+ /* @__PURE__ */ jsx22(
1606
+ LayoutProvider,
1607
+ {
1608
+ ...LayoutProps,
1609
+ layout: applicationLayout,
1610
+ onLayoutChange: handleLayoutChange,
1611
+ children: /* @__PURE__ */ jsx22(
1612
+ DraggableLayout3,
1613
+ {
1614
+ className,
1615
+ "data-mode": dataMode,
1616
+ ref: rootRef,
1617
+ ...htmlAttributes,
1618
+ children: shellLayout
1619
+ }
1620
+ )
1621
+ }
1622
+ ),
1623
+ children
1624
+ ] });
1625
+ };
1626
+
1627
+ // src/ShellContextProvider.tsx
1628
+ import { createContext as createContext2, useContext as useContext3 } from "react";
1629
+ import { jsx as jsx23 } from "react/jsx-runtime";
1630
+ var defaultConfig = {};
1631
+ var ShellContext = createContext2(defaultConfig);
1632
+ var Provider = ({
1633
+ children,
1634
+ context,
1635
+ inheritedContext
1636
+ }) => {
1637
+ const mergedContext = {
1638
+ ...inheritedContext,
1639
+ ...context
1640
+ };
1641
+ return /* @__PURE__ */ jsx23(ShellContext.Provider, { value: mergedContext, children });
1642
+ };
1643
+ var ShellContextProvider = ({
1644
+ children,
1645
+ value
1646
+ }) => {
1647
+ return /* @__PURE__ */ jsx23(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx23(Provider, { context: value, inheritedContext: context, children }) });
1648
+ };
1649
+ var useShellContext = () => {
1650
+ return useContext3(ShellContext);
1651
+ };
1652
+ export {
1653
+ ConnectionStatusIcon,
1654
+ ContextPanel,
1655
+ DEFAULT_DENSITY2 as DEFAULT_DENSITY,
1656
+ DEFAULT_THEME,
1657
+ DEFAULT_THEME_MODE,
1658
+ DensitySwitch,
1659
+ Feature,
1660
+ FeatureList,
1661
+ LayoutManagementContext,
1662
+ LayoutManagementProvider,
1663
+ LayoutsList,
1664
+ LeftNav,
1665
+ LoginPanel,
1666
+ SaveLayoutPanel,
1667
+ SessionEditingForm,
1668
+ Shell,
1669
+ ShellContextProvider,
1670
+ ThemeContext,
1671
+ ThemeProvider,
1672
+ ThemeSwitch,
1673
+ getAuthDetailsFromCookies,
1674
+ getAuthModeFromCookies,
1675
+ logout,
1676
+ redirectToLogin,
1677
+ useLayoutManager,
1678
+ useShellContext,
1679
+ useShellLayout,
1680
+ useThemeAttributes
1681
+ };
4
1682
  //# sourceMappingURL=index.js.map