@masterteam/components 0.0.281 → 0.0.283
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.
- package/assets/common.css +1 -1
- package/assets/i18n/ar.json +382 -368
- package/assets/i18n/en.json +382 -368
- package/fesm2022/masterteam-components-entities.mjs +273 -85
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components-formula.mjs +59 -1
- package/fesm2022/masterteam-components-formula.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-entities.d.ts +139 -4
- package/types/masterteam-components-formula.d.ts +5 -1
|
@@ -303,6 +303,13 @@ function shouldInsertSpace(previousType, previousValue, current) {
|
|
|
303
303
|
return false;
|
|
304
304
|
if (previousType === 'fn-separator')
|
|
305
305
|
return true;
|
|
306
|
+
// Grouping parens and commas inserted from the toolbar are plain operator
|
|
307
|
+
// tokens, so they need the same spacing their function-owned equivalents get
|
|
308
|
+
// above — otherwise they serialize as "( @a + @b ) * 2".
|
|
309
|
+
if (previousValue === '(')
|
|
310
|
+
return false;
|
|
311
|
+
if (current.value === ')' || current.value === ',')
|
|
312
|
+
return false;
|
|
306
313
|
if (current.value === ':')
|
|
307
314
|
return false;
|
|
308
315
|
if (previousValue === ':')
|
|
@@ -368,13 +375,37 @@ function tokenizeFormulaTemplate(template) {
|
|
|
368
375
|
let index = 0;
|
|
369
376
|
const parseExpression = (context) => {
|
|
370
377
|
const tokens = [];
|
|
378
|
+
/**
|
|
379
|
+
* Grouping parens opened by THIS expression. While it is above zero a ')'
|
|
380
|
+
* closes our own group instead of the enclosing function — without the
|
|
381
|
+
* counter the first ')' of "(@a + @b) * 2" ended the parse and everything
|
|
382
|
+
* after it was silently dropped.
|
|
383
|
+
*/
|
|
384
|
+
let groupDepth = 0;
|
|
371
385
|
while (index < source.length) {
|
|
372
386
|
skipWhitespace();
|
|
373
387
|
if (index >= source.length)
|
|
374
388
|
break;
|
|
375
389
|
const char = source[index];
|
|
390
|
+
if (char === '(') {
|
|
391
|
+
groupDepth += 1;
|
|
392
|
+
tokens.push(createOperatorToken(char, context.depth, context.functionId, context.argIndex));
|
|
393
|
+
index += 1;
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
376
396
|
if (char === ',' || char === ')') {
|
|
377
|
-
|
|
397
|
+
// Hand the character back to the enclosing function only when no group
|
|
398
|
+
// of ours is open. A root-level expression owns no function, so it
|
|
399
|
+
// keeps the character as a token rather than truncating the formula.
|
|
400
|
+
if (groupDepth === 0 && context.functionId !== undefined) {
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
if (char === ')' && groupDepth > 0) {
|
|
404
|
+
groupDepth -= 1;
|
|
405
|
+
}
|
|
406
|
+
tokens.push(createOperatorToken(char, context.depth, context.functionId, context.argIndex));
|
|
407
|
+
index += 1;
|
|
408
|
+
continue;
|
|
378
409
|
}
|
|
379
410
|
if (char === '@') {
|
|
380
411
|
const propertyPath = readPropertyPath();
|
|
@@ -2116,6 +2147,9 @@ const OPERATOR_SYMBOL_TO_TRANSLATION_KEY = {
|
|
|
2116
2147
|
'&&': 'and',
|
|
2117
2148
|
'||': 'or',
|
|
2118
2149
|
'!': 'not',
|
|
2150
|
+
'(': 'openParen',
|
|
2151
|
+
')': 'closeParen',
|
|
2152
|
+
',': 'comma',
|
|
2119
2153
|
};
|
|
2120
2154
|
const DEFAULT_OPERATORS = [
|
|
2121
2155
|
// Arithmetic
|
|
@@ -2219,6 +2253,30 @@ const DEFAULT_OPERATORS = [
|
|
|
2219
2253
|
description: 'Logical NOT',
|
|
2220
2254
|
precedence: 6,
|
|
2221
2255
|
},
|
|
2256
|
+
// Grouping — parens override precedence, the comma separates arguments.
|
|
2257
|
+
// Both are valid formula syntax the backend parser accepts, so the toolbar
|
|
2258
|
+
// has to offer them or they can only be typed in code mode.
|
|
2259
|
+
{
|
|
2260
|
+
symbol: '(',
|
|
2261
|
+
name: 'Open Bracket',
|
|
2262
|
+
type: 'grouping',
|
|
2263
|
+
description: 'Open bracket',
|
|
2264
|
+
precedence: 7,
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
symbol: ')',
|
|
2268
|
+
name: 'Close Bracket',
|
|
2269
|
+
type: 'grouping',
|
|
2270
|
+
description: 'Close bracket',
|
|
2271
|
+
precedence: 7,
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
symbol: ',',
|
|
2275
|
+
name: 'Comma',
|
|
2276
|
+
type: 'grouping',
|
|
2277
|
+
description: 'Argument separator',
|
|
2278
|
+
precedence: 0,
|
|
2279
|
+
},
|
|
2222
2280
|
];
|
|
2223
2281
|
|
|
2224
2282
|
/**
|