@vuu-ui/vuu-shell 0.7.0-debug → 0.7.0
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 +2 -724
- package/cjs/index.js.map +2 -2
- package/esm/index.js +2 -716
- package/esm/index.js.map +2 -2
- package/index.css +1 -161
- package/index.css.map +1 -1
- package/package.json +4 -4
package/cjs/index.js
CHANGED
|
@@ -1,726 +1,4 @@
|
|
|
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
|
-
ConnectionStatusIcon: () => ConnectionStatusIcon,
|
|
34
|
-
DEFAULT_DENSITY: () => DEFAULT_DENSITY2,
|
|
35
|
-
DEFAULT_THEME: () => DEFAULT_THEME,
|
|
36
|
-
DEFAULT_THEME_MODE: () => DEFAULT_THEME_MODE,
|
|
37
|
-
DensitySwitch: () => DensitySwitch,
|
|
38
|
-
Feature: () => Feature,
|
|
39
|
-
LoginPanel: () => LoginPanel,
|
|
40
|
-
Shell: () => Shell,
|
|
41
|
-
ShellContextProvider: () => ShellContextProvider,
|
|
42
|
-
ThemeContext: () => ThemeContext,
|
|
43
|
-
ThemeProvider: () => ThemeProvider,
|
|
44
|
-
ThemeSwitch: () => ThemeSwitch,
|
|
45
|
-
getAuthDetailsFromCookies: () => getAuthDetailsFromCookies,
|
|
46
|
-
logout: () => logout,
|
|
47
|
-
redirectToLogin: () => redirectToLogin,
|
|
48
|
-
useShellContext: () => useShellContext
|
|
49
|
-
});
|
|
50
|
-
module.exports = __toCommonJS(src_exports);
|
|
51
|
-
|
|
52
|
-
// src/connection-status/ConnectionStatusIcon.tsx
|
|
53
|
-
var import_react = __toESM(require("react"));
|
|
54
|
-
var import_classnames = __toESM(require("classnames"));
|
|
55
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
56
|
-
var ConnectionStatusIcon = ({ connectionStatus, className, element = "span", ...props }) => {
|
|
57
|
-
const [classBase5, setClassBase] = (0, import_react.useState)("vuuConnectingStatus");
|
|
58
|
-
(0, import_react.useEffect)(() => {
|
|
59
|
-
switch (connectionStatus) {
|
|
60
|
-
case "connected":
|
|
61
|
-
case "reconnected":
|
|
62
|
-
setClassBase("vuuActiveStatus");
|
|
63
|
-
break;
|
|
64
|
-
case "connecting":
|
|
65
|
-
setClassBase("vuuConnectingStatus");
|
|
66
|
-
break;
|
|
67
|
-
case "disconnected":
|
|
68
|
-
setClassBase("vuuDisconnectedStatus");
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}, [connectionStatus]);
|
|
74
|
-
const statusIcon = import_react.default.createElement(
|
|
75
|
-
element,
|
|
76
|
-
{
|
|
77
|
-
...props,
|
|
78
|
-
className: (0, import_classnames.default)("vuuStatus vuuIcon", classBase5, className)
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "vuuStatus-container salt-theme", children: [
|
|
82
|
-
statusIcon,
|
|
83
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "vuuStatus-text", children: [
|
|
84
|
-
"Status: ",
|
|
85
|
-
connectionStatus.toUpperCase()
|
|
86
|
-
] })
|
|
87
|
-
] }) });
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// src/density-switch/DensitySwitch.tsx
|
|
91
|
-
var import_salt_lab = require("@heswell/salt-lab");
|
|
92
|
-
var import_react2 = require("react");
|
|
93
|
-
var import_classnames2 = __toESM(require("classnames"));
|
|
94
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
95
|
-
var classBase = "vuuDensitySwitch";
|
|
96
|
-
var densities = ["high", "medium", "low", "touch"];
|
|
97
|
-
var DEFAULT_DENSITY = "high";
|
|
98
|
-
var DensitySwitch = ({
|
|
99
|
-
className: classNameProp,
|
|
100
|
-
defaultDensity = DEFAULT_DENSITY,
|
|
101
|
-
onDensityChange
|
|
102
|
-
}) => {
|
|
103
|
-
const handleSelectionChange = (0, import_react2.useCallback)((_event, selectedItem) => {
|
|
104
|
-
onDensityChange(selectedItem);
|
|
105
|
-
}, [onDensityChange]);
|
|
106
|
-
const className = (0, import_classnames2.default)(classBase, classNameProp);
|
|
107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
108
|
-
import_salt_lab.Dropdown,
|
|
109
|
-
{
|
|
110
|
-
className,
|
|
111
|
-
source: densities,
|
|
112
|
-
defaultSelected: defaultDensity,
|
|
113
|
-
onSelectionChange: handleSelectionChange
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// src/feature/Feature.tsx
|
|
119
|
-
var import_react4 = __toESM(require("react"));
|
|
120
|
-
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
121
|
-
|
|
122
|
-
// src/feature/ErrorBoundary.jsx
|
|
123
|
-
var import_react3 = __toESM(require("react"));
|
|
124
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
125
|
-
var ErrorBoundary = class extends import_react3.default.Component {
|
|
126
|
-
constructor(props) {
|
|
127
|
-
super(props);
|
|
128
|
-
this.state = { errorMessage: null };
|
|
129
|
-
}
|
|
130
|
-
static getDerivedStateFromError(error) {
|
|
131
|
-
return { errorMessage: error.message };
|
|
132
|
-
}
|
|
133
|
-
componentDidCatch(error, errorInfo) {
|
|
134
|
-
console.log(error, errorInfo);
|
|
135
|
-
}
|
|
136
|
-
render() {
|
|
137
|
-
if (this.state.errorMessage) {
|
|
138
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
139
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: "Something went wrong." }),
|
|
140
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: this.state.errorMessage })
|
|
141
|
-
] });
|
|
142
|
-
}
|
|
143
|
-
return this.props.children;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// src/feature/Loader.tsx
|
|
148
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
149
|
-
var Loader = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "hwLoader", children: "loading" });
|
|
150
|
-
|
|
151
|
-
// src/feature/Feature.tsx
|
|
152
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
153
|
-
function RawFeature({
|
|
154
|
-
url,
|
|
155
|
-
css,
|
|
156
|
-
params,
|
|
157
|
-
...props
|
|
158
|
-
}) {
|
|
159
|
-
if (css) {
|
|
160
|
-
import(
|
|
161
|
-
/* @vite-ignore */
|
|
162
|
-
css
|
|
163
|
-
).then(
|
|
164
|
-
(cssModule) => {
|
|
165
|
-
document.adoptedStyleSheets = [
|
|
166
|
-
...document.adoptedStyleSheets,
|
|
167
|
-
cssModule.default
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
const LazyFeature = import_react4.default.lazy(() => import(
|
|
173
|
-
/* @vite-ignore */
|
|
174
|
-
url
|
|
175
|
-
));
|
|
176
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Loader, {}), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LazyFeature, { ...props, ...params }) }) });
|
|
177
|
-
}
|
|
178
|
-
var Feature = import_react4.default.memo(RawFeature);
|
|
179
|
-
Feature.displayName = "Feature";
|
|
180
|
-
(0, import_vuu_layout.registerComponent)("Feature", Feature, "view");
|
|
181
|
-
|
|
182
|
-
// src/login/LoginPanel.tsx
|
|
183
|
-
var import_react5 = require("react");
|
|
184
|
-
var import_core = require("@salt-ds/core");
|
|
185
|
-
var import_salt_lab2 = require("@heswell/salt-lab");
|
|
186
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
187
|
-
var classBase2 = "vuuLoginPanel";
|
|
188
|
-
var LoginPanel = ({ onSubmit }) => {
|
|
189
|
-
const [username, setUserName] = (0, import_react5.useState)("");
|
|
190
|
-
const [password, setPassword] = (0, import_react5.useState)("");
|
|
191
|
-
const login = () => {
|
|
192
|
-
onSubmit(username, password);
|
|
193
|
-
};
|
|
194
|
-
const handleUsername = (_event, value) => {
|
|
195
|
-
setUserName(value);
|
|
196
|
-
};
|
|
197
|
-
const handlePassword = (_event, value) => {
|
|
198
|
-
setPassword(value);
|
|
199
|
-
};
|
|
200
|
-
const dataIsValid = username.trim() !== "" && password.trim() !== "";
|
|
201
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: classBase2, children: [
|
|
202
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab2.FormField, { label: "Username", style: { width: 200 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab2.Input, { value: username, id: "text-username", onChange: handleUsername }) }),
|
|
203
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_salt_lab2.FormField, { label: "Password", style: { width: 200 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
204
|
-
import_salt_lab2.Input,
|
|
205
|
-
{
|
|
206
|
-
type: "password",
|
|
207
|
-
value: password,
|
|
208
|
-
id: "text-password",
|
|
209
|
-
onChange: handlePassword
|
|
210
|
-
}
|
|
211
|
-
) }),
|
|
212
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
213
|
-
import_core.Button,
|
|
214
|
-
{
|
|
215
|
-
className: `${classBase2}-login`,
|
|
216
|
-
disabled: !dataIsValid,
|
|
217
|
-
onClick: login,
|
|
218
|
-
variant: "cta",
|
|
219
|
-
children: "Login"
|
|
220
|
-
}
|
|
221
|
-
)
|
|
222
|
-
] });
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// src/login/login-utils.ts
|
|
226
|
-
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
227
|
-
var getAuthDetailsFromCookies = () => {
|
|
228
|
-
const username = (0, import_vuu_utils.getCookieValue)("vuu-username");
|
|
229
|
-
const token = (0, import_vuu_utils.getCookieValue)("vuu-auth-token");
|
|
230
|
-
return [username, token];
|
|
231
|
-
};
|
|
232
|
-
var redirectToLogin = (loginUrl = "login.html") => {
|
|
233
|
-
window.location.href = loginUrl;
|
|
234
|
-
};
|
|
235
|
-
var logout = (loginUrl) => {
|
|
236
|
-
document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
237
|
-
document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
238
|
-
redirectToLogin(loginUrl);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
// src/shell.tsx
|
|
242
|
-
var import_vuu_data = require("@vuu-ui/vuu-data");
|
|
243
|
-
var import_classnames5 = __toESM(require("classnames"));
|
|
244
|
-
var import_react11 = require("react");
|
|
245
|
-
|
|
246
|
-
// src/ShellContextProvider.tsx
|
|
247
|
-
var import_react6 = require("react");
|
|
248
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
249
|
-
var defaultConfig = {};
|
|
250
|
-
var ShellContext = (0, import_react6.createContext)(defaultConfig);
|
|
251
|
-
var Provider = ({
|
|
252
|
-
children,
|
|
253
|
-
context,
|
|
254
|
-
inheritedContext
|
|
255
|
-
}) => {
|
|
256
|
-
const mergedContext = {
|
|
257
|
-
...inheritedContext,
|
|
258
|
-
...context
|
|
259
|
-
};
|
|
260
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ShellContext.Provider, { value: mergedContext, children });
|
|
261
|
-
};
|
|
262
|
-
var ShellContextProvider = ({
|
|
263
|
-
children,
|
|
264
|
-
value
|
|
265
|
-
}) => {
|
|
266
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Provider, { context: value, inheritedContext: context, children }) });
|
|
267
|
-
};
|
|
268
|
-
var useShellContext = () => {
|
|
269
|
-
return (0, import_react6.useContext)(ShellContext);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
// src/use-layout-config.js
|
|
273
|
-
var import_react7 = require("react");
|
|
274
|
-
var useLayoutConfig = (user, defaultLayout) => {
|
|
275
|
-
const [layout, _setLayout] = (0, import_react7.useState)(defaultLayout);
|
|
276
|
-
const setLayout = (layout2) => {
|
|
277
|
-
_setLayout(layout2);
|
|
278
|
-
};
|
|
279
|
-
const load = (0, import_react7.useCallback)(
|
|
280
|
-
async (id = "latest") => {
|
|
281
|
-
fetch(`api/vui/${user.username}/${id}`, {}).then((response) => {
|
|
282
|
-
return response.ok ? response.json() : defaultLayout;
|
|
283
|
-
}).then(setLayout).catch(() => {
|
|
284
|
-
setLayout(defaultLayout);
|
|
285
|
-
});
|
|
286
|
-
},
|
|
287
|
-
[defaultLayout, user.username]
|
|
288
|
-
);
|
|
289
|
-
(0, import_react7.useEffect)(() => {
|
|
290
|
-
load();
|
|
291
|
-
}, [load]);
|
|
292
|
-
const saveData = (0, import_react7.useCallback)(
|
|
293
|
-
(data) => {
|
|
294
|
-
fetch(`api/vui/${user.username}`, {
|
|
295
|
-
method: "POST",
|
|
296
|
-
headers: {
|
|
297
|
-
"Content-Type": "application/json"
|
|
298
|
-
},
|
|
299
|
-
body: JSON.stringify(data)
|
|
300
|
-
}).then((response) => {
|
|
301
|
-
return response.ok ? response.json() : defaultLayout;
|
|
302
|
-
});
|
|
303
|
-
},
|
|
304
|
-
[defaultLayout, user]
|
|
305
|
-
);
|
|
306
|
-
const loadLayoutById = (0, import_react7.useCallback)(
|
|
307
|
-
(id) => {
|
|
308
|
-
load(id);
|
|
309
|
-
},
|
|
310
|
-
[load]
|
|
311
|
-
);
|
|
312
|
-
return [layout, saveData, loadLayoutById];
|
|
313
|
-
};
|
|
314
|
-
var use_layout_config_default = useLayoutConfig;
|
|
315
|
-
|
|
316
|
-
// src/shell.tsx
|
|
317
|
-
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
318
|
-
|
|
319
|
-
// src/app-header/AppHeader.tsx
|
|
320
|
-
var import_react10 = require("react");
|
|
321
|
-
|
|
322
|
-
// src/user-profile/UserProfile.tsx
|
|
323
|
-
var import_core3 = require("@salt-ds/core");
|
|
324
|
-
var import_salt_lab4 = require("@heswell/salt-lab");
|
|
325
|
-
var import_icons2 = require("@salt-ds/icons");
|
|
326
|
-
|
|
327
|
-
// src/user-profile/UserPanel.tsx
|
|
328
|
-
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
329
|
-
var import_salt_lab3 = require("@heswell/salt-lab");
|
|
330
|
-
var import_core2 = require("@salt-ds/core");
|
|
331
|
-
var import_icons = require("@salt-ds/icons");
|
|
332
|
-
var import_react8 = require("react");
|
|
333
|
-
|
|
334
|
-
// src/get-layout-history.ts
|
|
335
|
-
var getLayoutHistory = async (user) => {
|
|
336
|
-
const history = await fetch(`api/vui/${user.username}`, {}).then((response) => {
|
|
337
|
-
return response.ok ? response.json() : null;
|
|
338
|
-
}).catch(() => {
|
|
339
|
-
console.log("error getting history");
|
|
340
|
-
});
|
|
341
|
-
return history;
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
// src/user-profile/UserPanel.tsx
|
|
345
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
346
|
-
var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
|
|
347
|
-
return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
|
|
348
|
-
};
|
|
349
|
-
var HistoryListItem = (props) => {
|
|
350
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_salt_lab3.ListItem, { ...props });
|
|
351
|
-
};
|
|
352
|
-
var UserPanel = (0, import_react8.forwardRef)(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
|
|
353
|
-
const [history, setHistory] = (0, import_react8.useState)([]);
|
|
354
|
-
(0, import_react8.useEffect)(() => {
|
|
355
|
-
async function getHistory() {
|
|
356
|
-
const history2 = await getLayoutHistory(user);
|
|
357
|
-
const sortedHistory = history2.filter((item) => item.id !== "latest").sort(byLastUpdate).map(({ id, lastUpdate }) => ({
|
|
358
|
-
lastUpdate,
|
|
359
|
-
id,
|
|
360
|
-
label: `Saved at ${(0, import_vuu_utils2.formatDate)(new Date(lastUpdate), "kk:mm:ss")}`
|
|
361
|
-
}));
|
|
362
|
-
console.log({ sortedHistory });
|
|
363
|
-
setHistory(sortedHistory);
|
|
364
|
-
}
|
|
365
|
-
getHistory();
|
|
366
|
-
}, [user]);
|
|
367
|
-
const handleHisorySelected = (0, import_react8.useCallback)(
|
|
368
|
-
(evt, selected2) => {
|
|
369
|
-
if (selected2) {
|
|
370
|
-
onNavigate(selected2.id);
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
[onNavigate]
|
|
374
|
-
);
|
|
375
|
-
const handleLogout = (0, import_react8.useCallback)(() => {
|
|
376
|
-
logout(loginUrl);
|
|
377
|
-
}, [loginUrl]);
|
|
378
|
-
const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
|
|
379
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
|
|
380
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
381
|
-
import_salt_lab3.List,
|
|
382
|
-
{
|
|
383
|
-
ListItem: HistoryListItem,
|
|
384
|
-
className: "vuuUserPanel-history",
|
|
385
|
-
onSelect: handleHisorySelected,
|
|
386
|
-
selected,
|
|
387
|
-
source: history
|
|
388
|
-
}
|
|
389
|
-
),
|
|
390
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core2.Button, { "aria-label": "logout", onClick: handleLogout, children: [
|
|
391
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons.ExportIcon, {}),
|
|
392
|
-
" Logout"
|
|
393
|
-
] }) })
|
|
394
|
-
] });
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
// src/user-profile/UserProfile.tsx
|
|
398
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
399
|
-
var UserProfile = ({
|
|
400
|
-
layoutId,
|
|
401
|
-
loginUrl,
|
|
402
|
-
onNavigate,
|
|
403
|
-
user
|
|
404
|
-
}) => {
|
|
405
|
-
const handleNavigate = (id) => {
|
|
406
|
-
onNavigate(id);
|
|
407
|
-
};
|
|
408
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_salt_lab4.DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
|
|
409
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core3.Button, { variant: "secondary", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons2.UserSolidIcon, {}) }),
|
|
410
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
411
|
-
UserPanel,
|
|
412
|
-
{
|
|
413
|
-
layoutId,
|
|
414
|
-
loginUrl,
|
|
415
|
-
onNavigate: handleNavigate,
|
|
416
|
-
user
|
|
417
|
-
}
|
|
418
|
-
)
|
|
419
|
-
] });
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
// src/theme-switch/ThemeSwitch.tsx
|
|
423
|
-
var import_salt_lab5 = require("@heswell/salt-lab");
|
|
424
|
-
var import_classnames3 = __toESM(require("classnames"));
|
|
425
|
-
var import_core4 = require("@salt-ds/core");
|
|
426
|
-
var import_react9 = require("react");
|
|
427
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
428
|
-
var classBase3 = "vuuThemeSwitch";
|
|
429
|
-
var modes = ["light", "dark"];
|
|
430
|
-
var ThemeSwitch = ({
|
|
431
|
-
className: classNameProp,
|
|
432
|
-
defaultMode: defaultModeProp,
|
|
433
|
-
mode: modeProp,
|
|
434
|
-
onChange,
|
|
435
|
-
...htmlAttributes
|
|
436
|
-
}) => {
|
|
437
|
-
const [mode, setMode] = (0, import_core4.useControlled)({
|
|
438
|
-
controlled: modeProp,
|
|
439
|
-
default: defaultModeProp != null ? defaultModeProp : "light",
|
|
440
|
-
name: "ThemeSwitch",
|
|
441
|
-
state: "mode"
|
|
442
|
-
});
|
|
443
|
-
const selectedIndex = modes.indexOf(mode);
|
|
444
|
-
const handleChangeSecondary = (0, import_react9.useCallback)(
|
|
445
|
-
(_evt, index) => {
|
|
446
|
-
const mode2 = modes[index];
|
|
447
|
-
setMode(mode2);
|
|
448
|
-
onChange(mode2);
|
|
449
|
-
},
|
|
450
|
-
[onChange, setMode]
|
|
451
|
-
);
|
|
452
|
-
const className = (0, import_classnames3.default)(classBase3, classNameProp);
|
|
453
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
454
|
-
import_salt_lab5.ToggleButtonGroup,
|
|
455
|
-
{
|
|
456
|
-
className,
|
|
457
|
-
...htmlAttributes,
|
|
458
|
-
onChange: handleChangeSecondary,
|
|
459
|
-
selectedIndex,
|
|
460
|
-
children: [
|
|
461
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
462
|
-
import_salt_lab5.ToggleButton,
|
|
463
|
-
{
|
|
464
|
-
"aria-label": "alert",
|
|
465
|
-
tooltipText: "Light Theme",
|
|
466
|
-
"data-icon": "light"
|
|
467
|
-
}
|
|
468
|
-
),
|
|
469
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
470
|
-
import_salt_lab5.ToggleButton,
|
|
471
|
-
{
|
|
472
|
-
"aria-label": "home",
|
|
473
|
-
tooltipText: "Dark Theme",
|
|
474
|
-
"data-icon": "dark"
|
|
475
|
-
}
|
|
476
|
-
)
|
|
477
|
-
]
|
|
478
|
-
}
|
|
479
|
-
);
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
// src/app-header/AppHeader.tsx
|
|
483
|
-
var import_classnames4 = __toESM(require("classnames"));
|
|
484
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
485
|
-
var classBase4 = "vuuAppHeader";
|
|
486
|
-
var AppHeader = ({
|
|
487
|
-
className: classNameProp,
|
|
488
|
-
layoutId,
|
|
489
|
-
loginUrl,
|
|
490
|
-
onNavigate,
|
|
491
|
-
onSwitchTheme,
|
|
492
|
-
themeMode = "light",
|
|
493
|
-
user,
|
|
494
|
-
...htmlAttributes
|
|
495
|
-
}) => {
|
|
496
|
-
const className = (0, import_classnames4.default)(classBase4, classNameProp);
|
|
497
|
-
const handleSwitchTheme = (0, import_react10.useCallback)(
|
|
498
|
-
(mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
|
|
499
|
-
[onSwitchTheme]
|
|
500
|
-
);
|
|
501
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("header", { className, ...htmlAttributes, children: [
|
|
502
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
|
|
503
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
504
|
-
UserProfile,
|
|
505
|
-
{
|
|
506
|
-
layoutId,
|
|
507
|
-
loginUrl,
|
|
508
|
-
onNavigate,
|
|
509
|
-
user
|
|
510
|
-
}
|
|
511
|
-
)
|
|
512
|
-
] });
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
// src/shell.tsx
|
|
516
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
517
|
-
var warningLayout = {
|
|
518
|
-
type: "View",
|
|
519
|
-
props: {
|
|
520
|
-
style: { height: "calc(100% - 6px)" }
|
|
521
|
-
},
|
|
522
|
-
children: [
|
|
523
|
-
{
|
|
524
|
-
props: {
|
|
525
|
-
className: "vuuShell-warningPlaceholder"
|
|
526
|
-
},
|
|
527
|
-
type: "Placeholder"
|
|
528
|
-
}
|
|
529
|
-
]
|
|
530
|
-
};
|
|
531
|
-
var Shell = ({
|
|
532
|
-
children,
|
|
533
|
-
className: classNameProp,
|
|
534
|
-
defaultLayout = warningLayout,
|
|
535
|
-
leftSidePanel,
|
|
536
|
-
loginUrl,
|
|
537
|
-
serverUrl,
|
|
538
|
-
user,
|
|
539
|
-
...htmlAttributes
|
|
540
|
-
}) => {
|
|
541
|
-
const rootRef = (0, import_react11.useRef)(null);
|
|
542
|
-
const paletteView = (0, import_react11.useRef)(null);
|
|
543
|
-
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
544
|
-
const layoutId = (0, import_react11.useRef)("latest");
|
|
545
|
-
const [layout, setLayoutConfig, loadLayoutById] = use_layout_config_default(
|
|
546
|
-
user,
|
|
547
|
-
defaultLayout
|
|
548
|
-
);
|
|
549
|
-
const handleLayoutChange = (0, import_react11.useCallback)(
|
|
550
|
-
(layout2) => {
|
|
551
|
-
setLayoutConfig(layout2);
|
|
552
|
-
},
|
|
553
|
-
[setLayoutConfig]
|
|
554
|
-
);
|
|
555
|
-
const handleSwitchTheme = (0, import_react11.useCallback)((mode) => {
|
|
556
|
-
if (rootRef.current) {
|
|
557
|
-
rootRef.current.dataset.mode = mode;
|
|
558
|
-
}
|
|
559
|
-
}, []);
|
|
560
|
-
const handleDrawerClick = (e) => {
|
|
561
|
-
var _a;
|
|
562
|
-
const target = e.target;
|
|
563
|
-
if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
|
|
564
|
-
setOpen(!open);
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
const handleNavigate = (0, import_react11.useCallback)(
|
|
568
|
-
(id) => {
|
|
569
|
-
layoutId.current = id;
|
|
570
|
-
loadLayoutById(id);
|
|
571
|
-
},
|
|
572
|
-
[loadLayoutById]
|
|
573
|
-
);
|
|
574
|
-
(0, import_react11.useEffect)(() => {
|
|
575
|
-
if (serverUrl && user.token) {
|
|
576
|
-
(0, import_vuu_data.connectToServer)({
|
|
577
|
-
authToken: user.token,
|
|
578
|
-
url: serverUrl,
|
|
579
|
-
username: user.username
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
}, [serverUrl, user.token, user.username]);
|
|
583
|
-
const getDrawers = () => {
|
|
584
|
-
const drawers = [];
|
|
585
|
-
if (leftSidePanel) {
|
|
586
|
-
drawers.push(
|
|
587
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
588
|
-
import_vuu_layout2.Drawer,
|
|
589
|
-
{
|
|
590
|
-
onClick: handleDrawerClick,
|
|
591
|
-
open,
|
|
592
|
-
position: "left",
|
|
593
|
-
inline: true,
|
|
594
|
-
peekaboo: true,
|
|
595
|
-
sizeOpen: 200,
|
|
596
|
-
toggleButton: "end",
|
|
597
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
598
|
-
import_vuu_layout2.View,
|
|
599
|
-
{
|
|
600
|
-
className: "vuuShell-palette",
|
|
601
|
-
id: "vw-app-palette",
|
|
602
|
-
ref: paletteView,
|
|
603
|
-
style: { height: "100%" },
|
|
604
|
-
children: leftSidePanel
|
|
605
|
-
},
|
|
606
|
-
"app-palette"
|
|
607
|
-
)
|
|
608
|
-
},
|
|
609
|
-
"left-panel"
|
|
610
|
-
)
|
|
611
|
-
);
|
|
612
|
-
}
|
|
613
|
-
return drawers;
|
|
614
|
-
};
|
|
615
|
-
const className = (0, import_classnames5.default)(
|
|
616
|
-
"vuuShell",
|
|
617
|
-
classNameProp,
|
|
618
|
-
"salt-theme",
|
|
619
|
-
"salt-density-high"
|
|
620
|
-
);
|
|
621
|
-
return (
|
|
622
|
-
// ShellContext TBD
|
|
623
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(ShellContextProvider, { value: void 0, children: [
|
|
624
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_vuu_layout2.LayoutProvider, { layout, onLayoutChange: handleLayoutChange, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
625
|
-
import_vuu_layout2.DraggableLayout,
|
|
626
|
-
{
|
|
627
|
-
className,
|
|
628
|
-
"data-mode": "light",
|
|
629
|
-
ref: rootRef,
|
|
630
|
-
...htmlAttributes,
|
|
631
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
632
|
-
import_vuu_layout2.Flexbox,
|
|
633
|
-
{
|
|
634
|
-
className: "App",
|
|
635
|
-
style: { flexDirection: "column", height: "100%", width: "100%" },
|
|
636
|
-
children: [
|
|
637
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
638
|
-
AppHeader,
|
|
639
|
-
{
|
|
640
|
-
layoutId: layoutId.current,
|
|
641
|
-
loginUrl,
|
|
642
|
-
user,
|
|
643
|
-
onNavigate: handleNavigate,
|
|
644
|
-
onSwitchTheme: handleSwitchTheme
|
|
645
|
-
}
|
|
646
|
-
),
|
|
647
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_vuu_layout2.DockLayout, { style: { flex: 1 }, children: getDrawers().concat(
|
|
648
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
649
|
-
import_vuu_layout2.DraggableLayout,
|
|
650
|
-
{
|
|
651
|
-
dropTarget: true,
|
|
652
|
-
style: { width: "100%", height: "100%" }
|
|
653
|
-
},
|
|
654
|
-
"main-content"
|
|
655
|
-
)
|
|
656
|
-
) })
|
|
657
|
-
]
|
|
658
|
-
}
|
|
659
|
-
)
|
|
660
|
-
}
|
|
661
|
-
) }),
|
|
662
|
-
children
|
|
663
|
-
] })
|
|
664
|
-
);
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
// src/theme-provider/ThemeProvider.tsx
|
|
668
|
-
var import_react12 = require("react");
|
|
669
|
-
var import_classnames6 = __toESM(require("classnames"));
|
|
670
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
671
|
-
var DEFAULT_DENSITY2 = "medium";
|
|
672
|
-
var DEFAULT_THEME = "salt-theme";
|
|
673
|
-
var DEFAULT_THEME_MODE = "light";
|
|
674
|
-
var ThemeContext = (0, import_react12.createContext)({
|
|
675
|
-
density: "high",
|
|
676
|
-
theme: "salt-theme",
|
|
677
|
-
themeMode: "light"
|
|
678
|
-
});
|
|
679
|
-
var createThemedChildren = (children, theme, themeMode, density) => {
|
|
680
|
-
var _a;
|
|
681
|
-
if ((0, import_react12.isValidElement)(children)) {
|
|
682
|
-
return (0, import_react12.cloneElement)(children, {
|
|
683
|
-
className: (0, import_classnames6.default)(
|
|
684
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
685
|
-
(_a = children.props) == null ? void 0 : _a.className,
|
|
686
|
-
theme,
|
|
687
|
-
`salt-density-${density}`
|
|
688
|
-
),
|
|
689
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
690
|
-
// @ts-expect-error
|
|
691
|
-
"data-mode": themeMode
|
|
692
|
-
});
|
|
693
|
-
} else {
|
|
694
|
-
console.warn(
|
|
695
|
-
`
|
|
1
|
+
"use strict";var _e=Object.create;var A=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Ye=(t,e)=>{for(var o in e)A(t,o,{get:e[o],enumerable:!0})},Q=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ge(e))!ze.call(t,n)&&n!==o&&A(t,n,{get:()=>e[n],enumerable:!(r=$e(e,n))||r.enumerable});return t};var y=(t,e,o)=>(o=t!=null?_e(Je(t)):{},Q(e||!t||!t.__esModule?A(o,"default",{value:t,enumerable:!0}):o,t)),qe=t=>Q(A({},"__esModule",{value:!0}),t);var pt={};Ye(pt,{ConnectionStatusIcon:()=>We,DEFAULT_DENSITY:()=>He,DEFAULT_THEME:()=>Ne,DEFAULT_THEME_MODE:()=>be,DensitySwitch:()=>Ze,Feature:()=>_,LoginPanel:()=>et,Shell:()=>ut,ShellContextProvider:()=>Y,ThemeContext:()=>W,ThemeProvider:()=>ke,ThemeSwitch:()=>q,getAuthDetailsFromCookies:()=>tt,logout:()=>J,redirectToLogin:()=>le,useShellContext:()=>nt});module.exports=qe(pt);var w=y(require("react")),X=y(require("classnames"));var P=require("react/jsx-runtime"),We=({connectionStatus:t,className:e,element:o="span",...r})=>{let[n,s]=(0,w.useState)("vuuConnectingStatus");(0,w.useEffect)(()=>{switch(t){case"connected":case"reconnected":s("vuuActiveStatus");break;case"connecting":s("vuuConnectingStatus");break;case"disconnected":s("vuuDisconnectedStatus");break;default:break}},[t]);let a=w.default.createElement(o,{...r,className:(0,X.default)("vuuStatus vuuIcon",n,e)});return(0,P.jsx)(P.Fragment,{children:(0,P.jsxs)("div",{className:"vuuStatus-container salt-theme",children:[a,(0,P.jsxs)("div",{className:"vuuStatus-text",children:["Status: ",t.toUpperCase()]})]})})};var Z=require("@heswell/salt-lab"),j=require("react"),ee=y(require("classnames")),te=require("react/jsx-runtime"),Ke="vuuDensitySwitch",Qe=["high","medium","low","touch"],Xe="high",Ze=({className:t,defaultDensity:e=Xe,onDensityChange:o})=>{let r=(0,j.useCallback)((s,a)=>{o(a)},[o]),n=(0,ee.default)(Ke,t);return(0,te.jsx)(Z.Dropdown,{className:n,source:Qe,defaultSelected:e,onSelectionChange:r})};var k=y(require("react")),se=require("@vuu-ui/vuu-layout");var oe=y(require("react")),M=require("react/jsx-runtime"),B=class extends oe.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,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("h1",{children:"Something went wrong."}),(0,M.jsx)("p",{children:this.state.errorMessage})]}):this.props.children}};var ne=require("react/jsx-runtime"),re=()=>(0,ne.jsx)("div",{className:"hwLoader",children:"loading"});var b=require("react/jsx-runtime");function je({url:t,css:e,params:o,...r}){e&&import(e).then(s=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,s.default]});let n=k.default.lazy(()=>import(t));return(0,b.jsx)(B,{children:(0,b.jsx)(k.Suspense,{fallback:(0,b.jsx)(re,{}),children:(0,b.jsx)(n,{...r,...o})})})}var _=k.default.memo(je);_.displayName="Feature";(0,se.registerComponent)("Feature",_,"view");var $=require("react"),ie=require("@salt-ds/core"),D=require("@heswell/salt-lab");var x=require("react/jsx-runtime"),ae="vuuLoginPanel",et=({onSubmit:t})=>{let[e,o]=(0,$.useState)(""),[r,n]=(0,$.useState)(""),s=()=>{t(e,r)},a=(l,c)=>{o(c)},m=(l,c)=>{n(c)},i=e.trim()!==""&&r.trim()!=="";return(0,x.jsxs)("div",{className:ae,children:[(0,x.jsx)(D.FormField,{label:"Username",style:{width:200},children:(0,x.jsx)(D.Input,{value:e,id:"text-username",onChange:a})}),(0,x.jsx)(D.FormField,{label:"Password",style:{width:200},children:(0,x.jsx)(D.Input,{type:"password",value:r,id:"text-password",onChange:m})}),(0,x.jsx)(ie.Button,{className:`${ae}-login`,disabled:!i,onClick:s,variant:"cta",children:"Login"})]})};var G=require("@vuu-ui/vuu-utils"),tt=()=>{let t=(0,G.getCookieValue)("vuu-username"),e=(0,G.getCookieValue)("vuu-auth-token");return[t,e]},le=(t="login.html")=>{window.location.href=t},J=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",le(t)};var Ee=require("@vuu-ui/vuu-data"),we=y(require("classnames")),p=require("react");var V=require("react"),F=require("react/jsx-runtime"),ot={},z=(0,V.createContext)(ot),rt=({children:t,context:e,inheritedContext:o})=>{let r={...o,...e};return(0,F.jsx)(z.Provider,{value:r,children:t})},Y=({children:t,value:e})=>(0,F.jsx)(z.Consumer,{children:o=>(0,F.jsx)(rt,{context:e,inheritedContext:o,children:t})}),nt=()=>(0,V.useContext)(z);var T=require("react"),st=(t,e)=>{let[o,r]=(0,T.useState)(e),n=i=>{r(i)},s=(0,T.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,T.useEffect)(()=>{s()},[s]);let a=(0,T.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]),m=(0,T.useCallback)(i=>{s(i)},[s]);return[o,a,m]},me=st;var u=require("@vuu-ui/vuu-layout");var Se=require("react");var ge=require("@salt-ds/core"),fe=require("@heswell/salt-lab"),ye=require("@salt-ds/icons");var ue=require("@vuu-ui/vuu-utils"),O=require("@heswell/salt-lab"),de=require("@salt-ds/core"),pe=require("@salt-ds/icons"),v=require("react");var ce=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"),at=({lastUpdate:t},{lastUpdate:e})=>e===t?0:e<t?-1:1,it=t=>(0,C.jsx)(O.ListItem,{...t}),he=(0,v.forwardRef)(function({loginUrl:e,onNavigate:o,user:r,layoutId:n="latest"},s){let[a,m]=(0,v.useState)([]);(0,v.useEffect)(()=>{async function h(){let S=(await ce(r)).filter(E=>E.id!=="latest").sort(at).map(({id:E,lastUpdate:N})=>({lastUpdate:N,id:E,label:`Saved at ${(0,ue.formatDate)(new Date(N),"kk:mm:ss")}`}));console.log({sortedHistory:S}),m(S)}h()},[r]);let i=(0,v.useCallback)((h,d)=>{d&&o(d.id)},[o]),l=(0,v.useCallback)(()=>{J(e)},[e]),c=a.length===0?null:n==="latest"?a[0]:a.find(h=>h.id===n);return(0,C.jsxs)("div",{className:"vuuUserPanel",ref:s,children:[(0,C.jsx)(O.List,{ListItem:it,className:"vuuUserPanel-history",onSelect:i,selected:c,source:a}),(0,C.jsx)("div",{className:"vuuUserPanel-buttonBar",children:(0,C.jsxs)(de.Button,{"aria-label":"logout",onClick:l,children:[(0,C.jsx)(pe.ExportIcon,{})," Logout"]})})]})});var H=require("react/jsx-runtime"),ve=({layoutId:t,loginUrl:e,onNavigate:o,user:r})=>(0,H.jsxs)(fe.DropdownBase,{className:"vuuUserProfile",placement:"bottom-end",children:[(0,H.jsx)(ge.Button,{variant:"secondary",children:(0,H.jsx)(ye.UserSolidIcon,{})}),(0,H.jsx)(he,{layoutId:t,loginUrl:e,onNavigate:s=>{o(s)},user:r})]});var U=require("@heswell/salt-lab"),Te=y(require("classnames")),Ce=require("@salt-ds/core"),Le=require("react");var I=require("react/jsx-runtime"),lt="vuuThemeSwitch",xe=["light","dark"],q=({className:t,defaultMode:e,mode:o,onChange:r,...n})=>{let[s,a]=(0,Ce.useControlled)({controlled:o,default:e!=null?e:"light",name:"ThemeSwitch",state:"mode"}),m=xe.indexOf(s),i=(0,Le.useCallback)((c,h)=>{let d=xe[h];a(d),r(d)},[r,a]),l=(0,Te.default)(lt,t);return(0,I.jsxs)(U.ToggleButtonGroup,{className:l,...n,onChange:i,selectedIndex:m,children:[(0,I.jsx)(U.ToggleButton,{"aria-label":"alert",tooltipText:"Light Theme","data-icon":"light"}),(0,I.jsx)(U.ToggleButton,{"aria-label":"home",tooltipText:"Dark Theme","data-icon":"dark"})]})};var Pe=y(require("classnames"));var R=require("react/jsx-runtime"),mt="vuuAppHeader",Me=({className:t,layoutId:e,loginUrl:o,onNavigate:r,onSwitchTheme:n,themeMode:s="light",user:a,...m})=>{let i=(0,Pe.default)(mt,t),l=(0,Se.useCallback)(c=>n==null?void 0:n(c),[n]);return(0,R.jsxs)("header",{className:i,...m,children:[(0,R.jsx)(q,{defaultMode:s,onChange:l}),(0,R.jsx)(ve,{layoutId:e,loginUrl:o,onNavigate:r,user:a})]})};var f=require("react/jsx-runtime"),ct={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},ut=({children:t,className:e,defaultLayout:o=ct,leftSidePanel:r,loginUrl:n,serverUrl:s,user:a,...m})=>{let i=(0,p.useRef)(null),l=(0,p.useRef)(null),[c,h]=(0,p.useState)(!1),d=(0,p.useRef)("latest"),[S,E,N]=me(a,o),Ie=(0,p.useCallback)(g=>{E(g)},[E]),Re=(0,p.useCallback)(g=>{i.current&&(i.current.dataset.mode=g)},[]),Ae=g=>{var K;let Oe=g.target;(K=l.current)!=null&&K.contains(Oe)||h(!c)},Be=(0,p.useCallback)(g=>{d.current=g,N(g)},[N]);(0,p.useEffect)(()=>{s&&a.token&&(0,Ee.connectToServer)({authToken:a.token,url:s,username:a.username})},[s,a.token,a.username]);let Fe=()=>{let g=[];return r&&g.push((0,f.jsx)(u.Drawer,{onClick:Ae,open:c,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:(0,f.jsx)(u.View,{className:"vuuShell-palette",id:"vw-app-palette",ref:l,style:{height:"100%"},children:r},"app-palette")},"left-panel")),g},Ve=(0,we.default)("vuuShell",e,"salt-theme","salt-density-high");return(0,f.jsxs)(Y,{value:void 0,children:[(0,f.jsx)(u.LayoutProvider,{layout:S,onLayoutChange:Ie,children:(0,f.jsx)(u.DraggableLayout,{className:Ve,"data-mode":"light",ref:i,...m,children:(0,f.jsxs)(u.Flexbox,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[(0,f.jsx)(Me,{layoutId:d.current,loginUrl:n,user:a,onNavigate:Be,onSwitchTheme:Re}),(0,f.jsx)(u.DockLayout,{style:{flex:1},children:Fe().concat((0,f.jsx)(u.DraggableLayout,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})})}),t]})};var L=require("react"),De=y(require("classnames")),Ue=require("react/jsx-runtime"),He="medium",Ne="salt-theme",be="light",W=(0,L.createContext)({density:"high",theme:"salt-theme",themeMode:"light"}),dt=(t,e,o,r)=>{var n;return(0,L.isValidElement)(t)?(0,L.cloneElement)(t,{className:(0,De.default)((n=t.props)==null?void 0:n.className,e,`salt-density-${r}`),"data-mode":o}):(console.warn(`
|
|
696
2
|
ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
|
|
697
|
-
Wrap elements with a single container`
|
|
698
|
-
);
|
|
699
|
-
return children;
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
var ThemeProvider = ({
|
|
703
|
-
children,
|
|
704
|
-
theme: themeProp,
|
|
705
|
-
themeMode: themeModeProp,
|
|
706
|
-
density: densityProp
|
|
707
|
-
}) => {
|
|
708
|
-
var _a, _b, _c;
|
|
709
|
-
const {
|
|
710
|
-
density: inheritedDensity,
|
|
711
|
-
themeMode: inheritedThemeMode,
|
|
712
|
-
theme: inheritedTheme
|
|
713
|
-
} = (0, import_react12.useContext)(ThemeContext);
|
|
714
|
-
const density = (_a = densityProp != null ? densityProp : inheritedDensity) != null ? _a : DEFAULT_DENSITY2;
|
|
715
|
-
const themeMode = (_b = themeModeProp != null ? themeModeProp : inheritedThemeMode) != null ? _b : DEFAULT_THEME_MODE;
|
|
716
|
-
const theme = (_c = themeProp != null ? themeProp : inheritedTheme) != null ? _c : DEFAULT_THEME;
|
|
717
|
-
const themedChildren = createThemedChildren(
|
|
718
|
-
children,
|
|
719
|
-
theme,
|
|
720
|
-
themeMode,
|
|
721
|
-
density
|
|
722
|
-
);
|
|
723
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ThemeContext.Provider, { value: { themeMode, density, theme }, children: themedChildren });
|
|
724
|
-
};
|
|
725
|
-
ThemeProvider.displayName = "ThemeProvider";
|
|
3
|
+
Wrap elements with a single container`),t)},ke=({children:t,theme:e,themeMode:o,density:r})=>{var h,d,S;let{density:n,themeMode:s,theme:a}=(0,L.useContext)(W),m=(h=r!=null?r:n)!=null?h:He,i=(d=o!=null?o:s)!=null?d:be,l=(S=e!=null?e:a)!=null?S:Ne,c=dt(t,l,i,m);return(0,Ue.jsx)(W.Provider,{value:{themeMode:i,density:m,theme:l},children:c})};ke.displayName="ThemeProvider";
|
|
726
4
|
//# sourceMappingURL=index.js.map
|