@pie-lib/math-input-mathlive 1.0.8 → 1.0.9-next.6618

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 (37) hide show
  1. package/LICENSE.md +5 -0
  2. package/README.md +1 -1
  3. package/lib/mathlive-instance.js +0 -13
  4. package/lib/mathlive-instance.js.map +1 -1
  5. package/lib/mf/input.js +5 -18
  6. package/lib/mf/input.js.map +1 -1
  7. package/lib/mf/static.js +4 -17
  8. package/lib/mf/static.js.map +1 -1
  9. package/package.json +4 -3
  10. package/src/__tests__/keypad-label.test.jsx +13 -5
  11. package/src/mathlive-instance.js +0 -12
  12. package/src/mf/input.jsx +5 -19
  13. package/src/mf/static.jsx +4 -20
  14. package/lib/__tests__/composites.test.js +0 -255
  15. package/lib/__tests__/composites.test.js.map +0 -1
  16. package/lib/__tests__/drop-in-compat.test.js +0 -133
  17. package/lib/__tests__/drop-in-compat.test.js.map +0 -1
  18. package/lib/__tests__/index.test.js +0 -118
  19. package/lib/__tests__/index.test.js.map +0 -1
  20. package/lib/__tests__/input-imperative.test.js +0 -155
  21. package/lib/__tests__/input-imperative.test.js.map +0 -1
  22. package/lib/__tests__/keypad-label.test.js +0 -44
  23. package/lib/__tests__/keypad-label.test.js.map +0 -1
  24. package/lib/__tests__/keypad-render.test.js +0 -206
  25. package/lib/__tests__/keypad-render.test.js.map +0 -1
  26. package/lib/__tests__/latex-bridge.test.js +0 -251
  27. package/lib/__tests__/latex-bridge.test.js.map +0 -1
  28. package/lib/__tests__/mathlive-instance.test.js +0 -188
  29. package/lib/__tests__/mathlive-instance.test.js.map +0 -1
  30. package/lib/__tests__/mount-race.test.js +0 -194
  31. package/lib/__tests__/mount-race.test.js.map +0 -1
  32. package/lib/__tests__/static-prompts.test.js +0 -282
  33. package/lib/__tests__/static-prompts.test.js.map +0 -1
  34. package/src/__tests__/composites.test.jsx +0 -220
  35. package/src/__tests__/keypad-render.test.jsx +0 -123
  36. package/src/__tests__/mount-race.test.jsx +0 -129
  37. package/src/__tests__/static-prompts.test.jsx +0 -251
package/src/mf/input.jsx CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import debug from 'debug';
5
- import { loadMathLive, getMacros, MATH_MODE_SPACE } from '../mathlive-instance';
5
+ import { loadMathLive, getMacros } from '../mathlive-instance';
6
6
  import { toMathLive, fromMathLive, keyToAction, KEYSTROKES } from '../latex-bridge';
7
7
 
8
8
  const log = debug('pie-lib:math-input-mathlive:input');
@@ -49,16 +49,9 @@ export class Input extends React.Component {
49
49
  }
50
50
 
