@pie-element/fraction-model 6.1.2-next.1 → 6.1.2

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 (85) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +594 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +18 -0
  5. package/configure/CHANGELOG.json +1 -0
  6. package/configure/CHANGELOG.md +559 -0
  7. package/configure/lib/card-bar.js +57 -0
  8. package/configure/lib/card-bar.js.map +1 -0
  9. package/configure/lib/defaults.js +114 -0
  10. package/configure/lib/defaults.js.map +1 -0
  11. package/configure/lib/index.js +163 -0
  12. package/configure/lib/index.js.map +1 -0
  13. package/configure/lib/main.js +253 -0
  14. package/configure/lib/main.js.map +1 -0
  15. package/configure/lib/model-options.js +144 -0
  16. package/configure/lib/model-options.js.map +1 -0
  17. package/configure/lib/number-text-field.js +47 -0
  18. package/configure/lib/number-text-field.js.map +1 -0
  19. package/configure/package.json +24 -0
  20. package/controller/CHANGELOG.json +1 -0
  21. package/controller/CHANGELOG.md +484 -0
  22. package/controller/lib/defaults.js +20 -0
  23. package/controller/lib/defaults.js.map +1 -0
  24. package/controller/lib/index.js +215 -0
  25. package/controller/lib/index.js.map +1 -0
  26. package/controller/package.json +15 -0
  27. package/docs/config-schema.json +1796 -0
  28. package/docs/config-schema.json.md +1318 -0
  29. package/docs/demo/config.js +8 -0
  30. package/docs/demo/generate.js +6 -0
  31. package/docs/demo/index.html +1 -0
  32. package/docs/demo/session.js +6 -0
  33. package/docs/pie-schema.json +873 -0
  34. package/docs/pie-schema.json.md +639 -0
  35. package/lib/answer-fraction.js +109 -0
  36. package/lib/answer-fraction.js.map +1 -0
  37. package/lib/fraction-model-chart.js +279 -0
  38. package/lib/fraction-model-chart.js.map +1 -0
  39. package/lib/index.js +91 -0
  40. package/lib/index.js.map +1 -0
  41. package/lib/main.js +203 -0
  42. package/lib/main.js.map +1 -0
  43. package/package.json +19 -83
  44. package/configure.js +0 -2
  45. package/controller.js +0 -1
  46. package/dist/author/card-bar.d.ts +0 -20
  47. package/dist/author/card-bar.js +0 -40
  48. package/dist/author/defaults.d.ts +0 -113
  49. package/dist/author/defaults.js +0 -84
  50. package/dist/author/index.d.ts +0 -44
  51. package/dist/author/index.js +0 -88
  52. package/dist/author/main.d.ts +0 -25
  53. package/dist/author/main.js +0 -156
  54. package/dist/author/model-options.d.ts +0 -32
  55. package/dist/author/model-options.js +0 -85
  56. package/dist/author/number-text-field.d.ts +0 -15
  57. package/dist/author/number-text-field.js +0 -24
  58. package/dist/browser/author/index.js +0 -36733
  59. package/dist/browser/author/index.js.map +0 -1
  60. package/dist/browser/controller/index.js +0 -78
  61. package/dist/browser/controller/index.js.map +0 -1
  62. package/dist/browser/delivery/index.js +0 -2
  63. package/dist/browser/delivery-BwB7hVA6.js +0 -27725
  64. package/dist/browser/delivery-BwB7hVA6.js.map +0 -1
  65. package/dist/browser/dist-DSzihwLW.js +0 -85
  66. package/dist/browser/dist-DSzihwLW.js.map +0 -1
  67. package/dist/browser/fraction-model.css +0 -2
  68. package/dist/controller/defaults.d.ts +0 -21
  69. package/dist/controller/defaults.js +0 -13
  70. package/dist/controller/index.d.ts +0 -23
  71. package/dist/controller/index.js +0 -68
  72. package/dist/delivery/answer-fraction.d.ts +0 -27
  73. package/dist/delivery/answer-fraction.js +0 -69
  74. package/dist/delivery/fraction-model-chart.d.ts +0 -11
  75. package/dist/delivery/fraction-model-chart.js +0 -154
  76. package/dist/delivery/index.d.ts +0 -22
  77. package/dist/delivery/index.js +0 -54
  78. package/dist/delivery/main.d.ts +0 -38
  79. package/dist/delivery/main.js +0 -136
  80. package/dist/index.d.ts +0 -1
  81. package/dist/index.iife.d.ts +0 -8
  82. package/dist/index.iife.js +0 -179
  83. package/dist/index.js +0 -2
  84. package/dist/runtime-support.d.ts +0 -12
  85. package/dist/runtime-support.js +0 -12
