@oat-sa/tao-core-ui 1.67.0 → 2.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 (239) hide show
  1. package/README.md +17 -16
  2. package/dist/animable/absorbable/css/absorb.css +25 -29
  3. package/dist/animable/absorbable/css/absorb.css.map +1 -1
  4. package/dist/animable/pulsable/css/pulse.css +20 -23
  5. package/dist/animable/pulsable/css/pulse.css.map +1 -1
  6. package/dist/autocomplete/css/autocomplete.css +20 -21
  7. package/dist/autocomplete/css/autocomplete.css.map +1 -1
  8. package/dist/badge/css/badge.css +67 -79
  9. package/dist/badge/css/badge.css.map +1 -1
  10. package/dist/breadcrumbs/css/breadcrumbs.css +54 -61
  11. package/dist/breadcrumbs/css/breadcrumbs.css.map +1 -1
  12. package/dist/bulkActionPopup/css/bulkActionPopup.css +27 -42
  13. package/dist/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
  14. package/dist/calculator/css/calculator.css +91 -112
  15. package/dist/calculator/css/calculator.css.map +1 -1
  16. package/dist/class/css/selector.css +83 -97
  17. package/dist/class/css/selector.css.map +1 -1
  18. package/dist/component/css/components.css +351 -406
  19. package/dist/component/css/components.css.map +1 -1
  20. package/dist/component/css/windowComponent.css +19 -28
  21. package/dist/component/css/windowComponent.css.map +1 -1
  22. package/dist/contextualPopup/css/contextualPopup.css +42 -55
  23. package/dist/contextualPopup/css/contextualPopup.css.map +1 -1
  24. package/dist/dashboard/css/dashboard.css +43 -57
  25. package/dist/dashboard/css/dashboard.css.map +1 -1
  26. package/dist/datalist/css/datalist.css +63 -88
  27. package/dist/datalist/css/datalist.css.map +1 -1
  28. package/dist/datatable/css/datatable.css +84 -113
  29. package/dist/datatable/css/datatable.css.map +1 -1
  30. package/dist/dateRange/css/dateRange.css +1 -2
  31. package/dist/dateRange/css/dateRange.css.map +1 -1
  32. package/dist/datetime/css/picker.css +71 -103
  33. package/dist/datetime/css/picker.css.map +1 -1
  34. package/dist/destination/css/selector.css +17 -24
  35. package/dist/destination/css/selector.css.map +1 -1
  36. package/dist/documentViewer/css/documentViewer.css +137 -162
  37. package/dist/documentViewer/css/documentViewer.css.map +1 -1
  38. package/dist/dropdown/css/dropdown.css +55 -72
  39. package/dist/dropdown/css/dropdown.css.map +1 -1
  40. package/dist/dynamicComponent/css/dynamicComponent.css +78 -91
  41. package/dist/dynamicComponent/css/dynamicComponent.css.map +1 -1
  42. package/dist/form/css/dropdownForm.css +36 -45
  43. package/dist/form/css/dropdownForm.css.map +1 -1
  44. package/dist/form/css/form.css +12 -16
  45. package/dist/form/css/form.css.map +1 -1
  46. package/dist/form/validator/css/validator.css +5 -7
  47. package/dist/form/validator/css/validator.css.map +1 -1
  48. package/dist/form/widget/css/widget.css +26 -34
  49. package/dist/form/widget/css/widget.css.map +1 -1
  50. package/dist/generis/form/css/form.css +14 -18
  51. package/dist/generis/form/css/form.css.map +1 -1
  52. package/dist/generis/validator/css/validator.css +5 -7
  53. package/dist/generis/validator/css/validator.css.map +1 -1
  54. package/dist/generis/widget/css/widget.css +29 -38
  55. package/dist/generis/widget/css/widget.css.map +1 -1
  56. package/dist/itemButtonList/css/item-button-list.css +135 -172
  57. package/dist/itemButtonList/css/item-button-list.css.map +1 -1
  58. package/dist/listbox/css/listbox.css +64 -84
  59. package/dist/listbox/css/listbox.css.map +1 -1
  60. package/dist/loadingButton/css/button.css +20 -29
  61. package/dist/loadingButton/css/button.css.map +1 -1
  62. package/dist/maths/calculator/basicCalculator.js +4 -4
  63. package/dist/maths/calculator/calculatorComponent.js +22 -25
  64. package/dist/maths/calculator/core/board.js +12327 -720
  65. package/dist/maths/calculator/core/labels.js +7918 -138
  66. package/dist/maths/calculator/core/plugin.js +4 -5
  67. package/dist/maths/calculator/css/calculator.css +224 -270
  68. package/dist/maths/calculator/css/calculator.css.map +1 -1
  69. package/dist/maths/calculator/defaultCalculator.js +10 -6
  70. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +23 -25
  71. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +7973 -194
  72. package/dist/maths/calculator/scientificCalculator.js +7 -12
  73. package/dist/mediaplayer/css/player.css +281 -370
  74. package/dist/mediaplayer/css/player.css.map +1 -1
  75. package/dist/pagination/css/pagination.css +38 -49
  76. package/dist/pagination/css/pagination.css.map +1 -1
  77. package/dist/propertySelector/css/propertySelector.css +34 -44
  78. package/dist/propertySelector/css/propertySelector.css.map +1 -1
  79. package/dist/resource/css/selector.css +400 -490
  80. package/dist/resource/css/selector.css.map +1 -1
  81. package/dist/resourcemgr/css/resourcemgr.css +192 -237
  82. package/dist/resourcemgr/css/resourcemgr.css.map +1 -1
  83. package/dist/searchModal/css/advancedSearch.css +92 -121
  84. package/dist/searchModal/css/advancedSearch.css.map +1 -1
  85. package/dist/searchModal/css/searchModal.css +261 -333
  86. package/dist/searchModal/css/searchModal.css.map +1 -1
  87. package/dist/switch/css/switch.css +36 -47
  88. package/dist/switch/css/switch.css.map +1 -1
  89. package/dist/tabs/css/tabs.css +32 -40
  90. package/dist/tabs/css/tabs.css.map +1 -1
  91. package/dist/taskQueue/css/taskQueue.css +17 -27
  92. package/dist/taskQueue/css/taskQueue.css.map +1 -1
  93. package/dist/taskQueueButton/css/taskable.css +1 -2
  94. package/dist/taskQueueButton/css/taskable.css.map +1 -1
  95. package/dist/taskQueueButton/css/treeButton.css +20 -26
  96. package/dist/taskQueueButton/css/treeButton.css.map +1 -1
  97. package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css +3 -5
  98. package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
  99. package/dist/waitingDialog/css/waitingDialog.css +18 -23
  100. package/dist/waitingDialog/css/waitingDialog.css.map +1 -1
  101. package/package.json +20 -24
  102. package/scss/inc/_base.scss +9 -8
  103. package/scss/inc/_flex-grid.scss +1 -1
  104. package/scss/inc/_forms.scss +5 -5
  105. package/scss/inc/_functions.scss +8 -8
  106. package/scss/inc/fonts/_tao-icon-classes.scss +230 -230
  107. package/src/animable/absorbable/css/absorb.css +25 -29
  108. package/src/animable/absorbable/css/absorb.css.map +1 -1
  109. package/src/animable/pulsable/css/pulse.css +20 -23
  110. package/src/animable/pulsable/css/pulse.css.map +1 -1
  111. package/src/autocomplete/css/autocomplete.css +20 -21
  112. package/src/autocomplete/css/autocomplete.css.map +1 -1
  113. package/src/badge/css/badge.css +67 -79
  114. package/src/badge/css/badge.css.map +1 -1
  115. package/src/breadcrumbs/css/breadcrumbs.css +54 -61
  116. package/src/breadcrumbs/css/breadcrumbs.css.map +1 -1
  117. package/src/bulkActionPopup/css/bulkActionPopup.css +27 -42
  118. package/src/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
  119. package/src/calculator/css/calculator.css +91 -112
  120. package/src/calculator/css/calculator.css.map +1 -1
  121. package/src/calculator/scss/calculator.scss +1 -1
  122. package/src/class/css/selector.css +83 -97
  123. package/src/class/css/selector.css.map +1 -1
  124. package/src/component/css/components.css +351 -406
  125. package/src/component/css/components.css.map +1 -1
  126. package/src/component/css/windowComponent.css +19 -28
  127. package/src/component/css/windowComponent.css.map +1 -1
  128. package/src/contextualPopup/css/contextualPopup.css +42 -55
  129. package/src/contextualPopup/css/contextualPopup.css.map +1 -1
  130. package/src/css/basic.css +4000 -4374
  131. package/src/css/basic.css.map +1 -1
  132. package/src/dashboard/css/dashboard.css +43 -57
  133. package/src/dashboard/css/dashboard.css.map +1 -1
  134. package/src/datalist/css/datalist.css +63 -88
  135. package/src/datalist/css/datalist.css.map +1 -1
  136. package/src/datatable/css/datatable.css +84 -113
  137. package/src/datatable/css/datatable.css.map +1 -1
  138. package/src/dateRange/css/dateRange.css +1 -2
  139. package/src/dateRange/css/dateRange.css.map +1 -1
  140. package/src/datetime/css/picker.css +71 -103
  141. package/src/datetime/css/picker.css.map +1 -1
  142. package/src/destination/css/selector.css +17 -24
  143. package/src/destination/css/selector.css.map +1 -1
  144. package/src/documentViewer/css/documentViewer.css +137 -162
  145. package/src/documentViewer/css/documentViewer.css.map +1 -1
  146. package/src/dropdown/css/dropdown.css +55 -72
  147. package/src/dropdown/css/dropdown.css.map +1 -1
  148. package/src/dynamicComponent/css/dynamicComponent.css +78 -91
  149. package/src/dynamicComponent/css/dynamicComponent.css.map +1 -1
  150. package/src/form/css/dropdownForm.css +36 -45
  151. package/src/form/css/dropdownForm.css.map +1 -1
  152. package/src/form/css/form.css +12 -16
  153. package/src/form/css/form.css.map +1 -1
  154. package/src/form/validator/css/validator.css +5 -7
  155. package/src/form/validator/css/validator.css.map +1 -1
  156. package/src/form/widget/css/widget.css +26 -34
  157. package/src/form/widget/css/widget.css.map +1 -1
  158. package/src/generis/form/css/form.css +14 -18
  159. package/src/generis/form/css/form.css.map +1 -1
  160. package/src/generis/validator/css/validator.css +5 -7
  161. package/src/generis/validator/css/validator.css.map +1 -1
  162. package/src/generis/widget/css/widget.css +29 -38
  163. package/src/generis/widget/css/widget.css.map +1 -1
  164. package/src/itemButtonList/css/item-button-list.css +135 -172
  165. package/src/itemButtonList/css/item-button-list.css.map +1 -1
  166. package/src/listbox/css/listbox.css +64 -84
  167. package/src/listbox/css/listbox.css.map +1 -1
  168. package/src/listbox/scss/listbox.scss +8 -8
  169. package/src/loadingButton/css/button.css +20 -29
  170. package/src/loadingButton/css/button.css.map +1 -1
  171. package/src/maths/calculator/basicCalculator.js +1 -4
  172. package/src/maths/calculator/calculatorComponent.js +49 -60
  173. package/src/maths/calculator/core/board.js +372 -493
  174. package/src/maths/calculator/core/labels.js +46 -48
  175. package/src/maths/calculator/core/plugin.js +3 -5
  176. package/src/maths/calculator/core/tpl/terms.tpl +7 -1
  177. package/src/maths/calculator/css/calculator.css +224 -270
  178. package/src/maths/calculator/css/calculator.css.map +1 -1
  179. package/src/maths/calculator/defaultCalculator.js +7 -9
  180. package/src/maths/calculator/plugins/keyboard/templateKeyboard/defaultTemplate.tpl +3 -3
  181. package/src/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +17 -20
  182. package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +102 -108
  183. package/src/maths/calculator/scientificCalculator.js +2 -10
  184. package/src/maths/calculator/scss/calculator.scss +20 -7
  185. package/src/maths/calculator/tpl/basicKeyboard.tpl +3 -3
  186. package/src/maths/calculator/tpl/scientificKeyboard.tpl +4 -4
  187. package/src/mediaplayer/css/player.css +281 -370
  188. package/src/mediaplayer/css/player.css.map +1 -1
  189. package/src/pagination/css/pagination.css +38 -49
  190. package/src/pagination/css/pagination.css.map +1 -1
  191. package/src/propertySelector/css/propertySelector.css +34 -44
  192. package/src/propertySelector/css/propertySelector.css.map +1 -1
  193. package/src/resource/css/selector.css +400 -490
  194. package/src/resource/css/selector.css.map +1 -1
  195. package/src/resourcemgr/css/resourcemgr.css +192 -237
  196. package/src/resourcemgr/css/resourcemgr.css.map +1 -1
  197. package/src/searchModal/css/advancedSearch.css +92 -121
  198. package/src/searchModal/css/advancedSearch.css.map +1 -1
  199. package/src/searchModal/css/searchModal.css +261 -333
  200. package/src/searchModal/css/searchModal.css.map +1 -1
  201. package/src/searchModal/scss/searchModal.scss +1 -1
  202. package/src/switch/css/switch.css +36 -47
  203. package/src/switch/css/switch.css.map +1 -1
  204. package/src/tabs/css/tabs.css +32 -40
  205. package/src/tabs/css/tabs.css.map +1 -1
  206. package/src/taskQueue/css/taskQueue.css +17 -27
  207. package/src/taskQueue/css/taskQueue.css.map +1 -1
  208. package/src/taskQueueButton/css/taskable.css +1 -2
  209. package/src/taskQueueButton/css/taskable.css.map +1 -1
  210. package/src/taskQueueButton/css/treeButton.css +20 -26
  211. package/src/taskQueueButton/css/treeButton.css.map +1 -1
  212. package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css +3 -5
  213. package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
  214. package/src/waitingDialog/css/waitingDialog.css +18 -23
  215. package/src/waitingDialog/css/waitingDialog.css.map +1 -1
  216. package/dist/maths/calculator/core/areaBroker.js +0 -43
  217. package/dist/maths/calculator/core/expression.js +0 -463
  218. package/dist/maths/calculator/core/terms.js +0 -456
  219. package/dist/maths/calculator/core/tokenizer.js +0 -229
  220. package/dist/maths/calculator/core/tokens.js +0 -167
  221. package/dist/maths/calculator/plugins/core/degrad.js +0 -71
  222. package/dist/maths/calculator/plugins/core/history.js +0 -149
  223. package/dist/maths/calculator/plugins/core/remind.js +0 -76
  224. package/dist/maths/calculator/plugins/core/stepNavigation.js +0 -148
  225. package/dist/maths/calculator/plugins/modifiers/pow10.js +0 -136
  226. package/dist/maths/calculator/plugins/modifiers/sign.js +0 -314
  227. package/dist/maths/calculator/pluginsLoader.js +0 -47
  228. package/src/maths/calculator/core/areaBroker.js +0 -38
  229. package/src/maths/calculator/core/expression.js +0 -430
  230. package/src/maths/calculator/core/terms.js +0 -459
  231. package/src/maths/calculator/core/tokenizer.js +0 -245
  232. package/src/maths/calculator/core/tokens.js +0 -178
  233. package/src/maths/calculator/plugins/core/degrad.js +0 -90
  234. package/src/maths/calculator/plugins/core/history.js +0 -166
  235. package/src/maths/calculator/plugins/core/remind.js +0 -96
  236. package/src/maths/calculator/plugins/core/stepNavigation.js +0 -175
  237. package/src/maths/calculator/plugins/modifiers/pow10.js +0 -143
  238. package/src/maths/calculator/plugins/modifiers/sign.js +0 -339
  239. package/src/maths/calculator/pluginsLoader.js +0 -46
