@pie-element/extended-text-entry 10.0.4-next.69 → 10.1.0-next.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,246 @@
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry",
3
- "version": "10.0.4-next.69+84f517e36",
3
+ "version": "10.1.0-next.1",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -12,7 +12,7 @@
12
12
  "@material-ui/core": "^3.9.2",
13
13
  "@material-ui/icons": "^3.0.2",
14
14
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/pie-toolbox": "1.4.0",
15
+ "@pie-lib/pie-toolbox": "1.4.1",
16
16
  "classnames": "^2.2.5",
17
17
  "debug": "^4.1.1",
18
18
  "lodash.throttle": "^4.1.1",
@@ -20,7 +20,7 @@
20
20
  "react": "^16.8.1",
21
21
  "react-dom": "^16.8.1"
22
22
  },
23
- "gitHead": "84f517e360d8415650bb7f0aec1be8cf8660c8f9",
23
+ "gitHead": "0e14ff981bcdc8a89a0e58484026496701bfdbc3",
24
24
  "scripts": {
25
25
  "postpublish": "../../scripts/postpublish"
26
26
  },
package/LICENSE.md DELETED
@@ -1,5 +0,0 @@
1
- Copyright 2019 CoreSpring Inc
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
-
5
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.