@pie-lib/render-ui 8.0.2-next.20261007003844 → 8.0.2-next.20261007021359

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 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 { jsx as l } from "react/jsx-runtime";
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 u = o("div")({
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
- }), d = o("div")({
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
- }), f = o("div")({
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
- }), p = class extends i.Component {
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__ */ l(s, {
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__ */ l(f, {
52
+ children: /* @__PURE__ */ u(p, {
52
53
  ref: this.nodeRef,
53
- children: /* @__PURE__ */ l(u, { children: /* @__PURE__ */ l(d, {
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__ */ l("div", { children: /* @__PURE__ */ l(c, { children: this.renderFeedback() }) });
62
+ return /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u(c, { children: this.renderFeedback() }) });
62
63
  }
63
64
  };
64
65
  //#endregion
65
- export { p as Feedback, p as default };
66
+ export { m as Feedback, m as default };
@@ -1,8 +1,9 @@
1
1
  import e from "react";
2
2
  import t from "prop-types";
3
- import { jsx as n } from "react/jsx-runtime";
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 r = class extends e.Component {
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: r } = this.props;
17
- return /* @__PURE__ */ n(e || "div", {
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: r }
21
+ dangerouslySetInnerHTML: { __html: n(i) }
21
22
  });
22
23
  }
23
24
  };
24
25
  //#endregion
25
- export { r as default };
26
+ export { i as default };
@@ -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 { jsx as l } from "react/jsx-runtime";
7
- import { renderMath as u } from "@pie-element/shared-math-rendering-mathjax";
8
- import d from "@pie-lib/translator";
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: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button", h = (e) => `&:not(.MathJax) > table${e}, &:not(.MathJax) > .pie-table-scroll > table${e}`, g = c("div")(({ theme: i, tagName: a }) => ({
11
- [`& .${m}:focus-visible`]: {
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
- [h(":not([role=\"presentation\"])")]: { borderCollapse: "collapse" },
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
- [h(":not([role=\"presentation\"]):has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)")]: { backgroundColor: n() },
21
- [h(":not([role=\"presentation\"]):has(tbody tr > td:first-child) tbody tr:nth-child(even) td")]: { backgroundColor: n() },
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
- [h(" td > p.kds-indent")]: { textAlign: "initial" },
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
- })), _ = /\\embed\{newLine\}\[\]/g, v = "\\newline ", y = "preview-prompt", b = class extends o {
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(p);
64
- playButtonId = i(m);
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(p), a.appendChild(e), n) {
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", f.t("common:playAudio", { lng: r })), e.id = this.playButtonId, e.className = m, Object.assign(e.style, {
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(`.${m}`), i = n?.querySelector(`.${p}`);
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 u == "function" && u(e);
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" : ""} ${y}`.trim();
155
- return /* @__PURE__ */ l(g, {
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(_, v) }
162
+ dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(v, y) }
162
163
  });
163
164
  }
164
165
  };
165
166
  //#endregion
166
- export { b as PreviewPrompt, b as default };
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-next.20261007003844",
3
+ "version": "8.0.2-next.20261007021359",
4
4
  "description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,8 @@
18
18
  "prop-types": "^15.7.2",
19
19
  "react-transition-group": "^4.4.5",
20
20
  "@pie-element/shared-math-rendering-mathjax": "0.1.3-next.20261007003844",
21
- "@pie-element/shared-lodash": "0.1.3-next.20261006160832"
21
+ "@pie-element/shared-lodash": "0.1.3-next.20261006160832",
22
+ "@pie-element/shared-utils": "0.2.0-next.20261007021359"
22
23
  },
23
24
  "type": "module",
24
25
  "main": "./dist/index.js",