@pie-lib/math-input 6.11.4 → 6.12.0-beta.1
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 +54 -187
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/horizontal-keypad.js +9 -3
- package/lib/horizontal-keypad.js.map +1 -1
- package/lib/index.js +10 -14
- package/lib/index.js.map +1 -1
- package/lib/keypad/index.js +95 -24
- package/lib/keypad/index.js.map +1 -1
- package/lib/keys/geometry.js +4 -2
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/grades.js +12 -0
- package/lib/keys/grades.js.map +1 -1
- package/lib/keys/log.js +1 -1
- package/lib/keys/log.js.map +1 -1
- package/lib/mq/common-mq-styles.js +110 -0
- package/lib/mq/common-mq-styles.js.map +1 -0
- package/lib/mq/index.js +8 -0
- package/lib/mq/index.js.map +1 -1
- package/lib/mq/input.js +12 -10
- package/lib/mq/input.js.map +1 -1
- package/lib/mq/static.js +198 -75
- package/lib/mq/static.js.map +1 -1
- package/lib/updateSpans.js +23 -0
- package/lib/updateSpans.js.map +1 -0
- package/package.json +5 -2
- package/src/__tests__/__snapshots__/math-input-test.jsx.snap +152 -0
- package/src/__tests__/math-input-test.jsx +85 -0
- package/src/horizontal-keypad.jsx +14 -1
- package/src/index.jsx +1 -10
- package/src/keypad/__tests__/__snapshots__/index.test.jsx.snap +193 -0
- package/src/keypad/__tests__/index.test.jsx +24 -0
- package/src/keypad/__tests__/keys-layout.test.js +15 -0
- package/src/keypad/index.jsx +99 -15
- package/src/keys/__tests__/utils.test.js +57 -0
- package/src/keys/geometry.js +6 -2
- package/src/keys/grades.js +11 -0
- package/src/keys/log.js +1 -1
- package/src/mq/__tests__/__snapshots__/input.test.jsx.snap +9 -0
- package/src/mq/__tests__/input.test.jsx +92 -0
- package/src/mq/__tests__/static.test.jsx +57 -0
- package/src/mq/common-mq-styles.js +105 -0
- package/src/mq/index.js +2 -1
- package/src/mq/input.jsx +22 -9
- package/src/mq/static.jsx +142 -13
- package/src/updateSpans.js +15 -0
- package/README.md +0 -27
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","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,GAAG,IAAzB;;AAEA,SAASC,WAAT,GAAkC;AAAA,MAAbC,MAAa,uEAAJ,EAAI;AAChC,SAAOA,MAAM,CAACC,OAAP,CAAeH,gBAAf,EAAiC,EAAjC,CAAP;AACD;AAED;AACA;AACA;;;IACqBI,M;;;;;;;;;;;;;;;gGAuGT,UAACC,CAAD,EAAO;AACf,UAAI;AACF,YAAIC,SAAS,GAAGD,CAAC,CAACE,MAAF,CAASC,aAAT,CAAuBC,WAAvC;AACA,YAAIC,EAAE,GAAGC,QAAQ,CAACL,SAAS,CAACM,YAAV,CAAuB,oBAAvB,CAAD,EAA+C,EAA/C,C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aAACG,CAAD;AAAA,iBAAQ,MAAI,CAAChC,KAAL,GAAagC,CAArB;AAAA;AAAxE,QAAP;AACD;;;EApIiCC,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;iCADAlE,M,kBAYG;AACpBgB,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 '../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 static defaultProps = {\n getFieldName: () => {},\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 // 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\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"}
|
|
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,CA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,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateSpans = void 0;
|
|
7
|
+
|
|
8
|
+
// increase the font of parallel notation
|
|
9
|
+
var updateSpans = function updateSpans() {
|
|
10
|
+
var spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));
|
|
11
|
+
(spans || []).forEach(function (span) {
|
|
12
|
+
if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {
|
|
13
|
+
span.style.fontSize = '32px';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if ((span.innerText === '′' || span.innerText === '′′') && !span.hasAttribute('data-prime')) {
|
|
17
|
+
span.setAttribute('data-prime', 'true');
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.updateSpans = updateSpans;
|
|
23
|
+
//# sourceMappingURL=updateSpans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/updateSpans.js"],"names":["updateSpans","spans","Array","from","document","querySelectorAll","forEach","span","innerText","className","style","fontSize","hasAttribute","setAttribute"],"mappings":";;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxB,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAWC,QAAQ,CAACC,gBAAT,CAA0B,4BAA1B,CAAX,CAAd;AACA,GAACJ,KAAK,IAAI,EAAV,EAAcK,OAAd,CAAsB,UAACC,IAAD,EAAU;AAC9B,QAAIA,IAAI,IAAIA,IAAI,CAACC,SAAL,KAAmB,GAA3B,IAAkCD,IAAI,CAACE,SAAL,KAAmB,mBAAzD,EAA8E;AAC5EF,MAAAA,IAAI,CAACG,KAAL,CAAWC,QAAX,GAAsB,MAAtB;AACD;;AAED,QAAI,CAACJ,IAAI,CAACC,SAAL,KAAmB,GAAnB,IAA0BD,IAAI,CAACC,SAAL,KAAmB,IAA9C,KAAuD,CAACD,IAAI,CAACK,YAAL,CAAkB,YAAlB,CAA5D,EAA6F;AAC3FL,MAAAA,IAAI,CAACM,YAAL,CAAkB,YAAlB,EAAgC,MAAhC;AACD;AACF,GARD;AASD,CAXD","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"],"file":"updateSpans.js"}
|
package/package.json
CHANGED
|
@@ -3,15 +3,18 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.
|
|
6
|
+
"version": "6.12.0-beta.1",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"module": "src/index.jsx",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.8.3",
|
|
11
11
|
"@material-ui/icons": "^3.0.2",
|
|
12
12
|
"@pie-framework/mathquill": "^1.1.3",
|
|
13
|
+
"@pie-lib/editable-html": "latest",
|
|
14
|
+
"classnames": "^2.2.6",
|
|
13
15
|
"debug": "^4.1.1",
|
|
14
16
|
"lodash": "^4.17.11",
|
|
17
|
+
"prop-types": "^15.7.2",
|
|
15
18
|
"react-portal": "^4.2.0"
|
|
16
19
|
},
|
|
17
20
|
"peerDependencies": {
|
|
@@ -22,5 +25,5 @@
|
|
|
22
25
|
"react-dom": "^16.9.0"
|
|
23
26
|
},
|
|
24
27
|
"scripts": {},
|
|
25
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453"
|
|
26
29
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`MathInput snapshot renders 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="className"
|
|
6
|
+
>
|
|
7
|
+
<WithStyles(Input)
|
|
8
|
+
innerRef={[Function]}
|
|
9
|
+
onBlur={[Function]}
|
|
10
|
+
onChange={[Function]}
|
|
11
|
+
onFocus={[Function]}
|
|
12
|
+
/>
|
|
13
|
+
<div>
|
|
14
|
+
<WithStyles(KeyPad)
|
|
15
|
+
additionalKeys={Array []}
|
|
16
|
+
baseSet={
|
|
17
|
+
Array [
|
|
18
|
+
Array [
|
|
19
|
+
Object {
|
|
20
|
+
"category": "digit",
|
|
21
|
+
"label": "7",
|
|
22
|
+
"name": "seven",
|
|
23
|
+
"write": "7",
|
|
24
|
+
},
|
|
25
|
+
Object {
|
|
26
|
+
"category": "digit",
|
|
27
|
+
"label": "8",
|
|
28
|
+
"name": "eight",
|
|
29
|
+
"write": "8",
|
|
30
|
+
},
|
|
31
|
+
Object {
|
|
32
|
+
"category": "digit",
|
|
33
|
+
"label": "9",
|
|
34
|
+
"name": "nine",
|
|
35
|
+
"write": "9",
|
|
36
|
+
},
|
|
37
|
+
Object {
|
|
38
|
+
"category": "operators",
|
|
39
|
+
"command": "\\\\divide",
|
|
40
|
+
"label": "÷",
|
|
41
|
+
"name": "divide",
|
|
42
|
+
"otherNotation": "\\\\div",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
Array [
|
|
46
|
+
Object {
|
|
47
|
+
"category": "digit",
|
|
48
|
+
"label": "4",
|
|
49
|
+
"name": "four",
|
|
50
|
+
"write": "4",
|
|
51
|
+
},
|
|
52
|
+
Object {
|
|
53
|
+
"category": "digit",
|
|
54
|
+
"label": "5",
|
|
55
|
+
"name": "five",
|
|
56
|
+
"write": "5",
|
|
57
|
+
},
|
|
58
|
+
Object {
|
|
59
|
+
"category": "digit",
|
|
60
|
+
"label": "6",
|
|
61
|
+
"name": "six",
|
|
62
|
+
"write": "6",
|
|
63
|
+
},
|
|
64
|
+
Object {
|
|
65
|
+
"category": "operators",
|
|
66
|
+
"command": "\\\\times",
|
|
67
|
+
"label": "×",
|
|
68
|
+
"name": "multiply",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
Array [
|
|
72
|
+
Object {
|
|
73
|
+
"category": "digit",
|
|
74
|
+
"label": "1",
|
|
75
|
+
"name": "one",
|
|
76
|
+
"write": "1",
|
|
77
|
+
},
|
|
78
|
+
Object {
|
|
79
|
+
"category": "digit",
|
|
80
|
+
"label": "2",
|
|
81
|
+
"name": "two",
|
|
82
|
+
"write": "2",
|
|
83
|
+
},
|
|
84
|
+
Object {
|
|
85
|
+
"category": "digit",
|
|
86
|
+
"label": "3",
|
|
87
|
+
"name": "three",
|
|
88
|
+
"write": "3",
|
|
89
|
+
},
|
|
90
|
+
Object {
|
|
91
|
+
"category": "operators",
|
|
92
|
+
"label": "−",
|
|
93
|
+
"write": "−",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
Array [
|
|
97
|
+
Object {
|
|
98
|
+
"category": "digit",
|
|
99
|
+
"label": "0",
|
|
100
|
+
"name": "zero",
|
|
101
|
+
"write": "0",
|
|
102
|
+
},
|
|
103
|
+
Object {
|
|
104
|
+
"category": "digit",
|
|
105
|
+
"label": ".",
|
|
106
|
+
"name": "decimal-point",
|
|
107
|
+
"write": ".",
|
|
108
|
+
},
|
|
109
|
+
Object {
|
|
110
|
+
"category": "digit",
|
|
111
|
+
"label": ",",
|
|
112
|
+
"name": "comma",
|
|
113
|
+
"write": ",",
|
|
114
|
+
},
|
|
115
|
+
Object {
|
|
116
|
+
"category": "operators",
|
|
117
|
+
"label": "+",
|
|
118
|
+
"write": "+",
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
Array [
|
|
122
|
+
Object {
|
|
123
|
+
"ariaLabel": "Move cursor left",
|
|
124
|
+
"category": "navigation",
|
|
125
|
+
"keystroke": "Left",
|
|
126
|
+
"label": "◀",
|
|
127
|
+
},
|
|
128
|
+
Object {
|
|
129
|
+
"ariaLabel": "Move cursor right",
|
|
130
|
+
"category": "navigation",
|
|
131
|
+
"keystroke": "Right",
|
|
132
|
+
"label": "▶",
|
|
133
|
+
},
|
|
134
|
+
Object {
|
|
135
|
+
"ariaLabel": "Delete",
|
|
136
|
+
"category": "edit",
|
|
137
|
+
"keystroke": "Backspace",
|
|
138
|
+
"label": "⌫",
|
|
139
|
+
},
|
|
140
|
+
Object {
|
|
141
|
+
"category": "operators",
|
|
142
|
+
"label": "=",
|
|
143
|
+
"write": "=",
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
onPress={[Function]}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
`;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { MathInput } from '../math-input';
|
|
4
|
+
|
|
5
|
+
describe('MathInput', () => {
|
|
6
|
+
let w;
|
|
7
|
+
let onChange;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
onChange = jest.fn();
|
|
11
|
+
});
|
|
12
|
+
const wrapper = (extras) => {
|
|
13
|
+
const defaults = {
|
|
14
|
+
classes: {},
|
|
15
|
+
className: 'className',
|
|
16
|
+
onChange,
|
|
17
|
+
};
|
|
18
|
+
const props = { ...defaults, ...extras };
|
|
19
|
+
return shallow(<MathInput {...props} />);
|
|
20
|
+
};
|
|
21
|
+
describe('snapshot', () => {
|
|
22
|
+
it('renders', () => {
|
|
23
|
+
w = wrapper();
|
|
24
|
+
expect(w).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('logic', () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
w = wrapper();
|
|
30
|
+
w.instance().input = {
|
|
31
|
+
write: jest.fn(),
|
|
32
|
+
command: jest.fn(),
|
|
33
|
+
keystroke: jest.fn(),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
describe('keypadPress', () => {
|
|
37
|
+
it('calls input.write for latex', () => {
|
|
38
|
+
w.instance().keypadPress({ latex: 'latex' });
|
|
39
|
+
expect(w.instance().input.write).toHaveBeenLastCalledWith('latex');
|
|
40
|
+
});
|
|
41
|
+
it('calls input.write for write', () => {
|
|
42
|
+
w.instance().keypadPress({ write: 'write' });
|
|
43
|
+
expect(w.instance().input.write).toHaveBeenLastCalledWith('write');
|
|
44
|
+
});
|
|
45
|
+
it('calls input.command for command', () => {
|
|
46
|
+
w.instance().keypadPress({ command: 'cmd' });
|
|
47
|
+
expect(w.instance().input.command).toHaveBeenLastCalledWith('cmd');
|
|
48
|
+
});
|
|
49
|
+
it('calls input.keystroke for keystroke', () => {
|
|
50
|
+
w.instance().keypadPress({ keystroke: 'k' });
|
|
51
|
+
expect(w.instance().input.keystroke).toHaveBeenLastCalledWith('k');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('changeLatex', () => {
|
|
57
|
+
it('calls onChange', () => {
|
|
58
|
+
w = wrapper();
|
|
59
|
+
w.instance().changeLatex('new-latex');
|
|
60
|
+
expect(onChange).toHaveBeenCalledWith('new-latex');
|
|
61
|
+
});
|
|
62
|
+
it('does not call onChange if it is the same as the existing latex', () => {
|
|
63
|
+
w = wrapper();
|
|
64
|
+
w.setProps({ latex: 'new-latex' });
|
|
65
|
+
w.instance().changeLatex('new-latex');
|
|
66
|
+
expect(onChange).not.toHaveBeenCalledWith('new-latex');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('inputFocus', () => {
|
|
71
|
+
it('sets state', () => {
|
|
72
|
+
w = wrapper();
|
|
73
|
+
w.instance().inputFocus();
|
|
74
|
+
expect(w.state().focused).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('inputBlur', () => {
|
|
78
|
+
it('sets state', () => {
|
|
79
|
+
w = wrapper();
|
|
80
|
+
w.instance().inputFocus();
|
|
81
|
+
w.instance().inputBlur();
|
|
82
|
+
expect(w.state().focused).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -17,12 +17,14 @@ const toOldModel = (d) => {
|
|
|
17
17
|
export default class HorizontalKeypad extends React.Component {
|
|
18
18
|
static propTypes = {
|
|
19
19
|
className: PropTypes.string,
|
|
20
|
+
controlledKeypadMode: PropTypes.bool,
|
|
20
21
|
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
21
22
|
layoutForKeyPad: PropTypes.object,
|
|
22
23
|
onClick: PropTypes.func.isRequired,
|
|
23
24
|
onFocus: PropTypes.func,
|
|
24
25
|
noDecimal: PropTypes.bool,
|
|
25
26
|
additionalKeys: PropTypes.array,
|
|
27
|
+
setKeypadInteraction: PropTypes.func,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
static defaultProps = {
|
|
@@ -38,18 +40,29 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
render() {
|
|
41
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
mode,
|
|
45
|
+
onFocus,
|
|
46
|
+
controlledKeypadMode,
|
|
47
|
+
noDecimal,
|
|
48
|
+
className,
|
|
49
|
+
additionalKeys,
|
|
50
|
+
layoutForKeyPad,
|
|
51
|
+
setKeypadInteraction,
|
|
52
|
+
} = this.props;
|
|
42
53
|
const normalizedKeys = normalizeAdditionalKeys(additionalKeys);
|
|
43
54
|
|
|
44
55
|
return (
|
|
45
56
|
<Keypad
|
|
46
57
|
className={className}
|
|
58
|
+
controlledKeypadMode={controlledKeypadMode}
|
|
47
59
|
onFocus={onFocus}
|
|
48
60
|
noDecimal={noDecimal}
|
|
49
61
|
layoutForKeyPad={layoutForKeyPad}
|
|
50
62
|
additionalKeys={extendKeySet(keysForGrade(mode), normalizedKeys)}
|
|
51
63
|
onPress={this.keypadPress}
|
|
52
64
|
mode={mode}
|
|
65
|
+
setKeypadInteraction={setKeypadInteraction}
|
|
53
66
|
/>
|
|
54
67
|
);
|
|
55
68
|
}
|
package/src/index.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { keysForGrade } from './keys/grades';
|
|
2
|
+
import { updateSpans } from './updateSpans';
|
|
2
3
|
|
|
3
4
|
const addLeftBracket = (s) => (s.indexOf('\\(') === 0 ? s : `\\(${s}`);
|
|
4
5
|
const addRightBracket = (s) => (s.indexOf('\\)') === s.length - 2 ? s : `${s}\\)`);
|
|
@@ -8,16 +9,6 @@ const rmRightBracket = (s) => (s.indexOf('\\)') === s.length - 2 ? s.substring(0
|
|
|
8
9
|
const addBrackets = (s) => addRightBracket(addLeftBracket(s));
|
|
9
10
|
const removeBrackets = (s) => rmRightBracket(rmLeftBracket(s));
|
|
10
11
|
|
|
11
|
-
// increase the font of parallel notation
|
|
12
|
-
const updateSpans = () => {
|
|
13
|
-
const spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));
|
|
14
|
-
(spans || []).forEach((span) => {
|
|
15
|
-
if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {
|
|
16
|
-
span.style.fontSize = '32px';
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
12
|
import * as keys from './keys';
|
|
22
13
|
|
|
23
14
|
import HorizontalKeypad from './horizontal-keypad';
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Keypad snapshot renders 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="className"
|
|
6
|
+
style={
|
|
7
|
+
Object {
|
|
8
|
+
"gridTemplateColumns": "repeat(4, minmax(min-content, 150px))",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
>
|
|
12
|
+
<WithStyles(Button)
|
|
13
|
+
aria-label="seven"
|
|
14
|
+
className=""
|
|
15
|
+
disabled={false}
|
|
16
|
+
key="7-0"
|
|
17
|
+
onClick={[Function]}
|
|
18
|
+
>
|
|
19
|
+
7
|
|
20
|
+
</WithStyles(Button)>
|
|
21
|
+
<WithStyles(Button)
|
|
22
|
+
aria-label="four"
|
|
23
|
+
className=""
|
|
24
|
+
disabled={false}
|
|
25
|
+
key="4-1"
|
|
26
|
+
onClick={[Function]}
|
|
27
|
+
>
|
|
28
|
+
4
|
|
29
|
+
</WithStyles(Button)>
|
|
30
|
+
<WithStyles(Button)
|
|
31
|
+
aria-label="one"
|
|
32
|
+
className=""
|
|
33
|
+
disabled={false}
|
|
34
|
+
key="1-2"
|
|
35
|
+
onClick={[Function]}
|
|
36
|
+
>
|
|
37
|
+
1
|
|
38
|
+
</WithStyles(Button)>
|
|
39
|
+
<WithStyles(Button)
|
|
40
|
+
aria-label="zero"
|
|
41
|
+
className=""
|
|
42
|
+
disabled={false}
|
|
43
|
+
key="0-3"
|
|
44
|
+
onClick={[Function]}
|
|
45
|
+
>
|
|
46
|
+
0
|
|
47
|
+
</WithStyles(Button)>
|
|
48
|
+
<WithStyles(Button)
|
|
49
|
+
aria-label="Move cursor left"
|
|
50
|
+
className=""
|
|
51
|
+
disabled={false}
|
|
52
|
+
key="◀-4"
|
|
53
|
+
onClick={[Function]}
|
|
54
|
+
>
|
|
55
|
+
◀
|
|
56
|
+
</WithStyles(Button)>
|
|
57
|
+
<WithStyles(Button)
|
|
58
|
+
aria-label="eight"
|
|
59
|
+
className=""
|
|
60
|
+
disabled={false}
|
|
61
|
+
key="8-5"
|
|
62
|
+
onClick={[Function]}
|
|
63
|
+
>
|
|
64
|
+
8
|
|
65
|
+
</WithStyles(Button)>
|
|
66
|
+
<WithStyles(Button)
|
|
67
|
+
aria-label="five"
|
|
68
|
+
className=""
|
|
69
|
+
disabled={false}
|
|
70
|
+
key="5-6"
|
|
71
|
+
onClick={[Function]}
|
|
72
|
+
>
|
|
73
|
+
5
|
|
74
|
+
</WithStyles(Button)>
|
|
75
|
+
<WithStyles(Button)
|
|
76
|
+
aria-label="two"
|
|
77
|
+
className=""
|
|
78
|
+
disabled={false}
|
|
79
|
+
key="2-7"
|
|
80
|
+
onClick={[Function]}
|
|
81
|
+
>
|
|
82
|
+
2
|
|
83
|
+
</WithStyles(Button)>
|
|
84
|
+
<WithStyles(Button)
|
|
85
|
+
aria-label="decimal-point"
|
|
86
|
+
className=""
|
|
87
|
+
disabled={false}
|
|
88
|
+
key=".-8"
|
|
89
|
+
onClick={[Function]}
|
|
90
|
+
>
|
|
91
|
+
.
|
|
92
|
+
</WithStyles(Button)>
|
|
93
|
+
<WithStyles(Button)
|
|
94
|
+
aria-label="Move cursor right"
|
|
95
|
+
className=""
|
|
96
|
+
disabled={false}
|
|
97
|
+
key="▶-9"
|
|
98
|
+
onClick={[Function]}
|
|
99
|
+
>
|
|
100
|
+
▶
|
|
101
|
+
</WithStyles(Button)>
|
|
102
|
+
<WithStyles(Button)
|
|
103
|
+
aria-label="nine"
|
|
104
|
+
className=""
|
|
105
|
+
disabled={false}
|
|
106
|
+
key="9-10"
|
|
107
|
+
onClick={[Function]}
|
|
108
|
+
>
|
|
109
|
+
9
|
|
110
|
+
</WithStyles(Button)>
|
|
111
|
+
<WithStyles(Button)
|
|
112
|
+
aria-label="six"
|
|
113
|
+
className=""
|
|
114
|
+
disabled={false}
|
|
115
|
+
key="6-11"
|
|
116
|
+
onClick={[Function]}
|
|
117
|
+
>
|
|
118
|
+
6
|
|
119
|
+
</WithStyles(Button)>
|
|
120
|
+
<WithStyles(Button)
|
|
121
|
+
aria-label="three"
|
|
122
|
+
className=""
|
|
123
|
+
disabled={false}
|
|
124
|
+
key="3-12"
|
|
125
|
+
onClick={[Function]}
|
|
126
|
+
>
|
|
127
|
+
3
|
|
128
|
+
</WithStyles(Button)>
|
|
129
|
+
<WithStyles(Button)
|
|
130
|
+
aria-label="comma"
|
|
131
|
+
className=""
|
|
132
|
+
disabled={false}
|
|
133
|
+
key=",-13"
|
|
134
|
+
onClick={[Function]}
|
|
135
|
+
>
|
|
136
|
+
,
|
|
137
|
+
</WithStyles(Button)>
|
|
138
|
+
<WithStyles(Button)
|
|
139
|
+
aria-label="Delete"
|
|
140
|
+
className="undefined"
|
|
141
|
+
disabled={false}
|
|
142
|
+
key="⌫-14"
|
|
143
|
+
onClick={[Function]}
|
|
144
|
+
>
|
|
145
|
+
⌫
|
|
146
|
+
</WithStyles(Button)>
|
|
147
|
+
<WithStyles(Button)
|
|
148
|
+
aria-label="divide"
|
|
149
|
+
className=""
|
|
150
|
+
disabled={false}
|
|
151
|
+
key="÷-15"
|
|
152
|
+
onClick={[Function]}
|
|
153
|
+
>
|
|
154
|
+
÷
|
|
155
|
+
</WithStyles(Button)>
|
|
156
|
+
<WithStyles(Button)
|
|
157
|
+
aria-label="multiply"
|
|
158
|
+
className=""
|
|
159
|
+
disabled={false}
|
|
160
|
+
key="×-16"
|
|
161
|
+
onClick={[Function]}
|
|
162
|
+
>
|
|
163
|
+
×
|
|
164
|
+
</WithStyles(Button)>
|
|
165
|
+
<WithStyles(Button)
|
|
166
|
+
aria-label="−"
|
|
167
|
+
className=""
|
|
168
|
+
disabled={false}
|
|
169
|
+
key="−-17"
|
|
170
|
+
onClick={[Function]}
|
|
171
|
+
>
|
|
172
|
+
−
|
|
173
|
+
</WithStyles(Button)>
|
|
174
|
+
<WithStyles(Button)
|
|
175
|
+
aria-label="+"
|
|
176
|
+
className=""
|
|
177
|
+
disabled={false}
|
|
178
|
+
key="+-18"
|
|
179
|
+
onClick={[Function]}
|
|
180
|
+
>
|
|
181
|
+
+
|
|
182
|
+
</WithStyles(Button)>
|
|
183
|
+
<WithStyles(Button)
|
|
184
|
+
aria-label="="
|
|
185
|
+
className=""
|
|
186
|
+
disabled={false}
|
|
187
|
+
key="=-19"
|
|
188
|
+
onClick={[Function]}
|
|
189
|
+
>
|
|
190
|
+
=
|
|
191
|
+
</WithStyles(Button)>
|
|
192
|
+
</div>
|
|
193
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { KeyPad } from '../index';
|
|
4
|
+
|
|
5
|
+
describe('Keypad', () => {
|
|
6
|
+
let w;
|
|
7
|
+
let onChange = jest.fn();
|
|
8
|
+
const wrapper = (extras) => {
|
|
9
|
+
const defaults = {
|
|
10
|
+
classes: {},
|
|
11
|
+
className: 'className',
|
|
12
|
+
onChange,
|
|
13
|
+
onPress: jest.fn(),
|
|
14
|
+
};
|
|
15
|
+
const props = { ...defaults, ...extras };
|
|
16
|
+
return shallow(<KeyPad {...props} />);
|
|
17
|
+
};
|
|
18
|
+
describe('snapshot', () => {
|
|
19
|
+
it('renders', () => {
|
|
20
|
+
w = wrapper();
|
|
21
|
+
expect(w).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sortKeys } from '../keys-layout';
|
|
2
|
+
import { baseSet, comparison } from '../../keys';
|
|
3
|
+
|
|
4
|
+
describe('keys-layout', () => {
|
|
5
|
+
describe('sortKeys', () => {
|
|
6
|
+
it('pads the rows', () => {
|
|
7
|
+
const result = sortKeys([[1, 2, 3]]);
|
|
8
|
+
expect(result).toEqual([
|
|
9
|
+
[1, undefined, undefined, undefined, undefined],
|
|
10
|
+
[2, undefined, undefined, undefined, undefined],
|
|
11
|
+
[3, undefined, undefined, undefined, undefined],
|
|
12
|
+
]);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|