@pie-element/rubric 8.1.0-next.28 → 8.1.1-next.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.
Files changed (88) hide show
  1. package/dist/author/defaults.d.ts +71 -0
  2. package/dist/author/defaults.js +53 -0
  3. package/dist/author/index.d.ts +21 -0
  4. package/dist/author/index.js +72 -0
  5. package/dist/author/main.d.ts +14 -0
  6. package/dist/author/main.js +51 -0
  7. package/dist/controller/defaults.d.ts +17 -0
  8. package/dist/controller/defaults.js +21 -0
  9. package/dist/controller/index.d.ts +10 -0
  10. package/dist/controller/index.js +23 -0
  11. package/dist/delivery/index.d.ts +16 -0
  12. package/dist/delivery/index.js +33 -0
  13. package/dist/delivery/main.d.ts +34 -0
  14. package/dist/delivery/main.js +156 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.iife.d.ts +8 -0
  17. package/dist/index.iife.js +145 -0
  18. package/dist/index.js +2 -0
  19. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +5 -0
  20. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +10 -0
  21. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTrim.js +8 -0
  22. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +4 -0
  23. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +14 -0
  24. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +7 -0
  25. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +5 -0
  26. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
  27. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/debounce.js +50 -0
  28. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +7 -0
  29. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +6 -0
  30. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +9 -0
  31. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/now.js +7 -0
  32. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toNumber.js +19 -0
  33. package/dist/print/index.d.ts +15 -0
  34. package/dist/print/index.js +34 -0
  35. package/package.json +57 -25
  36. package/CHANGELOG.json +0 -257
  37. package/CHANGELOG.md +0 -1707
  38. package/LICENSE.md +0 -5
  39. package/README.md +0 -3
  40. package/configure/CHANGELOG.json +0 -197
  41. package/configure/CHANGELOG.md +0 -1547
  42. package/configure/lib/defaults.js +0 -70
  43. package/configure/lib/defaults.js.map +0 -1
  44. package/configure/lib/index.js +0 -135
  45. package/configure/lib/index.js.map +0 -1
  46. package/configure/lib/main.js +0 -103
  47. package/configure/lib/main.js.map +0 -1
  48. package/configure/package.json +0 -23
  49. package/configure/src/__tests__/index.test.jsx +0 -192
  50. package/configure/src/defaults.js +0 -43
  51. package/configure/src/index.js +0 -139
  52. package/configure/src/main.jsx +0 -87
  53. package/controller/CHANGELOG.json +0 -17
  54. package/controller/CHANGELOG.md +0 -893
  55. package/controller/lib/defaults.js +0 -15
  56. package/controller/lib/defaults.js.map +0 -1
  57. package/controller/lib/index.js +0 -46
  58. package/controller/lib/index.js.map +0 -1
  59. package/controller/package.json +0 -12
  60. package/controller/src/__tests__/index.test.js +0 -33
  61. package/controller/src/defaults.js +0 -8
  62. package/controller/src/index.js +0 -41
  63. package/docs/config-schema.json +0 -712
  64. package/docs/config-schema.json.md +0 -532
  65. package/docs/demo/config.js +0 -8
  66. package/docs/demo/generate.js +0 -8
  67. package/docs/demo/index.html +0 -2
  68. package/docs/pie-schema.json +0 -391
  69. package/docs/pie-schema.json.md +0 -281
  70. package/lib/index.js +0 -52
  71. package/lib/index.js.map +0 -1
  72. package/lib/main.js +0 -208
  73. package/lib/main.js.map +0 -1
  74. package/lib/print.js +0 -71
  75. package/lib/print.js.map +0 -1
  76. package/module/configure.js +0 -1
  77. package/module/controller.js +0 -73
  78. package/module/demo.js +0 -33
  79. package/module/element.js +0 -1
  80. package/module/index.html +0 -21
  81. package/module/manifest.json +0 -14
  82. package/module/print-demo.js +0 -71
  83. package/module/print.html +0 -18
  84. package/module/print.js +0 -1
  85. package/src/__tests__/rubric-view.test.jsx +0 -37
  86. package/src/index.js +0 -48
  87. package/src/main.jsx +0 -226
  88. package/src/print.js +0 -74
