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