@pie-element/multi-trait-rubric 0.1.0

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 (188) hide show
  1. package/dist/author/common.d.ts +91 -0
  2. package/dist/author/common.d.ts.map +1 -0
  3. package/dist/author/common.js +275 -0
  4. package/dist/author/defaults.d.ts +154 -0
  5. package/dist/author/defaults.d.ts.map +1 -0
  6. package/dist/author/defaults.js +113 -0
  7. package/dist/author/index.d.ts +23 -0
  8. package/dist/author/index.d.ts.map +1 -0
  9. package/dist/author/index.js +89 -0
  10. package/dist/author/main.d.ts +44 -0
  11. package/dist/author/main.d.ts.map +1 -0
  12. package/dist/author/main.js +249 -0
  13. package/dist/author/modals.d.ts +95 -0
  14. package/dist/author/modals.d.ts.map +1 -0
  15. package/dist/author/modals.js +171 -0
  16. package/dist/author/scale.d.ts +47 -0
  17. package/dist/author/scale.d.ts.map +1 -0
  18. package/dist/author/scale.js +280 -0
  19. package/dist/author/trait.d.ts +71 -0
  20. package/dist/author/trait.d.ts.map +1 -0
  21. package/dist/author/trait.js +202 -0
  22. package/dist/author/traitsHeader.d.ts +29 -0
  23. package/dist/author/traitsHeader.d.ts.map +1 -0
  24. package/dist/author/traitsHeader.js +172 -0
  25. package/dist/author/utils.d.ts +11 -0
  26. package/dist/author/utils.d.ts.map +1 -0
  27. package/dist/author/utils.js +41 -0
  28. package/dist/controller/defaults.d.ts +21 -0
  29. package/dist/controller/defaults.d.ts.map +1 -0
  30. package/dist/controller/defaults.js +14 -0
  31. package/dist/controller/index.d.ts +27 -0
  32. package/dist/controller/index.d.ts.map +1 -0
  33. package/dist/controller/index.js +57 -0
  34. package/dist/controller/utils.d.ts +10 -0
  35. package/dist/controller/utils.d.ts.map +1 -0
  36. package/dist/controller/utils.js +4 -0
  37. package/dist/delivery/index.d.ts +18 -0
  38. package/dist/delivery/index.d.ts.map +1 -0
  39. package/dist/delivery/index.js +37 -0
  40. package/dist/delivery/main.d.ts +16 -0
  41. package/dist/delivery/main.d.ts.map +1 -0
  42. package/dist/delivery/main.js +95 -0
  43. package/dist/delivery/scale.d.ts +18 -0
  44. package/dist/delivery/scale.d.ts.map +1 -0
  45. package/dist/delivery/scale.js +175 -0
  46. package/dist/delivery/trait.d.ts +28 -0
  47. package/dist/delivery/trait.d.ts.map +1 -0
  48. package/dist/delivery/trait.js +44 -0
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.iife.d.ts +9 -0
  52. package/dist/index.iife.d.ts.map +1 -0
  53. package/dist/index.iife.js +145 -0
  54. package/dist/index.js +2 -0
  55. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
  56. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
  57. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
  58. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
  59. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
  60. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
  61. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
  62. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
  63. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
  64. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
  65. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
  66. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
  67. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
  68. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  69. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
  70. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
  71. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
  72. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
  73. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
  74. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
  75. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
  76. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
  77. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  78. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
  79. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
  80. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
  81. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
  82. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
  83. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  84. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
  85. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
  86. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
  87. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTrim.js +8 -0
  88. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
  89. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  90. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
  91. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
  92. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
  93. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
  94. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  95. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
  96. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
  97. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
  98. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  99. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
  100. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
  101. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
  102. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
  103. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  104. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
  105. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
  106. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
  107. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
  108. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
  109. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  110. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
  111. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
  112. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
  113. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
  114. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
  115. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
  116. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
  117. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
  118. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
  119. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
  120. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
  121. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
  122. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
  123. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
  124. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
  125. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
  126. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
  127. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
  128. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
  129. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
  130. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  131. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
  132. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
  133. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
  134. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
  135. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
  136. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  137. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
  138. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
  139. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
  140. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
  141. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
  142. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
  143. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
  144. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
  145. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
  146. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
  147. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
  148. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
  149. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +50 -0
  150. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
  151. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
  152. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
  153. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
  154. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
  155. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
  156. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
  157. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
  158. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
  159. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
  160. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
  161. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
  162. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
  163. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
  164. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
  165. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
  166. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +7 -0
  167. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
  168. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
  169. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +19 -0
  170. package/package.json +70 -0
  171. package/src/author/common.tsx +473 -0
  172. package/src/author/defaults.tsx +157 -0
  173. package/src/author/index.ts +174 -0
  174. package/src/author/main.tsx +407 -0
  175. package/src/author/modals.tsx +254 -0
  176. package/src/author/scale.tsx +453 -0
  177. package/src/author/trait.tsx +305 -0
  178. package/src/author/traitsHeader.tsx +301 -0
  179. package/src/author/utils.ts +83 -0
  180. package/src/controller/defaults.ts +21 -0
  181. package/src/controller/index.ts +137 -0
  182. package/src/controller/utils.ts +13 -0
  183. package/src/delivery/index.ts +61 -0
  184. package/src/delivery/main.tsx +140 -0
  185. package/src/delivery/scale.tsx +313 -0
  186. package/src/delivery/trait.tsx +86 -0
  187. package/src/index.iife.ts +16 -0
  188. package/src/index.ts +1 -0
