@vuu-ui/vuu-shell 0.8.10-debug → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -1,1769 +1,4 @@
1
- // src/connection-status/ConnectionStatusIcon.tsx
2
- import React, { useEffect, useState } from "react";
3
- import cx from "classnames";
4
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
- var ConnectionStatusIcon = ({ connectionStatus, className, element = "span", ...props }) => {
6
- const [classBase11, setClassBase] = useState("vuuConnectingStatus");
7
- useEffect(() => {
8
- switch (connectionStatus) {
9
- case "connected":
10
- case "reconnected":
11
- setClassBase("vuuActiveStatus");
12
- break;
13
- case "connecting":
14
- setClassBase("vuuConnectingStatus");
15
- break;
16
- case "disconnected":
17
- setClassBase("vuuDisconnectedStatus");
18
- break;
19
- default:
20
- break;
21
- }
22
- }, [connectionStatus]);
23
- const statusIcon = React.createElement(
24
- element,
25
- {
26
- ...props,
27
- className: cx("vuuStatus vuuIcon", classBase11, className)
28
- }
29
- );
30
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "vuuStatus-container salt-theme", children: [
31
- statusIcon,
32
- /* @__PURE__ */ jsxs("div", { className: "vuuStatus-text", children: [
33
- "Status: ",
34
- connectionStatus.toUpperCase()
35
- ] })
36
- ] }) });
37
- };
38
-
39
- // src/density-switch/DensitySwitch.tsx
40
- import { Dropdown } from "@salt-ds/lab";
41
- import { useCallback } from "react";
42
- import cx2 from "classnames";
43
- import { jsx as jsx2 } from "react/jsx-runtime";
44
- var classBase = "vuuDensitySwitch";
45
- var densities = ["high", "medium", "low", "touch"];
46
- var DEFAULT_DENSITY = "high";
47
- var DensitySwitch = ({
48
- className: classNameProp,
49
- defaultDensity = DEFAULT_DENSITY,
50
- onChange
51
- }) => {
52
- const handleSelectionChange = useCallback(
53
- (_event, selectedItem) => {
54
- onChange(selectedItem);
55
- },
56
- [onChange]
57
- );
58
- const className = cx2(classBase, classNameProp);
59
- return /* @__PURE__ */ jsx2(
60
- Dropdown,
61
- {
62
- className,
63
- source: densities,
64
- defaultSelected: defaultDensity,
65
- onSelectionChange: handleSelectionChange
66
- }
67
- );
68
- };
69
-
70
- // src/feature/Feature.tsx
71
- import React3, { Suspense, useEffect as useEffect2 } from "react";
72
- import { registerComponent } from "@vuu-ui/vuu-layout";
73
-
74
- // src/feature/FeatureErrorBoundary.tsx
75
- import React2 from "react";
76
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
77
- var FeatureErrorBoundary = class extends React2.Component {
78
- constructor(props) {
79
- super(props);
80
- this.state = { errorMessage: null };
81
- }
82
- static getDerivedStateFromError(error2) {
83
- return { errorMessage: error2.message };
84
- }
85
- componentDidCatch(error2, errorInfo) {
86
- console.log(`error creating component at ${this.props.url}`);
87
- console.log(error2, errorInfo);
88
- }
89
- render() {
90
- if (this.state.errorMessage) {
91
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
92
- /* @__PURE__ */ jsx3("h1", { children: "An error occured while creating component." }),
93
- /* @__PURE__ */ jsx3("p", { children: this.state.errorMessage })
94
- ] });
95
- }
96
- return this.props.children;
97
- }
98
- };
99
-
100
- // src/feature/Loader.tsx
101
- import { jsx as jsx4 } from "react/jsx-runtime";
102
- var Loader = () => /* @__PURE__ */ jsx4("div", { className: "hwLoader", children: "loading" });
103
-
104
- // src/feature/css-module-loader.ts
105
- var importCSS = async (path) => {
106
- const container = new CSSStyleSheet();
107
- return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
108
- };
109
-
110
- // src/feature/Feature.tsx
111
- import { jsx as jsx5 } from "react/jsx-runtime";
112
- var componentsMap = /* @__PURE__ */ new Map();
113
- var useCachedFeature = (url) => {
114
- useEffect2(
115
- () => () => {
116
- componentsMap.delete(url);
117
- },
118
- [url]
119
- );
120
- if (!componentsMap.has(url)) {
121
- componentsMap.set(
122
- url,
123
- React3.lazy(() => import(
124
- /* @vite-ignore */
125
- url
126
- ))
127
- );
128
- }
129
- const lazyFeature = componentsMap.get(url);
130
- if (!lazyFeature) {
131
- throw Error(`Unable to load Lazy Feature at url ${url}`);
132
- } else {
133
- return lazyFeature;
134
- }
135
- };
136
- function RawFeature({
137
- url,
138
- css,
139
- ComponentProps: params,
140
- ...props
141
- }) {
142
- if (css) {
143
- importCSS(css).then((styleSheet) => {
144
- document.adoptedStyleSheets = [
145
- ...document.adoptedStyleSheets,
146
- styleSheet
147
- ];
148
- });
149
- }
150
- const LazyFeature = useCachedFeature(url);
151
- return /* @__PURE__ */ jsx5(FeatureErrorBoundary, { url, children: /* @__PURE__ */ jsx5(Suspense, { fallback: /* @__PURE__ */ jsx5(Loader, {}), children: /* @__PURE__ */ jsx5(LazyFeature, { ...props, ...params }) }) });
152
- }
153
- var Feature = React3.memo(RawFeature);
154
- Feature.displayName = "Feature";
155
- registerComponent("Feature", Feature, "view");
156
-
157
- // src/layout-config/use-layout-config.ts
158
- import { useCallback as useCallback2, useEffect as useEffect3, useState as useState2 } from "react";
159
-
160
- // src/layout-config/local-config.ts
161
- import { resolveJSONPath } from "@vuu-ui/vuu-layout";
162
- var loadLocalConfig = (saveUrl, user, id = "latest") => new Promise((resolve, reject) => {
163
- console.log(
164
- `load local config at ${saveUrl} for user ${user == null ? void 0 : user.username}, id ${id}`
165
- );
166
- const data = localStorage.getItem(saveUrl);
167
- if (data) {
168
- const layout = JSON.parse(data);
169
- resolve(layout);
170
- } else {
171
- reject();
172
- }
173
- });
174
- var saveLocalConfig = (saveUrl, user, data) => new Promise((resolve, reject) => {
175
- try {
176
- const layoutJson = resolveJSONPath(data, "#main-tabs.ACTIVE_CHILD");
177
- console.log(layoutJson);
178
- localStorage.setItem(saveUrl, JSON.stringify(data));
179
- resolve(void 0);
180
- } catch {
181
- reject();
182
- }
183
- });
184
-
185
- // src/layout-config/remote-config.ts
186
- var loadRemoteConfig = (saveUrl, user, id = "latest") => new Promise((resolve, reject) => {
187
- if (user === void 0) {
188
- throw Error("user mustb be provided to load remote config");
189
- }
190
- fetch(`${saveUrl}/${user.username}/${id}`, {}).then((response) => {
191
- if (response.ok) {
192
- resolve(response.json());
193
- } else {
194
- reject(void 0);
195
- }
196
- }).catch(() => {
197
- reject(void 0);
198
- });
199
- });
200
- var saveRemoteConfig = (saveUrl, user, data) => new Promise((resolve, reject) => {
201
- if (user === void 0) {
202
- throw Error("user mustb be provided to load remote config");
203
- }
204
- fetch(`${saveUrl}/${user.username}`, {
205
- method: "POST",
206
- headers: {
207
- "Content-Type": "application/json"
208
- },
209
- body: JSON.stringify(data)
210
- }).then((response) => {
211
- if (response.ok) {
212
- resolve(void 0);
213
- } else {
214
- reject();
215
- }
216
- });
217
- });
218
-
219
- // src/layout-config/use-layout-config.ts
220
- var FALLBACK_LAYOUT = { type: "Placeholder" };
221
- var useLayoutConfig = ({
222
- saveLocation,
223
- saveUrl = "api/vui",
224
- user,
225
- // TODO this should be an error panel
226
- defaultLayout = FALLBACK_LAYOUT
227
- }) => {
228
- const [layout, _setLayout] = useState2(defaultLayout);
229
- const usingRemote = saveLocation === "remote";
230
- const loadConfig = usingRemote ? loadRemoteConfig : loadLocalConfig;
231
- const saveConfig = usingRemote ? saveRemoteConfig : saveLocalConfig;
232
- const load = useCallback2(
233
- async (id = "latest") => {
234
- try {
235
- const layout2 = await loadConfig(saveUrl, user, id);
236
- _setLayout(layout2);
237
- } catch {
238
- _setLayout(defaultLayout);
239
- }
240
- },
241
- [defaultLayout, loadConfig, saveUrl, user]
242
- );
243
- useEffect3(() => {
244
- load();
245
- }, [load]);
246
- const saveData = useCallback2(
247
- (data) => {
248
- saveConfig(saveUrl, user, data);
249
- },
250
- [saveConfig, saveUrl, user]
251
- );
252
- const loadLayoutById = useCallback2((id) => load(id), [load]);
253
- return [layout, saveData, loadLayoutById];
254
- };
255
-
256
- // src/layout-management/SaveLayoutPanel.tsx
257
- import { useEffect as useEffect4, useState as useState3 } from "react";
258
- import { Input, Button, FormField, FormFieldLabel, Text } from "@salt-ds/core";
259
- import { ComboBox, Checkbox, RadioButton } from "@vuu-ui/vuu-ui-controls";
260
- import { formatDate, takeScreenshot } from "@vuu-ui/vuu-utils";
261
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
262
- var classBase2 = "saveLayoutPanel";
263
- var formField = `${classBase2}-formField`;
264
- var groups = ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5"];
265
- var checkboxValues = ["Value 1", "Value 2", "Value 3"];
266
- var radioValues = ["Value 1", "Value 2", "Value 3"];
267
- var SaveLayoutPanel = (props) => {
268
- const { onCancel, onSave, componentId } = props;
269
- const [layoutName, setLayoutName] = useState3("");
270
- const [group, setGroup] = useState3("");
271
- const [checkValues, setCheckValues] = useState3([]);
272
- const [radioValue, setRadioValue] = useState3(radioValues[0]);
273
- const [screenshot, setScreenshot] = useState3();
274
- useEffect4(() => {
275
- if (componentId) {
276
- takeScreenshot(document.getElementById(componentId)).then(
277
- (screenshot2) => setScreenshot(screenshot2)
278
- );
279
- }
280
- }, []);
281
- const handleSubmit = () => {
282
- onSave({
283
- name: layoutName,
284
- group,
285
- screenshot: screenshot != null ? screenshot : "",
286
- user: "User",
287
- date: formatDate(/* @__PURE__ */ new Date(), "dd.mm.yyyy")
288
- });
289
- };
290
- return /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-panelContainer`, children: [
291
- /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-panelContent`, children: [
292
- /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-formContainer`, children: [
293
- /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
294
- /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Group" }),
295
- /* @__PURE__ */ jsx6(
296
- ComboBox,
297
- {
298
- ListProps: {
299
- style: {
300
- zIndex: 1e4,
301
- border: "1px solid #777C94",
302
- borderRadius: 10,
303
- boxSizing: "border-box"
304
- }
305
- },
306
- source: groups,
307
- allowFreeText: true,
308
- InputProps: {
309
- inputProps: {
310
- className: `${classBase2}-inputText`,
311
- placeholder: "Select Group or Enter New Name",
312
- onChange: (event) => setGroup(event.target.value)
313
- }
314
- },
315
- width: 120,
316
- onSelectionChange: (_, value) => setGroup(value || "")
317
- }
318
- )
319
- ] }),
320
- /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
321
- /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Layout Name" }),
322
- /* @__PURE__ */ jsx6(
323
- Input,
324
- {
325
- inputProps: {
326
- className: `${classBase2}-inputText`,
327
- placeholder: "Enter Layout Name"
328
- },
329
- onChange: (event) => setLayoutName(event.target.value),
330
- value: layoutName
331
- }
332
- )
333
- ] }),
334
- /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
335
- /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Some Layout Setting" }),
336
- /* @__PURE__ */ jsx6("div", { className: `${classBase2}-settingsGroup`, children: checkboxValues.map((value, i) => /* @__PURE__ */ jsx6(
337
- Checkbox,
338
- {
339
- onToggle: () => setCheckValues(
340
- (prev) => prev.includes(value) ? prev.filter((entry) => entry !== value) : [...prev, value]
341
- ),
342
- checked: checkValues.includes(value),
343
- label: value
344
- },
345
- i
346
- )) })
347
- ] }),
348
- /* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
349
- /* @__PURE__ */ jsx6(FormFieldLabel, { children: "Some Layout Setting" }),
350
- /* @__PURE__ */ jsx6("div", { className: `${classBase2}-settingsGroup`, children: radioValues.map((value, i) => /* @__PURE__ */ jsx6(
351
- RadioButton,
352
- {
353
- onClick: () => setRadioValue(value),
354
- checked: radioValue === value,
355
- label: value,
356
- groupName: "radioGroup"
357
- },
358
- i
359
- )) })
360
- ] })
361
- ] }),
362
- /* @__PURE__ */ jsx6("div", { className: `${classBase2}-screenshotContainer`, children: screenshot ? /* @__PURE__ */ jsx6(
363
- "img",
364
- {
365
- className: `${classBase2}-screenshot`,
366
- src: screenshot,
367
- alt: "screenshot of current layout"
368
- }
369
- ) : /* @__PURE__ */ jsx6(Text, { className: "screenshot", children: "No screenshot available" }) })
370
- ] }),
371
- /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-buttonsContainer`, children: [
372
- /* @__PURE__ */ jsx6(Button, { className: `${classBase2}-cancelButton`, onClick: onCancel, children: "Cancel" }),
373
- /* @__PURE__ */ jsx6(
374
- Button,
375
- {
376
- className: `${classBase2}-saveButton`,
377
- onClick: handleSubmit,
378
- disabled: layoutName === "" || group === "",
379
- children: "Save"
380
- }
381
- )
382
- ] })
383
- ] });
384
- };
385
-
386
- // src/layout-management/LayoutList.tsx
387
- import { List } from "@vuu-ui/vuu-ui-controls";
388
-
389
- // src/layout-management/useLayoutManager.tsx
390
- import React4, { useState as useState4, useCallback as useCallback3, useContext, useEffect as useEffect5 } from "react";
391
- import { getLocalEntity, saveLocalEntity } from "@vuu-ui/vuu-filters";
392
- import { getUniqueId } from "@vuu-ui/vuu-utils";
393
- import { jsx as jsx7 } from "react/jsx-runtime";
394
- var LayoutManagementContext = React4.createContext({ layouts: [], saveLayout: () => {
395
- } });
396
- var LayoutManagementProvider = (props) => {
397
- const [layouts, setLayouts] = useState4([]);
398
- useEffect5(() => {
399
- const layouts2 = getLocalEntity("layouts");
400
- setLayouts(layouts2 || []);
401
- }, []);
402
- useEffect5(() => {
403
- saveLocalEntity("layouts", layouts);
404
- }, [layouts]);
405
- const saveLayout = useCallback3((metadata) => {
406
- const json = getLocalEntity("api/vui");
407
- if (json) {
408
- setLayouts((prev) => [
409
- ...prev,
410
- {
411
- metadata: {
412
- ...metadata,
413
- id: getUniqueId()
414
- },
415
- json
416
- }
417
- ]);
418
- }
419
- }, []);
420
- return /* @__PURE__ */ jsx7(LayoutManagementContext.Provider, { value: { layouts, saveLayout }, children: props.children });
421
- };
422
- var useLayoutManager = () => useContext(LayoutManagementContext);
423
-
424
- // src/layout-management/LayoutList.tsx
425
- import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
426
- var classBase3 = "vuuLayoutList";
427
- var LayoutsList = (props) => {
428
- const { layouts } = useLayoutManager();
429
- const layoutMetadata = layouts.map((layout) => layout.metadata);
430
- const handleLoadLayout = (layoutId) => {
431
- console.log("loading layout with id", layoutId);
432
- console.log(
433
- "json:",
434
- layouts.find((layout) => layout.metadata.id === layoutId)
435
- );
436
- };
437
- const layoutsByGroup = layoutMetadata.reduce((acc, cur) => {
438
- if (acc[cur.group]) {
439
- return {
440
- ...acc,
441
- [cur.group]: [...acc[cur.group], cur]
442
- };
443
- }
444
- return {
445
- ...acc,
446
- [cur.group]: [cur]
447
- };
448
- }, {});
449
- return /* @__PURE__ */ jsxs4("div", { className: classBase3, ...props, children: [
450
- /* @__PURE__ */ jsx8("div", { className: `${classBase3}-header`, children: "My Layouts" }),
451
- /* @__PURE__ */ jsx8(
452
- List,
453
- {
454
- height: "fit-content",
455
- source: Object.entries(layoutsByGroup),
456
- ListItem: ({ item }) => /* @__PURE__ */ jsxs4(Fragment3, { children: [
457
- /* @__PURE__ */ jsx8("div", { className: `${classBase3}-groupName`, children: item == null ? void 0 : item[0] }),
458
- /* @__PURE__ */ jsx8(
459
- List,
460
- {
461
- height: "fit-content",
462
- source: item == null ? void 0 : item[1],
463
- ListItem: ({ item: layout }) => /* @__PURE__ */ jsxs4(
464
- "div",
465
- {
466
- className: `${classBase3}-layoutContainer`,
467
- onClick: () => handleLoadLayout(layout == null ? void 0 : layout.id),
468
- children: [
469
- /* @__PURE__ */ jsx8(
470
- "img",
471
- {
472
- className: `${classBase3}-screenshot`,
473
- src: layout == null ? void 0 : layout.screenshot
474
- }
475
- ),
476
- /* @__PURE__ */ jsxs4("div", { children: [
477
- /* @__PURE__ */ jsx8("div", { className: `${classBase3}-layoutName`, children: layout == null ? void 0 : layout.name }),
478
- /* @__PURE__ */ jsx8("div", { className: `${classBase3}-layoutDetails`, children: /* @__PURE__ */ jsx8("div", { children: `${layout == null ? void 0 : layout.user}, ${layout == null ? void 0 : layout.date}` }) })
479
- ] })
480
- ]
481
- },
482
- layout == null ? void 0 : layout.id
483
- )
484
- }
485
- )
486
- ] })
487
- }
488
- )
489
- ] });
490
- };
491
-
492
- // ../vuu-icons/src/VuuLogo.tsx
493
- import { memo } from "react";
494
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
495
- var VuuLogo = memo(() => {
496
- return /* @__PURE__ */ jsxs5(
497
- "svg",
498
- {
499
- width: "44",
500
- height: "45",
501
- viewBox: "0 0 44 45",
502
- fill: "none",
503
- xmlns: "http://www.w3.org/2000/svg",
504
- children: [
505
- /* @__PURE__ */ jsxs5("g", { clipPath: "url(#clip0_217_6990)", children: [
506
- /* @__PURE__ */ jsx9(
507
- "path",
508
- {
509
- d: "M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",
510
- fill: "url(#paint0_linear_217_6990)"
511
- }
512
- ),
513
- /* @__PURE__ */ jsx9(
514
- "path",
515
- {
516
- d: "M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",
517
- fill: "url(#paint1_linear_217_6990)"
518
- }
519
- ),
520
- /* @__PURE__ */ jsx9(
521
- "path",
522
- {
523
- d: "M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",
524
- fill: "#F37880"
525
- }
526
- ),
527
- /* @__PURE__ */ jsxs5("g", { opacity: "0.86", children: [
528
- /* @__PURE__ */ jsx9(
529
- "path",
530
- {
531
- d: "M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",
532
- fill: "white"
533
- }
534
- ),
535
- /* @__PURE__ */ jsx9(
536
- "path",
537
- {
538
- d: "M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",
539
- fill: "white"
540
- }
541
- ),
542
- /* @__PURE__ */ jsx9(
543
- "path",
544
- {
545
- d: "M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",
546
- fill: "white"
547
- }
548
- )
549
- ] })
550
- ] }),
551
- /* @__PURE__ */ jsxs5("defs", { children: [
552
- /* @__PURE__ */ jsxs5(
553
- "linearGradient",
554
- {
555
- id: "paint0_linear_217_6990",
556
- x1: "24.6235",
557
- y1: "18.7363",
558
- x2: "42.3152",
559
- y2: "18.7363",
560
- gradientUnits: "userSpaceOnUse",
561
- children: [
562
- /* @__PURE__ */ jsx9("stop", { stopColor: "#4906A5" }),
563
- /* @__PURE__ */ jsx9("stop", { offset: "1", stopColor: "#D3423A" })
564
- ]
565
- }
566
- ),
567
- /* @__PURE__ */ jsxs5(
568
- "linearGradient",
569
- {
570
- id: "paint1_linear_217_6990",
571
- x1: "-2.35794e-05",
572
- y1: "22.5009",
573
- x2: "42.7186",
574
- y2: "22.5009",
575
- gradientUnits: "userSpaceOnUse",
576
- children: [
577
- /* @__PURE__ */ jsx9("stop", { stopColor: "#7C06A5" }),
578
- /* @__PURE__ */ jsx9("stop", { offset: "1", stopColor: "#D3423A" })
579
- ]
580
- }
581
- ),
582
- /* @__PURE__ */ jsx9("clipPath", { id: "clip0_217_6990", children: /* @__PURE__ */ jsx9("rect", { width: "44", height: "45", fill: "white" }) })
583
- ] })
584
- ]
585
- }
586
- );
587
- });
588
- VuuLogo.displayName = "VuuLogo";
589
-
590
- // src/left-nav/LeftNav.tsx
591
- import { Action, Stack, useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
592
- import { Tab, Tabstrip } from "@vuu-ui/vuu-ui-controls";
593
- import cx4 from "classnames";
594
- import { useCallback as useCallback4, useState as useState5 } from "react";
595
-
596
- // src/feature-list/FeatureList.tsx
597
- import { Palette, PaletteItem } from "@vuu-ui/vuu-layout";
598
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
599
- var classBase4 = "vuuFeatureList";
600
- var FeatureList = ({
601
- features,
602
- title = "VUU TABLES",
603
- ...htmlAttributes
604
- }) => {
605
- const ViewProps = {};
606
- console.log({ features });
607
- return /* @__PURE__ */ jsxs6("div", { ...htmlAttributes, className: classBase4, children: [
608
- /* @__PURE__ */ jsx10("div", { className: `${classBase4}-header`, children: title }),
609
- /* @__PURE__ */ jsx10(Palette, { orientation: "vertical", ViewProps, children: features.map((featureProps, i) => /* @__PURE__ */ jsx10(
610
- PaletteItem,
611
- {
612
- closeable: true,
613
- label: featureProps.title,
614
- resizeable: true,
615
- resize: "defer",
616
- header: true,
617
- children: /* @__PURE__ */ jsx10(Feature, { ...featureProps })
618
- },
619
- i
620
- )) })
621
- ] });
622
- };
623
-
624
- // src/theme-provider/ThemeProvider.tsx
625
- import {
626
- createContext,
627
- isValidElement,
628
- cloneElement,
629
- useContext as useContext2
630
- } from "react";
631
- import cx3 from "classnames";
632
- import { jsx as jsx11 } from "react/jsx-runtime";
633
- var DEFAULT_DENSITY2 = "medium";
634
- var DEFAULT_THEME = "salt-theme";
635
- var DEFAULT_THEME_MODE = "light";
636
- var ThemeContext = createContext({
637
- density: "high",
638
- theme: "vuu",
639
- themeMode: "light"
640
- });
641
- var DEFAULT_THEME_ATTRIBUTES = [
642
- "vuu",
643
- "vuu-density-high",
644
- "light"
645
- ];
646
- var useThemeAttributes = () => {
647
- const context = useContext2(ThemeContext);
648
- if (context) {
649
- return [
650
- `${context.theme}-theme`,
651
- `${context.theme}-density-${context.density}`,
652
- context.themeMode
653
- ];
654
- }
655
- return DEFAULT_THEME_ATTRIBUTES;
656
- };
657
- var createThemedChildren = (children, theme, themeMode, density) => {
658
- var _a;
659
- if (isValidElement(children)) {
660
- return cloneElement(children, {
661
- className: cx3(
662
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
663
- (_a = children.props) == null ? void 0 : _a.className,
664
- `${theme}-theme`,
665
- `${theme}-density-${density}`
666
- ),
667
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
668
- // @ts-expect-error
669
- "data-mode": themeMode
670
- });
671
- } else {
672
- console.warn(
673
- `
1
+ import Mt,{useEffect as Ft,useState as Dt}from"react";import Ht from"classnames";import{Fragment as Vt,jsx as kt,jsxs as Pe}from"react/jsx-runtime";var Xr=({connectionStatus:e,className:t,element:o="span",...n})=>{let[a,r]=Dt("vuuConnectingStatus");Ft(()=>{switch(e){case"connected":case"reconnected":r("vuuActiveStatus");break;case"connecting":r("vuuConnectingStatus");break;case"disconnected":r("vuuDisconnectedStatus");break;default:break}},[e]);let s=Mt.createElement(o,{...n,className:Ht("vuuStatus vuuIcon",a,t)});return kt(Vt,{children:Pe("div",{className:"vuuStatus-container salt-theme",children:[s,Pe("div",{className:"vuuStatus-text",children:["Status: ",e.toUpperCase()]})]})})};import{Dropdown as Rt}from"@salt-ds/lab";import{useCallback as It}from"react";import Ut from"classnames";import{jsx as Ot}from"react/jsx-runtime";var $t="vuuDensitySwitch",At=["high","medium","low","touch"],Bt="high",sn=({className:e,defaultDensity:t=Bt,onChange:o})=>{let n=It((r,s)=>{o(s)},[o]),a=Ut($t,e);return Ot(Rt,{className:a,source:At,defaultSelected:t,onSelectionChange:n})};import Fe,{Suspense as Zt,useEffect as qt}from"react";import{registerComponent as zt}from"@vuu-ui/vuu-layout";import _t from"react";import{Fragment as Jt,jsx as Ee,jsxs as Gt}from"react/jsx-runtime";var Y=class extends _t.Component{constructor(t){super(t),this.state={errorMessage:null}}static getDerivedStateFromError(t){return{errorMessage:t.message}}componentDidCatch(t,o){console.log(`error creating component at ${this.props.url}`),console.log(t,o)}render(){return this.state.errorMessage?Gt(Jt,{children:[Ee("h1",{children:"An error occured while creating component."}),Ee("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as Yt}from"react/jsx-runtime";var we=()=>Yt("div",{className:"hwLoader",children:"loading"});var Me=async e=>{let t=new CSSStyleSheet;return fetch(e).then(o=>o.text()).then(o=>t.replace(o))};import{jsx as q}from"react/jsx-runtime";var Z=new Map,Wt=e=>{qt(()=>()=>{Z.delete(e)},[e]),Z.has(e)||Z.set(e,Fe.lazy(()=>import(e)));let t=Z.get(e);if(t)return t;throw Error(`Unable to load Lazy Feature at url ${e}`)};function Kt({url:e,css:t,ComponentProps:o,...n}){t&&Me(t).then(r=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]});let a=Wt(e);return q(Y,{url:e,children:q(Zt,{fallback:q(we,{}),children:q(a,{...n,...o})})})}var z=Fe.memo(Kt);z.displayName="Feature";zt("Feature",z,"view");import{useCallback as ue,useEffect as Qt,useState as jt}from"react";import{resolveJSONPath as Xt}from"@vuu-ui/vuu-layout";var De=(e,t,o="latest")=>new Promise((n,a)=>{console.log(`load local config at ${e} for user ${t==null?void 0:t.username}, id ${o}`);let r=localStorage.getItem(e);if(r){let s=JSON.parse(r);n(s)}else a()}),He=(e,t,o)=>new Promise((n,a)=>{try{let r=Xt(o,"#main-tabs.ACTIVE_CHILD");console.log(r),localStorage.setItem(e,JSON.stringify(o)),n(void 0)}catch{a()}});var Ve=(e,t,o="latest")=>new Promise((n,a)=>{if(t===void 0)throw Error("user mustb be provided to load remote config");fetch(`${e}/${t.username}/${o}`,{}).then(r=>{r.ok?n(r.json()):a(void 0)}).catch(()=>{a(void 0)})}),ke=(e,t,o)=>new Promise((n,a)=>{if(t===void 0)throw Error("user mustb be provided to load remote config");fetch(`${e}/${t.username}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then(r=>{r.ok?n(void 0):a()})});var eo={type:"Placeholder"},Re=({saveLocation:e,saveUrl:t="api/vui",user:o,defaultLayout:n=eo})=>{let[a,r]=jt(n),s=e==="remote",p=s?Ve:De,u=s?ke:He,m=ue(async(d="latest")=>{try{let g=await p(t,o,d);r(g)}catch{r(n)}},[n,p,t,o]);Qt(()=>{m()},[m]);let l=ue(d=>{u(t,o,d)},[u,t,o]),y=ue(d=>m(d),[m]);return[a,l,y]};import{useEffect as to,useState as _}from"react";import{Input as oo,Button as Ie,FormField as W,FormFieldLabel as K,Text as ro}from"@salt-ds/core";import{ComboBox as no,Checkbox as ao,RadioButton as so}from"@vuu-ui/vuu-ui-controls";import{formatDate as io,takeScreenshot as lo}from"@vuu-ui/vuu-utils";import{jsx as L,jsxs as V}from"react/jsx-runtime";var T="saveLayoutPanel",X=`${T}-formField`,uo=["Group 1","Group 2","Group 3","Group 4","Group 5"],co=["Value 1","Value 2","Value 3"],Ue=["Value 1","Value 2","Value 3"],Zn=e=>{let{onCancel:t,onSave:o,componentId:n}=e,[a,r]=_(""),[s,p]=_(""),[u,m]=_([]),[l,y]=_(Ue[0]),[d,g]=_();to(()=>{n&&lo(document.getElementById(n)).then(c=>g(c))},[]);let h=()=>{o({name:a,group:s,screenshot:d!=null?d:"",user:"User",date:io(new Date,"dd.mm.yyyy")})};return V("div",{className:`${T}-panelContainer`,children:[V("div",{className:`${T}-panelContent`,children:[V("div",{className:`${T}-formContainer`,children:[V(W,{className:X,children:[L(K,{children:"Group"}),L(no,{ListProps:{style:{zIndex:1e4,border:"1px solid #777C94",borderRadius:10,boxSizing:"border-box"}},source:uo,allowFreeText:!0,InputProps:{inputProps:{className:`${T}-inputText`,placeholder:"Select Group or Enter New Name",onChange:c=>p(c.target.value)}},width:120,onSelectionChange:(c,S)=>p(S||"")})]}),V(W,{className:X,children:[L(K,{children:"Layout Name"}),L(oo,{inputProps:{className:`${T}-inputText`,placeholder:"Enter Layout Name"},onChange:c=>r(c.target.value),value:a})]}),V(W,{className:X,children:[L(K,{children:"Some Layout Setting"}),L("div",{className:`${T}-settingsGroup`,children:co.map((c,S)=>L(ao,{onToggle:()=>m(E=>E.includes(c)?E.filter(R=>R!==c):[...E,c]),checked:u.includes(c),label:c},S))})]}),V(W,{className:X,children:[L(K,{children:"Some Layout Setting"}),L("div",{className:`${T}-settingsGroup`,children:Ue.map((c,S)=>L(so,{onClick:()=>y(c),checked:l===c,label:c,groupName:"radioGroup"},S))})]})]}),L("div",{className:`${T}-screenshotContainer`,children:d?L("img",{className:`${T}-screenshot`,src:d,alt:"screenshot of current layout"}):L(ro,{className:"screenshot",children:"No screenshot available"})})]}),V("div",{className:`${T}-buttonsContainer`,children:[L(Ie,{className:`${T}-cancelButton`,onClick:t,children:"Cancel"}),L(Ie,{className:`${T}-saveButton`,onClick:h,disabled:a===""||s==="",children:"Save"})]})]})};import{List as _e}from"@vuu-ui/vuu-ui-controls";import mo,{useState as po,useCallback as fo,useContext as ho,useEffect as $e}from"react";import{getLocalEntity as Ae,saveLocalEntity as go}from"@vuu-ui/vuu-filters";import{getUniqueId as yo}from"@vuu-ui/vuu-utils";import{jsx as vo}from"react/jsx-runtime";var Be=mo.createContext({layouts:[],saveLayout:()=>{}}),Qn=e=>{let[t,o]=po([]);$e(()=>{let a=Ae("layouts");o(a||[])},[]),$e(()=>{go("layouts",t)},[t]);let n=fo(a=>{let r=Ae("api/vui");r&&o(s=>[...s,{metadata:{...a,id:yo()},json:r}])},[]);return vo(Be.Provider,{value:{layouts:t,saveLayout:n},children:e.children})},Oe=()=>ho(Be);import{Fragment as Lo,jsx as k,jsxs as Q}from"react/jsx-runtime";var I="vuuLayoutList",Je=e=>{let{layouts:t}=Oe(),o=t.map(r=>r.metadata),n=r=>{console.log("loading layout with id",r),console.log("json:",t.find(s=>s.metadata.id===r))},a=o.reduce((r,s)=>r[s.group]?{...r,[s.group]:[...r[s.group],s]}:{...r,[s.group]:[s]},{});return Q("div",{className:I,...e,children:[k("div",{className:`${I}-header`,children:"My Layouts"}),k(_e,{height:"fit-content",source:Object.entries(a),ListItem:({item:r})=>Q(Lo,{children:[k("div",{className:`${I}-groupName`,children:r==null?void 0:r[0]}),k(_e,{height:"fit-content",source:r==null?void 0:r[1],ListItem:({item:s})=>Q("div",{className:`${I}-layoutContainer`,onClick:()=>n(s==null?void 0:s.id),children:[k("img",{className:`${I}-screenshot`,src:s==null?void 0:s.screenshot}),Q("div",{children:[k("div",{className:`${I}-layoutName`,children:s==null?void 0:s.name}),k("div",{className:`${I}-layoutDetails`,children:k("div",{children:`${s==null?void 0:s.user}, ${s==null?void 0:s.date}`})})]})]},s==null?void 0:s.id)})]})})]})};import{memo as Co}from"react";import{jsx as N,jsxs as A}from"react/jsx-runtime";var ce=Co(()=>A("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[A("g",{clipPath:"url(#clip0_217_6990)",children:[N("path",{d:"M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",fill:"url(#paint0_linear_217_6990)"}),N("path",{d:"M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",fill:"url(#paint1_linear_217_6990)"}),N("path",{d:"M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",fill:"#F37880"}),A("g",{opacity:"0.86",children:[N("path",{d:"M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",fill:"white"}),N("path",{d:"M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",fill:"white"}),N("path",{d:"M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",fill:"white"})]})]}),A("defs",{children:[A("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[N("stop",{stopColor:"#4906A5"}),N("stop",{offset:"1",stopColor:"#D3423A"})]}),A("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[N("stop",{stopColor:"#7C06A5"}),N("stop",{offset:"1",stopColor:"#D3423A"})]}),N("clipPath",{id:"clip0_217_6990",children:N("rect",{width:"44",height:"45",fill:"white"})})]})]}));ce.displayName="VuuLogo";import{Action as Ze,Stack as ko,useLayoutProviderDispatch as Ro}from"@vuu-ui/vuu-layout";import{Tab as J,Tabstrip as Io}from"@vuu-ui/vuu-ui-controls";import fe from"classnames";import{useCallback as te,useState as Uo}from"react";import{Palette as So,PaletteItem as xo}from"@vuu-ui/vuu-layout";import{jsx as j,jsxs as To}from"react/jsx-runtime";var Ge="vuuFeatureList",me=({features:e,title:t="VUU TABLES",...o})=>{let n={};return console.log({features:e}),To("div",{...o,className:Ge,children:[j("div",{className:`${Ge}-header`,children:t}),j(So,{orientation:"vertical",ViewProps:n,children:e.map((a,r)=>j(xo,{closeable:!0,label:a.title,resizeable:!0,resize:"defer",header:!0,children:j(z,{...a})},r))})]})};import{createContext as bo,isValidElement as No,cloneElement as Po,useContext as Ye}from"react";import Eo from"classnames";import{jsx as Vo}from"react/jsx-runtime";var wo="medium",Mo="salt-theme",Fo="light",de=bo({density:"high",theme:"vuu",themeMode:"light"}),Do=["vuu","vuu-density-high","light"],ee=()=>{let e=Ye(de);return e?[`${e.theme}-theme`,`${e.theme}-density-${e.density}`,e.themeMode]:Do},Ho=(e,t,o,n)=>{var a;return No(e)?Po(e,{className:Eo((a=e.props)==null?void 0:a.className,`${t}-theme`,`${t}-density-${n}`),"data-mode":o}):(console.warn(`
674
2
  ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
675
- Wrap elements with a single container`
676
- );
677
- return children;
678
- }
679
- };
680
- var ThemeProvider = ({
681
- applyThemeClasses = false,
682
- children,
683
- theme: themeProp,
684
- themeMode: themeModeProp,
685
- density: densityProp
686
- }) => {
687
- var _a, _b, _c;
688
- const {
689
- density: inheritedDensity,
690
- themeMode: inheritedThemeMode,
691
- theme: inheritedTheme
692
- } = useContext2(ThemeContext);
693
- const density = (_a = densityProp != null ? densityProp : inheritedDensity) != null ? _a : DEFAULT_DENSITY2;
694
- const themeMode = (_b = themeModeProp != null ? themeModeProp : inheritedThemeMode) != null ? _b : DEFAULT_THEME_MODE;
695
- const theme = (_c = themeProp != null ? themeProp : inheritedTheme) != null ? _c : DEFAULT_THEME;
696
- const themedChildren = applyThemeClasses ? createThemedChildren(children, theme, themeMode, density) : children;
697
- return /* @__PURE__ */ jsx11(ThemeContext.Provider, { value: { themeMode, density, theme }, children: themedChildren });
698
- };
699
- ThemeProvider.displayName = "ThemeProvider";
700
-
701
- // src/left-nav/LeftNav.tsx
702
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
703
- var classBase5 = "vuuLeftNav";
704
- var LeftNav = ({
705
- "data-path": path,
706
- features,
707
- onResize,
708
- sizeCollapsed = 80,
709
- sizeContent = 240,
710
- sizeExpanded = 240,
711
- style: styleProp,
712
- tableFeatures,
713
- ...htmlAttributes
714
- }) => {
715
- const dispatch = useLayoutProviderDispatch();
716
- const [navState, setNavState] = useState5({
717
- activeTabIndex: 0,
718
- navStatus: "menu-full"
719
- });
720
- const [themeClass] = useThemeAttributes();
721
- const toggleNavWidth = useCallback4(
722
- (navStatus) => {
723
- switch (navStatus) {
724
- case "menu-icons":
725
- return sizeExpanded;
726
- case "menu-full":
727
- return sizeCollapsed;
728
- case "menu-full-content":
729
- return sizeCollapsed + sizeContent;
730
- case "menu-icons-content":
731
- return sizeExpanded + sizeContent;
732
- }
733
- },
734
- [sizeCollapsed, sizeContent, sizeExpanded]
735
- );
736
- const toggleNavStatus = (navStatus) => {
737
- switch (navStatus) {
738
- case "menu-icons":
739
- return "menu-full";
740
- case "menu-full":
741
- return "menu-icons";
742
- case "menu-full-content":
743
- return "menu-icons-content";
744
- case "menu-icons-content":
745
- return "menu-full-content";
746
- }
747
- };
748
- const getWidthAndStatus = useCallback4(
749
- (navState2, tabIndex) => {
750
- if (tabIndex === 0) {
751
- const newNavState = navState2 === "menu-full-content" ? "menu-full" : navState2 === "menu-icons-content" ? "menu-icons" : navState2;
752
- return newNavState === "menu-icons" ? [sizeCollapsed, newNavState] : [sizeExpanded, newNavState];
753
- } else {
754
- const newNavState = navState2 === "menu-full" ? "menu-full-content" : navState2 === "menu-icons" ? "menu-icons-content" : navState2;
755
- return newNavState === "menu-icons-content" ? [sizeCollapsed + sizeContent, newNavState] : [sizeExpanded + sizeContent, newNavState];
756
- }
757
- },
758
- [sizeCollapsed, sizeContent, sizeExpanded]
759
- );
760
- const handleTabSelection = useCallback4(
761
- (value) => {
762
- const [width, navStatus] = getWidthAndStatus(navState.navStatus, value);
763
- setNavState({
764
- activeTabIndex: value,
765
- navStatus
766
- });
767
- dispatch({
768
- type: Action.LAYOUT_RESIZE,
769
- path,
770
- size: width
771
- });
772
- },
773
- [dispatch, getWidthAndStatus, navState, path]
774
- );
775
- const toggleSize = useCallback4(() => {
776
- const { activeTabIndex, navStatus: currentNavStatus } = navState;
777
- setNavState({
778
- activeTabIndex,
779
- navStatus: toggleNavStatus(currentNavStatus)
780
- });
781
- dispatch({
782
- type: Action.LAYOUT_RESIZE,
783
- path,
784
- size: toggleNavWidth(currentNavStatus)
785
- });
786
- }, [dispatch, navState, path, toggleNavWidth]);
787
- const style = {
788
- ...styleProp,
789
- "--nav-menu-collapsed-width": `${sizeCollapsed}px`,
790
- "--nav-menu-expanded-width": `${sizeExpanded}px`
791
- };
792
- return /* @__PURE__ */ jsxs7(
793
- "div",
794
- {
795
- ...htmlAttributes,
796
- className: cx4(classBase5, `${classBase5}-${navState.navStatus}`),
797
- style,
798
- children: [
799
- /* @__PURE__ */ jsxs7(
800
- "div",
801
- {
802
- className: cx4(`${classBase5}-menu-primary`, themeClass),
803
- "data-mode": "dark",
804
- children: [
805
- /* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-logo", children: /* @__PURE__ */ jsx12(VuuLogo, {}) }),
806
- /* @__PURE__ */ jsx12("div", { className: `${classBase5}-main`, children: /* @__PURE__ */ jsxs7(
807
- Tabstrip,
808
- {
809
- activeTabIndex: navState.activeTabIndex,
810
- animateSelectionThumb: false,
811
- className: `${classBase5}-Tabstrip`,
812
- onActiveChange: handleTabSelection,
813
- orientation: "vertical",
814
- children: [
815
- /* @__PURE__ */ jsx12(Tab, { "data-icon": "demo", label: "DEMO" }),
816
- /* @__PURE__ */ jsx12(Tab, { "data-icon": "features", label: "VUU FEATURES" }),
817
- /* @__PURE__ */ jsx12(Tab, { "data-icon": "tables", label: "VUU TABLES" }),
818
- /* @__PURE__ */ jsx12(Tab, { "data-icon": "templates", label: "LAYOUT TEMPLATES" }),
819
- /* @__PURE__ */ jsx12(Tab, { "data-icon": "layouts", label: "MY LAYOUTS" })
820
- ]
821
- }
822
- ) }),
823
- /* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-buttonBar", children: /* @__PURE__ */ jsx12(
824
- "button",
825
- {
826
- className: cx4("vuuLeftNav-toggleButton", {
827
- "vuuLeftNav-toggleButton-open": navState.navStatus.startsWith("menu-full"),
828
- "vuuLeftNav-toggleButton-closed": navState.navStatus.startsWith("menu-icons")
829
- }),
830
- "data-icon": navState.navStatus.startsWith("menu-full") ? "chevron-left" : "chevron-right",
831
- onClick: toggleSize
832
- }
833
- ) })
834
- ]
835
- }
836
- ),
837
- /* @__PURE__ */ jsxs7(
838
- Stack,
839
- {
840
- active: navState.activeTabIndex - 1,
841
- className: `${classBase5}-menu-secondary`,
842
- showTabs: false,
843
- children: [
844
- /* @__PURE__ */ jsx12(FeatureList, { features, title: "Vuu Features" }),
845
- /* @__PURE__ */ jsx12(FeatureList, { features: tableFeatures, title: "Vuu Tables" }),
846
- /* @__PURE__ */ jsx12("div", { style: { background: "green", height: "100%" }, children: "Layout Templates" }),
847
- /* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-drawer", children: /* @__PURE__ */ jsx12(LayoutsList, {}) })
848
- ]
849
- }
850
- )
851
- ]
852
- }
853
- );
854
- };
855
-
856
- // src/login/LoginPanel.tsx
857
- import { useState as useState6 } from "react";
858
- import { Button as Button2, FormField as FormField2, FormFieldLabel as FormFieldLabel2, Input as Input2 } from "@salt-ds/core";
859
- import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
860
- var classBase6 = "vuuLoginPanel";
861
- var LoginPanel = ({
862
- requirePassword = true,
863
- onSubmit
864
- }) => {
865
- const [username, setUserName] = useState6("");
866
- const [password, setPassword] = useState6("");
867
- const login = () => {
868
- onSubmit(username, password);
869
- };
870
- const handleUsername = (evt) => {
871
- setUserName(evt.target.value);
872
- };
873
- const handlePassword = (evt) => {
874
- setPassword(evt.target.value);
875
- };
876
- const dataIsValid = username.trim() !== "" && (requirePassword === false || password.trim() !== "");
877
- return /* @__PURE__ */ jsxs8("div", { className: classBase6, children: [
878
- /* @__PURE__ */ jsxs8(FormField2, { style: { width: 200 }, children: [
879
- /* @__PURE__ */ jsx13(FormFieldLabel2, { children: "Username" }),
880
- /* @__PURE__ */ jsx13(Input2, { value: username, id: "text-username", onChange: handleUsername })
881
- ] }),
882
- requirePassword ? /* @__PURE__ */ jsxs8(FormField2, { style: { width: 200 }, children: [
883
- /* @__PURE__ */ jsx13(FormFieldLabel2, { children: "Password" }),
884
- /* @__PURE__ */ jsx13(
885
- Input2,
886
- {
887
- inputProps: {
888
- type: "password"
889
- },
890
- value: password,
891
- id: "text-password",
892
- onChange: handlePassword
893
- }
894
- )
895
- ] }) : null,
896
- /* @__PURE__ */ jsx13(
897
- Button2,
898
- {
899
- className: `${classBase6}-login`,
900
- disabled: !dataIsValid,
901
- onClick: login,
902
- variant: "cta",
903
- children: "Login"
904
- }
905
- )
906
- ] });
907
- };
908
-
909
- // src/login/login-utils.ts
910
- import { getCookieValue } from "@vuu-ui/vuu-utils";
911
- var getAuthModeFromCookies = () => {
912
- const mode = getCookieValue("vuu-auth-mode");
913
- return mode != null ? mode : "";
914
- };
915
- var getAuthDetailsFromCookies = () => {
916
- const username = getCookieValue("vuu-username");
917
- const token = getCookieValue("vuu-auth-token");
918
- return [username, token];
919
- };
920
- var getDefaultLoginUrl = () => {
921
- const authMode = getAuthModeFromCookies();
922
- return authMode === "login" ? "login.html" : "demo.html";
923
- };
924
- var redirectToLogin = (loginUrl = getDefaultLoginUrl()) => {
925
- window.location.href = loginUrl;
926
- };
927
- var logout = (loginUrl) => {
928
- document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
929
- document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
930
- redirectToLogin(loginUrl);
931
- };
932
-
933
- // src/session-editing-form/SessionEditingForm.tsx
934
- import {
935
- useCallback as useCallback5,
936
- useEffect as useEffect6,
937
- useMemo,
938
- useRef,
939
- useState as useState7
940
- } from "react";
941
- import cx5 from "classnames";
942
- import { useIdMemo } from "@salt-ds/core";
943
- import { Button as Button3 } from "@salt-ds/core";
944
- import {
945
- hasAction,
946
- isErrorResponse,
947
- RemoteDataSource
948
- } from "@vuu-ui/vuu-data";
949
- import {
950
- buildColumnMap,
951
- isValidNumber,
952
- shallowEquals
953
- } from "@vuu-ui/vuu-utils";
954
- import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
955
- var classBase7 = "vuuSessionEditingForm";
956
- var getField = (fields, name) => {
957
- const field = fields.find((f) => f.name === name);
958
- if (field) {
959
- return field;
960
- } else {
961
- throw Error(`SessionEditingForm, no field '${name}' found`);
962
- }
963
- };
964
- var getFieldNameAndValue = (evt) => {
965
- const {
966
- dataset: { field },
967
- value
968
- } = evt.target;
969
- if (field === void 0) {
970
- throw Error("SessionEditingForm, form field has no field name");
971
- }
972
- return [field, value];
973
- };
974
- var Status = {
975
- uninitialised: 0,
976
- unchanged: 1,
977
- changed: 2,
978
- invalid: 3
979
- };
980
- function getTypedValue(value, type, throwIfUndefined = false) {
981
- switch (type) {
982
- case "int":
983
- case "long": {
984
- const typedValue = parseInt(value, 10);
985
- if (isValidNumber(typedValue)) {
986
- return typedValue;
987
- } else if (throwIfUndefined) {
988
- throw Error("SessionEditingForm getTypedValue");
989
- } else {
990
- return void 0;
991
- }
992
- }
993
- case "double": {
994
- const typedValue = parseFloat(value);
995
- if (isValidNumber(typedValue)) {
996
- return typedValue;
997
- }
998
- return void 0;
999
- }
1000
- case "boolean":
1001
- return value === "true" ? true : false;
1002
- default:
1003
- return value;
1004
- }
1005
- }
1006
- var getDataSource = (dataSource, schema) => {
1007
- if (dataSource) {
1008
- return dataSource;
1009
- } else if (schema) {
1010
- return new RemoteDataSource({
1011
- bufferSize: 0,
1012
- table: schema.table,
1013
- columns: schema.columns.map((col) => col.name)
1014
- });
1015
- } else {
1016
- throw Error(
1017
- "SessionEditingForm: either a DataSource or a TableSchema must be provided"
1018
- );
1019
- }
1020
- };
1021
- var SessionEditingForm = ({
1022
- className,
1023
- config: { fields, key: keyField },
1024
- dataSource: dataSourceProp,
1025
- id: idProp,
1026
- onClose,
1027
- schema,
1028
- ...htmlAttributes
1029
- }) => {
1030
- const [values, setValues] = useState7();
1031
- const [errorMessage, setErrorMessage] = useState7("");
1032
- const formContentRef = useRef(null);
1033
- const initialDataRef = useRef();
1034
- const dataStatusRef = useRef(Status.uninitialised);
1035
- const dataSource = useMemo(() => {
1036
- const applyServerData = (data) => {
1037
- if (columnMap) {
1038
- const values2 = {};
1039
- for (const column of dataSource.columns) {
1040
- values2[column] = data[columnMap[column]];
1041
- }
1042
- if (dataStatusRef.current === Status.uninitialised) {
1043
- dataStatusRef.current = Status.unchanged;
1044
- initialDataRef.current = values2;
1045
- }
1046
- setValues(values2);
1047
- }
1048
- };
1049
- const ds = getDataSource(dataSourceProp, schema);
1050
- const columnMap = buildColumnMap(ds.columns);
1051
- ds.subscribe({ range: { from: 0, to: 5 } }, (message) => {
1052
- if (message.type === "viewport-update" && message.rows) {
1053
- if (dataStatusRef.current === Status.uninitialised) {
1054
- applyServerData(message.rows[0]);
1055
- } else {
1056
- console.log("what do we do with server updates");
1057
- }
1058
- }
1059
- });
1060
- return ds;
1061
- }, [dataSourceProp, schema]);
1062
- const id = useIdMemo(idProp);
1063
- const handleChange = useCallback5(
1064
- (evt) => {
1065
- const [field, value] = getFieldNameAndValue(evt);
1066
- const { type } = getField(fields, field);
1067
- const typedValue = getTypedValue(value, type);
1068
- setValues((values2 = {}) => {
1069
- const newValues = {
1070
- ...values2,
1071
- [field]: typedValue
1072
- };
1073
- const notUpdated = shallowEquals(newValues, initialDataRef.current);
1074
- dataStatusRef.current = notUpdated ? Status.unchanged : typedValue !== void 0 ? Status.changed : Status.invalid;
1075
- return newValues;
1076
- });
1077
- },
1078
- [fields]
1079
- );
1080
- const handleBlur = useCallback5(
1081
- (evt) => {
1082
- const [field, value] = getFieldNameAndValue(evt);
1083
- const { type } = getField(fields, field);
1084
- const rowKey = values == null ? void 0 : values[keyField];
1085
- const typedValue = getTypedValue(value, type, true);
1086
- if (typeof rowKey === "string") {
1087
- dataSource.menuRpcCall({
1088
- rowKey,
1089
- field,
1090
- value: typedValue,
1091
- type: "VP_EDIT_CELL_RPC"
1092
- });
1093
- }
1094
- },
1095
- [dataSource, fields, keyField, values]
1096
- );
1097
- const applyAction = useCallback5(
1098
- (action) => {
1099
- if (typeof action === "object" && action !== null) {
1100
- if ("type" in action && action.type === "CLOSE_DIALOG_ACTION") {
1101
- onClose();
1102
- }
1103
- }
1104
- },
1105
- [onClose]
1106
- );
1107
- const handleSubmit = useCallback5(async () => {
1108
- const response = await dataSource.menuRpcCall({
1109
- type: "VP_EDIT_SUBMIT_FORM_RPC"
1110
- });
1111
- if (isErrorResponse(response)) {
1112
- setErrorMessage(response.error);
1113
- } else if (hasAction(response)) {
1114
- applyAction(response.action);
1115
- }
1116
- }, [applyAction, dataSource]);
1117
- const handleKeyDown = useCallback5(
1118
- (evt) => {
1119
- if (evt.key === "Enter" && dataStatusRef.current === Status.changed) {
1120
- handleSubmit();
1121
- }
1122
- },
1123
- [handleSubmit]
1124
- );
1125
- const handleCancel = useCallback5(() => {
1126
- onClose();
1127
- }, [onClose]);
1128
- const getFormControl = (field) => {
1129
- var _a;
1130
- const value = String((_a = values == null ? void 0 : values[field.name]) != null ? _a : "");
1131
- if (field.readonly || field.name === keyField) {
1132
- return /* @__PURE__ */ jsx14("div", { className: `${classBase7}-fieldValue vuuReadOnly`, children: value });
1133
- } else {
1134
- return /* @__PURE__ */ jsx14(
1135
- "input",
1136
- {
1137
- className: `${classBase7}-fieldValue`,
1138
- "data-field": field.name,
1139
- onBlur: handleBlur,
1140
- onChange: handleChange,
1141
- type: "text",
1142
- value,
1143
- id: `${id}-input-${field.name}`
1144
- }
1145
- );
1146
- }
1147
- };
1148
- useEffect6(() => {
1149
- if (formContentRef.current) {
1150
- const firstInput = formContentRef.current.querySelector(
1151
- "input"
1152
- );
1153
- if (firstInput) {
1154
- setTimeout(() => {
1155
- firstInput.focus();
1156
- firstInput.select();
1157
- }, 100);
1158
- }
1159
- }
1160
- }, []);
1161
- useEffect6(() => {
1162
- return () => {
1163
- if (dataSource) {
1164
- dataSource.unsubscribe();
1165
- }
1166
- };
1167
- }, [dataSource]);
1168
- const isDirty = dataStatusRef.current === Status.changed;
1169
- return /* @__PURE__ */ jsxs9("div", { ...htmlAttributes, className: cx5(classBase7, className), children: [
1170
- errorMessage ? /* @__PURE__ */ jsx14(
1171
- "div",
1172
- {
1173
- className: `${classBase7}-errorBanner`,
1174
- "data-icon": "error",
1175
- title: errorMessage,
1176
- children: "Error, edit(s) not saved"
1177
- }
1178
- ) : void 0,
1179
- /* @__PURE__ */ jsx14(
1180
- "div",
1181
- {
1182
- className: `${classBase7}-content`,
1183
- ref: formContentRef,
1184
- onKeyDown: handleKeyDown,
1185
- children: fields.map((field) => {
1186
- var _a;
1187
- return /* @__PURE__ */ jsxs9("div", { className: `${classBase7}-field`, children: [
1188
- /* @__PURE__ */ jsx14(
1189
- "label",
1190
- {
1191
- className: cx5(`${classBase7}-fieldLabel`, {
1192
- [`${classBase7}-required`]: field.required
1193
- }),
1194
- htmlFor: `${id}-input-${field.name}`,
1195
- children: (_a = field == null ? void 0 : field.label) != null ? _a : field.description
1196
- }
1197
- ),
1198
- getFormControl(field)
1199
- ] }, field.name);
1200
- })
1201
- }
1202
- ),
1203
- /* @__PURE__ */ jsxs9("div", { className: `${classBase7}-buttonbar salt-theme salt-density-high`, children: [
1204
- /* @__PURE__ */ jsx14(
1205
- Button3,
1206
- {
1207
- type: "submit",
1208
- variant: "cta",
1209
- disabled: !isDirty,
1210
- onClick: handleSubmit,
1211
- children: "Submit"
1212
- }
1213
- ),
1214
- /* @__PURE__ */ jsx14(Button3, { variant: "secondary", onClick: handleCancel, children: "Cancel" })
1215
- ] })
1216
- ] });
1217
- };
1218
-
1219
- // src/shell.tsx
1220
- import { connectToServer } from "@vuu-ui/vuu-data";
1221
- import cx9 from "classnames";
1222
- import {
1223
- useCallback as useCallback11,
1224
- useEffect as useEffect8,
1225
- useRef as useRef3
1226
- } from "react";
1227
- import {
1228
- DraggableLayout as DraggableLayout3,
1229
- LayoutProvider
1230
- } from "@vuu-ui/vuu-layout";
1231
-
1232
- // src/app-header/AppHeader.tsx
1233
- import { useCallback as useCallback8 } from "react";
1234
-
1235
- // src/user-profile/UserProfile.tsx
1236
- import { Button as Button5 } from "@salt-ds/core";
1237
- import { DropdownBase } from "@salt-ds/lab";
1238
- import { UserSolidIcon } from "@salt-ds/icons";
1239
-
1240
- // src/user-profile/UserPanel.tsx
1241
- import { formatDate as formatDate2 } from "@vuu-ui/vuu-utils";
1242
- import { List as List2, ListItem } from "@salt-ds/lab";
1243
- import { Button as Button4 } from "@salt-ds/core";
1244
- import { ExportIcon } from "@salt-ds/icons";
1245
- import {
1246
- forwardRef,
1247
- useCallback as useCallback6,
1248
- useEffect as useEffect7,
1249
- useState as useState8
1250
- } from "react";
1251
-
1252
- // src/get-layout-history.ts
1253
- var getLayoutHistory = async (user) => {
1254
- const history = await fetch(`api/vui/${user.username}`, {}).then((response) => {
1255
- return response.ok ? response.json() : null;
1256
- }).catch(() => {
1257
- console.log("error getting history");
1258
- });
1259
- return history;
1260
- };
1261
-
1262
- // src/user-profile/UserPanel.tsx
1263
- import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
1264
- var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
1265
- return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
1266
- };
1267
- var HistoryListItem = (props) => {
1268
- return /* @__PURE__ */ jsx15(ListItem, { ...props });
1269
- };
1270
- var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
1271
- const [history, setHistory] = useState8([]);
1272
- useEffect7(() => {
1273
- async function getHistory() {
1274
- const history2 = await getLayoutHistory(user);
1275
- const sortedHistory = history2.filter((item) => item.id !== "latest").sort(byLastUpdate).map(({ id, lastUpdate }) => ({
1276
- lastUpdate,
1277
- id,
1278
- label: `Saved at ${formatDate2(new Date(lastUpdate), "kk:mm:ss")}`
1279
- }));
1280
- console.log({ sortedHistory });
1281
- setHistory(sortedHistory);
1282
- }
1283
- getHistory();
1284
- }, [user]);
1285
- const handleHisorySelected = useCallback6(
1286
- (evt, selected2) => {
1287
- if (selected2) {
1288
- onNavigate(selected2.id);
1289
- }
1290
- },
1291
- [onNavigate]
1292
- );
1293
- const handleLogout = useCallback6(() => {
1294
- logout(loginUrl);
1295
- }, [loginUrl]);
1296
- const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
1297
- return /* @__PURE__ */ jsxs10("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
1298
- /* @__PURE__ */ jsx15(
1299
- List2,
1300
- {
1301
- ListItem: HistoryListItem,
1302
- className: "vuuUserPanel-history",
1303
- onSelect: handleHisorySelected,
1304
- selected,
1305
- source: history
1306
- }
1307
- ),
1308
- /* @__PURE__ */ jsx15("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ jsxs10(Button4, { "aria-label": "logout", onClick: handleLogout, children: [
1309
- /* @__PURE__ */ jsx15(ExportIcon, {}),
1310
- " Logout"
1311
- ] }) })
1312
- ] });
1313
- });
1314
-
1315
- // src/user-profile/UserProfile.tsx
1316
- import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
1317
- var UserProfile = ({
1318
- layoutId,
1319
- loginUrl,
1320
- onNavigate,
1321
- user
1322
- }) => {
1323
- const handleNavigate = (id) => {
1324
- onNavigate(id);
1325
- };
1326
- return /* @__PURE__ */ jsxs11(DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
1327
- /* @__PURE__ */ jsx16(Button5, { variant: "secondary", children: /* @__PURE__ */ jsx16(UserSolidIcon, {}) }),
1328
- /* @__PURE__ */ jsx16(
1329
- UserPanel,
1330
- {
1331
- layoutId,
1332
- loginUrl,
1333
- onNavigate: handleNavigate,
1334
- user
1335
- }
1336
- )
1337
- ] });
1338
- };
1339
-
1340
- // src/theme-switch/ThemeSwitch.tsx
1341
- import cx6 from "classnames";
1342
- import { ToggleButton, ToggleButtonGroup, useControlled } from "@salt-ds/core";
1343
- import { useCallback as useCallback7 } from "react";
1344
- import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
1345
- var classBase8 = "vuuThemeSwitch";
1346
- var ThemeSwitch = ({
1347
- className: classNameProp,
1348
- defaultMode: defaultModeProp,
1349
- mode: modeProp,
1350
- onChange,
1351
- ...htmlAttributes
1352
- }) => {
1353
- const [mode, setMode] = useControlled({
1354
- controlled: modeProp,
1355
- default: defaultModeProp != null ? defaultModeProp : "light",
1356
- name: "ThemeSwitch",
1357
- state: "mode"
1358
- });
1359
- const handleChangeSecondary = useCallback7(
1360
- (evt) => {
1361
- const { value } = evt.target;
1362
- setMode(value);
1363
- onChange(value);
1364
- },
1365
- [onChange, setMode]
1366
- );
1367
- const className = cx6(classBase8, classNameProp);
1368
- return /* @__PURE__ */ jsxs12(
1369
- ToggleButtonGroup,
1370
- {
1371
- className,
1372
- ...htmlAttributes,
1373
- onChange: handleChangeSecondary,
1374
- value: mode,
1375
- children: [
1376
- /* @__PURE__ */ jsx17(ToggleButton, { "aria-label": "alert", "data-icon": "light", value: "dark" }),
1377
- /* @__PURE__ */ jsx17(ToggleButton, { "aria-label": "home", "data-icon": "dark", value: "light" })
1378
- ]
1379
- }
1380
- );
1381
- };
1382
-
1383
- // src/app-header/AppHeader.tsx
1384
- import cx7 from "classnames";
1385
- import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
1386
- var classBase9 = "vuuAppHeader";
1387
- var AppHeader = ({
1388
- className: classNameProp,
1389
- layoutId,
1390
- loginUrl,
1391
- onNavigate,
1392
- onSwitchTheme,
1393
- themeMode = "light",
1394
- user,
1395
- ...htmlAttributes
1396
- }) => {
1397
- const className = cx7(classBase9, classNameProp);
1398
- const handleSwitchTheme = useCallback8(
1399
- (mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
1400
- [onSwitchTheme]
1401
- );
1402
- return /* @__PURE__ */ jsxs13("header", { className, ...htmlAttributes, children: [
1403
- /* @__PURE__ */ jsx18(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
1404
- /* @__PURE__ */ jsx18(
1405
- UserProfile,
1406
- {
1407
- layoutId,
1408
- loginUrl,
1409
- onNavigate,
1410
- user
1411
- }
1412
- )
1413
- ] });
1414
- };
1415
-
1416
- // src/shell.tsx
1417
- import { logger } from "@vuu-ui/vuu-utils";
1418
-
1419
- // src/shell-layouts/context-panel/ContextPanel.tsx
1420
- import { Button as Button6 } from "@salt-ds/core";
1421
- import cx8 from "classnames";
1422
- import { useCallback as useCallback9, useMemo as useMemo2 } from "react";
1423
- import {
1424
- layoutFromJson,
1425
- useLayoutProviderDispatch as useLayoutProviderDispatch2
1426
- } from "@vuu-ui/vuu-layout";
1427
- import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
1428
- var classBase10 = "vuuContextPanel";
1429
- var ContextPanel = ({
1430
- className: classNameProp,
1431
- expanded = false,
1432
- content: contentProp,
1433
- overlay = false,
1434
- title
1435
- }) => {
1436
- const dispatchLayoutAction = useLayoutProviderDispatch2();
1437
- const handleClose = useCallback9(() => {
1438
- dispatchLayoutAction({
1439
- path: "#context-panel",
1440
- propName: "expanded",
1441
- propValue: false,
1442
- type: "set-prop"
1443
- });
1444
- }, [dispatchLayoutAction]);
1445
- const className = cx8(classBase10, classNameProp, {
1446
- [`${classBase10}-expanded`]: expanded,
1447
- [`${classBase10}-inline`]: overlay !== true,
1448
- [`${classBase10}-overlay`]: overlay
1449
- });
1450
- const content = useMemo2(
1451
- () => contentProp ? layoutFromJson(contentProp, "context-0") : null,
1452
- [contentProp]
1453
- );
1454
- return /* @__PURE__ */ jsx19("div", { className: cx8(classBase10, className), children: /* @__PURE__ */ jsxs14("div", { className: `${classBase10}-inner`, children: [
1455
- /* @__PURE__ */ jsxs14("div", { className: `${classBase10}-header`, children: [
1456
- /* @__PURE__ */ jsx19("h2", { className: `${classBase10}-title`, children: title }),
1457
- /* @__PURE__ */ jsx19(
1458
- Button6,
1459
- {
1460
- className: `${classBase10}-close`,
1461
- "data-icon": "close",
1462
- onClick: handleClose,
1463
- variant: "secondary"
1464
- }
1465
- )
1466
- ] }),
1467
- /* @__PURE__ */ jsx19("div", { className: `${classBase10}-content`, children: content })
1468
- ] }) });
1469
- };
1470
-
1471
- // src/shell-layouts/useFullHeightLeftPanel.tsx
1472
- import { DraggableLayout, Flexbox } from "@vuu-ui/vuu-layout";
1473
- import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
1474
- var useFullHeightLeftPanel = ({
1475
- appHeader,
1476
- leftSidePanel
1477
- }) => {
1478
- return /* @__PURE__ */ jsxs15(
1479
- Flexbox,
1480
- {
1481
- className: "App",
1482
- style: {
1483
- flexDirection: "row",
1484
- height: "100%",
1485
- width: "100%"
1486
- },
1487
- children: [
1488
- leftSidePanel,
1489
- /* @__PURE__ */ jsxs15(
1490
- Flexbox,
1491
- {
1492
- className: "vuuShell-content",
1493
- style: { flex: 1, flexDirection: "column" },
1494
- children: [
1495
- appHeader,
1496
- /* @__PURE__ */ jsx20(DraggableLayout, { dropTarget: true, style: { flex: 1 } }, "main-content")
1497
- ]
1498
- }
1499
- ),
1500
- /* @__PURE__ */ jsx20(
1501
- ContextPanel,
1502
- {
1503
- id: "context-panel",
1504
- overlay: true,
1505
- title: "Column Settings"
1506
- }
1507
- )
1508
- ]
1509
- }
1510
- );
1511
- };
1512
-
1513
- // src/shell-layouts/useInlayLeftPanel.tsx
1514
- import {
1515
- DockLayout,
1516
- DraggableLayout as DraggableLayout2,
1517
- Drawer,
1518
- Flexbox as Flexbox2,
1519
- View
1520
- } from "@vuu-ui/vuu-layout";
1521
- import { useCallback as useCallback10, useRef as useRef2, useState as useState9 } from "react";
1522
- import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
1523
- var useInlayLeftPanel = ({
1524
- appHeader,
1525
- leftSidePanel
1526
- }) => {
1527
- const paletteView = useRef2(null);
1528
- const [open, setOpen] = useState9(true);
1529
- const handleDrawerClick = useCallback10(
1530
- (e) => {
1531
- var _a;
1532
- const target = e.target;
1533
- if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
1534
- setOpen(!open);
1535
- }
1536
- },
1537
- [open]
1538
- );
1539
- const getDrawers = useCallback10(
1540
- (leftSidePanel2) => {
1541
- const drawers = [];
1542
- drawers.push(
1543
- /* @__PURE__ */ jsx21(
1544
- Drawer,
1545
- {
1546
- onClick: handleDrawerClick,
1547
- open,
1548
- position: "left",
1549
- inline: true,
1550
- peekaboo: true,
1551
- sizeOpen: 200,
1552
- toggleButton: "end",
1553
- children: /* @__PURE__ */ jsx21(
1554
- View,
1555
- {
1556
- className: "vuuShell-palette",
1557
- id: "vw-app-palette",
1558
- ref: paletteView,
1559
- style: { height: "100%" },
1560
- children: leftSidePanel2
1561
- },
1562
- "app-palette"
1563
- )
1564
- },
1565
- "left-panel"
1566
- )
1567
- );
1568
- return drawers;
1569
- },
1570
- [handleDrawerClick, open]
1571
- );
1572
- return /* @__PURE__ */ jsxs16(
1573
- Flexbox2,
1574
- {
1575
- className: "App",
1576
- style: { flexDirection: "column", height: "100%", width: "100%" },
1577
- children: [
1578
- appHeader,
1579
- /* @__PURE__ */ jsx21(DockLayout, { style: { flex: 1 }, children: getDrawers(leftSidePanel).concat(
1580
- /* @__PURE__ */ jsx21(
1581
- DraggableLayout2,
1582
- {
1583
- dropTarget: true,
1584
- style: { width: "100%", height: "100%" }
1585
- },
1586
- "main-content"
1587
- )
1588
- ) })
1589
- ]
1590
- }
1591
- );
1592
- };
1593
-
1594
- // src/shell-layouts/useShellLayout.ts
1595
- var useShellLayout = ({
1596
- leftSidePanelLayout = "inlay",
1597
- ...props
1598
- }) => {
1599
- const useLayoutHook = leftSidePanelLayout === "inlay" ? useInlayLeftPanel : useFullHeightLeftPanel;
1600
- return useLayoutHook(props);
1601
- };
1602
-
1603
- // src/shell.tsx
1604
- import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
1605
- var { error } = logger("Shell");
1606
- var warningLayout = {
1607
- type: "View",
1608
- props: {
1609
- style: { height: "calc(100% - 6px)" }
1610
- },
1611
- children: [
1612
- {
1613
- props: {
1614
- className: "vuuShell-warningPlaceholder"
1615
- },
1616
- type: "Placeholder"
1617
- }
1618
- ]
1619
- };
1620
- var Shell = ({
1621
- LayoutProps,
1622
- children,
1623
- className: classNameProp,
1624
- defaultLayout = warningLayout,
1625
- leftSidePanel,
1626
- leftSidePanelLayout,
1627
- loginUrl,
1628
- saveLocation = "remote",
1629
- saveUrl,
1630
- serverUrl,
1631
- user,
1632
- ...htmlAttributes
1633
- }) => {
1634
- const rootRef = useRef3(null);
1635
- const layoutId = useRef3("latest");
1636
- const [layout, saveLayoutConfig, loadLayoutById] = useLayoutConfig({
1637
- defaultLayout,
1638
- saveLocation,
1639
- saveUrl,
1640
- user
1641
- });
1642
- const handleLayoutChange = useCallback11(
1643
- (layout2, layoutChangeReason) => {
1644
- try {
1645
- console.log(`handle layout changed ${layoutChangeReason}`);
1646
- saveLayoutConfig(layout2);
1647
- } catch {
1648
- error == null ? void 0 : error("Failed to save layout");
1649
- }
1650
- },
1651
- [saveLayoutConfig]
1652
- );
1653
- const handleSwitchTheme = useCallback11((mode) => {
1654
- if (rootRef.current) {
1655
- rootRef.current.dataset.mode = mode;
1656
- }
1657
- }, []);
1658
- const handleNavigate = useCallback11(
1659
- (id) => {
1660
- layoutId.current = id;
1661
- loadLayoutById(id);
1662
- },
1663
- [loadLayoutById]
1664
- );
1665
- useEffect8(() => {
1666
- if (serverUrl && user.token) {
1667
- connectToServer({
1668
- authToken: user.token,
1669
- url: serverUrl,
1670
- username: user.username
1671
- });
1672
- }
1673
- }, [serverUrl, user.token, user.username]);
1674
- const [themeClass, densityClass, dataMode] = useThemeAttributes();
1675
- const className = cx9("vuuShell", classNameProp, themeClass, densityClass);
1676
- const shellLayout = useShellLayout({
1677
- leftSidePanelLayout,
1678
- appHeader: /* @__PURE__ */ jsx22(
1679
- AppHeader,
1680
- {
1681
- layoutId: layoutId.current,
1682
- loginUrl,
1683
- user,
1684
- onNavigate: handleNavigate,
1685
- onSwitchTheme: handleSwitchTheme
1686
- }
1687
- ),
1688
- leftSidePanel
1689
- });
1690
- return /* @__PURE__ */ jsxs17(ThemeProvider, { children: [
1691
- /* @__PURE__ */ jsx22(
1692
- LayoutProvider,
1693
- {
1694
- ...LayoutProps,
1695
- layout,
1696
- onLayoutChange: handleLayoutChange,
1697
- children: /* @__PURE__ */ jsx22(
1698
- DraggableLayout3,
1699
- {
1700
- className,
1701
- "data-mode": dataMode,
1702
- ref: rootRef,
1703
- ...htmlAttributes,
1704
- children: shellLayout
1705
- }
1706
- )
1707
- }
1708
- ),
1709
- children
1710
- ] });
1711
- };
1712
-
1713
- // src/ShellContextProvider.tsx
1714
- import { createContext as createContext2, useContext as useContext3 } from "react";
1715
- import { jsx as jsx23 } from "react/jsx-runtime";
1716
- var defaultConfig = {};
1717
- var ShellContext = createContext2(defaultConfig);
1718
- var Provider = ({
1719
- children,
1720
- context,
1721
- inheritedContext
1722
- }) => {
1723
- const mergedContext = {
1724
- ...inheritedContext,
1725
- ...context
1726
- };
1727
- return /* @__PURE__ */ jsx23(ShellContext.Provider, { value: mergedContext, children });
1728
- };
1729
- var ShellContextProvider = ({
1730
- children,
1731
- value
1732
- }) => {
1733
- return /* @__PURE__ */ jsx23(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx23(Provider, { context: value, inheritedContext: context, children }) });
1734
- };
1735
- var useShellContext = () => {
1736
- return useContext3(ShellContext);
1737
- };
1738
- export {
1739
- ConnectionStatusIcon,
1740
- ContextPanel,
1741
- DEFAULT_DENSITY2 as DEFAULT_DENSITY,
1742
- DEFAULT_THEME,
1743
- DEFAULT_THEME_MODE,
1744
- DensitySwitch,
1745
- Feature,
1746
- FeatureList,
1747
- LayoutManagementContext,
1748
- LayoutManagementProvider,
1749
- LayoutsList,
1750
- LeftNav,
1751
- LoginPanel,
1752
- SaveLayoutPanel,
1753
- SessionEditingForm,
1754
- Shell,
1755
- ShellContextProvider,
1756
- ThemeContext,
1757
- ThemeProvider,
1758
- ThemeSwitch,
1759
- getAuthDetailsFromCookies,
1760
- getAuthModeFromCookies,
1761
- logout,
1762
- redirectToLogin,
1763
- useLayoutConfig,
1764
- useLayoutManager,
1765
- useShellContext,
1766
- useShellLayout,
1767
- useThemeAttributes
1768
- };
3
+ Wrap elements with a single container`),e)},pe=({applyThemeClasses:e=!1,children:t,theme:o,themeMode:n,density:a})=>{var d,g,h;let{density:r,themeMode:s,theme:p}=Ye(de),u=(d=a!=null?a:r)!=null?d:wo,m=(g=n!=null?n:s)!=null?g:Fo,l=(h=o!=null?o:p)!=null?h:Mo,y=e?Ho(t,l,m,u):t;return Vo(de.Provider,{value:{themeMode:m,density:u,theme:l},children:y})};pe.displayName="ThemeProvider";import{jsx as C,jsxs as oe}from"react/jsx-runtime";var B="vuuLeftNav",Ka=({"data-path":e,features:t,onResize:o,sizeCollapsed:n=80,sizeContent:a=240,sizeExpanded:r=240,style:s,tableFeatures:p,...u})=>{let m=Ro(),[l,y]=Uo({activeTabIndex:0,navStatus:"menu-full"}),[d]=ee(),g=te(f=>{switch(f){case"menu-icons":return r;case"menu-full":return n;case"menu-full-content":return n+a;case"menu-icons-content":return r+a}},[n,a,r]),h=f=>{switch(f){case"menu-icons":return"menu-full";case"menu-full":return"menu-icons";case"menu-full-content":return"menu-icons-content";case"menu-icons-content":return"menu-full-content"}},c=te((f,b)=>{if(b===0){let x=f==="menu-full-content"?"menu-full":f==="menu-icons-content"?"menu-icons":f;return x==="menu-icons"?[n,x]:[r,x]}else{let x=f==="menu-full"?"menu-full-content":f==="menu-icons"?"menu-icons-content":f;return x==="menu-icons-content"?[n+a,x]:[r+a,x]}},[n,a,r]),S=te(f=>{let[b,x]=c(l.navStatus,f);y({activeTabIndex:f,navStatus:x}),m({type:Ze.LAYOUT_RESIZE,path:e,size:b})},[m,c,l,e]),E=te(()=>{let{activeTabIndex:f,navStatus:b}=l;y({activeTabIndex:f,navStatus:h(b)}),m({type:Ze.LAYOUT_RESIZE,path:e,size:g(b)})},[m,l,e,g]),R={...s,"--nav-menu-collapsed-width":`${n}px`,"--nav-menu-expanded-width":`${r}px`};return oe("div",{...u,className:fe(B,`${B}-${l.navStatus}`),style:R,children:[oe("div",{className:fe(`${B}-menu-primary`,d),"data-mode":"dark",children:[C("div",{className:"vuuLeftNav-logo",children:C(ce,{})}),C("div",{className:`${B}-main`,children:oe(Io,{activeTabIndex:l.activeTabIndex,animateSelectionThumb:!1,className:`${B}-Tabstrip`,onActiveChange:S,orientation:"vertical",children:[C(J,{"data-icon":"demo",label:"DEMO"}),C(J,{"data-icon":"features",label:"VUU FEATURES"}),C(J,{"data-icon":"tables",label:"VUU TABLES"}),C(J,{"data-icon":"templates",label:"LAYOUT TEMPLATES"}),C(J,{"data-icon":"layouts",label:"MY LAYOUTS"})]})}),C("div",{className:"vuuLeftNav-buttonBar",children:C("button",{className:fe("vuuLeftNav-toggleButton",{"vuuLeftNav-toggleButton-open":l.navStatus.startsWith("menu-full"),"vuuLeftNav-toggleButton-closed":l.navStatus.startsWith("menu-icons")}),"data-icon":l.navStatus.startsWith("menu-full")?"chevron-left":"chevron-right",onClick:E})})]}),oe(ko,{active:l.activeTabIndex-1,className:`${B}-menu-secondary`,showTabs:!1,children:[C(me,{features:t,title:"Vuu Features"}),C(me,{features:p,title:"Vuu Tables"}),C("div",{style:{background:"green",height:"100%"},children:"Layout Templates"}),C("div",{className:"vuuLeftNav-drawer",children:C(Je,{})})]})]})};import{useState as qe}from"react";import{Button as $o,FormField as ze,FormFieldLabel as We,Input as Ke}from"@salt-ds/core";import{jsx as G,jsxs as he}from"react/jsx-runtime";var Xe="vuuLoginPanel",ls=({requirePassword:e=!0,onSubmit:t})=>{let[o,n]=qe(""),[a,r]=qe(""),s=()=>{t(o,a)},p=l=>{n(l.target.value)},u=l=>{r(l.target.value)},m=o.trim()!==""&&(e===!1||a.trim()!=="");return he("div",{className:Xe,children:[he(ze,{style:{width:200},children:[G(We,{children:"Username"}),G(Ke,{value:o,id:"text-username",onChange:p})]}),e?he(ze,{style:{width:200},children:[G(We,{children:"Password"}),G(Ke,{inputProps:{type:"password"},value:a,id:"text-password",onChange:u})]}):null,G($o,{className:`${Xe}-login`,disabled:!m,onClick:s,variant:"cta",children:"Login"})]})};import{getCookieValue as ge}from"@vuu-ui/vuu-utils";var Ao=()=>{let e=ge("vuu-auth-mode");return e!=null?e:""},ds=()=>{let e=ge("vuu-username"),t=ge("vuu-auth-token");return[e,t]},Bo=()=>Ao()==="login"?"login.html":"demo.html",Oo=(e=Bo())=>{window.location.href=e},Qe=e=>{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",Oo(e)};import{useCallback as O,useEffect as je,useMemo as _o,useRef as ye,useState as et}from"react";import tt from"classnames";import{useIdMemo as Jo}from"@salt-ds/core";import{Button as ot}from"@salt-ds/core";import{hasAction as Go,isErrorResponse as Yo,RemoteDataSource as Zo}from"@vuu-ui/vuu-data";import{buildColumnMap as qo,isValidNumber as rt,shallowEquals as zo}from"@vuu-ui/vuu-utils";import{jsx as U,jsxs as ve}from"react/jsx-runtime";var D="vuuSessionEditingForm",nt=(e,t)=>{let o=e.find(n=>n.name===t);if(o)return o;throw Error(`SessionEditingForm, no field '${t}' found`)},at=e=>{let{dataset:{field:t},value:o}=e.target;if(t===void 0)throw Error("SessionEditingForm, form field has no field name");return[t,o]},H={uninitialised:0,unchanged:1,changed:2,invalid:3};function st(e,t,o=!1){switch(t){case"int":case"long":{let n=parseInt(e,10);if(rt(n))return n;if(o)throw Error("SessionEditingForm getTypedValue");return}case"double":{let n=parseFloat(e);return rt(n)?n:void 0}case"boolean":return e==="true";default:return e}}var Wo=(e,t)=>{if(e)return e;if(t)return new Zo({bufferSize:0,table:t.table,columns:t.columns.map(o=>o.name)});throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided")},Ds=({className:e,config:{fields:t,key:o},dataSource:n,id:a,onClose:r,schema:s,...p})=>{let[u,m]=et(),[l,y]=et(""),d=ye(null),g=ye(),h=ye(H.uninitialised),c=_o(()=>{let i=M=>{if(w){let F={};for(let $ of c.columns)F[$]=M[w[$]];h.current===H.uninitialised&&(h.current=H.unchanged,g.current=F),m(F)}},v=Wo(n,s),w=qo(v.columns);return v.subscribe({range:{from:0,to:5}},M=>{M.type==="viewport-update"&&M.rows&&(h.current===H.uninitialised?i(M.rows[0]):console.log("what do we do with server updates"))}),v},[n,s]),S=Jo(a),E=O(i=>{let[v,w]=at(i),{type:M}=nt(t,v),F=st(w,M);m(($={})=>{let Ne={...$,[v]:F},wt=zo(Ne,g.current);return h.current=wt?H.unchanged:F!==void 0?H.changed:H.invalid,Ne})},[t]),R=O(i=>{let[v,w]=at(i),{type:M}=nt(t,v),F=u==null?void 0:u[o],$=st(w,M,!0);typeof F=="string"&&c.menuRpcCall({rowKey:F,field:v,value:$,type:"VP_EDIT_CELL_RPC"})},[c,t,o,u]),f=O(i=>{typeof i=="object"&&i!==null&&"type"in i&&i.type==="CLOSE_DIALOG_ACTION"&&r()},[r]),b=O(async()=>{let i=await c.menuRpcCall({type:"VP_EDIT_SUBMIT_FORM_RPC"});Yo(i)?y(i.error):Go(i)&&f(i.action)},[f,c]),x=O(i=>{i.key==="Enter"&&h.current===H.changed&&b()},[b]),se=O(()=>{r()},[r]),ie=i=>{var w;let v=String((w=u==null?void 0:u[i.name])!=null?w:"");return i.readonly||i.name===o?U("div",{className:`${D}-fieldValue vuuReadOnly`,children:v}):U("input",{className:`${D}-fieldValue`,"data-field":i.name,onBlur:R,onChange:E,type:"text",value:v,id:`${S}-input-${i.name}`})};je(()=>{if(d.current){let i=d.current.querySelector("input");i&&setTimeout(()=>{i.focus(),i.select()},100)}},[]),je(()=>()=>{c&&c.unsubscribe()},[c]);let le=h.current===H.changed;return ve("div",{...p,className:tt(D,e),children:[l?U("div",{className:`${D}-errorBanner`,"data-icon":"error",title:l,children:"Error, edit(s) not saved"}):void 0,U("div",{className:`${D}-content`,ref:d,onKeyDown:x,children:t.map(i=>{var v;return ve("div",{className:`${D}-field`,children:[U("label",{className:tt(`${D}-fieldLabel`,{[`${D}-required`]:i.required}),htmlFor:`${S}-input-${i.name}`,children:(v=i==null?void 0:i.label)!=null?v:i.description}),ie(i)]},i.name)})}),ve("div",{className:`${D}-buttonbar salt-theme salt-density-high`,children:[U(ot,{type:"submit",variant:"cta",disabled:!le,onClick:b,children:"Submit"}),U(ot,{variant:"secondary",onClick:se,children:"Cancel"})]})]})};import{connectToServer as kr}from"@vuu-ui/vuu-data";import Rr from"classnames";import{useCallback as Ce,useEffect as Ir,useRef as Et}from"react";import{DraggableLayout as Ur,LayoutProvider as $r}from"@vuu-ui/vuu-layout";import{useCallback as gr}from"react";import{Button as sr}from"@salt-ds/core";import{DropdownBase as ir}from"@salt-ds/lab";import{UserSolidIcon as lr}from"@salt-ds/icons";import{formatDate as Ko}from"@vuu-ui/vuu-utils";import{List as Xo,ListItem as Qo}from"@salt-ds/lab";import{Button as jo}from"@salt-ds/core";import{ExportIcon as er}from"@salt-ds/icons";import{forwardRef as tr,useCallback as lt,useEffect as or,useState as rr}from"react";var it=async e=>await fetch(`api/vui/${e.username}`,{}).then(o=>o.ok?o.json():null).catch(()=>{console.log("error getting history")});import{jsx as re,jsxs as ut}from"react/jsx-runtime";var nr=({lastUpdate:e},{lastUpdate:t})=>t===e?0:t<e?-1:1,ar=e=>re(Qo,{...e}),ct=tr(function({loginUrl:t,onNavigate:o,user:n,layoutId:a="latest"},r){let[s,p]=rr([]);or(()=>{async function y(){let g=(await it(n)).filter(h=>h.id!=="latest").sort(nr).map(({id:h,lastUpdate:c})=>({lastUpdate:c,id:h,label:`Saved at ${Ko(new Date(c),"kk:mm:ss")}`}));console.log({sortedHistory:g}),p(g)}y()},[n]);let u=lt((y,d)=>{d&&o(d.id)},[o]),m=lt(()=>{Qe(t)},[t]),l=s.length===0?null:a==="latest"?s[0]:s.find(y=>y.id===a);return ut("div",{className:"vuuUserPanel",ref:r,children:[re(Xo,{ListItem:ar,className:"vuuUserPanel-history",onSelect:u,selected:l,source:s}),re("div",{className:"vuuUserPanel-buttonBar",children:ut(jo,{"aria-label":"logout",onClick:m,children:[re(er,{})," Logout"]})})]})});import{jsx as Le,jsxs as ur}from"react/jsx-runtime";var mt=({layoutId:e,loginUrl:t,onNavigate:o,user:n})=>ur(ir,{className:"vuuUserProfile",placement:"bottom-end",children:[Le(sr,{variant:"secondary",children:Le(lr,{})}),Le(ct,{layoutId:e,loginUrl:t,onNavigate:r=>{o(r)},user:n})]});import cr from"classnames";import{ToggleButton as dt,ToggleButtonGroup as mr,useControlled as dr}from"@salt-ds/core";import{useCallback as pr}from"react";import{jsx as pt,jsxs as hr}from"react/jsx-runtime";var fr="vuuThemeSwitch",ft=({className:e,defaultMode:t,mode:o,onChange:n,...a})=>{let[r,s]=dr({controlled:o,default:t!=null?t:"light",name:"ThemeSwitch",state:"mode"}),p=pr(m=>{let{value:l}=m.target;s(l),n(l)},[n,s]),u=cr(fr,e);return hr(mr,{className:u,...a,onChange:p,value:r,children:[pt(dt,{"aria-label":"alert","data-icon":"light",value:"dark"}),pt(dt,{"aria-label":"home","data-icon":"dark",value:"light"})]})};import yr from"classnames";import{jsx as ht,jsxs as Lr}from"react/jsx-runtime";var vr="vuuAppHeader",gt=({className:e,layoutId:t,loginUrl:o,onNavigate:n,onSwitchTheme:a,themeMode:r="light",user:s,...p})=>{let u=yr(vr,e),m=gr(l=>a==null?void 0:a(l),[a]);return Lr("header",{className:u,...p,children:[ht(ft,{defaultMode:r,onChange:m}),ht(mt,{layoutId:t,loginUrl:o,onNavigate:n,user:s})]})};import{logger as Ar}from"@vuu-ui/vuu-utils";import{Button as Cr}from"@salt-ds/core";import yt from"classnames";import{useCallback as Sr,useMemo as xr}from"react";import{layoutFromJson as Tr,useLayoutProviderDispatch as br}from"@vuu-ui/vuu-layout";import{jsx as ne,jsxs as vt}from"react/jsx-runtime";var P="vuuContextPanel",Lt=({className:e,expanded:t=!1,content:o,overlay:n=!1,title:a})=>{let r=br(),s=Sr(()=>{r({path:"#context-panel",propName:"expanded",propValue:!1,type:"set-prop"})},[r]),p=yt(P,e,{[`${P}-expanded`]:t,[`${P}-inline`]:n!==!0,[`${P}-overlay`]:n}),u=xr(()=>o?Tr(o,"context-0"):null,[o]);return ne("div",{className:yt(P,p),children:vt("div",{className:`${P}-inner`,children:[vt("div",{className:`${P}-header`,children:[ne("h2",{className:`${P}-title`,children:a}),ne(Cr,{className:`${P}-close`,"data-icon":"close",onClick:s,variant:"secondary"})]}),ne("div",{className:`${P}-content`,children:u})]})})};import{DraggableLayout as Nr,Flexbox as Ct}from"@vuu-ui/vuu-layout";import{jsx as St,jsxs as xt}from"react/jsx-runtime";var Tt=({appHeader:e,leftSidePanel:t})=>xt(Ct,{className:"App",style:{flexDirection:"row",height:"100%",width:"100%"},children:[t,xt(Ct,{className:"vuuShell-content",style:{flex:1,flexDirection:"column"},children:[e,St(Nr,{dropTarget:!0,style:{flex:1}},"main-content")]}),St(Lt,{id:"context-panel",overlay:!0,title:"Column Settings"})]});import{DockLayout as Pr,DraggableLayout as Er,Drawer as wr,Flexbox as Mr,View as Fr}from"@vuu-ui/vuu-layout";import{useCallback as bt,useRef as Dr,useState as Hr}from"react";import{jsx as ae,jsxs as Vr}from"react/jsx-runtime";var Nt=({appHeader:e,leftSidePanel:t})=>{let o=Dr(null),[n,a]=Hr(!0),r=bt(p=>{var m;let u=p.target;(m=o.current)!=null&&m.contains(u)||a(!n)},[n]),s=bt(p=>{let u=[];return u.push(ae(wr,{onClick:r,open:n,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:ae(Fr,{className:"vuuShell-palette",id:"vw-app-palette",ref:o,style:{height:"100%"},children:p},"app-palette")},"left-panel")),u},[r,n]);return Vr(Mr,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[e,ae(Pr,{style:{flex:1},children:s(t).concat(ae(Er,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})};var Pt=({leftSidePanelLayout:e="inlay",...t})=>(e==="inlay"?Nt:Tt)(t);import{jsx as xe,jsxs as Or}from"react/jsx-runtime";var{error:Se}=Ar("Shell"),Br={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Nl=({LayoutProps:e,children:t,className:o,defaultLayout:n=Br,leftSidePanel:a,leftSidePanelLayout:r,loginUrl:s,saveLocation:p="remote",saveUrl:u,serverUrl:m,user:l,...y})=>{let d=Et(null),g=Et("latest"),[h,c,S]=Re({defaultLayout:n,saveLocation:p,saveUrl:u,user:l}),E=Ce((i,v)=>{try{console.log(`handle layout changed ${v}`),c(i)}catch{Se==null||Se("Failed to save layout")}},[c]),R=Ce(i=>{d.current&&(d.current.dataset.mode=i)},[]),f=Ce(i=>{g.current=i,S(i)},[S]);Ir(()=>{m&&l.token&&kr({authToken:l.token,url:m,username:l.username})},[m,l.token,l.username]);let[b,x,se]=ee(),ie=Rr("vuuShell",o,b,x),le=Pt({leftSidePanelLayout:r,appHeader:xe(gt,{layoutId:g.current,loginUrl:s,user:l,onNavigate:f,onSwitchTheme:R}),leftSidePanel:a});return Or(pe,{children:[xe($r,{...e,layout:h,onLayoutChange:E,children:xe(Ur,{className:ie,"data-mode":se,ref:d,...y,children:le})}),t]})};import{createContext as _r,useContext as Jr}from"react";import{jsx as Te}from"react/jsx-runtime";var Gr={},be=_r(Gr),Yr=({children:e,context:t,inheritedContext:o})=>{let n={...o,...t};return Te(be.Provider,{value:n,children:e})},Dl=({children:e,value:t})=>Te(be.Consumer,{children:o=>Te(Yr,{context:t,inheritedContext:o,children:e})}),Hl=()=>Jr(be);export{Xr as ConnectionStatusIcon,Lt as ContextPanel,wo as DEFAULT_DENSITY,Mo as DEFAULT_THEME,Fo as DEFAULT_THEME_MODE,sn as DensitySwitch,z as Feature,me as FeatureList,Be as LayoutManagementContext,Qn as LayoutManagementProvider,Je as LayoutsList,Ka as LeftNav,ls as LoginPanel,Zn as SaveLayoutPanel,Ds as SessionEditingForm,Nl as Shell,Dl as ShellContextProvider,de as ThemeContext,pe as ThemeProvider,ft as ThemeSwitch,ds as getAuthDetailsFromCookies,Ao as getAuthModeFromCookies,Qe as logout,Oo as redirectToLogin,Re as useLayoutConfig,Oe as useLayoutManager,Hl as useShellContext,Pt as useShellLayout,ee as useThemeAttributes};
1769
4
  //# sourceMappingURL=index.js.map