@hed-hog/lms 0.0.306 → 0.0.310
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/course/course-structure.controller.d.ts +60 -0
- package/dist/course/course-structure.controller.d.ts.map +1 -1
- package/dist/course/course-structure.controller.js +79 -0
- package/dist/course/course-structure.controller.js.map +1 -1
- package/dist/course/course-structure.service.d.ts +61 -1
- package/dist/course/course-structure.service.d.ts.map +1 -1
- package/dist/course/course-structure.service.js +326 -1
- package/dist/course/course-structure.service.js.map +1 -1
- package/dist/course/course.controller.d.ts +52 -4
- package/dist/course/course.controller.d.ts.map +1 -1
- package/dist/course/course.service.d.ts +52 -5
- package/dist/course/course.service.d.ts.map +1 -1
- package/dist/course/course.service.js +78 -57
- package/dist/course/course.service.js.map +1 -1
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-structure-lesson.dto.js +5 -1
- package/dist/course/dto/create-course-structure-lesson.dto.js.map +1 -1
- package/dist/course/dto/create-course.dto.d.ts +1 -1
- package/dist/course/dto/create-course.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course.dto.js +4 -1
- package/dist/course/dto/create-course.dto.js.map +1 -1
- package/dist/course/dto/move-lesson.dto.d.ts +10 -0
- package/dist/course/dto/move-lesson.dto.d.ts.map +1 -0
- package/dist/course/dto/move-lesson.dto.js +28 -0
- package/dist/course/dto/move-lesson.dto.js.map +1 -0
- package/dist/course/dto/paste-lessons.dto.d.ts +4 -0
- package/dist/course/dto/paste-lessons.dto.d.ts.map +1 -0
- package/dist/course/dto/paste-lessons.dto.js +24 -0
- package/dist/course/dto/paste-lessons.dto.js.map +1 -0
- package/dist/course/dto/reorder-lessons.dto.d.ts +5 -0
- package/dist/course/dto/reorder-lessons.dto.d.ts.map +1 -0
- package/dist/course/dto/reorder-lessons.dto.js +24 -0
- package/dist/course/dto/reorder-lessons.dto.js.map +1 -0
- package/dist/course/dto/reorder-sessions.dto.d.ts +5 -0
- package/dist/course/dto/reorder-sessions.dto.d.ts.map +1 -0
- package/dist/course/dto/reorder-sessions.dto.js +24 -0
- package/dist/course/dto/reorder-sessions.dto.js.map +1 -0
- package/dist/training/training.controller.js +1 -1
- package/dist/training/training.controller.js.map +1 -1
- package/hedhog/data/image_type.yaml +20 -0
- package/hedhog/data/menu.yaml +2 -2
- package/hedhog/data/route.yaml +60 -6
- package/hedhog/frontend/app/_components/class-form-sheet.tsx.ejs +146 -165
- package/hedhog/frontend/app/_components/course-avatar.tsx.ejs +70 -0
- package/hedhog/frontend/app/_components/course-form-sheet.tsx.ejs +372 -22
- package/hedhog/frontend/app/certificates/models/CanvasStage.tsx.ejs +10 -1
- package/hedhog/frontend/app/certificates/models/TopBar.tsx.ejs +44 -3
- package/hedhog/frontend/app/certificates/models/page.tsx.ejs +32 -0
- package/hedhog/frontend/app/classes/[id]/page.tsx.ejs +437 -77
- package/hedhog/frontend/app/classes/page.tsx.ejs +311 -289
- package/hedhog/frontend/app/courses/[id]/_components/CourseCertificateCard.tsx.ejs +10 -7
- package/hedhog/frontend/app/courses/[id]/_components/CourseClassificationCard.tsx.ejs +23 -32
- package/hedhog/frontend/app/courses/[id]/_components/CourseContentCard.tsx.ejs +3 -9
- package/hedhog/frontend/app/courses/[id]/_components/CourseDangerZoneCard.tsx.ejs +26 -16
- package/hedhog/frontend/app/courses/[id]/_components/CourseFlagsCard.tsx.ejs +19 -5
- package/hedhog/frontend/app/courses/[id]/_components/CourseMainInfoCard.tsx.ejs +10 -14
- package/hedhog/frontend/app/courses/[id]/_components/CourseMediaCard.tsx.ejs +131 -107
- package/hedhog/frontend/app/courses/[id]/_components/CourseRelationsCard.tsx.ejs +10 -7
- package/hedhog/frontend/app/courses/[id]/_components/CourseSectionCard.tsx.ejs +38 -19
- package/hedhog/frontend/app/courses/[id]/_components/CourseSummaryCard.tsx.ejs +1 -1
- package/hedhog/frontend/app/courses/[id]/_components/course-edit-types.ts.ejs +1 -1
- package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +336 -1057
- package/hedhog/frontend/app/courses/[id]/structure/_components/confirm-dialog.tsx.ejs +45 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree-dnd.tsx.ejs +362 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree-panel.tsx.ejs +111 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree-skeleton.tsx.ejs +64 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree.tsx.ejs +134 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-course.tsx.ejs +113 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +314 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-panel.tsx.ejs +62 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-session.tsx.ejs +174 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/drag-handle.tsx.ejs +58 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/drag-overlay.tsx.ejs +52 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-bulk.tsx.ejs +276 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +1216 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-lesson.tsx.ejs +1827 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-session.tsx.ejs +443 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/highlighted-text.tsx.ejs +41 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +184 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/multi-select-bar.tsx.ejs +264 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/search-filter.tsx.ejs +96 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/session-picker-dialog.tsx.ejs +74 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/shortcuts-help.tsx.ejs +136 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/sortable-tree-row.tsx.ejs +80 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/store.ts.ejs +948 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-context-menu.tsx.ejs +525 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-display-settings-popover.tsx.ejs +150 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-helpers.ts.ejs +182 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-course.tsx.ejs +52 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-lesson.tsx.ejs +271 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-session.tsx.ejs +167 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row.tsx.ejs +108 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/types.ts.ejs +122 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/use-course-structure-shortcuts.ts.ejs +318 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/use-tree-display-settings.ts.ejs +97 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/adapters/course-structure.adapter.ts.ejs +347 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/course-structure-contract.ts.ejs +195 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/services/course-structure.service.ts.ejs +420 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/types/api-course.types.ts.ejs +254 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-mutations.ts.ejs +987 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-query.ts.ejs +86 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure.ts.ejs +160 -0
- package/hedhog/frontend/app/courses/[id]/structure/page.tsx.ejs +10 -3212
- package/hedhog/frontend/app/courses/page.tsx.ejs +45 -26
- package/hedhog/frontend/app/{training → paths}/page.tsx.ejs +29 -7
- package/hedhog/frontend/messages/en.json +91 -11
- package/hedhog/frontend/messages/pt.json +91 -11
- package/hedhog/table/course.yaml +1 -1
- package/hedhog/table/image_type.yaml +14 -0
- package/package.json +7 -7
- package/src/course/course-structure.controller.ts +63 -0
- package/src/course/course-structure.service.ts +390 -3
- package/src/course/course.service.ts +59 -27
- package/src/course/dto/create-course-structure-lesson.dto.ts +3 -2
- package/src/course/dto/create-course.dto.ts +4 -1
- package/src/course/dto/move-lesson.dto.ts +17 -0
- package/src/course/dto/paste-lessons.dto.ts +9 -0
- package/src/course/dto/reorder-lessons.dto.ts +10 -0
- package/src/course/dto/reorder-sessions.dto.ts +10 -0
- package/src/training/training.controller.ts +1 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button } from '@/components/ui/button';
|
|
4
|
+
import { Separator } from '@/components/ui/separator';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
import { Copy, FolderOpen, Loader2, Trash2, X } from 'lucide-react';
|
|
7
|
+
import { toast } from 'sonner';
|
|
8
|
+
import {
|
|
9
|
+
useBulkDeleteMutation,
|
|
10
|
+
useDuplicateLessonMutation,
|
|
11
|
+
useDuplicateSessionMutation,
|
|
12
|
+
useMoveLessonsMutation,
|
|
13
|
+
} from '../_data/use-course-structure-mutations';
|
|
14
|
+
import { useStructureStore } from './store';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Compact action bar shown when 2+ items are selected.
|
|
18
|
+
* Fixed below the search toolbar inside CourseTreePanel.
|
|
19
|
+
*/
|
|
20
|
+
export function MultiSelectBar() {
|
|
21
|
+
const selectedIds = useStructureStore((s) => s.selectedIds);
|
|
22
|
+
const lessons = useStructureStore((s) => s.lessons);
|
|
23
|
+
const sessions = useStructureStore((s) => s.sessions);
|
|
24
|
+
const clearSelection = useStructureStore((s) => s.clearSelection);
|
|
25
|
+
const copyItems = useStructureStore((s) => s.copyItems);
|
|
26
|
+
const showConfirm = useStructureStore((s) => s.showConfirm);
|
|
27
|
+
const showSessionPicker = useStructureStore((s) => s.showSessionPicker);
|
|
28
|
+
|
|
29
|
+
const bulkDelete = useBulkDeleteMutation();
|
|
30
|
+
const duplicateLessonMutation = useDuplicateLessonMutation();
|
|
31
|
+
const duplicateSessionMutation = useDuplicateSessionMutation();
|
|
32
|
+
const moveLessonsMutation = useMoveLessonsMutation();
|
|
33
|
+
|
|
34
|
+
const isDuplicating =
|
|
35
|
+
duplicateLessonMutation.isPending || duplicateSessionMutation.isPending;
|
|
36
|
+
const isMoving = moveLessonsMutation.isPending;
|
|
37
|
+
|
|
38
|
+
const count = selectedIds.size;
|
|
39
|
+
if (count <= 1) return null;
|
|
40
|
+
|
|
41
|
+
const selectedLessonIds = lessons
|
|
42
|
+
.filter((l) => selectedIds.has(`lesson:${l.id}`))
|
|
43
|
+
.map((l) => l.id);
|
|
44
|
+
const selectedSessionIds = sessions
|
|
45
|
+
.filter((ss) => selectedIds.has(`session:${ss.id}`))
|
|
46
|
+
.map((ss) => ss.id);
|
|
47
|
+
|
|
48
|
+
const allAreLessons = selectedLessonIds.length === count;
|
|
49
|
+
const allAreSessions = selectedSessionIds.length === count;
|
|
50
|
+
|
|
51
|
+
const label = allAreLessons
|
|
52
|
+
? `${count} aulas`
|
|
53
|
+
: allAreSessions
|
|
54
|
+
? `${count} sessões`
|
|
55
|
+
: `${count} itens`;
|
|
56
|
+
|
|
57
|
+
const canMove = allAreLessons && sessions.length > 1;
|
|
58
|
+
|
|
59
|
+
function handleCopy() {
|
|
60
|
+
if (allAreLessons) {
|
|
61
|
+
copyItems(selectedLessonIds, 'lesson');
|
|
62
|
+
toast.success(`${count} aulas copiadas`);
|
|
63
|
+
} else if (allAreSessions) {
|
|
64
|
+
copyItems(selectedSessionIds, 'session');
|
|
65
|
+
toast.success(`${count} sessões copiadas`);
|
|
66
|
+
} else {
|
|
67
|
+
toast('Selecione apenas aulas ou apenas sessões para copiar.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function handleDuplicate() {
|
|
72
|
+
if (allAreLessons) {
|
|
73
|
+
// Duplicate each lesson sequentially
|
|
74
|
+
const duplicateNext = (index: number) => {
|
|
75
|
+
if (index >= selectedLessonIds.length) return;
|
|
76
|
+
const lessonId = selectedLessonIds[index]!;
|
|
77
|
+
const lesson = lessons.find((l) => l.id === lessonId);
|
|
78
|
+
if (!lesson) return;
|
|
79
|
+
duplicateLessonMutation.mutate(
|
|
80
|
+
{ sessionId: lesson.sessionId, lessonId },
|
|
81
|
+
{ onSettled: () => duplicateNext(index + 1) }
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
duplicateNext(0);
|
|
85
|
+
toast.success(`${count} aulas sendo duplicadas...`);
|
|
86
|
+
} else if (allAreSessions) {
|
|
87
|
+
const duplicateNext = (index: number) => {
|
|
88
|
+
if (index >= selectedSessionIds.length) return;
|
|
89
|
+
duplicateSessionMutation.mutate(
|
|
90
|
+
{ sessionId: selectedSessionIds[index]! },
|
|
91
|
+
{ onSettled: () => duplicateNext(index + 1) }
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
duplicateNext(0);
|
|
95
|
+
toast.success(`${count} sessões sendo duplicadas...`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function handleMove() {
|
|
100
|
+
if (!allAreLessons) return;
|
|
101
|
+
const parentSessionIds = new Set(
|
|
102
|
+
lessons
|
|
103
|
+
.filter((l) => selectedLessonIds.includes(l.id))
|
|
104
|
+
.map((l) => l.sessionId)
|
|
105
|
+
);
|
|
106
|
+
const excludeSessionId =
|
|
107
|
+
parentSessionIds.size === 1 ? ([...parentSessionIds][0] ?? null) : null;
|
|
108
|
+
|
|
109
|
+
showSessionPicker({
|
|
110
|
+
title: `Mover ${count} aulas para`,
|
|
111
|
+
excludeSessionId,
|
|
112
|
+
onPick: (targetId) => {
|
|
113
|
+
const previousLessons = [...lessons];
|
|
114
|
+
const movingLessons = selectedLessonIds
|
|
115
|
+
.map((id) => lessons.find((l) => l.id === id))
|
|
116
|
+
.filter(Boolean) as import('./types').Lesson[];
|
|
117
|
+
const moves = movingLessons.map((l, i) => ({
|
|
118
|
+
lessonId: l.id,
|
|
119
|
+
fromSessionId: l.sessionId,
|
|
120
|
+
toSessionId: targetId,
|
|
121
|
+
toIndex: i,
|
|
122
|
+
}));
|
|
123
|
+
// Optimistic
|
|
124
|
+
useStructureStore.getState().moveLessons(selectedLessonIds, targetId);
|
|
125
|
+
moveLessonsMutation.mutate({ moves, previousLessons });
|
|
126
|
+
toast.success(`${count} aulas movidas`);
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleDelete() {
|
|
132
|
+
// Compute the split: sessions + orphan lessons (lessons whose session is NOT deleted)
|
|
133
|
+
const sessionIdSet = new Set(selectedSessionIds);
|
|
134
|
+
const orphanLessons = lessons
|
|
135
|
+
.filter(
|
|
136
|
+
(l) =>
|
|
137
|
+
selectedIds.has(`lesson:${l.id}`) && !sessionIdSet.has(l.sessionId)
|
|
138
|
+
)
|
|
139
|
+
.map((l) => ({ lessonId: l.id, sessionId: l.sessionId }));
|
|
140
|
+
|
|
141
|
+
showConfirm({
|
|
142
|
+
title: `Excluir ${label}?`,
|
|
143
|
+
description: allAreSessions
|
|
144
|
+
? 'As sessões e todas as suas aulas serão excluídas permanentemente.'
|
|
145
|
+
: 'Esta ação não pode ser desfeita.',
|
|
146
|
+
onConfirm: () =>
|
|
147
|
+
bulkDelete.mutate({
|
|
148
|
+
sessionIds: selectedSessionIds,
|
|
149
|
+
lessons: orphanLessons,
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<div
|
|
156
|
+
role="toolbar"
|
|
157
|
+
aria-label={`${count} itens selecionados — ações`}
|
|
158
|
+
className={cn(
|
|
159
|
+
'flex items-center gap-0.5 px-2 py-1 shrink-0 border-b',
|
|
160
|
+
'bg-primary/5 dark:bg-primary/10'
|
|
161
|
+
)}
|
|
162
|
+
>
|
|
163
|
+
{/* Count chip */}
|
|
164
|
+
<span
|
|
165
|
+
className={cn(
|
|
166
|
+
'text-[0.65rem] font-semibold px-1.5 py-0.5 rounded-md mr-1 shrink-0',
|
|
167
|
+
'bg-primary/15 text-primary leading-none'
|
|
168
|
+
)}
|
|
169
|
+
>
|
|
170
|
+
{label}
|
|
171
|
+
</span>
|
|
172
|
+
|
|
173
|
+
<div className="flex-1" />
|
|
174
|
+
|
|
175
|
+
{/* Copy */}
|
|
176
|
+
<Button
|
|
177
|
+
variant="ghost"
|
|
178
|
+
size="icon"
|
|
179
|
+
className="size-6 text-muted-foreground hover:text-foreground"
|
|
180
|
+
title="Copiar selecionados (Ctrl+C)"
|
|
181
|
+
aria-label="Copiar selecionados"
|
|
182
|
+
onClick={handleCopy}
|
|
183
|
+
>
|
|
184
|
+
<Copy className="size-3" />
|
|
185
|
+
</Button>
|
|
186
|
+
|
|
187
|
+
{/* Duplicate */}
|
|
188
|
+
<Button
|
|
189
|
+
variant="ghost"
|
|
190
|
+
size="icon"
|
|
191
|
+
className="size-6 text-muted-foreground hover:text-foreground"
|
|
192
|
+
title="Duplicar selecionados (Ctrl+D)"
|
|
193
|
+
aria-label="Duplicar selecionados"
|
|
194
|
+
disabled={isDuplicating}
|
|
195
|
+
onClick={handleDuplicate}
|
|
196
|
+
>
|
|
197
|
+
{isDuplicating ? (
|
|
198
|
+
<Loader2 className="size-3 animate-spin" />
|
|
199
|
+
) : (
|
|
200
|
+
<svg
|
|
201
|
+
viewBox="0 0 24 24"
|
|
202
|
+
className="size-3 fill-none stroke-current stroke-2"
|
|
203
|
+
strokeLinecap="round"
|
|
204
|
+
strokeLinejoin="round"
|
|
205
|
+
aria-hidden
|
|
206
|
+
>
|
|
207
|
+
<rect x="9" y="9" width="13" height="13" rx="2" />
|
|
208
|
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
|
|
209
|
+
</svg>
|
|
210
|
+
)}
|
|
211
|
+
</Button>
|
|
212
|
+
|
|
213
|
+
{/* Move (lessons only) */}
|
|
214
|
+
{canMove && (
|
|
215
|
+
<Button
|
|
216
|
+
variant="ghost"
|
|
217
|
+
size="icon"
|
|
218
|
+
className="size-6 text-muted-foreground hover:text-foreground"
|
|
219
|
+
title="Mover para outra sessão"
|
|
220
|
+
aria-label="Mover para outra sessão"
|
|
221
|
+
disabled={isMoving}
|
|
222
|
+
onClick={handleMove}
|
|
223
|
+
>
|
|
224
|
+
{isMoving ? (
|
|
225
|
+
<Loader2 className="size-3 animate-spin" />
|
|
226
|
+
) : (
|
|
227
|
+
<FolderOpen className="size-3" />
|
|
228
|
+
)}
|
|
229
|
+
</Button>
|
|
230
|
+
)}
|
|
231
|
+
|
|
232
|
+
{/* Delete */}
|
|
233
|
+
<Button
|
|
234
|
+
variant="ghost"
|
|
235
|
+
size="icon"
|
|
236
|
+
className="size-6 text-destructive/60 hover:text-destructive"
|
|
237
|
+
title="Excluir selecionados (Delete)"
|
|
238
|
+
aria-label="Excluir selecionados"
|
|
239
|
+
disabled={bulkDelete.isPending}
|
|
240
|
+
onClick={handleDelete}
|
|
241
|
+
>
|
|
242
|
+
{bulkDelete.isPending ? (
|
|
243
|
+
<Loader2 className="size-3 animate-spin" />
|
|
244
|
+
) : (
|
|
245
|
+
<Trash2 className="size-3" />
|
|
246
|
+
)}
|
|
247
|
+
</Button>
|
|
248
|
+
|
|
249
|
+
<Separator orientation="vertical" className="mx-0.5 h-3.5" />
|
|
250
|
+
|
|
251
|
+
{/* Deselect */}
|
|
252
|
+
<Button
|
|
253
|
+
variant="ghost"
|
|
254
|
+
size="icon"
|
|
255
|
+
className="size-6 text-muted-foreground hover:text-foreground"
|
|
256
|
+
title="Limpar seleção (Escape)"
|
|
257
|
+
aria-label="Limpar seleção"
|
|
258
|
+
onClick={clearSelection}
|
|
259
|
+
>
|
|
260
|
+
<X className="size-3" />
|
|
261
|
+
</Button>
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Search, X } from 'lucide-react';
|
|
4
|
+
import { useTranslations } from 'next-intl';
|
|
5
|
+
import {
|
|
6
|
+
forwardRef,
|
|
7
|
+
useEffect,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
|
|
13
|
+
import { Button } from '@/components/ui/button';
|
|
14
|
+
import { Input } from '@/components/ui/input';
|
|
15
|
+
import { cn } from '@/lib/utils';
|
|
16
|
+
import { useDebounce } from '@/hooks/use-debounce';
|
|
17
|
+
import { useStructureStore } from './store';
|
|
18
|
+
|
|
19
|
+
export interface SearchFilterHandle {
|
|
20
|
+
focus(): void;
|
|
21
|
+
clear(): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface SearchFilterProps {
|
|
25
|
+
/** Number of matching items to show alongside the input. */
|
|
26
|
+
resultCount?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SearchFilter = forwardRef<SearchFilterHandle, SearchFilterProps>(
|
|
30
|
+
({ resultCount }, ref) => {
|
|
31
|
+
const t = useTranslations('lms.CoursesPage.StructurePage');
|
|
32
|
+
const setFilter = useStructureStore((s) => s.setFilter);
|
|
33
|
+
const [value, setValue] = useState('');
|
|
34
|
+
const debounced = useDebounce(value, 250);
|
|
35
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setFilter(debounced);
|
|
39
|
+
}, [debounced, setFilter]);
|
|
40
|
+
|
|
41
|
+
useImperativeHandle(ref, () => ({
|
|
42
|
+
focus() {
|
|
43
|
+
inputRef.current?.focus();
|
|
44
|
+
inputRef.current?.select();
|
|
45
|
+
},
|
|
46
|
+
clear() {
|
|
47
|
+
setValue('');
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const isActive = value.trim().length > 0;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="relative">
|
|
55
|
+
<Search
|
|
56
|
+
className={cn(
|
|
57
|
+
'absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 pointer-events-none transition-colors',
|
|
58
|
+
isActive ? 'text-primary' : 'text-muted-foreground'
|
|
59
|
+
)}
|
|
60
|
+
aria-hidden
|
|
61
|
+
/>
|
|
62
|
+
<Input
|
|
63
|
+
ref={inputRef}
|
|
64
|
+
value={value}
|
|
65
|
+
onChange={(e) => setValue(e.target.value)}
|
|
66
|
+
placeholder={t('search.placeholder')}
|
|
67
|
+
className={cn(
|
|
68
|
+
'pl-8 h-8 text-sm transition-colors',
|
|
69
|
+
isActive ? 'pr-16 ring-1 ring-primary/30' : 'pr-2'
|
|
70
|
+
)}
|
|
71
|
+
aria-label="Buscar sessões e aulas"
|
|
72
|
+
/>
|
|
73
|
+
{isActive && (
|
|
74
|
+
<div className="absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-1">
|
|
75
|
+
{resultCount !== undefined && (
|
|
76
|
+
<span className="text-[0.6rem] text-muted-foreground tabular-nums leading-none">
|
|
77
|
+
{resultCount}
|
|
78
|
+
</span>
|
|
79
|
+
)}
|
|
80
|
+
<Button
|
|
81
|
+
variant="ghost"
|
|
82
|
+
size="icon"
|
|
83
|
+
className="size-5 rounded-sm shrink-0"
|
|
84
|
+
onClick={() => setValue('')}
|
|
85
|
+
aria-label="Limpar busca"
|
|
86
|
+
>
|
|
87
|
+
<X className="size-3" />
|
|
88
|
+
</Button>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
SearchFilter.displayName = 'SearchFilter';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { FolderOpen } from 'lucide-react';
|
|
4
|
+
import {
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogHeader,
|
|
8
|
+
DialogTitle,
|
|
9
|
+
} from '@/components/ui/dialog';
|
|
10
|
+
import { ScrollArea } from '@/components/ui/scroll-area';
|
|
11
|
+
import { cn } from '@/lib/utils';
|
|
12
|
+
import { useStructureStore } from './store';
|
|
13
|
+
|
|
14
|
+
export function SessionPickerDialog() {
|
|
15
|
+
const sessions = useStructureStore((s) => s.sessions);
|
|
16
|
+
const lessons = useStructureStore((s) => s.lessons);
|
|
17
|
+
const sessionPickerDialog = useStructureStore((s) => s.sessionPickerDialog);
|
|
18
|
+
const closeSessionPicker = useStructureStore((s) => s.closeSessionPicker);
|
|
19
|
+
|
|
20
|
+
const sorted = [...sessions].sort((a, b) => a.order - b.order);
|
|
21
|
+
const visibleSessions = sorted.filter(
|
|
22
|
+
(ss) => ss.id !== sessionPickerDialog.excludeSessionId
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
function handlePick(sessionId: string) {
|
|
26
|
+
sessionPickerDialog.onPick?.(sessionId);
|
|
27
|
+
closeSessionPicker();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Dialog
|
|
32
|
+
open={sessionPickerDialog.open}
|
|
33
|
+
onOpenChange={(open) => !open && closeSessionPicker()}
|
|
34
|
+
>
|
|
35
|
+
<DialogContent className="max-w-xs p-0 gap-0">
|
|
36
|
+
<DialogHeader className="px-4 py-3 border-b">
|
|
37
|
+
<DialogTitle className="text-sm flex items-center gap-2">
|
|
38
|
+
<FolderOpen className="size-4 text-muted-foreground" />
|
|
39
|
+
{sessionPickerDialog.title}
|
|
40
|
+
</DialogTitle>
|
|
41
|
+
</DialogHeader>
|
|
42
|
+
|
|
43
|
+
<ScrollArea className="max-h-72">
|
|
44
|
+
<div className="flex flex-col p-2 gap-0.5">
|
|
45
|
+
{visibleSessions.length === 0 && (
|
|
46
|
+
<p className="text-xs text-muted-foreground text-center py-4">
|
|
47
|
+
Nenhuma sessão disponível.
|
|
48
|
+
</p>
|
|
49
|
+
)}
|
|
50
|
+
{visibleSessions.map((ss) => {
|
|
51
|
+
const count = lessons.filter((l) => l.sessionId === ss.id).length;
|
|
52
|
+
return (
|
|
53
|
+
<button
|
|
54
|
+
key={ss.id}
|
|
55
|
+
onClick={() => handlePick(ss.id)}
|
|
56
|
+
className={cn(
|
|
57
|
+
'flex items-center gap-2 px-2.5 py-2 rounded-md text-left text-sm',
|
|
58
|
+
'hover:bg-accent transition-colors cursor-pointer'
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
<FolderOpen className="size-3.5 shrink-0 text-muted-foreground" />
|
|
62
|
+
<span className="flex-1 truncate font-medium">{ss.title}</span>
|
|
63
|
+
<span className="text-[0.65rem] text-muted-foreground shrink-0">
|
|
64
|
+
{count} aulas
|
|
65
|
+
</span>
|
|
66
|
+
</button>
|
|
67
|
+
);
|
|
68
|
+
})}
|
|
69
|
+
</div>
|
|
70
|
+
</ScrollArea>
|
|
71
|
+
</DialogContent>
|
|
72
|
+
</Dialog>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Keyboard } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { Badge } from '@/components/ui/badge';
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import {
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogHeader,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
} from '@/components/ui/dialog';
|
|
13
|
+
import { Separator } from '@/components/ui/separator';
|
|
14
|
+
|
|
15
|
+
// ── Data ──────────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
const SHORTCUT_GROUPS: {
|
|
18
|
+
heading: string;
|
|
19
|
+
items: { keys: string[]; description: string }[];
|
|
20
|
+
}[] = [
|
|
21
|
+
{
|
|
22
|
+
heading: 'Navegação',
|
|
23
|
+
items: [
|
|
24
|
+
{ keys: ['↑', '↓'], description: 'Navegar entre itens' },
|
|
25
|
+
{ keys: ['→'], description: 'Expandir sessão selecionada' },
|
|
26
|
+
{ keys: ['←'], description: 'Recolher sessão / ir para pai' },
|
|
27
|
+
{ keys: ['Enter'], description: 'Focar primeiro campo do editor' },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
heading: 'Ações',
|
|
32
|
+
items: [
|
|
33
|
+
{ keys: ['Ctrl', 'S'], description: 'Salvar formulário do painel' },
|
|
34
|
+
{ keys: ['Ctrl', 'N'], description: 'Criar nova sessão ou aula' },
|
|
35
|
+
{ keys: ['Ctrl', 'C'], description: 'Copiar item selecionado' },
|
|
36
|
+
{ keys: ['Ctrl', 'V'], description: 'Colar no contexto atual' },
|
|
37
|
+
{ keys: ['Ctrl', 'D'], description: 'Duplicar item' },
|
|
38
|
+
{ keys: ['Delete'], description: 'Excluir item(ns) selecionado(s)' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
heading: 'Busca & Interface',
|
|
43
|
+
items: [
|
|
44
|
+
{ keys: ['Ctrl', 'F'], description: 'Focar campo de busca' },
|
|
45
|
+
{ keys: ['Ctrl', '/'], description: 'Abrir ajuda de atalhos' },
|
|
46
|
+
{ keys: ['Esc'], description: 'Limpar busca / seleção / foco' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
// ── Component ─────────────────────────────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
interface ShortcutsHelpProps {
|
|
54
|
+
open: boolean;
|
|
55
|
+
onOpenChange: (open: boolean) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function ShortcutsHelp({ open, onOpenChange }: ShortcutsHelpProps) {
|
|
59
|
+
return (
|
|
60
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
61
|
+
<DialogContent className="max-w-sm">
|
|
62
|
+
<DialogHeader>
|
|
63
|
+
<DialogTitle className="flex items-center gap-2">
|
|
64
|
+
<Keyboard className="size-4" />
|
|
65
|
+
Atalhos de teclado
|
|
66
|
+
</DialogTitle>
|
|
67
|
+
</DialogHeader>
|
|
68
|
+
|
|
69
|
+
<div className="flex flex-col gap-4 mt-1">
|
|
70
|
+
{SHORTCUT_GROUPS.map((group, gi) => (
|
|
71
|
+
<div key={gi}>
|
|
72
|
+
<p className="text-[0.65rem] font-semibold uppercase tracking-wider text-muted-foreground mb-2">
|
|
73
|
+
{group.heading}
|
|
74
|
+
</p>
|
|
75
|
+
<div className="flex flex-col gap-1.5">
|
|
76
|
+
{group.items.map(({ keys, description }, ki) => (
|
|
77
|
+
<div
|
|
78
|
+
key={ki}
|
|
79
|
+
className="flex items-center justify-between gap-3"
|
|
80
|
+
>
|
|
81
|
+
<span className="text-sm text-muted-foreground">
|
|
82
|
+
{description}
|
|
83
|
+
</span>
|
|
84
|
+
<div className="flex items-center gap-1 shrink-0">
|
|
85
|
+
{keys.map((k, i) => (
|
|
86
|
+
<Badge
|
|
87
|
+
key={i}
|
|
88
|
+
variant="outline"
|
|
89
|
+
className="h-5 px-1.5 text-[0.65rem] font-mono font-medium"
|
|
90
|
+
>
|
|
91
|
+
{k}
|
|
92
|
+
</Badge>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
))}
|
|
97
|
+
</div>
|
|
98
|
+
{gi < SHORTCUT_GROUPS.length - 1 && (
|
|
99
|
+
<Separator className="mt-3" />
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
))}
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<p className="text-[0.65rem] text-muted-foreground mt-1">
|
|
106
|
+
Atalhos são desativados quando o foco está em inputs, exceto Ctrl+S,
|
|
107
|
+
Ctrl+F e Ctrl+/ que funcionam em qualquer contexto.
|
|
108
|
+
</p>
|
|
109
|
+
</DialogContent>
|
|
110
|
+
</Dialog>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Convenience trigger button — renders standalone when no external state is needed.
|
|
116
|
+
*/
|
|
117
|
+
export function ShortcutsHelpTrigger({ onOpen }: { onOpen: () => void }) {
|
|
118
|
+
return (
|
|
119
|
+
<Button
|
|
120
|
+
variant="ghost"
|
|
121
|
+
size="sm"
|
|
122
|
+
className="h-8 gap-1.5 text-xs text-muted-foreground hover:text-foreground"
|
|
123
|
+
onClick={onOpen}
|
|
124
|
+
title="Atalhos de teclado (Ctrl+/)"
|
|
125
|
+
>
|
|
126
|
+
<Keyboard className="size-3.5" />
|
|
127
|
+
Atalhos
|
|
128
|
+
<Badge
|
|
129
|
+
variant="outline"
|
|
130
|
+
className="h-4 px-1 text-[0.6rem] font-mono ml-0.5"
|
|
131
|
+
>
|
|
132
|
+
Ctrl+/
|
|
133
|
+
</Badge>
|
|
134
|
+
</Button>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useSortable } from '@dnd-kit/sortable';
|
|
4
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
5
|
+
|
|
6
|
+
import { DragHandle } from './drag-handle';
|
|
7
|
+
import { TreeRow } from './tree-row';
|
|
8
|
+
import type { FlatItem } from './types';
|
|
9
|
+
|
|
10
|
+
interface SortableTreeRowProps {
|
|
11
|
+
item: FlatItem;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
isSelected: boolean;
|
|
14
|
+
query: string;
|
|
15
|
+
isMatched: boolean;
|
|
16
|
+
isEffectivelyExpanded: boolean;
|
|
17
|
+
lessonCountMap: Map<string, number>;
|
|
18
|
+
visibleItems: FlatItem[];
|
|
19
|
+
/** When true (filter active) drag is disabled. */
|
|
20
|
+
dragDisabled: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function SortableTreeRow({
|
|
24
|
+
item,
|
|
25
|
+
isActive,
|
|
26
|
+
isSelected,
|
|
27
|
+
query,
|
|
28
|
+
isMatched,
|
|
29
|
+
isEffectivelyExpanded,
|
|
30
|
+
lessonCountMap,
|
|
31
|
+
visibleItems,
|
|
32
|
+
dragDisabled,
|
|
33
|
+
}: SortableTreeRowProps) {
|
|
34
|
+
const {
|
|
35
|
+
attributes,
|
|
36
|
+
listeners,
|
|
37
|
+
setNodeRef,
|
|
38
|
+
transform,
|
|
39
|
+
transition,
|
|
40
|
+
isDragging,
|
|
41
|
+
} = useSortable({
|
|
42
|
+
id: `${item.type}:${item.id}`,
|
|
43
|
+
disabled: dragDisabled || item.type === 'course',
|
|
44
|
+
data: { item },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const style: React.CSSProperties = {
|
|
48
|
+
transform: CSS.Transform.toString(transform),
|
|
49
|
+
transition,
|
|
50
|
+
opacity: isDragging ? 0.35 : undefined,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div ref={setNodeRef} style={style} className="flex items-stretch h-full">
|
|
55
|
+
{/* Drag handle — only for sortable types */}
|
|
56
|
+
{item.type !== 'course' && (
|
|
57
|
+
<DragHandle
|
|
58
|
+
listeners={listeners}
|
|
59
|
+
attributes={attributes}
|
|
60
|
+
disabled={dragDisabled}
|
|
61
|
+
className="my-auto"
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
{/* Row content fills remaining space */}
|
|
66
|
+
<div className="flex-1 min-w-0">
|
|
67
|
+
<TreeRow
|
|
68
|
+
item={item}
|
|
69
|
+
isActive={isActive}
|
|
70
|
+
isSelected={isSelected}
|
|
71
|
+
query={query}
|
|
72
|
+
isMatched={isMatched}
|
|
73
|
+
isEffectivelyExpanded={isEffectivelyExpanded}
|
|
74
|
+
lessonCountMap={lessonCountMap}
|
|
75
|
+
visibleItems={visibleItems}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|