@pie-element/match 4.7.2 → 4.7.3-next.1016

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/configure/CHANGELOG.md +170 -0
  3. package/configure/lib/add-row.js +1 -1
  4. package/configure/lib/add-row.js.map +1 -1
  5. package/configure/lib/answer-config-block.js +151 -35
  6. package/configure/lib/answer-config-block.js.map +1 -1
  7. package/configure/lib/common.js +46 -0
  8. package/configure/lib/common.js.map +1 -0
  9. package/configure/lib/configure.js +49 -10
  10. package/configure/lib/configure.js.map +1 -1
  11. package/configure/lib/defaults.js +19 -1
  12. package/configure/lib/defaults.js.map +1 -1
  13. package/configure/lib/general-config-block.js +81 -31
  14. package/configure/lib/general-config-block.js.map +1 -1
  15. package/configure/lib/index.js +4 -4
  16. package/configure/lib/index.js.map +1 -1
  17. package/configure/lib/row.js +109 -21
  18. package/configure/lib/row.js.map +1 -1
  19. package/configure/package.json +4 -4
  20. package/configure/utils.js +11 -0
  21. package/controller/CHANGELOG.md +16 -0
  22. package/controller/lib/index.js +37 -3
  23. package/controller/lib/index.js.map +1 -1
  24. package/controller/package.json +1 -1
  25. package/docs/config-schema.json +94 -0
  26. package/docs/config-schema.json.md +73 -1
  27. package/docs/demo/generate.js +1 -0
  28. package/docs/pie-schema.json +42 -0
  29. package/docs/pie-schema.json.md +35 -0
  30. package/lib/answer-grid.js +9 -10
  31. package/lib/answer-grid.js.map +1 -1
  32. package/lib/index.js +7 -2
  33. package/lib/index.js.map +1 -1
  34. package/lib/main.js +11 -17
  35. package/lib/main.js.map +1 -1
  36. package/package.json +5 -5
  37. package/module/configure.js +0 -1776
  38. package/module/controller.js +0 -21219
  39. package/module/demo.js +0 -75
  40. package/module/element.js +0 -591
  41. package/module/index.html +0 -16
  42. package/module/manifest.json +0 -10
