@pie-lib/render-ui 8.0.1-next.20261005003301 → 8.0.1-next.20261005075357

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/color.d.ts CHANGED
@@ -51,6 +51,7 @@ export declare const defaults: {
51
51
  KEYPAD_BUTTON_HOVER: string;
52
52
  KEYPAD_BUTTON_OPERATOR_HOVER: string;
53
53
  KEY_BOARD_FOCUS_INDICATOR: string;
54
+ EDITOR_TOOLBAR: string;
54
55
  BUTTON_BORDER: string;
55
56
  BUTTON_HOVER_BG: string;
56
57
  };
@@ -99,6 +100,7 @@ export declare const focusCheckedBorder: () => any;
99
100
  export declare const focusUnchecked: () => any;
100
101
  export declare const focusUncheckedBorder: () => any;
101
102
  export declare const buttonFocusOutline: () => any;
103
+ export declare const focusOutline: () => any;
102
104
  export declare const blueGrey100: () => any;
103
105
  export declare const blueGrey300: () => any;
104
106
  export declare const blueGrey600: () => any;
@@ -108,6 +110,7 @@ export declare const keypadButtonOperator: () => any;
108
110
  export declare const keypadEmptyPlaceholder: () => any;
109
111
  export declare const keypadButtonHover: () => any;
110
112
  export declare const keypadButtonOperatorHover: () => any;
113
+ export declare const editorToolbar: () => string;
111
114
  export declare const keyBoardFocusIndicator: () => any;
112
115
  export declare const buttonBorder: () => any;
113
116
  export declare const buttonHoverBg: () => any;
package/dist/color.js CHANGED
@@ -1,21 +1,21 @@
1
- import { __exportAll as ee } from "./_virtual/_rolldown/runtime.js";
2
- import { green as e, indigo as t, orange as te, pink as n, red as r } from "@mui/material/colors";
1
+ import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
2
+ import { green as t, indigo as n, orange as ee, pink as r, red as te } from "@mui/material/colors";
3
3
  //#region src/color.ts
