@tuturuuu/ui 0.30.2 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/biome.json +1 -1
- package/package.json +95 -49
- package/src/components/ui/calendar-app/calendar-client-page.test.tsx +57 -0
- package/src/components/ui/calendar-app/calendar-client-page.tsx +13 -4
- package/src/components/ui/calendar-app/calendar-page-shell.tsx +7 -1
- package/src/components/ui/calendar-app/components/calendar-connections-compact.tsx +47 -39
- package/src/components/ui/calendar-app/components/calendar-connections-settings-content.tsx +14 -0
- package/src/components/ui/calendar-app/components/calendar-connections-unified.tsx +4 -0
- package/src/components/ui/calendar-app/components/calendar-sync-attention-button.tsx +47 -0
- package/src/components/ui/calendar-app/components/calendar-sync-recovery.test.tsx +112 -0
- package/src/components/ui/calendar-app/components/calendar-sync-recovery.tsx +206 -0
- package/src/components/ui/calendar-app/components/calendar-types.ts +1 -1
- package/src/components/ui/calendar-app/components/use-calendar-connections-manager.ts +86 -90
- package/src/components/ui/chat/ai-message-markdown.tsx +17 -2
- package/src/components/ui/custom/language-dropdown-item.tsx +6 -14
- package/src/components/ui/custom/nav-link.tsx +7 -7
- package/src/components/ui/custom/nav.tsx +15 -63
- package/src/components/ui/custom/notification-card.tsx +361 -0
- package/src/components/ui/custom/notification-list.tsx +178 -0
- package/src/components/ui/custom/notification-popover-client.tsx +12 -780
- package/src/components/ui/custom/notification-runtime.tsx +23 -0
- package/src/components/ui/custom/onboarding-settings-panel.tsx +8 -55
- package/src/components/ui/custom/satellite-account-switcher-menu.tsx +212 -0
- package/src/components/ui/custom/satellite-brand.tsx +122 -0
- package/src/components/ui/custom/satellite-content.tsx +148 -0
- package/src/components/ui/custom/satellite-footer-actions.tsx +350 -0
- package/src/components/ui/custom/satellite-language-item.tsx +26 -0
- package/src/components/ui/custom/satellite-navigation.tsx +86 -0
- package/src/components/ui/custom/satellite-notification-popover.tsx +272 -0
- package/src/components/ui/custom/satellite-onboarding-settings-panel.tsx +80 -0
- package/src/components/ui/custom/satellite-settings-dialog-shell.tsx +621 -0
- package/src/components/ui/custom/satellite-shell-utils.ts +163 -0
- package/src/components/ui/custom/satellite-shell.test.tsx +169 -0
- package/src/components/ui/custom/satellite-shell.tsx +50 -0
- package/src/components/ui/custom/satellite-theme-dropdown-items.tsx +92 -0
- package/src/components/ui/custom/satellite-user-menu-items.tsx +190 -0
- package/src/components/ui/custom/satellite-user-menu.tsx +93 -0
- package/src/components/ui/custom/satellite-workspace-section.tsx +46 -0
- package/src/components/ui/custom/settings/keyboard-shortcuts-settings.tsx +16 -0
- package/src/components/ui/custom/settings-dialog-shell.tsx +21 -600
- package/src/components/ui/custom/sidebar-context.tsx +5 -14
- package/src/components/ui/custom/sidebar-footer-actions.tsx +19 -322
- package/src/components/ui/custom/structure.tsx +14 -0
- package/src/components/ui/custom/system-language-dropdown-item.tsx +7 -14
- package/src/components/ui/custom/theme-dropdown-items.tsx +2 -85
- package/src/components/ui/custom/use-satellite-shell.tsx +165 -0
- package/src/components/ui/legacy/calendar/agenda-view.tsx +139 -47
- package/src/components/ui/legacy/calendar/calendar-content.test.tsx +116 -0
- package/src/components/ui/legacy/calendar/calendar-content.tsx +38 -74
- package/src/components/ui/legacy/calendar/calendar-event-tone.ts +20 -0
- package/src/components/ui/legacy/calendar/calendar-meeting-link.test.ts +27 -0
- package/src/components/ui/legacy/calendar/calendar-meeting-link.ts +34 -0
- package/src/components/ui/legacy/calendar/calendar-period.ts +28 -0
- package/src/components/ui/legacy/calendar/calendar-shortcuts.test.tsx +107 -0
- package/src/components/ui/legacy/calendar/calendar-views.test.tsx +169 -0
- package/src/components/ui/legacy/calendar/event-modal-header.tsx +52 -0
- package/src/components/ui/legacy/calendar/event-modal.tsx +107 -156
- package/src/components/ui/legacy/calendar/month-calendar.tsx +242 -933
- package/src/components/ui/legacy/calendar/save-calendar-event-drafts.test.ts +25 -0
- package/src/components/ui/legacy/calendar/save-calendar-event-drafts.ts +32 -0
- package/src/components/ui/legacy/calendar/smart-calendar.tsx +3 -0
- package/src/components/ui/legacy/calendar/use-calendar-view-shortcuts.ts +54 -0
- package/src/components/ui/legacy/calendar/use-event-draft-session.test.tsx +59 -0
- package/src/components/ui/legacy/calendar/use-event-draft-session.ts +20 -0
- package/src/components/ui/legacy/calendar/year-calendar.tsx +34 -16
- package/src/components/ui/pwa-status.test.tsx +53 -0
- package/src/components/ui/pwa-status.tsx +113 -0
- package/src/components/ui/report-problem-dialog-content.tsx +350 -0
- package/src/components/ui/report-problem-dialog.tsx +6 -975
- package/src/components/ui/report-problem-model.ts +133 -0
- package/src/components/ui/report-problem-mutation.ts +122 -0
- package/src/components/ui/save-notification.test.tsx +36 -0
- package/src/components/ui/save-notification.tsx +17 -0
- package/src/components/ui/use-report-problem.ts +488 -0
- package/src/declarations.d.ts +2 -0
- package/src/hooks/__tests__/use-calendar-readonly.test.tsx +46 -4
- package/src/hooks/__tests__/use-calendar-sync.test.tsx +24 -0
- package/src/hooks/calendar-date-utils.ts +11 -0
- package/src/hooks/calendar-event-lookup.test.ts +77 -0
- package/src/hooks/calendar-event-lookup.ts +47 -0
- package/src/hooks/calendar-range-cache.ts +52 -0
- package/src/hooks/pwa-install-prompt.ts +44 -0
- package/src/hooks/use-calendar-sync.tsx +23 -100
- package/src/hooks/use-calendar.tsx +21 -77
- package/src/hooks/use-notifications.ts +9 -24
- package/src/hooks/use-open-initial-calendar-event.ts +27 -0
- package/src/hooks/use-settings-dialog-shortcut.test.tsx +41 -0
- package/src/hooks/use-settings-dialog-shortcut.ts +12 -14
- package/src/hooks/use-workspace-presence.ts +0 -18
- package/src/lib/tasks-app-url.test.ts +25 -0
- package/src/lib/tasks-app-url.ts +8 -0
|
@@ -1,337 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import { ArrowBigUpDash, MessageSquareWarning } from '@tuturuuu/icons';
|
|
4
|
-
import { cn } from '@tuturuuu/utils/format';
|
|
5
2
|
import Link from 'next/link';
|
|
6
3
|
import { useTranslations } from 'next-intl';
|
|
7
|
-
import {
|
|
4
|
+
import { useState } from 'react';
|
|
8
5
|
import { ReportProblemDialog } from '../report-problem-dialog';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const DISCORD_LINK = process.env.NEXT_PUBLIC_DISCORD_LINK;
|
|
22
|
-
|
|
23
|
-
function DiscordIcon({ className }: { className?: string }) {
|
|
24
|
-
return (
|
|
25
|
-
<svg
|
|
26
|
-
className={className}
|
|
27
|
-
viewBox="0 -28.5 256 256"
|
|
28
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
-
preserveAspectRatio="xMidYMid"
|
|
30
|
-
>
|
|
31
|
-
<title>Discord</title>
|
|
32
|
-
<path
|
|
33
|
-
d="M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z"
|
|
34
|
-
fill="currentColor"
|
|
35
|
-
fillRule="nonzero"
|
|
36
|
-
/>
|
|
37
|
-
</svg>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function SidebarFooterActions({
|
|
42
|
-
wsId,
|
|
43
|
-
isCollapsed,
|
|
44
|
-
showUpgrade,
|
|
45
|
-
upgradeHref,
|
|
46
|
-
upgradeExternal = false,
|
|
47
|
-
}: SidebarFooterActionsProps) {
|
|
6
|
+
import {
|
|
7
|
+
SatelliteFooterActions,
|
|
8
|
+
type SatelliteFooterActionsProps,
|
|
9
|
+
} from './satellite-footer-actions';
|
|
10
|
+
export function SidebarFooterActions(
|
|
11
|
+
props: Omit<
|
|
12
|
+
SatelliteFooterActionsProps,
|
|
13
|
+
'labels' | 'discordHref' | 'onFeedback' | 'LinkComponent'
|
|
14
|
+
>
|
|
15
|
+
) {
|
|
48
16
|
const t = useTranslations('common');
|
|
49
17
|
const [feedbackOpen, setFeedbackOpen] = useState(false);
|
|
50
|
-
const [hoveredItem, setHoveredItem] = useState<FooterItem | null>(null);
|
|
51
|
-
const leaveTimer = useRef<ReturnType<typeof setTimeout>>(null);
|
|
52
|
-
// After switching items, ignore mouse events until the CSS transition
|
|
53
|
-
// finishes so layout shifts don't cause the cursor to "see" a different
|
|
54
|
-
// item mid-animation and oscillate.
|
|
55
|
-
const cooldownUntil = useRef(0);
|
|
56
|
-
|
|
57
|
-
const hasDiscord = !!DISCORD_LINK;
|
|
58
|
-
|
|
59
|
-
const resolvedUpgradeHref = upgradeHref ?? `/${wsId}/billing`;
|
|
60
|
-
|
|
61
|
-
const defaultExpanded: FooterItem = showUpgrade ? 'upgrade' : 'feedback';
|
|
62
|
-
const activeExpanded = hoveredItem ?? defaultExpanded;
|
|
63
|
-
|
|
64
|
-
const handleMouseMove = useCallback((e: React.MouseEvent) => {
|
|
65
|
-
if (leaveTimer.current) {
|
|
66
|
-
clearTimeout(leaveTimer.current);
|
|
67
|
-
leaveTimer.current = null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Skip during cooldown -- transition is still running
|
|
71
|
-
if (Date.now() < cooldownUntil.current) return;
|
|
72
|
-
|
|
73
|
-
const target = (e.target as HTMLElement).closest('[data-item]');
|
|
74
|
-
if (!target) return;
|
|
75
|
-
|
|
76
|
-
const item = target.getAttribute('data-item') as FooterItem;
|
|
77
|
-
setHoveredItem((prev) => {
|
|
78
|
-
if (prev === item) return prev;
|
|
79
|
-
// Lock out further changes for the transition duration (200ms + buffer)
|
|
80
|
-
cooldownUntil.current = Date.now() + 250;
|
|
81
|
-
return item;
|
|
82
|
-
});
|
|
83
|
-
}, []);
|
|
84
|
-
|
|
85
|
-
const handleMouseLeave = useCallback(() => {
|
|
86
|
-
leaveTimer.current = setTimeout(() => {
|
|
87
|
-
cooldownUntil.current = Date.now() + 250;
|
|
88
|
-
setHoveredItem(null);
|
|
89
|
-
}, 100);
|
|
90
|
-
}, []);
|
|
91
|
-
|
|
92
|
-
// Collapsed: vertical stack of icon-only buttons
|
|
93
|
-
if (isCollapsed) {
|
|
94
|
-
return (
|
|
95
|
-
<div className="flex w-full flex-col items-center gap-1">
|
|
96
|
-
{showUpgrade && (
|
|
97
|
-
<CollapsedItem
|
|
98
|
-
href={resolvedUpgradeHref}
|
|
99
|
-
external={upgradeExternal}
|
|
100
|
-
tooltip={t('upgrade')}
|
|
101
|
-
variant="upgrade"
|
|
102
|
-
>
|
|
103
|
-
<ArrowBigUpDash className="h-4.5 w-4.5" />
|
|
104
|
-
</CollapsedItem>
|
|
105
|
-
)}
|
|
106
|
-
{hasDiscord && (
|
|
107
|
-
<CollapsedItem href={DISCORD_LINK!} external tooltip="Discord">
|
|
108
|
-
<DiscordIcon className="h-4.5 w-4.5" />
|
|
109
|
-
</CollapsedItem>
|
|
110
|
-
)}
|
|
111
|
-
<CollapsedItem
|
|
112
|
-
tooltip={t('feedback')}
|
|
113
|
-
onClick={() => setFeedbackOpen(true)}
|
|
114
|
-
>
|
|
115
|
-
<MessageSquareWarning className="h-4.5 w-4.5" />
|
|
116
|
-
</CollapsedItem>
|
|
117
|
-
<ReportProblemDialog
|
|
118
|
-
open={feedbackOpen}
|
|
119
|
-
onOpenChange={setFeedbackOpen}
|
|
120
|
-
showTrigger={false}
|
|
121
|
-
/>
|
|
122
|
-
</div>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Expanded sidebar: horizontal bar.
|
|
127
|
-
// One item is "active" (expanded with label), others are icon-only.
|
|
128
18
|
return (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
isActive={activeExpanded === 'upgrade'}
|
|
138
|
-
label={t('upgrade')}
|
|
139
|
-
href={resolvedUpgradeHref}
|
|
140
|
-
external={upgradeExternal}
|
|
141
|
-
variant="upgrade"
|
|
142
|
-
>
|
|
143
|
-
<ArrowBigUpDash className="h-4 w-4 shrink-0" />
|
|
144
|
-
</FooterAction>
|
|
145
|
-
)}
|
|
146
|
-
{hasDiscord && (
|
|
147
|
-
<FooterAction
|
|
148
|
-
id="discord"
|
|
149
|
-
isActive={activeExpanded === 'discord'}
|
|
150
|
-
label="Discord"
|
|
151
|
-
href={DISCORD_LINK!}
|
|
152
|
-
external
|
|
153
|
-
>
|
|
154
|
-
<DiscordIcon className="h-4 w-4 shrink-0" />
|
|
155
|
-
</FooterAction>
|
|
156
|
-
)}
|
|
157
|
-
<FooterAction
|
|
158
|
-
id="feedback"
|
|
159
|
-
isActive={activeExpanded === 'feedback'}
|
|
160
|
-
label={t('feedback')}
|
|
161
|
-
onClick={() => setFeedbackOpen(true)}
|
|
162
|
-
>
|
|
163
|
-
<MessageSquareWarning className="h-4 w-4 shrink-0" />
|
|
164
|
-
</FooterAction>
|
|
19
|
+
<>
|
|
20
|
+
<SatelliteFooterActions
|
|
21
|
+
{...props}
|
|
22
|
+
labels={{ upgrade: t('upgrade'), feedback: t('feedback') }}
|
|
23
|
+
discordHref={process.env.NEXT_PUBLIC_DISCORD_LINK}
|
|
24
|
+
onFeedback={() => setFeedbackOpen(true)}
|
|
25
|
+
LinkComponent={Link}
|
|
26
|
+
/>
|
|
165
27
|
<ReportProblemDialog
|
|
166
28
|
open={feedbackOpen}
|
|
167
29
|
onOpenChange={setFeedbackOpen}
|
|
168
30
|
showTrigger={false}
|
|
169
31
|
/>
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// --- Sub-components ---
|
|
175
|
-
|
|
176
|
-
interface CollapsedItemProps {
|
|
177
|
-
children: ReactNode;
|
|
178
|
-
tooltip: string;
|
|
179
|
-
href?: string;
|
|
180
|
-
external?: boolean;
|
|
181
|
-
onClick?: () => void;
|
|
182
|
-
variant?: 'upgrade' | 'default';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function CollapsedItem({
|
|
186
|
-
children,
|
|
187
|
-
tooltip,
|
|
188
|
-
href,
|
|
189
|
-
external,
|
|
190
|
-
onClick,
|
|
191
|
-
variant = 'default',
|
|
192
|
-
}: CollapsedItemProps) {
|
|
193
|
-
const isUpgrade = variant === 'upgrade';
|
|
194
|
-
|
|
195
|
-
const className = cn(
|
|
196
|
-
'flex h-9 w-9 items-center justify-center rounded-lg transition-all duration-150',
|
|
197
|
-
isUpgrade
|
|
198
|
-
? [
|
|
199
|
-
'group bg-linear-to-br from-dynamic-purple/10 to-dynamic-indigo/10',
|
|
200
|
-
'border border-dynamic-purple/20 text-dynamic-purple',
|
|
201
|
-
'hover:border-dynamic-purple/40 hover:from-dynamic-purple/15 hover:to-dynamic-indigo/15',
|
|
202
|
-
'hover:[box-shadow:0_0_20px_-5px_oklch(var(--dynamic-purple)/0.3)]',
|
|
203
|
-
]
|
|
204
|
-
: 'text-foreground/60 hover:bg-foreground/5 hover:text-foreground'
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
const wrappedChildren = isUpgrade ? (
|
|
208
|
-
<span className="transition-transform duration-200 group-hover:-translate-y-0.5 group-hover:scale-110">
|
|
209
|
-
{children}
|
|
210
|
-
</span>
|
|
211
|
-
) : (
|
|
212
|
-
children
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const content = href ? (
|
|
216
|
-
external ? (
|
|
217
|
-
<a
|
|
218
|
-
href={href}
|
|
219
|
-
target="_blank"
|
|
220
|
-
rel="noopener noreferrer"
|
|
221
|
-
className={className}
|
|
222
|
-
>
|
|
223
|
-
{wrappedChildren}
|
|
224
|
-
</a>
|
|
225
|
-
) : (
|
|
226
|
-
<Link href={href} className={className}>
|
|
227
|
-
{wrappedChildren}
|
|
228
|
-
</Link>
|
|
229
|
-
)
|
|
230
|
-
) : (
|
|
231
|
-
<button type="button" onClick={onClick} className={className}>
|
|
232
|
-
{wrappedChildren}
|
|
233
|
-
</button>
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
return (
|
|
237
|
-
<Tooltip>
|
|
238
|
-
<TooltipTrigger asChild>{content}</TooltipTrigger>
|
|
239
|
-
<TooltipContent side="right">
|
|
240
|
-
<p>{tooltip}</p>
|
|
241
|
-
</TooltipContent>
|
|
242
|
-
</Tooltip>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
interface FooterActionProps {
|
|
247
|
-
id: FooterItem;
|
|
248
|
-
isActive: boolean;
|
|
249
|
-
label: string;
|
|
250
|
-
children: ReactNode;
|
|
251
|
-
href?: string;
|
|
252
|
-
external?: boolean;
|
|
253
|
-
onClick?: () => void;
|
|
254
|
-
variant?: 'upgrade' | 'default';
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function FooterAction({
|
|
258
|
-
id,
|
|
259
|
-
isActive,
|
|
260
|
-
label,
|
|
261
|
-
children,
|
|
262
|
-
href,
|
|
263
|
-
external,
|
|
264
|
-
onClick,
|
|
265
|
-
variant = id === 'upgrade' ? 'upgrade' : 'default',
|
|
266
|
-
}: FooterActionProps) {
|
|
267
|
-
const isUpgrade = variant === 'upgrade';
|
|
268
|
-
|
|
269
|
-
const className = cn(
|
|
270
|
-
'flex h-9 items-center justify-center gap-1.5 rounded-lg transition-all duration-200',
|
|
271
|
-
isActive ? 'min-w-0 flex-1' : 'w-9 shrink-0',
|
|
272
|
-
isUpgrade
|
|
273
|
-
? [
|
|
274
|
-
'group relative overflow-hidden text-dynamic-purple',
|
|
275
|
-
isActive
|
|
276
|
-
? [
|
|
277
|
-
'border border-dynamic-purple/20 bg-linear-to-r from-dynamic-purple/10 to-dynamic-indigo/8',
|
|
278
|
-
'hover:border-dynamic-purple/35 hover:[box-shadow:0_0_20px_-5px_oklch(var(--dynamic-purple)/0.3)]',
|
|
279
|
-
]
|
|
280
|
-
: 'hover:bg-dynamic-purple/8 hover:[box-shadow:0_0_16px_-4px_oklch(var(--dynamic-purple)/0.2)]',
|
|
281
|
-
]
|
|
282
|
-
: [
|
|
283
|
-
isActive
|
|
284
|
-
? 'bg-foreground/5 text-foreground'
|
|
285
|
-
: 'text-foreground/50 hover:bg-foreground/5 hover:text-foreground/70',
|
|
286
|
-
]
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
const inner = (
|
|
290
|
-
<>
|
|
291
|
-
<span
|
|
292
|
-
className={cn(
|
|
293
|
-
'shrink-0 transition-transform duration-200',
|
|
294
|
-
isUpgrade && 'group-hover:scale-110'
|
|
295
|
-
)}
|
|
296
|
-
>
|
|
297
|
-
{children}
|
|
298
|
-
</span>
|
|
299
|
-
{isActive && (
|
|
300
|
-
<span className="truncate font-medium text-sm">{label}</span>
|
|
301
|
-
)}
|
|
302
|
-
{isUpgrade && isActive && (
|
|
303
|
-
<span
|
|
304
|
-
className="pointer-events-none absolute inset-0 animate-[shimmer_4s_ease-in-out_infinite]"
|
|
305
|
-
style={{
|
|
306
|
-
background:
|
|
307
|
-
'linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%)',
|
|
308
|
-
}}
|
|
309
|
-
/>
|
|
310
|
-
)}
|
|
311
32
|
</>
|
|
312
33
|
);
|
|
313
|
-
|
|
314
|
-
// data-item is read by the container's onMouseMove for flicker-free tracking
|
|
315
|
-
const sharedProps = {
|
|
316
|
-
className,
|
|
317
|
-
'data-item': id,
|
|
318
|
-
} as const;
|
|
319
|
-
|
|
320
|
-
if (href) {
|
|
321
|
-
return external ? (
|
|
322
|
-
<a href={href} target="_blank" rel="noopener noreferrer" {...sharedProps}>
|
|
323
|
-
{inner}
|
|
324
|
-
</a>
|
|
325
|
-
) : (
|
|
326
|
-
<Link href={href} {...sharedProps}>
|
|
327
|
-
{inner}
|
|
328
|
-
</Link>
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return (
|
|
333
|
-
<button type="button" onClick={onClick} {...sharedProps}>
|
|
334
|
-
{inner}
|
|
335
|
-
</button>
|
|
336
|
-
);
|
|
337
34
|
}
|
|
@@ -7,6 +7,7 @@ import { cn } from '@tuturuuu/utils/format';
|
|
|
7
7
|
import { type CSSProperties, type ReactNode, useEffect } from 'react';
|
|
8
8
|
|
|
9
9
|
interface StructureProps {
|
|
10
|
+
sidebarLabels?: { open: string; close: string };
|
|
10
11
|
isCollapsed: boolean;
|
|
11
12
|
setIsCollapsed: (isCollapsed: boolean) => void;
|
|
12
13
|
hideSizeToggle?: boolean;
|
|
@@ -33,6 +34,7 @@ interface StructureProps {
|
|
|
33
34
|
export function Structure({
|
|
34
35
|
isCollapsed,
|
|
35
36
|
setIsCollapsed,
|
|
37
|
+
sidebarLabels,
|
|
36
38
|
hideSizeToggle = false,
|
|
37
39
|
overlayOnExpand = false,
|
|
38
40
|
header,
|
|
@@ -96,6 +98,9 @@ export function Structure({
|
|
|
96
98
|
size="icon"
|
|
97
99
|
variant="outline"
|
|
98
100
|
className="h-auto w-auto flex-none rounded-lg p-2 md:hidden"
|
|
101
|
+
aria-label={
|
|
102
|
+
isCollapsed ? sidebarLabels?.open : sidebarLabels?.close
|
|
103
|
+
}
|
|
99
104
|
onClick={() => setIsCollapsed(!isCollapsed)}
|
|
100
105
|
>
|
|
101
106
|
<Menu className="h-5 w-5" />
|
|
@@ -111,6 +116,7 @@ export function Structure({
|
|
|
111
116
|
<button
|
|
112
117
|
type="button"
|
|
113
118
|
className="fixed inset-0 z-40 bg-black/20 backdrop-blur-lg md:hidden"
|
|
119
|
+
aria-label={sidebarLabels?.close}
|
|
114
120
|
onClick={() => setIsCollapsed(true)}
|
|
115
121
|
/>
|
|
116
122
|
)}
|
|
@@ -156,6 +162,11 @@ export function Structure({
|
|
|
156
162
|
size="icon"
|
|
157
163
|
variant="outline"
|
|
158
164
|
className="h-auto w-auto flex-none rounded-lg p-2 md:hidden"
|
|
165
|
+
aria-label={
|
|
166
|
+
isCollapsed
|
|
167
|
+
? sidebarLabels?.open
|
|
168
|
+
: sidebarLabels?.close
|
|
169
|
+
}
|
|
159
170
|
onClick={() => setIsCollapsed(!isCollapsed)}
|
|
160
171
|
>
|
|
161
172
|
<X className="h-5 w-5" />
|
|
@@ -208,6 +219,9 @@ export function Structure({
|
|
|
208
219
|
size="icon"
|
|
209
220
|
variant="outline"
|
|
210
221
|
className="absolute top-1/2 -right-4 z-10 hidden h-auto w-auto -translate-y-1/2 rounded-full border-2 bg-background p-1.5 pl-1.5 opacity-0 transition duration-500 hover:bg-accent group-hover:opacity-100 md:block"
|
|
222
|
+
aria-label={
|
|
223
|
+
isCollapsed ? sidebarLabels?.open : sidebarLabels?.close
|
|
224
|
+
}
|
|
211
225
|
onClick={() => setIsCollapsed(!isCollapsed)}
|
|
212
226
|
>
|
|
213
227
|
{isCollapsed ? (
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Check, Monitor } from '@tuturuuu/icons';
|
|
4
3
|
import { useRouter } from 'next/navigation';
|
|
5
4
|
import { useTranslations } from 'next-intl';
|
|
6
|
-
import { DropdownMenuItem } from '../dropdown-menu';
|
|
7
5
|
import { clearLocalePreference } from './locale-preference';
|
|
6
|
+
import { SatelliteLanguageItem } from './satellite-language-item';
|
|
8
7
|
|
|
9
8
|
interface Props {
|
|
10
9
|
selected?: boolean;
|
|
@@ -27,17 +26,11 @@ export function SystemLanguageDropdownItem({ selected, onResetLocale }: Props) {
|
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
return (
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<Check className="h-4 w-4" />
|
|
37
|
-
) : (
|
|
38
|
-
<Monitor className="h-4 w-4" />
|
|
39
|
-
)}
|
|
40
|
-
{t('system')}
|
|
41
|
-
</DropdownMenuItem>
|
|
29
|
+
<SatelliteLanguageItem
|
|
30
|
+
label={t('system')}
|
|
31
|
+
selected={selected}
|
|
32
|
+
system
|
|
33
|
+
onSelect={useDefaultLocale}
|
|
34
|
+
/>
|
|
42
35
|
);
|
|
43
36
|
}
|
|
@@ -1,90 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import { Check, Monitor, Moon, Sun } from '@tuturuuu/icons';
|
|
4
2
|
import { useTranslations } from 'next-intl';
|
|
5
|
-
import {
|
|
6
|
-
import { DropdownMenuItem, DropdownMenuSeparator } from '../dropdown-menu';
|
|
7
|
-
|
|
3
|
+
import { SatelliteThemeDropdownItems } from './satellite-theme-dropdown-items';
|
|
8
4
|
export function ThemeDropdownItems() {
|
|
9
5
|
const t = useTranslations('common');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const isSystem = theme === 'system' || theme === null;
|
|
13
|
-
|
|
14
|
-
const primaryTheme = theme?.split('-')?.[0] as
|
|
15
|
-
| 'light'
|
|
16
|
-
| 'dark'
|
|
17
|
-
| 'system'
|
|
18
|
-
| undefined;
|
|
19
|
-
|
|
20
|
-
const updateTheme = ({
|
|
21
|
-
primary = primaryTheme,
|
|
22
|
-
}: {
|
|
23
|
-
primary?: 'light' | 'dark' | 'system';
|
|
24
|
-
secondary?:
|
|
25
|
-
| 'pink'
|
|
26
|
-
| 'purple'
|
|
27
|
-
| 'yellow'
|
|
28
|
-
| 'orange'
|
|
29
|
-
| 'green'
|
|
30
|
-
| 'blue'
|
|
31
|
-
| null;
|
|
32
|
-
}) => {
|
|
33
|
-
let theme = '';
|
|
34
|
-
|
|
35
|
-
if (primary) theme += primary === 'system' ? systemTheme : primary;
|
|
36
|
-
|
|
37
|
-
// remove leading dash
|
|
38
|
-
if (theme.startsWith('-')) theme = theme.slice(1);
|
|
39
|
-
|
|
40
|
-
setTheme(theme);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<>
|
|
45
|
-
<DropdownMenuItem
|
|
46
|
-
className="cursor-pointer"
|
|
47
|
-
onClick={() => updateTheme({ primary: 'light' })}
|
|
48
|
-
disabled={primaryTheme === 'light'}
|
|
49
|
-
>
|
|
50
|
-
{primaryTheme === 'light' ? (
|
|
51
|
-
<Check className="h-4 w-4 text-dynamic-yellow" />
|
|
52
|
-
) : (
|
|
53
|
-
<Sun className="h-4 w-4 text-dynamic-yellow" />
|
|
54
|
-
)}
|
|
55
|
-
|
|
56
|
-
{t('light')}
|
|
57
|
-
</DropdownMenuItem>
|
|
58
|
-
|
|
59
|
-
<DropdownMenuItem
|
|
60
|
-
className="cursor-pointer"
|
|
61
|
-
onClick={() => updateTheme({ primary: 'dark' })}
|
|
62
|
-
disabled={primaryTheme === 'dark'}
|
|
63
|
-
>
|
|
64
|
-
{primaryTheme === 'dark' ? (
|
|
65
|
-
<Check className="h-4 w-4 text-dynamic-purple" />
|
|
66
|
-
) : (
|
|
67
|
-
<Moon className="h-4 w-4 text-dynamic-purple" />
|
|
68
|
-
)}
|
|
69
|
-
|
|
70
|
-
{t('dark')}
|
|
71
|
-
</DropdownMenuItem>
|
|
72
|
-
|
|
73
|
-
<DropdownMenuSeparator />
|
|
74
|
-
|
|
75
|
-
<DropdownMenuItem
|
|
76
|
-
className="cursor-pointer"
|
|
77
|
-
onClick={() => setTheme('system')}
|
|
78
|
-
disabled={isSystem}
|
|
79
|
-
>
|
|
80
|
-
{isSystem ? (
|
|
81
|
-
<Check className="h-4 w-4" />
|
|
82
|
-
) : (
|
|
83
|
-
<Monitor className="h-4 w-4" />
|
|
84
|
-
)}
|
|
85
|
-
|
|
86
|
-
{t('system')}
|
|
87
|
-
</DropdownMenuItem>
|
|
88
|
-
</>
|
|
89
|
-
);
|
|
6
|
+
return <SatelliteThemeDropdownItems t={t} />;
|
|
90
7
|
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ArrowLeft } from '@tuturuuu/icons';
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import type { NavLink } from './navigation';
|
|
5
|
+
import {
|
|
6
|
+
findActiveNavigation,
|
|
7
|
+
type NavigationState,
|
|
8
|
+
} from './satellite-shell-utils';
|
|
9
|
+
export function useSatelliteShell({
|
|
10
|
+
pathname,
|
|
11
|
+
links,
|
|
12
|
+
defaultCollapsed = false,
|
|
13
|
+
behavior,
|
|
14
|
+
handleBehaviorChange,
|
|
15
|
+
persistCollapsed,
|
|
16
|
+
backLabel,
|
|
17
|
+
}: {
|
|
18
|
+
pathname: string;
|
|
19
|
+
links: (NavLink | null)[];
|
|
20
|
+
defaultCollapsed?: boolean;
|
|
21
|
+
behavior?: 'expanded' | 'collapsed' | 'hover' | 'hidden';
|
|
22
|
+
handleBehaviorChange?: (
|
|
23
|
+
behavior: 'expanded' | 'collapsed' | 'hover' | 'hidden'
|
|
24
|
+
) => void;
|
|
25
|
+
persistCollapsed?: (collapsed: boolean) => void;
|
|
26
|
+
backLabel: string;
|
|
27
|
+
}) {
|
|
28
|
+
const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);
|
|
29
|
+
const [appsLauncherOpen, setAppsLauncherOpen] = useState(false);
|
|
30
|
+
const [workspaceSelectVisible, setWorkspaceSelectVisible] = useState(false);
|
|
31
|
+
const navigationLinks = useMemo<(NavLink | null)[]>(() => links, [links]);
|
|
32
|
+
const [navState, setNavState] = useState<NavigationState>(() => {
|
|
33
|
+
const activeNavigation = findActiveNavigation({
|
|
34
|
+
currentPath: pathname,
|
|
35
|
+
navLinks: navigationLinks,
|
|
36
|
+
});
|
|
37
|
+
return (
|
|
38
|
+
activeNavigation ?? {
|
|
39
|
+
currentLinks: navigationLinks,
|
|
40
|
+
direction: 'forward',
|
|
41
|
+
history: [],
|
|
42
|
+
titleHistory: [],
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!behavior) return;
|
|
49
|
+
setIsCollapsed(
|
|
50
|
+
behavior === 'collapsed' || behavior === 'hover' || behavior === 'hidden'
|
|
51
|
+
);
|
|
52
|
+
}, [behavior]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (isCollapsed) setWorkspaceSelectVisible(false);
|
|
56
|
+
}, [isCollapsed]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setNavState((prevState) => {
|
|
60
|
+
const activeNavigation = findActiveNavigation({
|
|
61
|
+
currentPath: pathname,
|
|
62
|
+
navLinks: navigationLinks,
|
|
63
|
+
});
|
|
64
|
+
if (activeNavigation) return activeNavigation;
|
|
65
|
+
|
|
66
|
+
if (prevState.history.length > 0) {
|
|
67
|
+
return {
|
|
68
|
+
currentLinks: navigationLinks,
|
|
69
|
+
direction: 'backward',
|
|
70
|
+
history: [],
|
|
71
|
+
titleHistory: [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { ...prevState, currentLinks: navigationLinks };
|
|
76
|
+
});
|
|
77
|
+
}, [navigationLinks, pathname]);
|
|
78
|
+
|
|
79
|
+
const backButton: NavLink = useMemo(
|
|
80
|
+
() => ({
|
|
81
|
+
icon: <ArrowLeft className="h-4 w-4" />,
|
|
82
|
+
isBack: true,
|
|
83
|
+
onClick: () => {
|
|
84
|
+
setNavState((prevState) => {
|
|
85
|
+
const newHistory = prevState.history.slice(0, -1);
|
|
86
|
+
return {
|
|
87
|
+
currentLinks: prevState.history.at(-1) ?? navigationLinks,
|
|
88
|
+
direction: 'backward',
|
|
89
|
+
history: newHistory,
|
|
90
|
+
titleHistory: prevState.titleHistory.slice(0, -1),
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
title: backLabel,
|
|
95
|
+
}),
|
|
96
|
+
[navigationLinks, backLabel]
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const handleToggle = () => {
|
|
100
|
+
if (behavior === 'hidden') {
|
|
101
|
+
setIsCollapsed(true);
|
|
102
|
+
handleBehaviorChange?.('collapsed');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const newCollapsed = !isCollapsed;
|
|
107
|
+
setIsCollapsed(newCollapsed);
|
|
108
|
+
if (newCollapsed) setWorkspaceSelectVisible(false);
|
|
109
|
+
persistCollapsed?.(newCollapsed);
|
|
110
|
+
|
|
111
|
+
if (behavior === 'expanded' && newCollapsed) {
|
|
112
|
+
handleBehaviorChange?.('collapsed');
|
|
113
|
+
} else if (behavior === 'collapsed' && !newCollapsed) {
|
|
114
|
+
handleBehaviorChange?.('expanded');
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const expandSidebar = useCallback(() => {
|
|
119
|
+
setIsCollapsed(false);
|
|
120
|
+
persistCollapsed?.(false);
|
|
121
|
+
|
|
122
|
+
if (behavior !== 'expanded') {
|
|
123
|
+
handleBehaviorChange?.('expanded');
|
|
124
|
+
}
|
|
125
|
+
}, [behavior, handleBehaviorChange, persistCollapsed]);
|
|
126
|
+
|
|
127
|
+
const hasOpenDialogs = useCallback(
|
|
128
|
+
() =>
|
|
129
|
+
document.querySelector('[data-state="open"][role="dialog"]') !== null ||
|
|
130
|
+
document.querySelector('[data-state="open"][role="alertdialog"]') !==
|
|
131
|
+
null,
|
|
132
|
+
[]
|
|
133
|
+
);
|
|
134
|
+
const isHoverMode = behavior === 'hover';
|
|
135
|
+
const onMouseEnter = isHoverMode
|
|
136
|
+
? () => {
|
|
137
|
+
if (!hasOpenDialogs()) setIsCollapsed(false);
|
|
138
|
+
}
|
|
139
|
+
: undefined;
|
|
140
|
+
const onMouseLeave = isHoverMode
|
|
141
|
+
? () => {
|
|
142
|
+
if (!hasOpenDialogs()) setIsCollapsed(true);
|
|
143
|
+
}
|
|
144
|
+
: undefined;
|
|
145
|
+
const closeOnMobile = useCallback(() => {
|
|
146
|
+
if (window.innerWidth < 768) setIsCollapsed(true);
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
isCollapsed,
|
|
151
|
+
setIsCollapsed,
|
|
152
|
+
appsLauncherOpen,
|
|
153
|
+
setAppsLauncherOpen,
|
|
154
|
+
workspaceSelectVisible,
|
|
155
|
+
setWorkspaceSelectVisible,
|
|
156
|
+
navState,
|
|
157
|
+
setNavState,
|
|
158
|
+
backButton,
|
|
159
|
+
handleToggle,
|
|
160
|
+
expandSidebar,
|
|
161
|
+
closeOnMobile,
|
|
162
|
+
onMouseEnter,
|
|
163
|
+
onMouseLeave,
|
|
164
|
+
};
|
|
165
|
+
}
|