@pie-element/multiple-choice 14.0.4-next.20261011174919 → 14.0.4

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.
@@ -1,73 +1,75 @@
1
+ import type { ConfigureLanguageOptionsProp } from '@pie-element/shared-types';
2
+ import type { Choice } from '../types.js';
1
3
  /** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
2
4
  * functionalities are not defined yet - the value for those can belong to
3
5
  * model or to configure
4
6
  */
5
7
  declare const _default: {
6
8
  model: {
7
- choiceMode: string;
8
- choicePrefix: string;
9
- choices: never[];
10
- choicesLayout: string;
11
- feedbackEnabled: boolean;
9
+ choiceMode: "checkbox";
10
+ choicePrefix: "letters";
11
+ choices: Choice[];
12
+ choicesLayout: "vertical";
13
+ feedbackEnabled: false;
12
14
  gridColumns: number;
13
- lockChoiceOrder: boolean;
14
- partialScoring: boolean;
15
+ lockChoiceOrder: true;
16
+ partialScoring: true;
15
17
  prompt: string;
16
- promptEnabled: boolean;
18
+ promptEnabled: true;
17
19
  rationale: string;
18
- rationaleEnabled: boolean;
19
- scoringType: string;
20
- studentInstructionsEnabled: boolean;
20
+ rationaleEnabled: true;
21
+ scoringType: "auto";
22
+ studentInstructionsEnabled: true;
21
23
  teacherInstructions: string;
22
- teacherInstructionsEnabled: boolean;
23
- toolbarEditorPosition: string;
24
+ teacherInstructionsEnabled: true;
25
+ toolbarEditorPosition: "bottom";
24
26
  selectedAnswerBackgroundColor: string;
25
- keyboardEventsEnabled: boolean;
27
+ keyboardEventsEnabled: false;
26
28
  };
27
29
  configuration: {
28
30
  baseInputConfiguration: {
29
31
  h3: {
30
- disabled: boolean;
32
+ disabled: true;
31
33
  };
32
34
  audio: {
33
- disabled: boolean;
35
+ disabled: false;
34
36
  };
35
37
  video: {
36
- disabled: boolean;
38
+ disabled: false;
37
39
  };
38
40
  image: {
39
- disabled: boolean;
41
+ disabled: false;
40
42
  };
41
43
  textAlign: {
42
- disabled: boolean;
44
+ disabled: true;
43
45
  };
44
46
  showParagraphs: {
45
- disabled: boolean;
47
+ disabled: false;
46
48
  };
47
49
  separateParagraphs: {
48
- disabled: boolean;
50
+ disabled: true;
49
51
  };
50
52
  };
51
53
  choices: {
52
54
  inputConfiguration: {
53
55
  audio: {
54
- disabled: boolean;
56
+ disabled: false;
55
57
  };
56
58
  video: {
57
- disabled: boolean;
59
+ disabled: false;
58
60
  };
59
61
  image: {
60
- disabled: boolean;
62
+ disabled: false;
61
63
  };
62
64
  };
63
65
  };
64
66
  spellCheck: {
65
67
  label: string;
66
- settings: boolean;
67
- enabled: boolean;
68
+ settings: false;
69
+ enabled: true;
68
70
  };
69
71
  choicesLayout: {
70
- settings: boolean;
72
+ settings: false;
71
73
  label: string;
72
74
  };
73
75
  gridColumns: {
@@ -75,90 +77,90 @@ declare const _default: {
75
77
  };
76
78
  answerChoiceCount: number;
77
79
  addChoiceButton: {
78
- settings: boolean;
80
+ settings: true;
79
81
  label: string;
80
82
  };
81
83
  choiceMode: {
82
- settings: boolean;
84
+ settings: true;
83
85
  label: string;
84
86
  };
85
87
  choicePrefix: {
86
- settings: boolean;
88
+ settings: true;
87
89
  label: string;
88
90
  };
89
91
  deleteChoice: {
90
- settings: boolean;
92
+ settings: true;
91
93
  };
92
94
  feedback: {
93
- settings: boolean;
95
+ settings: true;
94
96
  label: string;
95
97
  };
96
98
  prompt: {
97
- settings: boolean;
99
+ settings: true;
98
100
  label: string;
99
101
  inputConfiguration: {
100
102
  audio: {
101
- disabled: boolean;
103
+ disabled: false;
102
104
  };
103
105
  video: {
104
- disabled: boolean;
106
+ disabled: false;
105
107
  };
106
108
  image: {
107
- disabled: boolean;
109
+ disabled: false;
108
110
  };
109
111
  };
110
- required: boolean;
112
+ required: false;
111
113
  };
112
114
  lockChoiceOrder: {
113
- settings: boolean;
115
+ settings: true;
114
116
  label: string;
115
117
  };
116
118
  partialScoring: {
117
- settings: boolean;
119
+ settings: false;
118
120
  label: string;
119
121
  };
120
122
  rationale: {
121
- settings: boolean;
123
+ settings: true;
122
124
  label: string;
123
125
  inputConfiguration: {
124
126
  audio: {
125
- disabled: boolean;
127
+ disabled: true;
126
128
  };
127
129
  video: {
128
- disabled: boolean;
130
+ disabled: true;
129
131
  };
130
132
  image: {
131
- disabled: boolean;
133
+ disabled: false;
132
134
  };
133
135
  };
134
- required: boolean;
136
+ required: false;
135
137
  };
136
138
  scoringType: {
137
- settings: boolean;
139
+ settings: false;
138
140
  label: string;
139
141
  };
140
142
  studentInstructions: {
141
- settings: boolean;
143
+ settings: false;
142
144
  label: string;
143
145
  };
144
146
  teacherInstructions: {
145
- settings: boolean;
147
+ settings: true;
146
148
  label: string;
147
149
  inputConfiguration: {
148
150
  audio: {
149
- disabled: boolean;
151
+ disabled: false;
150
152
  };
151
153
  video: {
152
- disabled: boolean;
154
+ disabled: false;
153
155
  };
154
156
  image: {
155
- disabled: boolean;
157
+ disabled: false;
156
158
  };
157
159
  };
158
- required: boolean;
160
+ required: false;
159
161
  };
160
162
  toolbarEditorPosition: {
161
- settings: boolean;
163
+ settings: false;
162
164
  label: string;
163
165
  };
164
166
  minAnswerChoices: number;
@@ -176,21 +178,21 @@ declare const _default: {
176
178
  choices: number;
177
179
  };
178
180
  withRubric: {
179
- settings: boolean;
181
+ settings: false;
180
182
  label: string;
181
183
  };
182
184
  mathMlOptions: {
183
- mmlOutput: boolean;
184
- mmlEditing: boolean;
185
+ mmlOutput: false;
186
+ mmlEditing: false;
185
187
  };
186
188
  language: {
187
- settings: boolean;
189
+ settings: false;
188
190
  label: string;
189
- enabled: boolean;
191
+ enabled: false;
190
192
  };
191
193
  languageChoices: {
192
194
  label: string;
193
- options: never[];
195
+ options: ConfigureLanguageOptionsProp[];
194
196
  };
195
197
  };
196
198
  };
@@ -1,17 +1,25 @@
1
+ import { type DeleteDone, type ImageHandler, type SoundHandler } from '@pie-element/shared-configure-events';
2
+ import { type AuthorModel } from './main.js';
3
+ import type { MultipleChoiceConfiguration, MultipleChoiceModel } from '../types.js';
1
4
  export default class MultipleChoice extends HTMLElement {
2
- static createDefaultModel: (model?: {}) => any;
5
+ private _root;
6
+ private _reactContainer;
7
+ private _model;
8
+ private _configuration;
9
+ private _disableSidePanel?;
10
+ static createDefaultModel: (model?: Partial<MultipleChoiceModel>) => AuthorModel;
3
11
  constructor();
4
- set model(s: any);
5
- set configuration(c: any);
6
- set disableSidePanel(s: any);
7
- dispatchModelUpdated(reset: any): void;
8
- onModelChanged(m: any, reset: any): void;
9
- onConfigurationChanged(c: any): void;
12
+ set model(s: Partial<MultipleChoiceModel>);
13
+ set configuration(c: MultipleChoiceConfiguration);
14
+ set disableSidePanel(s: boolean);
15
+ dispatchModelUpdated(reset?: boolean): void;
16
+ onModelChanged(m: Partial<AuthorModel>, reset?: boolean): void;
17
+ onConfigurationChanged(c: MultipleChoiceConfiguration): void;
10
18
  /** @param {done, progress, file} handler */
11
- insertImage(handler: any): void;
12
- onDeleteImage(src: any, done: any): void;
13
- insertSound(handler: any): void;
14
- onDeleteSound(src: any, done: any): void;
19
+ insertImage(handler: ImageHandler): void;
20
+ onDeleteImage(src: string, done: DeleteDone): void;
21
+ insertSound(handler: SoundHandler): void;
22
+ onDeleteSound(src: string, done: DeleteDone): void;
15
23
  _render(): void;
16
24
  connectedCallback(): void;
17
25
  disconnectedCallback(): void;
@@ -31,6 +31,11 @@ var f = a("multiple-choice:configure"), p = (e, t = 0) => {
31
31
  }
32
32
  };
33
33
  }, h = class i extends HTMLElement {
34
+ _root;
35
+ _reactContainer;
36
+ _model;
37
+ _configuration;
38
+ _disableSidePanel;
34
39
  static createDefaultModel = (e = {}) => {
35
40
  let n = d.normalizeChoices({
36
41
  ...t.model,
@@ -52,7 +57,7 @@ var f = a("multiple-choice:configure"), p = (e, t = 0) => {
52
57
  ...t.configuration,
53
58
  ...n.configuration
54
59
  };
55
- this._configuration = r, r?.language?.enabled ? r?.languageChoices?.options?.length && (this._model.language = r?.languageChoices.options[0].value) : r.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
60
+ this._configuration = r, r?.language?.enabled ? r?.languageChoices?.options?.length && (this._model.language = r?.languageChoices.options[0].value) : r.language.settings && this._model.language ? (r.language.enabled = !0, (!r.languageChoices.options || !r.languageChoices.options.length) && (r.languageChoices.options = []), r.languageChoices.options.find((e) => e.value === this._model.language) || r.languageChoices.options.push({
56
61
  value: this._model.language,
57
62
  label: this._model.language
58
63
  })) : delete this._model.language, this._render();
@@ -1,26 +1,37 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
- export declare class Main extends React.Component {
4
- static propTypes: {
5
- model: PropTypes.Validator<object>;
6
- configuration: PropTypes.Validator<object>;
7
- disableSidePanel: PropTypes.Requireable<boolean>;
8
- onModelChanged: PropTypes.Validator<(...args: any[]) => any>;
9
- onConfigurationChanged: PropTypes.Validator<(...args: any[]) => any>;
10
- imageSupport: PropTypes.Requireable<PropTypes.InferProps<{
11
- add: PropTypes.Validator<(...args: any[]) => any>;
12
- delete: PropTypes.Validator<(...args: any[]) => any>;
13
- }>>;
14
- };
2
+ import type { DeleteDone, ImageHandler, SoundHandler } from '@pie-element/shared-configure-events';
3
+ import type { MultipleChoiceValidationErrors } from '../controller/index.js';
4
+ import type { Choice, MultipleChoiceConfiguration, MultipleChoiceModel } from '../types.js';
5
+ /** The model the author edits; the host sets `errors` from the controller's `validate()`. */
6
+ export type AuthorModel = Partial<MultipleChoiceModel> & {
7
+ choices: Choice[];
8
+ errors?: MultipleChoiceValidationErrors;
9
+ };
10
+ type MediaSupport<Handler> = {
11
+ add: (handler: Handler) => void;
12
+ delete: (src: string, done: DeleteDone) => void;
13
+ };
14
+ export type MainProps = {
15
+ model: AuthorModel;
16
+ configuration: MultipleChoiceConfiguration;
17
+ disableSidePanel?: boolean;
18
+ onModelChanged: (model: Partial<AuthorModel>, reset?: boolean) => void;
19
+ onConfigurationChanged: (configuration: MultipleChoiceConfiguration) => void;
20
+ imageSupport?: MediaSupport<ImageHandler>;
21
+ uploadSoundSupport?: MediaSupport<SoundHandler>;
22
+ };
23
+ export declare class Main extends React.Component<MainProps, {
24
+ showWarning: boolean;
25
+ }> {
15
26
  state: {
16
27
  showWarning: boolean;
17
28
  };
18
- onRemoveChoice: any;
19
- onAddChoice: any;
20
- onChoiceChanged: any;
21
- onPromptChanged: any;
22
- onTeacherInstructionsChanged: any;
23
- onModelChanged: any;
29
+ onRemoveChoice: (index: number) => void;
30
+ onAddChoice: () => void;
31
+ onChoiceChanged: (index: number, choice: Choice) => void;
32
+ onPromptChanged: (prompt: string) => void;
33
+ onTeacherInstructionsChanged: (teacherInstructions: string) => void;
34
+ onModelChanged: (model: AuthorModel, key?: string) => void;
24
35
  render(): React.JSX.Element;
25
36
  }
26
37
  export default Main;