@pie-lib/render-ui 6.1.1-next.36 → 6.1.1-next.37
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/_virtual/_rolldown/runtime.js +11 -0
- package/dist/assets/enableAudioAutoplayImage.d.ts +10 -0
- package/dist/assets/enableAudioAutoplayImage.js +4 -0
- package/dist/collapsible/index.d.ts +31 -0
- package/dist/collapsible/index.js +53 -0
- package/dist/color.d.ts +116 -0
- package/dist/color.js +120 -0
- package/dist/feedback.d.ts +20 -0
- package/dist/feedback.js +65 -0
- package/dist/has-media.d.ts +9 -0
- package/dist/has-media.js +10 -0
- package/dist/has-text.d.ts +9 -0
- package/dist/has-text.js +10 -0
- package/dist/html-and-math.d.ts +22 -0
- package/dist/html-and-math.js +25 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +18 -0
- package/dist/inline-menu.d.ts +33 -0
- package/dist/inline-menu.js +29 -0
- package/dist/input-container.d.ts +23 -0
- package/dist/input-container.js +39 -0
- package/dist/preview-layout.d.ts +24 -0
- package/dist/preview-layout.js +37 -0
- package/dist/preview-prompt.d.ts +38 -0
- package/dist/preview-prompt.js +154 -0
- package/dist/purpose.d.ts +18 -0
- package/dist/purpose.js +11 -0
- package/dist/readable.d.ts +18 -0
- package/dist/readable.js +11 -0
- package/dist/response-indicators.d.ts +121 -0
- package/dist/response-indicators.js +62 -0
- package/{src/transform-headings.js → dist/transform-headings.d.ts} +9 -30
- package/dist/transform-headings.js +15 -0
- package/dist/ui-layout.d.ts +31 -0
- package/dist/ui-layout.js +55 -0
- package/dist/withUndoReset.d.ts +47 -0
- package/dist/withUndoReset.js +84 -0
- package/package.json +32 -20
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -1144
- package/LICENSE.md +0 -5
- package/lib/assets/enableAudioAutoplayImage.js +0 -8
- package/lib/assets/enableAudioAutoplayImage.js.map +0 -1
- package/lib/collapsible/index.js +0 -105
- package/lib/collapsible/index.js.map +0 -1
- package/lib/color.js +0 -235
- package/lib/color.js.map +0 -1
- package/lib/feedback.js +0 -112
- package/lib/feedback.js.map +0 -1
- package/lib/has-media.js +0 -22
- package/lib/has-media.js.map +0 -1
- package/lib/has-text.js +0 -22
- package/lib/has-text.js.map +0 -1
- package/lib/html-and-math.js +0 -54
- package/lib/html-and-math.js.map +0 -1
- package/lib/index.js +0 -113
- package/lib/index.js.map +0 -1
- package/lib/input-container.js +0 -59
- package/lib/input-container.js.map +0 -1
- package/lib/preview-layout.js +0 -65
- package/lib/preview-layout.js.map +0 -1
- package/lib/preview-prompt.js +0 -299
- package/lib/preview-prompt.js.map +0 -1
- package/lib/purpose.js +0 -22
- package/lib/purpose.js.map +0 -1
- package/lib/readable.js +0 -22
- package/lib/readable.js.map +0 -1
- package/lib/response-indicators.js +0 -102
- package/lib/response-indicators.js.map +0 -1
- package/lib/transform-headings.js +0 -53
- package/lib/transform-headings.js.map +0 -1
- package/lib/ui-layout.js +0 -125
- package/lib/ui-layout.js.map +0 -1
- package/lib/withUndoReset.js +0 -135
- package/lib/withUndoReset.js.map +0 -1
- package/src/__tests__/color.test.js +0 -259
- package/src/__tests__/feedback.test.jsx +0 -279
- package/src/__tests__/has-media.test.js +0 -19
- package/src/__tests__/has-text.test.js +0 -20
- package/src/__tests__/html-and-math.test.js +0 -36
- package/src/__tests__/input-container.test.jsx +0 -328
- package/src/__tests__/preview-layout.test.jsx +0 -349
- package/src/__tests__/preview-prompt.test.jsx +0 -379
- package/src/__tests__/purpose.test.jsx +0 -51
- package/src/__tests__/readable.test.jsx +0 -69
- package/src/__tests__/response-indicators.test.jsx +0 -111
- package/src/__tests__/ui-layout.test.jsx +0 -52
- package/src/__tests__/withUndoReset.test.jsx +0 -176
- package/src/assets/enableAudioAutoplayImage.js +0 -1
- package/src/collapsible/__tests__/index.test.jsx +0 -39
- package/src/collapsible/index.jsx +0 -64
- package/src/color.js +0 -139
- package/src/feedback.jsx +0 -84
- package/src/has-media.js +0 -16
- package/src/has-text.js +0 -18
- package/src/html-and-math.js +0 -21
- package/src/index.js +0 -35
- package/src/input-container.jsx +0 -47
- package/src/preview-layout.jsx +0 -41
- package/src/preview-prompt.jsx +0 -280
- package/src/purpose.jsx +0 -17
- package/src/readable.jsx +0 -19
- package/src/response-indicators.jsx +0 -82
- package/src/ui-layout.jsx +0 -96
- package/src/withUndoReset.jsx +0 -114
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/render-ui/src/response-indicators.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const Correct: {
|
|
11
|
+
new (props: any): {
|
|
12
|
+
handlePopoverOpen: any;
|
|
13
|
+
handlePopoverClose: any;
|
|
14
|
+
render(): React.JSX.Element;
|
|
15
|
+
context: unknown;
|
|
16
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
17
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
18
|
+
readonly props: Readonly<{}>;
|
|
19
|
+
state: Readonly<{}>;
|
|
20
|
+
refs: {
|
|
21
|
+
[key: string]: React.ReactInstance;
|
|
22
|
+
};
|
|
23
|
+
componentDidMount?(): void;
|
|
24
|
+
shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
25
|
+
componentWillUnmount?(): void;
|
|
26
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
27
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
28
|
+
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
29
|
+
componentWillMount?(): void;
|
|
30
|
+
UNSAFE_componentWillMount?(): void;
|
|
31
|
+
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
32
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
33
|
+
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
34
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
35
|
+
};
|
|
36
|
+
contextType?: React.Context<any> | undefined;
|
|
37
|
+
};
|
|
38
|
+
export declare const Incorrect: {
|
|
39
|
+
new (props: any): {
|
|
40
|
+
handlePopoverOpen: any;
|
|
41
|
+
handlePopoverClose: any;
|
|
42
|
+
render(): React.JSX.Element;
|
|
43
|
+
context: unknown;
|
|
44
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
45
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
46
|
+
readonly props: Readonly<{}>;
|
|
47
|
+
state: Readonly<{}>;
|
|
48
|
+
refs: {
|
|
49
|
+
[key: string]: React.ReactInstance;
|
|
50
|
+
};
|
|
51
|
+
componentDidMount?(): void;
|
|
52
|
+
shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
53
|
+
componentWillUnmount?(): void;
|
|
54
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
55
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
56
|
+
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
57
|
+
componentWillMount?(): void;
|
|
58
|
+
UNSAFE_componentWillMount?(): void;
|
|
59
|
+
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
60
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
61
|
+
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
62
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
63
|
+
};
|
|
64
|
+
contextType?: React.Context<any> | undefined;
|
|
65
|
+
};
|
|
66
|
+
export declare const PartiallyCorrect: {
|
|
67
|
+
new (props: any): {
|
|
68
|
+
handlePopoverOpen: any;
|
|
69
|
+
handlePopoverClose: any;
|
|
70
|
+
render(): React.JSX.Element;
|
|
71
|
+
context: unknown;
|
|
72
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
73
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
74
|
+
readonly props: Readonly<{}>;
|
|
75
|
+
state: Readonly<{}>;
|
|
76
|
+
refs: {
|
|
77
|
+
[key: string]: React.ReactInstance;
|
|
78
|
+
};
|
|
79
|
+
componentDidMount?(): void;
|
|
80
|
+
shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
81
|
+
componentWillUnmount?(): void;
|
|
82
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
83
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
84
|
+
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
85
|
+
componentWillMount?(): void;
|
|
86
|
+
UNSAFE_componentWillMount?(): void;
|
|
87
|
+
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
88
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
89
|
+
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
90
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
91
|
+
};
|
|
92
|
+
contextType?: React.Context<any> | undefined;
|
|
93
|
+
};
|
|
94
|
+
export declare const NothingSubmitted: {
|
|
95
|
+
new (props: any): {
|
|
96
|
+
handlePopoverOpen: any;
|
|
97
|
+
handlePopoverClose: any;
|
|
98
|
+
render(): React.JSX.Element;
|
|
99
|
+
context: unknown;
|
|
100
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
101
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
102
|
+
readonly props: Readonly<{}>;
|
|
103
|
+
state: Readonly<{}>;
|
|
104
|
+
refs: {
|
|
105
|
+
[key: string]: React.ReactInstance;
|
|
106
|
+
};
|
|
107
|
+
componentDidMount?(): void;
|
|
108
|
+
shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
109
|
+
componentWillUnmount?(): void;
|
|
110
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
111
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
112
|
+
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
113
|
+
componentWillMount?(): void;
|
|
114
|
+
UNSAFE_componentWillMount?(): void;
|
|
115
|
+
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
116
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
117
|
+
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
118
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
119
|
+
};
|
|
120
|
+
contextType?: React.Context<any> | undefined;
|
|
121
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import t from "./feedback.js";
|
|
3
|
+
import n from "react";
|
|
4
|
+
import r from "prop-types";
|
|
5
|
+
import * as i from "@pie-lib/icons";
|
|
6
|
+
import a from "@mui/material/Popover";
|
|
7
|
+
import { styled as o } from "@mui/material/styles";
|
|
8
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
9
|
+
import l from "debug";
|
|
10
|
+
//#region src/response-indicators.tsx
|
|
11
|
+
var u = /* @__PURE__ */ e({
|
|
12
|
+
Correct: () => g,
|
|
13
|
+
Incorrect: () => _,
|
|
14
|
+
NothingSubmitted: () => y,
|
|
15
|
+
PartiallyCorrect: () => v
|
|
16
|
+
}), d = l("pie-libs:render-ui:response-indicators"), f = o("div")(({ hasFeedback: e }) => ({ cursor: e ? "pointer" : "default" })), p = o(a)({ cursor: "pointer" }), m = o("div")({
|
|
17
|
+
padding: "0",
|
|
18
|
+
borderRadius: "4px"
|
|
19
|
+
}), h = (e, i) => {
|
|
20
|
+
class a extends n.Component {
|
|
21
|
+
constructor(e) {
|
|
22
|
+
super(e), this.state = {};
|
|
23
|
+
}
|
|
24
|
+
handlePopoverOpen = (e) => {
|
|
25
|
+
d("[handlePopoverOpen]", e.target), this.setState({ anchorEl: e.target });
|
|
26
|
+
};
|
|
27
|
+
handlePopoverClose = () => {
|
|
28
|
+
this.setState({ anchorEl: null });
|
|
29
|
+
};
|
|
30
|
+
render() {
|
|
31
|
+
let { feedback: n } = this.props, { anchorEl: r } = this.state;
|
|
32
|
+
return /* @__PURE__ */ c(f, {
|
|
33
|
+
hasFeedback: !!n,
|
|
34
|
+
children: [/* @__PURE__ */ s("span", {
|
|
35
|
+
ref: (e) => this.icon = e,
|
|
36
|
+
onClick: this.handlePopoverOpen,
|
|
37
|
+
children: /* @__PURE__ */ s(e, {})
|
|
38
|
+
}), n && /* @__PURE__ */ s(p, {
|
|
39
|
+
PaperComponent: m,
|
|
40
|
+
open: !!r,
|
|
41
|
+
anchorEl: r,
|
|
42
|
+
anchorOrigin: {
|
|
43
|
+
vertical: "bottom",
|
|
44
|
+
horizontal: "left"
|
|
45
|
+
},
|
|
46
|
+
transformOrigin: {
|
|
47
|
+
vertical: "top",
|
|
48
|
+
horizontal: "left"
|
|
49
|
+
},
|
|
50
|
+
onClose: this.handlePopoverClose,
|
|
51
|
+
children: /* @__PURE__ */ s(t, {
|
|
52
|
+
feedback: n,
|
|
53
|
+
correctness: i
|
|
54
|
+
})
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return a.propTypes = { feedback: r.string }, a;
|
|
60
|
+
}, g = h(i.Correct, "correct"), _ = h(i.Incorrect, "incorrect"), v = h(i.PartiallyCorrect, "partially-correct"), y = h(i.NothingSubmitted, "nothing-submitted");
|
|
61
|
+
//#endregion
|
|
62
|
+
export { u as response_indicators_exports };
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/render-ui/src/transform-headings.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* transformDataHeadings
|
|
3
11
|
*
|
|
@@ -18,33 +26,4 @@
|
|
|
18
26
|
* // baseLevel=2, data-heading="heading2" → <h3 data-heading="heading2">…</h3>
|
|
19
27
|
* // baseLevel=3, data-heading="heading1" → <h3 data-heading="heading1">…</h3>
|
|
20
28
|
*/
|
|
21
|
-
export function transformDataHeadings(html
|
|
22
|
-
if (!html) return html;
|
|
23
|
-
|
|
24
|
-
const parser = new DOMParser();
|
|
25
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
26
|
-
|
|
27
|
-
doc.body.querySelectorAll('[data-heading]').forEach((el) => {
|
|
28
|
-
const raw = el.getAttribute('data-heading') || '';
|
|
29
|
-
const n = parseInt(raw.replace('heading', ''), 10);
|
|
30
|
-
|
|
31
|
-
if (!Number.isFinite(n)) return; // skip malformed values
|
|
32
|
-
|
|
33
|
-
const level = Math.min(6, Math.max(1, baseLevel + n - 1));
|
|
34
|
-
const heading = doc.createElement(`h${level}`);
|
|
35
|
-
|
|
36
|
-
heading.setAttribute('data-heading', raw);
|
|
37
|
-
|
|
38
|
-
// Copy all other attributes (class, id, style, …)
|
|
39
|
-
Array.from(el.attributes).forEach((attr) => {
|
|
40
|
-
if (attr.name !== 'data-heading') {
|
|
41
|
-
heading.setAttribute(attr.name, attr.value);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
heading.innerHTML = el.innerHTML;
|
|
46
|
-
el.replaceWith(heading);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return doc.body.innerHTML;
|
|
50
|
-
}
|
|
29
|
+
export declare function transformDataHeadings(html?: string, baseLevel?: number): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/transform-headings.tsx
|
|
2
|
+
function e(e = "", t = 2) {
|
|
3
|
+
if (!e) return e;
|
|
4
|
+
let n = new DOMParser().parseFromString(e, "text/html");
|
|
5
|
+
return n.body.querySelectorAll("[data-heading]").forEach((e) => {
|
|
6
|
+
let r = e.getAttribute("data-heading") || "", i = parseInt(r.replace("heading", ""), 10);
|
|
7
|
+
if (!Number.isFinite(i)) return;
|
|
8
|
+
let a = Math.min(6, Math.max(1, t + i - 1)), o = n.createElement(`h${a}`);
|
|
9
|
+
o.setAttribute("data-heading", r), Array.from(e.attributes).forEach((e) => {
|
|
10
|
+
e.name !== "data-heading" && o.setAttribute(e.name, e.value);
|
|
11
|
+
}), o.innerHTML = e.innerHTML, e.replaceWith(o);
|
|
12
|
+
}), n.body.innerHTML;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { e as transformDataHeadings };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/render-ui/src/ui-layout.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
declare class UiLayout extends React.Component {
|
|
12
|
+
static propTypes: {
|
|
13
|
+
className: PropTypes.Requireable<string>;
|
|
14
|
+
children: PropTypes.Requireable<any[]>;
|
|
15
|
+
extraCSSRules: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
names: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
17
|
+
rules: PropTypes.Requireable<string>;
|
|
18
|
+
}>>;
|
|
19
|
+
fontSizeFactor: PropTypes.Requireable<number>;
|
|
20
|
+
};
|
|
21
|
+
static defaultProps: {
|
|
22
|
+
extraCSSRules: {};
|
|
23
|
+
fontSizeFactor: number;
|
|
24
|
+
};
|
|
25
|
+
constructor(props: any);
|
|
26
|
+
computeStyle(fontSizeFactor: any): {
|
|
27
|
+
fontSize: string;
|
|
28
|
+
} | null;
|
|
29
|
+
render(): React.JSX.Element;
|
|
30
|
+
}
|
|
31
|
+
export default UiLayout;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { StyledEngineProvider as n, ThemeProvider as r, createTheme as i, styled as a } from "@mui/material/styles";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region src/ui-layout.tsx
|
|
6
|
+
var c = i({
|
|
7
|
+
typography: { fontFamily: "inherit" },
|
|
8
|
+
palette: { action: { disabled: "rgba(0, 0, 0, 0.54);" } },
|
|
9
|
+
components: {
|
|
10
|
+
MuiTypography: { styleOverrides: { root: { fontFamily: "inherit" } } },
|
|
11
|
+
MuiButton: { styleOverrides: { contained: {
|
|
12
|
+
backgroundColor: "#e0e0e0",
|
|
13
|
+
color: "#000000",
|
|
14
|
+
"&:hover": { backgroundColor: "#bdbdbd" }
|
|
15
|
+
} } }
|
|
16
|
+
}
|
|
17
|
+
}), l = a("div")({ "& table, th, td": { fontSize: "inherit" } }), u = class extends e.Component {
|
|
18
|
+
static propTypes = {
|
|
19
|
+
className: t.string,
|
|
20
|
+
children: t.array,
|
|
21
|
+
extraCSSRules: t.shape({
|
|
22
|
+
names: t.arrayOf(t.string),
|
|
23
|
+
rules: t.string
|
|
24
|
+
}),
|
|
25
|
+
fontSizeFactor: t.number
|
|
26
|
+
};
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
extraCSSRules: {},
|
|
29
|
+
fontSizeFactor: 1
|
|
30
|
+
};
|
|
31
|
+
constructor(e) {
|
|
32
|
+
super(e), this.classesSheet = document.createElement("style");
|
|
33
|
+
}
|
|
34
|
+
computeStyle(e) {
|
|
35
|
+
let t = (e) => parseFloat(getComputedStyle(e).fontSize), n = t(document.documentElement), r = t(document.body), i = Math.max(n, r), a = e != null && typeof e == "number" ? e : 1;
|
|
36
|
+
return a === 1 ? null : { fontSize: `${i * a}px` };
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
let { children: e, className: t, fontSizeFactor: i, ...a } = this.props, { extraCSSRules: u, ...d } = a, f = this.computeStyle(i);
|
|
40
|
+
return /* @__PURE__ */ o(n, {
|
|
41
|
+
injectFirst: !0,
|
|
42
|
+
children: /* @__PURE__ */ s(r, {
|
|
43
|
+
theme: c,
|
|
44
|
+
children: [u?.rules ? /* @__PURE__ */ o("style", { dangerouslySetInnerHTML: { __html: `.extraCSSRules { ${u.rules} }` } }) : null, /* @__PURE__ */ o(l, {
|
|
45
|
+
className: `${t} extraCSSRules`,
|
|
46
|
+
...d,
|
|
47
|
+
...f && { style: f },
|
|
48
|
+
children: e
|
|
49
|
+
})]
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { u as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/render-ui/src/withUndoReset.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
/**
|
|
12
|
+
* HOC that adds undo and reset functionality for session values
|
|
13
|
+
*/
|
|
14
|
+
declare const withUndoReset: (WrappedComponent: any) => {
|
|
15
|
+
new (props: any): {
|
|
16
|
+
onSessionChange: any;
|
|
17
|
+
onUndo: any;
|
|
18
|
+
onReset: any;
|
|
19
|
+
render(): React.JSX.Element;
|
|
20
|
+
context: unknown;
|
|
21
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
22
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
23
|
+
readonly props: Readonly<{}>;
|
|
24
|
+
state: Readonly<{}>;
|
|
25
|
+
refs: {
|
|
26
|
+
[key: string]: React.ReactInstance;
|
|
27
|
+
};
|
|
28
|
+
componentDidMount?(): void;
|
|
29
|
+
shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
30
|
+
componentWillUnmount?(): void;
|
|
31
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
32
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
33
|
+
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
34
|
+
componentWillMount?(): void;
|
|
35
|
+
UNSAFE_componentWillMount?(): void;
|
|
36
|
+
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
37
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
38
|
+
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
39
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
40
|
+
};
|
|
41
|
+
propTypes: {
|
|
42
|
+
session: PropTypes.Requireable<object>;
|
|
43
|
+
onSessionChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
44
|
+
};
|
|
45
|
+
contextType?: React.Context<any> | undefined;
|
|
46
|
+
};
|
|
47
|
+
export default withUndoReset;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
import a from "@mui/material/Button";
|
|
6
|
+
import o from "@mui/icons-material/Restore";
|
|
7
|
+
import s from "@mui/icons-material/Undo";
|
|
8
|
+
//#region src/withUndoReset.tsx
|
|
9
|
+
var c = n("div")({
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column"
|
|
12
|
+
}), l = n("div")({
|
|
13
|
+
display: "flex",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
justifyContent: "center"
|
|
16
|
+
}), u = n("div")(({ theme: e }) => ({
|
|
17
|
+
width: "24px",
|
|
18
|
+
height: "24px",
|
|
19
|
+
color: "gray",
|
|
20
|
+
marginRight: e.spacing(1),
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center"
|
|
23
|
+
})), d = n(a)(({ theme: e }) => ({
|
|
24
|
+
display: "flex",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
marginLeft: e.spacing(3),
|
|
27
|
+
marginRight: e.spacing(3)
|
|
28
|
+
})), f = (n) => {
|
|
29
|
+
class a extends e.Component {
|
|
30
|
+
static propTypes = {
|
|
31
|
+
session: t.object,
|
|
32
|
+
onSessionChange: t.func
|
|
33
|
+
};
|
|
34
|
+
constructor(e) {
|
|
35
|
+
super(e), this.state = {
|
|
36
|
+
sessionInitialValues: JSON.parse(JSON.stringify(e.session)),
|
|
37
|
+
session: e.session,
|
|
38
|
+
changes: []
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
onSessionChange = (e) => {
|
|
42
|
+
this.setState((t) => ({
|
|
43
|
+
session: e,
|
|
44
|
+
changes: [...t.changes, e]
|
|
45
|
+
}), () => this.props.onSessionChange(e));
|
|
46
|
+
};
|
|
47
|
+
onUndo = () => {
|
|
48
|
+
this.setState((e) => {
|
|
49
|
+
let t = [...e.changes];
|
|
50
|
+
return t.pop(), {
|
|
51
|
+
changes: t,
|
|
52
|
+
session: t.length ? t[t.length - 1] : e.sessionInitialValues
|
|
53
|
+
};
|
|
54
|
+
}, () => this.props.onSessionChange(this.state.session));
|
|
55
|
+
};
|
|
56
|
+
onReset = () => {
|
|
57
|
+
this.setState((e) => ({
|
|
58
|
+
session: e.sessionInitialValues,
|
|
59
|
+
changes: []
|
|
60
|
+
}), () => this.props.onSessionChange(this.state.sessionInitialValues));
|
|
61
|
+
};
|
|
62
|
+
render() {
|
|
63
|
+
let { ...e } = this.props, { changes: t, session: a } = this.state;
|
|
64
|
+
return /* @__PURE__ */ i(c, { children: [/* @__PURE__ */ i(l, { children: [/* @__PURE__ */ i(d, {
|
|
65
|
+
color: "primary",
|
|
66
|
+
disabled: t.length === 0,
|
|
67
|
+
onClick: this.onUndo,
|
|
68
|
+
children: [/* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(s, {}) }), "Undo"]
|
|
69
|
+
}), /* @__PURE__ */ i(d, {
|
|
70
|
+
color: "primary",
|
|
71
|
+
disabled: t.length === 0,
|
|
72
|
+
onClick: this.onReset,
|
|
73
|
+
children: [/* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(o, {}) }), "Start Over"]
|
|
74
|
+
})] }), /* @__PURE__ */ r(n, {
|
|
75
|
+
...e,
|
|
76
|
+
session: a,
|
|
77
|
+
onSessionChange: this.onSessionChange
|
|
78
|
+
})] });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return a;
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { f as default };
|
package/package.json
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "6.1.1-next.
|
|
3
|
+
"version": "6.1.1-next.37",
|
|
4
4
|
"description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
|
|
5
|
-
"module": "src/index.js",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {},
|
|
11
|
-
"repository": "pie-framework/pie-lib",
|
|
12
5
|
"dependencies": {
|
|
13
6
|
"@emotion/react": "^11.14.0",
|
|
14
7
|
"@emotion/styled": "^11.14.1",
|
|
15
8
|
"@mui/icons-material": "^7.3.4",
|
|
16
9
|
"@mui/material": "^7.3.4",
|
|
17
|
-
"@pie-lib/icons": "
|
|
18
|
-
"@pie-lib/
|
|
19
|
-
"@pie-lib/test-utils": "^2.0.2",
|
|
10
|
+
"@pie-lib/icons": "4.0.2",
|
|
11
|
+
"@pie-lib/test-utils": "2.0.2",
|
|
20
12
|
"debug": "^4.1.1",
|
|
21
|
-
"lodash-es": "^4.17.23",
|
|
22
13
|
"prop-types": "^15.7.2",
|
|
23
|
-
"react-transition-group": "^4.4.5"
|
|
14
|
+
"react-transition-group": "^4.4.5",
|
|
15
|
+
"@pie-element/shared-math-rendering-mathjax": "0.1.1-next.0",
|
|
16
|
+
"@pie-element/shared-lodash": "0.1.1-next.0"
|
|
24
17
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "bun x vite build && bun x tsc --emitDeclarationOnly",
|
|
33
|
+
"dev": "bun x vite",
|
|
34
|
+
"test": "bun x vitest run"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
37
|
+
"vite": "^8.0.1",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
40
|
+
"@types/react": "^18.2.0",
|
|
41
|
+
"@types/react-dom": "^18.2.0"
|
|
33
42
|
},
|
|
34
|
-
"
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^18.0.0",
|
|
45
|
+
"react-dom": "^18.0.0"
|
|
46
|
+
}
|
|
35
47
|
}
|
package/CHANGELOG.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[]
|