@pie-lib/math-input 8.1.1-next.2 → 8.1.1-next.57

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 (185) hide show
  1. package/CHANGELOG.json +17 -0
  2. package/CHANGELOG.md +1172 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/horizontal-keypad.js +96 -0
  5. package/lib/horizontal-keypad.js.map +1 -0
  6. package/lib/index.js +69 -0
  7. package/lib/index.js.map +1 -0
  8. package/lib/keypad/index.js +413 -0
  9. package/lib/keypad/index.js.map +1 -0
  10. package/lib/keypad/keys-layout.js +22 -0
  11. package/lib/keypad/keys-layout.js.map +1 -0
  12. package/lib/keys/basic-operators.js +33 -0
  13. package/lib/keys/basic-operators.js.map +1 -0
  14. package/lib/keys/chars.js +12 -0
  15. package/lib/keys/chars.js.map +1 -0
  16. package/lib/keys/comparison.js +39 -0
  17. package/lib/keys/comparison.js.map +1 -0
  18. package/lib/keys/constants.js +37 -0
  19. package/lib/keys/constants.js.map +1 -0
  20. package/lib/keys/digits.js +46 -0
  21. package/lib/keys/digits.js.map +1 -0
  22. package/lib/keys/edit.js +14 -0
  23. package/lib/keys/edit.js.map +1 -0
  24. package/lib/keys/exponent.js +30 -0
  25. package/lib/keys/exponent.js.map +1 -0
  26. package/lib/keys/fractions.js +29 -0
  27. package/lib/keys/fractions.js.map +1 -0
  28. package/lib/keys/geometry.js +140 -0
  29. package/lib/keys/geometry.js.map +1 -0
  30. package/lib/keys/grades.js +259 -0
  31. package/lib/keys/grades.js.map +1 -0
  32. package/lib/keys/index.js +35 -0
  33. package/lib/keys/index.js.map +1 -0
  34. package/lib/keys/log.js +27 -0
  35. package/lib/keys/log.js.map +1 -0
  36. package/lib/keys/logic.js +19 -0
  37. package/lib/keys/logic.js.map +1 -0
  38. package/lib/keys/matrices.js +19 -0
  39. package/lib/keys/matrices.js.map +1 -0
  40. package/lib/keys/misc.js +62 -0
  41. package/lib/keys/misc.js.map +1 -0
  42. package/lib/keys/navigation.js +20 -0
  43. package/lib/keys/navigation.js.map +1 -0
  44. package/lib/keys/operators.js +15 -0
  45. package/lib/keys/operators.js.map +1 -0
  46. package/lib/keys/statistics.js +40 -0
  47. package/lib/keys/statistics.js.map +1 -0
  48. package/lib/keys/sub-sup.js +19 -0
  49. package/lib/keys/sub-sup.js.map +1 -0
  50. package/lib/keys/trigonometry.js +45 -0
  51. package/lib/keys/trigonometry.js.map +1 -0
  52. package/lib/keys/utils.js +87 -0
  53. package/lib/keys/utils.js.map +1 -0
  54. package/lib/keys/vars.js +24 -0
  55. package/lib/keys/vars.js.map +1 -0
  56. package/lib/math-input.js +141 -0
  57. package/lib/math-input.js.map +1 -0
  58. package/lib/mq/common-mq-styles.js +102 -0
  59. package/lib/mq/common-mq-styles.js.map +1 -0
  60. package/lib/mq/custom-elements.js +20 -0
  61. package/lib/mq/custom-elements.js.map +1 -0
  62. package/lib/mq/index.js +28 -0
  63. package/lib/mq/index.js.map +1 -0
  64. package/lib/mq/input.js +186 -0
  65. package/lib/mq/input.js.map +1 -0
  66. package/lib/mq/mathquill-instance.js +52 -0
  67. package/lib/mq/mathquill-instance.js.map +1 -0
  68. package/lib/mq/static.js +301 -0
  69. package/lib/mq/static.js.map +1 -0
  70. package/lib/updateSpans.js +19 -0
  71. package/lib/updateSpans.js.map +1 -0
  72. package/package.json +18 -33
  73. package/src/__tests__/horizontal-keypad.test.jsx +463 -0
  74. package/src/__tests__/index.test.js +247 -0
  75. package/src/__tests__/math-input-test.jsx +45 -0
  76. package/src/__tests__/updateSpans.test.js +297 -0
  77. package/src/horizontal-keypad.jsx +69 -0
  78. package/src/index.jsx +28 -0
  79. package/src/keypad/__tests__/index.test.jsx +25 -0
  80. package/src/keypad/__tests__/keys-layout.test.js +14 -0
  81. package/src/keypad/index.jsx +439 -0
  82. package/src/keypad/keys-layout.js +16 -0
  83. package/src/keys/__tests__/utils.test.js +57 -0
  84. package/src/keys/basic-operators.js +32 -0
  85. package/src/keys/chars.js +5 -0
  86. package/src/keys/comparison.js +28 -0
  87. package/src/keys/constants.js +35 -0
  88. package/src/keys/digits.js +40 -0
  89. package/src/keys/edit.js +3 -0
  90. package/src/keys/exponent.js +28 -0
  91. package/src/keys/fractions.js +26 -0
  92. package/src/keys/geometry.js +144 -0
  93. package/src/keys/grades.js +367 -0
  94. package/src/keys/index.js +20 -0
  95. package/src/keys/log.js +22 -0
  96. package/src/keys/logic.js +15 -0
  97. package/src/keys/matrices.js +15 -0
  98. package/src/keys/misc.js +65 -0
  99. package/src/keys/navigation.js +8 -0
  100. package/src/keys/operators.js +10 -0
  101. package/src/keys/statistics.js +38 -0
  102. package/src/keys/sub-sup.js +15 -0
  103. package/src/keys/trigonometry.js +15 -0
  104. package/src/keys/utils.js +66 -0
  105. package/src/keys/vars.js +19 -0
  106. package/src/math-input.jsx +119 -0
  107. package/src/mq/__tests__/custom-elements.test.js +342 -0
  108. package/src/mq/__tests__/input.test.jsx +40 -0
  109. package/src/mq/__tests__/mathquill-instance.test.js +67 -0
  110. package/src/mq/__tests__/static.test.jsx +33 -0
  111. package/src/mq/common-mq-styles.js +109 -0
  112. package/src/mq/custom-elements.js +11 -0
  113. package/src/mq/index.js +5 -0
  114. package/src/mq/input.jsx +166 -0
  115. package/src/mq/mathquill-instance.js +45 -0
  116. package/src/mq/static.jsx +290 -0
  117. package/src/updateSpans.js +15 -0
  118. package/dist/_virtual/_rolldown/runtime.js +0 -11
  119. package/dist/horizontal-keypad.d.ts +0 -31
  120. package/dist/horizontal-keypad.js +0 -57
  121. package/dist/index.d.ts +0 -18
  122. package/dist/index.js +0 -19
  123. package/dist/keypad/accessible-keypad.d.ts +0 -37
  124. package/dist/keypad/accessible-keypad.js +0 -614
  125. package/dist/keypad/index.d.ts +0 -2
  126. package/dist/keypad/keys-layout.d.ts +0 -15
  127. package/dist/keypad/keys-layout.js +0 -5
  128. package/dist/keypad/model.d.ts +0 -28
  129. package/dist/keypad/model.js +0 -4
  130. package/dist/keys/basic-operators.d.ts +0 -13
  131. package/dist/keys/basic-operators.js +0 -30
  132. package/dist/keys/chars.d.ts +0 -13
  133. package/dist/keys/comparison.d.ts +0 -12
  134. package/dist/keys/comparison.js +0 -32
  135. package/dist/keys/constants.d.ts +0 -12
  136. package/dist/keys/constants.js +0 -35
  137. package/dist/keys/digits.d.ts +0 -23
  138. package/dist/keys/digits.js +0 -34
  139. package/dist/keys/edit.d.ts +0 -14
  140. package/dist/keys/edit.js +0 -9
  141. package/dist/keys/exponent.d.ts +0 -12
  142. package/dist/keys/exponent.js +0 -28
  143. package/dist/keys/fractions.d.ts +0 -11
  144. package/dist/keys/fractions.js +0 -27
  145. package/dist/keys/geometry.d.ts +0 -31
  146. package/dist/keys/geometry.js +0 -127
  147. package/dist/keys/grades.d.ts +0 -17
  148. package/dist/keys/grades.js +0 -414
  149. package/dist/keys/index.d.ts +0 -14
  150. package/dist/keys/index.js +0 -50
  151. package/dist/keys/log.d.ts +0 -11
  152. package/dist/keys/log.js +0 -25
  153. package/dist/keys/logic.d.ts +0 -10
  154. package/dist/keys/logic.js +0 -13
  155. package/dist/keys/matrices.d.ts +0 -10
  156. package/dist/keys/matrices.js +0 -17
  157. package/dist/keys/misc.d.ts +0 -18
  158. package/dist/keys/misc.js +0 -60
  159. package/dist/keys/navigation.d.ts +0 -10
  160. package/dist/keys/navigation.js +0 -13
  161. package/dist/keys/operators.d.ts +0 -9
  162. package/dist/keys/operators.js +0 -11
  163. package/dist/keys/statistics.d.ts +0 -13
  164. package/dist/keys/statistics.js +0 -38
  165. package/dist/keys/sub-sup.d.ts +0 -10
  166. package/dist/keys/sub-sup.js +0 -17
  167. package/dist/keys/trigonometry.d.ts +0 -14
  168. package/dist/keys/trigonometry.js +0 -43
  169. package/dist/keys/utils.d.ts +0 -13
  170. package/dist/keys/utils.js +0 -24
  171. package/dist/keys/vars.d.ts +0 -11
  172. package/dist/keys/vars.js +0 -22
  173. package/dist/math-input.d.ts +0 -30
  174. package/dist/mq/common-mq-styles.d.ts +0 -225
  175. package/dist/mq/common-mq-styles.js +0 -54
  176. package/dist/mq/custom-elements.d.ts +0 -10
  177. package/dist/mq/custom-elements.js +0 -10
  178. package/dist/mq/index.d.ts +0 -12
  179. package/dist/mq/index.js +0 -12
  180. package/dist/mq/input.d.ts +0 -35
  181. package/dist/mq/input.js +0 -83
  182. package/dist/mq/static.d.ts +0 -43
  183. package/dist/mq/static.js +0 -142
  184. package/dist/updateSpans.d.ts +0 -10
  185. package/dist/updateSpans.js +0 -9
