@pie-element/extended-text-entry 15.1.1 → 15.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 (100) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/defaults.d.ts +166 -0
  4. package/dist/author/defaults.js +209 -0
  5. package/dist/author/index.d.ts +52 -0
  6. package/dist/author/index.js +74 -0
  7. package/dist/author/main.d.ts +26 -0
  8. package/dist/author/main.js +166 -0
  9. package/dist/browser/author/index.js +495 -0
  10. package/dist/browser/author/index.js.map +1 -0
  11. package/dist/browser/browser-kkT1XVKw.js +219 -0
  12. package/dist/browser/browser-kkT1XVKw.js.map +1 -0
  13. package/dist/browser/controller/index.js +184 -0
  14. package/dist/browser/controller/index.js.map +1 -0
  15. package/dist/browser/delivery/index.js +98 -0
  16. package/dist/browser/delivery/index.js.map +1 -0
  17. package/dist/browser/dist-CfUys1Kx.js +47872 -0
  18. package/dist/browser/dist-CfUys1Kx.js.map +1 -0
  19. package/dist/browser/extended-text-entry.css +2 -0
  20. package/dist/browser/main-BVg6yw7a.js +714 -0
  21. package/dist/browser/main-BVg6yw7a.js.map +1 -0
  22. package/dist/browser/print/index.js +48 -0
  23. package/dist/browser/print/index.js.map +1 -0
  24. package/dist/controller/defaults.d.ts +33 -0
  25. package/dist/controller/defaults.js +104 -0
  26. package/dist/controller/index.d.ts +59 -0
  27. package/dist/controller/index.js +72 -0
  28. package/dist/delivery/annotation/annotation-editor.d.ts +47 -0
  29. package/dist/delivery/annotation/annotation-editor.js +296 -0
  30. package/dist/delivery/annotation/annotation-menu.d.ts +25 -0
  31. package/dist/delivery/annotation/annotation-menu.js +113 -0
  32. package/dist/delivery/annotation/annotation-utils.d.ts +20 -0
  33. package/dist/delivery/annotation/annotation-utils.js +65 -0
  34. package/dist/delivery/annotation/freeform-editor.d.ts +30 -0
  35. package/dist/delivery/annotation/freeform-editor.js +143 -0
  36. package/dist/delivery/index.d.ts +23 -0
  37. package/dist/delivery/index.js +68 -0
  38. package/dist/delivery/main.d.ts +27 -0
  39. package/dist/delivery/main.js +134 -0
  40. package/dist/extended-text-entry.css +2 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.iife.d.ts +8 -0
  43. package/dist/index.iife.js +403 -0
  44. package/dist/index.js +2 -0
  45. package/dist/print/index.d.ts +15 -0
  46. package/dist/print/index.js +48 -0
  47. package/dist/runtime-support.d.ts +12 -0
  48. package/dist/runtime-support.js +12 -0
  49. package/package.json +89 -23
  50. package/CHANGELOG.json +0 -1282
  51. package/CHANGELOG.md +0 -2264
  52. package/LICENSE.md +0 -5
  53. package/README.md +0 -1
  54. package/configure/CHANGELOG.json +0 -922
  55. package/configure/CHANGELOG.md +0 -1953
  56. package/configure/lib/defaults.js +0 -224
  57. package/configure/lib/defaults.js.map +0 -1
  58. package/configure/lib/index.js +0 -125
  59. package/configure/lib/index.js.map +0 -1
  60. package/configure/lib/main.js +0 -247
  61. package/configure/lib/main.js.map +0 -1
  62. package/configure/package.json +0 -23
  63. package/controller/CHANGELOG.json +0 -362
  64. package/controller/CHANGELOG.md +0 -1183
  65. package/controller/lib/defaults.js +0 -91
  66. package/controller/lib/defaults.js.map +0 -1
  67. package/controller/lib/index.js +0 -101
  68. package/controller/lib/index.js.map +0 -1
  69. package/controller/package.json +0 -16
  70. package/docs/config-schema.json +0 -1782
  71. package/docs/config-schema.json.md +0 -1333
  72. package/docs/demo/config.js +0 -7
  73. package/docs/demo/generate.js +0 -14
  74. package/docs/demo/index.html +0 -3
  75. package/docs/demo/session.js +0 -7
  76. package/docs/pie-schema.json +0 -954
  77. package/docs/pie-schema.json.md +0 -717
  78. package/lib/annotation/annotation-editor.js +0 -636
  79. package/lib/annotation/annotation-editor.js.map +0 -1
  80. package/lib/annotation/annotation-menu.js +0 -147
  81. package/lib/annotation/annotation-menu.js.map +0 -1
  82. package/lib/annotation/annotation-utils.js +0 -205
  83. package/lib/annotation/annotation-utils.js.map +0 -1
  84. package/lib/annotation/freeform-editor.js +0 -241
  85. package/lib/annotation/freeform-editor.js.map +0 -1
  86. package/lib/index.js +0 -108
  87. package/lib/index.js.map +0 -1
  88. package/lib/main.js +0 -205
  89. package/lib/main.js.map +0 -1
  90. package/lib/print.js +0 -86
  91. package/lib/print.js.map +0 -1
  92. package/module/configure.js +0 -1
  93. package/module/controller.js +0 -139
  94. package/module/demo.js +0 -38
  95. package/module/element.js +0 -1
  96. package/module/index.html +0 -21
  97. package/module/manifest.json +0 -22
  98. package/module/print-demo.js +0 -76
  99. package/module/print.html +0 -18
  100. package/module/print.js +0 -1
