@vuu-ui/vuu-shell 0.6.25-debug → 0.6.26-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 +199 -151
- package/cjs/index.js.map +4 -4
- package/esm/index.js +179 -126
- package/esm/index.js.map +4 -4
- package/package.json +4 -4
- package/types/app-header/AppHeader.d.ts +2 -5
- package/types/density-switch/DensitySwitch.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/theme-provider/ThemeProvider.d.ts +13 -6
- package/types/theme-provider/index.d.ts +1 -0
- package/types/theme-switch/ThemeSwitch.d.ts +1 -1
package/esm/index.js
CHANGED
|
@@ -36,13 +36,41 @@ var ConnectionStatusIcon = ({ connectionStatus, className, element = "span", ...
|
|
|
36
36
|
] }) });
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
// src/density-switch/DensitySwitch.tsx
|
|
40
|
+
import { Dropdown } from "@heswell/salt-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
|
+
onDensityChange
|
|
51
|
+
}) => {
|
|
52
|
+
const handleSelectionChange = useCallback((_event, selectedItem) => {
|
|
53
|
+
onDensityChange(selectedItem);
|
|
54
|
+
}, [onDensityChange]);
|
|
55
|
+
const className = cx2(classBase, classNameProp);
|
|
56
|
+
return /* @__PURE__ */ jsx2(
|
|
57
|
+
Dropdown,
|
|
58
|
+
{
|
|
59
|
+
className,
|
|
60
|
+
source: densities,
|
|
61
|
+
defaultSelected: defaultDensity,
|
|
62
|
+
onSelectionChange: handleSelectionChange
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
39
67
|
// src/feature/Feature.tsx
|
|
40
68
|
import React3, { Suspense } from "react";
|
|
41
69
|
import { registerComponent } from "@vuu-ui/vuu-layout";
|
|
42
70
|
|
|
43
71
|
// src/feature/ErrorBoundary.jsx
|
|
44
72
|
import React2 from "react";
|
|
45
|
-
import { Fragment as Fragment2, jsx as
|
|
73
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
46
74
|
var ErrorBoundary = class extends React2.Component {
|
|
47
75
|
constructor(props) {
|
|
48
76
|
super(props);
|
|
@@ -57,8 +85,8 @@ var ErrorBoundary = class extends React2.Component {
|
|
|
57
85
|
render() {
|
|
58
86
|
if (this.state.errorMessage) {
|
|
59
87
|
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ jsx3("h1", { children: "Something went wrong." }),
|
|
89
|
+
/* @__PURE__ */ jsx3("p", { children: this.state.errorMessage })
|
|
62
90
|
] });
|
|
63
91
|
}
|
|
64
92
|
return this.props.children;
|
|
@@ -66,17 +94,11 @@ var ErrorBoundary = class extends React2.Component {
|
|
|
66
94
|
};
|
|
67
95
|
|
|
68
96
|
// src/feature/Loader.tsx
|
|
69
|
-
import { jsx as
|
|
70
|
-
var Loader = () => /* @__PURE__ */
|
|
71
|
-
|
|
72
|
-
// src/feature/css-module-loader.ts
|
|
73
|
-
var importCSS = async (path) => {
|
|
74
|
-
const container = new CSSStyleSheet();
|
|
75
|
-
return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
|
|
76
|
-
};
|
|
97
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
98
|
+
var Loader = () => /* @__PURE__ */ jsx4("div", { className: "hwLoader", children: "loading" });
|
|
77
99
|
|
|
78
100
|
// src/feature/Feature.tsx
|
|
79
|
-
import { jsx as
|
|
101
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
80
102
|
function RawFeature({
|
|
81
103
|
url,
|
|
82
104
|
css,
|
|
@@ -84,18 +106,23 @@ function RawFeature({
|
|
|
84
106
|
...props
|
|
85
107
|
}) {
|
|
86
108
|
if (css) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
109
|
+
import(
|
|
110
|
+
/* @vite-ignore */
|
|
111
|
+
css
|
|
112
|
+
).then(
|
|
113
|
+
(cssModule) => {
|
|
114
|
+
document.adoptedStyleSheets = [
|
|
115
|
+
...document.adoptedStyleSheets,
|
|
116
|
+
cssModule.default
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
);
|
|
93
120
|
}
|
|
94
121
|
const LazyFeature = React3.lazy(() => import(
|
|
95
122
|
/* @vite-ignore */
|
|
96
123
|
url
|
|
97
124
|
));
|
|
98
|
-
return /* @__PURE__ */
|
|
125
|
+
return /* @__PURE__ */ jsx5(ErrorBoundary, { children: /* @__PURE__ */ jsx5(Suspense, { fallback: /* @__PURE__ */ jsx5(Loader, {}), children: /* @__PURE__ */ jsx5(LazyFeature, { ...props, ...params }) }) });
|
|
99
126
|
}
|
|
100
127
|
var Feature = React3.memo(RawFeature);
|
|
101
128
|
Feature.displayName = "Feature";
|
|
@@ -105,8 +132,8 @@ registerComponent("Feature", Feature, "view");
|
|
|
105
132
|
import { useState as useState2 } from "react";
|
|
106
133
|
import { Button } from "@salt-ds/core";
|
|
107
134
|
import { FormField, Input } from "@heswell/salt-lab";
|
|
108
|
-
import { jsx as
|
|
109
|
-
var
|
|
135
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
136
|
+
var classBase2 = "vuuLoginPanel";
|
|
110
137
|
var LoginPanel = ({ onSubmit }) => {
|
|
111
138
|
const [username, setUserName] = useState2("");
|
|
112
139
|
const [password, setPassword] = useState2("");
|
|
@@ -120,9 +147,9 @@ var LoginPanel = ({ onSubmit }) => {
|
|
|
120
147
|
setPassword(value);
|
|
121
148
|
};
|
|
122
149
|
const dataIsValid = username.trim() !== "" && password.trim() !== "";
|
|
123
|
-
return /* @__PURE__ */ jsxs3("div", { className:
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
150
|
+
return /* @__PURE__ */ jsxs3("div", { className: classBase2, children: [
|
|
151
|
+
/* @__PURE__ */ jsx6(FormField, { label: "Username", style: { width: 200 }, children: /* @__PURE__ */ jsx6(Input, { value: username, id: "text-username", onChange: handleUsername }) }),
|
|
152
|
+
/* @__PURE__ */ jsx6(FormField, { label: "Password", style: { width: 200 }, children: /* @__PURE__ */ jsx6(
|
|
126
153
|
Input,
|
|
127
154
|
{
|
|
128
155
|
type: "password",
|
|
@@ -131,10 +158,10 @@ var LoginPanel = ({ onSubmit }) => {
|
|
|
131
158
|
onChange: handlePassword
|
|
132
159
|
}
|
|
133
160
|
) }),
|
|
134
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ jsx6(
|
|
135
162
|
Button,
|
|
136
163
|
{
|
|
137
|
-
className: `${
|
|
164
|
+
className: `${classBase2}-login`,
|
|
138
165
|
disabled: !dataIsValid,
|
|
139
166
|
onClick: login,
|
|
140
167
|
variant: "cta",
|
|
@@ -162,6 +189,7 @@ var logout = (loginUrl) => {
|
|
|
162
189
|
|
|
163
190
|
// src/shell.tsx
|
|
164
191
|
import { connectToServer } from "@vuu-ui/vuu-data";
|
|
192
|
+
import cx5 from "classnames";
|
|
165
193
|
import {
|
|
166
194
|
useCallback as useCallback6,
|
|
167
195
|
useEffect as useEffect4,
|
|
@@ -169,14 +197,40 @@ import {
|
|
|
169
197
|
useState as useState5
|
|
170
198
|
} from "react";
|
|
171
199
|
|
|
200
|
+
// src/ShellContextProvider.tsx
|
|
201
|
+
import { createContext, useContext } from "react";
|
|
202
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
203
|
+
var defaultConfig = {};
|
|
204
|
+
var ShellContext = createContext(defaultConfig);
|
|
205
|
+
var Provider = ({
|
|
206
|
+
children,
|
|
207
|
+
context,
|
|
208
|
+
inheritedContext
|
|
209
|
+
}) => {
|
|
210
|
+
const mergedContext = {
|
|
211
|
+
...inheritedContext,
|
|
212
|
+
...context
|
|
213
|
+
};
|
|
214
|
+
return /* @__PURE__ */ jsx7(ShellContext.Provider, { value: mergedContext, children });
|
|
215
|
+
};
|
|
216
|
+
var ShellContextProvider = ({
|
|
217
|
+
children,
|
|
218
|
+
value
|
|
219
|
+
}) => {
|
|
220
|
+
return /* @__PURE__ */ jsx7(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx7(Provider, { context: value, inheritedContext: context, children }) });
|
|
221
|
+
};
|
|
222
|
+
var useShellContext = () => {
|
|
223
|
+
return useContext(ShellContext);
|
|
224
|
+
};
|
|
225
|
+
|
|
172
226
|
// src/use-layout-config.js
|
|
173
|
-
import { useCallback, useEffect as useEffect2, useState as useState3 } from "react";
|
|
227
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState3 } from "react";
|
|
174
228
|
var useLayoutConfig = (user, defaultLayout) => {
|
|
175
229
|
const [layout, _setLayout] = useState3(defaultLayout);
|
|
176
230
|
const setLayout = (layout2) => {
|
|
177
231
|
_setLayout(layout2);
|
|
178
232
|
};
|
|
179
|
-
const load =
|
|
233
|
+
const load = useCallback2(
|
|
180
234
|
async (id = "latest") => {
|
|
181
235
|
fetch(`api/vui/${user.username}/${id}`, {}).then((response) => {
|
|
182
236
|
return response.ok ? response.json() : defaultLayout;
|
|
@@ -189,7 +243,7 @@ var useLayoutConfig = (user, defaultLayout) => {
|
|
|
189
243
|
useEffect2(() => {
|
|
190
244
|
load();
|
|
191
245
|
}, [load]);
|
|
192
|
-
const saveData =
|
|
246
|
+
const saveData = useCallback2(
|
|
193
247
|
(data) => {
|
|
194
248
|
fetch(`api/vui/${user.username}`, {
|
|
195
249
|
method: "POST",
|
|
@@ -203,7 +257,7 @@ var useLayoutConfig = (user, defaultLayout) => {
|
|
|
203
257
|
},
|
|
204
258
|
[defaultLayout, user]
|
|
205
259
|
);
|
|
206
|
-
const loadLayoutById =
|
|
260
|
+
const loadLayoutById = useCallback2(
|
|
207
261
|
(id) => {
|
|
208
262
|
load(id);
|
|
209
263
|
},
|
|
@@ -213,36 +267,9 @@ var useLayoutConfig = (user, defaultLayout) => {
|
|
|
213
267
|
};
|
|
214
268
|
var use_layout_config_default = useLayoutConfig;
|
|
215
269
|
|
|
216
|
-
// src/ShellContextProvider.tsx
|
|
217
|
-
import { createContext, useContext } from "react";
|
|
218
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
219
|
-
var defaultConfig = {};
|
|
220
|
-
var ShellContext = createContext(defaultConfig);
|
|
221
|
-
var Provider = ({
|
|
222
|
-
children,
|
|
223
|
-
context,
|
|
224
|
-
inheritedContext
|
|
225
|
-
}) => {
|
|
226
|
-
const mergedContext = {
|
|
227
|
-
...inheritedContext,
|
|
228
|
-
...context
|
|
229
|
-
};
|
|
230
|
-
return /* @__PURE__ */ jsx6(ShellContext.Provider, { value: mergedContext, children });
|
|
231
|
-
};
|
|
232
|
-
var ShellContextProvider = ({
|
|
233
|
-
children,
|
|
234
|
-
value
|
|
235
|
-
}) => {
|
|
236
|
-
return /* @__PURE__ */ jsx6(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx6(Provider, { context: value, inheritedContext: context, children }) });
|
|
237
|
-
};
|
|
238
|
-
var useShellContext = () => {
|
|
239
|
-
return useContext(ShellContext);
|
|
240
|
-
};
|
|
241
|
-
|
|
242
270
|
// src/shell.tsx
|
|
243
|
-
import cx5 from "classnames";
|
|
244
271
|
import {
|
|
245
|
-
|
|
272
|
+
DockLayout,
|
|
246
273
|
DraggableLayout,
|
|
247
274
|
Drawer,
|
|
248
275
|
Flexbox,
|
|
@@ -265,7 +292,7 @@ import { Button as Button2 } from "@salt-ds/core";
|
|
|
265
292
|
import { ExportIcon } from "@salt-ds/icons";
|
|
266
293
|
import {
|
|
267
294
|
forwardRef,
|
|
268
|
-
useCallback as
|
|
295
|
+
useCallback as useCallback3,
|
|
269
296
|
useEffect as useEffect3,
|
|
270
297
|
useState as useState4
|
|
271
298
|
} from "react";
|
|
@@ -281,12 +308,12 @@ var getLayoutHistory = async (user) => {
|
|
|
281
308
|
};
|
|
282
309
|
|
|
283
310
|
// src/user-profile/UserPanel.tsx
|
|
284
|
-
import { jsx as
|
|
311
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
285
312
|
var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
|
|
286
313
|
return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
|
|
287
314
|
};
|
|
288
315
|
var HistoryListItem = (props) => {
|
|
289
|
-
return /* @__PURE__ */
|
|
316
|
+
return /* @__PURE__ */ jsx8(ListItem, { ...props });
|
|
290
317
|
};
|
|
291
318
|
var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
|
|
292
319
|
const [history, setHistory] = useState4([]);
|
|
@@ -303,7 +330,7 @@ var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, lay
|
|
|
303
330
|
}
|
|
304
331
|
getHistory();
|
|
305
332
|
}, [user]);
|
|
306
|
-
const handleHisorySelected =
|
|
333
|
+
const handleHisorySelected = useCallback3(
|
|
307
334
|
(evt, selected2) => {
|
|
308
335
|
if (selected2) {
|
|
309
336
|
onNavigate(selected2.id);
|
|
@@ -311,12 +338,12 @@ var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, lay
|
|
|
311
338
|
},
|
|
312
339
|
[onNavigate]
|
|
313
340
|
);
|
|
314
|
-
const handleLogout =
|
|
341
|
+
const handleLogout = useCallback3(() => {
|
|
315
342
|
logout(loginUrl);
|
|
316
343
|
}, [loginUrl]);
|
|
317
344
|
const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
|
|
318
345
|
return /* @__PURE__ */ jsxs4("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
|
|
319
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ jsx8(
|
|
320
347
|
List,
|
|
321
348
|
{
|
|
322
349
|
ListItem: HistoryListItem,
|
|
@@ -326,15 +353,15 @@ var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, lay
|
|
|
326
353
|
source: history
|
|
327
354
|
}
|
|
328
355
|
),
|
|
329
|
-
/* @__PURE__ */
|
|
330
|
-
/* @__PURE__ */
|
|
356
|
+
/* @__PURE__ */ jsx8("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ jsxs4(Button2, { "aria-label": "logout", onClick: handleLogout, children: [
|
|
357
|
+
/* @__PURE__ */ jsx8(ExportIcon, {}),
|
|
331
358
|
" Logout"
|
|
332
359
|
] }) })
|
|
333
360
|
] });
|
|
334
361
|
});
|
|
335
362
|
|
|
336
363
|
// src/user-profile/UserProfile.tsx
|
|
337
|
-
import { jsx as
|
|
364
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
338
365
|
var UserProfile = ({
|
|
339
366
|
layoutId,
|
|
340
367
|
loginUrl,
|
|
@@ -345,8 +372,8 @@ var UserProfile = ({
|
|
|
345
372
|
onNavigate(id);
|
|
346
373
|
};
|
|
347
374
|
return /* @__PURE__ */ jsxs5(DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ jsx9(Button3, { variant: "secondary", children: /* @__PURE__ */ jsx9(UserSolidIcon, {}) }),
|
|
376
|
+
/* @__PURE__ */ jsx9(
|
|
350
377
|
UserPanel,
|
|
351
378
|
{
|
|
352
379
|
layoutId,
|
|
@@ -363,11 +390,11 @@ import {
|
|
|
363
390
|
ToggleButton,
|
|
364
391
|
ToggleButtonGroup
|
|
365
392
|
} from "@heswell/salt-lab";
|
|
366
|
-
import
|
|
393
|
+
import cx3 from "classnames";
|
|
367
394
|
import { useControlled } from "@salt-ds/core";
|
|
368
|
-
import { useCallback as
|
|
369
|
-
import { jsx as
|
|
370
|
-
var
|
|
395
|
+
import { useCallback as useCallback4 } from "react";
|
|
396
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
397
|
+
var classBase3 = "vuuThemeSwitch";
|
|
371
398
|
var modes = ["light", "dark"];
|
|
372
399
|
var ThemeSwitch = ({
|
|
373
400
|
className: classNameProp,
|
|
@@ -383,7 +410,7 @@ var ThemeSwitch = ({
|
|
|
383
410
|
state: "mode"
|
|
384
411
|
});
|
|
385
412
|
const selectedIndex = modes.indexOf(mode);
|
|
386
|
-
const handleChangeSecondary =
|
|
413
|
+
const handleChangeSecondary = useCallback4(
|
|
387
414
|
(_evt, index) => {
|
|
388
415
|
const mode2 = modes[index];
|
|
389
416
|
setMode(mode2);
|
|
@@ -391,7 +418,7 @@ var ThemeSwitch = ({
|
|
|
391
418
|
},
|
|
392
419
|
[onChange, setMode]
|
|
393
420
|
);
|
|
394
|
-
const className =
|
|
421
|
+
const className = cx3(classBase3, classNameProp);
|
|
395
422
|
return /* @__PURE__ */ jsxs6(
|
|
396
423
|
ToggleButtonGroup,
|
|
397
424
|
{
|
|
@@ -400,7 +427,7 @@ var ThemeSwitch = ({
|
|
|
400
427
|
onChange: handleChangeSecondary,
|
|
401
428
|
selectedIndex,
|
|
402
429
|
children: [
|
|
403
|
-
/* @__PURE__ */
|
|
430
|
+
/* @__PURE__ */ jsx10(
|
|
404
431
|
ToggleButton,
|
|
405
432
|
{
|
|
406
433
|
"aria-label": "alert",
|
|
@@ -408,7 +435,7 @@ var ThemeSwitch = ({
|
|
|
408
435
|
"data-icon": "light"
|
|
409
436
|
}
|
|
410
437
|
),
|
|
411
|
-
/* @__PURE__ */
|
|
438
|
+
/* @__PURE__ */ jsx10(
|
|
412
439
|
ToggleButton,
|
|
413
440
|
{
|
|
414
441
|
"aria-label": "home",
|
|
@@ -423,36 +450,6 @@ var ThemeSwitch = ({
|
|
|
423
450
|
|
|
424
451
|
// src/app-header/AppHeader.tsx
|
|
425
452
|
import cx4 from "classnames";
|
|
426
|
-
|
|
427
|
-
// src/density-switch/DensitySwitch.tsx
|
|
428
|
-
import { Dropdown } from "@heswell/salt-lab";
|
|
429
|
-
import { DEFAULT_DENSITY } from "@salt-ds/core";
|
|
430
|
-
import { useCallback as useCallback4 } from "react";
|
|
431
|
-
import cx3 from "classnames";
|
|
432
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
433
|
-
var classBase3 = "vuuDensitySwitch";
|
|
434
|
-
var densities = ["high", "medium", "low", "touch"];
|
|
435
|
-
var DensitySwitch = ({
|
|
436
|
-
className: classNameProp,
|
|
437
|
-
defaultDensity = DEFAULT_DENSITY,
|
|
438
|
-
onDensityChange
|
|
439
|
-
}) => {
|
|
440
|
-
const handleSelectionChange = useCallback4((_event, selectedItem) => {
|
|
441
|
-
onDensityChange(selectedItem);
|
|
442
|
-
}, [onDensityChange]);
|
|
443
|
-
const className = cx3(classBase3, classNameProp);
|
|
444
|
-
return /* @__PURE__ */ jsx10(
|
|
445
|
-
Dropdown,
|
|
446
|
-
{
|
|
447
|
-
className,
|
|
448
|
-
source: densities,
|
|
449
|
-
defaultSelected: defaultDensity,
|
|
450
|
-
onSelectionChange: handleSelectionChange
|
|
451
|
-
}
|
|
452
|
-
);
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
// src/app-header/AppHeader.tsx
|
|
456
453
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
457
454
|
var classBase4 = "vuuAppHeader";
|
|
458
455
|
var AppHeader = ({
|
|
@@ -462,23 +459,16 @@ var AppHeader = ({
|
|
|
462
459
|
onNavigate,
|
|
463
460
|
onSwitchTheme,
|
|
464
461
|
themeMode = "light",
|
|
465
|
-
onDensitySwitch,
|
|
466
|
-
density = "medium",
|
|
467
462
|
user,
|
|
468
463
|
...htmlAttributes
|
|
469
464
|
}) => {
|
|
470
|
-
const className = cx4(classBase4, classNameProp
|
|
465
|
+
const className = cx4(classBase4, classNameProp);
|
|
471
466
|
const handleSwitchTheme = useCallback5(
|
|
472
467
|
(mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
|
|
473
468
|
[onSwitchTheme]
|
|
474
469
|
);
|
|
475
|
-
const handleDensitySwitch = useCallback5(
|
|
476
|
-
(density2) => onDensitySwitch == null ? void 0 : onDensitySwitch(density2),
|
|
477
|
-
[onDensitySwitch]
|
|
478
|
-
);
|
|
479
470
|
return /* @__PURE__ */ jsxs7("header", { className, ...htmlAttributes, children: [
|
|
480
471
|
/* @__PURE__ */ jsx11(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
|
|
481
|
-
/* @__PURE__ */ jsx11(DensitySwitch, { defaultDensity: density, onDensityChange: handleDensitySwitch }),
|
|
482
472
|
/* @__PURE__ */ jsx11(
|
|
483
473
|
UserProfile,
|
|
484
474
|
{
|
|
@@ -518,7 +508,6 @@ var Shell = ({
|
|
|
518
508
|
...htmlAttributes
|
|
519
509
|
}) => {
|
|
520
510
|
const rootRef = useRef(null);
|
|
521
|
-
const [density, setDensity] = useState5("medium");
|
|
522
511
|
const paletteView = useRef(null);
|
|
523
512
|
const [open, setOpen] = useState5(false);
|
|
524
513
|
const layoutId = useRef("latest");
|
|
@@ -537,12 +526,6 @@ var Shell = ({
|
|
|
537
526
|
rootRef.current.dataset.mode = mode;
|
|
538
527
|
}
|
|
539
528
|
}, []);
|
|
540
|
-
const handleDensitySwitch = useCallback6(
|
|
541
|
-
(density2) => {
|
|
542
|
-
setDensity(density2);
|
|
543
|
-
},
|
|
544
|
-
[setDensity]
|
|
545
|
-
);
|
|
546
529
|
const handleDrawerClick = (e) => {
|
|
547
530
|
var _a;
|
|
548
531
|
const target = e.target;
|
|
@@ -598,7 +581,7 @@ var Shell = ({
|
|
|
598
581
|
"vuuShell",
|
|
599
582
|
classNameProp,
|
|
600
583
|
"salt-theme",
|
|
601
|
-
|
|
584
|
+
"salt-density-high"
|
|
602
585
|
);
|
|
603
586
|
return (
|
|
604
587
|
// ShellContext TBD
|
|
@@ -623,11 +606,10 @@ var Shell = ({
|
|
|
623
606
|
loginUrl,
|
|
624
607
|
user,
|
|
625
608
|
onNavigate: handleNavigate,
|
|
626
|
-
onSwitchTheme: handleSwitchTheme
|
|
627
|
-
onDensitySwitch: handleDensitySwitch
|
|
609
|
+
onSwitchTheme: handleSwitchTheme
|
|
628
610
|
}
|
|
629
611
|
),
|
|
630
|
-
/* @__PURE__ */ jsx12(
|
|
612
|
+
/* @__PURE__ */ jsx12(DockLayout, { style: { flex: 1 }, children: getDrawers().concat(
|
|
631
613
|
/* @__PURE__ */ jsx12(
|
|
632
614
|
DraggableLayout,
|
|
633
615
|
{
|
|
@@ -646,12 +628,83 @@ var Shell = ({
|
|
|
646
628
|
] })
|
|
647
629
|
);
|
|
648
630
|
};
|
|
631
|
+
|
|
632
|
+
// src/theme-provider/ThemeProvider.tsx
|
|
633
|
+
import {
|
|
634
|
+
createContext as createContext2,
|
|
635
|
+
isValidElement,
|
|
636
|
+
cloneElement,
|
|
637
|
+
useContext as useContext2
|
|
638
|
+
} from "react";
|
|
639
|
+
import cx6 from "classnames";
|
|
640
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
641
|
+
var DEFAULT_DENSITY2 = "medium";
|
|
642
|
+
var DEFAULT_THEME = "salt-theme";
|
|
643
|
+
var DEFAULT_THEME_MODE = "light";
|
|
644
|
+
var ThemeContext = createContext2({
|
|
645
|
+
density: "high",
|
|
646
|
+
theme: "salt-theme",
|
|
647
|
+
themeMode: "light"
|
|
648
|
+
});
|
|
649
|
+
var createThemedChildren = (children, theme, themeMode, density) => {
|
|
650
|
+
var _a;
|
|
651
|
+
if (isValidElement(children)) {
|
|
652
|
+
return cloneElement(children, {
|
|
653
|
+
className: cx6(
|
|
654
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
655
|
+
(_a = children.props) == null ? void 0 : _a.className,
|
|
656
|
+
theme,
|
|
657
|
+
`salt-density-${density}`
|
|
658
|
+
),
|
|
659
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
660
|
+
// @ts-expect-error
|
|
661
|
+
"data-mode": themeMode
|
|
662
|
+
});
|
|
663
|
+
} else {
|
|
664
|
+
console.warn(
|
|
665
|
+
`
|
|
666
|
+
ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
|
|
667
|
+
Wrap elements with a single container`
|
|
668
|
+
);
|
|
669
|
+
return children;
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
var ThemeProvider = ({
|
|
673
|
+
children,
|
|
674
|
+
theme: themeProp,
|
|
675
|
+
themeMode: themeModeProp,
|
|
676
|
+
density: densityProp
|
|
677
|
+
}) => {
|
|
678
|
+
var _a, _b, _c;
|
|
679
|
+
const {
|
|
680
|
+
density: inheritedDensity,
|
|
681
|
+
themeMode: inheritedThemeMode,
|
|
682
|
+
theme: inheritedTheme
|
|
683
|
+
} = useContext2(ThemeContext);
|
|
684
|
+
const density = (_a = densityProp != null ? densityProp : inheritedDensity) != null ? _a : DEFAULT_DENSITY2;
|
|
685
|
+
const themeMode = (_b = themeModeProp != null ? themeModeProp : inheritedThemeMode) != null ? _b : DEFAULT_THEME_MODE;
|
|
686
|
+
const theme = (_c = themeProp != null ? themeProp : inheritedTheme) != null ? _c : DEFAULT_THEME;
|
|
687
|
+
const themedChildren = createThemedChildren(
|
|
688
|
+
children,
|
|
689
|
+
theme,
|
|
690
|
+
themeMode,
|
|
691
|
+
density
|
|
692
|
+
);
|
|
693
|
+
return /* @__PURE__ */ jsx13(ThemeContext.Provider, { value: { themeMode, density, theme }, children: themedChildren });
|
|
694
|
+
};
|
|
695
|
+
ThemeProvider.displayName = "ThemeProvider";
|
|
649
696
|
export {
|
|
650
697
|
ConnectionStatusIcon,
|
|
698
|
+
DEFAULT_DENSITY2 as DEFAULT_DENSITY,
|
|
699
|
+
DEFAULT_THEME,
|
|
700
|
+
DEFAULT_THEME_MODE,
|
|
701
|
+
DensitySwitch,
|
|
651
702
|
Feature,
|
|
652
703
|
LoginPanel,
|
|
653
704
|
Shell,
|
|
654
705
|
ShellContextProvider,
|
|
706
|
+
ThemeContext,
|
|
707
|
+
ThemeProvider,
|
|
655
708
|
ThemeSwitch,
|
|
656
709
|
getAuthDetailsFromCookies,
|
|
657
710
|
logout,
|