@pie-element/matrix 4.1.2-next.5 → 4.1.3

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 (117) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +1421 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +59 -0
  5. package/configure/CHANGELOG.json +1 -0
  6. package/configure/CHANGELOG.md +1347 -0
  7. package/configure/lib/HeaderCommon.js +28 -0
  8. package/configure/lib/HeaderCommon.js.map +1 -0
  9. package/configure/lib/Main.js +179 -0
  10. package/configure/lib/Main.js.map +1 -0
  11. package/configure/lib/MatrixColumnsSizeHeaderInput.js +56 -0
  12. package/configure/lib/MatrixColumnsSizeHeaderInput.js.map +1 -0
  13. package/configure/lib/MatrixLabelEditableButton.js +224 -0
  14. package/configure/lib/MatrixLabelEditableButton.js.map +1 -0
  15. package/configure/lib/MatrixLabelTypeHeaderInput.js +98 -0
  16. package/configure/lib/MatrixLabelTypeHeaderInput.js.map +1 -0
  17. package/configure/lib/MatrixRowsSizeHeaderInput.js +56 -0
  18. package/configure/lib/MatrixRowsSizeHeaderInput.js.map +1 -0
  19. package/configure/lib/MatrixValues.js +217 -0
  20. package/configure/lib/MatrixValues.js.map +1 -0
  21. package/configure/lib/NumberInput.js +77 -0
  22. package/configure/lib/NumberInput.js.map +1 -0
  23. package/configure/lib/columnLabelsGenerator.js +49 -0
  24. package/configure/lib/columnLabelsGenerator.js.map +1 -0
  25. package/configure/lib/defaults.js +86 -0
  26. package/configure/lib/defaults.js.map +1 -0
  27. package/configure/lib/index.js +98 -0
  28. package/configure/lib/index.js.map +1 -0
  29. package/configure/lib/isNumeric.js +11 -0
  30. package/configure/lib/isNumeric.js.map +1 -0
  31. package/configure/lib/matrixEntities.js +16 -0
  32. package/configure/lib/matrixEntities.js.map +1 -0
  33. package/configure/package.json +28 -0
  34. package/controller/CHANGELOG.json +1 -0
  35. package/controller/CHANGELOG.md +88 -0
  36. package/controller/lib/defaults.js +17 -0
  37. package/controller/lib/defaults.js.map +1 -0
  38. package/controller/lib/index.js +96 -0
  39. package/controller/lib/index.js.map +1 -0
  40. package/controller/package.json +17 -0
  41. package/docs/config-schema.json +1475 -0
  42. package/docs/config-schema.json.md +1093 -0
  43. package/docs/demo/config.js +8 -0
  44. package/docs/demo/generate.js +9 -0
  45. package/docs/demo/index.html +1 -0
  46. package/docs/demo/session.js +6 -0
  47. package/docs/pie-schema.json +1 -0
  48. package/docs/pie-schema.json.md +1 -0
  49. package/lib/ChoiceInput.js +59 -0
  50. package/lib/ChoiceInput.js.map +1 -0
  51. package/lib/Main.js +42 -0
  52. package/lib/Main.js.map +1 -0
  53. package/lib/Matrix.js +104 -0
  54. package/lib/Matrix.js.map +1 -0
  55. package/lib/index.js +80 -0
  56. package/lib/index.js.map +1 -0
  57. package/lib/session-updater.js +10 -0
  58. package/lib/session-updater.js.map +1 -0
  59. package/package.json +19 -83
  60. package/configure.js +0 -2
  61. package/controller.js +0 -1
  62. package/dist/author/HeaderCommon.d.ts +0 -12
  63. package/dist/author/HeaderCommon.js +0 -20
  64. package/dist/author/Main.d.ts +0 -27
  65. package/dist/author/Main.js +0 -134
  66. package/dist/author/MatrixColumnsSizeHeaderInput.d.ts +0 -21
  67. package/dist/author/MatrixColumnsSizeHeaderInput.js +0 -39
  68. package/dist/author/MatrixLabelEditableButton.d.ts +0 -27
  69. package/dist/author/MatrixLabelEditableButton.js +0 -191
  70. package/dist/author/MatrixLabelTypeHeaderInput.d.ts +0 -21
  71. package/dist/author/MatrixLabelTypeHeaderInput.js +0 -96
  72. package/dist/author/MatrixRowsSizeHeaderInput.d.ts +0 -21
  73. package/dist/author/MatrixRowsSizeHeaderInput.js +0 -39
  74. package/dist/author/MatrixValues.d.ts +0 -29
  75. package/dist/author/MatrixValues.js +0 -156
  76. package/dist/author/NumberInput.d.ts +0 -20
  77. package/dist/author/NumberInput.js +0 -61
  78. package/dist/author/columnLabelsGenerator.d.ts +0 -11
  79. package/dist/author/columnLabelsGenerator.js +0 -101
  80. package/dist/author/defaults.d.ts +0 -88
  81. package/dist/author/defaults.js +0 -56
  82. package/dist/author/index.d.ts +0 -31
  83. package/dist/author/index.js +0 -66
  84. package/dist/author/isNumeric.d.ts +0 -10
  85. package/dist/author/isNumeric.js +0 -4
  86. package/dist/author/matrixEntities.d.ts +0 -17
  87. package/dist/author/matrixEntities.js +0 -12
  88. package/dist/browser/Radio-1GgjpmF9.js +0 -10145
  89. package/dist/browser/Radio-1GgjpmF9.js.map +0 -1
  90. package/dist/browser/author/index.js +0 -45674
  91. package/dist/browser/author/index.js.map +0 -1
  92. package/dist/browser/controller/index.js +0 -60
  93. package/dist/browser/controller/index.js.map +0 -1
  94. package/dist/browser/delivery/index.js +0 -205
  95. package/dist/browser/delivery/index.js.map +0 -1
  96. package/dist/browser/dist-BjoC1dWE.js +0 -96
  97. package/dist/browser/dist-BjoC1dWE.js.map +0 -1
  98. package/dist/browser/matrix.css +0 -2
  99. package/dist/controller/defaults.d.ts +0 -19
  100. package/dist/controller/defaults.js +0 -17
  101. package/dist/controller/index.d.ts +0 -19
  102. package/dist/controller/index.js +0 -46
  103. package/dist/delivery/ChoiceInput.d.ts +0 -25
  104. package/dist/delivery/ChoiceInput.js +0 -36
  105. package/dist/delivery/Main.d.ts +0 -23
  106. package/dist/delivery/Main.js +0 -37
  107. package/dist/delivery/Matrix.d.ts +0 -29
  108. package/dist/delivery/Matrix.js +0 -81
  109. package/dist/delivery/index.d.ts +0 -22
  110. package/dist/delivery/index.js +0 -45
  111. package/dist/delivery/session-updater.d.ts +0 -9
  112. package/dist/index.d.ts +0 -1
  113. package/dist/index.iife.d.ts +0 -8
  114. package/dist/index.iife.js +0 -164
  115. package/dist/index.js +0 -2
  116. package/dist/runtime-support.d.ts +0 -12
  117. package/dist/runtime-support.js +0 -12
