@pie-element/extended-text-entry 10.1.0-next.1 → 10.1.1-next.8

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/module/element.js DELETED
@@ -1,289 +0,0 @@
1
- import {_dll_react, _dll_pie_lib__pie_toolbox_editable_html, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_debug, _dll_lodash, _dll_pie_lib__pie_toolbox_render_ui, _dll_classnames, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-module@1.3.3/module/index.js";
2
- const React$1 = _dll_react;
3
- const {EditableHtml: EditableHtml} = _dll_pie_lib__pie_toolbox_editable_html;
4
- const PropTypes = _dll_prop_types;
5
- const {Typography: Typography} = _dll_material_ui__core;
6
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
7
- const debug$1 = _dll_debug;
8
- const {debounce: debounce} = _dll_lodash;
9
- const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
10
- const {Feedback: Feedback} = _dll_pie_lib__pie_toolbox_render_ui;
11
- const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
12
- const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
13
- const classnames = _dll_classnames;
14
- const _jsxFileName = "/Users/andreeapescar/WORK/pie/pie-elements/packages/extended-text-entry/src/main.jsx";
15
- const log$1 = debug$1('@pie-ui:extended-text-entry');
16
- const style = theme => ({
17
- main: {
18
- backgroundColor: color.background(),
19
- color: color.text()
20
- },
21
- prompt: {
22
- width: '100%',
23
- color: color.text(),
24
- marginBottom: theme.spacing.unit * 2,
25
- fontSize: 'inherit'
26
- },
27
- teacherInstructions: {
28
- marginBottom: theme.spacing.unit * 2
29
- },
30
- editor: {
31
- marginBottom: theme.spacing.unit * 2,
32
- borderRadius: '4px'
33
- },
34
- srOnly: {
35
- position: 'absolute',
36
- left: '-10000px',
37
- top: 'auto',
38
- width: '1px',
39
- height: '1px',
40
- overflow: 'hidden'
41
- }
42
- });
43
- class Main extends React$1.Component {
44
- constructor(...args) {
45
- super(...args);
46
- Main.prototype.__init.call(this);
47
- }
48
- static __initStatic() {
49
- this.propTypes = {
50
- onChange: PropTypes.func.isRequired,
51
- model: PropTypes.object,
52
- classes: PropTypes.object.isRequired,
53
- session: PropTypes.shape({
54
- value: PropTypes.string
55
- }).isRequired
56
- };
57
- }
58
- __init() {
59
- this.changeSession = debounce(this.props.onChange, 1500);
60
- }
61
- render() {
62
- const {model, classes, session} = this.props;
63
- const {dimensions, disabled, feedback, teacherInstructions, mathInput, spanishInput, specialInput, animationsDisabled, playersToolbarPosition, spellCheckEnabled} = model;
64
- const {value} = session;
65
- const {width, height} = dimensions || ({});
66
- const maxHeight = '40vh';
67
- const toolbarOpts = {
68
- position: playersToolbarPosition === 'top' ? 'top' : 'bottom'
69
- };
70
- log$1('[render] disabled? ', disabled);
71
- const teacherInstructionsDiv = React$1.createElement(PreviewPrompt, {
72
- defaultClassName: "teacher-instructions",
73
- prompt: teacherInstructions,
74
- __self: this,
75
- __source: {
76
- fileName: _jsxFileName,
77
- lineNumber: 76
78
- }
79
- });
80
- const languageCharactersProps = [];
81
- if (spanishInput) {
82
- languageCharactersProps.push({
83
- language: 'spanish'
84
- });
85
- }
86
- if (specialInput) {
87
- languageCharactersProps.push({
88
- language: 'special'
89
- });
90
- }
91
- return React$1.createElement('div', {
92
- className: classes.main,
93
- ref: ref => {
94
- this.containerRef = ref;
95
- },
96
- __self: this,
97
- __source: {
98
- fileName: _jsxFileName,
99
- lineNumber: 90
100
- }
101
- }, React$1.createElement('h2', {
102
- className: classes.srOnly,
103
- __self: this,
104
- __source: {
105
- fileName: _jsxFileName,
106
- lineNumber: 96
107
- }
108
- }, "Constructed Response Question"), teacherInstructions && React$1.createElement('div', {
109
- className: classes.teacherInstructions,
110
- __self: this,
111
- __source: {
112
- fileName: _jsxFileName,
113
- lineNumber: 99
114
- }
115
- }, !animationsDisabled ? React$1.createElement(Collapsible, {
116
- labels: {
117
- hidden: 'Show Teacher Instructions',
118
- visible: 'Hide Teacher Instructions'
119
- },
120
- className: classes.collapsible,
121
- __self: this,
122
- __source: {
123
- fileName: _jsxFileName,
124
- lineNumber: 101
125
- }
126
- }, teacherInstructionsDiv) : teacherInstructionsDiv), model.prompt && React$1.createElement(Typography, {
127
- component: 'span',
128
- className: classes.prompt,
129
- __self: this,
130
- __source: {
131
- fileName: _jsxFileName,
132
- lineNumber: 114
133
- }
134
- }, React$1.createElement(PreviewPrompt, {
135
- defaultClassName: "prompt",
136
- prompt: model.prompt,
137
- __self: this,
138
- __source: {
139
- fileName: _jsxFileName,
140
- lineNumber: 115
141
- }
142
- })), React$1.createElement(EditableHtml, {
143
- className: classnames(classes.editor, 'response-area-editor'),
144
- onChange: this.changeSession,
145
- markup: value || '',
146
- width: width && width.toString(),
147
- minHeight: height && height.toString(),
148
- maxHeight: maxHeight,
149
- disabled: disabled,
150
- highlightShape: true,
151
- toolbarOpts: toolbarOpts,
152
- spellCheck: spellCheckEnabled,
153
- pluginProps: {
154
- math: {
155
- disabled: !mathInput,
156
- customKeys: this.props.model.customKeys,
157
- keypadMode: this.props.model.equationEditor,
158
- controlledKeypadMode: false
159
- },
160
- video: {
161
- disabled: true
162
- },
163
- audio: {
164
- disabled: true
165
- }
166
- },
167
- languageCharactersProps: languageCharactersProps,
168
- __self: this,
169
- __source: {
170
- fileName: _jsxFileName,
171
- lineNumber: 119
172
- }
173
- }), feedback && React$1.createElement(Feedback, {
174
- correctness: "correct",
175
- feedback: feedback,
176
- __self: this,
177
- __source: {
178
- fileName: _jsxFileName,
179
- lineNumber: 147
180
- }
181
- }));
182
- }
183
- }
184
- Main.__initStatic();
185
- var Main$1 = withStyles(style)(Main);
186
- var lib = {};
187
- Object.defineProperty(lib, "__esModule", {
188
- value: true
189
- });
190
- class ModelSetEvent extends CustomEvent {
191
- constructor(component, complete, hasModel) {
192
- super(ModelSetEvent.TYPE, {
193
- bubbles: true,
194
- composed: true,
195
- detail: {
196
- complete,
197
- component,
198
- hasModel
199
- }
200
- });
201
- this.component = component;
202
- this.complete = complete;
203
- }
204
- }
205
- ModelSetEvent.TYPE = 'model-set';
206
- var ModelSetEvent_1 = lib.ModelSetEvent = ModelSetEvent;
207
- class SessionChangedEvent extends CustomEvent {
208
- constructor(component, complete) {
209
- super(SessionChangedEvent.TYPE, {
210
- bubbles: true,
211
- composed: true,
212
- detail: {
213
- complete,
214
- component
215
- }
216
- });
217
- this.component = component;
218
- this.complete = complete;
219
- }
220
- }
221
- SessionChangedEvent.TYPE = 'session-changed';
222
- var SessionChangedEvent_1 = lib.SessionChangedEvent = SessionChangedEvent;
223
- const React = _dll_react;
224
- const ReactDOM = _dll_react_dom;
225
- const {renderMath: renderMath} = _dll_pie_lib__pie_toolbox_math_rendering;
226
- const debug = _dll_debug;
227
- const log = debug('@pie-ui:extended-text-entry');
228
- const domParser = typeof window !== undefined ? new DOMParser() : {
229
- parseFromString: v => v
230
- };
231
- function textContent(value) {
232
- if (typeof value !== 'string') {
233
- return undefined;
234
- }
235
- try {
236
- const document = domParser.parseFromString(value, 'text/html');
237
- const textContent = document.body.textContent;
238
- return textContent;
239
- } catch (err) {
240
- log('tried to parse as dom and failed', value);
241
- return value;
242
- }
243
- }
244
- function isComplete(value) {
245
- const tc = textContent(value);
246
- const out = tc !== undefined && tc.length > 0;
247
- return out;
248
- }
249
- class RootExtendedTextEntry extends HTMLElement {
250
- constructor() {
251
- super();
252
- this._model = null;
253
- this._session = null;
254
- }
255
- set model(m) {
256
- this._model = m;
257
- this.dispatchEvent(new ModelSetEvent_1(this.tagName.toLowerCase(), false, !!this._model));
258
- this.render();
259
- }
260
- set session(s) {
261
- this._session = s;
262
- this.render();
263
- }
264
- get session() {
265
- return this._session;
266
- }
267
- handleChange(value) {
268
- this._session.value = value;
269
- this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), isComplete(value)));
270
- }
271
- connectedCallback() {
272
- this.setAttribute('aria-label', 'Written Response Question');
273
- this.setAttribute('role', 'region');
274
- this.render();
275
- }
276
- render() {
277
- if (this._model && this._session) {
278
- let elem = React.createElement(Main$1, {
279
- model: this._model,
280
- session: this._session,
281
- onChange: this.handleChange.bind(this)
282
- });
283
- ReactDOM.render(elem, this, () => {
284
- renderMath(this);
285
- });
286
- }
287
- }
288
- }
289
- export {RootExtendedTextEntry as default, isComplete, textContent};
package/module/index.html DELETED
@@ -1,21 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/extended-text-entry@10.1.0</title>
6
- <script
7
- type="module"
8
- src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
9
-
10
- <link
11
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
12
- rel="stylesheet"
13
- />
14
- <style>
15
- html, body {
16
- font-family: 'Roboto', sans-serif;
17
- }
18
- </style>
19
- <script type="module" src="./demo.js"></script>
20
- </head>
21
- </html>
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@pie-element/extended-text-entry",
3
- "version": "10.1.0",
4
- "modules": [
5
- {
6
- "name": "@pie-lib/pie-toolbox-module",
7
- "version": "1.3.3"
8
- }
9
- ]
10
- }
@@ -1,75 +0,0 @@
1
- import PrintElement from './print.js';
2
-
3
- var generate = {};
4
-
5
- generate.model = (id, element) => ({
6
- id,
7
- element,
8
- customKeys: ['\\square'],
9
- feedback: { type: 'default', default: 'this is default feedback' },
10
- prompt: 'This is the question prompt',
11
- promptEnabled: true,
12
- mathInput: true,
13
- playersToolbarPosition: 'bottom',
14
- toolbarEditorPosition: 'bottom',
15
- spellCheckEnabled: true,
16
- rubricEnabled: false,
17
- });
18
-
19
- const { model } = generate;
20
- var config = {
21
- elements: {
22
- 'extended-text-entry': '../..',
23
- },
24
- models: [model('1', 'extended-text-entry')],
25
- };
26
-
27
- // new init - just shows off print!
28
-
29
- const init = async () => {
30
- console.log('define the element...');
31
- await Promise.all(
32
- config.models.map(async (m) => {
33
- try {
34
- const printTag = `${m.element}-print`;
35
- if (customElements.get(printTag)) {
36
- return true;
37
- } else {
38
- customElements.define(printTag, PrintElement);
39
- await customElements.whenDefined(printTag);
40
- return true;
41
- }
42
- } catch (e) {
43
- return false;
44
- }
45
- })
46
- );
47
-
48
- console.log('now apply the model...');
49
- config.models.forEach((m) => {
50
- const printTag = `${m.element}-print`;
51
- const h3s = document.createElement('h3');
52
- h3s.textContent = 'student mode';
53
- document.body.appendChild(h3s);
54
- const de = document.createElement(printTag);
55
- document.body.appendChild(de);
56
- de.options = {};
57
- de.model = m;
58
-
59
- const h3 = document.createElement('h3');
60
- h3.textContent = 'instructor mode';
61
- document.body.appendChild(h3);
62
- const instr = document.createElement(printTag);
63
- document.body.appendChild(instr);
64
- instr.options = { mode: 'instructor' };
65
- instr.model = JSON.parse(JSON.stringify(m));
66
- });
67
- };
68
-
69
- init()
70
- .then(() => {
71
- console.log('ready');
72
- })
73
- .catch((e) => {
74
- console.error(e);
75
- });
package/module/print.html DELETED
@@ -1,18 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/extended-text-entry@10.1.0</title>
6
- <link
7
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
- rel="stylesheet"
9
- />
10
- <style>
11
- html, body {
12
- font-family: 'Roboto', sans-serif;
13
- }
14
- </style>
15
- <script type="module" src="./print-demo.js"></script>
16
- </head>
17
- <body></body>
18
- </html>
package/module/print.js DELETED
@@ -1,246 +0,0 @@
1
- import {_dll_react, _dll_pie_lib__pie_toolbox_editable_html, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_debug, _dll_lodash, _dll_pie_lib__pie_toolbox_render_ui, _dll_classnames, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-module@1.3.3/module/index.js";
2
- const React$1 = _dll_react;
3
- const {EditableHtml: EditableHtml} = _dll_pie_lib__pie_toolbox_editable_html;
4
- const PropTypes = _dll_prop_types;
5
- const {Typography: Typography} = _dll_material_ui__core;
6
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
7
- const debug$1 = _dll_debug;
8
- const {debounce: debounce$1} = _dll_lodash;
9
- const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
10
- const {Feedback: Feedback} = _dll_pie_lib__pie_toolbox_render_ui;
11
- const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
12
- const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
13
- const classnames = _dll_classnames;
14
- const _jsxFileName = "/Users/andreeapescar/WORK/pie/pie-elements/packages/extended-text-entry/src/main.jsx";
15
- const log$1 = debug$1('@pie-ui:extended-text-entry');
16
- const style = theme => ({
17
- main: {
18
- backgroundColor: color.background(),
19
- color: color.text()
20
- },
21
- prompt: {
22
- width: '100%',
23
- color: color.text(),
24
- marginBottom: theme.spacing.unit * 2,
25
- fontSize: 'inherit'
26
- },
27
- teacherInstructions: {
28
- marginBottom: theme.spacing.unit * 2
29
- },
30
- editor: {
31
- marginBottom: theme.spacing.unit * 2,
32
- borderRadius: '4px'
33
- },
34
- srOnly: {
35
- position: 'absolute',
36
- left: '-10000px',
37
- top: 'auto',
38
- width: '1px',
39
- height: '1px',
40
- overflow: 'hidden'
41
- }
42
- });
43
- class Main extends React$1.Component {
44
- constructor(...args) {
45
- super(...args);
46
- Main.prototype.__init.call(this);
47
- }
48
- static __initStatic() {
49
- this.propTypes = {
50
- onChange: PropTypes.func.isRequired,
51
- model: PropTypes.object,
52
- classes: PropTypes.object.isRequired,
53
- session: PropTypes.shape({
54
- value: PropTypes.string
55
- }).isRequired
56
- };
57
- }
58
- __init() {
59
- this.changeSession = debounce$1(this.props.onChange, 1500);
60
- }
61
- render() {
62
- const {model, classes, session} = this.props;
63
- const {dimensions, disabled, feedback, teacherInstructions, mathInput, spanishInput, specialInput, animationsDisabled, playersToolbarPosition, spellCheckEnabled} = model;
64
- const {value} = session;
65
- const {width, height} = dimensions || ({});
66
- const maxHeight = '40vh';
67
- const toolbarOpts = {
68
- position: playersToolbarPosition === 'top' ? 'top' : 'bottom'
69
- };
70
- log$1('[render] disabled? ', disabled);
71
- const teacherInstructionsDiv = React$1.createElement(PreviewPrompt, {
72
- defaultClassName: "teacher-instructions",
73
- prompt: teacherInstructions,
74
- __self: this,
75
- __source: {
76
- fileName: _jsxFileName,
77
- lineNumber: 76
78
- }
79
- });
80
- const languageCharactersProps = [];
81
- if (spanishInput) {
82
- languageCharactersProps.push({
83
- language: 'spanish'
84
- });
85
- }
86
- if (specialInput) {
87
- languageCharactersProps.push({
88
- language: 'special'
89
- });
90
- }
91
- return React$1.createElement('div', {
92
- className: classes.main,
93
- ref: ref => {
94
- this.containerRef = ref;
95
- },
96
- __self: this,
97
- __source: {
98
- fileName: _jsxFileName,
99
- lineNumber: 90
100
- }
101
- }, React$1.createElement('h2', {
102
- className: classes.srOnly,
103
- __self: this,
104
- __source: {
105
- fileName: _jsxFileName,
106
- lineNumber: 96
107
- }
108
- }, "Constructed Response Question"), teacherInstructions && React$1.createElement('div', {
109
- className: classes.teacherInstructions,
110
- __self: this,
111
- __source: {
112
- fileName: _jsxFileName,
113
- lineNumber: 99
114
- }
115
- }, !animationsDisabled ? React$1.createElement(Collapsible, {
116
- labels: {
117
- hidden: 'Show Teacher Instructions',
118
- visible: 'Hide Teacher Instructions'
119
- },
120
- className: classes.collapsible,
121
- __self: this,
122
- __source: {
123
- fileName: _jsxFileName,
124
- lineNumber: 101
125
- }
126
- }, teacherInstructionsDiv) : teacherInstructionsDiv), model.prompt && React$1.createElement(Typography, {
127
- component: 'span',
128
- className: classes.prompt,
129
- __self: this,
130
- __source: {
131
- fileName: _jsxFileName,
132
- lineNumber: 114
133
- }
134
- }, React$1.createElement(PreviewPrompt, {
135
- defaultClassName: "prompt",
136
- prompt: model.prompt,
137
- __self: this,
138
- __source: {
139
- fileName: _jsxFileName,
140
- lineNumber: 115
141
- }
142
- })), React$1.createElement(EditableHtml, {
143
- className: classnames(classes.editor, 'response-area-editor'),
144
- onChange: this.changeSession,
145
- markup: value || '',
146
- width: width && width.toString(),
147
- minHeight: height && height.toString(),
148
- maxHeight: maxHeight,
149
- disabled: disabled,
150
- highlightShape: true,
151
- toolbarOpts: toolbarOpts,
152
- spellCheck: spellCheckEnabled,
153
- pluginProps: {
154
- math: {
155
- disabled: !mathInput,
156
- customKeys: this.props.model.customKeys,
157
- keypadMode: this.props.model.equationEditor,
158
- controlledKeypadMode: false
159
- },
160
- video: {
161
- disabled: true
162
- },
163
- audio: {
164
- disabled: true
165
- }
166
- },
167
- languageCharactersProps: languageCharactersProps,
168
- __self: this,
169
- __source: {
170
- fileName: _jsxFileName,
171
- lineNumber: 119
172
- }
173
- }), feedback && React$1.createElement(Feedback, {
174
- correctness: "correct",
175
- feedback: feedback,
176
- __self: this,
177
- __source: {
178
- fileName: _jsxFileName,
179
- lineNumber: 147
180
- }
181
- }));
182
- }
183
- }
184
- Main.__initStatic();
185
- var Main$1 = withStyles(style)(Main);
186
- const React = _dll_react;
187
- const ReactDOM = _dll_react_dom;
188
- const {debounce: debounce} = _dll_lodash;
189
- const {renderMath: renderMath} = _dll_pie_lib__pie_toolbox_math_rendering;
190
- const debug = _dll_debug;
191
- const log = debug('pie-element:extended-text-entry:print');
192
- const preparePrintModel = (model, opts) => {
193
- const instr = opts.role === 'instructor';
194
- model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
195
- model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
196
- model.showTeacherInstructions = instr;
197
- model.mode = instr ? 'evaluate' : model.mode;
198
- const defaultDimensions = {
199
- height: 100,
200
- width: 500
201
- };
202
- model.dimensions = {
203
- ...defaultDimensions,
204
- ...model.dimensions
205
- };
206
- model.disabled = true;
207
- model.feedback = undefined;
208
- model.animationsDisabled = true;
209
- return model;
210
- };
211
- class ExtendedTextEntryPrint extends HTMLElement {
212
- constructor() {
213
- super();
214
- this._options = null;
215
- this._model = null;
216
- this._session = [];
217
- this._rerender = debounce(() => {
218
- if (this._model && this._session) {
219
- const printModel = preparePrintModel(this._model, this._options);
220
- const element = this._options && React.createElement(Main$1, {
221
- model: printModel,
222
- session: {},
223
- onChange: () => {}
224
- });
225
- ReactDOM.render(element, this, () => {
226
- log('render complete - render math');
227
- renderMath(this);
228
- });
229
- } else {
230
- log('skip');
231
- }
232
- }, 50, {
233
- leading: false,
234
- trailing: true
235
- });
236
- }
237
- set options(o) {
238
- this._options = o;
239
- }
240
- set model(s) {
241
- this._model = s;
242
- this._rerender();
243
- }
244
- connectedCallback() {}
245
- }
246
- export {ExtendedTextEntryPrint as default};