@pie-element/rubric 6.3.4-next.3 → 7.0.0-beta.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +0 -11
  2. package/configure/CHANGELOG.md +0 -11
  3. package/configure/lib/defaults.js +2 -3
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/index.js +90 -152
  6. package/configure/lib/index.js.map +1 -1
  7. package/configure/lib/main.js +90 -149
  8. package/configure/lib/main.js.map +1 -1
  9. package/configure/package.json +11 -7
  10. package/configure/src/__tests__/index.test.jsx +12 -2
  11. package/configure/src/index.js +12 -2
  12. package/configure/src/main.jsx +11 -13
  13. package/controller/lib/defaults.js +2 -3
  14. package/controller/lib/defaults.js.map +1 -1
  15. package/controller/lib/index.js +15 -28
  16. package/controller/lib/index.js.map +1 -1
  17. package/controller/package.json +1 -1
  18. package/lib/index.js +38 -80
  19. package/lib/index.js.map +1 -1
  20. package/lib/main.js +182 -244
  21. package/lib/main.js.map +1 -1
  22. package/lib/print.js +41 -84
  23. package/lib/print.js.map +1 -1
  24. package/package.json +8 -13
  25. package/src/__tests__/rubric-view.test.jsx +12 -24
  26. package/src/index.js +14 -3
  27. package/src/main.jsx +100 -93
  28. package/src/print.js +13 -2
  29. package/configure/lib/pie-toolbox-rubric/authoring.js +0 -573
  30. package/configure/lib/pie-toolbox-rubric/authoring.js.map +0 -1
  31. package/configure/lib/pie-toolbox-rubric/index.js +0 -24
  32. package/configure/lib/pie-toolbox-rubric/index.js.map +0 -1
  33. package/configure/lib/pie-toolbox-rubric/point-menu.js +0 -172
  34. package/configure/lib/pie-toolbox-rubric/point-menu.js.map +0 -1
  35. package/configure/src/pie-toolbox-rubric/authoring.jsx +0 -449
  36. package/configure/src/pie-toolbox-rubric/index.js +0 -9
  37. package/configure/src/pie-toolbox-rubric/point-menu.jsx +0 -94
  38. package/esm/configure.js +0 -34632
  39. package/esm/configure.js.map +0 -1
  40. package/esm/controller.js +0 -68
  41. package/esm/controller.js.map +0 -1
  42. package/esm/element.js +0 -12909
  43. package/esm/element.js.map +0 -1
  44. package/esm/package.json +0 -3
  45. package/esm/print.js +0 -13482
  46. package/esm/print.js.map +0 -1
  47. package/module/configure.js +0 -1
  48. package/module/controller.js +0 -113
  49. package/module/demo.js +0 -33
  50. package/module/element.js +0 -1
  51. package/module/index.html +0 -21
  52. package/module/manifest.json +0 -14
  53. package/module/print-demo.js +0 -71
  54. package/module/print.html +0 -18
  55. package/module/print.js +0 -1
  56. package/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +0 -2521
@@ -1,162 +1,103 @@
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["default"] = void 0;
9
-
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
7
+ exports.default = void 0;
24
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
9
  var _react = _interopRequireDefault(require("react"));
27
-
28
- var _index = require("./pie-toolbox-rubric/index");
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
10
+ var _rubric = require("@pie-lib/rubric");
11
+ var _styles = require("@mui/material/styles");
32
12
  var _configUi = require("@pie-lib/config-ui");
