@pie-element/ebsr 11.0.0 → 12.0.1-esmbeta.1
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.
- package/CHANGELOG.md +22 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +4186 -0
- package/configure/node_modules/@pie-element/multiple-choice/LICENSE.md +5 -0
- package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
- package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +3332 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +202 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +248 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +597 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +2297 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +34 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +346 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +28 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +2993 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +2217 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +61 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +1332 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +1015 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js +1218 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js +324 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.js +3287 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.js +3017 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +427 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +252 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +388 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +108 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +469 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +48 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/controller.js +3472 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +86 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/element.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/index.html +21 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/index.js +2 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/manifest.json +10 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print-demo.js +124 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print.html +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/package.json +53 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.md +898 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js +262 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js +88 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js +181 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js +66 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/package.json +44 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/__tests__/index.test.jsx +99 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/expander.jsx +61 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/index.jsx +98 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/styles.js +61 -0
- package/configure/node_modules/@pie-lib/icons/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/icons/CHANGELOG.md +539 -0
- package/configure/node_modules/@pie-lib/icons/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/icons/esm/index.js +1153 -0
- package/configure/node_modules/@pie-lib/icons/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js +89 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js +153 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-base.js +206 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-base.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-root.js +130 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-root.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js +92 -0
- package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/index.js +72 -0
- package/configure/node_modules/@pie-lib/icons/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js +229 -0
- package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js +145 -0
- package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js +183 -0
- package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js +82 -0
- package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js +206 -0
- package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/sized.js +41 -0
- package/configure/node_modules/@pie-lib/icons/lib/sized.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/package.json +35 -0
- package/configure/node_modules/@pie-lib/icons/src/__tests__/index.test.js +3 -0
- package/configure/node_modules/@pie-lib/icons/src/correct-icon.jsx +64 -0
- package/configure/node_modules/@pie-lib/icons/src/correct-response-icon.jsx +121 -0
- package/configure/node_modules/@pie-lib/icons/src/icon-base.jsx +158 -0
- package/configure/node_modules/@pie-lib/icons/src/icon-root.jsx +76 -0
- package/configure/node_modules/@pie-lib/icons/src/incorrect-icon.jsx +61 -0
- package/configure/node_modules/@pie-lib/icons/src/index.js +19 -0
- package/configure/node_modules/@pie-lib/icons/src/instructions-icon.jsx +189 -0
- package/configure/node_modules/@pie-lib/icons/src/learn-more-icon.jsx +107 -0
- package/configure/node_modules/@pie-lib/icons/src/nothing-submitted-icon.jsx +130 -0
- package/configure/node_modules/@pie-lib/icons/src/partially-correct-icon.jsx +49 -0
- package/configure/node_modules/@pie-lib/icons/src/show-rationale-icon.jsx +152 -0
- package/configure/node_modules/@pie-lib/icons/src/sized.jsx +25 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +775 -0
- package/configure/node_modules/@pie-lib/math-rendering/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/esm/index.js +690 -0
- package/configure/node_modules/@pie-lib/math-rendering/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +38 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js +15 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +296 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +109 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +95 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +438 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/package.json +28 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/mml-to-latex.test.js +14 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/normalization.test.js +50 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/render-math.test.js +155 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/index.js +5 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mml-to-latex.js +2 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/__snapshots__/chtml.test.js.snap +9 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/chtml.test.js +104 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +220 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +387 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +1026 -0
- package/configure/node_modules/@pie-lib/render-ui/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/render-ui/esm/index.js +1616 -0
- package/configure/node_modules/@pie-lib/render-ui/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js +88 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js +9 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +135 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js +344 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +150 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js +27 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +74 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js +136 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +145 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +321 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +151 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js +122 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +181 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/package.json +40 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/html-and-math.test.js.snap +11 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +37 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/purpose.test.jsx.snap +42 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/readable.test.jsx.snap +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +27 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/color.test.js +12 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-media.test.js +20 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-text.test.js +21 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/html-and-math.test.js +24 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/preview-prompt.test.jsx +56 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/purpose.test.jsx +47 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/readable.test.jsx +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/response-indicators.test.jsx +16 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/ui-layout.test.jsx +34 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/withUndoReset.test.jsx +254 -0
- package/configure/node_modules/@pie-lib/render-ui/src/append-css-rules.js +51 -0
- package/configure/node_modules/@pie-lib/render-ui/src/assets/enableAudioAutoplayImage.js +1 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +18 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/index.test.jsx +13 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/color.js +121 -0
- package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +99 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-media.js +16 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +18 -0
- package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +21 -0
- package/configure/node_modules/@pie-lib/render-ui/src/index.js +35 -0
- package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +95 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +254 -0
- package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +17 -0
- package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
- package/configure/node_modules/@pie-lib/render-ui/src/ui-layout.jsx +66 -0
- package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +116 -0
- package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.md +410 -0
- package/configure/node_modules/@pie-lib/test-utils/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/test-utils/esm/index.js +39 -0
- package/configure/node_modules/@pie-lib/test-utils/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/test-utils/lib/index.js +40 -0
- package/configure/node_modules/@pie-lib/test-utils/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/test-utils/package.json +25 -0
- package/configure/node_modules/@pie-lib/test-utils/src/__tests__/index.test.js +45 -0
- package/configure/node_modules/@pie-lib/test-utils/src/index.js +18 -0
- package/configure/node_modules/@pie-lib/translator/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/translator/CHANGELOG.md +282 -0
- package/configure/node_modules/@pie-lib/translator/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/translator/esm/index.js +257 -0
- package/configure/node_modules/@pie-lib/translator/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/en.js +102 -0
- package/configure/node_modules/@pie-lib/translator/lib/en.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/es.js +102 -0
- package/configure/node_modules/@pie-lib/translator/lib/es.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/index.js +69 -0
- package/configure/node_modules/@pie-lib/translator/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/package.json +25 -0
- package/configure/node_modules/@pie-lib/translator/src/en.js +99 -0
- package/configure/node_modules/@pie-lib/translator/src/es.js +99 -0
- package/configure/node_modules/@pie-lib/translator/src/index.js +43 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +8 -0
- package/controller/package.json +3 -3
- package/esm/configure.js +40550 -0
- package/esm/configure.js.map +1 -0
- package/esm/controller.js +3358 -0
- package/esm/controller.js.map +1 -0
- package/esm/element.js +2203 -0
- package/esm/element.js.map +1 -0
- package/esm/package.json +4 -0
- package/esm/print.js +4090 -0
- package/esm/print.js.map +1 -0
- package/module/controller.js +4973 -2252
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +1 -1
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +24 -6
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import * as color from './color';
|
|
5
|
+
|
|
6
|
+
//Used these below to replace \\embed{newLine} with \\newline from prompt which will get parsed in MathJax
|
|
7
|
+
const NEWLINE_BLOCK_REGEX = /\\embed\{newLine\}\[\]/g;
|
|
8
|
+
const NEWLINE_LATEX = '\\newline ';
|
|
9
|
+
|
|
10
|
+
export class PreviewPrompt extends Component {
|
|
11
|
+
static propTypes = {
|
|
12
|
+
classes: PropTypes.object,
|
|
13
|
+
prompt: PropTypes.string,
|
|
14
|
+
tagName: PropTypes.string,
|
|
15
|
+
className: PropTypes.string,
|
|
16
|
+
onClick: PropTypes.func,
|
|
17
|
+
defaultClassName: PropTypes.string,
|
|
18
|
+
autoplayAudioEnabled: PropTypes.bool,
|
|
19
|
+
customAudioButton: {
|
|
20
|
+
playImage: PropTypes.string,
|
|
21
|
+
pauseImage: PropTypes.string,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
static defaultProps = {
|
|
26
|
+
onClick: () => {},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
parsedText = (text) => {
|
|
30
|
+
const { customAudioButton } = this.props;
|
|
31
|
+
const div = document.createElement('div');
|
|
32
|
+
div.innerHTML = text;
|
|
33
|
+
|
|
34
|
+
const audio = div.querySelector('audio');
|
|
35
|
+
if (audio) {
|
|
36
|
+
const source = document.createElement('source');
|
|
37
|
+
|
|
38
|
+
source.setAttribute('type', 'audio/mp3');
|
|
39
|
+
source.setAttribute('src', audio.getAttribute('src'));
|
|
40
|
+
|
|
41
|
+
audio.removeAttribute('src');
|
|
42
|
+
audio.setAttribute('id', 'pie-prompt-audio-player');
|
|
43
|
+
|
|
44
|
+
audio.appendChild(source);
|
|
45
|
+
|
|
46
|
+
if (customAudioButton) {
|
|
47
|
+
audio.style.display = 'none';
|
|
48
|
+
|
|
49
|
+
const playButton = document.createElement('div');
|
|
50
|
+
playButton.id = 'play-audio-button';
|
|
51
|
+
|
|
52
|
+
Object.assign(playButton.style, {
|
|
53
|
+
cursor: 'pointer',
|
|
54
|
+
display: 'block',
|
|
55
|
+
width: '128px',
|
|
56
|
+
height: '128px',
|
|
57
|
+
backgroundImage: `url(${customAudioButton.pauseImage})`,
|
|
58
|
+
backgroundSize: 'cover',
|
|
59
|
+
borderRadius: '50%',
|
|
60
|
+
border: '1px solid #326295',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
audio.parentNode.insertBefore(playButton, audio);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return div.innerHTML;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
addCustomAudioButtonControls() {
|
|
71
|
+
const { autoplayAudioEnabled, customAudioButton } = this.props;
|
|
72
|
+
const playButton = document.getElementById('play-audio-button');
|
|
73
|
+
const audio = document.getElementById('pie-prompt-audio-player');
|
|
74
|
+
|
|
75
|
+
if (autoplayAudioEnabled && audio) {
|
|
76
|
+
audio
|
|
77
|
+
.play()
|
|
78
|
+
.then(() => {
|
|
79
|
+
if (playButton && customAudioButton) {
|
|
80
|
+
audio.addEventListener('ended', handleAudioEnded);
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.catch((error) => {
|
|
84
|
+
console.error('Error playing audio', error);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!playButton || !audio || !customAudioButton) return;
|
|
89
|
+
|
|
90
|
+
const handlePlayClick = () => {
|
|
91
|
+
// if already playing, don't play again
|
|
92
|
+
if (!audio.paused) return;
|
|
93
|
+
if (playButton.style.backgroundImage.includes(customAudioButton.pauseImage)) return;
|
|
94
|
+
|
|
95
|
+
audio.play();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleAudioEnded = () => {
|
|
99
|
+
playButton.style.backgroundImage = `url(${customAudioButton.playImage})`;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const handleAudioPlay = () => {
|
|
103
|
+
Object.assign(playButton.style, {
|
|
104
|
+
backgroundImage: `url(${customAudioButton.pauseImage})`,
|
|
105
|
+
border: '1px solid #ccc',
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const handleAudioPause = () => {
|
|
110
|
+
Object.assign(playButton.style, {
|
|
111
|
+
backgroundImage: `url(${customAudioButton.playImage})`,
|
|
112
|
+
border: '1px solid #326295',
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
playButton.addEventListener('click', handlePlayClick);
|
|
117
|
+
audio.addEventListener('play', handleAudioPlay);
|
|
118
|
+
audio.addEventListener('pause', handleAudioPause);
|
|
119
|
+
audio.addEventListener('ended', handleAudioEnded);
|
|
120
|
+
|
|
121
|
+
// store event handler references so they can be removed later
|
|
122
|
+
this._handlePlayClick = handlePlayClick;
|
|
123
|
+
this._handleAudioPlay = handleAudioPlay;
|
|
124
|
+
this._handleAudioPause = handleAudioPause;
|
|
125
|
+
this._handleAudioEnded = handleAudioEnded;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
removeCustomAudioButtonListeners() {
|
|
129
|
+
const playButton = document.getElementById('play-audio-button');
|
|
130
|
+
const audio = document.querySelector('audio');
|
|
131
|
+
|
|
132
|
+
if (!playButton || !audio) return;
|
|
133
|
+
|
|
134
|
+
// remove event listeners using stored references
|
|
135
|
+
playButton.removeEventListener('click', this._handlePlayClick);
|
|
136
|
+
audio.removeEventListener('play', this._handleAudioPlay);
|
|
137
|
+
audio.removeEventListener('pause', this._handleAudioPause);
|
|
138
|
+
audio.removeEventListener('ended', this._handleAudioEnded);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
componentDidMount() {
|
|
142
|
+
this.alignImages();
|
|
143
|
+
this.addCustomAudioButtonControls();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
componentDidUpdate() {
|
|
147
|
+
this.alignImages();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
componentWillUnmount() {
|
|
151
|
+
this.removeCustomAudioButtonListeners();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
alignImages() {
|
|
155
|
+
const previewPrompts = document.querySelectorAll('#preview-prompt');
|
|
156
|
+
|
|
157
|
+
previewPrompts.forEach((previewPrompt) => {
|
|
158
|
+
const images = previewPrompt.getElementsByTagName('img');
|
|
159
|
+
|
|
160
|
+
if (images && images.length) {
|
|
161
|
+
for (let image of images) {
|
|
162
|
+
// check if alignment property was set
|
|
163
|
+
if (image.attributes && image.attributes.alignment && image.attributes.alignment.value) {
|
|
164
|
+
const parentNode = image.parentElement;
|
|
165
|
+
|
|
166
|
+
// check if div is not already added to dom and replace current image with wrapped image
|
|
167
|
+
if (
|
|
168
|
+
!(
|
|
169
|
+
parentNode.tagName === 'DIV' &&
|
|
170
|
+
parentNode.style.display === 'flex' &&
|
|
171
|
+
parentNode.style.width === '100%'
|
|
172
|
+
)
|
|
173
|
+
) {
|
|
174
|
+
const div = document.createElement('div');
|
|
175
|
+
div.style.display = 'flex';
|
|
176
|
+
div.style.width = '100%';
|
|
177
|
+
|
|
178
|
+
const copyImage = image.cloneNode(true);
|
|
179
|
+
div.appendChild(copyImage);
|
|
180
|
+
parentNode.replaceChild(div, image);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
render() {
|
|
189
|
+
const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;
|
|
190
|
+
const CustomTag = tagName || 'div';
|
|
191
|
+
// legend tag was added once with accessibility tasks, wee need extra style to make it work with images alignment
|
|
192
|
+
const legendClass = tagName === 'legend' ? 'legend' : '';
|
|
193
|
+
const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName || ''} ${classes[
|
|
194
|
+
legendClass
|
|
195
|
+
] || ''}`;
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<CustomTag
|
|
199
|
+
id={'preview-prompt'}
|
|
200
|
+
onClick={onClick}
|
|
201
|
+
className={customClasses}
|
|
202
|
+
dangerouslySetInnerHTML={{
|
|
203
|
+
__html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX),
|
|
204
|
+
}}
|
|
205
|
+
/>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const styles = (theme) => ({
|
|
211
|
+
prompt: {
|
|
212
|
+
verticalAlign: 'middle',
|
|
213
|
+
color: color.text(),
|
|
214
|
+
},
|
|
215
|
+
legend: {
|
|
216
|
+
width: '100%',
|
|
217
|
+
fontSize: 'inherit !important',
|
|
218
|
+
},
|
|
219
|
+
rationale: {
|
|
220
|
+
paddingLeft: theme.spacing.unit * 4,
|
|
221
|
+
paddingBottom: theme.spacing.unit,
|
|
222
|
+
},
|
|
223
|
+
label: {
|
|
224
|
+
color: `${color.text()} !important`, //'var(--choice-input-color, black)',
|
|
225
|
+
display: 'flex',
|
|
226
|
+
flexDirection: 'column',
|
|
227
|
+
verticalAlign: 'middle',
|
|
228
|
+
cursor: 'pointer',
|
|
229
|
+
'& > p': {
|
|
230
|
+
margin: '0 0 0 0 !important',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
promptTable: {
|
|
234
|
+
'&:not(.MathJax) > table': {
|
|
235
|
+
borderCollapse: 'collapse',
|
|
236
|
+
},
|
|
237
|
+
'&:not(.MathJax) > table tr': {
|
|
238
|
+
'&:nth-child(2n)': {
|
|
239
|
+
backgroundColor: '#f6f8fa',
|
|
240
|
+
color: theme.palette.common.black,
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
// align table content to left as per STAR requirement PD-3687
|
|
244
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
245
|
+
padding: '.6em 1em',
|
|
246
|
+
textAlign: 'left',
|
|
247
|
+
},
|
|
248
|
+
// added this to fix alignment of text in prompt imported from studio (PD-3423)
|
|
249
|
+
'&:not(.MathJax) > table td > p.kds-indent': {
|
|
250
|
+
textAlign: 'initial',
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
export default withStyles(styles)(PreviewPrompt);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const Purpose = (props) => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
{React.Children.map(props.children, (child) => React.cloneElement(child, { 'data-pie-purpose': props.purpose }))}
|
|
8
|
+
</>
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
Purpose.propTypes = {
|
|
13
|
+
children: PropTypes.node,
|
|
14
|
+
purpose: PropTypes.string,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default Purpose;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const Readable = (props) => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
{React.Children.map(props.children, (child) =>
|
|
8
|
+
React.cloneElement(child, { 'data-pie-readable': props.false === undefined }),
|
|
9
|
+
)}
|
|
10
|
+
</>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Readable.propTypes = {
|
|
15
|
+
children: PropTypes.node,
|
|
16
|
+
false: PropTypes.bool,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Readable;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as icons from '@pie-lib/icons';
|
|
4
|
+
import Popover from '@material-ui/core/Popover';
|
|
5
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
6
|
+
import Feedback from './feedback';
|
|
7
|
+
import debug from 'debug';
|
|
8
|
+
|
|
9
|
+
const log = debug('pie-libs:render-ui:response-indicators');
|
|
10
|
+
|
|
11
|
+
const styles = () => ({
|
|
12
|
+
responseIndicator: {
|
|
13
|
+
cursor: 'pointer',
|
|
14
|
+
},
|
|
15
|
+
paper: {
|
|
16
|
+
padding: '0',
|
|
17
|
+
borderRadius: '4px',
|
|
18
|
+
},
|
|
19
|
+
popover: {
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
},
|
|
22
|
+
popperClose: {
|
|
23
|
+
cursor: 'pointer',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const BuildIndicator = (Icon, correctness) => {
|
|
28
|
+
class RawIndicator extends React.Component {
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
this.state = {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handlePopoverOpen = (event) => {
|
|
35
|
+
log('[handlePopoverOpen]', event.target);
|
|
36
|
+
this.setState({ anchorEl: event.target });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
handlePopoverClose = () => {
|
|
40
|
+
this.setState({ anchorEl: null });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
const { feedback, classes } = this.props;
|
|
45
|
+
const { anchorEl } = this.state;
|
|
46
|
+
return (
|
|
47
|
+
<div className={feedback && classes.responseIndicator}>
|
|
48
|
+
<span ref={(r) => (this.icon = r)} onClick={this.handlePopoverOpen}>
|
|
49
|
+
<Icon />
|
|
50
|
+
</span>
|
|
51
|
+
|
|
52
|
+
{feedback && (
|
|
53
|
+
<Popover
|
|
54
|
+
className={classes.popover}
|
|
55
|
+
classes={{
|
|
56
|
+
paper: classes.paper,
|
|
57
|
+
}}
|
|
58
|
+
open={!!anchorEl}
|
|
59
|
+
anchorEl={anchorEl}
|
|
60
|
+
anchorOrigin={{
|
|
61
|
+
vertical: 'bottom',
|
|
62
|
+
horizontal: 'left',
|
|
63
|
+
}}
|
|
64
|
+
transformOrigin={{
|
|
65
|
+
vertical: 'top',
|
|
66
|
+
horizontal: 'left',
|
|
67
|
+
}}
|
|
68
|
+
onClose={this.handlePopoverClose}
|
|
69
|
+
>
|
|
70
|
+
<Feedback feedback={feedback} correctness={correctness} />
|
|
71
|
+
</Popover>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
RawIndicator.propTypes = {
|
|
79
|
+
feedback: PropTypes.string,
|
|
80
|
+
classes: PropTypes.object.isRequired,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return withStyles(styles)(RawIndicator);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Correct = BuildIndicator(icons.Correct, 'correct');
|
|
87
|
+
export const Incorrect = BuildIndicator(icons.Incorrect, 'incorrect');
|
|
88
|
+
export const PartiallyCorrect = BuildIndicator(icons.PartiallyCorrect, 'partially-correct');
|
|
89
|
+
export const NothingSubmitted = BuildIndicator(icons.NothingSubmitted, 'nothing-submitted');
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import AppendCSSRules from './append-css-rules';
|
|
6
|
+
|
|
7
|
+
class UiLayout extends AppendCSSRules {
|
|
8
|
+
static propTypes = {
|
|
9
|
+
classes: PropTypes.object,
|
|
10
|
+
className: PropTypes.string,
|
|
11
|
+
children: PropTypes.array,
|
|
12
|
+
extraCSSRules: PropTypes.shape({
|
|
13
|
+
names: PropTypes.arrayOf(PropTypes.string),
|
|
14
|
+
rules: PropTypes.string,
|
|
15
|
+
}),
|
|
16
|
+
fontSizeFactor: PropTypes.number,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
static defaultProps = {
|
|
20
|
+
extraCSSRules: {},
|
|
21
|
+
fontSizeFactor: 1,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
constructor(props) {
|
|
25
|
+
super(props);
|
|
26
|
+
this.classesSheet = document.createElement('style');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
computeStyle(fontSizeFactor) {
|
|
30
|
+
const getFontSize = (element) => parseFloat(getComputedStyle(element).fontSize);
|
|
31
|
+
|
|
32
|
+
const rootFontSize = getFontSize(document.documentElement);
|
|
33
|
+
const bodyFontSize = getFontSize(document.body);
|
|
34
|
+
const effectiveFontSize = Math.max(rootFontSize, bodyFontSize);
|
|
35
|
+
|
|
36
|
+
return fontSizeFactor !== 1 ? { fontSize: `${effectiveFontSize * fontSizeFactor}px` } : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
render() {
|
|
40
|
+
const { children, className, classes, fontSizeFactor, ...rest } = this.props;
|
|
41
|
+
|
|
42
|
+
const finalClass = classNames(className, classes.extraCSSRules, classes.uiLayoutContainer);
|
|
43
|
+
const { extraCSSRules, ...restProps } = rest;
|
|
44
|
+
const style = this.computeStyle(fontSizeFactor);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className={finalClass} {...restProps} {...(style && { style })}>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const styles = {
|
|
55
|
+
extraCSSRules: {},
|
|
56
|
+
// need this because some browsers set their own style on table
|
|
57
|
+
uiLayoutContainer: {
|
|
58
|
+
'& table, th, td': {
|
|
59
|
+
fontSize: 'inherit' /* Ensure table elements inherit font size */,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const Styled = withStyles(styles)(UiLayout);
|
|
65
|
+
|
|
66
|
+
export default Styled;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Button from '@material-ui/core/Button';
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
+
import Restore from '@material-ui/icons/Restore';
|
|
6
|
+
import Undo from '@material-ui/icons/Undo';
|
|
7
|
+
|
|
8
|
+
const styles = (theme) => ({
|
|
9
|
+
wrapper: {
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
},
|
|
13
|
+
resetUndoContainer: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
},
|
|
18
|
+
icon: {
|
|
19
|
+
width: '24px',
|
|
20
|
+
height: '24px',
|
|
21
|
+
color: 'gray',
|
|
22
|
+
marginRight: theme.spacing.unit,
|
|
23
|
+
},
|
|
24
|
+
buttonContainer: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
marginLeft: theme.spacing.unit * 3,
|
|
28
|
+
marginRight: theme.spacing.unit * 3,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* HOC that adds undo and reset functionality for session values
|
|
34
|
+
*/
|
|
35
|
+
const withUndoReset = (WrappedComponent) => {
|
|
36
|
+
class WithUndoReset extends React.Component {
|
|
37
|
+
static propTypes = {
|
|
38
|
+
classes: PropTypes.object,
|
|
39
|
+
session: PropTypes.object,
|
|
40
|
+
onSessionChange: PropTypes.func,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
constructor(props) {
|
|
44
|
+
super(props);
|
|
45
|
+
|
|
46
|
+
this.state = {
|
|
47
|
+
sessionInitialValues: JSON.parse(JSON.stringify(props.session)),
|
|
48
|
+
session: props.session,
|
|
49
|
+
changes: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onSessionChange = (session) => {
|
|
54
|
+
this.setState(
|
|
55
|
+
(state) => ({ session, changes: [...state.changes, session] }),
|
|
56
|
+
() => this.props.onSessionChange(session),
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
onUndo = () => {
|
|
61
|
+
this.setState(
|
|
62
|
+
(state) => {
|
|
63
|
+
const newChanges = [...state.changes];
|
|
64
|
+
|
|
65
|
+
newChanges.pop();
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
changes: newChanges,
|
|
69
|
+
session: newChanges.length ? newChanges[newChanges.length - 1] : state.sessionInitialValues,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
() => this.props.onSessionChange(this.state.session),
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
onReset = () => {
|
|
77
|
+
this.setState(
|
|
78
|
+
(state) => ({ session: state.sessionInitialValues, changes: [] }),
|
|
79
|
+
() => this.props.onSessionChange(this.state.sessionInitialValues),
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
render() {
|
|
84
|
+
const { classes, ...rest } = this.props;
|
|
85
|
+
const { changes, session } = this.state;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className={classes.wrapper}>
|
|
89
|
+
<div className={classes.resetUndoContainer}>
|
|
90
|
+
<Button
|
|
91
|
+
className={classes.buttonContainer}
|
|
92
|
+
color="primary"
|
|
93
|
+
disabled={changes.length === 0}
|
|
94
|
+
onClick={this.onUndo}
|
|
95
|
+
>
|
|
96
|
+
<Undo className={classes.icon} /> Undo
|
|
97
|
+
</Button>
|
|
98
|
+
<Button
|
|
99
|
+
className={classes.buttonContainer}
|
|
100
|
+
color="primary"
|
|
101
|
+
disabled={changes.length === 0}
|
|
102
|
+
onClick={this.onReset}
|
|
103
|
+
>
|
|
104
|
+
<Restore className={classes.icon} /> Start Over
|
|
105
|
+
</Button>
|
|
106
|
+
</div>
|
|
107
|
+
<WrappedComponent {...rest} session={session} onSessionChange={this.onSessionChange} />
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return withStyles(styles)(WithUndoReset);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default withUndoReset;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|