@deephaven/iris-grid 0.8.1 → 0.8.2-beta.6

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.
@@ -19,20 +19,13 @@ declare class Formatter {
19
19
  };
20
20
  /**
21
21
  * @param {Array} columnFormattingRules Optional array of column formatting rules
22
- * @param {Object} dateTimeOptions Optional object with DateTime configuration
23
- * @param {string} dateTimeOptions.timeZone Time zone
24
- * @param {boolean} dateTimeOptions.showTimeZone Show time zone in DateTime values
25
- * @param {boolean} dateTimeOptions.showTSeparator Show 'T' separator in DateTime values
26
- * @param {string} dateTimeOptions.defaultDateTimeFormatString DateTime format to use if columnFormats for DateTime isn't set
22
+ * @param {DateTimeColumnFormatterOptions} dateTimeOptions Optional object with DateTime configuration
23
+ * @param {DecimalColumnFormatterOptions} decimalFormatOptions Optional object with Decimal format configuration
24
+ * @param {IntegerColumnFormatterOptions} integerFormatOptions Optional object with Integer format configuration
27
25
  */
28
- constructor(columnFormattingRules?: any[], dateTimeOptions?: {
29
- timeZone: string;
30
- showTimeZone: boolean;
31
- showTSeparator: boolean;
32
- defaultDateTimeFormatString: string;
33
- });
26
+ constructor(columnFormattingRules?: any[], dateTimeOptions?: any, decimalFormatOptions?: any, integerFormatOptions?: any);
34
27
  defaultColumnFormatter: DefaultColumnFormatter;
35
- typeFormatterMap: Map<string, DateTimeColumnFormatter>;
28
+ typeFormatterMap: Map<string, CharColumnFormatter>;
36
29
  columnFormatMap: any;
37
30
  /**
38
31
  * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
@@ -48,7 +41,7 @@ declare class Formatter {
48
41
  * @returns format object or null for Default
49
42
  */
50
43
  getColumnFormat(columnType: string, columnName: string): any;
51
- getColumnTypeFormatter(columnType: any): DateTimeColumnFormatter | DefaultColumnFormatter | undefined;
44
+ getColumnTypeFormatter(columnType: any): CharColumnFormatter | DefaultColumnFormatter | undefined;
52
45
  /**
53
46
  * Gets formatted string for a given value, column type and name
54
47
  * @param {Any} value Value to format
@@ -64,5 +57,5 @@ declare class Formatter {
64
57
  get timeZone(): string;
65
58
  }
66
59
  import { DefaultColumnFormatter } from "./formatters";
67
- import { DateTimeColumnFormatter } from "./formatters";
60
+ import { CharColumnFormatter } from "./formatters";
68
61
  //# sourceMappingURL=Formatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.js"],"names":[],"mappings":";AAUA;IACE;;;;OAIG;IACH,8DAaC;IAED;;;;;OAKG;IACH;;;;MAMC;IAED;;;;;;;OAOG;IACH;QALmC,QAAQ,EAAhC,MAAM;QACmB,YAAY,EAArC,OAAO;QACkB,cAAc,EAAvC,OAAO;QACiB,2BAA2B,EAAnD,MAAM;OAwBhB;IAhBC,+CAA0D;IAG1D,uDASE;IAGF,qBAA2E;IAG7E;;;;;OAKG;IACH,gFAMC;IAED;;;;;OAKG;IACH,6DAMC;IAED,sGAMC;IAED;;;;;;OAMG;IACH,yGAeC;IAED;;;OAGG;IACH,uBAGC;CACF"}
1
+ {"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.js"],"names":[],"mappings":";AAUA;IACE;;;;OAIG;IACH,8DAaC;IAED;;;;;OAKG;IACH;;;;MAMC;IAED;;;;;OAKG;IACH,0HAiCC;IAtBC,+CAA0D;IAG1D,mDAeE;IAGF,qBAA2E;IAG7E;;;;;OAKG;IACH,gFAMC;IAED;;;;;OAKG;IACH,6DAMC;IAED,kGAMC;IAED;;;;;;OAMG;IACH,yGAeC;IAED;;;OAGG;IACH,uBAGC;CACF"}
package/dist/Formatter.js CHANGED
@@ -41,24 +41,24 @@ class Formatter {
41
41
  }
42
42
  /**
43
43
  * @param {Array} columnFormattingRules Optional array of column formatting rules
44
- * @param {Object} dateTimeOptions Optional object with DateTime configuration
45
- * @param {string} dateTimeOptions.timeZone Time zone
46
- * @param {boolean} dateTimeOptions.showTimeZone Show time zone in DateTime values
47
- * @param {boolean} dateTimeOptions.showTSeparator Show 'T' separator in DateTime values
48
- * @param {string} dateTimeOptions.defaultDateTimeFormatString DateTime format to use if columnFormats for DateTime isn't set
44
+ * @param {DateTimeColumnFormatterOptions} dateTimeOptions Optional object with DateTime configuration
45
+ * @param {DecimalColumnFormatterOptions} decimalFormatOptions Optional object with Decimal format configuration
46
+ * @param {IntegerColumnFormatterOptions} integerFormatOptions Optional object with Integer format configuration
49
47
  */
