@tuturuuu/ui 0.30.2 → 0.31.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 +41 -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/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
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ArrowBigUpDash, MessageSquareWarning } from '@tuturuuu/icons';
|
|
4
|
+
import { cn } from '@tuturuuu/utils/format';
|
|
5
|
+
import { type ReactNode, useCallback, useRef, useState } from 'react';
|
|
6
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip';
|
|
7
|
+
import { type SatelliteBrandProps, ShellAnchor } from './satellite-brand';
|
|
8
|
+
|
|
9
|
+
type FooterItem = 'upgrade' | 'discord' | 'feedback';
|
|
10
|
+
|
|
11
|
+
export interface SatelliteFooterActionsProps {
|
|
12
|
+
labels: { upgrade: string; feedback: string };
|
|
13
|
+
discordHref?: string;
|
|
14
|
+
onFeedback: () => void;
|
|
15
|
+
LinkComponent?: SatelliteBrandProps['LinkComponent'];
|
|
16
|
+
wsId: string;
|
|
17
|
+
isCollapsed: boolean;
|
|
18
|
+
showUpgrade: boolean;
|
|
19
|
+
upgradeHref?: string;
|
|
20
|
+
upgradeExternal?: boolean;
|
|
21
|
+
}
|
|
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 SatelliteFooterActions({
|
|
42
|
+
labels,
|
|
43
|
+
discordHref,
|
|
44
|
+
onFeedback,
|
|
45
|
+
LinkComponent = ShellAnchor,
|
|
46
|
+
wsId,
|
|
47
|
+
isCollapsed,
|
|
48
|
+
showUpgrade,
|
|
49
|
+
upgradeHref,
|
|
50
|
+
upgradeExternal = false,
|
|
51
|
+
}: SatelliteFooterActionsProps) {
|
|
52
|
+
const [hoveredItem, setHoveredItem] = useState<FooterItem | null>(null);
|
|
53
|
+
const leaveTimer = useRef<ReturnType<typeof setTimeout>>(null);
|
|
54
|
+
// After switching items, ignore mouse events until the CSS transition
|
|
55
|
+
// finishes so layout shifts don't cause the cursor to "see" a different
|
|
56
|
+
// item mid-animation and oscillate.
|
|
57
|
+
const cooldownUntil = useRef(0);
|
|
58
|
+
|
|
59
|
+
const hasDiscord = !!discordHref;
|
|
60
|
+
|
|
61
|
+
const resolvedUpgradeHref = upgradeHref ?? `/${wsId}/billing`;
|
|
62
|
+
|
|
63
|
+
const defaultExpanded: FooterItem = showUpgrade ? 'upgrade' : 'feedback';
|
|
64
|
+
const activeExpanded = hoveredItem ?? defaultExpanded;
|
|
65
|
+
|
|
66
|
+
const handleMouseMove = useCallback((e: React.MouseEvent) => {
|
|
67
|
+
if (leaveTimer.current) {
|
|
68
|
+
clearTimeout(leaveTimer.current);
|
|
69
|
+
leaveTimer.current = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Skip during cooldown -- transition is still running
|
|
73
|
+
if (Date.now() < cooldownUntil.current) return;
|
|
74
|
+
|
|
75
|
+
const target = (e.target as HTMLElement).closest('[data-item]');
|
|
76
|
+
if (!target) return;
|
|
77
|
+
|
|
78
|
+
const item = target.getAttribute('data-item') as FooterItem;
|
|
79
|
+
setHoveredItem((prev) => {
|
|
80
|
+
if (prev === item) return prev;
|
|
81
|
+
// Lock out further changes for the transition duration (200ms + buffer)
|
|
82
|
+
cooldownUntil.current = Date.now() + 250;
|
|
83
|
+
return item;
|
|
84
|
+
});
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
const handleMouseLeave = useCallback(() => {
|
|
88
|
+
leaveTimer.current = setTimeout(() => {
|
|
89
|
+
cooldownUntil.current = Date.now() + 250;
|
|
90
|
+
setHoveredItem(null);
|
|
91
|
+
}, 100);
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
// Collapsed: vertical stack of icon-only buttons
|
|
95
|
+
if (isCollapsed) {
|
|
96
|
+
return (
|
|
97
|
+
<div className="flex w-full flex-col items-center gap-1">
|
|
98
|
+
{showUpgrade && (
|
|
99
|
+
<CollapsedItem
|
|
100
|
+
LinkComponent={LinkComponent}
|
|
101
|
+
href={resolvedUpgradeHref}
|
|
102
|
+
external={upgradeExternal}
|
|
103
|
+
tooltip={labels.upgrade}
|
|
104
|
+
variant="upgrade"
|
|
105
|
+
>
|
|
106
|
+
<ArrowBigUpDash className="h-4.5 w-4.5" />
|
|
107
|
+
</CollapsedItem>
|
|
108
|
+
)}
|
|
109
|
+
{hasDiscord && (
|
|
110
|
+
<CollapsedItem
|
|
111
|
+
LinkComponent={LinkComponent}
|
|
112
|
+
href={discordHref!}
|
|
113
|
+
external
|
|
114
|
+
tooltip="Discord"
|
|
115
|
+
>
|
|
116
|
+
<DiscordIcon className="h-4.5 w-4.5" />
|
|
117
|
+
</CollapsedItem>
|
|
118
|
+
)}
|
|
119
|
+
<CollapsedItem
|
|
120
|
+
LinkComponent={LinkComponent}
|
|
121
|
+
tooltip={labels.feedback}
|
|
122
|
+
onClick={onFeedback}
|
|
123
|
+
>
|
|
124
|
+
<MessageSquareWarning className="h-4.5 w-4.5" />
|
|
125
|
+
</CollapsedItem>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Expanded sidebar: horizontal bar.
|
|
131
|
+
// One item is "active" (expanded with label), others are icon-only.
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
className="flex w-full items-center gap-1"
|
|
135
|
+
onMouseMove={handleMouseMove}
|
|
136
|
+
onMouseLeave={handleMouseLeave}
|
|
137
|
+
>
|
|
138
|
+
{showUpgrade && (
|
|
139
|
+
<FooterAction
|
|
140
|
+
LinkComponent={LinkComponent}
|
|
141
|
+
id="upgrade"
|
|
142
|
+
isActive={activeExpanded === 'upgrade'}
|
|
143
|
+
label={labels.upgrade}
|
|
144
|
+
href={resolvedUpgradeHref}
|
|
145
|
+
external={upgradeExternal}
|
|
146
|
+
variant="upgrade"
|
|
147
|
+
>
|
|
148
|
+
<ArrowBigUpDash className="h-4 w-4 shrink-0" />
|
|
149
|
+
</FooterAction>
|
|
150
|
+
)}
|
|
151
|
+
{hasDiscord && (
|
|
152
|
+
<FooterAction
|
|
153
|
+
LinkComponent={LinkComponent}
|
|
154
|
+
id="discord"
|
|
155
|
+
isActive={activeExpanded === 'discord'}
|
|
156
|
+
label="Discord"
|
|
157
|
+
href={discordHref!}
|
|
158
|
+
external
|
|
159
|
+
>
|
|
160
|
+
<DiscordIcon className="h-4 w-4 shrink-0" />
|
|
161
|
+
</FooterAction>
|
|
162
|
+
)}
|
|
163
|
+
<FooterAction
|
|
164
|
+
LinkComponent={LinkComponent}
|
|
165
|
+
id="feedback"
|
|
166
|
+
isActive={activeExpanded === 'feedback'}
|
|
167
|
+
label={labels.feedback}
|
|
168
|
+
onClick={onFeedback}
|
|
169
|
+
>
|
|
170
|
+
<MessageSquareWarning className="h-4 w-4 shrink-0" />
|
|
171
|
+
</FooterAction>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// --- Sub-components ---
|
|
177
|
+
|
|
178
|
+
interface CollapsedItemProps {
|
|
179
|
+
LinkComponent: NonNullable<SatelliteBrandProps['LinkComponent']>;
|
|
180
|
+
children: ReactNode;
|
|
181
|
+
tooltip: string;
|
|
182
|
+
href?: string;
|
|
183
|
+
external?: boolean;
|
|
184
|
+
onClick?: () => void;
|
|
185
|
+
variant?: 'upgrade' | 'default';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function CollapsedItem({
|
|
189
|
+
LinkComponent: Link,
|
|
190
|
+
children,
|
|
191
|
+
tooltip,
|
|
192
|
+
href,
|
|
193
|
+
external,
|
|
194
|
+
onClick,
|
|
195
|
+
variant = 'default',
|
|
196
|
+
}: CollapsedItemProps) {
|
|
197
|
+
const isUpgrade = variant === 'upgrade';
|
|
198
|
+
|
|
199
|
+
const className = cn(
|
|
200
|
+
'flex h-9 w-9 items-center justify-center rounded-lg transition-all duration-150',
|
|
201
|
+
isUpgrade
|
|
202
|
+
? [
|
|
203
|
+
'group bg-linear-to-br from-dynamic-purple/10 to-dynamic-indigo/10',
|
|
204
|
+
'border border-dynamic-purple/20 text-dynamic-purple',
|
|
205
|
+
'hover:border-dynamic-purple/40 hover:from-dynamic-purple/15 hover:to-dynamic-indigo/15',
|
|
206
|
+
'hover:[box-shadow:0_0_20px_-5px_oklch(var(--dynamic-purple)/0.3)]',
|
|
207
|
+
]
|
|
208
|
+
: 'text-foreground/60 hover:bg-foreground/5 hover:text-foreground'
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const wrappedChildren = isUpgrade ? (
|
|
212
|
+
<span className="transition-transform duration-200 group-hover:-translate-y-0.5 group-hover:scale-110">
|
|
213
|
+
{children}
|
|
214
|
+
</span>
|
|
215
|
+
) : (
|
|
216
|
+
children
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
const content = href ? (
|
|
220
|
+
external ? (
|
|
221
|
+
<a
|
|
222
|
+
href={href}
|
|
223
|
+
target="_blank"
|
|
224
|
+
rel="noopener noreferrer"
|
|
225
|
+
className={className}
|
|
226
|
+
aria-label={tooltip}
|
|
227
|
+
>
|
|
228
|
+
{wrappedChildren}
|
|
229
|
+
</a>
|
|
230
|
+
) : (
|
|
231
|
+
<Link href={href} className={className} aria-label={tooltip}>
|
|
232
|
+
{wrappedChildren}
|
|
233
|
+
</Link>
|
|
234
|
+
)
|
|
235
|
+
) : (
|
|
236
|
+
<button
|
|
237
|
+
type="button"
|
|
238
|
+
onClick={onClick}
|
|
239
|
+
className={className}
|
|
240
|
+
aria-label={tooltip}
|
|
241
|
+
>
|
|
242
|
+
{wrappedChildren}
|
|
243
|
+
</button>
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<Tooltip>
|
|
248
|
+
<TooltipTrigger asChild>{content}</TooltipTrigger>
|
|
249
|
+
<TooltipContent side="right">
|
|
250
|
+
<p>{tooltip}</p>
|
|
251
|
+
</TooltipContent>
|
|
252
|
+
</Tooltip>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface FooterActionProps {
|
|
257
|
+
LinkComponent: NonNullable<SatelliteBrandProps['LinkComponent']>;
|
|
258
|
+
id: FooterItem;
|
|
259
|
+
isActive: boolean;
|
|
260
|
+
label: string;
|
|
261
|
+
children: ReactNode;
|
|
262
|
+
href?: string;
|
|
263
|
+
external?: boolean;
|
|
264
|
+
onClick?: () => void;
|
|
265
|
+
variant?: 'upgrade' | 'default';
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function FooterAction({
|
|
269
|
+
LinkComponent: Link,
|
|
270
|
+
id,
|
|
271
|
+
isActive,
|
|
272
|
+
label,
|
|
273
|
+
children,
|
|
274
|
+
href,
|
|
275
|
+
external,
|
|
276
|
+
onClick,
|
|
277
|
+
variant = id === 'upgrade' ? 'upgrade' : 'default',
|
|
278
|
+
}: FooterActionProps) {
|
|
279
|
+
const isUpgrade = variant === 'upgrade';
|
|
280
|
+
|
|
281
|
+
const className = cn(
|
|
282
|
+
'flex h-9 items-center justify-center gap-1.5 rounded-lg transition-all duration-200',
|
|
283
|
+
isActive ? 'min-w-0 flex-1' : 'w-9 shrink-0',
|
|
284
|
+
isUpgrade
|
|
285
|
+
? [
|
|
286
|
+
'group relative overflow-hidden text-dynamic-purple',
|
|
287
|
+
isActive
|
|
288
|
+
? [
|
|
289
|
+
'border border-dynamic-purple/20 bg-linear-to-r from-dynamic-purple/10 to-dynamic-indigo/8',
|
|
290
|
+
'hover:border-dynamic-purple/35 hover:[box-shadow:0_0_20px_-5px_oklch(var(--dynamic-purple)/0.3)]',
|
|
291
|
+
]
|
|
292
|
+
: 'hover:bg-dynamic-purple/8 hover:[box-shadow:0_0_16px_-4px_oklch(var(--dynamic-purple)/0.2)]',
|
|
293
|
+
]
|
|
294
|
+
: [
|
|
295
|
+
isActive
|
|
296
|
+
? 'bg-foreground/5 text-foreground'
|
|
297
|
+
: 'text-foreground/50 hover:bg-foreground/5 hover:text-foreground/70',
|
|
298
|
+
]
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const inner = (
|
|
302
|
+
<>
|
|
303
|
+
<span
|
|
304
|
+
className={cn(
|
|
305
|
+
'shrink-0 transition-transform duration-200',
|
|
306
|
+
isUpgrade && 'group-hover:scale-110'
|
|
307
|
+
)}
|
|
308
|
+
>
|
|
309
|
+
{children}
|
|
310
|
+
</span>
|
|
311
|
+
{isActive && (
|
|
312
|
+
<span className="truncate font-medium text-sm">{label}</span>
|
|
313
|
+
)}
|
|
314
|
+
{isUpgrade && isActive && (
|
|
315
|
+
<span
|
|
316
|
+
className="pointer-events-none absolute inset-0 animate-[shimmer_4s_ease-in-out_infinite]"
|
|
317
|
+
style={{
|
|
318
|
+
background:
|
|
319
|
+
'linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%)',
|
|
320
|
+
}}
|
|
321
|
+
/>
|
|
322
|
+
)}
|
|
323
|
+
</>
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
// data-item is read by the container's onMouseMove for flicker-free tracking
|
|
327
|
+
const sharedProps = {
|
|
328
|
+
className,
|
|
329
|
+
'data-item': id,
|
|
330
|
+
'aria-label': label,
|
|
331
|
+
} as const;
|
|
332
|
+
|
|
333
|
+
if (href) {
|
|
334
|
+
return external ? (
|
|
335
|
+
<a href={href} target="_blank" rel="noopener noreferrer" {...sharedProps}>
|
|
336
|
+
{inner}
|
|
337
|
+
</a>
|
|
338
|
+
) : (
|
|
339
|
+
<Link href={href} {...sharedProps}>
|
|
340
|
+
{inner}
|
|
341
|
+
</Link>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return (
|
|
346
|
+
<button type="button" onClick={onClick} {...sharedProps}>
|
|
347
|
+
{inner}
|
|
348
|
+
</button>
|
|
349
|
+
);
|
|
350
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Check, Hexagon, Monitor } from '@tuturuuu/icons';
|
|
3
|
+
import { DropdownMenuItem } from '../dropdown-menu';
|
|
4
|
+
export function SatelliteLanguageItem({
|
|
5
|
+
label,
|
|
6
|
+
selected,
|
|
7
|
+
system = false,
|
|
8
|
+
onSelect,
|
|
9
|
+
}: {
|
|
10
|
+
label: string;
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
system?: boolean;
|
|
13
|
+
onSelect: () => void | Promise<void>;
|
|
14
|
+
}) {
|
|
15
|
+
const Icon = selected ? Check : system ? Monitor : Hexagon;
|
|
16
|
+
return (
|
|
17
|
+
<DropdownMenuItem
|
|
18
|
+
className="cursor-pointer"
|
|
19
|
+
onClick={onSelect}
|
|
20
|
+
disabled={selected}
|
|
21
|
+
>
|
|
22
|
+
<Icon className={system ? 'h-4 w-4' : 'h-4 w-4 text-dynamic-indigo'} />
|
|
23
|
+
{label}
|
|
24
|
+
</DropdownMenuItem>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@tuturuuu/utils/format';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import type { NavLink as NavLinkType } from './navigation';
|
|
6
|
+
|
|
7
|
+
export interface SidebarNavigationProps {
|
|
8
|
+
isCollapsed: boolean;
|
|
9
|
+
links: (NavLinkType | null)[];
|
|
10
|
+
className?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
renderLink: (link: NavLinkType) => ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export function SidebarNavigation({
|
|
15
|
+
links,
|
|
16
|
+
isCollapsed,
|
|
17
|
+
className,
|
|
18
|
+
label,
|
|
19
|
+
renderLink,
|
|
20
|
+
}: SidebarNavigationProps) {
|
|
21
|
+
if (!links?.length) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
data-collapsed={isCollapsed}
|
|
28
|
+
className={cn('group flex flex-col gap-y-0.5 p-2', className)}
|
|
29
|
+
>
|
|
30
|
+
<nav aria-label={label} className="grid gap-y-0.5">
|
|
31
|
+
{links.map((link, index) => {
|
|
32
|
+
if (!link) {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
key={`nav-divider-${index}`}
|
|
36
|
+
className={cn(
|
|
37
|
+
'my-1 border-b',
|
|
38
|
+
isCollapsed ? 'mx-auto w-1/2' : 'w-auto'
|
|
39
|
+
)}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const previousSectionLabel = links
|
|
45
|
+
.slice(0, index)
|
|
46
|
+
.reverse()
|
|
47
|
+
.find((previousLink) => previousLink)?.sectionLabel;
|
|
48
|
+
const shouldShowSectionLabel =
|
|
49
|
+
link.sectionLabel && link.sectionLabel !== previousSectionLabel;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div key={`nav-item-${link.href || link.title}-${index}`}>
|
|
53
|
+
{shouldShowSectionLabel && !isCollapsed && (
|
|
54
|
+
<div className="px-2 pt-3 pb-1 first:pt-0">
|
|
55
|
+
<span className="font-semibold text-[11px] text-muted-foreground/80 uppercase tracking-wider">
|
|
56
|
+
{link.sectionLabel}
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
)}
|
|
60
|
+
{renderLink(link)}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
})}
|
|
64
|
+
</nav>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function satelliteNavigationItemClass({
|
|
70
|
+
isCollapsed,
|
|
71
|
+
isActive,
|
|
72
|
+
isDisabled,
|
|
73
|
+
}: {
|
|
74
|
+
isCollapsed: boolean;
|
|
75
|
+
isActive?: boolean;
|
|
76
|
+
isDisabled?: boolean;
|
|
77
|
+
}) {
|
|
78
|
+
return cn(
|
|
79
|
+
'group/navlink flex w-full cursor-pointer items-center justify-between rounded-md p-2 font-medium text-sm',
|
|
80
|
+
isCollapsed && 'justify-center',
|
|
81
|
+
isActive && 'bg-accent text-accent-foreground',
|
|
82
|
+
isDisabled
|
|
83
|
+
? 'cursor-not-allowed opacity-50'
|
|
84
|
+
: 'hover:bg-accent hover:text-accent-foreground'
|
|
85
|
+
);
|
|
86
|
+
}
|