33
-
34
- var _excluded = ["points", "sampleAnswers"];
35
-
36
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
-
38
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
39
-
40
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
41
-
42
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
-
44
- var Panel = _configUi.settings.Panel,
45
- toggle = _configUi.settings.toggle;
46
-
47
- var styles = function styles(theme) {
48
- return {
49
- design: {
50
- fontFamily: 'Cerebri Sans',
51
- fontSize: theme.typography.fontSize
52
- }
53
- };
54
- };
55
-
56
- var Main = /*#__PURE__*/function (_React$Component) {
57
- (0, _inherits2["default"])(Main, _React$Component);
58
-
59
- var _super = _createSuper(Main);
60
-
61
- function Main() {
62
- var _this;
63
-
64
- (0, _classCallCheck2["default"])(this, Main);
65
-
66
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
67
- args[_key] = arguments[_key];
68
- }
69
-
70
- _this = _super.call.apply(_super, [this].concat(args));
71
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "verifyRubriclessModel", function (m, config) {
72
- var _ref = config || {},
73
- _ref$rubricless = _ref.rubricless,
74
- rubricless = _ref$rubricless === void 0 ? false : _ref$rubricless;
75
-
76
- return rubricless ? function (_ref2) {
77
- var points = _ref2.points,
78
- sampleAnswers = _ref2.sampleAnswers,
79
- rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
80
- return rest;
81
- }(m) : m;
13
+ const {
14
+ Panel,
15
+ toggle
16
+ } = _configUi.settings;
17
+ const StyledDiv = (0, _styles.styled)('div')(({
18
+ theme,
19
+ width
20
+ }) => ({
21
+ maxWidth: width,
22
+ fontFamily: 'Cerebri Sans',
23
+ fontSize: theme.typography.fontSize
24
+ }));
25
+ class Main extends _react.default.Component {
26
+ constructor(...args) {
27
+ super(...args);
28
+ (0, _defineProperty2.default)(this, "verifyRubriclessModel", (m, config) => {
29
+ const {
30
+ rubricless = false
31
+ } = config || {};
32
+ return rubricless ? (({
33
+ points,
34
+ sampleAnswers,
35
+ ...rest
36
+ }) => rest)(m) : m;
82
37
  });
83
- return _this;
84
38
  }
85
-
86
- (0, _createClass2["default"])(Main, [{
87
- key: "render",
88
- value: function render() {
89
- var _ref3 = this.props || {},
90
- model = _ref3.model,
91
- configuration = _ref3.configuration,
92
- onConfigurationChanged = _ref3.onConfigurationChanged,
93
- onModelChanged = _ref3.onModelChanged,
94
- imageSupport = _ref3.imageSupport;
95
-
96
- var _ref4 = configuration || {},
97
- _ref4$baseInputConfig = _ref4.baseInputConfiguration,
98
- baseInputConfiguration = _ref4$baseInputConfig === void 0 ? {} : _ref4$baseInputConfig,
99
- _ref4$contentDimensio = _ref4.contentDimensions,
100
- contentDimensions = _ref4$contentDimensio === void 0 ? {} : _ref4$contentDimensio,
101
- settingsPanelDisabled = _ref4.settingsPanelDisabled,
102
- _ref4$showExcludeZero = _ref4.showExcludeZero,
103
- showExcludeZero = _ref4$showExcludeZero === void 0 ? {} : _ref4$showExcludeZero,
104
- _ref4$showMaxPoint = _ref4.showMaxPoint,
105
- showMaxPoint = _ref4$showMaxPoint === void 0 ? {} : _ref4$showMaxPoint,
106
- _ref4$mathMlOptions = _ref4.mathMlOptions,
107
- mathMlOptions = _ref4$mathMlOptions === void 0 ? {} : _ref4$mathMlOptions,
108
- _ref4$rubricless = _ref4.rubricless,
109
- rubricless = _ref4$rubricless === void 0 ? false : _ref4$rubricless,
110
- rubriclessInstruction = _ref4.rubriclessInstruction,
111
- width = _ref4.width; // ensure to eliminate points and sampleAnswers in case of rubricless
112
-
113
-
114
- var value = this.verifyRubriclessModel(model, configuration);
115
- var extraCSSRules = model.extraCSSRules;
116
- var panelProperties = {
117
- excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),
118
- maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
119
- rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label)
120
- };
121
-
122
- var getPluginProps = function getPluginProps(props) {
123
- return Object.assign(_objectSpread({}, baseInputConfiguration), props || {});
124
- };
125
-
126
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
127
- extraCSSRules: extraCSSRules,
128
- dimensions: contentDimensions,
129
- hideSettings: settingsPanelDisabled,
130
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
131
- model: model,
132
- onChangeModel: onModelChanged,
133
- configuration: configuration,
134
- onChangeConfiguration: onConfigurationChanged,
135
- pluginOpts: getPluginProps(rubriclessInstruction === null || rubriclessInstruction === void 0 ? void 0 : rubriclessInstruction.inputConfiguration),
136
- groups: {
137
- Properties: panelProperties
138
- },
139
- imageSupport: imageSupport
140
- })
141
- }, /*#__PURE__*/_react["default"].createElement("div", {
142
- style: {
143
- maxWidth: width
144
- }
145
- }, /*#__PURE__*/_react["default"].createElement(_index.Authoring, {
146
- value: value,
147
- config: configuration,
148
- onChange: onModelChanged,
149
- mathMlOptions: mathMlOptions,
150
- rubricless: rubricless,
151
- pluginOpts: baseInputConfiguration,
39
+ render() {
40
+ const {
41
+ model,
42
+ configuration,
43
+ onConfigurationChanged,
44
+ onModelChanged,
45
+ imageSupport
46
+ } = this.props || {};
47
+ const {
48
+ baseInputConfiguration = {},
49
+ contentDimensions = {},
50
+ settingsPanelDisabled,
51
+ showExcludeZero = {},
52
+ showMaxPoint = {},
53
+ mathMlOptions = {},
54
+ rubricless = false,
55
+ rubriclessInstruction,
56
+ width
57
+ } = configuration || {};
58
+
59
+ // ensure to eliminate points and sampleAnswers in case of rubricless
60
+ const value = this.verifyRubriclessModel(model, configuration);
61
+ const {
62
+ extraCSSRules
63
+ } = model;
64
+ const panelProperties = {
65
+ excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),
66
+ maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
67
+ rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label)
68
+ };
69
+ const getPluginProps = props => {
70
+ return Object.assign({
71
+ ...baseInputConfiguration
72
+ }, props || {});
73
+ };
74
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
75
+ extraCSSRules: extraCSSRules,
76
+ dimensions: contentDimensions,
77
+ hideSettings: settingsPanelDisabled,
78
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
79
+ model: model,
80
+ onChangeModel: onModelChanged,
81
+ configuration: configuration,
82
+ onChangeConfiguration: onConfigurationChanged,
83
+ pluginOpts: getPluginProps(rubriclessInstruction?.inputConfiguration),
84
+ groups: {
85
+ Properties: panelProperties
86
+ },
152
87
  imageSupport: imageSupport
153
- })));
154
- }
155
- }]);
156
- return Main;
157
- }(_react["default"].Component);
158
-
159
- var _default = (0, _styles.withStyles)(styles)(Main);
160
-
161
- exports["default"] = _default;
88
+ })
89
+ }, /*#__PURE__*/_react.default.createElement(StyledDiv, {
90
+ width: width
91
+ }, /*#__PURE__*/_react.default.createElement(_rubric.Authoring, {
92
+ value: value,
93
+ config: configuration,
94
+ onChange: onModelChanged,
95
+ mathMlOptions: mathMlOptions,
96
+ rubricless: rubricless,
97
+ pluginOpts: baseInputConfiguration,
98
+ imageSupport: imageSupport
99
+ })));
100
+ }
101
+ }
102
+ var _default = exports.default = Main;
162
103
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["Panel","settings","toggle","styles","theme","design","fontFamily","fontSize","typography","Main","m","config","rubricless","points","sampleAnswers","rest","props","model","configuration","onConfigurationChanged","onModelChanged","imageSupport","baseInputConfiguration","contentDimensions","settingsPanelDisabled","showExcludeZero","showMaxPoint","mathMlOptions","rubriclessInstruction","width","value","verifyRubriclessModel","extraCSSRules","panelProperties","excludeZeroEnabled","label","maxPointsEnabled","rubriclessInstructionEnabled","getPluginProps","Object","assign","inputConfiguration","Properties","maxWidth","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAQA,KAAR,GAA0BC,kBAA1B,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA0BD,kBAA1B,CAAeC,MAAf;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAE,cADN;AAENC,MAAAA,QAAQ,EAAEH,KAAK,CAACI,UAAN,CAAiBD;AAFrB;AADiB,GAAZ;AAAA,CAAf;;IAOME,I;;;;;;;;;;;;;;;8GACoB,UAACC,CAAD,EAAIC,MAAJ,EAAe;AACrC,iBAA+BA,MAAM,IAAI,EAAzC;AAAA,iCAAQC,UAAR;AAAA,UAAQA,UAAR,gCAAqB,KAArB;;AACA,aAAOA,U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Styles } from '@material-ui/core/styles';\nimport { layout, settings } from '@pie-lib/config-ui';\n\nconst { Panel, toggle } = settings;\n\nconst styles = (theme) => ({\n design: {\n fontFamily: 'Cerebri Sans',\n fontSize: theme.typography.fontSize,\n },\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 >\n <div style={{ maxWidth: 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 </div>\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}
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,CAAC,CAAC;AAEH,MAAME,IAAI,SAASC,cAAK,CAACC,SAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,iCACT,CAACC,CAAC,EAAEC,MAAM,KAAK;MACrC,MAAM;QAAEC,UAAU,GAAG;MAAM,CAAC,GAA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CAAAuB,OAAA,CAAAgC,aAAA,CAAClD,SAAA,CAAAmD,MAAM,CAACC,YAAY;MAClBX,aAAa,EAAEA,aAAc;MAC7BY,UAAU,EAAEpB,iBAAkB;MAC9BqB,YAAY,EAAEpB,qBAAsB;MACpC/B,QAAQ,eACNR,MAAA,CAAAuB,OAAA,CAAAgC,aAAA,CAACjD,KAAK;QACJyB,KAAK,EAAEA,KAAM;QACb6B,aAAa,EAAE1B,cAAe;QAC9BF,aAAa,EAAEA,aAAc;QAC7B6B,qBAAqB,EAAE5B,sBAAuB;QAC9C6B,UAAU,EAAEV,cAAc,CAACT,qBAAqB,EAAEoB,kBAAkB,CAAE;QACtEC,MAAM,EAAE;UACNC,UAAU,EAAElB;QACd,CAAE;QACFZ,YAAY,EAAEA;MAAa,CAC5B;IACF,gBACDnC,MAAA,CAAAuB,OAAA,CAAAgC,aAAA,CAAC9C,SAAS;MAACG,KAAK,EAAEA;IAAM,gBACtBZ,MAAA,CAAAuB,OAAA,CAAAgC,aAAA,CAACpD,OAAA,CAAA+D,SAAS;MACRtB,KAAK,EAAEA,KAAM;MACbnB,MAAM,EAAEO,aAAc;MACtBmC,QAAQ,EAAEjC,cAAe;MACzBQ,aAAa,EAAEA,aAAc;MAC7BhB,UAAU,EAAEA,UAAW;MACvBoC,UAAU,EAAEzB,sBAAuB;MACnCF,YAAY,EAAEA;IAAa,CAC5B,CACQ,CACQ,CAAC;EAE1B;AACF;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAA9C,OAAA,GAEcN,IAAI","ignoreList":[]}
@@ -1,20 +1,24 @@
1
1
  {
2
2
  "name": "@pie-element/rubric-configure",
3
3
  "private": true,
4
- "version": "5.3.3",
4
+ "version": "6.0.0-beta.1",
5
5
  "description": "Rubric authoring view",
6
6
  "main": "lib/index.js",
7
7
  "author": "Pie Framework Authors",
8
8
  "dependencies": {
9
- "@material-ui/core": "^3.9.2",
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.2",
12
- "@pie-lib/editable-html": "11.21.2",
13
- "@pie-lib/render-ui": "4.35.2",
14
+ "@pie-lib/config-ui": "12.1.0-next.5",
15
+ "@pie-lib/editable-html-tip-tap": "1.1.0-next.5",
16
+ "@pie-lib/render-ui": "5.1.0-next.5",
17
+ "@pie-lib/rubric": "1.1.0-next.5",
14
18
  "debug": "^4.1.1",
15
- "react": "^16.8.6",
19
+ "react": "18.2.0",
16
20
  "react-beautiful-dnd": "^11.0.2",
17
- "react-dom": "^16.8.6"
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
- render: jest.fn(),
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
  });
@@ -1,6 +1,6 @@
1
1
  import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';
2
2
  import React from 'react';
3
- import ReactDOM from 'react-dom';
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
- ReactDOM.render(element, this);
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
  }
