@deephaven/jsapi-utils 0.85.3 → 0.85.12
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/ViewportDataUtils.d.ts +3 -15
- package/dist/ViewportDataUtils.d.ts.map +1 -1
- package/dist/ViewportDataUtils.js +2 -14
- package/dist/ViewportDataUtils.js.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.d.ts +1 -0
- package/dist/formatters/DecimalColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.js +1 -0
- package/dist/formatters/DecimalColumnFormatter.js.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.d.ts +1 -0
- package/dist/formatters/IntegerColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.js +1 -0
- package/dist/formatters/IntegerColumnFormatter.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,12 +5,9 @@ export declare const ITEM_KEY_PREFIX = "DH_ITEM_KEY";
|
|
|
5
5
|
export type OnTableUpdatedEvent = CustomEvent<{
|
|
6
6
|
offset: number;
|
|
7
7
|
columns: dh.Column[];
|
|
8
|
-
rows:
|
|
8
|
+
rows: dh.Row[];
|
|
9
9
|
}>;
|
|
10
|
-
export type RowDeserializer<T> = (row:
|
|
11
|
-
export type ViewportRow = dh.Row & {
|
|
12
|
-
offsetInSnapshot: number;
|
|
13
|
-
};
|
|
10
|
+
export type RowDeserializer<T> = (row: dh.Row, columns: dh.Column[]) => T;
|
|
14
11
|
/**
|
|
15
12
|
* Create a `KeyedItem.key` for a given index. The prefix is necessary to avoid
|
|
16
13
|
* collisions with property values in the `item` property that may be used as
|
|
@@ -19,15 +16,6 @@ export type ViewportRow = dh.Row & {
|
|
|
19
16
|
* @returns A unique key for the given index.
|
|
20
17
|
*/
|
|
21
18
|
export declare function createKeyedItemKey(index: number): string;
|
|
22
|
-
/**
|
|
23
|
-
* Create a unique string key for a row based on its ordinal position in its
|
|
24
|
-
* source table. This is calculated based on it's offset in the viewport
|
|
25
|
-
* (row.offsetInSnapshot) + the offset of the snapshot.
|
|
26
|
-
* @param row Row from a Table update event.
|
|
27
|
-
* @param offset Offset of the current viewport.
|
|
28
|
-
* @returns Unique string key for the ordinal position of the given row.
|
|
29
|
-
*/
|
|
30
|
-
export declare function createKeyFromOffsetRow(row: ViewportRow, offset: number): string;
|
|
31
19
|
/**
|
|
32
20
|
* Creates a handler function for a `dh.Table.EVENT_UPDATED` event. Rows that
|
|
33
21
|
* get passed to the handler will be bulk updated in the given `viewportData`
|
|
@@ -46,7 +34,7 @@ export declare function createOnTableUpdatedHandler<T>({ bulkUpdate }: {
|
|
|
46
34
|
* @param columns Columns to map.
|
|
47
35
|
* @returns A key / value object for the row.
|
|
48
36
|
*/
|
|
49
|
-
export declare function defaultRowDeserializer<T>(row:
|
|
37
|
+
export declare function defaultRowDeserializer<T>(row: dh.Row, columns: dh.Column[]): T;
|
|
50
38
|
/**
|
|
51
39
|
* For windowing to work, the underlying list needs to maintain a KeyedItem for
|
|
52
40
|
* each row in the backing table (even if these rows haven't been loaded yet).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportDataUtils.d.ts","sourceRoot":"","sources":["../src/ViewportDataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAW,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"ViewportDataUtils.d.ts","sourceRoot":"","sources":["../src/ViewportDataUtils.ts"],"names":[],"mappings":"AA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;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,MAAM,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,GAAG,OAAO,CAMhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,EAAE,MAAM,CAAC,CAQlB"}
|
|
@@ -14,18 +14,6 @@ export function createKeyedItemKey(index) {
|
|
|
14
14
|
return "".concat(ITEM_KEY_PREFIX, "_").concat(index);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Create a unique string key for a row based on its ordinal position in its
|
|
19
|
-
* source table. This is calculated based on it's offset in the viewport
|
|
20
|
-
* (row.offsetInSnapshot) + the offset of the snapshot.
|
|
21
|
-
* @param row Row from a Table update event.
|
|
22
|
-
* @param offset Offset of the current viewport.
|
|
23
|
-
* @returns Unique string key for the ordinal position of the given row.
|
|
24
|
-
*/
|
|
25
|
-
export function createKeyFromOffsetRow(row, offset) {
|
|
26
|
-
return createKeyedItemKey(row.offsetInSnapshot + offset);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
17
|
/**
|
|
30
18
|
* Creates a handler function for a `dh.Table.EVENT_UPDATED` event. Rows that
|
|
31
19
|
* get passed to the handler will be bulk updated in the given `viewportData`
|
|
@@ -49,9 +37,9 @@ export function createOnTableUpdatedHandler(_ref, deserializeRow) {
|
|
|
49
37
|
} = event.detail;
|
|
50
38
|
log.debug('table updated', event.detail);
|
|
51
39
|
var updateKeyMap = new Map();
|
|
52
|
-
rows.forEach(row => {
|
|
40
|
+
rows.forEach((row, offsetInSnapshot) => {
|
|
53
41
|
var item = deserializeRow(row, columns);
|
|
54
|
-
var key =
|
|
42
|
+
var key = createKeyedItemKey(offset + offsetInSnapshot);
|
|
55
43
|
updateKeyMap.set(key, {
|
|
56
44
|
key,
|
|
57
45
|
item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportDataUtils.js","names":["clamp","Log","ITEM_KEY_PREFIX","log","module","createKeyedItemKey","index","concat","
|
|
1
|
+
{"version":3,"file":"ViewportDataUtils.js","names":["clamp","Log","ITEM_KEY_PREFIX","log","module","createKeyedItemKey","index","concat","createOnTableUpdatedHandler","_ref","deserializeRow","bulkUpdate","onTableUpdated","event","columns","offset","rows","detail","debug","updateKeyMap","Map","forEach","row","offsetInSnapshot","item","key","set","defaultRowDeserializer","reduce","result","col","name","get","generateEmptyKeyedItems","start","end","i","getSize","table","isClosed","size","padFirstAndLastRow","firstRow","viewportSize","padding","tableSize","lastRow","min","max","first","last"],"sources":["../src/ViewportDataUtils.ts"],"sourcesContent":["import type { Key } from 'react';\nimport clamp from 'lodash.clamp';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { KeyedItem, ValueOf } from '@deephaven/utils';\n\nexport const ITEM_KEY_PREFIX = 'DH_ITEM_KEY';\n\nexport type OnTableUpdatedEvent = CustomEvent<{\n offset: number;\n columns: dh.Column[];\n rows: dh.Row[];\n}>;\n\nexport type RowDeserializer<T> = (row: dh.Row, columns: dh.Column[]) => T;\n\nconst log = Log.module('ViewportDataUtils');\n\n/**\n * Create a `KeyedItem.key` for a given index. The prefix is necessary to avoid\n * collisions with property values in the `item` property that may be used as\n * keys once the item is loaded and rendered.\n * @param index Index to create a key for.\n * @returns A unique key for the given index.\n */\nexport function createKeyedItemKey(index: number): string {\n return `${ITEM_KEY_PREFIX}_${index}`;\n}\n\n/**\n * Creates a handler function for a `dh.Table.EVENT_UPDATED` event. Rows that\n * get passed to the handler will be bulk updated in the given `viewportData`\n * object based on their derived item keys.\n * @param viewportData State object for managing a list of KeyedItem data.\n * @param deserializeRow Converts a DH Row to an item object.\n * @returns Handler function for a `dh.Table.EVENT_UPDATED` event.\n */\nexport function createOnTableUpdatedHandler<T>(\n { bulkUpdate }: { bulkUpdate: (itemMap: Map<Key, KeyedItem<T>>) => void },\n deserializeRow: RowDeserializer<T>\n): (event: OnTableUpdatedEvent) => void {\n /**\n * Handler for a `dh.Table.EVENT_UPDATED` event.\n */\n return function onTableUpdated(event: OnTableUpdatedEvent) {\n const { columns, offset, rows } = event.detail;\n\n log.debug('table updated', event.detail);\n\n const updateKeyMap = new Map<Key, KeyedItem<T>>();\n\n rows.forEach((row, offsetInSnapshot) => {\n const item = deserializeRow(row, columns);\n const key = createKeyedItemKey(offset + offsetInSnapshot);\n updateKeyMap.set(key, { key, item });\n });\n\n log.debug('update keys', updateKeyMap);\n\n bulkUpdate(updateKeyMap);\n };\n}\n\n/**\n * Maps a Row to a key / value object. Keys are mapped ver batim from column\n * names.\n * @param row Row to map to an item.\n * @param columns Columns to map.\n * @returns A key / value object for the row.\n */\nexport function defaultRowDeserializer<T>(\n row: dh.Row,\n columns: dh.Column[]\n): T {\n return columns.reduce((result, col) => {\n // eslint-disable-next-line no-param-reassign\n result[col.name as keyof T] = row.get(col) as ValueOf<T>;\n return result;\n }, {} as T);\n}\n\n/**\n * For windowing to work, the underlying list needs to maintain a KeyedItem for\n * each row in the backing table (even if these rows haven't been loaded yet).\n * This is needed internally by react-spectrum so it can calculate the content\n * area size. This generator can create a range of empty `KeyedItem` objects.\n * @param start The starting index to generate\n * @param end The ending index to generate\n */\nexport function* generateEmptyKeyedItems<T>(\n start: number,\n end: number\n): Generator<KeyedItem<T>, void, unknown> {\n // eslint-disable-next-line no-plusplus\n for (let i = start; i <= end; ++i) {\n yield { key: createKeyedItemKey(i) };\n }\n}\n\n/**\n * Check a Table to see if it is closed before checking its size property. This\n * is important because calling Table.size on a closed table throws an error. If\n * the table is null or closed, return zero. Otherwise, return the current size.\n * @param table The table to check for its size.\n * @returns The size of the table or zero if the table is null or closed.\n */\nexport function getSize(table?: dh.Table | dh.TreeTable | null): number {\n return table == null || isClosed(table) ? 0 : table.size;\n}\n\n/**\n * Check if a given table is closed. Tree tables don't have an `isClosed` prop,\n * so will always return false.\n * @param table The table to check if it is closed.\n */\nexport function isClosed(table: dh.Table | dh.TreeTable): boolean {\n if ('isClosed' in table) {\n return table.isClosed;\n }\n\n return false;\n}\n\n/**\n * Determine the first and last row index for a viewport + extra leading and\n * trailing padding. Values will be \"clamped\" to stay within the table size.\n * @param firstRow Starting row index for the viewport.\n * @param viewportSize Size of the viewport.\n * @param padding Extra rows to add to the viewport. Will be used for leading\n * and trailing rows.\n * @param tableSize Total table size.\n * @returns Tuple containing indices for the first and last row.\n */\nexport function padFirstAndLastRow(\n firstRow: number,\n viewportSize: number,\n padding: number,\n tableSize: number\n): [number, number] {\n const lastRow = firstRow + viewportSize - 1;\n const [min, max] = [0, tableSize - 1];\n\n const first = clamp(firstRow - padding, min, max);\n const last = clamp(lastRow + padding, min, max);\n\n return [first, last];\n}\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,cAAc;AAEhC,OAAOC,GAAG,MAAM,gBAAgB;AAGhC,OAAO,IAAMC,eAAe,GAAG,aAAa;AAU5C,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,mBAAmB,CAAC;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAAa,EAAU;EACxD,UAAAC,MAAA,CAAUL,eAAe,OAAAK,MAAA,CAAID,KAAK;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,2BAA2BA,CAAAC,IAAA,EAEzCC,cAAkC,EACI;EAAA,IAFtC;IAAEC;EAAsE,CAAC,GAAAF,IAAA;EAGzE;AACF;AACA;EACE,OAAO,SAASG,cAAcA,CAACC,KAA0B,EAAE;IACzD,IAAM;MAAEC,OAAO;MAAEC,MAAM;MAAEC;I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AU;EACtE,OAAOA,KAAK,IAAI,IAAI,IAAIC,QAAQ,CAACD,KAAK,CAAC,GAAG,CAAC,GAAGA,KAAK,CAACE,IAAI;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASD,QAAQA,CAACD,KAA8B,EAAW;EAChE,IAAI,UAAU,IAAIA,KAAK,EAAE;IACvB,OAAOA,KAAK,CAACC,QAAQ;EACvB;EAEA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAChCC,QAAgB,EAChBC,YAAoB,EACpBC,OAAe,EACfC,SAAiB,EACC;EAClB,IAAMC,OAAO,GAAGJ,QAAQ,GAAGC,YAAY,GAAG,CAAC;EAC3C,IAAM,CAACI,GAAG,EAAEC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAEH,SAAS,GAAG,CAAC,CAAC;EAErC,IAAMI,KAAK,GAAGjD,KAAK,CAAC0C,QAAQ,GAAGE,OAAO,EAAEG,GAAG,EAAEC,GAAG,CAAC;EACjD,IAAME,IAAI,GAAGlD,KAAK,CAAC8C,OAAO,GAAGF,OAAO,EAAEG,GAAG,EAAEC,GAAG,CAAC;EAE/C,OAAO,CAACC,KAAK,EAAEC,IAAI,CAAC;AACtB"}
|
|
@@ -41,6 +41,7 @@ export declare class DecimalColumnFormatter extends TableColumnFormatter<number>
|
|
|
41
41
|
static DEFAULT_FORMAT_STRING: string;
|
|
42
42
|
static FORMAT_PERCENT: DecimalColumnFormat;
|
|
43
43
|
static FORMAT_BASIS_POINTS: DecimalColumnFormat;
|
|
44
|
+
static FORMAT_THOUSANDS: DecimalColumnFormat;
|
|
44
45
|
static FORMAT_MILLIONS: DecimalColumnFormat;
|
|
45
46
|
static FORMAT_SCIENTIFIC_NOTATION: DecimalColumnFormat;
|
|
46
47
|
static FORMAT_ROUND: DecimalColumnFormat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dec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B;;;;;;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,gBAAgB,sBAIrB;IAEF,MAAM,CAAC,eAAe,sBAIpB;IAEF,MAAM,CAAC,0BAA0B,sBAG/B;IAEF,MAAM,CAAC,YAAY,sBAGjB;IAEF,MAAM,CAAC,yBAAyB,sBAG9B;IAEF,MAAM,CAAC,0BAA0B,sBAG/B;IAEF;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,OAAO,EAAE,mBAAmB,GAAG,IAAI,EACnC,OAAO,EAAE,mBAAmB,GAAG,IAAI,GAClC,OAAO;IAWV,mBAAmB,EAAE,MAAM,CAAC;IAE5B,EAAE,EAAE,OAAO,MAAM,CAAC;gBAGhB,EAAE,EAAE,OAAO,MAAM,EACjB,EACE,mBAAkE,GACnE,GAAE,6BAAkC;IAQvC;;;;;OAKG;IACH,MAAM,CACJ,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM,GACxC,MAAM;CAgBV;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -109,6 +109,7 @@ export class DecimalColumnFormatter extends TableColumnFormatter {
|
|
|
109
109
|
_defineProperty(DecimalColumnFormatter, "DEFAULT_FORMAT_STRING", '###,##0.0000');
|
|
110
110
|
_defineProperty(DecimalColumnFormatter, "FORMAT_PERCENT", DecimalColumnFormatter.makePresetFormat('Percent', '##0.00%'));
|
|
111
111
|
_defineProperty(DecimalColumnFormatter, "FORMAT_BASIS_POINTS", DecimalColumnFormatter.makePresetFormat('Basis Points', '###,##0 bp', 10000));
|
|
112
|
+
_defineProperty(DecimalColumnFormatter, "FORMAT_THOUSANDS", DecimalColumnFormatter.makePresetFormat('Thousands', '##0.000 k', 0.001));
|
|
112
113
|
_defineProperty(DecimalColumnFormatter, "FORMAT_MILLIONS", DecimalColumnFormatter.makePresetFormat('Millions', '###,##0.000 mm', 0.000001));
|
|
113
114
|
_defineProperty(DecimalColumnFormatter, "FORMAT_SCIENTIFIC_NOTATION", DecimalColumnFormatter.makePresetFormat('Scientific Notation', '0.0000E0'));
|
|
114
115
|
_defineProperty(DecimalColumnFormatter, "FORMAT_ROUND", DecimalColumnFormatter.makePresetFormat('Round', '###,##0'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalColumnFormatter.js","names":["Log","TableColumnFormatter","log","module","DecimalColumnFormatter","isValid","dh","format","formatString","i18n","NumberFormat","e","makeFormat","label","type","arguments","length","undefined","TYPE_CONTEXT_PRESET","multiplier","makePresetFormat","makeCustomFormat","TYPE_CONTEXT_CUSTOM","isSameFormat","formatA","formatB","constructor","defaultFormatString","DEFAULT_FORMAT_STRING","_defineProperty","valueParam","value","error"],"sources":["../../src/formatters/DecimalColumnFormatter.ts"],"sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport type { dh as DhType } from '@deephaven/jsapi-types';\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 | null;\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<number> {\n /**\n * Validates format object\n * @param dh JSAPI instance\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(\n dh: typeof DhType,\n format: Pick<TableColumnFormat, 'formatString'>\n ): boolean {\n if (format.formatString == null) {\n return false;\n }\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_SCIENTIFIC_NOTATION = DecimalColumnFormatter.makePresetFormat(\n 'Scientific Notation',\n '0.0000E0'\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 | null,\n formatB: DecimalColumnFormat | null\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 dh: typeof DhType;\n\n constructor(\n dh: typeof DhType,\n {\n defaultFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING,\n }: DecimalColumnFormatterOptions = {}\n ) {\n super();\n\n this.dh = dh;\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(\n valueParam: number,\n format: Partial<DecimalColumnFormat> = {}\n ): string {\n const formatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultFormatString;\n const value =\n format.multiplier != null && format.multiplier !== 0\n ? valueParam * format.multiplier\n : valueParam;\n try {\n return this.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"],"mappings":";;;AAAA;;AAEA,OAAOA,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,oBAAoB;AAI3B,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,wBAAwB,CAAC;AAWhD,OAAO,MAAMC,sBAAsB,SAASH,oBAAoB,CAAS;EACvE;AACF;AACA;AACA;AAC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AA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEnB,OAAOb,sBAAsB,CAACQ,UAAU,CACtC,eAAe,EACfJ,YAAY,EACZP,oBAAoB,CAACqB,mBAAmB,EACxCH,UACF,CAAC;EACH;
|
|
1
|
+
{"version":3,"file":"DecimalColumnFormatter.js","names":["Log","TableColumnFormatter","log","module","DecimalColumnFormatter","isValid","dh","format","formatString","i18n","NumberFormat","e","makeFormat","label","type","arguments","length","undefined","TYPE_CONTEXT_PRESET","multiplier","makePresetFormat","makeCustomFormat","TYPE_CONTEXT_CUSTOM","isSameFormat","formatA","formatB","constructor","defaultFormatString","DEFAULT_FORMAT_STRING","_defineProperty","valueParam","value","error"],"sources":["../../src/formatters/DecimalColumnFormatter.ts"],"sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport type { dh as DhType } from '@deephaven/jsapi-types';\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 | null;\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<number> {\n /**\n * Validates format object\n * @param dh JSAPI instance\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(\n dh: typeof DhType,\n format: Pick<TableColumnFormat, 'formatString'>\n ): boolean {\n if (format.formatString == null) {\n return false;\n }\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_THOUSANDS = DecimalColumnFormatter.makePresetFormat(\n 'Thousands',\n '##0.000 k',\n 0.001\n );\n\n static FORMAT_MILLIONS = DecimalColumnFormatter.makePresetFormat(\n 'Millions',\n '###,##0.000 mm',\n 0.000001\n );\n\n static FORMAT_SCIENTIFIC_NOTATION = DecimalColumnFormatter.makePresetFormat(\n 'Scientific Notation',\n '0.0000E0'\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 | null,\n formatB: DecimalColumnFormat | null\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 dh: typeof DhType;\n\n constructor(\n dh: typeof DhType,\n {\n defaultFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING,\n }: DecimalColumnFormatterOptions = {}\n ) {\n super();\n\n this.dh = dh;\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(\n valueParam: number,\n format: Partial<DecimalColumnFormat> = {}\n ): string {\n const formatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultFormatString;\n const value =\n format.multiplier != null && format.multiplier !== 0\n ? valueParam * format.multiplier\n : valueParam;\n try {\n return this.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"],"mappings":";;;AAAA;;AAEA,OAAOA,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,oBAAoB;AAI3B,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,wBAAwB,CAAC;AAWhD,OAAO,MAAMC,sBAAsB,SAASH,oBAAoB,CAAS;EACvE;AACF;AACA;AACA;AACA;AACA;EACE,OAAOI,OAAOA,CACZC,EAAiB,EACjBC,MAA+C,EACtC;IACT,IAAIA,MAAM,CAACC,YAAY,IAAI,IAAI,EAAE;MAC/B,OAAO,KAAK;IACd;IACA,IAAI;MACFF,EAAE,CAACG,IAAI,CAACC,YAAY,CAACH,MAAM,CAACA,MAAM,CAACC,YAAY,EAA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K,CAAC,0BAA0B,CAAC;IACvC;IACA,OAAO,EAAE;EACX;AACF;AAACH,eAAA,CA5LYzB,sBAAsB,2BAkFF,cAAc;AAAAyB,eAAA,CAlFlCzB,sBAAsB,oBAoFTA,sBAAsB,CAACgB,gBAAgB,CAC7D,SAAS,EACT,SACF,CAAC;AAAAS,eAAA,CAvFUzB,sBAAsB,yBAyFJA,sBAAsB,CAACgB,gBAAgB,CAClE,cAAc,EACd,YAAY,EACZ,KACF,CAAC;AAAAS,eAAA,CA7FUzB,sBAAsB,sBA+FPA,sBAAsB,CAACgB,gBAAgB,CAC/D,WAAW,EACX,WAAW,EACX,KACF,CAAC;AAAAS,eAAA,CAnGUzB,sBAAsB,qBAqGRA,sBAAsB,CAACgB,gBAAgB,CAC9D,UAAU,EACV,gBAAgB,EAChB,QACF,CAAC;AAAAS,eAAA,CAzGUzB,sBAAsB,gCA2GGA,sBAAsB,CAACgB,gBAAgB,CACzE,qBAAqB,EACrB,UACF,CAAC;AAAAS,eAAA,CA9GUzB,sBAAsB,kBAgHXA,sBAAsB,CAACgB,gBAAgB,CAC3D,OAAO,EACP,SACF,CAAC;AAAAS,eAAA,CAnHUzB,sBAAsB,+BAqHEA,sBAAsB,CAACgB,gBAAgB,CACxE,MAAM,EACN,YACF,CAAC;AAAAS,eAAA,CAxHUzB,sBAAsB,gCA0HGA,sBAAsB,CAACgB,gBAAgB,CACzE,QAAQ,EACR,cACF,CAAC;AAiEH,eAAehB,sBAAsB"}
|
|
@@ -47,6 +47,7 @@ export declare class IntegerColumnFormatter extends TableColumnFormatter<number>
|
|
|
47
47
|
*/
|
|
48
48
|
static isSameFormat(formatA: IntegerColumnFormat | null, formatB: IntegerColumnFormat | null): boolean;
|
|
49
49
|
static DEFAULT_FORMAT_STRING: string;
|
|
50
|
+
static FORMAT_THOUSANDS: IntegerColumnFormat;
|
|
50
51
|
static FORMAT_MILLIONS: IntegerColumnFormat;
|
|
51
52
|
static FORMAT_SCIENTIFIC_NOTATION: IntegerColumnFormat;
|
|
52
53
|
dh: typeof DhType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegerColumnFormatter.d.ts","sourceRoot":"","sources":["../../src/formatters/IntegerColumnFormatter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,oBAAoB,EAAE,EAC3B,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAE1C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,kDAAkD;AAClD,qBAAa,sBAAuB,SAAQ,oBAAoB,CAAC,MAAM,CAAC;IACtE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAE,EAAE,OAAO,MAAM,EACjB,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,GAC9C,OAAO;IAYV;;;;;;;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,EAAE,mBAAmB,GAAG,IAAI,EACnC,OAAO,EAAE,mBAAmB,GAAG,IAAI,GAClC,OAAO;IAWV,MAAM,CAA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AM,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,EAAE,mBAAmB,GAAG,IAAI,EACnC,OAAO,EAAE,mBAAmB,GAAG,IAAI,GAClC,OAAO;IAWV,MAAM,CAAC,qBAAqB,SAAa;IAEzC,MAAM,CAAC,gBAAgB,sBAIrB;IAEF,MAAM,CAAC,eAAe,sBAIpB;IAEF,MAAM,CAAC,0BAA0B,sBAG/B;IAEF,EAAE,EAAE,OAAO,MAAM,CAAC;IAElB,mBAAmB,EAAE,MAAM,CAAC;gBAG1B,EAAE,EAAE,OAAO,MAAM,EACjB,EACE,mBAAkE,GACnE,GAAE,6BAAkC;IAOvC;;;;;OAKG;IACH,MAAM,CACJ,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM,GACxC,MAAM;CAgBV;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -109,6 +109,7 @@ export class IntegerColumnFormatter extends TableColumnFormatter {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
_defineProperty(IntegerColumnFormatter, "DEFAULT_FORMAT_STRING", '###,##0');
|
|
112
|
+
_defineProperty(IntegerColumnFormatter, "FORMAT_THOUSANDS", IntegerColumnFormatter.makePresetFormat('Thousands', '##0.000 k', 0.001));
|
|
112
113
|
_defineProperty(IntegerColumnFormatter, "FORMAT_MILLIONS", IntegerColumnFormatter.makePresetFormat('Millions', '###,##0.000 mm', 0.000001));
|
|
113
114
|
_defineProperty(IntegerColumnFormatter, "FORMAT_SCIENTIFIC_NOTATION", IntegerColumnFormatter.makePresetFormat('Scientific Notation', '0.0000E0'));
|
|
114
115
|
export default IntegerColumnFormatter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegerColumnFormatter.js","names":["Log","TableColumnFormatter","log","module","IntegerColumnFormatter","isValid","dh","format","formatString","i18n","NumberFormat","e","makeFormat","label","type","arguments","length","undefined","TYPE_CONTEXT_PRESET","multiplier","makePresetFormat","makeCustomFormat","TYPE_CONTEXT_CUSTOM","isSameFormat","formatA","formatB","constructor","defaultFormatString","DEFAULT_FORMAT_STRING","_defineProperty","valueParam","value","error"],"sources":["../../src/formatters/IntegerColumnFormatter.ts"],"sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport type { dh as DhType } from '@deephaven/jsapi-types';\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 | null;\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<number> {\n /**\n * Validates format object\n * @param dh JSAPI instance\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(\n dh: typeof DhType,\n format: Pick<TableColumnFormat, 'formatString'>\n ): boolean {\n if (format.formatString == null) {\n return false;\n }\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 | null,\n formatB: IntegerColumnFormat | null\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 static FORMAT_SCIENTIFIC_NOTATION = IntegerColumnFormatter.makePresetFormat(\n 'Scientific Notation',\n '0.0000E0'\n );\n\n dh: typeof DhType;\n\n defaultFormatString: string;\n\n constructor(\n dh: typeof DhType,\n {\n defaultFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING,\n }: IntegerColumnFormatterOptions = {}\n ) {\n super();\n this.dh = dh;\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(\n valueParam: number,\n format: Partial<IntegerColumnFormat> = {}\n ): string {\n const formatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultFormatString;\n const value =\n format.multiplier != null && format.multiplier !== 0\n ? valueParam * format.multiplier\n : valueParam;\n try {\n return this.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"],"mappings":";;;AAAA;;AAEA,OAAOA,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,oBAAoB;AAI3B,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,wBAAwB,CAAC;AAWhD;AACA,OAAO,MAAMC,sBAAsB,SAASH,oBAAoB,CAAS;EACvE;AACF;AACA;AACA;AACA;AACA;EACE,OAAOI,OAAOA,CACZC,EAAiB,EACjBC,MAA+C,EACtC;IACT,IAAIA,MAAM,CAACC,YAAY,IAAI,IAAI,EAAE;MAC/B,OAAO,KAAK;IACd;IACA,IAAI;MACFF,EAAE,CAACG,IAAI,CAACC,YAAY,CAACH,MAAM,CAACA,MAAM,CAACC,YAAY,EAAE,CAAC,CAAC;MACnD,OAAO,IAAI;IACb,CAAC,CAAC,OAAOG,CAAC,EAAE;MACV,OAAO,KAAK;IACd;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,UAAUA,CACfC,KAAa,EACbL,YAAoB,EAGC;IAAA,IAFrBM,IAAI,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGd,oBAAoB,CAACiB,mBAAmB;IAAA,IAC/CC,UAAmB,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEnB,OAAO;MACLJ,KAAK;MACLC,IAAI;MACJN,YAAY;MACZW;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,gBAAgBA,CACrBP,KAAa,EAGQ;IAAA,IAFrBL,YAAY,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACjBI,UAAmB,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEnB,OAAOb,sBAAsB,CAACQ,UAAU,CACtCC,KAAK,EACLL,YAAY,EACZP,oBAAoB,CAACiB,mBAAmB,EACxCC,UACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOE,gBAAgBA,CAAA,EAGA;IAAA,IAFrBb,YAAY,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACjBI,UAAmB,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEnB,OAAOb,sBAAsB,CAACQ,UAAU,CACtC,eAAe,EACfJ,YAAY,EACZP,oBAAoB,CAACqB,mBAAmB,EACxCH,UACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOI,YAAYA,CACjBC,OAAmC,EACnCC,OAAmC,EAC1B;IACT,OACED,OAAO,KAAKC,OAAO,IAClBD,OAAO,IAAI,IAAI,IACdC,OAAO,IAAI,IAAI,IACfD,OAAO,CAACV,IAAI,KAAKW,OAAO,CAACX,IAAI,IAC7BU,OAAO,CAAChB,YAAY,KAAKiB,OAAO,CAACjB,YAAY,IAC7CgB,OAAO,CAACL,UAAU,KAAKM,OAAO,CAACN,UAAW;EAEhD;
|
|
1
|
+
{"version":3,"file":"IntegerColumnFormatter.js","names":["Log","TableColumnFormatter","log","module","IntegerColumnFormatter","isValid","dh","format","formatString","i18n","NumberFormat","e","makeFormat","label","type","arguments","length","undefined","TYPE_CONTEXT_PRESET","multiplier","makePresetFormat","makeCustomFormat","TYPE_CONTEXT_CUSTOM","isSameFormat","formatA","formatB","constructor","defaultFormatString","DEFAULT_FORMAT_STRING","_defineProperty","valueParam","value","error"],"sources":["../../src/formatters/IntegerColumnFormatter.ts"],"sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport type { dh as DhType } from '@deephaven/jsapi-types';\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 | null;\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<number> {\n /**\n * Validates format object\n * @param dh JSAPI instance\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(\n dh: typeof DhType,\n format: Pick<TableColumnFormat, 'formatString'>\n ): boolean {\n if (format.formatString == null) {\n return false;\n }\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 | null,\n formatB: IntegerColumnFormat | null\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_THOUSANDS = IntegerColumnFormatter.makePresetFormat(\n 'Thousands',\n '##0.000 k',\n 0.001\n );\n\n static FORMAT_MILLIONS = IntegerColumnFormatter.makePresetFormat(\n 'Millions',\n '###,##0.000 mm',\n 0.000001\n );\n\n static FORMAT_SCIENTIFIC_NOTATION = IntegerColumnFormatter.makePresetFormat(\n 'Scientific Notation',\n '0.0000E0'\n );\n\n dh: typeof DhType;\n\n defaultFormatString: string;\n\n constructor(\n dh: typeof DhType,\n {\n defaultFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING,\n }: IntegerColumnFormatterOptions = {}\n ) {\n super();\n this.dh = dh;\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(\n valueParam: number,\n format: Partial<IntegerColumnFormat> = {}\n ): string {\n const formatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultFormatString;\n const value =\n format.multiplier != null && format.multiplier !== 0\n ? valueParam * format.multiplier\n : valueParam;\n try {\n return this.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"],"mappings":";;;AAAA;;AAEA,OAAOA,GAAG,MAAM,gBAAgB;AA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EAAE,GACrDD,MAAM,CAACC,YAAY,GACnB,IAAI,CAACmB,mBAAmB;IAC9B,IAAMI,KAAK,GACTxB,MAAM,CAACY,UAAU,IAAI,IAAI,IAAIZ,MAAM,CAACY,UAAU,KAAK,CAAC,GAChDW,UAAU,GAAGvB,MAAM,CAACY,UAAU,GAC9BW,UAAU;IAChB,IAAI;MACF,OAAO,IAAI,CAACxB,EAAE,CAACG,IAAI,CAACC,YAAY,CAACH,MAAM,CAACC,YAAY,EAAEuB,KAAK,CAAC;IAC9D,CAAC,CAAC,OAAOpB,CAAC,EAAE;MACVT,GAAG,CAAC8B,KAAK,CAAC,0BAA0B,CAAC;IACvC;IACA,OAAO,EAAE;EACX;AACF;AAACH,eAAA,CAjKYzB,sBAAsB,2BAsGF,SAAS;AAAAyB,eAAA,CAtG7BzB,sBAAsB,sBAwGPA,sBAAsB,CAACgB,gBAAgB,CAC/D,WAAW,EACX,WAAW,EACX,KACF,CAAC;AAAAS,eAAA,CA5GUzB,sBAAsB,qBA8GRA,sBAAsB,CAACgB,gBAAgB,CAC9D,UAAU,EACV,gBAAgB,EAChB,QACF,CAAC;AAAAS,eAAA,CAlHUzB,sBAAsB,gCAoHGA,sBAAsB,CAACgB,gBAAgB,CACzE,qBAAqB,EACrB,UACF,CAAC;AA4CH,eAAehB,sBAAsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/jsapi-utils",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.12",
|
|
4
4
|
"description": "Deephaven JSAPI Utils",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a411f250f0abe64dfea9f8b7940947fa82156904"
|
|
42
42
|
}
|