@capytale/meta-player 0.8.2 → 0.8.3
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/.prettierrc.json +4 -4
- package/LICENSE +674 -674
- package/README.md +12 -12
- package/eslint.config.js +28 -28
- package/index.html +15 -15
- package/package.json +60 -60
- package/public/themes/lara-dark-blue/theme.css +7015 -7015
- package/public/themes/lara-light-blue/theme.css +7005 -7005
- package/src/App.tsx +139 -139
- package/src/AppRedux.css +39 -39
- package/src/MetaPlayer.tsx +170 -170
- package/src/activityJs.ts +7 -7
- package/src/app/createAppSlice.ts +6 -6
- package/src/app/hooks.ts +12 -12
- package/src/app/store.ts +52 -52
- package/src/app.module.scss +80 -80
- package/src/demo.tsx +87 -87
- package/src/external/prime.ts +5 -5
- package/src/features/activityData/ExitWarning.ts +28 -28
- package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
- package/src/features/activityData/IsDirtySetter.tsx +17 -17
- package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
- package/src/features/activityData/activityDataSlice.ts +256 -256
- package/src/features/activityData/activityJsData.ts +82 -82
- package/src/features/activityData/hooks.ts +34 -34
- package/src/features/activityData/metaPlayerOptions.ts +23 -23
- package/src/features/activityData/uiState.ts +20 -20
- package/src/features/activityJS/ActivityJSProvider.tsx +339 -339
- package/src/features/activityJS/AfterResetAction.tsx +23 -23
- package/src/features/activityJS/AfterSaveAction.tsx +23 -23
- package/src/features/activityJS/BeforeResetAction.tsx +23 -23
- package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
- package/src/features/activityJS/Saver.tsx +167 -167
- package/src/features/activityJS/hooks.ts +85 -85
- package/src/features/activityJS/internal-hooks.ts +96 -96
- package/src/features/activityJS/saverSlice.ts +96 -96
- package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
- package/src/features/activitySettings/hooks.ts +12 -12
- package/src/features/activitySettings/index.tsx +43 -43
- package/src/features/activitySettings/store.ts +108 -108
- package/src/features/activitySettings/style.module.scss +8 -8
- package/src/features/activitySettings/types.ts +140 -140
- package/src/features/activitySettings/ui.tsx +299 -299
- package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
- package/src/features/functionalities/PreviewDialog.tsx +83 -83
- package/src/features/functionalities/functionalitiesSlice.ts +98 -98
- package/src/features/functionalities/hooks.ts +70 -70
- package/src/features/layout/hooks.ts +7 -7
- package/src/features/layout/layoutSlice.ts +90 -90
- package/src/features/navbar/activity-info/index.tsx +54 -54
- package/src/features/navbar/activity-info/style.module.scss +38 -38
- package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +57 -57
- package/src/features/navbar/activity-menu/index.tsx +154 -153
- package/src/features/navbar/activity-menu/style.module.scss +7 -7
- package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
- package/src/features/navbar/capytale-menu/Countdown.tsx +312 -312
- package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +115 -115
- package/src/features/navbar/capytale-menu/index.tsx +260 -260
- package/src/features/navbar/capytale-menu/style.module.scss +8 -8
- package/src/features/navbar/index.tsx +39 -39
- package/src/features/navbar/navbarSlice.ts +79 -79
- package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
- package/src/features/navbar/review-navbar/index.tsx +18 -18
- package/src/features/navbar/review-navbar/style.module.scss +22 -22
- package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
- package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
- package/src/features/navbar/sidebars/style.module.scss +15 -15
- package/src/features/navbar/student-utils.ts +11 -11
- package/src/features/navbar/style.module.scss +65 -65
- package/src/features/pedago/InstructionsEditor.tsx +102 -102
- package/src/features/pedago/PdfEditor.tsx +91 -91
- package/src/features/pedago/PedagoCommands.tsx +353 -353
- package/src/features/pedago/SharedNotesEditor.tsx +144 -144
- package/src/features/pedago/index.tsx +207 -204
- package/src/features/pedago/style.module.scss +233 -233
- package/src/features/theming/ThemeSwitcher.tsx +51 -51
- package/src/features/theming/hooks.ts +6 -6
- package/src/features/theming/themingSlice.ts +93 -93
- package/src/features/toast.tsx +38 -38
- package/src/hooks/index.ts +16 -16
- package/src/index.css +132 -132
- package/src/index.ts +90 -90
- package/src/logo.svg +1 -1
- package/src/my_json_data.js +4146 -4146
- package/src/settings.ts +6 -6
- package/src/types.ts +9 -9
- package/src/utils/ButtonDoubleIcon.tsx +35 -35
- package/src/utils/CardSelector.tsx +41 -41
- package/src/utils/ErrorBoundary.tsx +41 -41
- package/src/utils/PopupButton.tsx +134 -134
- package/src/utils/activity.ts +8 -8
- package/src/utils/breakpoints.ts +4 -4
- package/src/utils/capytale.ts +10 -10
- package/src/utils/clipboard.ts +11 -11
- package/src/utils/download.ts +7 -7
- package/src/utils/equality.ts +32 -32
- package/src/utils/server-clock.ts +42 -42
- package/src/utils/style.module.scss +45 -45
- package/src/utils/useFullscreen.ts +65 -65
- package/src/vite-env.d.ts +1 -1
- package/tsconfig.json +28 -28
- package/tsconfig.node.json +9 -9
- package/vite.config.ts +11 -11
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { Fieldset } from "primereact/fieldset";
|
|
2
|
-
import {
|
|
3
|
-
ActivitySettingsFormDisplay,
|
|
4
|
-
ActivitySettingsOptionsDisplay,
|
|
5
|
-
} from "./ui";
|
|
6
|
-
import { useActivitySettingsStore } from "./store";
|
|
7
|
-
import { useAppSelector } from "../../app/hooks";
|
|
8
|
-
import { selectMode } from "../activityData/activityDataSlice";
|
|
9
|
-
|
|
10
|
-
type ActivitySettingsDisplayProps = {};
|
|
11
|
-
|
|
12
|
-
export function ActivitySettingsDisplay({}: ActivitySettingsDisplayProps) {
|
|
13
|
-
const settings = useActivitySettingsStore((state) => state.settings);
|
|
14
|
-
const mode = useAppSelector(selectMode) as
|
|
15
|
-
| "assignment"
|
|
16
|
-
| "create"
|
|
17
|
-
| "review"
|
|
18
|
-
| "view"
|
|
19
|
-
| null;
|
|
20
|
-
if (!settings) return null;
|
|
21
|
-
return (
|
|
22
|
-
<div>
|
|
23
|
-
{settings.map((section, i) => {
|
|
24
|
-
if (!mode || (section.modes && !section.modes.includes(mode))) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return (
|
|
28
|
-
<Fieldset
|
|
29
|
-
key={`section-${i}`}
|
|
30
|
-
legend={section.title}
|
|
31
|
-
className="sidebarFieldset"
|
|
32
|
-
>
|
|
33
|
-
{section.type === "form" ? (
|
|
34
|
-
<ActivitySettingsFormDisplay form={section} mode={mode} />
|
|
35
|
-
) : (
|
|
36
|
-
<ActivitySettingsOptionsDisplay section={section} />
|
|
37
|
-
)}
|
|
38
|
-
</Fieldset>
|
|
39
|
-
);
|
|
40
|
-
})}
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
1
|
+
import { Fieldset } from "primereact/fieldset";
|
|
2
|
+
import {
|
|
3
|
+
ActivitySettingsFormDisplay,
|
|
4
|
+
ActivitySettingsOptionsDisplay,
|
|
5
|
+
} from "./ui";
|
|
6
|
+
import { useActivitySettingsStore } from "./store";
|
|
7
|
+
import { useAppSelector } from "../../app/hooks";
|
|
8
|
+
import { selectMode } from "../activityData/activityDataSlice";
|
|
9
|
+
|
|
10
|
+
type ActivitySettingsDisplayProps = {};
|
|
11
|
+
|
|
12
|
+
export function ActivitySettingsDisplay({}: ActivitySettingsDisplayProps) {
|
|
13
|
+
const settings = useActivitySettingsStore((state) => state.settings);
|
|
14
|
+
const mode = useAppSelector(selectMode) as
|
|
15
|
+
| "assignment"
|
|
16
|
+
| "create"
|
|
17
|
+
| "review"
|
|
18
|
+
| "view"
|
|
19
|
+
| null;
|
|
20
|
+
if (!settings) return null;
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
{settings.map((section, i) => {
|
|
24
|
+
if (!mode || (section.modes && !section.modes.includes(mode))) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return (
|
|
28
|
+
<Fieldset
|
|
29
|
+
key={`section-${i}`}
|
|
30
|
+
legend={section.title}
|
|
31
|
+
className="sidebarFieldset"
|
|
32
|
+
>
|
|
33
|
+
{section.type === "form" ? (
|
|
34
|
+
<ActivitySettingsFormDisplay form={section} mode={mode} />
|
|
35
|
+
) : (
|
|
36
|
+
<ActivitySettingsOptionsDisplay section={section} />
|
|
37
|
+
)}
|
|
38
|
+
</Fieldset>
|
|
39
|
+
);
|
|
40
|
+
})}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
import type {
|
|
3
|
-
ActivitySettings,
|
|
4
|
-
ActivitySettingsSection,
|
|
5
|
-
ActivitySettingsFormSection,
|
|
6
|
-
ActivitySettingsMultipleOptionsSection,
|
|
7
|
-
ActivitySettingsRadioOptionsSection,
|
|
8
|
-
} from "./types";
|
|
9
|
-
|
|
10
|
-
function getFormSectionInitialValues(
|
|
11
|
-
section: ActivitySettingsFormSection,
|
|
12
|
-
): Record<string, any> {
|
|
13
|
-
const values: Record<string, any> = {};
|
|
14
|
-
for (const field of section.fields) {
|
|
15
|
-
values[field.name] = field.defaultValue;
|
|
16
|
-
}
|
|
17
|
-
return values;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getMultipleOptionsSectionInitialValues(
|
|
21
|
-
section: ActivitySettingsMultipleOptionsSection,
|
|
22
|
-
): Record<string, any> {
|
|
23
|
-
return { [section.name]: section.defaultValues };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getRadioOptionsSectionInitialValues(
|
|
27
|
-
section: ActivitySettingsRadioOptionsSection,
|
|
28
|
-
): Record<string, any> {
|
|
29
|
-
return { [section.name]: section.defaultValue };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getSectionInitialValues(
|
|
33
|
-
section: ActivitySettingsSection,
|
|
34
|
-
): Record<string, any> {
|
|
35
|
-
switch (section.type) {
|
|
36
|
-
case "form":
|
|
37
|
-
return getFormSectionInitialValues(section);
|
|
38
|
-
case "checkboxes":
|
|
39
|
-
case "switches":
|
|
40
|
-
return getMultipleOptionsSectionInitialValues(section);
|
|
41
|
-
case "radio":
|
|
42
|
-
return getRadioOptionsSectionInitialValues(section);
|
|
43
|
-
default:
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getSettingsInitialValues(
|
|
49
|
-
settings: ActivitySettings,
|
|
50
|
-
): Record<string, any> {
|
|
51
|
-
const values: Record<string, any> = {};
|
|
52
|
-
for (const section of settings) {
|
|
53
|
-
Object.assign(values, getSectionInitialValues(section));
|
|
54
|
-
}
|
|
55
|
-
return values;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type ActivitySettingsState = {
|
|
59
|
-
settings: ActivitySettings;
|
|
60
|
-
values: Record<string, any>;
|
|
61
|
-
onChange: null | ((name: string, value: any) => void);
|
|
62
|
-
|
|
63
|
-
setSettings: (
|
|
64
|
-
settings: ActivitySettings,
|
|
65
|
-
onChange: null | ((name: string, value: any) => void),
|
|
66
|
-
) => void;
|
|
67
|
-
updateValue: (key: string, value: any) => void;
|
|
68
|
-
toggleContainsValue: (key: string, value: any) => void;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const useActivitySettingsStore = create<ActivitySettingsState>()(
|
|
72
|
-
(set) => ({
|
|
73
|
-
settings: [],
|
|
74
|
-
values: {},
|
|
75
|
-
onChange: null,
|
|
76
|
-
|
|
77
|
-
setSettings: (settings, onChange) =>
|
|
78
|
-
set(() => ({
|
|
79
|
-
settings,
|
|
80
|
-
values: getSettingsInitialValues(settings),
|
|
81
|
-
onChange,
|
|
82
|
-
})),
|
|
83
|
-
updateValue: (key: string, value: any) =>
|
|
84
|
-
set((state) => {
|
|
85
|
-
if (!(key in state.values)) {
|
|
86
|
-
throw new Error(`Unknown settings key: ${key}`);
|
|
87
|
-
}
|
|
88
|
-
state.onChange && state.onChange(key, value);
|
|
89
|
-
return { values: { ...state.values, [key]: value } };
|
|
90
|
-
}),
|
|
91
|
-
toggleContainsValue: (key: string, value: any) =>
|
|
92
|
-
set((state) => {
|
|
93
|
-
if (!(key in state.values)) {
|
|
94
|
-
throw new Error(`Unknown settings key: ${key}`);
|
|
95
|
-
}
|
|
96
|
-
const currentValues = state.values[key];
|
|
97
|
-
if (!Array.isArray(currentValues)) {
|
|
98
|
-
throw new Error(`Value for key ${key} is not an array`);
|
|
99
|
-
}
|
|
100
|
-
const containsValue = currentValues.includes(value);
|
|
101
|
-
const newValues = containsValue
|
|
102
|
-
? currentValues.filter((v: any) => v !== value)
|
|
103
|
-
: [...currentValues, value];
|
|
104
|
-
state.onChange && state.onChange(key, newValues);
|
|
105
|
-
return { values: { ...state.values, [key]: newValues } };
|
|
106
|
-
}),
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import type {
|
|
3
|
+
ActivitySettings,
|
|
4
|
+
ActivitySettingsSection,
|
|
5
|
+
ActivitySettingsFormSection,
|
|
6
|
+
ActivitySettingsMultipleOptionsSection,
|
|
7
|
+
ActivitySettingsRadioOptionsSection,
|
|
8
|
+
} from "./types";
|
|
9
|
+
|
|
10
|
+
function getFormSectionInitialValues(
|
|
11
|
+
section: ActivitySettingsFormSection,
|
|
12
|
+
): Record<string, any> {
|
|
13
|
+
const values: Record<string, any> = {};
|
|
14
|
+
for (const field of section.fields) {
|
|
15
|
+
values[field.name] = field.defaultValue;
|
|
16
|
+
}
|
|
17
|
+
return values;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getMultipleOptionsSectionInitialValues(
|
|
21
|
+
section: ActivitySettingsMultipleOptionsSection,
|
|
22
|
+
): Record<string, any> {
|
|
23
|
+
return { [section.name]: section.defaultValues };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getRadioOptionsSectionInitialValues(
|
|
27
|
+
section: ActivitySettingsRadioOptionsSection,
|
|
28
|
+
): Record<string, any> {
|
|
29
|
+
return { [section.name]: section.defaultValue };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getSectionInitialValues(
|
|
33
|
+
section: ActivitySettingsSection,
|
|
34
|
+
): Record<string, any> {
|
|
35
|
+
switch (section.type) {
|
|
36
|
+
case "form":
|
|
37
|
+
return getFormSectionInitialValues(section);
|
|
38
|
+
case "checkboxes":
|
|
39
|
+
case "switches":
|
|
40
|
+
return getMultipleOptionsSectionInitialValues(section);
|
|
41
|
+
case "radio":
|
|
42
|
+
return getRadioOptionsSectionInitialValues(section);
|
|
43
|
+
default:
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getSettingsInitialValues(
|
|
49
|
+
settings: ActivitySettings,
|
|
50
|
+
): Record<string, any> {
|
|
51
|
+
const values: Record<string, any> = {};
|
|
52
|
+
for (const section of settings) {
|
|
53
|
+
Object.assign(values, getSectionInitialValues(section));
|
|
54
|
+
}
|
|
55
|
+
return values;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type ActivitySettingsState = {
|
|
59
|
+
settings: ActivitySettings;
|
|
60
|
+
values: Record<string, any>;
|
|
61
|
+
onChange: null | ((name: string, value: any) => void);
|
|
62
|
+
|
|
63
|
+
setSettings: (
|
|
64
|
+
settings: ActivitySettings,
|
|
65
|
+
onChange: null | ((name: string, value: any) => void),
|
|
66
|
+
) => void;
|
|
67
|
+
updateValue: (key: string, value: any) => void;
|
|
68
|
+
toggleContainsValue: (key: string, value: any) => void;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const useActivitySettingsStore = create<ActivitySettingsState>()(
|
|
72
|
+
(set) => ({
|
|
73
|
+
settings: [],
|
|
74
|
+
values: {},
|
|
75
|
+
onChange: null,
|
|
76
|
+
|
|
77
|
+
setSettings: (settings, onChange) =>
|
|
78
|
+
set(() => ({
|
|
79
|
+
settings,
|
|
80
|
+
values: getSettingsInitialValues(settings),
|
|
81
|
+
onChange,
|
|
82
|
+
})),
|
|
83
|
+
updateValue: (key: string, value: any) =>
|
|
84
|
+
set((state) => {
|
|
85
|
+
if (!(key in state.values)) {
|
|
86
|
+
throw new Error(`Unknown settings key: ${key}`);
|
|
87
|
+
}
|
|
88
|
+
state.onChange && state.onChange(key, value);
|
|
89
|
+
return { values: { ...state.values, [key]: value } };
|
|
90
|
+
}),
|
|
91
|
+
toggleContainsValue: (key: string, value: any) =>
|
|
92
|
+
set((state) => {
|
|
93
|
+
if (!(key in state.values)) {
|
|
94
|
+
throw new Error(`Unknown settings key: ${key}`);
|
|
95
|
+
}
|
|
96
|
+
const currentValues = state.values[key];
|
|
97
|
+
if (!Array.isArray(currentValues)) {
|
|
98
|
+
throw new Error(`Value for key ${key} is not an array`);
|
|
99
|
+
}
|
|
100
|
+
const containsValue = currentValues.includes(value);
|
|
101
|
+
const newValues = containsValue
|
|
102
|
+
? currentValues.filter((v: any) => v !== value)
|
|
103
|
+
: [...currentValues, value];
|
|
104
|
+
state.onChange && state.onChange(key, newValues);
|
|
105
|
+
return { values: { ...state.values, [key]: newValues } };
|
|
106
|
+
}),
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
.formLabel {
|
|
2
|
-
}
|
|
3
|
-
.formGroup {
|
|
4
|
-
margin-bottom: 1rem;
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
gap: 0.3rem;
|
|
8
|
-
}
|
|
1
|
+
.formLabel {
|
|
2
|
+
}
|
|
3
|
+
.formGroup {
|
|
4
|
+
margin-bottom: 1rem;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 0.3rem;
|
|
8
|
+
}
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
export type ActivitySettingsSelect = {
|
|
2
|
-
type: "select";
|
|
3
|
-
options: {
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
}[];
|
|
7
|
-
defaultValue: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ActivitySettingsRange = {
|
|
11
|
-
type: "range";
|
|
12
|
-
min: number;
|
|
13
|
-
max: number;
|
|
14
|
-
step?: number;
|
|
15
|
-
defaultValue: number;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type ActivitySettingsTextArea = {
|
|
19
|
-
type: "textarea";
|
|
20
|
-
defaultValue: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type ActivitySettingsOption = {
|
|
24
|
-
type: "checkbox" | "switch";
|
|
25
|
-
defaultValue: boolean;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type ActivitySettingsInput = {
|
|
29
|
-
type: "input";
|
|
30
|
-
inputType:
|
|
31
|
-
| "color"
|
|
32
|
-
| "date"
|
|
33
|
-
| "datetime-local"
|
|
34
|
-
| "email"
|
|
35
|
-
| "month"
|
|
36
|
-
| "password"
|
|
37
|
-
| "search"
|
|
38
|
-
| "tel"
|
|
39
|
-
| "text"
|
|
40
|
-
| "time"
|
|
41
|
-
| "url"
|
|
42
|
-
| "week";
|
|
43
|
-
defaultValue: string;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type ActivitySettingsNumberInput = {
|
|
47
|
-
type: "input";
|
|
48
|
-
inputType: "number";
|
|
49
|
-
defaultValue: number;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type FormField = (
|
|
53
|
-
| ActivitySettingsRange
|
|
54
|
-
| ActivitySettingsInput
|
|
55
|
-
| ActivitySettingsNumberInput
|
|
56
|
-
| ActivitySettingsTextArea
|
|
57
|
-
| ActivitySettingsOption
|
|
58
|
-
| ActivitySettingsSelect
|
|
59
|
-
) & {
|
|
60
|
-
label: string;
|
|
61
|
-
name: string;
|
|
62
|
-
modes?: ("assignment" | "create" | "review" | "view")[];
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type ActivitySettingsFormSection = {
|
|
66
|
-
type: "form";
|
|
67
|
-
fields: FormField[];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type ActivitySettingsMultipleOptionsSection = {
|
|
71
|
-
name: string;
|
|
72
|
-
type: "checkboxes" | "switches";
|
|
73
|
-
options: {
|
|
74
|
-
label: string;
|
|
75
|
-
value: string;
|
|
76
|
-
}[];
|
|
77
|
-
defaultValues: string[];
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export type ActivitySettingsRadioOptionsSection = {
|
|
81
|
-
name: string;
|
|
82
|
-
type: "radio";
|
|
83
|
-
options: {
|
|
84
|
-
label: string;
|
|
85
|
-
value: string;
|
|
86
|
-
}[];
|
|
87
|
-
defaultValue: string | null;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export type ActivitySettingsSection = (
|
|
91
|
-
| ActivitySettingsMultipleOptionsSection
|
|
92
|
-
| ActivitySettingsRadioOptionsSection
|
|
93
|
-
| ActivitySettingsFormSection
|
|
94
|
-
) & {
|
|
95
|
-
title: string;
|
|
96
|
-
modes?: ("assignment" | "create" | "review" | "view")[];
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export type ActivitySettings = ActivitySettingsSection[];
|
|
100
|
-
|
|
101
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
102
|
-
k: infer I,
|
|
103
|
-
) => void
|
|
104
|
-
? I
|
|
105
|
-
: never;
|
|
106
|
-
|
|
107
|
-
type InferFieldType<T> = T extends {
|
|
108
|
-
type: "checkboxes" | "switches";
|
|
109
|
-
options: readonly { value: infer V }[];
|
|
110
|
-
}
|
|
111
|
-
? V[]
|
|
112
|
-
: T extends { type: "radio"; options: readonly { value: infer V }[] }
|
|
113
|
-
? V | null
|
|
114
|
-
: T extends { type: "select"; options: readonly { value: infer V }[] }
|
|
115
|
-
? V
|
|
116
|
-
: T extends { type: "input"; inputType: "number" }
|
|
117
|
-
? number
|
|
118
|
-
: T extends { type: "input" | "textarea" }
|
|
119
|
-
? string
|
|
120
|
-
: T extends { type: "range" }
|
|
121
|
-
? number
|
|
122
|
-
: T extends { type: "checkbox" | "switch" }
|
|
123
|
-
? boolean
|
|
124
|
-
: never;
|
|
125
|
-
|
|
126
|
-
export type InferValue<T> = T extends readonly (infer Section)[]
|
|
127
|
-
? UnionToIntersection<
|
|
128
|
-
Section extends { type: "form"; fields: infer F extends readonly any[] }
|
|
129
|
-
? UnionToIntersection<
|
|
130
|
-
{
|
|
131
|
-
[K in keyof F]: F[K] extends { name: infer N extends string }
|
|
132
|
-
? { [P in N]: InferFieldType<F[K]> }
|
|
133
|
-
: never;
|
|
134
|
-
}[number]
|
|
135
|
-
>
|
|
136
|
-
: Section extends { name: infer N extends string }
|
|
137
|
-
? { [P in N]: InferFieldType<Section> }
|
|
138
|
-
: never
|
|
139
|
-
>
|
|
140
|
-
: never;
|
|
1
|
+
export type ActivitySettingsSelect = {
|
|
2
|
+
type: "select";
|
|
3
|
+
options: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
defaultValue: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ActivitySettingsRange = {
|
|
11
|
+
type: "range";
|
|
12
|
+
min: number;
|
|
13
|
+
max: number;
|
|
14
|
+
step?: number;
|
|
15
|
+
defaultValue: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ActivitySettingsTextArea = {
|
|
19
|
+
type: "textarea";
|
|
20
|
+
defaultValue: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ActivitySettingsOption = {
|
|
24
|
+
type: "checkbox" | "switch";
|
|
25
|
+
defaultValue: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ActivitySettingsInput = {
|
|
29
|
+
type: "input";
|
|
30
|
+
inputType:
|
|
31
|
+
| "color"
|
|
32
|
+
| "date"
|
|
33
|
+
| "datetime-local"
|
|
34
|
+
| "email"
|
|
35
|
+
| "month"
|
|
36
|
+
| "password"
|
|
37
|
+
| "search"
|
|
38
|
+
| "tel"
|
|
39
|
+
| "text"
|
|
40
|
+
| "time"
|
|
41
|
+
| "url"
|
|
42
|
+
| "week";
|
|
43
|
+
defaultValue: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type ActivitySettingsNumberInput = {
|
|
47
|
+
type: "input";
|
|
48
|
+
inputType: "number";
|
|
49
|
+
defaultValue: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type FormField = (
|
|
53
|
+
| ActivitySettingsRange
|
|
54
|
+
| ActivitySettingsInput
|
|
55
|
+
| ActivitySettingsNumberInput
|
|
56
|
+
| ActivitySettingsTextArea
|
|
57
|
+
| ActivitySettingsOption
|
|
58
|
+
| ActivitySettingsSelect
|
|
59
|
+
) & {
|
|
60
|
+
label: string;
|
|
61
|
+
name: string;
|
|
62
|
+
modes?: ("assignment" | "create" | "review" | "view")[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type ActivitySettingsFormSection = {
|
|
66
|
+
type: "form";
|
|
67
|
+
fields: FormField[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type ActivitySettingsMultipleOptionsSection = {
|
|
71
|
+
name: string;
|
|
72
|
+
type: "checkboxes" | "switches";
|
|
73
|
+
options: {
|
|
74
|
+
label: string;
|
|
75
|
+
value: string;
|
|
76
|
+
}[];
|
|
77
|
+
defaultValues: string[];
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type ActivitySettingsRadioOptionsSection = {
|
|
81
|
+
name: string;
|
|
82
|
+
type: "radio";
|
|
83
|
+
options: {
|
|
84
|
+
label: string;
|
|
85
|
+
value: string;
|
|
86
|
+
}[];
|
|
87
|
+
defaultValue: string | null;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type ActivitySettingsSection = (
|
|
91
|
+
| ActivitySettingsMultipleOptionsSection
|
|
92
|
+
| ActivitySettingsRadioOptionsSection
|
|
93
|
+
| ActivitySettingsFormSection
|
|
94
|
+
) & {
|
|
95
|
+
title: string;
|
|
96
|
+
modes?: ("assignment" | "create" | "review" | "view")[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type ActivitySettings = ActivitySettingsSection[];
|
|
100
|
+
|
|
101
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
102
|
+
k: infer I,
|
|
103
|
+
) => void
|
|
104
|
+
? I
|
|
105
|
+
: never;
|
|
106
|
+
|
|
107
|
+
type InferFieldType<T> = T extends {
|
|
108
|
+
type: "checkboxes" | "switches";
|
|
109
|
+
options: readonly { value: infer V }[];
|
|
110
|
+
}
|
|
111
|
+
? V[]
|
|
112
|
+
: T extends { type: "radio"; options: readonly { value: infer V }[] }
|
|
113
|
+
? V | null
|
|
114
|
+
: T extends { type: "select"; options: readonly { value: infer V }[] }
|
|
115
|
+
? V
|
|
116
|
+
: T extends { type: "input"; inputType: "number" }
|
|
117
|
+
? number
|
|
118
|
+
: T extends { type: "input" | "textarea" }
|
|
119
|
+
? string
|
|
120
|
+
: T extends { type: "range" }
|
|
121
|
+
? number
|
|
122
|
+
: T extends { type: "checkbox" | "switch" }
|
|
123
|
+
? boolean
|
|
124
|
+
: never;
|
|
125
|
+
|
|
126
|
+
export type InferValue<T> = T extends readonly (infer Section)[]
|
|
127
|
+
? UnionToIntersection<
|
|
128
|
+
Section extends { type: "form"; fields: infer F extends readonly any[] }
|
|
129
|
+
? UnionToIntersection<
|
|
130
|
+
{
|
|
131
|
+
[K in keyof F]: F[K] extends { name: infer N extends string }
|
|
132
|
+
? { [P in N]: InferFieldType<F[K]> }
|
|
133
|
+
: never;
|
|
134
|
+
}[number]
|
|
135
|
+
>
|
|
136
|
+
: Section extends { name: infer N extends string }
|
|
137
|
+
? { [P in N]: InferFieldType<Section> }
|
|
138
|
+
: never
|
|
139
|
+
>
|
|
140
|
+
: never;
|