@deephaven/iris-grid 0.8.2-beta.1 → 0.8.2-beta.5
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/IrisGrid.d.ts +8 -0
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +20 -4
- package/dist/IrisGrid.js.map +1 -1
- package/dist/MissingKeyError.js +4 -0
- package/dist/MissingKeyError.js.map +1 -1
- package/dist/PartitionSelectorSearch.d.ts +1 -1
- package/dist/formatters/DateTimeColumnFormatter.d.ts +8 -7
- package/dist/formatters/DateTimeColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.js +12 -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/key-handlers/ClearFilterKeyHandler.js +5 -0
- package/dist/key-handlers/ClearFilterKeyHandler.js.map +1 -1
- package/dist/key-handlers/CopyKeyHandler.js +5 -0
- package/dist/key-handlers/CopyKeyHandler.js.map +1 -1
- package/dist/key-handlers/ReverseKeyHandler.js +5 -0
- package/dist/key-handlers/ReverseKeyHandler.js.map +1 -1
- package/dist/sidebar/ChartBuilder.d.ts +1 -1
- package/dist/sidebar/ChartBuilder.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/MissingKeyError.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/MissingKeyError.ts"],"names":["MissingKeyError","Error","constructor","rowIndex","columnName"],"mappings":";;AAAA,MAAMA,eAAN,SAA8BC,KAA9B,CAAoC;AAOlCC,EAAAA,WAAW,CAACC,QAAD,EAAmBC,UAAnB,EAAuC;AAChD,oBAASA,UAAT,6CAAsDD,QAAQ,GAAG,CAAjE;;AADgD,0CANnC,IAMmC;;AAEhD,SAAKA,QAAL,GAAgBA,QAAhB;AACA,SAAKC,UAAL,GAAkBA,UAAlB;AACD;;AAXiC;;AAcpC,eAAeJ,eAAf","sourcesContent":["class MissingKeyError extends Error {\n isMissingKey = true;\n\n rowIndex: number;\n\n columnName: string;\n\n constructor(rowIndex: number, columnName: string) {\n super(`${columnName} can't be empty (on pending row ${rowIndex + 1})`);\n this.rowIndex = rowIndex;\n this.columnName = columnName;\n }\n}\n\nexport default MissingKeyError;\n"],"file":"MissingKeyError.js"}
|
|
1
|
+
{"version":3,"sources":["../src/MissingKeyError.ts"],"names":["MissingKeyError","Error","constructor","rowIndex","columnName"],"mappings":";;AAAA,MAAMA,eAAN,SAA8BC,KAA9B,CAAoC;AAOlCC,EAAAA,WAAW,CAACC,QAAD,EAAmBC,UAAnB,EAAuC;AAChD,oBAASA,UAAT,6CAAsDD,QAAQ,GAAG,CAAjE;;AADgD,0CANnC,IAMmC;;AAAA;;AAAA;;AAEhD,SAAKA,QAAL,GAAgBA,QAAhB;AACA,SAAKC,UAAL,GAAkBA,UAAlB;AACD;;AAXiC;;AAcpC,eAAeJ,eAAf","sourcesContent":["class MissingKeyError extends Error {\n isMissingKey = true;\n\n rowIndex: number;\n\n columnName: string;\n\n constructor(rowIndex: number, columnName: string) {\n super(`${columnName} can't be empty (on pending row ${rowIndex + 1})`);\n this.rowIndex = rowIndex;\n this.columnName = columnName;\n }\n}\n\nexport default MissingKeyError;\n"],"file":"MissingKeyError.js"}
|
|
@@ -49,6 +49,6 @@ declare namespace PartitionSelectorSearch {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
import React from "react";
|
|
52
|
-
import { ItemList } from "
|
|
52
|
+
import { ItemList } from "packages/components/src/ItemList";
|
|
53
53
|
import PropTypes from "prop-types";
|
|
54
54
|
//# sourceMappingURL=PartitionSelectorSearch.d.ts.map
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import TableColumnFormatter, { TableColumnFormat } from './TableColumnFormatter';
|
|
2
|
-
declare
|
|
2
|
+
export declare type DateTimeColumnFormatterOptions = {
|
|
3
|
+
timeZone?: string;
|
|
4
|
+
showTimeZone?: boolean;
|
|
5
|
+
showTSeparator?: boolean;
|
|
6
|
+
defaultDateTimeFormatString?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class DateTimeColumnFormatter extends TableColumnFormatter {
|
|
3
9
|
/**
|
|
4
10
|
* Validates format object
|
|
5
11
|
* @param format Format object
|
|
@@ -25,12 +31,7 @@ declare class DateTimeColumnFormatter extends TableColumnFormatter {
|
|
|
25
31
|
showTimeZone: boolean;
|
|
26
32
|
showTSeparator: boolean;
|
|
27
33
|
formatStringMap: Map<string, string>;
|
|
28
|
-
constructor({ timeZone: timeZoneParam, showTimeZone, showTSeparator, defaultDateTimeFormatString, }?:
|
|
29
|
-
timeZone?: string;
|
|
30
|
-
showTimeZone?: boolean;
|
|
31
|
-
showTSeparator?: boolean;
|
|
32
|
-
defaultDateTimeFormatString?: string;
|
|
33
|
-
});
|
|
34
|
+
constructor({ timeZone: timeZoneParam, showTimeZone, showTSeparator, defaultDateTimeFormatString, }?: DateTimeColumnFormatterOptions);
|
|
34
35
|
getEffectiveFormatString(baseFormatString: string): string;
|
|
35
36
|
format(value: unknown, format?: TableColumnFormat): string;
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/DateTimeColumnFormatter.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,EAAE,EAC3B,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAIhC,
|
|
1
|
+
{"version":3,"file":"DateTimeColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/DateTimeColumnFormatter.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,EAAE,EAC3B,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAIhC,oBAAY,8BAA8B,GAAG;IAE3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,cAAc,CAAC,EAAE,OAAO,CAAC;IAGzB,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,qBAAa,uBAAwB,SAAQ,oBAAoB;IAC/D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;IASlD,MAAM,CAAC,UAAU,CACf,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,IAAI,yDAA2C,GAC9C,iBAAiB;IAQpB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,OAAO,CAAC,EAAE,iBAAiB,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO;IAUV,MAAM,CAAC,8BAA8B,SAA6B;IAElE,MAAM,CAAC,oBAAoB,SAAsB;IAEjD,MAAM,CAAC,yBAAyB,CAC9B,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,GACtB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAatB,MAAM,CAAC,gBAAgB,CACrB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,GACtB,MAAM,EAAE;IAQX,MAAM,CAAC,mBAAmB,CACxB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,GACtB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAkBtB,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,EAAE;IAQ3E,UAAU,EAAE,OAAO,CAAC;IAEpB,2BAA2B,EAAE,MAAM,CAAC;IAEpC,YAAY,EAAE,OAAO,CAAC;IAEtB,cAAc,EAAE,OAAO,CAAC;IAExB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEzB,EACV,QAAQ,EAAE,aAAkB,EAC5B,YAAmB,EACnB,cAAsB,EACtB,2BAAoF,GACrF,GAAE,8BAAmC;IAwBtC,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAI1D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM;CAe3D;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -5,8 +5,7 @@ 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('DateTimeColumnFormatter');
|
|
8
|
-
|
|
9
|
-
class DateTimeColumnFormatter extends TableColumnFormatter {
|
|
8
|
+
export class DateTimeColumnFormatter extends TableColumnFormatter {
|
|
10
9
|
/**
|
|
11
10
|
* Validates format object
|
|
12
11
|
* @param format Format object
|
|
@@ -71,6 +70,17 @@ class DateTimeColumnFormatter extends TableColumnFormatter {
|
|
|
71
70
|
defaultDateTimeFormatString = DateTimeColumnFormatter.DEFAULT_DATETIME_FORMAT_STRING
|
|
72
71
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
73
72
|
super();
|
|
73
|
+
|
|
74
|
+
_defineProperty(this, "dhTimeZone", void 0);
|
|
75
|
+
|
|
76
|
+
_defineProperty(this, "defaultDateTimeFormatString", void 0);
|
|
77
|
+
|
|
78
|
+
_defineProperty(this, "showTimeZone", void 0);
|
|
79
|
+
|
|
80
|
+
_defineProperty(this, "showTSeparator", void 0);
|
|
81
|
+
|
|
82
|
+
_defineProperty(this, "formatStringMap", void 0);
|
|
83
|
+
|
|
74
84
|
var timeZone = timeZoneParam || DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID;
|
|
75
85
|
|
|
76
86
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/formatters/DateTimeColumnFormatter.ts"],"names":["dh","Log","TableColumnFormatter","log","module","DateTimeColumnFormatter","isValid","format","i18n","DateTimeFormat","formatString","Date","e","makeFormat","label","type","TYPE_CONTEXT_PRESET","isSameFormat","formatA","formatB","makeGlobalFormatStringMap","showTimeZone","showTSeparator","separator","tz","Map","getGlobalFormats","formatStringMap","keys","makeFormatStringMap","getFormats","constructor","timeZone","timeZoneParam","defaultDateTimeFormatString","DEFAULT_DATETIME_FORMAT_STRING","DEFAULT_TIME_ZONE_ID","dhTimeZone","TimeZone","getTimeZone","error","getEffectiveFormatString","baseFormatString","get","value"],"mappings":";;AAAA;AACA,OAAOA,EAAP,MAAe,uBAAf;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,oB;AAIP,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,yBAAX,CAAZ
|
|
1
|
+
{"version":3,"sources":["../../src/formatters/DateTimeColumnFormatter.ts"],"names":["dh","Log","TableColumnFormatter","log","module","DateTimeColumnFormatter","isValid","format","i18n","DateTimeFormat","formatString","Date","e","makeFormat","label","type","TYPE_CONTEXT_PRESET","isSameFormat","formatA","formatB","makeGlobalFormatStringMap","showTimeZone","showTSeparator","separator","tz","Map","getGlobalFormats","formatStringMap","keys","makeFormatStringMap","getFormats","constructor","timeZone","timeZoneParam","defaultDateTimeFormatString","DEFAULT_DATETIME_FORMAT_STRING","DEFAULT_TIME_ZONE_ID","dhTimeZone","TimeZone","getTimeZone","error","getEffect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P,EAAU;AACVT,MAAAA,GAAG,CAACqC,KAAJ,CAAU,0BAAV;AACD;;AACD,WAAO,EAAP;AACD;;AAnK+D;;gBAArDnC,uB,oCA8C6B,yB;;gBA9C7BA,uB,0BAgDmB,kB;;AAsHhC,eAAeA,uBAAf","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('DateTimeColumnFormatter');\n\nexport type DateTimeColumnFormatterOptions = {\n // Time zone\n timeZone?: string;\n\n // Show time zone in DateTime values\n showTimeZone?: boolean;\n\n // Show 'T' separator in DateTime values\n showTSeparator?: boolean;\n\n // DateTime format to use if columnFormats for DateTime isn't set\n defaultDateTimeFormatString?: string;\n};\n\nexport class DateTimeColumnFormatter 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.DateTimeFormat.format(format.formatString, new Date());\n return true;\n } catch (e) {\n return false;\n }\n }\n\n static makeFormat(\n label: string,\n formatString: string,\n type = TableColumnFormatter.TYPE_CONTEXT_PRESET\n ): TableColumnFormat {\n return {\n label,\n formatString,\n type,\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?: TableColumnFormat,\n formatB?: TableColumnFormat\n ): boolean {\n return (\n formatA === formatB ||\n (formatA != null &&\n formatB != null &&\n formatA.type === formatB.type &&\n formatA.formatString === formatB.formatString)\n );\n }\n\n static DEFAULT_DATETIME_FORMAT_STRING = 'yyyy-MM-dd HH:mm:ss.SSS';\n\n static DEFAULT_TIME_ZONE_ID = 'America/New_York';\n\n static makeGlobalFormatStringMap(\n showTimeZone: boolean,\n showTSeparator: boolean\n ): Map<string, string> {\n const separator = showTSeparator ? `'T'` : ' ';\n const tz = showTimeZone ? ' z' : '';\n return new Map([\n ['yyyy-MM-dd HH:mm:ss', `yyyy-MM-dd${separator}HH:mm:ss${tz}`],\n ['yyyy-MM-dd HH:mm:ss.SSS', `yyyy-MM-dd${separator}HH:mm:ss.SSS${tz}`],\n [\n 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS',\n `yyyy-MM-dd${separator}HH:mm:ss.SSSSSSSSS${tz}`,\n ],\n ]);\n }\n\n static getGlobalFormats(\n showTimeZone: boolean,\n showTSeparator: boolean\n ): string[] {\n const formatStringMap = DateTimeColumnFormatter.makeGlobalFormatStringMap(\n showTimeZone,\n showTSeparator\n );\n return [...formatStringMap.keys()];\n }\n\n static makeFormatStringMap(\n showTimeZone: boolean,\n showTSeparator: boolean\n ): Map<string, string> {\n const separator = showTSeparator ? `'T'` : ' ';\n const tz = showTimeZone ? ' z' : '';\n return new Map([\n ['yyyy-MM-dd', `yyyy-MM-dd${tz}`],\n ['MM-dd-yyyy', `MM-dd-yyyy${tz}`],\n ['HH:mm:ss', `HH:mm:ss${tz}`],\n ['HH:mm:ss.SSS', `HH:mm:ss.SSS${tz}`],\n ['HH:mm:ss.SSSSSSSSS', `HH:mm:ss.SSSSSSSSS${tz}`],\n ['yyyy-MM-dd HH:mm:ss', `yyyy-MM-dd${separator}HH:mm:ss${tz}`],\n ['yyyy-MM-dd HH:mm:ss.SSS', `yyyy-MM-dd${separator}HH:mm:ss.SSS${tz}`],\n [\n 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS',\n `yyyy-MM-dd${separator}HH:mm:ss.SSSSSSSSS${tz}`,\n ],\n ]);\n }\n\n static getFormats(showTimeZone: boolean, showTSeparator: boolean): string[] {\n const formatStringMap = DateTimeColumnFormatter.makeFormatStringMap(\n showTimeZone,\n showTSeparator\n );\n return [...formatStringMap.keys()];\n }\n\n dhTimeZone: unknown;\n\n defaultDateTimeFormatString: string;\n\n showTimeZone: boolean;\n\n showTSeparator: boolean;\n\n formatStringMap: Map<string, string>;\n\n constructor({\n timeZone: timeZoneParam = '',\n showTimeZone = true,\n showTSeparator = false,\n defaultDateTimeFormatString = DateTimeColumnFormatter.DEFAULT_DATETIME_FORMAT_STRING,\n }: DateTimeColumnFormatterOptions = {}) {\n super();\n\n const timeZone =\n timeZoneParam || DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID;\n\n try {\n this.dhTimeZone = dh.i18n.TimeZone.getTimeZone(timeZone);\n } catch (e) {\n log.error('Unsupported time zone id', timeZone);\n this.dhTimeZone = dh.i18n.TimeZone.getTimeZone(\n DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID\n );\n }\n\n this.defaultDateTimeFormatString = defaultDateTimeFormatString;\n this.showTimeZone = showTimeZone;\n this.showTSeparator = showTSeparator;\n this.formatStringMap = DateTimeColumnFormatter.makeFormatStringMap(\n showTimeZone,\n showTSeparator\n );\n }\n\n getEffectiveFormatString(baseFormatString: string): string {\n return this.formatStringMap.get(baseFormatString) || baseFormatString;\n }\n\n format(value: unknown, format?: TableColumnFormat): string {\n const baseFormatString =\n (format && format.formatString) || this.defaultDateTimeFormatString;\n const formatString = this.getEffectiveFormatString(baseFormatString);\n try {\n return dh.i18n.DateTimeFormat.format(\n formatString,\n value,\n this.dhTimeZone\n );\n } catch (e) {\n log.error('Invalid format arguments');\n }\n return '';\n }\n}\n\nexport default DateTimeColumnFormatter;\n"],"file":"DateTimeColumnFormatter.js"}
|
|
@@ -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":";;AAAA;AACA,OAAOA,EAAP,MAAe,uBAAf;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,oB;AAIP,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,wBAAX,CAAZ;AAWA,OAAO,MAAMC,sBAAN,SAAqCH,oBAArC,CAA0D;AAC/D;AACF;AACA;AACA;AACA;AACgB,SAAPI,OAAO,CAACC,MAAD,EAAqC;AACjD,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;AAA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A0CiB,KAA1C,CAAP;AACD,KAFD,CAEE,OAAOhB,CAAP,EAAU;AACVR,MAAAA,GAAG,CAACyB,KAAJ,CAAU,0BAAV;AACD;;AACD,WAAO,EAAP;AACD;;AA5J8D;;gBAApDvB,sB,2BA2EoB,c;;gBA3EpBA,sB,oBA6EaA,sBAAsB,CAACY,gBAAvB,CACtB,SADsB,EAEtB,SAFsB,C;;gBA7EbZ,sB,yBAkFkBA,sBAAsB,CAACY,gBAAvB,CAC3B,cAD2B,EAE3B,YAF2B,EAG3B,KAH2B,C;;gBAlFlBZ,sB,qBAwFcA,sBAAsB,CAACY,gBAAvB,CACvB,UADuB,EAEvB,gBAFuB,EAGvB,QAHuB,C;;gBAxFdZ,sB,kBA8FWA,sBAAsB,CAACY,gBAAvB,CACpB,OADoB,EAEpB,SAFoB,C;;gBA9FXZ,sB,+BAmGwBA,sBAAsB,CAACY,gBAAvB,CACjC,MADiC,EAEjC,YAFiC,C;;gBAnGxBZ,sB,gCAwGyBA,sBAAsB,CAACY,gBAAvB,CAClC,QADkC,EAElC,cAFkC,C;;AAuDtC,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('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,Y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