@@ -0,0 +1,290 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import debug from 'debug';
4
+ import { updateSpans } from '../updateSpans';
5
+ import { MQ } from './mathquill-instance';
6
+
7
+ const log = debug('pie-lib:math-input:mq:static');
8
+ const REGEX = /\\MathQuillMathField\[r\d*\]\{(.*?)\}/g;
9
+ const WHITESPACE_REGEX = / /g;
10
+
11
+ function stripSpaces(string = '') {
12
+ return string.replace(WHITESPACE_REGEX, '');
13
+ }
14
+
15
+ function countBraces(latex) {
16
+ let count = 0;
17
+
18
+ for (let i = 0; i < (latex || '').length; i++) {
19
+ if (latex[i] === '{') {
20
+ count++;
21
+ }
22
+ }
23
+
24
+ return count;
25
+ }
26
+
27
+ /**
28
+ * Wrapper for MathQuill MQ.MathField.
29
+ */
30
+ export default class Static extends React.Component {
31
+ static propTypes = {
32
+ latex: PropTypes.string.isRequired,
33
+ onFocus: PropTypes.func,
34
+ onBlur: PropTypes.func,
35
+ className: PropTypes.string,
36
+ getFieldName: PropTypes.func,
37
+ onSubFieldChange: PropTypes.func,
38
+ onSubFieldFocus: PropTypes.func,
39
+ setInput: PropTypes.func,
40
+ };
41
+
42
+ static defaultProps = {
43
+ getFieldName: () => {},
44
+ };
45
+
46
+ constructor(props) {
47
+ super(props);
48
+ this.state = {
49
+ announcement: '',
50
+ previousLatex: '',
51
+ inputSource: null,
52
+ isDeleteKeyPressed: false,
53
+ };
54
+
55
+ this.inputRef = React.createRef();
56
+ }
57
+
58
+ componentDidMount() {
59
+ this.update();
60
+ updateSpans();
61
+
62
+ this.createLiveRegion();
63
+ this.addEventListeners();
64
+ }
65
+
66
+ componentDidUpdate() {
67
+ this.update();
68
+ updateSpans();
69
+ }
70
+
71
+ componentWillUnmount() {
72
+ this.removeLiveRegion();
73
+ this.removeEventListeners();
74
+ }
75
+
76
+ createLiveRegion = () => {
77
+ this.liveRegion = document.createElement('div');
78
+ this.liveRegion.style.position = 'absolute';
79
+ this.liveRegion.style.width = '1px';
80
+ this.liveRegion.style.height = '1px';
81
+ this.liveRegion.style.marginTop = '-1px';
82
+ this.liveRegion.style.clip = 'rect(1px, 1px, 1px, 1px)';
83
+ this.liveRegion.style.overflow = 'hidden';
84
+ this.liveRegion.setAttribute('aria-live', 'polite');
85
+ this.liveRegion.setAttribute('aria-atomic', 'true');
86
+
87
+ document.body.appendChild(this.liveRegion);
88
+ };
89
+
90
+ addEventListeners = () => {
91
+ const input = this.inputRef.current;
92
+
93
+ if (input) {
94
+ input.addEventListener('keydown', this.handleKeyDown);
95
+ input.addEventListener('click', this.handleMathKeyboardClick);
96
+ }
97
+ };
98
+
99
+ removeEventListeners = () => {
100
+ const input = this.inputRef.current;
101
+
102
+ if (input) {
103
+ input.removeEventListener('keydown', this.handleKeyDown);
104
+ input.removeEventListener('click', this.handleMathKeyboardClick);
105
+ }
106
+ };
107
+
108
+ removeLiveRegion = () => {
109
+ if (this.liveRegion) {
110
+ document.body.removeChild(this.liveRegion);
111
+ this.liveRegion = null;
112
+ }
113
+ };
114
+
115
+ handleKeyDown = (event) => {
116
+ if (event?.key === 'Backspace' || event?.key === 'Delete') {
117
+ this.setState({ isDeleteKeyPressed: true });
118
+ }
119
+ this.setState({ inputSource: 'keyboard' });
120
+ };
121
+
122
+ handleMathKeyboardClick = () => {
123
+ this.setState({ inputSource: 'mathKeyboard' });
124
+ };
125
+
126
+ onInputEdit = (field) => {
127
+ if (!this.mathField || this._isProgrammaticUpdate) {
128
+ return;
129
+ }
130
+ const name = this.props.getFieldName(field, this.mathField.innerFields);
131
+
132
+ if (this.props.onSubFieldChange) {
133
+ // eslint-disable-next-line no-useless-escape
134
+ const regexMatch = field.latex().match(/[0-9]\\ \\frac\{[^\{]*\}\{ \}/);
135
+
136
+ if (this.inputRef?.current && regexMatch && regexMatch?.length) {
137
+ try {
138
+ field.__controller.cursor.insLeftOf(field.__controller.cursor.parent[-1].parent);
139
+ field.el().dispatchEvent(new KeyboardEvent('keydown', { keyCode: 8 }));
140
+ } catch (e) {
141
+ // eslint-disable-next-line no-console
142
+ console.error(e.toString());
143
+ }
144
+ } else {
145
+ this.props.onSubFieldChange(name, field.latex());
146
+ }
147
+ }
148
+
149
+ this.announceLatexConversion(field.latex());
150
+ };
151
+
152
+ announceLatexConversion = (newLatex) => {
153
+ if (!this.state) {
154
+ // eslint-disable-next-line no-console
155
+ console.error('State is not initialized');
156
+ return;
157
+ }
158
+
159
+ const { previousLatex, inputSource, isDeleteKeyPressed } = this.state;
160
+ const announcement = 'Converted to math symbol';
161
+
162
+ if (inputSource === 'keyboard' && !isDeleteKeyPressed) {
163
+ const newBraces = countBraces(newLatex);
164
+ const oldBraces = countBraces(previousLatex);
165
+
166
+ if (newBraces > oldBraces) {
167
+ this.announceMessage(announcement);
168
+ } else {
169
+ try {
170
+ this.mathField.parseLatex(previousLatex);
171
+ this.mathField.parseLatex(newLatex);
172
+
173
+ if (newLatex == previousLatex) {
174
+ this.announceMessage(announcement);
175
+ }
176
+ } catch (e) {
177
+ // eslint-disable-next-line no-console
178
+ console.warn('Error parsing latex:', e.message);
179
+ // eslint-disable-next-line no-console
180
+ console.warn(e);
181
+ }
182
+ }
183
+ }
184
+
185
+ // Only setState when values change to avoid "Maximum update depth exceeded"
186
+ if (this.state.previousLatex !== newLatex || this.state.isDeleteKeyPressed) {
187
+ this.setState({ previousLatex: newLatex, isDeleteKeyPressed: false });
188
+ }
189
+ };
190
+
191
+ announceMessage = (message) => {
192
+ this.setState({ previousLatex: '' });
193
+
194
+ if (this.liveRegion) {
195
+ this.liveRegion.textContent = message;
196
+
197
+ // Clear the message after it is announced
198
+ setTimeout(() => {
199
+ this.liveRegion.textContent = '';
200
+ }, 500);
201
+ }
202
+ };
203
+
204
+ update = () => {
205
+ if (!MQ) {
206
+ throw new Error('MQ is not defined - but component has mounted?');
207
+ }
208
+ if (!this.mathField) {
209
+ this.mathField = MQ.StaticMath(this.inputRef?.current, {
210
+ handlers: {
211
+ edit: this.onInputEdit.bind(this),
212
+ },
213
+ });
214
+ }
215
+
216
+ try {
217
+ this._isProgrammaticUpdate = true;
218
+ this.mathField.parseLatex(this.props.latex);
219
+ this.mathField.latex(this.props.latex);
220
+ } catch (e) {
221
+ // default latex if received has errors
222
+ this.mathField.latex('\\MathQuillMathField[r1]{}');
223
+ } finally {
224
+ this._isProgrammaticUpdate = false;
225
+ }
226
+ };
227
+
228
+
229
+ blur = () => {
230
+ log('blur mathfield');
231
+ this.mathField.blur();
232
+ };
233
+
234
+ focus = () => {
235
+ log('focus mathfield...');
236
+ this.mathField.focus();
237
+ };
238
+
239
+ shouldComponentUpdate(nextProps) {
240
+ try {
241
+ const parsedLatex = this.mathField.parseLatex(nextProps.latex);
242
+ const stripped = stripSpaces(parsedLatex);
243
+ const newFieldCount = (nextProps.latex.match(REGEX) || []).length;
244
+
245
+ const out =
246
+ stripped !== stripSpaces(this.mathField.latex().trim()) ||
247
+ newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;
248
+
249
+ log('[shouldComponentUpdate] ', out);
250
+ return out;
251
+ } catch (e) {
252
+ // eslint-disable-next-line no-console
253
+ console.warn('Error parsing latex:', e.message, 'skip update');
254
+ // eslint-disable-next-line no-console
255
+ console.warn(e);
256
+ return false;
257
+ }
258
+ }
259
+
260
+ onFocus = (e) => {
261
+ try {
262
+ let rootBlock = e.target.parentElement.nextSibling;
263
+ let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);
264
+
265
+ if (!id) {
266
+ rootBlock = rootBlock.parentElement;
267
+ id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);
268
+ }
269
+
270
+ const innerField = this.mathField.innerFields.find((f) => f.id === id);
271
+
272
+ if (innerField) {
273
+ const name = this.props.getFieldName(innerField, this.mathField.innerFields);
274
+ if (this.props.setInput) {
275
+ this.props.setInput(innerField);
276
+ }
277
+ this.props.onSubFieldFocus(name, innerField);
278
+ }
279
+ } catch (err) {
280
+ // eslint-disable-next-line no-console
281
+ console.error('error finding root block', err.message);
282
+ }
283
+ };
284
+
285
+ render() {
286
+ const { onBlur, className } = this.props;
287
+
288
+ return <span className={className} onFocus={this.onFocus} onBlur={onBlur} ref={this.inputRef} />;
289
+ }
290
+ }
@@ -0,0 +1,15 @@
1
+ // increase the font of parallel notation
2
+ const updateSpans = () => {
3
+ const spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));
4
+ (spans || []).forEach((span) => {
5
+ if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {
6
+ span.style.fontSize = '32px';
7
+ }
8
+
9
+ if ((span.innerText === '′' || span.innerText === '′′') && !span.hasAttribute('data-prime')) {
10
+ span.setAttribute('data-prime', 'true');
11
+ }
12
+ });
13
+ };
14
+
15
+ export { updateSpans };
@@ -1,11 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var e = Object.defineProperty, t = (t, n) => {
3
- let r = {};
4
- for (var i in t) e(r, i, {
5
- get: t[i],
6
- enumerable: !0
7
- });
8
- return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
- };
10
- //#endregion
11
- export { t as __exportAll };
@@ -1,31 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/math-input/src/horizontal-keypad.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- import PropTypes from 'prop-types';
11
- export default class HorizontalKeypad extends React.Component {
12
- static propTypes: {
13
- className: PropTypes.Requireable<string>;
14
- controlledKeypadMode: PropTypes.Requireable<boolean>;
15
- mode: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
16
- layoutForKeyPad: PropTypes.Requireable<object>;
17
- onClick: PropTypes.Validator<(...args: any[]) => any>;
18
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
19
- noDecimal: PropTypes.Requireable<boolean>;
20
- additionalKeys: PropTypes.Requireable<any[]>;
21
- setKeypadInteraction: PropTypes.Requireable<(...args: any[]) => any>;
22
- onRequestClose: PropTypes.Requireable<(...args: any[]) => any>;
23
- };
24
- static defaultProps: {
25
- mode: string;
26
- noDecimal: boolean;
27
- additionalKeys: never[];
28
- };
29
- keypadPress: any;
30
- render(): React.JSX.Element;
31
- }
@@ -1,57 +0,0 @@
1
- import { extendKeySet as e } from "./keys/utils.js";
2
- import { keysForGrade as t, normalizeAdditionalKeys as n } from "./keys/grades.js";
3
- import r from "./keypad/accessible-keypad.js";
4
- import i from "react";
5
- import a from "prop-types";
6
- import { jsx as o } from "react/jsx-runtime";
7
- //#region src/horizontal-keypad.tsx
8
- var s = (e) => {
9
- if (e.command) return {
10
- value: e.command,
11
- type: "command"
12
- };
13
- if (e.write) return { value: e.write };
14
- if (e.keystroke) return {
15
- type: "cursor",
16
- value: e.keystroke
17
- };
18
- }, c = class extends i.Component {
19
- static propTypes = {
20
- className: a.string,
21
- controlledKeypadMode: a.bool,
22
- mode: a.oneOfType([a.string, a.number]),
23
- layoutForKeyPad: a.object,
24
- onClick: a.func.isRequired,
25
- onFocus: a.func,
26
- noDecimal: a.bool,
27
- additionalKeys: a.array,
28
- setKeypadInteraction: a.func,
29
- onRequestClose: a.func
30
- };
31
- static defaultProps = {
32
- mode: "scientific",
33
- noDecimal: !1,
34
- additionalKeys: []
35
- };
36
- keypadPress = (e) => {
37
- let { onClick: t } = this.props;
38
- t(s(e));
39
- };
40
- render() {
41
- let { mode: i, onFocus: a, controlledKeypadMode: s, noDecimal: c, className: l, additionalKeys: u, layoutForKeyPad: d, setKeypadInteraction: f, onRequestClose: p } = this.props, m = n(u);
42
- return /* @__PURE__ */ o(r, {
43
- className: l,
44
- controlledKeypadMode: s,
45
- onFocus: a,
46
- noDecimal: c,
47
- layoutForKeyPad: d,
48
- additionalKeys: e(t(i), m),
49
- onPress: this.keypadPress,
50
- mode: i,
51
- setKeypadInteraction: f,
52
- onRequestClose: p
53
- });
54
- }
55
- };
56
- //#endregion
57
- export { c as default };
package/dist/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/math-input/src/index.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import { keysForGrade } from './keys/grades';
10
- import { updateSpans } from './updateSpans';
11
- import * as keys from './keys';
12
- import HorizontalKeypad from './horizontal-keypad';
13
- import * as mq from './mq';
14
- declare const addBrackets: (s: any) => any;
15
- declare const removeBrackets: (s: any) => any;
16
- declare const registerEmbed: (name: any, factory: any) => void;
17
- declare const applyStaticMath: (element: any, latex?: string) => any;
18
- export { keysForGrade, addBrackets, removeBrackets, keys, HorizontalKeypad, mq, updateSpans, registerEmbed, applyStaticMath, };
package/dist/index.js DELETED
@@ -1,19 +0,0 @@
1
- import { keysForGrade as e } from "./keys/grades.js";
2
- import { updateSpans as t } from "./updateSpans.js";
3
- import { keys_exports as n } from "./keys/index.js";
4
- import r from "./horizontal-keypad.js";
5
- import { mq_exports as i } from "./mq/index.js";
6
- import a from "@pie-framework/mathquill";
7
- //#region src/index.tsx
8
- var o = (e) => e.indexOf("\\(") === 0 ? e : `\\(${e}`, s = (e) => e.indexOf("\\)") === e.length - 2 ? e : `${e}\\)`, c = (e) => e.indexOf("\\(") === 0 ? e.substring(2) : e, l = (e) => e.indexOf("\\)") === e.length - 2 ? e.substring(0, e.length - 2) : e, u = (e) => s(o(e)), d = (e) => l(c(e)), f = () => typeof window > "u" ? null : a.getInterface(2), p = (e, t) => {
9
- let n = f();
10
- n?.registerEmbed && n.registerEmbed(e, t);
11
- }, m = (e, n = "") => {
12
- let r = f();
13
- if (!r?.StaticMath || !e) return null;
14
- e.textContent = "";
15
- let i = r.StaticMath(e);
16
- return typeof i?.latex == "function" && i.latex(n), t(e), i;
17
- };
18
- //#endregion
19
- export { r as HorizontalKeypad, u as addBrackets, m as applyStaticMath, n as keys, e as keysForGrade, i as mq, p as registerEmbed, d as removeBrackets, t as updateSpans };
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- export default class AccessibleKeypad extends React.Component {
4
- static propTypes: {
5
- className: PropTypes.Requireable<string>;
6
- controlledKeypadMode: PropTypes.Requireable<boolean>;
7
- baseSet: PropTypes.Requireable<any[]>;
8
- additionalKeys: PropTypes.Requireable<any[]>;
9
- layoutForKeyPad: PropTypes.Requireable<object>;
10
- onPress: PropTypes.Validator<(...args: any[]) => any>;
11
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
12
- noDecimal: PropTypes.Requireable<boolean>;
13
- setKeypadInteraction: PropTypes.Requireable<(...args: any[]) => any>;
14
- mode: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
15
- onRequestClose: PropTypes.Requireable<(...args: any[]) => any>;
16
- };
17
- static defaultProps: {
18
- baseSet: any[][];
19
- noDecimal: boolean;
20
- };
21
- constructor(props: any);
22
- componentDidMount(): void;
23
- componentWillUnmount(): void;
24
- handleKeypadInteraction: () => void;
25
- keyIsNotAllowed: (key: any) => any;
26
- flowKeys: (base: any, extras: any) => unknown[];
27
- toRenderModel: () => {
28
- id: string;
29
- ariaLabel: string;
30
- key: any;
31
- }[];
32
- pressKey: (definition: any) => void;
33
- moveFocus: (nextIndex: any) => void;
34
- onButtonKeyDown: (event: any, index: any) => void;
35
- renderKey: (definition: any, index: any) => React.JSX.Element;
36
- render(): React.JSX.Element;
37
- }