@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,161 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/categorize/configure/src/design/categories/category.jsx
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 PropTypes from 'prop-types';
13
+ import { styled } from '@mui/material/styles';
14
+ import Card from '@mui/material/Card';
15
+ import CardActions from '@mui/material/CardActions';
16
+
17
+ import InputHeader from '../input-header.js';
18
+ import { DeleteButton } from '../buttons.js';
19
+ import PlaceHolder from './droppable-placeholder.js';
20
+
21
+ const StyledCard: any = styled(Card, {
22
+ shouldForwardProp: (prop) => prop !== 'isDuplicated',
23
+ })(({ theme, isDuplicated }) => ({
24
+ minWidth: '196px',
25
+ padding: theme.spacing(1),
26
+ overflow: 'visible',
27
+ ...(isDuplicated && {
28
+ border: '1px solid red',
29
+ }),
30
+ }));
31
+
32
+ const StyledCardActions: any = styled(CardActions)(({ theme }) => ({
33
+ padding: 0,
34
+ paddingBottom: 0,
35
+ paddingTop: theme.spacing(1),
36
+ }));
37
+
38
+ const CategoryHeader: any = styled('div')(({ theme }) => ({
39
+ padding: theme.spacing(2),
40
+ '& p': {
41
+ margin: 0,
42
+ },
43
+ }));
44
+
45
+ const ErrorText: any = styled('div')(({ theme }) => ({
46
+ fontSize: theme.typography.fontSize - 2,
47
+ color: theme.palette.error.main,
48
+ paddingBottom: theme.spacing(1),
49
+ }));
50
+
51
+ export class Category extends React.Component {
52
+ static propTypes = {
53
+ alternateResponseIndex: PropTypes.number,
54
+ category: PropTypes.object.isRequired,
55
+ configuration: PropTypes.object.isRequired,
56
+ defaultImageMaxHeight: PropTypes.number,
57
+ defaultImageMaxWidth: PropTypes.number,
58
+ deleteFocusedEl: PropTypes.func,
59
+ focusedEl: PropTypes.number,
60
+ index: PropTypes.number,
61
+ error: PropTypes.string,
62
+ isDuplicated: PropTypes.bool,
63
+ maxImageWidth: PropTypes.object,
64
+ maxImageHeight: PropTypes.object,
65
+ onChange: PropTypes.func,
66
+ onDelete: PropTypes.func,
67
+ onDeleteChoice: PropTypes.func,
68
+ imageSupport: PropTypes.shape({
69
+ add: PropTypes.func.isRequired,
70
+ delete: PropTypes.func.isRequired,
71
+ }),
72
+ toolbarOpts: PropTypes.object,
73
+ spellCheck: PropTypes.bool,
74
+ uploadSoundSupport: PropTypes.shape({
75
+ add: PropTypes.func.isRequired,
76
+ delete: PropTypes.func.isRequired,
77
+ }),
78
+ isAlternate: PropTypes.bool,
79
+ };
80
+
81
+ static defaultProps = {};
82
+
83
+ changeLabel: any = (l) => {
84
+ const { category, onChange } = this.props;
85
+ category.label = l;
86
+ onChange(category);
87
+ };
88
+
89
+ render() {
90
+ const {
91
+ alternateResponseIndex,
92
+ category,
93
+ configuration,
94
+ deleteFocusedEl,
95
+ focusedEl,
96
+ index,
97
+ error,
98
+ isDuplicated,
99
+ onDelete,
100
+ onDeleteChoice,
101
+ imageSupport,
102
+ spellCheck,
103
+ toolbarOpts,
104
+ maxImageWidth,
105
+ maxImageHeight,
106
+ uploadSoundSupport,
107
+ mathMlOptions = {},
108
+ } = this.props;
109
+ const isCategoryHeaderDisabled = !!alternateResponseIndex || alternateResponseIndex === 0;
110
+
111
+ return (
112
+ <StyledCard isDuplicated={isDuplicated}>
113
+ <span>
114
+ {!isCategoryHeaderDisabled ? (
115
+ <InputHeader
116
+ label={category.label}
117
+ focusedEl={focusedEl}
118
+ deleteFocusedEl={deleteFocusedEl}
119
+ index={index}
120
+ disabled={!!alternateResponseIndex || alternateResponseIndex === 0}
121
+ error={error}
122
+ onChange={this.changeLabel}
123
+ onDelete={onDelete}
124
+ imageSupport={imageSupport}
125
+ toolbarOpts={toolbarOpts}
126
+ spellCheck={spellCheck}
127
+ maxImageWidth={maxImageWidth}
128
+ maxImageHeight={maxImageHeight}
129
+ uploadSoundSupport={uploadSoundSupport}
130
+ mathMlOptions={mathMlOptions}
131
+ configuration={configuration}
132
+ />
133
+ ) : (
134
+ <CategoryHeader
135
+ dangerouslySetInnerHTML={{
136
+ __html: category.label,
137
+ }}
138
+ />
139
+ )}
140
+ {error && <ErrorText>{error}</ErrorText>}
141
+ </span>
142
+ <PlaceHolder
143
+ alternateResponseIndex={alternateResponseIndex}
144
+ category={category}
145
+ choices={category.choices}
146
+ onDeleteChoice={onDeleteChoice}
147
+ categoryId={category.id}
148
+ extraStyles={{ minHeight: '100px', }}
149
+ isAlternate={this.props.isAlternate}
150
+ />
151
+ {onDelete && (
152
+ <StyledCardActions>
153
+ <DeleteButton label={'delete'} onClick={onDelete} />
154
+ </StyledCardActions>
155
+ )}
156
+ </StyledCard>
157
+ );
158
+ }
159
+ }
160
+
161
+ export default Category;
@@ -0,0 +1,112 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/categorize/configure/src/design/categories/choice-preview.jsx
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 PropTypes from 'prop-types';
13
+ import { styled } from '@mui/material/styles';
14
+ import { DraggableChoice } from '@pie-lib/drag';
15
+ import IconButton from '@mui/material/IconButton';
16
+ import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
17
+ import { HtmlAndMath as HtmlAndMathImport } from '@pie-lib/render-ui';
18
+
19
+ function isRenderableReactInteropType(value: any) {
20
+ return (
21
+ typeof value === 'function' ||
22
+ (typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
23
+ );
24
+ }
25
+
26
+ function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
27
+ if (!maybeSymbol) return maybeSymbol;
28
+ if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
29
+ if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
30
+ if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
31
+ return maybeSymbol[namedExport];
32
+ }
33
+ if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
34
+ return maybeSymbol[namedExport].default;
35
+ }
36
+ return maybeSymbol;
37
+ }
38
+ const HtmlAndMath = unwrapReactInteropSymbol(HtmlAndMathImport, 'HtmlAndMath') || unwrapReactInteropSymbol(renderUi.HtmlAndMath, 'HtmlAndMath');
39
+ import * as RenderUiNamespace from '@pie-lib/render-ui';
40
+ const renderUiNamespaceAny = RenderUiNamespace as any;
41
+ const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
42
+ const renderUi =
43
+ renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
44
+ ? renderUiDefaultMaybe
45
+ : renderUiNamespaceAny;
46
+ import { color } from '@pie-lib/render-ui';
47
+
48
+ const ChoicePreviewContainer: any = styled('div')({
49
+ position: 'relative',
50
+ overflow: 'auto',
51
+ touchAction: 'none',
52
+ });
53
+
54
+ const DeleteIconButton: any = styled(IconButton)({
55
+ position: 'absolute',
56
+ right: 0,
57
+ top: 0,
58
+ color: `${color.tertiary()} !important`,
59
+ });
60
+
61
+ export class ChoicePreview extends React.Component {
62
+ static propTypes = {
63
+ alternateResponseIndex: PropTypes.number,
64
+ category: PropTypes.object,
65
+ choice: PropTypes.object.isRequired,
66
+ choiceIndex: PropTypes.number,
67
+ onDelete: PropTypes.func,
68
+ };
69
+ static defaultProps = {
70
+ onDelete: () => {},
71
+ };
72
+
73
+ delete: any = () => {
74
+ const { onDelete, choice } = this.props;
75
+ onDelete(choice);
76
+ };
77
+
78
+ render() {
79
+ const { alternateResponseIndex, category, choice, choiceIndex } = this.props;
80
+
81
+ // Generate unique ID for each instance to distinguish multiple instances of the same choice
82
+ const categoryId = category && category.id;
83
+ const uniqueId =
84
+ alternateResponseIndex !== undefined
85
+ ? `${choice.id}-${categoryId}-${choiceIndex}-alt-${alternateResponseIndex}`
86
+ : `${choice.id}-${categoryId}-${choiceIndex}`;
87
+
88
+ return (
89
+ <ChoicePreviewContainer>
90
+ {choice ? (
91
+ <DraggableChoice
92
+ alternateResponseIndex={alternateResponseIndex}
93
+ category={category}
94
+ choice={choice}
95
+ choiceIndex={choiceIndex}
96
+ onRemoveChoice={this.delete}
97
+ type={'choice-preview'}
98
+ id={uniqueId}
99
+ categoryId={categoryId}
100
+ >
101
+ <HtmlAndMath html={choice?.content} />
102
+ </DraggableChoice>
103
+ ) : null}
104
+ <DeleteIconButton aria-label="delete" onClick={this.delete} size="large">
105
+ <RemoveCircleOutlineIcon />
106
+ </DeleteIconButton>
107
+ </ChoicePreviewContainer>
108
+ );
109
+ }
110
+ }
111
+
112
+ export default ChoicePreview;
@@ -0,0 +1,114 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/categorize/configure/src/design/categories/droppable-placeholder.jsx
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 PropTypes from 'prop-types';
13
+ import { styled } from '@mui/material/styles';
14
+ import ChoicePreview from './choice-preview.js';
15
+ import { useDroppable } from '@dnd-kit/core';
16
+ import { uid, PlaceHolder } from '@pie-lib/drag';
17
+ import debug from 'debug';
18
+
19
+ const log = debug('@pie-element:categorize:configure');
20
+
21
+ const HelperText: any = styled('div')(({ theme }) => ({
22
+ display: 'flex',
23
+ alignItems: 'center',
24
+ fontSize: theme.typography.fontSize - 2,
25
+ color: `rgba(${theme.palette.common.black}, 0.4)`,
26
+ width: '100%',
27
+ height: '100%',
28
+ }));
29
+
30
+ const Helper = () => <HelperText>Drag your correct answers here</HelperText>;
31
+
32
+ const DroppablePlaceholderContainer: any = styled('div')({
33
+ minHeight: '100px',
34
+ });
35
+
36
+ const Previews = ({ alternateResponseIndex, category, choices, onDeleteChoice }) => (
37
+ <React.Fragment>
38
+ {(choices || []).map((c, index) =>
39
+ c && (
40
+ <ChoicePreview
41
+ alternateResponseIndex={alternateResponseIndex}
42
+ category={category}
43
+ choice={c}
44
+ key={index}
45
+ choiceIndex={index}
46
+ onDelete={(choice) => onDeleteChoice(choice, index)}
47
+ />
48
+ )
49
+ )}
50
+ </React.Fragment>
51
+ );
52
+
53
+ Previews.propTypes = {
54
+ alternateResponseIndex: PropTypes.number,
55
+ category: PropTypes.object,
56
+ choices: PropTypes.array,
57
+ onDeleteChoice: PropTypes.func,
58
+ };
59
+
60
+ const DroppablePlaceHolder = ({
61
+ alternateResponseIndex,
62
+ category,
63
+ choices,
64
+ onDeleteChoice,
65
+ categoryId,
66
+ isAlternate
67
+ }) => {
68
+ const { setNodeRef, isOver } = useDroppable({
69
+ id: `${categoryId}-${isAlternate ? 'alternate' : 'standard'}`,
70
+ data: {
71
+ accepts: ['choice', 'choice-preview'],
72
+ alternateResponseIndex,
73
+ categoryId,
74
+ type: isAlternate ? 'category-alternate' : 'category',
75
+ id: categoryId,
76
+ },
77
+ });
78
+
79
+ return (
80
+ <div ref={setNodeRef}>
81
+ <DroppablePlaceholderContainer>
82
+ <PlaceHolder
83
+ isOver={isOver}
84
+ extraStyles={{
85
+ width: '100%',
86
+ minHeight: '100px',
87
+ height: 'auto',
88
+ }}>
89
+ {(choices || []).length === 0 ? (
90
+ <Helper />
91
+ ) : (
92
+ <Previews
93
+ alternateResponseIndex={alternateResponseIndex}
94
+ category={category}
95
+ choices={choices}
96
+ onDeleteChoice={onDeleteChoice}
97
+ />
98
+ )}
99
+ </PlaceHolder>
100
+ </DroppablePlaceholderContainer>
101
+ </div>
102
+ );
103
+ };
104
+
105
+ DroppablePlaceHolder.propTypes = {
106
+ alternateResponseIndex: PropTypes.number,
107
+ category: PropTypes.object,
108
+ choices: PropTypes.array,
109
+ onDeleteChoice: PropTypes.func,
110
+ categoryId: PropTypes.string.isRequired,
111
+ isAlternate: PropTypes.bool,
112
+ };
113
+
114
+ export default uid.withUid(DroppablePlaceHolder);
@@ -0,0 +1,254 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/categorize/configure/src/design/categories/index.jsx
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 PropTypes from 'prop-types';
13
+ import { styled } from '@mui/material/styles';
14
+ import { choiceUtils as utils } from '@pie-lib/config-ui';
15
+ import Info from '@mui/icons-material/Info';
16
+ import Tooltip from '@mui/material/Tooltip';
17
+ import {
18
+ removeCategory,
19
+ removeChoiceFromCategory,
20
+ } from '@pie-lib/categorize';
21
+
22
+ import Category from './category.js';
23
+ import Header from '../header.js';
24
+ import { generateValidationMessage } from '../../utils.js';
25
+ import { RowLabel } from './RowLabel.js';
26
+
27
+ const CategoriesContainer: any = styled('div')(({ theme }) => ({
28
+ marginBottom: theme.spacing(3),
29
+ }));
30
+
31
+ const CategoriesHolder: any = styled('div')(({ theme }) => ({
32
+ display: 'grid',
33
+ gridRowGap: `${theme.spacing(1)}px`,
34
+ gridColumnGap: `${theme.spacing(1)}px`,
35
+ }));
36
+
37
+ const StyledTooltip: any = styled(Tooltip)(({ theme }) => ({
38
+ '& .MuiTooltip-tooltip': {
39
+ fontSize: theme.typography.fontSize - 2,
40
+ whiteSpace: 'pre',
41
+ maxWidth: '500px',
42
+ },
43
+ }));
44
+
45
+ const ErrorText: any = styled('div')(({ theme }) => ({
46
+ fontSize: theme.typography.fontSize - 2,
47
+ color: theme.palette.error.main,
48
+ paddingTop: theme.spacing(0.5),
49
+ }));
50
+
51
+ export class Categories extends React.Component {
52
+ static propTypes = {
53
+ defaultImageMaxHeight: PropTypes.number,
54
+ defaultImageMaxWidth: PropTypes.number,
55
+ imageSupport: PropTypes.shape({
56
+ add: PropTypes.func.isRequired,
57
+ delete: PropTypes.func.isRequired,
58
+ }),
59
+ uploadSoundSupport: PropTypes.shape({
60
+ add: PropTypes.func.isRequired,
61
+ delete: PropTypes.func.isRequired,
62
+ }),
63
+ categories: PropTypes.array,
64
+ onModelChanged: PropTypes.func,
65
+ model: PropTypes.object.isRequired,
66
+ configuration: PropTypes.object.isRequired,
67
+ toolbarOpts: PropTypes.object,
68
+ spellCheck: PropTypes.bool,
69
+ };
70
+
71
+ state = {
72
+ focusedEl: null,
73
+ };
74
+
75
+ add: any = () => {
76
+ const { model, categories: oldCategories } = this.props;
77
+ const { categoriesPerRow, correctResponse, allowAlternateEnabled } = model;
78
+
79
+ const id = utils.firstAvailableIndex(
80
+ model.categories.map((a) => a.id),
81
+ 1,
82
+ );
83
+ const data = { id, label: 'Category ' + id };
84
+ const addRowLabel = model.categories.length % categoriesPerRow === 0;
85
+ const rowLabels = [...model.rowLabels];
86
+
87
+ if (addRowLabel) {
88
+ rowLabels.push('');
89
+ }
90
+
91
+ this.setState(
92
+ {
93
+ focusedEl: oldCategories.length,
94
+ },
95
+ () => {
96
+ this.props.onModelChanged({
97
+ rowLabels,
98
+ categories: model.categories.concat([data]),
99
+ correctResponse: allowAlternateEnabled
100
+ ? [...correctResponse, { category: id, choices: [], alternateResponses: [] }]
101
+ : correctResponse,
102
+ });
103
+ },
104
+ );
105
+ };
106
+
107
+ deleteFocusedEl: any = () => {
108
+ this.setState({
109
+ focusedEl: null,
110
+ });
111
+ };
112
+
113
+ delete: any = (category) => {
114
+ const { model, onModelChanged } = this.props;
115
+ const index = model.categories.findIndex((a) => a.id === category.id);
116
+
117
+ if (index !== -1) {
118
+ model.categories.splice(index, 1);
119
+ model.correctResponse = removeCategory(category.id, model.correctResponse);
120
+ onModelChanged(model);
121
+ }
122
+ };
123
+
124
+ change: any = (c) => {
125
+ const { categories } = this.props;
126
+ const index = categories.findIndex((a) => a.id === c.id);
127
+
128
+ if (index !== -1) {
129
+ categories.splice(index, 1, c);
130
+ this.props.onModelChanged({ categories });
131
+ }
132
+ };
133
+
134
+ deleteChoiceFromCategory: any = (category, choice, choiceIndex) => {
135
+ const { model, onModelChanged } = this.props;
136
+ const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);
137
+
138
+ onModelChanged({ correctResponse });
139
+ };
140
+
141
+ changeRowLabel: any = (val, index) => {
142
+ const { model } = this.props;
143
+ const { rowLabels } = model;
144
+ const newRowLabels = [...rowLabels];
145
+
146
+ if (newRowLabels.length < index) {
147
+ newRowLabels.push(val);
148
+ } else {
149
+ newRowLabels[index] = val;
150
+ }
151
+
152
+ this.props.onModelChanged({
153
+ rowLabels: newRowLabels,
154
+ });
155
+ };
156
+
157
+ render() {
158
+ const {
159
+ model,
160
+ categories,
161
+ imageSupport,
162
+ uploadSoundSupport,
163
+ toolbarOpts,
164
+ spellCheck,
165
+ configuration,
166
+ defaultImageMaxHeight,
167
+ defaultImageMaxWidth,
168
+ mathMlOptions = {},
169
+ } = this.props;
170
+
171
+ const { categoriesPerRow, rowLabels, errors } = model;
172
+ const { associationError, categoriesError, categoriesErrors } = errors || {};
173
+ const { maxCategories, maxImageWidth = {}, maxImageHeight = {} } = configuration || {};
174
+ const holderStyle = {
175
+ gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`,
176
+ };
177
+
178
+ const validationMessage = generateValidationMessage(configuration);
179
+
180
+ return (
181
+ <CategoriesContainer>
182
+ <Header
183
+ label="Categories"
184
+ buttonLabel="ADD A CATEGORY"
185
+ onAdd={this.add}
186
+ info={
187
+ <StyledTooltip
188
+ disableFocusListener
189
+ disableTouchListener
190
+ placement={'right'}
191
+ title={validationMessage}
192
+ >
193
+ <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />
194
+ </StyledTooltip>
195
+ }
196
+ buttonDisabled={maxCategories && categories && maxCategories === categories.length}
197
+ />
198
+
199
+ <CategoriesHolder style={holderStyle}>
200
+ {categories.map((category, index) => {
201
+ const hasRowLabel = index % categoriesPerRow === 0;
202
+ const rowIndex = index / categoriesPerRow;
203
+
204
+ return (
205
+ <React.Fragment key={index}>
206
+ {hasRowLabel && (
207
+ <RowLabel
208
+ categoriesPerRow={categoriesPerRow}
209
+ disabled={false}
210
+ rowIndex={rowIndex}
211
+ markup={rowLabels[rowIndex] || ''}
212
+ onChange={(val) => this.changeRowLabel(val, rowIndex)}
213
+ imageSupport={imageSupport}
214
+ toolbarOpts={toolbarOpts}
215
+ spellCheck={spellCheck}
216
+ maxImageWidth={(maxImageWidth && maxImageWidth.rowLabel) || defaultImageMaxWidth}
217
+ maxImageHeight={(maxImageHeight && maxImageHeight.rowLabel) || defaultImageMaxHeight}
218
+ uploadSoundSupport={uploadSoundSupport}
219
+ mathMlOptions={mathMlOptions}
220
+ configuration={configuration}
221
+ />
222
+ )}
223
+
224
+ <Category
225
+ imageSupport={imageSupport}
226
+ focusedEl={this.state.focusedEl}
227
+ deleteFocusedEl={this.deleteFocusedEl}
228
+ index={index}
229
+ category={category}
230
+ error={categoriesErrors && categoriesErrors[category.id]}
231
+ onChange={this.change}
232
+ onDelete={() => this.delete(category)}
233
+ toolbarOpts={toolbarOpts}
234
+ spellCheck={spellCheck}
235
+ onDeleteChoice={(choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex)}
236
+ maxImageWidth={(maxImageWidth && maxImageWidth.categoryLabel) || defaultImageMaxWidth}
237
+ maxImageHeight={(maxImageHeight && maxImageHeight.categoryLabel) || defaultImageMaxHeight}
238
+ uploadSoundSupport={uploadSoundSupport}
239
+ configuration={configuration}
240
+ alternateResponseIndex={undefined}
241
+ />
242
+ </React.Fragment>
243
+ );
244
+ })}
245
+ </CategoriesHolder>
246
+
247
+ {associationError && <ErrorText>{associationError}</ErrorText>}
248
+ {categoriesError && <ErrorText>{categoriesError}</ErrorText>}
249
+ </CategoriesContainer>
250
+ );
251
+ }
252
+ }
253
+
254
+ export default Categories;