@pie-lib/render-ui 8.0.2-next.20261007003844 → 8.0.2
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.
- package/dist/feedback.js +12 -11
- package/dist/html-and-math.js +7 -6
- package/dist/preview-prompt.js +22 -21
- package/package.json +6 -5
package/dist/feedback.js
CHANGED
|
@@ -3,15 +3,16 @@ import i from "react";
|
|
|
3
3
|
import a from "prop-types";
|
|
4
4
|
import { styled as o } from "@mui/material/styles";
|
|
5
5
|
import { CSSTransition as s, TransitionGroup as c } from "react-transition-group";
|
|
6
|
-
import {
|
|
6
|
+
import { sanitizeModelHtml as l } from "@pie-element/shared-utils";
|
|
7
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
7
8
|
//#region src/feedback.tsx
|
|
8
|
-
var
|
|
9
|
+
var d = o("div")({
|
|
9
10
|
transformOrigin: "0% 0px 0px",
|
|
10
11
|
width: "100%",
|
|
11
12
|
display: "block",
|
|
12
13
|
overflow: "hidden",
|
|
13
14
|
"&.incorrect": { color: "#946202" }
|
|
14
|
-
}),
|
|
15
|
+
}), f = o("div")({
|
|
15
16
|
WebkitFontSmoothing: "antialiased",
|
|
16
17
|
backgroundColor: `var(--feedback-bg-color, ${e()})`,
|
|
17
18
|
borderRadius: "4px",
|
|
@@ -22,7 +23,7 @@ var u = o("div")({
|
|
|
22
23
|
color: `var(--feedback-color, ${r()})`,
|
|
23
24
|
"&.correct": { backgroundColor: `var(--feedback-correct-bg-color, ${t()})` },
|
|
24
25
|
"&.incorrect": { backgroundColor: `var(--feedback-incorrect-bg-color, ${n()})` }
|
|
25
|
-
}),
|
|
26
|
+
}), p = o("div")({
|
|
26
27
|
"&.feedback-enter": { height: "1px" },
|
|
27
28
|
"&.feedback-enter-active": {
|
|
28
29
|
height: "45px",
|
|
@@ -33,7 +34,7 @@ var u = o("div")({
|
|
|
33
34
|
height: "1px",
|
|
34
35
|
transition: "height 200ms"
|
|
35
36
|
}
|
|
36
|
-
}),
|
|
37
|
+
}), m = class extends i.Component {
|
|
37
38
|
static propTypes = {
|
|
38
39
|
correctness: a.string,
|
|
39
40
|
feedback: a.string
|
|
@@ -41,25 +42,25 @@ var u = o("div")({
|
|
|
41
42
|
nodeRef = i.createRef();
|
|
42
43
|
renderFeedback() {
|
|
43
44
|
let { correctness: e, feedback: t } = this.props;
|
|
44
|
-
return !e || !t ? null : /* @__PURE__ */
|
|
45
|
+
return !e || !t ? null : /* @__PURE__ */ u(s, {
|
|
45
46
|
nodeRef: this.nodeRef,
|
|
46
47
|
timeout: {
|
|
47
48
|
enter: 500,
|
|
48
49
|
exit: 200
|
|
49
50
|
},
|
|
50
51
|
classNames: "feedback",
|
|
51
|
-
children: /* @__PURE__ */
|
|
52
|
+
children: /* @__PURE__ */ u(p, {
|
|
52
53
|
ref: this.nodeRef,
|
|
53
|
-
children: /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ u(d, { children: /* @__PURE__ */ u(f, {
|
|
54
55
|
className: e,
|
|
55
|
-
dangerouslySetInnerHTML: { __html: t }
|
|
56
|
+
dangerouslySetInnerHTML: { __html: l(t) }
|
|
56
57
|
}) })
|
|
57
58
|
})
|
|
58
59
|
}, "hasFeedback");
|
|
59
60
|
}
|
|
60
61
|
render() {
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
+
return /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u(c, { children: this.renderFeedback() }) });
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
65
|
//#endregion
|
|
65
|
-
export {
|
|
66
|
+
export { m as Feedback, m as default };
|
package/dist/html-and-math.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import e from "react";
|
|
2
2
|
import t from "prop-types";
|
|
3
|
-
import {
|
|
3
|
+
import { sanitizeModelHtml as n } from "@pie-element/shared-utils";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
5
|
//#region src/html-and-math.tsx
|
|
5
|
-
var
|
|
6
|
+
var i = class extends e.Component {
|
|
6
7
|
static propTypes = {
|
|
7
8
|
tag: t.string,
|
|
8
9
|
className: t.string,
|
|
@@ -13,13 +14,13 @@ var r = class extends e.Component {
|
|
|
13
14
|
html: ""
|
|
14
15
|
};
|
|
15
16
|
render() {
|
|
16
|
-
let { tag: e, className: t, html:
|
|
17
|
-
return /* @__PURE__ */
|
|
17
|
+
let { tag: e, className: t, html: i } = this.props;
|
|
18
|
+
return /* @__PURE__ */ r(e || "div", {
|
|
18
19
|
ref: (e) => this.node = e,
|
|
19
20
|
className: t,
|
|
20
|
-
dangerouslySetInnerHTML: { __html:
|
|
21
|
+
dangerouslySetInnerHTML: { __html: n(i) }
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
//#endregion
|
|
25
|
-
export {
|
|
26
|
+
export { i as default };
|
package/dist/preview-prompt.js
CHANGED
|
@@ -3,27 +3,28 @@ import { createUniqueId as i } from "./unique-id.js";
|
|
|
3
3
|
import a, { Component as o } from "react";
|
|
4
4
|
import s from "prop-types";
|
|
5
5
|
import { styled as c } from "@mui/material/styles";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import d from "@pie-
|
|
6
|
+
import { sanitizeModelHtml as l } from "@pie-element/shared-utils";
|
|
7
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
8
|
+
import { renderMath as d } from "@pie-element/shared-math-rendering-mathjax";
|
|
9
|
+
import f from "@pie-lib/translator";
|
|
9
10
|
//#region src/preview-prompt.tsx
|
|
10
|
-
var { translator:
|
|
11
|
-
[`& .${
|
|
11
|
+
var { translator: p } = f, m = "pie-prompt-audio-player", h = "play-audio-button", g = (e) => `&:not(.MathJax) > table${e}, &:not(.MathJax) > .pie-table-scroll > table${e}`, _ = c("div")(({ theme: i, tagName: a }) => ({
|
|
12
|
+
[`& .${h}:focus-visible`]: {
|
|
12
13
|
outline: `2px solid ${e()}`,
|
|
13
14
|
outlineOffset: "2px"
|
|
14
15
|
},
|
|
15
|
-
[
|
|
16
|
+
[g(":not([role=\"presentation\"])")]: { borderCollapse: "collapse" },
|
|
16
17
|
"&:not(.MathJax) table[border]:not([role=\"presentation\"]), &:not(.MathJax) table[border]:not([role=\"presentation\"]) td, &:not(.MathJax) table[border]:not([role=\"presentation\"]) th": {
|
|
17
18
|
borderStyle: "solid",
|
|
18
19
|
borderColor: t()
|
|
19
20
|
},
|
|
20
|
-
[
|
|
21
|
-
[
|
|
21
|
+
[g(":not([role=\"presentation\"]):has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)")]: { backgroundColor: n() },
|
|
22
|
+
[g(":not([role=\"presentation\"]):has(tbody tr > td:first-child) tbody tr:nth-child(even) td")]: { backgroundColor: n() },
|
|
22
23
|
"&:not(.MathJax) table:not([role=\"presentation\"]) td, &:not(.MathJax) table:not([role=\"presentation\"]) th": {
|
|
23
24
|
padding: ".6em 1em",
|
|
24
25
|
textAlign: "left"
|
|
25
26
|
},
|
|
26
|
-
[
|
|
27
|
+
[g(" td > p.kds-indent")]: { textAlign: "initial" },
|
|
27
28
|
"&.prompt": {
|
|
28
29
|
verticalAlign: "middle",
|
|
29
30
|
color: r()
|
|
@@ -44,7 +45,7 @@ var { translator: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button
|
|
|
44
45
|
cursor: "pointer",
|
|
45
46
|
"& > p": { margin: "0 0 0 0 !important" }
|
|
46
47
|
}
|
|
47
|
-
})),
|
|
48
|
+
})), v = /\\embed\{newLine\}\[\]/g, y = "\\newline ", b = "preview-prompt", x = class extends o {
|
|
48
49
|
static propTypes = {
|
|
49
50
|
prompt: s.string,
|
|
50
51
|
tagName: s.string,
|
|
@@ -60,18 +61,18 @@ var { translator: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button
|
|
|
60
61
|
};
|
|
61
62
|
static defaultProps = { onClick: () => {} };
|
|
62
63
|
promptRef = a.createRef();
|
|
63
|
-
audioId = i(
|
|
64
|
-
playButtonId = i(
|
|
64
|
+
audioId = i(m);
|
|
65
|
+
playButtonId = i(h);
|
|
65
66
|
parsedText = (e) => {
|
|
66
67
|
let { autoplayAudioEnabled: t, customAudioButton: n, language: r } = this.props, i = document.createElement("div");
|
|
67
|
-
i.innerHTML = e;
|
|
68
|
+
i.innerHTML = l(e);
|
|
68
69
|
let a = i.querySelector("audio");
|
|
69
70
|
if (a) {
|
|
70
71
|
let e = document.createElement("source");
|
|
71
|
-
if (e.setAttribute("type", "audio/mp3"), e.setAttribute("src", a.getAttribute("src")), a.removeAttribute("src"), a.id = this.audioId, a.classList.add(
|
|
72
|
+
if (e.setAttribute("type", "audio/mp3"), e.setAttribute("src", a.getAttribute("src")), a.removeAttribute("src"), a.id = this.audioId, a.classList.add(m), a.appendChild(e), n) {
|
|
72
73
|
a.style.display = "none";
|
|
73
74
|
let e = document.createElement("button");
|
|
74
|
-
e.setAttribute("type", "button"), e.setAttribute("aria-label",
|
|
75
|
+
e.setAttribute("type", "button"), e.setAttribute("aria-label", p.t("common:playAudio", { lng: r })), e.id = this.playButtonId, e.className = h, Object.assign(e.style, {
|
|
75
76
|
cursor: "pointer",
|
|
76
77
|
display: "block",
|
|
77
78
|
width: "128px",
|
|
@@ -90,7 +91,7 @@ var { translator: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button
|
|
|
90
91
|
return i.innerHTML;
|
|
91
92
|
};
|
|
92
93
|
addCustomAudioButtonControls() {
|
|
93
|
-
let { autoplayAudioEnabled: e, customAudioButton: t } = this.props, n = this.promptRef.current, r = n?.querySelector(`.${
|
|
94
|
+
let { autoplayAudioEnabled: e, customAudioButton: t } = this.props, n = this.promptRef.current, r = n?.querySelector(`.${h}`), i = n?.querySelector(`.${m}`);
|
|
94
95
|
if (e && i && i.play().then(() => {
|
|
95
96
|
r && t && i.addEventListener("ended", o);
|
|
96
97
|
}).catch((e) => {
|
|
@@ -131,7 +132,7 @@ var { translator: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button
|
|
|
131
132
|
}
|
|
132
133
|
renderMathContent() {
|
|
133
134
|
let e = this.promptRef.current;
|
|
134
|
-
e && typeof
|
|
135
|
+
e && typeof d == "function" && d(e);
|
|
135
136
|
}
|
|
136
137
|
alignImages() {
|
|
137
138
|
let e = this.promptRef.current;
|
|
@@ -151,16 +152,16 @@ var { translator: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
render() {
|
|
154
|
-
let { prompt: e, tagName: t, className: n, onClick: r, defaultClassName: i } = this.props, a = `${n || ""} ${i || ""} ${t === "legend" ? "legend" : ""} ${
|
|
155
|
-
return /* @__PURE__ */
|
|
155
|
+
let { prompt: e, tagName: t, className: n, onClick: r, defaultClassName: i } = this.props, a = `${n || ""} ${i || ""} ${t === "legend" ? "legend" : ""} ${b}`.trim();
|
|
156
|
+
return /* @__PURE__ */ u(_, {
|
|
156
157
|
as: t || "div",
|
|
157
158
|
ref: this.promptRef,
|
|
158
159
|
onClick: r,
|
|
159
160
|
className: a,
|
|
160
161
|
tagName: t,
|
|
161
|
-
dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(
|
|
162
|
+
dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(v, y) }
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
165
|
};
|
|
165
166
|
//#endregion
|
|
166
|
-
export {
|
|
167
|
+
export { x as PreviewPrompt, x as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "8.0.2
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
"@emotion/styled": "^11.14.1",
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
|
-
"@pie-lib/icons": "5.0.
|
|
16
|
-
"@pie-lib/translator": "5.0.
|
|
15
|
+
"@pie-lib/icons": "5.0.1",
|
|
16
|
+
"@pie-lib/translator": "5.0.1",
|
|
17
17
|
"debug": "^4.1.1",
|
|
18
18
|
"prop-types": "^15.7.2",
|
|
19
19
|
"react-transition-group": "^4.4.5",
|
|
20
|
-
"@pie-element/shared-math-rendering-mathjax": "0.1.3
|
|
21
|
-
"@pie-element/shared-lodash": "0.1.
|
|
20
|
+
"@pie-element/shared-math-rendering-mathjax": "0.1.3",
|
|
21
|
+
"@pie-element/shared-lodash": "0.1.2",
|
|
22
|
+
"@pie-element/shared-utils": "0.1.2"
|
|
22
23
|
},
|
|
23
24
|
"type": "module",
|
|
24
25
|
"main": "./dist/index.js",
|