@pie-element/categorize 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 (238) hide show
  1. package/dist/author/defaults.d.ts +224 -0
  2. package/dist/author/defaults.d.ts.map +1 -0
  3. package/dist/author/defaults.js +170 -0
  4. package/dist/author/design/builder.d.ts +11 -0
  5. package/dist/author/design/builder.d.ts.map +1 -0
  6. package/dist/author/design/builder.js +24 -0
  7. package/dist/author/design/buttons.d.ts +29 -0
  8. package/dist/author/design/buttons.d.ts.map +1 -0
  9. package/dist/author/design/buttons.js +36 -0
  10. package/dist/author/design/categories/RowLabel.d.ts +24 -0
  11. package/dist/author/design/categories/RowLabel.d.ts.map +1 -0
  12. package/dist/author/design/categories/RowLabel.js +46 -0
  13. package/dist/author/design/categories/alternateResponses.d.ts +32 -0
  14. package/dist/author/design/categories/alternateResponses.d.ts.map +1 -0
  15. package/dist/author/design/categories/alternateResponses.js +62 -0
  16. package/dist/author/design/categories/category.d.ts +45 -0
  17. package/dist/author/design/categories/category.d.ts.map +1 -0
  18. package/dist/author/design/categories/category.js +102 -0
  19. package/dist/author/design/categories/choice-preview.d.ts +26 -0
  20. package/dist/author/design/categories/choice-preview.d.ts.map +1 -0
  21. package/dist/author/design/categories/choice-preview.js +60 -0
  22. package/dist/author/design/categories/droppable-placeholder.d.ts +11 -0
  23. package/dist/author/design/categories/droppable-placeholder.d.ts.map +1 -0
  24. package/dist/author/design/categories/droppable-placeholder.js +70 -0
  25. package/dist/author/design/categories/index.d.ts +42 -0
  26. package/dist/author/design/categories/index.d.ts.map +1 -0
  27. package/dist/author/design/categories/index.js +146 -0
  28. package/dist/author/design/choices/choice.d.ts +11 -0
  29. package/dist/author/design/choices/choice.d.ts.map +1 -0
  30. package/dist/author/design/choices/choice.js +129 -0
  31. package/dist/author/design/choices/config.d.ts +22 -0
  32. package/dist/author/design/choices/config.d.ts.map +1 -0
  33. package/dist/author/design/choices/config.js +33 -0
  34. package/dist/author/design/choices/index.d.ts +42 -0
  35. package/dist/author/design/choices/index.d.ts.map +1 -0
  36. package/dist/author/design/choices/index.js +110 -0
  37. package/dist/author/design/header.d.ts +25 -0
  38. package/dist/author/design/header.d.ts.map +1 -0
  39. package/dist/author/design/header.js +49 -0
  40. package/dist/author/design/index.d.ts +53 -0
  41. package/dist/author/design/index.d.ts.map +1 -0
  42. package/dist/author/design/index.js +410 -0
  43. package/dist/author/design/input-header.d.ts +40 -0
  44. package/dist/author/design/input-header.d.ts.map +1 -0
  45. package/dist/author/design/input-header.js +69 -0
  46. package/dist/author/design/utils.d.ts +10 -0
  47. package/dist/author/design/utils.d.ts.map +1 -0
  48. package/dist/author/design/utils.js +7 -0
  49. package/dist/author/index.d.ts +52 -0
  50. package/dist/author/index.d.ts.map +1 -0
  51. package/dist/author/index.js +87 -0
  52. package/dist/author/main.d.ts +24 -0
  53. package/dist/author/main.d.ts.map +1 -0
  54. package/dist/author/main.js +30 -0
  55. package/dist/author/utils.d.ts +17 -0
  56. package/dist/author/utils.d.ts.map +1 -0
  57. package/dist/author/utils.js +17 -0
  58. package/dist/controller/defaults.d.ts +35 -0
  59. package/dist/controller/defaults.d.ts.map +1 -0
  60. package/dist/controller/defaults.js +29 -0
  61. package/dist/controller/index.d.ts +62 -0
  62. package/dist/controller/index.d.ts.map +1 -0
  63. package/dist/controller/index.js +155 -0
  64. package/dist/controller/utils.d.ts +21 -0
  65. package/dist/controller/utils.d.ts.map +1 -0
  66. package/dist/controller/utils.js +35 -0
  67. package/dist/delivery/categorize/categories.d.ts +35 -0
  68. package/dist/delivery/categorize/categories.d.ts.map +1 -0
  69. package/dist/delivery/categorize/categories.js +66 -0
  70. package/dist/delivery/categorize/category.d.ts +29 -0
  71. package/dist/delivery/categorize/category.d.ts.map +1 -0
  72. package/dist/delivery/categorize/category.js +48 -0
  73. package/dist/delivery/categorize/choice.d.ts +28 -0
  74. package/dist/delivery/categorize/choice.d.ts.map +1 -0
  75. package/dist/delivery/categorize/choice.js +94 -0
  76. package/dist/delivery/categorize/choices.d.ts +40 -0
  77. package/dist/delivery/categorize/choices.d.ts.map +1 -0
  78. package/dist/delivery/categorize/choices.js +51 -0
  79. package/dist/delivery/categorize/droppable-placeholder.d.ts +33 -0
  80. package/dist/delivery/categorize/droppable-placeholder.d.ts.map +1 -0
  81. package/dist/delivery/categorize/droppable-placeholder.js +64 -0
  82. package/dist/delivery/categorize/grid-content.d.ts +26 -0
  83. package/dist/delivery/categorize/grid-content.d.ts.map +1 -0
  84. package/dist/delivery/categorize/grid-content.js +39 -0
  85. package/dist/delivery/categorize/index.d.ts +58 -0
  86. package/dist/delivery/categorize/index.d.ts.map +1 -0
  87. package/dist/delivery/categorize/index.js +260 -0
  88. package/dist/delivery/index.d.ts +28 -0
  89. package/dist/delivery/index.d.ts.map +1 -0
  90. package/dist/delivery/index.js +152 -0
  91. package/dist/index.d.ts +2 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.iife.d.ts +9 -0
  94. package/dist/index.iife.d.ts.map +1 -0
  95. package/dist/index.iife.js +152 -0
  96. package/dist/index.js +2 -0
  97. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
  98. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
  99. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
  100. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
  101. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
  102. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
  103. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
  104. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
  105. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
  106. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
  107. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
  108. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
  109. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
  110. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  111. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
  112. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
  113. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
  114. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
  115. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
  116. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
  117. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
  118. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
  119. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  120. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
  121. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
  122. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
  123. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
  124. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
  125. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  126. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
  127. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
  128. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
  129. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
  130. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  131. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
  132. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
  133. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
  134. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
  135. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  136. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
  137. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
  138. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
  139. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  140. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
  141. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
  142. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
  143. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
  144. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  145. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
  146. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
  147. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
  148. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
  149. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
  150. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  151. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
  152. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
  153. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
  154. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
  155. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
  156. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
  157. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
  158. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
  159. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
  160. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
  161. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
  162. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
  163. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
  164. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
  165. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
  166. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
  167. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
  168. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
  169. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
  170. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
  171. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  172. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
  173. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
  174. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
  175. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
  176. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
  177. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  178. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
  179. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
  180. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
  181. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
  182. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
  183. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
  184. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
  185. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
  186. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
  187. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
  188. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
  189. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
  190. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
  191. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
  192. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
  193. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
  194. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
  195. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
  196. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
  197. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
  198. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
  199. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
  200. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
  201. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
  202. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
  203. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
  204. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
  205. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
  206. package/package.json +74 -0
  207. package/src/author/defaults.ts +182 -0
  208. package/src/author/design/builder.ts +63 -0
  209. package/src/author/design/buttons.tsx +60 -0
  210. package/src/author/design/categories/RowLabel.tsx +91 -0
  211. package/src/author/design/categories/alternateResponses.tsx +127 -0
  212. package/src/author/design/categories/category.tsx +161 -0
  213. package/src/author/design/categories/choice-preview.tsx +112 -0
  214. package/src/author/design/categories/droppable-placeholder.tsx +114 -0
  215. package/src/author/design/categories/index.tsx +254 -0
  216. package/src/author/design/choices/choice.tsx +200 -0
  217. package/src/author/design/choices/config.tsx +58 -0
  218. package/src/author/design/choices/index.tsx +185 -0
  219. package/src/author/design/header.tsx +74 -0
  220. package/src/author/design/index.tsx +764 -0
  221. package/src/author/design/input-header.tsx +109 -0
  222. package/src/author/design/utils.ts +14 -0
  223. package/src/author/index.ts +171 -0
  224. package/src/author/main.tsx +45 -0
  225. package/src/author/utils.ts +46 -0
  226. package/src/controller/defaults.ts +37 -0
  227. package/src/controller/index.ts +469 -0
  228. package/src/controller/utils.ts +79 -0
  229. package/src/delivery/categorize/categories.tsx +139 -0
  230. package/src/delivery/categorize/category.tsx +78 -0
  231. package/src/delivery/categorize/choice.tsx +117 -0
  232. package/src/delivery/categorize/choices.tsx +95 -0
  233. package/src/delivery/categorize/droppable-placeholder.tsx +95 -0
  234. package/src/delivery/categorize/grid-content.tsx +53 -0
  235. package/src/delivery/categorize/index.tsx +515 -0
  236. package/src/delivery/index.ts +390 -0
  237. package/src/index.iife.ts +16 -0
  238. package/src/index.ts +1 -0
