@pie-element/rubric 6.3.4-next.3 → 7.0.0-beta.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.
- package/configure/lib/defaults.js +2 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +90 -152
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +90 -149
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +11 -7
- package/configure/src/__tests__/index.test.jsx +12 -2
- package/configure/src/index.js +12 -2
- package/configure/src/main.jsx +11 -13
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +15 -28
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/lib/index.js +38 -80
- package/lib/index.js.map +1 -1
- package/lib/main.js +182 -244
- package/lib/main.js.map +1 -1
- package/lib/print.js +41 -84
- package/lib/print.js.map +1 -1
- package/package.json +8 -13
- package/src/__tests__/rubric-view.test.jsx +12 -24
- package/src/index.js +14 -3
- package/src/main.jsx +100 -93
- package/src/print.js +13 -2
- package/configure/lib/pie-toolbox-rubric/authoring.js +0 -573
- package/configure/lib/pie-toolbox-rubric/authoring.js.map +0 -1
- package/configure/lib/pie-toolbox-rubric/index.js +0 -24
- package/configure/lib/pie-toolbox-rubric/index.js.map +0 -1
- package/configure/lib/pie-toolbox-rubric/point-menu.js +0 -172
- package/configure/lib/pie-toolbox-rubric/point-menu.js.map +0 -1
- package/configure/src/pie-toolbox-rubric/authoring.jsx +0 -449
- package/configure/src/pie-toolbox-rubric/index.js +0 -9
- package/configure/src/pie-toolbox-rubric/point-menu.jsx +0 -94
- package/esm/configure.js +0 -34632
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -68
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -12909
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
- package/esm/print.js +0 -13482
- package/esm/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -113
- package/module/demo.js +0 -33
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -71
- package/module/print.html +0 -18
- package/module/print.js +0 -1
- package/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +0 -2521
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_rubric","_styles","_configUi","Panel","toggle","settings","StyledDiv","styled","theme","width","maxWidth","fontFamily","fontSize","typography","Main","React","Component","constructor","args","_defineProperty2","default","m","config","rubricless","points","sampleAnswers","rest","render","model","configuration","onConfigurationChanged","onModelChanged","imageSupport","props","baseInputConfiguration","contentDimensions","settingsPanelDisabled","showExcludeZero","showMaxPoint","mathMlOptions","rubriclessInstruction","value","verifyRubriclessModel","extraCSSRules","panelProperties","excludeZeroEnabled","label","maxPointsEnabled","rubriclessInstructionEnabled","getPluginProps","Object","assign","createElement","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onChangeConfiguration","pluginOpts","inputConfiguration","groups","Properties","Authoring","onChange","_default","exports"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport { Authoring } from '@pie-lib/rubric';\nimport { styled } from '@mui/material/styles';\nimport { layout, settings } from '@pie-lib/config-ui';\n\nconst { Panel, toggle } = settings;\n\nconst StyledDiv = styled('div')(({ theme, width }) => ({\n maxWidth: width,\n fontFamily: 'Cerebri Sans',\n fontSize: theme.typography.fontSize,\n}));\n\nclass Main extends React.Component {\n verifyRubriclessModel = (m, config) => {\n const { rubricless = false } = config || {};\n return rubricless ? (({ points, sampleAnswers, ...rest }) => rest)(m) : m;\n };\n\n render() {\n const { model, configuration, onConfigurationChanged, onModelChanged, imageSupport } = this.props || {};\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n settingsPanelDisabled,\n showExcludeZero = {},\n showMaxPoint = {},\n mathMlOptions = {},\n rubricless = false,\n rubriclessInstruction,\n width,\n } = configuration || {};\n\n // ensure to eliminate points and sampleAnswers in case of rubricless\n const value = this.verifyRubriclessModel(model, configuration);\n const { extraCSSRules } = model;\n\n const panelProperties = {\n excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),\n maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),\n rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label),\n };\n\n const getPluginProps = (props) => {\n return Object.assign(\n {\n ...baseInputConfiguration,\n },\n props || {},\n );\n };\n\n return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n onChangeModel={onModelChanged}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n pluginOpts={getPluginProps(rubriclessInstruction?.inputConfiguration)}\n groups={{\n Properties: panelProperties,\n }}\n imageSupport={imageSupport}\n />\n } >\n <StyledDiv width={width}>\n <Authoring\n value={value}\n config={configuration}\n onChange={onModelChanged}\n mathMlOptions={mathMlOptions}\n rubricless={rubricless}\n pluginOpts={baseInputConfiguration}\n imageSupport={imageSupport}\n />\n </StyledDiv>\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEA,MAAM;EAAEI,KAAK;EAAEC;AAAO,CAAC,GAAGC,kBAAQ;AAElC,MAAMC,SAAS,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC,KAAK;EAAEC;AAAM,CAAC,MAAM;EACrDC,QAAQ,EAAED,KAAK;EACfE,UAAU,EAAE,cAAc;EAC1BC,QAAQ,EAAEJ,KAAK,CAACK,UAAU,CAACD;AAC7B,CAAC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|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/rubric-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0-beta.0",
|
|
5
5
|
"description": "Rubric authoring view",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"author": "Pie Framework Authors",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@
|
|
9
|
+
"@emotion/react": "^11.14.0",
|
|
10
|
+
"@emotion/style": "^0.8.0",
|
|
11
|
+
"@mui/icons-material": "^7.3.4",
|
|
12
|
+
"@mui/material": "^7.3.4",
|
|
10
13
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
11
|
-
"@pie-lib/config-ui": "11.30.
|
|
12
|
-
"@pie-lib/editable-html": "11.21.
|
|
13
|
-
"@pie-lib/render-ui": "4.35.
|
|
14
|
+
"@pie-lib/config-ui": "11.30.4-next.0",
|
|
15
|
+
"@pie-lib/editable-html": "11.21.4-next.0",
|
|
16
|
+
"@pie-lib/render-ui": "4.35.4-next.0",
|
|
17
|
+
"@pie-lib/rubric": "0.28.4-next.0",
|
|
14
18
|
"debug": "^4.1.1",
|
|
15
|
-
"react": "
|
|
19
|
+
"react": "18.2.0",
|
|
16
20
|
"react-beautiful-dnd": "^11.0.2",
|
|
17
|
-
"react-dom": "
|
|
21
|
+
"react-dom": "18.2.0"
|
|
18
22
|
},
|
|
19
23
|
"license": "ISC"
|
|
20
24
|
}
|
|
@@ -3,8 +3,11 @@ import defaults from '../defaults';
|
|
|
3
3
|
import { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
-
jest.mock('react-dom', () => ({
|
|
7
|
-
|
|
6
|
+
jest.mock('react-dom/client', () => ({
|
|
7
|
+
createRoot: jest.fn(() => ({
|
|
8
|
+
render: jest.fn(),
|
|
9
|
+
unmount: jest.fn(),
|
|
10
|
+
})),
|
|
8
11
|
}));
|
|
9
12
|
|
|
10
13
|
jest.mock('@pie-lib/config-ui', () => ({
|
|
@@ -46,6 +49,13 @@ const configuration = (c) => ({ ...defaults.configuration, ...c });
|
|
|
46
49
|
describe('RubricElement', () => {
|
|
47
50
|
let element;
|
|
48
51
|
|
|
52
|
+
beforeAll(() => {
|
|
53
|
+
// Register the custom element if not already registered
|
|
54
|
+
if (!customElements.get('pie-rubric-configure')) {
|
|
55
|
+
customElements.define('pie-rubric-configure', RubricElement);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
49
59
|
beforeEach(() => {
|
|
50
60
|
element = new RubricElement();
|
|
51
61
|
});
|
package/configure/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import debug from 'debug';
|
|
5
5
|
|
|
6
6
|
import Main from './main';
|
|
@@ -13,6 +13,7 @@ const configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });
|
|
|
13
13
|
export default class RubricElement extends HTMLElement {
|
|
14
14
|
constructor() {
|
|
15
15
|
super();
|
|
16
|
+
this._root = null;
|
|
16
17
|
debug.log('constructor called');
|
|
17
18
|
this._model = modelWithDefaults();
|
|
18
19
|
this._configuration = configurationWithDefaults();
|
|
@@ -123,7 +124,16 @@ export default class RubricElement extends HTMLElement {
|
|
|
123
124
|
},
|
|
124
125
|
});
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
if (!this._root) {
|
|
128
|
+
this._root = createRoot(this);
|
|
129
|
+
}
|
|
130
|
+
this._root.render(element);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
disconnectedCallback() {
|
|
135
|
+
if (this._root) {
|
|
136
|
+
this._root.unmount();
|
|
127
137
|
}
|
|
128
138
|
}
|
|
129
139
|
}
|
package/configure/src/main.jsx
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Authoring } from '
|
|
3
|
-
import {
|
|
2
|
+
import { Authoring } from '@pie-lib/rubric';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { layout, settings } from '@pie-lib/config-ui';
|
|
5
5
|
|
|
6
6
|
const { Panel, toggle } = settings;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
8
|
+
const StyledDiv = styled('div')(({ theme, width }) => ({
|
|
9
|
+
maxWidth: width,
|
|
10
|
+
fontFamily: 'Cerebri Sans',
|
|
11
|
+
fontSize: theme.typography.fontSize,
|
|
12
|
+
}));
|
|
14
13
|
|
|
15
14
|
class Main extends React.Component {
|
|
16
15
|
verifyRubriclessModel = (m, config) => {
|
|
@@ -68,9 +67,8 @@ class Main extends React.Component {
|
|
|
68
67
|
}}
|
|
69
68
|
imageSupport={imageSupport}
|
|
70
69
|
/>
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
<div style={{ maxWidth: width }}>
|
|
70
|
+
} >
|
|
71
|
+
<StyledDiv width={width}>
|
|
74
72
|
<Authoring
|
|
75
73
|
value={value}
|
|
76
74
|
config={configuration}
|
|
@@ -80,10 +78,10 @@ class Main extends React.Component {
|
|
|
80
78
|
pluginOpts={baseInputConfiguration}
|
|
81
79
|
imageSupport={imageSupport}
|
|
82
80
|
/>
|
|
83
|
-
</
|
|
81
|
+
</StyledDiv>
|
|
84
82
|
</layout.ConfigLayout>
|
|
85
83
|
);
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
export default
|
|
87
|
+
export default Main;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
var _default = {
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
8
|
points: ['', '', '', ''],
|
|
9
9
|
sampleAnswers: [null, null, null, null],
|
|
10
10
|
maxPoints: 3,
|
|
@@ -12,5 +12,4 @@ var _default = {
|
|
|
12
12
|
excludeZero: false,
|
|
13
13
|
excludeZeroEnabled: true
|
|
14
14
|
};
|
|
15
|
-
exports["default"] = _default;
|
|
16
15
|
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["points","sampleAnswers","maxPoints","maxPointsEnabled","excludeZero","excludeZeroEnabled"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n points: ['', '', '', ''],\n sampleAnswers: [null, null, null, null],\n maxPoints: 3,\n maxPointsEnabled: true,\n excludeZero: false,\n excludeZeroEnabled: true,\n};\n"],"mappings":";;;;;;iCAAe;EACbA,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;EACxBC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;EACvCC,SAAS,EAAE,CAAC;EACZC,gBAAgB,EAAE,IAAI;EACtBC,WAAW,EAAE,KAAK;EAClBC,kBAAkB,EAAE;AACtB,CAAC","ignoreList":[]}
|
package/controller/lib/index.js
CHANGED
|
@@ -1,59 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.model = model;
|
|
9
8
|
exports.validate = validate;
|
|
10
|
-
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
|
|
13
9
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var normalize = function normalize(model) {
|
|
20
|
-
return _objectSpread(_objectSpread({}, _defaults["default"]), model);
|
|
21
|
-
};
|
|
22
|
-
|
|
10
|
+
const normalize = model => ({
|
|
11
|
+
..._defaults.default,
|
|
12
|
+
...model
|
|
13
|
+
});
|
|
23
14
|
function model(model, session, env) {
|
|
24
|
-
return new Promise(
|
|
25
|
-
|
|
15
|
+
return new Promise(resolve => {
|
|
16
|
+
const modelResult = normalize(model || {});
|
|
26
17
|
resolve(env && env.role && env.role === 'instructor' ? modelResult : {});
|
|
27
18
|
});
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
function markupToText(s) {
|
|
31
21
|
return (s || '').replace(/(<([^>]+)>)/gi, '');
|
|
32
|
-
}
|
|
33
|
-
|
|
22
|
+
}
|
|
34
23
|
|
|
24
|
+
// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.
|
|
35
25
|
function validate(model) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
const {
|
|
27
|
+
points
|
|
28
|
+
} = model;
|
|
29
|
+
const errors = {};
|
|
30
|
+
const pointsDescriptorsErrors = {};
|
|
31
|
+
(points || []).forEach((point, index) => {
|
|
40
32
|
if (!point || point === '<div></div>') {
|
|
41
33
|
pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
|
|
42
34
|
} else {
|
|
43
|
-
|
|
44
|
-
return markupToText(p) === markupToText(point);
|
|
45
|
-
});
|
|
46
|
-
|
|
35
|
+
const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));
|
|
47
36
|
if (identicalPointDescr) {
|
|
48
37
|
pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';
|
|
49
38
|
}
|
|
50
39
|
}
|
|
51
40
|
});
|
|
52
|
-
|
|
53
41
|
if (Object.keys(pointsDescriptorsErrors).length > 0) {
|
|
54
42
|
errors.pointsDescriptorsErrors = pointsDescriptorsErrors;
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
return errors;
|
|
58
45
|
}
|
|
59
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","normalize","model","defaults","session","env","Promise","resolve","modelResult","role","markupToText","s","replace","validate","points","errors","pointsDescriptorsErrors","forEach","point","index","identicalPointDescr","slice","some","p","Object","keys","length"],"sources":["../src/index.js"],"sourcesContent":["import defaults from './defaults';\n\nconst normalize = (model) => ({ ...defaults, ...model });\n\nexport function model(model, session, env) {\n return new Promise((resolve) => {\n const modelResult = normalize(model || {});\n\n resolve(env && env.role && env.role === 'instructor' ? modelResult : {});\n });\n}\n\nfunction markupToText(s) {\n return (s || '').replace(/(<([^>]+)>)/gi, '');\n}\n\n// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.\nexport function validate(model) {\n const { points } = model;\n const errors = {};\n const pointsDescriptorsErrors = {};\n\n (points || []).forEach((point, index) => {\n\n if (!point || point === '<div></div>') {\n pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';\n } else {\n const identicalPointDescr = points.slice(index + 1).some((p) => markupToText(p) === markupToText(point));\n\n if (identicalPointDescr) {\n pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';\n }\n }\n });\n\n if (Object.keys(pointsDescriptorsErrors).length > 0) {\n errors.pointsDescriptorsErrors = pointsDescriptorsErrors;\n }\n\n return errors;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,SAAS,GAAIC,KAAK,KAAM;EAAE,GAAGC,iBAAQ;EAAE,GAAGD;AAAM,CAAC,CAAC;AAEjD,SAASA,KAAKA,CAACA,KAAK,EAAEE,OAAO,E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package.json
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,94 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
23
|
-
|
|
7
|
+
exports.default = void 0;
|
|
24
8
|
var _main = _interopRequireDefault(require("./main"));
|
|
25
|
-
|
|
26
9
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
29
|
-
|
|
10
|
+
var _client = require("react-dom/client");
|
|
30
11
|
var _debug = _interopRequireDefault(require("debug"));
|
|
31
|
-
|
|
32
12
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(0, _inherits2["default"])(RubricRender, _HTMLElement);
|
|
40
|
-
|
|
41
|
-
var _super = _createSuper(RubricRender);
|
|
42
|
-
|
|
43
|
-
function RubricRender() {
|
|
44
|
-
var _this;
|
|
45
|
-
|
|
46
|
-
(0, _classCallCheck2["default"])(this, RubricRender);
|
|
47
|
-
_this = _super.call(this);
|
|
48
|
-
|
|
49
|
-
_debug["default"].log('constructor called');
|
|
50
|
-
|
|
51
|
-
_this.onModelChanged = _this.onModelChanged.bind((0, _assertThisInitialized2["default"])(_this));
|
|
52
|
-
return _this;
|
|
13
|
+
class RubricRender extends HTMLElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
_debug.default.log('constructor called');
|
|
17
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
18
|
+
this._root = null;
|
|
53
19
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this._render();
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
key: "_render",
|
|
76
|
-
value: function _render() {
|
|
77
|
-
var _this2 = this;
|
|
78
|
-
|
|
79
|
-
if (this._model) {
|
|
80
|
-
var el = /*#__PURE__*/_react["default"].createElement(_main["default"], {
|
|
81
|
-
value: this._model
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
_reactDom["default"].render(el, this, function () {
|
|
85
|
-
(0, _mathRendering.renderMath)(_this2);
|
|
86
|
-
});
|
|
20
|
+
set model(s) {
|
|
21
|
+
this._model = s;
|
|
22
|
+
this._render();
|
|
23
|
+
}
|
|
24
|
+
onModelChanged(m) {
|
|
25
|
+
this._model = m;
|
|
26
|
+
this._render();
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
this._render();
|
|
30
|
+
}
|
|
31
|
+
_render() {
|
|
32
|
+
if (this._model) {
|
|
33
|
+
const el = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
34
|
+
value: this._model
|
|
35
|
+
});
|
|
36
|
+
if (!this._root) {
|
|
37
|
+
this._root = (0, _client.createRoot)(this);
|
|
87
38
|
}
|
|
39
|
+
this._root.render(el);
|
|
40
|
+
queueMicrotask(() => {
|
|
41
|
+
(0, _mathRendering.renderMath)(this);
|
|
42
|
+
});
|
|
88
43
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
44
|
+
}
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
if (this._root) {
|
|
47
|
+
this._root.unmount();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = RubricRender;
|
|
94
52
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_debug","_mathRendering","RubricRender","HTMLElement","constructor","debug","log","onModelChanged","bind","_root","model","s","_model","_render","m","connectedCallback","el","React","createElement","Rubric","value","createRoot","render","queueMicrotask","renderMath","disconnectedCallback","unmount","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import Rubric from './main';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nexport default class RubricRender extends HTMLElement {\n constructor() {\n super();\n debug.log('constructor called');\n this.onModelChanged = this.onModelChanged.bind(this);\n this._root = null;\n }\n\n set model(s) {\n this._model = s;\n this._render();\n }\n\n onModelChanged(m) {\n this._model = m;\n this._render();\n }\n\n connectedCallback() {\n this._render();\n }\n\n _render() {\n if (this._model) {\n const el = React.createElement(Rubric, { value: this._model });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n queueMicrotask(() => {\n renderM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