@@ -0,0 +1,143 @@
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import { Popover as a, TextField as o } from "@mui/material";
6
+ //#region src/delivery/annotation/freeform-editor.tsx
7
+ var s = n(a)(({ theme: e, annotationType: t }) => ({ "& .MuiPaper-root": {
8
+ overflowX: "unset",
9
+ overflowY: "unset",
10
+ marginLeft: "16px",
11
+ "&::before": {
12
+ position: "absolute",
13
+ right: "100%",
14
+ top: "13px",
15
+ border: "solid transparent",
16
+ content: "\"\"",
17
+ height: 0,
18
+ width: 0,
19
+ pointerEvents: "none",
20
+ borderWidth: "7px",
21
+ borderRightColor: e.palette.grey[100]
22
+ },
23
+ ...t === "negative" && { "&::before": { borderRightColor: "rgb(255, 204, 238) !important" } },
24
+ ...t === "positive" && { "&::before": { borderRightColor: "rgb(153, 255, 153) !important" } }
25
+ } })), c = n("div")(({ theme: e, annotationType: t }) => ({
26
+ width: "200px",
27
+ overflow: "hidden",
28
+ borderRadius: "4px",
29
+ backgroundColor: "#ffffff",
30
+ border: `4px solid ${e.palette.grey[100]}`,
31
+ ...t === "negative" && { borderColor: "rgb(255, 204, 238) !important" },
32
+ ...t === "positive" && { borderColor: "rgb(153, 255, 153) !important" }
33
+ })), l = n("div")(({ theme: e }) => ({
34
+ display: "flex",
35
+ flexWrap: "wrap",
36
+ borderTop: `2px solid ${e.palette.grey[100]}`
37
+ })), u = n("div")(({ theme: e, variant: t, annotationType: n }) => ({
38
+ flexGrow: 1,
39
+ width: "28%",
40
+ textAlign: "center",
41
+ padding: "4px",
42
+ cursor: "pointer",
43
+ "&:not(:nth-child(3n))": { borderRight: `1px solid ${e.palette.grey[100]}` },
44
+ "&:hover": { backgroundColor: e.palette.grey[100] },
45
+ ...t === "positive" && {
46
+ backgroundColor: "rgb(153, 255, 153) !important",
47
+ "&:hover": { filter: "brightness(85%)" }
48
+ },
49
+ ...t === "negative" && {
50
+ backgroundColor: "rgb(255, 204, 238) !important",
51
+ "&:hover": { filter: "brightness(85%)" }
52
+ },
53
+ ...t === "typeChange" && n === "negative" && { "&:hover": { backgroundColor: "rgb(153, 255, 153) !important" } },
54
+ ...t === "typeChange" && n === "positive" && { "&:hover": { backgroundColor: "rgb(255, 204, 238) !important" } }
55
+ })), d = class extends e.Component {
56
+ static propTypes = {
57
+ anchorEl: t.object,
58
+ open: t.bool,
59
+ offset: t.number,
60
+ value: t.string,
61
+ type: t.string,
62
+ onClose: t.func,
63
+ onDelete: t.func,
64
+ onSave: t.func,
65
+ onTypeChange: t.func
66
+ };
67
+ constructor(e) {
68
+ super(e), this.state = { value: e.value };
69
+ }
70
+ UNSAFE_componentWillReceiveProps(e) {
71
+ let { value: t } = e, { value: n } = this.props;
72
+ t !== n && this.setState({ value: t });
73
+ }
74
+ onValueChange = (e) => this.setState({ value: e.target.value });
75
+ handleSave = () => {
76
+ let { value: e, onSave: t, onClose: n, onDelete: r } = this.props, { value: i } = this.state;
77
+ i === "" && r(), e !== i && t(e, i), this.setState({ value: "" }), n();
78
+ };
79
+ handleTypeChange = () => {
80
+ let { onTypeChange: e, onDelete: t } = this.props, { value: n } = this.state;
81
+ n === "" ? t() : e(n), this.setState({ value: "" });
82
+ };
83
+ render() {
84
+ let { anchorEl: e, offset: t, onDelete: n, open: a, type: d } = this.props, { value: f } = this.state;
85
+ return /* @__PURE__ */ r(s, {
86
+ anchorEl: e,
87
+ elevation: 2,
88
+ open: a,
89
+ onClose: this.handleSave,
90
+ annotationType: d,
91
+ style: {
92
+ marginTop: `${t}px`,
93
+ transition: "margin-top 2s ease-out"
94
+ },
95
+ transitionDuration: {
96
+ enter: 225,
97
+ exit: 195
98
+ },
99
+ anchorOrigin: {
100
+ vertical: "top",
101
+ horizontal: "right"
102
+ },
103
+ transformOrigin: {
104
+ vertical: "top",
105
+ horizontal: "left"
106
+ },
107
+ children: /* @__PURE__ */ i(c, {
108
+ annotationType: d,
109
+ children: [/* @__PURE__ */ r(o, {
110
+ id: "annotation-editor",
111
+ style: {
112
+ padding: "2px 5px",
113
+ width: "95%"
114
+ },
115
+ autoFocus: !0,
116
+ multiline: !0,
117
+ rows: 1,
118
+ maxRows: 4,
119
+ value: f,
120
+ onChange: this.onValueChange,
121
+ InputProps: { disableUnderline: !0 }
122
+ }), /* @__PURE__ */ i(l, { children: [
123
+ /* @__PURE__ */ r(u, {
124
+ onClick: n,
125
+ children: "Delete"
126
+ }),
127
+ /* @__PURE__ */ r(u, {
128
+ variant: "typeChange",
129
+ annotationType: d,
130
+ onClick: this.handleTypeChange,
131
+ children: d === "negative" ? "Green" : "Pink"
132
+ }),
133
+ /* @__PURE__ */ r(u, {
134
+ onClick: this.handleSave,
135
+ children: "Save"
136
+ })
137
+ ] })]
138
+ })
139
+ });
140
+ }
141
+ };
142
+ //#endregion
143
+ export { d as default };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/extended-text-entry/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 function textContent(value: any): any;
10
+ export declare function isComplete(value: any): boolean;
11
+ export default class RootExtendedTextEntry extends HTMLElement {
12
+ constructor();
13
+ setLangAttribute(): void;
14
+ set model(m: any);
15
+ set session(s: any);
16
+ get session(): any;
17
+ valueChange(value: any): void;
18
+ annotationsChange(annotations: any): void;
19
+ commentChange(comment: any): void;
20
+ connectedCallback(): void;
21
+ render(): void;
22
+ disconnectedCallback(): void;
23
+ }
@@ -0,0 +1,68 @@
1
+ import e from "./main.js";
2
+ import t from "react";
3
+ import n from "debug";
4
+ import { createRoot as r } from "react-dom/client";
5
+ import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
+ import { ModelSetEvent as a, SessionChangedEvent as o } from "@pie-element/shared-player-events";
7
+ //#region src/delivery/index.ts
8
+ var s = n("@pie-elements:extended-text-entry"), c = new DOMParser();
9
+ function l(e) {
10
+ if (typeof e == "string") try {
11
+ return c.parseFromString(e, "text/html").body.textContent;
12
+ } catch {
13
+ return s("tried to parse as dom and failed", e), e;
14
+ }
15
+ }
16
+ function u(e) {
17
+ let t = l(e);
18
+ return t !== void 0 && t.length > 0;
19
+ }
20
+ var d = class extends HTMLElement {
21
+ constructor() {
22
+ super(), this._model = null, this._session = null, this._root = null;
23
+ }
24
+ setLangAttribute() {
25
+ let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
26
+ this.setAttribute("lang", t);
27
+ }
28
+ set model(e) {
29
+ this._model = e, this.dispatchEvent(new a(this.tagName.toLowerCase(), !1, !!this._model)), this.render();
30
+ }
31
+ set session(e) {
32
+ this._session = e, this.render();
33
+ }
34
+ get session() {
35
+ return this._session;
36
+ }
37
+ valueChange(e) {
38
+ this._session.value = e, this.dispatchEvent(new o(this.tagName.toLowerCase(), u(e))), this.render();
39
+ }
40
+ annotationsChange(e) {
41
+ this._session.annotations = e, this.dispatchEvent(new o(this.tagName.toLowerCase(), !0)), this.render();
42
+ }
43
+ commentChange(e) {
44
+ this._session.comment = e, this.dispatchEvent(new o(this.tagName.toLowerCase(), u(e))), this.render();
45
+ }
46
+ connectedCallback() {
47
+ this.setAttribute("aria-label", "Written Response Question"), this.setAttribute("role", "region"), this.render();
48
+ }
49
+ render() {
50
+ if (this._model && this._session) {
51
+ let n = t.createElement(e, {
52
+ model: this._model,
53
+ session: this._session,
54
+ onValueChange: this.valueChange.bind(this),
55
+ onAnnotationsChange: this.annotationsChange.bind(this),
56
+ onCommentChange: this.commentChange.bind(this)
57
+ });
58
+ this.setLangAttribute(), this._root ||= r(this), this._root.render(n), queueMicrotask(() => {
59
+ i(this);
60
+ });
61
+ }
62
+ }
63
+ disconnectedCallback() {
64
+ this._root && this._root.unmount();
65
+ }
66
+ };
67
+ //#endregion
68
+ export { d as default, u as isComplete, l as textContent };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/extended-text-entry/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
+ export declare class Main extends React.Component {
12
+ static propTypes: {
13
+ onValueChange: PropTypes.Validator<(...args: any[]) => any>;
14
+ onAnnotationsChange: PropTypes.Validator<(...args: any[]) => any>;
15
+ onCommentChange: PropTypes.Validator<(...args: any[]) => any>;
16
+ model: PropTypes.Requireable<object>;
17
+ session: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
18
+ value: PropTypes.Requireable<string>;
19
+ annotations: PropTypes.Requireable<any[]>;
20
+ comment: PropTypes.Requireable<string>;
21
+ }>>>;
22
+ };
23
+ changeSessionValue: import("@pie-element/shared-lodash").CancelableFunction<any>;
24
+ changeSessionComment: import("@pie-element/shared-lodash").CancelableFunction<any>;
25
+ render(): React.JSX.Element;
26
+ }
27
+ export default Main;
@@ -0,0 +1,134 @@
1
+ import e from "./annotation/annotation-editor.js";
2
+ import t from "react";
3
+ import n from "prop-types";
4
+ import { debounce as r } from "@pie-element/shared-lodash";
5
+ import i from "debug";
6
+ import a from "@mui/material/Typography";
7
+ import { styled as o } from "@mui/material/styles";
8
+ import s from "@pie-lib/editable-html-tip-tap";
9
+ import * as c from "@pie-lib/render-ui";
10
+ import { Collapsible as l, Feedback as u, PreviewPrompt as d, UiLayout as f, color as p } from "@pie-lib/render-ui";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ //#region src/delivery/main.tsx
13
+ function g(e) {
14
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
15
+ }
16
+ function _(e, t) {
17
+ return !e || g(e) ? e : g(e.default) ? e.default : t && g(e[t]) ? e[t] : t && g(e[t]?.default) ? e[t].default : e;
18
+ }
19
+ var v = _(f, "UiLayout") || _(w.UiLayout, "UiLayout"), y = _(d, "PreviewPrompt") || _(w.PreviewPrompt, "PreviewPrompt"), b = _(l, "Collapsible") || _(w.Collapsible, "Collapsible"), x = _(u, "Feedback") || _(w.Feedback, "Feedback"), S = c, C = S.default, w = C && typeof C == "object" ? C : S, T = i("@pie-ui:extended-text-entry"), E = o(v)({
20
+ backgroundColor: p.background(),
21
+ color: p.text()
22
+ }), D = o(a)(({ theme: e }) => ({
23
+ width: "100%",
24
+ color: p.text(),
25
+ marginBottom: e.spacing(2),
26
+ fontSize: "inherit"
27
+ })), O = o("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), k = o(s)(({ theme: e }) => ({
28
+ marginBottom: e.spacing(2),
29
+ borderRadius: "4px"
30
+ })), A = o("h2")({
31
+ position: "absolute",
32
+ left: "-10000px",
33
+ top: "auto",
34
+ width: "1px",
35
+ height: "1px",
36
+ overflow: "hidden"
37
+ }), j = class extends t.Component {
38
+ static propTypes = {
39
+ onValueChange: n.func.isRequired,
40
+ onAnnotationsChange: n.func.isRequired,
41
+ onCommentChange: n.func.isRequired,
42
+ model: n.object,
43
+ session: n.shape({
44
+ value: n.string,
45
+ annotations: n.array,
46
+ comment: n.string
47
+ }).isRequired
48
+ };
49
+ changeSessionValue = r(this.props.onValueChange, 1500);
50
+ changeSessionComment = r(this.props.onCommentChange, 1500);
51
+ render() {
52
+ let { model: t, session: n, onAnnotationsChange: r } = this.props, { animationsDisabled: i, annotatorMode: a, customKeys: o, dimensions: s, disabled: c, disabledAnnotator: l, equationEditor: u, extraCSSRules: d, feedback: f, mathInput: p, playersToolbarPosition: g, predefinedAnnotations: _, prompt: v, spanishInput: S, specialInput: C, spellCheckEnabled: w, teacherInstructions: j } = t, { annotations: M, comment: N, value: P } = n, { width: F, height: I } = s || {}, L = "40vh", R = { position: g === "top" ? "top" : "bottom" };
53
+ T("[render] disabled? ", c);
54
+ let z = /* @__PURE__ */ m(y, {
55
+ defaultClassName: "teacher-instructions",
56
+ prompt: j
57
+ }), B = [];
58
+ return S && B.push({ language: "spanish" }), C && B.push({ language: "special" }), /* @__PURE__ */ h(E, {
59
+ extraCSSRules: d,
60
+ ref: (e) => {
61
+ this.containerRef = e;
62
+ },
63
+ children: [
64
+ /* @__PURE__ */ m(A, { children: "Constructed Response Question" }),
65
+ j && /* @__PURE__ */ m(O, { children: i ? z : /* @__PURE__ */ m(b, {
66
+ labels: {
67
+ hidden: "Show Teacher Instructions",
68
+ visible: "Hide Teacher Instructions"
69
+ },
70
+ children: z
71
+ }) }),
72
+ v && /* @__PURE__ */ m(D, {
73
+ component: "span",
74
+ children: /* @__PURE__ */ m(y, {
75
+ defaultClassName: "prompt",
76
+ prompt: t.prompt
77
+ })
78
+ }),
79
+ a ? /* @__PURE__ */ m(e, {
80
+ text: P || "",
81
+ annotations: M || [],
82
+ comment: N || "",
83
+ predefinedAnnotations: _ || [],
84
+ onChange: r,
85
+ onCommentChange: this.changeSessionComment,
86
+ width: F,
87
+ height: I,
88
+ maxHeight: L,
89
+ disabled: l,
90
+ disabledMath: !p,
91
+ customKeys: o,
92
+ keypadMode: u
93
+ }) : /* @__PURE__ */ m(k, {
94
+ className: "response-area-editor",
95
+ onChange: this.changeSessionValue,
96
+ markup: P || "",
97
+ maxWidth: F && F.toString(),
98
+ minWidth: "100px",
99
+ minHeight: I && I.toString(),
100
+ maxHeight: L,
101
+ disabled: c,
102
+ highlightShape: !0,
103
+ toolbarOpts: R,
104
+ spellCheck: w,
105
+ charactersLimit: 5e4,
106
+ autoWidthToolbar: !0,
107
+ pluginProps: {
108
+ math: {
109
+ disabled: !p,
110
+ customKeys: this.props.model.customKeys,
111
+ keypadMode: this.props.model.equationEditor,
112
+ controlledKeypadMode: !1
113
+ },
114
+ video: { disabled: !0 },
115
+ audio: { disabled: !0 },
116
+ table: { disabled: !0 },
117
+ textAlign: { disabled: !0 },
118
+ h3: { disabled: !0 },
119
+ separateParagraphs: { disabled: !1 },
120
+ ul_list: { disabled: !0 },
121
+ ol_list: { disabled: !0 }
122
+ },
123
+ languageCharactersProps: B
124
+ }),
125
+ f && /* @__PURE__ */ m(x, {
126
+ correctness: "correct",
127
+ feedback: f
128
+ })
129
+ ]
130
+ });
131
+ }
132
+ };
133
+ //#endregion
134
+ export { j as default };