@pie-element/graphing 10.1.2 → 10.1.4
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 +13 -0
- package/configure/CHANGELOG.md +12 -0
- package/configure/package.json +4 -4
- package/docs/demo/generate.js +7 -2
- package/lib/index.js +42 -3
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing@10.1.3...@pie-element/graphing@10.1.4) (2026-06-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
11
|
+
- **graphing, charting:** render title/label math on first paint via observer PIE-688 ([95a4c0a](https://github.com/pie-framework/pie-elements/commit/95a4c0a018cf74a24324edc7536013eb271d7c00))
|
|
12
|
+
|
|
13
|
+
## [10.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing@10.1.2...@pie-element/graphing@10.1.3) (2026-06-12)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
18
|
+
|
|
6
19
|
## [10.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing@10.1.1...@pie-element/graphing@10.1.2) (2026-06-04)
|
|
7
20
|
|
|
8
21
|
### Bug Fixes
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-configure@9.1.3...@pie-element/graphing-configure@9.1.4) (2026-06-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
11
|
+
|
|
12
|
+
## [9.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-configure@9.1.2...@pie-element/graphing-configure@9.1.3) (2026-06-12)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
17
|
+
|
|
6
18
|
## [9.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-configure@9.1.1...@pie-element/graphing-configure@9.1.2) (2026-06-04)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/graphing-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "9.1.
|
|
4
|
+
"version": "9.1.4",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"@mui/icons-material": "^7.3.4",
|
|
13
13
|
"@mui/material": "^7.3.4",
|
|
14
14
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
15
|
-
"@pie-lib/config-ui": "13.0.
|
|
16
|
-
"@pie-lib/editable-html-tip-tap": "2.1.
|
|
17
|
-
"@pie-lib/graphing": "4.0.
|
|
15
|
+
"@pie-lib/config-ui": "13.0.8",
|
|
16
|
+
"@pie-lib/editable-html-tip-tap": "2.1.6",
|
|
17
|
+
"@pie-lib/graphing": "4.0.9",
|
|
18
18
|
"@pie-lib/math-rendering": "5.0.2",
|
|
19
19
|
"classnames": "^2.2.6",
|
|
20
20
|
"debug": "^4.1.1",
|
package/docs/demo/generate.js
CHANGED
|
@@ -176,7 +176,12 @@ const oldModel = {
|
|
|
176
176
|
height: 480,
|
|
177
177
|
},
|
|
178
178
|
coordinatesOnHover: false,
|
|
179
|
-
labels: {
|
|
179
|
+
labels: {
|
|
180
|
+
"top": "<div>Math in the top label: <span data-latex=\"\" data-raw=\"x^2\">\\(x^2\\)</span></div>",
|
|
181
|
+
"right": "<div><span data-latex=\"\" data-raw=\"\\frac{\\pi}{2}\">\\(\\frac{\\pi}{2}\\)</span></div>",
|
|
182
|
+
"left": "<div><span data-latex=\"\" data-raw=\"3\\pi\">\\(3\\pi\\)</span></div>",
|
|
183
|
+
"bottom": "<div><span data-latex=\"\" data-raw=\"3x^2\">\\(3x^2\\)</span></div>"
|
|
184
|
+
},
|
|
180
185
|
padding: true,
|
|
181
186
|
prompt: 'Here goes item stem !!!!!!',
|
|
182
187
|
promptEnabled: true,
|
|
@@ -189,7 +194,7 @@ const oldModel = {
|
|
|
189
194
|
axisLabel: 'y',
|
|
190
195
|
},
|
|
191
196
|
rationale: 'Rationale goes here',
|
|
192
|
-
title:
|
|
197
|
+
title: "<div>Math in the title: <span data-latex=\"\" data-raw=\"\\frac{x}{y}\">\\(\\frac{x}{y}\\)</span></div>",
|
|
193
198
|
rubricEnabled: false,
|
|
194
199
|
};
|
|
195
200
|
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,29 @@ var _main = _interopRequireDefault(require("./main"));
|
|
|
20
20
|
class Graphing extends HTMLElement {
|
|
21
21
|
constructor() {
|
|
22
22
|
super();
|
|
23
|
+
// The title and axis labels are injected synchronously via dangerouslySetInnerHTML,
|
|
24
|
+
// but createRoot().render() commits asynchronously, so a queueMicrotask(renderMath)
|
|
25
|
+
// would run before the LaTeX spans are in the DOM and leave raw LaTeX on first render.
|
|
26
|
+
// Observing the DOM and typesetting after each commit keeps math in sync regardless of timing.
|
|
27
|
+
(0, _defineProperty2.default)(this, "_scheduleMathRender", () => {
|
|
28
|
+
if (this._mathRenderPending) return;
|
|
29
|
+
this._mathRenderPending = true;
|
|
30
|
+
requestAnimationFrame(() => {
|
|
31
|
+
if (this._mathObserver) {
|
|
32
|
+
this._mathObserver.disconnect();
|
|
33
|
+
}
|
|
34
|
+
(0, _mathRendering.renderMath)(this);
|
|
35
|
+
this._mathRenderPending = false;
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
if (this._mathObserver) {
|
|
38
|
+
this._mathObserver.observe(this, {
|
|
39
|
+
childList: true,
|
|
40
|
+
subtree: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, 50);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
23
46
|
(0, _defineProperty2.default)(this, "isComplete", answer => Array.isArray(answer) && answer.length > 0);
|
|
24
47
|
(0, _defineProperty2.default)(this, "changeAnswers", answer => {
|
|
25
48
|
this._session.answer = answer;
|
|
@@ -27,6 +50,22 @@ class Graphing extends HTMLElement {
|
|
|
27
50
|
this._render();
|
|
28
51
|
});
|
|
29
52
|
this._root = null;
|
|
53
|
+
this._mathObserver = null;
|
|
54
|
+
this._mathRenderPending = false;
|
|
55
|
+
}
|
|
56
|
+
_initMathObserver() {
|
|
57
|
+
if (this._mathObserver) return;
|
|
58
|
+
this._mathObserver = new MutationObserver(this._scheduleMathRender);
|
|
59
|
+
this._mathObserver.observe(this, {
|
|
60
|
+
childList: true,
|
|
61
|
+
subtree: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
_disconnectMathObserver() {
|
|
65
|
+
if (this._mathObserver) {
|
|
66
|
+
this._mathObserver.disconnect();
|
|
67
|
+
this._mathObserver = null;
|
|
68
|
+
}
|
|
30
69
|
}
|
|
31
70
|
set model(m) {
|
|
32
71
|
this._model = m;
|
|
@@ -40,12 +79,14 @@ class Graphing extends HTMLElement {
|
|
|
40
79
|
return this._session;
|
|
41
80
|
}
|
|
42
81
|
connectedCallback() {
|
|
82
|
+
this._initMathObserver();
|
|
43
83
|
this._render();
|
|
44
84
|
}
|
|
45
85
|
_render() {
|
|
46
86
|
if (!this._model || !this._session) {
|
|
47
87
|
return;
|
|
48
88
|
}
|
|
89
|
+
this._initMathObserver();
|
|
49
90
|
const el = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
50
91
|
model: this._model,
|
|
51
92
|
session: this._session,
|
|
@@ -55,11 +96,9 @@ class Graphing extends HTMLElement {
|
|
|
55
96
|
this._root = (0, _client.createRoot)(this);
|
|
56
97
|
}
|
|
57
98
|
this._root.render(el);
|
|
58
|
-
queueMicrotask(() => {
|
|
59
|
-
(0, _mathRendering.renderMath)(this);
|
|
60
|
-
});
|
|
61
99
|
}
|
|
62
100
|
disconnectedCallback() {
|
|
101
|
+
this._disconnectMathObserver();
|
|
63
102
|
if (this._root) {
|
|
64
103
|
this._root.unmount();
|
|
65
104
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_piePlayerEvents","_mathRendering","_main","Graphing","HTMLElement","constructor","_defineProperty2","default","answer","Array","isArray","length","_session","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","isComplete","_render","_root","model","m","_model","session","s","connectedCallback","el","React","createElement","Main","onAnswersChange","changeAnswers","createRoot","render","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_piePlayerEvents","_mathRendering","_main","Graphing","HTMLElement","constructor","_defineProperty2","default","_mathRenderPending","requestAnimationFrame","_mathObserver","disconnect","renderMath","setTimeout","observe","childList","subtree","answer","Array","isArray","length","_session","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","isComplete","_render","_root","_initMathObserver","MutationObserver","_scheduleMathRender","_disconnectMathObserver","model","m","_model","session","s","connectedCallback","el","React","createElement","Main","onAnswersChange","changeAnswers","createRoot","render","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport Main from './main';\n\nexport { Main as Component };\n\nexport default class Graphing extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n this._mathObserver = null;\n this._mathRenderPending = false;\n }\n\n // The title and axis labels are injected synchronously via dangerouslySetInnerHTML,\n // but createRoot().render() commits asynchronously, so a queueMicrotask(renderMath)\n // would run before the LaTeX spans are in the DOM and leave raw LaTeX on first render.\n // Observing the DOM and typesetting after each commit keeps math in sync regardless of timing.\n _scheduleMathRender = () => {\n if (this._mathRenderPending) return;\n this._mathRenderPending = true;\n\n requestAnimationFrame(() => {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n }\n renderMath(this);\n this._mathRenderPending = false;\n setTimeout(() => {\n if (this._mathObserver) {\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n }, 50);\n });\n };\n\n _initMathObserver() {\n if (this._mathObserver) return;\n this._mathObserver = new MutationObserver(this._scheduleMathRender);\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n\n _disconnectMathObserver() {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n this._mathObserver = null;\n }\n }\n\n set model(m) {\n this._model = m;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n connectedCallback() {\n this._initMathObserver();\n this._render();\n }\n\n isComplete = (answer) => Array.isArray(answer) && answer.length > 0;\n\n changeAnswers = (answer) => {\n this._session.answer = answer;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete(this._session.answer)));\n\n this._render();\n };\n\n _render() {\n if (!this._model || !this._session) {\n return;\n }\n\n this._initMathObserver();\n\n const el = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onAnswersChange: this.changeAnswers,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n }\n\n disconnectedCallback() {\n this._disconnectMathObserver();\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AAIe,MAAMK,QAAQ,SAASC,WAAW,CAAC;EAChDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAMT;IACA;IACA;IACA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,+BACsB,MAAM;MAC1B,IAAI,IAAI,CAACC,kBAAkB,EAAE;MAC7B,IAAI,CAACA,kBAAkB,GAAG,IAAI;MAE9BC,qBAAqB,CAAC,MAAM;QAC1B,IAAI,IAAI,CAACC,aAAa,EAAE;UACtB,IAAI,CAACA,aAAa,CAACC,UAAU,CAAC,CAAC;QACjC;QACA,IAAAC,yBAAU,EAAC,IAAI,CAAC;QAChB,IAAI,CAACJ,kBAAkB,GAAG,KAAK;QAC/BK,UAAU,CAAC,MAAM;UACf,IAAI,IAAI,CAACH,aAAa,EAAE;YACtB,IAAI,CAACA,aAAa,CAACI,OAAO,CAAC,IAAI,EAAE;cAAEC,SAAS,EAAE,IAAI;cAAEC,OAAO,EAAE;YAAK,CAAC,CAAC;UACtE;QACF,CAAC,EAAE,EAAE,CAAC;MACR,CAAC,CAA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,IAAI,CAACV,OAAO,CAAC,CAAC;EAChB;EAEA,IAAIS,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACf,QAAQ;EACtB;EAEAiB,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAACT,iBAAiB,CAAC,CAAC;IACxB,IAAI,CAACF,OAAO,CAAC,CAAC;EAChB;EAYAA,OAAOA,CAAA,EAAG;IACR,IAAI,CAAC,IAAI,CAACQ,MAAM,IAAI,CAAC,IAAI,CAACd,QAAQ,EAAE;MAClC;IACF;IAEA,IAAI,CAACQ,iBAAiB,CAAC,CAAC;IAExB,MAAMU,EAAE,gBAAGC,cAAK,CAACC,aAAa,CAACC,aAAI,EAAE;MACnCT,KAAK,EAAE,IAAI,CAACE,MAAM;MAClBC,OAAO,EAAE,IAAI,CAACf,QAAQ;MACtBsB,eAAe,EAAE,IAAI,CAACC;IACxB,CAAC,CAAC;IAEF,IAAI,CAAC,IAAI,CAAChB,KAAK,EAAE;MACf,IAAI,CAACA,KAAK,GAAG,IAAAiB,kBAAU,EAAC,IAAI,CAAC;IAC/B;IACA,IAAI,CAACjB,KAAK,CAACkB,MAAM,CAACP,EAAE,CAAC;EACvB;EAEAQ,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAACf,uBAAuB,CAAC,CAAC;IAC9B,IAAI,IAAI,CAACJ,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACoB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAA1C,OAAA,GAAAJ,QAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "10.1.
|
|
7
|
+
"version": "10.1.4",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postpublish": "../../scripts/postpublish"
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"@mui/icons-material": "^7.3.4",
|
|
16
16
|
"@mui/material": "^7.3.4",
|
|
17
17
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
18
|
-
"@pie-lib/correct-answer-toggle": "4.0.
|
|
19
|
-
"@pie-lib/graphing": "4.0.
|
|
18
|
+
"@pie-lib/correct-answer-toggle": "4.0.4",
|
|
19
|
+
"@pie-lib/graphing": "4.0.9",
|
|
20
20
|
"@pie-lib/math-rendering": "5.0.2",
|
|
21
|
-
"@pie-lib/render-ui": "6.1.
|
|
21
|
+
"@pie-lib/render-ui": "6.1.2",
|
|
22
22
|
"classnames": "^2.2.6",
|
|
23
23
|
"debug": "^4.1.1",
|
|
24
24
|
"react": "18.3.1",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"author": "",
|
|
28
28
|
"license": "ISC",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "395c1eeab967e1201bc5904cfe3cc63914ebbb4a",
|
|
30
30
|
"main": "lib/index.js",
|
|
31
31
|
"module": "src/index.js"
|
|
32
32
|
}
|