@pie-lib/rubric 2.0.4-next.30 → 2.0.4-next.34

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 (31) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +1448 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/authoring.js +496 -0
  5. package/lib/authoring.js.map +1 -0
  6. package/lib/index.js +20 -0
  7. package/lib/index.js.map +1 -0
  8. package/lib/point-menu.js +125 -0
  9. package/lib/point-menu.js.map +1 -0
  10. package/package.json +12 -35
  11. package/src/__tests__/rubric.test.jsx +373 -0
  12. package/src/authoring.jsx +413 -0
  13. package/src/index.js +9 -0
  14. package/src/point-menu.jsx +87 -0
  15. package/dist/_virtual/_rolldown/runtime.js +0 -7
  16. package/dist/authoring.d.ts +0 -62
  17. package/dist/authoring.js +0 -298
  18. package/dist/index.d.ts +0 -15
  19. package/dist/index.js +0 -9
  20. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/extends.js +0 -12
  21. package/dist/node_modules/.bun/@hello-pangea_dnd@18.0.1_d0d44917b9a63a72/node_modules/@hello-pangea/dnd/dist/dnd.esm.js +0 -4451
  22. package/dist/node_modules/.bun/css-box-model@1.2.1/node_modules/css-box-model/dist/css-box-model.esm.js +0 -102
  23. package/dist/node_modules/.bun/raf-schd@4.0.3/node_modules/raf-schd/dist/raf-schd.esm.js +0 -13
  24. package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +0 -471
  25. package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +0 -159
  26. package/dist/node_modules/.bun/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -11
  27. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +0 -53
  28. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +0 -51
  29. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +0 -10
  30. package/dist/point-menu.d.ts +0 -27
  31. package/dist/point-menu.js +0 -73