@@ -1,1776 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_react_dnd, _dll_pie_lib__drag, _dll_lodash, _dll_react_dom} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
2
- import {_dll_pie_lib__config_ui, _dll_pie_lib__editable_html, _dll_pie_framework__pie_configure_events} from "../../shared-config@^1.8.13/module/index.js";
3
- function unwrapExports(x) {
4
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
- }
6
- function createCommonjsModule(fn, module) {
7
- return (module = {
8
- exports: {}
9
- }, fn(module, module.exports), module.exports);
10
- }
11
- var s = 1000;
12
- var m = s * 60;
13
- var h = m * 60;
14
- var d = h * 24;
15
- var w = d * 7;
16
- var y = d * 365.25;
17
- var ms = function (val, options) {
18
- options = options || ({});
19
- var type = typeof val;
20
- if (type === 'string' && val.length > 0) {
21
- return parse(val);
22
- } else if (type === 'number' && isFinite(val)) {
23
- return options.long ? fmtLong(val) : fmtShort(val);
24
- }
25
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
26
- };
27
- function parse(str) {
28
- str = String(str);
29
- if (str.length > 100) {
30
- return;
31
- }
32
- var match = (/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i).exec(str);
33
- if (!match) {
34
- return;
35
- }
36
- var n = parseFloat(match[1]);
37
- var type = (match[2] || 'ms').toLowerCase();
38
- switch (type) {
39
- case 'years':
40
- case 'year':
41
- case 'yrs':
42
- case 'yr':
43
- case 'y':
44
- return n * y;
45
- case 'weeks':
46
- case 'week':
47
- case 'w':
48
- return n * w;
49
- case 'days':
50
- case 'day':
51
- case 'd':
52
- return n * d;
53
- case 'hours':
54
- case 'hour':
55
- case 'hrs':
56
- case 'hr':
57
- case 'h':
58
- return n * h;
59
- case 'minutes':
60
- case 'minute':
61
- case 'mins':
62
- case 'min':
63
- case 'm':
64
- return n * m;
65
- case 'seconds':
66
- case 'second':
67
- case 'secs':
68
- case 'sec':
69
- case 's':
70
- return n * s;
71
- case 'milliseconds':
72
- case 'millisecond':
73
- case 'msecs':
74
- case 'msec':
75
- case 'ms':
76
- return n;
77
- default:
78
- return undefined;
79
- }
80
- }
81
- function fmtShort(ms) {
82
- var msAbs = Math.abs(ms);
83
- if (msAbs >= d) {
84
- return Math.round(ms / d) + 'd';
85
- }
86
- if (msAbs >= h) {
87
- return Math.round(ms / h) + 'h';
88
- }
89
- if (msAbs >= m) {
90
- return Math.round(ms / m) + 'm';
91
- }
92
- if (msAbs >= s) {
93
- return Math.round(ms / s) + 's';
94
- }
95
- return ms + 'ms';
96
- }
97
- function fmtLong(ms) {
98
- var msAbs = Math.abs(ms);
99
- if (msAbs >= d) {
100
- return plural(ms, msAbs, d, 'day');
101
- }
102
- if (msAbs >= h) {
103
- return plural(ms, msAbs, h, 'hour');
104
- }
105
- if (msAbs >= m) {
106
- return plural(ms, msAbs, m, 'minute');
107
- }
108
- if (msAbs >= s) {
109
- return plural(ms, msAbs, s, 'second');
110
- }
111
- return ms + ' ms';
112
- }
113
- function plural(ms, msAbs, n, name) {
114
- var isPlural = msAbs >= n * 1.5;
115
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
116
- }
117
- function setup(env) {
118
- createDebug.debug = createDebug;
119
- createDebug.default = createDebug;
120
- createDebug.coerce = coerce;
121
- createDebug.disable = disable;
122
- createDebug.enable = enable;
123
- createDebug.enabled = enabled;
124
- createDebug.humanize = ms;
125
- Object.keys(env).forEach(function (key) {
126
- createDebug[key] = env[key];
127
- });
128
- createDebug.instances = [];
129
- createDebug.names = [];
130
- createDebug.skips = [];
131
- createDebug.formatters = {};
132
- function selectColor(namespace) {
133
- var hash = 0;
134
- for (var i = 0; i < namespace.length; i++) {
135
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
136
- hash |= 0;
137
- }
138
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
139
- }
140
- createDebug.selectColor = selectColor;
141
- function createDebug(namespace) {
142
- var prevTime;
143
- function debug() {
144
- if (!debug.enabled) {
145
- return;
146
- }
147
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
148
- args[_key] = arguments[_key];
149
- }
150
- var self = debug;
151
- var curr = Number(new Date());
152
- var ms = curr - (prevTime || curr);
153
- self.diff = ms;
154
- self.prev = prevTime;
155
- self.curr = curr;
156
- prevTime = curr;
157
- args[0] = createDebug.coerce(args[0]);
158
- if (typeof args[0] !== 'string') {
159
- args.unshift('%O');
160
- }
161
- var index = 0;
162
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
163
- if (match === '%%') {
164
- return match;
165
- }
166
- index++;
167
- var formatter = createDebug.formatters[format];
168
- if (typeof formatter === 'function') {
169
- var val = args[index];
170
- match = formatter.call(self, val);
171
- args.splice(index, 1);
172
- index--;
173
- }
174
- return match;
175
- });
176
- createDebug.formatArgs.call(self, args);
177
- var logFn = self.log || createDebug.log;
178
- logFn.apply(self, args);
179
- }
180
- debug.namespace = namespace;
181
- debug.enabled = createDebug.enabled(namespace);
182
- debug.useColors = createDebug.useColors();
183
- debug.color = selectColor(namespace);
184
- debug.destroy = destroy;
185
- debug.extend = extend;
186
- if (typeof createDebug.init === 'function') {
187
- createDebug.init(debug);
188
- }
189
- createDebug.instances.push(debug);
190
- return debug;
191
- }
192
- function destroy() {
193
- var index = createDebug.instances.indexOf(this);
194
- if (index !== -1) {
195
- createDebug.instances.splice(index, 1);
196
- return true;
197
- }
198
- return false;
199
- }
200
- function extend(namespace, delimiter) {
201
- return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
202
- }
203
- function enable(namespaces) {
204
- createDebug.save(namespaces);
205
- createDebug.names = [];
206
- createDebug.skips = [];
207
- var i;
208
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
209
- var len = split.length;
210
- for (i = 0; i < len; i++) {
211
- if (!split[i]) {
212
- continue;
213
- }
214
- namespaces = split[i].replace(/\*/g, '.*?');
215
- if (namespaces[0] === '-') {
216
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
217
- } else {
218
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
219
- }
220
- }
221
- for (i = 0; i < createDebug.instances.length; i++) {
222
- var instance = createDebug.instances[i];
223
- instance.enabled = createDebug.enabled(instance.namespace);
224
- }
225
- }
226
- function disable() {
227
- createDebug.enable('');
228
- }
229
- function enabled(name) {
230
- if (name[name.length - 1] === '*') {
231
- return true;
232
- }
233
- var i;
234
- var len;
235
- for ((i = 0, len = createDebug.skips.length); i < len; i++) {
236
- if (createDebug.skips[i].test(name)) {
237
- return false;
238
- }
239
- }
240
- for ((i = 0, len = createDebug.names.length); i < len; i++) {
241
- if (createDebug.names[i].test(name)) {
242
- return true;
243
- }
244
- }
245
- return false;
246
- }
247
- function coerce(val) {
248
- if (val instanceof Error) {
249
- return val.stack || val.message;
250
- }
251
- return val;
252
- }
253
- createDebug.enable(createDebug.load());
254
- return createDebug;
255
- }
256
- var common = setup;
257
- var browser = createCommonjsModule(function (module, exports) {
258
- function _typeof(obj) {
259
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
260
- _typeof = function _typeof(obj) {
261
- return typeof obj;
262
- };
263
- } else {
264
- _typeof = function _typeof(obj) {
265
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
266
- };
267
- }
268
- return _typeof(obj);
269
- }
270
- exports.log = log;
271
- exports.formatArgs = formatArgs;
272
- exports.save = save;
273
- exports.load = load;
274
- exports.useColors = useColors;
275
- exports.storage = localstorage();
276
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
277
- function useColors() {
278
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
279
- return true;
280
- }
281
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
282
- return false;
283
- }
284
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
285
- }
286
- function formatArgs(args) {
287
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
288
- if (!this.useColors) {
289
- return;
290
- }
291
- var c = 'color: ' + this.color;
292
- args.splice(1, 0, c, 'color: inherit');
293
- var index = 0;
294
- var lastC = 0;
295
- args[0].replace(/%[a-zA-Z%]/g, function (match) {
296
- if (match === '%%') {
297
- return;
298
- }
299
- index++;
300
- if (match === '%c') {
301
- lastC = index;
302
- }
303
- });
304
- args.splice(lastC, 0, c);
305
- }
306
- function log() {
307
- var _console;
308
- return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
309
- }
310
- function save(namespaces) {
311
- try {
312
- if (namespaces) {
313
- exports.storage.setItem('debug', namespaces);
314
- } else {
315
- exports.storage.removeItem('debug');
316
- }
317
- } catch (error) {}
318
- }
319
- function load() {
320
- var r;
321
- try {
322
- r = exports.storage.getItem('debug');
323
- } catch (error) {}
324
- if (!r && typeof process !== 'undefined' && ('env' in process)) {
325
- r = process.env.DEBUG;
326
- }
327
- return r;
328
- }
329
- function localstorage() {
330
- try {
331
- return localStorage;
332
- } catch (error) {}
333
- }
334
- module.exports = common(exports);
335
- var formatters = module.exports.formatters;
336
- formatters.j = function (v) {
337
- try {
338
- return JSON.stringify(v);
339
- } catch (error) {
340
- return '[UnexpectedJSONParseError]: ' + error.message;
341
- }
342
- };
343
- });
344
- browser.log;
345
- browser.formatArgs;
346
- browser.save;
347
- browser.load;
348
- browser.useColors;
349
- browser.storage;
350
- browser.colors;
351
- const React = _dll_react;
352
- const PropTypes = _dll_prop_types;
353
- const {Select: Select} = _dll_material_ui__core;
354
- const {MenuItem: MenuItem} = _dll_material_ui__core;
355
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
356
- const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
357
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/packages/match/configure/src/general-config-block.jsx";
358
- const styles = theme => ({
359
- container: {
360
- marginTop: theme.spacing.unit * 2,
361
- display: 'flex'
362
- },
363
- input: {
364
- flex: 1
365
- },
366
- inputContainer: {
367
- width: '90%'
368
- }
369
- });
370
- class GeneralConfigBlock extends React.Component {
371
- constructor(...args) {
372
- super(...args);
373
- GeneralConfigBlock.prototype.__init.call(this);
374
- }
375
- static __initStatic() {
376
- this.propTypes = {
377
- classes: PropTypes.object.isRequired,
378
- model: PropTypes.object.isRequired,
379
- configuration: PropTypes.object.isRequired,
380
- onResponseTypeChange: PropTypes.func.isRequired,
381
- onLayoutChange: PropTypes.func.isRequired
382
- };
383
- }
384
- __init() {
385
- this.onChange = name => event => {
386
- const {model, onLayoutChange, onResponseTypeChange} = this.props;
387
- const newModel = {
388
- ...model
389
- };
390
- newModel[name] = event.target.value;
391
- if (name === 'layout') {
392
- onLayoutChange(newModel[name]);
393
- } else {
394
- onResponseTypeChange(newModel[name]);
395
- }
396
- };
397
- }
398
- render() {
399
- const {classes, model, configuration} = this.props;
400
- const {layout = {}, choiceMode = {}} = configuration || ({});
401
- return React.createElement('div', {
402
- className: classes.container,
403
- __self: this,
404
- __source: {
405
- fileName: _jsxFileName,
406
- lineNumber: 51
407
- }
408
- }, React.createElement('div', {
409
- className: classes.input,
410
- __self: this,
411
- __source: {
412
- fileName: _jsxFileName,
413
- lineNumber: 52
414
- }
415
- }, layout.settings && React.createElement(InputContainer, {
416
- label: layout.label,
417
- className: classes.inputContainer,
418
- __self: this,
419
- __source: {
420
- fileName: _jsxFileName,
421
- lineNumber: 54
422
- }
423
- }, React.createElement(Select, {
424
- className: classes.select,
425
- onChange: this.onChange('layout'),
426
- value: model.layout,
427
- __self: this,
428
- __source: {
429
- fileName: _jsxFileName,
430
- lineNumber: 58
431
- }
432
- }, React.createElement(MenuItem, {
433
- value: 3,
434
- __self: this,
435
- __source: {
436
- fileName: _jsxFileName,
437
- lineNumber: 63
438
- }
439
- }, "3 Columns"), React.createElement(MenuItem, {
440
- value: 4,
441
- __self: this,
442
- __source: {
443
- fileName: _jsxFileName,
444
- lineNumber: 64
445
- }
446
- }, "4 Columns"), React.createElement(MenuItem, {
447
- value: 5,
448
- __self: this,
449
- __source: {
450
- fileName: _jsxFileName,
451
- lineNumber: 65
452
- }
453
- }, "5 Columns")))), React.createElement('div', {
454
- className: classes.input,
455
- __self: this,
456
- __source: {
457
- fileName: _jsxFileName,
458
- lineNumber: 70
459
- }
460
- }, choiceMode.settings && React.createElement(InputContainer, {
461
- label: choiceMode.label,
462
- className: classes.inputContainer,
463
- __self: this,
464
- __source: {
465
- fileName: _jsxFileName,
466
- lineNumber: 73
467
- }
468
- }, React.createElement(Select, {
469
- className: classes.select,
470
- onChange: this.onChange('choiceMode'),
471
- value: model.choiceMode,
472
- __self: this,
473
- __source: {
474
- fileName: _jsxFileName,
475
- lineNumber: 74
476
- }
477
- }, React.createElement(MenuItem, {
478
- value: "radio",
479
- __self: this,
480
- __source: {
481
- fileName: _jsxFileName,
482
- lineNumber: 79
483
- }
484
- }, "Radio - One Answer"), React.createElement(MenuItem, {
485
- value: "checkbox",
486
- __self: this,
487
- __source: {
488
- fileName: _jsxFileName,
489
- lineNumber: 80
490
- }
491
- }, "Checkbox - Multiple Answers")))));
492
- }
493
- }
494
- GeneralConfigBlock.__initStatic();
495
- var GeneralConfigBlock$1 = withStyles(styles)(GeneralConfigBlock);
496
- var classnames = createCommonjsModule(function (module) {
497
- (function () {
498
- var hasOwn = ({}).hasOwnProperty;
499
- function classNames() {
500
- var classes = [];
501
- for (var i = 0; i < arguments.length; i++) {
502
- var arg = arguments[i];
503
- if (!arg) continue;
504
- var argType = typeof arg;
505
- if (argType === 'string' || argType === 'number') {
506
- classes.push(arg);
507
- } else if (Array.isArray(arg) && arg.length) {
508
- var inner = classNames.apply(null, arg);
509
- if (inner) {
510
- classes.push(inner);
511
- }
512
- } else if (argType === 'object') {
513
- for (var key in arg) {
514
- if (hasOwn.call(arg, key) && arg[key]) {
515
- classes.push(key);
516
- }
517
- }
518
- }
519
- }
520
- return classes.join(' ');
521
- }
522
- if (module.exports) {
523
- classNames.default = classNames;
524
- module.exports = classNames;
525
- } else {
526
- window.classNames = classNames;
527
- }
528
- })();
529
- });
530
- var interopRequireDefault = createCommonjsModule(function (module) {
531
- function _interopRequireDefault(obj) {
532
- return obj && obj.__esModule ? obj : {
533
- "default": obj
534
- };
535
- }
536
- module.exports = _interopRequireDefault;
537
- });
538
- unwrapExports(interopRequireDefault);
539
- var setPrototypeOf = createCommonjsModule(function (module) {
540
- function _setPrototypeOf(o, p) {
541
- module.exports = _setPrototypeOf = Object.setPrototypeOf || (function _setPrototypeOf(o, p) {
542
- o.__proto__ = p;
543
- return o;
544
- });
545
- return _setPrototypeOf(o, p);
546
- }
547
- module.exports = _setPrototypeOf;
548
- });
549
- function _inheritsLoose(subClass, superClass) {
550
- subClass.prototype = Object.create(superClass.prototype);
551
- subClass.prototype.constructor = subClass;
552
- setPrototypeOf(subClass, superClass);
553
- }
554
- var inheritsLoose = _inheritsLoose;
555
- var setStatic_1 = createCommonjsModule(function (module, exports) {
556
- exports.__esModule = true;
557
- exports.default = void 0;
558
- var setStatic = function setStatic(key, value) {
559
- return function (BaseComponent) {
560
- BaseComponent[key] = value;
561
- return BaseComponent;
562
- };
563
- };
564
- var _default = setStatic;
565
- exports.default = _default;
566
- });
567
- unwrapExports(setStatic_1);
568
- var setDisplayName_1 = createCommonjsModule(function (module, exports) {
569
- exports.__esModule = true;
570
- exports.default = void 0;
571
- var _setStatic = interopRequireDefault(setStatic_1);
572
- var setDisplayName = function setDisplayName(displayName) {
573
- return (0, _setStatic.default)('displayName', displayName);
574
- };
575
- var _default = setDisplayName;
576
- exports.default = _default;
577
- });
578
- unwrapExports(setDisplayName_1);
579
- var getDisplayName_1 = createCommonjsModule(function (module, exports) {
580
- exports.__esModule = true;
581
- exports.default = void 0;
582
- var getDisplayName = function getDisplayName(Component) {
583
- if (typeof Component === 'string') {
584
- return Component;
585
- }
586
- if (!Component) {
587
- return undefined;
588
- }
589
- return Component.displayName || Component.name || 'Component';
590
- };
591
- var _default = getDisplayName;
592
- exports.default = _default;
593
- });
594
- unwrapExports(getDisplayName_1);
595
- var wrapDisplayName_1 = createCommonjsModule(function (module, exports) {
596
- exports.__esModule = true;
597
- exports.default = void 0;
598
- var _getDisplayName = interopRequireDefault(getDisplayName_1);
599
- var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
600
- return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
601
- };
602
- var _default = wrapDisplayName;
603
- exports.default = _default;
604
- });
605
- unwrapExports(wrapDisplayName_1);
606
- const _react = _dll_react;
607
- var shouldUpdate_1 = createCommonjsModule(function (module, exports) {
608
- exports.__esModule = true;
609
- exports.default = void 0;
610
- var _inheritsLoose2 = interopRequireDefault(inheritsLoose);
611
- var _setDisplayName = interopRequireDefault(setDisplayName_1);
612
- var _wrapDisplayName = interopRequireDefault(wrapDisplayName_1);
613
- var shouldUpdate = function shouldUpdate(test) {
614
- return function (BaseComponent) {
615
- var factory = (0, _react.createFactory)(BaseComponent);
616
- var ShouldUpdate = (function (_Component) {
617
- (0, _inheritsLoose2.default)(ShouldUpdate, _Component);
618
- function ShouldUpdate() {
619
- return _Component.apply(this, arguments) || this;
620
- }
621
- var _proto = ShouldUpdate.prototype;
622
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
623
- return test(this.props, nextProps);
624
- };
625
- _proto.render = function render() {
626
- return factory(this.props);
627
- };
628
- return ShouldUpdate;
629
- })(_react.Component);
630
- {
631
- return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
632
- }
633
- };
634
- };
635
- var _default = shouldUpdate;
636
- exports.default = _default;
637
- });
638
- unwrapExports(shouldUpdate_1);
639
- var hasOwnProperty = Object.prototype.hasOwnProperty;
640
- function is(x, y) {
641
- if (x === y) {
642
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
643
- } else {
644
- return x !== x && y !== y;
645
- }
646
- }
647
- function shallowEqual(objA, objB) {
648
- if (is(objA, objB)) {
649
- return true;
650
- }
651
- if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
652
- return false;
653
- }
654
- var keysA = Object.keys(objA);
655
- var keysB = Object.keys(objB);
656
- if (keysA.length !== keysB.length) {
657
- return false;
658
- }
659
- for (var i = 0; i < keysA.length; i++) {
660
- if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
661
- return false;
662
- }
663
- }
664
- return true;
665
- }
666
- var shallowEqual_1 = shallowEqual;
667
- var shallowEqual$1 = createCommonjsModule(function (module, exports) {
668
- exports.__esModule = true;
669
- exports.default = void 0;
670
- var _shallowEqual = interopRequireDefault(shallowEqual_1);
671
- var _default = _shallowEqual.default;
672
- exports.default = _default;
673
- });
674
- unwrapExports(shallowEqual$1);
675
- var pure_1 = createCommonjsModule(function (module, exports) {
676
- exports.__esModule = true;
677
- exports.default = void 0;
678
- var _shouldUpdate = interopRequireDefault(shouldUpdate_1);
679
- var _shallowEqual = interopRequireDefault(shallowEqual$1);
680
- var _setDisplayName = interopRequireDefault(setDisplayName_1);
681
- var _wrapDisplayName = interopRequireDefault(wrapDisplayName_1);
682
- var pure = function pure(BaseComponent) {
683
- var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
684
- return !(0, _shallowEqual.default)(props, nextProps);
685
- });
686
- {
687
- return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
688
- }
689
- };
690
- var _default = pure;
691
- exports.default = _default;
692
- });
693
- unwrapExports(pure_1);
694
- const require$$0 = _dll_react;
695
- const {SvgIcon: require$$2} = _dll_material_ui__core;
696
- var createSvgIcon_1 = createCommonjsModule(function (module, exports) {
697
- Object.defineProperty(exports, "__esModule", {
698
- value: true
699
- });
700
- exports.default = void 0;
701
- var _react = interopRequireDefault(require$$0);
702
- var _pure = interopRequireDefault(pure_1);
703
- var _SvgIcon = interopRequireDefault(require$$2);
704
- function createSvgIcon(path, displayName) {
705
- var Icon = function Icon(props) {
706
- return _react.default.createElement(_SvgIcon.default, props, path);
707
- };
708
- Icon.displayName = ("").concat(displayName, "Icon");
709
- Icon = (0, _pure.default)(Icon);
710
- Icon.muiName = 'SvgIcon';
711
- return Icon;
712
- }
713
- var _default = createSvgIcon;
714
- exports.default = _default;
715
- });
716
- unwrapExports(createSvgIcon_1);
717
- const require$$0$1 = _dll_react;
718
- var Add = createCommonjsModule(function (module, exports) {
719
- Object.defineProperty(exports, "__esModule", {
720
- value: true
721
- });
722
- exports.default = void 0;
723
- var _react = interopRequireDefault(require$$0$1);
724
- var _createSvgIcon = interopRequireDefault(createSvgIcon_1);
725
- var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
726
- d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"
727
- }), _react.default.createElement("path", {
728
- fill: "none",
729
- d: "M0 0h24v24H0z"
730
- })), 'Add');
731
- exports.default = _default;
732
- });
733
- var AddButton = unwrapExports(Add);
734
- const React$1 = _dll_react;
735
- const PropTypes$1 = _dll_prop_types;
736
- const {Button: Button} = _dll_material_ui__core;
737
- const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
738
- const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/packages/match/configure/src/add-row.jsx";
739
- class AddRowButton extends React$1.Component {
740
- static __initStatic() {
741
- this.propTypes = {
742
- classes: PropTypes$1.object.isRequired,
743
- onAddClick: PropTypes$1.func.isRequired
744
- };
745
- }
746
- render() {
747
- const {classes, onAddClick} = this.props;
748
- return React$1.createElement(Button, {
749
- className: classes.button,
750
- disabled: false,
751
- onClick: onAddClick,
752
- __self: this,
753
- __source: {
754
- fileName: _jsxFileName$1,
755
- lineNumber: 17
756
- }
757
- }, React$1.createElement(AddButton, {
758
- __self: this,
759
- __source: {
760
- fileName: _jsxFileName$1,
761
- lineNumber: 18
762
- }
763
- }), "Add Another Row");
764
- }
765
- }
766
- AddRowButton.__initStatic();
767
- const styles$1 = theme => ({
768
- button: {
769
- display: 'flex',
770
- alignSelf: 'flex-start',
771
- margin: 0,
772
- marginBottom: theme.spacing.unit * 2
773
- }
774
- });
775
- var AddRow = withStyles$1(styles$1)(AddRowButton);
776
- const require$$0$2 = _dll_react;
777
- var DragHandle = createCommonjsModule(function (module, exports) {
778
- Object.defineProperty(exports, "__esModule", {
779
- value: true
780
- });
781
- exports.default = void 0;
782
- var _react = interopRequireDefault(require$$0$2);
783
- var _createSvgIcon = interopRequireDefault(createSvgIcon_1);
784
- var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("defs", null, _react.default.createElement("path", {
785
- id: "a",
786
- d: "M0 0h24v24H0V0z"
787
- })), _react.default.createElement("path", {
788
- d: "M20 9H4v2h16V9zM4 15h16v-2H4v2z"
789
- })), 'DragHandle');
790
- exports.default = _default;
791
- });
792
- var DragHandle$1 = unwrapExports(DragHandle);
793
- const require$$0$3 = _dll_react;
794
- var Delete = createCommonjsModule(function (module, exports) {
795
- Object.defineProperty(exports, "__esModule", {
796
- value: true
797
- });
798
- exports.default = void 0;
799
- var _react = interopRequireDefault(require$$0$3);
800
- var _createSvgIcon = interopRequireDefault(createSvgIcon_1);
801
- var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
802
- d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
803
- }), _react.default.createElement("path", {
804
- fill: "none",
805
- d: "M0 0h24v24H0z"
806
- })), 'Delete');
807
- exports.default = _default;
808
- });
809
- var Delete$1 = unwrapExports(Delete);
810
- const React$2 = _dll_react;
811
- const PropTypes$2 = _dll_prop_types;
812
- const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
813
- const {Radio: Radio} = _dll_material_ui__core;
814
- const {Button: Button$1} = _dll_material_ui__core;
815
- const {DragSource: DragSource} = _dll_react_dnd;
816
- const {DropTarget: DropTarget} = _dll_react_dnd;
817
- const {Checkbox: Checkbox} = _dll_pie_lib__config_ui;
818
- const EditableHtml = _dll_pie_lib__editable_html;
819
- const _jsxFileName$2 = "/home/ede/dev/github/pie-framework/pie-elements/packages/match/configure/src/row.jsx";
820
- const log = browser('@pie-element:categorize:configure:choice');
821
- let canDrag = false;
822
- class Row extends React$2.Component {
823
- constructor(...args) {
824
- super(...args);
825
- Row.prototype.__init.call(this);
826
- Row.prototype.__init2.call(this);
827
- Row.prototype.__init3.call(this);
828
- Row.prototype.__init4.call(this);
829
- Row.prototype.__init5.call(this);
830
- }
831
- static __initStatic() {
832
- this.propTypes = {
833
- classes: PropTypes$2.object.isRequired,
834
- model: PropTypes$2.object.isRequired,
835
- row: PropTypes$2.object.isRequired,
836
- idx: PropTypes$2.number.isRequired,
837
- isDragging: PropTypes$2.bool.isRequired,
838
- onDeleteRow: PropTypes$2.func.isRequired,
839
- onChange: PropTypes$2.func.isRequired,
840
- connectDragSource: PropTypes$2.func.isRequired,
841
- connectDropTarget: PropTypes$2.func.isRequired,
842
- onMoveRow: PropTypes$2.func.isRequired,
843
- imageSupport: PropTypes$2.shape({
844
- add: PropTypes$2.func.isRequired,
845
- delete: PropTypes$2.func.isRequired
846
- }),
847
- enableImages: PropTypes$2.bool
848
- };
849
- }
850
- static __initStatic2() {
851
- this.defaultProps = {};
852
- }
853
- componentDidMount() {
854
- document.addEventListener('mouseup', this.onMouseUpOnHandle);
855
- }
856
- __init() {
857
- this.onRowTitleChange = rowIndex => value => {
858
- const {model, onChange} = this.props;
859
- const newModel = {
860
- ...model
861
- };
862
- newModel.rows[rowIndex].title = value;
863
- onChange(newModel);
864
- };
865
- }
866
- __init2() {
867
- this.onRowValueChange = (rowIndex, rowValueIndex) => event => {
868
- const {model, onChange} = this.props;
869
- const newModel = {
870
- ...model
871
- };
872
- if (model.choiceMode === 'radio') {
873
- for (let i = 0; i < newModel.rows[rowIndex].values.length; i++) {
874
- newModel.rows[rowIndex].values[i] = false;
875
- }
876
- }
877
- newModel.rows[rowIndex].values[rowValueIndex] = event.target.checked;
878
- onChange(newModel);
879
- };
880
- }
881
- __init3() {
882
- this.onDeleteRow = idx => () => {
883
- this.props.onDeleteRow(idx);
884
- };
885
- }
886
- __init4() {
887
- this.onMouseDownOnHandle = () => {
888
- canDrag = true;
889
- };
890
- }
891
- __init5() {
892
- this.onMouseUpOnHandle = () => {
893
- canDrag = false;
894
- };
895
- }
896
- render() {
897
- const {classes, imageSupport, connectDragSource, connectDropTarget, isDragging, model, row, idx, enableImages} = this.props;
898
- const opacity = isDragging ? 0 : 1;
899
- const content = React$2.createElement('div', {
900
- style: {
901
- opacity: opacity
902
- },
903
- __self: this,
904
- __source: {
905
- fileName: _jsxFileName$2,
906
- lineNumber: 94
907
- }
908
- }, React$2.createElement('span', {
909
- itemID: 'handle',
910
- className: classes.dragHandle,
911
- onMouseDown: this.onMouseDownOnHandle,
912
- __self: this,
913
- __source: {
914
- fileName: _jsxFileName$2,
915
- lineNumber: 97
916
- }
917
- }, React$2.createElement(DragHandle$1, {
918
- color: 'primary',
919
- __self: this,
920
- __source: {
921
- fileName: _jsxFileName$2,
922
- lineNumber: 102
923
- }
924
- })), React$2.createElement('div', {
925
- className: classes.rowContainer,
926
- __self: this,
927
- __source: {
928
- fileName: _jsxFileName$2,
929
- lineNumber: 104
930
- }
931
- }, React$2.createElement('div', {
932
- className: classnames(classes.rowItem, classes.questionText),
933
- __self: this,
934
- __source: {
935
- fileName: _jsxFileName$2,
936
- lineNumber: 105
937
- }
938
- }, React$2.createElement(EditableHtml, {
939
- imageSupport: imageSupport,
940
- autoWidthToolbar: true,
941
- disableUnderline: true,
942
- label: 'label',
943
- markup: row.title,
944
- onChange: this.onRowTitleChange(idx),
945
- className: classes.editor,
946
- pluginProps: {
947
- image: {
948
- disabled: !enableImages
949
- }
950
- },
951
- __self: this,
952
- __source: {
953
- fileName: _jsxFileName$2,
954
- lineNumber: 106
955
- }
956
- })), row.values.map((rowValue, rowIdx) => React$2.createElement('div', {
957
- key: rowIdx,
958
- className: classes.rowItem,
959
- __self: this,
960
- __source: {
961
- fileName: _jsxFileName$2,
962
- lineNumber: 122
963
- }
964
- }, model.choiceMode === 'radio' ? React$2.createElement(Radio, {
965
- onChange: this.onRowValueChange(idx, rowIdx),
966
- checked: rowValue === true,
967
- __self: this,
968
- __source: {
969
- fileName: _jsxFileName$2,
970
- lineNumber: 124
971
- }
972
- }) : React$2.createElement(Checkbox, {
973
- onChange: this.onRowValueChange(idx, rowIdx),
974
- checked: rowValue === true,
975
- label: '',
976
- __self: this,
977
- __source: {
978
- fileName: _jsxFileName$2,
979
- lineNumber: 129
980
- }
981
- }))), React$2.createElement('div', {
982
- className: classes.deleteIcon,
983
- __self: this,
984
- __source: {
985
- fileName: _jsxFileName$2,
986
- lineNumber: 137
987
- }
988
- }, React$2.createElement(Button$1, {
989
- onClick: this.onDeleteRow(idx),
990
- __self: this,
991
- __source: {
992
- fileName: _jsxFileName$2,
993
- lineNumber: 138
994
- }
995
- }, React$2.createElement(Delete$1, {
996
- className: classes.deleteIcon,
997
- __self: this,
998
- __source: {
999
- fileName: _jsxFileName$2,
1000
- lineNumber: 139
1001
- }
1002
- })))), React$2.createElement('hr', {
1003
- className: classes.separator,
1004
- __self: this,
1005
- __source: {
1006
- fileName: _jsxFileName$2,
1007
- lineNumber: 143
1008
- }
1009
- }));
1010
- return connectDragSource(connectDropTarget(content));
1011
- }
1012
- }
1013
- Row.__initStatic();
1014
- Row.__initStatic2();
1015
- const styles$2 = theme => ({
1016
- actions: {
1017
- padding: 0,
1018
- justifyContent: 'space-between'
1019
- },
1020
- choice: {
1021
- padding: theme.spacing.unit,
1022
- overflow: 'visible'
1023
- },
1024
- dragHandle: {
1025
- cursor: 'move'
1026
- },
1027
- dragDisabled: {
1028
- cursor: 'inherit'
1029
- },
1030
- container: {
1031
- marginTop: theme.spacing.unit * 2,
1032
- display: 'flex',
1033
- flexDirection: 'column'
1034
- },
1035
- rowContainer: {
1036
- marginTop: theme.spacing.unit * 2,
1037
- display: 'flex',
1038
- alignItems: 'center',
1039
- flex: 1
1040
- },
1041
- rowItem: {
1042
- flex: 1,
1043
- display: 'flex',
1044
- justifyContent: 'center',
1045
- '&> div': {
1046
- width: '100%'
1047
- }
1048
- },
1049
- deleteIcon: {
1050
- flex: 0.5,
1051
- minWidth: '88px'
1052
- },
1053
- questionText: {
1054
- flex: 2,
1055
- display: 'flex',
1056
- justifyContent: 'flex-start'
1057
- },
1058
- separator: {
1059
- marginTop: theme.spacing.unit * 2,
1060
- border: 0,
1061
- borderTop: '2px solid lightgray',
1062
- width: '100%'
1063
- }
1064
- });
1065
- const StyledRow = withStyles$2(styles$2)(Row);
1066
- const NAME = 'row-config';
1067
- const choiceSource = {
1068
- canDrag() {
1069
- return canDrag;
1070
- },
1071
- beginDrag(props) {
1072
- return {
1073
- id: props.row.id,
1074
- index: props.idx
1075
- };
1076
- }
1077
- };
1078
- const StyledSource = DragSource(NAME, choiceSource, (connect, monitor) => ({
1079
- connectDragSource: connect.dragSource(),
1080
- isDragging: monitor.isDragging()
1081
- }))(StyledRow);
1082
- const choiceTarget = {
1083
- hover() {
1084
- log('[hover]');
1085
- },
1086
- drop(props, monitor) {
1087
- const item = monitor.getItem();
1088
- log('[drop] item: ', item, 'didDrop?', monitor.didDrop());
1089
- props.onMoveRow(item.index, props.idx);
1090
- }
1091
- };
1092
- const StyledSourceAndTarget = DropTarget(NAME, choiceTarget, connect => ({
1093
- connectDropTarget: connect.dropTarget()
1094
- }))(StyledSource);
1095
- const React$3 = _dll_react;
1096
- const PropTypes$3 = _dll_prop_types;
1097
- const {Button: Button$2} = _dll_material_ui__core;
1098
- const {Input: Input} = _dll_material_ui__core;
1099
- const {Typography: Typography} = _dll_material_ui__core;
1100
- const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
1101
- const {swap: swap} = _dll_pie_lib__drag;
1102
- const {withDragContext: withDragContext} = _dll_pie_lib__drag;
1103
- const lodash = _dll_lodash;
1104
- const _jsxFileName$3 = "/home/ede/dev/github/pie-framework/pie-elements/packages/match/configure/src/answer-config-block.jsx";
1105
- const log$1 = browser('pie-elements:match:configure');
1106
- const styles$3 = theme => ({
1107
- container: {
1108
- marginTop: theme.spacing.unit * 2,
1109
- display: 'flex',
1110
- flexDirection: 'column'
1111
- },
1112
- rowContainer: {
1113
- marginTop: theme.spacing.unit * 2,
1114
- display: 'flex',
1115
- alignItems: 'center',
1116
- flex: 1
1117
- },
1118
- rowItem: {
1119
- flex: 1,
1120
- display: 'flex',
1121
- justifyContent: 'center'
1122
- },
1123
- deleteIcon: {
1124
- flex: 0.5,
1125
- minWidth: '88px'
1126
- },
1127
- questionText: {
1128
- flex: 2,
1129
- display: 'flex',
1130
- justifyContent: 'flex-start'
1131
- },
1132
- rowTable: {
1133
- display: 'flex',
1134
- flexDirection: 'column'
1135
- },
1136
- separator: {
1137
- marginTop: theme.spacing.unit * 2,
1138
- border: 0,
1139
- borderTop: '2px solid lightgray',
1140
- width: '100%'
1141
- },
1142
- headerInput: {
1143
- textAlign: 'center',
1144
- maxWidth: '100px'
1145
- }
1146
- });
1147
- class AnswerConfigBlock extends React$3.Component {
1148
- constructor(...args) {
1149
- super(...args);
1150
- AnswerConfigBlock.prototype.__init.call(this);
1151
- AnswerConfigBlock.prototype.__init2.call(this);
1152
- AnswerConfigBlock.prototype.__init3.call(this);
1153
- }
1154
- static __initStatic() {
1155
- this.propTypes = {
1156
- classes: PropTypes$3.object.isRequired,
1157
- model: PropTypes$3.object.isRequired,
1158
- configuration: PropTypes$3.object.isRequired,
1159
- onChange: PropTypes$3.func.isRequired,
1160
- onDeleteRow: PropTypes$3.func.isRequired,
1161
- onAddRow: PropTypes$3.func.isRequired,
1162
- imageSupport: PropTypes$3.shape({
1163
- add: PropTypes$3.func.isRequired,
1164
- delete: PropTypes$3.func.isRequired
1165
- })
1166
- };
1167
- }
1168
- __init() {
1169
- this.moveRow = (from, to) => {
1170
- const {model, onChange} = this.props;
1171
- const newModel = {
1172
- ...model
1173
- };
1174
- const rows = newModel.rows;
1175
- log$1('[moveRow]: ', from, to);
1176
- const update = swap(rows, from, to);
1177
- log$1('update: ', update);
1178
- newModel.rows = update;
1179
- onChange(newModel);
1180
- };
1181
- }
1182
- __init2() {
1183
- this.onChange = (name, isBoolean) => ({target}) => {
1184
- const {model, onChange} = this.props;
1185
- let value;
1186
- if (isBoolean) {
1187
- value = target.checked;
1188
- } else {
1189
- value = target.value;
1190
- }
1191
- lodash.set(model, name, value);
1192
- onChange(model, name);
1193
- };
1194
- }
1195
- __init3() {
1196
- this.onHeaderChange = headerIndex => event => {
1197
- const {model, onChange} = this.props;
1198
- const newModel = {
1199
- ...model
1200
- };
1201
- newModel.headers[headerIndex] = event.target.value;
1202
- onChange(newModel);
1203
- };
1204
- }
1205
- render() {
1206
- const {classes, model, onAddRow, imageSupport, configuration} = this.props;
1207
- const {headers = {}} = configuration || ({});
1208
- return React$3.createElement('div', {
1209
- className: classes.container,
1210
- __self: this,
1211
- __source: {
1212
- fileName: _jsxFileName$3,
1213
- lineNumber: 122
1214
- }
1215
- }, React$3.createElement(Typography, {
1216
- type: "body1",
1217
- component: "div",
1218
- __self: this,
1219
- __source: {
1220
- fileName: _jsxFileName$3,
1221
- lineNumber: 123
1222
- }
1223
- }, "Click on the labels to edit or remove. Set the correct answers by clicking each correct answer per row."), React$3.createElement('div', {
1224
- className: classes.rowTable,
1225
- __self: this,
1226
- __source: {
1227
- fileName: _jsxFileName$3,
1228
- lineNumber: 127
1229
- }
1230
- }, React$3.createElement('div', {
1231
- className: classes.rowContainer,
1232
- __self: this,
1233
- __source: {
1234
- fileName: _jsxFileName$3,
1235
- lineNumber: 128
1236
- }
1237
- }, headers.settings && model.headers.map((header, idx) => React$3.createElement('div', {
1238
- key: idx,
1239
- className: classnames(classes.rowItem, {
1240
- [classes.questionText]: idx === 0
1241
- }),
1242
- __self: this,
1243
- __source: {
1244
- fileName: _jsxFileName$3,
1245
- lineNumber: 131
1246
- }
1247
- }, React$3.createElement(Input, {
1248
- type: "text",
1249
- disableUnderline: true,
1250
- classes: idx === 0 ? null : {
1251
- input: classes.headerInput
1252
- },
1253
- onChange: this.onHeaderChange(idx),
1254
- value: header,
1255
- placeholder: "Enter Value",
1256
- __self: this,
1257
- __source: {
1258
- fileName: _jsxFileName$3,
1259
- lineNumber: 137
1260
- }
1261
- }))), React$3.createElement('div', {
1262
- className: classes.deleteIcon,
1263
- __self: this,
1264
- __source: {
1265
- fileName: _jsxFileName$3,
1266
- lineNumber: 147
1267
- }
1268
- }, React$3.createElement(Button$2, {
1269
- disabled: true,
1270
- __self: this,
1271
- __source: {
1272
- fileName: _jsxFileName$3,
1273
- lineNumber: 148
1274
- }
1275
- }, React$3.createElement('div', {
1276
- __self: this,
1277
- __source: {
1278
- fileName: _jsxFileName$3,
1279
- lineNumber: 149
1280
- }
1281
- })))), React$3.createElement('hr', {
1282
- className: classes.separator,
1283
- __self: this,
1284
- __source: {
1285
- fileName: _jsxFileName$3,
1286
- lineNumber: 153
1287
- }
1288
- }), model.rows.map((row, idx) => React$3.createElement(StyledSourceAndTarget, {
1289
- key: idx,
1290
- model: model,
1291
- row: row,
1292
- idx: idx,
1293
- onDeleteRow: this.props.onDeleteRow,
1294
- onChange: this.props.onChange,
1295
- onMoveRow: this.moveRow,
1296
- imageSupport: imageSupport,
1297
- enableImages: model.enableImages,
1298
- __self: this,
1299
- __source: {
1300
- fileName: _jsxFileName$3,
1301
- lineNumber: 155
1302
- }
1303
- })), React$3.createElement(AddRow, {
1304
- onAddClick: onAddRow,
1305
- __self: this,
1306
- __source: {
1307
- fileName: _jsxFileName$3,
1308
- lineNumber: 167
1309
- }
1310
- })));
1311
- }
1312
- }
1313
- AnswerConfigBlock.__initStatic();
1314
- var AnswerConfigBlock$1 = withDragContext(withStyles$3(styles$3)(AnswerConfigBlock));
1315
- const React$4 = _dll_react;
1316
- const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
1317
- const PropTypes$4 = _dll_prop_types;
1318
- const {FeedbackConfig: FeedbackConfig} = _dll_pie_lib__config_ui;
1319
- const {settings: settings} = _dll_pie_lib__config_ui;
1320
- const {layout: layout} = _dll_pie_lib__config_ui;
1321
- const {InputContainer: InputContainer$1} = _dll_pie_lib__config_ui;
1322
- const EditableHtml$1 = _dll_pie_lib__editable_html;
1323
- const _jsxFileName$4 = "/home/ede/dev/github/pie-framework/pie-elements/packages/match/configure/src/configure.jsx";
1324
- const log$2 = browser('@pie-element:match:configure');
1325
- const {Panel, toggle, radio} = settings;
1326
- const styles$4 = theme => ({
1327
- title: {
1328
- fontSize: '1.1rem',
1329
- display: 'block',
1330
- marginTop: theme.spacing.unit * 2,
1331
- marginBottom: theme.spacing.unit
1332
- },
1333
- content: {
1334
- marginTop: theme.spacing.unit * 2
1335
- },
1336
- promptHolder: {
1337
- width: '100%',
1338
- paddingTop: theme.spacing.unit * 2
1339
- },
1340
- prompt: {
1341
- paddingTop: theme.spacing.unit * 2,
1342
- width: '100%'
1343
- }
1344
- });
1345
- class Configure extends React$4.Component {
1346
- static __initStatic() {
1347
- this.propTypes = {
1348
- onModelChanged: PropTypes$4.func,
1349
- onConfigurationChanged: PropTypes$4.func,
1350
- classes: PropTypes$4.object,
1351
- model: PropTypes$4.object.isRequired,
1352
- configuration: PropTypes$4.object.isRequired,
1353
- imageSupport: PropTypes$4.shape({
1354
- add: PropTypes$4.func.isRequired,
1355
- delete: PropTypes$4.func.isRequired
1356
- })
1357
- };
1358
- }
1359
- static __initStatic2() {
1360
- this.defaultProps = {
1361
- classes: {}
1362
- };
1363
- }
1364
- constructor(props) {
1365
- super(props);
1366
- Configure.prototype.__init.call(this);
1367
- Configure.prototype.__init2.call(this);
1368
- Configure.prototype.__init3.call(this);
1369
- Configure.prototype.__init4.call(this);
1370
- Configure.prototype.__init5.call(this);
1371
- Configure.prototype.__init6.call(this);
1372
- Configure.prototype.__init7.call(this);
1373
- Configure.prototype.__init8.call(this);
1374
- Configure.prototype.__init9.call(this);
1375
- Configure.prototype.__init10.call(this);
1376
- Configure.prototype.__init11.call(this);
1377
- Configure.prototype.__init12.call(this);
1378
- this.rowIdCounter = props.model.rows[props.model.rows.length - 1].id + 1;
1379
- this.state = {
1380
- activeTab: 0
1381
- };
1382
- }
1383
- __init() {
1384
- this.onTabChange = (event, value) => {
1385
- this.setState({
1386
- activeTab: value
1387
- });
1388
- };
1389
- }
1390
- __init2() {
1391
- this.onChangeTabIndex = index => {
1392
- this.setState({
1393
- activeTab: index
1394
- });
1395
- };
1396
- }
1397
- __init3() {
1398
- this.onChange = model => {
1399
- this.props.onModelChanged(model);
1400
- };
1401
- }
1402
- __init4() {
1403
- this.onFeedbackChange = feedback => {
1404
- const {model, onModelChanged} = this.props;
1405
- model.feedback = feedback;
1406
- onModelChanged(model);
1407
- };
1408
- }
1409
- __init5() {
1410
- this.onDeleteRow = rowIndex => {
1411
- const {model} = this.props;
1412
- const newModel = {
1413
- ...model
1414
- };
1415
- newModel.rows.splice(rowIndex, 1);
1416
- this.onChange(newModel);
1417
- };
1418
- }
1419
- __init6() {
1420
- this.onAddRow = () => {
1421
- const {model} = this.props;
1422
- const newModel = {
1423
- ...model
1424
- };
1425
- newModel.rows = newModel.rows.concat({
1426
- id: this.rowIdCounter + 1,
1427
- title: `Question Text ${newModel.rows.length + 1}`,
1428
- values: new Array(model.layout - 1).fill(false)
1429
- });
1430
- this.rowIdCounter += 1;
1431
- this.onChange(newModel);
1432
- };
1433
- }
1434
- __init7() {
1435
- this.onLayoutChange = newLayout => {
1436
- const {model} = this.props;
1437
- const oldLayout = model.layout;
1438
- const newModel = {
1439
- ...model
1440
- };
1441
- if (newLayout > oldLayout) {
1442
- for (let i = 0; i < newLayout - oldLayout; i++) {
1443
- newModel.headers.push(`Column ${newModel.headers.length + 1}`);
1444
- }
1445
- newModel.rows.forEach(row => {
1446
- for (let i = 0; i < newLayout - oldLayout; i++) {
1447
- row.values.push(false);
1448
- }
1449
- });
1450
- } else if (newLayout < oldLayout) {
1451
- newModel.headers.splice(newLayout);
1452
- newModel.rows.forEach(row => {
1453
- row.values.splice(newLayout - 1);
1454
- });
1455
- }
1456
- newModel.layout = newLayout;
1457
- this.onChange(newModel);
1458
- };
1459
- }
1460
- __init8() {
1461
- this.onResponseTypeChange = newChoiceMode => {
1462
- const {model} = this.props;
1463
- const newModel = {
1464
- ...model
1465
- };
1466
- if (newChoiceMode === 'radio') {
1467
- newModel.rows.forEach(row => {
1468
- const trueCount = row.values.reduce((total, current) => current === true ? total + 1 : total);
1469
- if (trueCount > 1) {
1470
- row.values = new Array(model.layout - 1).fill(false);
1471
- }
1472
- });
1473
- }
1474
- newModel.choiceMode = newChoiceMode;
1475
- this.onChange(newModel);
1476
- };
1477
- }
1478
- __init9() {
1479
- this.onPartialScoringChange = partialScoring => {
1480
- this.props.model.partialScoring = partialScoring;
1481
- this.props.onModelChanged(this.props.model);
1482
- };
1483
- }
1484
- __init10() {
1485
- this.onPromptChanged = prompt => {
1486
- this.props.onModelChanged({
1487
- ...this.props.model,
1488
- prompt
1489
- });
1490
- };
1491
- }
1492
- __init11() {
1493
- this.onTeacherInstructionsChanged = teacherInstructions => {
1494
- this.props.onModelChanged({
1495
- ...this.props.model,
1496
- teacherInstructions
1497
- });
1498
- };
1499
- }
1500
- __init12() {
1501
- this.onRationaleChanged = rationale => {
1502
- this.props.onModelChanged({
1503
- ...this.props.model,
1504
- rationale
1505
- });
1506
- };
1507
- }
1508
- render() {
1509
- const {classes, model, imageSupport, onModelChanged, configuration, onConfigurationChanged} = this.props;
1510
- const {enableImages = {}, partialScoring = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, lockChoiceOrder = {}, scoringType = {}, prompt = {}, feedback = {}} = configuration || ({});
1511
- const {teacherInstructionsEnabled, promptEnabled, rationaleEnabled, feedbackEnabled} = model || ({});
1512
- log$2('[render] model', model);
1513
- return React$4.createElement(layout.ConfigLayout, {
1514
- settings: React$4.createElement(Panel, {
1515
- model: model,
1516
- configuration: configuration,
1517
- onChangeModel: model => onModelChanged(model),
1518
- onChangeConfiguration: config => onConfigurationChanged(config),
1519
- groups: {
1520
- Settings: {
1521
- enableImages: enableImages.settings && toggle(enableImages.label),
1522
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
1523
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
1524
- feedbackEnabled: feedback.settings && toggle(feedback.label)
1525
- },
1526
- Properties: {
1527
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
1528
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
1529
- promptEnabled: prompt.settings && toggle(prompt.label),
1530
- rationaleEnabled: rationale.settings && toggle(rationale.label),
1531
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
1532
- }
1533
- },
1534
- __self: this,
1535
- __source: {
1536
- fileName: _jsxFileName$4,
1537
- lineNumber: 212
1538
- }
1539
- }),
1540
- __self: this,
1541
- __source: {
1542
- fileName: _jsxFileName$4,
1543
- lineNumber: 210
1544
- }
1545
- }, React$4.createElement('div', {
1546
- className: classes.content,
1547
- __self: this,
1548
- __source: {
1549
- fileName: _jsxFileName$4,
1550
- lineNumber: 245
1551
- }
1552
- }, teacherInstructionsEnabled && React$4.createElement(InputContainer$1, {
1553
- label: teacherInstructions.label,
1554
- className: classes.promptHolder,
1555
- __self: this,
1556
- __source: {
1557
- fileName: _jsxFileName$4,
1558
- lineNumber: 247
1559
- }
1560
- }, React$4.createElement(EditableHtml$1, {
1561
- className: classes.prompt,
1562
- markup: model.teacherInstructions || '',
1563
- onChange: this.onTeacherInstructionsChanged,
1564
- imageSupport: imageSupport,
1565
- nonEmpty: false,
1566
- __self: this,
1567
- __source: {
1568
- fileName: _jsxFileName$4,
1569
- lineNumber: 251
1570
- }
1571
- })), promptEnabled && React$4.createElement(InputContainer$1, {
1572
- label: prompt.label,
1573
- className: classes.promptHolder,
1574
- __self: this,
1575
- __source: {
1576
- fileName: _jsxFileName$4,
1577
- lineNumber: 262
1578
- }
1579
- }, React$4.createElement(EditableHtml$1, {
1580
- className: classes.prompt,
1581
- markup: model.prompt,
1582
- onChange: this.onPromptChanged,
1583
- imageSupport: imageSupport,
1584
- nonEmpty: false,
1585
- disableUnderline: true,
1586
- __self: this,
1587
- __source: {
1588
- fileName: _jsxFileName$4,
1589
- lineNumber: 266
1590
- }
1591
- })), rationaleEnabled && React$4.createElement(InputContainer$1, {
1592
- label: rationale.label,
1593
- className: classes.promptHolder,
1594
- __self: this,
1595
- __source: {
1596
- fileName: _jsxFileName$4,
1597
- lineNumber: 278
1598
- }
1599
- }, React$4.createElement(EditableHtml$1, {
1600
- className: classes.prompt,
1601
- markup: model.rationale || '',
1602
- onChange: this.onRationaleChanged,
1603
- imageSupport: imageSupport,
1604
- __self: this,
1605
- __source: {
1606
- fileName: _jsxFileName$4,
1607
- lineNumber: 282
1608
- }
1609
- })), React$4.createElement(GeneralConfigBlock$1, {
1610
- model: model,
1611
- configuration: configuration,
1612
- onResponseTypeChange: this.onResponseTypeChange,
1613
- onLayoutChange: this.onLayoutChange,
1614
- __self: this,
1615
- __source: {
1616
- fileName: _jsxFileName$4,
1617
- lineNumber: 290
1618
- }
1619
- }), React$4.createElement(AnswerConfigBlock$1, {
1620
- model: model,
1621
- configuration: configuration,
1622
- imageSupport: imageSupport,
1623
- onChange: this.onChange,
1624
- onAddRow: this.onAddRow,
1625
- onDeleteRow: this.onDeleteRow,
1626
- __self: this,
1627
- __source: {
1628
- fileName: _jsxFileName$4,
1629
- lineNumber: 296
1630
- }
1631
- }), feedbackEnabled && React$4.createElement(FeedbackConfig, {
1632
- feedback: model.feedback,
1633
- onChange: this.onFeedbackChange,
1634
- __self: this,
1635
- __source: {
1636
- fileName: _jsxFileName$4,
1637
- lineNumber: 305
1638
- }
1639
- })));
1640
- }
1641
- }
1642
- Configure.__initStatic();
1643
- Configure.__initStatic2();
1644
- var Configure$1 = withStyles$4(styles$4)(Configure);
1645
- var defaultValues = {
1646
- model: {
1647
- enableImages: true,
1648
- headers: ['Column 1', 'Column 2', 'Column 3'],
1649
- layout: 3,
1650
- lockChoiceOrder: true,
1651
- partialScoring: false,
1652
- choiceMode: 'radio',
1653
- prompt: 'Prompt goes here',
1654
- rows: [{
1655
- id: 1,
1656
- title: 'Question Text 1',
1657
- values: [false, false]
1658
- }],
1659
- scoringType: 'auto',
1660
- feedbackEnabled: true,
1661
- promptEnabled: true,
1662
- rationaleEnabled: true,
1663
- teacherInstructionsEnabled: true,
1664
- studentInstructionsEnabled: true
1665
- },
1666
- configuration: {
1667
- enableImages: {
1668
- settings: true,
1669
- label: 'Enable Images'
1670
- },
1671
- feedback: {
1672
- settings: true,
1673
- label: 'Feedback',
1674
- enabled: true
1675
- },
1676
- headers: {
1677
- settings: true
1678
- },
1679
- layout: {
1680
- settings: true,
1681
- label: 'Layout'
1682
- },
1683
- lockChoiceOrder: {
1684
- settings: true,
1685
- label: 'Lock Choice Order'
1686
- },
1687
- partialScoring: {
1688
- settings: false,
1689
- label: 'Allow Partial Scoring'
1690
- },
1691
- choiceMode: {
1692
- settings: true,
1693
- label: 'Response Type'
1694
- },
1695
- prompt: {
1696
- settings: true,
1697
- label: 'Prompt'
1698
- },
1699
- rationale: {
1700
- settings: true,
1701
- label: 'Rationale'
1702
- },
1703
- scoringType: {
1704
- settings: false,
1705
- label: 'Scoring Type'
1706
- },
1707
- studentInstructions: {
1708
- settings: false,
1709
- label: 'Student Instructions'
1710
- },
1711
- teacherInstructions: {
1712
- settings: true,
1713
- label: 'Teacher Instructions'
1714
- }
1715
- }
1716
- };
1717
- const React$5 = _dll_react;
1718
- const ReactDOM = _dll_react_dom;
1719
- const {ModelUpdatedEvent: ModelUpdatedEvent} = _dll_pie_framework__pie_configure_events;
1720
- const {DeleteImageEvent: DeleteImageEvent} = _dll_pie_framework__pie_configure_events;
1721
- const {InsertImageEvent: InsertImageEvent} = _dll_pie_framework__pie_configure_events;
1722
- const log$3 = browser('pie-elements:match:configure');
1723
- class MatchConfigure extends HTMLElement {
1724
- static __initStatic() {
1725
- this.createDefaultModel = (model = {}) => ({
1726
- ...defaultValues.model,
1727
- ...model
1728
- });
1729
- }
1730
- constructor() {
1731
- super();
1732
- this._model = MatchConfigure.createDefaultModel();
1733
- this._configuration = defaultValues.configuration;
1734
- }
1735
- set model(m) {
1736
- this._model = MatchConfigure.createDefaultModel(m);
1737
- this._render();
1738
- }
1739
- set configuration(c) {
1740
- this._configuration = c;
1741
- this._render();
1742
- }
1743
- onModelChanged(model) {
1744
- this._model = model;
1745
- log$3('[onModelChanged]: ', this._model);
1746
- this._render();
1747
- this.dispatchEvent(new ModelUpdatedEvent(this._model, true));
1748
- }
1749
- onConfigurationChanged(config) {
1750
- this._configuration = config;
1751
- this._render();
1752
- }
1753
- insertImage(handler) {
1754
- this.dispatchEvent(new InsertImageEvent(handler));
1755
- }
1756
- onDeleteImage(src, done) {
1757
- this.dispatchEvent(new DeleteImageEvent(src, done));
1758
- }
1759
- _render() {
1760
- if (this._model) {
1761
- const el = React$5.createElement(Configure$1, {
1762
- onModelChanged: this.onModelChanged.bind(this),
1763
- onConfigurationChanged: this.onConfigurationChanged.bind(this),
1764
- model: this._model,
1765
- configuration: this._configuration,
1766
- imageSupport: {
1767
- add: this.insertImage.bind(this),
1768
- delete: this.onDeleteImage.bind(this)
1769
- }
1770
- });
1771
- ReactDOM.render(el, this);
1772
- }
1773
- }
1774
- }
1775
- MatchConfigure.__initStatic();
1776
- export default MatchConfigure;