@@ -1,139 +0,0 @@
1
- import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';
2
- import React from 'react';
3
- import { createRoot } from 'react-dom/client';
4
- import debug from 'debug';
5
-
6
- import Main from './main';
7
- import defaults from './defaults';
8
-
9
- const modelWithDefaults = (m) => ({ ...defaults.model, ...m });
10
-
11
- const configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });
12
-
13
- export default class RubricElement extends HTMLElement {
14
- constructor() {
15
- super();
16
- this._root = null;
17
- debug.log('constructor called');
18
- this._model = modelWithDefaults();
19
- this._configuration = configurationWithDefaults();
20
- this.onModelChanged = this.onModelChanged.bind(this);
21
- this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
22
- }
23
-
24
- updateModelAccordingToReceivedProps = (nextModel) => {
25
- const currentModel = { ...this._model };
26
-
27
- if (!nextModel) {
28
- return currentModel;
29
- }
30
-
31
- const validatedModel = { ...nextModel };
32
-
33
- // excludeZero should be false and disabled when maxPoints is 1
34
- if (validatedModel.maxPoints === 1) {
35
- validatedModel.excludeZero = false;
36
- }
37
-
38
- const { maxPoints, excludeZero } = validatedModel || {};
39
-
40
- validatedModel.points = validatedModel.points ? [...validatedModel.points] : [];
41
- validatedModel.sampleAnswers = validatedModel.sampleAnswers ? [...validatedModel.sampleAnswers] : [];
42
-
43
- const howManyPointsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
44
- const howManyPointsDoesItHave = validatedModel.points.length;
45
-
46
- const excludeZeroChanged = currentModel?.excludeZero !== nextModel?.excludeZero;
47
- const maxPointsChanged = currentModel?.maxPoints !== nextModel?.maxPoints;
48
-
49
- if (howManyPointsDoesItHave < howManyPointsShouldHave) {
50
- if (excludeZeroChanged && !excludeZero) {
51
- validatedModel.points = ['', ...validatedModel.points];
52
- validatedModel.sampleAnswers = [null, ...validatedModel.sampleAnswers];
53
- }
54
-
55
- if (maxPointsChanged) {
56
- for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {
57
- validatedModel.points.push('');
58
- validatedModel.sampleAnswers.push(null);
59
- }
60
- }
61
- } else if (howManyPointsDoesItHave > howManyPointsShouldHave) {
62
- if (excludeZeroChanged && excludeZero) {
63
- validatedModel.points = validatedModel.points.slice(1);
64
- validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(1);
65
- }
66
-
67
- if (maxPointsChanged) {
68
- validatedModel.points = validatedModel.points.slice(0, howManyPointsShouldHave);
69
- validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(0, howManyPointsShouldHave);
70
- }
71
- }
72
-
73
- return validatedModel;
74
- };
75
-
76
- set model(m) {
77
- this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
78
- this._render();
79
- }
80
-
81
- set configuration(c) {
82
- this._configuration = configurationWithDefaults(c);
83
- this._render();
84
- }
85
-
86
- onModelChanged(m) {
87
- this._model = this.updateModelAccordingToReceivedProps(m);
88
- this._render();
89
- this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
90
- }
91
-
92
- onConfigurationChanged = (c) => {
93
- this._configuration = configurationWithDefaults(c);
94
-
95
- if (this._model) {
96
- this.onModelChanged(this._model);
97
- }
98
-
99
- this._render();
100
- };
101
-
102
- insertImage(handler) {
103
- this.dispatchEvent(new InsertImageEvent(handler));
104
- }
105
-
106
- onDeleteImage(src, done) {
107
- this.dispatchEvent(new DeleteImageEvent(src, done));
108
- }
109
-
110
- connectedCallback() {
111
- this._render();
112
- }
113
-
114
- _render() {
115
- if (this._model) {
116
- let element = React.createElement(Main, {
117
- model: this._model,
118
- configuration: this._configuration,
119
- onModelChanged: this.onModelChanged,
120
- onConfigurationChanged: this.onConfigurationChanged,
121
- imageSupport: {
122
- add: this.insertImage.bind(this),
123
- delete: this.onDeleteImage.bind(this),
124
- },
125
- });
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();
137
- }
138
- }
139
- }
@@ -1,87 +0,0 @@
1
- import React from 'react';
2
- import { Authoring } from '@pie-lib/rubric';
3
- import { styled } from '@mui/material/styles';
4
- import { layout, settings } from '@pie-lib/config-ui';
5
-
6
- const { Panel, toggle } = settings;
7
-
8
- const StyledDiv = styled('div')(({ theme, width }) => ({
9
- maxWidth: width,
10
- fontFamily: 'Cerebri Sans',
11
- fontSize: theme.typography.fontSize,
12
- }));
13
-
14
- class Main extends React.Component {
15
- verifyRubriclessModel = (m, config) => {
16
- const { rubricless = false } = config || {};
17
- return rubricless ? (({ points, sampleAnswers, ...rest }) => rest)(m) : m;
18
- };
19
-
20
- render() {
21
- const { model, configuration, onConfigurationChanged, onModelChanged, imageSupport } = this.props || {};
22
- const {
23
- baseInputConfiguration = {},
24
- contentDimensions = {},
25
- settingsPanelDisabled,
26
- showExcludeZero = {},
27
- showMaxPoint = {},
28
- mathMlOptions = {},
29
- rubricless = false,
30
- rubriclessInstruction,
31
- width,
32
- } = configuration || {};
33
-
34
- // ensure to eliminate points and sampleAnswers in case of rubricless
35
- const value = this.verifyRubriclessModel(model, configuration);
36
- const { extraCSSRules } = model;
37
-
38
- const panelProperties = {
39
- excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),
40
- maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
41
- rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label),
42
- };
43
-
44
- const getPluginProps = (props) => {
45
- return Object.assign(
46
- {
47
- ...baseInputConfiguration,
48
- },
49
- props || {},
50
- );
51
- };
52
-
53
- return (
54
- <layout.ConfigLayout
55
- extraCSSRules={extraCSSRules}
56
- dimensions={contentDimensions}
57
- hideSettings={settingsPanelDisabled}
58
- settings={
59
- <Panel
60
- model={model}
61
- onChangeModel={onModelChanged}
62
- configuration={configuration}
63
- onChangeConfiguration={onConfigurationChanged}
64
- pluginOpts={getPluginProps(rubriclessInstruction?.inputConfiguration)}
65
- groups={{
66
- Properties: panelProperties,
67
- }}
68
- imageSupport={imageSupport}
69
- />
70
- } >
71
- <StyledDiv width={width}>
72
- <Authoring
73
- value={value}
74
- config={configuration}
75
- onChange={onModelChanged}
76
- mathMlOptions={mathMlOptions}
77
- rubricless={rubricless}
78
- pluginOpts={baseInputConfiguration}
79
- imageSupport={imageSupport}
80
- />
81
- </StyledDiv>
82
- </layout.ConfigLayout>
83
- );
84
- }
85
- }
86
-
87
- export default Main;
@@ -1,17 +0,0 @@
1
- [
2
- {
3
- "type": "fix",
4
- "scope": null,
5
- "subject": "bump all packages to avoid tag conflict",
6
- "merge": null,
7
- "header": "fix: bump all packages to avoid tag conflict",
8
- "body": null,
9
- "footer": null,
10
- "notes": [],
11
- "hash": "d9ec9a8689f0a391594b5e2f4ea958c6dc9f6d7b",
12
- "gitTags": " (develop)",
13
- "committerDate": "2020-04-10 20:01:37 +0100",
14
- "isTagged": true,
15
- "tag": "@pie-element/rubric-controller@1.1.1"
16
- }
17
- ]