@mhmttosun/dnd 0.0.0-stage → 1.1.1

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.
@@ -0,0 +1,102 @@
1
+ export interface ActivityProject {
2
+ schemaVersion: 1;
3
+ version: string;
4
+ project: {
5
+ id: string;
6
+ name: string;
7
+ activityType: 'image-labeling' | 'matching' | 'categorization' | 'sequencing';
8
+ };
9
+ stage: {
10
+ width: number;
11
+ height: number;
12
+ backgroundColor?: string;
13
+ backgroundImage?: string | null;
14
+ };
15
+ objects: Array<{
16
+ id: string;
17
+ type: string;
18
+ role: 'draggable' | 'target' | 'category' | 'sequence_slot' | 'decorative';
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ text?: string;
24
+ src?: string | null;
25
+ backgroundColor?: string;
26
+ borderColor?: string;
27
+ borderWidth?: number;
28
+ borderRadius?: number;
29
+ zIndex?: number;
30
+ }>;
31
+ answerKey: Record<string, string>;
32
+ settings?: {
33
+ soundEnabled?: boolean;
34
+ shuffleDraggables?: boolean;
35
+ evaluationMode?: 'instant' | 'submit';
36
+ correctAnswerBehavior?: 'lock' | 'stay';
37
+ wrongAnswerBehavior?: 'return' | 'stay';
38
+ completionMessage?: string;
39
+ };
40
+ }
41
+
42
+ export interface ActivityStats {
43
+ score: number;
44
+ attempts: number;
45
+ correctCount: number;
46
+ }
47
+
48
+ export interface ActivityState {
49
+ isCompleted: boolean;
50
+ score: number;
51
+ attempts: number;
52
+ correctCount: number;
53
+ totalDraggables: number;
54
+ placedMap: Record<string, string>;
55
+ }
56
+
57
+ export interface DropInfo {
58
+ dragId: string;
59
+ targetId: string;
60
+ isCorrect?: boolean;
61
+ isPending?: boolean;
62
+ }
63
+
64
+ export interface ActivityPlayerOptions {
65
+ target?: HTMLElement | string;
66
+ data?: ActivityProject;
67
+ src?: string;
68
+ file?: File | Blob;
69
+ jsonString?: string;
70
+ sound?: boolean;
71
+ stagePadding?: number | null;
72
+ initialState?: ActivityState;
73
+ onComplete?: (stats: ActivityStats) => void;
74
+ onStep?: (state: ActivityState) => void;
75
+ onDrop?: (dropInfo: DropInfo) => void;
76
+ onReset?: (state: ActivityState) => void;
77
+ onReady?: (player: ActivityPlayer) => void;
78
+ }
79
+
80
+ export declare class ActivityPlayer {
81
+ constructor(options?: ActivityPlayerOptions);
82
+ mount(projectData: ActivityProject): void;
83
+ loadFromUrl(url: string): Promise<void>;
84
+ loadFromFile(file: File | Blob): Promise<void>;
85
+ loadFromJsonString(jsonString: string): void;
86
+ on(event: 'complete' | 'step' | 'drop' | 'reset' | 'destroy', callback: (data: any) => void): () => void;
87
+ off(event: string, callback: (data: any) => void): void;
88
+ getState(): ActivityState | null;
89
+ setState(state: ActivityState): ActivityState;
90
+ setSound(enabled: boolean): void;
91
+ reset(): void;
92
+ destroy(): void;
93
+ }
94
+
95
+ export declare class DNDPlayerElement extends HTMLElement {
96
+ data: ActivityProject | null;
97
+ readonly player: ActivityPlayer | null;
98
+ loadFile(file: File | Blob): void;
99
+ loadJsonString(jsonString: string): void;
100
+ reset(): void;
101
+ getState(): ActivityState | null;
102
+ }