@@ -1,19 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/controller/src/defaults.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
- declare const _default: {
10
- columnLabels: string[];
11
- labelType: string;
12
- matrixValues: {};
13
- prompt: string;
14
- promptEnabled: boolean;
15
- rowLabels: string[];
16
- teacherInstructions: string;
17
- teacherInstructionsEnabled: boolean;
18
- };
19
- export default _default;
@@ -1,17 +0,0 @@
1
- //#region src/controller/defaults.ts
2
- var e = {
3
- columnLabels: [
4
- "COLUMN 1",
5
- "COLUMN 2",
6
- "COLUMN 3"
7
- ],
8
- labelType: "agreement",
9
- matrixValues: {},
10
- prompt: "",
11
- promptEnabled: !0,
12
- rowLabels: ["STATEMENT 1", "STATEMENT 2"],
13
- teacherInstructions: "",
14
- teacherInstructionsEnabled: !0
15
- };
16
- //#endregion
17
- export { e as default };
@@ -1,19 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/controller/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 declare const createDefaultModel: (model?: {}) => Promise<unknown>;
10
- /**
11
- *
12
- * @param {*} question
13
- * @param {*} session
14
- * @param {*} env
15
- */
16
- export declare function model(question: any, session: any, env: any): Promise<any>;
17
- export declare function outcome(model: any, session: any): Promise<unknown>;
18
- export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
19
- export declare const validate: (model?: {}, config?: {}) => {};
@@ -1,46 +0,0 @@
1
- import e from "./defaults.js";
2
- import { isEmpty as t } from "@pie-element/shared-lodash";
3
- //#region src/controller/index.ts
4
- var n = (t = {}) => new Promise((n) => n({
5
- ...e,
6
- ...t
7
- }));
8
- async function r(t, n, r) {
9
- let i = {
10
- ...e,
11
- ...t
12
- }, a = {
13
- ...i,
14
- disabled: r.mode !== "gather",
15
- mode: r.mode
16
- }, { role: o, mode: s } = r || {};
17
- return o === "instructor" && (s === "view" || s === "evaluate") ? a.teacherInstructions = i.teacherInstructionsEnabled ? i.teacherInstructions : null : a.teacherInstructions = null, a;
18
- }
19
- function i(e, n) {
20
- return new Promise((r) => {
21
- if (!n || t(n)) return r({
22
- score: 0,
23
- empty: !0
24
- });
25
- r({
26
- score: Object.keys(n.value).reduce((t, n) => t + (e.matrixValues[n] || 0), 0),
27
- empty: !1
28
- });
29
- });
30
- }
31
- var a = (e, t) => new Promise((n) => {
32
- if (t.mode !== "evaluate" && t.role === "instructor") {
33
- let { matrixValues: t } = e || [];
34
- n({
35
- id: "1",
36
- value: t
37
- });
38
- } else n(null);
39
- }), o = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), s = (e = {}, t = {}) => {
40
- let n = {};
41
- return ["teacherInstructions", "prompt"].forEach((r) => {
42
- t[r]?.required && !o(e[r]) && (n[r] = "This field is required.");
43
- }), n;
44
- };
45
- //#endregion
46
- export { a as createCorrectResponseSession, n as createDefaultModel, r as model, i as outcome, s as validate };
@@ -1,25 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/src/ChoiceInput.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 React from 'react';
10
- import PropTypes from 'prop-types';
11
- declare const ChoiceInput: {
12
- (props: any): React.JSX.Element;
13
- propTypes: {
14
- checked: PropTypes.Validator<boolean>;
15
- disabled: PropTypes.Validator<boolean>;
16
- matrixValue: PropTypes.Validator<number>;
17
- matrixKey: PropTypes.Validator<string>;
18
- onChange: PropTypes.Validator<(...args: any[]) => any>;
19
- };
20
- defaultProps: {
21
- checked: boolean;
22
- disabled: boolean;
23
- };
24
- };
25
- export default ChoiceInput;
@@ -1,36 +0,0 @@
1
- import "react";
2
- import e from "prop-types";
3
- import { color as t } from "@pie-lib/render-ui";
4
- import { jsx as n } from "react/jsx-runtime";
5
- import { styled as r } from "@mui/material/styles";
6
- import i from "@mui/material/Radio";
7
- //#region src/delivery/ChoiceInput.tsx
8
- var a = r(i)({
9
- "&.MuiRadio-root": { color: `var(--choice-input-color, ${t.text()})` },
10
- "&.MuiRadio-root.Mui-checked": { color: `var(--choice-input-selected-color, ${t.primary()})` },
11
- "&.MuiRadio-root.Mui-disabled": { color: `var(--choice-input-disabled-color, ${t.defaults.DISABLED})` }
12
- }), o = (e) => {
13
- let { disabled: t, checked: r, matrixKey: i, matrixValue: o, onChange: s } = e;
14
- return /* @__PURE__ */ n(a, {
15
- checked: r,
16
- onChange: () => {
17
- t || s({
18
- matrixValue: o,
19
- matrixKey: i
20
- });
21
- },
22
- disabled: t
23
- });
24
- };
25
- o.propTypes = {
26
- checked: e.bool.isRequired,
27
- disabled: e.bool.isRequired,
28
- matrixValue: e.number.isRequired,
29
- matrixKey: e.string.isRequired,
30
- onChange: e.func.isRequired
31
- }, o.defaultProps = {
32
- checked: !1,
33
- disabled: !1
34
- };
35
- //#endregion
36
- export { o as default };
@@ -1,23 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/src/Main.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 React from 'react';
10
- import PropTypes from 'prop-types';
11
- declare class Main extends React.Component {
12
- static propTypes: {
13
- model: PropTypes.Requireable<object>;
14
- session: PropTypes.Requireable<object>;
15
- onSessionChange: PropTypes.Requireable<(...args: any[]) => any>;
16
- };
17
- static defaultProps: {
18
- model: {};
19
- session: {};
20
- };
21
- render(): React.JSX.Element;
22
- }
23
- export default Main;
@@ -1,37 +0,0 @@
1
- import e from "./Matrix.js";
2
- import t from "react";
3
- import n from "prop-types";
4
- import * as r from "@pie-lib/render-ui";
5
- import { PreviewLayout as i } from "@pie-lib/render-ui";
6
- import { jsx as a } from "react/jsx-runtime";
7
- //#region src/delivery/Main.tsx
8
- function o(e) {
9
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
10
- }
11
- function s(e, t) {
12
- return !e || o(e) ? e : o(e.default) ? e.default : t && o(e[t]) ? e[t] : t && o(e[t]?.default) ? e[t].default : e;
13
- }
14
- var c = s(i, "PreviewLayout") || s(d.PreviewLayout, "PreviewLayout"), l = r, u = l.default, d = u && typeof u == "object" ? u : l, f = class extends t.Component {
15
- static propTypes = {
16
- model: n.object,
17
- session: n.object,
18
- onSessionChange: n.func
19
- };
20
- static defaultProps = {
21
- model: {},
22
- session: {}
23
- };
24
- render() {
25
- let { model: t, onSessionChange: n, session: r } = this.props, { extraCSSRules: i } = t;
26
- return /* @__PURE__ */ a(c, {
27
- extraCSSRules: i,
28
- children: /* @__PURE__ */ a(e, {
29
- ...t,
30
- session: r,
31
- onSessionChange: n
32
- })
33
- });
34
- }
35
- };
36
- //#endregion
37
- export { f as default };
@@ -1,29 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/src/Matrix.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 React from 'react';
10
- import PropTypes from 'prop-types';
11
- declare const Matrix: {
12
- (props: any): React.JSX.Element;
13
- propTypes: {
14
- prompt: PropTypes.Requireable<string>;
15
- teacherInstructions: PropTypes.Requireable<string>;
16
- session: PropTypes.Requireable<object>;
17
- matrixValues: PropTypes.Requireable<object>;
18
- rowLabels: PropTypes.Requireable<(string | null | undefined)[]>;
19
- columnLabels: PropTypes.Requireable<(string | null | undefined)[]>;
20
- disabled: PropTypes.Validator<boolean>;
21
- onSessionChange: PropTypes.Validator<(...args: any[]) => any>;
22
- };
23
- defaultProps: {
24
- session: {
25
- value: {};
26
- };
27
- };
28
- };
29
- export default Matrix;
@@ -1,81 +0,0 @@
1
- import e from "./ChoiceInput.js";
2
- import "react";
3
- import t from "prop-types";
4
- import * as n from "@pie-lib/render-ui";
5
- import { Collapsible as r, PreviewPrompt as i, color as a } from "@pie-lib/render-ui";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
- import c from "styled-components";
8
- //#region src/delivery/Matrix.tsx
9
- function l(e) {
10
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
11
- }
12
- function u(e, t) {
13
- return !e || l(e) ? e : l(e.default) ? e.default : t && l(e[t]) ? e[t] : t && l(e[t]?.default) ? e[t].default : e;
14
- }
15
- var d = u(i, "PreviewPrompt") || u(h.PreviewPrompt, "PreviewPrompt"), f = u(r, "Collapsible") || u(h.Collapsible, "Collapsible"), p = n, m = p.default, h = m && typeof m == "object" ? m : p, g = c.div`
16
- color: ${a.text()};
17
- background-color: ${a.background()};
18
- font-family: Roboto, Arial, Helvetica, sans-serif;
19
- `, _ = c.div`
20
- display: grid;
21
- grid-template-columns: ${(e) => e.gridTemplateColumns};
22
- grid-column-gap: 30px;
23
- grid-row-gap: 20px;
24
- margin-top: 20px;
25
- `, v = c(f)`
26
- margin-bottom: 16px;
27
- `, y = c.div`
28
- align-self: center;
29
- justify-self: center;
30
- white-space: nowrap;
31
- `, b = (t) => {
32
- let { disabled: n, prompt: r, onSessionChange: i, columnLabels: a, matrixValues: c, rowLabels: l, session: u, teacherInstructions: f } = t, p = [];
33
- for (let t = 0; t < l.length + 1; t++) for (let r = 0; r < a.length + 1; r++) {
34
- let s;
35
- if (t === 0 && r === 0) s = null;
36
- else if (t === 0) s = a[r - 1];
37
- else if (r === 0) s = l[t - 1];
38
- else {
39
- let a = `${t - 1}-${r - 1}`, l = c[a];
40
- s = /* @__PURE__ */ o(e, {
41
- matrixKey: a,
42
- matrixValue: l || 0,
43
- disabled: n,
44
- onChange: i,
45
- checked: u.value && Object.prototype.hasOwnProperty.call(u.value, a)
46
- });
47
- }
48
- p.push(s);
49
- }
50
- let m = [...a, {}].map(() => "min-content").join(" ");
51
- return /* @__PURE__ */ s(g, { children: [
52
- f && /* @__PURE__ */ o(v, {
53
- className: f,
54
- labels: {
55
- hidden: "Show Teacher Instructions",
56
- visible: "Hide Teacher Instructions"
57
- },
58
- children: /* @__PURE__ */ o(d, { prompt: f })
59
- }),
60
- /* @__PURE__ */ o(d, {
61
- className: "prompt",
62
- prompt: r
63
- }),
64
- /* @__PURE__ */ o(_, {
65
- gridTemplateColumns: m,
66
- children: p.map((e, t) => /* @__PURE__ */ o(y, { children: e }, `${t}`))
67
- })
68
- ] });
69
- };
70
- b.propTypes = {
71
- prompt: t.string,
72
- teacherInstructions: t.string,
73
- session: t.object,
74
- matrixValues: t.object,
75
- rowLabels: t.arrayOf(t.string),
76
- columnLabels: t.arrayOf(t.string),
77
- disabled: t.bool.isRequired,
78
- onSessionChange: t.func.isRequired
79
- }, b.defaultProps = { session: { value: {} } };
80
- //#endregion
81
- export { b as default };
@@ -1,22 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/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 declare const isComplete: (session: any) => boolean;
10
- export default class Matrix extends HTMLElement {
11
- constructor();
12
- set model(m: any);
13
- set session(s: any);
14
- get session(): any;
15
- sessionChanged({ matrixKey, matrixValue }: {
16
- matrixKey: any;
17
- matrixValue: any;
18
- }): void;
19
- connectedCallback(): void;
20
- _render(): void;
21
- disconnectedCallback(): void;
22
- }
@@ -1,45 +0,0 @@
1
- import e from "./Main.js";
2
- import t from "react";
3
- import { createRoot as n } from "react-dom/client";
4
- import { SessionChangedEvent as r } from "@pie-element/shared-player-events";
5
- import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
- //#region src/delivery/index.ts
7
- var a = (e) => !e || !e.value ? !1 : !!Object.keys(e.value).length, o = class extends HTMLElement {
8
- constructor() {
9
- super(), this._root = null;
10
- }
11
- set model(e) {
12
- this._model = e, this._render();
13
- }
14
- set session(e) {
15
- this._session = e, this._render();
16
- }
17
- get session() {
18
- return this._session;
19
- }
20
- sessionChanged({ matrixKey: e, matrixValue: t }) {
21
- let n = e.split("-")[0], i = Object.keys(this._session.value || {}).reduce((e, t) => (t.startsWith(n) || (e[t] = this._session.value[t]), e), {});
22
- i[e] = t, this._session.value = i;
23
- let o = a(this._session, this._model);
24
- this.dispatchEvent(new r(this.tagName.toLowerCase(), o)), this._render();
25
- }
26
- connectedCallback() {
27
- this._render();
28
- }
29
- _render() {
30
- if (!this._model || !this._session) return;
31
- let r = t.createElement(e, {
32
- model: this._model,
33
- session: this._session,
34
- onSessionChange: this.sessionChanged.bind(this)
35
- });
36
- this._root ||= n(this), this._root.render(r), queueMicrotask(() => {
37
- i(this);
38
- });
39
- }
40
- disconnectedCallback() {
41
- this._root && this._root.unmount();
42
- }
43
- };
44
- //#endregion
45
- export { o as default, a as isComplete };
@@ -1,9 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/matrix/src/session-updater.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 function updateSessionValue(session: any, data: any): void;
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from './delivery/index.js';
@@ -1,8 +0,0 @@
1
- /**
2
- * IIFE entry point for matrix element
3
- * This file is only used for IIFE builds and includes auto-registration
4
- *
5
- * @sync-generated - Auto-generated during sync from pie-elements
6
- */
7
- import Element from './index.js';
8
- export default Element;