@deephaven/iris-grid 0.6.3-beta.11 → 0.6.4
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/Formatter.d.ts +7 -14
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +6 -6
- package/dist/Formatter.js.map +1 -1
- package/dist/FormatterUtils.d.ts +8 -0
- package/dist/FormatterUtils.d.ts.map +1 -1
- package/dist/FormatterUtils.js +15 -0
- package/dist/FormatterUtils.js.map +1 -1
- package/dist/IrisGrid.d.ts +8 -0
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +39 -71
- package/dist/IrisGrid.js.map +1 -1
- package/dist/IrisGridBottomBar.js +1 -1
- package/dist/IrisGridModelUpdater.js +1 -1
- package/dist/IrisGridModelUpdater.js.map +1 -1
- package/dist/IrisGridTableModel.d.ts.map +1 -1
- package/dist/IrisGridTableModel.js +4 -8
- package/dist/IrisGridTableModel.js.map +1 -1
- package/dist/IrisGridTreeTableModel.js +1 -1
- package/dist/IrisGridUtils.js +32 -32
- package/dist/IrisGridUtils.js.map +1 -1
- package/dist/PendingDataBottomBar.js +1 -1
- package/dist/PendingDataBottomBar.js.map +1 -1
- package/dist/TableUtils.d.ts.map +1 -1
- package/dist/TableUtils.js +3 -1
- package/dist/TableUtils.js.map +1 -1
- package/dist/ToastBottomBar.js +1 -1
- package/dist/ToastBottomBar.js.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.d.ts +8 -7
- package/dist/formatters/DateTimeColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.js +1 -2
- package/dist/formatters/DateTimeColumnFormatter.js.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.d.ts +55 -59
- package/dist/formatters/DecimalColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.js +66 -27
- package/dist/formatters/DecimalColumnFormatter.js.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.d.ts +50 -29
- package/dist/formatters/IntegerColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.js +60 -19
- package/dist/formatters/IntegerColumnFormatter.js.map +1 -1
- package/dist/formatters/index.d.ts +7 -7
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +3 -3
- package/dist/formatters/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -1
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js +12 -4
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.js +1 -1
- package/dist/sidebar/AdvancedSettingsMenu.js +2 -2
- package/dist/sidebar/CustomColumnBuilder.js +2 -2
- package/dist/sidebar/CustomColumnBuilder.js.map +1 -1
- package/dist/sidebar/InputEditor.js +1 -1
- package/dist/sidebar/RollupRows.js +10 -10
- package/dist/sidebar/RollupRows.js.map +1 -1
- package/dist/sidebar/SelectDistinctBuilder.js +5 -5
- package/dist/sidebar/SelectDistinctBuilder.js.map +1 -1
- package/dist/sidebar/TableCsvExporter.d.ts.map +1 -1
- package/dist/sidebar/TableCsvExporter.js +10 -3
- package/dist/sidebar/TableCsvExporter.js.map +1 -1
- package/dist/sidebar/TableSaver.d.ts +1 -0
- package/dist/sidebar/TableSaver.d.ts.map +1 -1
- package/dist/sidebar/TableSaver.js +20 -1
- package/dist/sidebar/TableSaver.js.map +1 -1
- package/dist/sidebar/VisibilityOrderingBuilder.js +10 -10
- package/dist/sidebar/VisibilityOrderingBuilder.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.js +3 -3
- package/dist/sidebar/aggregations/AggregationEdit.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationUtils.js +1 -1
- package/dist/sidebar/aggregations/Aggregations.js +4 -4
- package/dist/sidebar/aggregations/Aggregations.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -13
|
@@ -1,68 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
1
|
+
import TableColumnFormatter, { TableColumnFormat } from './TableColumnFormatter';
|
|
2
|
+
export declare type DecimalColumnFormat = TableColumnFormat & {
|
|
3
|
+
multiplier?: number;
|
|
4
|
+
};
|
|
5
|
+
export declare type DecimalColumnFormatterOptions = {
|
|
6
|
+
defaultFormatString?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class DecimalColumnFormatter extends TableColumnFormatter {
|
|
3
9
|
/**
|
|
4
10
|
* Validates format object
|
|
5
|
-
* @param
|
|
6
|
-
* @returns
|
|
11
|
+
* @param format Format object
|
|
12
|
+
* @returns true for valid object
|
|
7
13
|
*/
|
|
8
|
-
static isValid(format:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
static isValid(format: TableColumnFormat): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Create a DecimalColumnFormat object with the parameters specified
|
|
17
|
+
* @param label Label for the format
|
|
18
|
+
* @param formatString Format string for the format
|
|
19
|
+
* @param multiplier Optional multiplier for the formatter
|
|
20
|
+
* @param type Type of format created
|
|
21
|
+
* @returns DecimalColumnFormat object
|
|
22
|
+
*/
|
|
23
|
+
static makeFormat(label: string, formatString: string, type?: import("./TableColumnFormatter").TableColumnFormatType, multiplier?: number): DecimalColumnFormat;
|
|
24
|
+
/**
|
|
25
|
+
* Convenient function to create a DecimalFormatObject with Preset type set
|
|
26
|
+
* @param label Label for this format object
|
|
27
|
+
* @param formatString Format string to use
|
|
28
|
+
* @param multiplier Multiplier to use
|
|
29
|
+
* @returns DecimalColumnFormat object
|
|
30
|
+
*/
|
|
31
|
+
static makePresetFormat(label: string, formatString?: string, multiplier?: number): DecimalColumnFormat;
|
|
32
|
+
/**
|
|
33
|
+
* Convenient function to create a DecimalFormatObject with a default 'Custom Format' label and Custom type
|
|
34
|
+
* @param formatString Format string to use
|
|
35
|
+
* @param multiplier Multiplier to use
|
|
36
|
+
* @returns DecimalColumnFormat object
|
|
37
|
+
*/
|
|
38
|
+
static makeCustomFormat(formatString?: string, multiplier?: number): DecimalColumnFormat;
|
|
21
39
|
static DEFAULT_FORMAT_STRING: string;
|
|
22
|
-
static FORMAT_PERCENT:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
static FORMAT_BASIS_POINTS: {
|
|
29
|
-
label: any;
|
|
30
|
-
type: import("./TableColumnFormatter").TableColumnFormatType;
|
|
31
|
-
formatString: any;
|
|
32
|
-
multiplier: any;
|
|
33
|
-
};
|
|
34
|
-
static FORMAT_MILLIONS: {
|
|
35
|
-
label: any;
|
|
36
|
-
type: import("./TableColumnFormatter").TableColumnFormatType;
|
|
37
|
-
formatString: any;
|
|
38
|
-
multiplier: any;
|
|
39
|
-
};
|
|
40
|
-
static FORMAT_ROUND: {
|
|
41
|
-
label: any;
|
|
42
|
-
type: import("./TableColumnFormatter").TableColumnFormatType;
|
|
43
|
-
formatString: any;
|
|
44
|
-
multiplier: any;
|
|
45
|
-
};
|
|
46
|
-
static FORMAT_ROUND_TWO_DECIMALS: {
|
|
47
|
-
label: any;
|
|
48
|
-
type: import("./TableColumnFormatter").TableColumnFormatType;
|
|
49
|
-
formatString: any;
|
|
50
|
-
multiplier: any;
|
|
51
|
-
};
|
|
52
|
-
static FORMAT_ROUND_FOUR_DECIMALS: {
|
|
53
|
-
label: any;
|
|
54
|
-
type: import("./TableColumnFormatter").TableColumnFormatType;
|
|
55
|
-
formatString: any;
|
|
56
|
-
multiplier: any;
|
|
57
|
-
};
|
|
40
|
+
static FORMAT_PERCENT: DecimalColumnFormat;
|
|
41
|
+
static FORMAT_BASIS_POINTS: DecimalColumnFormat;
|
|
42
|
+
static FORMAT_MILLIONS: DecimalColumnFormat;
|
|
43
|
+
static FORMAT_ROUND: DecimalColumnFormat;
|
|
44
|
+
static FORMAT_ROUND_TWO_DECIMALS: DecimalColumnFormat;
|
|
45
|
+
static FORMAT_ROUND_FOUR_DECIMALS: DecimalColumnFormat;
|
|
58
46
|
/**
|
|
59
47
|
* Check if the given formats match
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @returns
|
|
48
|
+
* @param formatA format object to check
|
|
49
|
+
* @param formatB format object to check
|
|
50
|
+
* @returns True if the formats match
|
|
51
|
+
*/
|
|
52
|
+
static isSameFormat(formatA?: DecimalColumnFormat, formatB?: DecimalColumnFormat): boolean;
|
|
53
|
+
defaultFormatString: string;
|
|
54
|
+
constructor({ defaultFormatString, }?: DecimalColumnFormatterOptions);
|
|
55
|
+
/**
|
|
56
|
+
* Format a value with the provided format object
|
|
57
|
+
* @param valueParam Value to format
|
|
58
|
+
* @param format Format object
|
|
59
|
+
* @returns Formatted string
|
|
63
60
|
*/
|
|
64
|
-
|
|
65
|
-
constructor();
|
|
61
|
+
format(valueParam: number, format: DecimalColumnFormat): string;
|
|
66
62
|
}
|
|
67
|
-
|
|
63
|
+
export default DecimalColumnFormatter;
|
|
68
64
|
//# sourceMappingURL=DecimalColumnFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/DecimalColumnFormatter.
|
|
1
|
+
{"version":3,"file":"DecimalColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/DecimalColumnFormatter.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,EAAE,EAC3B,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAIhC,oBAAY,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,6BAA6B,GAAG;IAE1C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,qBAAa,sBAAuB,SAAQ,oBAAoB;IAC9D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;IASlD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CACf,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,IAAI,yDAA2C,EAC/C,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB;IAStB;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,KAAK,EAAE,MAAM,EACb,YAAY,SAAK,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB;IAStB;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CACrB,YAAY,SAAK,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB;IAStB,MAAM,CAAC,qBAAqB,SAAkB;IAE9C,MAAM,CAAC,cAAc,sBAGnB;IAEF,MAAM,CAAC,mBAAmB,sBAIxB;IAEF,MAAM,CAAC,eAAe,sBAIpB;IAEF,MAAM,CAAC,YAAY,sBAGjB;IAEF,MAAM,CAAC,yBAAyB,sBAG9B;IAEF,MAAM,CAAC,0BAA0B,sBAG/B;IAEF;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,OAAO,CAAC,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO;IAWV,mBAAmB,EAAE,MAAM,CAAC;gBAEhB,EACV,mBAAkE,GACnE,GAAE,6BAAkC;IAMrC;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM;CAYhE;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -4,13 +4,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
4
4
|
import dh from '@deephaven/jsapi-shim';
|
|
5
5
|
import Log from '@deephaven/log';
|
|
6
6
|
import TableColumnFormatter from "./TableColumnFormatter.js";
|
|
7
|
-
var log = Log.module('
|
|
8
|
-
|
|
9
|
-
class DecimalTableColumnFormatter extends TableColumnFormatter {
|
|
7
|
+
var log = Log.module('DecimalColumnFormatter');
|
|
8
|
+
export class DecimalColumnFormatter extends TableColumnFormatter {
|
|
10
9
|
/**
|
|
11
10
|
* Validates format object
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
11
|
+
* @param format Format object
|
|
12
|
+
* @returns true for valid object
|
|
14
13
|
*/
|
|
15
14
|
static isValid(format) {
|
|
16
15
|
try {
|
|
@@ -20,10 +19,19 @@ class DecimalTableColumnFormatter extends TableColumnFormatter {
|
|
|
20
19
|
return false;
|
|
21
20
|
}
|
|
22
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a DecimalColumnFormat object with the parameters specified
|
|
24
|
+
* @param label Label for the format
|
|
25
|
+
* @param formatString Format string for the format
|
|
26
|
+
* @param multiplier Optional multiplier for the formatter
|
|
27
|
+
* @param type Type of format created
|
|
28
|
+
* @returns DecimalColumnFormat object
|
|
29
|
+
*/
|
|
30
|
+
|
|
23
31
|
|
|
24
32
|
static makeFormat(label, formatString) {
|
|
25
|
-
var
|
|
26
|
-
var
|
|
33
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TableColumnFormatter.TYPE_CONTEXT_PRESET;
|
|
34
|
+
var multiplier = arguments.length > 3 ? arguments[3] : undefined;
|
|
27
35
|
return {
|
|
28
36
|
label,
|
|
29
37
|
type,
|
|
@@ -31,33 +39,64 @@ class DecimalTableColumnFormatter extends TableColumnFormatter {
|
|
|
31
39
|
multiplier
|
|
32
40
|
};
|
|
33
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Convenient function to create a DecimalFormatObject with Preset type set
|
|
44
|
+
* @param label Label for this format object
|
|
45
|
+
* @param formatString Format string to use
|
|
46
|
+
* @param multiplier Multiplier to use
|
|
47
|
+
* @returns DecimalColumnFormat object
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
static makePresetFormat(label) {
|
|
52
|
+
var formatString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
53
|
+
var multiplier = arguments.length > 2 ? arguments[2] : undefined;
|
|
54
|
+
return DecimalColumnFormatter.makeFormat(label, formatString, TableColumnFormatter.TYPE_CONTEXT_PRESET, multiplier);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Convenient function to create a DecimalFormatObject with a default 'Custom Format' label and Custom type
|
|
58
|
+
* @param formatString Format string to use
|
|
59
|
+
* @param multiplier Multiplier to use
|
|
60
|
+
* @returns DecimalColumnFormat object
|
|
61
|
+
*/
|
|
62
|
+
|
|
34
63
|
|
|
35
64
|
static makeCustomFormat() {
|
|
36
|
-
var formatString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
37
|
-
var multiplier = arguments.length > 1
|
|
38
|
-
return
|
|
65
|
+
var formatString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
66
|
+
var multiplier = arguments.length > 1 ? arguments[1] : undefined;
|
|
67
|
+
return DecimalColumnFormatter.makeFormat('Custom Format', formatString, TableColumnFormatter.TYPE_CONTEXT_CUSTOM, multiplier);
|
|
39
68
|
}
|
|
40
69
|
|
|
41
70
|
/**
|
|
42
71
|
* Check if the given formats match
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @returns
|
|
72
|
+
* @param formatA format object to check
|
|
73
|
+
* @param formatB format object to check
|
|
74
|
+
* @returns True if the formats match
|
|
46
75
|
*/
|
|
47
76
|
static isSameFormat(formatA, formatB) {
|
|
48
77
|
return formatA === formatB || formatA != null && formatB != null && formatA.type === formatB.type && formatA.formatString === formatB.formatString && formatA.multiplier === formatB.multiplier;
|
|
49
78
|
}
|
|
79
|
+
|
|
80
|
+
constructor() {
|
|
81
|
+
var {
|
|
82
|
+
defaultFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING
|
|
83
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
84
|
+
super();
|
|
85
|
+
|
|
86
|
+
_defineProperty(this, "defaultFormatString", void 0);
|
|
87
|
+
|
|
88
|
+
this.defaultFormatString = defaultFormatString;
|
|
89
|
+
}
|
|
50
90
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @
|
|
55
|
-
* @returns {string} Formatted string
|
|
91
|
+
* Format a value with the provided format object
|
|
92
|
+
* @param valueParam Value to format
|
|
93
|
+
* @param format Format object
|
|
94
|
+
* @returns Formatted string
|
|
56
95
|
*/
|
|
57
96
|
|
|
58
97
|
|
|
59
98
|
format(valueParam, format) {
|
|
60
|
-
var formatString = format && format.formatString ||
|
|
99
|
+
var formatString = format && format.formatString || this.defaultFormatString;
|
|
61
100
|
var value = format && format.multiplier ? valueParam * format.multiplier : valueParam;
|
|
62
101
|
|
|
63
102
|
try {
|
|
@@ -71,19 +110,19 @@ class DecimalTableColumnFormatter extends TableColumnFormatter {
|
|
|
71
110
|
|
|
72
111
|
}
|
|
73
112
|
|
|
74
|
-
_defineProperty(
|
|
113
|
+
_defineProperty(DecimalColumnFormatter, "DEFAULT_FORMAT_STRING", '###,##0.0000');
|
|
75
114
|
|
|
76
|
-
_defineProperty(
|
|
115
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_PERCENT", DecimalColumnFormatter.makePresetFormat('Percent', '##0.00%'));
|
|
77
116
|
|
|
78
|
-
_defineProperty(
|
|
117
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_BASIS_POINTS", DecimalColumnFormatter.makePresetFormat('Basis Points', '###,##0 bp', 10000));
|
|
79
118
|
|
|
80
|
-
_defineProperty(
|
|
119
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_MILLIONS", DecimalColumnFormatter.makePresetFormat('Millions', '###,##0.000 mm', 0.000001));
|
|
81
120
|
|
|
82
|
-
_defineProperty(
|
|
121
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_ROUND", DecimalColumnFormatter.makePresetFormat('Round', '###,##0'));
|
|
83
122
|
|
|
84
|
-
_defineProperty(
|
|
123
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_ROUND_TWO_DECIMALS", DecimalColumnFormatter.makePresetFormat('0.00', '###,##0.00'));
|
|
85
124
|
|
|
86
|
-
_defineProperty(
|
|
125
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_ROUND_FOUR_DECIMALS", DecimalColumnFormatter.makePresetFormat('0.0000', '###,##0.0000'));
|
|
87
126
|
|
|
88
|
-
export default
|
|
127
|
+
export default DecimalColumnFormatter;
|
|
89
128
|
//# sourceMappingURL=DecimalColumnFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/formatters/DecimalColumnFormatter.
|
|
1
|
+
{"version":3,"sources":["../../src/formatters/DecimalColumnFormatter.ts"],"names":["dh","Log","TableColumnFormatter","log","module","DecimalColumnFormatter","isValid","format","i18n","NumberFormat","formatString","e","makeFormat","label","type","TYPE_CONTEXT_PRESET","multiplier","makePresetFormat","makeCustomFormat","TYPE_CONTEXT_CUSTOM","isSameFormat","formatA","formatB","constructor","defaultFormatString","DEFAULT_FORMAT_STRING","valueParam","value","error"],"mappings":"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","sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport dh from '@deephaven/jsapi-shim';\nimport Log from '@deephaven/log';\nimport TableColumnFormatter, {\n TableColumnFormat,\n} from './TableColumnFormatter';\n\nconst log = Log.module('DecimalColumnFormatter');\n\nexport type DecimalColumnFormat = TableColumnFormat & {\n multiplier?: number;\n};\n\nexport type DecimalColumnFormatterOptions = {\n // Default format string to use. Defaults to DecimalColumnFormatter.DEFAULT_FORMAT_STRING\n defaultFormatString?: string;\n};\n\nexport class DecimalColumnFormatter extends TableColumnFormatter {\n /**\n * Validates format object\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(format: TableColumnFormat): boolean {\n try {\n dh.i18n.NumberFormat.format(format.formatString, 0);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Create a DecimalColumnFormat object with the parameters specified\n * @param label Label for the format\n * @param formatString Format string for the format\n * @param multiplier Optional multiplier for the formatter\n * @param type Type of format created\n * @returns DecimalColumnFormat object\n */\n static makeFormat(\n label: string,\n formatString: string,\n type = TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier?: number\n ): DecimalColumnFormat {\n return {\n label,\n type,\n formatString,\n multiplier,\n };\n }\n\n /**\n * Convenient function to create a DecimalFormatObject with Preset type set\n * @param label Label for this format object\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns DecimalColumnFormat object\n */\n static makePresetFormat(\n label: string,\n formatString = '',\n multiplier?: number\n ): DecimalColumnFormat {\n return DecimalColumnFormatter.makeFormat(\n label,\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier\n );\n }\n\n /**\n * Convenient function to create a DecimalFormatObject with a default 'Custom Format' label and Custom type\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns DecimalColumnFormat object\n */\n static makeCustomFormat(\n formatString = '',\n multiplier?: number\n ): DecimalColumnFormat {\n return DecimalColumnFormatter.makeFormat(\n 'Custom Format',\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_CUSTOM,\n multiplier\n );\n }\n\n static DEFAULT_FORMAT_STRING = '###,##0.0000';\n\n static FORMAT_PERCENT = DecimalColumnFormatter.makePresetFormat(\n 'Percent',\n '##0.00%'\n );\n\n static FORMAT_BASIS_POINTS = DecimalColumnFormatter.makePresetFormat(\n 'Basis Points',\n '###,##0 bp',\n 10000\n );\n\n static FORMAT_MILLIONS = DecimalColumnFormatter.makePresetFormat(\n 'Millions',\n '###,##0.000 mm',\n 0.000001\n );\n\n static FORMAT_ROUND = DecimalColumnFormatter.makePresetFormat(\n 'Round',\n '###,##0'\n );\n\n static FORMAT_ROUND_TWO_DECIMALS = DecimalColumnFormatter.makePresetFormat(\n '0.00',\n '###,##0.00'\n );\n\n static FORMAT_ROUND_FOUR_DECIMALS = DecimalColumnFormatter.makePresetFormat(\n '0.0000',\n '###,##0.0000'\n );\n\n /**\n * Check if the given formats match\n * @param formatA format object to check\n * @param formatB format object to check\n * @returns True if the formats match\n */\n static isSameFormat(\n formatA?: DecimalColumnFormat,\n formatB?: DecimalColumnFormat\n ): boolean {\n return (\n formatA === formatB ||\n (formatA != null &&\n formatB != null &&\n formatA.type === formatB.type &&\n formatA.formatString === formatB.formatString &&\n formatA.multiplier === formatB.multiplier)\n );\n }\n\n defaultFormatString: string;\n\n constructor({\n defaultFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING,\n }: DecimalColumnFormatterOptions = {}) {\n super();\n\n this.defaultFormatString = defaultFormatString;\n }\n\n /**\n * Format a value with the provided format object\n * @param valueParam Value to format\n * @param format Format object\n * @returns Formatted string\n */\n format(valueParam: number, format: DecimalColumnFormat): string {\n const formatString =\n (format && format.formatString) || this.defaultFormatString;\n const value =\n format && format.multiplier ? valueParam * format.multiplier : valueParam;\n try {\n return dh.i18n.NumberFormat.format(formatString, value);\n } catch (e) {\n log.error('Invalid format arguments');\n }\n return '';\n }\n}\n\nexport default DecimalColumnFormatter;\n"],"file":"DecimalColumnFormatter.js"}
|
|
@@ -1,39 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import TableColumnFormatter, { TableColumnFormat } from './TableColumnFormatter';
|
|
2
|
+
export declare type IntegerColumnFormat = TableColumnFormat & {
|
|
3
|
+
multiplier?: number;
|
|
4
|
+
};
|
|
5
|
+
export declare type IntegerColumnFormatterOptions = {
|
|
6
|
+
defaultFormatString?: string;
|
|
7
|
+
};
|
|
2
8
|
/** Column formatter for integers/whole numbers */
|
|
3
|
-
declare class IntegerColumnFormatter extends TableColumnFormatter
|
|
9
|
+
export declare class IntegerColumnFormatter extends TableColumnFormatter {
|
|
4
10
|
/**
|
|
5
11
|
* Validates format object
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
12
|
+
* @param format Format object
|
|
13
|
+
* @returns true for valid object
|
|
14
|
+
*/
|
|
15
|
+
static isValid(format: IntegerColumnFormat): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Create an IntegerColumnFormat object with the parameters specified
|
|
18
|
+
* @param label Label for the format
|
|
19
|
+
* @param formatString Format string for the format
|
|
20
|
+
* @param multiplier Optional multiplier for the formatter
|
|
21
|
+
* @param type Type of format created
|
|
22
|
+
* @returns IntegerColumnFormat object
|
|
23
|
+
*/
|
|
24
|
+
static makeFormat(label: string, formatString: string, type?: import("./TableColumnFormatter").TableColumnFormatType, multiplier?: number): IntegerColumnFormat;
|
|
25
|
+
/**
|
|
26
|
+
* Convenient function to create a IntegerFormatObject with Preset type set
|
|
27
|
+
* @param label Label for this format object
|
|
28
|
+
* @param formatString Format string to use
|
|
29
|
+
* @param multiplier Multiplier to use
|
|
30
|
+
* @returns IntegerColumnFormat object
|
|
8
31
|
*/
|
|
9
|
-
static
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
static makeCustomFormat(formatString?:
|
|
17
|
-
label: any;
|
|
18
|
-
type: import("./TableColumnFormatter").TableColumnFormatType;
|
|
19
|
-
formatString: any;
|
|
20
|
-
multiplier: any;
|
|
21
|
-
};
|
|
32
|
+
static makePresetFormat(label: string, formatString?: string, multiplier?: number): IntegerColumnFormat;
|
|
33
|
+
/**
|
|
34
|
+
* Convenient function to create a IntegerFormatObject with a default 'Custom Format' label and Custom type
|
|
35
|
+
* @param formatString Format string to use
|
|
36
|
+
* @param multiplier Multiplier to use
|
|
37
|
+
* @returns IntegerColumnFormat object
|
|
38
|
+
*/
|
|
39
|
+
static makeCustomFormat(formatString?: string, multiplier?: number): IntegerColumnFormat;
|
|
22
40
|
/**
|
|
23
41
|
* Check if the given formats match
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
42
|
+
* @param formatA format object to check
|
|
43
|
+
* @param formatB format object to check
|
|
44
|
+
* @returns True if the formats match
|
|
27
45
|
*/
|
|
28
|
-
static isSameFormat(formatA
|
|
46
|
+
static isSameFormat(formatA?: IntegerColumnFormat, formatB?: IntegerColumnFormat): boolean;
|
|
29
47
|
static DEFAULT_FORMAT_STRING: string;
|
|
30
|
-
static FORMAT_MILLIONS:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
static FORMAT_MILLIONS: IntegerColumnFormat;
|
|
49
|
+
defaultFormatString: string;
|
|
50
|
+
constructor({ defaultFormatString, }?: IntegerColumnFormatterOptions);
|
|
51
|
+
/**
|
|
52
|
+
* Format a value with the provided format object
|
|
53
|
+
* @param valueParam Value to format
|
|
54
|
+
* @param format Format object
|
|
55
|
+
* @returns Formatted string
|
|
56
|
+
*/
|
|
57
|
+
format(valueParam: number, format: IntegerColumnFormat): string;
|
|
37
58
|
}
|
|
38
|
-
|
|
59
|
+
export default IntegerColumnFormatter;
|
|
39
60
|
//# sourceMappingURL=IntegerColumnFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegerColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/IntegerColumnFormatter.
|
|
1
|
+
{"version":3,"file":"IntegerColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/IntegerColumnFormatter.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,EAAE,EAC3B,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAIhC,oBAAY,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,6BAA6B,GAAG;IAE1C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,kDAAkD;AAClD,qBAAa,sBAAuB,SAAQ,oBAAoB;IAC9D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO;IASpD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CACf,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,IAAI,yDAA2C,EAC/C,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB;IAStB;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,KAAK,EAAE,MAAM,EACb,YAAY,SAAK,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB;IAStB;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CACrB,YAAY,SAAK,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB;IAStB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,OAAO,CAAC,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO;IAWV,MAAM,CAAC,qBAAqB,SAAa;IAEzC,MAAM,CAAC,eAAe,sBAIpB;IAEF,mBAAmB,EAAE,MAAM,CAAC;gBAEhB,EACV,mBAAkE,GACnE,GAAE,6BAAkC;IAMrC;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM;CAYhE;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -5,13 +5,13 @@ import dh from '@deephaven/jsapi-shim';
|
|
|
5
5
|
import Log from '@deephaven/log';
|
|
6
6
|
import TableColumnFormatter from "./TableColumnFormatter.js";
|
|
7
7
|
var log = Log.module('IntegerColumnFormatter');
|
|
8
|
-
/** Column formatter for integers/whole numbers */
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
/** Column formatter for integers/whole numbers */
|
|
10
|
+
export class IntegerColumnFormatter extends TableColumnFormatter {
|
|
11
11
|
/**
|
|
12
12
|
* Validates format object
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
13
|
+
* @param format Format object
|
|
14
|
+
* @returns true for valid object
|
|
15
15
|
*/
|
|
16
16
|
static isValid(format) {
|
|
17
17
|
try {
|
|
@@ -21,10 +21,19 @@ class IntegerColumnFormatter extends TableColumnFormatter {
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Create an IntegerColumnFormat object with the parameters specified
|
|
26
|
+
* @param label Label for the format
|
|
27
|
+
* @param formatString Format string for the format
|
|
28
|
+
* @param multiplier Optional multiplier for the formatter
|
|
29
|
+
* @param type Type of format created
|
|
30
|
+
* @returns IntegerColumnFormat object
|
|
31
|
+
*/
|
|
32
|
+
|
|
24
33
|
|
|
25
34
|
static makeFormat(label, formatString) {
|
|
26
|
-
var
|
|
27
|
-
var
|
|
35
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TableColumnFormatter.TYPE_CONTEXT_PRESET;
|
|
36
|
+
var multiplier = arguments.length > 3 ? arguments[3] : undefined;
|
|
28
37
|
return {
|
|
29
38
|
label,
|
|
30
39
|
type,
|
|
@@ -32,17 +41,38 @@ class IntegerColumnFormatter extends TableColumnFormatter {
|
|
|
32
41
|
multiplier
|
|
33
42
|
};
|
|
34
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Convenient function to create a IntegerFormatObject with Preset type set
|
|
46
|
+
* @param label Label for this format object
|
|
47
|
+
* @param formatString Format string to use
|
|
48
|
+
* @param multiplier Multiplier to use
|
|
49
|
+
* @returns IntegerColumnFormat object
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
static makePresetFormat(label) {
|
|
54
|
+
var formatString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
55
|
+
var multiplier = arguments.length > 2 ? arguments[2] : undefined;
|
|
56
|
+
return IntegerColumnFormatter.makeFormat(label, formatString, TableColumnFormatter.TYPE_CONTEXT_PRESET, multiplier);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Convenient function to create a IntegerFormatObject with a default 'Custom Format' label and Custom type
|
|
60
|
+
* @param formatString Format string to use
|
|
61
|
+
* @param multiplier Multiplier to use
|
|
62
|
+
* @returns IntegerColumnFormat object
|
|
63
|
+
*/
|
|
64
|
+
|
|
35
65
|
|
|
36
66
|
static makeCustomFormat() {
|
|
37
|
-
var formatString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
38
|
-
var multiplier = arguments.length > 1
|
|
39
|
-
return IntegerColumnFormatter.makeFormat('Custom Format', formatString,
|
|
67
|
+
var formatString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
68
|
+
var multiplier = arguments.length > 1 ? arguments[1] : undefined;
|
|
69
|
+
return IntegerColumnFormatter.makeFormat('Custom Format', formatString, TableColumnFormatter.TYPE_CONTEXT_CUSTOM, multiplier);
|
|
40
70
|
}
|
|
41
71
|
/**
|
|
42
72
|
* Check if the given formats match
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @returns
|
|
73
|
+
* @param formatA format object to check
|
|
74
|
+
* @param formatB format object to check
|
|
75
|
+
* @returns True if the formats match
|
|
46
76
|
*/
|
|
47
77
|
|
|
48
78
|
|
|
@@ -50,15 +80,26 @@ class IntegerColumnFormatter extends TableColumnFormatter {
|
|
|
50
80
|
return formatA === formatB || formatA != null && formatB != null && formatA.type === formatB.type && formatA.formatString === formatB.formatString && formatA.multiplier === formatB.multiplier;
|
|
51
81
|
}
|
|
52
82
|
|
|
83
|
+
constructor() {
|
|
84
|
+
var {
|
|
85
|
+
defaultFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING
|
|
86
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
87
|
+
super();
|
|
88
|
+
|
|
89
|
+
_defineProperty(this, "defaultFormatString", void 0);
|
|
90
|
+
|
|
91
|
+
this.defaultFormatString = defaultFormatString;
|
|
92
|
+
}
|
|
53
93
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @
|
|
58
|
-
* @returns {string} Formatted string
|
|
94
|
+
* Format a value with the provided format object
|
|
95
|
+
* @param valueParam Value to format
|
|
96
|
+
* @param format Format object
|
|
97
|
+
* @returns Formatted string
|
|
59
98
|
*/
|
|
99
|
+
|
|
100
|
+
|
|
60
101
|
format(valueParam, format) {
|
|
61
|
-
var formatString = format && format.formatString ||
|
|
102
|
+
var formatString = format && format.formatString || this.defaultFormatString;
|
|
62
103
|
var value = format && format.multiplier ? valueParam * format.multiplier : valueParam;
|
|
63
104
|
|
|
64
105
|
try {
|
|
@@ -74,7 +115,7 @@ class IntegerColumnFormatter extends TableColumnFormatter {
|
|
|
74
115
|
|
|
75
116
|
_defineProperty(IntegerColumnFormatter, "DEFAULT_FORMAT_STRING", '###,##0');
|
|
76
117
|
|
|
77
|
-
_defineProperty(IntegerColumnFormatter, "FORMAT_MILLIONS", IntegerColumnFormatter.
|
|
118
|
+
_defineProperty(IntegerColumnFormatter, "FORMAT_MILLIONS", IntegerColumnFormatter.makePresetFormat('Millions', '###,##0.000 mm', 0.000001));
|
|
78
119
|
|
|
79
120
|
export default IntegerColumnFormatter;
|
|
80
121
|
//# sourceMappingURL=IntegerColumnFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/formatters/IntegerColumnFormatter.
|
|
1
|
+
{"version":3,"sources":["../../src/formatters/IntegerColumnFormatter.ts"],"names":["dh","Log","TableColumnFormatter","log","module","IntegerColumnFormatter","isValid","format","i18n","NumberFormat","formatString","e","makeFormat","label","type","TYPE_CONTEXT_PRESET","multiplier","makePresetFormat","makeCustomFormat","TYPE_CONTEXT_CUSTOM","isSameFormat","formatA","formatB","constructor","defaultFormatString","DEFAULT_FORMAT_STRING","valueParam","value","error"],"mappings":";;AAAA;AACA,OAAOA,EAAP,MAAe,uBAAf;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,oB;AAIP,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,wBAAX,CAAZ;;AAWA;AACA,OAAO,MAAMC,sBAAN,SAAqCH,oBAArC,CAA0D;AAC/D;AACF;AACA;AACA;AACA;AACgB,SAAPI,OAAO,CAACC,MAAD,EAAuC;AACnD,QAAI;AACFP,MAAAA,EAAE,CAACQ,IAAH,CAAQC,YAAR,CAAqBF,MAArB,CAA4BA,MAAM,CAACG,YAAnC,EAAiD,CAAjD;AACA,aAAO,IAAP;AACD,KAHD,CAGE,OAAOC,CAAP,EAAU;AACV,aAAO,KAAP;AACD;AACF;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;AACmB,SAAVC,UAAU,CACfC,KADe,EAEfH,YAFe,EAKM;AAAA,QAFrBI,IAEqB,uEAFdZ,oBAAoB,CAACa,mBAEP;AAAA,QADrBC,UACqB;AACrB,WAAO;AACLH,MAAAA,KADK;AAELC,MAAAA,IAFK;AAGLJ,MAAAA,YAHK;AAILM,MAAAA;AAJK,KAAP;AAMD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACyB,SAAhBC,gBAAgB,CACrBJ,KADqB,EAIA;AAAA,QAFrBH,YAEqB,uEAFN,EAEM;AAAA,QADrBM,UACqB;AACrB,WAAOX,sBAAsB,CAACO,UAAvB,CACLC,KADK,EAELH,YAFK,EAGLR,oBAAoB,CAACa,mBAHhB,EAILC,UAJK,CAAP;AAMD;AAED;AACF;AACA;AACA;AACA;AACA;;;AACyB,SAAhBE,gBAAgB,GAGA;AAAA,QAFrBR,YAEqB,uEAFN,EAEM;AAAA,QADrBM,UACqB;AACrB,WAAOX,sBAAsB,CAACO,UAAvB,CACL,eADK,EAELF,YAFK,EAGLR,oBAAoB,CAACiB,mBAHhB,EAILH,UAJK,CAAP;AAMD;AAED;AACF;AACA;AACA;AACA;AACA;;;AACqB,SAAZI,YAAY,CACjBC,OADiB,EAEjBC,OAFiB,EAGR;AACT,WACED,OAAO,KAAKC,OAAZ,IACCD,OAAO,IAAI,IAAX,IACCC,OAAO,IAAI,IADZ,IAECD,OAAO,CAACP,IAAR,KAAiBQ,OAAO,CAACR,IAF1B,IAGCO,OAAO,CAACX,YAAR,KAAyBY,OAAO,CAACZ,YAHlC,IAICW,OAAO,CAACL,UAAR,KAAuBM,OAAO,CAACN,UANnC;AAQD;;AAYDO,EAAAA,WAAW,GAE4B;AAAA,QAF3B;AACVC,MAAAA,mBAAmB,GAAGnB,sBAAsB,CAACoB;AADnC,KAE2B,uEAAJ,EAAI;AACrC;;AADqC;;AAGrC,SAAKD,mBAAL,GAA2BA,mBAA3B;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;AACEjB,EAAAA,MAAM,CAACmB,UAAD,EAAqBnB,MAArB,EAA0D;AAC9D,QAAMG,YAAY,GACfH,MAAM,IAAIA,MAAM,CAACG,YAAlB,IAAmC,KAAKc,mBAD1C;AAEA,QAAMG,KAAK,GACTpB,MAAM,IAAIA,MAAM,CAACS,UAAjB,GAA8BU,UAAU,GAAGnB,MAAM,CAACS,UAAlD,GAA+DU,UADjE;;AAEA,QAAI;AACF,aAAO1B,EAAE,CAACQ,IAAH,CAAQC,YAAR,CAAqBF,MAArB,CAA4BG,YAA5B,EAA0CiB,KAA1C,CAAP;AACD,KAFD,CAEE,OAAOhB,CAAP,EAAU;AACVR,MAAAA,GAAG,CAACyB,KAAJ,CAAU,0BAAV;AACD;;AACD,WAAO,EAAP;AACD;;AAlI8D;;gBAApDvB,sB,2BA+FoB,S;;gBA/FpBA,sB,qBAiGcA,sBAAsB,CAACY,gBAAvB,CACvB,UADuB,EAEvB,gBAFuB,EAGvB,QAHuB,C;;AAoC3B,eAAeZ,sBAAf","sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport dh from '@deephaven/jsapi-shim';\nimport Log from '@deephaven/log';\nimport TableColumnFormatter, {\n TableColumnFormat,\n} from './TableColumnFormatter';\n\nconst log = Log.module('IntegerColumnFormatter');\n\nexport type IntegerColumnFormat = TableColumnFormat & {\n multiplier?: number;\n};\n\nexport type IntegerColumnFormatterOptions = {\n // Default format string to use. Defaults to IntegerColumnFormatter.DEFAULT_FORMAT_STRING\n defaultFormatString?: string;\n};\n\n/** Column formatter for integers/whole numbers */\nexport class IntegerColumnFormatter extends TableColumnFormatter {\n /**\n * Validates format object\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(format: IntegerColumnFormat): boolean {\n try {\n dh.i18n.NumberFormat.format(format.formatString, 0);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Create an IntegerColumnFormat object with the parameters specified\n * @param label Label for the format\n * @param formatString Format string for the format\n * @param multiplier Optional multiplier for the formatter\n * @param type Type of format created\n * @returns IntegerColumnFormat object\n */\n static makeFormat(\n label: string,\n formatString: string,\n type = TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier?: number\n ): IntegerColumnFormat {\n return {\n label,\n type,\n formatString,\n multiplier,\n };\n }\n\n /**\n * Convenient function to create a IntegerFormatObject with Preset type set\n * @param label Label for this format object\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns IntegerColumnFormat object\n */\n static makePresetFormat(\n label: string,\n formatString = '',\n multiplier?: number\n ): IntegerColumnFormat {\n return IntegerColumnFormatter.makeFormat(\n label,\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier\n );\n }\n\n /**\n * Convenient function to create a IntegerFormatObject with a default 'Custom Format' label and Custom type\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns IntegerColumnFormat object\n */\n static makeCustomFormat(\n formatString = '',\n multiplier?: number\n ): IntegerColumnFormat {\n return IntegerColumnFormatter.makeFormat(\n 'Custom Format',\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_CUSTOM,\n multiplier\n );\n }\n\n /**\n * Check if the given formats match\n * @param formatA format object to check\n * @param formatB format object to check\n * @returns True if the formats match\n */\n static isSameFormat(\n formatA?: IntegerColumnFormat,\n formatB?: IntegerColumnFormat\n ): boolean {\n return (\n formatA === formatB ||\n (formatA != null &&\n formatB != null &&\n formatA.type === formatB.type &&\n formatA.formatString === formatB.formatString &&\n formatA.multiplier === formatB.multiplier)\n );\n }\n\n static DEFAULT_FORMAT_STRING = '###,##0';\n\n static FORMAT_MILLIONS = IntegerColumnFormatter.makePresetFormat(\n 'Millions',\n '###,##0.000 mm',\n 0.000001\n );\n\n defaultFormatString: string;\n\n constructor({\n defaultFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING,\n }: IntegerColumnFormatterOptions = {}) {\n super();\n\n this.defaultFormatString = defaultFormatString;\n }\n\n /**\n * Format a value with the provided format object\n * @param valueParam Value to format\n * @param format Format object\n * @returns Formatted string\n */\n format(valueParam: number, format: IntegerColumnFormat): string {\n const formatString =\n (format && format.formatString) || this.defaultFormatString;\n const value =\n format && format.multiplier ? valueParam * format.multiplier : valueParam;\n try {\n return dh.i18n.NumberFormat.format(formatString, value);\n } catch (e) {\n log.error('Invalid format arguments');\n }\n return '';\n }\n}\n\nexport default IntegerColumnFormatter;\n"],"file":"IntegerColumnFormatter.js"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { default as BooleanColumnFormatter } from
|
|
2
|
-
export { default as CharColumnFormatter } from
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export { default as DefaultColumnFormatter } from
|
|
6
|
-
export
|
|
7
|
-
export { default as TableColumnFormatter } from
|
|
1
|
+
export { default as BooleanColumnFormatter } from './BooleanColumnFormatter';
|
|
2
|
+
export { default as CharColumnFormatter } from './CharColumnFormatter';
|
|
3
|
+
export * from './DateTimeColumnFormatter';
|
|
4
|
+
export * from './DecimalColumnFormatter';
|
|
5
|
+
export { default as DefaultColumnFormatter } from './DefaultColumnFormatter';
|
|
6
|
+
export * from './IntegerColumnFormatter';
|
|
7
|
+
export { default as TableColumnFormatter } from './TableColumnFormatter';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/formatters/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { default as BooleanColumnFormatter } from "./BooleanColumnFormatter.js";
|
|
2
2
|
export { default as CharColumnFormatter } from "./CharColumnFormatter.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export * from "./DateTimeColumnFormatter.js";
|
|
4
|
+
export * from "./DecimalColumnFormatter.js";
|
|
5
5
|
export { default as DefaultColumnFormatter } from "./DefaultColumnFormatter.js";
|
|
6
|
-
export
|
|
6
|
+
export * from "./IntegerColumnFormatter.js";
|
|
7
7
|
export { default as TableColumnFormatter } from "./TableColumnFormatter.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/formatters/index.
|
|
1
|
+
{"version":3,"sources":["../../src/formatters/index.ts"],"names":["default","BooleanColumnFormatter","CharColumnFormatter","DefaultColumnFormatter","TableColumnFormatter"],"mappings":"SAASA,OAAO,IAAIC,sB;SACXD,OAAO,IAAIE,mB;;;SAGXF,OAAO,IAAIG,sB;;SAEXH,OAAO,IAAII,oB","sourcesContent":["export { default as BooleanColumnFormatter } from './BooleanColumnFormatter';\nexport { default as CharColumnFormatter } from './CharColumnFormatter';\nexport * from './DateTimeColumnFormatter';\nexport * from './DecimalColumnFormatter';\nexport { default as DefaultColumnFormatter } from './DefaultColumnFormatter';\nexport * from './IntegerColumnFormatter';\nexport { default as TableColumnFormatter } from './TableColumnFormatter';\n"],"file":"index.js"}
|