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