@pie-lib/render-ui 4.35.2-next.0 → 4.35.2-next.6
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/lib/preview-prompt.js +6 -12
- package/lib/preview-prompt.js.map +1 -1
- package/lib/ui-layout.js +0 -30
- package/lib/ui-layout.js.map +1 -1
- package/package.json +5 -5
- package/src/preview-prompt.jsx +7 -12
- package/src/ui-layout.jsx +0 -30
package/lib/preview-prompt.js
CHANGED
|
@@ -296,19 +296,13 @@ var styles = function styles(theme) {
|
|
|
296
296
|
'&:not(.MathJax) > table': {
|
|
297
297
|
borderCollapse: 'collapse'
|
|
298
298
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
backgroundColor: '#f6f8fa',
|
|
303
|
-
color: theme.palette.common.black
|
|
304
|
-
}
|
|
299
|
+
'&:not(.MathJax) > table:has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)': {
|
|
300
|
+
backgroundColor: '#f6f8fa',
|
|
301
|
+
color: theme.palette.common.black
|
|
305
302
|
},
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
backgroundColor: '#f6f8fa',
|
|
310
|
-
color: theme.palette.common.black
|
|
311
|
-
}
|
|
303
|
+
'&:not(.MathJax) > table:has(tbody tr > td:first-child) tbody tr:nth-child(even) td': {
|
|
304
|
+
backgroundColor: '#f6f8fa',
|
|
305
|
+
color: theme.palette.common.black
|
|
312
306
|
},
|
|
313
307
|
// align table content to left as per STAR requirement PD-3687
|
|
314
308
|
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
@@ -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,CAAoB,KAApB,EAA2BH,KAAK,CAACI,YAAN,CAAmB,KAAnB,CAA3B;AAEAJ,QAAAA,KAAK,CA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, { 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"}
|
|
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,GA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,QAAAA,KAAK,EAAEF,KAAK,CAACe,OAAN,CAAcC,MAAd,CAAqBC;AAFwD,OAT3E;AAaX;AACA,4DAAsD;AACpDC,QAAAA,OAAO,EAAE,UAD2C;AAEpDC,QAAAA,SAAS,EAAE;AAFyC,OAd3C;AAkBX;AACA,mDAA6C;AAC3CA,QAAAA,SAAS,EAAE;AADgC;AAnBlC;AAvBY,GAAZ;AAAA,CAAf;;eA+Ce,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:has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)': {\n backgroundColor: '#f6f8fa',\n color: theme.palette.common.black,\n },\n\n '&:not(.MathJax) > table:has(tbody tr > td:first-child) tbody tr:nth-child(even) td': {\n backgroundColor: '#f6f8fa',\n color: theme.palette.common.black,\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
|
@@ -55,36 +55,6 @@ var theme = (0, _styles.createMuiTheme)({
|
|
|
55
55
|
root: {
|
|
56
56
|
fontFamily: 'inherit'
|
|
57
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
58
|
}
|
|
89
59
|
}
|
|
90
60
|
});
|
package/lib/ui-layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui-layout.jsx"],"names":["theme","typography","useNextVariants","fontFamily","palette","action","disabled","overrides","MuiTypography","root","
|
|
1
|
+
{"version":3,"sources":["../src/ui-layout.jsx"],"names":["theme","typography","useNextVariants","fontFamily","palette","action","disabled","overrides","MuiTypography","root","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;AADN;AAVgB,CAAf,CAAd;;IAiBMO,Q;;;;;AAiBJ,oBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AACA,UAAKC,YAAL,GAAoBC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAApB;AAFiB;AAGlB;;;;WAED,sBAAaC,cAAb,EAA6B;AAC3B,UAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,OAAD;AAAA,eAAaC,UAAU,CAACC,gBAAgB,CAACF,OAAD,CAAhB,CAA0BG,QAA3B,CAAvB;AAAA,OAApB;;AAEA,UAAMC,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AUM,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 },\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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "4.35.2-next.
|
|
3
|
+
"version": "4.35.2-next.6+d255c5c5",
|
|
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",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@material-ui/core": "^3.8.3",
|
|
13
13
|
"@material-ui/icons": "^3.0.2",
|
|
14
|
-
"@pie-lib/icons": "^2.24.
|
|
15
|
-
"@pie-lib/math-rendering": "^3.22.
|
|
16
|
-
"@pie-lib/test-utils": "^0.22.
|
|
14
|
+
"@pie-lib/icons": "^2.24.1",
|
|
15
|
+
"@pie-lib/math-rendering": "^3.22.1",
|
|
16
|
+
"@pie-lib/test-utils": "^0.22.1",
|
|
17
17
|
"classnames": "^2.2.6",
|
|
18
18
|
"debug": "^4.1.1",
|
|
19
19
|
"lodash": "^4.17.11",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"react": "^16.8.1",
|
|
29
29
|
"react-dom": "^16.8.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "d255c5c52e4e2c3401691da8dcdb041d74e8809d"
|
|
32
32
|
}
|
package/src/preview-prompt.jsx
CHANGED
|
@@ -234,19 +234,14 @@ const styles = (theme) => ({
|
|
|
234
234
|
'&:not(.MathJax) > table': {
|
|
235
235
|
borderCollapse: 'collapse',
|
|
236
236
|
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
backgroundColor: '#f6f8fa',
|
|
241
|
-
color: theme.palette.common.black,
|
|
242
|
-
},
|
|
237
|
+
'&:not(.MathJax) > table:has(tbody tr > th:first-child):not(:has(tbody tr > td:first-child)) tbody td:nth-child(even)': {
|
|
238
|
+
backgroundColor: '#f6f8fa',
|
|
239
|
+
color: theme.palette.common.black,
|
|
243
240
|
},
|
|
244
|
-
|
|
245
|
-
'&:not(.MathJax) > table:
|
|
246
|
-
'
|
|
247
|
-
|
|
248
|
-
color: theme.palette.common.black,
|
|
249
|
-
},
|
|
241
|
+
|
|
242
|
+
'&:not(.MathJax) > table:has(tbody tr > td:first-child) tbody tr:nth-child(even) td': {
|
|
243
|
+
backgroundColor: '#f6f8fa',
|
|
244
|
+
color: theme.palette.common.black,
|
|
250
245
|
},
|
|
251
246
|
// align table content to left as per STAR requirement PD-3687
|
|
252
247
|
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
package/src/ui-layout.jsx
CHANGED
|
@@ -18,36 +18,6 @@ const theme = createMuiTheme({
|
|
|
18
18
|
MuiTypography: {
|
|
19
19
|
root: { fontFamily: 'inherit' },
|
|
20
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
21
|
},
|
|
52
22
|
});
|
|
53
23
|
|