@dra2020/baseclient 1.0.137 → 1.0.139
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/dist/baseclient.js +19 -6
- package/dist/baseclient.js.map +1 -1
- package/dist/detail/detail.d.ts +1 -1
- package/lib/detail/detail.ts +13 -5
- package/lib/filterexpr/filterexpr.ts +8 -1
- package/package.json +1 -1
package/dist/detail/detail.d.ts
CHANGED
package/lib/detail/detail.ts
CHANGED
|
@@ -16,17 +16,25 @@ import * as Util from '../util/all';
|
|
|
16
16
|
const reIdentifier = /\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g;
|
|
17
17
|
const reParam = /^__\d+$/
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Number format: (locale|general|integer|currency).precision
|
|
20
|
+
|
|
21
|
+
function formatNumber(n: number, format: string): string
|
|
20
22
|
{
|
|
21
|
-
|
|
23
|
+
if (!format) format = 'locale.0';
|
|
24
|
+
let parts = format.split('.');
|
|
25
|
+
let fmt = parts[0];
|
|
26
|
+
let precision = Number(parts[1] || '0');
|
|
27
|
+
n = Util.precisionRound(n, precision);
|
|
28
|
+
// Only have implementation for 'locale'
|
|
29
|
+
return n.toLocaleString();
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
export interface DetailOptions
|
|
25
33
|
{
|
|
26
|
-
numberFormat?:
|
|
34
|
+
numberFormat?: string,
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
const DefaultDetailOptions: DetailOptions = { numberFormat:
|
|
37
|
+
const DefaultDetailOptions: DetailOptions = { numberFormat: 'locale.0' };
|
|
30
38
|
|
|
31
39
|
class Evaluator
|
|
32
40
|
{
|
|
@@ -194,7 +202,7 @@ export class FormatDetail
|
|
|
194
202
|
n = e.eval(o);
|
|
195
203
|
if (! this._error)
|
|
196
204
|
this._error = e.error;
|
|
197
|
-
return this.options.numberFormat
|
|
205
|
+
return formatNumber(n, this.options.numberFormat);
|
|
198
206
|
}
|
|
199
207
|
});
|
|
200
208
|
return { n, v: av.join('') }
|
|
@@ -32,6 +32,13 @@ function isWhite(c: number): boolean
|
|
|
32
32
|
return c === Space || c === Newline || c === Tab || c == CR;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function toString(a: any): string
|
|
36
|
+
{
|
|
37
|
+
if (typeof a === 'object' && a && typeof a.value === 'string')
|
|
38
|
+
return a.value;
|
|
39
|
+
return String(a);
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
enum TokType
|
|
36
43
|
{
|
|
37
44
|
Text,
|
|
@@ -637,7 +644,7 @@ export class FilterExpr
|
|
|
637
644
|
case TokType.Text:
|
|
638
645
|
for (let p in o) if (o.hasOwnProperty(p) && (prop == null || p.toLowerCase() === prop))
|
|
639
646
|
{
|
|
640
|
-
let s =
|
|
647
|
+
let s = toString(o[p]);
|
|
641
648
|
if (s)
|
|
642
649
|
{
|
|
643
650
|
let t = types ? types[p] : undefined;
|