51
51
  async componentDidMount() {
52
- // MathLive loads asynchronously, so this method resumes after an await and
53
- // has to know whether it is still the current mount. React StrictMode calls
54
- // mount -> unmount -> mount on the SAME instance in dev, so a boolean
55
- // "unmounted" flag would latch and block the remount from ever creating a
56
- // field. A generation counter identifies the live mount instead: only the
57
- // newest one proceeds, and a real unmount invalidates all pending ones.
58
- const generation = (this.mountGeneration = (this.mountGeneration || 0) + 1);
59
52
  const ml = await loadMathLive();
60
53
 
61
- if (generation !== this.mountGeneration || !ml || !this.holderRef.current || this.mathField) {
54
+ if (!ml || !this.holderRef.current) {
62
55
  return;
63
56
  }
64
57
 
@@ -71,18 +64,15 @@ export class Input extends React.Component {
71
64
 
72
65
  // pie drives input through its own keypad, so suppress MathLive's.
73
66
  this.mathField.mathVirtualKeyboardPolicy = 'manual';
74
- // Without this the spacebar does nothing: MathLive's mathModeSpace
75
- // defaults to an empty string.
76
- this.mathField.mathModeSpace = MATH_MODE_SPACE;
77
67
 
78
68
  this.mathField.addEventListener('input', this.onInputEdit);
79
-
80
- // Belt and braces: drop anything a previous mount may have left behind.
81
- this.holderRef.current.replaceChildren(this.mathField);
69
+ this.holderRef.current.appendChild(this.mathField);
82
70
 
83
71
  if (this.props.innerRef) {
84
72
  this.props.innerRef(this);
85
73
  }
74
+
75
+ this.setState?.({});
86
76
  }
87
77
 
88
78
  componentDidUpdate(prevProps) {
@@ -109,10 +99,6 @@ export class Input extends React.Component {
109
99
  }
110
100
 
111
101
  componentWillUnmount() {
112
- // Invalidate any mount still awaiting the MathLive load, so it does not
113
- // append a field into a holder that is going away.
114
- this.mountGeneration = (this.mountGeneration || 0) + 1;
115
-
116
102
  if (this.mathField) {
117
103
  this.mathField.removeEventListener('input', this.onInputEdit);
118
104
  this.mathField.remove();
package/src/mf/static.jsx CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import debug from 'debug';
5
- import { loadMathLive, getMacros, latexToMarkup, MATH_MODE_SPACE } from '../mathlive-instance';
5
+ import { loadMathLive, getMacros, latexToMarkup } from '../mathlive-instance';
6
6
  import { toMathLive, fromMathLive, fieldIds } from '../latex-bridge';
7
7
  import { placeholderStyles } from './common-styles';
8
8
 
@@ -64,41 +64,28 @@ export default class Static extends React.Component {
64
64
  }
65
65
 
66
66
  async componentDidMount() {
67
- // See the note in mf/input.jsx: a generation counter, not a boolean, so a
68
- // StrictMode mount -> unmount -> mount on the same instance still ends up
69
- // with exactly one field.
70
- const generation = (this.mountGeneration = (this.mountGeneration || 0) + 1);
71
-
72
67
  if (!this.isInteractive()) {
73
68
  await loadMathLive();
74
-
75
- if (generation === this.mountGeneration) {
76
- this.renderMarkup();
77
- }
78
-
69
+ this.renderMarkup();
79
70
  return;
80
71
  }
81
72
 
82
73
  const ml = await loadMathLive();
83
74
 
84
- if (generation !== this.mountGeneration || !ml || !this.holderRef.current || this.mathField) {
75
+ if (!ml || !this.holderRef.current) {
85
76
  return;
86
77
  }
87
78
 
88
79
  this.mathField = new ml.MathfieldElement({ macros: getMacros() });
89
80
  this.mathField.readOnly = true;
90
81
  this.mathField.mathVirtualKeyboardPolicy = 'manual';
91
- // Without this the spacebar does nothing: MathLive's mathModeSpace
92
- // defaults to an empty string.
93
- this.mathField.mathModeSpace = MATH_MODE_SPACE;
94
82
  this.mathField.value = toMathLive(this.props.latex);
95
83
 
96
84
  this.mathField.addEventListener('input', this.onPromptInput);
97
85
  this.mathField.addEventListener('focusin', this.onPromptFocus);
98
86
  this.mathField.addEventListener('keydown', this.onKeyDown);
99
87
 
100
- // Belt and braces: drop anything a previous mount may have left behind.
101
- this.holderRef.current.replaceChildren(this.mathField);
88
+ this.holderRef.current.appendChild(this.mathField);
102
89
 
103
90
  this.createLiveRegion();
104
91
  }
@@ -116,9 +103,6 @@ export default class Static extends React.Component {
116
103
  }
117
104
 
118
105
  componentWillUnmount() {
119
- // Invalidate any mount still awaiting the MathLive load.
120
- this.mountGeneration = (this.mountGeneration || 0) + 1;
121
-
122
106
  if (this.mathField) {
123
107
  this.mathField.removeEventListener('input', this.onPromptInput);
124
108
  this.mathField.removeEventListener('focusin', this.onPromptFocus);
@@ -1,255 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _react = _interopRequireDefault(require("react"));
5
- var _react2 = require("@testing-library/react");
6
- var _mathInput = _interopRequireDefault(require("../math-input"));
7
- var _horizontalKeypad = _interopRequireDefault(require("../horizontal-keypad"));
8
- var _input = _interopRequireDefault(require("../mf/input"));
9
- /**
10
- * The pieces that sit between the keypad and the field: how a pressed key is
11
- * routed into the field, and the legacy `{value,type}` shape math-toolbar
12
- * consumes.
13
- */
14
- describe('MathInput.keypadPress routing', function () {
15
- var withInput = function withInput() {
16
- var mi = new _mathInput["default"]({});
17
- var calls = {
18
- write: [],
19
- keystroke: []
20
- };
21
- mi.input = {
22
- write: function write(v) {
23
- return calls.write.push(v);
24
- },
25
- keystroke: function keystroke(v) {
26
- return calls.keystroke.push(v);
27
- }
28
- };
29
- return {
30
- mi: mi,
31
- calls: calls
32
- };
33
- };
34
- it('routes an insert action to write()', function () {
35
- var _withInput = withInput(),
36
- mi = _withInput.mi,
37
- calls = _withInput.calls;
38
- mi.keypadPress({
39
- latex: '\\pi'
40
- });
41
- expect(calls.write).toEqual(['\\pi']);
42
- expect(calls.keystroke).toEqual([]);
43
- });
44
- it('expands an argument-taking command before writing', function () {
45
- var _withInput2 = withInput(),
46
- mi = _withInput2.mi,
47
- calls = _withInput2.calls;
48
- mi.keypadPress({
49
- command: '\\frac'
50
- });
51
- expect(calls.write).toEqual(['\\frac{#?}{#?}']);
52
- });
53
- it('routes a cursor keystroke to keystroke()', function () {
54
- var _withInput3 = withInput(),
55
- mi = _withInput3.mi,
56
- calls = _withInput3.calls;
57
- mi.keypadPress({
58
- keystroke: 'Left'
59
- });
60
- expect(calls.keystroke).toEqual(['moveToPreviousChar']);
61
- expect(calls.write).toEqual([]);
62
- });
63
- it('ignores keys with no action', function () {
64
- var _withInput4 = withInput(),
65
- mi = _withInput4.mi,
66
- calls = _withInput4.calls;
67
- mi.keypadPress({});
68
- mi.keypadPress({
69
- keystroke: 'Nonsense'
70
- });
71
- expect(calls.write).toEqual([]);
72
- expect(calls.keystroke).toEqual([]);
73
- });
74
- it('is a no-op before the field ref exists', function () {
75
- var mi = new _mathInput["default"]({});
76
- expect(function () {
77
- return mi.keypadPress({
78
- latex: '\\pi'
79
- });
80
- }).not.toThrow();
81
- });
82
- it('changeLatex only fires onChange when the value differs', function () {
83
- var onChange = jest.fn();
84
- var mi = new _mathInput["default"]({
85
- latex: 'x',
86
- onChange: onChange
87
- });
88
- mi.changeLatex('x');
89
- expect(onChange).not.toHaveBeenCalled();
90
- mi.changeLatex('y');
91
- expect(onChange).toHaveBeenCalledWith('y');
92
- });
93
- it('tracks focus state', function () {
94
- var mi = new _mathInput["default"]({});
95
- mi.setState = function (s) {
96
- return Object.assign(mi.state, s);
97
- };
98
- mi.inputFocus();
99
- expect(mi.state.focused).toBe(true);
100
- mi.inputBlur();
101
- expect(mi.state.focused).toBe(false);
102
- });
103
- });
104
- describe('HorizontalKeypad legacy {value,type} model', function () {
105
- var pressed = function pressed(key) {
106
- var onClick = jest.fn();
107
- var hk = new _horizontalKeypad["default"]({
108
- onClick: onClick
109
- });
110
- hk.keypadPress(key);
111
- return onClick.mock.calls[0][0];
112
- };
113
- it('maps a command to {value, type: command}', function () {
114
- expect(pressed({
115
- command: '\\frac'
116
- })).toEqual({
117
- value: '\\frac',
118
- type: 'command'
119
- });
120
- });
121
- it('maps a write to {value}', function () {
122
- expect(pressed({
123
- write: 'x'
124
- })).toEqual({
125
- value: 'x'
126
- });
127
- });
128
- it('maps a keystroke to {type: cursor}', function () {
129
- expect(pressed({
130
- keystroke: 'Left'
131
- })).toEqual({
132
- type: 'cursor',
133
- value: 'Left'
134
- });
135
- });
136
- it('renders without throwing', function () {
137
- expect(function () {
138
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_horizontalKeypad["default"], {
139
- onClick: function onClick() {}
140
- }));
141
- }).not.toThrow();
142
- });
143
- });
144
- describe('Input: controlled-value sync and events', function () {
145
- var withField = function withField() {
146
- var input = new _input["default"]({});
147
- input.mathField = {
148
- value: '',
149
- getValue: function getValue() {
150
- return input.mathField.value;
151
- },
152
- insert: function insert(v) {
153
- input.mathField.value += v;
154
- },
155
- executeCommand: function executeCommand() {},
156
- focus: function focus() {},
157
- blur: function blur() {},
158
- addEventListener: function addEventListener() {},
159
- removeEventListener: function removeEventListener() {},
160
- remove: function remove() {}
161
- };
162
- return input;
163
- };
164
- it('emits stored-form latex on edit', function () {
165
- var onChange = jest.fn();
166
- var input = withField();
167
- input.props = {
168
- onChange: onChange
169
- };
170
- input.mathField.value = '\\longdiv{\\placeholder{}}';
171
- input.onInputEdit();
172
-
173
- // \placeholder is MathLive-internal and must not reach the model
174
- expect(onChange).toHaveBeenCalledWith('\\longdiv{}');
175
- expect(input.lastEmitted).toEqual('\\longdiv{}');
176
- });
177
- it('does not push a prop echo back into the field', function () {
178
- var input = withField();
179
- input.mathField.value = 'x';
180
- input.lastEmitted = 'x';
181
- input.props = {
182
- latex: 'x'
183
- };
184
- input.componentDidUpdate({
185
- latex: ''
186
- });
187
- expect(input.mathField.value).toEqual('x');
188
- });
189
- it('pushes a genuinely new latex prop into the field', function () {
190
- var input = withField();
191
- input.mathField.value = 'x';
192
- input.lastEmitted = 'x';
193
- input.props = {
194
- latex: 'y'
195
- };
196
- input.componentDidUpdate({
197
- latex: 'x'
198
- });
199
- expect(input.mathField.value).toEqual('y');
200
- });
201
- it('bridges stored latex on the way in', function () {
202
- var input = withField();
203
- input.props = {
204
- latex: '\\longdiv{5}'
205
- };
206
- input.componentDidUpdate({
207
- latex: ''
208
- });
209
-
210
- // must become native \enclose so the content stays editable
211
- expect(input.mathField.value).toEqual('\\enclose{longdiv}{5}');
212
- });
213
- it('toggles readOnly', function () {
214
- var input = withField();
215
- input.props = {
216
- readOnly: true
217
- };
218
- input.componentDidUpdate({
219
- readOnly: false
220
- });
221
- expect(input.mathField.readOnly).toBe(true);
222
- });
223
- it('clear() empties the field', function () {
224
- var input = withField();
225
- input.mathField.value = 'abc';
226
- expect(input.clear()).toEqual('');
227
- expect(input.mathField.value).toEqual('');
228
- });
229
- it('suppresses Enter so it cannot insert a line break', function () {
230
- var input = withField();
231
- var preventDefault = jest.fn();
232
- input.onKeyDown({
233
- key: 'Enter',
234
- preventDefault: preventDefault
235
- });
236
- expect(preventDefault).toHaveBeenCalled();
237
- preventDefault.mockClear();
238
- input.onKeyDown({
239
- key: 'a',
240
- preventDefault: preventDefault
241
- });
242
- expect(preventDefault).not.toHaveBeenCalled();
243
- });
244
- it('componentDidUpdate is safe before the field exists', function () {
245
- var input = new _input["default"]({
246
- latex: 'x'
247
- });
248
- expect(function () {
249
- return input.componentDidUpdate({
250
- latex: ''
251
- });
252
- }).not.toThrow();
253
- });
254
- });
255
- //# sourceMappingURL=composites.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"composites.test.js","names":["_react","_interopRequireDefault","require","_react2","_mathInput","_horizontalKeypad","_input","describe","withInput","mi","MathInput","calls","write","keystroke","input","v","push","it","_withInput","keypadPress","latex","expect","toEqual","_withInput2","command","_withInput3","_withInput4","not","toThrow","onChange","jest","fn","changeLatex","toHaveBeenCalled","toHaveBeenCalledWith","setState","s","Object","assign","state","inputFocus","focused","toBe","inputBlur","pressed","key","onClick","hk","HorizontalKeypad","mock","value","type","render","createElement","withField","Input","mathField","getValue","insert","executeCommand","focus","blur","addEventListener","removeEventListener","remove","props","onInputEdit","lastEmitted","componentDidUpdate","readOnly","clear","preventDefault","onKeyDown","mockClear"],"sources":["../../src/__tests__/composites.test.jsx"],"sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\n\nimport MathInput from '../math-input';\nimport HorizontalKeypad from '../horizontal-keypad';\nimport Input from '../mf/input';\n\n/**\n * The pieces that sit between the keypad and the field: how a pressed key is\n * routed into the field, and the legacy `{value,type}` shape math-toolbar\n * consumes.\n */\ndescribe('MathInput.keypadPress routing', () => {\n const withInput = () => {\n const mi = new MathInput({});\n const calls = { write: [], keystroke: [] };\n\n mi.input = {\n write: (v) => calls.write.push(v),\n keystroke: (v) => calls.keystroke.push(v),\n };\n\n return { mi, calls };\n };\n\n it('routes an insert action to write()', () => {\n const { mi, calls } = withInput();\n\n mi.keypadPress({ latex: '\\\\pi' });\n\n expect(calls.write).toEqual(['\\\\pi']);\n expect(calls.keystroke).toEqual([]);\n });\n\n it('expands an argument-taking command before writing', () => {\n const { mi, calls } = withInput();\n\n mi.keypadPress({ command: '\\\\frac' });\n\n expect(calls.write).toEqual(['\\\\frac{#?}{#?}']);\n });\n\n it('routes a cursor keystroke to keystroke()', () => {\n const { mi, calls } = withInput();\n\n mi.keypadPress({ keystroke: 'Left' });\n\n expect(calls.keystroke).toEqual(['moveToPreviousChar']);\n expect(calls.write).toEqual([]);\n });\n\n it('ignores keys with no action', () => {\n const { mi, calls } = withInput();\n\n mi.keypadPress({});\n mi.keypadPress({ keystroke: 'Nonsense' });\n\n expect(calls.write).toEqual([]);\n expect(calls.keystroke).toEqual([]);\n });\n\n it('is a no-op before the field ref exists', () => {\n const mi = new MathInput({});\n\n expect(() => mi.keypadPress({ latex: '\\\\pi' })).not.toThrow();\n });\n\n it('changeLatex only fires onChange when the value differs', () => {\n const onChange = jest.fn();\n const mi = new MathInput({ latex: 'x', onChange });\n\n mi.changeLatex('x');\n expect(onChange).not.toHaveBeenCalled();\n\n mi.changeLatex('y');\n expect(onChange).toHaveBeenCalledWith('y');\n });\n\n it('tracks focus state', () => {\n const mi = new MathInput({});\n\n mi.setState = (s) => Object.assign(mi.state, s);\n mi.inputFocus();\n expect(mi.state.focused).toBe(true);\n\n mi.inputBlur();\n expect(mi.state.focused).toBe(false);\n });\n});\n\ndescribe('HorizontalKeypad legacy {value,type} model', () => {\n const pressed = (key) => {\n const onClick = jest.fn();\n const hk = new HorizontalKeypad({ onClick });\n\n hk.keypadPress(key);\n\n return onClick.mock.calls[0][0];\n };\n\n it('maps a command to {value, type: command}', () => {\n expect(pressed({ command: '\\\\frac' })).toEqual({ value: '\\\\frac', type: 'command' });\n });\n\n it('maps a write to {value}', () => {\n expect(pressed({ write: 'x' })).toEqual({ value: 'x' });\n });\n\n it('maps a keystroke to {type: cursor}', () => {\n expect(pressed({ keystroke: 'Left' })).toEqual({ type: 'cursor', value: 'Left' });\n });\n\n it('renders without throwing', () => {\n expect(() => render(<HorizontalKeypad onClick={() => {}} />)).not.toThrow();\n });\n});\n\ndescribe('Input: controlled-value sync and events', () => {\n const withField = () => {\n const input = new Input({});\n\n input.mathField = {\n value: '',\n getValue: () => input.mathField.value,\n insert(v) {\n input.mathField.value += v;\n },\n executeCommand() {},\n focus() {},\n blur() {},\n addEventListener() {},\n removeEventListener() {},\n remove() {},\n };\n\n return input;\n };\n\n it('emits stored-form latex on edit', () => {\n const onChange = jest.fn();\n const input = withField();\n\n input.props = { onChange };\n input.mathField.value = '\\\\longdiv{\\\\placeholder{}}';\n input.onInputEdit();\n\n // \\placeholder is MathLive-internal and must not reach the model\n expect(onChange).toHaveBeenCalledWith('\\\\longdiv{}');\n expect(input.lastEmitted).toEqual('\\\\longdiv{}');\n });\n\n it('does not push a prop echo back into the field', () => {\n const input = withField();\n\n input.mathField.value = 'x';\n input.lastEmitted = 'x';\n input.props = { latex: 'x' };\n\n input.componentDidUpdate({ latex: '' });\n\n expect(input.mathField.value).toEqual('x');\n });\n\n it('pushes a genuinely new latex prop into the field', () => {\n const input = withField();\n\n input.mathField.value = 'x';\n input.lastEmitted = 'x';\n input.props = { latex: 'y' };\n\n input.componentDidUpdate({ latex: 'x' });\n\n expect(input.mathField.value).toEqual('y');\n });\n\n it('bridges stored latex on the way in', () => {\n const input = withField();\n\n input.props = { latex: '\\\\longdiv{5}' };\n input.componentDidUpdate({ latex: '' });\n\n // must become native \\enclose so the content stays editable\n expect(input.mathField.value).toEqual('\\\\enclose{longdiv}{5}');\n });\n\n it('toggles readOnly', () => {\n const input = withField();\n\n input.props = { readOnly: true };\n input.componentDidUpdate({ readOnly: false });\n\n expect(input.mathField.readOnly).toBe(true);\n });\n\n it('clear() empties the field', () => {\n const input = withField();\n\n input.mathField.value = 'abc';\n expect(input.clear()).toEqual('');\n expect(input.mathField.value).toEqual('');\n });\n\n it('suppresses Enter so it cannot insert a line break', () => {\n const input = withField();\n const preventDefault = jest.fn();\n\n input.onKeyDown({ key: 'Enter', preventDefault });\n expect(preventDefault).toHaveBeenCalled();\n\n preventDefault.mockClear();\n input.onKeyDown({ key: 'a', preventDefault });\n expect(preventDefault).not.toHaveBeenCalled();\n });\n\n it('componentDidUpdate is safe before the field exists', () => {\n const input = new Input({ latex: 'x' });\n\n expect(() => input.componentDidUpdate({ latex: '' })).not.toThrow();\n });\n});\n"],"mappings":";;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACAK,QAAQ,CAAC,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C,MAAM,CAAC;MAAA,OAAMP,KAAK,CAACsD,kBAAkB,CAAC;QAAEhD,KAAK,EAAE;MAAG,CAAC,CAAC;IAAA,EAAC,CAACO,GAAG,CAACC,OAAO,CAAC,CAAC;EACrE,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
5
- var _react = _interopRequireDefault(require("react"));
6
- var _react2 = require("@testing-library/react");
7
- var _styles = require("@mui/material/styles");
8
- var _index = require("../index");
9
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- /**
12
- * Exercises the exact call patterns real consumers use against
13
- * @pie-lib/math-input, to catch drop-in incompatibilities.
14
- *
15
- * Sources:
16
- * - packages/math-toolbar/src/editor-and-pad.jsx:16,185
17
- * - packages/math-toolbar/src/math-preview.jsx:8,156
18
- * - packages/editable-html/src/plugins/respArea/math-templated/index.jsx:92
19
- * - packages/editable-html-tip-tap/src/components/respArea/MathTemplated.jsx:111
20
- */
21
- describe('drop-in compatibility with @pie-lib/math-input consumers', function () {
22
- describe('mq.CommonMqStyles destructuring', function () {
23
- it('math-preview.jsx: { commonMqFontStyles, longdivStyles, supsubStyles }', function () {
24
- var _mq$CommonMqStyles = _index.mq.CommonMqStyles,
25
- commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
26
- longdivStyles = _mq$CommonMqStyles.longdivStyles,
27
- supsubStyles = _mq$CommonMqStyles.supsubStyles;
28
- expect(commonMqFontStyles).toBeDefined();
29
- expect(longdivStyles).toBeDefined();
30
- expect(supsubStyles).toBeDefined();
31
- });
32
- it('editor-and-pad.jsx: also { commonMqKeyboardStyles }', function () {
33
- var _mq$CommonMqStyles2 = _index.mq.CommonMqStyles,
34
- commonMqFontStyles = _mq$CommonMqStyles2.commonMqFontStyles,
35
- commonMqKeyboardStyles = _mq$CommonMqStyles2.commonMqKeyboardStyles,
36
- longdivStyles = _mq$CommonMqStyles2.longdivStyles,
37
- supsubStyles = _mq$CommonMqStyles2.supsubStyles;
38
- expect(commonMqKeyboardStyles).toBeDefined();
39
- // All four must be spreadable into an emotion style object.
40
- expect(function () {
41
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), commonMqKeyboardStyles), longdivStyles), supsubStyles);
42
- }).not.toThrow();
43
- });
44
- it('the destructured groups survive being spread into a styled component', function () {
45
- var _mq$CommonMqStyles3 = _index.mq.CommonMqStyles,
46
- commonMqFontStyles = _mq$CommonMqStyles3.commonMqFontStyles,
47
- longdivStyles = _mq$CommonMqStyles3.longdivStyles,
48
- supsubStyles = _mq$CommonMqStyles3.supsubStyles;
49
- var Styled = (0, _styles.styled)('div')(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), longdivStyles), supsubStyles));
50
- expect(function () {
51
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(Styled, null));
52
- }).not.toThrow();
53
- });
54
- });
55
- describe('mq.Input', function () {
56
- it('editor-and-pad.jsx: styled(mq.Input) renders', function () {
57
- var MathEditor = (0, _styles.styled)(_index.mq.Input)(function () {
58
- return {
59
- width: '100%'
60
- };
61
- });
62
- expect(function () {
63
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(MathEditor, {
64
- latex: "\\\\frac{1}{2}",
65
- onChange: function onChange() {}
66
- }));
67
- }).not.toThrow();
68
- });
69
- it('accepts the className that styled() injects', function () {
70
- var Styled = (0, _styles.styled)(_index.mq.Input)({
71
- padding: 4
72
- });
73
- var _render = (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(Styled, {
74
- latex: "x",
75
- onChange: function onChange() {}
76
- })),
77
- container = _render.container;
78
- expect(container.firstChild).toBeTruthy();
79
- expect(container.firstChild.className).toBeTruthy();
80
- });
81
- });
82
- describe('mq.Static', function () {
83
- it('math-preview.jsx: <mq.Static latex onFocus onBlur />', function () {
84
- expect(function () {
85
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_index.mq.Static, {
86
- latex: '\\frac{1}{2}',
87
- onFocus: function onFocus() {},
88
- onBlur: function onBlur() {}
89
- }));
90
- }).not.toThrow();
91
- });
92
- it('math-templated respArea: <mq.Static latex={value} />', function () {
93
- expect(function () {
94
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_index.mq.Static, {
95
- latex: 'x=1'
96
- }));
97
- }).not.toThrow();
98
- });
99
- it('renders answer-block latex (the templated-math case) without throwing', function () {
100
- expect(function () {
101
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(_index.mq.Static, {
102
- latex: 'x=\\MathQuillMathField[r1]{}',
103
- onSubFieldChange: function onSubFieldChange() {}
104
- }));
105
- }).not.toThrow();
106
- });
107
- it('is styleable, as keypad labels were in math-input', function () {
108
- var Styled = (0, _styles.styled)(_index.mq.Static)({
109
- pointerEvents: 'none'
110
- });
111
- expect(function () {
112
- return (0, _react2.render)(/*#__PURE__*/_react["default"].createElement(Styled, {
113
- latex: '\\pi'
114
- }));
115
- }).not.toThrow();
116
- });
117
- });
118
- describe('surface parity', function () {
119
- it('exposes exactly the names math-input exported', function () {
120
- // eslint-disable-next-line global-require
121
- var pkg = require('../index');
122
- ['keysForGrade', 'addBrackets', 'removeBrackets', 'keys', 'HorizontalKeypad', 'mq', 'updateSpans', 'registerEmbed', 'applyStaticMath'].forEach(function (name) {
123
- expect(pkg[name]).toBeDefined();
124
- });
125
- });
126
- it('mq exposes Input, Static and CommonMqStyles', function () {
127
- ['Input', 'Static', 'CommonMqStyles'].forEach(function (name) {
128
- expect(_index.mq[name]).toBeDefined();
129
- });
130
- });
131
- });
132
- });
133
- //# sourceMappingURL=drop-in-compat.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"drop-in-compat.test.js","names":["_react","_interopRequireDefault","require","_react2","_styles","_index","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","describe","it","_mq$CommonMqStyles","mq","CommonMqStyles","commonMqFontStyles","longdivStyles","supsubStyles","expect","toBeDefined","_mq$CommonMqStyles2","commonMqKeyboardStyles","not","toThrow","_mq$CommonMqStyles3","Styled","styled","render","createElement","MathEditor","Input","width","latex","onChange","padding","_render","container","firstChild","toBeTruthy","className","Static","onFocus","onBlur","onSubFieldChange","pointerEvents","pkg","name"],"sources":["../../src/__tests__/drop-in-compat.test.jsx"],"sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\nimport { styled } from '@mui/material/styles';\n\nimport { mq } from '../index';\n\n/**\n * Exercises the exact call patterns real consumers use against\n * @pie-lib/math-input, to catch drop-in incompatibilities.\n *\n * Sources:\n * - packages/math-toolbar/src/editor-and-pad.jsx:16,185\n * - packages/math-toolbar/src/math-preview.jsx:8,156\n * - packages/editable-html/src/plugins/respArea/math-templated/index.jsx:92\n * - packages/editable-html-tip-tap/src/components/respArea/MathTemplated.jsx:111\n */\ndescribe('drop-in compatibility with @pie-lib/math-input consumers', () => {\n describe('mq.CommonMqStyles destructuring', () => {\n it('math-preview.jsx: { commonMqFontStyles, longdivStyles, supsubStyles }', () => {\n const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n\n expect(commonMqFontStyles).toBeDefined();\n expect(longdivStyles).toBeDefined();\n expect(supsubStyles).toBeDefined();\n });\n\n it('editor-and-pad.jsx: also { commonMqKeyboardStyles }', () => {\n const { commonMqFontStyles, commonMqKeyboardStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n\n expect(commonMqKeyboardStyles).toBeDefined();\n // All four must be spreadable into an emotion style object.\n expect(() => ({\n ...commonMqFontStyles,\n ...commonMqKeyboardStyles,\n ...longdivStyles,\n ...supsubStyles,\n })).not.toThrow();\n });\n\n it('the destructured groups survive being spread into a styled component', () => {\n const { commonMqFontStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\n const Styled = styled('div')({ ...commonMqFontStyles, ...longdivStyles, ...supsubStyles });\n\n expect(() => render(<Styled />)).not.toThrow();\n });\n });\n\n describe('mq.Input', () => {\n it('editor-and-pad.jsx: styled(mq.Input) renders', () => {\n const MathEditor = styled(mq.Input)(() => ({ width: '100%' }));\n\n expect(() => render(<MathEditor latex=\"\\\\frac{1}{2}\" onChange={() => {}} />)).not.toThrow();\n });\n\n it('accepts the className that styled() injects', () => {\n const Styled = styled(mq.Input)({ padding: 4 });\n const { container } = render(<Styled latex=\"x\" onChange={() => {}} />);\n\n expect(container.firstChild).toBeTruthy();\n expect(container.firstChild.className).toBeTruthy();\n });\n });\n\n describe('mq.Static', () => {\n it('math-preview.jsx: <mq.Static latex onFocus onBlur />', () => {\n expect(() => render(<mq.Static latex={'\\\\frac{1}{2}'} onFocus={() => {}} onBlur={() => {}} />)).not.toThrow();\n });\n\n it('math-templated respArea: <mq.Static latex={value} />', () => {\n expect(() => render(<mq.Static latex={'x=1'} />)).not.toThrow();\n });\n\n it('renders answer-block latex (the templated-math case) without throwing', () => {\n expect(() =>\n render(<mq.Static latex={'x=\\\\MathQuillMathField[r1]{}'} onSubFieldChange={() => {}} />),\n ).not.toThrow();\n });\n\n it('is styleable, as keypad labels were in math-input', () => {\n const Styled = styled(mq.Static)({ pointerEvents: 'none' });\n\n expect(() => render(<Styled latex={'\\\\pi'} />)).not.toThrow();\n });\n });\n\n describe('surface parity', () => {\n it('exposes exactly the names math-input exported', () => {\n // eslint-disable-next-line global-require\n const pkg = require('../index');\n\n [\n 'keysForGrade',\n 'addBrackets',\n 'removeBrackets',\n 'keys',\n 'HorizontalKeypad',\n 'mq',\n 'updateSpans',\n 'registerEmbed',\n 'applyStaticMath',\n ].forEach((name) => {\n expect(pkg[name]).toBeDefined();\n });\n });\n\n it('mq exposes Input, Static and CommonMqStyles', () => {\n ['Input', 'Static', 'CommonMqStyles'].forEach((name) => {\n expect(mq[name]).toBeDefined();\n });\n });\n });\n});\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAA8B,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAA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