@pie-lib/math-input-mathlive 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +119 -0
  2. package/lib/__tests__/index.test.js +118 -0
  3. package/lib/__tests__/index.test.js.map +1 -0
  4. package/lib/__tests__/latex-bridge.test.js +186 -0
  5. package/lib/__tests__/latex-bridge.test.js.map +1 -0
  6. package/lib/__tests__/mathlive-instance.test.js +137 -0
  7. package/lib/__tests__/mathlive-instance.test.js.map +1 -0
  8. package/lib/horizontal-keypad.js +101 -0
  9. package/lib/horizontal-keypad.js.map +1 -0
  10. package/lib/index.js +143 -0
  11. package/lib/index.js.map +1 -0
  12. package/lib/keypad/index.js +365 -0
  13. package/lib/keypad/index.js.map +1 -0
  14. package/lib/keypad/keys-layout.js +22 -0
  15. package/lib/keypad/keys-layout.js.map +1 -0
  16. package/lib/keys/basic-operators.js +33 -0
  17. package/lib/keys/basic-operators.js.map +1 -0
  18. package/lib/keys/chars.js +12 -0
  19. package/lib/keys/chars.js.map +1 -0
  20. package/lib/keys/comparison.js +39 -0
  21. package/lib/keys/comparison.js.map +1 -0
  22. package/lib/keys/constants.js +37 -0
  23. package/lib/keys/constants.js.map +1 -0
  24. package/lib/keys/digits.js +46 -0
  25. package/lib/keys/digits.js.map +1 -0
  26. package/lib/keys/edit.js +14 -0
  27. package/lib/keys/edit.js.map +1 -0
  28. package/lib/keys/exponent.js +30 -0
  29. package/lib/keys/exponent.js.map +1 -0
  30. package/lib/keys/fractions.js +29 -0
  31. package/lib/keys/fractions.js.map +1 -0
  32. package/lib/keys/geometry.js +140 -0
  33. package/lib/keys/geometry.js.map +1 -0
  34. package/lib/keys/grades.js +259 -0
  35. package/lib/keys/grades.js.map +1 -0
  36. package/lib/keys/index.js +35 -0
  37. package/lib/keys/index.js.map +1 -0
  38. package/lib/keys/log.js +27 -0
  39. package/lib/keys/log.js.map +1 -0
  40. package/lib/keys/logic.js +19 -0
  41. package/lib/keys/logic.js.map +1 -0
  42. package/lib/keys/matrices.js +19 -0
  43. package/lib/keys/matrices.js.map +1 -0
  44. package/lib/keys/misc.js +62 -0
  45. package/lib/keys/misc.js.map +1 -0
  46. package/lib/keys/navigation.js +20 -0
  47. package/lib/keys/navigation.js.map +1 -0
  48. package/lib/keys/operators.js +15 -0
  49. package/lib/keys/operators.js.map +1 -0
  50. package/lib/keys/statistics.js +40 -0
  51. package/lib/keys/statistics.js.map +1 -0
  52. package/lib/keys/sub-sup.js +19 -0
  53. package/lib/keys/sub-sup.js.map +1 -0
  54. package/lib/keys/trigonometry.js +45 -0
  55. package/lib/keys/trigonometry.js.map +1 -0
  56. package/lib/keys/utils.js +87 -0
  57. package/lib/keys/utils.js.map +1 -0
  58. package/lib/keys/vars.js +24 -0
  59. package/lib/keys/vars.js.map +1 -0
  60. package/lib/latex-bridge.js +195 -0
  61. package/lib/latex-bridge.js.map +1 -0
  62. package/lib/math-input.js +143 -0
  63. package/lib/math-input.js.map +1 -0
  64. package/lib/mathlive-instance.js +319 -0
  65. package/lib/mathlive-instance.js.map +1 -0
  66. package/lib/mf/common-styles.js +111 -0
  67. package/lib/mf/common-styles.js.map +1 -0
  68. package/lib/mf/index.js +72 -0
  69. package/lib/mf/index.js.map +1 -0
  70. package/lib/mf/input.js +266 -0
  71. package/lib/mf/input.js.map +1 -0
  72. package/lib/mf/static.js +396 -0
  73. package/lib/mf/static.js.map +1 -0
  74. package/package.json +31 -0
  75. package/src/__tests__/index.test.jsx +109 -0
  76. package/src/__tests__/latex-bridge.test.js +151 -0
  77. package/src/__tests__/mathlive-instance.test.js +130 -0
  78. package/src/horizontal-keypad.jsx +73 -0
  79. package/src/index.jsx +63 -0
  80. package/src/keypad/index.jsx +335 -0
  81. package/src/keypad/keys-layout.js +16 -0
  82. package/src/keys/basic-operators.js +32 -0
  83. package/src/keys/chars.js +5 -0
  84. package/src/keys/comparison.js +28 -0
  85. package/src/keys/constants.js +35 -0
  86. package/src/keys/digits.js +40 -0
  87. package/src/keys/edit.js +3 -0
  88. package/src/keys/exponent.js +28 -0
  89. package/src/keys/fractions.js +26 -0
  90. package/src/keys/geometry.js +144 -0
  91. package/src/keys/grades.js +367 -0
  92. package/src/keys/index.js +20 -0
  93. package/src/keys/log.js +22 -0
  94. package/src/keys/logic.js +15 -0
  95. package/src/keys/matrices.js +15 -0
  96. package/src/keys/misc.js +65 -0
  97. package/src/keys/navigation.js +8 -0
  98. package/src/keys/operators.js +10 -0
  99. package/src/keys/statistics.js +38 -0
  100. package/src/keys/sub-sup.js +15 -0
  101. package/src/keys/trigonometry.js +15 -0
  102. package/src/keys/utils.js +66 -0
  103. package/src/keys/vars.js +19 -0
  104. package/src/latex-bridge.js +190 -0
  105. package/src/math-input.jsx +115 -0
  106. package/src/mathlive-instance.js +286 -0
  107. package/src/mf/common-styles.js +108 -0
  108. package/src/mf/index.js +26 -0
  109. package/src/mf/input.jsx +223 -0
  110. package/src/mf/static.jsx +358 -0