@@ -0,0 +1,157 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/configure/src/defaults.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ export default {
12
+ model: {
13
+ addScaleEnabled: true,
14
+ description: false,
15
+ excludeZero: false,
16
+ halfScoring: false,
17
+ maxPointsEnabled: true,
18
+ pointLabels: true,
19
+ scales: [],
20
+ standards: false,
21
+ visibleToStudent: true,
22
+ },
23
+ configuration: {
24
+ baseInputConfiguration: {
25
+ h3: { disabled: true },
26
+ audio: { disabled: false },
27
+ video: { disabled: false },
28
+ image: { disabled: false },
29
+ textAlign: { disabled: true },
30
+ showParagraphs: { disabled: false },
31
+ separateParagraphs: { disabled: true },
32
+ },
33
+ expandedInput: {
34
+ inputConfiguration: {
35
+ math: { disabled: true },
36
+ audio: { disabled: false },
37
+ video: { disabled: false },
38
+ image: { disabled: false },
39
+ },
40
+ },
41
+ labelInput: {
42
+ inputConfiguration: {
43
+ math: { disabled: true },
44
+ audio: { disabled: true },
45
+ video: { disabled: true },
46
+ image: { disabled: true },
47
+ },
48
+ },
49
+ excludeZeroDialogBoxContent: {
50
+ title: 'Exclude 0 (Zero) from Score Point Values.',
51
+ text: `<div>
52
+ You are about to exclude 0 from score point values.
53
+ <br/>
54
+ Some of the existing data has to be changed.
55
+ <br/>
56
+ Please choose if you want to:
57
+ <ul>
58
+ <li>
59
+ shift Labels and Descriptions to the left
60
+ </li>
61
+ <li>
62
+ remove 0 column with its Label and Description
63
+ </li>
64
+ </ul>
65
+ </div>`,
66
+ },
67
+ includeZeroDialogBoxContent: {
68
+ title: 'Include 0 (Zero) in Score Point Values.',
69
+ text: `<div>
70
+ You are about to include 0 in score point values.
71
+ <br/>
72
+ Some of the existing data has to be changed.
73
+ <br/>
74
+ Please choose if you want to:
75
+ <ul>
76
+ <li>
77
+ shift Labels and Descriptions to the right
78
+ </li>
79
+ <li>
80
+ add 0 column with empty Label and Descriptions
81
+ </li>
82
+ </ul>
83
+ </div>`,
84
+ },
85
+ deleteScaleDialogBoxContent: {
86
+ title: 'Delete Scale',
87
+ text: 'Are you sure you want to delete this scale?',
88
+ },
89
+ maxPointsDialogBoxContent: {
90
+ title: 'Decreasing Max Points.',
91
+ text: ` You are about to decrease max score point value.
92
+ <br/>
93
+ All the Labels and Descriptions for scores above Max Point will be deleted.`,
94
+ },
95
+ settingsPanelDisabled: false,
96
+ spellCheck: {
97
+ label: 'Spellcheck',
98
+ settings: false,
99
+ enabled: true,
100
+ },
101
+ showExcludeZero: {
102
+ settings: true,
103
+ label: 'Exclude Zero',
104
+ },
105
+ showScorePointLabels: {
106
+ settings: true,
107
+ label: 'Show Score Point Labels',
108
+ },
109
+ showDescription: {
110
+ settings: true,
111
+ label: 'Show Description',
112
+ },
113
+ showVisibleToStudent: {
114
+ settings: true,
115
+ label: 'Visible to Student',
116
+ },
117
+ showHalfScoring: {
118
+ settings: true,
119
+ label: 'Half Scoring',
120
+ },
121
+ // commenting this in order to use the dynamic width if the width was not set by the client (PD-3203)
122
+ // width: '900px',
123
+ // these should not be set to true (should not be used) for now
124
+ showStandards: {
125
+ settings: false,
126
+ label: 'Show Standards',
127
+ },
128
+ showLevelTagInput: {
129
+ settings: false,
130
+ label: 'Show Level Tag Input',
131
+ enabled: false,
132
+ },
133
+ dragAndDrop: {
134
+ settings: true,
135
+ label: 'Enable Drag and Drop',
136
+ enabled: false,
137
+ },
138
+ showMaxPoint: {
139
+ settings: true,
140
+ label: 'Show Max Points Dropdown',
141
+ },
142
+ addScale: {
143
+ settings: true,
144
+ label: 'Add Scale Available',
145
+ },
146
+ minNoOfTraits: 1,
147
+ maxNoOfTraits: 10,
148
+ minNoOfScales: 1,
149
+ maxNoOfScales: 10,
150
+ defaultTraitLabel: 'Trait',
151
+ mathMlOptions: {
152
+ mmlOutput: false,
153
+ mmlEditing: false,
154
+ },
155
+ maxMaxPoints: 10,
156
+ },
157
+ };
@@ -0,0 +1,174 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/configure/src/index.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ import {
12
+ ModelUpdatedEvent,
13
+ InsertSoundEvent,
14
+ DeleteSoundEvent,
15
+ InsertImageEvent,
16
+ DeleteImageEvent,
17
+ } from '@pie-element/shared-configure-events';
18
+
19
+ import React from 'react';
20
+ import { createRoot } from 'react-dom/client';
21
+
22
+ import Main from './main.js';
23
+ import defaults from './defaults.js';
24
+ import { addOrRemoveScaleColumn } from './utils.js';
25
+ import { excludeZeroTypes } from './modals.js';
26
+
27
+ const modelWithDefaults = (m) => ({ ...defaults.model, ...m });
28
+ const configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });
29
+
30
+ export default class MultiTraitRubricElement extends HTMLElement {
31
+ constructor() {
32
+ super();
33
+ this._root = null;
34
+ this._model = modelWithDefaults();
35
+ this._configuration = configurationWithDefaults();
36
+ }
37
+
38
+ updateModelAccordingToReceivedProps: any = (m) => {
39
+ const currentModel = { ...this._model };
40
+
41
+ if (!m) {
42
+ return currentModel;
43
+ }
44
+
45
+ const validatedModel = { ...m };
46
+ const { scales, excludeZero } = validatedModel || {};
47
+
48
+ (scales || []).forEach((scale) => {
49
+ if (!scale) {
50
+ scale = { scorePointsLabels: [], traits: [] };
51
+ }
52
+
53
+ const { maxPoints } = scale || {};
54
+
55
+ scale.scorePointsLabels = [...(scale.scorePointsLabels || [])];
56
+ scale.traits = [...(scale.traits || [])];
57
+
58
+ const howManyScorePointLabelsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
59
+ const howManyScorePointLabelsItHas = scale.scorePointsLabels.length;
60
+
61
+ if (howManyScorePointLabelsItHas !== howManyScorePointLabelsShouldHave) {
62
+ if (howManyScorePointLabelsItHas < howManyScorePointLabelsShouldHave) {
63
+ for (let i = 0; i < howManyScorePointLabelsShouldHave - howManyScorePointLabelsItHas; i++) {
64
+ scale.scorePointsLabels.push('');
65
+ }
66
+ } else {
67
+ scale.scorePointsLabels = scale.scorePointsLabels.slice(0, howManyScorePointLabelsShouldHave);
68
+ }
69
+ }
70
+
71
+ (scale.traits || []).forEach((trait) => {
72
+ if (!trait) {
73
+ trait = { scorePointsDescriptors: [] };
74
+ }
75
+
76
+ trait.scorePointsDescriptors = [...(trait.scorePointsDescriptors || [])];
77
+
78
+ const howManyScorePointDescriptorsItHas = trait.scorePointsDescriptors.length;
79
+
80
+ if (howManyScorePointDescriptorsItHas !== howManyScorePointLabelsShouldHave) {
81
+ if (howManyScorePointDescriptorsItHas < howManyScorePointLabelsShouldHave) {
82
+ for (let i = 0; i < howManyScorePointLabelsShouldHave - howManyScorePointDescriptorsItHas; i++) {
83
+ trait.scorePointsDescriptors.push('');
84
+ }
85
+ } else {
86
+ trait.scorePointsDescriptors = trait.scorePointsDescriptors.slice(0, howManyScorePointLabelsShouldHave);
87
+ }
88
+ }
89
+ });
90
+ });
91
+
92
+ if (validatedModel.excludeZero) {
93
+ // check if any scale has maxPoints set to 1
94
+ const shouldAddColumn0 = validatedModel.scales.some((scale) => scale.maxPoints === 1);
95
+
96
+ if (shouldAddColumn0) {
97
+ // excludeZero should be false and disabled when maxPoints is 1
98
+ validatedModel.excludeZero = false;
99
+ // add column 0 for all scales
100
+ validatedModel.scales = addOrRemoveScaleColumn(scales, excludeZeroTypes.add0);
101
+ }
102
+ }
103
+
104
+ return validatedModel;
105
+ };
106
+
107
+ set model(m) {
108
+ this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
109
+ this._render();
110
+ }
111
+
112
+ set configuration(c) {
113
+ this._configuration = configurationWithDefaults(c);
114
+ this._render();
115
+ }
116
+
117
+ onModelChanged: any = (m) => {
118
+ this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
119
+ this._render();
120
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
121
+ };
122
+
123
+ onConfigurationChanged: any = (c) => {
124
+ this._configuration = configurationWithDefaults(c);
125
+
126
+ this._render();
127
+ };
128
+
129
+ insertSound(handler) {
130
+ this.dispatchEvent(new InsertSoundEvent(handler));
131
+ }
132
+
133
+ onDeleteSound(src, done) {
134
+ this.dispatchEvent(new DeleteSoundEvent(src, done));
135
+ }
136
+
137
+ insertImage(handler) {
138
+ this.dispatchEvent(new InsertImageEvent(handler));
139
+ }
140
+
141
+ onDeleteImage(src, done) {
142
+ this.dispatchEvent(new DeleteImageEvent(src, done));
143
+ }
144
+
145
+ _render() {
146
+ if (this._model) {
147
+ let element = React.createElement(Main, {
148
+ model: this._model,
149
+ configuration: this._configuration,
150
+ onModelChanged: this.onModelChanged,
151
+ onConfigurationChanged: this.onConfigurationChanged,
152
+ uploadSoundSupport: {
153
+ add: this.insertSound.bind(this),
154
+ delete: this.onDeleteSound.bind(this),
155
+ },
156
+ imageSupport: {
157
+ add: this.insertImage.bind(this),
158
+ delete: this.onDeleteImage.bind(this),
159
+ },
160
+ });
161
+
162
+ if (!this._root) {
163
+ this._root = createRoot(this);
164
+ }
165
+ this._root.render(element);
166
+ }
167
+ }
168
+
169
+ disconnectedCallback() {
170
+ if (this._root) {
171
+ this._root.unmount();
172
+ }
173
+ }
174
+ }