@pie-lib/render-ui 8.0.6-next.20261015154938 → 8.0.6-next.20261016234357
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/collapsible/index.d.ts +2 -0
- package/dist/collapsible/index.js +31 -30
- package/dist/i18n/en-US.d.ts +9 -0
- package/dist/i18n/en-US.js +8 -0
- package/dist/i18n/es.d.ts +6 -0
- package/dist/i18n/es.js +8 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.js +13 -0
- package/dist/preview-prompt.d.ts +8 -0
- package/dist/preview-prompt.js +64 -55
- package/package.json +3 -3
|
@@ -19,6 +19,8 @@ export declare class Collapsible extends React.Component {
|
|
|
19
19
|
};
|
|
20
20
|
panelId: string;
|
|
21
21
|
toggleExpanded: any;
|
|
22
|
+
/** Re-renders once the item language's catalog lands, for an element that did not preload it. */
|
|
23
|
+
relabel: () => void;
|
|
22
24
|
componentDidMount(): void;
|
|
23
25
|
componentDidUpdate(): void;
|
|
24
26
|
render(): React.JSX.Element;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { tertiary as e } from "../color.js";
|
|
2
|
-
import {
|
|
3
|
-
import n from "
|
|
4
|
-
import r from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import s from "
|
|
8
|
-
import
|
|
9
|
-
import l from "@pie-
|
|
2
|
+
import { catalogs as t } from "../i18n/index.js";
|
|
3
|
+
import { createUniqueId as n } from "../unique-id.js";
|
|
4
|
+
import r from "react";
|
|
5
|
+
import i from "prop-types";
|
|
6
|
+
import { styled as a } from "@mui/material/styles";
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
import c from "@mui/material/Collapse";
|
|
9
|
+
import { renderMath as l } from "@pie-element/shared-math-rendering-mathjax";
|
|
10
10
|
//#region src/collapsible/index.tsx
|
|
11
|
-
var
|
|
11
|
+
var u = a("button")({
|
|
12
12
|
display: "inline-block",
|
|
13
13
|
minHeight: "24px",
|
|
14
14
|
padding: 0,
|
|
@@ -18,53 +18,54 @@ var { translator: u } = l, d = i("button")({
|
|
|
18
18
|
textAlign: "inherit",
|
|
19
19
|
color: e(),
|
|
20
20
|
cursor: "pointer"
|
|
21
|
-
}),
|
|
21
|
+
}), d = a("span")({ borderBottom: "1px dotted currentColor" }), f = a(c)(({ theme: e }) => ({ paddingTop: e.spacing(2) })), p = class extends r.Component {
|
|
22
22
|
static propTypes = {
|
|
23
|
-
className:
|
|
24
|
-
children:
|
|
25
|
-
labels:
|
|
26
|
-
visible:
|
|
27
|
-
hidden:
|
|
23
|
+
className: i.string,
|
|
24
|
+
children: i.object,
|
|
25
|
+
labels: i.shape({
|
|
26
|
+
visible: i.string,
|
|
27
|
+
hidden: i.string
|
|
28
28
|
}),
|
|
29
|
-
language:
|
|
29
|
+
language: i.string
|
|
30
30
|
};
|
|
31
31
|
static defaultProps = { labels: {} };
|
|
32
32
|
state = { expanded: !1 };
|
|
33
|
-
panelId =
|
|
33
|
+
panelId = n("pie-collapsible");
|
|
34
34
|
toggleExpanded = () => {
|
|
35
35
|
this.setState((e) => ({ expanded: !e.expanded }));
|
|
36
36
|
};
|
|
37
|
+
relabel = () => this.forceUpdate();
|
|
37
38
|
componentDidMount() {
|
|
38
|
-
|
|
39
|
+
l(this.root);
|
|
39
40
|
}
|
|
40
41
|
componentDidUpdate() {
|
|
41
|
-
|
|
42
|
+
l(this.root);
|
|
42
43
|
}
|
|
43
44
|
render() {
|
|
44
|
-
let { labels: e, children:
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
className:
|
|
45
|
+
let { labels: e, children: n, className: r, language: i } = this.props, { expanded: a } = this.state, c = t.forLocale(i, this.relabel), l = a ? e.visible || c.t("hide") : e.hidden || c.t("show");
|
|
46
|
+
return /* @__PURE__ */ s("div", {
|
|
47
|
+
className: r,
|
|
47
48
|
ref: (e) => this.root = e,
|
|
48
|
-
children: [/* @__PURE__ */
|
|
49
|
+
children: [/* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(u, {
|
|
49
50
|
type: "button",
|
|
50
|
-
"aria-expanded":
|
|
51
|
+
"aria-expanded": a,
|
|
51
52
|
"aria-controls": this.panelId,
|
|
52
53
|
onClick: this.toggleExpanded,
|
|
53
|
-
children: /* @__PURE__ */
|
|
54
|
-
}) }), /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ o(d, { children: l })
|
|
55
|
+
}) }), /* @__PURE__ */ o("div", {
|
|
55
56
|
id: this.panelId,
|
|
56
|
-
children: /* @__PURE__ */
|
|
57
|
-
in:
|
|
57
|
+
children: /* @__PURE__ */ o(f, {
|
|
58
|
+
in: a,
|
|
58
59
|
timeout: {
|
|
59
60
|
enter: 225,
|
|
60
61
|
exit: 195
|
|
61
62
|
},
|
|
62
63
|
unmountOnExit: !0,
|
|
63
|
-
children:
|
|
64
|
+
children: n
|
|
64
65
|
})
|
|
65
66
|
})]
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
//#endregion
|
|
70
|
-
export {
|
|
71
|
+
export { p as Collapsible, p as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The interface strings `@pie-lib/render-ui` renders itself; the source for every other locale. */
|
|
2
|
+
declare const _default: {
|
|
3
|
+
/** Accessible name of a prompt's custom audio play button. */
|
|
4
|
+
playAudio: string;
|
|
5
|
+
/** Default toggle labels of a collapsed and an expanded `Collapsible`. */
|
|
6
|
+
show: string;
|
|
7
|
+
hide: string;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
package/dist/i18n/es.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e from "./en-US.js";
|
|
2
|
+
import { defineCatalogs as t } from "@pie-element/shared-i18n";
|
|
3
|
+
//#region src/i18n/index.ts
|
|
4
|
+
var n = t({
|
|
5
|
+
packageName: "@pie-lib/render-ui",
|
|
6
|
+
source: e,
|
|
7
|
+
loaders: { es: () => import(
|
|
8
|
+
/* webpackMode: "eager" */
|
|
9
|
+
"./es.js"
|
|
10
|
+
) }
|
|
11
|
+
});
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as catalogs };
|
package/dist/preview-prompt.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class PreviewPrompt extends Component {
|
|
|
8
8
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
9
|
defaultClassName: PropTypes.Requireable<string>;
|
|
10
10
|
autoplayAudioEnabled: PropTypes.Requireable<boolean>;
|
|
11
|
+
/** Set by the item player when the toolkit holds autoplay; it outranks `autoplayAudioEnabled`. */
|
|
12
|
+
autoplayAudioHeld: PropTypes.Requireable<boolean>;
|
|
11
13
|
customAudioButton: PropTypes.Requireable<PropTypes.InferProps<{
|
|
12
14
|
playImage: PropTypes.Requireable<string>;
|
|
13
15
|
pauseImage: PropTypes.Requireable<string>;
|
|
@@ -22,6 +24,12 @@ export declare class PreviewPrompt extends Component {
|
|
|
22
24
|
audioId: string;
|
|
23
25
|
playButtonId: string;
|
|
24
26
|
parsedText: any;
|
|
27
|
+
/**
|
|
28
|
+
* Names the custom audio button on the live node. The name stays out of `parsedText`: a
|
|
29
|
+
* catalog landing after the first render would change the prompt's HTML, and React would
|
|
30
|
+
* replace the prompt, audio included, mid-playback.
|
|
31
|
+
*/
|
|
32
|
+
labelPlayButton: () => void;
|
|
25
33
|
addCustomAudioButtonControls(): void;
|
|
26
34
|
removeCustomAudioButtonListeners(): void;
|
|
27
35
|
componentDidMount(): void;
|
package/dist/preview-prompt.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { focusOutline as e, tableGrid as t, tableStripe as n, text as r } from "./color.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import s from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
2
|
+
import { catalogs as i } from "./i18n/index.js";
|
|
3
|
+
import { createUniqueId as a } from "./unique-id.js";
|
|
4
|
+
import o, { Component as s } from "react";
|
|
5
|
+
import c from "prop-types";
|
|
6
|
+
import { styled as l } from "@mui/material/styles";
|
|
7
|
+
import { PLAY_AUDIO_ATTR as u, autoplayAudioOn as d, sanitizeModelHtml as f } from "@pie-element/shared-utils";
|
|
8
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
9
|
+
import { renderMath as m } from "@pie-element/shared-math-rendering-mathjax";
|
|
10
10
|
//#region src/preview-prompt.tsx
|
|
11
|
-
var
|
|
11
|
+
var h = "pie-prompt-audio-player", g = "play-audio-button", _ = (e) => `&:not(.MathJax) > table${e}, &:not(.MathJax) > .pie-table-scroll > table${e}`, v = l("div")(({ theme: i, tagName: a }) => ({
|
|
12
12
|
[`& .${g}:focus-visible`]: {
|
|
13
13
|
outline: `2px solid ${e()}`,
|
|
14
14
|
outlineOffset: "2px"
|
|
@@ -45,35 +45,41 @@ var { translator: m } = p, h = "pie-prompt-audio-player", g = "play-audio-button
|
|
|
45
45
|
cursor: "pointer",
|
|
46
46
|
"& > p": { margin: "0 0 0 0 !important" }
|
|
47
47
|
}
|
|
48
|
-
})), y = /\\embed\{newLine\}\[\]/g, b = "\\newline ", x = "preview-prompt", S = class extends
|
|
48
|
+
})), y = /\\embed\{newLine\}\[\]/g, b = "\\newline ", x = "preview-prompt", S = class extends s {
|
|
49
49
|
static propTypes = {
|
|
50
|
-
prompt:
|
|
51
|
-
tagName:
|
|
52
|
-
className:
|
|
53
|
-
onClick:
|
|
54
|
-
defaultClassName:
|
|
55
|
-
autoplayAudioEnabled:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
prompt: c.string,
|
|
51
|
+
tagName: c.string,
|
|
52
|
+
className: c.string,
|
|
53
|
+
onClick: c.func,
|
|
54
|
+
defaultClassName: c.string,
|
|
55
|
+
autoplayAudioEnabled: c.bool,
|
|
56
|
+
autoplayAudioHeld: c.bool,
|
|
57
|
+
customAudioButton: c.shape({
|
|
58
|
+
playImage: c.string,
|
|
59
|
+
pauseImage: c.string
|
|
59
60
|
}),
|
|
60
|
-
language:
|
|
61
|
+
language: c.string
|
|
61
62
|
};
|
|
62
63
|
static defaultProps = { onClick: () => {} };
|
|
63
|
-
promptRef =
|
|
64
|
-
audioId =
|
|
65
|
-
playButtonId =
|
|
64
|
+
promptRef = o.createRef();
|
|
65
|
+
audioId = a(h);
|
|
66
|
+
playButtonId = a(g);
|
|
66
67
|
parsedText = (e) => {
|
|
67
|
-
let {
|
|
68
|
-
|
|
69
|
-
let
|
|
70
|
-
if (
|
|
71
|
-
let e =
|
|
72
|
-
if (e
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
let { customAudioButton: t } = this.props, n = d(this.props), r = document.createElement("div");
|
|
69
|
+
r.innerHTML = f(e);
|
|
70
|
+
let i = r.querySelector("audio");
|
|
71
|
+
if (i) {
|
|
72
|
+
let e = i.getAttribute("src");
|
|
73
|
+
if (e) {
|
|
74
|
+
let t = document.createElement("source");
|
|
75
|
+
t.setAttribute("type", "audio/mp3"), t.setAttribute("src", e), i.removeAttribute("src"), i.appendChild(t);
|
|
76
|
+
}
|
|
77
|
+
let a = !1;
|
|
78
|
+
if (i.id) for (let e of r.querySelectorAll(`[${u}]`)) e.getAttribute(u) === i.id && (e.setAttribute(u, this.audioId), a = !0);
|
|
79
|
+
if (i.id = this.audioId, i.classList.add(h), !n && !t && !a && i.setAttribute("controls", ""), t) {
|
|
80
|
+
i.style.display = "none";
|
|
75
81
|
let e = document.createElement("button");
|
|
76
|
-
e.setAttribute("type", "button"), e.
|
|
82
|
+
e.setAttribute("type", "button"), e.id = this.playButtonId, e.className = g, Object.assign(e.style, {
|
|
77
83
|
cursor: "pointer",
|
|
78
84
|
display: "block",
|
|
79
85
|
width: "128px",
|
|
@@ -82,48 +88,51 @@ var { translator: m } = p, h = "pie-prompt-audio-player", g = "play-audio-button
|
|
|
82
88
|
padding: "0",
|
|
83
89
|
font: "inherit",
|
|
84
90
|
backgroundColor: "transparent",
|
|
85
|
-
backgroundImage: `url(${
|
|
91
|
+
backgroundImage: `url(${n ? t.pauseImage : t.playImage})`,
|
|
86
92
|
backgroundSize: "cover",
|
|
87
93
|
borderRadius: "50%",
|
|
88
94
|
border: "1px solid #326295"
|
|
89
|
-
}),
|
|
95
|
+
}), i.parentNode.insertBefore(e, i);
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
|
-
return
|
|
98
|
+
return r.innerHTML;
|
|
99
|
+
};
|
|
100
|
+
labelPlayButton = () => {
|
|
101
|
+
(this.promptRef.current?.querySelector(`.${g}`))?.setAttribute("aria-label", i.forLocale(this.props.language, this.labelPlayButton).t("playAudio"));
|
|
93
102
|
};
|
|
94
103
|
addCustomAudioButtonControls() {
|
|
95
|
-
let {
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
}).catch((
|
|
99
|
-
|
|
100
|
-
}), !
|
|
101
|
-
let
|
|
102
|
-
|
|
104
|
+
let { customAudioButton: e } = this.props, t = this.promptRef.current, n = t?.querySelector(`.${g}`), r = t?.querySelector(`.${h}`);
|
|
105
|
+
if (d(this.props) && r && r.play().then(() => {
|
|
106
|
+
n && e && r.addEventListener("ended", a);
|
|
107
|
+
}).catch((t) => {
|
|
108
|
+
n && e && (n.style.backgroundImage = `url(${e.playImage})`), console.error("Error playing audio", t);
|
|
109
|
+
}), !n || !r || !e) return;
|
|
110
|
+
let i = () => {
|
|
111
|
+
r.paused && r.play();
|
|
112
|
+
}, a = () => {
|
|
113
|
+
n.style.backgroundImage = `url(${e.playImage})`;
|
|
103
114
|
}, o = () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Object.assign(r.style, {
|
|
107
|
-
backgroundImage: `url(${t.pauseImage})`,
|
|
115
|
+
Object.assign(n.style, {
|
|
116
|
+
backgroundImage: `url(${e.pauseImage})`,
|
|
108
117
|
border: "1px solid #ccc"
|
|
109
118
|
});
|
|
110
|
-
},
|
|
111
|
-
Object.assign(
|
|
112
|
-
backgroundImage: `url(${
|
|
119
|
+
}, s = () => {
|
|
120
|
+
Object.assign(n.style, {
|
|
121
|
+
backgroundImage: `url(${e.playImage})`,
|
|
113
122
|
border: "1px solid #326295"
|
|
114
123
|
});
|
|
115
124
|
};
|
|
116
|
-
|
|
125
|
+
n.addEventListener("click", i), r.addEventListener("play", o), r.addEventListener("pause", s), r.addEventListener("ended", a), this._playButton = n, this._audio = r, this._handlePlayClick = i, this._handleAudioPlay = o, this._handleAudioPause = s, this._handleAudioEnded = a;
|
|
117
126
|
}
|
|
118
127
|
removeCustomAudioButtonListeners() {
|
|
119
128
|
let e = this._playButton, t = this._audio;
|
|
120
129
|
!e || !t || (e.removeEventListener("click", this._handlePlayClick), t.removeEventListener("play", this._handleAudioPlay), t.removeEventListener("pause", this._handleAudioPause), t.removeEventListener("ended", this._handleAudioEnded));
|
|
121
130
|
}
|
|
122
131
|
componentDidMount() {
|
|
123
|
-
this.alignImages(), this.addCustomAudioButtonControls(), this.setupMathRendering();
|
|
132
|
+
this.alignImages(), this.labelPlayButton(), this.addCustomAudioButtonControls(), this.setupMathRendering();
|
|
124
133
|
}
|
|
125
134
|
componentDidUpdate(e) {
|
|
126
|
-
this.alignImages(), e.prompt !== this.props.prompt && this.renderMathContent();
|
|
135
|
+
this.alignImages(), this.labelPlayButton(), e.prompt !== this.props.prompt && this.renderMathContent();
|
|
127
136
|
}
|
|
128
137
|
componentWillUnmount() {
|
|
129
138
|
this.removeCustomAudioButtonListeners();
|
|
@@ -133,7 +142,7 @@ var { translator: m } = p, h = "pie-prompt-audio-player", g = "play-audio-button
|
|
|
133
142
|
}
|
|
134
143
|
renderMathContent() {
|
|
135
144
|
let e = this.promptRef.current;
|
|
136
|
-
e && typeof
|
|
145
|
+
e && typeof m == "function" && m(e);
|
|
137
146
|
}
|
|
138
147
|
alignImages() {
|
|
139
148
|
let e = this.promptRef.current;
|
|
@@ -154,7 +163,7 @@ var { translator: m } = p, h = "pie-prompt-audio-player", g = "play-audio-button
|
|
|
154
163
|
}
|
|
155
164
|
render() {
|
|
156
165
|
let { prompt: e, tagName: t, className: n, onClick: r, defaultClassName: i } = this.props, a = `${n || ""} ${i || ""} ${t === "legend" ? "legend" : ""} ${x}`.trim();
|
|
157
|
-
return /* @__PURE__ */
|
|
166
|
+
return /* @__PURE__ */ p(v, {
|
|
158
167
|
as: t || "div",
|
|
159
168
|
ref: this.promptRef,
|
|
160
169
|
onClick: r,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "8.0.6-next.
|
|
3
|
+
"version": "8.0.6-next.20261016234357",
|
|
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,13 +13,13 @@
|
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
15
|
"@pie-lib/icons": "5.0.2-next.20261006160832",
|
|
16
|
-
"@pie-
|
|
16
|
+
"@pie-element/shared-i18n": "0.1.1-next.20261016234357",
|
|
17
17
|
"debug": "^4.1.1",
|
|
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.7-next.20261015154938",
|
|
21
21
|
"@pie-element/shared-lodash": "0.1.3-next.20261012213240",
|
|
22
|
-
"@pie-element/shared-utils": "0.1.5-next.
|
|
22
|
+
"@pie-element/shared-utils": "0.1.5-next.20261016234357"
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
25
|
"main": "./dist/index.js",
|