@pie-lib/render-ui 4.32.6-esmbeta.2 → 4.35.0
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/CHANGELOG.md +48 -0
- package/lib/feedback.js +0 -1
- package/lib/feedback.js.map +1 -1
- package/lib/preview-layout.js +1 -45
- package/lib/preview-layout.js.map +1 -1
- package/lib/preview-prompt.js +9 -1
- package/lib/preview-prompt.js.map +1 -1
- package/lib/ui-layout.js +53 -2
- package/lib/ui-layout.js.map +1 -1
- package/package.json +5 -12
- package/src/feedback.jsx +0 -1
- package/src/preview-layout.jsx +2 -49
- package/src/preview-prompt.jsx +9 -1
- package/src/ui-layout.jsx +53 -4
- package/esm/index.css +0 -847
- package/esm/index.js +0 -48476
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.35.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.34.0...@pie-lib/render-ui@4.35.0) (2025-10-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/render-ui
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [4.34.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.34.0) (2025-10-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-lib/render-ui
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [4.33.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.33.0) (2025-10-16)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-lib/render-ui
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [4.32.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.32.0) (2025-10-16)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/render-ui
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [4.31.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.1...@pie-lib/render-ui@4.31.2) (2025-10-14)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @pie-lib/render-ui
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [4.31.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.31.1) (2025-10-09)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @pie-lib/render-ui
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
6
54
|
# [4.31.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.31.0) (2025-09-25)
|
|
7
55
|
|
|
8
56
|
|
package/lib/feedback.js
CHANGED
|
@@ -55,7 +55,6 @@ var styleSheet = {
|
|
|
55
55
|
'-webkit-font-smoothing': 'antialiased',
|
|
56
56
|
backgroundColor: "var(--feedback-bg-color, ".concat(color.disabled(), ")"),
|
|
57
57
|
borderRadius: '4px',
|
|
58
|
-
fontFamily: '"Roboto", "Noto", sans-serif',
|
|
59
58
|
lineHeight: '25px',
|
|
60
59
|
margin: '0px',
|
|
61
60
|
padding: '10px',
|
package/lib/feedback.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/feedback.jsx"],"names":["styleSheet","corespringFeedback","transformOrigin","width","display","overflow","color","content","backgroundColor","disabled","borderRadius","
|
|
1
|
+
{"version":3,"sources":["../src/feedback.jsx"],"names":["styleSheet","corespringFeedback","transformOrigin","width","display","overflow","color","content","backgroundColor","disabled","borderRadius","lineHeight","margin","padding","verticalAlign","correct","incorrect","feedbackEnter","height","feedbackEnterActive","transition","feedbackLeave","feedbackLeaveActive","Feedback","props","correctness","feedback","classes","chooseFeedback","enter","enterActive","leave","leaveActive","exit","__html","React","Component","PropTypes","string","object","isRequired","name"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG;AACjBC,EAAAA,kBAAkB,EAAE;AAClBC,IAAAA,eAAe,EAAE,YADC;AAElBC,IAAAA,KAAK,EAAE,MAFW;AAGlBC,IAAAA,OAAO,EAAE,OAHS;AAIlBC,IAAAA,QAAQ,EAAE,QAJQ;AAKlB,oBAAgB;AACdC,MAAAA,KAAK,EAAE;AADO;AALE,GADH;AAUjBC,EAAAA,OAAO,EAAE;AACP,8BAA0B,aADnB;AAEPC,IAAAA,eAAe,qCAA8BF,KAAK,CAACG,QAAN,EAA9B,MAFR;AAGPC,IAAAA,YAAY,EAAE,KAHP;AAIPC,IAAAA,UAAU,EAAE,MAJL;AAKPC,IAAAA,MAAM,EAAE,KALD;AAMPC,IAAAA,OAAO,EAAE,MANF;AAOPC,IAAAA,aAAa,EAAE,QAPR;AAQPR,IAAAA,KAAK,EAAE;AARA,GAVQ;AAoBjBS,EAAAA,OAAO,EAAE;AACPP,IAAAA,eAAe,6CAAsCF,KAAK,CAACS,OAAN,EAAtC;AADR,GApBQ;AAuBjBC,EAAAA,SAAS,EAAE;AACTR,IAAAA,eAAe,+CAAwCF,KAAK,CAACU,SAAN,EAAxC;AADN,GAvBM;AA0BjBC,EAAAA,aAAa,EAAE;AACbC,IAAAA,MAAM,EAAE;AADK,GA1BE;AA6BjBC,EAAAA,mBAAmB,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AAKD;;;EAzC2BU,kBAAMC,S;;;iCAAvBb,Q,eACQ;AACjBE,EAAAA,WAAW,EAAEY,sBAAUC,MADN;AAEjBZ,EAAAA,QAAQ,EAAEW,sBAAUC,MAFH;AAGjBX,EAAAA,OAAO,EAAEU,sBAAUE,MAAV,CAAiBC;AAHT,C;;eA2CN,wBAAWxC,UAAX,EAAuB;AAAEyC,EAAAA,IAAI,EAAE;AAAR,CAAvB,EAA6ClB,QAA7C,C","sourcesContent":["/**\n * Lifted from multiple-choice - TODO: create a shared package for it.\n */\nimport { withStyles } from '@material-ui/core/styles';\n\nimport React from 'react';\nimport { TransitionGroup, CSSTransition } from 'react-transition-group';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport * as color from './color';\n\nconst styleSheet = {\n corespringFeedback: {\n transformOrigin: '0% 0px 0px',\n width: '100%',\n display: 'block',\n overflow: 'hidden',\n '&:.incorrect': {\n color: '#946202',\n },\n },\n content: {\n '-webkit-font-smoothing': 'antialiased',\n backgroundColor: `var(--feedback-bg-color, ${color.disabled()})`,\n borderRadius: '4px',\n lineHeight: '25px',\n margin: '0px',\n padding: '10px',\n verticalAlign: 'middle',\n color: 'var(--feedback-color, white)',\n },\n correct: {\n backgroundColor: `var(--feedback-correct-bg-color, ${color.correct()})`,\n },\n incorrect: {\n backgroundColor: `var(--feedback-incorrect-bg-color, ${color.incorrect()})`,\n },\n feedbackEnter: {\n height: '1px',\n },\n feedbackEnterActive: {\n height: '45px',\n transition: 'height 500ms',\n },\n feedbackLeave: {\n height: '45px',\n },\n feedbackLeaveActive: {\n height: '1px',\n transition: 'height 200ms',\n },\n};\n\nexport class Feedback extends React.Component {\n static propTypes = {\n correctness: PropTypes.string,\n feedback: PropTypes.string,\n classes: PropTypes.object.isRequired,\n };\n\n render() {\n const { correctness, feedback, classes } = this.props;\n\n function chooseFeedback(correctness) {\n if (correctness && feedback) {\n return (\n <CSSTransition\n classNames={{\n enter: classes.feedbackEnter,\n enterActive: classes.feedbackEnterActive,\n leave: classes.feedbackLeave,\n leaveActive: classes.feedbackLeaveActive,\n }}\n key=\"hasFeedback\"\n timeout={{ enter: 500, exit: 300 }}\n >\n <div className={classes.corespringFeedback}>\n <div\n className={classNames(classes.content, classes[correctness])}\n dangerouslySetInnerHTML={{ __html: feedback }}\n />\n </div>\n </CSSTransition>\n );\n } else {\n return null;\n }\n }\n\n return (\n <div>\n <TransitionGroup>{chooseFeedback(correctness)}</TransitionGroup>\n </div>\n );\n }\n}\n\nexport default withStyles(styleSheet, { name: 'Feedback' })(Feedback);\n"],"file":"feedback.js"}
|
package/lib/preview-layout.js
CHANGED
|
@@ -90,54 +90,10 @@ var styles = function styles() {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
var theme = (0, _styles.createMuiTheme)({
|
|
94
|
-
typography: {
|
|
95
|
-
useNextVariants: true
|
|
96
|
-
},
|
|
97
|
-
palette: {
|
|
98
|
-
action: {
|
|
99
|
-
disabled: 'rgba(0, 0, 0, 0.54);'
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
overrides: {
|
|
103
|
-
MuiRadio: {
|
|
104
|
-
root: {
|
|
105
|
-
'&$checked': {
|
|
106
|
-
color: '#3f51b5 !important'
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
MuiCheckbox: {
|
|
111
|
-
root: {
|
|
112
|
-
'&$checked': {
|
|
113
|
-
color: '#3f51b5 !important'
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
MuiTabs: {
|
|
118
|
-
root: {
|
|
119
|
-
borderBottom: '1px solid #eee'
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
MuiSwitch: {
|
|
123
|
-
root: {
|
|
124
|
-
'&$checked': {
|
|
125
|
-
color: '#3f51b5 !important',
|
|
126
|
-
'& + $bar': {
|
|
127
|
-
backgroundColor: '#3f51b5 !important',
|
|
128
|
-
opacity: 0.5
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
93
|
var Styled = (0, _styles.withStyles)(styles)(PreviewLayout);
|
|
136
94
|
|
|
137
95
|
var RootElem = function RootElem(props) {
|
|
138
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
139
|
-
theme: theme
|
|
140
|
-
}, /*#__PURE__*/_react["default"].createElement(Styled, props));
|
|
96
|
+
return /*#__PURE__*/_react["default"].createElement(Styled, props);
|
|
141
97
|
};
|
|
142
98
|
|
|
143
99
|
var _default = RootElem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview-layout.jsx"],"names":["PreviewLayout","props","children","classes","ariaLabel","role","extraCSSRules","fontSizeFactor","accessibility","container","React","Component","PropTypes","string","oneOfType","arrayOf","node","isRequired","object","shape","names","rules","number","styles","display","flexDirection","position","
|
|
1
|
+
{"version":3,"sources":["../src/preview-layout.jsx"],"names":["PreviewLayout","props","children","classes","ariaLabel","role","extraCSSRules","fontSizeFactor","accessibility","container","React","Component","PropTypes","string","oneOfType","arrayOf","node","isRequired","object","shape","names","rules","number","styles","display","flexDirection","position","Styled","RootElem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;IAEMA,a;;;;;;;;;;;;WAaJ,kBAAS;AACP,wBAA8E,KAAKC,KAAnF;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,OAAlB,eAAkBA,OAAlB;AAAA,UAA2BC,SAA3B,eAA2BA,SAA3B;AAAA,UAAsCC,IAAtC,eAAsCA,IAAtC;AAAA,UAA4CC,aAA5C,eAA4CA,aAA5C;AAAA,UAA2DC,cAA3D,eAA2DA,cAA3D;AACA,UAAMC,aAAa,GAAGJ,SAAS,GAAG;AAAE,sBAAcA,SAAhB;AAA2BC,QAAAA,IAAI,EAAJA;AAA3B,OAAH,GAAuC,EAAtE;AAEA,0BACE,gCAAC,oBAAD;AACE,QAAA,SAAS,EAAEF,OAAO,CAACM;AADrB,SAEMD,aAFN;AAGE,QAAA,aAAa,EAAEF,aAHjB;AAIE,QAAA,cAAc,EAAEC;AAJlB,UAMGL,QANH,CADF;AAUD;;;EA3ByBQ,kBAAMC,S;;iCAA5BX,a,eACe;AACjBI,EAAAA,SAAS,EAAEQ,sBAAUC,MADJ;AAEjBX,EAAAA,QAAQ,EAAEU,sBAAUE,SAAV,CAAoB,CAACF,sBAAUG,OAAV,CAAkBH,sBAAUI,IAA5B,CAAD,EAAoCJ,sBAAUI,IAA9C,CAApB,EAAyEC,UAFlE;AAGjBd,EAAAA,OAAO,EAAES,sBAAUM,MAHF;AAIjBb,EAAAA,IAAI,EAAEO,sBAAUC,MAJC;AAKjBP,EAAAA,aAAa,EAAEM,sBAAUO,KAAV,CAAgB;AAC7BC,IAAAA,KAAK,EAAER,sBAAUG,OAAV,CAAkBH,sBAAUC,MAA5B,CADsB;AAE7BQ,IAAAA,KAAK,EAAET,sBAAUC;AAFY,GAAhB,CALE;AASjBN,EAAAA,cAAc,EAAEK,sBAAUU;AATT,C;;AA6BrB,IAAMC,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBd,IAAAA,SAAS,EAAE;AACTe,MAAAA,OAAO,EAAE,MADA;AAETC,MAAAA,aAAa,EAAE,QAFN;AAGTC,MAAAA,QAAQ,EAAE;AAHD;AADS,GAAP;AAAA,CAAf;;AAQA,IAAMC,MAAM,GAAG,wBAAWJ,MAAX,EAAmBvB,aAAnB,CAAf;;AAEA,IAAM4B,QAAQ,GAAG,SAAXA,QAAW,CAAC3B,KAAD;AAAA,sBAAW,gCAAC,MAAD,EAAYA,KAAZ,CAAX;AAAA,CAAjB;;eAEe2B,Q","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport UiLayout from './ui-layout';\n\nclass PreviewLayout extends React.Component {\n static propTypes = {\n ariaLabel: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n classes: PropTypes.object,\n role: PropTypes.string,\n extraCSSRules: PropTypes.shape({\n names: PropTypes.arrayOf(PropTypes.string),\n rules: PropTypes.string,\n }),\n fontSizeFactor: PropTypes.number,\n };\n\n render() {\n const { children, classes, ariaLabel, role, extraCSSRules, fontSizeFactor } = this.props;\n const accessibility = ariaLabel ? { 'aria-label': ariaLabel, role } : {};\n\n return (\n <UiLayout\n className={classes.container}\n {...accessibility}\n extraCSSRules={extraCSSRules}\n fontSizeFactor={fontSizeFactor}\n >\n {children}\n </UiLayout>\n );\n }\n}\n\nconst styles = () => ({\n container: {\n display: 'flex',\n flexDirection: 'column',\n position: 'relative',\n },\n});\n\nconst Styled = withStyles(styles)(PreviewLayout);\n\nconst RootElem = (props) => <Styled {...props} />;\n\nexport default RootElem;\n"],"file":"preview-layout.js"}
|
package/lib/preview-prompt.js
CHANGED
|
@@ -296,7 +296,15 @@ var styles = function styles(theme) {
|
|
|
296
296
|
'&:not(.MathJax) > table': {
|
|
297
297
|
borderCollapse: 'collapse'
|
|
298
298
|
},
|
|
299
|
-
|
|
299
|
+
// Apply vertical striping only when first column is a header column (th)
|
|
300
|
+
'&:not(.MathJax) > table:has(tr:first-child th:first-child) td': {
|
|
301
|
+
'&:nth-child(2n)': {
|
|
302
|
+
backgroundColor: '#f6f8fa',
|
|
303
|
+
color: theme.palette.common.black
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
// Apply horizontal striping for tables where first element is NOT a header (th)
|
|
307
|
+
'&:not(.MathJax) > table:not(:has(tr:first-child th:first-child)) tr': {
|
|
300
308
|
'&:nth-child(2n)': {
|
|
301
309
|
backgroundColor: '#f6f8fa',
|
|
302
310
|
color: theme.palette.common.black
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview-prompt.jsx"],"names":["NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","PreviewPrompt","text","customAudioButton","props","div","document","createElement","innerHTML","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","style","display","playButton","id","Object","assign","cursor","width","height","backgroundImage","pauseImage","backgroundSize","borderRadius","border","parentNode","insertBefore","autoplayAudioEnabled","getElementById","play","then","addEventListener","handleAudioEnded","error","console","handlePlayClick","paused","includes","playImage","handleAudioPlay","handleAudioPause","_handlePlayClick","_handleAudioPlay","_handleAudioPause","_handleAudioEnded","removeEventListener","alignImages","addCustomAudioButtonControls","removeCustomAudioButtonListeners","previewPrompts","querySelectorAll","forEach","previewPrompt","images","getElementsByTagName","length","image","attributes","alignment","value","parentElement","tagName","copyImage","cloneNode","replaceChild","prompt","classes","className","onClick","defaultClassName","CustomTag","legendClass","customClasses","promptTable","__html","parsedText","replace","Component","PropTypes","object","string","func","bool","styles","theme","verticalAlign","color","legend","fontSize","rationale","paddingLeft","spacing","unit","paddingBottom","label","flexDirection","margin","borderCollapse","backgroundColor","palette","common","black","padding","textAlign"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA;AACA,IAAMA,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;;IAEaC,a;;;;;;;;;;;;;;;mGAmBE,UAACC,IAAD,EAAU;AACrB,UAAQC,iBAAR,GAA8B,MAAKC,KAAnC,CAAQD,iBAAR;AACA,UAAME,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AACAF,MAAAA,GAAG,CAACG,SAAJ,GAAgBN,IAAhB;AAEA,UAAMO,KAAK,GAAGJ,GAAG,CAACK,aAAJ,CAAkB,OAAlB,CAAd;;AACA,UAAID,KAAJ,EAAW;AACT,YAAME,MAAM,GAAGL,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAf;AAEAI,QAAAA,MAAM,CAACC,YAAP,CAAoB,MAApB,EAA4B,WAA5B;AACAD,QAAAA,MAAM,CAACC,YAAP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MAAS,CAACC,KAAD;AAAA,SAAY;AACzBnB,IAAAA,MAAM,EAAE;AACNoB,MAAAA,aAAa,EAAE,QADT;AAENC,MAAAA,KAAK,EAAEA,KAAK,CAACzF,IAAN;AAFD,KADiB;AAKzB0F,IAAAA,MAAM,EAAE;AACNrE,MAAAA,KAAK,EAAE,MADD;AAENsE,MAAAA,QAAQ,EAAE;AAFJ,KALiB;AASzBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,WAAW,EAAEN,KAAK,CAACO,OAAN,CAAcC,IAAd,GAAqB,CADzB;AAETC,MAAAA,aAAa,EAAET,KAAK,CAACO,OAAN,CAAcC;AAFpB,KATc;AAazBE,IAAAA,KAAK,EAAE;AACLR,MAAAA,KAAK,YAAKA,KAAK,CAACzF,IAAN,EAAL,gBADA;AACgC;AACrCe,MAAAA,OAAO,EAAE,MAFJ;AAGLmF,MAAAA,aAAa,EAAE,QAHV;AAILV,MAAAA,aAAa,EAAE,QAJV;AAKLpE,MAAAA,MAAM,EAAE,SALH;AAML,eAAS;AACP+E,QAAAA,MAAM,EAAE;AADD;AANJ,KAbkB;AAuBzBvB,IAAAA,WAAW,EAAE;AACX,iCAA2B;AACzBwB,QAAAA,cAAc,EAAE;AADS,OADhB;AAIX,oCAA8B;AAC5B,2BAAmB;AACjBC,UAAAA,eAAe,EAAE,SADA;AAEjBZ,UAAAA,KAAK,EAAEF,KAAK,CAACe,OAAN,CAAcC,MAAd,CAAqBC;AAFX;AADS,OAJnB;AAUX;AACA,4DAAsD;AACpDC,QAAAA,OAAO,EAAE,UAD2C;AAEpDC,QAAAA,SAAS,EAAE;AAFyC,OAX3C;AAeX;AACA,mDAA6C;AAC3CA,QAAAA,SAAS,EAAE;AADgC;AAhBlC;AAvBY,GAAZ;AAAA,CAAf;;eA4Ce,wBAAWpB,MAAX,EAAmBvF,aAAnB,C","sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport * as color from './color';\n\n//Used these below to replace \\\\embed{newLine} with \\\\newline from prompt which will get parsed in MathJax\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nexport class PreviewPrompt extends Component {\n static propTypes = {\n classes: PropTypes.object,\n prompt: PropTypes.string,\n tagName: PropTypes.string,\n className: PropTypes.string,\n onClick: PropTypes.func,\n defaultClassName: PropTypes.string,\n autoplayAudioEnabled: PropTypes.bool,\n customAudioButton: {\n playImage: PropTypes.string,\n pauseImage: PropTypes.string,\n },\n };\n\n static defaultProps = {\n onClick: () => {},\n };\n\n parsedText = (text) => {\n const { customAudioButton } = this.props;\n const div = document.createElement('div');\n div.innerHTML = text;\n\n const audio = div.querySelector('audio');\n if (audio) {\n const source = document.createElement('source');\n\n source.setAttribute('type', 'audio/mp3');\n source.setAttribute('src', audio.getAttribute('src'));\n\n audio.removeAttribute('src');\n audio.setAttribute('id', 'pie-prompt-audio-player');\n\n audio.appendChild(source);\n\n if (customAudioButton) {\n audio.style.display = 'none';\n\n const playButton = document.createElement('div');\n playButton.id = 'play-audio-button';\n\n Object.assign(playButton.style, {\n cursor: 'pointer',\n display: 'block',\n width: '128px',\n height: '128px',\n backgroundImage: `url(${customAudioButton.pauseImage})`,\n backgroundSize: 'cover',\n borderRadius: '50%',\n border: '1px solid #326295',\n });\n\n audio.parentNode.insertBefore(playButton, audio);\n }\n }\n\n return div.innerHTML;\n };\n\n addCustomAudioButtonControls() {\n const { autoplayAudioEnabled, customAudioButton } = this.props;\n const playButton = document.getElementById('play-audio-button');\n const audio = document.getElementById('pie-prompt-audio-player');\n\n if (autoplayAudioEnabled && audio) {\n audio\n .play()\n .then(() => {\n if (playButton && customAudioButton) {\n audio.addEventListener('ended', handleAudioEnded);\n }\n })\n .catch((error) => {\n console.error('Error playing audio', error);\n });\n }\n\n if (!playButton || !audio || !customAudioButton) return;\n\n const handlePlayClick = () => {\n // if already playing, don't play again\n if (!audio.paused) return;\n if (playButton.style.backgroundImage.includes(customAudioButton.pauseImage)) return;\n\n audio.play();\n };\n\n const handleAudioEnded = () => {\n playButton.style.backgroundImage = `url(${customAudioButton.playImage})`;\n };\n\n const handleAudioPlay = () => {\n Object.assign(playButton.style, {\n backgroundImage: `url(${customAudioButton.pauseImage})`,\n border: '1px solid #ccc',\n });\n };\n\n const handleAudioPause = () => {\n Object.assign(playButton.style, {\n backgroundImage: `url(${customAudioButton.playImage})`,\n border: '1px solid #326295',\n });\n };\n\n playButton.addEventListener('click', handlePlayClick);\n audio.addEventListener('play', handleAudioPlay);\n audio.addEventListener('pause', handleAudioPause);\n audio.addEventListener('ended', handleAudioEnded);\n\n // store event handler references so they can be removed later\n this._handlePlayClick = handlePlayClick;\n this._handleAudioPlay = handleAudioPlay;\n this._handleAudioPause = handleAudioPause;\n this._handleAudioEnded = handleAudioEnded;\n }\n\n removeCustomAudioButtonListeners() {\n const playButton = document.getElementById('play-audio-button');\n const audio = document.querySelector('audio');\n\n if (!playButton || !audio) return;\n\n // remove event listeners using stored references\n playButton.removeEventListener('click', this._handlePlayClick);\n audio.removeEventListener('play', this._handleAudioPlay);\n audio.removeEventListener('pause', this._handleAudioPause);\n audio.removeEventListener('ended', this._handleAudioEnded);\n }\n\n componentDidMount() {\n this.alignImages();\n this.addCustomAudioButtonControls();\n }\n\n componentDidUpdate() {\n this.alignImages();\n }\n\n componentWillUnmount() {\n this.removeCustomAudioButtonListeners();\n }\n\n alignImages() {\n const previewPrompts = document.querySelectorAll('#preview-prompt');\n\n previewPrompts.forEach((previewPrompt) => {\n const images = previewPrompt.getElementsByTagName('img');\n\n if (images && images.length) {\n for (let image of images) {\n // check if alignment property was set\n if (image.attributes && image.attributes.alignment && image.attributes.alignment.value) {\n const parentNode = image.parentElement;\n\n // check if div is not already added to dom and replace current image with wrapped image\n if (\n !(\n parentNode.tagName === 'DIV' &&\n parentNode.style.display === 'flex' &&\n parentNode.style.width === '100%'\n )\n ) {\n const div = document.createElement('div');\n div.style.display = 'flex';\n div.style.width = '100%';\n\n const copyImage = image.cloneNode(true);\n div.appendChild(copyImage);\n parentNode.replaceChild(div, image);\n }\n }\n }\n }\n });\n }\n\n render() {\n const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;\n const CustomTag = tagName || 'div';\n // legend tag was added once with accessibility tasks, wee need extra style to make it work with images alignment\n const legendClass = tagName === 'legend' ? 'legend' : '';\n const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName || ''} ${classes[\n legendClass\n ] || ''}`;\n\n return (\n <CustomTag\n id={'preview-prompt'}\n onClick={onClick}\n className={customClasses}\n dangerouslySetInnerHTML={{\n __html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX),\n }}\n />\n );\n }\n}\n\nconst styles = (theme) => ({\n prompt: {\n verticalAlign: 'middle',\n color: color.text(),\n },\n legend: {\n width: '100%',\n fontSize: 'inherit !important',\n },\n rationale: {\n paddingLeft: theme.spacing.unit * 4,\n paddingBottom: theme.spacing.unit,\n },\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)',\n display: 'flex',\n flexDirection: 'column',\n verticalAlign: 'middle',\n cursor: 'pointer',\n '& > p': {\n margin: '0 0 0 0 !important',\n },\n },\n promptTable: {\n '&:not(.MathJax) > table': {\n borderCollapse: 'collapse',\n },\n '&:not(.MathJax) > table tr': {\n '&:nth-child(2n)': {\n backgroundColor: '#f6f8fa',\n color: theme.palette.common.black,\n },\n },\n // align table content to left as per STAR requirement PD-3687\n '&:not(.MathJax) table td, &:not(.MathJax) table th': {\n padding: '.6em 1em',\n textAlign: 'left',\n },\n // added this to fix alignment of text in prompt imported from studio (PD-3423)\n '&:not(.MathJax) > table td > p.kds-indent': {\n textAlign: 'initial',\n },\n },\n});\nexport default withStyles(styles)(PreviewPrompt);\n"],"file":"preview-prompt.js"}
|
|
1
|
+
{"version":3,"sources":["../src/preview-prompt.jsx"],"names":["NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","PreviewPrompt","text","customAudioButton","props","div","document","createElement","innerHTML","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","style","display","playButton","id","Object","assign","cursor","width","height","backgroundImage","pauseImage","backgroundSize","borderRadius","border","parentNode","insertBefore","autoplayAudioEnabled","getElementById","play","then","addEventListener","handleAudioEnded","error","console","handlePlayClick","paused","includes","playImage","handleAudioPlay","handleAudioPause","_handlePlayClick","_handleAudioPlay","_handleAudioPause","_handleAudioEnded","removeEventListener","alignImages","addCustomAudioButtonControls","removeCustomAudioButtonListeners","previewPrompts","querySelectorAll","forEach","previewPrompt","images","getElementsByTagName","length","image","attributes","alignment","value","parentElement","tagName","copyImage","cloneNode","replaceChild","prompt","classes","className","onClick","defaultClassName","CustomTag","legendClass","customClasses","promptTable","__html","parsedText","replace","Component","PropTypes","object","string","func","bool","styles","theme","verticalAlign","color","legend","fontSize","rationale","paddingLeft","spacing","unit","paddingBottom","label","flexDirection","margin","borderCollapse","backgroundColor","palette","common","black","padding","textAlign"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA;AACA,IAAMA,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;;IAEaC,a;;;;;;;;;;;;;;;mGAmBE,UAACC,IAAD,EAAU;AACrB,UAAQC,iBAAR,GAA8B,MAAKC,KAAnC,CAAQD,iBAAR;AACA,UAAME,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AACAF,MAAAA,GAAG,CAACG,SAAJ,GAAgBN,IAAhB;AAEA,UAAMO,KAAK,GAAGJ,GAAG,CAACK,aAAJ,CAAkB,OAAlB,CAAd;;AACA,UAAID,KAAJ,EAAW;AACT,YAAME,MAAM,GAAGL,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAf;AAEAI,QAAAA,MAAM,CAACC,YAAP,CAAoB,MAApB,EAA4B,WAA5B;AACAD,QAAAA,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,EAAE;AADgC;AAxBlC;AAvBY,GAAZ;AAAA,CAAf;;eAoDe,wBAAWpB,MAAX,EAAmBvF,aAAnB,C","sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport * as color from './color';\n\n//Used these below to replace \\\\embed{newLine} with \\\\newline from prompt which will get parsed in MathJax\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nexport class PreviewPrompt extends Component {\n static propTypes = {\n classes: PropTypes.object,\n prompt: PropTypes.string,\n tagName: PropTypes.string,\n className: PropTypes.string,\n onClick: PropTypes.func,\n defaultClassName: PropTypes.string,\n autoplayAudioEnabled: PropTypes.bool,\n customAudioButton: {\n playImage: PropTypes.string,\n pauseImage: PropTypes.string,\n },\n };\n\n static defaultProps = {\n onClick: () => {},\n };\n\n parsedText = (text) => {\n const { customAudioButton } = this.props;\n const div = document.createElement('div');\n div.innerHTML = text;\n\n const audio = div.querySelector('audio');\n if (audio) {\n const source = document.createElement('source');\n\n source.setAttribute('type', 'audio/mp3');\n source.setAttribute('src', audio.getAttribute('src'));\n\n audio.removeAttribute('src');\n audio.setAttribute('id', 'pie-prompt-audio-player');\n\n audio.appendChild(source);\n\n if (customAudioButton) {\n audio.style.display = 'none';\n\n const playButton = document.createElement('div');\n playButton.id = 'play-audio-button';\n\n Object.assign(playButton.style, {\n cursor: 'pointer',\n display: 'block',\n width: '128px',\n height: '128px',\n backgroundImage: `url(${customAudioButton.pauseImage})`,\n backgroundSize: 'cover',\n borderRadius: '50%',\n border: '1px solid #326295',\n });\n\n audio.parentNode.insertBefore(playButton, audio);\n }\n }\n\n return div.innerHTML;\n };\n\n addCustomAudioButtonControls() {\n const { autoplayAudioEnabled, customAudioButton } = this.props;\n const playButton = document.getElementById('play-audio-button');\n const audio = document.getElementById('pie-prompt-audio-player');\n\n if (autoplayAudioEnabled && audio) {\n audio\n .play()\n .then(() => {\n if (playButton && customAudioButton) {\n audio.addEventListener('ended', handleAudioEnded);\n }\n })\n .catch((error) => {\n console.error('Error playing audio', error);\n });\n }\n\n if (!playButton || !audio || !customAudioButton) return;\n\n const handlePlayClick = () => {\n // if already playing, don't play again\n if (!audio.paused) return;\n if (playButton.style.backgroundImage.includes(customAudioButton.pauseImage)) return;\n\n audio.play();\n };\n\n const handleAudioEnded = () => {\n playButton.style.backgroundImage = `url(${customAudioButton.playImage})`;\n };\n\n const handleAudioPlay = () => {\n Object.assign(playButton.style, {\n backgroundImage: `url(${customAudioButton.pauseImage})`,\n border: '1px solid #ccc',\n });\n };\n\n const handleAudioPause = () => {\n Object.assign(playButton.style, {\n backgroundImage: `url(${customAudioButton.playImage})`,\n border: '1px solid #326295',\n });\n };\n\n playButton.addEventListener('click', handlePlayClick);\n audio.addEventListener('play', handleAudioPlay);\n audio.addEventListener('pause', handleAudioPause);\n audio.addEventListener('ended', handleAudioEnded);\n\n // store event handler references so they can be removed later\n this._handlePlayClick = handlePlayClick;\n this._handleAudioPlay = handleAudioPlay;\n this._handleAudioPause = handleAudioPause;\n this._handleAudioEnded = handleAudioEnded;\n }\n\n removeCustomAudioButtonListeners() {\n const playButton = document.getElementById('play-audio-button');\n const audio = document.querySelector('audio');\n\n if (!playButton || !audio) return;\n\n // remove event listeners using stored references\n playButton.removeEventListener('click', this._handlePlayClick);\n audio.removeEventListener('play', this._handleAudioPlay);\n audio.removeEventListener('pause', this._handleAudioPause);\n audio.removeEventListener('ended', this._handleAudioEnded);\n }\n\n componentDidMount() {\n this.alignImages();\n this.addCustomAudioButtonControls();\n }\n\n componentDidUpdate() {\n this.alignImages();\n }\n\n componentWillUnmount() {\n this.removeCustomAudioButtonListeners();\n }\n\n alignImages() {\n const previewPrompts = document.querySelectorAll('#preview-prompt');\n\n previewPrompts.forEach((previewPrompt) => {\n const images = previewPrompt.getElementsByTagName('img');\n\n if (images && images.length) {\n for (let image of images) {\n // check if alignment property was set\n if (image.attributes && image.attributes.alignment && image.attributes.alignment.value) {\n const parentNode = image.parentElement;\n\n // check if div is not already added to dom and replace current image with wrapped image\n if (\n !(\n parentNode.tagName === 'DIV' &&\n parentNode.style.display === 'flex' &&\n parentNode.style.width === '100%'\n )\n ) {\n const div = document.createElement('div');\n div.style.display = 'flex';\n div.style.width = '100%';\n\n const copyImage = image.cloneNode(true);\n div.appendChild(copyImage);\n parentNode.replaceChild(div, image);\n }\n }\n }\n }\n });\n }\n\n render() {\n const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;\n const CustomTag = tagName || 'div';\n // legend tag was added once with accessibility tasks, wee need extra style to make it work with images alignment\n const legendClass = tagName === 'legend' ? 'legend' : '';\n const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName || ''} ${classes[\n legendClass\n ] || ''}`;\n\n return (\n <CustomTag\n id={'preview-prompt'}\n onClick={onClick}\n className={customClasses}\n dangerouslySetInnerHTML={{\n __html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX),\n }}\n />\n );\n }\n}\n\nconst styles = (theme) => ({\n prompt: {\n verticalAlign: 'middle',\n color: color.text(),\n },\n legend: {\n width: '100%',\n fontSize: 'inherit !important',\n },\n rationale: {\n paddingLeft: theme.spacing.unit * 4,\n paddingBottom: theme.spacing.unit,\n },\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)',\n display: 'flex',\n flexDirection: 'column',\n verticalAlign: 'middle',\n cursor: 'pointer',\n '& > p': {\n margin: '0 0 0 0 !important',\n },\n },\n promptTable: {\n '&:not(.MathJax) > table': {\n borderCollapse: 'collapse',\n },\n // Apply vertical striping only when first column is a header column (th)\n '&:not(.MathJax) > table:has(tr:first-child th:first-child) td': {\n '&:nth-child(2n)': {\n backgroundColor: '#f6f8fa',\n color: theme.palette.common.black,\n },\n },\n // Apply horizontal striping for tables where first element is NOT a header (th)\n '&:not(.MathJax) > table:not(:has(tr:first-child th:first-child)) tr': {\n '&:nth-child(2n)': {\n backgroundColor: '#f6f8fa',\n color: theme.palette.common.black,\n },\n },\n // align table content to left as per STAR requirement PD-3687\n '&:not(.MathJax) table td, &:not(.MathJax) table th': {\n padding: '.6em 1em',\n textAlign: 'left',\n },\n // added this to fix alignment of text in prompt imported from studio (PD-3423)\n '&:not(.MathJax) > table td > p.kds-indent': {\n textAlign: 'initial',\n },\n },\n});\nexport default withStyles(styles)(PreviewPrompt);\n"],"file":"preview-prompt.js"}
|
package/lib/ui-layout.js
CHANGED
|
@@ -40,6 +40,55 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
40
40
|
|
|
41
41
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
42
42
|
|
|
43
|
+
var theme = (0, _styles.createMuiTheme)({
|
|
44
|
+
typography: {
|
|
45
|
+
useNextVariants: true,
|
|
46
|
+
fontFamily: 'inherit'
|
|
47
|
+
},
|
|
48
|
+
palette: {
|
|
49
|
+
action: {
|
|
50
|
+
disabled: 'rgba(0, 0, 0, 0.54);'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
overrides: {
|
|
54
|
+
MuiTypography: {
|
|
55
|
+
root: {
|
|
56
|
+
fontFamily: 'inherit'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
MuiRadio: {
|
|
60
|
+
root: {
|
|
61
|
+
'&$checked': {
|
|
62
|
+
color: '#3f51b5 !important'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
MuiCheckbox: {
|
|
67
|
+
root: {
|
|
68
|
+
'&$checked': {
|
|
69
|
+
color: '#3f51b5 !important'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
MuiTabs: {
|
|
74
|
+
root: {
|
|
75
|
+
borderBottom: '1px solid #eee'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
MuiSwitch: {
|
|
79
|
+
root: {
|
|
80
|
+
'&$checked': {
|
|
81
|
+
color: '#3f51b5 !important',
|
|
82
|
+
'& + $bar': {
|
|
83
|
+
backgroundColor: '#3f51b5 !important',
|
|
84
|
+
opacity: 0.5
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
43
92
|
var UiLayout = /*#__PURE__*/function (_AppendCSSRules) {
|
|
44
93
|
(0, _inherits2["default"])(UiLayout, _AppendCSSRules);
|
|
45
94
|
|
|
@@ -81,11 +130,13 @@ var UiLayout = /*#__PURE__*/function (_AppendCSSRules) {
|
|
|
81
130
|
var extraCSSRules = rest.extraCSSRules,
|
|
82
131
|
restProps = (0, _objectWithoutProperties2["default"])(rest, _excluded2);
|
|
83
132
|
var style = this.computeStyle(fontSizeFactor);
|
|
84
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement(_styles.MuiThemeProvider, {
|
|
134
|
+
theme: theme
|
|
135
|
+
}, /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
85
136
|
className: finalClass
|
|
86
137
|
}, restProps, style && {
|
|
87
138
|
style: style
|
|
88
|
-
}), children);
|
|
139
|
+
}), children));
|
|
89
140
|
}
|
|
90
141
|
}]);
|
|
91
142
|
return UiLayout;
|
package/lib/ui-layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui-layout.jsx"],"names":["UiLayout","props","classesSheet","document","createElement","fontSizeFactor","getFontSize","element","parseFloat","getComputedStyle","fontSize","rootFontSize","documentElement","bodyFontSize","body","effectiveFontSize","Math","max","children","className","classes","rest","finalClass","extraCSSRules","uiLayoutContainer","restProps","style","computeStyle","AppendCSSRules","PropTypes","object","string","array","shape","names","arrayOf","rules","number","styles","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/ui-layout.jsx"],"names":["theme","typography","useNextVariants","fontFamily","palette","action","disabled","overrides","MuiTypography","root","MuiRadio","color","MuiCheckbox","MuiTabs","borderBottom","MuiSwitch","backgroundColor","opacity","UiLayout","props","classesSheet","document","createElement","fontSizeFactor","getFontSize","element","parseFloat","getComputedStyle","fontSize","rootFontSize","documentElement","bodyFontSize","body","effectiveFontSize","Math","max","children","className","classes","rest","finalClass","extraCSSRules","uiLayoutContainer","restProps","style","computeStyle","AppendCSSRules","PropTypes","object","string","array","shape","names","arrayOf","rules","number","styles","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;AAEA,IAAMA,KAAK,GAAG,4BAAe;AAC3BC,EAAAA,UAAU,EAAE;AACVC,IAAAA,eAAe,EAAE,IADP;AAEVC,IAAAA,UAAU,EAAE;AAFF,GADe;AAK3BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE;AACNC,MAAAA,QAAQ,EAAE;AADJ;AADD,GALkB;AAU3BC,EAAAA,SAAS,EAAE;AACTC,IAAAA,aAAa,EAAE;AACbC,MAAAA,IAAI,EAAE;AAAEN,QAAAA,UAAU,EAAE;AAAd;AADO,KADN;AAITO,IAAAA,QAAQ,EAAE;AACRD,MAAAA,IAAI,EAAE;AACJ,qBAAa;AACXE,UAAAA,KAAK,EAAE;AADI;AADT;AADE,KAJD;AAWTC,IAAAA,WAAW,EAAE;AACXH,MAAAA,IAAI,EAAE;AACJ,qBAAa;AACXE,UAAAA,KAAK,EAAE;AADI;AADT;AADK,KAXJ;AAkBTE,IAAAA,OAAO,EAAE;AACPJ,MAAAA,IAAI,EAAE;AACJK,QAAAA,YAAY,EAAE;AADV;AADC,KAlBA;AAuBTC,IAAAA,SAAS,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A0BE,SAA1B,6CAAwCJ,IAAxC;AACA,UAAMK,KAAK,GAAG,KAAKC,YAAL,CAAkBtB,cAAlB,CAAd;AAEA,0BACE,gCAAC,wBAAD;AAAkB,QAAA,KAAK,EAAEvB;AAAzB,sBACE;AAAK,QAAA,SAAS,EAAEwC;AAAhB,SAAgCG,SAAhC,EAAgDC,KAAK,IAAI;AAAEA,QAAAA,KAAK,EAALA;AAAF,OAAzD,GACGR,QADH,CADF,CADF;AAOD;;;EA9CoBU,0B;;iCAAjB5B,Q,eACe;AACjBoB,EAAAA,OAAO,EAAES,sBAAUC,MADF;AAEjBX,EAAAA,SAAS,EAAEU,sBAAUE,MAFJ;AAGjBb,EAAAA,QAAQ,EAAEW,sBAAUG,KAHH;AAIjBT,EAAAA,aAAa,EAAEM,sBAAUI,KAAV,CAAgB;AAC7BC,IAAAA,KAAK,EAAEL,sBAAUM,OAAV,CAAkBN,sBAAUE,MAA5B,CADsB;AAE7BK,IAAAA,KAAK,EAAEP,sBAAUE;AAFY,GAAhB,CAJE;AAQjB1B,EAAAA,cAAc,EAAEwB,sBAAUQ;AART,C;iCADfrC,Q,kBAYkB;AACpBuB,EAAAA,aAAa,EAAE,EADK;AAEpBlB,EAAAA,cAAc,EAAE;AAFI,C;AAqCxB,IAAMiC,MAAM,GAAG;AACbf,EAAAA,aAAa,EAAE,EADF;AAEb;AACAC,EAAAA,iBAAiB,EAAE;AACjB,uBAAmB;AACjBd,MAAAA,QAAQ,EAAE;AAAU;;AADH;AADF;AAHN,CAAf;AAUA,IAAM6B,MAAM,GAAG,wBAAWD,MAAX,EAAmBtC,QAAnB,CAAf;eAEeuC,M","sourcesContent":["import React from 'react';\nimport { createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport AppendCSSRules from './append-css-rules';\n\nconst theme = createMuiTheme({\n typography: {\n useNextVariants: true,\n fontFamily: 'inherit',\n },\n palette: {\n action: {\n disabled: 'rgba(0, 0, 0, 0.54);',\n },\n },\n overrides: {\n MuiTypography: {\n root: { fontFamily: 'inherit' },\n },\n MuiRadio: {\n root: {\n '&$checked': {\n color: '#3f51b5 !important',\n },\n },\n },\n MuiCheckbox: {\n root: {\n '&$checked': {\n color: '#3f51b5 !important',\n },\n },\n },\n MuiTabs: {\n root: {\n borderBottom: '1px solid #eee',\n },\n },\n MuiSwitch: {\n root: {\n '&$checked': {\n color: '#3f51b5 !important',\n '& + $bar': {\n backgroundColor: '#3f51b5 !important',\n opacity: 0.5,\n },\n },\n },\n },\n },\n});\n\nclass UiLayout extends AppendCSSRules {\n static propTypes = {\n classes: PropTypes.object,\n className: PropTypes.string,\n children: PropTypes.array,\n extraCSSRules: PropTypes.shape({\n names: PropTypes.arrayOf(PropTypes.string),\n rules: PropTypes.string,\n }),\n fontSizeFactor: PropTypes.number,\n };\n\n static defaultProps = {\n extraCSSRules: {},\n fontSizeFactor: 1,\n };\n\n constructor(props) {\n super(props);\n this.classesSheet = document.createElement('style');\n }\n\n computeStyle(fontSizeFactor) {\n const getFontSize = (element) => parseFloat(getComputedStyle(element).fontSize);\n\n const rootFontSize = getFontSize(document.documentElement);\n const bodyFontSize = getFontSize(document.body);\n const effectiveFontSize = Math.max(rootFontSize, bodyFontSize);\n\n return fontSizeFactor !== 1 ? { fontSize: `${effectiveFontSize * fontSizeFactor}px` } : null;\n }\n\n render() {\n const { children, className, classes, fontSizeFactor, ...rest } = this.props;\n\n const finalClass = classNames(className, classes.extraCSSRules, classes.uiLayoutContainer);\n const { extraCSSRules, ...restProps } = rest;\n const style = this.computeStyle(fontSizeFactor);\n\n return (\n <MuiThemeProvider theme={theme}>\n <div className={finalClass} {...restProps} {...(style && { style })}>\n {children}\n </div>\n </MuiThemeProvider>\n );\n }\n}\n\nconst styles = {\n extraCSSRules: {},\n // need this because some browsers set their own style on table\n uiLayoutContainer: {\n '& table, th, td': {\n fontSize: 'inherit' /* Ensure table elements inherit font size */,\n },\n },\n};\n\nconst Styled = withStyles(styles)(UiLayout);\n\nexport default Styled;\n"],"file":"ui-layout.js"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.35.0",
|
|
4
4
|
"description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./esm/index.js",
|
|
10
|
-
"require": "./lib/index.js",
|
|
11
|
-
"default": "./esm/index.js"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
7
|
"publishConfig": {
|
|
15
8
|
"access": "public"
|
|
16
9
|
},
|
|
@@ -18,9 +11,9 @@
|
|
|
18
11
|
"dependencies": {
|
|
19
12
|
"@material-ui/core": "^3.8.3",
|
|
20
13
|
"@material-ui/icons": "^3.0.2",
|
|
21
|
-
"@pie-lib/icons": "^2.
|
|
22
|
-
"@pie-lib/math-rendering": "^3.
|
|
23
|
-
"@pie-lib/test-utils": "^0.19.
|
|
14
|
+
"@pie-lib/icons": "^2.24.0",
|
|
15
|
+
"@pie-lib/math-rendering": "^3.22.0",
|
|
16
|
+
"@pie-lib/test-utils": "^0.19.5",
|
|
24
17
|
"classnames": "^2.2.6",
|
|
25
18
|
"debug": "^4.1.1",
|
|
26
19
|
"lodash": "^4.17.11",
|
|
@@ -36,5 +29,5 @@
|
|
|
36
29
|
"react": "^16.8.1",
|
|
37
30
|
"react-dom": "^16.8.1"
|
|
38
31
|
},
|
|
39
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "0c4b22e10cf3a7a5880d382f7dfed0ff0007d122"
|
|
40
33
|
}
|
package/src/feedback.jsx
CHANGED
|
@@ -23,7 +23,6 @@ const styleSheet = {
|
|
|
23
23
|
'-webkit-font-smoothing': 'antialiased',
|
|
24
24
|
backgroundColor: `var(--feedback-bg-color, ${color.disabled()})`,
|
|
25
25
|
borderRadius: '4px',
|
|
26
|
-
fontFamily: '"Roboto", "Noto", sans-serif',
|
|
27
26
|
lineHeight: '25px',
|
|
28
27
|
margin: '0px',
|
|
29
28
|
padding: '10px',
|
package/src/preview-layout.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { withStyles
|
|
2
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import UiLayout from './ui-layout';
|
|
5
5
|
|
|
@@ -41,55 +41,8 @@ const styles = () => ({
|
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const theme = createMuiTheme({
|
|
45
|
-
typography: {
|
|
46
|
-
useNextVariants: true,
|
|
47
|
-
},
|
|
48
|
-
palette: {
|
|
49
|
-
action: {
|
|
50
|
-
disabled: 'rgba(0, 0, 0, 0.54);',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
overrides: {
|
|
54
|
-
MuiRadio: {
|
|
55
|
-
root: {
|
|
56
|
-
'&$checked': {
|
|
57
|
-
color: '#3f51b5 !important',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
MuiCheckbox: {
|
|
62
|
-
root: {
|
|
63
|
-
'&$checked': {
|
|
64
|
-
color: '#3f51b5 !important',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
MuiTabs: {
|
|
69
|
-
root: {
|
|
70
|
-
borderBottom: '1px solid #eee',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
MuiSwitch: {
|
|
74
|
-
root: {
|
|
75
|
-
'&$checked': {
|
|
76
|
-
color: '#3f51b5 !important',
|
|
77
|
-
'& + $bar': {
|
|
78
|
-
backgroundColor: '#3f51b5 !important',
|
|
79
|
-
opacity: 0.5,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
44
|
const Styled = withStyles(styles)(PreviewLayout);
|
|
88
45
|
|
|
89
|
-
const RootElem = (props) =>
|
|
90
|
-
<MuiThemeProvider theme={theme}>
|
|
91
|
-
<Styled {...props} />
|
|
92
|
-
</MuiThemeProvider>
|
|
93
|
-
);
|
|
46
|
+
const RootElem = (props) => <Styled {...props} />;
|
|
94
47
|
|
|
95
48
|
export default RootElem;
|
package/src/preview-prompt.jsx
CHANGED
|
@@ -234,7 +234,15 @@ const styles = (theme) => ({
|
|
|
234
234
|
'&:not(.MathJax) > table': {
|
|
235
235
|
borderCollapse: 'collapse',
|
|
236
236
|
},
|
|
237
|
-
|
|
237
|
+
// Apply vertical striping only when first column is a header column (th)
|
|
238
|
+
'&:not(.MathJax) > table:has(tr:first-child th:first-child) td': {
|
|
239
|
+
'&:nth-child(2n)': {
|
|
240
|
+
backgroundColor: '#f6f8fa',
|
|
241
|
+
color: theme.palette.common.black,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
// Apply horizontal striping for tables where first element is NOT a header (th)
|
|
245
|
+
'&:not(.MathJax) > table:not(:has(tr:first-child th:first-child)) tr': {
|
|
238
246
|
'&:nth-child(2n)': {
|
|
239
247
|
backgroundColor: '#f6f8fa',
|
|
240
248
|
color: theme.palette.common.black,
|
package/src/ui-layout.jsx
CHANGED
|
@@ -1,9 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
2
|
+
import { createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import AppendCSSRules from './append-css-rules';
|
|
6
6
|
|
|
7
|
+
const theme = createMuiTheme({
|
|
8
|
+
typography: {
|
|
9
|
+
useNextVariants: true,
|
|
10
|
+
fontFamily: 'inherit',
|
|
11
|
+
},
|
|
12
|
+
palette: {
|
|
13
|
+
action: {
|
|
14
|
+
disabled: 'rgba(0, 0, 0, 0.54);',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
overrides: {
|
|
18
|
+
MuiTypography: {
|
|
19
|
+
root: { fontFamily: 'inherit' },
|
|
20
|
+
},
|
|
21
|
+
MuiRadio: {
|
|
22
|
+
root: {
|
|
23
|
+
'&$checked': {
|
|
24
|
+
color: '#3f51b5 !important',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
MuiCheckbox: {
|
|
29
|
+
root: {
|
|
30
|
+
'&$checked': {
|
|
31
|
+
color: '#3f51b5 !important',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
MuiTabs: {
|
|
36
|
+
root: {
|
|
37
|
+
borderBottom: '1px solid #eee',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
MuiSwitch: {
|
|
41
|
+
root: {
|
|
42
|
+
'&$checked': {
|
|
43
|
+
color: '#3f51b5 !important',
|
|
44
|
+
'& + $bar': {
|
|
45
|
+
backgroundColor: '#3f51b5 !important',
|
|
46
|
+
opacity: 0.5,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
7
54
|
class UiLayout extends AppendCSSRules {
|
|
8
55
|
static propTypes = {
|
|
9
56
|
classes: PropTypes.object,
|
|
@@ -44,9 +91,11 @@ class UiLayout extends AppendCSSRules {
|
|
|
44
91
|
const style = this.computeStyle(fontSizeFactor);
|
|
45
92
|
|
|
46
93
|
return (
|
|
47
|
-
<
|
|
48
|
-
{
|
|
49
|
-
|
|
94
|
+
<MuiThemeProvider theme={theme}>
|
|
95
|
+
<div className={finalClass} {...restProps} {...(style && { style })}>
|
|
96
|
+
{children}
|
|
97
|
+
</div>
|
|
98
|
+
</MuiThemeProvider>
|
|
50
99
|
);
|
|
51
100
|
}
|
|
52
101
|
}
|