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