@vuu-ui/vuu-shell 0.6.21 → 0.6.22-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -1,2 +1,578 @@
1
- import D,{Suspense as he}from"react";import{registerComponent as ge}from"@vuu-ui/vuu-layout";import ue from"react";import{Fragment as ce,jsx as U,jsxs as pe}from"react/jsx-runtime";var x=class extends ue.Component{constructor(e){super(e),this.state={errorMessage:null}}static getDerivedStateFromError(e){return{errorMessage:e.message}}componentDidCatch(e,o){console.log(e,o)}render(){return this.state.errorMessage?pe(ce,{children:[U("h1",{children:"Something went wrong."}),U("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as de}from"react/jsx-runtime";var E=()=>de("div",{className:"hwLoader",children:"loading"});var k=async t=>{let e=new CSSStyleSheet;return fetch(t).then(o=>o.text()).then(o=>e.replace(o))};import{jsx as C}from"react/jsx-runtime";function fe({url:t,css:e,params:o,...r}){e&&k(e).then(n=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,n]});let s=D.lazy(()=>import(t));return C(x,{children:C(he,{fallback:C(E,{}),children:C(s,{...r,...o})})})}var I=D.memo(fe);I.displayName="Feature";ge("Feature",I,"view");import{useState as R}from"react";import{Button as ye}from"@salt-ds/core";import{FormField as B,Input as F}from"@heswell/salt-lab";import{jsx as v,jsxs as ve}from"react/jsx-runtime";var A="vuuLoginPanel",Nt=({onSubmit:t})=>{let[e,o]=R(""),[r,s]=R(""),n=()=>{t(e,r)},a=(l,u)=>{o(u)},m=(l,u)=>{s(u)},i=e.trim()!==""&&r.trim()!=="";return ve("div",{className:A,children:[v(B,{label:"Username",style:{width:200},children:v(F,{value:e,id:"text-username",onChange:a})}),v(B,{label:"Password",style:{width:200},children:v(F,{type:"password",value:r,id:"text-password",onChange:m})}),v(ye,{className:`${A}-login`,disabled:!i,onClick:n,variant:"cta",children:"Login"})]})};import{getCookieValue as V}from"@vuu-ui/vuu-utils";var Dt=()=>{let t=V("vuu-username"),e=V("vuu-auth-token");return[t,e]},xe=(t="/login.html")=>{window.location.href=t},O=t=>{document.cookie="vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",document.cookie="vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",xe(t)};import{connectToServer as Ye}from"@vuu-ui/vuu-data";import{useCallback as H,useEffect as Ze,useRef as M,useState as ee}from"react";import{useCallback as P,useEffect as Ce,useState as Le}from"react";var Pe=(t,e)=>{let[o,r]=Le(e),s=i=>{r(i)},n=P(async(i="latest")=>{fetch(`api/vui/${t.username}/${i}`,{}).then(l=>l.ok?l.json():e).then(s).catch(()=>{s(e)})},[e,t.username]);Ce(()=>{n()},[n]);let a=P(i=>{fetch(`api/vui/${t.username}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then(l=>l.ok?l.json():e)},[e,t]),m=P(i=>{n(i)},[n]);return[o,a,m]},$=Pe;import{createContext as Se,useContext as Te}from"react";import{jsx as S}from"react/jsx-runtime";var we={},T=Se(we),He=({children:t,context:e,inheritedContext:o})=>{let r={...o,...e};return S(T.Provider,{value:r,children:t})},G=({children:t,value:e})=>S(T.Consumer,{children:o=>S(He,{context:e,inheritedContext:o,children:t})}),Jt=()=>Te(T);import je from"classnames";import{Chest as et,DraggableLayout as te,Drawer as tt,Flexbox as ot,LayoutProvider as rt,View as nt}from"@vuu-ui/vuu-layout";import{useCallback as Ke}from"react";import{Button as Fe}from"@salt-ds/core";import{DropdownBase as Ae}from"@heswell/salt-lab";import{UserSolidIcon as Ve}from"@salt-ds/icons";import{formatDate as Me}from"@vuu-ui/vuu-utils";import{List as be,ListItem as Ne}from"@heswell/salt-lab";import{Button as Ue}from"@salt-ds/core";import{ExportIcon as Ee}from"@salt-ds/icons";import{forwardRef as ke,useCallback as _,useEffect as De,useState as Ie}from"react";var J=async t=>await fetch(`api/vui/${t.username}`,{}).then(o=>o.ok?o.json():null).catch(()=>{console.log("error getting history")});import{jsx as L,jsxs as z}from"react/jsx-runtime";var Re=({lastUpdate:t},{lastUpdate:e})=>e===t?0:e<t?-1:1,Be=t=>L(Ne,{...t}),q=ke(function({loginUrl:e,onNavigate:o,user:r,layoutId:s="latest"},n){let[a,m]=Ie([]);De(()=>{async function p(){let g=(await J(r)).filter(f=>f.id!=="latest").sort(Re).map(({id:f,lastUpdate:y})=>({lastUpdate:y,id:f,label:`Saved at ${Me(new Date(y),"kk:mm:ss")}`}));console.log({sortedHistory:g}),m(g)}p()},[r]);let i=_((p,d)=>{d&&o(d.id)},[o]),l=_(()=>{O(e)},[e]),u=a.length===0?null:s==="latest"?a[0]:a.find(p=>p.id===s);return z("div",{className:"vuuUserPanel",ref:n,children:[L(be,{ListItem:Be,className:"vuuUserPanel-history",onSelect:i,selected:u,source:a}),L("div",{className:"vuuUserPanel-buttonBar",children:z(Ue,{"aria-label":"logout",onClick:l,children:[L(Ee,{})," Logout"]})})]})});import{jsx as w,jsxs as Oe}from"react/jsx-runtime";var K=({layoutId:t,loginUrl:e,onNavigate:o,user:r})=>Oe(Ae,{className:"vuuUserProfile",placement:"bottom-end",children:[w(Fe,{variant:"secondary",children:w(Ve,{})}),w(q,{layoutId:t,loginUrl:e,onNavigate:n=>{o(n)},user:r})]});import{ToggleButton as Q,ToggleButtonGroup as $e}from"@heswell/salt-lab";import Ge from"classnames";import{useControlled as Je}from"@salt-ds/core";import{useCallback as _e}from"react";import{jsx as X,jsxs as qe}from"react/jsx-runtime";var ze="vuuThemeSwitch",W=["light","dark"],Y=({className:t,defaultMode:e,mode:o,onChange:r,...s})=>{let[n,a]=Je({controlled:o,default:e!=null?e:"light",name:"ThemeSwitch",state:"mode"}),m=W.indexOf(n),i=_e((u,p)=>{let d=W[p];a(d),r(d)},[r,a]),l=Ge(ze,t);return qe($e,{className:l,...s,onChange:i,selectedIndex:m,children:[X(Q,{"aria-label":"alert",tooltipText:"Light Theme","data-icon":"light"}),X(Q,{"aria-label":"home",tooltipText:"Dark Theme","data-icon":"dark"})]})};import Qe from"classnames";import{jsx as Z,jsxs as Xe}from"react/jsx-runtime";var We="vuuAppHeader",j=({className:t,layoutId:e,loginUrl:o,onNavigate:r,onSwitchTheme:s,themeMode:n="light",user:a,...m})=>{let i=Qe(We,t,"salt-density-medium"),l=Ke(u=>s==null?void 0:s(u),[s]);return Xe("header",{className:i,...m,children:[Z(Y,{defaultMode:n,onChange:l}),Z(K,{layoutId:e,loginUrl:o,onNavigate:r,user:a})]})};import{jsx as h,jsxs as oe}from"react/jsx-runtime";var st={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},ir=({children:t,className:e,defaultLayout:o=st,leftSidePanel:r,loginUrl:s,serverUrl:n,user:a,...m})=>{let i=M(null),[l]=ee("high"),u=M(null),[p,d]=ee(!1),g=M("latest"),[f,y,b]=$(a,o),re=H(c=>{y(c)},[y]),ne=H(c=>{i.current&&(i.current.dataset.mode=c)},[]),se=c=>{var N;let me=c.target;(N=u.current)!=null&&N.contains(me)||d(!p)},ae=H(c=>{g.current=c,b(c)},[b]);Ze(()=>{n&&a.token&&Ye(n,a.token)},[n,a.token]);let ie=()=>{let c=[];return r&&c.push(h(tt,{onClick:se,open:p,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:h(nt,{className:"vuuShell-palette",id:"vw-app-palette",ref:u,style:{height:"100%"},children:r},"app-palette")},"left-panel")),c},le=je("vuuShell",e,"salt-theme",`salt-density-${l}`);return oe(G,{value:void 0,children:[h(rt,{layout:f,onLayoutChange:re,children:h(te,{className:le,"data-mode":"light",ref:i,...m,children:oe(ot,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[h(j,{layoutId:g.current,loginUrl:s,user:a,onNavigate:ae,onSwitchTheme:ne}),h(et,{style:{flex:1},children:ie().concat(h(te,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})})}),t]})};export{I as Feature,Nt as LoginPanel,ir as Shell,G as ShellContextProvider,Y as ThemeSwitch,Dt as getAuthDetailsFromCookies,O as logout,xe as redirectToLogin,Jt as useShellContext};
1
+ // src/feature/Feature.tsx
2
+ import React2, { Suspense } from "react";
3
+ import { registerComponent } from "@vuu-ui/vuu-layout";
4
+
5
+ // src/feature/ErrorBoundary.jsx
6
+ import React from "react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ var ErrorBoundary = class extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.state = { errorMessage: null };
12
+ }
13
+ static getDerivedStateFromError(error) {
14
+ return { errorMessage: error.message };
15
+ }
16
+ componentDidCatch(error, errorInfo) {
17
+ console.log(error, errorInfo);
18
+ }
19
+ render() {
20
+ if (this.state.errorMessage) {
21
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ /* @__PURE__ */ jsx("h1", { children: "Something went wrong." }),
23
+ /* @__PURE__ */ jsx("p", { children: this.state.errorMessage })
24
+ ] });
25
+ }
26
+ return this.props.children;
27
+ }
28
+ };
29
+
30
+ // src/feature/Loader.tsx
31
+ import { jsx as jsx2 } from "react/jsx-runtime";
32
+ var Loader = () => /* @__PURE__ */ jsx2("div", { className: "hwLoader", children: "loading" });
33
+
34
+ // src/feature/css-module-loader.ts
35
+ var importCSS = async (path) => {
36
+ const container = new CSSStyleSheet();
37
+ return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
38
+ };
39
+
40
+ // src/feature/Feature.tsx
41
+ import { jsx as jsx3 } from "react/jsx-runtime";
42
+ function RawFeature({
43
+ url,
44
+ css,
45
+ params,
46
+ ...props
47
+ }) {
48
+ if (css) {
49
+ importCSS(css).then((styleSheet) => {
50
+ document.adoptedStyleSheets = [
51
+ ...document.adoptedStyleSheets,
52
+ styleSheet
53
+ ];
54
+ });
55
+ }
56
+ const LazyFeature = React2.lazy(() => import(
57
+ /* @vite-ignore */
58
+ url
59
+ ));
60
+ return /* @__PURE__ */ jsx3(ErrorBoundary, { children: /* @__PURE__ */ jsx3(Suspense, { fallback: /* @__PURE__ */ jsx3(Loader, {}), children: /* @__PURE__ */ jsx3(LazyFeature, { ...props, ...params }) }) });
61
+ }
62
+ var Feature = React2.memo(RawFeature);
63
+ Feature.displayName = "Feature";
64
+ registerComponent("Feature", Feature, "view");
65
+
66
+ // src/login/LoginPanel.tsx
67
+ import { useState } from "react";
68
+ import { Button } from "@salt-ds/core";
69
+ import { FormField, Input } from "@heswell/salt-lab";
70
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
71
+ var classBase = "vuuLoginPanel";
72
+ var LoginPanel = ({ onSubmit }) => {
73
+ const [username, setUserName] = useState("");
74
+ const [password, setPassword] = useState("");
75
+ const login = () => {
76
+ onSubmit(username, password);
77
+ };
78
+ const handleUsername = (_event, value) => {
79
+ setUserName(value);
80
+ };
81
+ const handlePassword = (_event, value) => {
82
+ setPassword(value);
83
+ };
84
+ const dataIsValid = username.trim() !== "" && password.trim() !== "";
85
+ return /* @__PURE__ */ jsxs2("div", { className: classBase, children: [
86
+ /* @__PURE__ */ jsx4(FormField, { label: "Username", style: { width: 200 }, children: /* @__PURE__ */ jsx4(Input, { value: username, id: "text-username", onChange: handleUsername }) }),
87
+ /* @__PURE__ */ jsx4(FormField, { label: "Password", style: { width: 200 }, children: /* @__PURE__ */ jsx4(
88
+ Input,
89
+ {
90
+ type: "password",
91
+ value: password,
92
+ id: "text-password",
93
+ onChange: handlePassword
94
+ }
95
+ ) }),
96
+ /* @__PURE__ */ jsx4(
97
+ Button,
98
+ {
99
+ className: `${classBase}-login`,
100
+ disabled: !dataIsValid,
101
+ onClick: login,
102
+ variant: "cta",
103
+ children: "Login"
104
+ }
105
+ )
106
+ ] });
107
+ };
108
+
109
+ // src/login/login-utils.ts
110
+ import { getCookieValue } from "@vuu-ui/vuu-utils";
111
+ var getAuthDetailsFromCookies = () => {
112
+ const username = getCookieValue("vuu-username");
113
+ const token = getCookieValue("vuu-auth-token");
114
+ return [username, token];
115
+ };
116
+ var redirectToLogin = (loginUrl = "/login.html") => {
117
+ window.location.href = loginUrl;
118
+ };
119
+ var logout = (loginUrl) => {
120
+ document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
121
+ document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
122
+ redirectToLogin(loginUrl);
123
+ };
124
+
125
+ // src/shell.tsx
126
+ import { connectToServer } from "@vuu-ui/vuu-data";
127
+ import {
128
+ useCallback as useCallback5,
129
+ useEffect as useEffect3,
130
+ useRef,
131
+ useState as useState4
132
+ } from "react";
133
+
134
+ // src/use-layout-config.js
135
+ import { useCallback, useEffect, useState as useState2 } from "react";
136
+ var useLayoutConfig = (user, defaultLayout) => {
137
+ const [layout, _setLayout] = useState2(defaultLayout);
138
+ const setLayout = (layout2) => {
139
+ _setLayout(layout2);
140
+ };
141
+ const load = useCallback(
142
+ async (id = "latest") => {
143
+ fetch(`api/vui/${user.username}/${id}`, {}).then((response) => {
144
+ return response.ok ? response.json() : defaultLayout;
145
+ }).then(setLayout).catch(() => {
146
+ setLayout(defaultLayout);
147
+ });
148
+ },
149
+ [defaultLayout, user.username]
150
+ );
151
+ useEffect(() => {
152
+ load();
153
+ }, [load]);
154
+ const saveData = useCallback(
155
+ (data) => {
156
+ fetch(`api/vui/${user.username}`, {
157
+ method: "POST",
158
+ headers: {
159
+ "Content-Type": "application/json"
160
+ },
161
+ body: JSON.stringify(data)
162
+ }).then((response) => {
163
+ return response.ok ? response.json() : defaultLayout;
164
+ });
165
+ },
166
+ [defaultLayout, user]
167
+ );
168
+ const loadLayoutById = useCallback(
169
+ (id) => {
170
+ load(id);
171
+ },
172
+ [load]
173
+ );
174
+ return [layout, saveData, loadLayoutById];
175
+ };
176
+ var use_layout_config_default = useLayoutConfig;
177
+
178
+ // src/ShellContextProvider.tsx
179
+ import { createContext, useContext } from "react";
180
+ import { jsx as jsx5 } from "react/jsx-runtime";
181
+ var defaultConfig = {};
182
+ var ShellContext = createContext(defaultConfig);
183
+ var Provider = ({
184
+ children,
185
+ context,
186
+ inheritedContext
187
+ }) => {
188
+ const mergedContext = {
189
+ ...inheritedContext,
190
+ ...context
191
+ };
192
+ return /* @__PURE__ */ jsx5(ShellContext.Provider, { value: mergedContext, children });
193
+ };
194
+ var ShellContextProvider = ({
195
+ children,
196
+ value
197
+ }) => {
198
+ return /* @__PURE__ */ jsx5(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx5(Provider, { context: value, inheritedContext: context, children }) });
199
+ };
200
+ var useShellContext = () => {
201
+ return useContext(ShellContext);
202
+ };
203
+
204
+ // src/shell.tsx
205
+ import cx3 from "classnames";
206
+ import {
207
+ Chest,
208
+ DraggableLayout,
209
+ Drawer,
210
+ Flexbox,
211
+ LayoutProvider,
212
+ View
213
+ } from "@vuu-ui/vuu-layout";
214
+
215
+ // src/app-header/AppHeader.tsx
216
+ import { useCallback as useCallback4 } from "react";
217
+
218
+ // src/user-profile/UserProfile.tsx
219
+ import { Button as Button3 } from "@salt-ds/core";
220
+ import { DropdownBase } from "@heswell/salt-lab";
221
+ import { UserSolidIcon } from "@salt-ds/icons";
222
+
223
+ // src/user-profile/UserPanel.tsx
224
+ import { formatDate } from "@vuu-ui/vuu-utils";
225
+ import { List, ListItem } from "@heswell/salt-lab";
226
+ import { Button as Button2 } from "@salt-ds/core";
227
+ import { ExportIcon } from "@salt-ds/icons";
228
+ import {
229
+ forwardRef,
230
+ useCallback as useCallback2,
231
+ useEffect as useEffect2,
232
+ useState as useState3
233
+ } from "react";
234
+
235
+ // src/get-layout-history.ts
236
+ var getLayoutHistory = async (user) => {
237
+ const history = await fetch(`api/vui/${user.username}`, {}).then((response) => {
238
+ return response.ok ? response.json() : null;
239
+ }).catch(() => {
240
+ console.log("error getting history");
241
+ });
242
+ return history;
243
+ };
244
+
245
+ // src/user-profile/UserPanel.tsx
246
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
247
+ var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
248
+ return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
249
+ };
250
+ var HistoryListItem = (props) => {
251
+ return /* @__PURE__ */ jsx6(ListItem, { ...props });
252
+ };
253
+ var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
254
+ const [history, setHistory] = useState3([]);
255
+ useEffect2(() => {
256
+ async function getHistory() {
257
+ const history2 = await getLayoutHistory(user);
258
+ const sortedHistory = history2.filter((item) => item.id !== "latest").sort(byLastUpdate).map(({ id, lastUpdate }) => ({
259
+ lastUpdate,
260
+ id,
261
+ label: `Saved at ${formatDate(new Date(lastUpdate), "kk:mm:ss")}`
262
+ }));
263
+ console.log({ sortedHistory });
264
+ setHistory(sortedHistory);
265
+ }
266
+ getHistory();
267
+ }, [user]);
268
+ const handleHisorySelected = useCallback2(
269
+ (evt, selected2) => {
270
+ if (selected2) {
271
+ onNavigate(selected2.id);
272
+ }
273
+ },
274
+ [onNavigate]
275
+ );
276
+ const handleLogout = useCallback2(() => {
277
+ logout(loginUrl);
278
+ }, [loginUrl]);
279
+ const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
280
+ return /* @__PURE__ */ jsxs3("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
281
+ /* @__PURE__ */ jsx6(
282
+ List,
283
+ {
284
+ ListItem: HistoryListItem,
285
+ className: "vuuUserPanel-history",
286
+ onSelect: handleHisorySelected,
287
+ selected,
288
+ source: history
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsx6("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ jsxs3(Button2, { "aria-label": "logout", onClick: handleLogout, children: [
292
+ /* @__PURE__ */ jsx6(ExportIcon, {}),
293
+ " Logout"
294
+ ] }) })
295
+ ] });
296
+ });
297
+
298
+ // src/user-profile/UserProfile.tsx
299
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
300
+ var UserProfile = ({
301
+ layoutId,
302
+ loginUrl,
303
+ onNavigate,
304
+ user
305
+ }) => {
306
+ const handleNavigate = (id) => {
307
+ onNavigate(id);
308
+ };
309
+ return /* @__PURE__ */ jsxs4(DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
310
+ /* @__PURE__ */ jsx7(Button3, { variant: "secondary", children: /* @__PURE__ */ jsx7(UserSolidIcon, {}) }),
311
+ /* @__PURE__ */ jsx7(
312
+ UserPanel,
313
+ {
314
+ layoutId,
315
+ loginUrl,
316
+ onNavigate: handleNavigate,
317
+ user
318
+ }
319
+ )
320
+ ] });
321
+ };
322
+
323
+ // src/theme-switch/ThemeSwitch.tsx
324
+ import {
325
+ ToggleButton,
326
+ ToggleButtonGroup
327
+ } from "@heswell/salt-lab";
328
+ import cx from "classnames";
329
+ import { useControlled } from "@salt-ds/core";
330
+ import { useCallback as useCallback3 } from "react";
331
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
332
+ var classBase2 = "vuuThemeSwitch";
333
+ var modes = ["light", "dark"];
334
+ var ThemeSwitch = ({
335
+ className: classNameProp,
336
+ defaultMode: defaultModeProp,
337
+ mode: modeProp,
338
+ onChange,
339
+ ...htmlAttributes
340
+ }) => {
341
+ const [mode, setMode] = useControlled({
342
+ controlled: modeProp,
343
+ default: defaultModeProp != null ? defaultModeProp : "light",
344
+ name: "ThemeSwitch",
345
+ state: "mode"
346
+ });
347
+ const selectedIndex = modes.indexOf(mode);
348
+ const handleChangeSecondary = useCallback3(
349
+ (_evt, index) => {
350
+ const mode2 = modes[index];
351
+ setMode(mode2);
352
+ onChange(mode2);
353
+ },
354
+ [onChange, setMode]
355
+ );
356
+ const className = cx(classBase2, classNameProp);
357
+ return /* @__PURE__ */ jsxs5(
358
+ ToggleButtonGroup,
359
+ {
360
+ className,
361
+ ...htmlAttributes,
362
+ onChange: handleChangeSecondary,
363
+ selectedIndex,
364
+ children: [
365
+ /* @__PURE__ */ jsx8(
366
+ ToggleButton,
367
+ {
368
+ "aria-label": "alert",
369
+ tooltipText: "Light Theme",
370
+ "data-icon": "light"
371
+ }
372
+ ),
373
+ /* @__PURE__ */ jsx8(
374
+ ToggleButton,
375
+ {
376
+ "aria-label": "home",
377
+ tooltipText: "Dark Theme",
378
+ "data-icon": "dark"
379
+ }
380
+ )
381
+ ]
382
+ }
383
+ );
384
+ };
385
+
386
+ // src/app-header/AppHeader.tsx
387
+ import cx2 from "classnames";
388
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
389
+ var classBase3 = "vuuAppHeader";
390
+ var AppHeader = ({
391
+ className: classNameProp,
392
+ layoutId,
393
+ loginUrl,
394
+ onNavigate,
395
+ onSwitchTheme,
396
+ themeMode = "light",
397
+ user,
398
+ ...htmlAttributes
399
+ }) => {
400
+ const className = cx2(classBase3, classNameProp, "salt-density-medium");
401
+ const handleSwitchTheme = useCallback4(
402
+ (mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
403
+ [onSwitchTheme]
404
+ );
405
+ return /* @__PURE__ */ jsxs6("header", { className, ...htmlAttributes, children: [
406
+ /* @__PURE__ */ jsx9(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
407
+ /* @__PURE__ */ jsx9(
408
+ UserProfile,
409
+ {
410
+ layoutId,
411
+ loginUrl,
412
+ onNavigate,
413
+ user
414
+ }
415
+ )
416
+ ] });
417
+ };
418
+
419
+ // src/shell.tsx
420
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
421
+ var warningLayout = {
422
+ type: "View",
423
+ props: {
424
+ style: { height: "calc(100% - 6px)" }
425
+ },
426
+ children: [
427
+ {
428
+ props: {
429
+ className: "vuuShell-warningPlaceholder"
430
+ },
431
+ type: "Placeholder"
432
+ }
433
+ ]
434
+ };
435
+ var Shell = ({
436
+ children,
437
+ className: classNameProp,
438
+ defaultLayout = warningLayout,
439
+ leftSidePanel,
440
+ loginUrl,
441
+ serverUrl,
442
+ user,
443
+ ...htmlAttributes
444
+ }) => {
445
+ const rootRef = useRef(null);
446
+ const [density] = useState4("high");
447
+ const paletteView = useRef(null);
448
+ const [open, setOpen] = useState4(false);
449
+ const layoutId = useRef("latest");
450
+ const [layout, setLayoutConfig, loadLayoutById] = use_layout_config_default(
451
+ user,
452
+ defaultLayout
453
+ );
454
+ const handleLayoutChange = useCallback5(
455
+ (layout2) => {
456
+ setLayoutConfig(layout2);
457
+ },
458
+ [setLayoutConfig]
459
+ );
460
+ const handleSwitchTheme = useCallback5((mode) => {
461
+ if (rootRef.current) {
462
+ rootRef.current.dataset.mode = mode;
463
+ }
464
+ }, []);
465
+ const handleDrawerClick = (e) => {
466
+ var _a;
467
+ const target = e.target;
468
+ if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
469
+ setOpen(!open);
470
+ }
471
+ };
472
+ const handleNavigate = useCallback5(
473
+ (id) => {
474
+ layoutId.current = id;
475
+ loadLayoutById(id);
476
+ },
477
+ [loadLayoutById]
478
+ );
479
+ useEffect3(() => {
480
+ if (serverUrl && user.token) {
481
+ connectToServer(serverUrl, user.token);
482
+ }
483
+ }, [serverUrl, user.token]);
484
+ const getDrawers = () => {
485
+ const drawers = [];
486
+ if (leftSidePanel) {
487
+ drawers.push(
488
+ /* @__PURE__ */ jsx10(
489
+ Drawer,
490
+ {
491
+ onClick: handleDrawerClick,
492
+ open,
493
+ position: "left",
494
+ inline: true,
495
+ peekaboo: true,
496
+ sizeOpen: 200,
497
+ toggleButton: "end",
498
+ children: /* @__PURE__ */ jsx10(
499
+ View,
500
+ {
501
+ className: "vuuShell-palette",
502
+ id: "vw-app-palette",
503
+ ref: paletteView,
504
+ style: { height: "100%" },
505
+ children: leftSidePanel
506
+ },
507
+ "app-palette"
508
+ )
509
+ },
510
+ "left-panel"
511
+ )
512
+ );
513
+ }
514
+ return drawers;
515
+ };
516
+ const className = cx3(
517
+ "vuuShell",
518
+ classNameProp,
519
+ "salt-theme",
520
+ `salt-density-${density}`
521
+ );
522
+ return (
523
+ // ShellContext TBD
524
+ /* @__PURE__ */ jsxs7(ShellContextProvider, { value: void 0, children: [
525
+ /* @__PURE__ */ jsx10(LayoutProvider, { layout, onLayoutChange: handleLayoutChange, children: /* @__PURE__ */ jsx10(
526
+ DraggableLayout,
527
+ {
528
+ className,
529
+ "data-mode": "light",
530
+ ref: rootRef,
531
+ ...htmlAttributes,
532
+ children: /* @__PURE__ */ jsxs7(
533
+ Flexbox,
534
+ {
535
+ className: "App",
536
+ style: { flexDirection: "column", height: "100%", width: "100%" },
537
+ children: [
538
+ /* @__PURE__ */ jsx10(
539
+ AppHeader,
540
+ {
541
+ layoutId: layoutId.current,
542
+ loginUrl,
543
+ user,
544
+ onNavigate: handleNavigate,
545
+ onSwitchTheme: handleSwitchTheme
546
+ }
547
+ ),
548
+ /* @__PURE__ */ jsx10(Chest, { style: { flex: 1 }, children: getDrawers().concat(
549
+ /* @__PURE__ */ jsx10(
550
+ DraggableLayout,
551
+ {
552
+ dropTarget: true,
553
+ style: { width: "100%", height: "100%" }
554
+ },
555
+ "main-content"
556
+ )
557
+ ) })
558
+ ]
559
+ }
560
+ )
561
+ }
562
+ ) }),
563
+ children
564
+ ] })
565
+ );
566
+ };
567
+ export {
568
+ Feature,
569
+ LoginPanel,
570
+ Shell,
571
+ ShellContextProvider,
572
+ ThemeSwitch,
573
+ getAuthDetailsFromCookies,
574
+ logout,
575
+ redirectToLogin,
576
+ useShellContext
577
+ };
2
578
  //# sourceMappingURL=index.js.map