@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,390 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/categorize/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 React from 'react';
12
+ import { createRoot } from 'react-dom/client';
13
+ import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
14
+ import { EnableAudioAutoplayImage as EnableAudioAutoplayImageImport } from '@pie-lib/render-ui';
15
+
16
+ function isRenderableReactInteropType(value: any) {
17
+ return (
18
+ typeof value === 'function' ||
19
+ (typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
20
+ );
21
+ }
22
+
23
+ function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
24
+ if (!maybeSymbol) return maybeSymbol;
25
+ if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
26
+ if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
27
+ if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
28
+ return maybeSymbol[namedExport];
29
+ }
30
+ if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
31
+ return maybeSymbol[namedExport].default;
32
+ }
33
+ return maybeSymbol;
34
+ }
35
+ const EnableAudioAutoplayImage = unwrapReactInteropSymbol(EnableAudioAutoplayImageImport, 'EnableAudioAutoplayImage') || unwrapReactInteropSymbol(renderUi.EnableAudioAutoplayImage, 'EnableAudioAutoplayImage');
36
+ import * as RenderUiNamespace from '@pie-lib/render-ui';
37
+ const renderUiNamespaceAny = RenderUiNamespace as any;
38
+ const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
39
+ const renderUi =
40
+ renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
41
+ ? renderUiDefaultMaybe
42
+ : renderUiNamespaceAny;
43
+ import { SessionChangedEvent, ModelSetEvent } from '@pie-element/shared-player-events';
44
+ import CategorizeComponent from './categorize/index.js';
45
+
46
+ export default class Categorize extends HTMLElement {
47
+ constructor() {
48
+ super();
49
+ this._root = null;
50
+ this._mathObserver = null;
51
+ this._mathRenderPending = false;
52
+ }
53
+
54
+ _scheduleMathRender: any = () => {
55
+ if (this._mathRenderPending) return;
56
+
57
+ this._mathRenderPending = true;
58
+
59
+ requestAnimationFrame(() => {
60
+ if (this._mathObserver && !this._mathObserverPaused) {
61
+ this._mathObserver.disconnect();
62
+ }
63
+
64
+ renderMath(this);
65
+
66
+ this._mathRenderPending = false;
67
+
68
+ setTimeout(() => {
69
+ if (this._mathObserver && !this._mathObserverPaused) {
70
+ this._mathObserver.observe(this, {
71
+ childList: true,
72
+ subtree: true,
73
+ characterData: false,
74
+ });
75
+ }
76
+ }, 50);
77
+ });
78
+ };
79
+
80
+ _initMathObserver() {
81
+ if (this._mathObserver) return;
82
+
83
+ this._mathObserver = new MutationObserver(() => {
84
+ this._scheduleMathRender();
85
+ });
86
+
87
+ this._mathObserver.observe(this, {
88
+ childList: true,
89
+ subtree: true,
90
+ characterData: false,
91
+ });
92
+ }
93
+
94
+ _disconnectMathObserver() {
95
+ if (this._mathObserver) {
96
+ this._mathObserver.disconnect();
97
+ this._mathObserver = null;
98
+ }
99
+ }
100
+
101
+ pauseMathObserver: any = () => {
102
+ if (this._mathObserver) {
103
+ this._mathObserver.disconnect();
104
+ this._mathObserverPaused = true;
105
+ }
106
+ };
107
+
108
+ resumeMathObserver: any = () => {
109
+ if (this._mathObserverPaused) {
110
+ this._mathObserverPaused = false;
111
+
112
+ if (this._mathObserver) {
113
+ this._mathObserver.observe(this, {
114
+ childList: true,
115
+ subtree: true,
116
+ characterData: false,
117
+ });
118
+ }
119
+ }
120
+ };
121
+
122
+ set model(m) {
123
+ this._model = m;
124
+
125
+ this.eliminateBlindAnswersFromSession();
126
+ this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
127
+ // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio
128
+ this._audioInitialized = false;
129
+
130
+ this.render();
131
+ }
132
+
133
+ isComplete() {
134
+ const {
135
+ autoplayAudioEnabled,
136
+ choices,
137
+ completeAudioEnabled,
138
+ hasUnplacedChoices,
139
+ possibleResponses,
140
+ responseAreasToBeFilled,
141
+ } = this._model || {};
142
+ const elementContext = this;
143
+
144
+ // check audio completion if audio settings are enabled and audio actually exists
145
+ if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
146
+ if (elementContext) {
147
+ const audio = elementContext.querySelector('audio');
148
+ const isInsidePrompt = audio && audio.closest('#preview-prompt');
149
+
150
+ // only require audio completion if audio exists and is inside the prompt
151
+ if (audio && isInsidePrompt) {
152
+ return false;
153
+ }
154
+ }
155
+ }
156
+
157
+ if (!this._session || !this._session.answers) {
158
+ return false;
159
+ }
160
+
161
+ const { answers } = this._session;
162
+
163
+ if (!Array.isArray(answers)) {
164
+ return false;
165
+ }
166
+
167
+ // filter answers by category and count the ones with content
168
+ const filledResponseAreas = answers.filter((answer) => answer.choices.length).length;
169
+ // check if an answer choice was added to at least as many response areas
170
+ // as the number of populated response areas in the correct answer
171
+ const areResponseAreasFilled = filledResponseAreas >= responseAreasToBeFilled;
172
+ // check if multiple placements are allowed
173
+ const duplicatesAllowed = (choices || []).some((choice) => choice.categoryCount === 0);
174
+
175
+ if (duplicatesAllowed) {
176
+ // an answer choice can be used multiple times
177
+ return areResponseAreasFilled;
178
+ }
179
+
180
+ // any correct answer have any unplaced answer choices (by the author)
181
+ if (hasUnplacedChoices) {
182
+ return areResponseAreasFilled;
183
+ }
184
+
185
+ const allAnswersIds = answers.map((answer) => answer.choices).flat();
186
+
187
+ // check if any correct answer have any unplaced answer choices (by the student)
188
+ const requiredAnswersPlaced = (possibleResponses || []).some((response) =>
189
+ response.every((val) => allAnswersIds.includes(val)),
190
+ );
191
+
192
+ // true - all choices (required for a correct response) were placed into a response area
193
+ return requiredAnswersPlaced;
194
+ }
195
+
196
+ set session(s) {
197
+ if (s && !s.answers) {
198
+ s.answers = [];
199
+ }
200
+
201
+ this._session = s;
202
+ this.render();
203
+ }
204
+
205
+ get session() {
206
+ return this._session;
207
+ }
208
+
209
+ eliminateBlindAnswersFromSession() {
210
+ const { answers = [] } = this._session || {};
211
+ const { choices = [] } = this._model || {};
212
+
213
+ const mappedChoices = choices.map((c) => c.id) || [];
214
+ const filteredAnswers = answers.map((answer) => {
215
+ const answerChoices = answer?.choices || [];
216
+ answer.choices = answerChoices.filter((c) => mappedChoices.includes(c));
217
+
218
+ return answer;
219
+ });
220
+
221
+ if (filteredAnswers.length > 0) {
222
+ this.changeAnswers(filteredAnswers);
223
+ }
224
+ }
225
+
226
+ changeAnswers(answers) {
227
+ this._session.answers = answers;
228
+ this._session.selector = 'Mouse';
229
+
230
+ this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
231
+
232
+ this.render();
233
+ }
234
+
235
+ onShowCorrectToggle() {
236
+ renderMath(this);
237
+ }
238
+
239
+ _createAudioInfoToast() {
240
+ const info = document.createElement('div');
241
+ info.id = 'play-audio-info';
242
+
243
+ Object.assign(info.style, {
244
+ position: 'absolute',
245
+ top: 0,
246
+ width: '100%',
247
+ height: '100%',
248
+ display: 'flex',
249
+ justifyContent: 'center',
250
+ alignItems: 'center',
251
+ background: 'white',
252
+ zIndex: '1000',
253
+ cursor: 'pointer',
254
+ });
255
+
256
+ const img = document.createElement('img');
257
+ img.src = EnableAudioAutoplayImage;
258
+ img.alt = 'Click anywhere to enable audio autoplay';
259
+ img.width = 500;
260
+ img.height = 300;
261
+
262
+ info.appendChild(img);
263
+ return info;
264
+ }
265
+
266
+ connectedCallback() {
267
+ this._initMathObserver();
268
+
269
+ // Observation: audio in Chrome will have the autoplay attribute,
270
+ // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
271
+ // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
272
+ const observer = new MutationObserver((mutationsList, observer) => {
273
+ mutationsList.forEach((mutation) => {
274
+ if (mutation.type === 'childList') {
275
+ if (this._audioInitialized) return;
276
+ const audio = this.querySelector('audio');
277
+ const isInsidePrompt = audio && audio.closest('#preview-prompt');
278
+
279
+ if (!this._model) return;
280
+ if (!this._model.autoplayAudioEnabled) return;
281
+ if (audio && !isInsidePrompt) return;
282
+ if (!audio) return;
283
+
284
+ const info = this._createAudioInfoToast();
285
+ const container = this.querySelector('#main-container');
286
+ const enableAudio = () => {
287
+ if (this.querySelector('#play-audio-info')) {
288
+ audio.play();
289
+ container.removeChild(info);
290
+ }
291
+
292
+ document.removeEventListener('click', enableAudio);
293
+ };
294
+
295
+ // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
296
+ // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
297
+ setTimeout(() => {
298
+ if (audio.paused && !this.querySelector('#play-audio-info')) {
299
+ // add info message as a toast to enable audio playback
300
+ container.appendChild(info);
301
+ document.addEventListener('click', enableAudio);
302
+ } else {
303
+ document.removeEventListener('click', enableAudio);
304
+ }
305
+ }, 500);
306
+
307
+ // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
308
+ const handlePlaying = () => {
309
+ //timestamp when auto-played audio started playing
310
+ this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();
311
+
312
+ const info = this.querySelector('#play-audio-info');
313
+ if (info) {
314
+ container.removeChild(info);
315
+ }
316
+
317
+ audio.removeEventListener('playing', handlePlaying);
318
+ };
319
+
320
+ audio.addEventListener('playing', handlePlaying);
321
+
322
+ // we need to listen for the ended event to update the isComplete state
323
+ const handleEnded = () => {
324
+ //timestamp when auto-played audio completed playing
325
+ this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();
326
+
327
+ let { audioStartTime, audioEndTime, waitTime } = this._session;
328
+ if (!waitTime && audioStartTime && audioEndTime) {
329
+ // waitTime is elapsed time the user waited for auto-played audio to finish
330
+ this._session.waitTime = audioEndTime - audioStartTime;
331
+ }
332
+
333
+ this.audioComplete = true;
334
+ this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
335
+
336
+ audio.removeEventListener('ended', handleEnded);
337
+ };
338
+
339
+ audio.addEventListener('ended', handleEnded);
340
+
341
+ // store references to remove later
342
+ this._audio = audio;
343
+ this._handlePlaying = handlePlaying;
344
+ this._handleEnded = handleEnded;
345
+ this._enableAudio = enableAudio;
346
+ // set to true to prevent multiple initializations
347
+ this._audioInitialized = true;
348
+
349
+ observer.disconnect();
350
+ }
351
+ });
352
+ });
353
+
354
+ observer.observe(this, { childList: true, subtree: true });
355
+ }
356
+
357
+ disconnectedCallback() {
358
+ this._disconnectMathObserver();
359
+
360
+ document.removeEventListener('click', this._enableAudio);
361
+
362
+ if (this._audio) {
363
+ this._audio.removeEventListener('playing', this._handlePlaying);
364
+ this._audio.removeEventListener('ended', this._handleEnded);
365
+ this._audio = null;
366
+ }
367
+
368
+ if (this._root) {
369
+ this._root.unmount();
370
+ }
371
+ }
372
+
373
+ render() {
374
+ if (this._model && this._session) {
375
+ const el = React.createElement(CategorizeComponent, {
376
+ model: this._model,
377
+ session: this._session,
378
+ onAnswersChange: this.changeAnswers.bind(this),
379
+ onShowCorrectToggle: this.onShowCorrectToggle.bind(this),
380
+ pauseMathObserver: this.pauseMathObserver,
381
+ resumeMathObserver: this.resumeMathObserver,
382
+ });
383
+
384
+ if (!this._root) {
385
+ this._root = createRoot(this);
386
+ }
387
+ this._root.render(el);
388
+ }
389
+ }
390
+ }
@@ -0,0 +1,16 @@
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
+
8
+ import Element from './index.js';
9
+
10
+ // Auto-register the custom element for IIFE mode
11
+ if (typeof window !== 'undefined' && !customElements.get('categorize-element')) {
12
+ customElements.define('categorize-element', Element);
13
+ }
14
+
15
+ // Export for IIFE global
16
+ export default Element;
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './delivery/index.js';