@pie-element/complex-rubric 5.3.4-next.3 → 6.0.0-beta.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.
Files changed (145) hide show
  1. package/configure/lib/defaults.js +52 -24
  2. package/configure/lib/defaults.js.map +1 -1
  3. package/configure/lib/index.js +103 -194
  4. package/configure/lib/index.js.map +1 -1
  5. package/configure/lib/main.js +140 -199
  6. package/configure/lib/main.js.map +1 -1
  7. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.json +1 -0
  8. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.md +2491 -0
  9. package/configure/node_modules/@pie-element/multi-trait-rubric/README.md +55 -0
  10. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.json +1 -0
  11. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.md +2333 -0
  12. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js +429 -0
  13. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js.map +1 -0
  14. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js +181 -0
  15. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js.map +1 -0
  16. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js +157 -0
  17. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js.map +1 -0
  18. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js +455 -0
  19. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js.map +1 -0
  20. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js +206 -0
  21. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js.map +1 -0
  22. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js +451 -0
  23. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js.map +1 -0
  24. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js +275 -0
  25. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js.map +1 -0
  26. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js +233 -0
  27. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js.map +1 -0
  28. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js +87 -0
  29. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js.map +1 -0
  30. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/package.json +24 -0
  31. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.json +1 -0
  32. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.md +1571 -0
  33. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js +18 -0
  34. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js.map +1 -0
  35. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js +158 -0
  36. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js.map +1 -0
  37. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/utils.js +11 -0
  38. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/utils.js.map +1 -0
  39. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/package.json +14 -0
  40. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json +1628 -0
  41. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json.md +1202 -0
  42. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/config.js +8 -0
  43. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/generate.js +117 -0
  44. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/index.html +1 -0
  45. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/session.js +6 -0
  46. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json +861 -0
  47. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json.md +614 -0
  48. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js +54 -0
  49. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js.map +1 -0
  50. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js +123 -0
  51. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js.map +1 -0
  52. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js +248 -0
  53. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js.map +1 -0
  54. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js +83 -0
  55. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js.map +1 -0
  56. package/configure/node_modules/@pie-element/multi-trait-rubric/package.json +32 -0
  57. package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +257 -0
  58. package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +2774 -0
  59. package/configure/node_modules/@pie-element/rubric/README.md +3 -0
  60. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +197 -0
  61. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +2541 -0
  62. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js +67 -0
  63. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js.map +1 -0
  64. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +135 -0
  65. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +1 -0
  66. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js +103 -0
  67. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js.map +1 -0
  68. package/configure/node_modules/@pie-element/rubric/configure/package.json +24 -0
  69. package/configure/node_modules/@pie-element/rubric/configure/src/__tests__/index.test.jsx +178 -0
  70. package/configure/node_modules/@pie-element/rubric/configure/src/defaults.js +42 -0
  71. package/configure/node_modules/@pie-element/rubric/configure/src/index.js +139 -0
  72. package/configure/node_modules/@pie-element/rubric/configure/src/main.jsx +87 -0
  73. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +17 -0
  74. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +1564 -0
  75. package/configure/node_modules/@pie-element/rubric/controller/lib/defaults.js +15 -0
  76. package/configure/node_modules/@pie-element/rubric/controller/lib/defaults.js.map +1 -0
  77. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +46 -0
  78. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +1 -0
  79. package/configure/node_modules/@pie-element/rubric/controller/package.json +12 -0
  80. package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +33 -0
  81. package/configure/node_modules/@pie-element/rubric/controller/src/defaults.js +8 -0
  82. package/configure/node_modules/@pie-element/rubric/controller/src/index.js +41 -0
  83. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +712 -0
  84. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +532 -0
  85. package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +8 -0
  86. package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +8 -0
  87. package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +2 -0
  88. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +391 -0
  89. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +281 -0
  90. package/configure/node_modules/@pie-element/rubric/lib/index.js +52 -0
  91. package/configure/node_modules/@pie-element/rubric/lib/index.js.map +1 -0
  92. package/configure/node_modules/@pie-element/rubric/lib/main.js +210 -0
  93. package/configure/node_modules/@pie-element/rubric/lib/main.js.map +1 -0
  94. package/configure/node_modules/@pie-element/rubric/lib/print.js +71 -0
  95. package/configure/node_modules/@pie-element/rubric/lib/print.js.map +1 -0
  96. package/configure/node_modules/@pie-element/rubric/package.json +30 -0
  97. package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +2641 -0
  98. package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +49 -0
  99. package/configure/node_modules/@pie-element/rubric/src/index.js +48 -0
  100. package/configure/node_modules/@pie-element/rubric/src/main.jsx +226 -0
  101. package/configure/node_modules/@pie-element/rubric/src/print.js +74 -0
  102. package/configure/node_modules/clsx/clsx.d.ts +6 -0
  103. package/configure/node_modules/clsx/dist/clsx.js +1 -0
  104. package/configure/node_modules/clsx/dist/clsx.m.js +1 -0
  105. package/configure/node_modules/clsx/dist/clsx.min.js +1 -0
  106. package/configure/node_modules/clsx/license +9 -0
  107. package/configure/node_modules/clsx/package.json +37 -0
  108. package/configure/node_modules/clsx/readme.md +88 -0
  109. package/configure/package.json +12 -9
  110. package/configure/src/__tests__/index.test.js +30 -5
  111. package/configure/src/__tests__/main.test.jsx +39 -23
  112. package/configure/src/index.js +13 -6
  113. package/configure/src/main.jsx +16 -15
  114. package/controller/lib/defaults.js +11 -15
  115. package/controller/lib/defaults.js.map +1 -1
  116. package/controller/lib/index.js +117 -180
  117. package/controller/lib/index.js.map +1 -1
  118. package/controller/lib/utils.js +1 -3
  119. package/controller/lib/utils.js.map +1 -1
  120. package/controller/package.json +1 -1
  121. package/lib/index.js +113 -204
  122. package/lib/index.js.map +1 -1
  123. package/lib/print.js +96 -190
  124. package/lib/print.js.map +1 -1
  125. package/package.json +10 -14
  126. package/src/__tests__/index.test.js +25 -7
  127. package/configure/src/__tests__/__snapshots__/main.test.jsx.snap +0 -193
  128. package/esm/configure.js +0 -15856
  129. package/esm/configure.js.map +0 -1
  130. package/esm/controller.js +0 -281
  131. package/esm/controller.js.map +0 -1
  132. package/esm/element.js +0 -179
  133. package/esm/element.js.map +0 -1
  134. package/esm/package.json +0 -3
  135. package/esm/print.js +0 -163
  136. package/esm/print.js.map +0 -1
  137. package/module/configure.js +0 -1
  138. package/module/controller.js +0 -262
  139. package/module/demo.js +0 -221
  140. package/module/element.js +0 -1
  141. package/module/index.html +0 -21
  142. package/module/manifest.json +0 -22
  143. package/module/print-demo.js +0 -259
  144. package/module/print.html +0 -18
  145. package/module/print.js +0 -1
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _client = require("react-dom/client");
12
+ var _main = _interopRequireDefault(require("./main"));
13
+ var _defaults = _interopRequireDefault(require("./defaults"));
14
+ var _utils = require("./utils");
15
+ var _modals = require("./modals");
16
+ const modelWithDefaults = m => ({
17
+ ..._defaults.default.model,
18
+ ...m
19
+ });
20
+ const configurationWithDefaults = c => ({
21
+ ..._defaults.default.configuration,
22
+ ...c
23
+ });
24
+ class MultiTraitRubricElement extends HTMLElement {
25
+ constructor() {
26
+ super();
27
+ (0, _defineProperty2.default)(this, "updateModelAccordingToReceivedProps", m => {
28
+ const currentModel = {
29
+ ...this._model
30
+ };
31
+ if (!m) {
32
+ return currentModel;
33
+ }
34
+ const validatedModel = {
35
+ ...m
36
+ };
37
+ const {
38
+ scales,
39
+ excludeZero
40
+ } = validatedModel || {};
41
+ (scales || []).forEach(scale => {
42
+ if (!scale) {
43
+ scale = {
44
+ scorePointsLabels: [],
45
+ traits: []
46
+ };
47
+ }
48
+ const {
49
+ maxPoints
50
+ } = scale || {};
51
+ scale.scorePointsLabels = [...(scale.scorePointsLabels || [])];
52
+ scale.traits = [...(scale.traits || [])];
53
+ const howManyScorePointLabelsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
54
+ const howManyScorePointLabelsItHas = scale.scorePointsLabels.length;
55
+ if (howManyScorePointLabelsItHas !== howManyScorePointLabelsShouldHave) {
56
+ if (howManyScorePointLabelsItHas < howManyScorePointLabelsShouldHave) {
57
+ for (let i = 0; i < howManyScorePointLabelsShouldHave - howManyScorePointLabelsItHas; i++) {
58
+ scale.scorePointsLabels.push('');
59
+ }
60
+ } else {
61
+ scale.scorePointsLabels = scale.scorePointsLabels.slice(0, howManyScorePointLabelsShouldHave);
62
+ }
63
+ }
64
+ (scale.traits || []).forEach(trait => {
65
+ if (!trait) {
66
+ trait = {
67
+ scorePointsDescriptors: []
68
+ };
69
+ }
70
+ trait.scorePointsDescriptors = [...(trait.scorePointsDescriptors || [])];
71
+ const howManyScorePointDescriptorsItHas = trait.scorePointsDescriptors.length;
72
+ if (howManyScorePointDescriptorsItHas !== howManyScorePointLabelsShouldHave) {
73
+ if (howManyScorePointDescriptorsItHas < howManyScorePointLabelsShouldHave) {
74
+ for (let i = 0; i < howManyScorePointLabelsShouldHave - howManyScorePointDescriptorsItHas; i++) {
75
+ trait.scorePointsDescriptors.push('');
76
+ }
77
+ } else {
78
+ trait.scorePointsDescriptors = trait.scorePointsDescriptors.slice(0, howManyScorePointLabelsShouldHave);
79
+ }
80
+ }
81
+ });
82
+ });
83
+ if (validatedModel.excludeZero) {
84
+ // check if any scale has maxPoints set to 1
85
+ const shouldAddColumn0 = validatedModel.scales.some(scale => scale.maxPoints === 1);
86
+ if (shouldAddColumn0) {
87
+ // excludeZero should be false and disabled when maxPoints is 1
88
+ validatedModel.excludeZero = false;
89
+ // add column 0 for all scales
90
+ validatedModel.scales = (0, _utils.addOrRemoveScaleColumn)(scales, _modals.excludeZeroTypes.add0);
91
+ }
92
+ }
93
+ return validatedModel;
94
+ });
95
+ (0, _defineProperty2.default)(this, "onModelChanged", m => {
96
+ this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
97
+ this._render();
98
+ this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, false));
99
+ });
100
+ (0, _defineProperty2.default)(this, "onConfigurationChanged", c => {
101
+ this._configuration = configurationWithDefaults(c);
102
+ this._render();
103
+ });
104
+ this._root = null;
105
+ this._model = modelWithDefaults();
106
+ this._configuration = configurationWithDefaults();
107
+ }
108
+ set model(m) {
109
+ this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
110
+ this._render();
111
+ }
112
+ set configuration(c) {
113
+ this._configuration = configurationWithDefaults(c);
114
+ this._render();
115
+ }
116
+ insertSound(handler) {
117
+ this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
118
+ }
119
+ onDeleteSound(src, done) {
120
+ this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
121
+ }
122
+ insertImage(handler) {
123
+ this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
124
+ }
125
+ onDeleteImage(src, done) {
126
+ this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
127
+ }
128
+ _render() {
129
+ if (this._model) {
130
+ let element = /*#__PURE__*/_react.default.createElement(_main.default, {
131
+ model: this._model,
132
+ configuration: this._configuration,
133
+ onModelChanged: this.onModelChanged,
134
+ onConfigurationChanged: this.onConfigurationChanged,
135
+ uploadSoundSupport: {
136
+ add: this.insertSound.bind(this),
137
+ delete: this.onDeleteSound.bind(this)
138
+ },
139
+ imageSupport: {
140
+ add: this.insertImage.bind(this),
141
+ delete: this.onDeleteImage.bind(this)
142
+ }
143
+ });
144
+ if (!this._root) {
145
+ this._root = (0, _client.createRoot)(this);
146
+ }
147
+ this._root.render(element);
148
+ }
149
+ }
150
+ disconnectedCallback() {
151
+ if (this._root) {
152
+ this._root.unmount();
153
+ }
154
+ }
155
+ }
156
+ exports.default = MultiTraitRubricElement;
157
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_main","_defaults","_utils","_modals","modelWithDefaults","m","defaults","model","configurationWithDefaults","c","configuration","MultiTraitRubricElement","HTMLElement","constructor","_defineProperty2","default","currentModel","_model","validatedModel","scales","excludeZero","forEach","scale","scorePointsLabels","traits","maxPoints","howManyScorePointLabelsShouldHave","howManyScorePointLabelsItHas","length","i","push","slice","trait","scorePointsDescriptors","howManyScorePointDescriptorsItHas","shouldAddColumn0","some","addOrRemoveScaleColumn","excludeZeroTypes","add0","updateModelAccordingToReceivedProps","_render","dispatchEvent","ModelUpdatedEvent","_configuration","_root","insertSound","handler","InsertSoundEvent","onDeleteSound","src","done","DeleteSoundEvent","insertImage","InsertImageEvent","onDeleteImage","DeleteImageEvent","element","React","createElement","Main","onModelChanged","onConfigurationChanged","uploadSoundSupport","add","bind","delete","imageSupport","createRoot","render","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import {\n ModelUpdatedEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n InsertImageEvent,\n DeleteImageEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport Main from './main';\nimport defaults from './defaults';\nimport { addOrRemoveScaleColumn } from './utils';\nimport { excludeZeroTypes } from './modals';\n\nconst modelWithDefaults = (m) => ({ ...defaults.model, ...m });\nconst configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });\n\nexport default class MultiTraitRubricElement extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n this._model = modelWithDefaults();\n this._configuration = configurationWithDefaults();\n }\n\n updateModelAccordingToReceivedProps = (m) => {\n const currentModel = { ...this._model };\n\n if (!m) {\n return currentModel;\n }\n\n const validatedModel = { ...m };\n const { scales, excludeZero } = validatedModel || {};\n\n (scales || []).forEach((scale) => {\n if (!scale) {\n scale = { scorePointsLabels: [], traits: [] };\n }\n\n const { maxPoints } = scale || {};\n\n scale.scorePointsLabels = [...(scale.scorePointsLabels || [])];\n scale.traits = [...(scale.traits || [])];\n\n const howManyScorePointLabelsShouldHave = excludeZero ? maxPoints : maxPoints + 1;\n const howManyScorePointLabelsItHas = scale.scorePointsLabels.length;\n\n if (howManyScorePointLabelsItHas !== howManyScorePointLabelsShouldHave) {\n if (howManyScorePointLabelsItHas < howManyScorePointLabelsShouldHave) {\n for (let i = 0; i < howManyScorePointLabelsShouldHave - howManyScorePointLabelsItHas; i++) {\n scale.scorePointsLabels.push('');\n }\n } else {\n scale.scorePointsLabels = scale.scorePointsLabels.slice(0, howManyScorePointLabelsShouldHave);\n }\n }\n\n (scale.traits || []).forEach((trait) => {\n if (!trait) {\n trait = { scorePointsDescriptors: [] };\n }\n\n trait.scorePointsDescriptors = [...(trait.scorePointsDescriptors || [])];\n\n const howManyScorePointDescriptorsItHas = trait.scorePointsDescriptors.length;\n\n if (howManyScorePointDescriptorsItHas !== howManyScorePointLabelsShouldHave) {\n if (howManyScorePointDescriptorsItHas < howManyScorePointLabelsShouldHave) {\n for (let i = 0; i < howManyScorePointLabelsShouldHave - howManyScorePointDescriptorsItHas; i++) {\n trait.scorePointsDescriptors.push('');\n }\n } else {\n trait.scorePointsDescriptors = trait.scorePointsDescriptors.slice(0, howManyScorePointLabelsShouldHave);\n }\n }\n });\n });\n\n if (validatedModel.excludeZero) {\n // check if any scale has maxPoints set to 1\n const shouldAddColumn0 = validatedModel.scales.some((scale) => scale.maxPoints === 1);\n\n if (shouldAddColumn0) {\n // excludeZero should be false and disabled when maxPoints is 1\n validatedModel.excludeZero = false;\n // add column 0 for all scales\n validatedModel.scales = addOrRemoveScaleColumn(scales, excludeZeroTypes.add0);\n }\n }\n\n return validatedModel;\n };\n\n set model(m) {\n this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));\n this._render();\n }\n\n set configuration(c) {\n this._configuration = configurationWithDefaults(c);\n this._render();\n }\n\n onModelChanged = (m) => {\n this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));\n this._render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model, false));\n };\n\n onConfigurationChanged = (c) => {\n this._configuration = configurationWithDefaults(c);\n\n this._render();\n };\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n _render() {\n if (this._model) {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,MAAMQ,iBAAiB,GAAIC,CAAC,KAAM;EAAE,GAAGC,iBAAQ,CAACC,KAAK;EAAE,GAAGF;AAAE,CAAC,CAAC;AAC9D,MAAMG,yBAAyB,GAAIC,CAAC,KAAM;EAAE,GAAGH,iBAAQ,CAACI,aAAa;EAAE,GAAGD;AAAE,CAAC,CAAC;AAE/D,MAAME,uBAAuB,SAASC,WAAW,CAAC;EAC/DC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,+CAM6BV,CAAC,IAAK;MAC3C,MAAMW,YAAY,GAAG;QAAE,GAAG,IAAI,CAACC;MAAO,CAAC;MAEvC,IAAI,CAACZ,CAAC,EAAE;QACN,OAAOW,YAAY;MACrB;MAEA,MAAME,cAAc,G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,aAAI,EAAE;QACtCrD,KAAK,EAAE,IAAI,CAACU,MAAM;QAClBP,aAAa,EAAE,IAAI,CAACkC,cAAc;QAClCiB,cAAc,EAAE,IAAI,CAACA,cAAc;QACnCC,sBAAsB,EAAE,IAAI,CAACA,sBAAsB;QACnDC,kBAAkB,EAAE;UAClBC,GAAG,EAAE,IAAI,CAAClB,WAAW,CAACmB,IAAI,CAAC,IAAI,CAAC;UAChCC,MAAM,EAAE,IAAI,CAACjB,aAAa,CAACgB,IAAI,CAAC,IAAI;QACtC,CAAC;QACDE,YAAY,EAAE;UACZH,GAAG,EAAE,IAAI,CAACX,WAAW,CAACY,IAAI,CAAC,IAAI,CAAC;UAChCC,MAAM,EAAE,IAAI,CAACX,aAAa,CAACU,IAAI,CAAC,IAAI;QACtC;MACF,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAACpB,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAuB,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAACvB,KAAK,CAACwB,MAAM,CAACZ,OAAO,CAAC;IAC5B;EACF;EAEAa,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACzB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAAC0B,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAzD,OAAA,GAAAJ,uBAAA","ignoreList":[]}
@@ -0,0 +1,455 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Main = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
13
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
14
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
15
+ var _styles = require("@mui/material/styles");
16
+ var _configUi = require("@pie-lib/config-ui");
17
+ var _scale = _interopRequireDefault(require("./scale"));
18
+ var _common = require("./common");
19
+ var _modals = require("./modals");
20
+ var _utils = require("./utils");
21
+ const {
22
+ Panel,
23
+ toggle
24
+ } = _configUi.settings;
25
+ const MIN_WIDTH = '650px';
26
+ const StyledDiv = (0, _styles.styled)('div')(({
27
+ theme
28
+ }) => ({
29
+ fontFamily: 'Cerebri Sans',
30
+ fontSize: theme.typography.fontSize,
31
+ padding: '16px 0'
32
+ }));
33
+ const ShowModal = ({
34
+ showExcludeZeroDialog,
35
+ excludeZero,
36
+ changeExcludeZero,
37
+ cancel
38
+ }) => {
39
+ if (showExcludeZeroDialog && !excludeZero) {
40
+ return /*#__PURE__*/_react.default.createElement(_modals.ExcludeZeroDialog, {
41
+ open: showExcludeZeroDialog && !excludeZero,
42
+ changeExcludeZero: changeExcludeZero,
43
+ cancel: cancel
44
+ });
45
+ } else if (showExcludeZeroDialog && excludeZero) {
46
+ return /*#__PURE__*/_react.default.createElement(_modals.IncludeZeroDialog, {
47
+ open: showExcludeZeroDialog && excludeZero,
48
+ changeExcludeZero: changeExcludeZero,
49
+ cancel: cancel
50
+ });
51
+ } else {
52
+ return null;
53
+ }
54
+ };
55
+ ShowModal.propTypes = {
56
+ showExcludeZeroDialog: _propTypes.default.bool,
57
+ excludeZero: _propTypes.default.bool,
58
+ changeExcludeZero: _propTypes.default.func,
59
+ cancel: _propTypes.default.func
60
+ };
61
+ class Main extends _react.default.Component {
62
+ constructor(props) {
63
+ super(props);
64
+ (0, _defineProperty2.default)(this, "state", {
65
+ showDecreaseMaxPointsDialog: false,
66
+ showDeleteScaleDialog: false,
67
+ showDeleteTraitDialog: false,
68
+ showExcludeZeroDialog: false,
69
+ showInfoDialog: false,
70
+ infoDialogText: '',
71
+ adjustedWidth: MIN_WIDTH,
72
+ initialUpdateCompleted: false // flag to track the initial update of the div width
73
+ });
74
+ (0, _defineProperty2.default)(this, "updateDivWidthDebounced", (0, _debounce.default)(() => this.updateDivWidth(), 50));
75
+ (0, _defineProperty2.default)(this, "onScaleAdded", () => {
76
+ const {
77
+ model,
78
+ onModelChanged,
79
+ configuration
80
+ } = this.props;
81
+ let {
82
+ scales,
83
+ excludeZero
84
+ } = model || {};
85
+ const {
86
+ maxNoOfScales
87
+ } = configuration || {};
88
+ let {
89
+ defaultTraitLabel
90
+ } = configuration || '';
91
+ if (!scales.length) {
92
+ scales = [];
93
+ }
94
+
95
+ // if no default trait label is defined, take the trait label of the first scale
96
+ defaultTraitLabel = typeof defaultTraitLabel === 'string' ? defaultTraitLabel : scales[0]?.traitLabel || '';
97
+ if (scales.length === maxNoOfScales) {
98
+ this.set({
99
+ infoDialogText: `There can't be more than ${maxNoOfScales} scales.`,
100
+ showInfoDialog: true
101
+ });
102
+ return false;
103
+ }
104
+ scales.push({
105
+ maxPoints: 1,
106
+ scorePointsLabels: excludeZero ? [''] : ['', ''],
107
+ traitLabel: defaultTraitLabel,
108
+ traits: []
109
+ });
110
+ onModelChanged({
111
+ ...model,
112
+ scales
113
+ });
114
+ });
115
+ (0, _defineProperty2.default)(this, "onScaleChanged", (scaleIndex, params) => {
116
+ const {
117
+ model,
118
+ onModelChanged
119
+ } = this.props;
120
+ let scales = (0, _cloneDeep.default)((model || {}).scales);
121
+ if (scaleIndex < 0 || scaleIndex >= scales.length || (0, _isEmpty.default)(params)) return false;
122
+ Object.keys(params).forEach(key => {
123
+ scales[scaleIndex][key] = params[key];
124
+ });
125
+ if (model.excludeZero && params.maxPoints === 1) {
126
+ // excludeZero should be false and disabled when maxPoints is 1 for any scale
127
+ model.excludeZero = false;
128
+ scales = (0, _utils.addOrRemoveScaleColumn)(scales, _modals.excludeZeroTypes.add0);
129
+ }
130
+ onModelChanged({
131
+ ...model,
132
+ scales
133
+ });
134
+ });
135
+ (0, _defineProperty2.default)(this, "onScaleRemoved", scaleIndex => {
136
+ const {
137
+ model,
138
+ onModelChanged,
139
+ configuration
140
+ } = this.props;
141
+ let {
142
+ scales
143
+ } = model || {};
144
+ const {
145
+ minNoOfScales
146
+ } = configuration || {};
147
+ if (scaleIndex < 0 || scaleIndex >= scales.length) return false;
148
+ if (scales.length === minNoOfScales) {
149
+ this.set({
150
+ infoDialogText: `There can't be less than ${minNoOfScales} scales.`,
151
+ showInfoDialog: true
152
+ });
153
+ return false;
154
+ }
155
+ scales = [...scales.slice(0, scaleIndex), ...scales.slice(scaleIndex + 1)];
156
+ onModelChanged({
157
+ ...model,
158
+ scales
159
+ });
160
+ });
161
+ (0, _defineProperty2.default)(this, "onHalfScoringChanged", () => {
162
+ const {
163
+ model,
164
+ onModelChanged
165
+ } = this.props;
166
+ let {
167
+ halfScoring
168
+ } = model || {};
169
+ onModelChanged({
170
+ ...model,
171
+ halfScoring: !halfScoring
172
+ });
173
+ });
174
+ (0, _defineProperty2.default)(this, "onVisibleToStudentChanged", () => {
175
+ const {
176
+ model,
177
+ onModelChanged
178
+ } = this.props;
179
+ let {
180
+ visibleToStudent
181
+ } = model || {};
182
+ onModelChanged({
183
+ ...model,
184
+ visibleToStudent: !visibleToStudent
185
+ });
186
+ });
187
+ (0, _defineProperty2.default)(this, "set", newState => this.setState(newState));
188
+ (0, _defineProperty2.default)(this, "changeShowScorePointLabels", () => {
189
+ const {
190
+ model,
191
+ onModelChanged
192
+ } = this.props || {};
193
+ let {
194
+ pointLabels
195
+ } = model || {};
196
+ pointLabels = !pointLabels;
197
+ onModelChanged({
198
+ ...model,
199
+ pointLabels
200
+ });
201
+ });
202
+ (0, _defineProperty2.default)(this, "changeShowDescription", () => {
203
+ const {
204
+ model,
205
+ onModelChanged
206
+ } = this.props || {};
207
+ let {
208
+ description
209
+ } = model || {};
210
+ description = !description;
211
+ onModelChanged({
212
+ ...model,
213
+ description
214
+ });
215
+ });
216
+ (0, _defineProperty2.default)(this, "changeShowStandards", () => {
217
+ const {
218
+ model,
219
+ onModelChanged
220
+ } = this.props || {};
221
+ let {
222
+ standards
223
+ } = model || {};
224
+ standards = !standards;
225
+ onModelChanged({
226
+ ...model,
227
+ standards
228
+ });
229
+ });
230
+ // Exclude Zero
231
+ (0, _defineProperty2.default)(this, "showToggleExcludeZeroModal", () => this.set({
232
+ showExcludeZeroDialog: true
233
+ }));
234
+ (0, _defineProperty2.default)(this, "hideToggleExcludeZeroModal", () => {
235
+ this.set({
236
+ showExcludeZeroDialog: false
237
+ });
238
+ });
239
+ (0, _defineProperty2.default)(this, "onCloseInfoDialog", () => this.set({
240
+ showInfoDialog: false
241
+ }));
242
+ (0, _defineProperty2.default)(this, "changeExcludeZero", excludeZeroType => {
243
+ const {
244
+ model,
245
+ onModelChanged
246
+ } = this.props || {};
247
+ const {
248
+ scales
249
+ } = model || {};
250
+ let {
251
+ excludeZero
252
+ } = model || {};
253
+ if (!scales || !scales.length) return;
254
+ excludeZero = !excludeZero;
255
+ const newScales = (0, _utils.addOrRemoveScaleColumn)(scales, excludeZeroType);
256
+ onModelChanged({
257
+ ...model,
258
+ scales: newScales,
259
+ excludeZero
260
+ });
261
+ this.hideToggleExcludeZeroModal();
262
+ });
263
+ (0, _defineProperty2.default)(this, "onModelChanged", (updatedModel, updatedProperty) => {
264
+ const {
265
+ onModelChanged
266
+ } = this.props || {};
267
+ if (updatedProperty === 'excludeZero') {
268
+ this.showToggleExcludeZeroModal();
269
+ } else {
270
+ onModelChanged(updatedModel);
271
+ }
272
+ });
273
+ this.divRef = /*#__PURE__*/_react.default.createRef();
274
+ this.updateDivWidth = this.updateDivWidth.bind(this);
275
+ }
276
+ componentDidMount() {
277
+ window.addEventListener('resize', this.updateDivWidthDebounced);
278
+ window.addEventListener('load', this.updateDivWidth);
279
+
280
+ // delay updateDivWidth to avoid having this.divRef.current = null at first load
281
+ setTimeout(this.updateDivWidth, 0);
282
+ }
283
+ componentWillUnmount() {
284
+ window.removeEventListener('resize', this.updateDivWidthDebounced);
285
+ window.removeEventListener('load', this.updateDivWidth);
286
+ }
287
+ componentDidUpdate() {
288
+ if (!this.state.initialUpdateCompleted) {
289
+ this.updateDivWidth();
290
+ this.setState({
291
+ initialUpdateCompleted: true
292
+ });
293
+ }
294
+ }
295
+ updateDivWidth() {
296
+ if (this.divRef && this.divRef.current) {
297
+ const divWidth = this.divRef.current.offsetWidth;
298
+ if (divWidth !== this.state.adjustedWidth) {
299
+ this.set({
300
+ adjustedWidth: divWidth
301
+ });
302
+ }
303
+ }
304
+ }
305
+ render() {
306
+ const {
307
+ model,
308
+ configuration,
309
+ onConfigurationChanged,
310
+ uploadSoundSupport,
311
+ imageSupport
312
+ } = this.props || {};
313
+ const {
314
+ addScale,
315
+ baseInputConfiguration = {},
316
+ dragAndDrop,
317
+ contentDimensions = {},
318
+ showDescription,
319
+ showExcludeZero,
320
+ showLevelTagInput,
321
+ showStandards,
322
+ showHalfScoring,
323
+ showMaxPoint,
324
+ showScorePointLabels,
325
+ showVisibleToStudent,
326
+ spellCheck = {},
327
+ settingsPanelDisabled,
328
+ maxNoOfTraits,
329
+ minNoOfTraits,
330
+ width,
331
+ mathMlOptions = {},
332
+ maxMaxPoints,
333
+ expandedInput = {},
334
+ labelInput = {}
335
+ } = configuration || {};
336
+ const {
337
+ errors,
338
+ extraCSSRules,
339
+ scales,
340
+ excludeZero,
341
+ description,
342
+ pointLabels,
343
+ standards,
344
+ spellCheckEnabled,
345
+ maxPointsEnabled,
346
+ addScaleEnabled
347
+ } = model || {};
348
+ const {
349
+ showExcludeZeroDialog,
350
+ showInfoDialog,
351
+ infoDialogText,
352
+ adjustedWidth
353
+ } = this.state || {};
354
+
355
+ // excludeZero should be false and disabled when maxPoints is 1 for any scale
356
+ const disabledExcludeZero = scales?.some(scale => scale.maxPoints === 1);
357
+ const panelSettings = {
358
+ standards: showStandards.settings && toggle(showStandards.label),
359
+ 'showLevelTagInput.enabled': showLevelTagInput.settings && toggle(showLevelTagInput.label, true),
360
+ visibleToStudent: showVisibleToStudent.settings && toggle(showVisibleToStudent.label),
361
+ excludeZero: showExcludeZero.settings && toggle(showExcludeZero.label, false, disabledExcludeZero),
362
+ halfScoring: showHalfScoring.settings && toggle(showHalfScoring.label),
363
+ 'dragAndDrop.enabled': dragAndDrop.settings && toggle(dragAndDrop.label, true)
364
+ };
365
+ const panelProperties = {
366
+ description: showDescription.settings && toggle(showDescription.label),
367
+ pointLabels: showScorePointLabels.settings && toggle(showScorePointLabels.label),
368
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
369
+ maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
370
+ addScaleEnabled: addScale.settings && toggle(addScale.label)
371
+ };
372
+ const getPluginProps = props => {
373
+ return Object.assign({
374
+ ...baseInputConfiguration
375
+ }, props || {});
376
+ };
377
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
378
+ extraCSSRules: extraCSSRules,
379
+ dimensions: contentDimensions,
380
+ hideSettings: settingsPanelDisabled,
381
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
382
+ model: model,
383
+ onChangeModel: this.onModelChanged,
384
+ configuration: configuration,
385
+ onChangeConfiguration: onConfigurationChanged,
386
+ groups: {
387
+ Settings: panelSettings,
388
+ Properties: panelProperties
389
+ },
390
+ modal: /*#__PURE__*/_react.default.createElement(ShowModal, {
391
+ showExcludeZeroDialog: showExcludeZeroDialog,
392
+ excludeZero: excludeZero,
393
+ changeExcludeZero: this.changeExcludeZero,
394
+ cancel: this.hideToggleExcludeZeroModal
395
+ })
396
+ })
397
+ }, /*#__PURE__*/_react.default.createElement("div", {
398
+ style: {
399
+ width: '100%'
400
+ },
401
+ ref: this.divRef
402
+ }), /*#__PURE__*/_react.default.createElement(StyledDiv, {
403
+ style: {
404
+ width: width || adjustedWidth
405
+ }
406
+ }, (scales || []).map((scale, scaleIndex) => /*#__PURE__*/_react.default.createElement(_scale.default, (0, _extends2.default)({
407
+ key: `scale-${scaleIndex}`,
408
+ scale: scale,
409
+ scaleIndex: scaleIndex,
410
+ errors: errors,
411
+ onScaleRemoved: this.onScaleRemoved,
412
+ onScaleChanged: this.onScaleChanged,
413
+ showStandards: standards,
414
+ showScorePointLabels: pointLabels,
415
+ showDescription: description,
416
+ showLevelTagInput: showLevelTagInput.enabled,
417
+ excludeZero: excludeZero,
418
+ enableDragAndDrop: dragAndDrop.enabled,
419
+ spellCheck: spellCheckEnabled,
420
+ width: adjustedWidth,
421
+ uploadSoundSupport: uploadSoundSupport,
422
+ maxPointsEnabled: maxPointsEnabled,
423
+ maxNoOfTraits: maxNoOfTraits,
424
+ minNoOfTraits: minNoOfTraits,
425
+ imageSupport: imageSupport
426
+ }, this.props, {
427
+ mathMlOptions: mathMlOptions,
428
+ maxMaxPoints: maxMaxPoints,
429
+ expandedPluginProps: getPluginProps(expandedInput?.inputConfiguration),
430
+ labelPluginProps: getPluginProps(labelInput?.inputConfiguration)
431
+ }))), addScaleEnabled && /*#__PURE__*/_react.default.createElement(_common.MultiTraitButton, {
432
+ onClick: this.onScaleAdded
433
+ }, "Add Scale")), /*#__PURE__*/_react.default.createElement(_modals.InfoDialog, {
434
+ open: showInfoDialog,
435
+ text: infoDialogText,
436
+ onClose: () => this.set({
437
+ showInfoDialog: false
438
+ })
439
+ }));
440
+ }
441
+ }
442
+ exports.Main = Main;
443
+ Main.propTypes = {
444
+ model: _propTypes.default.object,
445
+ uploadSoundSupport: _propTypes.default.object,
446
+ configuration: _propTypes.default.object,
447
+ onModelChanged: _propTypes.default.func,
448
+ onConfigurationChanged: _propTypes.default.func,
449
+ imageSupport: _propTypes.default.shape({
450
+ add: _propTypes.default.func.isRequired,
451
+ delete: _propTypes.default.func.isRequired
452
+ })
453
+ };
454
+ var _default = exports.default = Main;
455
+ //# sourceMappingURL=main.js.map