@pie-lib/math-input 6.8.4-next.0 → 6.8.5-next.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/horizontal-keypad.js.map +1 -1
  3. package/lib/index.js.map +1 -1
  4. package/lib/keypad/index.js.map +1 -1
  5. package/lib/keypad/keys-layout.js.map +1 -1
  6. package/lib/keys/basic-operators.js.map +1 -1
  7. package/lib/keys/comparison.js.map +1 -1
  8. package/lib/keys/constants.js.map +1 -1
  9. package/lib/keys/digits.js.map +1 -1
  10. package/lib/keys/exponent.js.map +1 -1
  11. package/lib/keys/fractions.js.map +1 -1
  12. package/lib/keys/geometry.js.map +1 -1
  13. package/lib/keys/grades.js.map +1 -1
  14. package/lib/keys/index.js.map +1 -1
  15. package/lib/keys/log.js.map +1 -1
  16. package/lib/keys/logic.js.map +1 -1
  17. package/lib/keys/matrices.js.map +1 -1
  18. package/lib/keys/misc.js.map +1 -1
  19. package/lib/keys/operators.js.map +1 -1
  20. package/lib/keys/statistics.js.map +1 -1
  21. package/lib/keys/sub-sup.js.map +1 -1
  22. package/lib/keys/utils.js.map +1 -1
  23. package/lib/keys/vars.js.map +1 -1
  24. package/lib/math-input.js.map +1 -1
  25. package/lib/mq/custom-elements.js.map +1 -1
  26. package/lib/mq/input.js.map +1 -1
  27. package/lib/mq/static.js +1 -1
  28. package/lib/mq/static.js.map +1 -1
  29. package/package.json +2 -2
  30. package/src/horizontal-keypad.jsx +4 -4
  31. package/src/index.jsx +7 -7
  32. package/src/keypad/index.jsx +66 -97
  33. package/src/keypad/keys-layout.js +1 -1
  34. package/src/keys/basic-operators.js +5 -5
  35. package/src/keys/comparison.js +5 -5
  36. package/src/keys/constants.js +4 -4
  37. package/src/keys/digits.js +5 -5
  38. package/src/keys/exponent.js +4 -4
  39. package/src/keys/fractions.js +3 -3
  40. package/src/keys/geometry.js +24 -24
  41. package/src/keys/grades.js +43 -67
  42. package/src/keys/index.js +1 -1
  43. package/src/keys/log.js +3 -3
  44. package/src/keys/logic.js +2 -2
  45. package/src/keys/matrices.js +2 -2
  46. package/src/keys/misc.js +10 -10
  47. package/src/keys/operators.js +1 -1
  48. package/src/keys/statistics.js +5 -5
  49. package/src/keys/sub-sup.js +2 -2
  50. package/src/keys/utils.js +8 -8
  51. package/src/keys/vars.js +3 -3
  52. package/src/math-input.jsx +14 -14
  53. package/src/mq/custom-elements.js +1 -1
  54. package/src/mq/input.jsx +6 -6
  55. package/src/mq/static.jsx +7 -14
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mq/custom-elements.js"],"names":["registerLineBreak","MQ","registerEmbed","htmlString","text","latex"],"mappings":";;;;;;;AAAA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAASC,EAAT,EAAa;AACrCA,EAAAA,EAAE,CAACC,aAAH,CAAiB,SAAjB,EAA4B,YAAM;AAChC,WAAO;AACLC,MAAAA,UAAU,EAAE,6BADP;AAELC,MAAAA,IAAI,EAAE;AAAA,eAAM,UAAN;AAAA,OAFD;AAGLC,MAAAA,KAAK,EAAE;AAAA,eAAM,oBAAN;AAAA;AAHF,KAAP;AAKD,GAND;AAOD,CARD","sourcesContent":["const registerLineBreak = function(MQ) {\n MQ.registerEmbed('newLine', () => {\n return {\n htmlString: '<div class=\"newLine\"></div>',\n text: () => 'testText',\n latex: () => '\\\\embed{newLine}[]'\n };\n });\n};\n\nexport { registerLineBreak };\n"],"file":"custom-elements.js"}
1
+ {"version":3,"sources":["../../src/mq/custom-elements.js"],"names":["registerLineBreak","MQ","registerEmbed","htmlString","text","latex"],"mappings":";;;;;;;AAAA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAASC,EAAT,EAAa;AACrCA,EAAAA,EAAE,CAACC,aAAH,CAAiB,SAAjB,EAA4B,YAAM;AAChC,WAAO;AACLC,MAAAA,UAAU,EAAE,6BADP;AAELC,MAAAA,IAAI,EAAE;AAAA,eAAM,UAAN;AAAA,OAFD;AAGLC,MAAAA,KAAK,EAAE;AAAA,eAAM,oBAAN;AAAA;AAHF,KAAP;AAKD,GAND;AAOD,CARD","sourcesContent":["const registerLineBreak = function(MQ) {\n MQ.registerEmbed('newLine', () => {\n return {\n htmlString: '<div class=\"newLine\"></div>',\n text: () => 'testText',\n latex: () => '\\\\embed{newLine}[]',\n };\n });\n};\n\nexport { registerLineBreak };\n"],"file":"custom-elements.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mq/input.jsx"],"names":["MQ","window","MathQuill","getInterface","registerEmbed","log","Input","onChange","props","mathField","latex","blur","focus","event","keys","Object","__controller","options","indexOf","refresh","charCode","write","onInputEdit","Error","MathField","input","handlers","edit","bind","updateLatex","v","Array","isArray","forEach","vv","cmd","keystroke","nextProps","onClick","onFocus","onBlur","classes","className","onKeyPress","r","React","Component","PropTypes","string","object","isRequired","func","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;;AAEA,MAAIH,EAAE,IAAIA,EAAE,CAACI,aAAb,EAA4B;AAC1B,2CAAkBJ,EAAlB;AACD;AACF;;AAED,IAAMK,GAAG,GAAG,uBAAM,qBAAN,CAAZ;AAEA;AACA;AACA;;IACaC,K;;;;;;;;;;;;;;;oGAgFG,YAAM;AAClBD,MAAAA,GAAG,CAAC,mBAAD,CAAH;AACA,UAAQE,QAAR,GAAqB,MAAKC,KAA1B,CAAQD,QAAR;;AACA,UAAI,CAAC,MAAKE,SAAV,EAAqB;AACnB;AACD;;AAED,UAAIF,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAAC,MAAKE,SAAL,CAAeC,KAAf,EAAD,CAAR;AACD;AACF,K;gGAES,YAAM;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C,OAAlC,eAAkCA,OAAlC;AAAA,UAA2CC,SAA3C,eAA2CA,SAA3C;AAEA,0BACE;AACE,QAAA,SAAS,EAAE,4BAAWD,OAAO,CAAChB,KAAnB,EAA0BiB,SAA1B,CADb;AAEE,QAAA,UAAU,EAAE,KAAKC,UAFnB;AAGE,QAAA,OAAO,EAAEL,OAHX;AAIE,QAAA,OAAO,EAAEC,OAJX;AAKE,QAAA,MAAM,EAAEC,MALV;AAME,QAAA,GAAG,EAAE,aAAAI,CAAC;AAAA,iBAAK,MAAI,CAACnB,KAAL,GAAamB,CAAlB;AAAA;AANR,QADF;AAUD;;;EAvIwBC,kBAAMC,S;;;iCAApBxC,K,eACQ;AACjBoC,EAAAA,SAAS,EAAEK,sBAAUC,MADJ;AAEjBP,EAAAA,OAAO,EAAEM,sBAAUE,MAAV,CAAiBC,UAFT;AAGjBZ,EAAAA,OAAO,EAAES,sBAAUI,IAHF;AAIjB5C,EAAAA,QAAQ,EAAEwC,sBAAUI,IAJH;AAKjBzC,EAAAA,KAAK,EAAEqC,sBAAUC,MALA;AAMjBT,EAAAA,OAAO,EAAEQ,sBAAUI,IANF;AAOjBX,EAAAA,MAAM,EAAEO,sBAAUI;AAPD,C;;AAyIrB,IAAMC,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO,EAAP;AAAA,CAAf;;eAEe,wBAAWA,MAAX,EAAmB9C,KAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport debug from 'debug';\nimport classNames from 'classnames';\nimport { registerLineBreak } from './custom-elements';\nimport MathQuill from '@pie-framework/mathquill';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n\n if (MQ && MQ.registerEmbed) {\n registerLineBreak(MQ);\n }\n}\n\nconst log = debug('math-input:mq:input');\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport class Input extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n onChange: PropTypes.func,\n latex: PropTypes.string,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func\n };\n\n componentDidMount() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n\n this.mathField = MQ.MathField(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this)\n }\n });\n\n this.updateLatex();\n }\n\n componentDidUpdate() {\n this.updateLatex();\n }\n\n updateLatex() {\n if (!this.mathField) {\n return;\n }\n const { latex } = this.props;\n if (latex) {\n this.mathField.latex(latex);\n }\n }\n\n clear() {\n this.mathField.latex('');\n return '';\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 command(v) {\n log('command: ', v);\n if (Array.isArray(v)) {\n v.forEach(vv => {\n this.mathField.cmd(vv);\n });\n } else {\n this.mathField.cmd(v);\n }\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n keystroke(v) {\n this.mathField.keystroke(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n write(v) {\n log('write: ', v);\n this.mathField.write(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n onInputEdit = () => {\n log('[onInputEdit] ...');\n const { onChange } = this.props;\n if (!this.mathField) {\n return;\n }\n\n if (onChange) {\n onChange(this.mathField.latex());\n }\n };\n\n refresh = () => {\n this.blur();\n this.focus();\n };\n\n onKeyPress = event => {\n const keys = Object.keys(this.mathField.__controller.options);\n\n if (keys.indexOf('ignoreNextMousedown') < 0) {\n // It seems like the controller has the above handler as an option\n // when all the right events are set and everything works fine\n // this seems to work in all cases\n this.refresh();\n }\n\n if (event.charCode === 13) {\n // if enter's pressed, we're going for a custom embedded element that'll\n // have a block display (empty div) - for a hacked line break using ccs\n // all because mathquill doesn't support a line break\n this.write('\\\\embed{newLine}[]');\n this.onInputEdit();\n }\n };\n\n shouldComponentUpdate(nextProps) {\n log('next: ', nextProps.latex);\n log('current: ', this.mathField.latex());\n return nextProps.latex !== this.mathField.latex();\n }\n\n render() {\n const { onClick, onFocus, onBlur, classes, className } = this.props;\n\n return (\n <span\n className={classNames(classes.input, className)}\n onKeyPress={this.onKeyPress}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n\nconst styles = () => ({});\n\nexport default withStyles(styles)(Input);\n"],"file":"input.js"}
1
+ {"version":3,"sources":["../../src/mq/input.jsx"],"names":["MQ","window","MathQuill","getInterface","registerEmbed","log","Input","onChange","props","mathField","latex","blur","focus","event","keys","Object","__controller","options","indexOf","refresh","charCode","write","onInputEdit","Error","MathField","input","handlers","edit","bind","updateLatex","v","Array","isArray","forEach","vv","cmd","keystroke","nextProps","onClick","onFocus","onBlur","classes","className","onKeyPress","r","React","Component","PropTypes","string","object","isRequired","func","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;;AAEA,MAAIH,EAAE,IAAIA,EAAE,CAACI,aAAb,EAA4B;AAC1B,2CAAkBJ,EAAlB;AACD;AACF;;AAED,IAAMK,GAAG,GAAG,uBAAM,qBAAN,CAAZ;AAEA;AACA;AACA;;IACaC,K;;;;;;;;;;;;;;;oGAgFG,YAAM;AAClBD,MAAAA,GAAG,CAAC,mBAAD,CAAH;AACA,UAAQE,QAAR,GAAqB,MAAKC,KAA1B,CAAQD,QAAR;;AACA,UAAI,CAAC,MAAKE,SAAV,EAAqB;AACnB;AACD;;AAED,UAAIF,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAAC,MAAKE,SAAL,CAAeC,KAAf,EAAD,CAAR;AACD;AACF,K;gGAES,YAAM;AACd,YAAKC,IAAL;;AACA,YAAKC,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UAA2CC,SAA3C,eAA2CA,SAA3C;AAEA,0BACE;AACE,QAAA,SAAS,EAAE,4BAAWD,OAAO,CAAChB,KAAnB,EAA0BiB,SAA1B,CADb;AAEE,QAAA,UAAU,EAAE,KAAKC,UAFnB;AAGE,QAAA,OAAO,EAAEL,OAHX;AAIE,QAAA,OAAO,EAAEC,OAJX;AAKE,QAAA,MAAM,EAAEC,MALV;AAME,QAAA,GAAG,EAAE,aAACI,CAAD;AAAA,iBAAQ,MAAI,CAACnB,KAAL,GAAamB,CAArB;AAAA;AANP,QADF;AAUD;;;EAvIwBC,kBAAMC,S;;;iCAApBxC,K,eACQ;AACjBoC,EAAAA,SAAS,EAAEK,sBAAUC,MADJ;AAEjBP,EAAAA,OAAO,EAAEM,sBAAUE,MAAV,CAAiBC,UAFT;AAGjBZ,EAAAA,OAAO,EAAES,sBAAUI,IAHF;AAIjB5C,EAAAA,QAAQ,EAAEwC,sBAAUI,IAJH;AAKjBzC,EAAAA,KAAK,EAAEqC,sBAAUC,MALA;AAMjBT,EAAAA,OAAO,EAAEQ,sBAAUI,IANF;AAOjBX,EAAAA,MAAM,EAAEO,sBAAUI;AAPD,C;;AAyIrB,IAAMC,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO,EAAP;AAAA,CAAf;;eAEe,wBAAWA,MAAX,EAAmB9C,KAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport debug from 'debug';\nimport classNames from 'classnames';\nimport { registerLineBreak } from './custom-elements';\nimport MathQuill from '@pie-framework/mathquill';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n\n if (MQ && MQ.registerEmbed) {\n registerLineBreak(MQ);\n }\n}\n\nconst log = debug('math-input:mq:input');\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport class Input extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n onChange: PropTypes.func,\n latex: PropTypes.string,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n };\n\n componentDidMount() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n\n this.mathField = MQ.MathField(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this),\n },\n });\n\n this.updateLatex();\n }\n\n componentDidUpdate() {\n this.updateLatex();\n }\n\n updateLatex() {\n if (!this.mathField) {\n return;\n }\n const { latex } = this.props;\n if (latex) {\n this.mathField.latex(latex);\n }\n }\n\n clear() {\n this.mathField.latex('');\n return '';\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 command(v) {\n log('command: ', v);\n if (Array.isArray(v)) {\n v.forEach((vv) => {\n this.mathField.cmd(vv);\n });\n } else {\n this.mathField.cmd(v);\n }\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n keystroke(v) {\n this.mathField.keystroke(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n write(v) {\n log('write: ', v);\n this.mathField.write(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n onInputEdit = () => {\n log('[onInputEdit] ...');\n const { onChange } = this.props;\n if (!this.mathField) {\n return;\n }\n\n if (onChange) {\n onChange(this.mathField.latex());\n }\n };\n\n refresh = () => {\n this.blur();\n this.focus();\n };\n\n onKeyPress = (event) => {\n const keys = Object.keys(this.mathField.__controller.options);\n\n if (keys.indexOf('ignoreNextMousedown') < 0) {\n // It seems like the controller has the above handler as an option\n // when all the right events are set and everything works fine\n // this seems to work in all cases\n this.refresh();\n }\n\n if (event.charCode === 13) {\n // if enter's pressed, we're going for a custom embedded element that'll\n // have a block display (empty div) - for a hacked line break using ccs\n // all because mathquill doesn't support a line break\n this.write('\\\\embed{newLine}[]');\n this.onInputEdit();\n }\n };\n\n shouldComponentUpdate(nextProps) {\n log('next: ', nextProps.latex);\n log('current: ', this.mathField.latex());\n return nextProps.latex !== this.mathField.latex();\n }\n\n render() {\n const { onClick, onFocus, onBlur, classes, className } = this.props;\n\n return (\n <span\n className={classNames(classes.input, className)}\n onKeyPress={this.onKeyPress}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={(r) => (this.input = r)}\n />\n );\n }\n}\n\nconst styles = () => ({});\n\nexport default withStyles(styles)(Input);\n"],"file":"input.js"}
package/lib/mq/static.js CHANGED
@@ -129,7 +129,7 @@ var Static = /*#__PURE__*/function (_React$Component) {
129
129
  try {
130
130
  field.__controller.cursor.insLeftOf(field.__controller.cursor.parent[-1].parent);
131
131
 
132
- field.el().dispatchEvent(new KeyboardEvent("keydown", {
132
+ field.el().dispatchEvent(new KeyboardEvent('keydown', {
133
133
  keyCode: 8
134
134
  }));
135
135
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mq/static.jsx"],"names":["MQ","window","MathQuill","getInterface","log","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","Static","e","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","mathField","innerFields","find","f","name","props","getFieldName","setInput","onSubFieldFocus","err","console","error","message","update","field","onSubFieldChange","regexMatch","latex","match","input","length","__controller","cursor","insLeftOf","parent","el","dispatchEvent","KeyboardEvent","keyCode","toString","Error","StaticMath","handlers","edit","onInputEdit","bind","parseLatex","blur","focus","nextProps","parsedLatex","stripped","newFieldCount","out","trim","Object","keys","warn","onBlur","className","onFocus","r","React","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,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AC,CAACqB,OAAvC,EAAgD,aAAhD,EAFU,CAGV;;AACAF,QAAAA,OAAO,CAACqC,IAAR,CAAaxD,CAAb;AACA,eAAO,KAAP;AACD;AACF;;;WA2BD,kBAAS;AAAA;;AACP,wBAA8B,KAAKc,KAAnC;AAAA,UAAQ2C,MAAR,eAAQA,MAAR;AAAA,UAAgBC,SAAhB,eAAgBA,SAAhB;AAEA,0BACE;AACE,QAAA,SAAS,EAAEA,SADb;AAEE,QAAA,OAAO,EAAE,KAAKC,OAFhB;AAGE,QAAA,MAAM,EAAEF,MAHV;AAIE,QAAA,GAAG,EAAE,aAAAG,CAAC;AAAA,iBAAK,MAAI,CAAChC,KAAL,GAAagC,CAAlB;AAAA;AAJR,QADF;AAQD;;;EAtIiCC,kBAAMC,S;;;iCAArB/D,M,eACA;AACjB2B,EAAAA,KAAK,EAAEqC,sBAAUlE,MAAV,CAAiBmE,UADP;AAEjBL,EAAAA,OAAO,EAAEI,sBAAUE,IAFF;AAGjBR,EAAAA,MAAM,EAAEM,sBAAUE,IAHD;AAIjBP,EAAAA,SAAS,EAAEK,sBAAUlE,MAJJ;AAKjBkB,EAAAA,YAAY,EAAEgD,sBAAUE,IALP;AAMjBzC,EAAAA,gBAAgB,EAAEuC,sBAAUE,IANX;AAOjBhD,EAAAA,eAAe,EAAE8C,sBAAUE,IAPV;AAQjBjD,EAAAA,QAAQ,EAAE+C,sBAAUE;AARH,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../index';\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\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 componentDidMount() {\n this.update();\n updateSpans();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\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.input && 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 console.error(e.toString());\n }\n } else {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n }\n\n update() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n // this.input.innerHTML = this.props.latex;\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.input, {\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 (\n <span\n className={className}\n onFocus={this.onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n"],"file":"static.js"}
1
+ {"version":3,"sources":["../../src/mq/static.jsx"],"names":["MQ","window","MathQuill","getInterface","log","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","Static","e","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","mathField","innerFields","find","f","name","props","getFieldName","setInput","onSubFieldFocus","err","console","error","message","update","field","onSubFieldChange","regexMatch","latex","match","input","length","__controller","cursor","insLeftOf","parent","el","dispatchEvent","KeyboardEvent","keyCode","toString","Error","StaticMath","handlers","edit","onInputEdit","bind","parseLatex","blur","focus","nextProps","parsedLatex","stripped","newFieldCount","out","trim","Object","keys","warn","onBlur","className","onFocus","r","React","Component","PropTypes","isRequired","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,s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2D,GAA7B,CAAH;AACA,eAAOA,GAAP;AACD,OAXD,CAWE,OAAOpD,CAAP,EAAU;AACV;AACAmB,QAAAA,OAAO,CAACqC,IAAR,CAAa,sBAAb,EAAqCxD,CAAC,CAACqB,OAAvC,EAAgD,aAAhD,EAFU,CAGV;;AACAF,QAAAA,OAAO,CAACqC,IAAR,CAAaxD,CAAb;AACA,eAAO,KAAP;AACD;AACF;;;WA2BD,kBAAS;AAAA;;AACP,wBAA8B,KAAKc,KAAnC;AAAA,UAAQ2C,MAAR,eAAQA,MAAR;AAAA,UAAgBC,SAAhB,eAAgBA,SAAhB;AAEA,0BAAO;AAAM,QAAA,SAAS,EAAEA,SAAjB;AAA4B,QAAA,OAAO,EAAE,KAAKC,OAA1C;AAAmD,QAAA,MAAM,EAAEF,MAA3D;AAAmE,QAAA,GAAG,EAAE,aAACG,CAAD;AAAA,iBAAQ,MAAI,CAAChC,KAAL,GAAagC,CAArB;AAAA;AAAxE,QAAP;AACD;;;EA/HiCC,kBAAMC,S;;;iCAArB/D,M,eACA;AACjB2B,EAAAA,KAAK,EAAEqC,sBAAUlE,MAAV,CAAiBmE,UADP;AAEjBL,EAAAA,OAAO,EAAEI,sBAAUE,IAFF;AAGjBR,EAAAA,MAAM,EAAEM,sBAAUE,IAHD;AAIjBP,EAAAA,SAAS,EAAEK,sBAAUlE,MAJJ;AAKjBkB,EAAAA,YAAY,EAAEgD,sBAAUE,IALP;AAMjBzC,EAAAA,gBAAgB,EAAEuC,sBAAUE,IANX;AAOjBhD,EAAAA,eAAe,EAAE8C,sBAAUE,IAPV;AAQjBjD,EAAAA,QAAQ,EAAE+C,sBAAUE;AARH,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../index';\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\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 componentDidMount() {\n this.update();\n updateSpans();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\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.input && 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 console.error(e.toString());\n }\n } else {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n }\n\n update() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n // this.input.innerHTML = this.props.latex;\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.input, {\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={(r) => (this.input = r)} />;\n }\n}\n"],"file":"static.js"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "6.8.4-next.0+15cb0236",
6
+ "version": "6.8.5-next.0+1fa37b5f",
7
7
  "main": "lib/index.js",
8
8
  "module": "src/index.jsx",
9
9
  "dependencies": {
@@ -22,5 +22,5 @@
22
22
  "react-dom": "^16.9.0"
23
23
  },
24
24
  "scripts": {},
25
- "gitHead": "15cb0236ce51d8ffd9144c20fe1b7630c2ddb4c6"
25
+ "gitHead": "1fa37b5fc8de14d2836e884e11de6d84eb5fbd27"
26
26
  }
@@ -4,7 +4,7 @@ import { keysForGrade, normalizeAdditionalKeys } from './keys/grades';
4
4
  import { extendKeySet } from './keys/utils';
5
5
  import Keypad from './keypad';
6
6
 
7
- const toOldModel = d => {
7
+ const toOldModel = (d) => {
8
8
  if (d.command) {
9
9
  return { value: d.command, type: 'command' };
10
10
  } else if (d.write) {
@@ -22,16 +22,16 @@ export default class HorizontalKeypad extends React.Component {
22
22
  onClick: PropTypes.func.isRequired,
23
23
  onFocus: PropTypes.func,
24
24
  noDecimal: PropTypes.bool,
25
- additionalKeys: PropTypes.array
25
+ additionalKeys: PropTypes.array,
26
26
  };
27
27
 
28
28
  static defaultProps = {
29
29
  mode: 'scientific',
30
30
  noDecimal: false,
31
- additionalKeys: []
31
+ additionalKeys: [],
32
32
  };
33
33
 
34
- keypadPress = data => {
34
+ keypadPress = (data) => {
35
35
  const { onClick } = this.props;
36
36
 
37
37
  onClick(toOldModel(data));
package/src/index.jsx CHANGED
@@ -1,17 +1,17 @@
1
1
  import { keysForGrade } from './keys/grades';
2
2
 
3
- const addLeftBracket = s => (s.indexOf('\\(') === 0 ? s : `\\(${s}`);
4
- const addRightBracket = s => (s.indexOf('\\)') === s.length - 2 ? s : `${s}\\)`);
5
- const rmLeftBracket = s => (s.indexOf('\\(') === 0 ? s.substring(2) : s);
6
- const rmRightBracket = s => (s.indexOf('\\)') === s.length - 2 ? s.substring(0, s.length - 2) : s);
3
+ const addLeftBracket = (s) => (s.indexOf('\\(') === 0 ? s : `\\(${s}`);
4
+ const addRightBracket = (s) => (s.indexOf('\\)') === s.length - 2 ? s : `${s}\\)`);
5
+ const rmLeftBracket = (s) => (s.indexOf('\\(') === 0 ? s.substring(2) : s);
6
+ const rmRightBracket = (s) => (s.indexOf('\\)') === s.length - 2 ? s.substring(0, s.length - 2) : s);
7
7
 
8
- const addBrackets = s => addRightBracket(addLeftBracket(s));
9
- const removeBrackets = s => rmRightBracket(rmLeftBracket(s));
8
+ const addBrackets = (s) => addRightBracket(addLeftBracket(s));
9
+ const removeBrackets = (s) => rmRightBracket(rmLeftBracket(s));
10
10
 
11
11
  // increase the font of parallel notation
12
12
  const updateSpans = () => {
13
13
  const spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));
14
- (spans || []).forEach(span => {
14
+ (spans || []).forEach((span) => {
15
15
  if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {
16
16
  span.style.fontSize = '32px';
17
17
  }
@@ -14,27 +14,27 @@ import _ from 'lodash';
14
14
 
15
15
  const log = debug('pie-lib:math-inline:keypad');
16
16
 
17
- const LatexButton = withStyles(theme => ({
17
+ const LatexButton = withStyles((theme) => ({
18
18
  root: {
19
19
  textTransform: 'none',
20
20
  padding: 0,
21
21
  margin: 0,
22
- fontSize: '110% !important'
22
+ fontSize: '110% !important',
23
23
  },
24
24
  latexButton: {
25
25
  pointerEvents: 'none',
26
26
  textTransform: 'none !important',
27
27
  '& .mq-scaled.mq-sqrt-prefix': {
28
- transform: 'scale(1, 0.9) !important'
28
+ transform: 'scale(1, 0.9) !important',
29
29
  },
30
30
  '& .mq-sup-only .mq-sup': {
31
- marginBottom: '0.9px !important'
31
+ marginBottom: '0.9px !important',
32
32
  },
33
33
  '& .mq-empty': {
34
- backgroundColor: `${fade(theme.palette.secondary.main, 0.4)} !important`
34
+ backgroundColor: `${fade(theme.palette.secondary.main, 0.4)} !important`,
35
35
  },
36
36
  '& .mq-overline .mq-overline-inner': {
37
- borderTop: '2px solid black'
37
+ borderTop: '2px solid black',
38
38
  },
39
39
  '& .mq-overarrow': {
40
40
  width: '30px',
@@ -45,107 +45,99 @@ const LatexButton = withStyles(theme => ({
45
45
  '&.mq-arrow-both': {
46
46
  top: '0px !important',
47
47
  '& *': {
48
- lineHeight: '1 !important'
48
+ lineHeight: '1 !important',
49
49
  },
50
50
  '&:before': {
51
51
  fontSize: '80%',
52
52
  left: 'calc(-13%)',
53
- top: '-0.31em'
53
+ top: '-0.31em',
54
54
  },
55
55
  '&:after': {
56
56
  fontSize: '80% !important',
57
57
  right: 'calc(-13%) !important',
58
- top: '-1.5em'
58
+ top: '-1.5em',
59
59
  },
60
60
  '&.mq-empty:before': {
61
61
  fontSize: '80%',
62
62
  left: 'calc(-13%)',
63
- top: '-0.26em'
63
+ top: '-0.26em',
64
64
  },
65
65
  '&.mq-empty:after': {
66
66
  fontSize: '80%',
67
67
  right: 'calc(-13%)',
68
- top: '-0.26em'
68
+ top: '-0.26em',
69
69
  },
70
70
  '&.mq-empty': {
71
- minHeight: '1.4em'
72
- }
71
+ minHeight: '1.4em',
72
+ },
73
73
  },
74
74
  '&.mq-arrow-right:before': {
75
75
  fontSize: '80%',
76
76
  right: 'calc(-13%)',
77
- top: '-0.26em'
77
+ top: '-0.26em',
78
78
  },
79
79
  '& .mq-overarrow-inner': {
80
- border: 'none !important'
80
+ border: 'none !important',
81
81
  },
82
82
  '& .mq-overarrow-inner .mq-overarrow-inner-right': {
83
- display: 'none !important'
84
- }
83
+ display: 'none !important',
84
+ },
85
85
  },
86
86
  '& .mq-root-block': {
87
- padding: '5px'
87
+ padding: '5px',
88
88
  },
89
89
  '& .mq-overarrow.mq-arrow-both.mq-empty:after': {
90
90
  right: '-6px',
91
91
  fontSize: '80% !important',
92
- top: '-3px'
92
+ top: '-3px',
93
93
  },
94
94
  '& .mq-overarrow.mq-arrow-right.mq-empty:before': {
95
95
  right: '-5px',
96
96
  fontSize: '80% !important',
97
- top: '-3px'
97
+ top: '-3px',
98
98
  },
99
99
  '& .mq-overarrow.mq-arrow-both.mq-empty:before': {
100
100
  left: '-6px',
101
101
  fontSize: '80% !important',
102
- top: '-3px'
102
+ top: '-3px',
103
103
  },
104
104
  '& .mq-longdiv-inner': {
105
105
  borderTop: '1px solid !important',
106
- paddingTop: '1.5px !important'
106
+ paddingTop: '1.5px !important',
107
107
  },
108
108
  '& .mq-parallelogram': {
109
- lineHeight: 0.85
109
+ lineHeight: 0.85,
110
110
  },
111
111
  '& .mq-overarc': {
112
112
  borderTop: '2px solid black !important',
113
113
  '& .mq-overline-inner': {
114
114
  borderTop: 'none !important',
115
- paddingTop: '0 !important'
116
- }
117
- }
115
+ paddingTop: '0 !important',
116
+ },
117
+ },
118
118
  },
119
119
  parallelButton: {
120
- fontStyle: 'italic'
120
+ fontStyle: 'italic',
121
121
  },
122
122
  leftRightArrowButton: {
123
123
  '& .mq-overarrow.mq-arrow-both': {
124
124
  '& .mq-overline-inner': {
125
125
  borderTop: 'none !important',
126
- paddingTop: '0 !important'
126
+ paddingTop: '0 !important',
127
127
  },
128
128
  '&:after': {
129
129
  position: 'absolute !important',
130
- top: '0px !important'
131
- }
132
- }
133
- }
134
- }))(props => {
130
+ top: '0px !important',
131
+ },
132
+ },
133
+ },
134
+ }))((props) => {
135
135
  let buttonClass;
136
136
 
137
137
  if (props.latex === '\\parallel') {
138
- buttonClass = classNames(
139
- props.classes.latexButton,
140
- props.mqClassName,
141
- props.classes.parallelButton
142
- );
138
+ buttonClass = classNames(props.classes.latexButton, props.mqClassName, props.classes.parallelButton);
143
139
  } else if (props.latex === '\\overleftrightarrow{\\overline{}}') {
144
- buttonClass = classNames(
145
- props.classes.latexButton,
146
- props.mqClassName,
147
- props.classes.leftRightArrowButton
148
- );
140
+ buttonClass = classNames(props.classes.latexButton, props.mqClassName, props.classes.leftRightArrowButton);
149
141
  } else {
150
142
  buttonClass = classNames(props.classes.latexButton, props.mqClassName);
151
143
  }
@@ -170,12 +162,12 @@ const LatexButton = withStyles(theme => ({
170
162
  );
171
163
  });
172
164
 
173
- const createCustomLayout = layoutObj => {
165
+ const createCustomLayout = (layoutObj) => {
174
166
  if (layoutObj) {
175
167
  return {
176
168
  gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,
177
169
  gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,
178
- gridAutoFlow: 'initial'
170
+ gridAutoFlow: 'initial',
179
171
  };
180
172
  }
181
173
 
@@ -192,14 +184,14 @@ export class KeyPad extends React.Component {
192
184
  onPress: PropTypes.func.isRequired,
193
185
  onFocus: PropTypes.func,
194
186
  noDecimal: PropTypes.bool,
195
- mode: PropTypes.string
187
+ mode: PropTypes.string,
196
188
  };
197
189
  static defaultProps = {
198
190
  baseSet: baseSet,
199
- noDecimal: false
191
+ noDecimal: false,
200
192
  };
201
193
 
202
- buttonClick = key => {
194
+ buttonClick = (key) => {
203
195
  log('[buttonClick]', key);
204
196
  const { onPress } = this.props;
205
197
  onPress(key);
@@ -210,13 +202,10 @@ export class KeyPad extends React.Component {
210
202
  return _.flatten(transposed);
211
203
  };
212
204
 
213
- keyIsNotAllowed = key => {
205
+ keyIsNotAllowed = (key) => {
214
206
  const { noDecimal } = this.props;
215
207
 
216
- if (
217
- ((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) &&
218
- noDecimal
219
- ) {
208
+ if (((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal) {
220
209
  return true;
221
210
  }
222
211
 
@@ -224,24 +213,9 @@ export class KeyPad extends React.Component {
224
213
  };
225
214
 
226
215
  render() {
227
- const {
228
- classes,
229
- className,
230
- baseSet,
231
- additionalKeys,
232
- layoutForKeyPad,
233
- onFocus,
234
- mode
235
- } = this.props;
216
+ const { classes, className, baseSet, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;
236
217
 
237
- const noBaseSet = [
238
- 'non-negative-integers',
239
- 'integers',
240
- 'decimals',
241
- 'fractions',
242
- 'item-authoring',
243
- 'language'
244
- ];
218
+ const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];
245
219
 
246
220
  const keysWithoutBaseSet = noBaseSet.includes(mode);
247
221
  const allKeys = keysWithoutBaseSet
@@ -250,16 +224,11 @@ export class KeyPad extends React.Component {
250
224
 
251
225
  const shift = allKeys.length % 5 ? 1 : 0;
252
226
  const style = {
253
- gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) +
254
- shift}, minmax(min-content, 150px))`,
255
- ...createCustomLayout(layoutForKeyPad)
227
+ gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`,
228
+ ...createCustomLayout(layoutForKeyPad),
256
229
  };
257
230
  return (
258
- <div
259
- className={classNames(classes.keys, className, classes[mode])}
260
- style={style}
261
- onFocus={onFocus}
262
- >
231
+ <div className={classNames(classes.keys, className, classes[mode])} style={style} onFocus={onFocus}>
263
232
  {allKeys.map((k, index) => {
264
233
  const onClick = this.buttonClick.bind(this, k);
265
234
 
@@ -274,12 +243,12 @@ export class KeyPad extends React.Component {
274
243
  !keysWithoutBaseSet && classes[k.category],
275
244
  classes[k.extraClass],
276
245
  k.label === ',' && classes.comma,
277
- k.label === '.' && classes.dot
246
+ k.label === '.' && classes.dot,
278
247
  ),
279
248
  disabled: this.keyIsNotAllowed(k),
280
249
  key: `${k.label || k.latex || k.command}-${index}`,
281
250
  ...(k.actions || {}),
282
- ...(k.extraProps || {})
251
+ ...(k.extraProps || {}),
283
252
  };
284
253
 
285
254
  if (k.latex) {
@@ -303,20 +272,20 @@ export class KeyPad extends React.Component {
303
272
  }
304
273
  }
305
274
 
306
- const styles = theme => ({
275
+ const styles = (theme) => ({
307
276
  keys: {
308
277
  '& *': {
309
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
278
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
310
279
  },
311
280
  width: '100%',
312
281
  display: 'grid',
313
282
  gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
314
283
  gridRowGap: '0px',
315
284
  gridColumnGap: '0px',
316
- gridAutoFlow: 'column'
285
+ gridAutoFlow: 'column',
317
286
  },
318
287
  character: {
319
- textTransform: 'initial !important'
288
+ textTransform: 'initial !important',
320
289
  },
321
290
  holder: {
322
291
  position: 'relative',
@@ -324,49 +293,49 @@ const styles = theme => ({
324
293
  height: '100%',
325
294
  backgroundColor: '#cef',
326
295
  borderRadius: 0,
327
- padding: `${theme.spacing.unit}px 0 ${theme.spacing.unit}px 0`
296
+ padding: `${theme.spacing.unit}px 0 ${theme.spacing.unit}px 0`,
328
297
  },
329
298
  labelButton: {
330
299
  minWidth: 'auto',
331
300
  fontSize: '140% !important',
332
301
  backgroundColor: lighten(theme.palette.primary.light, 0.5),
333
302
  '&:hover': {
334
- backgroundColor: lighten(theme.palette.primary.light, 0.7)
303
+ backgroundColor: lighten(theme.palette.primary.light, 0.7),
335
304
  },
336
- borderRadius: 0
305
+ borderRadius: 0,
337
306
  },
338
307
  latexButton: {
339
308
  minWidth: 'auto',
340
309
  borderRadius: 0,
341
310
  backgroundColor: lighten(theme.palette.primary.light, 0.5),
342
311
  '&:hover': {
343
- backgroundColor: lighten(theme.palette.primary.light, 0.7)
344
- }
312
+ backgroundColor: lighten(theme.palette.primary.light, 0.7),
313
+ },
345
314
  },
346
315
  base: {},
347
316
  operators: {
348
317
  backgroundColor: lighten(theme.palette.secondary.light, 0.5),
349
318
  '&:hover': {
350
- backgroundColor: lighten(theme.palette.secondary.light, 0.7)
351
- }
319
+ backgroundColor: lighten(theme.palette.secondary.light, 0.7),
320
+ },
352
321
  },
353
322
  comparison: {
354
323
  backgroundColor: lighten(green[500], 0.5),
355
324
  '&:hover': {
356
- backgroundColor: lighten(green[500], 0.7)
357
- }
325
+ backgroundColor: lighten(green[500], 0.7),
326
+ },
358
327
  },
359
328
  comma: {
360
329
  fontSize: '200% !important',
361
- lineHeight: '100%'
330
+ lineHeight: '100%',
362
331
  },
363
332
  dot: {
364
333
  fontSize: '200% !important',
365
- lineHeight: '100%'
334
+ lineHeight: '100%',
366
335
  },
367
336
  icon: {
368
- height: '30px'
369
- }
337
+ height: '30px',
338
+ },
370
339
  });
371
340
 
372
341
  export default withStyles(styles)(KeyPad);
@@ -6,7 +6,7 @@ import * as _ from 'lodash';
6
6
  * Expects an array of rows.
7
7
  * @param {} keys
8
8
  */
9
- export const sortKeys = keys => {
9
+ export const sortKeys = (keys) => {
10
10
  // add any missing rows
11
11
  _.times(5 - keys.length, () => {
12
12
  keys.push([]);
@@ -5,28 +5,28 @@ const set = mkSet('operators');
5
5
 
6
6
  export const equals = set({
7
7
  write: '=',
8
- label: '='
8
+ label: '=',
9
9
  });
10
10
 
11
11
  export const plus = set({
12
12
  write: '+',
13
- label: '+'
13
+ label: '+',
14
14
  });
15
15
 
16
16
  export const minus = set({
17
17
  write: '−',
18
- label: '−'
18
+ label: '−',
19
19
  });
20
20
 
21
21
  export const divide = set({
22
22
  name: 'divide',
23
23
  label: DIVIDE,
24
24
  command: '\\divide',
25
- otherNotation: '\\div'
25
+ otherNotation: '\\div',
26
26
  });
27
27
 
28
28
  export const multiply = set({
29
29
  name: 'multiply',
30
30
  label: MULTIPLY,
31
- command: '\\times'
31
+ command: '\\times',
32
32
  });
@@ -1,27 +1,27 @@
1
- const set = o => ({ ...o, category: 'comparison' });
1
+ const set = (o) => ({ ...o, category: 'comparison' });
2
2
 
3
3
  export const lessThan = set({
4
4
  name: 'Less than',
5
5
  latex: '<',
6
- command: '\\lt'
6
+ command: '\\lt',
7
7
  });
8
8
 
9
9
  export const greaterThan = set({
10
10
  name: 'Greater than',
11
11
  latex: '>',
12
- command: '\\gt'
12
+ command: '\\gt',
13
13
  });
14
14
 
15
15
  export const lessThanEqual = set({
16
16
  name: 'Less than or equal',
17
17
  latex: '\\le',
18
18
  symbol: '<=',
19
- command: '\\le'
19
+ command: '\\le',
20
20
  });
21
21
 
22
22
  export const greaterThanEqual = set({
23
23
  name: 'Greater than or equal',
24
24
  symbol: '>=',
25
25
  command: '\\ge',
26
- latex: '\\ge'
26
+ latex: '\\ge',
27
27
  });
@@ -7,7 +7,7 @@ export const pi = set({
7
7
  label: 'π',
8
8
  latex: '\\pi',
9
9
  command: '\\pi',
10
- category: 'constants'
10
+ category: 'constants',
11
11
  });
12
12
 
13
13
  export const eulers = set({
@@ -15,7 +15,7 @@ export const eulers = set({
15
15
  label: 'e',
16
16
  latex: 'e',
17
17
  command: 'e',
18
- category: 'constants'
18
+ category: 'constants',
19
19
  });
20
20
 
21
21
  export const infinity = set({
@@ -23,7 +23,7 @@ export const infinity = set({
23
23
  label: '\\infty',
24
24
  latex: '\\infty',
25
25
  command: '\\infty',
26
- category: 'constants'
26
+ category: 'constants',
27
27
  });
28
28
 
29
29
  export const halfInfinity = set({
@@ -31,5 +31,5 @@ export const halfInfinity = set({
31
31
  label: '\\propto',
32
32
  latex: '\\propto',
33
33
  command: '\\propto',
34
- category: 'constants'
34
+ category: 'constants',
35
35
  });