@pie-element/graphing 10.1.1 → 10.1.2-next.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 (86) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/configure.d.ts +26 -0
  4. package/dist/author/configure.js +208 -0
  5. package/dist/author/correct-response.d.ts +54 -0
  6. package/dist/author/correct-response.js +303 -0
  7. package/dist/author/defaults.d.ts +294 -0
  8. package/dist/author/defaults.js +415 -0
  9. package/dist/author/graphing-config.d.ts +34 -0
  10. package/dist/author/graphing-config.js +244 -0
  11. package/dist/author/index.d.ts +59 -0
  12. package/dist/author/index.js +96 -0
  13. package/dist/author/utils.d.ts +43 -0
  14. package/dist/author/utils.js +260 -0
  15. package/dist/browser/author/index.js +4480 -0
  16. package/dist/browser/author/index.js.map +1 -0
  17. package/dist/browser/container-DaIvr1Vu.js +57966 -0
  18. package/dist/browser/container-DaIvr1Vu.js.map +1 -0
  19. package/dist/browser/controller/index.js +353 -0
  20. package/dist/browser/controller/index.js.map +1 -0
  21. package/dist/browser/delivery/index.js +683 -0
  22. package/dist/browser/delivery/index.js.map +1 -0
  23. package/dist/browser/dist-BrN2xZtM.js +547 -0
  24. package/dist/browser/dist-BrN2xZtM.js.map +1 -0
  25. package/dist/browser/graphing.css +2 -0
  26. package/dist/controller/defaults.d.ts +59 -0
  27. package/dist/controller/defaults.js +61 -0
  28. package/dist/controller/index.d.ts +34 -0
  29. package/dist/controller/index.js +179 -0
  30. package/dist/controller/utils.d.ts +37 -0
  31. package/dist/controller/utils.js +111 -0
  32. package/dist/delivery/index.d.ts +21 -0
  33. package/dist/delivery/index.js +43 -0
  34. package/dist/delivery/main.d.ts +23 -0
  35. package/dist/delivery/main.js +107 -0
  36. package/dist/delivery/utils.d.ts +22 -0
  37. package/dist/graphing.css +2 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.iife.d.ts +8 -0
  40. package/dist/index.iife.js +406 -0
  41. package/dist/index.js +2 -0
  42. package/dist/runtime-support.d.ts +12 -0
  43. package/dist/runtime-support.js +12 -0
  44. package/package.json +88 -21
  45. package/CHANGELOG.json +0 -652
  46. package/CHANGELOG.md +0 -2043
  47. package/LICENSE.md +0 -5
  48. package/README.md +0 -1
  49. package/configure/CHANGELOG.json +0 -382
  50. package/configure/CHANGELOG.md +0 -1834
  51. package/configure/lib/configure.js +0 -328
  52. package/configure/lib/configure.js.map +0 -1
  53. package/configure/lib/correct-response.js +0 -484
  54. package/configure/lib/correct-response.js.map +0 -1
  55. package/configure/lib/defaults.js +0 -448
  56. package/configure/lib/defaults.js.map +0 -1
  57. package/configure/lib/graphing-config.js +0 -388
  58. package/configure/lib/graphing-config.js.map +0 -1
  59. package/configure/lib/index.js +0 -173
  60. package/configure/lib/index.js.map +0 -1
  61. package/configure/lib/utils.js +0 -122
  62. package/configure/lib/utils.js.map +0 -1
  63. package/configure/package.json +0 -30
  64. package/controller/CHANGELOG.json +0 -412
  65. package/controller/CHANGELOG.md +0 -1267
  66. package/controller/lib/defaults.js +0 -64
  67. package/controller/lib/defaults.js.map +0 -1
  68. package/controller/lib/index.js +0 -459
  69. package/controller/lib/index.js.map +0 -1
  70. package/controller/lib/utils.js +0 -451
  71. package/controller/lib/utils.js.map +0 -1
  72. package/controller/package.json +0 -24
  73. package/docs/config-schema.json +0 -3164
  74. package/docs/config-schema.json.md +0 -2293
  75. package/docs/demo/config.js +0 -8
  76. package/docs/demo/generate.js +0 -200
  77. package/docs/demo/index.html +0 -1
  78. package/docs/demo/session.js +0 -20
  79. package/docs/pie-schema.json +0 -3495
  80. package/docs/pie-schema.json.md +0 -1345
  81. package/lib/index.js +0 -69
  82. package/lib/index.js.map +0 -1
  83. package/lib/main.js +0 -161
  84. package/lib/main.js.map +0 -1
  85. package/lib/utils.js +0 -24
  86. package/lib/utils.js.map +0 -1
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/graphing/configure/src/graphing-config.jsx
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 * as React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare class GraphingConfig extends React.Component {
12
+ static propTypes: {
13
+ availableTools: PropTypes.Requireable<any[]>;
14
+ authoring: PropTypes.Requireable<object>;
15
+ dimensionsEnabled: PropTypes.Requireable<boolean>;
16
+ graphDimensions: PropTypes.Requireable<object>;
17
+ gridConfigurations: PropTypes.Requireable<any[]>;
18
+ labelsPlaceholders: PropTypes.Requireable<object>;
19
+ model: PropTypes.Validator<object>;
20
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
21
+ showLabels: PropTypes.Requireable<boolean>;
22
+ showTitle: PropTypes.Requireable<boolean>;
23
+ titlePlaceholder: PropTypes.Requireable<string>;
24
+ };
25
+ constructor(props: any);
26
+ changeBackgroundMarks: any;
27
+ changeLabels: any;
28
+ changeTitle: any;
29
+ onConfigChange: any;
30
+ onChangeView: any;
31
+ changeGridConfiguration: any;
32
+ render(): React.JSX.Element;
33
+ }
34
+ export default GraphingConfig;
@@ -0,0 +1,244 @@
1
+ import { applyConstraints as e, filterPlotableMarks as t, getGridValues as n, getLabelValues as r } from "./utils.js";
2
+ import * as i from "react";
3
+ import a from "prop-types";
4
+ import { styled as o } from "@mui/material/styles";
5
+ import { GraphContainer as s, GridSetup as c } from "@pie-lib/graphing";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
+ import { isEqual as d } from "@pie-element/shared-lodash";
8
+ import { AlertDialog as f } from "@pie-lib/config-ui";
9
+ import { MenuItem as p, OutlinedInput as m, Select as h, Typography as g } from "@mui/material";
10
+ //#region src/author/graphing-config.tsx
11
+ var _ = o("div")(({ theme: e }) => ({
12
+ display: "flex",
13
+ flexWrap: "wrap",
14
+ marginBottom: e.spacing(2.5)
15
+ })), v = o("div")(({ theme: e }) => ({
16
+ display: "flex",
17
+ flexDirection: "column",
18
+ marginRight: e.spacing(3),
19
+ marginBottom: e.spacing(2.5)
20
+ })), y = o("div")({
21
+ display: "flex",
22
+ flexDirection: "column"
23
+ }), b = o(g)(({ theme: e }) => ({
24
+ marginTop: e.spacing(1.5),
25
+ marginBottom: e.spacing(1)
26
+ })), x = o("div")(({ theme: e }) => ({
27
+ display: "flex",
28
+ flexWrap: "wrap",
29
+ alignItems: "center",
30
+ width: "100%",
31
+ marginBottom: e.spacing(2.5)
32
+ })), S = o(g)(({ theme: e }) => ({ padding: `0 ${e.spacing(1)}` })), C = o(h)({ flex: "1" }), w = class extends i.Component {
33
+ static propTypes = {
34
+ availableTools: a.array,
35
+ authoring: a.object,
36
+ dimensionsEnabled: a.bool,
37
+ graphDimensions: a.object,
38
+ gridConfigurations: a.array,
39
+ labelsPlaceholders: a.object,
40
+ model: a.object.isRequired,
41
+ onChange: a.func.isRequired,
42
+ showLabels: a.bool,
43
+ showTitle: a.bool,
44
+ titlePlaceholder: a.string
45
+ };
46
+ constructor(e) {
47
+ super(e);
48
+ let { domain: t, range: i, graph: a } = e.model || {}, o = {
49
+ domain: n(t, a.width, !0),
50
+ range: n(i, a.height, !0)
51
+ }, s = {
52
+ domain: r(t.step),
53
+ range: r(i.step)
54
+ };
55
+ this.state = {
56
+ gridValues: o,
57
+ labelValues: s,
58
+ showPixelGuides: !1,
59
+ dialog: { isOpened: !1 },
60
+ domain: { ...t },
61
+ range: { ...i }
62
+ };
63
+ }
64
+ changeBackgroundMarks = (e) => {
65
+ let t = {
66
+ ...this.props.model,
67
+ backgroundMarks: e
68
+ };
69
+ this.props.onChange(t);
70
+ };
71
+ changeLabels = (e) => {
72
+ let { model: t, onChange: n } = this.props;
73
+ n({
74
+ ...t,
75
+ labels: e
76
+ });
77
+ };
78
+ changeTitle = (e) => {
79
+ let { model: t, onChange: n } = this.props;
80
+ n({
81
+ ...t,
82
+ title: e
83
+ });
84
+ };
85
+ onConfigChange = (n, r) => {
86
+ let { model: i, onChange: a } = this.props, { defaultGridConfiguration: o = 0 } = i, { gridValues: s, labelValues: c, domain: l, range: u } = this.state, f = {
87
+ ...i,
88
+ ...n
89
+ }, { answers: p, domain: m, includeAxes: h, graph: g, range: _, standardGrid: v } = f, y = {
90
+ domain: [],
91
+ range: []
92
+ }, b = {
93
+ domain: [],
94
+ range: []
95
+ }, x = r >= 0 ? r : o;
96
+ if (h) {
97
+ let t = e(m, g.width, s.domain, c.domain);
98
+ y.domain = t.gridValues || [], b.domain = t.labelValues || [];
99
+ }
100
+ if (v) y.range = y.domain, b.range = b.domain, _.step = m.step, _.labelStep = m.labelStep;
101
+ else if (h) {
102
+ let t = e(_, g.height, s.range, c.range);
103
+ y.range = t.gridValues || [], b.range = t.labelValues || [];
104
+ }
105
+ let S = t(m, _, p);
106
+ if (!d(p, S)) {
107
+ this.setState({ dialog: {
108
+ isOpened: !0,
109
+ onClose: () => this.setState({ dialog: { isOpened: !1 } }, a({
110
+ ...i,
111
+ domain: l,
112
+ range: u
113
+ })),
114
+ onConfirm: () => {
115
+ this.setState({
116
+ gridValues: y,
117
+ labelValues: b,
118
+ dialog: { isOpened: !1 },
119
+ domain: { ...m },
120
+ range: { ..._ }
121
+ }, a({
122
+ ...f,
123
+ answers: S,
124
+ defaultGridConfiguration: x
125
+ }));
126
+ }
127
+ } });
128
+ return;
129
+ }
130
+ this.setState({
131
+ gridValues: y,
132
+ labelValues: b,
133
+ domain: { ...m },
134
+ range: { ..._ }
135
+ }), a({
136
+ ...f,
137
+ defaultGridConfiguration: x
138
+ });
139
+ };
140
+ onChangeView = (e, t) => {
141
+ let { graphDimensions: { enabled: n } = {} } = this.props;
142
+ n && this.setState({ showPixelGuides: t });
143
+ };
144
+ changeGridConfiguration = (e) => {
145
+ let { gridConfigurations: t } = this.props, { value: n } = e.target;
146
+ this.onConfigChange(t?.[n] || {}, n);
147
+ };
148
+ render() {
149
+ let { authoring: e = {}, availableTools: t = [], gridConfigurations: n = [], graphDimensions: r = {}, labelsPlaceholders: i, model: a, showLabels: o, dimensionsEnabled: d, showTitle: h, titlePlaceholder: w, mathMlOptions: T = {}, removeIncompleteTool: E } = this.props, { arrows: D, backgroundMarks: O, coordinatesOnHover: k, defaultGridConfiguration: A, domain: j, includeAxes: M, labels: N, range: P, standardGrid: F, title: I } = a || {}, L = (a || {}).graph || {}, { min: R, max: z, step: B } = r || {}, { dialog: V = {}, gridValues: H, labelValues: U, showPixelGuides: W } = this.state, G = {
150
+ min: Math.max(150, R),
151
+ max: Math.min(800, z),
152
+ step: B >= 1 ? Math.min(200, B) : 20
153
+ }, K = {
154
+ axisLabel: e.axisLabel,
155
+ dimensionsEnabled: d,
156
+ includeAxesEnabled: e.includeAxesEnabled,
157
+ labelStep: e.labelStep,
158
+ min: e.min,
159
+ max: e.max,
160
+ standardGridEnabled: e.standardGridEnabled,
161
+ step: e.step
162
+ }, q = e.enabled && Object.values(K).some((e) => typeof e == "object" ? e.enabled : e);
163
+ return /* @__PURE__ */ u(_, { children: [
164
+ /* @__PURE__ */ u(v, { children: [n && n.length ? /* @__PURE__ */ u(x, { children: [/* @__PURE__ */ l(S, {
165
+ component: "div",
166
+ variant: "h6",
167
+ children: "Grid Configuration"
168
+ }), /* @__PURE__ */ l(C, {
169
+ input: /* @__PURE__ */ l(m, {}),
170
+ displayEmpty: !0,
171
+ onChange: this.changeGridConfiguration,
172
+ value: A,
173
+ MenuProps: { transitionDuration: {
174
+ enter: 225,
175
+ exit: 195
176
+ } },
177
+ children: (n || []).map((e, t) => /* @__PURE__ */ l(p, {
178
+ value: t,
179
+ children: e.label
180
+ }, t))
181
+ })] }) : null, q && /* @__PURE__ */ l(c, {
182
+ displayedFields: K,
183
+ domain: j,
184
+ gridValues: H,
185
+ includeAxes: M,
186
+ labelValues: U,
187
+ range: P,
188
+ size: L,
189
+ sizeConstraints: G,
190
+ standardGrid: F,
191
+ onChange: this.onConfigChange,
192
+ onChangeView: this.onChangeView
193
+ })] }),
194
+ /* @__PURE__ */ u(y, { children: [
195
+ /* @__PURE__ */ l(g, {
196
+ component: "div",
197
+ variant: "h6",
198
+ children: "Define Graph Attributes"
199
+ }),
200
+ /* @__PURE__ */ l(b, {
201
+ component: "div",
202
+ variant: "body1",
203
+ children: "Use this interface to add/edit a title and/or labels, and to set background shapes"
204
+ }),
205
+ /* @__PURE__ */ l(s, {
206
+ axesSettings: { includeArrows: D },
207
+ backgroundMarks: [],
208
+ coordinatesOnHover: k,
209
+ collapsibleToolbar: !0,
210
+ collapsibleToolbarTitle: "Add Background Shapes to Graph",
211
+ domain: j,
212
+ labels: N,
213
+ labelsPlaceholders: i,
214
+ marks: O,
215
+ onChangeLabels: this.changeLabels,
216
+ onChangeMarks: this.changeBackgroundMarks,
217
+ onChangeTitle: this.changeTitle,
218
+ range: P,
219
+ showLabels: o,
220
+ showPixelGuides: W,
221
+ showTitle: h,
222
+ size: {
223
+ width: L.width,
224
+ height: L.height
225
+ },
226
+ title: I,
227
+ titlePlaceholder: w,
228
+ toolbarTools: t,
229
+ mathMlOptions: T,
230
+ removeIncompleteTool: E
231
+ }, "graphing-config")
232
+ ] }, "graph"),
233
+ /* @__PURE__ */ l(f, {
234
+ open: V.isOpened,
235
+ title: "Warning",
236
+ text: "This change would make it impossible for students to plot one or more graph objects in the current correct answers. If you proceed, all such graph objects will be removed from the correct answers.",
237
+ onClose: V.onClose,
238
+ onConfirm: V.onConfirm
239
+ })
240
+ ] });
241
+ }
242
+ };
243
+ //#endregion
244
+ export { w as default };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/graphing/configure/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
+ export default class GraphLinesConfigure extends HTMLElement {
10
+ static createDefaultModel: (model?: {}) => {
11
+ answers: any;
12
+ defaultTool: any;
13
+ range: {};
14
+ graph: {};
15
+ arrows: {
16
+ left: boolean;
17
+ right: boolean;
18
+ up: boolean;
19
+ down: boolean;
20
+ };
21
+ backgroundMarks: never[];
22
+ coordinatesOnHover: boolean;
23
+ defaultGridConfiguration: number;
24
+ domain: {
25
+ min: number;
26
+ max: number;
27
+ step: number;
28
+ labelStep: number;
29
+ axisLabel: string;
30
+ };
31
+ includeAxes: boolean;
32
+ labels: {};
33
+ labelsEnabled: boolean;
34
+ padding: boolean;
35
+ prompt: string;
36
+ promptEnabled: boolean;
37
+ rationale: string;
38
+ rationaleEnabled: boolean;
39
+ standardGrid: boolean;
40
+ studentInstructionsEnabled: boolean;
41
+ teacherInstructions: string;
42
+ teacherInstructionsEnabled: boolean;
43
+ title: string;
44
+ titleEnabled: boolean;
45
+ toolbarTools: string[];
46
+ };
47
+ constructor();
48
+ set model(m: any);
49
+ resetModelAfterConfigurationIsSet: any;
50
+ set configuration(c: any);
51
+ onModelChanged: any;
52
+ onConfigurationChanged: any;
53
+ insertImage: any;
54
+ onDeleteImage: any;
55
+ insertSound(handler: any): void;
56
+ onDeleteSound(src: any, done: any): void;
57
+ _render(): void;
58
+ disconnectedCallback(): void;
59
+ }
@@ -0,0 +1,96 @@
1
+ import e from "./configure.js";
2
+ import t from "./defaults.js";
3
+ import n from "react";
4
+ import { createRoot as r } from "react-dom/client";
5
+ import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
+ import a from "debug";
7
+ import { cloneDeep as o } from "@pie-element/shared-lodash";
8
+ import { DeleteImageEvent as s, DeleteSoundEvent as c, InsertImageEvent as l, InsertSoundEvent as u, ModelUpdatedEvent as d } from "@pie-element/shared-configure-events";
9
+ //#region src/author/index.ts
10
+ var f = a("pie-elements:graphing:configure"), p = (e) => Object.keys(e || {}).sort().reduce((t, n) => (n !== "correctAnswer" && (t[n] = e[n]), t), {}), m = class a extends HTMLElement {
11
+ static createDefaultModel = (e = {}) => {
12
+ let n = {
13
+ ...t.model,
14
+ ...e
15
+ }, { answers: r = {}, domain: i = {}, defaultTool: a, graph: o = {}, range: s = {}, standardGrid: c, toolbarTools: l } = n, u = (l || []).filter((e) => e !== "label"), d = a || u.length && u[0] || "";
16
+ return {
17
+ ...n,
18
+ answers: r && r.correctAnswer && {
19
+ correctAnswer: r.correctAnswer,
20
+ ...p(r)
21
+ } || r,
22
+ defaultTool: d,
23
+ range: c && {
24
+ ...s,
25
+ min: i.min,
26
+ max: i.max,
27
+ step: i.step,
28
+ labelStep: i.labelStep
29
+ } || s,
30
+ graph: c && {
31
+ ...o,
32
+ height: o.width
33
+ } || o
34
+ };
35
+ };
36
+ constructor() {
37
+ super(), this._root = null, this._model = a.createDefaultModel(), this._configuration = t.configuration;
38
+ }
39
+ set model(e) {
40
+ this._model = a.createDefaultModel(e), this._modelCopy = o(this._model), this._render();
41
+ }
42
+ resetModelAfterConfigurationIsSet = () => {
43
+ let e = document.querySelectorAll("pie-author");
44
+ this.hasPlayerAsParent = Array.from(e).some((e) => e.contains(this)), this.hasPlayerAsParent && (this._modelCopy ? this._model = this._modelCopy : delete this._modelCopy);
45
+ };
46
+ set configuration(e) {
47
+ this._configuration = {
48
+ ...t.configuration,
49
+ ...e
50
+ }, this.resetModelAfterConfigurationIsSet(), e.language?.enabled ? e.languageChoices?.options?.length && (this._model.language = e.languageChoices.options[0].value) : e.language.settings ? this._model.language && (this._configuration.language.enabled = !0) : delete this._model.language, this._render();
51
+ }
52
+ onModelChanged = (e) => {
53
+ this._model = e, this._render(), f("[onModelChanged]: ", this._model), this.dispatchEvent(new d(this._model));
54
+ };
55
+ onConfigurationChanged = (e) => {
56
+ this._configuration = e, this._render();
57
+ };
58
+ insertImage = (e) => {
59
+ this.dispatchEvent(new l(e));
60
+ };
61
+ onDeleteImage = (e, t) => {
62
+ this.dispatchEvent(new s(e, t));
63
+ };
64
+ insertSound(e) {
65
+ this.dispatchEvent(new u(e));
66
+ }
67
+ onDeleteSound(e, t) {
68
+ this.dispatchEvent(new c(e, t));
69
+ }
70
+ _render() {
71
+ if (this._model) {
72
+ let t = n.createElement(e, {
73
+ onModelChanged: this.onModelChanged,
74
+ onConfigurationChanged: this.onConfigurationChanged,
75
+ model: this._model,
76
+ configuration: this._configuration,
77
+ imageSupport: {
78
+ add: this.insertImage,
79
+ delete: this.onDeleteImage
80
+ },
81
+ uploadSoundSupport: {
82
+ add: this.insertSound.bind(this),
83
+ delete: this.onDeleteSound.bind(this)
84
+ }
85
+ });
86
+ this._root ||= r(this), this._root.render(t), queueMicrotask(() => {
87
+ i(this);
88
+ });
89
+ }
90
+ }
91
+ disconnectedCallback() {
92
+ this._root && this._root.unmount();
93
+ }
94
+ };
95
+ //#endregion
96
+ export { m as default };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/graphing/configure/src/utils.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
+ export declare const VALID_LABEL_VALUES: {
10
+ 0.01: number[];
11
+ 0.02: number[];
12
+ 0.04: number[];
13
+ 0.05: number[];
14
+ 0.0625: number[];
15
+ 0.1: number[];
16
+ 0.125: number[];
17
+ 0.2: number[];
18
+ 0.25: number[];
19
+ 0.5: number[];
20
+ 1: number[];
21
+ 2: number[];
22
+ 3: number[];
23
+ 4: number[];
24
+ 5: number[];
25
+ 8: number[];
26
+ 10: number[];
27
+ 12: number[];
28
+ 15: number[];
29
+ 20: number[];
30
+ 40: number[];
31
+ 50: number[];
32
+ 64: number[];
33
+ 100: number[];
34
+ 500: number[];
35
+ 1000: number[];
36
+ };
37
+ export declare const getGridValues: (axis: any, size: any, prefferedValues?: boolean) => number[];
38
+ export declare const getLabelValues: (value: any) => any;
39
+ export declare const applyConstraints: (axis: any, size: any, oldGridValues: any, oldLabelValues: any) => {
40
+ gridValues: number[];
41
+ labelValues: any;
42
+ };
43
+ export declare const filterPlotableMarks: (domain: any, range: any, answers: any) => {};