50
48
 
51
49
 
52
50
  constructor() {
53
51
  var columnFormattingRules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
54
52
  var dateTimeOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
53
+ var decimalFormatOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54
+ var integerFormatOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
55
55
  // Formatting order:
56
56
  // - columnFormatMap[type][name]
57
57
  // - typeFormatterMap[type]
58
58
  // - defaultColumnFormatter
59
59
  this.defaultColumnFormatter = new DefaultColumnFormatter(); // Default formatters by data type
60
60
 
61
- this.typeFormatterMap = new Map([[TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()], [TableUtils.dataType.CHAR, new CharColumnFormatter()], [TableUtils.dataType.DATETIME, new DateTimeColumnFormatter(dateTimeOptions)], [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter()], [TableUtils.dataType.INT, new IntegerColumnFormatter()]]); // Formats indexed by data type and column name
61
+ this.typeFormatterMap = new Map([[TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()], [TableUtils.dataType.CHAR, new CharColumnFormatter()], [TableUtils.dataType.DATETIME, new DateTimeColumnFormatter(dateTimeOptions)], [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter(decimalFormatOptions)], [TableUtils.dataType.INT, new IntegerColumnFormatter(integerFormatOptions)]]); // Formats indexed by data type and column name
62
62
 
63
63
  this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Formatter.js"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","Formatter","makeColumnFormatMap","columnFormattingRules","Map","reduce","map","next","dataType","getNormalizedType","columnType","has","set","formatMap","get","columnName","format","makeColumnFormattingRule","constructor","dateTimeOptions","defaultColumnFormatter","typeFormatterMap","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","columnFormatMap","getColumnFormatMapForType","createIfNecessary","getColumnFormat","getColumnTypeFormatter","getFormattedString","value","formatOverride","formatter","timeZone","dhTimeZone","id"],"mappings":"OAAOA,U;SAELC,sB,EACAC,mB,EACAC,uB,EACAC,sB,EACAC,sB,EACAC,sB;;AAGF,MAAMC,SAAN,CAAgB;AACd;AACF;AACA;AACA;AACA;AAC4B,SAAnBC,mBAAmB,CAACC,qBAAD,EAAwB;AAChD,QAAIA,qBAAqB,IAAI,IAA7B,EAAmC;AACjC,aAAO,IAAIC,GAAJ,EAAP;AACD;;AACD,WAAOD,qBAAqB,CAACE,MAAtB,CAA6B,CAACC,GAAD,EAAMC,IAAN,KAAe;AACjD,UAAMC,QAAQ,GAAGd,UAAU,CAACe,iBAAX,CAA6BF,IAAI,CAACG,UAAlC,CAAjB;;AACA,UAAI,CAACJ,GAAG,CAACK,GAAJ,CAAQH,QAAR,CAAL,EAAwB;AACtBF,QAAAA,GAAG,CAACM,GAAJ,CAAQJ,QAAR,EAAkB,IAAIJ,GAAJ,EAAlB;AACD;;AACD,UAAMS,SAAS,GAAGP,GAAG,CAACQ,GAAJ,CAAQN,QAAR,CAAlB;AACAK,MAAAA,SAAS,CAACD,GAAV,CAAcL,IAAI,CAACQ,UAAnB,EAA+BR,IAAI,CAACS,MAApC;AACA,aAAOV,GAAP;AACD,KARM,EAQJ,IAAIF,GAAJ,EARI,CAAP;AASD;AAED;AACF;AACA;AACA;AACA;AACA;;;AACiC,SAAxBa,wBAA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AACF;AACA;AACA;;;AACc,MAARoB,QAAQ,GAAG;AAAA;;AACb,oCAAO,KAAKf,gBAAL,CAAsBP,GAAtB,CAA0BpB,UAAU,CAACc,QAAX,CAAoBgB,QAA9C,CAAP,oFAAO,sBAAyDa,UAAhE,2DAAO,uBACHC,EADJ;AAED;;AAtIa;;AAyIhB,eAAerC,SAAf","sourcesContent":["import TableUtils from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n} from './formatters';\n\nclass Formatter {\n /**\n * Converts [{columnType, columnName, format}] to Map { dataType, Map { columnName, format }}\n * @param {Array} columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(columnFormattingRules) {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (!map.has(dataType)) {\n map.set(dataType, new Map());\n }\n const formatMap = map.get(dataType);\n formatMap.set(next.columnName, next.format);\n return map;\n }, new Map());\n }\n\n /**\n * Creates a column formatting rule\n * @param {String} columnType Normalized data type\n * @param {String} columnName Column name\n * @param {String} format Format string\n */\n static makeColumnFormattingRule(columnType, columnName, format) {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param {Array} columnFormattingRules Optional array of column formatting rules\n * @param {Object} dateTimeOptions Optional object with DateTime configuration\n * @param {string} dateTimeOptions.timeZone Time zone\n * @param {boolean} dateTimeOptions.showTimeZone Show time zone in DateTime values\n * @param {boolean} dateTimeOptions.showTSeparator Show 'T' separator in DateTime values\n * @param {string} dateTimeOptions.defaultDateTimeFormatString DateTime format to use if columnFormats for DateTime isn't set\n */\n constructor(columnFormattingRules = [], dateTimeOptions = {}) {\n // Formatting order:\n // - columnFormatMap[type][name]\n // - typeFormatterMap[type]\n // - defaultColumnFormatter\n\n this.defaultColumnFormatter = new DefaultColumnFormatter();\n\n // Default formatters by data type\n this.typeFormatterMap = new Map([\n [TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()],\n [TableUtils.dataType.CHAR, new CharColumnFormatter()],\n [\n TableUtils.dataType.DATETIME,\n new DateTimeColumnFormatter(dateTimeOptions),\n ],\n [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter()],\n [TableUtils.dataType.INT, new IntegerColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n }\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param {String} columnType column type\n * @param {Boolean} createIfNecessary create new entry if true\n * @returns Map of format strings indexed by column name or undefined if it doesn't exist\n */\n getColumnFormatMapForType(columnType, createIfNecessary = false) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (createIfNecessary && !this.columnFormatMap.has(dataType)) {\n this.columnFormatMap.set(dataType, new Map());\n }\n return this.columnFormatMap.get(dataType);\n }\n\n /**\n * Gets a column format object for a given column type and name\n * @param {String} columnType column type\n * @param {String} columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(columnType, columnName) {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n if (columnFormatMap && columnFormatMap.has(columnName)) {\n return columnFormatMap.get(columnName);\n }\n return null;\n }\n\n getColumnTypeFormatter(columnType) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType && this.typeFormatterMap.has(dataType)) {\n return this.typeFormatterMap.get(dataType);\n }\n return this.defaultColumnFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param {Any} value Value to format\n * @param {String} columnType Column type used to determine the formatting settings\n * @param {String} columnName Column name used to determine the formatting settings\n * @param {String} formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value,\n columnType,\n columnName = '',\n formatOverride = null\n ) {\n if (value == null) {\n return '';\n }\n\n const formatter = this.getColumnTypeFormatter(columnType);\n const format =\n formatOverride || this.getColumnFormat(columnType, columnName);\n\n return formatter.format(value, format);\n }\n\n /**\n * Gets the timeZone name\n * @returns {string} The time zone name E.g. America/New_York\n */\n get timeZone() {\n return this.typeFormatterMap.get(TableUtils.dataType.DATETIME)?.dhTimeZone\n ?.id;\n }\n}\n\nexport default Formatter;\n"],"file":"Formatter.js"}