@@ -1,16 +1,15 @@
1
1
  import React from 'react';
2
- import { Authoring } from './pie-toolbox-rubric/index';
3
- import { withStyles } from '@material-ui/core/styles';
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 styles = (theme) => ({
9
- design: {
10
- fontFamily: 'Cerebri Sans',
11
- fontSize: theme.typography.fontSize,
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
- </div>
81
+ </StyledDiv>
84
82
  </layout.ConfigLayout>
85
83
  );
86
84
  }
87
85
  }
88
86
 
89
- export default withStyles(styles)(Main);
87
+ export default Main;
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
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,"sources":["../src/defaults.js"],"names":["points","sampleAnswers","maxPoints","maxPointsEnabled","excludeZero","excludeZeroEnabled"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,CAAC,EAAD,EAAK,EAAL,EAAS,EAAT,EAAa,EAAb,CADK;AAEbC,EAAAA,aAAa,EAAE,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,IAAnB,CAFF;AAGbC,EAAAA,SAAS,EAAE,CAHE;AAIbC,EAAAA,gBAAgB,EAAE,IAJL;AAKbC,EAAAA,WAAW,EAAE,KALA;AAMbC,EAAAA,kBAAkB,EAAE;AANP,C","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"],"file":"defaults.js"}
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":[]}
@@ -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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
-
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(function (resolve) {
25
- var modelResult = normalize(model || {});
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
- } // IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.
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
- var points = model.points;
37
- var errors = {};
38
- var pointsDescriptorsErrors = {};
39
- (points || []).forEach(function (point, index) {
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
- var identicalPointDescr = points.slice(index + 1).some(function (p) {
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,"sources":["../src/index.js"],"names":["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"],"mappings":";;;;;;;;;;;;AAAA;;;;;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD;AAAA,yCAAiBC,oBAAjB,GAA8BD,KAA9B;AAAA,CAAlB;;AAEO,SAASA,KAAT,CAAeA,KAAf,EAAsBE,OAAtB,EAA+BC,GAA/B,EAAoC;AACzC,SAAO,IAAIC,OAAJ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","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"],"file":"index.js"}
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,EAAEC,GAAG,EAAE;EACzC,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,MAAMC,WAAW,GAAGP,SAAS,CAACC,KAAK,IAAI,CAAC,CAAC,CAAC;IAE1CK,OAAO,CAACF,GAAG,IAAIA,GAAG,CAACI,IAAI,IAAIJ,GAAG,CAACI,IAAI,KAAK,YAAY,GAAGD,WAAW,GAAG,CAAC,CAAC,CAAC;EAC1E,CAAC,CAAC;AACJ;AAEA,SAASE,YAAYA,CAACC,CAAC,EAAE;EACvB,OAAO,CAACA,CAAC,IAAI,EAAE,EAAEC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;AAC/C;;AAEA;AACO,SAASC,QAAQA,CAACX,KAAK,EAAE;EAC9B,MAAM;IAAEY;EAAO,CAAC,GAAGZ,KAAK;EACxB,MAAMa,MAAM,GAAG,CAAC,CAAC;EACjB,MAAMC,uBAAuB,GAAG,CAAC,CAAC;EAElC,CAACF,MAAM,IAAI,EAAE,EAAEG,OAAO,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAK;IAEvC,IAAI,CAACD,KAAK,IAAIA,KAAK,KAAK,aAAa,EAAE;MACrCF,uBAAuB,CAACG,KAAK,CAAC,GAAG,qCAAqC;IACxE,CAAC,MAAM;MACL,MAAMC,mBAAmB,GAAGN,MAAM,CAACO,KAAK,CAACF,KAAK,GAAG,CAAC,CAAC,CAACG,IAAI,CAAEC,CAAC,IAAKb,YAAY,CAACa,CAAC,CAAC,KAAKb,YAAY,CAACQ,KAAK,CAAC,CAAC;MAExG,IAAIE,mBAAmB,EAAE;QACvBJ,uBAAuB,CAACG,KAAK,CAAC,GAAG,sCAAsC;MACzE;IACF;EACF,CAAC,CAAC;EAEF,IAAIK,MAAM,CAACC,IAAI,CAACT,uBAAuB,CAAC,CAACU,MAAM,GAAG,CAAC,EAAE;IACnDX,MAAM,CAACC,uBAAuB,GAAGA,uBAAuB;EAC1D;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/rubric-controller",
3
3
  "private": true,
4
- "version": "4.2.1",
4
+ "version": "5.0.0-beta.0",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
7
  "test": "./node_modules/.bin/jest"