@re-venue/ui-core-react 0.1.1 → 0.1.3
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/dist/index.d.ts +9 -1
- package/dist/ui-core-react.css +1 -1
- package/dist/ui-core-react.js +191 -119
- package/dist/ui-core-react.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/components/AppShell.tsx +62 -3
- package/src/hooks/useTheme.ts +42 -0
- package/src/index.ts +1 -0
- package/src/styles/shell.css +11 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { ReactPortal } from 'react';
|
|
4
4
|
|
|
5
|
-
export declare function AppShell({ user, isAdmin, venues, activeVenueId, navItems, cookieDomain, onSwitchVenue, onLogout, headerSlot, sidebarPanel, scrollable, children, }: Props): JSX_2.Element;
|
|
5
|
+
export declare function AppShell({ user, isAdmin, venues, activeVenueId, navItems, cookieDomain, onSwitchVenue, onLogout, accountSettingsUrl, headerSlot, sidebarPanel, scrollable, children, }: Props): JSX_2.Element;
|
|
6
6
|
|
|
7
7
|
export declare interface AuthUser {
|
|
8
8
|
id: string;
|
|
@@ -23,6 +23,7 @@ declare interface Props {
|
|
|
23
23
|
cookieDomain?: string;
|
|
24
24
|
onSwitchVenue?: (venueId: string) => void;
|
|
25
25
|
onLogout: () => void;
|
|
26
|
+
accountSettingsUrl?: string;
|
|
26
27
|
headerSlot?: ReactNode;
|
|
27
28
|
sidebarPanel?: ReactNode;
|
|
28
29
|
scrollable?: boolean;
|
|
@@ -55,6 +56,13 @@ export declare interface SidebarNavItem {
|
|
|
55
56
|
hidden?: boolean;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
declare type Theme = 'light' | 'dark';
|
|
60
|
+
|
|
61
|
+
export declare function useTheme(): {
|
|
62
|
+
theme: Theme;
|
|
63
|
+
toggleTheme: () => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
58
66
|
export declare interface Venue {
|
|
59
67
|
id: string;
|
|
60
68
|
name: string;
|
package/dist/ui-core-react.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.rv-app-shell{display:flex;height:100dvh;overflow:hidden;font-family:Host Grotesk,system-ui,sans-serif}.rv-sidebar{width:280px;flex-shrink:0;display:flex;flex-direction:column;background:var(--color-bg-panel, #ffffff);border-right:1px solid var(--color-border-subtle, #d1d5db);transition:width var(--transition-slow, .25s ease);overflow:hidden}.rv-sidebar.rv-collapsed{width:56px}.rv-sidebar.rv-collapsed .rv-sidebar-top{justify-content:center;padding:0}.rv-sidebar.rv-collapsed .rv-sidebar-nav{padding:.5rem 0;align-items:center}.rv-sidebar.rv-collapsed .rv-nav-item{justify-content:center;padding:.625rem 0;width:100%}.rv-sidebar.rv-collapsed .rv-sidebar-user{flex-direction:column;align-items:center;gap:.5rem;padding:.75rem 0}.rv-sidebar.rv-collapsed .rv-logout-btn{margin-left:0}.rv-sidebar-top{display:flex;align-items:center;gap:.5rem;padding:0 .875rem;border-bottom:1px solid var(--color-border-subtle, #d1d5db);height:64px;flex-shrink:0}.rv-sidebar-brand{flex:1;display:flex;flex-direction:column;gap:.25rem;min-width:0}.rv-sidebar-logo{width:90px;height:auto;color:var(--color-text-primary, #111111)}.rv-sidebar-workspace{font-size:.8rem;font-weight:600;color:var(--color-text-secondary, #444444);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rv-collapse-toggle{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;background:none;border-radius:var(--radius-sm, 4px);cursor:pointer;color:var(--color-text-muted, #777777);transition:background var(--transition-fast, .1s ease),color var(--transition-fast, .1s ease)}.rv-collapse-toggle:hover{background:var(--color-bg-surface, #f0f0f0);color:var(--color-text-secondary, #444444)}.rv-sidebar-panel{border-bottom:1px solid var(--color-border-subtle, #d1d5db);overflow:hidden}.rv-sidebar-nav{flex:1;display:flex;flex-direction:column;gap:2px;padding:.625rem .5rem;overflow-y:auto}.rv-nav-item{display:flex;align-items:center;gap:.625rem;padding:.5rem .625rem;border-radius:var(--radius-md, 8px);color:var(--color-text-secondary, #444444);text-decoration:none;font-size:.875rem;font-weight:400;transition:background var(--transition-fast, .1s ease),color var(--transition-fast, .1s ease);white-space:nowrap}.rv-nav-item:hover{background:var(--color-bg-surface, #f0f0f0);color:var(--color-text-primary, #111111)}.rv-nav-item.rv-active{background:var(--color-primary-focus, rgba(22, 163, 74, .1));color:var(--color-primary, #16a34a);font-weight:600}.rv-nav-icon{width:18px;height:18px;flex-shrink:0;display:flex;align-items:center;justify-content:center}.rv-nav-icon svg{width:18px;height:18px}.rv-nav-label{flex:1;overflow:hidden;text-overflow:ellipsis}.rv-sidebar-pinned{display:flex;flex-direction:column;gap:2px;padding:.5rem;border-top:1px solid var(--color-border-subtle, #d1d5db);flex-shrink:0}.rv-sidebar.rv-collapsed .rv-sidebar-pinned{padding:.5rem 0;align-items:center}.rv-sidebar-user{display:flex;align-items:center;gap:.5rem;padding:.75rem;border-top:1px solid var(--color-border-subtle, #d1d5db);flex-shrink:0}.rv-user-avatar{width:28px;height:28px;border-radius:var(--radius-full, 999px);background:var(--color-primary-focus, rgba(22, 163, 74, .1));color:var(--color-primary, #16a34a);font-size:.65rem;font-weight:700;display:flex;align-items:center;justify-content:center;flex-shrink:0;letter-spacing:.02em}.rv-user-info{flex:1;min-width:0;display:flex;flex-direction:column}.rv-user-email{font-size:.875rem;font-weight:400;color:var(--color-text-secondary, #444444);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rv-logout-btn{flex-shrink:0;display:flex;align-items:center;justify-content:center;
|
|
1
|
+
.rv-app-shell{display:flex;height:100dvh;overflow:hidden;font-family:Host Grotesk,system-ui,sans-serif}.rv-sidebar{width:280px;flex-shrink:0;display:flex;flex-direction:column;background:var(--color-bg-panel, #ffffff);border-right:1px solid var(--color-border-subtle, #d1d5db);transition:width var(--transition-slow, .25s ease);overflow:hidden}.rv-sidebar.rv-collapsed{width:56px}.rv-sidebar.rv-collapsed .rv-sidebar-top{justify-content:center;padding:0}.rv-sidebar.rv-collapsed .rv-sidebar-nav{padding:.5rem 0;align-items:center}.rv-sidebar.rv-collapsed .rv-nav-item{justify-content:center;padding:.625rem 0;width:100%}.rv-sidebar.rv-collapsed .rv-sidebar-user{flex-direction:column;align-items:center;gap:.5rem;padding:.75rem 0}.rv-sidebar.rv-collapsed .rv-theme-toggle-btn,.rv-sidebar.rv-collapsed .rv-account-settings-btn,.rv-sidebar.rv-collapsed .rv-logout-btn{margin-left:0}.rv-sidebar-top{display:flex;align-items:center;gap:.5rem;padding:0 .875rem;border-bottom:1px solid var(--color-border-subtle, #d1d5db);height:64px;flex-shrink:0}.rv-sidebar-brand{flex:1;display:flex;flex-direction:column;gap:.25rem;min-width:0}.rv-sidebar-logo{width:90px;height:auto;color:var(--color-text-primary, #111111)}.rv-sidebar-workspace{font-size:.8rem;font-weight:600;color:var(--color-text-secondary, #444444);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rv-collapse-toggle{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;background:none;border-radius:var(--radius-sm, 4px);cursor:pointer;color:var(--color-text-muted, #777777);transition:background var(--transition-fast, .1s ease),color var(--transition-fast, .1s ease)}.rv-collapse-toggle:hover{background:var(--color-bg-surface, #f0f0f0);color:var(--color-text-secondary, #444444)}.rv-sidebar-panel{border-bottom:1px solid var(--color-border-subtle, #d1d5db);overflow:hidden}.rv-sidebar-nav{flex:1;display:flex;flex-direction:column;gap:2px;padding:.625rem .5rem;overflow-y:auto}.rv-nav-item{display:flex;align-items:center;gap:.625rem;padding:.5rem .625rem;border-radius:var(--radius-md, 8px);color:var(--color-text-secondary, #444444);text-decoration:none;font-size:.875rem;font-weight:400;transition:background var(--transition-fast, .1s ease),color var(--transition-fast, .1s ease);white-space:nowrap}.rv-nav-item:hover{background:var(--color-bg-surface, #f0f0f0);color:var(--color-text-primary, #111111)}.rv-nav-item.rv-active{background:var(--color-primary-focus, rgba(22, 163, 74, .1));color:var(--color-primary, #16a34a);font-weight:600}.rv-nav-icon{width:18px;height:18px;flex-shrink:0;display:flex;align-items:center;justify-content:center}.rv-nav-icon svg{width:18px;height:18px}.rv-nav-label{flex:1;overflow:hidden;text-overflow:ellipsis}.rv-sidebar-pinned{display:flex;flex-direction:column;gap:2px;padding:.5rem;border-top:1px solid var(--color-border-subtle, #d1d5db);flex-shrink:0}.rv-sidebar.rv-collapsed .rv-sidebar-pinned{padding:.5rem 0;align-items:center}.rv-sidebar-user{display:flex;align-items:center;gap:.5rem;padding:.75rem;border-top:1px solid var(--color-border-subtle, #d1d5db);flex-shrink:0}.rv-user-avatar{width:28px;height:28px;border-radius:var(--radius-full, 999px);background:var(--color-primary-focus, rgba(22, 163, 74, .1));color:var(--color-primary, #16a34a);font-size:.65rem;font-weight:700;display:flex;align-items:center;justify-content:center;flex-shrink:0;letter-spacing:.02em}.rv-user-info{flex:1;min-width:0;display:flex;flex-direction:column}.rv-user-email{font-size:.875rem;font-weight:400;color:var(--color-text-secondary, #444444);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rv-theme-toggle-btn,.rv-account-settings-btn,.rv-logout-btn{flex-shrink:0;display:flex;align-items:center;justify-content:center;border:none;background:none;cursor:pointer;color:var(--color-text-muted, #777777);border-radius:var(--radius-sm, 4px);padding:4px;text-decoration:none;transition:background var(--transition-fast, .1s ease),color var(--transition-fast, .1s ease)}.rv-theme-toggle-btn:hover,.rv-account-settings-btn:hover,.rv-logout-btn:hover{background:var(--color-bg-surface, #f0f0f0);color:var(--color-text-secondary, #444444)}.rv-logout-btn{margin-left:auto}.rv-shell-body{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0;min-height:0}.rv-shell-header{height:64px;flex-shrink:0;display:flex;align-items:center;padding:0 1.25rem;border-bottom:1px solid var(--color-border-subtle, #d1d5db);background:var(--color-bg-panel, #ffffff)}.rv-shell-content{flex:1;min-height:0;background:var(--color-bg-base, #f9f8f6)}.rv-shell-content--scroll{overflow-y:auto}.rv-shell-content--fill{overflow:hidden;display:flex;flex-direction:column}.rv-venue-switcher{position:relative}.rv-vs-trigger{display:flex;align-items:center;gap:.5rem;padding:.4rem .65rem;border:1px solid var(--color-border-subtle, #d1d5db);border-radius:8px;background:var(--color-bg-panel, #ffffff);cursor:pointer;font-size:.875rem;font-weight:400;color:var(--color-text-primary, #111111);transition:border-color .15s,background .15s;min-width:140px;max-width:220px;font-family:inherit}.rv-vs-trigger:hover{background:var(--color-bg-surface, #f0f0f0)}.rv-vs-trigger.rv-open{border-color:var(--color-primary, #16a34a);outline:none}.rv-vs-label{flex:1;display:flex;flex-direction:column;align-items:flex-start;gap:.05rem;overflow:hidden}.rv-vs-venue{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}.rv-vs-workspace{font-size:.7rem;font-weight:400;color:var(--color-text-muted, #777777);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}.rv-vs-chevron{flex-shrink:0;color:var(--color-text-muted, #777777);transition:transform .15s}.rv-vs-trigger.rv-open .rv-vs-chevron{transform:rotate(180deg)}.rv-vs-dropdown{position:absolute;top:calc(100% + 6px);left:0;min-width:100%;width:max-content;max-width:280px;background:var(--color-bg-panel, #ffffff);border:1px solid var(--color-border-subtle, #d1d5db);border-radius:10px;box-shadow:0 8px 24px #00000026;max-height:min(360px,80dvh);overflow-y:auto;overscroll-behavior:contain;z-index:200;padding:.3rem}.rv-vs-workspace-header{padding:.45rem .65rem .25rem;font-size:.7rem;font-weight:700;color:var(--color-text-muted, #777777);text-transform:uppercase;letter-spacing:.06em}.rv-vs-workspace-header+.rv-vs-workspace-header,.rv-vs-venue-option+.rv-vs-workspace-header{border-top:1px solid var(--color-border-muted, #e5e7eb);margin-top:.25rem;padding-top:.6rem}.rv-vs-venue-option{display:block;width:100%;text-align:left;padding:.5rem .65rem;font-size:.875rem;font-weight:400;color:var(--color-text-secondary, #444444);border:none;background:none;border-radius:6px;cursor:pointer;transition:background .1s;font-family:inherit}.rv-vs-venue-option:hover{background:var(--color-bg-surface, #f0f0f0)}.rv-vs-venue-option.rv-active{background:var(--color-primary-focus, rgba(22, 163, 74, .1));color:var(--color-primary, #16a34a);font-weight:600}.rv-modal-backdrop{position:fixed;inset:0;background:#00000073;display:flex;align-items:center;justify-content:center;z-index:1000;padding:1rem;opacity:0;transition:opacity .2s ease}.rv-modal-backdrop.rv-modal-visible{opacity:1}.rv-modal-dialog{background:var(--color-bg-panel, #ffffff);border-radius:var(--radius-lg, 12px);padding:2rem;max-width:420px;width:100%;box-shadow:var(--shadow-lg, rgba(0, 0, 0, .32) 0px 8px 24px);transform:scale(.95) translateY(-8px);opacity:0;transition:transform .2s ease,opacity .2s ease;font-family:Host Grotesk,system-ui,sans-serif}.rv-modal-backdrop.rv-modal-visible .rv-modal-dialog{transform:scale(1) translateY(0);opacity:1}.rv-modal-title{font-size:1.15rem;font-weight:700;color:var(--color-text-primary, #111111);margin:0 0 .75rem}.rv-modal-body{font-size:.9rem;color:var(--color-text-secondary, #444444);margin:0 0 1.5rem;line-height:1.55}.rv-modal-actions{display:flex;justify-content:flex-end;gap:.75rem}.rv-modal-btn{display:inline-flex;align-items:center;justify-content:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;border-radius:var(--radius-md, 8px);cursor:pointer;border:none;font-family:inherit;transition:background .15s,color .15s}.rv-modal-btn-ghost{background:transparent;color:var(--color-text-secondary, #444444);border:1px solid var(--color-border-subtle, #d1d5db)}.rv-modal-btn-ghost:hover{background:var(--color-bg-surface, #f0f0f0)}.rv-modal-btn-danger{background:var(--color-error, #ef4444);color:#fff}.rv-modal-btn-danger:hover{background:var(--color-error-hover, #dc2626)}
|
package/dist/ui-core-react.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
function
|
|
5
|
-
open:
|
|
6
|
-
title:
|
|
7
|
-
message:
|
|
8
|
-
confirmLabel:
|
|
9
|
-
loading:
|
|
10
|
-
onConfirm:
|
|
1
|
+
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as _, useEffect as N, useMemo as m, useCallback as R } from "react";
|
|
3
|
+
import { createPortal as I } from "react-dom";
|
|
4
|
+
function K({
|
|
5
|
+
open: n,
|
|
6
|
+
title: o = "Are you sure?",
|
|
7
|
+
message: l = "This action cannot be undone.",
|
|
8
|
+
confirmLabel: s = "Confirm",
|
|
9
|
+
loading: c = !1,
|
|
10
|
+
onConfirm: p,
|
|
11
11
|
onCancel: v
|
|
12
12
|
}) {
|
|
13
|
-
const [
|
|
14
|
-
return
|
|
15
|
-
if (
|
|
16
|
-
|
|
13
|
+
const [g, C] = f(!1), [w, t] = f(!1), a = _(`rv-confirm-${Math.random().toString(36).slice(2)}`).current;
|
|
14
|
+
return N(() => {
|
|
15
|
+
if (n)
|
|
16
|
+
t(!0), requestAnimationFrame(() => C(!0));
|
|
17
17
|
else {
|
|
18
18
|
C(!1);
|
|
19
|
-
const
|
|
20
|
-
return () => clearTimeout(
|
|
19
|
+
const d = setTimeout(() => t(!1), 200);
|
|
20
|
+
return () => clearTimeout(d);
|
|
21
21
|
}
|
|
22
|
-
}, [
|
|
22
|
+
}, [n]), w ? I(
|
|
23
23
|
/* @__PURE__ */ e(
|
|
24
24
|
"div",
|
|
25
25
|
{
|
|
26
|
-
className: `rv-modal-backdrop${
|
|
27
|
-
onClick: (
|
|
28
|
-
|
|
26
|
+
className: `rv-modal-backdrop${g ? " rv-modal-visible" : ""}`,
|
|
27
|
+
onClick: (d) => {
|
|
28
|
+
d.target === d.currentTarget && v();
|
|
29
29
|
},
|
|
30
|
-
children: /* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */ e("h2", { id:
|
|
32
|
-
/* @__PURE__ */ e("p", { className: "rv-modal-body", children:
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */ e("button", { className: "rv-modal-btn rv-modal-btn-ghost", onClick: v, disabled:
|
|
35
|
-
/* @__PURE__ */ e("button", { className: "rv-modal-btn rv-modal-btn-danger", onClick:
|
|
30
|
+
children: /* @__PURE__ */ i("div", { className: "rv-modal-dialog", role: "dialog", "aria-modal": "true", "aria-labelledby": a, children: [
|
|
31
|
+
/* @__PURE__ */ e("h2", { id: a, className: "rv-modal-title", children: o }),
|
|
32
|
+
/* @__PURE__ */ e("p", { className: "rv-modal-body", children: l }),
|
|
33
|
+
/* @__PURE__ */ i("div", { className: "rv-modal-actions", children: [
|
|
34
|
+
/* @__PURE__ */ e("button", { className: "rv-modal-btn rv-modal-btn-ghost", onClick: v, disabled: c, children: "Cancel" }),
|
|
35
|
+
/* @__PURE__ */ e("button", { className: "rv-modal-btn rv-modal-btn-danger", onClick: p, disabled: c, children: s })
|
|
36
36
|
] })
|
|
37
37
|
] })
|
|
38
38
|
}
|
|
@@ -40,28 +40,28 @@ function H({
|
|
|
40
40
|
document.body
|
|
41
41
|
) : null;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const [
|
|
45
|
-
const
|
|
46
|
-
for (const
|
|
47
|
-
const
|
|
48
|
-
|
|
43
|
+
function z({ value: n, venues: o, onChange: l }) {
|
|
44
|
+
const [s, c] = f(!1), p = _(null), v = m(() => o.find((t) => t.id === n), [o, n]), g = m(() => {
|
|
45
|
+
const t = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const a of o) {
|
|
47
|
+
const d = a.workspace?.id ?? "__none__", k = a.workspace?.name ?? "";
|
|
48
|
+
t.has(d) || t.set(d, { workspaceName: k, venues: [] }), t.get(d).venues.push(a);
|
|
49
49
|
}
|
|
50
|
-
return [...
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
if (!
|
|
54
|
-
function
|
|
55
|
-
|
|
50
|
+
return [...t.values()];
|
|
51
|
+
}, [o]), C = g.length > 1;
|
|
52
|
+
N(() => {
|
|
53
|
+
if (!s) return;
|
|
54
|
+
function t(a) {
|
|
55
|
+
p.current && !p.current.contains(a.target) && c(!1);
|
|
56
56
|
}
|
|
57
|
-
return document.addEventListener("mousedown",
|
|
58
|
-
}, [
|
|
59
|
-
function
|
|
60
|
-
t
|
|
57
|
+
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
58
|
+
}, [s]);
|
|
59
|
+
function w(t) {
|
|
60
|
+
l(t), c(!1);
|
|
61
61
|
}
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
62
|
+
return /* @__PURE__ */ i("div", { ref: p, className: "rv-venue-switcher", children: [
|
|
63
|
+
/* @__PURE__ */ i("button", { className: `rv-vs-trigger${s ? " rv-open" : ""}`, onClick: () => c((t) => !t), children: [
|
|
64
|
+
/* @__PURE__ */ i("span", { className: "rv-vs-label", children: [
|
|
65
65
|
/* @__PURE__ */ e("span", { className: "rv-vs-venue", children: v?.name ?? "Select venue" }),
|
|
66
66
|
v?.workspace && C && /* @__PURE__ */ e("span", { className: "rv-vs-workspace", children: v.workspace.name })
|
|
67
67
|
] }),
|
|
@@ -82,61 +82,108 @@ function B({ value: l, venues: a, onChange: t }) {
|
|
|
82
82
|
}
|
|
83
83
|
)
|
|
84
84
|
] }),
|
|
85
|
-
|
|
86
|
-
C && /* @__PURE__ */ e("div", { className: "rv-vs-workspace-header", children:
|
|
87
|
-
|
|
85
|
+
s && /* @__PURE__ */ e("div", { className: "rv-vs-dropdown", children: g.map((t) => /* @__PURE__ */ i("div", { children: [
|
|
86
|
+
C && /* @__PURE__ */ e("div", { className: "rv-vs-workspace-header", children: t.workspaceName }),
|
|
87
|
+
t.venues.map((a) => /* @__PURE__ */ e(
|
|
88
88
|
"button",
|
|
89
89
|
{
|
|
90
|
-
className: `rv-vs-venue-option${
|
|
91
|
-
onClick: () =>
|
|
92
|
-
children:
|
|
90
|
+
className: `rv-vs-venue-option${a.id === n ? " rv-active" : ""}`,
|
|
91
|
+
onClick: () => w(a.id),
|
|
92
|
+
children: a.name
|
|
93
93
|
},
|
|
94
|
-
|
|
94
|
+
a.id
|
|
95
95
|
))
|
|
96
|
-
] },
|
|
96
|
+
] }, t.workspaceName)) })
|
|
97
97
|
] });
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
const $ = "rv-theme";
|
|
100
|
+
function D() {
|
|
101
|
+
return document.cookie.split("; ").find((l) => l.startsWith(`${$}=`))?.split("=")[1] === "dark" ? "dark" : "light";
|
|
102
|
+
}
|
|
103
|
+
function G(n) {
|
|
104
|
+
const o = [`${$}=${n}`, "path=/", "max-age=31536000", "SameSite=Lax"];
|
|
105
|
+
document.cookie = o.join("; ");
|
|
106
|
+
}
|
|
107
|
+
function U(n) {
|
|
108
|
+
document.documentElement.setAttribute("data-theme", n);
|
|
109
|
+
}
|
|
110
|
+
function q() {
|
|
111
|
+
const [n, o] = f(() => D());
|
|
112
|
+
N(() => {
|
|
113
|
+
U(n);
|
|
114
|
+
}, [n]);
|
|
115
|
+
const l = R(() => {
|
|
116
|
+
o((s) => {
|
|
117
|
+
const c = s === "light" ? "dark" : "light";
|
|
118
|
+
return G(c), c;
|
|
119
|
+
});
|
|
120
|
+
}, []);
|
|
121
|
+
return { theme: n, toggleTheme: l };
|
|
122
|
+
}
|
|
123
|
+
function F() {
|
|
124
|
+
const n = window;
|
|
125
|
+
if (n.__rvHistoryPatched) return;
|
|
126
|
+
n.__rvHistoryPatched = !0;
|
|
127
|
+
const o = history.pushState.bind(history);
|
|
128
|
+
history.pushState = (...s) => {
|
|
129
|
+
o(...s), window.dispatchEvent(new Event("locationchange"));
|
|
130
|
+
};
|
|
131
|
+
const l = history.replaceState.bind(history);
|
|
132
|
+
history.replaceState = (...s) => {
|
|
133
|
+
l(...s), window.dispatchEvent(new Event("locationchange"));
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const V = "rv_sidebar_collapsed", X = 3600 * 24 * 365;
|
|
137
|
+
function Y() {
|
|
138
|
+
const n = `${V}=`;
|
|
139
|
+
for (const o of document.cookie.split(";")) {
|
|
140
|
+
const l = o.trim();
|
|
141
|
+
if (l.startsWith(n)) return decodeURIComponent(l.slice(n.length)) === "true";
|
|
105
142
|
}
|
|
106
143
|
return !1;
|
|
107
144
|
}
|
|
108
|
-
function
|
|
109
|
-
const
|
|
110
|
-
document.cookie = `${
|
|
145
|
+
function J(n, o) {
|
|
146
|
+
const l = o ? `; Domain=${o}` : "";
|
|
147
|
+
document.cookie = `${V}=${n}; Path=/; Max-Age=${X}; SameSite=Lax${l}`;
|
|
111
148
|
}
|
|
112
|
-
function
|
|
113
|
-
user:
|
|
114
|
-
isAdmin:
|
|
115
|
-
venues:
|
|
116
|
-
activeVenueId:
|
|
117
|
-
navItems:
|
|
118
|
-
cookieDomain:
|
|
149
|
+
function r2({
|
|
150
|
+
user: n,
|
|
151
|
+
isAdmin: o,
|
|
152
|
+
venues: l,
|
|
153
|
+
activeVenueId: s,
|
|
154
|
+
navItems: c,
|
|
155
|
+
cookieDomain: p,
|
|
119
156
|
onSwitchVenue: v,
|
|
120
|
-
onLogout:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
157
|
+
onLogout: g,
|
|
158
|
+
accountSettingsUrl: C,
|
|
159
|
+
headerSlot: w,
|
|
160
|
+
sidebarPanel: t,
|
|
161
|
+
scrollable: a = !0,
|
|
162
|
+
children: d
|
|
125
163
|
}) {
|
|
126
|
-
const [
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
const { theme: k, toggleTheme: H } = q(), [h, W] = f(() => Y()), [A, y] = f(!1), [L, P] = f(() => window.location.href);
|
|
165
|
+
N(() => {
|
|
166
|
+
F();
|
|
167
|
+
function r() {
|
|
168
|
+
P(window.location.href);
|
|
169
|
+
}
|
|
170
|
+
return window.addEventListener("popstate", r), window.addEventListener("locationchange", r), () => {
|
|
171
|
+
window.removeEventListener("popstate", r), window.removeEventListener("locationchange", r);
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
function T() {
|
|
175
|
+
const r = !h;
|
|
176
|
+
W(r), J(r, p);
|
|
130
177
|
}
|
|
131
|
-
const
|
|
132
|
-
const r =
|
|
133
|
-
return
|
|
134
|
-
}, [
|
|
135
|
-
return /* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
!
|
|
139
|
-
/* @__PURE__ */
|
|
178
|
+
const x = m(() => l.find((r) => r.id === s), [l, s]), M = x?.workspace?.name ?? "", Z = m(() => n?.email ? n.email.slice(0, 2).toUpperCase() : "?", [n?.email]), b = m(() => {
|
|
179
|
+
const r = x?.workspace?.id;
|
|
180
|
+
return c.filter((u) => u.hidden ? !1 : !!(!u.permission || o || n?.globalPermissions.includes(u.permission) || r && n?.workspacePermissions?.[r]?.includes(u.permission) || s && n?.venuePermissions?.[s]?.includes(u.permission)));
|
|
181
|
+
}, [c, o, n, x, s]), j = m(() => b.filter((r) => !r.pinned), [b]), S = m(() => b.filter((r) => r.pinned), [b]), E = m(() => c.filter((u) => u.url && L.startsWith(u.url)).sort((u, O) => O.url.length - u.url.length)[0]?.url ?? null, [c, L]), B = l.length > 0 || w !== void 0;
|
|
182
|
+
return /* @__PURE__ */ i("div", { className: "rv-app-shell", children: [
|
|
183
|
+
/* @__PURE__ */ i("aside", { className: `rv-sidebar${h ? " rv-collapsed" : ""}`, children: [
|
|
184
|
+
/* @__PURE__ */ i("div", { className: "rv-sidebar-top", children: [
|
|
185
|
+
!h && /* @__PURE__ */ i("div", { className: "rv-sidebar-brand", children: [
|
|
186
|
+
/* @__PURE__ */ i(
|
|
140
187
|
"svg",
|
|
141
188
|
{
|
|
142
189
|
className: "rv-sidebar-logo",
|
|
@@ -145,7 +192,7 @@ function T({
|
|
|
145
192
|
xmlns: "http://www.w3.org/2000/svg",
|
|
146
193
|
"aria-label": "Re-venue",
|
|
147
194
|
children: [
|
|
148
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ i("g", { clipPath: "url(#rv-logo-clip)", children: [
|
|
149
196
|
/* @__PURE__ */ e("path", { d: "M24.946 0.60506C24.6367 1.30638 24.2289 3.01155 24.2289 7.32948V8.73212L23.5117 9.22717C22.3867 8.12706 20.2212 7.61826 18.4775 7.61826C11.9105 7.61826 8.0013 13.6414 8.0013 21.3696V35.0247C8.0013 41.0479 8.09974 45.6683 8.4091 48.9824C6.86228 48.6799 5.54045 48.4736 4.303 48.4736C2.96711 48.4736 1.63122 48.6799 -0.0140381 48.9824C0.295326 46.2734 0.39376 42.9593 0.39376 38.2426V15.8691C0.407822 11.5512 0.309388 4.0154 2.39182e-05 1.00385C1.95464 1.40264 3.0796 1.4989 4.31706 1.4989C5.55452 1.4989 6.89041 1.29263 8.42316 1.00385L8.01537 6.0231C7.91693 7.12321 7.91693 8.73212 7.91693 10.7398L8.12786 10.8361C12.1215 3.61661 16.8322 0 21.768 0C23.0055 0 23.7226 0.206271 24.946 0.60506Z", fill: "currentColor" }),
|
|
150
197
|
/* @__PURE__ */ e("path", { d: "M74.7396 20.5858V22.291L74.5287 24.3949C68.3695 24.2987 61.6901 24.0924 54.4059 24.0924C49.4842 24.0924 44.3376 24.2987 39.1065 24.3949C39.0081 24.9037 39.0081 26.3064 39.0081 26.6089C39.0081 39.0539 46.4047 45.7921 56.6699 45.7921C61.901 45.7921 68.1727 42.9868 72.1663 38.6689L72.6866 38.9714L72.0678 43.8944C66.7243 47.9098 60.2557 50.0137 54.8137 50.0137C40.5408 50.0137 29.9662 40.0715 29.9662 26.3201C29.9802 9.84598 38.6003 0 53.4919 0C66.6399 0 74.7396 8.12706 74.7396 20.5858ZM52.6623 20.8883C56.2621 20.8883 62.3088 20.5858 66.3165 20.5858C66.218 9.03465 61.9994 3.21782 53.6888 3.21782C45.3781 3.21782 40.4424 9.74972 39.3174 20.5858C43.3251 20.5858 51.017 20.8883 52.6623 20.8883Z", fill: "currentColor" }),
|
|
151
198
|
/* @__PURE__ */ e("path", { d: "M164.989 22.9923V27.709H82.8533V22.9923H164.989Z", fill: "currentColor" }),
|
|
@@ -159,88 +206,113 @@ function T({
|
|
|
159
206
|
]
|
|
160
207
|
}
|
|
161
208
|
),
|
|
162
|
-
|
|
209
|
+
M && /* @__PURE__ */ e("span", { className: "rv-sidebar-workspace", children: M })
|
|
163
210
|
] }),
|
|
164
211
|
/* @__PURE__ */ e(
|
|
165
212
|
"button",
|
|
166
213
|
{
|
|
167
214
|
className: "rv-collapse-toggle",
|
|
168
|
-
title:
|
|
169
|
-
onClick:
|
|
170
|
-
children:
|
|
215
|
+
title: h ? "Expand sidebar" : "Collapse sidebar",
|
|
216
|
+
onClick: T,
|
|
217
|
+
children: h ? /* @__PURE__ */ i("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
171
218
|
/* @__PURE__ */ e("polyline", { points: "13 17 18 12 13 7" }),
|
|
172
219
|
/* @__PURE__ */ e("polyline", { points: "6 17 11 12 6 7" })
|
|
173
|
-
] }) : /* @__PURE__ */
|
|
220
|
+
] }) : /* @__PURE__ */ i("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
174
221
|
/* @__PURE__ */ e("polyline", { points: "11 17 6 12 11 7" }),
|
|
175
222
|
/* @__PURE__ */ e("polyline", { points: "18 17 13 12 18 7" })
|
|
176
223
|
] })
|
|
177
224
|
}
|
|
178
225
|
)
|
|
179
226
|
] }),
|
|
180
|
-
|
|
181
|
-
/* @__PURE__ */ e("nav", { className: "rv-sidebar-nav", children:
|
|
227
|
+
t && /* @__PURE__ */ e("div", { className: "rv-sidebar-panel", children: t }),
|
|
228
|
+
/* @__PURE__ */ e("nav", { className: "rv-sidebar-nav", children: j.map((r) => /* @__PURE__ */ i(
|
|
182
229
|
"a",
|
|
183
230
|
{
|
|
184
231
|
href: r.url,
|
|
185
|
-
className: `rv-nav-item${r.
|
|
186
|
-
title:
|
|
232
|
+
className: `rv-nav-item${r.url === E ? " rv-active" : ""}`,
|
|
233
|
+
title: h ? r.label : void 0,
|
|
187
234
|
children: [
|
|
188
235
|
/* @__PURE__ */ e("span", { className: "rv-nav-icon", dangerouslySetInnerHTML: { __html: r.icon } }),
|
|
189
|
-
!
|
|
236
|
+
!h && /* @__PURE__ */ e("span", { className: "rv-nav-label", children: r.label })
|
|
190
237
|
]
|
|
191
238
|
},
|
|
192
239
|
r.url
|
|
193
240
|
)) }),
|
|
194
|
-
|
|
241
|
+
S.length > 0 && /* @__PURE__ */ e("nav", { className: "rv-sidebar-pinned", children: S.map((r) => /* @__PURE__ */ i(
|
|
195
242
|
"a",
|
|
196
243
|
{
|
|
197
244
|
href: r.url,
|
|
198
|
-
className: `rv-nav-item${r.
|
|
199
|
-
title:
|
|
245
|
+
className: `rv-nav-item${r.url === E ? " rv-active" : ""}`,
|
|
246
|
+
title: h ? r.label : void 0,
|
|
200
247
|
children: [
|
|
201
248
|
/* @__PURE__ */ e("span", { className: "rv-nav-icon", dangerouslySetInnerHTML: { __html: r.icon } }),
|
|
202
|
-
!
|
|
249
|
+
!h && /* @__PURE__ */ e("span", { className: "rv-nav-label", children: r.label })
|
|
203
250
|
]
|
|
204
251
|
},
|
|
205
252
|
r.url
|
|
206
253
|
)) }),
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */ e("div", { className: "rv-user-avatar", children:
|
|
209
|
-
!
|
|
210
|
-
/* @__PURE__ */ e(
|
|
254
|
+
/* @__PURE__ */ i("div", { className: "rv-sidebar-user", children: [
|
|
255
|
+
/* @__PURE__ */ e("div", { className: "rv-user-avatar", children: Z }),
|
|
256
|
+
!h && /* @__PURE__ */ e("div", { className: "rv-user-info", children: /* @__PURE__ */ e("span", { className: "rv-user-email", title: n?.email ?? "", children: n?.email }) }),
|
|
257
|
+
/* @__PURE__ */ e(
|
|
258
|
+
"button",
|
|
259
|
+
{
|
|
260
|
+
className: "rv-theme-toggle-btn",
|
|
261
|
+
title: `Switch to ${k === "light" ? "dark" : "light"} mode`,
|
|
262
|
+
"aria-label": `Switch to ${k === "light" ? "dark" : "light"} mode`,
|
|
263
|
+
onClick: H,
|
|
264
|
+
children: k === "light" ? /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) }) : /* @__PURE__ */ i("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
265
|
+
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "5" }),
|
|
266
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "1", x2: "12", y2: "3" }),
|
|
267
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "21", x2: "12", y2: "23" }),
|
|
268
|
+
/* @__PURE__ */ e("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }),
|
|
269
|
+
/* @__PURE__ */ e("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }),
|
|
270
|
+
/* @__PURE__ */ e("line", { x1: "1", y1: "12", x2: "3", y2: "12" }),
|
|
271
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "12", x2: "23", y2: "12" }),
|
|
272
|
+
/* @__PURE__ */ e("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }),
|
|
273
|
+
/* @__PURE__ */ e("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })
|
|
274
|
+
] })
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
C && /* @__PURE__ */ e("a", { className: "rv-account-settings-btn", href: C, title: "Account settings", children: /* @__PURE__ */ i("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
278
|
+
/* @__PURE__ */ e("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),
|
|
279
|
+
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "3" })
|
|
280
|
+
] }) }),
|
|
281
|
+
/* @__PURE__ */ e("button", { className: "rv-logout-btn", title: "Sign out", onClick: () => y(!0), children: /* @__PURE__ */ i("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
211
282
|
/* @__PURE__ */ e("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
|
|
212
283
|
/* @__PURE__ */ e("polyline", { points: "16 17 21 12 16 7" }),
|
|
213
284
|
/* @__PURE__ */ e("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
|
|
214
285
|
] }) })
|
|
215
286
|
] })
|
|
216
287
|
] }),
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
|
|
219
|
-
|
|
288
|
+
/* @__PURE__ */ i("div", { className: "rv-shell-body", children: [
|
|
289
|
+
B && /* @__PURE__ */ e("header", { className: "rv-shell-header", children: w !== void 0 ? w : /* @__PURE__ */ e(
|
|
290
|
+
z,
|
|
220
291
|
{
|
|
221
|
-
value:
|
|
222
|
-
venues:
|
|
292
|
+
value: s ?? "",
|
|
293
|
+
venues: l,
|
|
223
294
|
onChange: v ?? (() => {
|
|
224
295
|
})
|
|
225
296
|
}
|
|
226
297
|
) }),
|
|
227
|
-
/* @__PURE__ */ e("main", { className: `rv-shell-content${
|
|
298
|
+
/* @__PURE__ */ e("main", { className: `rv-shell-content${a ? " rv-shell-content--scroll" : " rv-shell-content--fill"}`, children: d })
|
|
228
299
|
] }),
|
|
229
300
|
/* @__PURE__ */ e(
|
|
230
|
-
|
|
301
|
+
K,
|
|
231
302
|
{
|
|
232
|
-
open:
|
|
303
|
+
open: A,
|
|
233
304
|
title: "Sign out",
|
|
234
305
|
message: "Are you sure you want to sign out?",
|
|
235
306
|
confirmLabel: "Sign out",
|
|
236
|
-
onConfirm:
|
|
237
|
-
onCancel: () =>
|
|
307
|
+
onConfirm: g,
|
|
308
|
+
onCancel: () => y(!1)
|
|
238
309
|
}
|
|
239
310
|
)
|
|
240
311
|
] });
|
|
241
312
|
}
|
|
242
313
|
export {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
314
|
+
r2 as AppShell,
|
|
315
|
+
K as ConfirmModal,
|
|
316
|
+
z as VenueSwitcher,
|
|
317
|
+
q as useTheme
|
|
246
318
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.ReVenueUiCoreReact={},d.jsxRuntime,d.React,d.ReactDOM))})(this,(function(d,e,n,x){"use strict";function N({open:o,title:i="Are you sure?",message:t="This action cannot be undone.",confirmLabel:c="Confirm",loading:C=!1,onConfirm:p,onCancel:h}){const[f,v]=n.useState(!1),[u,s]=n.useState(!1),a=n.useRef(`rv-confirm-${Math.random().toString(36).slice(2)}`).current;return n.useEffect(()=>{if(o)s(!0),requestAnimationFrame(()=>v(!0));else{v(!1);const l=setTimeout(()=>s(!1),200);return()=>clearTimeout(l)}},[o]),u?x.createPortal(e.jsx("div",{className:`rv-modal-backdrop${f?" rv-modal-visible":""}`,onClick:l=>{l.target===l.currentTarget&&h()},children:e.jsxs("div",{className:"rv-modal-dialog",role:"dialog","aria-modal":"true","aria-labelledby":a,children:[e.jsx("h2",{id:a,className:"rv-modal-title",children:i}),e.jsx("p",{className:"rv-modal-body",children:t}),e.jsxs("div",{className:"rv-modal-actions",children:[e.jsx("button",{className:"rv-modal-btn rv-modal-btn-ghost",onClick:h,disabled:C,children:"Cancel"}),e.jsx("button",{className:"rv-modal-btn rv-modal-btn-danger",onClick:p,disabled:C,children:c})]})]})}),document.body):null}function k({value:o,venues:i,onChange:t}){const[c,C]=n.useState(!1),p=n.useRef(null),h=n.useMemo(()=>i.find(s=>s.id===o),[i,o]),f=n.useMemo(()=>{const s=new Map;for(const a of i){const l=a.workspace?.id??"__none__",g=a.workspace?.name??"";s.has(l)||s.set(l,{workspaceName:g,venues:[]}),s.get(l).venues.push(a)}return[...s.values()]},[i]),v=f.length>1;n.useEffect(()=>{if(!c)return;function s(a){p.current&&!p.current.contains(a.target)&&C(!1)}return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[c]);function u(s){t(s),C(!1)}return e.jsxs("div",{ref:p,className:"rv-venue-switcher",children:[e.jsxs("button",{className:`rv-vs-trigger${c?" rv-open":""}`,onClick:()=>C(s=>!s),children:[e.jsxs("span",{className:"rv-vs-label",children:[e.jsx("span",{className:"rv-vs-venue",children:h?.name??"Select venue"}),h?.workspace&&v&&e.jsx("span",{className:"rv-vs-workspace",children:h.workspace.name})]}),e.jsx("svg",{className:"rv-vs-chevron",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),c&&e.jsx("div",{className:"rv-vs-dropdown",children:f.map(s=>e.jsxs("div",{children:[v&&e.jsx("div",{className:"rv-vs-workspace-header",children:s.workspaceName}),s.venues.map(a=>e.jsx("button",{className:`rv-vs-venue-option${a.id===o?" rv-active":""}`,onClick:()=>u(a.id),children:a.name},a.id))]},s.workspaceName))})]})}const L="rv_sidebar_collapsed",V=3600*24*365;function _(){const o=`${L}=`;for(const i of document.cookie.split(";")){const t=i.trim();if(t.startsWith(o))return decodeURIComponent(t.slice(o.length))==="true"}return!1}function $(o,i){const t=i?`; Domain=${i}`:"";document.cookie=`${L}=${o}; Path=/; Max-Age=${V}; SameSite=Lax${t}`}function Z({user:o,isAdmin:i,venues:t,activeVenueId:c,navItems:C,cookieDomain:p,onSwitchVenue:h,onLogout:f,headerSlot:v,sidebarPanel:u,scrollable:s=!0,children:a}){const[l,g]=n.useState(()=>_()),[j,M]=n.useState(!1);function E(){const r=!l;g(r),$(r,p)}const b=n.useMemo(()=>t.find(r=>r.id===c),[t,c]),S=b?.workspace?.name??"",A=n.useMemo(()=>o?.email?o.email.slice(0,2).toUpperCase():"?",[o?.email]),m=n.useMemo(()=>{const r=b?.workspace?.id;return C.filter(w=>w.hidden?!1:!!(!w.permission||i||o?.globalPermissions.includes(w.permission)||r&&o?.workspacePermissions?.[r]?.includes(w.permission)||c&&o?.venuePermissions?.[c]?.includes(w.permission)))},[C,i,o,b,c]),T=n.useMemo(()=>m.filter(r=>!r.pinned),[m]),y=n.useMemo(()=>m.filter(r=>r.pinned),[m]),H=t.length>0||v!==void 0;return e.jsxs("div",{className:"rv-app-shell",children:[e.jsxs("aside",{className:`rv-sidebar${l?" rv-collapsed":""}`,children:[e.jsxs("div",{className:"rv-sidebar-top",children:[!l&&e.jsxs("div",{className:"rv-sidebar-brand",children:[e.jsxs("svg",{className:"rv-sidebar-logo",viewBox:"0 0 429 50",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-label":"Re-venue",children:[e.jsxs("g",{clipPath:"url(#rv-logo-clip)",children:[e.jsx("path",{d:"M24.946 0.60506C24.6367 1.30638 24.2289 3.01155 24.2289 7.32948V8.73212L23.5117 9.22717C22.3867 8.12706 20.2212 7.61826 18.4775 7.61826C11.9105 7.61826 8.0013 13.6414 8.0013 21.3696V35.0247C8.0013 41.0479 8.09974 45.6683 8.4091 48.9824C6.86228 48.6799 5.54045 48.4736 4.303 48.4736C2.96711 48.4736 1.63122 48.6799 -0.0140381 48.9824C0.295326 46.2734 0.39376 42.9593 0.39376 38.2426V15.8691C0.407822 11.5512 0.309388 4.0154 2.39182e-05 1.00385C1.95464 1.40264 3.0796 1.4989 4.31706 1.4989C5.55452 1.4989 6.89041 1.29263 8.42316 1.00385L8.01537 6.0231C7.91693 7.12321 7.91693 8.73212 7.91693 10.7398L8.12786 10.8361C12.1215 3.61661 16.8322 0 21.768 0C23.0055 0 23.7226 0.206271 24.946 0.60506Z",fill:"currentColor"}),e.jsx("path",{d:"M74.7396 20.5858V22.291L74.5287 24.3949C68.3695 24.2987 61.6901 24.0924 54.4059 24.0924C49.4842 24.0924 44.3376 24.2987 39.1065 24.3949C39.0081 24.9037 39.0081 26.3064 39.0081 26.6089C39.0081 39.0539 46.4047 45.7921 56.6699 45.7921C61.901 45.7921 68.1727 42.9868 72.1663 38.6689L72.6866 38.9714L72.0678 43.8944C66.7243 47.9098 60.2557 50.0137 54.8137 50.0137C40.5408 50.0137 29.9662 40.0715 29.9662 26.3201C29.9802 9.84598 38.6003 0 53.4919 0C66.6399 0 74.7396 8.12706 74.7396 20.5858ZM52.6623 20.8883C56.2621 20.8883 62.3088 20.5858 66.3165 20.5858C66.218 9.03465 61.9994 3.21782 53.6888 3.21782C45.3781 3.21782 40.4424 9.74972 39.3174 20.5858C43.3251 20.5858 51.017 20.8883 52.6623 20.8883Z",fill:"currentColor"}),e.jsx("path",{d:"M164.989 22.9923V27.709H82.8533V22.9923H164.989Z",fill:"currentColor"}),e.jsx("path",{d:"M172.274 1.51265C173.82 1.51265 175.142 1.30638 176.788 1.0176C180.992 14.1639 185.928 26.8152 192.087 40.1815C195.687 32.852 198.148 26.8289 207.794 1.0176C208.821 1.32013 209.847 1.51265 210.972 1.51265C212.21 1.51265 213.025 1.30638 214.15 1.0176L203.477 24.615C199.779 32.9483 196.502 40.9791 193.521 49.0099C192.495 48.7074 191.468 48.5011 190.343 48.5011C189.106 48.5011 188.6 48.5974 187.053 49.0099C180.486 32.5495 174.636 17.1755 167.141 1.0176C169.292 1.41639 170.741 1.51265 172.274 1.51265Z",fill:"currentColor"}),e.jsx("path",{d:"M263.452 20.5858V22.291L263.241 24.3949C257.082 24.2987 250.402 24.0924 243.118 24.0924C238.196 24.0924 233.05 24.2987 227.819 24.3949C227.72 24.9037 227.72 26.3064 227.72 26.6089C227.72 39.0539 235.117 45.7921 245.382 45.7921C250.613 45.7921 256.885 42.9868 260.878 38.6689L261.399 38.9714L260.78 43.8944C255.436 47.9098 248.968 50.0138 243.526 50.0138C229.253 50.0138 218.678 40.0715 218.678 26.3201C218.678 9.85973 227.298 0.0137513 242.19 0.0137513C255.338 0.0137513 263.438 8.14081 263.438 20.5996L263.452 20.5858ZM241.374 20.8883C244.974 20.8883 251.021 20.5858 255.029 20.5858C254.93 9.03465 250.711 3.21782 242.401 3.21782C234.09 3.21782 229.154 9.74972 228.029 20.5858C232.037 20.5858 239.729 20.8883 241.374 20.8883Z",fill:"currentColor"}),e.jsx("path",{d:"M315.706 17.7668C315.706 23.0886 315.298 28.9054 315.298 36.5374C315.298 45.3795 315.509 47.181 315.509 48.9824C313.765 48.5836 312.528 48.4736 311.192 48.4736C309.856 48.4736 308.619 48.5699 306.988 48.9824C306.988 43.2618 307.705 34.2272 307.705 27.6953V19.967C307.705 11.6337 303.908 5.21177 296.413 5.21177C287.371 5.21177 282.66 10.8361 282.66 21.2734V33.3196C282.66 37.6375 282.97 44.4582 283.476 48.9824C281.831 48.6799 280.396 48.4736 278.85 48.4736C277.303 48.4736 275.868 48.6799 274.223 48.9824C275.039 42.6568 275.039 35.3273 275.039 31.3119V17.753C275.039 11.7299 274.729 6.20187 274.223 0.990099C275.967 1.38889 277.514 1.48515 278.85 1.48515C279.876 1.48515 281.212 1.27888 282.956 0.990099C282.857 2.69527 282.646 6.61441 282.646 9.0209H282.857C286.654 3.30033 291.787 -0.0137513 299.183 -0.0137513C309.448 -0.0137513 315.72 5.70682 315.72 17.753L315.706 17.7668Z",fill:"currentColor"}),e.jsx("path",{d:"M331.413 1.00385C333.157 1.30638 334.591 1.4989 335.73 1.4989C336.968 1.4989 338.304 1.29263 339.935 1.00385C339.218 9.43344 338.908 19.6782 338.908 28.9191C338.908 31.4356 338.908 37.6513 341.889 40.7728C343.844 43.0831 346.924 44.7882 350.931 44.7882C356.584 44.7882 359.861 42.3817 361.815 39.2602C364.276 35.2448 364.487 32.2332 364.487 21.3834C364.487 11.2486 364.389 3.10781 364.276 1.00385C366.02 1.40264 367.257 1.4989 368.593 1.4989C370.14 1.4989 371.265 1.40264 372.798 1.00385C372.39 7.42574 372.081 17.368 372.081 31.1194C372.081 38.8476 372.179 44.2657 372.488 48.9961C370.942 48.6936 369.62 48.4873 368.481 48.4873C367.342 48.4873 366.02 48.6936 364.473 48.9961C364.571 47.6898 364.684 45.4758 364.684 43.9769V40.3603H364.473C360.873 46.7822 355.023 50 348.456 50C337.783 50 331.315 44.3757 331.315 33.1271C331.315 29.0154 331.624 19.7745 331.624 16.5567C331.624 11.3311 331.526 6.21562 331.413 0.990099V1.00385Z",fill:"currentColor"}),e.jsx("path",{d:"M428.947 20.5858V22.291L428.736 24.3949C422.577 24.2987 415.898 24.0924 408.614 24.0924C403.692 24.0924 398.545 24.2987 393.314 24.3949C393.216 24.9037 393.216 26.3064 393.216 26.6089C393.216 39.0539 400.612 45.7921 410.878 45.7921C416.109 45.7921 422.38 42.9868 426.374 38.6689L426.894 38.9714L426.276 43.8944C420.932 47.9098 414.463 50.0138 409.021 50.0138C394.749 50.0138 384.174 40.0715 384.174 26.3201C384.174 9.85973 392.794 0.0137513 407.686 0.0137513C420.834 0.0137513 428.933 8.14081 428.933 20.5996L428.947 20.5858ZM406.87 20.8883C410.47 20.8883 416.517 20.5858 420.524 20.5858C420.426 9.03465 416.207 3.21782 407.897 3.21782C399.586 3.21782 394.65 9.74972 393.525 20.5858C397.533 20.5858 405.225 20.8883 406.87 20.8883Z",fill:"currentColor"})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"rv-logo-clip",children:e.jsx("rect",{width:"428.947",height:"50",fill:"white"})})})]}),S&&e.jsx("span",{className:"rv-sidebar-workspace",children:S})]}),e.jsx("button",{className:"rv-collapse-toggle",title:l?"Expand sidebar":"Collapse sidebar",onClick:E,children:l?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"13 17 18 12 13 7"}),e.jsx("polyline",{points:"6 17 11 12 6 7"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"11 17 6 12 11 7"}),e.jsx("polyline",{points:"18 17 13 12 18 7"})]})})]}),u&&e.jsx("div",{className:"rv-sidebar-panel",children:u}),e.jsx("nav",{className:"rv-sidebar-nav",children:T.map(r=>e.jsxs("a",{href:r.url,className:`rv-nav-item${r.active?" rv-active":""}`,title:l?r.label:void 0,children:[e.jsx("span",{className:"rv-nav-icon",dangerouslySetInnerHTML:{__html:r.icon}}),!l&&e.jsx("span",{className:"rv-nav-label",children:r.label})]},r.url))}),y.length>0&&e.jsx("nav",{className:"rv-sidebar-pinned",children:y.map(r=>e.jsxs("a",{href:r.url,className:`rv-nav-item${r.active?" rv-active":""}`,title:l?r.label:void 0,children:[e.jsx("span",{className:"rv-nav-icon",dangerouslySetInnerHTML:{__html:r.icon}}),!l&&e.jsx("span",{className:"rv-nav-label",children:r.label})]},r.url))}),e.jsxs("div",{className:"rv-sidebar-user",children:[e.jsx("div",{className:"rv-user-avatar",children:A}),!l&&e.jsx("div",{className:"rv-user-info",children:e.jsx("span",{className:"rv-user-email",title:o?.email??"",children:o?.email})}),e.jsx("button",{className:"rv-logout-btn",title:"Sign out",onClick:()=>M(!0),children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("polyline",{points:"16 17 21 12 16 7"}),e.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})]}),e.jsxs("div",{className:"rv-shell-body",children:[H&&e.jsx("header",{className:"rv-shell-header",children:v!==void 0?v:e.jsx(k,{value:c??"",venues:t,onChange:h??(()=>{})})}),e.jsx("main",{className:`rv-shell-content${s?" rv-shell-content--scroll":" rv-shell-content--fill"}`,children:a})]}),e.jsx(N,{open:j,title:"Sign out",message:"Are you sure you want to sign out?",confirmLabel:"Sign out",onConfirm:f,onCancel:()=>M(!1)})]})}d.AppShell=Z,d.ConfirmModal=N,d.VenueSwitcher=k,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.ReVenueUiCoreReact={},d.jsxRuntime,d.React,d.ReactDOM))})(this,(function(d,e,l,T){"use strict";function y({open:r,title:n="Are you sure?",message:t="This action cannot be undone.",confirmLabel:a="Confirm",loading:c=!1,onConfirm:u,onCancel:p}){const[g,f]=l.useState(!1),[w,s]=l.useState(!1),i=l.useRef(`rv-confirm-${Math.random().toString(36).slice(2)}`).current;return l.useEffect(()=>{if(r)s(!0),requestAnimationFrame(()=>f(!0));else{f(!1);const h=setTimeout(()=>s(!1),200);return()=>clearTimeout(h)}},[r]),w?T.createPortal(e.jsx("div",{className:`rv-modal-backdrop${g?" rv-modal-visible":""}`,onClick:h=>{h.target===h.currentTarget&&p()},children:e.jsxs("div",{className:"rv-modal-dialog",role:"dialog","aria-modal":"true","aria-labelledby":i,children:[e.jsx("h2",{id:i,className:"rv-modal-title",children:n}),e.jsx("p",{className:"rv-modal-body",children:t}),e.jsxs("div",{className:"rv-modal-actions",children:[e.jsx("button",{className:"rv-modal-btn rv-modal-btn-ghost",onClick:p,disabled:c,children:"Cancel"}),e.jsx("button",{className:"rv-modal-btn rv-modal-btn-danger",onClick:u,disabled:c,children:a})]})]})}),document.body):null}function N({value:r,venues:n,onChange:t}){const[a,c]=l.useState(!1),u=l.useRef(null),p=l.useMemo(()=>n.find(s=>s.id===r),[n,r]),g=l.useMemo(()=>{const s=new Map;for(const i of n){const h=i.workspace?.id??"__none__",k=i.workspace?.name??"";s.has(h)||s.set(h,{workspaceName:k,venues:[]}),s.get(h).venues.push(i)}return[...s.values()]},[n]),f=g.length>1;l.useEffect(()=>{if(!a)return;function s(i){u.current&&!u.current.contains(i.target)&&c(!1)}return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[a]);function w(s){t(s),c(!1)}return e.jsxs("div",{ref:u,className:"rv-venue-switcher",children:[e.jsxs("button",{className:`rv-vs-trigger${a?" rv-open":""}`,onClick:()=>c(s=>!s),children:[e.jsxs("span",{className:"rv-vs-label",children:[e.jsx("span",{className:"rv-vs-venue",children:p?.name??"Select venue"}),p?.workspace&&f&&e.jsx("span",{className:"rv-vs-workspace",children:p.workspace.name})]}),e.jsx("svg",{className:"rv-vs-chevron",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&e.jsx("div",{className:"rv-vs-dropdown",children:g.map(s=>e.jsxs("div",{children:[f&&e.jsx("div",{className:"rv-vs-workspace-header",children:s.workspaceName}),s.venues.map(i=>e.jsx("button",{className:`rv-vs-venue-option${i.id===r?" rv-active":""}`,onClick:()=>w(i.id),children:i.name},i.id))]},s.workspaceName))})]})}const x="rv-theme";function j(){return document.cookie.split("; ").find(t=>t.startsWith(`${x}=`))?.split("=")[1]==="dark"?"dark":"light"}function H(r){const n=[`${x}=${r}`,"path=/","max-age=31536000","SameSite=Lax"];document.cookie=n.join("; ")}function A(r){document.documentElement.setAttribute("data-theme",r)}function L(){const[r,n]=l.useState(()=>j());l.useEffect(()=>{A(r)},[r]);const t=l.useCallback(()=>{n(a=>{const c=a==="light"?"dark":"light";return H(c),c})},[]);return{theme:r,toggleTheme:t}}function P(){const r=window;if(r.__rvHistoryPatched)return;r.__rvHistoryPatched=!0;const n=history.pushState.bind(history);history.pushState=(...a)=>{n(...a),window.dispatchEvent(new Event("locationchange"))};const t=history.replaceState.bind(history);history.replaceState=(...a)=>{t(...a),window.dispatchEvent(new Event("locationchange"))}}const M="rv_sidebar_collapsed",W=3600*24*365;function Z(){const r=`${M}=`;for(const n of document.cookie.split(";")){const t=n.trim();if(t.startsWith(r))return decodeURIComponent(t.slice(r.length))==="true"}return!1}function B(r,n){const t=n?`; Domain=${n}`:"";document.cookie=`${M}=${r}; Path=/; Max-Age=${W}; SameSite=Lax${t}`}function O({user:r,isAdmin:n,venues:t,activeVenueId:a,navItems:c,cookieDomain:u,onSwitchVenue:p,onLogout:g,accountSettingsUrl:f,headerSlot:w,sidebarPanel:s,scrollable:i=!0,children:h}){const{theme:k,toggleTheme:I}=L(),[v,q]=l.useState(()=>Z()),[K,S]=l.useState(!1),[E,D]=l.useState(()=>window.location.href);l.useEffect(()=>{P();function o(){D(window.location.href)}return window.addEventListener("popstate",o),window.addEventListener("locationchange",o),()=>{window.removeEventListener("popstate",o),window.removeEventListener("locationchange",o)}},[]);function U(){const o=!v;q(o),B(o,u)}const b=l.useMemo(()=>t.find(o=>o.id===a),[t,a]),_=b?.workspace?.name??"",z=l.useMemo(()=>r?.email?r.email.slice(0,2).toUpperCase():"?",[r?.email]),m=l.useMemo(()=>{const o=b?.workspace?.id;return c.filter(C=>C.hidden?!1:!!(!C.permission||n||r?.globalPermissions.includes(C.permission)||o&&r?.workspacePermissions?.[o]?.includes(C.permission)||a&&r?.venuePermissions?.[a]?.includes(C.permission)))},[c,n,r,b,a]),G=l.useMemo(()=>m.filter(o=>!o.pinned),[m]),$=l.useMemo(()=>m.filter(o=>o.pinned),[m]),V=l.useMemo(()=>c.filter(C=>C.url&&E.startsWith(C.url)).sort((C,X)=>X.url.length-C.url.length)[0]?.url??null,[c,E]),F=t.length>0||w!==void 0;return e.jsxs("div",{className:"rv-app-shell",children:[e.jsxs("aside",{className:`rv-sidebar${v?" rv-collapsed":""}`,children:[e.jsxs("div",{className:"rv-sidebar-top",children:[!v&&e.jsxs("div",{className:"rv-sidebar-brand",children:[e.jsxs("svg",{className:"rv-sidebar-logo",viewBox:"0 0 429 50",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-label":"Re-venue",children:[e.jsxs("g",{clipPath:"url(#rv-logo-clip)",children:[e.jsx("path",{d:"M24.946 0.60506C24.6367 1.30638 24.2289 3.01155 24.2289 7.32948V8.73212L23.5117 9.22717C22.3867 8.12706 20.2212 7.61826 18.4775 7.61826C11.9105 7.61826 8.0013 13.6414 8.0013 21.3696V35.0247C8.0013 41.0479 8.09974 45.6683 8.4091 48.9824C6.86228 48.6799 5.54045 48.4736 4.303 48.4736C2.96711 48.4736 1.63122 48.6799 -0.0140381 48.9824C0.295326 46.2734 0.39376 42.9593 0.39376 38.2426V15.8691C0.407822 11.5512 0.309388 4.0154 2.39182e-05 1.00385C1.95464 1.40264 3.0796 1.4989 4.31706 1.4989C5.55452 1.4989 6.89041 1.29263 8.42316 1.00385L8.01537 6.0231C7.91693 7.12321 7.91693 8.73212 7.91693 10.7398L8.12786 10.8361C12.1215 3.61661 16.8322 0 21.768 0C23.0055 0 23.7226 0.206271 24.946 0.60506Z",fill:"currentColor"}),e.jsx("path",{d:"M74.7396 20.5858V22.291L74.5287 24.3949C68.3695 24.2987 61.6901 24.0924 54.4059 24.0924C49.4842 24.0924 44.3376 24.2987 39.1065 24.3949C39.0081 24.9037 39.0081 26.3064 39.0081 26.6089C39.0081 39.0539 46.4047 45.7921 56.6699 45.7921C61.901 45.7921 68.1727 42.9868 72.1663 38.6689L72.6866 38.9714L72.0678 43.8944C66.7243 47.9098 60.2557 50.0137 54.8137 50.0137C40.5408 50.0137 29.9662 40.0715 29.9662 26.3201C29.9802 9.84598 38.6003 0 53.4919 0C66.6399 0 74.7396 8.12706 74.7396 20.5858ZM52.6623 20.8883C56.2621 20.8883 62.3088 20.5858 66.3165 20.5858C66.218 9.03465 61.9994 3.21782 53.6888 3.21782C45.3781 3.21782 40.4424 9.74972 39.3174 20.5858C43.3251 20.5858 51.017 20.8883 52.6623 20.8883Z",fill:"currentColor"}),e.jsx("path",{d:"M164.989 22.9923V27.709H82.8533V22.9923H164.989Z",fill:"currentColor"}),e.jsx("path",{d:"M172.274 1.51265C173.82 1.51265 175.142 1.30638 176.788 1.0176C180.992 14.1639 185.928 26.8152 192.087 40.1815C195.687 32.852 198.148 26.8289 207.794 1.0176C208.821 1.32013 209.847 1.51265 210.972 1.51265C212.21 1.51265 213.025 1.30638 214.15 1.0176L203.477 24.615C199.779 32.9483 196.502 40.9791 193.521 49.0099C192.495 48.7074 191.468 48.5011 190.343 48.5011C189.106 48.5011 188.6 48.5974 187.053 49.0099C180.486 32.5495 174.636 17.1755 167.141 1.0176C169.292 1.41639 170.741 1.51265 172.274 1.51265Z",fill:"currentColor"}),e.jsx("path",{d:"M263.452 20.5858V22.291L263.241 24.3949C257.082 24.2987 250.402 24.0924 243.118 24.0924C238.196 24.0924 233.05 24.2987 227.819 24.3949C227.72 24.9037 227.72 26.3064 227.72 26.6089C227.72 39.0539 235.117 45.7921 245.382 45.7921C250.613 45.7921 256.885 42.9868 260.878 38.6689L261.399 38.9714L260.78 43.8944C255.436 47.9098 248.968 50.0138 243.526 50.0138C229.253 50.0138 218.678 40.0715 218.678 26.3201C218.678 9.85973 227.298 0.0137513 242.19 0.0137513C255.338 0.0137513 263.438 8.14081 263.438 20.5996L263.452 20.5858ZM241.374 20.8883C244.974 20.8883 251.021 20.5858 255.029 20.5858C254.93 9.03465 250.711 3.21782 242.401 3.21782C234.09 3.21782 229.154 9.74972 228.029 20.5858C232.037 20.5858 239.729 20.8883 241.374 20.8883Z",fill:"currentColor"}),e.jsx("path",{d:"M315.706 17.7668C315.706 23.0886 315.298 28.9054 315.298 36.5374C315.298 45.3795 315.509 47.181 315.509 48.9824C313.765 48.5836 312.528 48.4736 311.192 48.4736C309.856 48.4736 308.619 48.5699 306.988 48.9824C306.988 43.2618 307.705 34.2272 307.705 27.6953V19.967C307.705 11.6337 303.908 5.21177 296.413 5.21177C287.371 5.21177 282.66 10.8361 282.66 21.2734V33.3196C282.66 37.6375 282.97 44.4582 283.476 48.9824C281.831 48.6799 280.396 48.4736 278.85 48.4736C277.303 48.4736 275.868 48.6799 274.223 48.9824C275.039 42.6568 275.039 35.3273 275.039 31.3119V17.753C275.039 11.7299 274.729 6.20187 274.223 0.990099C275.967 1.38889 277.514 1.48515 278.85 1.48515C279.876 1.48515 281.212 1.27888 282.956 0.990099C282.857 2.69527 282.646 6.61441 282.646 9.0209H282.857C286.654 3.30033 291.787 -0.0137513 299.183 -0.0137513C309.448 -0.0137513 315.72 5.70682 315.72 17.753L315.706 17.7668Z",fill:"currentColor"}),e.jsx("path",{d:"M331.413 1.00385C333.157 1.30638 334.591 1.4989 335.73 1.4989C336.968 1.4989 338.304 1.29263 339.935 1.00385C339.218 9.43344 338.908 19.6782 338.908 28.9191C338.908 31.4356 338.908 37.6513 341.889 40.7728C343.844 43.0831 346.924 44.7882 350.931 44.7882C356.584 44.7882 359.861 42.3817 361.815 39.2602C364.276 35.2448 364.487 32.2332 364.487 21.3834C364.487 11.2486 364.389 3.10781 364.276 1.00385C366.02 1.40264 367.257 1.4989 368.593 1.4989C370.14 1.4989 371.265 1.40264 372.798 1.00385C372.39 7.42574 372.081 17.368 372.081 31.1194C372.081 38.8476 372.179 44.2657 372.488 48.9961C370.942 48.6936 369.62 48.4873 368.481 48.4873C367.342 48.4873 366.02 48.6936 364.473 48.9961C364.571 47.6898 364.684 45.4758 364.684 43.9769V40.3603H364.473C360.873 46.7822 355.023 50 348.456 50C337.783 50 331.315 44.3757 331.315 33.1271C331.315 29.0154 331.624 19.7745 331.624 16.5567C331.624 11.3311 331.526 6.21562 331.413 0.990099V1.00385Z",fill:"currentColor"}),e.jsx("path",{d:"M428.947 20.5858V22.291L428.736 24.3949C422.577 24.2987 415.898 24.0924 408.614 24.0924C403.692 24.0924 398.545 24.2987 393.314 24.3949C393.216 24.9037 393.216 26.3064 393.216 26.6089C393.216 39.0539 400.612 45.7921 410.878 45.7921C416.109 45.7921 422.38 42.9868 426.374 38.6689L426.894 38.9714L426.276 43.8944C420.932 47.9098 414.463 50.0138 409.021 50.0138C394.749 50.0138 384.174 40.0715 384.174 26.3201C384.174 9.85973 392.794 0.0137513 407.686 0.0137513C420.834 0.0137513 428.933 8.14081 428.933 20.5996L428.947 20.5858ZM406.87 20.8883C410.47 20.8883 416.517 20.5858 420.524 20.5858C420.426 9.03465 416.207 3.21782 407.897 3.21782C399.586 3.21782 394.65 9.74972 393.525 20.5858C397.533 20.5858 405.225 20.8883 406.87 20.8883Z",fill:"currentColor"})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"rv-logo-clip",children:e.jsx("rect",{width:"428.947",height:"50",fill:"white"})})})]}),_&&e.jsx("span",{className:"rv-sidebar-workspace",children:_})]}),e.jsx("button",{className:"rv-collapse-toggle",title:v?"Expand sidebar":"Collapse sidebar",onClick:U,children:v?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"13 17 18 12 13 7"}),e.jsx("polyline",{points:"6 17 11 12 6 7"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"11 17 6 12 11 7"}),e.jsx("polyline",{points:"18 17 13 12 18 7"})]})})]}),s&&e.jsx("div",{className:"rv-sidebar-panel",children:s}),e.jsx("nav",{className:"rv-sidebar-nav",children:G.map(o=>e.jsxs("a",{href:o.url,className:`rv-nav-item${o.url===V?" rv-active":""}`,title:v?o.label:void 0,children:[e.jsx("span",{className:"rv-nav-icon",dangerouslySetInnerHTML:{__html:o.icon}}),!v&&e.jsx("span",{className:"rv-nav-label",children:o.label})]},o.url))}),$.length>0&&e.jsx("nav",{className:"rv-sidebar-pinned",children:$.map(o=>e.jsxs("a",{href:o.url,className:`rv-nav-item${o.url===V?" rv-active":""}`,title:v?o.label:void 0,children:[e.jsx("span",{className:"rv-nav-icon",dangerouslySetInnerHTML:{__html:o.icon}}),!v&&e.jsx("span",{className:"rv-nav-label",children:o.label})]},o.url))}),e.jsxs("div",{className:"rv-sidebar-user",children:[e.jsx("div",{className:"rv-user-avatar",children:z}),!v&&e.jsx("div",{className:"rv-user-info",children:e.jsx("span",{className:"rv-user-email",title:r?.email??"",children:r?.email})}),e.jsx("button",{className:"rv-theme-toggle-btn",title:`Switch to ${k==="light"?"dark":"light"} mode`,"aria-label":`Switch to ${k==="light"?"dark":"light"} mode`,onClick:I,children:k==="light"?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),e.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),e.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),e.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),e.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),e.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),e.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}),f&&e.jsx("a",{className:"rv-account-settings-btn",href:f,title:"Account settings",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),e.jsx("button",{className:"rv-logout-btn",title:"Sign out",onClick:()=>S(!0),children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("polyline",{points:"16 17 21 12 16 7"}),e.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})]}),e.jsxs("div",{className:"rv-shell-body",children:[F&&e.jsx("header",{className:"rv-shell-header",children:w!==void 0?w:e.jsx(N,{value:a??"",venues:t,onChange:p??(()=>{})})}),e.jsx("main",{className:`rv-shell-content${i?" rv-shell-content--scroll":" rv-shell-content--fill"}`,children:h})]}),e.jsx(y,{open:K,title:"Sign out",message:"Are you sure you want to sign out?",confirmLabel:"Sign out",onConfirm:g,onCancel:()=>S(!1)})]})}d.AppShell=O,d.ConfirmModal=y,d.VenueSwitcher=N,d.useTheme=L,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react'
|
|
1
|
+
import { useMemo, useState, useEffect } from 'react'
|
|
2
2
|
import type { ReactNode } from 'react'
|
|
3
3
|
import { ConfirmModal } from './ConfirmModal'
|
|
4
4
|
import { VenueSwitcher } from './VenueSwitcher'
|
|
5
|
+
import { useTheme } from '../hooks/useTheme'
|
|
5
6
|
import type { AuthUser, SidebarNavItem, Venue } from '../types'
|
|
6
7
|
import '../styles/shell.css'
|
|
7
8
|
|
|
@@ -14,12 +15,29 @@ interface Props {
|
|
|
14
15
|
cookieDomain?: string
|
|
15
16
|
onSwitchVenue?: (venueId: string) => void
|
|
16
17
|
onLogout: () => void
|
|
18
|
+
accountSettingsUrl?: string
|
|
17
19
|
headerSlot?: ReactNode
|
|
18
20
|
sidebarPanel?: ReactNode
|
|
19
21
|
scrollable?: boolean
|
|
20
22
|
children: ReactNode
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
function ensureHistoryPatched() {
|
|
26
|
+
const win = window as Window & { __rvHistoryPatched?: boolean }
|
|
27
|
+
if (win.__rvHistoryPatched) return
|
|
28
|
+
win.__rvHistoryPatched = true
|
|
29
|
+
const origPush = history.pushState.bind(history)
|
|
30
|
+
history.pushState = (...args: Parameters<typeof history.pushState>) => {
|
|
31
|
+
origPush(...args)
|
|
32
|
+
window.dispatchEvent(new Event('locationchange'))
|
|
33
|
+
}
|
|
34
|
+
const origReplace = history.replaceState.bind(history)
|
|
35
|
+
history.replaceState = (...args: Parameters<typeof history.replaceState>) => {
|
|
36
|
+
origReplace(...args)
|
|
37
|
+
window.dispatchEvent(new Event('locationchange'))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
23
41
|
const SIDEBAR_COOKIE = 'rv_sidebar_collapsed'
|
|
24
42
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 365
|
|
25
43
|
|
|
@@ -46,13 +64,27 @@ export function AppShell({
|
|
|
46
64
|
cookieDomain,
|
|
47
65
|
onSwitchVenue,
|
|
48
66
|
onLogout,
|
|
67
|
+
accountSettingsUrl,
|
|
49
68
|
headerSlot,
|
|
50
69
|
sidebarPanel,
|
|
51
70
|
scrollable = true,
|
|
52
71
|
children,
|
|
53
72
|
}: Props) {
|
|
73
|
+
const { theme, toggleTheme } = useTheme()
|
|
54
74
|
const [collapsed, setCollapsed] = useState(() => readSidebarCookie())
|
|
55
75
|
const [showLogoutConfirm, setShowLogoutConfirm] = useState(false)
|
|
76
|
+
const [currentHref, setCurrentHref] = useState(() => window.location.href)
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
ensureHistoryPatched()
|
|
80
|
+
function onLocationChange() { setCurrentHref(window.location.href) }
|
|
81
|
+
window.addEventListener('popstate', onLocationChange)
|
|
82
|
+
window.addEventListener('locationchange', onLocationChange)
|
|
83
|
+
return () => {
|
|
84
|
+
window.removeEventListener('popstate', onLocationChange)
|
|
85
|
+
window.removeEventListener('locationchange', onLocationChange)
|
|
86
|
+
}
|
|
87
|
+
}, [])
|
|
56
88
|
|
|
57
89
|
function toggleCollapse() {
|
|
58
90
|
const next = !collapsed
|
|
@@ -84,6 +116,13 @@ export function AppShell({
|
|
|
84
116
|
const mainNavItems = useMemo(() => visibleNavItems.filter((item) => !item.pinned), [visibleNavItems])
|
|
85
117
|
const pinnedNavItems = useMemo(() => visibleNavItems.filter((item) => item.pinned), [visibleNavItems])
|
|
86
118
|
|
|
119
|
+
const activeNavUrl = useMemo(() => {
|
|
120
|
+
const matches = navItems
|
|
121
|
+
.filter(item => item.url && currentHref.startsWith(item.url))
|
|
122
|
+
.sort((a, b) => b.url.length - a.url.length)
|
|
123
|
+
return matches[0]?.url ?? null
|
|
124
|
+
}, [navItems, currentHref])
|
|
125
|
+
|
|
87
126
|
const showHeader = venues.length > 0 || headerSlot !== undefined
|
|
88
127
|
|
|
89
128
|
return (
|
|
@@ -144,7 +183,7 @@ export function AppShell({
|
|
|
144
183
|
<a
|
|
145
184
|
key={item.url}
|
|
146
185
|
href={item.url}
|
|
147
|
-
className={`rv-nav-item${item.
|
|
186
|
+
className={`rv-nav-item${item.url === activeNavUrl ? ' rv-active' : ''}`}
|
|
148
187
|
title={collapsed ? item.label : undefined}
|
|
149
188
|
>
|
|
150
189
|
<span className="rv-nav-icon" dangerouslySetInnerHTML={{ __html: item.icon }} />
|
|
@@ -159,7 +198,7 @@ export function AppShell({
|
|
|
159
198
|
<a
|
|
160
199
|
key={item.url}
|
|
161
200
|
href={item.url}
|
|
162
|
-
className={`rv-nav-item${item.
|
|
201
|
+
className={`rv-nav-item${item.url === activeNavUrl ? ' rv-active' : ''}`}
|
|
163
202
|
title={collapsed ? item.label : undefined}
|
|
164
203
|
>
|
|
165
204
|
<span className="rv-nav-icon" dangerouslySetInnerHTML={{ __html: item.icon }} />
|
|
@@ -176,6 +215,26 @@ export function AppShell({
|
|
|
176
215
|
<span className="rv-user-email" title={user?.email ?? ''}>{user?.email}</span>
|
|
177
216
|
</div>
|
|
178
217
|
)}
|
|
218
|
+
<button
|
|
219
|
+
className="rv-theme-toggle-btn"
|
|
220
|
+
title={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
|
|
221
|
+
aria-label={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
|
|
222
|
+
onClick={toggleTheme}
|
|
223
|
+
>
|
|
224
|
+
{theme === 'light' ? (
|
|
225
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" /></svg>
|
|
226
|
+
) : (
|
|
227
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="5" /><line x1="12" y1="1" x2="12" y2="3" /><line x1="12" y1="21" x2="12" y2="23" /><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" /><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" /><line x1="1" y1="12" x2="3" y2="12" /><line x1="21" y1="12" x2="23" y2="12" /><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" /><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" /></svg>
|
|
228
|
+
)}
|
|
229
|
+
</button>
|
|
230
|
+
{accountSettingsUrl && (
|
|
231
|
+
<a className="rv-account-settings-btn" href={accountSettingsUrl} title="Account settings">
|
|
232
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
233
|
+
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" />
|
|
234
|
+
<circle cx="12" cy="12" r="3" />
|
|
235
|
+
</svg>
|
|
236
|
+
</a>
|
|
237
|
+
)}
|
|
179
238
|
<button className="rv-logout-btn" title="Sign out" onClick={() => setShowLogoutConfirm(true)}>
|
|
180
239
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
181
240
|
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const COOKIE_KEY = 'rv-theme'
|
|
4
|
+
const COOKIE_DOMAIN = import.meta.env.VITE_COOKIE_DOMAIN as string | undefined
|
|
5
|
+
|
|
6
|
+
type Theme = 'light' | 'dark'
|
|
7
|
+
|
|
8
|
+
function readCookie(): Theme {
|
|
9
|
+
const match = document.cookie.split('; ').find((row) => row.startsWith(`${COOKIE_KEY}=`))
|
|
10
|
+
const value = match?.split('=')[1]
|
|
11
|
+
return value === 'dark' ? 'dark' : 'light'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function writeCookie(value: Theme) {
|
|
15
|
+
const parts = [`${COOKIE_KEY}=${value}`, 'path=/', 'max-age=31536000', 'SameSite=Lax']
|
|
16
|
+
if (COOKIE_DOMAIN) {
|
|
17
|
+
parts.push(`domain=${COOKIE_DOMAIN}`)
|
|
18
|
+
}
|
|
19
|
+
document.cookie = parts.join('; ')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function applyTheme(value: Theme) {
|
|
23
|
+
document.documentElement.setAttribute('data-theme', value)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function useTheme() {
|
|
27
|
+
const [theme, setTheme] = useState<Theme>(() => readCookie())
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
applyTheme(theme)
|
|
31
|
+
}, [theme])
|
|
32
|
+
|
|
33
|
+
const toggleTheme = useCallback(() => {
|
|
34
|
+
setTheme((current) => {
|
|
35
|
+
const next: Theme = current === 'light' ? 'dark' : 'light'
|
|
36
|
+
writeCookie(next)
|
|
37
|
+
return next
|
|
38
|
+
})
|
|
39
|
+
}, [])
|
|
40
|
+
|
|
41
|
+
return { theme, toggleTheme }
|
|
42
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AppShell } from './components/AppShell'
|
|
2
2
|
export { VenueSwitcher } from './components/VenueSwitcher'
|
|
3
3
|
export { ConfirmModal } from './components/ConfirmModal'
|
|
4
|
+
export { useTheme } from './hooks/useTheme'
|
|
4
5
|
export type { AuthUser, Venue, SidebarNavItem } from './types'
|
package/src/styles/shell.css
CHANGED
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
padding: 0.75rem 0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
.rv-sidebar.rv-collapsed .rv-theme-toggle-btn,
|
|
47
|
+
.rv-sidebar.rv-collapsed .rv-account-settings-btn,
|
|
46
48
|
.rv-sidebar.rv-collapsed .rv-logout-btn {
|
|
47
49
|
margin-left: 0;
|
|
48
50
|
}
|
|
@@ -213,26 +215,34 @@
|
|
|
213
215
|
text-overflow: ellipsis;
|
|
214
216
|
}
|
|
215
217
|
|
|
218
|
+
.rv-theme-toggle-btn,
|
|
219
|
+
.rv-account-settings-btn,
|
|
216
220
|
.rv-logout-btn {
|
|
217
221
|
flex-shrink: 0;
|
|
218
222
|
display: flex;
|
|
219
223
|
align-items: center;
|
|
220
224
|
justify-content: center;
|
|
221
|
-
margin-left: auto;
|
|
222
225
|
border: none;
|
|
223
226
|
background: none;
|
|
224
227
|
cursor: pointer;
|
|
225
228
|
color: var(--color-text-muted, #777777);
|
|
226
229
|
border-radius: var(--radius-sm, 4px);
|
|
227
230
|
padding: 4px;
|
|
231
|
+
text-decoration: none;
|
|
228
232
|
transition: background var(--transition-fast, 0.1s ease), color var(--transition-fast, 0.1s ease);
|
|
229
233
|
}
|
|
230
234
|
|
|
235
|
+
.rv-theme-toggle-btn:hover,
|
|
236
|
+
.rv-account-settings-btn:hover,
|
|
231
237
|
.rv-logout-btn:hover {
|
|
232
238
|
background: var(--color-bg-surface, #f0f0f0);
|
|
233
239
|
color: var(--color-text-secondary, #444444);
|
|
234
240
|
}
|
|
235
241
|
|
|
242
|
+
.rv-logout-btn {
|
|
243
|
+
margin-left: auto;
|
|
244
|
+
}
|
|
245
|
+
|
|
236
246
|
.rv-shell-body {
|
|
237
247
|
flex: 1;
|
|
238
248
|
display: flex;
|