@pie-lib/math-input 6.28.6-esmbeta.0 → 6.29.0-mui-update.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 +20 -0
- package/lib/horizontal-keypad.js +16 -44
- package/lib/horizontal-keypad.js.map +1 -1
- package/lib/index.js +3 -25
- package/lib/index.js.map +1 -1
- package/lib/keypad/index.js +233 -314
- package/lib/keypad/index.js.map +1 -1
- package/lib/keypad/keys-layout.js +2 -12
- package/lib/keypad/keys-layout.js.map +1 -1
- package/lib/keys/basic-operators.js +5 -13
- package/lib/keys/basic-operators.js.map +1 -1
- package/lib/keys/chars.js +5 -10
- package/lib/keys/chars.js.map +1 -1
- package/lib/keys/comparison.js +6 -16
- package/lib/keys/comparison.js.map +1 -1
- package/lib/keys/constants.js +4 -10
- package/lib/keys/constants.js.map +1 -1
- package/lib/keys/digits.js +1 -7
- package/lib/keys/digits.js.map +1 -1
- package/lib/keys/edit.js +1 -4
- package/lib/keys/edit.js.map +1 -1
- package/lib/keys/exponent.js +4 -10
- package/lib/keys/exponent.js.map +1 -1
- package/lib/keys/fractions.js +3 -8
- package/lib/keys/fractions.js.map +1 -1
- package/lib/keys/geometry.js +25 -54
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/grades.js +10 -46
- package/lib/keys/grades.js.map +1 -1
- package/lib/keys/index.js +13 -32
- package/lib/keys/index.js.map +1 -1
- package/lib/keys/log.js +3 -8
- package/lib/keys/log.js.map +1 -1
- package/lib/keys/logic.js +2 -6
- package/lib/keys/logic.js.map +1 -1
- package/lib/keys/matrices.js +2 -6
- package/lib/keys/matrices.js.map +1 -1
- package/lib/keys/misc.js +10 -22
- package/lib/keys/misc.js.map +1 -1
- package/lib/keys/navigation.js +2 -7
- package/lib/keys/navigation.js.map +1 -1
- package/lib/keys/operators.js +1 -4
- package/lib/keys/operators.js.map +1 -1
- package/lib/keys/statistics.js +5 -12
- package/lib/keys/statistics.js.map +1 -1
- package/lib/keys/sub-sup.js +2 -6
- package/lib/keys/sub-sup.js.map +1 -1
- package/lib/keys/trigonometry.js +6 -14
- package/lib/keys/trigonometry.js.map +1 -1
- package/lib/keys/utils.js +7 -40
- package/lib/keys/utils.js.map +1 -1
- package/lib/keys/vars.js +3 -8
- package/lib/keys/vars.js.map +1 -1
- package/lib/math-input.js +52 -103
- package/lib/math-input.js.map +1 -1
- package/lib/mq/common-mq-styles.js +7 -18
- package/lib/mq/common-mq-styles.js.map +1 -1
- package/lib/mq/custom-elements.js +1 -4
- package/lib/mq/custom-elements.js.map +1 -1
- package/lib/mq/index.js +0 -4
- package/lib/mq/index.js.map +1 -1
- package/lib/mq/input.js +22 -75
- package/lib/mq/input.js.map +1 -1
- package/lib/mq/static.js +31 -92
- package/lib/mq/static.js.map +1 -1
- package/lib/shared/constants.js +3 -6
- package/lib/updateSpans.js +1 -5
- package/lib/updateSpans.js.map +1 -1
- package/package.json +9 -14
- package/src/keypad/index.jsx +151 -151
- package/src/math-input.jsx +35 -44
- package/src/mq/input.jsx +9 -9
- package/esm/index.css +0 -847
- package/esm/index.js +0 -60134
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
package/lib/mq/static.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mq/static.jsx"],"names":["MQ","window","MathQuill","getInterface","log","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","countBraces","latex","count","i","length","Static","props","liveRegion","document","createElement","style","position","width","height","marginTop","clip","overflow","setAttribute","body","appendChild","input","inputRef","current","addEventListener","handleKeyDown","handleMathKeyboardClick","removeEventListener","removeChild","event","key","setState","isDeleteKeyPressed","inputSource","field","mathField","name","getFieldName","innerFields","onSubFieldChange","regexMatch","match","__controller","cursor","insLeftOf","parent","el","dispatchEvent","KeyboardEvent","keyCode","e","console","error","toString","announceLatexConversion","newLatex","state","previousLatex","announcement","newBraces","oldBraces","announceMessage","parseLatex","warn","message","textContent","setTimeout","Error","StaticMath","handlers","edit","onInputEdit","bind","blur","focus","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","find","f","setInput","onSubFieldFocus","err","React","createRef","update","createLiveRegion","addEventListeners","removeLiveRegion","removeEventListeners","nextProps","parsedLatex","stripped","newFieldCount","out","trim","Object","keys","onBlur","className","onFocus","Component","PropTypes","isRequired","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;AACD;;AAED,IAAMC,GAAG,GAAG,uBAAM,8BAAN,CAAZ;AACA,IAAMC,KAAK,GAAG,wCAAd;AACA,IAAMC,gBAAgB,GAAG,IAAzB;;AAEA,SAASC,WAAT,GAAkC;AAAA,MAAbC,MAAa,uEAAJ,EAAI;AAChC,SAAOA,MAAM,CAACC,OAAP,CAAeH,gBAAf,EAAiC,EAAjC,CAAP;AACD;;AAED,SAASI,WAAT,CAAqBC,KAArB,EAA4B;AAC1B,MAAIC,KAAK,GAAG,CAAZ;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,CAACF,KAAK,IAAI,EAAV,EAAcG,MAAlC,EAA0CD,CAAC,EAA3C,EAA+C;AAC7C,QAAIF,KAAK,CAACE,CAAD,CAAL,KAAa,GAAjB,EAAsB;AACpBD,MAAAA,KAAK;AACN;AACF;;AAED,SAAOA,KAAP;AACD;AAED;AACA;AACA;;;IACqBG,M;;;;;AAgBnB,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,yGA8BA,YAAM;AACvB,YAAKC,UAAL,GAAkBC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAlB;AACA,YAAKF,UAAL,CAAgBG,KAAhB,CAAsBC,QAAtB,GAAiC,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A,OAAO,EAAE,KAAKC,OAA1C;AAAmD,QAAA,MAAM,EAAEF,MAA3D;AAAmE,QAAA,GAAG,EAAE,KAAKjF;AAA7E,QAAP;AACD;;;EAzPiCkE,kBAAMkB,S;;;iCAArBpG,M,eACA;AACjBJ,EAAAA,KAAK,EAAEyG,sBAAU5G,MAAV,CAAiB6G,UADP;AAEjBH,EAAAA,OAAO,EAAEE,sBAAUE,IAFF;AAGjBN,EAAAA,MAAM,EAAEI,sBAAUE,IAHD;AAIjBL,EAAAA,SAAS,EAAEG,sBAAU5G,MAJJ;AAKjBsC,EAAAA,YAAY,EAAEsE,sBAAUE,IALP;AAMjBtE,EAAAA,gBAAgB,EAAEoE,sBAAUE,IANX;AAOjBvB,EAAAA,eAAe,EAAEqB,sBAAUE,IAPV;AAQjBxB,EAAAA,QAAQ,EAAEsB,sBAAUE;AARH,C;iCADAvG,M,kBAYG;AACpB+B,EAAAA,YAAY,EAAE,wBAAM,CAAE;AADF,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../updateSpans';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n}\n\nconst log = debug('pie-lib:math-input:mq:static');\nconst REGEX = /\\\\MathQuillMathField\\[r\\d*\\]\\{(.*?)\\}/g;\nconst WHITESPACE_REGEX = / /g;\n\nfunction stripSpaces(string = '') {\n return string.replace(WHITESPACE_REGEX, '');\n}\n\nfunction countBraces(latex) {\n let count = 0;\n\n for (let i = 0; i < (latex || '').length; i++) {\n if (latex[i] === '{') {\n count++;\n }\n }\n\n return count;\n}\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n className: PropTypes.string,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func,\n };\n\n static defaultProps = {\n getFieldName: () => {},\n };\n\n constructor(props) {\n super(props);\n this.state = {\n announcement: '',\n previousLatex: '',\n inputSource: null,\n isDeleteKeyPressed: false,\n };\n\n this.inputRef = React.createRef();\n }\n\n componentDidMount() {\n this.update();\n updateSpans();\n\n this.createLiveRegion();\n this.addEventListeners();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\n }\n\n componentWillUnmount() {\n this.removeLiveRegion();\n this.removeEventListeners();\n }\n\n createLiveRegion = () => {\n this.liveRegion = document.createElement('div');\n this.liveRegion.style.position = 'absolute';\n this.liveRegion.style.width = '1px';\n this.liveRegion.style.height = '1px';\n this.liveRegion.style.marginTop = '-1px';\n this.liveRegion.style.clip = 'rect(1px, 1px, 1px, 1px)';\n this.liveRegion.style.overflow = 'hidden';\n this.liveRegion.setAttribute('aria-live', 'polite');\n this.liveRegion.setAttribute('aria-atomic', 'true');\n\n document.body.appendChild(this.liveRegion);\n };\n\n addEventListeners = () => {\n const input = this.inputRef.current;\n\n if (input) {\n input.addEventListener('keydown', this.handleKeyDown);\n input.addEventListener('click', this.handleMathKeyboardClick);\n }\n };\n\n removeEventListeners = () => {\n const input = this.inputRef.current;\n\n if (input) {\n input.removeEventListener('keydown', this.handleKeyDown);\n input.removeEventListener('click', this.handleMathKeyboardClick);\n }\n };\n\n removeLiveRegion = () => {\n if (this.liveRegion) {\n document.body.removeChild(this.liveRegion);\n this.liveRegion = null;\n }\n };\n\n handleKeyDown = (event) => {\n if (event?.key === 'Backspace' || event?.key === 'Delete') {\n this.setState({ isDeleteKeyPressed: true });\n }\n this.setState({ inputSource: 'keyboard' });\n };\n\n handleMathKeyboardClick = () => {\n this.setState({ inputSource: 'mathKeyboard' });\n };\n\n onInputEdit = (field) => {\n if (!this.mathField) {\n return;\n }\n const name = this.props.getFieldName(field, this.mathField.innerFields);\n\n if (this.props.onSubFieldChange) {\n // eslint-disable-next-line no-useless-escape\n const regexMatch = field.latex().match(/[0-9]\\\\ \\\\frac\\{[^\\{]*\\}\\{ \\}/);\n\n if (this.inputRef?.current && regexMatch && regexMatch?.length) {\n try {\n field.__controller.cursor.insLeftOf(field.__controller.cursor.parent[-1].parent);\n field.el().dispatchEvent(new KeyboardEvent('keydown', { keyCode: 8 }));\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e.toString());\n }\n } else {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n\n this.announceLatexConversion(field.latex());\n };\n\n announceLatexConversion = (newLatex) => {\n if (!this.state) {\n console.error('State is not initialized');\n return;\n }\n\n const { previousLatex, inputSource, isDeleteKeyPressed } = this.state;\n const announcement = 'Converted to math symbol';\n\n if (inputSource === 'keyboard' && !isDeleteKeyPressed) {\n const newBraces = countBraces(newLatex);\n const oldBraces = countBraces(previousLatex);\n\n if (newBraces > oldBraces) {\n this.announceMessage(announcement);\n } else {\n try {\n this.mathField.parseLatex(previousLatex);\n this.mathField.parseLatex(newLatex);\n\n if (newLatex == previousLatex) {\n this.announceMessage(announcement);\n }\n } catch (e) {\n console.warn('Error parsing latex:', e.message);\n console.warn(e);\n }\n }\n }\n\n this.setState({ previousLatex: newLatex, isDeleteKeyPressed: false });\n };\n\n announceMessage = (message) => {\n this.setState({ previousLatex: '' });\n\n if (this.liveRegion) {\n this.liveRegion.textContent = message;\n\n // Clear the message after it is announced\n setTimeout(() => {\n this.liveRegion.textContent = '';\n }, 500);\n }\n };\n\n update = () => {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.inputRef?.current, {\n handlers: {\n edit: this.onInputEdit.bind(this),\n },\n });\n }\n\n try {\n this.mathField.parseLatex(this.props.latex);\n this.mathField.latex(this.props.latex);\n } catch (e) {\n // default latex if received has errors\n this.mathField.latex('\\\\MathQuillMathField[r1]{}');\n }\n };\n\n blur = () => {\n log('blur mathfield');\n this.mathField.blur();\n };\n\n focus = () => {\n log('focus mathfield...');\n this.mathField.focus();\n };\n\n shouldComponentUpdate(nextProps) {\n try {\n const parsedLatex = this.mathField.parseLatex(nextProps.latex);\n const stripped = stripSpaces(parsedLatex);\n const newFieldCount = (nextProps.latex.match(REGEX) || []).length;\n\n const out =\n stripped !== stripSpaces(this.mathField.latex().trim()) ||\n newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;\n\n log('[shouldComponentUpdate] ', out);\n return out;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('Error parsing latex:', e.message, 'skip update');\n // eslint-disable-next-line no-console\n console.warn(e);\n return false;\n }\n }\n\n onFocus = (e) => {\n try {\n let rootBlock = e.target.parentElement.nextSibling;\n let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n\n if (!id) {\n rootBlock = rootBlock.parentElement;\n id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n }\n\n const innerField = this.mathField.innerFields.find((f) => f.id === id);\n\n if (innerField) {\n const name = this.props.getFieldName(innerField, this.mathField.innerFields);\n if (this.props.setInput) {\n this.props.setInput(innerField);\n }\n this.props.onSubFieldFocus(name, innerField);\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('error finding root block', err.message);\n }\n };\n\n render() {\n const { onBlur, className } = this.props;\n\n return <span className={className} onFocus={this.onFocus} onBlur={onBlur} ref={this.inputRef} />;\n }\n}\n"],"file":"static.js"}
|
|
1
|
+
{"version":3,"file":"static.js","names":["_propTypes","_interopRequireDefault","require","_react","_debug","_mathquill","_updateSpans","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","MQ","window","MathQuill","getInterface","log","debug","REGEX","WHITESPACE_REGEX","stripSpaces","string","arguments","length","undefined","replace","countBraces","latex","count","i","Static","exports","_React$Component","props","_this","_classCallCheck2","_defineProperty2","liveRegion","document","createElement","style","position","width","height","marginTop","clip","overflow","setAttribute","body","appendChild","input","inputRef","current","addEventListener","handleKeyDown","handleMathKeyboardClick","removeEventListener","removeChild","event","key","setState","isDeleteKeyPressed","inputSource","field","mathField","name","getFieldName","innerFields","onSubFieldChange","_this$inputRef","regexMatch","match","__controller","cursor","insLeftOf","parent","el","dispatchEvent","KeyboardEvent","keyCode","console","error","toString","announceLatexConversion","newLatex","state","_this$state","previousLatex","announcement","newBraces","oldBraces","announceMessage","parseLatex","warn","message","textContent","setTimeout","Error","_this$inputRef2","StaticMath","handlers","edit","onInputEdit","bind","blur","focus","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","find","f","setInput","onSubFieldFocus","err","React","createRef","_inherits2","_createClass2","value","componentDidMount","update","updateSpans","createLiveRegion","addEventListeners","componentDidUpdate","componentWillUnmount","removeLiveRegion","removeEventListeners","shouldComponentUpdate","nextProps","parsedLatex","stripped","newFieldCount","out","trim","Object","keys","render","_this$props","onBlur","className","onFocus","ref","Component","PropTypes","isRequired","func"],"sources":["../../src/mq/static.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../updateSpans';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n}\n\nconst log = debug('pie-lib:math-input:mq:static');\nconst REGEX = /\\\\MathQuillMathField\\[r\\d*\\]\\{(.*?)\\}/g;\nconst WHITESPACE_REGEX = / /g;\n\nfunction stripSpaces(string = '') {\n return string.replace(WHITESPACE_REGEX, '');\n}\n\nfunction countBraces(latex) {\n let count = 0;\n\n for (let i = 0; i < (latex || '').length; i++) {\n if (latex[i] === '{') {\n count++;\n }\n }\n\n return count;\n}\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n className: PropTypes.string,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func,\n };\n\n static defaultProps = {\n getFieldName: () => {},\n };\n\n constructor(props) {\n super(props);\n this.state = {\n announcement: '',\n previousLatex: '',\n inputSource: null,\n isDeleteKeyPressed: false,\n };\n\n this.inputRef = React.createRef();\n }\n\n componentDidMount() {\n this.update();\n updateSpans();\n\n this.createLiveRegion();\n this.addEventListeners();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\n }\n\n componentWillUnmount() {\n this.removeLiveRegion();\n this.removeEventListeners();\n }\n\n createLiveRegion = () => {\n this.liveRegion = document.createElement('div');\n this.liveRegion.style.position = 'absolute';\n this.liveRegion.style.width = '1px';\n this.liveRegion.style.height = '1px';\n this.liveRegion.style.marginTop = '-1px';\n this.liveRegion.style.clip = 'rect(1px, 1px, 1px, 1px)';\n this.liveRegion.style.overflow = 'hidden';\n this.liveRegion.setAttribute('aria-live', 'polite');\n this.liveRegion.setAttribute('aria-atomic', 'true');\n\n document.body.appendChild(this.liveRegion);\n };\n\n addEventListeners = () => {\n const input = this.inputRef.current;\n\n if (input) {\n input.addEventListener('keydown', this.handleKeyDown);\n input.addEventListener('click', this.handleMathKeyboardClick);\n }\n };\n\n removeEventListeners = () => {\n const input = this.inputRef.current;\n\n if (input) {\n input.removeEventListener('keydown', this.handleKeyDown);\n input.removeEventListener('click', this.handleMathKeyboardClick);\n }\n };\n\n removeLiveRegion = () => {\n if (this.liveRegion) {\n document.body.removeChild(this.liveRegion);\n this.liveRegion = null;\n }\n };\n\n handleKeyDown = (event) => {\n if (event?.key === 'Backspace' || event?.key === 'Delete') {\n this.setState({ isDeleteKeyPressed: true });\n }\n this.setState({ inputSource: 'keyboard' });\n };\n\n handleMathKeyboardClick = () => {\n this.setState({ inputSource: 'mathKeyboard' });\n };\n\n onInputEdit = (field) => {\n if (!this.mathField) {\n return;\n }\n const name = this.props.getFieldName(field, this.mathField.innerFields);\n\n if (this.props.onSubFieldChange) {\n // eslint-disable-next-line no-useless-escape\n const regexMatch = field.latex().match(/[0-9]\\\\ \\\\frac\\{[^\\{]*\\}\\{ \\}/);\n\n if (this.inputRef?.current && regexMatch && regexMatch?.length) {\n try {\n field.__controller.cursor.insLeftOf(field.__controller.cursor.parent[-1].parent);\n field.el().dispatchEvent(new KeyboardEvent('keydown', { keyCode: 8 }));\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e.toString());\n }\n } else {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n\n this.announceLatexConversion(field.latex());\n };\n\n announceLatexConversion = (newLatex) => {\n if (!this.state) {\n console.error('State is not initialized');\n return;\n }\n\n const { previousLatex, inputSource, isDeleteKeyPressed } = this.state;\n const announcement = 'Converted to math symbol';\n\n if (inputSource === 'keyboard' && !isDeleteKeyPressed) {\n const newBraces = countBraces(newLatex);\n const oldBraces = countBraces(previousLatex);\n\n if (newBraces > oldBraces) {\n this.announceMessage(announcement);\n } else {\n try {\n this.mathField.parseLatex(previousLatex);\n this.mathField.parseLatex(newLatex);\n\n if (newLatex == previousLatex) {\n this.announceMessage(announcement);\n }\n } catch (e) {\n console.warn('Error parsing latex:', e.message);\n console.warn(e);\n }\n }\n }\n\n this.setState({ previousLatex: newLatex, isDeleteKeyPressed: false });\n };\n\n announceMessage = (message) => {\n this.setState({ previousLatex: '' });\n\n if (this.liveRegion) {\n this.liveRegion.textContent = message;\n\n // Clear the message after it is announced\n setTimeout(() => {\n this.liveRegion.textContent = '';\n }, 500);\n }\n };\n\n update = () => {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.inputRef?.current, {\n handlers: {\n edit: this.onInputEdit.bind(this),\n },\n });\n }\n\n try {\n this.mathField.parseLatex(this.props.latex);\n this.mathField.latex(this.props.latex);\n } catch (e) {\n // default latex if received has errors\n this.mathField.latex('\\\\MathQuillMathField[r1]{}');\n }\n };\n\n blur = () => {\n log('blur mathfield');\n this.mathField.blur();\n };\n\n focus = () => {\n log('focus mathfield...');\n this.mathField.focus();\n };\n\n shouldComponentUpdate(nextProps) {\n try {\n const parsedLatex = this.mathField.parseLatex(nextProps.latex);\n const stripped = stripSpaces(parsedLatex);\n const newFieldCount = (nextProps.latex.match(REGEX) || []).length;\n\n const out =\n stripped !== stripSpaces(this.mathField.latex().trim()) ||\n newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;\n\n log('[shouldComponentUpdate] ', out);\n return out;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('Error parsing latex:', e.message, 'skip update');\n // eslint-disable-next-line no-console\n console.warn(e);\n return false;\n }\n }\n\n onFocus = (e) => {\n try {\n let rootBlock = e.target.parentElement.nextSibling;\n let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n\n if (!id) {\n rootBlock = rootBlock.parentElement;\n id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n }\n\n const innerField = this.mathField.innerFields.find((f) => f.id === id);\n\n if (innerField) {\n const name = this.props.getFieldName(innerField, this.mathField.innerFields);\n if (this.props.setInput) {\n this.props.setInput(innerField);\n }\n this.props.onSubFieldFocus(name, innerField);\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('error finding root block', err.message);\n }\n };\n\n render() {\n const { onBlur, className } = this.props;\n\n return <span className={className} onFocus={this.onFocus} onBlur={onBlur} ref={this.inputRef} />;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAA6C,SAAAK,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,C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F,CAAC,CAAC;QACf,OAAO,KAAK;MACd;IACF;EAAC;IAAA2D,GAAA;IAAAgE,KAAA,EA2BD,SAAAmB,MAAMA,CAAA,EAAG;MACP,IAAAC,WAAA,GAA8B,IAAI,CAAC9G,KAAK;QAAhC+G,MAAM,GAAAD,WAAA,CAANC,MAAM;QAAEC,SAAS,GAAAF,WAAA,CAATE,SAAS;MAEzB,oBAAOxJ,MAAA,YAAA8C,aAAA;QAAM0G,SAAS,EAAEA,SAAU;QAACC,OAAO,EAAE,IAAI,CAACA,OAAQ;QAACF,MAAM,EAAEA,MAAO;QAACG,GAAG,EAAE,IAAI,CAAChG;MAAS,CAAE,CAAC;IAClG;EAAC;AAAA,EAzPiCoE,iBAAK,CAAC6B,SAAS;AAAA,IAAAhH,gBAAA,aAA9BN,MAAM,eACN;EACjBH,KAAK,EAAE0H,qBAAS,CAAChI,MAAM,CAACiI,UAAU;EAClCJ,OAAO,EAAEG,qBAAS,CAACE,IAAI;EACvBP,MAAM,EAAEK,qBAAS,CAACE,IAAI;EACtBN,SAAS,EAAEI,qBAAS,CAAChI,MAAM;EAC3B6C,YAAY,EAAEmF,qBAAS,CAACE,IAAI;EAC5BnF,gBAAgB,EAAEiF,qBAAS,CAACE,IAAI;EAChClC,eAAe,EAAEgC,qBAAS,CAACE,IAAI;EAC/BnC,QAAQ,EAAEiC,qBAAS,CAACE;AACtB,CAAC;AAAA,IAAAnH,gBAAA,aAVkBN,MAAM,kBAYH;EACpBoC,YAAY,EAAE,SAAdA,YAAYA,CAAA,EAAQ,CAAC;AACvB,CAAC","ignoreList":[]}
|
package/lib/shared/constants.js
CHANGED
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.PIE_TOOLBAR__CLASS = exports.MAIN_CONTAINER_CLASS = void 0;
|
|
7
|
-
var MAIN_CONTAINER_CLASS = 'main-container';
|
|
8
|
-
exports.
|
|
9
|
-
var
|
|
10
|
-
exports.PIE_TOOLBAR__CLASS = PIE_TOOLBAR__CLASS;
|
|
11
|
-
var _default = {
|
|
7
|
+
var MAIN_CONTAINER_CLASS = exports.MAIN_CONTAINER_CLASS = 'main-container';
|
|
8
|
+
var PIE_TOOLBAR__CLASS = exports.PIE_TOOLBAR__CLASS = 'pie-toolbar';
|
|
9
|
+
var _default = exports["default"] = {
|
|
12
10
|
MAIN_CONTAINER_CLASS: MAIN_CONTAINER_CLASS,
|
|
13
11
|
PIE_TOOLBAR__CLASS: PIE_TOOLBAR__CLASS
|
|
14
12
|
};
|
|
15
|
-
exports["default"] = _default;
|
|
16
13
|
//# sourceMappingURL=constants.js.map
|
package/lib/updateSpans.js
CHANGED
|
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.updateSpans = void 0;
|
|
7
|
-
|
|
8
7
|
// increase the font of parallel notation
|
|
9
|
-
var updateSpans = function updateSpans() {
|
|
8
|
+
var updateSpans = exports.updateSpans = function updateSpans() {
|
|
10
9
|
var spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));
|
|
11
10
|
(spans || []).forEach(function (span) {
|
|
12
11
|
if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {
|
|
13
12
|
span.style.fontSize = '32px';
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
if ((span.innerText === '′' || span.innerText === '′′') && !span.hasAttribute('data-prime')) {
|
|
17
15
|
span.setAttribute('data-prime', 'true');
|
|
18
16
|
}
|
|
19
17
|
});
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
exports.updateSpans = updateSpans;
|
|
23
19
|
//# sourceMappingURL=updateSpans.js.map
|
package/lib/updateSpans.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"updateSpans.js","names":["updateSpans","exports","spans","Array","from","document","querySelectorAll","forEach","span","innerText","className","style","fontSize","hasAttribute","setAttribute"],"sources":["../src/updateSpans.js"],"sourcesContent":["// increase the font of parallel notation\nconst updateSpans = () => {\n const spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));\n (spans || []).forEach((span) => {\n if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {\n span.style.fontSize = '32px';\n }\n\n if ((span.innerText === '′' || span.innerText === '′′') && !span.hasAttribute('data-prime')) {\n span.setAttribute('data-prime', 'true');\n }\n });\n};\n\nexport { updateSpans };\n"],"mappings":";;;;;;AAAA;AACA,IAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,SAAdA,WAAWA,CAAA,EAAS;EACxB,IAAME,KAAK,GAAGC,KAAK,CAACC,IAAI,CAACC,QAAQ,CAACC,gBAAgB,CAAC,4BAA4B,CAAC,CAAC;EACjF,CAACJ,KAAK,IAAI,EAAE,EAAEK,OAAO,CAAC,UAACC,IAAI,EAAK;IAC9B,IAAIA,IAAI,IAAIA,IAAI,CAACC,SAAS,KAAK,GAAG,IAAID,IAAI,CAACE,SAAS,KAAK,mBAAmB,EAAE;MAC5EF,IAAI,CAACG,KAAK,CAACC,QAAQ,GAAG,MAAM;IAC9B;IAEA,IAAI,CAACJ,IAAI,CAACC,SAAS,KAAK,GAAG,IAAID,IAAI,CAACC,SAAS,KAAK,IAAI,KAAK,CAACD,IAAI,CAACK,YAAY,CAAC,YAAY,CAAC,EAAE;MAC3FL,IAAI,CAACM,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC;IACzC;EACF,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.
|
|
6
|
+
"version": "6.29.0-mui-update.0",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"module": "src/index.jsx",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"@
|
|
10
|
+
"@emotion/react": "^11.14.0",
|
|
11
|
+
"@emotion/style": "^0.8.0",
|
|
12
|
+
"@mui/icons-material": "^7.3.4",
|
|
13
|
+
"@mui/material": "^7.3.4",
|
|
12
14
|
"@pie-framework/mathquill": "^1.1.3",
|
|
13
15
|
"classnames": "^2.2.6",
|
|
14
16
|
"debug": "^4.1.1",
|
|
@@ -17,19 +19,12 @@
|
|
|
17
19
|
"react-portal": "^4.2.0"
|
|
18
20
|
},
|
|
19
21
|
"peerDependencies": {
|
|
20
|
-
"react": "^
|
|
22
|
+
"react": "^18.2.0"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
|
-
"react": "^
|
|
24
|
-
"react-dom": "^
|
|
25
|
+
"react": "^18.2.0",
|
|
26
|
+
"react-dom": "^18.2.0"
|
|
25
27
|
},
|
|
26
28
|
"scripts": {},
|
|
27
|
-
"gitHead": "
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"import": "./esm/index.js",
|
|
31
|
-
"require": "./lib/index.js",
|
|
32
|
-
"default": "./esm/index.js"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
29
|
+
"gitHead": "4b009262d3ab5bb833be81c23fc612fca3cb82f5"
|
|
35
30
|
}
|
package/src/keypad/index.jsx
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Button from '@material
|
|
4
|
-
import IconButton from '@material
|
|
5
|
-
import {
|
|
3
|
+
import Button from '@mui/material/Button';
|
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
|
5
|
+
import { lighten, alpha, styled } from '@mui/material/styles';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import { lighten, fade } from '@material-ui/core/styles/colorManipulator';
|
|
8
|
-
import green from '@material-ui/core/colors/green';
|
|
9
7
|
import debug from 'debug';
|
|
10
8
|
import _ from 'lodash';
|
|
11
9
|
import MathQuill from '@pie-framework/mathquill';
|
|
12
|
-
|
|
13
10
|
import * as mq from '../mq';
|
|
11
|
+
|
|
14
12
|
import { baseSet } from '../keys';
|
|
15
13
|
import editableHtmlConstants from '../../../editable-html/src/constants';
|
|
16
14
|
import { commonMqKeyboardStyles } from '../mq/common-mq-styles';
|
|
17
15
|
import { sortKeys } from './keys-layout';
|
|
16
|
+
import { green } from '@mui/material/colors';
|
|
18
17
|
|
|
19
18
|
const log = debug('pie-lib:math-inline:keypad');
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const StyledLatexButton = styled(Button)(({ theme }) => ({
|
|
21
|
+
textTransform: 'none',
|
|
22
|
+
padding: 0,
|
|
23
|
+
margin: 0,
|
|
24
|
+
fontSize: '110% !important',
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const LatexButtonContent = styled(mq.Static)(({ theme, latex }) => {
|
|
28
|
+
const baseStyles = {
|
|
29
29
|
pointerEvents: 'none',
|
|
30
30
|
textTransform: 'none !important',
|
|
31
31
|
'& .mq-scaled.mq-sqrt-prefix': {
|
|
@@ -35,25 +35,24 @@ const LatexButton = withStyles((theme) => ({
|
|
|
35
35
|
marginBottom: '0.9px !important',
|
|
36
36
|
},
|
|
37
37
|
'& .mq-empty': {
|
|
38
|
-
backgroundColor: `${
|
|
38
|
+
backgroundColor: `${alpha(theme.palette.secondary.main, 0.4)} !important`,
|
|
39
39
|
},
|
|
40
40
|
'& .mq-overline .mq-overline-inner': {
|
|
41
41
|
borderTop: '2px solid black',
|
|
42
42
|
},
|
|
43
43
|
'& .mq-non-leaf.mq-overline': {
|
|
44
|
-
borderTop: 'none !important',
|
|
44
|
+
borderTop: 'none !important',
|
|
45
45
|
},
|
|
46
46
|
'& .mq-overarrow': {
|
|
47
47
|
width: '30px',
|
|
48
48
|
marginTop: '0 !important',
|
|
49
49
|
borderTop: '2px solid black',
|
|
50
50
|
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
51
|
-
|
|
52
51
|
'&.mq-arrow-both': {
|
|
53
52
|
top: '0px !important',
|
|
54
53
|
'& *': {
|
|
55
54
|
lineHeight: '1 !important',
|
|
56
|
-
borderTop: 'none !important',
|
|
55
|
+
borderTop: 'none !important',
|
|
57
56
|
},
|
|
58
57
|
'&:before': {
|
|
59
58
|
fontSize: '80%',
|
|
@@ -119,40 +118,43 @@ const LatexButton = withStyles((theme) => ({
|
|
|
119
118
|
'& .mq-overarc': {
|
|
120
119
|
borderTop: '2px solid black !important',
|
|
121
120
|
'& .mq-overline': {
|
|
122
|
-
borderTop: 'none !important', // fixing PD-4873 - in OT, it has border-top 1px and adds extra line
|
|
123
|
-
},
|
|
124
|
-
'& .mq-overline-inner': {
|
|
125
121
|
borderTop: 'none !important',
|
|
126
|
-
paddingTop: '0 !important',
|
|
127
122
|
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
parallelButton: {
|
|
131
|
-
fontStyle: 'italic !important',
|
|
132
|
-
},
|
|
133
|
-
leftRightArrowButton: {
|
|
134
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
135
123
|
'& .mq-overline-inner': {
|
|
136
124
|
borderTop: 'none !important',
|
|
137
125
|
paddingTop: '0 !important',
|
|
138
126
|
},
|
|
139
|
-
'&:after': {
|
|
140
|
-
position: 'absolute !important',
|
|
141
|
-
top: '0px !important',
|
|
142
|
-
},
|
|
143
127
|
},
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Add specific styles based on latex content
|
|
131
|
+
if (latex === '\\parallel') {
|
|
132
|
+
return {
|
|
133
|
+
...baseStyles,
|
|
134
|
+
fontStyle: 'italic !important',
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (latex === '\\overleftrightarrow{\\overline{}}') {
|
|
139
|
+
return {
|
|
140
|
+
...baseStyles,
|
|
141
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
142
|
+
'& .mq-overline-inner': {
|
|
143
|
+
borderTop: 'none !important',
|
|
144
|
+
paddingTop: '0 !important',
|
|
145
|
+
},
|
|
146
|
+
'&:after': {
|
|
147
|
+
position: 'absolute !important',
|
|
148
|
+
top: '0px !important',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
154
152
|
}
|
|
155
153
|
|
|
154
|
+
return baseStyles;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const LatexButton = (props) => {
|
|
156
158
|
try {
|
|
157
159
|
const MQ = MathQuill.getInterface(2);
|
|
158
160
|
const span = document.createElement('span');
|
|
@@ -167,15 +169,15 @@ const LatexButton = withStyles((theme) => ({
|
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
return (
|
|
170
|
-
<
|
|
171
|
-
className={
|
|
172
|
+
<StyledLatexButton
|
|
173
|
+
className={props.className}
|
|
172
174
|
onClick={props.onClick}
|
|
173
175
|
aria-label={props.ariaLabel}
|
|
174
176
|
>
|
|
175
|
-
<
|
|
176
|
-
</
|
|
177
|
+
<LatexButtonContent latex={props.latex} />
|
|
178
|
+
</StyledLatexButton>
|
|
177
179
|
);
|
|
178
|
-
}
|
|
180
|
+
};
|
|
179
181
|
|
|
180
182
|
const createCustomLayout = (layoutObj) => {
|
|
181
183
|
if (layoutObj) {
|
|
@@ -189,9 +191,83 @@ const createCustomLayout = (layoutObj) => {
|
|
|
189
191
|
return {};
|
|
190
192
|
};
|
|
191
193
|
|
|
194
|
+
const KeyPadContainer = styled('div')(({ theme }) => ({
|
|
195
|
+
...commonMqKeyboardStyles,
|
|
196
|
+
width: '100%',
|
|
197
|
+
display: 'grid',
|
|
198
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
199
|
+
gridRowGap: '0px',
|
|
200
|
+
gridColumnGap: '0px',
|
|
201
|
+
gridAutoFlow: 'column',
|
|
202
|
+
'&.character': {
|
|
203
|
+
textTransform: 'initial !important',
|
|
204
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',
|
|
205
|
+
},
|
|
206
|
+
'&.language': {
|
|
207
|
+
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
208
|
+
'& *': {
|
|
209
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
}));
|
|
213
|
+
|
|
214
|
+
const StyledButton = styled(Button)(({ theme, category, isDelete, isComma, isDot }) => ({
|
|
215
|
+
minWidth: 'auto',
|
|
216
|
+
fontSize: isComma || isDot ? '200% !important' : '140% !important',
|
|
217
|
+
lineHeight: isComma || isDot ? '100%' : 'normal',
|
|
218
|
+
backgroundColor:
|
|
219
|
+
category === 'operators' ? lighten(theme.palette.secondary.light, 0.5) :
|
|
220
|
+
category === 'comparison' ? lighten(green[500], 0.5) :
|
|
221
|
+
lighten(theme.palette.primary.light, 0.5),
|
|
222
|
+
'&:hover': {
|
|
223
|
+
backgroundColor:
|
|
224
|
+
category === 'operators' ? lighten(theme.palette.secondary.light, 0.7) :
|
|
225
|
+
category === 'comparison' ? lighten(green[500], 0.7) :
|
|
226
|
+
lighten(theme.palette.primary.light, 0.7),
|
|
227
|
+
},
|
|
228
|
+
borderRadius: 0,
|
|
229
|
+
...(isDelete && {
|
|
230
|
+
'& > span': {
|
|
231
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
}));
|
|
235
|
+
|
|
236
|
+
const StyledLatexButtonWrapper = styled(Button)(({ theme, category }) => ({
|
|
237
|
+
minWidth: 'auto',
|
|
238
|
+
borderRadius: 0,
|
|
239
|
+
backgroundColor:
|
|
240
|
+
category === 'operators' ? lighten(theme.palette.secondary.light, 0.5) :
|
|
241
|
+
category === 'comparison' ? lighten(green[500], 0.5) :
|
|
242
|
+
lighten(theme.palette.primary.light, 0.5),
|
|
243
|
+
'&:hover': {
|
|
244
|
+
backgroundColor:
|
|
245
|
+
category === 'operators' ? lighten(theme.palette.secondary.light, 0.7) :
|
|
246
|
+
category === 'comparison' ? lighten(green[500], 0.7) :
|
|
247
|
+
lighten(theme.palette.primary.light, 0.7),
|
|
248
|
+
},
|
|
249
|
+
}));
|
|
250
|
+
|
|
251
|
+
const StyledIconButton = styled(IconButton)(({ theme, category }) => ({
|
|
252
|
+
minWidth: 'auto',
|
|
253
|
+
backgroundColor:
|
|
254
|
+
category === 'operators' ? lighten(theme.palette.secondary.light, 0.5) :
|
|
255
|
+
category === 'comparison' ? lighten(green[500], 0.5) :
|
|
256
|
+
lighten(theme.palette.primary.light, 0.5),
|
|
257
|
+
'&:hover': {
|
|
258
|
+
backgroundColor:
|
|
259
|
+
category === 'operators' ? lighten(theme.palette.secondary.light, 0.7) :
|
|
260
|
+
category === 'comparison' ? lighten(green[500], 0.7) :
|
|
261
|
+
lighten(theme.palette.primary.light, 0.7),
|
|
262
|
+
},
|
|
263
|
+
borderRadius: 0,
|
|
264
|
+
'& .icon': {
|
|
265
|
+
height: '30px',
|
|
266
|
+
},
|
|
267
|
+
}));
|
|
268
|
+
|
|
192
269
|
export class KeyPad extends React.Component {
|
|
193
270
|
static propTypes = {
|
|
194
|
-
classes: PropTypes.object.isRequired,
|
|
195
271
|
className: PropTypes.string,
|
|
196
272
|
controlledKeypadMode: PropTypes.bool,
|
|
197
273
|
baseSet: PropTypes.array,
|
|
@@ -289,14 +365,14 @@ export class KeyPad extends React.Component {
|
|
|
289
365
|
};
|
|
290
366
|
|
|
291
367
|
render() {
|
|
292
|
-
const {
|
|
368
|
+
const { className, baseSet, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;
|
|
293
369
|
|
|
294
370
|
const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];
|
|
295
371
|
|
|
296
372
|
const keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
297
373
|
const allKeys = keysWithoutBaseSet
|
|
298
374
|
? this.flowKeys([], additionalKeys || [])
|
|
299
|
-
: this.flowKeys(baseSet, additionalKeys || []);
|
|
375
|
+
: this.flowKeys(baseSet, additionalKeys || []);
|
|
300
376
|
|
|
301
377
|
const shift = allKeys.length % 5 ? 1 : 0;
|
|
302
378
|
const style = {
|
|
@@ -305,9 +381,9 @@ export class KeyPad extends React.Component {
|
|
|
305
381
|
};
|
|
306
382
|
|
|
307
383
|
return (
|
|
308
|
-
<
|
|
384
|
+
<KeyPadContainer
|
|
309
385
|
ref={this.keypadRef}
|
|
310
|
-
className={classNames(
|
|
386
|
+
className={classNames(className, mode)}
|
|
311
387
|
style={style}
|
|
312
388
|
onFocus={onFocus}
|
|
313
389
|
>
|
|
@@ -320,13 +396,6 @@ export class KeyPad extends React.Component {
|
|
|
320
396
|
|
|
321
397
|
const common = {
|
|
322
398
|
onClick,
|
|
323
|
-
className: classNames(
|
|
324
|
-
classes.labelButton,
|
|
325
|
-
!keysWithoutBaseSet && classes[k.category],
|
|
326
|
-
classes[k.extraClass],
|
|
327
|
-
k.label === ',' && classes.comma,
|
|
328
|
-
k.label === '.' && classes.dot,
|
|
329
|
-
),
|
|
330
399
|
disabled: this.keyIsNotAllowed(k),
|
|
331
400
|
key: `${k.label || k.latex || k.command}-${index}`,
|
|
332
401
|
...(k.actions || {}),
|
|
@@ -335,116 +404,47 @@ export class KeyPad extends React.Component {
|
|
|
335
404
|
|
|
336
405
|
if (k.latex) {
|
|
337
406
|
return (
|
|
338
|
-
<
|
|
339
|
-
latex={k.latex}
|
|
340
|
-
key={index}
|
|
407
|
+
<StyledLatexButtonWrapper
|
|
341
408
|
{...common}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
409
|
+
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
410
|
+
aria-label={k.ariaLabel ? k.ariaLabel : k.name || k.label}
|
|
411
|
+
>
|
|
412
|
+
<LatexButtonContent latex={k.latex} />
|
|
413
|
+
</StyledLatexButtonWrapper>
|
|
345
414
|
);
|
|
346
415
|
}
|
|
347
416
|
|
|
348
417
|
if (k.label) {
|
|
349
418
|
return (
|
|
350
|
-
<
|
|
351
|
-
key={index}
|
|
419
|
+
<StyledButton
|
|
352
420
|
{...common}
|
|
353
|
-
|
|
421
|
+
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
422
|
+
isDelete={k.label === '⌫'}
|
|
423
|
+
isComma={k.label === ','}
|
|
424
|
+
isDot={k.label === '.'}
|
|
354
425
|
aria-label={k.ariaLabel ? k.ariaLabel : k.name || k.label}
|
|
355
426
|
>
|
|
356
427
|
{k.label}
|
|
357
|
-
</
|
|
428
|
+
</StyledButton>
|
|
358
429
|
);
|
|
359
430
|
} else {
|
|
360
431
|
const Icon = k.icon ? k.icon : 'div';
|
|
361
432
|
|
|
362
433
|
return (
|
|
363
|
-
<
|
|
364
|
-
|
|
365
|
-
|
|
434
|
+
<StyledIconButton
|
|
435
|
+
tabIndex={'-1'}
|
|
436
|
+
{...common}
|
|
437
|
+
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
438
|
+
size="large"
|
|
439
|
+
>
|
|
440
|
+
<Icon className="icon" />
|
|
441
|
+
</StyledIconButton>
|
|
366
442
|
);
|
|
367
443
|
}
|
|
368
444
|
})}
|
|
369
|
-
</
|
|
445
|
+
</KeyPadContainer>
|
|
370
446
|
);
|
|
371
447
|
}
|
|
372
448
|
}
|
|
373
449
|
|
|
374
|
-
|
|
375
|
-
keys: {
|
|
376
|
-
...commonMqKeyboardStyles,
|
|
377
|
-
width: '100%',
|
|
378
|
-
display: 'grid',
|
|
379
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
380
|
-
gridRowGap: '0px',
|
|
381
|
-
gridColumnGap: '0px',
|
|
382
|
-
gridAutoFlow: 'column',
|
|
383
|
-
},
|
|
384
|
-
character: {
|
|
385
|
-
textTransform: 'initial !important',
|
|
386
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',
|
|
387
|
-
},
|
|
388
|
-
language: {
|
|
389
|
-
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
390
|
-
'& *': {
|
|
391
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
holder: {
|
|
395
|
-
position: 'relative',
|
|
396
|
-
width: '100%',
|
|
397
|
-
height: '100%',
|
|
398
|
-
backgroundColor: '#cef',
|
|
399
|
-
borderRadius: 0,
|
|
400
|
-
padding: `${theme.spacing.unit}px 0 ${theme.spacing.unit}px 0`,
|
|
401
|
-
},
|
|
402
|
-
labelButton: {
|
|
403
|
-
minWidth: 'auto',
|
|
404
|
-
fontSize: '140% !important',
|
|
405
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.5),
|
|
406
|
-
'&:hover': {
|
|
407
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.7),
|
|
408
|
-
},
|
|
409
|
-
borderRadius: 0,
|
|
410
|
-
},
|
|
411
|
-
latexButton: {
|
|
412
|
-
minWidth: 'auto',
|
|
413
|
-
borderRadius: 0,
|
|
414
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.5),
|
|
415
|
-
'&:hover': {
|
|
416
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.7),
|
|
417
|
-
},
|
|
418
|
-
},
|
|
419
|
-
deleteButton: {
|
|
420
|
-
'& > span': {
|
|
421
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
422
|
-
},
|
|
423
|
-
},
|
|
424
|
-
base: {},
|
|
425
|
-
operators: {
|
|
426
|
-
backgroundColor: lighten(theme.palette.secondary.light, 0.5),
|
|
427
|
-
'&:hover': {
|
|
428
|
-
backgroundColor: lighten(theme.palette.secondary.light, 0.7),
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
comparison: {
|
|
432
|
-
backgroundColor: lighten(green[500], 0.5),
|
|
433
|
-
'&:hover': {
|
|
434
|
-
backgroundColor: lighten(green[500], 0.7),
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
comma: {
|
|
438
|
-
fontSize: '200% !important',
|
|
439
|
-
lineHeight: '100%',
|
|
440
|
-
},
|
|
441
|
-
dot: {
|
|
442
|
-
fontSize: '200% !important',
|
|
443
|
-
lineHeight: '100%',
|
|
444
|
-
},
|
|
445
|
-
icon: {
|
|
446
|
-
height: '30px',
|
|
447
|
-
},
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
export default withStyles(styles)(KeyPad);
|
|
450
|
+
export default KeyPad;
|