@@ -1,88 +0,0 @@
1
- import e from "./main.js";
2
- import t from "./defaults.js";
3
- import n from "react";
4
- import { createRoot as r } from "react-dom/client";
5
- import { DeleteImageEvent as i, DeleteSoundEvent as a, InsertImageEvent as o, InsertSoundEvent as s, ModelUpdatedEvent as c } from "@pie-element/shared-configure-events";
6
- //#region src/author/index.ts
7
- var l = class l extends HTMLElement {
8
- static createDefaultModel = (e = {}) => {
9
- let n = t.configuration, r = e.language || "";
10
- return !r && n.language && n.language.enabled && n.languageChoices?.options?.length && (r = n.languageChoices.options[0].value), {
11
- ...t.model,
12
- ...e,
13
- language: r
14
- };
15
- };
16
- constructor() {
17
- super(), this._root = null, this._model = l.createDefaultModel(), this._configuration = t.configuration;
18
- }
19
- set model(e) {
20
- this._model = l.createDefaultModel(e), this.render();
21
- }
22
- set configuration(e) {
23
- let n = {
24
- ...t.configuration,
25
- ...e
26
- };
27
- this._configuration = n, this.resetModelAfterConfigurationIsSet(), n?.language?.enabled ? n?.languageChoices?.options?.length && (this._model.language = n?.languageChoices.options[0].value) : n.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
28
- value: this._model.language,
29
- label: this._model.language
30
- })) : delete this._model.language, this.render();
31
- }
32
- resetModelAfterConfigurationIsSet = () => {
33
- let e = document.querySelectorAll("pie-author");
34
- this.hasPlayerAsParent = Array.from(e).some((e) => e.contains(this)), this.hasPlayerAsParent && (this._modelCopy ? this._model = this._modelCopy : delete this._modelCopy);
35
- };
36
- connectedCallback() {
37
- this.render();
38
- }
39
- modelChanged(e) {
40
- this._model = e, this.dispatchEvent(new c(this._model), !0), this.render();
41
- }
42
- onChange = (e) => {
43
- this._model = {
44
- ...this._model,
45
- ...e
46
- }, this.dispatchEvent(new c(this._model)), this.render();
47
- };
48
- onConfigurationChanged(e) {
49
- this._configuration = e, this.render();
50
- }
51
- insertImage(e) {
52
- this.dispatchEvent(new o(e));
53
- }
54
- onDeleteImage(e, t) {
55
- this.dispatchEvent(new i(e, t));
56
- }
57
- insertSound(e) {
58
- this.dispatchEvent(new s(e));
59
- }
60
- onDeleteSound(e, t) {
61
- this.dispatchEvent(new a(e, t));
62
- }
63
- render() {
64
- if (this._model) {
65
- let t = n.createElement(e, {
66
- classes: {},
67
- model: this._model,
68
- configuration: this._configuration,
69
- onConfigurationChanged: this.onConfigurationChanged,
70
- onChange: this.onChange,
71
- imageSupport: {
72
- add: this.insertImage.bind(this),
73
- delete: this.onDeleteImage.bind(this)
74
- },
75
- uploadSoundSupport: {
76
- add: this.insertSound.bind(this),
77
- delete: this.onDeleteSound.bind(this)
78
- }
79
- });
80
- this._root ||= r(this), this._root.render(t);
81
- }
82
- }
83
- disconnectedCallback() {
84
- this._root && this._root.unmount();
85
- }
86
- };
87
- //#endregion
88
- export { l as default };
@@ -1,25 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/fraction-model/configure/src/main.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- import PropTypes from 'prop-types';
11
- export declare class Main extends React.Component {
12
- static propTypes: {
13
- model: PropTypes.Validator<object>;
14
- configuration: PropTypes.Validator<object>;
15
- onConfigurationChanged: PropTypes.Validator<(...args: any[]) => any>;
16
- onChange: PropTypes.Validator<(...args: any[]) => any>;
17
- uploadSoundSupport: PropTypes.Validator<object>;
18
- };
19
- constructor(props: any);
20
- onCorrectAnswerChange: any;
21
- onModelOptionsChange: any;
22
- generateRandomKey: any;
23
- render(): React.JSX.Element;
24
- }
25
- export default Main;
@@ -1,156 +0,0 @@
1
- import e from "../delivery/fraction-model-chart.js";
2
- import t from "./card-bar.js";
3
- import n from "./model-options.js";
4
- import r from "react";
5
- import i from "prop-types";
6
- import { styled as a } from "@mui/material/styles";
7
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
- import { AlertDialog as c, FormSection as l, layout as u } from "@pie-lib/config-ui";
9
- import d from "@pie-lib/editable-html-tip-tap";
10
- import f from "@mui/material/Tooltip";
11
- import p from "@mui/icons-material/Info";
12
- //#region src/author/main.tsx
13
- var m = a(l)(({ theme: e }) => ({ marginBottom: e.spacing(4) })), h = a(f)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
14
- fontSize: e.typography.fontSize - 2,
15
- whiteSpace: "pre",
16
- maxWidth: "500px"
17
- } })), g = a("div")(({ theme: e }) => ({
18
- fontSize: e.typography.fontSize - 2,
19
- color: e.palette.error.main,
20
- marginTop: e.spacing(1)
21
- })), _ = a("div")(({ theme: e, hasError: t }) => ({ ...t && { border: `2px solid ${e.palette.error.main}` } })), v = a("label")(({ theme: e }) => ({ marginBottom: e.spacing(4) })), y = class extends r.Component {
22
- static propTypes = {
23
- model: i.object.isRequired,
24
- configuration: i.object.isRequired,
25
- onConfigurationChanged: i.func.isRequired,
26
- onChange: i.func.isRequired,
27
- uploadSoundSupport: i.object.isRequired
28
- };
29
- constructor(e) {
30
- super(e), this.state = { correctAnswerChangeDialog: {
31
- open: !1,
32
- text: ""
33
- } };
34
- }
35
- onCorrectAnswerChange = (e) => {
36
- let { model: t, onChange: n } = this.props;
37
- t.correctResponse = e, n({ ...t });
38
- };
39
- onModelOptionsChange = (e, t, n) => {
40
- let { onChange: r } = this.props;
41
- n && e.correctResponse.length > 0 ? this.setState({ correctAnswerChangeDialog: {
42
- open: !0,
43
- oldModel: e,
44
- newModel: t,
45
- text: "Changing either the Number of Models or Parts per Model will remove added correct answer. Are you sure you want to continue?"
46
- } }) : r({ ...t });
47
- };
48
- generateRandomKey = () => Math.floor(Math.random() * 1e4);
49
- render() {
50
- let { model: r, onChange: i, configuration: a, imageSupport: f, uploadSoundSupport: y } = this.props, { baseInputConfiguration: b = {}, contentDimensions: x = {}, title: S = {}, prompt: C = {}, modelOptions: w = {}, mathMlOptions: T = {} } = a || {}, { errors: E = {}, extraCSSRules: D, spellCheckEnabled: O, toolbarEditorPosition: k } = r || {}, { correctAnswerChangeDialog: A } = this.state, j = { position: k === "top" ? "top" : "bottom" }, M = (e = {}) => ({
51
- ...b,
52
- ...e
53
- }), N = this.generateRandomKey();
54
- return /* @__PURE__ */ s(u.ConfigLayout, {
55
- extraCSSRules: D,
56
- dimensions: x,
57
- hideSettings: !0,
58
- children: [
59
- /* @__PURE__ */ o(t, { header: "Set Up" }),
60
- /* @__PURE__ */ o(m, {
61
- label: S?.label || "Title",
62
- children: /* @__PURE__ */ o(d, {
63
- markup: r.title || "",
64
- onChange: (e) => i({ title: e }),
65
- toolbarOpts: j,
66
- activePlugins: [
67
- "bold",
68
- "html",
69
- "italic",
70
- "underline",
71
- "strikethrough",
72
- "image",
73
- "math",
74
- "languageCharacters",
75
- "responseArea"
76
- ],
77
- pluginProps: M(S?.inputConfiguration),
78
- spellCheck: O,
79
- uploadSoundSupport: y,
80
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
81
- mathMlOptions: T
82
- })
83
- }),
84
- /* @__PURE__ */ o(m, {
85
- label: C?.label || "Question",
86
- children: /* @__PURE__ */ o(d, {
87
- markup: r.prompt || "",
88
- minHeight: 60,
89
- onChange: (e) => i({ prompt: e }),
90
- toolbarOpts: j,
91
- pluginProps: M(C?.inputConfiguration),
92
- spellCheck: O,
93
- uploadSoundSupport: y,
94
- imageSupport: f,
95
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
96
- mathMlOptions: T
97
- })
98
- }),
99
- /* @__PURE__ */ o(l, { children: /* @__PURE__ */ o(n, {
100
- model: r,
101
- onChange: this.onModelOptionsChange,
102
- modelOptions: w
103
- }) }),
104
- /* @__PURE__ */ s(l, { children: [
105
- " ",
106
- /* @__PURE__ */ o(t, {
107
- header: "Correct Answer",
108
- info: /* @__PURE__ */ o(h, {
109
- disableFocusListener: !0,
110
- disableTouchListener: !0,
111
- placement: "right",
112
- title: "The correct answer should include no more than one partially-filled model",
113
- children: /* @__PURE__ */ o(p, {
114
- fontSize: "small",
115
- color: "primary",
116
- style: { marginLeft: "8px" }
117
- })
118
- })
119
- }),
120
- /* @__PURE__ */ o("br", {}),
121
- /* @__PURE__ */ o(v, { children: "Click/touch the number of parts to represent the correct fraction model" }),
122
- /* @__PURE__ */ o("br", {}),
123
- /* @__PURE__ */ o(_, {
124
- hasError: !!E.correctResponse,
125
- children: /* @__PURE__ */ o(e, {
126
- value: r.correctResponse,
127
- modelType: r.modelTypeSelected,
128
- noOfModels: r.maxModelSelected,
129
- partsPerModel: r.partsPerModel,
130
- showLabel: r.showGraphLabels,
131
- onChange: this.onCorrectAnswerChange
132
- }, N)
133
- }),
134
- E.correctResponse && /* @__PURE__ */ o(g, { children: E.correctResponse })
135
- ] }),
136
- /* @__PURE__ */ o(c, {
137
- open: A.open,
138
- title: "Warning",
139
- text: A.text,
140
- onConfirm: () => {
141
- let e = this.state.correctAnswerChangeDialog.newModel;
142
- e.correctResponse = [], i({ ...e }), this.setState({ correctAnswerChangeDialog: { open: !1 } });
143
- },
144
- onClose: () => {
145
- let e = this.state.correctAnswerChangeDialog.oldModel;
146
- i({ ...e }), this.setState({ correctAnswerChangeDialog: { open: !1 } });
147
- },
148
- onConfirmText: "OK",
149
- onCloseText: "Cancel"
150
- })
151
- ]
152
- });
153
- }
154
- };
155
- //#endregion
156
- export { y as default };
@@ -1,32 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/fraction-model/configure/src/model-options.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- import PropTypes from 'prop-types';
11
- export declare class ModelOptions extends React.Component {
12
- static propTypes: {
13
- model: PropTypes.Validator<object>;
14
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
15
- modelOptions: PropTypes.Validator<object>;
16
- };
17
- constructor(props: any);
18
- /**
19
- * Function to trigger when DOM elements value change for Number type
20
- * @param {string} key contains key of element
21
- * @param {object} event contains event object
22
- * @param {string} value contains value of DOM element
23
- */
24
- change(key: any, event: any, value: any): void;
25
- /**
26
- * Function to trigger on change of dropdown value model type
27
- * @param {string} value contains selection value
28
- */
29
- handleSelect: any;
30
- render(): React.JSX.Element;
31
- }
32
- export default ModelOptions;
@@ -1,85 +0,0 @@
1
- import e from "./card-bar.js";
2
- import { MiniField as t } from "./number-text-field.js";
3
- import n from "react";
4
- import r from "prop-types";
5
- import { styled as i } from "@mui/material/styles";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
- import { Checkbox as s } from "@pie-lib/config-ui";
8
- import { cloneDeep as c } from "@pie-element/shared-lodash";
9
- import l from "@mui/material/Select";
10
- import u from "@mui/material/MenuItem";
11
- //#region src/author/model-options.tsx
12
- var d = i("div")({
13
- alignItems: "center",
14
- display: "flex",
15
- gap: "20px"
16
- }), f = i("div")({ margin: "12px 0" }), p = i("label")({
17
- display: "block",
18
- marginBottom: "4px"
19
- }), m = i(l)({
20
- width: "80px",
21
- alignItems: "center",
22
- height: "40px",
23
- verticalAlign: "top",
24
- marginBottom: "8px",
25
- "& .MuiSelect-select": { paddingLeft: "10px" }
26
- }), h = i("div")({ marginLeft: "-15px" }), g = i("span")({ verticalAlign: "middle" }), _ = class extends n.Component {
27
- static propTypes = {
28
- model: r.object.isRequired,
29
- onChange: r.func,
30
- modelOptions: r.object.isRequired
31
- };
32
- constructor(e) {
33
- super(e), this.changeMaxModel = this.change.bind(this, "max"), this.changePartModel = this.change.bind(this, "part"), this.studentConfig = this.change.bind(this, "student-config");
34
- }
35
- change(e, t, n) {
36
- let { model: r, onChange: i } = this.props, a = c(r), o = c(r), s = !1;
37
- e === "max" ? (o.maxModelSelected = n, s = !0) : e === "part" ? (o.partsPerModel = n, s = !0) : e === "student-config" && (o.allowedStudentConfig = n, s = !1), i(a, o, s);
38
- }
39
- handleSelect = (e) => {
40
- let { model: t, onChange: n } = this.props;
41
- t.modelTypeSelected = e?.target.value, n(t, { ...t }, !1);
42
- };
43
- render() {
44
- let { model: n, modelOptions: r } = this.props, { maxOfModel: i, partsPerModel: c, modelTypeChoices: l } = r;
45
- return /* @__PURE__ */ o("div", { children: [
46
- /* @__PURE__ */ a(e, { header: "Configure Fraction Model" }),
47
- /* @__PURE__ */ a("br", {}),
48
- /* @__PURE__ */ o(d, { children: [
49
- /* @__PURE__ */ o(f, { children: [/* @__PURE__ */ a(p, { children: "Model Type" }), /* @__PURE__ */ a(m, {
50
- onChange: this.handleSelect,
51
- value: n.modelTypeSelected,
52
- MenuProps: { transitionDuration: {
53
- enter: 225,
54
- exit: 195
55
- } },
56
- children: l.map((e, t) => /* @__PURE__ */ a(u, {
57
- value: e.value,
58
- children: e.label
59
- }, "item_" + t))
60
- })] }),
61
- /* @__PURE__ */ o(f, { children: [/* @__PURE__ */ a(p, { children: "Max # of Models" }), /* @__PURE__ */ a(t, {
62
- min: i.min,
63
- max: i.max,
64
- value: n.maxModelSelected,
65
- name: "max-model",
66
- onChange: this.changeMaxModel
67
- })] }),
68
- /* @__PURE__ */ o(f, { children: [/* @__PURE__ */ a(p, { children: "Parts per Model" }), /* @__PURE__ */ a(t, {
69
- min: c.min,
70
- max: c.max,
71
- value: n.partsPerModel,
72
- name: "model-parts",
73
- onChange: this.changePartModel
74
- })] })
75
- ] }),
76
- /* @__PURE__ */ o(h, { children: [/* @__PURE__ */ a(s, {
77
- onChange: this.studentConfig,
78
- checked: n.allowedStudentConfig,
79
- label: ""
80
- }), /* @__PURE__ */ a(g, { children: "Allow student to configure number of models and parts per model" })] })
81
- ] });
82
- }
83
- };
84
- //#endregion
85
- export { _ as default };
@@ -1,15 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/fraction-model/configure/src/number-text-field.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- export declare class NumberTextField extends React.Component {
11
- static propTypes: {};
12
- render(): React.JSX.Element;
13
- }
14
- export declare const MiniField: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
15
- export default NumberTextField;
@@ -1,24 +0,0 @@
1
- import e from "react";
2
- import { styled as t } from "@mui/material/styles";
3
- import { jsx as n } from "react/jsx-runtime";
4
- import { NumberTextField as r } from "@pie-lib/config-ui";
5
- t(r)(({ theme: e }) => ({ marginLeft: e.spacing(1) }));
6
- //#region src/author/number-text-field.tsx
7
- var i = t(r)({
8
- maxWidth: "120px",
9
- width: "120px",
10
- marginTop: "0",
11
- "& [class^=\"MuiInputBase-root\"]": {
12
- height: 40,
13
- fontSize: "14px"
14
- },
15
- "& [class^=\"MuiInputBase-input\"]": { padding: "18.5px 14px" }
16
- });
17
- e.Component;
18
- var a = e.forwardRef((e, t) => /* @__PURE__ */ n(i, {
19
- ...e,
20
- ref: t,
21
- variant: "outlined"
22
- }));
23
- //#endregion
24
- export { a as MiniField };