@pie-element/fraction-model 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 (166) hide show
  1. package/dist/author/card-bar.d.ts +21 -0
  2. package/dist/author/card-bar.d.ts.map +1 -0
  3. package/dist/author/card-bar.js +40 -0
  4. package/dist/author/defaults.d.ts +114 -0
  5. package/dist/author/defaults.d.ts.map +1 -0
  6. package/dist/author/defaults.js +84 -0
  7. package/dist/author/index.d.ts +45 -0
  8. package/dist/author/index.d.ts.map +1 -0
  9. package/dist/author/index.js +88 -0
  10. package/dist/author/main.d.ts +26 -0
  11. package/dist/author/main.d.ts.map +1 -0
  12. package/dist/author/main.js +156 -0
  13. package/dist/author/model-options.d.ts +33 -0
  14. package/dist/author/model-options.d.ts.map +1 -0
  15. package/dist/author/model-options.js +85 -0
  16. package/dist/author/number-text-field.d.ts +16 -0
  17. package/dist/author/number-text-field.d.ts.map +1 -0
  18. package/dist/author/number-text-field.js +20 -0
  19. package/dist/controller/defaults.d.ts +22 -0
  20. package/dist/controller/defaults.d.ts.map +1 -0
  21. package/dist/controller/defaults.js +13 -0
  22. package/dist/controller/index.d.ts +24 -0
  23. package/dist/controller/index.d.ts.map +1 -0
  24. package/dist/controller/index.js +68 -0
  25. package/dist/delivery/answer-fraction.d.ts +28 -0
  26. package/dist/delivery/answer-fraction.d.ts.map +1 -0
  27. package/dist/delivery/answer-fraction.js +69 -0
  28. package/dist/delivery/fraction-model-chart.d.ts +12 -0
  29. package/dist/delivery/fraction-model-chart.d.ts.map +1 -0
  30. package/dist/delivery/fraction-model-chart.js +154 -0
  31. package/dist/delivery/index.d.ts +23 -0
  32. package/dist/delivery/index.d.ts.map +1 -0
  33. package/dist/delivery/index.js +54 -0
  34. package/dist/delivery/main.d.ts +39 -0
  35. package/dist/delivery/main.d.ts.map +1 -0
  36. package/dist/delivery/main.js +136 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.iife.d.ts +9 -0
  40. package/dist/index.iife.d.ts.map +1 -0
  41. package/dist/index.iife.js +179 -0
  42. package/dist/index.js +2 -0
  43. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
  44. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
  45. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
  46. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
  47. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
  48. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
  49. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
  50. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
  51. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
  52. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
  53. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
  54. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
  55. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
  56. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  57. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
  58. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
  59. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
  60. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
  61. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
  62. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
  63. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
  64. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
  65. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  66. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
  67. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
  68. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
  69. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
  70. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
  71. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  72. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
  73. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
  74. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
  75. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
  76. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  77. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
  78. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
  79. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
  80. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
  81. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  82. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
  83. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
  84. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
  85. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  86. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
  87. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
  88. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
  89. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
  90. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  91. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
  92. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
  93. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
  94. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
  95. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
  96. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  97. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
  98. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
  99. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
  100. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
  101. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
  102. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
  103. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
  104. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
  105. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
  106. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
  107. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
  108. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
  109. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
  110. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
  111. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
  112. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
  113. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
  114. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
  115. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
  116. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
  117. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  118. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
  119. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
  120. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
  121. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
  122. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
  123. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  124. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
  125. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
  126. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
  127. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
  128. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
  129. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
  130. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
  131. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
  132. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
  133. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
  134. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
  135. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
  136. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
  137. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
  138. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
  139. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
  140. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
  141. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
  142. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
  143. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
  144. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
  145. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
  146. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
  147. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
  148. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
  149. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
  150. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
  151. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
  152. package/package.json +70 -0
  153. package/src/author/card-bar.tsx +67 -0
  154. package/src/author/defaults.ts +88 -0
  155. package/src/author/index.ts +187 -0
  156. package/src/author/main.tsx +243 -0
  157. package/src/author/model-options.tsx +158 -0
  158. package/src/author/number-text-field.tsx +42 -0
  159. package/src/controller/defaults.ts +23 -0
  160. package/src/controller/index.ts +207 -0
  161. package/src/delivery/answer-fraction.tsx +113 -0
  162. package/src/delivery/fraction-model-chart.tsx +261 -0
  163. package/src/delivery/index.ts +96 -0
  164. package/src/delivery/main.tsx +256 -0
  165. package/src/index.iife.ts +16 -0
  166. package/src/index.ts +1 -0
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@pie-element/fraction-model",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "dependencies": {
6
+ "@emotion/react": "^11.14.0",
7
+ "@emotion/style": "^0.8.0",
8
+ "@mui/icons-material": "^7.3.4",
9
+ "@mui/material": "^7.3.4",
10
+ "@pie-lib/config-ui": "0.1.0",
11
+ "@pie-lib/correct-answer-toggle": "0.1.0",
12
+ "@pie-lib/render-ui": "0.1.0",
13
+ "@pie-lib/test-utils": "0.1.0",
14
+ "prop-types": "^15.8.1",
15
+ "recharts": "^3.7.0",
16
+ "@pie-element/shared-configure-events": "0.1.0",
17
+ "@pie-lib/editable-html-tip-tap": "0.1.0",
18
+ "@pie-element/shared-player-events": "0.1.0",
19
+ "@pie-element/shared-math-rendering-mathjax": "0.1.0",
20
+ "react-is": "^19.2.0",
21
+ "lodash-es": "^4.17.21"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^18.0.0",
25
+ "react-dom": "^18.0.0"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "development": "./src/index.ts",
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ },
33
+ "./delivery": {
34
+ "development": "./src/delivery/index.ts",
35
+ "types": "./dist/delivery/index.d.ts",
36
+ "default": "./dist/delivery/index.js"
37
+ },
38
+ "./author": {
39
+ "development": "./src/author/index.ts",
40
+ "types": "./dist/author/index.d.ts",
41
+ "default": "./dist/author/index.js"
42
+ },
43
+ "./controller": {
44
+ "development": "./src/controller/index.ts",
45
+ "types": "./dist/controller/index.d.ts",
46
+ "default": "./dist/controller/index.js"
47
+ }
48
+ },
49
+ "type": "module",
50
+ "main": "./dist/index.js",
51
+ "types": "./dist/index.d.ts",
52
+ "files": [
53
+ "dist",
54
+ "src"
55
+ ],
56
+ "sideEffects": false,
57
+ "devDependencies": {
58
+ "vite": "^8.0.1",
59
+ "typescript": "^5.9.3",
60
+ "@vitejs/plugin-react": "^6.0.1",
61
+ "@types/react": "^18.2.0",
62
+ "@types/react-dom": "^18.2.0"
63
+ },
64
+ "scripts": {
65
+ "build": "bun x vite build && bun x vite build --config vite.config.iife.ts && bun x tsc --emitDeclarationOnly",
66
+ "dev": "bun x vite",
67
+ "demo": "bun x vite --mode demo",
68
+ "test": "bun x vitest run"
69
+ }
70
+ }
@@ -0,0 +1,67 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/fraction-model/configure/src/card-bar.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 Tooltip from '@mui/material/Tooltip';
15
+ import HelpIcon from '@mui/icons-material/HelpOutline';
16
+ import IconButton from '@mui/material/IconButton';
17
+ import Typography from '@mui/material/Typography';
18
+
19
+ const StyledCardBar: any = styled('div')({
20
+ display: 'flex',
21
+ justifyContent: 'space-between',
22
+ });
23
+
24
+ const FlexContainer: any = styled('div')({
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ });
28
+
29
+ const StyledIconButton: any = styled(IconButton)({
30
+ margin: 0,
31
+ padding: 0,
32
+ });
33
+
34
+ const StyledTooltip: any = styled(Tooltip)(({ theme }) => ({
35
+ '& .MuiTooltip-tooltip': {
36
+ fontSize: theme.typography.fontSize - 2,
37
+ },
38
+ }));
39
+
40
+ const CardBar = (props) => {
41
+ const { header, children, mini, info } = props;
42
+
43
+ return (
44
+ <StyledCardBar>
45
+ <FlexContainer>
46
+ <Typography variant={mini ? 'h6' : 'h5'}>{header}</Typography>
47
+ {info}
48
+ </FlexContainer>
49
+ {children && (
50
+ <StyledTooltip title={children}>
51
+ <StyledIconButton aria-label="Delete" size="large">
52
+ <HelpIcon />
53
+ </StyledIconButton>
54
+ </StyledTooltip>
55
+ )}
56
+ </StyledCardBar>
57
+ );
58
+ };
59
+
60
+ CardBar.propTypes = {
61
+ mini: PropTypes.bool,
62
+ header: PropTypes.string,
63
+ children: PropTypes.node,
64
+ info: PropTypes.any,
65
+ };
66
+
67
+ export default CardBar;
@@ -0,0 +1,88 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/fraction-model/configure/src/defaults.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ export default {
12
+ model: {
13
+ correctResponse: [],
14
+ title: '',
15
+ prompt: '',
16
+ modelTypeSelected: 'bar',
17
+ maxModelSelected: 1,
18
+ partsPerModel: 5,
19
+ allowedStudentConfig: false,
20
+ showGraphLabels: false,
21
+ },
22
+ configuration: {
23
+ baseInputConfiguration: {
24
+ h3: { disabled: true },
25
+ audio: { disabled: false },
26
+ video: { disabled: false },
27
+ image: { disabled: false },
28
+ textAlign: { disabled: true },
29
+ showParagraphs: { disabled: false },
30
+ separateParagraphs: { disabled: true },
31
+ },
32
+ title: {
33
+ label: 'Title',
34
+ settings: true,
35
+ enabled: true,
36
+ inputConfiguration: {
37
+ audio: { disabled: false },
38
+ video: { disabled: false },
39
+ image: { disabled: false },
40
+ },
41
+ },
42
+ prompt: {
43
+ label: 'Question',
44
+ settings: true,
45
+ enabled: true,
46
+ inputConfiguration: {
47
+ audio: { disabled: false },
48
+ video: { disabled: false },
49
+ image: { disabled: false },
50
+ },
51
+ },
52
+ modelOptions: {
53
+ maxOfModel: {
54
+ min: 1,
55
+ max: 9,
56
+ default: 1,
57
+ },
58
+ partsPerModel: {
59
+ min: 1,
60
+ max: 9,
61
+ default: 5,
62
+ },
63
+ modelTypeChoices: [
64
+ { value: 'bar', label: 'Bar' },
65
+ { value: 'pie', label: 'Pie' },
66
+ ],
67
+ },
68
+ mathMlOptions: {
69
+ mmlOutput: false,
70
+ mmlEditing: false,
71
+ },
72
+ language: {
73
+ settings: false,
74
+ label: 'Specify Language',
75
+ enabled: false,
76
+ },
77
+ languageChoices: {
78
+ label: 'Language Choices',
79
+ options: [],
80
+ },
81
+ spellCheck: {
82
+ label: 'Spellcheck',
83
+ settings: false,
84
+ enabled: true,
85
+ },
86
+ settingsPanelDisabled: true,
87
+ },
88
+ };
@@ -0,0 +1,187 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/fraction-model/configure/src/index.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ import React from 'react';
12
+ import { createRoot } from 'react-dom/client';
13
+ import Main from './main.js';
14
+ import {
15
+ ModelUpdatedEvent,
16
+ DeleteImageEvent,
17
+ InsertImageEvent,
18
+ InsertSoundEvent,
19
+ DeleteSoundEvent,
20
+ } from '@pie-element/shared-configure-events';
21
+ import defaultValues from './defaults.js';
22
+
23
+ export default class FractionModelConfigure extends HTMLElement {
24
+ /**
25
+ * This function makes sure you set the default values on the model
26
+ * @param model
27
+ * @returns model
28
+ */
29
+ static createDefaultModel = (model = {}) => {
30
+ const c = defaultValues.configuration;
31
+ let language = model.language || '';
32
+
33
+ if (!language && c.language && c.language.enabled) {
34
+ if (c.languageChoices?.options?.length) {
35
+ language = c.languageChoices.options[0].value;
36
+ }
37
+ }
38
+
39
+ const normalizedModel = {
40
+ ...defaultValues.model,
41
+ ...model,
42
+ language,
43
+ };
44
+
45
+ return normalizedModel;
46
+ };
47
+
48
+ constructor() {
49
+ super();
50
+ this._root = null;
51
+ this._model = FractionModelConfigure.createDefaultModel();
52
+ this._configuration = defaultValues.configuration;
53
+ }
54
+
55
+ set model(m) {
56
+ this._model = FractionModelConfigure.createDefaultModel(m);
57
+ this.render();
58
+ }
59
+
60
+ set configuration(c) {
61
+ const newConfiguration = {
62
+ ...defaultValues.configuration,
63
+ ...c,
64
+ };
65
+ this._configuration = newConfiguration;
66
+
67
+ this.resetModelAfterConfigurationIsSet();
68
+
69
+ // if language:enabled is true, then the corresponding default item model should include a language value;
70
+ // if it is false, then the language field should be omitted from the item model.
71
+ // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
72
+ // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
73
+ if (newConfiguration?.language?.enabled) {
74
+ if (newConfiguration?.languageChoices?.options?.length) {
75
+ this._model.language = newConfiguration?.languageChoices.options[0].value;
76
+ }
77
+ } else if (newConfiguration.language.settings && this._model.language) {
78
+ this._configuration.language.enabled = true;
79
+
80
+ if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
81
+ this._configuration.languageChoices.options = [];
82
+ }
83
+
84
+ // check if the language is already included in the languageChoices.options array
85
+ // and if not, then add it.
86
+ if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {
87
+ this._configuration.languageChoices.options.push({
88
+ value: this._model.language,
89
+ label: this._model.language,
90
+ });
91
+ }
92
+ } else {
93
+ delete this._model.language;
94
+ }
95
+ this.render();
96
+ }
97
+
98
+ resetModelAfterConfigurationIsSet: any = () => {
99
+ // In environments that use pie-player-components, model is set before configuration.
100
+ // This is the reason why sometimes the model gets altered non-reversible
101
+ // (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)
102
+ // Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset
103
+ // the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called
104
+ const pieAuthors = document.querySelectorAll('pie-author');
105
+ this.hasPlayerAsParent = Array.from(pieAuthors).some((author) => author.contains(this));
106
+
107
+ if (this.hasPlayerAsParent) {
108
+ if (this._modelCopy) {
109
+ this._model = this._modelCopy;
110
+ } else {
111
+ delete this._modelCopy;
112
+ }
113
+ }
114
+ };
115
+
116
+ connectedCallback() {
117
+ this.render();
118
+ }
119
+
120
+ modelChanged(m) {
121
+ this._model = m;
122
+ this.dispatchEvent(new ModelUpdatedEvent(this._model), true);
123
+ this.render();
124
+ }
125
+
126
+ onChange: any = (o) => {
127
+ this._model = { ...this._model, ...o };
128
+ this.dispatchEvent(new ModelUpdatedEvent(this._model));
129
+ this.render();
130
+ };
131
+
132
+ onConfigurationChanged(c) {
133
+ this._configuration = c;
134
+ this.render();
135
+ }
136
+
137
+ /**
138
+ *
139
+ * @param {done, progress, file} handler
140
+ */
141
+ insertImage(handler) {
142
+ this.dispatchEvent(new InsertImageEvent(handler));
143
+ }
144
+
145
+ onDeleteImage(src, done) {
146
+ this.dispatchEvent(new DeleteImageEvent(src, done));
147
+ }
148
+
149
+ insertSound(handler) {
150
+ this.dispatchEvent(new InsertSoundEvent(handler));
151
+ }
152
+
153
+ onDeleteSound(src, done) {
154
+ this.dispatchEvent(new DeleteSoundEvent(src, done));
155
+ }
156
+
157
+ render() {
158
+ if (this._model) {
159
+ const el = React.createElement(Main, {
160
+ classes: {},
161
+ model: this._model,
162
+ configuration: this._configuration,
163
+ onConfigurationChanged: this.onConfigurationChanged,
164
+ onChange: this.onChange,
165
+ imageSupport: {
166
+ add: this.insertImage.bind(this),
167
+ delete: this.onDeleteImage.bind(this),
168
+ },
169
+ uploadSoundSupport: {
170
+ add: this.insertSound.bind(this),
171
+ delete: this.onDeleteSound.bind(this),
172
+ },
173
+ });
174
+
175
+ if (!this._root) {
176
+ this._root = createRoot(this);
177
+ }
178
+ this._root.render(el);
179
+ }
180
+ }
181
+
182
+ disconnectedCallback() {
183
+ if (this._root) {
184
+ this._root.unmount();
185
+ }
186
+ }
187
+ }
@@ -0,0 +1,243 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/fraction-model/configure/src/main.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 { FormSection, layout, AlertDialog } from '@pie-lib/config-ui';
14
+ import EditableHtml from '@pie-lib/editable-html-tip-tap';
15
+ import { FractionModelChart } from '../delivery/index.js';
16
+ import Tooltip from '@mui/material/Tooltip';
17
+ import Info from '@mui/icons-material/Info';
18
+ import { styled } from '@mui/material/styles';
19
+
20
+ import CardBar from './card-bar.js';
21
+ import ModelOptions from './model-options.js';
22
+
23
+ const StyledFormSection: any = styled(FormSection)(({ theme }) => ({
24
+ marginBottom: theme.spacing(4),
25
+ }));
26
+
27
+ const StyledTooltip: any = styled(Tooltip)(({ theme }) => ({
28
+ '& .MuiTooltip-tooltip': {
29
+ fontSize: theme.typography.fontSize - 2,
30
+ whiteSpace: 'pre',
31
+ maxWidth: '500px',
32
+ },
33
+ }));
34
+
35
+ const ErrorMessage: any = styled('div')(({ theme }) => ({
36
+ fontSize: theme.typography.fontSize - 2,
37
+ color: theme.palette.error.main,
38
+ marginTop: theme.spacing(1),
39
+ }));
40
+
41
+ const ModelErrorContainer: any = styled('div')(({ theme, hasError }) => ({
42
+ ...(hasError && {
43
+ border: `2px solid ${theme.palette.error.main}`,
44
+ }),
45
+ }));
46
+
47
+ const Label: any = styled('label')(({ theme }) => ({
48
+ marginBottom: theme.spacing(4),
49
+ }));
50
+
51
+ export class Main extends React.Component {
52
+ static propTypes = {
53
+ model: PropTypes.object.isRequired,
54
+ configuration: PropTypes.object.isRequired,
55
+ onConfigurationChanged: PropTypes.func.isRequired,
56
+ onChange: PropTypes.func.isRequired,
57
+ uploadSoundSupport: PropTypes.object.isRequired,
58
+ };
59
+
60
+ constructor(props) {
61
+ super(props);
62
+
63
+ this.state = {
64
+ correctAnswerChangeDialog: {
65
+ open: false,
66
+ text: '',
67
+ },
68
+ };
69
+ }
70
+
71
+ /*
72
+ * Method to handle correct answer change
73
+ * @param {array} correctResponse - correct response
74
+ * */
75
+ onCorrectAnswerChange: any = (correctResponse) => {
76
+ const { model, onChange } = this.props;
77
+ model.correctResponse = correctResponse;
78
+ onChange({ ...model });
79
+ };
80
+
81
+ /*
82
+ * Method to handle model options change
83
+ * @param {object} oldModel - old model
84
+ * @param {object} newModel - new model
85
+ * @param {boolean} showDiag - show dialog or not
86
+ * */
87
+ onModelOptionsChange: any = (oldModel, newModel, showDiag) => {
88
+ const { onChange } = this.props;
89
+ if (showDiag && oldModel.correctResponse.length > 0) {
90
+ this.setState({
91
+ correctAnswerChangeDialog: {
92
+ open: true,
93
+ oldModel: oldModel,
94
+ newModel: newModel,
95
+ text: 'Changing either the Number of Models or Parts per Model will remove added correct answer. Are you sure you want to continue?',
96
+ },
97
+ });
98
+ } else {
99
+ onChange({ ...newModel });
100
+ }
101
+ };
102
+
103
+ /*
104
+ * Method to generate random key
105
+ * */
106
+ generateRandomKey: any = () => {
107
+ return Math.floor(Math.random() * 10000);
108
+ };
109
+
110
+ render() {
111
+ const { model, onChange, configuration, imageSupport, uploadSoundSupport } = this.props;
112
+ const {
113
+ baseInputConfiguration = {},
114
+ contentDimensions = {},
115
+ title = {},
116
+ prompt = {},
117
+ modelOptions = {},
118
+ mathMlOptions = {},
119
+ } = configuration || {};
120
+
121
+ const { errors = {}, extraCSSRules, spellCheckEnabled, toolbarEditorPosition } = model || {};
122
+
123
+ const { correctAnswerChangeDialog } = this.state;
124
+
125
+ const toolbarOpts = {
126
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',
127
+ };
128
+
129
+ const getPluginProps = (props = {}) => ({
130
+ ...baseInputConfiguration,
131
+ ...props,
132
+ });
133
+
134
+ const fractionModelChartKey = this.generateRandomKey();
135
+
136
+ return (
137
+ <layout.ConfigLayout extraCSSRules={extraCSSRules} dimensions={contentDimensions} hideSettings={true}>
138
+ <CardBar header="Set Up"></CardBar>
139
+
140
+ <StyledFormSection label={title?.label || 'Title'}>
141
+ <EditableHtml
142
+ markup={model.title || ''}
143
+ onChange={(title) => onChange({ title })}
144
+ toolbarOpts={toolbarOpts}
145
+ activePlugins={[
146
+ 'bold',
147
+ 'html',
148
+ 'italic',
149
+ 'underline',
150
+ 'strikethrough',
151
+ 'image',
152
+ 'math',
153
+ 'languageCharacters',
154
+ 'responseArea',
155
+ ]}
156
+ pluginProps={getPluginProps(title?.inputConfiguration)}
157
+ spellCheck={spellCheckEnabled}
158
+ uploadSoundSupport={uploadSoundSupport}
159
+ languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
160
+ mathMlOptions={mathMlOptions}
161
+ />
162
+ </StyledFormSection>
163
+
164
+ <StyledFormSection label={prompt?.label || 'Question'}>
165
+ <EditableHtml
166
+ markup={model.prompt || ''}
167
+ minHeight={60}
168
+ onChange={(prompt) => onChange({ prompt })}
169
+ toolbarOpts={toolbarOpts}
170
+ pluginProps={getPluginProps(prompt?.inputConfiguration)}
171
+ spellCheck={spellCheckEnabled}
172
+ uploadSoundSupport={uploadSoundSupport}
173
+ imageSupport={imageSupport}
174
+ languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
175
+ mathMlOptions={mathMlOptions}
176
+ />
177
+ </StyledFormSection>
178
+
179
+ <FormSection>
180
+ <ModelOptions model={model} onChange={this.onModelOptionsChange} modelOptions={modelOptions} />
181
+ </FormSection>
182
+
183
+ <FormSection> <CardBar
184
+ header="Correct Answer"
185
+ info={
186
+ <StyledTooltip
187
+ disableFocusListener
188
+ disableTouchListener
189
+ placement={'right'}
190
+ title={'The correct answer should include no more than one partially-filled model'}
191
+ >
192
+ <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />
193
+ </StyledTooltip>
194
+ }
195
+ ></CardBar>
196
+
197
+ <br />
198
+ <Label>
199
+ Click/touch the number of parts to represent the correct fraction model
200
+ </Label>
201
+ <br />
202
+
203
+ <ModelErrorContainer hasError={!!errors.correctResponse}>
204
+ <FractionModelChart
205
+ key={fractionModelChartKey}
206
+ value={model.correctResponse}
207
+ modelType={model.modelTypeSelected}
208
+ noOfModels={model.maxModelSelected}
209
+ partsPerModel={model.partsPerModel}
210
+ showLabel={model.showGraphLabels}
211
+ onChange={this.onCorrectAnswerChange}
212
+ ></FractionModelChart>
213
+ </ModelErrorContainer>
214
+
215
+ {errors.correctResponse && <ErrorMessage>{errors.correctResponse}</ErrorMessage>}
216
+ </FormSection>
217
+
218
+ <AlertDialog
219
+ open={correctAnswerChangeDialog.open}
220
+ title="Warning"
221
+ text={correctAnswerChangeDialog.text}
222
+ onConfirm={() => {
223
+ let newModel = this.state.correctAnswerChangeDialog.newModel;
224
+ newModel.correctResponse = [];
225
+ onChange({ ...newModel });
226
+ this.setState({
227
+ correctAnswerChangeDialog: { open: false },
228
+ });
229
+ }}
230
+ onClose={() => {
231
+ const oldModel = this.state.correctAnswerChangeDialog.oldModel;
232
+ onChange({ ...oldModel });
233
+ this.setState({ correctAnswerChangeDialog: { open: false } });
234
+ }}
235
+ onConfirmText={'OK'}
236
+ onCloseText={'Cancel'}
237
+ />
238
+ </layout.ConfigLayout>
239
+ );
240
+ }
241
+ }
242
+
243
+ export default Main;