@pie-lib/render-ui 8.0.4 → 8.0.5-next.20261012213240

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.
@@ -3,28 +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 { 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";
6
+ import { PLAY_AUDIO_ATTR as l, sanitizeModelHtml as u } from "@pie-element/shared-utils";
7
+ import { jsx as d } from "react/jsx-runtime";
8
+ import { renderMath as f } from "@pie-element/shared-math-rendering-mathjax";
9
+ import p from "@pie-lib/translator";
10
10
  //#region src/preview-prompt.tsx
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`]: {
11
+ var { translator: m } = p, h = "pie-prompt-audio-player", g = "play-audio-button", _ = (e) => `&:not(.MathJax) > table${e}, &:not(.MathJax) > .pie-table-scroll > table${e}`, v = c("div")(({ theme: i, tagName: a }) => ({
12
+ [`& .${g}:focus-visible`]: {
13
13
  outline: `2px solid ${e()}`,
14
14
  outlineOffset: "2px"
15
15
  },
16
- [g(":not([role=\"presentation\"])")]: { borderCollapse: "collapse" },
16
+ [_(":not([role=\"presentation\"])")]: { borderCollapse: "collapse" },
17
17
  "&:not(.MathJax) table[border]:not([role=\"presentation\"]), &:not(.MathJax) table[border]:not([role=\"presentation\"]) td, &:not(.MathJax) table[border]:not([role=\"presentation\"]) th": {
18
18
  borderStyle: "solid",
19
19
  borderColor: t()
20
20
  },
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() },
21
+ [_(":not([role=\"presentation\"]):has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)")]: { backgroundColor: n() },
22
+ [_(":not([role=\"presentation\"]):has(tbody tr > td:first-child) tbody tr:nth-child(even) td")]: { backgroundColor: n() },
23
23
  "&:not(.MathJax) table:not([role=\"presentation\"]) td, &:not(.MathJax) table:not([role=\"presentation\"]) th": {
24
24
  padding: ".6em 1em",
25
25
  textAlign: "left"
26
26
  },
27
- [g(" td > p.kds-indent")]: { textAlign: "initial" },
27
+ [_(" td > p.kds-indent")]: { textAlign: "initial" },
28
28
  "&.prompt": {
29
29
  verticalAlign: "middle",
30
30
  color: r()
@@ -45,7 +45,7 @@ var { translator: p } = f, m = "pie-prompt-audio-player", h = "play-audio-button
45
45
  cursor: "pointer",
46
46
  "& > p": { margin: "0 0 0 0 !important" }
47
47
  }
48
- })), v = /\\embed\{newLine\}\[\]/g, y = "\\newline ", b = "preview-prompt", x = class extends o {
48
+ })), y = /\\embed\{newLine\}\[\]/g, b = "\\newline ", x = "preview-prompt", S = class extends o {
49
49
  static propTypes = {
50
50
  prompt: s.string,
51
51
  tagName: s.string,
@@ -61,18 +61,19 @@ var { translator: p } = f, m = "pie-prompt-audio-player", h = "play-audio-button
61
61
  };
62
62
  static defaultProps = { onClick: () => {} };
63
63
  promptRef = a.createRef();
64
- audioId = i(m);
65
- playButtonId = i(h);
64
+ audioId = i(h);
65
+ playButtonId = i(g);
66
66
  parsedText = (e) => {
67
67
  let { autoplayAudioEnabled: t, customAudioButton: n, language: r } = this.props, i = document.createElement("div");
68
- i.innerHTML = l(e);
68
+ i.innerHTML = u(e);
69
69
  let a = i.querySelector("audio");
70
70
  if (a) {
71
71
  let e = document.createElement("source");
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
+ if (e.setAttribute("type", "audio/mp3"), e.setAttribute("src", a.getAttribute("src")), a.removeAttribute("src"), a.id) for (let e of i.querySelectorAll(`[${l}]`)) e.getAttribute(l) === a.id && e.setAttribute(l, this.audioId);
73
+ if (a.id = this.audioId, a.classList.add(h), a.appendChild(e), n) {
73
74
  a.style.display = "none";
74
75
  let e = document.createElement("button");
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, {
76
+ e.setAttribute("type", "button"), e.setAttribute("aria-label", m.t("common:playAudio", { lng: r })), e.id = this.playButtonId, e.className = g, Object.assign(e.style, {
76
77
  cursor: "pointer",
77
78
  display: "block",
78
79
  width: "128px",
@@ -91,7 +92,7 @@ var { translator: p } = f, m = "pie-prompt-audio-player", h = "play-audio-button
91
92
  return i.innerHTML;
92
93
  };
93
94
  addCustomAudioButtonControls() {
94
- let { autoplayAudioEnabled: e, customAudioButton: t } = this.props, n = this.promptRef.current, r = n?.querySelector(`.${h}`), i = n?.querySelector(`.${m}`);
95
+ let { autoplayAudioEnabled: e, customAudioButton: t } = this.props, n = this.promptRef.current, r = n?.querySelector(`.${g}`), i = n?.querySelector(`.${h}`);
95
96
  if (e && i && i.play().then(() => {
96
97
  r && t && i.addEventListener("ended", o);
97
98
  }).catch((e) => {
@@ -132,7 +133,7 @@ var { translator: p } = f, m = "pie-prompt-audio-player", h = "play-audio-button
132
133
  }
133
134
  renderMathContent() {
134
135
  let e = this.promptRef.current;
135
- e && typeof d == "function" && d(e);
136
+ e && typeof f == "function" && f(e);
136
137
  }
137
138
  alignImages() {
138
139
  let e = this.promptRef.current;
@@ -152,16 +153,16 @@ var { translator: p } = f, m = "pie-prompt-audio-player", h = "play-audio-button
152
153
  }
153
154
  }
154
155
  render() {
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
+ let { prompt: e, tagName: t, className: n, onClick: r, defaultClassName: i } = this.props, a = `${n || ""} ${i || ""} ${t === "legend" ? "legend" : ""} ${x}`.trim();
157
+ return /* @__PURE__ */ d(v, {
157
158
  as: t || "div",
158
159
  ref: this.promptRef,
159
160
  onClick: r,
160
161
  className: a,
161
162
  tagName: t,
162
- dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(v, y) }
163
+ dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(y, b) }
163
164
  });
164
165
  }
165
166
  };
166
167
  //#endregion
167
- export { x as PreviewPrompt, x as default };
168
+ export { S as PreviewPrompt, S as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/render-ui",
3
- "version": "8.0.4",
3
+ "version": "8.0.5-next.20261012213240",
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,14 +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.1",
16
- "@pie-lib/translator": "5.0.1",
15
+ "@pie-lib/icons": "5.0.2-next.20261006160832",
16
+ "@pie-lib/translator": "5.0.2-next.20261006160832",
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.5",
21
- "@pie-element/shared-lodash": "0.1.2",
22
- "@pie-element/shared-utils": "0.1.4"
20
+ "@pie-element/shared-math-rendering-mathjax": "0.1.6-next.20261012010413",
21
+ "@pie-element/shared-lodash": "0.1.3-next.20261012213240",
22
+ "@pie-element/shared-utils": "0.1.5-next.20261012213240"
23
23
  },
24
24
  "type": "module",
25
25
  "main": "./dist/index.js",