package/dist/authoring.js DELETED
@@ -1,298 +0,0 @@
1
- import { ConnectedDroppable as e, DragDropContext as t, PublicDraggable as n } from "./node_modules/.bun/@hello-pangea_dnd@18.0.1_d0d44917b9a63a72/node_modules/@hello-pangea/dnd/dist/dnd.esm.js";
2
- import r from "./point-menu.js";
3
- import i from "react";
4
- import a from "prop-types";
5
- import { styled as o } from "@mui/material/styles";
6
- import s from "@mui/material/InputLabel";
7
- import c from "@mui/material/OutlinedInput";
8
- import l from "@mui/material/Select";
9
- import u from "@mui/material/FormControl";
10
- import d from "@mui/material/MenuItem";
11
- import { range as f, takeRight as p, times as m } from "@pie-element/shared-lodash";
12
- import h from "@mui/material/Checkbox";
13
- import g from "@mui/material/FormGroup";
14
- import _ from "@mui/material/FormControlLabel";
15
- import v from "@mui/material/Typography";
16
- import y from "@mui/icons-material/DragIndicator";
17
- import b from "debug";
18
- import { jsx as x, jsxs as S } from "react/jsx-runtime";
19
- import C from "@pie-lib/editable-html-tip-tap";
20
- import { InputContainer as w } from "@pie-lib/config-ui";
21
- import { grey as T } from "@mui/material/colors";
22
- //#region src/authoring.tsx
23
- var E = b("pie-lib:rubric:authoring"), D = (e, t, n) => {
24
- let r = Array.from(e), [i] = r.splice(t, 1);
25
- return r.splice(n, 0, i), r;
26
- }, O = a.shape({
27
- excludeZero: a.bool,
28
- points: a.arrayOf(a.string),
29
- sampleAnswers: a.arrayOf(a.string),
30
- maxPoints: a.number,
31
- rubriclessInstruction: a.string
32
- }), k = (e) => {
33
- let { value: t, onChange: n, max: r } = e, i = "max-points-label";
34
- return /* @__PURE__ */ S(u, {
35
- sx: {
36
- minWidth: 120,
37
- m: 1
38
- },
39
- variant: "outlined",
40
- children: [/* @__PURE__ */ x(s, {
41
- id: i,
42
- children: "Max Points"
43
- }), /* @__PURE__ */ x(l, {
44
- labelId: i,
45
- label: "Max Points",
46
- value: t,
47
- onChange: (e) => n(e.target.value),
48
- input: /* @__PURE__ */ x(c, { label: "Max Points" }),
49
- MenuProps: { transitionDuration: {
50
- enter: 225,
51
- exit: 195
52
- } },
53
- children: f(1, r + 1).map((e) => /* @__PURE__ */ x(d, {
54
- value: e,
55
- children: e
56
- }, `${e}`))
57
- })]
58
- });
59
- }, A = (e) => e === null || e === "null", j = o("div")(() => ({
60
- display: "flex",
61
- width: "100%",
62
- position: "relative"
63
- })), M = o("div")(({ theme: e }) => ({
64
- width: "100%",
65
- backgroundColor: `${e.palette.common.white}`
66
- })), N = o(y)(({ theme: e }) => ({
67
- paddingTop: e.spacing(1),
68
- color: T[500]
69
- })), P = o(v)(({ theme: e }) => ({
70
- color: T[500],
71
- paddingBottom: e.spacing(1),
72
- textTransform: "uppercase"
73
- })), F = o("div")(({ theme: e }) => ({ paddingLeft: e.spacing(3) })), I = o("div")(({ theme: e }) => ({
74
- fontSize: e.typography.fontSize - 2,
75
- color: e.palette.error.main,
76
- paddingLeft: e.spacing(3),
77
- paddingTop: e.spacing(1)
78
- })), L = o("div")(() => ({
79
- position: "absolute",
80
- right: 0
81
- })), R = (e) => {
82
- let { points: t, content: n, sampleAnswer: i, mathMlOptions: a = {}, error: o, pluginOpts: s = {} } = e, c = `${t} ${t <= 1 ? "pt" : "pts"}`, l = A(i);
83
- return /* @__PURE__ */ S("div", { children: [
84
- /* @__PURE__ */ x(P, {
85
- variant: "overline",
86
- children: c
87
- }),
88
- /* @__PURE__ */ S(j, { children: [
89
- /* @__PURE__ */ x(N, {}),
90
- /* @__PURE__ */ x(M, { children: /* @__PURE__ */ x(C, {
91
- error: o,
92
- pluginProps: s,
93
- markup: n,
94
- onChange: e.onChange,
95
- mathMlOptions: a
96
- }) }),
97
- /* @__PURE__ */ x(L, { children: /* @__PURE__ */ x(r, {
98
- showSampleAnswer: l,
99
- onChange: e.onMenuChange
100
- }) })
101
- ] }),
102
- o && /* @__PURE__ */ x(I, { children: o }),
103
- !l && /* @__PURE__ */ S(F, { children: [/* @__PURE__ */ x(N, {
104
- as: v,
105
- variant: "overline",
106
- children: "Sample Response"
107
- }), /* @__PURE__ */ x(M, { children: /* @__PURE__ */ x(C, {
108
- markup: i,
109
- pluginProps: s,
110
- onChange: e.onSampleChange,
111
- mathMlOptions: a
112
- }) })] })
113
- ] });
114
- }, z = o("div")(({ theme: e }) => ({
115
- backgroundColor: T[200],
116
- borderWidth: 1,
117
- borderStyle: "solid",
118
- borderColor: T[300],
119
- padding: e.spacing(2),
120
- margin: e.spacing(1)
121
- })), B = o(w)(({ theme: e }) => ({
122
- width: "100%",
123
- paddingTop: e.spacing(2.5),
124
- marginBottom: e.spacing(2),
125
- marginTop: e.spacing(1),
126
- "& .MuiFormControl-root": { width: "100%" },
127
- "& > .MuiFormLabel-root.MuiInputLabel-shrink": {
128
- fontSize: e.typography.fontSize + 2,
129
- transform: "translate(0, 1.5px) scale(0.75)"
130
- }
131
- })), V = o("div")(() => ({ display: "none" })), H = o("div")(({ theme: e }) => ({
132
- paddingTop: e.spacing(1),
133
- paddingBottom: e.spacing(1)
134
- })), U = o(v)(({ theme: e }) => ({
135
- paddingLeft: e.spacing(1),
136
- margin: e.spacing(1)
137
- })), W = class extends i.Component {
138
- static propTypes = {
139
- value: O,
140
- config: a.object,
141
- pluginOpts: a.object,
142
- rubricless: a.bool,
143
- onChange: a.func
144
- };
145
- static defaultProps = {};
146
- dragEnd = (e) => {
147
- if (!e.destination) return;
148
- let { value: t, onChange: n } = this.props, r = D(t.points, e.source.index, e.destination.index), i = D(t.sampleAnswers, e.source.index, e.destination.index);
149
- n({
150
- ...t,
151
- points: r,
152
- sampleAnswers: i
153
- });
154
- };
155
- changeRubriclessInstruction = (e) => {
156
- let { value: t, onChange: n } = this.props;
157
- n({
158
- ...t,
159
- rubriclessInstruction: e
160
- });
161
- };
162
- changeMaxPoints = (e) => {
163
- let { value: t, onChange: n, rubricless: r } = this.props, i = t.points.length - 1;
164
- E("current", i, "new: ", e);
165
- let a, o;
166
- e > i && (a = m(e - i).map(() => "").concat(t.points), o = m(e - i).map(() => null).concat(t.sampleAnswers)), e < i && (E("less than"), a = p(t.points, e + 1), o = p(t.sampleAnswers, e + 1)), n(a && !r ? {
167
- ...t,
168
- points: a,
169
- sampleAnswers: o,
170
- maxPoints: e
171
- } : {
172
- ...t,
173
- maxPoints: e
174
- });
175
- };
176
- changeContent = (e, t, n) => {
177
- if (E(`changeModel[${n}]:`, e, t), n !== "points" && n !== "sampleAnswers") return;
178
- let { value: r, onChange: i } = this.props, a = r[n] && Array.from(r[n]);
179
- a.splice(e, 1, t), E(`changeModel[${n}]:`, a), i({
180
- ...r,
181
- [n]: a
182
- });
183
- };
184
- excludeZeros = () => {
185
- let { value: e, onChange: t } = this.props;
186
- t({
187
- ...e,
188
- excludeZero: !e.excludeZero
189
- });
190
- };
191
- getPointForIndex = (e, t) => (t.excludeZero ? t.points.length - 1 + 1 : t.points.length - 1) - e;
192
- getMaxPoint = (e) => e.excludeZero ? e.points.length : e.points.length - 1;
193
- shouldRenderPoint = (e, t) => this.getPointForIndex(e, t) > 0 || !t.excludeZero;
194
- onPointMenuChange = (e, t) => {
195
- if (t === "sample") {
196
- let { value: t } = this.props;
197
- A(Array.from(t.sampleAnswers || [])[e]) ? this.changeContent(e, "", "sampleAnswers") : this.changeContent(e, null, "sampleAnswers");
198
- }
199
- };
200
- render() {
201
- let { value: r, mathMlOptions: i = {}, config: a = {}, rubricless: o = !1, pluginOpts: s = {} } = this.props, { excludeZeroEnabled: c = !0, maxPointsEnabled: l = !0, errors: u = {}, rubriclessInstructionEnabled: d = !1, maxPoints: f = 10 } = r || {}, { rubriclessInstruction: p = {}, maxMaxPoints: m = 10 } = a || {}, { pointsDescriptorsErrors: v } = u || {};
202
- r && Number.isFinite(r.maxPoints) && console.warn("maxPoints is deprecated - remove from model");
203
- let y = o ? f : r.excludeZero ? r.points.length : r.points.length - 1;
204
- return /* @__PURE__ */ S("div", { children: [
205
- /* @__PURE__ */ x(U, {
206
- variant: "h5",
207
- children: "Rubric"
208
- }),
209
- /* @__PURE__ */ S(g, {
210
- row: !0,
211
- children: [l && /* @__PURE__ */ x(k, {
212
- max: m < 100 ? m : 100,
213
- value: y,
214
- onChange: this.changeMaxPoints,
215
- pluginOpts: s
216
- }), c && /* @__PURE__ */ x(_, {
217
- label: "Exclude zeros",
218
- control: /* @__PURE__ */ x(h, {
219
- checked: r.excludeZero,
220
- onChange: this.excludeZeros
221
- })
222
- })]
223
- }),
224
- d && o && /* @__PURE__ */ x(B, {
225
- label: p.label,
226
- children: /* @__PURE__ */ x(C, {
227
- markup: r.rubriclessInstruction || "",
228
- onChange: this.changeRubriclessInstruction,
229
- pluginProps: s,
230
- nonEmpty: !1,
231
- disableUnderline: !0,
232
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
233
- mathMlOptions: i,
234
- autoWidthToolbar: !0
235
- })
236
- }),
237
- /* @__PURE__ */ x("div", { children: o ? /* @__PURE__ */ x(V, {}) : /* @__PURE__ */ x(z, { children: /* @__PURE__ */ x(t, {
238
- onDragEnd: this.dragEnd,
239
- children: /* @__PURE__ */ x(e, {
240
- droppableId: "droppable",
241
- children: (e) => /* @__PURE__ */ S("div", {
242
- ...e.droppableProps,
243
- ref: e.innerRef,
244
- children: [r.points.map((e, t) => this.shouldRenderPoint(t, r) && /* @__PURE__ */ x(n, {
245
- index: t,
246
- draggableId: t.toString(),
247
- children: (n) => /* @__PURE__ */ x(H, {
248
- ref: n.innerRef,
249
- ...n.draggableProps,
250
- ...n.dragHandleProps,
251
- children: /* @__PURE__ */ x(R, {
252
- points: this.getPointForIndex(t, r),
253
- content: e,
254
- error: v && v[r.points.length - 1 - t],
255
- sampleAnswer: r.sampleAnswers && r.sampleAnswers[t],
256
- onChange: (e) => this.changeContent(t, e, "points"),
257
- onSampleChange: (e) => this.changeContent(t, e, "sampleAnswers"),
258
- onMenuChange: (e) => this.onPointMenuChange(t, e),
259
- mathMlOptions: i,
260
- pluginOpts: s
261
- })
262
- })
263
- }, `${e.points}-${t}`)), e.placeholder]
264
- })
265
- })
266
- }) }) })
267
- ] });
268
- }
269
- }, G = (e) => {
270
- let { rubricless: t = !1, config: n = {}, pluginOpts: r = {} } = e || {}, i = Array.from(e.value.points || []).reverse(), a = Array.from(e.value.sampleAnswers || []).reverse();
271
- return i.length > a.length && (a = m(i.length - a.length).map(() => null).concat(a)), /* @__PURE__ */ x(W, {
272
- value: {
273
- ...e.value,
274
- points: i,
275
- sampleAnswers: a
276
- },
277
- config: n,
278
- onChange: (t) => {
279
- e.onChange({
280
- ...t,
281
- points: Array.from(t.points || []).reverse(),
282
- sampleAnswers: Array.from(t.sampleAnswers || []).reverse()
283
- });
284
- },
285
- rubricless: t,
286
- pluginOpts: r
287
- });
288
- };
289
- G.propTypes = {
290
- value: O,
291
- config: a.object,
292
- pluginOpts: a.object,
293
- rubricless: a.bool,
294
- getIndex: a.func,
295
- onChange: a.func
296
- };
297
- //#endregion
298
- export { G as default };
package/dist/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/rubric/src/index.js
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 Authoring from './authoring.js';
10
- declare const RUBRIC_TYPES: {
11
- SIMPLE_RUBRIC: string;
12
- MULTI_TRAIT_RUBRIC: string;
13
- RUBRICLESS: string;
14
- };
15
- export { Authoring, RUBRIC_TYPES };
package/dist/index.js DELETED
@@ -1,9 +0,0 @@
1
- import e from "./authoring.js";
2
- //#region src/index.ts
3
- var t = {
4
- SIMPLE_RUBRIC: "simpleRubric",
5
- MULTI_TRAIT_RUBRIC: "multiTraitRubric",
6
- RUBRICLESS: "rubricless"
7
- };
8
- //#endregion
9
- export { e as Authoring, t as RUBRIC_TYPES };
@@ -1,12 +0,0 @@
1
- //#region ../../../node_modules/.bun/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/extends.js
2
- function e() {
3
- return e = Object.assign ? Object.assign.bind() : function(e) {
4
- for (var t = 1; t < arguments.length; t++) {
5
- var n = arguments[t];
6
- for (var r in n) ({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
7
- }
8
- return e;
9
- }, e.apply(null, arguments);
10
- }
11
- //#endregion
12
- export { e as _extends };