@@ -0,0 +1,367 @@
1
+ import * as comparison from './comparison';
2
+ import * as vars from './vars';
3
+ import * as fractions from './fractions';
4
+ import * as exponent from './exponent';
5
+ import * as misc from './misc';
6
+ import * as constants from './constants';
7
+ import * as trigonometry from './trigonometry';
8
+ import * as geometry from './geometry';
9
+ import * as operators from './operators';
10
+ import * as log from './log';
11
+ import * as subSup from './sub-sup';
12
+ import * as statistics from './statistics';
13
+ import * as basicOperators from './basic-operators';
14
+ import * as matrices from './matrices';
15
+ import digits from './digits';
16
+ import * as logic from './logic';
17
+ import * as nav from './navigation';
18
+ import * as edit from './edit';
19
+
20
+ const hs = [
21
+ [fractions.blankOverBlank, misc.percentage, vars.x, exponent.squared, exponent.squareRoot],
22
+ [operators.circleDot, vars.y, subSup.subscript, exponent.xToPowerOfN, exponent.nthRoot],
23
+ [misc.plusMinus, comparison.lessThan, comparison.greaterThan, comparison.lessThanEqual, comparison.greaterThanEqual],
24
+ [constants.pi, vars.theta, misc.parenthesis, misc.brackets, misc.absValue],
25
+ [misc.notEqual, trigonometry.sin, trigonometry.cos, trigonometry.tan, geometry.degree],
26
+ ];
27
+
28
+ const advancedAlgebra = (() => {
29
+ const out = [...hs.map((arr) => [...arr])];
30
+
31
+ out[0].push({ name: 'i', latex: 'i', write: 'i' });
32
+ out[1].push(log.log);
33
+ out[2].push(log.logSubscript);
34
+ out[3].push(log.ln);
35
+ out[4].push(constants.eulers);
36
+ return out;
37
+ })();
38
+
39
+ const statisticsSet = (() => {
40
+ const out = [...hs.map((arr) => [...arr])];
41
+ out[0].push(statistics.mu);
42
+ out[1].push(statistics.xBar);
43
+ out[2].push(statistics.yBar);
44
+ out[3].push(statistics.sigma);
45
+ out[4].push(statistics.smallSigma);
46
+ return out;
47
+ })();
48
+
49
+ export const gradeSets = [
50
+ {
51
+ predicate: (n) => n >= 3 && n <= 5,
52
+ set: [
53
+ [comparison.lessThan, comparison.greaterThan],
54
+ [fractions.xOverBlank, fractions.xBlankBlank],
55
+ [vars.x, logic.longDivision],
56
+ [exponent.squared, exponent.xToPowerOfN],
57
+ ],
58
+ },
59
+ {
60
+ predicate: (n) => n >= 6 && n <= 7,
61
+ set: [
62
+ [geometry.degree, comparison.lessThan, comparison.greaterThan],
63
+ [operators.circleDot, comparison.lessThanEqual, comparison.greaterThanEqual],
64
+ [vars.x, vars.y, exponent.squared, exponent.xToPowerOfN],
65
+ [misc.plusMinus, fractions.xOverBlank, fractions.xBlankBlank, exponent.squareRoot],
66
+ [constants.pi, misc.parenthesis, misc.absValue, exponent.nthRoot],
67
+ ],
68
+ },
69
+ {
70
+ predicate: (n) => n >= 8 || n === 'HS',
71
+ set: hs,
72
+ },
73
+ {
74
+ predicate: 'non-negative-integers',
75
+ set: [
76
+ [digits.seven, digits.eight, digits.nine],
77
+ [digits.four, digits.five, digits.six],
78
+ [digits.one, digits.two, digits.three],
79
+ [digits.zero, { name: '', latex: '', write: '' }, { name: '', latex: '', write: '' }],
80
+ [nav.left, nav.right, edit.del],
81
+ ],
82
+ },
83
+ {
84
+ predicate: 'integers',
85
+ set: [
86
+ [digits.seven, digits.eight, digits.nine],
87
+ [digits.four, digits.five, digits.six],
88
+ [digits.one, digits.two, digits.three],
89
+ [digits.zero, { name: '', latex: '', write: '' }, basicOperators.minus],
90
+ [nav.left, nav.right, edit.del],
91
+ ],
92
+ },
93
+ {
94
+ predicate: 'decimals',
95
+ set: [
96
+ [digits.seven, digits.eight, digits.nine],
97
+ [digits.four, digits.five, digits.six],
98
+ [digits.one, digits.two, digits.three],
99
+ [digits.zero, digits.decimalPoint, basicOperators.minus],
100
+ [nav.left, nav.right, edit.del],
101
+ ],
102
+ },
103
+ {
104
+ predicate: 'fractions',
105
+ set: [
106
+ [digits.seven, digits.eight, digits.nine],
107
+ [digits.four, digits.five, digits.six],
108
+ [digits.one, digits.two, digits.three],
109
+ [digits.zero, fractions.blankOverBlank, basicOperators.minus],
110
+ [nav.left, nav.right, edit.del],
111
+ ],
112
+ },
113
+ {
114
+ predicate: 'geometry',
115
+ set: [
116
+ [
117
+ fractions.blankOverBlank,
118
+ geometry.degree,
119
+ geometry.primeArcminute,
120
+ geometry.doublePrimeArcSecond,
121
+ geometry.congruentTo,
122
+ geometry.similarTo,
123
+ ],
124
+ [
125
+ operators.circleDot,
126
+ geometry.angle,
127
+ geometry.measureOfAngle,
128
+ geometry.triangle,
129
+ geometry.notCongruentTo,
130
+ misc.notSimilar,
131
+ ],
132
+ [trigonometry.sin, trigonometry.cos, trigonometry.tan, constants.pi, exponent.squareRoot, exponent.nthRoot],
133
+ [trigonometry.csc, trigonometry.sec, trigonometry.cot, vars.theta, subSup.subscript, exponent.xToPowerOfN],
134
+ [
135
+ geometry.overline,
136
+ geometry.overRightArrow,
137
+ geometry.overLeftRightArrow,
138
+ geometry.overArc,
139
+ geometry.perpindicular,
140
+ geometry.parallel,
141
+ ],
142
+ ],
143
+ },
144
+ // {
145
+ // predicate: 'miscellaneous',
146
+ // set: [
147
+ // [
148
+ // subSup.superscript,
149
+ // subSup.subscript,
150
+ // fractions.blankOverBlank,
151
+ // misc.percentage,
152
+ // geometry.segment,
153
+ // geometry.parallel
154
+ // ],
155
+ // [
156
+ // exponent.squareRoot,
157
+ // exponent.nthRoot,
158
+ // misc.absValue,
159
+ // misc.parenthesis,
160
+ // geometry.perpindicular,
161
+ // geometry.angle
162
+ // ],
163
+ // [
164
+ // comparison.lessThan,
165
+ // comparison.greaterThan,
166
+ // geometry.degree,
167
+ // misc.approx,
168
+ // geometry.measureOfAngle,
169
+ // geometry.triangle
170
+ // ],
171
+ // [
172
+ // misc.nApprox,
173
+ // misc.notEqual,
174
+ // geometry.congruentTo,
175
+ // geometry.notCongruentTo,
176
+ // geometry.parallelogram,
177
+ // geometry.circledDot
178
+ // ],
179
+ // [
180
+ // misc.similar,
181
+ // misc.notSimilar,
182
+ // comparison.lessThanEqual,
183
+ // comparison.greaterThanEqual,
184
+ // vars.x,
185
+ // vars.y
186
+ // ]
187
+ // ]
188
+ // },
189
+ // {
190
+ // predicate: 'everything',
191
+ // set: [
192
+ // [
193
+ // subSup.superscript,
194
+ // subSup.subscript,
195
+ // fractions.blankOverBlank,
196
+ // misc.percentage,
197
+ // geometry.segment,
198
+ // geometry.parallel
199
+ // ],
200
+ // [
201
+ // exponent.squareRoot,
202
+ // exponent.nthRoot,
203
+ // misc.absValue,
204
+ // misc.parenthesis,
205
+ // geometry.perpindicular,
206
+ // geometry.angle
207
+ // ],
208
+ // [
209
+ // comparison.lessThan,
210
+ // comparison.greaterThan,
211
+ // geometry.degree,
212
+ // misc.approx,
213
+ // geometry.measureOfAngle,
214
+ // geometry.triangle
215
+ // ],
216
+ // [
217
+ // misc.nApprox,
218
+ // misc.notEqual,
219
+ // geometry.congruentTo,
220
+ // geometry.notCongruentTo,
221
+ // geometry.parallelogram,
222
+ // geometry.circledDot
223
+ // ],
224
+ // [
225
+ // misc.similar,
226
+ // misc.notSimilar,
227
+ // comparison.lessThanEqual,
228
+ // comparison.greaterThanEqual,
229
+ // vars.x,
230
+ // vars.y
231
+ // ]
232
+ // ]
233
+ // },
234
+ {
235
+ predicate: 'advanced-algebra',
236
+ set: advancedAlgebra,
237
+ },
238
+ {
239
+ predicate: 'statistics',
240
+ set: statisticsSet,
241
+ },
242
+ {
243
+ predicate: 'item-authoring',
244
+ set: [
245
+ [
246
+ basicOperators.divide,
247
+ fractions.blankOverBlank,
248
+ logic.longDivision,
249
+ constants.halfInfinity,
250
+ exponent.squared,
251
+ exponent.squareRoot,
252
+ geometry.overline,
253
+ geometry.overRightArrow,
254
+ geometry.overLeftRightArrow,
255
+ log.log,
256
+ ],
257
+ [
258
+ basicOperators.multiply,
259
+ operators.circleDot,
260
+ { name: '', latex: '', write: '' },
261
+ subSup.subscript,
262
+ exponent.xToPowerOfN,
263
+ exponent.nthRoot,
264
+ geometry.perpindicular,
265
+ geometry.parallel,
266
+ geometry.overArc,
267
+ log.logSubscript,
268
+ ],
269
+ [
270
+ misc.plusMinus,
271
+ constants.pi,
272
+ vars.theta,
273
+ geometry.degree,
274
+ geometry.angle,
275
+ geometry.leftArrow,
276
+ geometry.rightArrow,
277
+ geometry.triangle,
278
+ geometry.square,
279
+ log.ln,
280
+ ],
281
+ [
282
+ misc.notEqual,
283
+ misc.absValue,
284
+ statistics.smallSigma,
285
+ statistics.mu,
286
+ logic.therefore,
287
+ statistics.sigma,
288
+ geometry.leftrightArrow,
289
+ trigonometry.sin,
290
+ trigonometry.cos,
291
+ trigonometry.tan,
292
+ ],
293
+ [
294
+ comparison.lessThanEqual,
295
+ comparison.greaterThanEqual,
296
+ { name: '', latex: '', write: '' },
297
+ { name: '', latex: '', write: '' },
298
+ constants.infinity,
299
+ { name: '', latex: '', write: '' },
300
+ { name: '', latex: '', write: '' },
301
+ trigonometry.csc,
302
+ trigonometry.sec,
303
+ trigonometry.cot,
304
+ ],
305
+ ],
306
+ },
307
+ // for grade 1-2, we want to display the base set only
308
+ // we need it here because we don't want to display the default set (grade 8)
309
+ {
310
+ predicate: (n) => n >= 1 && n <= 2,
311
+ set: [],
312
+ },
313
+ ];
314
+
315
+ export const keysForGrade = (n) => {
316
+ const number = parseInt(n, 10);
317
+ n = isNaN(number) ? n : number;
318
+ if (!n) {
319
+ return [];
320
+ }
321
+
322
+ const match = gradeSets.find((gs) => {
323
+ if (typeof gs.predicate === 'string') {
324
+ return gs.predicate === n;
325
+ } else {
326
+ return gs.predicate(n);
327
+ }
328
+ });
329
+
330
+ if (match) {
331
+ return match.set || [];
332
+ }
333
+
334
+ // if the grade is not found, return the default set which is grade 8 (as per PD-3549), for mode language it is not the default
335
+ if (n !== 'language') {
336
+ return gradeSets[2].set;
337
+ }
338
+ };
339
+
340
+ const ALL_KEYS = [
341
+ ...Object.values(basicOperators),
342
+ ...Object.values(comparison),
343
+ ...Object.values(constants),
344
+ ...Object.values(digits),
345
+ ...Object.values(exponent),
346
+ ...Object.values(fractions),
347
+ ...Object.values(geometry),
348
+ ...Object.values(log),
349
+ ...Object.values(matrices),
350
+ ...Object.values(misc),
351
+ ...Object.values(operators),
352
+ ...Object.values(statistics),
353
+ ...Object.values(subSup),
354
+ ...Object.values(trigonometry),
355
+ ...Object.values(vars),
356
+ ];
357
+
358
+ export const normalizeAdditionalKeys = (additionalKeys) => {
359
+ return (additionalKeys || []).map((additionalkey) => {
360
+ const { latex } = additionalkey;
361
+ const predefinedKey = (ALL_KEYS || []).find(
362
+ (key) => latex === key.latex || latex === key.write || latex === key.command || latex === key.otherNotation,
363
+ );
364
+
365
+ return !latex ? additionalkey : predefinedKey || additionalkey;
366
+ });
367
+ };
@@ -0,0 +1,20 @@
1
+ import digits from './digits';
2
+ import * as nav from './navigation';
3
+ import * as edit from './edit';
4
+ import { divide, equals, minus, multiply, plus } from './basic-operators';
5
+ import * as comparison from './comparison';
6
+ import * as fractions from './fractions';
7
+ import * as exponent from './exponent';
8
+ import * as misc from './misc';
9
+
10
+ const { one, two, three, four, five, six, seven, eight, nine, zero, comma, decimalPoint } = digits;
11
+
12
+ export const baseSet = [
13
+ [seven, eight, nine, divide],
14
+ [four, five, six, multiply],
15
+ [one, two, three, minus],
16
+ [zero, decimalPoint, comma, plus],
17
+ [nav.left, nav.right, edit.del, equals],
18
+ ];
19
+
20
+ export { comparison, fractions, exponent, misc };
@@ -0,0 +1,22 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('log');
4
+
5
+ export const log = set({
6
+ name: 'Log',
7
+ label: 'log',
8
+ command: '\\log',
9
+ latex: '\\log',
10
+ });
11
+ export const logSubscript = set({
12
+ name: 'log base n',
13
+ label: 'log s',
14
+ latex: '\\log_{}',
15
+ command: ['\\log', '_'],
16
+ });
17
+ export const ln = set({
18
+ name: 'natural log',
19
+ label: 'ln',
20
+ command: '\\ln',
21
+ latex: '\\ln',
22
+ });
@@ -0,0 +1,15 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('logic');
4
+
5
+ export const therefore = set({
6
+ name: 'Therefore',
7
+ label: '∴',
8
+ write: '∴',
9
+ });
10
+
11
+ export const longDivision = set({
12
+ name: 'Long division',
13
+ latex: '\\longdiv{}',
14
+ command: '\\longdiv',
15
+ });
@@ -0,0 +1,15 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('matrices');
4
+
5
+ export const singleCellMatrix = set({
6
+ name: 'Single Cell Matrix',
7
+ label: '[ ]',
8
+ write: '\\begin{pmatrix}\\end{pmatrix}',
9
+ });
10
+
11
+ export const doubleCellMatrix = set({
12
+ name: 'Double Cell Matrix',
13
+ label: '[ ] [ ] \\\\newline [ ] [ ]',
14
+ write: '\\begin{bmatrix}&\\\\&\\end{bmatrix}',
15
+ });
@@ -0,0 +1,65 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('misc');
4
+
5
+ export const plusMinus = set({
6
+ name: 'Plus or Minus',
7
+ latex: '\\pm',
8
+ write: '\\pm',
9
+ });
10
+
11
+ export const absValue = set({
12
+ name: 'Absolute Value',
13
+ latex: '\\abs{}',
14
+ symbol: '| |',
15
+ command: '|',
16
+ });
17
+
18
+ export const parenthesis = set({
19
+ name: 'Parenthesis',
20
+ latex: '\\left(\\right)',
21
+ symbol: '( )',
22
+ command: '(',
23
+ });
24
+
25
+ export const brackets = set({
26
+ name: 'Brackets',
27
+ latex: '\\left[\\right]',
28
+ symbol: '[ ]',
29
+ command: '[',
30
+ });
31
+
32
+ export const percentage = set({
33
+ name: 'Percent',
34
+ latex: '%',
35
+ command: '%',
36
+ });
37
+
38
+ export const approx = set({
39
+ latex: '\\approx',
40
+ command: '\\approx',
41
+ ariaLabel: 'Approximately equal to',
42
+ });
43
+
44
+ export const nApprox = set({
45
+ latex: '\\napprox',
46
+ command: '\\napprox',
47
+ ariaLabel: 'Not pproximately equal to',
48
+ });
49
+
50
+ export const notEqual = set({
51
+ latex: '\\neq',
52
+ command: '\\neq',
53
+ ariaLabel: 'Not equals',
54
+ });
55
+
56
+ export const similar = set({
57
+ latex: '\\sim',
58
+ command: '\\sim',
59
+ ariaLabel: 'Similar',
60
+ });
61
+ export const notSimilar = set({
62
+ latex: '\\nsim',
63
+ command: '\\nsim',
64
+ ariaLabel: 'Not similar',
65
+ });
@@ -0,0 +1,8 @@
1
+ import { LEFT_ARROW, RIGHT_ARROW } from './chars';
2
+ import { mkSet } from './utils';
3
+
4
+ const set = mkSet('navigation');
5
+
6
+ export const left = set({ label: LEFT_ARROW, keystroke: 'Left', ariaLabel: 'Move cursor left' });
7
+
8
+ export const right = set({ label: RIGHT_ARROW, keystroke: 'Right', ariaLabel: 'Move cursor right' });
@@ -0,0 +1,10 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('operators');
4
+
5
+ export const circleDot = set({
6
+ name: 'CircleDot',
7
+ label: '⋅',
8
+ write: '\\cdot',
9
+ ariaLabel: 'Dot multiplier',
10
+ });
@@ -0,0 +1,38 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('statistics');
4
+ export const xBar = set({
5
+ name: 'X Bar',
6
+ label: 'x̄',
7
+ latex: '\\overline{x}',
8
+ write: '\\overline{x}',
9
+ });
10
+
11
+ export const yBar = set({
12
+ name: 'Y Bar',
13
+ latex: '\\overline{y}',
14
+ write: '\\overline{y}',
15
+ });
16
+
17
+ export const mu = set({
18
+ name: 'mu',
19
+ label: 'mu',
20
+ latex: '\\mu',
21
+ write: '\\mu',
22
+ });
23
+
24
+ export const sigma = set({
25
+ name: 'Sigma',
26
+ ariaLabel: 'Uppercase Sigma',
27
+ label: '\\Sigma',
28
+ latex: '\\Sigma',
29
+ write: '\\Sigma',
30
+ });
31
+
32
+ export const smallSigma = set({
33
+ name: 'sigma',
34
+ ariaLabel: 'Lowercase Sigma',
35
+ label: '\\sigma',
36
+ latex: '\\sigma',
37
+ write: '\\sigma',
38
+ });
@@ -0,0 +1,15 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('sub-sup');
4
+
5
+ export const superscript = set({
6
+ name: 'Superscript',
7
+ latex: 'x^{}',
8
+ command: '^',
9
+ });
10
+
11
+ export const subscript = set({
12
+ name: 'Subscript',
13
+ latex: 'x_{}',
14
+ command: '_',
15
+ });
@@ -0,0 +1,15 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('trigonometry');
4
+
5
+ export const sin = set({ name: 'sine', label: 'sin', command: '\\sin', latex: '\\sin' });
6
+
7
+ export const cos = set({ name: 'cosine', label: 'cos', command: '\\cos', latex: '\\cos' });
8
+
9
+ export const tan = set({ name: 'tanget', label: 'tan', command: '\\tan', latex: '\\tan' });
10
+
11
+ export const sec = set({ name: 'secant', label: 'sec', command: '\\sec', latex: '\\sec' });
12
+
13
+ export const csc = set({ name: 'cosecant', label: 'csc', command: '\\csc', latex: '\\csc' });
14
+
15
+ export const cot = set({ name: 'cotangent', label: 'cot', command: '\\cot', latex: '\\cot' });
@@ -0,0 +1,66 @@
1
+ import { flatten, times } from 'lodash-es';
2
+
3
+ export const mkSet = (category) => (o) => ({ ...o, category });
4
+
5
+ export const toArray = (o) => Object.keys(o).map((k) => o[k]);
6
+
7
+ export const toKey = (category) => (v) => {
8
+ if (typeof v === 'string') {
9
+ return {
10
+ name: v,
11
+ label: v,
12
+ category,
13
+ write: v,
14
+ };
15
+ } else {
16
+ return {
17
+ ...v,
18
+ category,
19
+ };
20
+ }
21
+ };
22
+
23
+ export const transformToKeySetStructure = (data = []) => {
24
+ const structure = [];
25
+
26
+ times(5, () => structure.push([]));
27
+
28
+ let ln = data.length;
29
+ let i = 0;
30
+ let j = 0;
31
+
32
+ while (j < ln) {
33
+ structure[i++].push(data[j++]);
34
+
35
+ if (i === 5) {
36
+ i = 0;
37
+ }
38
+ }
39
+
40
+ return structure;
41
+ };
42
+
43
+ const latexAndNameDontExist = (base) => (k) => {
44
+ const flattened = flatten(base);
45
+ const latexExists = flattened.some((b) => b.latex === k.latex);
46
+ const nameExists = flattened.some((b) => b.name === k.name);
47
+
48
+ return !latexExists && !nameExists;
49
+ };
50
+
51
+ export const extendKeySet = (base = [], keySetData = []) => {
52
+ keySetData = keySetData.filter(latexAndNameDontExist(base));
53
+
54
+ const final = [];
55
+
56
+ times(5 - base.length, () => base.push([]));
57
+ times(5, () => final.push([]));
58
+
59
+ const extra = transformToKeySetStructure(keySetData);
60
+
61
+ for (let i = 0; i < 5; i++) {
62
+ final[i] = [...base[i], ...extra[i]];
63
+ }
64
+
65
+ return final;
66
+ };
@@ -0,0 +1,19 @@
1
+ import { mkSet } from './utils';
2
+
3
+ const set = mkSet('vars');
4
+
5
+ export const x = set({
6
+ name: 'X',
7
+ latex: 'x',
8
+ write: 'x',
9
+ });
10
+ export const y = set({
11
+ name: 'Y',
12
+ latex: 'y',
13
+ write: 'y',
14
+ });
15
+ export const theta = set({
16
+ name: 'Theta',
17
+ latex: '\\theta',
18
+ write: '\\theta',
19
+ });