1
+ {"version":3,"sources":["../src/Formatter.js"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","Formatter","makeColumnFormatMap","columnFormattingRules","Map","reduce","map","next","dataType","getNormalizedType","columnType","has","set","formatMap","get","columnName","format","makeColumnFormattingRule","constructor","dateTimeOptions","decimalFormatOptions","integerFormatOptions","defaultColumnFormatter","typeFormatterMap","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","columnFormatMap","getColumnFormatMapForType","createIfNecessary","getColumnFormat","getColumnTypeFormatter","getFormattedString","value","formatOverride","formatter","timeZone","dhTimeZone","id"],"mappings":"OAAOA,U;SAELC,sB,EACAC,mB,EACAC,uB,EACAC,sB,EACAC,sB,EACAC,sB;;AAGF,MAAMC,SAAN,CAAgB;AACd;AACF;AACA;AACA;AACA;AAC4B,SAAnBC,mBAAmB,CAACC,qBAAD,EAAwB;AAChD,QAAIA,qBAAqB,IAAI,IAA7B,EAAmC;AACjC,aAAO,IAAIC,GAAJ,EAAP;AACD;;AACD,WAAOD,qBAAqB,CAACE,MAAtB,CAA6B,CAACC,GAAD,EAAMC,IAAN,KAAe;AACjD,UAAMC,QAAQ,GAAGd,UAAU,CAACe,iBAAX,CAA6BF,IAAI,CAACG,UAAlC,CAAjB;;AACA,UAAI,CAACJ,GAAG,CAACK,GAAJ,CAAQH,QAAR,CAAL,EAAwB;AACtBF,QAAAA,GAAG,CAACM,GAAJ,CAAQJ,QAAR,EAAkB,IAAIJ,GAAJ,EAAlB;AACD;;AACD,UAAMS,SAAS,GAAG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ADAqB,cACA,uEADiB,IACjB;;AACA,QAAID,KAAK,IAAI,IAAb,EAAmB;AACjB,aAAO,EAAP;AACD;;AAED,QAAME,SAAS,GAAG,KAAKJ,sBAAL,CAA4BvB,UAA5B,CAAlB;AACA,QAAMM,MAAM,GACVoB,cAAc,IAAI,KAAKJ,eAAL,CAAqBtB,UAArB,EAAiCK,UAAjC,CADpB;AAGA,WAAOsB,SAAS,CAACrB,MAAV,CAAiBmB,KAAjB,EAAwBnB,MAAxB,CAAP;AACD;AAED;AACF;AACA;AACA;;;AACc,MAARsB,QAAQ,GAAG;AAAA;;AACb,oCAAO,KAAKf,gBAAL,CAAsBT,GAAtB,CAA0BpB,UAAU,CAACc,QAAX,CAAoBkB,QAA9C,CAAP,oFAAO,sBAAyDa,UAAhE,2DAAO,uBACHC,EADJ;AAED;;AA/Ia;;AAkJhB,eAAevC,SAAf","sourcesContent":["import TableUtils from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n} from './formatters';\n\nclass Formatter {\n /**\n * Converts [{columnType, columnName, format}] to Map { dataType, Map { columnName, format }}\n * @param {Array} columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(columnFormattingRules) {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (!map.has(dataType)) {\n map.set(dataType, new Map());\n }\n const formatMap = map.get(dataType);\n formatMap.set(next.columnName, next.format);\n return map;\n }, new Map());\n }\n\n /**\n * Creates a column formatting rule\n * @param {String} columnType Normalized data type\n * @param {String} columnName Column name\n * @param {String} format Format string\n */\n static makeColumnFormattingRule(columnType, columnName, format) {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param {Array} columnFormattingRules Optional array of column formatting rules\n * @param {DateTimeColumnFormatterOptions} dateTimeOptions Optional object with DateTime configuration\n * @param {DecimalColumnFormatterOptions} decimalFormatOptions Optional object with Decimal format configuration\n * @param {IntegerColumnFormatterOptions} integerFormatOptions Optional object with Integer format configuration\n */\n constructor(\n columnFormattingRules = [],\n dateTimeOptions = {},\n decimalFormatOptions = {},\n integerFormatOptions = {}\n ) {\n // Formatting order:\n // - columnFormatMap[type][name]\n // - typeFormatterMap[type]\n // - defaultColumnFormatter\n\n this.defaultColumnFormatter = new DefaultColumnFormatter();\n\n // Default formatters by data type\n this.typeFormatterMap = new Map([\n [TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()],\n [TableUtils.dataType.CHAR, new CharColumnFormatter()],\n [\n TableUtils.dataType.DATETIME,\n new DateTimeColumnFormatter(dateTimeOptions),\n ],\n [\n TableUtils.dataType.DECIMAL,\n new DecimalColumnFormatter(decimalFormatOptions),\n ],\n [\n TableUtils.dataType.INT,\n new IntegerColumnFormatter(integerFormatOptions),\n ],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n }\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param {String} columnType column type\n * @param {Boolean} createIfNecessary create new entry if true\n * @returns Map of format strings indexed by column name or undefined if it doesn't exist\n */\n getColumnFormatMapForType(columnType, createIfNecessary = false) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (createIfNecessary && !this.columnFormatMap.has(dataType)) {\n this.columnFormatMap.set(dataType, new Map());\n }\n return this.columnFormatMap.get(dataType);\n }\n\n /**\n * Gets a column format object for a given column type and name\n * @param {String} columnType column type\n * @param {String} columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(columnType, columnName) {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n if (columnFormatMap && columnFormatMap.has(columnName)) {\n return columnFormatMap.get(columnName);\n }\n return null;\n }\n\n getColumnTypeFormatter(columnType) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType && this.typeFormatterMap.has(dataType)) {\n return this.typeFormatterMap.get(dataType);\n }\n return this.defaultColumnFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param {Any} value Value to format\n * @param {String} columnType Column type used to determine the formatting settings\n * @param {String} columnName Column name used to determine the formatting settings\n * @param {String} formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value,\n columnType,\n columnName = '',\n formatOverride = null\n ) {\n if (value == null) {\n return '';\n }\n\n const formatter = this.getColumnTypeFormatter(columnType);\n const format =\n formatOverride || this.getColumnFormat(columnType, columnName);\n\n return formatter.format(value, format);\n }\n\n /**\n * Gets the timeZone name\n * @returns {string} The time zone name E.g. America/New_York\n */\n get timeZone() {\n return this.typeFormatterMap.get(TableUtils.dataType.DATETIME)?.dhTimeZone\n ?.id;\n }\n}\n\nexport default Formatter;\n"],"file":"Formatter.js"}
@@ -80,6 +80,8 @@ export class IrisGrid extends React.Component<any, any, any> {
80
80
  pending: Pending;
81
81
  globalColumnFormats: any[];
82
82
  dateTimeFormatterOptions: {};
83
+ decimalFormatOptions: {};
84
+ integerFormatOptions: {};
83
85
  loadingScrimStartTime: number | null;
84
86
  loadingScrimFinishTime: number | null;
85
87
  loadingTimer: NodeJS.Timeout | null;
@@ -467,6 +469,12 @@ export namespace IrisGrid {
467
469
  const showTimeZone: boolean;
468
470
  const showTSeparator: boolean;
469
471
  const formatter: never[];
472
+ const decimalFormatOptions: PropTypes.Requireable<PropTypes.InferProps<{
473
+ defaultFormatString: PropTypes.Requireable<string>;
474
+ }>>;
475
+ const integerFormatOptions: PropTypes.Requireable<PropTypes.InferProps<{
476
+ defaultFormatString: PropTypes.Requireable<string>;
477
+ }>>;
470
478
  }
471
479
  export { settings_1 as settings };
472
480
  const canCopy_1: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"IrisGrid.d.ts","sourceRoot":"","sources":["../src/IrisGrid.jsx"],"names":[],"mappings":"AAiHA;IACE,2BAA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CC;IAED,gCAYC;IAED;;;OAGG;IACH,gCAGC;IAED;;OAEG;IACH,kDAcC;IAqhBD;;;OAGG;IACH,qBAFW,SAAS,EAAE,QASrB;IAED,6BAYC;IAED,gDAUC;IAED,wBASC;CAkxBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoHgB,wCAAQ;;QACL,2CAAQ;;QACV,yCAAQ;;QACf,kCAAQ;;QACF,wCAAQ;;QACJ,4CAAQ;;QACD,mDAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;QAYd,6CAAQ;;;;;;;;;;;;;;;;;;;;;;;;QAYb,2CAAQ"}
package/dist/IrisGrid.js CHANGED
@@ -341,7 +341,9 @@ export class IrisGrid extends Component {
341
341
  this.tooltip = null;
342
342
  this.pending = new Pending();
343
343
  this.globalColumnFormats = [];
344
- this.dateTimeFormatterOptions = {}; // When the loading scrim started/when it should extend to the end of the screen.
344
+ this.dateTimeFormatterOptions = {};
345
+ this.decimalFormatOptions = {};
346
+ this.integerFormatOptions = {}; // When the loading scrim started/when it should extend to the end of the screen.
345
347
 
346
348
  this.loadingScrimStartTime = null;
347
349
  this.loadingScrimFinishTime = null;
@@ -962,12 +964,20 @@ export class IrisGrid extends Component {
962
964
  var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
963
965
  var globalColumnFormats = FormatterUtils.getColumnFormats(settings);
964
966
  var dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(settings);
967
+ var {
968
+ defaultDecimalFormatOptions = {},
969
+ defaultIntegerFormatOptions = {}
970
+ } = settings;
965
971
  var isColumnFormatChanged = !deepEqual(this.globalColumnFormats, globalColumnFormats);
966
972
  var isDateFormattingChanged = !deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions);
973
+ var isDecimalFormattingChanged = !deepEqual(this.decimalFormatOptions, defaultDecimalFormatOptions);
974
+ var isIntegerFormattingChanged = !deepEqual(this.integerFormatOptions, defaultIntegerFormatOptions);
967
975
 
968
- if (isColumnFormatChanged || isDateFormattingChanged) {
976
+ if (isColumnFormatChanged || isDateFormattingChanged || isDecimalFormattingChanged || isIntegerFormattingChanged) {
969
977
  this.globalColumnFormats = globalColumnFormats;
970
978
  this.dateTimeFormatterOptions = dateTimeFormatterOptions;
979
+ this.decimalFormatOptions = defaultDecimalFormatOptions;
980
+ this.integerFormatOptions = defaultIntegerFormatOptions;
971
981
  this.updateFormatter({}, forceUpdate);
972
982
 
973
983
  if (isDateFormattingChanged && forceUpdate) {
@@ -987,7 +997,7 @@ export class IrisGrid extends Component {
987
997
  }, updatedFormats);
988
998
 
989
999
  var mergedColumnFormats = [...this.globalColumnFormats, ...update.customColumnFormatMap.values()];
990
- var formatter = new Formatter(mergedColumnFormats, this.dateTimeFormatterOptions);
1000
+ var formatter = new Formatter(mergedColumnFormats, this.dateTimeFormatterOptions, this.decimalFormatOptions, this.integerFormatOptions);
991
1001
  log.debug('updateFormatter', this.globalColumnFormats, mergedColumnFormats);
992
1002
  this.setState(_objectSpread(_objectSpread({}, update), {}, {
993
1003
  formatter
@@ -3193,7 +3203,13 @@ IrisGrid.defaultProps = {
3193
3203
  defaultDateTimeFormat: DateUtils.FULL_DATE_FORMAT,
3194
3204
  showTimeZone: false,
3195
3205
  showTSeparator: true,
3196
- formatter: []
3206
+ formatter: [],
3207
+ decimalFormatOptions: PropTypes.shape({
3208
+ defaultFormatString: PropTypes.string
3209
+ }),
3210
+ integerFormatOptions: PropTypes.shape({
3211
+ defaultFormatString: PropTypes.string
3212
+ })
3197
3213
  },
3198
3214
  canCopy: true,
3199
3215
  canDownloadCsv: true,