@vuu-ui/vuu-shell 0.6.8 → 0.6.9-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +593 -1
- package/cjs/index.js.map +2 -2
- package/esm/index.js +580 -1
- package/esm/index.js.map +2 -2
- package/index.css +101 -1
- package/index.css.map +1 -1
- package/package.json +4 -5
package/esm/index.js
CHANGED
|
@@ -1,2 +1,581 @@
|
|
|
1
|
-
|
|
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
|
+
var getCookieValue = (name) => {
|
|
111
|
+
var _a;
|
|
112
|
+
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
113
|
+
};
|
|
114
|
+
var getAuthDetailsFromCookies = () => {
|
|
115
|
+
const username = getCookieValue("vuu-username");
|
|
116
|
+
const token = getCookieValue("vuu-auth-token");
|
|
117
|
+
return [username, token];
|
|
118
|
+
};
|
|
119
|
+
var redirectToLogin = (loginUrl = "/login.html") => {
|
|
120
|
+
window.location.href = loginUrl;
|
|
121
|
+
};
|
|
122
|
+
var logout = (loginUrl) => {
|
|
123
|
+
document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
124
|
+
document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
125
|
+
redirectToLogin(loginUrl);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/shell.tsx
|
|
129
|
+
import { connectToServer } from "@vuu-ui/vuu-data";
|
|
130
|
+
import {
|
|
131
|
+
useCallback as useCallback5,
|
|
132
|
+
useEffect as useEffect3,
|
|
133
|
+
useRef,
|
|
134
|
+
useState as useState4
|
|
135
|
+
} from "react";
|
|
136
|
+
|
|
137
|
+
// src/use-layout-config.js
|
|
138
|
+
import { useCallback, useEffect, useState as useState2 } from "react";
|
|
139
|
+
var useLayoutConfig = (user, defaultLayout) => {
|
|
140
|
+
const [layout, _setLayout] = useState2(defaultLayout);
|
|
141
|
+
const setLayout = (layout2) => {
|
|
142
|
+
_setLayout(layout2);
|
|
143
|
+
};
|
|
144
|
+
const load = useCallback(
|
|
145
|
+
async (id = "latest") => {
|
|
146
|
+
fetch(`api/vui/${user.username}/${id}`, {}).then((response) => {
|
|
147
|
+
return response.ok ? response.json() : defaultLayout;
|
|
148
|
+
}).then(setLayout).catch(() => {
|
|
149
|
+
setLayout(defaultLayout);
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
[defaultLayout, user.username]
|
|
153
|
+
);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
load();
|
|
156
|
+
}, [load]);
|
|
157
|
+
const saveData = useCallback(
|
|
158
|
+
(data) => {
|
|
159
|
+
fetch(`api/vui/${user.username}`, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
headers: {
|
|
162
|
+
"Content-Type": "application/json"
|
|
163
|
+
},
|
|
164
|
+
body: JSON.stringify(data)
|
|
165
|
+
}).then((response) => {
|
|
166
|
+
return response.ok ? response.json() : defaultLayout;
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
[defaultLayout, user]
|
|
170
|
+
);
|
|
171
|
+
const loadLayoutById = useCallback(
|
|
172
|
+
(id) => {
|
|
173
|
+
load(id);
|
|
174
|
+
},
|
|
175
|
+
[load]
|
|
176
|
+
);
|
|
177
|
+
return [layout, saveData, loadLayoutById];
|
|
178
|
+
};
|
|
179
|
+
var use_layout_config_default = useLayoutConfig;
|
|
180
|
+
|
|
181
|
+
// src/ShellContextProvider.tsx
|
|
182
|
+
import { createContext, useContext } from "react";
|
|
183
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
184
|
+
var defaultConfig = {};
|
|
185
|
+
var ShellContext = createContext(defaultConfig);
|
|
186
|
+
var Provider = ({
|
|
187
|
+
children,
|
|
188
|
+
context,
|
|
189
|
+
inheritedContext
|
|
190
|
+
}) => {
|
|
191
|
+
const mergedContext = {
|
|
192
|
+
...inheritedContext,
|
|
193
|
+
...context
|
|
194
|
+
};
|
|
195
|
+
return /* @__PURE__ */ jsx5(ShellContext.Provider, { value: mergedContext, children });
|
|
196
|
+
};
|
|
197
|
+
var ShellContextProvider = ({
|
|
198
|
+
children,
|
|
199
|
+
value
|
|
200
|
+
}) => {
|
|
201
|
+
return /* @__PURE__ */ jsx5(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx5(Provider, { context: value, inheritedContext: context, children }) });
|
|
202
|
+
};
|
|
203
|
+
var useShellContext = () => {
|
|
204
|
+
return useContext(ShellContext);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/shell.tsx
|
|
208
|
+
import cx3 from "classnames";
|
|
209
|
+
import {
|
|
210
|
+
Chest,
|
|
211
|
+
DraggableLayout,
|
|
212
|
+
Drawer,
|
|
213
|
+
Flexbox,
|
|
214
|
+
LayoutProvider,
|
|
215
|
+
View
|
|
216
|
+
} from "@vuu-ui/vuu-layout";
|
|
217
|
+
|
|
218
|
+
// src/app-header/AppHeader.tsx
|
|
219
|
+
import { useCallback as useCallback4 } from "react";
|
|
220
|
+
|
|
221
|
+
// src/user-profile/UserProfile.tsx
|
|
222
|
+
import { Button as Button3 } from "@salt-ds/core";
|
|
223
|
+
import { DropdownBase } from "@heswell/salt-lab";
|
|
224
|
+
import { UserSolidIcon } from "@salt-ds/icons";
|
|
225
|
+
|
|
226
|
+
// src/user-profile/UserPanel.tsx
|
|
227
|
+
import { formatDate } from "@vuu-ui/vuu-utils";
|
|
228
|
+
import { List, ListItem } from "@heswell/salt-lab";
|
|
229
|
+
import { Button as Button2 } from "@salt-ds/core";
|
|
230
|
+
import { ExportIcon } from "@salt-ds/icons";
|
|
231
|
+
import {
|
|
232
|
+
forwardRef,
|
|
233
|
+
useCallback as useCallback2,
|
|
234
|
+
useEffect as useEffect2,
|
|
235
|
+
useState as useState3
|
|
236
|
+
} from "react";
|
|
237
|
+
|
|
238
|
+
// src/get-layout-history.ts
|
|
239
|
+
var getLayoutHistory = async (user) => {
|
|
240
|
+
const history = await fetch(`api/vui/${user.username}`, {}).then((response) => {
|
|
241
|
+
return response.ok ? response.json() : null;
|
|
242
|
+
}).catch(() => {
|
|
243
|
+
console.log(`error getting history`);
|
|
244
|
+
});
|
|
245
|
+
return history;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// src/user-profile/UserPanel.tsx
|
|
249
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
250
|
+
var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
|
|
251
|
+
return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
|
|
252
|
+
};
|
|
253
|
+
var HistoryListItem = (props) => {
|
|
254
|
+
return /* @__PURE__ */ jsx6(ListItem, { ...props });
|
|
255
|
+
};
|
|
256
|
+
var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
|
|
257
|
+
const [history, setHistory] = useState3([]);
|
|
258
|
+
useEffect2(() => {
|
|
259
|
+
async function getHistory() {
|
|
260
|
+
const history2 = await getLayoutHistory(user);
|
|
261
|
+
const sortedHistory = history2.filter((item) => item.id !== "latest").sort(byLastUpdate).map(({ id, lastUpdate }) => ({
|
|
262
|
+
lastUpdate,
|
|
263
|
+
id,
|
|
264
|
+
label: `Saved at ${formatDate(new Date(lastUpdate), "kk:mm:ss")}`
|
|
265
|
+
}));
|
|
266
|
+
console.log({ sortedHistory });
|
|
267
|
+
setHistory(sortedHistory);
|
|
268
|
+
}
|
|
269
|
+
getHistory();
|
|
270
|
+
}, [user]);
|
|
271
|
+
const handleHisorySelected = useCallback2(
|
|
272
|
+
(evt, selected2) => {
|
|
273
|
+
if (selected2) {
|
|
274
|
+
onNavigate(selected2.id);
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
[onNavigate]
|
|
278
|
+
);
|
|
279
|
+
const handleLogout = useCallback2(() => {
|
|
280
|
+
logout(loginUrl);
|
|
281
|
+
}, [loginUrl]);
|
|
282
|
+
const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
|
|
283
|
+
return /* @__PURE__ */ jsxs3("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
|
|
284
|
+
/* @__PURE__ */ jsx6(
|
|
285
|
+
List,
|
|
286
|
+
{
|
|
287
|
+
ListItem: HistoryListItem,
|
|
288
|
+
className: "vuuUserPanel-history",
|
|
289
|
+
onSelect: handleHisorySelected,
|
|
290
|
+
selected,
|
|
291
|
+
source: history
|
|
292
|
+
}
|
|
293
|
+
),
|
|
294
|
+
/* @__PURE__ */ jsx6("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ jsxs3(Button2, { "aria-label": "logout", onClick: handleLogout, children: [
|
|
295
|
+
/* @__PURE__ */ jsx6(ExportIcon, {}),
|
|
296
|
+
" Logout"
|
|
297
|
+
] }) })
|
|
298
|
+
] });
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// src/user-profile/UserProfile.tsx
|
|
302
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
303
|
+
var UserProfile = ({
|
|
304
|
+
layoutId,
|
|
305
|
+
loginUrl,
|
|
306
|
+
onNavigate,
|
|
307
|
+
user
|
|
308
|
+
}) => {
|
|
309
|
+
const handleNavigate = (id) => {
|
|
310
|
+
onNavigate(id);
|
|
311
|
+
};
|
|
312
|
+
return /* @__PURE__ */ jsxs4(DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
|
|
313
|
+
/* @__PURE__ */ jsx7(Button3, { variant: "secondary", children: /* @__PURE__ */ jsx7(UserSolidIcon, {}) }),
|
|
314
|
+
/* @__PURE__ */ jsx7(
|
|
315
|
+
UserPanel,
|
|
316
|
+
{
|
|
317
|
+
layoutId,
|
|
318
|
+
loginUrl,
|
|
319
|
+
onNavigate: handleNavigate,
|
|
320
|
+
user
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
] });
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// src/theme-switch/ThemeSwitch.tsx
|
|
327
|
+
import {
|
|
328
|
+
ToggleButton,
|
|
329
|
+
ToggleButtonGroup
|
|
330
|
+
} from "@heswell/salt-lab";
|
|
331
|
+
import cx from "classnames";
|
|
332
|
+
import { useControlled } from "@salt-ds/core";
|
|
333
|
+
import { useCallback as useCallback3 } from "react";
|
|
334
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
335
|
+
var classBase2 = "vuuThemeSwitch";
|
|
336
|
+
var modes = ["light", "dark"];
|
|
337
|
+
var ThemeSwitch = ({
|
|
338
|
+
className: classNameProp,
|
|
339
|
+
defaultMode: defaultModeProp,
|
|
340
|
+
mode: modeProp,
|
|
341
|
+
onChange,
|
|
342
|
+
...htmlAttributes
|
|
343
|
+
}) => {
|
|
344
|
+
const [mode, setMode] = useControlled({
|
|
345
|
+
controlled: modeProp,
|
|
346
|
+
default: defaultModeProp != null ? defaultModeProp : "light",
|
|
347
|
+
name: "ThemeSwitch",
|
|
348
|
+
state: "mode"
|
|
349
|
+
});
|
|
350
|
+
const selectedIndex = modes.indexOf(mode);
|
|
351
|
+
const handleChangeSecondary = useCallback3(
|
|
352
|
+
(_evt, index) => {
|
|
353
|
+
const mode2 = modes[index];
|
|
354
|
+
setMode(mode2);
|
|
355
|
+
onChange(mode2);
|
|
356
|
+
},
|
|
357
|
+
[onChange, setMode]
|
|
358
|
+
);
|
|
359
|
+
const className = cx(classBase2, classNameProp);
|
|
360
|
+
return /* @__PURE__ */ jsxs5(
|
|
361
|
+
ToggleButtonGroup,
|
|
362
|
+
{
|
|
363
|
+
className,
|
|
364
|
+
...htmlAttributes,
|
|
365
|
+
onChange: handleChangeSecondary,
|
|
366
|
+
selectedIndex,
|
|
367
|
+
children: [
|
|
368
|
+
/* @__PURE__ */ jsx8(
|
|
369
|
+
ToggleButton,
|
|
370
|
+
{
|
|
371
|
+
"aria-label": "alert",
|
|
372
|
+
tooltipText: "Light Theme",
|
|
373
|
+
"data-icon": "light"
|
|
374
|
+
}
|
|
375
|
+
),
|
|
376
|
+
/* @__PURE__ */ jsx8(
|
|
377
|
+
ToggleButton,
|
|
378
|
+
{
|
|
379
|
+
"aria-label": "home",
|
|
380
|
+
tooltipText: "Dark Theme",
|
|
381
|
+
"data-icon": "dark"
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
]
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// src/app-header/AppHeader.tsx
|
|
390
|
+
import cx2 from "classnames";
|
|
391
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
392
|
+
var classBase3 = "vuuAppHeader";
|
|
393
|
+
var AppHeader = ({
|
|
394
|
+
className: classNameProp,
|
|
395
|
+
layoutId,
|
|
396
|
+
loginUrl,
|
|
397
|
+
onNavigate,
|
|
398
|
+
onSwitchTheme,
|
|
399
|
+
themeMode = "light",
|
|
400
|
+
user,
|
|
401
|
+
...htmlAttributes
|
|
402
|
+
}) => {
|
|
403
|
+
const className = cx2(classBase3, classNameProp, "salt-density-medium");
|
|
404
|
+
const handleSwitchTheme = useCallback4(
|
|
405
|
+
(mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
|
|
406
|
+
[onSwitchTheme]
|
|
407
|
+
);
|
|
408
|
+
return /* @__PURE__ */ jsxs6("header", { className, ...htmlAttributes, children: [
|
|
409
|
+
/* @__PURE__ */ jsx9(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
|
|
410
|
+
/* @__PURE__ */ jsx9(
|
|
411
|
+
UserProfile,
|
|
412
|
+
{
|
|
413
|
+
layoutId,
|
|
414
|
+
loginUrl,
|
|
415
|
+
onNavigate,
|
|
416
|
+
user
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] });
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// src/shell.tsx
|
|
423
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
424
|
+
var warningLayout = {
|
|
425
|
+
type: "View",
|
|
426
|
+
props: {
|
|
427
|
+
style: { height: "calc(100% - 6px)" }
|
|
428
|
+
},
|
|
429
|
+
children: [
|
|
430
|
+
{
|
|
431
|
+
props: {
|
|
432
|
+
className: "vuuShell-warningPlaceholder"
|
|
433
|
+
},
|
|
434
|
+
type: "Placeholder"
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
};
|
|
438
|
+
var Shell = ({
|
|
439
|
+
children,
|
|
440
|
+
className: classNameProp,
|
|
441
|
+
defaultLayout = warningLayout,
|
|
442
|
+
leftSidePanel,
|
|
443
|
+
loginUrl,
|
|
444
|
+
serverUrl,
|
|
445
|
+
user,
|
|
446
|
+
...htmlAttributes
|
|
447
|
+
}) => {
|
|
448
|
+
const rootRef = useRef(null);
|
|
449
|
+
const [density] = useState4("high");
|
|
450
|
+
const paletteView = useRef(null);
|
|
451
|
+
const [open, setOpen] = useState4(false);
|
|
452
|
+
const layoutId = useRef("latest");
|
|
453
|
+
const [layout, setLayoutConfig, loadLayoutById] = use_layout_config_default(
|
|
454
|
+
user,
|
|
455
|
+
defaultLayout
|
|
456
|
+
);
|
|
457
|
+
const handleLayoutChange = useCallback5(
|
|
458
|
+
(layout2) => {
|
|
459
|
+
setLayoutConfig(layout2);
|
|
460
|
+
},
|
|
461
|
+
[setLayoutConfig]
|
|
462
|
+
);
|
|
463
|
+
const handleSwitchTheme = useCallback5((mode) => {
|
|
464
|
+
if (rootRef.current) {
|
|
465
|
+
rootRef.current.dataset.mode = mode;
|
|
466
|
+
}
|
|
467
|
+
}, []);
|
|
468
|
+
const handleDrawerClick = (e) => {
|
|
469
|
+
var _a;
|
|
470
|
+
const target = e.target;
|
|
471
|
+
if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
|
|
472
|
+
setOpen(!open);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
const handleNavigate = useCallback5(
|
|
476
|
+
(id) => {
|
|
477
|
+
layoutId.current = id;
|
|
478
|
+
loadLayoutById(id);
|
|
479
|
+
},
|
|
480
|
+
[loadLayoutById]
|
|
481
|
+
);
|
|
482
|
+
useEffect3(() => {
|
|
483
|
+
if (serverUrl && user.token) {
|
|
484
|
+
connectToServer(serverUrl, user.token);
|
|
485
|
+
}
|
|
486
|
+
}, [serverUrl, user.token]);
|
|
487
|
+
const getDrawers = () => {
|
|
488
|
+
const drawers = [];
|
|
489
|
+
if (leftSidePanel) {
|
|
490
|
+
drawers.push(
|
|
491
|
+
/* @__PURE__ */ jsx10(
|
|
492
|
+
Drawer,
|
|
493
|
+
{
|
|
494
|
+
onClick: handleDrawerClick,
|
|
495
|
+
open,
|
|
496
|
+
position: "left",
|
|
497
|
+
inline: true,
|
|
498
|
+
peekaboo: true,
|
|
499
|
+
sizeOpen: 200,
|
|
500
|
+
toggleButton: "end",
|
|
501
|
+
children: /* @__PURE__ */ jsx10(
|
|
502
|
+
View,
|
|
503
|
+
{
|
|
504
|
+
className: "vuuShell-palette",
|
|
505
|
+
id: "vw-app-palette",
|
|
506
|
+
ref: paletteView,
|
|
507
|
+
style: { height: "100%" },
|
|
508
|
+
children: leftSidePanel
|
|
509
|
+
},
|
|
510
|
+
"app-palette"
|
|
511
|
+
)
|
|
512
|
+
},
|
|
513
|
+
"left-panel"
|
|
514
|
+
)
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
return drawers;
|
|
518
|
+
};
|
|
519
|
+
const className = cx3(
|
|
520
|
+
"vuuShell",
|
|
521
|
+
classNameProp,
|
|
522
|
+
"salt-theme",
|
|
523
|
+
`salt-density-${density}`
|
|
524
|
+
);
|
|
525
|
+
return (
|
|
526
|
+
// ShellContext TBD
|
|
527
|
+
/* @__PURE__ */ jsxs7(ShellContextProvider, { value: void 0, children: [
|
|
528
|
+
/* @__PURE__ */ jsx10(LayoutProvider, { layout, onLayoutChange: handleLayoutChange, children: /* @__PURE__ */ jsx10(
|
|
529
|
+
DraggableLayout,
|
|
530
|
+
{
|
|
531
|
+
className,
|
|
532
|
+
"data-mode": "light",
|
|
533
|
+
ref: rootRef,
|
|
534
|
+
...htmlAttributes,
|
|
535
|
+
children: /* @__PURE__ */ jsxs7(
|
|
536
|
+
Flexbox,
|
|
537
|
+
{
|
|
538
|
+
className: "App",
|
|
539
|
+
style: { flexDirection: "column", height: "100%", width: "100%" },
|
|
540
|
+
children: [
|
|
541
|
+
/* @__PURE__ */ jsx10(
|
|
542
|
+
AppHeader,
|
|
543
|
+
{
|
|
544
|
+
layoutId: layoutId.current,
|
|
545
|
+
loginUrl,
|
|
546
|
+
user,
|
|
547
|
+
onNavigate: handleNavigate,
|
|
548
|
+
onSwitchTheme: handleSwitchTheme
|
|
549
|
+
}
|
|
550
|
+
),
|
|
551
|
+
/* @__PURE__ */ jsx10(Chest, { style: { flex: 1 }, children: getDrawers().concat(
|
|
552
|
+
/* @__PURE__ */ jsx10(
|
|
553
|
+
DraggableLayout,
|
|
554
|
+
{
|
|
555
|
+
dropTarget: true,
|
|
556
|
+
style: { width: "100%", height: "100%" }
|
|
557
|
+
},
|
|
558
|
+
"main-content"
|
|
559
|
+
)
|
|
560
|
+
) })
|
|
561
|
+
]
|
|
562
|
+
}
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
) }),
|
|
566
|
+
children
|
|
567
|
+
] })
|
|
568
|
+
);
|
|
569
|
+
};
|
|
570
|
+
export {
|
|
571
|
+
Feature,
|
|
572
|
+
LoginPanel,
|
|
573
|
+
Shell,
|
|
574
|
+
ShellContextProvider,
|
|
575
|
+
ThemeSwitch,
|
|
576
|
+
getAuthDetailsFromCookies,
|
|
577
|
+
logout,
|
|
578
|
+
redirectToLogin,
|
|
579
|
+
useShellContext
|
|
580
|
+
};
|
|
2
581
|
//# sourceMappingURL=index.js.map
|