@lessonkit/react 0.3.1 → 0.5.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/README.md +24 -10
- package/dist/index.cjs +369 -85
- package/dist/index.d.cts +46 -16
- package/dist/index.d.ts +46 -16
- package/dist/index.js +367 -80
- package/package.json +7 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import * as _lessonkit_core from '@lessonkit/core';
|
|
4
|
-
import { CourseId, TelemetryUser,
|
|
4
|
+
import { LessonId, CourseId, TelemetryUser, TrackingClient, TelemetryEventName, CheckId, BlockId } from '@lessonkit/core';
|
|
5
5
|
import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
|
|
6
|
+
import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
|
|
7
|
+
export { ThemePresetName } from '@lessonkit/themes';
|
|
8
|
+
|
|
9
|
+
type ProgressState = {
|
|
10
|
+
activeLessonId?: LessonId;
|
|
11
|
+
completedLessonIds: ReadonlySet<LessonId>;
|
|
12
|
+
courseCompleted: boolean;
|
|
13
|
+
};
|
|
6
14
|
|
|
7
15
|
type LessonkitConfig = {
|
|
8
|
-
courseId
|
|
16
|
+
courseId: CourseId;
|
|
9
17
|
session?: {
|
|
10
18
|
sessionId?: string;
|
|
11
19
|
attemptId?: string;
|
|
@@ -13,8 +21,8 @@ type LessonkitConfig = {
|
|
|
13
21
|
};
|
|
14
22
|
tracking?: {
|
|
15
23
|
enabled?: boolean;
|
|
16
|
-
sink?: (event:
|
|
17
|
-
batchSink?: (events:
|
|
24
|
+
sink?: (event: Parameters<TrackingClient["track"]>[0]) => void | Promise<void>;
|
|
25
|
+
batchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
|
|
18
26
|
batch?: {
|
|
19
27
|
enabled?: boolean;
|
|
20
28
|
flushIntervalMs?: number;
|
|
@@ -27,11 +35,7 @@ type LessonkitConfig = {
|
|
|
27
35
|
client?: XAPIClient;
|
|
28
36
|
};
|
|
29
37
|
};
|
|
30
|
-
|
|
31
|
-
activeLessonId?: LessonId;
|
|
32
|
-
completedLessonIds: ReadonlySet<LessonId>;
|
|
33
|
-
courseCompleted: boolean;
|
|
34
|
-
};
|
|
38
|
+
|
|
35
39
|
type LessonkitRuntime = {
|
|
36
40
|
config: LessonkitConfig;
|
|
37
41
|
tracking: TrackingClient;
|
|
@@ -45,39 +49,43 @@ type LessonkitRuntime = {
|
|
|
45
49
|
setActiveLesson: (lessonId: LessonId) => void;
|
|
46
50
|
completeLesson: (lessonId: LessonId) => void;
|
|
47
51
|
completeCourse: () => void;
|
|
48
|
-
track: (name:
|
|
52
|
+
track: (name: TelemetryEventName, data?: unknown, opts?: {
|
|
49
53
|
lessonId?: LessonId;
|
|
50
54
|
}) => void;
|
|
51
55
|
};
|
|
52
56
|
declare function LessonkitProvider(props: {
|
|
53
|
-
config
|
|
57
|
+
config: LessonkitConfig;
|
|
54
58
|
children: React.ReactNode;
|
|
55
59
|
}): react_jsx_runtime.JSX.Element;
|
|
56
60
|
|
|
57
61
|
declare function Course(props: {
|
|
58
62
|
title: string;
|
|
59
|
-
courseId
|
|
63
|
+
courseId: CourseId;
|
|
60
64
|
config?: Omit<React.ComponentProps<typeof LessonkitProvider>["config"], "courseId">;
|
|
61
65
|
children: React.ReactNode;
|
|
62
66
|
}): react_jsx_runtime.JSX.Element;
|
|
63
67
|
declare function Lesson(props: {
|
|
64
68
|
title: string;
|
|
65
|
-
lessonId
|
|
69
|
+
lessonId: LessonId;
|
|
66
70
|
children: React.ReactNode;
|
|
67
71
|
}): react_jsx_runtime.JSX.Element;
|
|
68
72
|
declare function Scenario(props: {
|
|
73
|
+
blockId?: BlockId;
|
|
69
74
|
children: React.ReactNode;
|
|
70
75
|
}): react_jsx_runtime.JSX.Element;
|
|
71
76
|
declare function Reflection(props: {
|
|
77
|
+
blockId?: BlockId;
|
|
72
78
|
prompt?: string;
|
|
73
79
|
children?: React.ReactNode;
|
|
74
80
|
}): react_jsx_runtime.JSX.Element;
|
|
75
81
|
declare function KnowledgeCheck(props: {
|
|
82
|
+
checkId: CheckId;
|
|
76
83
|
question: string;
|
|
77
84
|
choices: string[];
|
|
78
85
|
answer: string;
|
|
79
86
|
}): react_jsx_runtime.JSX.Element;
|
|
80
87
|
declare function Quiz(props: {
|
|
88
|
+
checkId: CheckId;
|
|
81
89
|
question: string;
|
|
82
90
|
choices: string[];
|
|
83
91
|
answer: string;
|
|
@@ -87,7 +95,7 @@ declare function ProgressTracker(): react_jsx_runtime.JSX.Element;
|
|
|
87
95
|
declare function useLessonkit(): LessonkitRuntime;
|
|
88
96
|
declare function useProgress(): ProgressState;
|
|
89
97
|
declare function useTracking(): {
|
|
90
|
-
track: (name: _lessonkit_core.
|
|
98
|
+
track: (name: _lessonkit_core.TelemetryEventName, data?: unknown, opts?: {
|
|
91
99
|
lessonId?: _lessonkit_core.LessonId;
|
|
92
100
|
}) => void;
|
|
93
101
|
};
|
|
@@ -97,14 +105,36 @@ declare function useCompletion(): {
|
|
|
97
105
|
};
|
|
98
106
|
declare function useQuizState(): {
|
|
99
107
|
answer: (opts: {
|
|
108
|
+
checkId: CheckId;
|
|
100
109
|
question: string;
|
|
101
110
|
choice: string;
|
|
102
111
|
correct: boolean;
|
|
103
112
|
}) => void;
|
|
104
|
-
complete: (opts
|
|
113
|
+
complete: (opts: {
|
|
114
|
+
checkId: CheckId;
|
|
105
115
|
score?: number;
|
|
106
116
|
maxScore?: number;
|
|
107
117
|
}) => void;
|
|
108
118
|
};
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
type ThemeMode = "light" | "dark" | "system";
|
|
121
|
+
type ThemeResolvedMode = "light" | "dark";
|
|
122
|
+
type ThemeProviderProps = {
|
|
123
|
+
children: React.ReactNode;
|
|
124
|
+
/** Partial theme merged on top of the resolved preset (last writer wins). */
|
|
125
|
+
theme?: PartialLessonkitThemeV1;
|
|
126
|
+
preset?: ThemePresetName;
|
|
127
|
+
mode?: ThemeMode;
|
|
128
|
+
/** `document` injects on `:root`; `element` scopes to the provider wrapper. */
|
|
129
|
+
target?: "document" | "element";
|
|
130
|
+
};
|
|
131
|
+
type ThemeContextValue = {
|
|
132
|
+
theme: LessonkitThemeV1;
|
|
133
|
+
preset: ThemePresetName;
|
|
134
|
+
mode: ThemeMode;
|
|
135
|
+
resolvedMode: ThemeResolvedMode;
|
|
136
|
+
};
|
|
137
|
+
declare function ThemeProvider(props: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
138
|
+
declare function useTheme(): ThemeContextValue;
|
|
139
|
+
|
|
140
|
+
export { Course, KnowledgeCheck, Lesson, type LessonkitConfig, LessonkitProvider, type LessonkitRuntime, ProgressTracker, Quiz, Reflection, Scenario, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import * as _lessonkit_core from '@lessonkit/core';
|
|
4
|
-
import { CourseId, TelemetryUser,
|
|
4
|
+
import { LessonId, CourseId, TelemetryUser, TrackingClient, TelemetryEventName, CheckId, BlockId } from '@lessonkit/core';
|
|
5
5
|
import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
|
|
6
|
+
import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
|
|
7
|
+
export { ThemePresetName } from '@lessonkit/themes';
|
|
8
|
+
|
|
9
|
+
type ProgressState = {
|
|
10
|
+
activeLessonId?: LessonId;
|
|
11
|
+
completedLessonIds: ReadonlySet<LessonId>;
|
|
12
|
+
courseCompleted: boolean;
|
|
13
|
+
};
|
|
6
14
|
|
|
7
15
|
type LessonkitConfig = {
|
|
8
|
-
courseId
|
|
16
|
+
courseId: CourseId;
|
|
9
17
|
session?: {
|
|
10
18
|
sessionId?: string;
|
|
11
19
|
attemptId?: string;
|
|
@@ -13,8 +21,8 @@ type LessonkitConfig = {
|
|
|
13
21
|
};
|
|
14
22
|
tracking?: {
|
|
15
23
|
enabled?: boolean;
|
|
16
|
-
sink?: (event:
|
|
17
|
-
batchSink?: (events:
|
|
24
|
+
sink?: (event: Parameters<TrackingClient["track"]>[0]) => void | Promise<void>;
|
|
25
|
+
batchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
|
|
18
26
|
batch?: {
|
|
19
27
|
enabled?: boolean;
|
|
20
28
|
flushIntervalMs?: number;
|
|
@@ -27,11 +35,7 @@ type LessonkitConfig = {
|
|
|
27
35
|
client?: XAPIClient;
|
|
28
36
|
};
|
|
29
37
|
};
|
|
30
|
-
|
|
31
|
-
activeLessonId?: LessonId;
|
|
32
|
-
completedLessonIds: ReadonlySet<LessonId>;
|
|
33
|
-
courseCompleted: boolean;
|
|
34
|
-
};
|
|
38
|
+
|
|
35
39
|
type LessonkitRuntime = {
|
|
36
40
|
config: LessonkitConfig;
|
|
37
41
|
tracking: TrackingClient;
|
|
@@ -45,39 +49,43 @@ type LessonkitRuntime = {
|
|
|
45
49
|
setActiveLesson: (lessonId: LessonId) => void;
|
|
46
50
|
completeLesson: (lessonId: LessonId) => void;
|
|
47
51
|
completeCourse: () => void;
|
|
48
|
-
track: (name:
|
|
52
|
+
track: (name: TelemetryEventName, data?: unknown, opts?: {
|
|
49
53
|
lessonId?: LessonId;
|
|
50
54
|
}) => void;
|
|
51
55
|
};
|
|
52
56
|
declare function LessonkitProvider(props: {
|
|
53
|
-
config
|
|
57
|
+
config: LessonkitConfig;
|
|
54
58
|
children: React.ReactNode;
|
|
55
59
|
}): react_jsx_runtime.JSX.Element;
|
|
56
60
|
|
|
57
61
|
declare function Course(props: {
|
|
58
62
|
title: string;
|
|
59
|
-
courseId
|
|
63
|
+
courseId: CourseId;
|
|
60
64
|
config?: Omit<React.ComponentProps<typeof LessonkitProvider>["config"], "courseId">;
|
|
61
65
|
children: React.ReactNode;
|
|
62
66
|
}): react_jsx_runtime.JSX.Element;
|
|
63
67
|
declare function Lesson(props: {
|
|
64
68
|
title: string;
|
|
65
|
-
lessonId
|
|
69
|
+
lessonId: LessonId;
|
|
66
70
|
children: React.ReactNode;
|
|
67
71
|
}): react_jsx_runtime.JSX.Element;
|
|
68
72
|
declare function Scenario(props: {
|
|
73
|
+
blockId?: BlockId;
|
|
69
74
|
children: React.ReactNode;
|
|
70
75
|
}): react_jsx_runtime.JSX.Element;
|
|
71
76
|
declare function Reflection(props: {
|
|
77
|
+
blockId?: BlockId;
|
|
72
78
|
prompt?: string;
|
|
73
79
|
children?: React.ReactNode;
|
|
74
80
|
}): react_jsx_runtime.JSX.Element;
|
|
75
81
|
declare function KnowledgeCheck(props: {
|
|
82
|
+
checkId: CheckId;
|
|
76
83
|
question: string;
|
|
77
84
|
choices: string[];
|
|
78
85
|
answer: string;
|
|
79
86
|
}): react_jsx_runtime.JSX.Element;
|
|
80
87
|
declare function Quiz(props: {
|
|
88
|
+
checkId: CheckId;
|
|
81
89
|
question: string;
|
|
82
90
|
choices: string[];
|
|
83
91
|
answer: string;
|
|
@@ -87,7 +95,7 @@ declare function ProgressTracker(): react_jsx_runtime.JSX.Element;
|
|
|
87
95
|
declare function useLessonkit(): LessonkitRuntime;
|
|
88
96
|
declare function useProgress(): ProgressState;
|
|
89
97
|
declare function useTracking(): {
|
|
90
|
-
track: (name: _lessonkit_core.
|
|
98
|
+
track: (name: _lessonkit_core.TelemetryEventName, data?: unknown, opts?: {
|
|
91
99
|
lessonId?: _lessonkit_core.LessonId;
|
|
92
100
|
}) => void;
|
|
93
101
|
};
|
|
@@ -97,14 +105,36 @@ declare function useCompletion(): {
|
|
|
97
105
|
};
|
|
98
106
|
declare function useQuizState(): {
|
|
99
107
|
answer: (opts: {
|
|
108
|
+
checkId: CheckId;
|
|
100
109
|
question: string;
|
|
101
110
|
choice: string;
|
|
102
111
|
correct: boolean;
|
|
103
112
|
}) => void;
|
|
104
|
-
complete: (opts
|
|
113
|
+
complete: (opts: {
|
|
114
|
+
checkId: CheckId;
|
|
105
115
|
score?: number;
|
|
106
116
|
maxScore?: number;
|
|
107
117
|
}) => void;
|
|
108
118
|
};
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
type ThemeMode = "light" | "dark" | "system";
|
|
121
|
+
type ThemeResolvedMode = "light" | "dark";
|
|
122
|
+
type ThemeProviderProps = {
|
|
123
|
+
children: React.ReactNode;
|
|
124
|
+
/** Partial theme merged on top of the resolved preset (last writer wins). */
|
|
125
|
+
theme?: PartialLessonkitThemeV1;
|
|
126
|
+
preset?: ThemePresetName;
|
|
127
|
+
mode?: ThemeMode;
|
|
128
|
+
/** `document` injects on `:root`; `element` scopes to the provider wrapper. */
|
|
129
|
+
target?: "document" | "element";
|
|
130
|
+
};
|
|
131
|
+
type ThemeContextValue = {
|
|
132
|
+
theme: LessonkitThemeV1;
|
|
133
|
+
preset: ThemePresetName;
|
|
134
|
+
mode: ThemeMode;
|
|
135
|
+
resolvedMode: ThemeResolvedMode;
|
|
136
|
+
};
|
|
137
|
+
declare function ThemeProvider(props: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
138
|
+
declare function useTheme(): ThemeContextValue;
|
|
139
|
+
|
|
140
|
+
export { Course, KnowledgeCheck, Lesson, type LessonkitConfig, LessonkitProvider, type LessonkitRuntime, ProgressTracker, Quiz, Reflection, Scenario, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
|