4
- var ne = /* @__PURE__ */ ee({
4
+ var ne = /* @__PURE__ */ e({
5
5
  background: () => k,
6
6
  backgroundDark: () => A,
7
7
  black: () => H,
8
- blueGrey100: () => X,
9
- blueGrey300: () => Z,
10
- blueGrey600: () => Q,
11
- blueGrey900: () => ie,
8
+ blueGrey100: () => Z,
9
+ blueGrey300: () => ie,
10
+ blueGrey600: () => ae,
11
+ blueGrey900: () => oe,
12
12
  border: () => F,
13
13
  borderDark: () => L,
14
14
  borderGray: () => R,
15
15
  borderLight: () => I,
16
- buttonBorder: () => ue,
16
+ buttonBorder: () => me,
17
17
  buttonFocusOutline: () => Y,
18
- buttonHoverBg: () => de,
18
+ buttonHoverBg: () => he,
19
19
  correct: () => d,
20
20
  correctSecondary: () => f,
21
21
  correctTertiary: () => p,
@@ -24,20 +24,22 @@ var ne = /* @__PURE__ */ ee({
24
24
  disabled: () => c,
25
25
  disabledSecondary: () => l,
26
26
  disabledText: () => u,
27
- dropdownBackground: () => re,
27
+ dropdownBackground: () => M,
28
+ editorToolbar: () => fe,
28
29
  fadedPrimary: () => w,
29
30
  focusChecked: () => G,
30
31
  focusCheckedBorder: () => K,
32
+ focusOutline: () => X,
31
33
  focusUnchecked: () => q,
32
34
  focusUncheckedBorder: () => J,
33
35
  incorrect: () => h,
34
36
  incorrectSecondary: () => _,
35
37
  incorrectWithIcon: () => g,
36
- keyBoardFocusIndicator: () => le,
37
- keypadButton: () => ae,
38
- keypadButtonHover: () => se,
39
- keypadButtonOperator: () => oe,
40
- keypadButtonOperatorHover: () => ce,
38
+ keyBoardFocusIndicator: () => pe,
39
+ keypadButton: () => ce,
40
+ keypadButtonHover: () => ue,
41
+ keypadButtonOperator: () => le,
42
+ keypadButtonOperatorHover: () => de,
41
43
  keypadEmptyPlaceholder: () => $,
42
44
  missing: () => v,
43
45
  missingWithIcon: () => y,
@@ -50,37 +52,37 @@ var ne = /* @__PURE__ */ ee({
50
52
  secondaryDark: () => D,
51
53
  secondaryLight: () => E,
52
54
  secondaryText: () => O,
53
- surface: () => M,
55
+ surface: () => N,
54
56
  tableGrid: () => z,
55
57
  tableGridLight: () => B,
56
58
  tableStripe: () => V,
57
- tertiary: () => N,
59
+ tertiary: () => re,
58
60
  tertiaryLight: () => P,
59
61
  text: () => s,
60
62
  transparent: () => W,
61
63
  v: () => a,
62
- visualElementsColors: () => fe,
64
+ visualElementsColors: () => ge,
63
65
  white: () => U
64
66
  }), i = {
65
67
  TEXT: "black",
66
68
  DISABLED: "grey",
67
69
  DISABLED_SECONDARY: "#ABABAB",
68
70
  DISABLED_TEXT: "#545454",
69
- CORRECT: e[500],
70
- CORRECT_SECONDARY: e[50],
71
+ CORRECT: t[500],
72
+ CORRECT_SECONDARY: t[50],
71
73
  CORRECT_TERTIARY: "#0EA449",
72
74
  CORRECT_WITH_ICON: "#087D38",
73
- INCORRECT: te[500],
74
- INCORRECT_SECONDARY: r[50],
75
+ INCORRECT: ee[500],
76
+ INCORRECT_SECONDARY: te[50],
75
77
  INCORRECT_WITH_ICON: "#BF0D00",
76
- MISSING: r[700],
78
+ MISSING: te[700],
77
79
  MISSING_WITH_ICON: "#6A78A1",
78
- PRIMARY: t[500],
79
- PRIMARY_LIGHT: t[200],
80
- PRIMARY_DARK: t[800],
81
- SECONDARY: n.A400,
82
- SECONDARY_LIGHT: n[200],
83
- SECONDARY_DARK: n[900],
80
+ PRIMARY: n[500],
81
+ PRIMARY_LIGHT: n[200],
82
+ PRIMARY_DARK: n[800],
83
+ SECONDARY: r.A400,
84
+ SECONDARY_LIGHT: r[200],
85
+ SECONDARY_DARK: r[900],
84
86
  TERTIARY: "#146EB3",
85
87
  TERTIARY_LIGHT: "#D0E2F0",
86
88
  BACKGROUND: "rgba(255,255,255,0)",
@@ -114,14 +116,18 @@ var ne = /* @__PURE__ */ ee({
114
116
  KEYPAD_BUTTON_HOVER: "rgb(214, 218, 239)",
115
117
  KEYPAD_BUTTON_OPERATOR_HOVER: "rgb(255, 197, 217)",
116
118
  KEY_BOARD_FOCUS_INDICATOR: "#2B87FF",
119
+ EDITOR_TOOLBAR: "#efefef",
117
120
  BUTTON_BORDER: "rgba(0, 0, 0, 0.23)",
118
121
  BUTTON_HOVER_BG: "rgba(0, 0, 0, 0.08)"
119
122
  };
120
123
  Object.freeze(i);
121
- var a = (ee) => (...e) => {
122
- let t = e.pop();
123
- return e.reduceRight((e, t) => `var(--${ee}-${t}, ${e})`, t);
124
- }, o = a("pie"), s = () => o("text", i.TEXT), c = () => o("disabled", i.DISABLED), l = () => o("disabled-secondary", i.DISABLED_SECONDARY), u = () => o("disabled-text", "text", i.DISABLED_TEXT), d = () => o("correct", i.CORRECT), f = () => o("correct-secondary", i.CORRECT_SECONDARY), p = () => o("correct-tertiary", i.CORRECT_TERTIARY), m = () => o("correct-icon", i.CORRECT_WITH_ICON), h = () => o("incorrect", i.INCORRECT), g = () => o("incorrect-icon", i.INCORRECT_WITH_ICON), _ = () => o("incorrect-secondary", i.INCORRECT_SECONDARY), v = () => o("missing", i.MISSING), y = () => o("missing-icon", i.MISSING_WITH_ICON), b = () => o("primary", i.PRIMARY), x = () => o("primary-light", i.PRIMARY_LIGHT), S = () => o("primary-dark", i.PRIMARY_DARK), C = () => o("primary-text", "text", i.TEXT), w = () => o("faded-primary", i.FADED_PRIMARY), T = () => o("secondary", i.SECONDARY), E = () => o("secondary-light", i.SECONDARY_LIGHT), D = () => o("secondary-dark", i.SECONDARY_DARK), O = () => o("secondary-text", "text", i.TEXT), k = () => o("background", i.BACKGROUND), A = () => o("background-dark", i.BACKGROUND_DARK), j = () => o("secondary-background", i.SECONDARY_BACKGROUND), re = () => o("dropdown-background", i.DROPDOWN_BACKGROUND), M = () => o("surface", i.SURFACE), N = () => o("tertiary", i.TERTIARY), P = () => o("tertiary-light", i.TERTIARY_LIGHT), F = () => o("border", i.BORDER), I = () => o("border-light", i.BORDER_LIGHT), L = () => o("border-dark", i.BORDER_DARK), R = () => o("border-gray", i.BORDER_GRAY), z = () => o("table-grid", "text", i.TABLE_GRID), B = () => o("table-grid-light", "border-light", i.TABLE_GRID_LIGHT), V = () => o("table-stripe", "background-dark", i.TABLE_STRIPE), H = () => o("black", i.BLACK), U = () => o("white", i.WHITE), W = () => i.TRANSPARENT, G = () => o("focus-checked", i.FOCUS_CHECKED), K = () => o("focus-checked-border", i.FOCUS_CHECKED_BORDER), q = () => o("focus-unchecked", i.FOCUS_UNCHECKED), J = () => o("focus-unchecked-border", i.FOCUS_UNCHECKED_BORDER), Y = () => o("button-focus-outline", i.BUTTON_FOCUS_OUTLINE), X = () => o("blue-grey-100", i.BLUE_GREY100), Z = () => o("blue-grey-300", i.BLUE_GREY300), Q = () => o("blue-grey-600", i.BLUE_GREY600), ie = () => o("blue-grey-900", i.BLUE_GREY900), ae = () => o("keypad-button", i.KEYPAD_BUTTON), oe = () => o("keypad-button-operator", i.KEYPAD_BUTTON_OPERATOR), $ = () => o("keypad-empty-placeholder", i.KEYPAD_EMPTY_PLACEHOLDER), se = () => o("keypad-button-hover", i.KEYPAD_BUTTON_HOVER), ce = () => o("keypad-button-operator-hover", i.KEYPAD_BUTTON_OPERATOR_HOVER), le = () => o("keyboard-focus-indicator", i.KEY_BOARD_FOCUS_INDICATOR), ue = () => o("button-border", i.BUTTON_BORDER), de = () => o("button-hover-bg", i.BUTTON_HOVER_BG), fe = {
124
+ var a = (e) => (...t) => {
125
+ let n = t.pop();
126
+ return t.reduceRight((t, n) => `var(--${e}-${n}, ${t})`, n);
127
+ }, o = a("pie"), s = () => o("text", i.TEXT), c = () => o("disabled", i.DISABLED), l = () => o("disabled-secondary", i.DISABLED_SECONDARY), u = () => o("disabled-text", "text", i.DISABLED_TEXT), d = () => o("correct", i.CORRECT), f = () => o("correct-secondary", i.CORRECT_SECONDARY), p = () => o("correct-tertiary", i.CORRECT_TERTIARY), m = () => o("correct-icon", i.CORRECT_WITH_ICON), h = () => o("incorrect", i.INCORRECT), g = () => o("incorrect-icon", i.INCORRECT_WITH_ICON), _ = () => o("incorrect-secondary", i.INCORRECT_SECONDARY), v = () => o("missing", i.MISSING), y = () => o("missing-icon", i.MISSING_WITH_ICON), b = () => o("primary", i.PRIMARY), x = () => o("primary-light", i.PRIMARY_LIGHT), S = () => o("primary-dark", i.PRIMARY_DARK), C = () => o("primary-text", "text", i.TEXT), w = () => o("faded-primary", i.FADED_PRIMARY), T = () => o("secondary", i.SECONDARY), E = () => o("secondary-light", i.SECONDARY_LIGHT), D = () => o("secondary-dark", i.SECONDARY_DARK), O = () => o("secondary-text", "text", i.TEXT), k = () => o("background", i.BACKGROUND), A = () => o("background-dark", i.BACKGROUND_DARK), j = () => o("secondary-background", i.SECONDARY_BACKGROUND), M = () => o("dropdown-background", i.DROPDOWN_BACKGROUND), N = () => o("surface", i.SURFACE), re = () => o("tertiary", i.TERTIARY), P = () => o("tertiary-light", i.TERTIARY_LIGHT), F = () => o("border", i.BORDER), I = () => o("border-light", i.BORDER_LIGHT), L = () => o("border-dark", i.BORDER_DARK), R = () => o("border-gray", i.BORDER_GRAY), z = () => o("table-grid", "text", i.TABLE_GRID), B = () => o("table-grid-light", "border-light", i.TABLE_GRID_LIGHT), V = () => o("table-stripe", "background-dark", i.TABLE_STRIPE), H = () => o("black", i.BLACK), U = () => o("white", i.WHITE), W = () => i.TRANSPARENT, G = () => o("focus-checked", i.FOCUS_CHECKED), K = () => o("focus-checked-border", i.FOCUS_CHECKED_BORDER), q = () => o("focus-unchecked", i.FOCUS_UNCHECKED), J = () => o("focus-unchecked-border", i.FOCUS_UNCHECKED_BORDER), Y = () => o("button-focus-outline", i.BUTTON_FOCUS_OUTLINE), X = () => o("focus-outline", "button-focus-outline", "focus-checked-border", i.FOCUS_CHECKED_BORDER), Z = () => o("blue-grey-100", i.BLUE_GREY100), ie = () => o("blue-grey-300", i.BLUE_GREY300), ae = () => o("blue-grey-600", i.BLUE_GREY600), oe = () => o("blue-grey-900", i.BLUE_GREY900), se = (e) => {
128
+ let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
129
+ return t ? t.slice(1).map((e) => parseInt(e, 16)) : e.match(/\d+/g).slice(0, 3).map(Number);
130
+ }, Q = (e, t) => `color-mix(in srgb, rgb(${se(e).map((e) => (e - 255 * (1 - t)) / t).join(" ")}) ${t * 100}%, ${o("background", i.WHITE)})`, ce = () => o("keypad-button", Q(i.KEYPAD_BUTTON, .5)), le = () => o("keypad-button-operator", Q(i.KEYPAD_BUTTON_OPERATOR, .5)), $ = () => o("keypad-empty-placeholder", i.KEYPAD_EMPTY_PLACEHOLDER), ue = () => o("keypad-button-hover", Q(i.KEYPAD_BUTTON_HOVER, .25)), de = () => o("keypad-button-operator-hover", Q(i.KEYPAD_BUTTON_OPERATOR_HOVER, .25)), fe = () => Q(i.EDITOR_TOOLBAR, .125), pe = () => o("keyboard-focus-indicator", i.KEY_BOARD_FOCUS_INDICATOR), me = () => o("button-border", i.BUTTON_BORDER), he = () => o("button-hover-bg", i.BUTTON_HOVER_BG), ge = {
125
131
  AXIS_LINE_COLOR: "#5A53C9",
126
132
  ROLLOVER_FILL_BAR_COLOR: "#050F2D",
127
133
  GRIDLINES_COLOR: "#8E88EA",
@@ -129,4 +135,4 @@ var a = (ee) => (...e) => {
129
135
  SHAPES_FILL_COLOR: "#7986cb"
130
136
  };
131
137
  //#endregion
132
- export { k as background, A as backgroundDark, H as black, X as blueGrey100, Z as blueGrey300, Q as blueGrey600, ie as blueGrey900, F as border, L as borderDark, R as borderGray, I as borderLight, ue as buttonBorder, Y as buttonFocusOutline, de as buttonHoverBg, ne as color_exports, d as correct, f as correctSecondary, p as correctTertiary, m as correctWithIcon, i as defaults, c as disabled, l as disabledSecondary, u as disabledText, re as dropdownBackground, w as fadedPrimary, G as focusChecked, K as focusCheckedBorder, q as focusUnchecked, J as focusUncheckedBorder, h as incorrect, _ as incorrectSecondary, g as incorrectWithIcon, le as keyBoardFocusIndicator, ae as keypadButton, se as keypadButtonHover, oe as keypadButtonOperator, ce as keypadButtonOperatorHover, $ as keypadEmptyPlaceholder, v as missing, y as missingWithIcon, b as primary, S as primaryDark, x as primaryLight, C as primaryText, T as secondary, j as secondaryBackground, D as secondaryDark, E as secondaryLight, O as secondaryText, M as surface, z as tableGrid, B as tableGridLight, V as tableStripe, N as tertiary, P as tertiaryLight, s as text, W as transparent, a as v, fe as visualElementsColors, U as white };
138
+ export { k as background, A as backgroundDark, H as black, Z as blueGrey100, ie as blueGrey300, ae as blueGrey600, oe as blueGrey900, F as border, L as borderDark, R as borderGray, I as borderLight, me as buttonBorder, Y as buttonFocusOutline, he as buttonHoverBg, ne as color_exports, d as correct, f as correctSecondary, p as correctTertiary, m as correctWithIcon, i as defaults, c as disabled, l as disabledSecondary, u as disabledText, M as dropdownBackground, fe as editorToolbar, w as fadedPrimary, G as focusChecked, K as focusCheckedBorder, X as focusOutline, q as focusUnchecked, J as focusUncheckedBorder, h as incorrect, _ as incorrectSecondary, g as incorrectWithIcon, pe as keyBoardFocusIndicator, ce as keypadButton, ue as keypadButtonHover, le as keypadButtonOperator, de as keypadButtonOperatorHover, $ as keypadEmptyPlaceholder, v as missing, y as missingWithIcon, b as primary, S as primaryDark, x as primaryLight, C as primaryText, T as secondary, j as secondaryBackground, D as secondaryDark, E as secondaryLight, O as secondaryText, N as surface, z as tableGrid, B as tableGridLight, V as tableStripe, re as tertiary, P as tertiaryLight, s as text, W as transparent, a as v, ge as visualElementsColors, U as white };
@@ -12,11 +12,15 @@ export declare class PreviewPrompt extends Component {
12
12
  playImage: PropTypes.Requireable<string>;
13
13
  pauseImage: PropTypes.Requireable<string>;
14
14
  }>>;
15
+ /** The item language, which the custom audio button's accessible name follows. */
16
+ language: PropTypes.Requireable<string>;
15
17
  };
16
18
  static defaultProps: {
17
19
  onClick: () => void;
18
20
  };
19
21
  promptRef: React.RefObject<unknown>;
22
+ audioId: string;
23
+ playButtonId: string;
20
24
  parsedText: any;
21
25
  addCustomAudioButtonControls(): void;
22
26
  removeCustomAudioButtonListeners(): void;
@@ -1,18 +1,24 @@
1
- import { tableGrid as e, tableStripe as t, text as n } from "./color.js";
2
- import r, { Component as i } from "react";
3
- import a from "prop-types";
4
- import { styled as o } from "@mui/material/styles";
5
- import { jsx as s } from "react/jsx-runtime";
6
- import { renderMath as c } from "@pie-element/shared-math-rendering-mathjax";
1
+ import { focusOutline as e, tableGrid as t, tableStripe as n, text as r } from "./color.js";
2
+ import { createUniqueId as i } from "./unique-id.js";
3
+ import a, { Component as o } from "react";
4
+ import s from "prop-types";
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";
7
9
  //#region src/preview-prompt.tsx
8
- var l = o("div")(({ theme: r, tagName: i }) => ({
10
+ var { translator: f } = d, p = "pie-prompt-audio-player", m = "play-audio-button", h = c("div")(({ theme: i, tagName: a }) => ({
11
+ [`& .${m}:focus-visible`]: {
12
+ outline: `2px solid ${e()}`,
13
+ outlineOffset: "2px"
14
+ },
9
15
  "&:not(.MathJax) > table:not([role=\"presentation\"])": { borderCollapse: "collapse" },
10
16
  "&:not(.MathJax) table[border]:not([role=\"presentation\"]), &:not(.MathJax) table[border]:not([role=\"presentation\"]) td, &:not(.MathJax) table[border]:not([role=\"presentation\"]) th": {
11
17
  borderStyle: "solid",
12
- borderColor: e()
18
+ borderColor: t()
13
19
  },
14
- "&:not(.MathJax) > table:not([role=\"presentation\"]):has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)": { backgroundColor: t() },
15
- "&:not(.MathJax) > table:not([role=\"presentation\"]):has(tbody tr > td:first-child) tbody tr:nth-child(even) td": { backgroundColor: t() },
20
+ "&:not(.MathJax) > table:not([role=\"presentation\"]):has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)": { backgroundColor: n() },
21
+ "&:not(.MathJax) > table:not([role=\"presentation\"]):has(tbody tr > td:first-child) tbody tr:nth-child(even) td": { backgroundColor: n() },
16
22
  "&:not(.MathJax) table:not([role=\"presentation\"]) td, &:not(.MathJax) table:not([role=\"presentation\"]) th": {
17
23
  padding: ".6em 1em",
18
24
  textAlign: "left"
@@ -20,88 +26,95 @@ var l = o("div")(({ theme: r, tagName: i }) => ({
20
26
  "&:not(.MathJax) > table td > p.kds-indent": { textAlign: "initial" },
21
27
  "&.prompt": {
22
28
  verticalAlign: "middle",
23
- color: n()
29
+ color: r()
24
30
  },
25
31
  "&.legend": {
26
32
  width: "100%",
27
33
  fontSize: "inherit !important"
28
34
  },
29
35
  "&.rationale": {
30
- paddingLeft: r.spacing(4),
31
- paddingBottom: r.spacing(1)
36
+ paddingLeft: i.spacing(4),
37
+ paddingBottom: i.spacing(1)
32
38
  },
33
39
  "&.prompt-label": {
34
- color: `${n()} !important`,
40
+ color: `${r()} !important`,
35
41
  display: "flex",
36
42
  flexDirection: "column",
37
43
  verticalAlign: "middle",
38
44
  cursor: "pointer",
39
45
  "& > p": { margin: "0 0 0 0 !important" }
40
46
  }
41
- })), u = /\\embed\{newLine\}\[\]/g, d = "\\newline ", f = "preview-prompt", p = class extends i {
47
+ })), g = /\\embed\{newLine\}\[\]/g, _ = "\\newline ", v = "preview-prompt", y = class extends o {
42
48
  static propTypes = {
43
- prompt: a.string,
44
- tagName: a.string,
45
- className: a.string,
46
- onClick: a.func,
47
- defaultClassName: a.string,
48
- autoplayAudioEnabled: a.bool,
49
- customAudioButton: a.shape({
50
- playImage: a.string,
51
- pauseImage: a.string
52
- })
49
+ prompt: s.string,
50
+ tagName: s.string,
51
+ className: s.string,
52
+ onClick: s.func,
53
+ defaultClassName: s.string,
54
+ autoplayAudioEnabled: s.bool,
55
+ customAudioButton: s.shape({
56
+ playImage: s.string,
57
+ pauseImage: s.string
58
+ }),
59
+ language: s.string
53
60
  };
54
61
  static defaultProps = { onClick: () => {} };
55
- promptRef = r.createRef();
62
+ promptRef = a.createRef();
63
+ audioId = i(p);
64
+ playButtonId = i(m);
56
65
  parsedText = (e) => {
57
- let { autoplayAudioEnabled: t, customAudioButton: n } = this.props, r = document.createElement("div");
58
- r.innerHTML = e;
59
- let i = r.querySelector("audio");
60
- if (i) {
66
+ let { autoplayAudioEnabled: t, customAudioButton: n, language: r } = this.props, i = document.createElement("div");
67
+ i.innerHTML = e;
68
+ let a = i.querySelector("audio");
69
+ if (a) {
61
70
  let e = document.createElement("source");
62
- if (e.setAttribute("type", "audio/mp3"), e.setAttribute("src", i.getAttribute("src")), i.removeAttribute("src"), i.setAttribute("id", "pie-prompt-audio-player"), i.appendChild(e), n) {
63
- i.style.display = "none";
64
- let e = document.createElement("div");
65
- e.id = "play-audio-button", Object.assign(e.style, {
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
+ a.style.display = "none";
73
+ 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, {
66
75
  cursor: "pointer",
67
76
  display: "block",
68
77
  width: "128px",
69
78
  height: "128px",
79
+ margin: "0",
80
+ padding: "0",
81
+ font: "inherit",
82
+ backgroundColor: "transparent",
70
83
  backgroundImage: `url(${t ? n.pauseImage : n.playImage})`,
71
84
  backgroundSize: "cover",
72
85
  borderRadius: "50%",
73
86
  border: "1px solid #326295"
74
- }), i.parentNode.insertBefore(e, i);
87
+ }), a.parentNode.insertBefore(e, a);
75
88
  }
76
89
  }
77
- return r.innerHTML;
90
+ return i.innerHTML;
78
91
  };
79
92
  addCustomAudioButtonControls() {
80
- let { autoplayAudioEnabled: e, customAudioButton: t } = this.props, n = document.getElementById("play-audio-button"), r = document.getElementById("pie-prompt-audio-player");
81
- if (e && r && r.play().then(() => {
82
- n && t && r.addEventListener("ended", a);
93
+ let { autoplayAudioEnabled: e, customAudioButton: t } = this.props, n = this.promptRef.current, r = n?.querySelector(`.${m}`), i = n?.querySelector(`.${p}`);
94
+ if (e && i && i.play().then(() => {
95
+ r && t && i.addEventListener("ended", o);
83
96
  }).catch((e) => {
84
- n && t && (n.style.backgroundImage = `url(${t.playImage})`), console.error("Error playing audio", e);
85
- }), !n || !r || !t) return;
86
- let i = () => {
87
- r.paused && r.play();
88
- }, a = () => {
89
- n.style.backgroundImage = `url(${t.playImage})`;
97
+ r && t && (r.style.backgroundImage = `url(${t.playImage})`), console.error("Error playing audio", e);
98
+ }), !r || !i || !t) return;
99
+ let a = () => {
100
+ i.paused && i.play();
90
101
  }, o = () => {
91
- Object.assign(n.style, {
102
+ r.style.backgroundImage = `url(${t.playImage})`;
103
+ }, s = () => {
104
+ Object.assign(r.style, {
92
105
  backgroundImage: `url(${t.pauseImage})`,
93
106
  border: "1px solid #ccc"
94
107
  });
95
- }, s = () => {
96
- Object.assign(n.style, {
108
+ }, c = () => {
109
+ Object.assign(r.style, {
97
110
  backgroundImage: `url(${t.playImage})`,
98
111
  border: "1px solid #326295"
99
112
  });
100
113
  };
101
- n.addEventListener("click", i), r.addEventListener("play", o), r.addEventListener("pause", s), r.addEventListener("ended", a), this._handlePlayClick = i, this._handleAudioPlay = o, this._handleAudioPause = s, this._handleAudioEnded = a;
114
+ r.addEventListener("click", a), i.addEventListener("play", s), i.addEventListener("pause", c), i.addEventListener("ended", o), this._playButton = r, this._audio = i, this._handlePlayClick = a, this._handleAudioPlay = s, this._handleAudioPause = c, this._handleAudioEnded = o;
102
115
  }
103
116
  removeCustomAudioButtonListeners() {
104
- let e = document.getElementById("play-audio-button"), t = document.querySelector("audio");
117
+ let e = this._playButton, t = this._audio;
105
118
  !e || !t || (e.removeEventListener("click", this._handlePlayClick), t.removeEventListener("play", this._handleAudioPlay), t.removeEventListener("pause", this._handleAudioPause), t.removeEventListener("ended", this._handleAudioEnded));
106
119
  }
107
120
  componentDidMount() {
@@ -118,7 +131,7 @@ var l = o("div")(({ theme: r, tagName: i }) => ({
118
131
  }
119
132
  renderMathContent() {
120
133
  let e = this.promptRef.current;
121
- e && typeof c == "function" && c(e);
134
+ e && typeof u == "function" && u(e);
122
135
  }
123
136
  alignImages() {
124
137
  let e = this.promptRef.current;
@@ -138,16 +151,16 @@ var l = o("div")(({ theme: r, tagName: i }) => ({
138
151
  }
139
152
  }
140
153
  render() {
141
- let { prompt: e, tagName: t, className: n, onClick: r, defaultClassName: i } = this.props, a = `${n || ""} ${i || ""} ${t === "legend" ? "legend" : ""} ${f}`.trim();
142
- return /* @__PURE__ */ s(l, {
154
+ let { prompt: e, tagName: t, className: n, onClick: r, defaultClassName: i } = this.props, a = `${n || ""} ${i || ""} ${t === "legend" ? "legend" : ""} ${v}`.trim();
155
+ return /* @__PURE__ */ l(h, {
143
156
  as: t || "div",
144
157
  ref: this.promptRef,
145
158
  onClick: r,
146
159
  className: a,
147
160
  tagName: t,
148
- dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(u, d) }
161
+ dangerouslySetInnerHTML: { __html: this.parsedText(e || "").replace(g, _) }
149
162
  });
150
163
  }
151
164
  };
152
165
  //#endregion
153
- export { p as PreviewPrompt, p as default };
166
+ export { y as PreviewPrompt, y as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/render-ui",
3
- "version": "8.0.1-next.20261005003301",
3
+ "version": "8.0.1-next.20261005075357",
4
4
  "description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  "@mui/icons-material": "^7.3.4",
14
14
  "@mui/material": "^7.3.4",
15
15
  "@pie-lib/icons": "5.0.1-next.20261004165705",
16
- "@pie-lib/translator": "5.0.1-next.20261005003301",
16
+ "@pie-lib/translator": "5.0.1-next.20261005075357",
17
17
  "debug": "^4.1.1",
18
18
  "prop-types": "^15.7.2",
19
19
  "react-transition-group": "^4.4.5",