@@ -1,459 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018-2019 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
20
- */
21
- import __ from 'i18n';
22
- import labels from 'ui/maths/calculator/core/labels';
23
-
24
- /**
25
- * @typedef {Object} term - Represents a tokenizable term
26
- * @property {String} label - The displayable text
27
- * @property {String} value - The related text that should be found in the expression
28
- * @property {String} type - The type of token
29
- * @property {String} description - A description of what represent the term
30
- * @property {String|null} exponent - Some terms introduce exponent notation, and this property tells on which side
31
- */
32
-
33
- /**
34
- * Defines the terms that can be tokenized from an expression
35
- * @type {term[]}
36
- */
37
- export default {
38
- // Digits definition
39
- NUM0: {
40
- label: labels.NUM0,
41
- value: '0',
42
- type: 'digit',
43
- description: __('Digit 0'),
44
- exponent: null
45
- },
46
- NUM1: {
47
- label: labels.NUM1,
48
- value: '1',
49
- type: 'digit',
50
- description: __('Digit 1'),
51
- exponent: null
52
- },
53
- NUM2: {
54
- label: labels.NUM2,
55
- value: '2',
56
- type: 'digit',
57
- description: __('Digit 2'),
58
- exponent: null
59
- },
60
- NUM3: {
61
- label: labels.NUM3,
62
- value: '3',
63
- type: 'digit',
64
- description: __('Digit 3'),
65
- exponent: null
66
- },
67
- NUM4: {
68
- label: labels.NUM4,
69
- value: '4',
70
- type: 'digit',
71
- description: __('Digit 4'),
72
- exponent: null
73
- },
74
- NUM5: {
75
- label: labels.NUM5,
76
- value: '5',
77
- type: 'digit',
78
- description: __('Digit 5'),
79
- exponent: null
80
- },
81
- NUM6: {
82
- label: labels.NUM6,
83
- value: '6',
84
- type: 'digit',
85
- description: __('Digit 6'),
86
- exponent: null
87
- },
88
- NUM7: {
89
- label: labels.NUM7,
90
- value: '7',
91
- type: 'digit',
92
- description: __('Digit 7'),
93
- exponent: null
94
- },
95
- NUM8: {
96
- label: labels.NUM8,
97
- value: '8',
98
- type: 'digit',
99
- description: __('Digit 8'),
100
- exponent: null
101
- },
102
- NUM9: {
103
- label: labels.NUM9,
104
- value: '9',
105
- type: 'digit',
106
- description: __('Digit 9'),
107
- exponent: null
108
- },
109
- DOT: {
110
- label: labels.DOT,
111
- value: '.',
112
- type: 'digit',
113
- description: __('Dot'),
114
- exponent: null
115
- },
116
- EXP10: {
117
- label: labels.EXP10,
118
- value: 'e',
119
- type: 'digit',
120
- description: __('Power of 10'),
121
- exponent: 'right'
122
- },
123
-
124
- // Aggregators
125
- LPAR: {
126
- label: labels.LPAR,
127
- value: '(',
128
- type: 'aggregator',
129
- description: __('Left parenthesis'),
130
- exponent: null
131
- },
132
- RPAR: {
133
- label: labels.RPAR,
134
- value: ')',
135
- type: 'aggregator',
136
- description: __('Right parenthesis'),
137
- exponent: null
138
- },
139
-
140
- // Separator
141
- COMMA: {
142
- label: labels.COMMA,
143
- value: ',',
144
- type: 'separator',
145
- description: __('Arguments separator'),
146
- exponent: null
147
- },
148
- ELLIPSIS: {
149
- label: labels.ELLIPSIS,
150
- value: '~',
151
- type: 'separator',
152
- description: __('Value ellipsis'),
153
- exponent: null
154
- },
155
-
156
- // Operators
157
- SUB: {
158
- label: labels.SUB,
159
- value: '-',
160
- type: 'operator',
161
- description: __('Binary operator -'),
162
- exponent: null
163
- },
164
- NEG: {
165
- label: labels.NEG,
166
- value: labels.NEG,
167
- type: 'operator',
168
- description: __('Unary operator -'),
169
- exponent: null
170
- },
171
- ADD: {
172
- label: labels.ADD,
173
- value: '+',
174
- type: 'operator',
175
- description: __('Binary operator +'),
176
- exponent: null
177
- },
178
- POS: {
179
- label: labels.POS,
180
- value: labels.POS,
181
- type: 'operator',
182
- description: __('Unary operator +'),
183
- exponent: null
184
- },
185
- MUL: {
186
- label: labels.MUL,
187
- value: '*',
188
- type: 'operator',
189
- description: __('Binary operator *'),
190
- exponent: null
191
- },
192
- DIV: {
193
- label: labels.DIV,
194
- value: '/',
195
- type: 'operator',
196
- description: __('Binary operator /'),
197
- exponent: null
198
- },
199
- MOD: {
200
- label: labels.MOD,
201
- value: '%',
202
- type: 'operator',
203
- description: __('Binary operator modulo'),
204
- exponent: null
205
- },
206
- POW: {
207
- label: labels.POW,
208
- value: '^',
209
- type: 'operator',
210
- description: __('Power of'),
211
- exponent: 'right'
212
- },
213
- FAC: {
214
- label: labels.FAC,
215
- value: '!',
216
- type: 'operator',
217
- description: __('Factorial'),
218
- exponent: null
219
- },
220
- ASSIGN: {
221
- label: labels.ASSIGN,
222
- value: '=',
223
- type: 'operator',
224
- description: __('Assign'),
225
- exponent: null
226
- },
227
-
228
- // Variables
229
- ANS: {
230
- label: labels.ANS,
231
- value: 'ans',
232
- type: 'variable',
233
- description: __('Last result'),
234
- exponent: null
235
- },
236
-
237
- // Constants
238
- PI: {
239
- label: labels.PI,
240
- value: 'PI',
241
- type: 'constant',
242
- description: __('Value of PI'),
243
- exponent: null
244
- },
245
- E: {
246
- label: labels.E,
247
- value: 'E',
248
- type: 'constant',
249
- description: __('Value of E'),
250
- exponent: null
251
- },
252
-
253
- // Errors
254
- NAN: {
255
- label: labels.NAN,
256
- value: 'NaN',
257
- type: 'error',
258
- description: __('Error in value'),
259
- exponent: null
260
- },
261
- INFINITY: {
262
- label: labels.INFINITY,
263
- value: 'Infinity',
264
- type: 'error',
265
- description: __('Error in result'),
266
- exponent: null
267
- },
268
- ERROR: {
269
- label: labels.ERROR,
270
- value: '#',
271
- type: 'error',
272
- description: __('Error in syntax'),
273
- exponent: null
274
- },
275
-
276
- // Functions
277
- EXP: {
278
- label: labels.EXP,
279
- value: 'exp',
280
- type: 'function',
281
- description: __('Exponent'),
282
- exponent: 'right'
283
- },
284
- SQRT: {
285
- label: labels.SQRT,
286
- value: 'sqrt',
287
- type: 'function',
288
- description: __('Square root'),
289
- exponent: null
290
- },
291
- CBRT: {
292
- label: labels.CBRT,
293
- value: 'cbrt',
294
- type: 'function',
295
- description: __('Cube root'),
296
- exponent: null
297
- },
298
- NTHRT: {
299
- label: labels.SQRT,
300
- value: 'nthrt',
301
- type: 'function',
302
- description: __('Nth root'),
303
- exponent: 'left'
304
- },
305
- FLOOR: {
306
- label: labels.FLOOR,
307
- value: 'floor',
308
- type: 'function',
309
- description: __('Round to lower whole number'),
310
- exponent: null
311
- },
312
- CEIL: {
313
- label: labels.CEIL,
314
- value: 'ceil',
315
- type: 'function',
316
- description: __('Round to upper whole number'),
317
- exponent: null
318
- },
319
- ROUND: {
320
- label: labels.ROUND,
321
- value: 'round',
322
- type: 'function',
323
- description: __('Round to closest whole number'),
324
- exponent: null
325
- },
326
- TRUNC: {
327
- label: labels.TRUNC,
328
- value: 'trunc',
329
- type: 'function',
330
- description: __('Whole number part'),
331
- exponent: null
332
- },
333
- SIN: {
334
- label: labels.SIN,
335
- value: 'sin',
336
- type: 'function',
337
- description: __('Sine'),
338
- exponent: null
339
- },
340
- COS: {
341
- label: labels.COS,
342
- value: 'cos',
343
- type: 'function',
344
- description: __('Cosine'),
345
- exponent: null
346
- },
347
- TAN: {
348
- label: labels.TAN,
349
- value: 'tan',
350
- type: 'function',
351
- description: __('Tangent'),
352
- exponent: null
353
- },
354
- ASIN: {
355
- label: labels.ASIN,
356
- value: 'asin',
357
- type: 'function',
358
- description: __('Arc sine'),
359
- exponent: null
360
- },
361
- ACOS: {
362
- label: labels.ACOS,
363
- value: 'acos',
364
- type: 'function',
365
- description: __('Arc cosine'),
366
- exponent: null
367
- },
368
- ATAN: {
369
- label: labels.ATAN,
370
- value: 'atan',
371
- type: 'function',
372
- description: __('Arc tangent'),
373
- exponent: null
374
- },
375
- SINH: {
376
- label: labels.SINH,
377
- value: 'sinh',
378
- type: 'function',
379
- description: __('Hyperbolic sine'),
380
- exponent: null
381
- },
382
- COSH: {
383
- label: labels.COSH,
384
- value: 'cosh',
385
- type: 'function',
386
- description: __('Hyperbolic cosine'),
387
- exponent: null
388
- },
389
- TANH: {
390
- label: labels.TANH,
391
- value: 'tanh',
392
- type: 'function',
393
- description: __('Hyperbolic tangent'),
394
- exponent: null
395
- },
396
- ASINH: {
397
- label: labels.ASINH,
398
- value: 'asinh',
399
- type: 'function',
400
- description: __('Hyperbolic arc sine'),
401
- exponent: null
402
- },
403
- ACOSH: {
404
- label: labels.ACOSH,
405
- value: 'acosh',
406
- type: 'function',
407
- description: __('Hyperbolic arc cosine'),
408
- exponent: null
409
- },
410
- ATANH: {
411
- label: labels.ATANH,
412
- value: 'atanh',
413
- type: 'function',
414
- description: __('Hyperbolic arc tangent'),
415
- exponent: null
416
- },
417
- LN: {
418
- label: labels.LN,
419
- value: 'ln',
420
- type: 'function',
421
- description: __('Natural logarithm'),
422
- exponent: null
423
- },
424
- LOG: {
425
- label: labels.LN,
426
- value: 'log',
427
- type: 'function',
428
- description: __('Natural logarithm'),
429
- exponent: null
430
- },
431
- LG: {
432
- label: labels.LOG,
433
- value: 'lg',
434
- type: 'function',
435
- description: __('Base-10 logarithm'),
436
- exponent: null
437
- },
438
- LOG10: {
439
- label: labels.LOG,
440
- value: 'log10',
441
- type: 'function',
442
- description: __('Base-10 logarithm'),
443
- exponent: null
444
- },
445
- ABS: {
446
- label: labels.ABS,
447
- value: 'abs',
448
- type: 'function',
449
- description: __('Absolute value'),
450
- exponent: null
451
- },
452
- RAND: {
453
- label: labels.RAND,
454
- value: 'random',
455
- type: 'function',
456
- description: __('Random value'),
457
- exponent: null
458
- }
459
- };
@@ -1,245 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018-2019 Open Assessment Technologies SA ;
17
- */
18
-
19
- /**
20
- * Tokenize a mathematical expression based on the list of known terms.
21
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
22
- */
23
- import _ from 'lodash';
24
- import registeredTerms from 'ui/maths/calculator/core/terms';
25
- import tokensHelper from 'ui/maths/calculator/core/tokens';
26
- import moo from 'lib/moo/moo';
27
-
28
- /**
29
- * List of ignored tokens
30
- * @type {Object}
31
- */
32
- var ignoredTokens = {
33
- SPACE: {
34
- match: /\s+/,
35
- lineBreaks: true
36
- }
37
- };
38
-
39
- /**
40
- * Match keywords
41
- * @type {RegExp}
42
- */
43
- var reKeyword = /[a-zA-Z_]\w*/;
44
-
45
- /**
46
- * Match numbers
47
- * @type {RegExp}
48
- */
49
- var reNumber = /[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/;
50
-
51
- /**
52
- * Match keywords prefixed with @
53
- * @type {RegExp}
54
- */
55
- var rePrefixedKeyword = new RegExp('@' + reKeyword.source);
56
-
57
- /**
58
- * Match keywords only
59
- * @type {RegExp}
60
- */
61
- var reKeywordOnly = new RegExp('^' + reKeyword.source + '$');
62
-
63
- /**
64
- * List of keywords (functions from the list of registered terms).
65
- * @type {Object}
66
- */
67
- var keywords = _.pick(registeredTerms, filterKeyword);
68
-
69
- /**
70
- * List of symbols (operators and operands from the list of registered terms).
71
- * @type {Object}
72
- */
73
- var symbols = _.omit(registeredTerms, filterKeyword);
74
-
75
- /**
76
- * List of digits and related symbols
77
- * @type {Object}
78
- */
79
- var digits = _.pick(registeredTerms, filterDigit);
80
-
81
- /**
82
- * Filter function that checks if the provided term is a keyword.
83
- * Keywords are all terms that have alphanumeric non digit value from the list of terms.
84
- * @param term
85
- * @returns {boolean}
86
- */
87
- function filterKeyword(term) {
88
- return term.value.match(reKeywordOnly);
89
- }
90
-
91
- /**
92
- * Filter function that checks if the provided term is a digit or a related symbol.
93
- * @param term
94
- * @returns {boolean}
95
- */
96
- function filterDigit(term) {
97
- return tokensHelper.isDigit(term.type) || term.value === '-' || term.value === '+';
98
- }
99
-
100
- /**
101
- * @typedef {Object} token
102
- * @property {String} type - The identifier of the token
103
- * @property {String} value - The actual value of the token
104
- * @property {String} text - The raw value that produced the token
105
- * @property {Number} offset - The original offset in the source
106
- * @property {Number} lineBreaks - How many line breaks are contained in the raw value
107
- * @property {Number} line - The line number of the token (starting from 1)
108
- * @property {Number} col - The column number of the token (starting from 1)
109
- */
110
-
111
- /**
112
- * Generates an expression tokenizer.
113
- *
114
- * @example
115
- *
116
- * var expression = '(.1 + .2) * 10^8';
117
- * var tokenizer = calculatorTokenizerFactory();
118
- * var terms = tokenizer(expression);
119
- *
120
- * // terms now contains an array of terms:
121
- * // [{type: "LPAR", value: "(", text: "(", offset: 0, lineBreaks: 0, line: 1, col: 1},
122
- * // {type: "DOT", value: ".", text: ".", offset: 1, lineBreaks: 0, line: 1, col: 2},
123
- * // {type: "NUM1", value: "1", text: "1", offset: 2, lineBreaks: 0, line: 1, col: 3},
124
- * // {type: "ADD", value: "+", text: "+", offset: 4, lineBreaks: 0, line: 1, col: 5},
125
- * // {type: "DOT", value: ".", text: ".", offset: 6, lineBreaks: 0, line: 1, col: 7},
126
- * // {type: "NUM2", value: "2", text: "2", offset: 7, lineBreaks: 0, line: 1, col: 8},
127
- * // {type: "RPAR", value: ")", text: ")", offset: 8, lineBreaks: 0, line: 1, col: 9},
128
- * // {type: "MUL", value: "*", text: "*", offset: 10, lineBreaks: 0, line: 1, col: 11},
129
- * // {type: "NUM1", value: "1", text: "1", offset: 12, lineBreaks: 0, line: 1, col: 13},
130
- * // {type: "NUM0", value: "0", text: "0", offset: 13, lineBreaks: 0, line: 1, col: 14},
131
- * // {type: "POW", value: "^", text: "^", offset: 14, lineBreaks: 0, line: 1, col: 15},
132
- * // {type: "NUM8", value: "8", text: "8", offset: 15, lineBreaks: 0, line: 1, col: 16}]
133
- *
134
- * @param {Object} [config]
135
- * @param {Object} [config.keywords] - List of additional keywords: key being the name, value being the pattern (should be on the domain /[a-zA-Z]+/)
136
- * @param {Object} [config.symbols] - List of additional symbols: key being the name, value being the pattern
137
- * @returns {calculatorTokenizer}
138
- */
139
- function calculatorTokenizerFactory(config) {
140
- var keywordsTransform, lexer, digitLexer, digitContext;
141
-
142
- /**
143
- * Extracts a token from the current position in the expression
144
- * @returns {token}
145
- */
146
- var next = function next() {
147
- var term;
148
-
149
- if (digitContext) {
150
- term = digitLexer.next();
151
- if (term) {
152
- term.offset += digitContext.offset;
153
- }
154
- }
155
-
156
- if (!term) {
157
- digitContext = null;
158
-
159
- do {
160
- term = lexer.next();
161
- } while (term && ignoredTokens[term.type]);
162
-
163
- // rely on a specific lexer to tokenize numbers
164
- // this is required to properly identify numbers like 42e15 without colliding with regular identifiers
165
- if (term && term.type === 'number') {
166
- digitContext = term;
167
- digitLexer.reset(term.value);
168
- term = next();
169
- }
170
- }
171
-
172
- return term;
173
- };
174
-
175
- /**
176
- * @typedef {Object} calculatorTokenizer
177
- */
178
- var tokenizer = {
179
- /**
180
- * Gets an iterator that will returns tokens from the provided expression
181
- * @param {String} expression
182
- * @returns {function(): token}
183
- */
184
- iterator: function iterator(expression) {
185
- lexer.reset(tokensHelper.stringValue(expression));
186
- return next;
187
- },
188
-
189
- /**
190
- * Tokenizes the expression
191
- * @param {String} expression
192
- * @returns {token[]}
193
- */
194
- tokenize: function tokenize(expression) {
195
- var iterator = tokenizer.iterator(expression);
196
- var terms = [];
197
- var term;
198
-
199
- do {
200
- term = iterator();
201
- if (term) {
202
- terms.push(term);
203
- }
204
- } while (term);
205
-
206
- return terms;
207
- }
208
- };
209
-
210
- config = config || {};
211
- config.keywords = _.defaults(_.mapValues(keywords, 'value'), config.keywords);
212
- config.symbols = _.defaults(_.mapValues(symbols, 'value'), config.symbols);
213
- keywordsTransform = moo.keywords(config.keywords);
214
-
215
- // Lexer used to tokenize the expression
216
- lexer = moo.compile(
217
- _.defaults(
218
- {},
219
- ignoredTokens,
220
- {
221
- number: reNumber,
222
- prefixed: {
223
- match: rePrefixedKeyword,
224
- type: function(token) {
225
- // simply rely on the keywords transform to identify the prefixed keyword
226
- return keywordsTransform(token.substring(1));
227
- }
228
- },
229
- term: {
230
- match: reKeyword,
231
- type: keywordsTransform
232
- },
233
- syntaxError: moo.error
234
- },
235
- config.symbols
236
- )
237
- );
238
-
239
- // Lexer used to tokenize numbers
240
- digitLexer = moo.compile(_.mapValues(digits, 'value'));
241
-
242
- return tokenizer;
243
- }
244
-
245
- export default calculatorTokenizerFactory;