@@ -0,0 +1,260 @@
1
+ import e from "./choice.js";
2
+ import t from "./choices.js";
3
+ import n from "./categories.js";
4
+ import r from "react";
5
+ import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
+ import * as a from "@pie-lib/render-ui";
7
+ import { Collapsible as o, Feedback as s, PreviewPrompt as c, UiLayout as l, color as u, hasMedia as d, hasText as f } from "@pie-lib/render-ui";
8
+ import p from "prop-types";
9
+ import m from "debug";
10
+ import { styled as h } from "@mui/material/styles";
11
+ import { DragOverlay as g } from "@dnd-kit/core";
12
+ import _ from "@pie-lib/correct-answer-toggle";
13
+ import { buildState as v, moveChoiceToCategory as y, removeChoiceFromCategory as b } from "@pie-lib/categorize";
14
+ import { DragProvider as x, uid as S } from "@pie-lib/drag";
15
+ import { jsx as C, jsxs as w } from "react/jsx-runtime";
16
+ import T from "@pie-lib/translator";
17
+ import { AlertDialog as E } from "@pie-lib/config-ui";
18
+ //#region src/delivery/categorize/index.tsx
19
+ function D(e) {
20
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
21
+ }
22
+ function O(e, t) {
23
+ return !e || D(e) ? e : D(e.default) ? e.default : t && D(e[t]) ? e[t] : t && D(e[t]?.default) ? e[t].default : e;
24
+ }
25
+ var k = O(l, "UiLayout") || O(F.UiLayout, "UiLayout"), A = O(c, "PreviewPrompt") || O(F.PreviewPrompt, "PreviewPrompt"), j = O(o, "Collapsible") || O(F.Collapsible, "Collapsible"), M = O(s, "Feedback") || O(F.Feedback, "Feedback"), N = a, P = N.default, F = P && typeof P == "object" ? P : N, { translator: I } = T, L = m("@pie-ui:categorize"), R = class extends r.Component {
26
+ static propTypes = { children: p.node };
27
+ containerRef = r.createRef();
28
+ componentDidMount() {
29
+ this.containerRef.current && i(this.containerRef.current);
30
+ }
31
+ render() {
32
+ return /* @__PURE__ */ C("div", {
33
+ ref: this.containerRef,
34
+ children: this.props.children
35
+ });
36
+ }
37
+ }, z = class extends r.Component {
38
+ static propTypes = {
39
+ model: p.object,
40
+ session: p.shape({ answers: p.arrayOf(p.shape({
41
+ choice: p.string,
42
+ category: p.string
43
+ })) }),
44
+ onAnswersChange: p.func.isRequired,
45
+ onShowCorrectToggle: p.func.isRequired,
46
+ pauseMathObserver: p.func,
47
+ resumeMathObserver: p.func
48
+ };
49
+ static defaultProps = { disabled: !1 };
50
+ constructor(e) {
51
+ super(e), this.state = {
52
+ showCorrect: !1,
53
+ showMaxChoiceAlert: !1
54
+ };
55
+ }
56
+ removeChoice = (e) => {
57
+ L("[removeChoice]: ", e);
58
+ let { onAnswersChange: t, session: n } = this.props;
59
+ t(b(e.id, e.categoryId, e.choiceIndex, n.answers));
60
+ };
61
+ dropChoice = (e, t) => {
62
+ let { session: n, onAnswersChange: r, model: i } = this.props, { maxChoicesPerCategory: a = 0 } = i || {}, { answers: o = [] } = n || {}, s;
63
+ t ? L("[dropChoice] category: ", t.categoryId, "choice: ", t) : L("[dropChoice] category: ", void 0, "choice: ", void 0);
64
+ let c = o.find((t) => t.category === e);
65
+ t && a === 1 && c && c.choices && c.choices.length === 1 ? (s = y(t.id, t.categoryId, e, t.choiceIndex, o), s = b(c.choices[0], e, 0, s)) : t && a > 1 && c && c.choices && c.choices.length === a ? (s = t.categoryId ? y(t.id, t.categoryId, t.categoryId, t.choiceIndex, o) : b(t.id, t.categoryId, t.choiceIndex, o), this.setState({ showMaxChoiceAlert: !0 })) : a !== 0 && c && c.choices && c.choices.length > a ? (s = o, this.setState({ showMaxChoiceAlert: !0 })) : s = t ? y(t.id, t.categoryId, e, t.choiceIndex, o) : this.removeChoice(e), t && r(s);
66
+ };
67
+ UNSAFE_componentWillReceiveProps(e) {
68
+ let { model: t } = this.props, { model: n } = e;
69
+ t.note && t.language && t.language !== n.language && t.note === I.t("common:commonCorrectAnswerWithAlternates", { lng: t.language }) && (t.note = I.t("common:commonCorrectAnswerWithAlternates", { lng: n.language })), this.setState({ showCorrect: !1 });
70
+ }
71
+ toggleShowCorrect = () => this.setState({ showCorrect: !this.state.showCorrect }, () => {
72
+ this.props.onShowCorrectToggle();
73
+ });
74
+ getPositionDirection = (e) => {
75
+ let t;
76
+ switch (e) {
77
+ case "left":
78
+ t = "row-reverse";
79
+ break;
80
+ case "right":
81
+ t = "row";
82
+ break;
83
+ case "below":
84
+ t = "column";
85
+ break;
86
+ default:
87
+ t = "column-reverse";
88
+ break;
89
+ }
90
+ return t;
91
+ };
92
+ existAlternateResponse = (e) => e?.some((e) => e.alternateResponses?.length > 0);
93
+ render() {
94
+ let { model: e, session: i } = this.props, { showCorrect: a, showMaxChoiceAlert: o } = this.state, { choicesPosition: s, extraCSSRules: c, note: l, showNote: u, env: p, language: m, maxChoicesPerCategory: h, autoplayAudioEnabled: g, customAudioButton: y } = e, { mode: b, role: x } = p || {}, S = s || "above", T = {
95
+ flexDirection: this.getPositionDirection(S),
96
+ gap: "8px"
97
+ }, { categories: D, choices: O, correct: k } = v(e.categories, e.choices, a ? e.correctResponse : i.answers, e.correctResponse);
98
+ L("[render] disabled: ", e.disabled);
99
+ let { rowLabels: j, categoriesPerRow: N, correctResponse: P, fontSizeFactor: F } = e, R = D && Math.ceil(D.length / N) || 0, z = this.existAlternateResponse(P) || !1, B = (a || b === "view" && x === "instructor") && u && l && z, G = I.t("translation:categorize:limitMaxChoicesPerCategory", {
100
+ lng: e.language,
101
+ maxChoicesPerCategory: h
102
+ }), K = I.t("common:warning", { lng: e.language }), q = I.t("common:cancel", { lng: e.language }), J = e.rationale && (f(e.rationale) || d(e.rationale));
103
+ return /* @__PURE__ */ w(V, {
104
+ extraCSSRules: c,
105
+ id: "main-container",
106
+ fontSizeFactor: F,
107
+ children: [
108
+ e.teacherInstructions && (f(e.teacherInstructions) || d(e.teacherInstructions)) && /* @__PURE__ */ C(r.Fragment, { children: /* @__PURE__ */ C(W, {
109
+ labels: {
110
+ hidden: "Show Teacher Instructions",
111
+ visible: "Hide Teacher Instructions"
112
+ },
113
+ children: /* @__PURE__ */ C(A, { prompt: e.teacherInstructions })
114
+ }) }),
115
+ e.prompt && /* @__PURE__ */ C(A, {
116
+ prompt: e.prompt,
117
+ autoplayAudioEnabled: g,
118
+ customAudioButton: y
119
+ }),
120
+ /* @__PURE__ */ C(_, {
121
+ show: a || k === !1,
122
+ toggled: a,
123
+ onToggle: this.toggleShowCorrect,
124
+ language: m
125
+ }),
126
+ /* @__PURE__ */ w(U, {
127
+ style: T,
128
+ children: [/* @__PURE__ */ C("div", {
129
+ style: {
130
+ display: "flex",
131
+ flex: 1
132
+ },
133
+ children: /* @__PURE__ */ C(n, {
134
+ model: e,
135
+ disabled: e.disabled,
136
+ categories: D,
137
+ onDropChoice: this.dropChoice,
138
+ onRemoveChoice: this.removeChoice,
139
+ rowLabels: (j || []).slice(0, R)
140
+ })
141
+ }), /* @__PURE__ */ C(t, {
142
+ disabled: e.disabled,
143
+ model: e,
144
+ choices: O,
145
+ choicePosition: S,
146
+ onDropChoice: this.dropChoice,
147
+ onRemoveChoice: this.removeChoice,
148
+ correct: k
149
+ })]
150
+ }),
151
+ B && /* @__PURE__ */ C(H, { dangerouslySetInnerHTML: { __html: l } }),
152
+ J && /* @__PURE__ */ C(W, {
153
+ labels: {
154
+ hidden: "Show Rationale",
155
+ visible: "Hide Rationale"
156
+ },
157
+ children: /* @__PURE__ */ C(A, { prompt: e.rationale })
158
+ }),
159
+ e.correctness && e.feedback && !a && /* @__PURE__ */ C(M, {
160
+ correctness: e.correctness,
161
+ feedback: e.feedback
162
+ }),
163
+ /* @__PURE__ */ C(E, {
164
+ title: K,
165
+ text: G,
166
+ open: o,
167
+ onCloseText: q,
168
+ onClose: () => this.setState({ showMaxChoiceAlert: !1 })
169
+ })
170
+ ]
171
+ });
172
+ }
173
+ }, B = class extends r.Component {
174
+ static propTypes = {
175
+ model: p.object,
176
+ session: p.shape({ answers: p.arrayOf(p.shape({
177
+ choice: p.string,
178
+ category: p.string
179
+ })) }),
180
+ onAnswersChange: p.func.isRequired,
181
+ onShowCorrectToggle: p.func.isRequired,
182
+ pauseMathObserver: p.func,
183
+ resumeMathObserver: p.func
184
+ };
185
+ constructor(e) {
186
+ super(e), this.uid = S.generateId(), this.state = {
187
+ activeDragItem: null,
188
+ isValidDrop: !1
189
+ };
190
+ }
191
+ onDragStart = (e) => {
192
+ let { active: t } = e, { pauseMathObserver: n } = this.props;
193
+ n && n(), t?.data?.current && this.setState({
194
+ activeDragItem: t.data.current,
195
+ isValidDrop: !1
196
+ });
197
+ };
198
+ onDragEnd = (e) => {
199
+ let { active: t, over: n } = e, { resumeMathObserver: r } = this.props, i = t?.data?.current, a = n?.data?.current, o = n && t && i && i.type === "choice" && a && a.itemType === "categorize";
200
+ if (this.setState({
201
+ activeDragItem: null,
202
+ isValidDrop: o
203
+ }), r && r(), !t || !i || i.type !== "choice") return;
204
+ let s = {
205
+ id: i.id,
206
+ categoryId: i.categoryId,
207
+ choiceIndex: i.choiceIndex,
208
+ value: i.value,
209
+ itemType: i.itemType
210
+ };
211
+ if (!n) {
212
+ this.categorizeRef && this.categorizeRef.removeChoice && i.categoryId && this.categorizeRef.removeChoice(s);
213
+ return;
214
+ }
215
+ if (n.id === "choices-board") {
216
+ this.categorizeRef && this.categorizeRef.removeChoice && i.categoryId && this.categorizeRef.removeChoice(s);
217
+ return;
218
+ }
219
+ this.categorizeRef && this.categorizeRef.dropChoice && this.categorizeRef.dropChoice(n.id, s);
220
+ };
221
+ renderDragOverlay = () => {
222
+ let { activeDragItem: t } = this.state, { model: n } = this.props;
223
+ if (!t) return null;
224
+ if (t.type === "choice") {
225
+ let r = n.choices?.find((e) => e.id === t.id);
226
+ if (r) return /* @__PURE__ */ C(e, {
227
+ id: r.id,
228
+ ...r
229
+ }, r.id);
230
+ }
231
+ return null;
232
+ };
233
+ render() {
234
+ let { isValidDrop: e } = this.state, t = e ? null : void 0;
235
+ return /* @__PURE__ */ C(x, {
236
+ onDragStart: this.onDragStart,
237
+ onDragEnd: this.onDragEnd,
238
+ children: /* @__PURE__ */ w(S.Provider, {
239
+ value: this.uid,
240
+ children: [/* @__PURE__ */ C(z, {
241
+ ref: (e) => this.categorizeRef = e,
242
+ ...this.props
243
+ }), /* @__PURE__ */ C(g, {
244
+ dropAnimation: t,
245
+ children: /* @__PURE__ */ C(R, { children: this.renderDragOverlay() })
246
+ })]
247
+ })
248
+ });
249
+ }
250
+ }, V = h(k)({
251
+ color: u.text(),
252
+ backgroundColor: u.background(),
253
+ position: "relative"
254
+ }), H = h("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), U = h("div")(({ theme: e }) => ({
255
+ marginBottom: e.spacing(1),
256
+ display: "flex",
257
+ flexDirection: "column"
258
+ })), W = h(j)(({ theme: e }) => ({ paddingBottom: e.spacing(2) }));
259
+ //#endregion
260
+ export { B as default };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/index.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export default class Categorize extends HTMLElement {
10
+ constructor();
11
+ _scheduleMathRender: any;
12
+ _initMathObserver(): void;
13
+ _disconnectMathObserver(): void;
14
+ pauseMathObserver: any;
15
+ resumeMathObserver: any;
16
+ set model(m: any);
17
+ isComplete(): any;
18
+ set session(s: any);
19
+ get session(): any;
20
+ eliminateBlindAnswersFromSession(): void;
21
+ changeAnswers(answers: any): void;
22
+ onShowCorrectToggle(): void;
23
+ _createAudioInfoToast(): HTMLDivElement;
24
+ connectedCallback(): void;
25
+ disconnectedCallback(): void;
26
+ render(): void;
27
+ }
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delivery/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAqCH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;;IAQjD,mBAAmB,EAAE,GAAG,CAwBtB;IAEF,iBAAiB;IAcjB,uBAAuB;IAOvB,iBAAiB,EAAE,GAAG,CAKpB;IAEF,kBAAkB,EAAE,GAAG,CAYrB;IAEF,IAAI,KAAK,CAAC,CAAC,KAAA,EASV;IAED,UAAU;IA+DV,IAAI,OAAO,CAAC,CAAC,KAAA,EAOZ;IAED,IAAI,OAAO,QAEV;IAED,gCAAgC;IAiBhC,aAAa,CAAC,OAAO,KAAA;IASrB,mBAAmB;IAInB,qBAAqB;IA2BrB,iBAAiB;IA2FjB,oBAAoB;IAgBpB,MAAM;CAiBP"}
@@ -0,0 +1,152 @@
1
+ import e from "./categorize/index.js";
2
+ import t from "react";
3
+ import { createRoot as n } from "react-dom/client";
4
+ import { renderMath as r } from "@pie-element/shared-math-rendering-mathjax";
5
+ import * as i from "@pie-lib/render-ui";
6
+ import { EnableAudioAutoplayImage as a } from "@pie-lib/render-ui";
7
+ import { ModelSetEvent as o, SessionChangedEvent as s } from "@pie-element/shared-player-events";
8
+ //#region src/delivery/index.ts
9
+ function c(e) {
10
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
11
+ }
12
+ function l(e, t) {
13
+ return !e || c(e) ? e : c(e.default) ? e.default : t && c(e[t]) ? e[t] : t && c(e[t]?.default) ? e[t].default : e;
14
+ }
15
+ var u = l(a, "EnableAudioAutoplayImage") || l(p.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), d = i, f = d.default, p = f && typeof f == "object" ? f : d, m = class extends HTMLElement {
16
+ constructor() {
17
+ super(), this._root = null, this._mathObserver = null, this._mathRenderPending = !1;
18
+ }
19
+ _scheduleMathRender = () => {
20
+ this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
21
+ this._mathObserver && !this._mathObserverPaused && this._mathObserver.disconnect(), r(this), this._mathRenderPending = !1, setTimeout(() => {
22
+ this._mathObserver && !this._mathObserverPaused && this._mathObserver.observe(this, {
23
+ childList: !0,
24
+ subtree: !0,
25
+ characterData: !1
26
+ });
27
+ }, 50);
28
+ }));
29
+ };
30
+ _initMathObserver() {
31
+ this._mathObserver || (this._mathObserver = new MutationObserver(() => {
32
+ this._scheduleMathRender();
33
+ }), this._mathObserver.observe(this, {
34
+ childList: !0,
35
+ subtree: !0,
36
+ characterData: !1
37
+ }));
38
+ }
39
+ _disconnectMathObserver() {
40
+ this._mathObserver &&= (this._mathObserver.disconnect(), null);
41
+ }
42
+ pauseMathObserver = () => {
43
+ this._mathObserver && (this._mathObserver.disconnect(), this._mathObserverPaused = !0);
44
+ };
45
+ resumeMathObserver = () => {
46
+ this._mathObserverPaused && (this._mathObserverPaused = !1, this._mathObserver && this._mathObserver.observe(this, {
47
+ childList: !0,
48
+ subtree: !0,
49
+ characterData: !1
50
+ }));
51
+ };
52
+ set model(e) {
53
+ this._model = e, this.eliminateBlindAnswersFromSession(), this.dispatchEvent(new o(this.tagName.toLowerCase(), this.isComplete(), !!this._model)), this._audioInitialized = !1, this.render();
54
+ }
55
+ isComplete() {
56
+ let { autoplayAudioEnabled: e, choices: t, completeAudioEnabled: n, hasUnplacedChoices: r, possibleResponses: i, responseAreasToBeFilled: a } = this._model || {}, o = this;
57
+ if (e && n && !this.audioComplete && o) {
58
+ let e = o.querySelector("audio"), t = e && e.closest("#preview-prompt");
59
+ if (e && t) return !1;
60
+ }
61
+ if (!this._session || !this._session.answers) return !1;
62
+ let { answers: s } = this._session;
63
+ if (!Array.isArray(s)) return !1;
64
+ let c = s.filter((e) => e.choices.length).length >= a;
65
+ if ((t || []).some((e) => e.categoryCount === 0) || r) return c;
66
+ let l = s.map((e) => e.choices).flat();
67
+ return (i || []).some((e) => e.every((e) => l.includes(e)));
68
+ }
69
+ set session(e) {
70
+ e && !e.answers && (e.answers = []), this._session = e, this.render();
71
+ }
72
+ get session() {
73
+ return this._session;
74
+ }
75
+ eliminateBlindAnswersFromSession() {
76
+ let { answers: e = [] } = this._session || {}, { choices: t = [] } = this._model || {}, n = t.map((e) => e.id) || [], r = e.map((e) => (e.choices = (e?.choices || []).filter((e) => n.includes(e)), e));
77
+ r.length > 0 && this.changeAnswers(r);
78
+ }
79
+ changeAnswers(e) {
80
+ this._session.answers = e, this._session.selector = "Mouse", this.dispatchEvent(new s(this.tagName.toLowerCase(), this.isComplete())), this.render();
81
+ }
82
+ onShowCorrectToggle() {
83
+ r(this);
84
+ }
85
+ _createAudioInfoToast() {
86
+ let e = document.createElement("div");
87
+ e.id = "play-audio-info", Object.assign(e.style, {
88
+ position: "absolute",
89
+ top: 0,
90
+ width: "100%",
91
+ height: "100%",
92
+ display: "flex",
93
+ justifyContent: "center",
94
+ alignItems: "center",
95
+ background: "white",
96
+ zIndex: "1000",
97
+ cursor: "pointer"
98
+ });
99
+ let t = document.createElement("img");
100
+ return t.src = u, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
101
+ }
102
+ connectedCallback() {
103
+ this._initMathObserver(), new MutationObserver((e, t) => {
104
+ e.forEach((e) => {
105
+ if (e.type === "childList") {
106
+ if (this._audioInitialized) return;
107
+ let e = this.querySelector("audio"), n = e && e.closest("#preview-prompt");
108
+ if (!this._model || !this._model.autoplayAudioEnabled || e && !n || !e) return;
109
+ let r = this._createAudioInfoToast(), i = this.querySelector("#main-container"), a = () => {
110
+ this.querySelector("#play-audio-info") && (e.play(), i.removeChild(r)), document.removeEventListener("click", a);
111
+ };
112
+ setTimeout(() => {
113
+ e.paused && !this.querySelector("#play-audio-info") ? (i.appendChild(r), document.addEventListener("click", a)) : document.removeEventListener("click", a);
114
+ }, 500);
115
+ let o = () => {
116
+ this._session.audioStartTime = this._session.audioStartTime || (/* @__PURE__ */ new Date()).getTime();
117
+ let t = this.querySelector("#play-audio-info");
118
+ t && i.removeChild(t), e.removeEventListener("playing", o);
119
+ };
120
+ e.addEventListener("playing", o);
121
+ let c = () => {
122
+ this._session.audioEndTime = this._session.audioEndTime || (/* @__PURE__ */ new Date()).getTime();
123
+ let { audioStartTime: t, audioEndTime: n, waitTime: r } = this._session;
124
+ !r && t && n && (this._session.waitTime = n - t), this.audioComplete = !0, this.dispatchEvent(new s(this.tagName.toLowerCase(), this.isComplete())), e.removeEventListener("ended", c);
125
+ };
126
+ e.addEventListener("ended", c), this._audio = e, this._handlePlaying = o, this._handleEnded = c, this._enableAudio = a, this._audioInitialized = !0, t.disconnect();
127
+ }
128
+ });
129
+ }).observe(this, {
130
+ childList: !0,
131
+ subtree: !0
132
+ });
133
+ }
134
+ disconnectedCallback() {
135
+ this._disconnectMathObserver(), document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), null), this._root && this._root.unmount();
136
+ }
137
+ render() {
138
+ if (this._model && this._session) {
139
+ let r = t.createElement(e, {
140
+ model: this._model,
141
+ session: this._session,
142
+ onAnswersChange: this.changeAnswers.bind(this),
143
+ onShowCorrectToggle: this.onShowCorrectToggle.bind(this),
144
+ pauseMathObserver: this.pauseMathObserver,
145
+ resumeMathObserver: this.resumeMathObserver
146
+ });
147
+ this._root ||= n(this), this._root.render(r);
148
+ }
149
+ }
150
+ };
151
+ //#endregion
152
+ export { m as default };
@@ -0,0 +1,2 @@
1
+ export { default } from './delivery/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * IIFE entry point for categorize element
3
+ * This file is only used for IIFE builds and includes auto-registration
4
+ *
5
+ * @sync-generated - Auto-generated during sync from pie-elements
6
+ */
7
+ import Element from './index.js';
8
+ export default Element;
9
+ //# sourceMappingURL=index.iife.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.iife.d.ts","sourceRoot":"","sources":["../src/index.iife.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,YAAY,CAAC;AAQjC,eAAe,OAAO,CAAC"}