@deephaven/iris-grid 0.8.2-beta.1 → 0.9.1-beta.0
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/AdvancedFilterCreator.d.ts +2 -2
- package/dist/AdvancedFilterCreator.d.ts.map +1 -1
- package/dist/AdvancedFilterCreatorFilterItem.d.ts +30 -31
- package/dist/AdvancedFilterCreatorFilterItem.d.ts.map +1 -1
- package/dist/AdvancedFilterCreatorFilterItem.js +21 -28
- package/dist/AdvancedFilterCreatorFilterItem.js.map +1 -1
- package/dist/CrossColumnSearch.d.ts +1 -1
- package/dist/CrossColumnSearch.d.ts.map +1 -1
- package/dist/DateUtils.d.ts +46 -44
- package/dist/DateUtils.d.ts.map +1 -1
- package/dist/DateUtils.js +37 -32
- package/dist/DateUtils.js.map +1 -1
- package/dist/Formatter.d.ts +37 -42
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +58 -38
- package/dist/Formatter.js.map +1 -1
- package/dist/FormatterUtils.d.ts +12 -8
- package/dist/FormatterUtils.d.ts.map +1 -1
- package/dist/FormatterUtils.js.map +1 -1
- package/dist/IrisGrid.d.ts +12 -4
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +20 -4
- package/dist/IrisGrid.js.map +1 -1
- package/dist/IrisGridMetricCalculator.d.ts +16 -2
- package/dist/IrisGridMetricCalculator.d.ts.map +1 -1
- package/dist/IrisGridMetricCalculator.js +4 -3
- package/dist/IrisGridMetricCalculator.js.map +1 -1
- package/dist/IrisGridTheme.d.ts +5 -75
- package/dist/IrisGridTheme.d.ts.map +1 -1
- package/dist/IrisGridTheme.js +2 -1
- package/dist/IrisGridTheme.js.map +1 -1
- package/dist/IrisGridUtils.d.ts +4 -4
- package/dist/IrisGridUtils.d.ts.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/TableUtils.d.ts +127 -114
- package/dist/TableUtils.d.ts.map +1 -1
- package/dist/TableUtils.js +76 -69
- package/dist/TableUtils.js.map +1 -1
- package/dist/declaration.d.js +2 -0
- package/dist/declaration.d.js.map +1 -0
- package/dist/filters/FilterOperator.d.ts +5 -5
- package/dist/filters/FilterOperator.d.ts.map +1 -1
- package/dist/filters/FilterOperator.js +1 -3
- package/dist/filters/FilterOperator.js.map +1 -1
- package/dist/filters/FilterType.d.ts +23 -23
- package/dist/filters/FilterType.d.ts.map +1 -1
- package/dist/filters/FilterType.js +1 -3
- package/dist/filters/FilterType.js.map +1 -1
- package/dist/filters/index.d.ts +2 -2
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/filters/index.js +2 -2
- package/dist/filters/index.js.map +1 -1
- package/dist/format-context-menus/CustomFormatAction.d.ts +27 -39
- package/dist/format-context-menus/CustomFormatAction.d.ts.map +1 -1
- package/dist/format-context-menus/CustomFormatAction.js +24 -23
- package/dist/format-context-menus/CustomFormatAction.js.map +1 -1
- package/dist/format-context-menus/DateTimeFormatContextMenu.d.ts +8 -5
- package/dist/format-context-menus/DateTimeFormatContextMenu.d.ts.map +1 -1
- package/dist/format-context-menus/DateTimeFormatContextMenu.js +3 -3
- package/dist/format-context-menus/DateTimeFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/DecimalFormatContextMenu.d.ts +7 -5
- package/dist/format-context-menus/DecimalFormatContextMenu.d.ts.map +1 -1
- package/dist/format-context-menus/DecimalFormatContextMenu.js +3 -3
- package/dist/format-context-menus/DecimalFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/FormatContextMenuUtils.d.ts +28 -27
- package/dist/format-context-menus/FormatContextMenuUtils.d.ts.map +1 -1
- package/dist/format-context-menus/FormatContextMenuUtils.js +12 -10
- package/dist/format-context-menus/FormatContextMenuUtils.js.map +1 -1
- package/dist/format-context-menus/IntegerFormatContextMenu.d.ts +7 -5
- package/dist/format-context-menus/IntegerFormatContextMenu.d.ts.map +1 -1
- package/dist/format-context-menus/IntegerFormatContextMenu.js +3 -3
- package/dist/format-context-menus/IntegerFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/index.d.ts +3 -3
- package/dist/format-context-menus/index.d.ts.map +1 -1
- package/dist/format-context-menus/index.js.map +1 -1
- package/dist/formatters/BooleanColumnFormatter.d.ts +4 -4
- package/dist/formatters/BooleanColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/BooleanColumnFormatter.js.map +1 -1
- package/dist/formatters/CharColumnFormatter.d.ts +4 -4
- package/dist/formatters/CharColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/CharColumnFormatter.js.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.d.ts +13 -11
- 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/DefaultColumnFormatter.d.ts +4 -4
- package/dist/formatters/DefaultColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DefaultColumnFormatter.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 +8 -7
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +4 -3
- package/dist/formatters/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/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/mousehandlers/IrisGridContextMenuHandler.d.ts +14 -5
- package/dist/mousehandlers/IrisGridContextMenuHandler.d.ts.map +1 -1
- package/dist/sidebar/ChartBuilder.d.ts +1 -1
- package/dist/sidebar/ChartBuilder.d.ts.map +1 -1
- package/dist/sidebar/TableCsvExporter.d.ts +1 -1
- package/dist/sidebar/TableCsvExporter.d.ts.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.d.ts +2 -4
- package/dist/sidebar/aggregations/AggregationEdit.d.ts.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationUtils.d.ts +1 -4
- package/dist/sidebar/aggregations/AggregationUtils.d.ts.map +1 -1
- package/dist/sidebar/aggregations/AggregationUtils.js.map +1 -1
- package/package.json +11 -11
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/DateUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/DateUtils.js"],"names":["dh","DateUtils","makeDateWrapper","timeZone","year","month","day","hour","minute","second","ns","yearString","padStart","monthString","dayString","hourString","minuteString","secondString","nanoString","dateString","i18n","DateTimeFormat","parse","FULL_DATE_FORMAT","TimeZone","getTimeZone","getNextNanos","sigNanos","parseInt","zeros","repeat","length","nextNanoString","getNextDate","components","values","date","hours","minutes","seconds","nanos","jsDate","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","parseMonth","Number","isNaN","NaN","cleanMonthString","trim","toLowerCase","i","months","startsWith","parseDateValues","padEnd","parseDateTimeString","dateTimeString","regex","result","exec","Error","overflow","parseDateRange","text","cleanText","now","startDate","endDate","DateWrapper","ofJsDate","getJsDate","dateWrapper","asDate"],"mappings":";;AAAA,OAAOA,EAAP,MAAe,uBA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UAAtB,EAAkCC,MAAlC,EAA0ChC,QAA1C,CAAhB;AACA,WAAO,CAACqE,SAAD,EAAYC,OAAZ,CAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACkB,SAATG,SAAS,CAACC,WAAD,EAAc;AAC5B,QAAIA,WAAW,CAACC,MAAhB,EAAwB;AACtB,aAAOD,WAAW,CAACC,MAAZ,EAAP;AACD;;AACD,WAAO,IAAIpC,IAAJ,CAASmC,WAAT,CAAP;AACD;;AAzUa;;gBAAV5E,S,sBACsB,+B;;gBADtBA,S,YAGY,CACd,SADc,EAEd,UAFc,EAGd,OAHc,EAId,OAJc,EAKd,KALc,EAMd,MANc,EAOd,MAPc,EAQd,QARc,EASd,WATc,EAUd,SAVc,EAWd,UAXc,EAYd,UAZc,C;;AAyUlB,eAAeA,SAAf","sourcesContent":["import dh from '@deephaven/jsapi-shim';\n\nclass DateUtils {\n static FULL_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS';\n\n static months = [\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ];\n\n /**\n *\n * @param {string} timeZone The time zone to parse this time in. E.g. America/New_York\n * @param {Number} year The year for the date\n * @param {Number} month The month, starting at 0\n * @param {Number} day The day, starting at 1\n * @param {Number} hour The hours\n * @param {Number} minute The minutes\n * @param {Number} second The seconds\n * @param {Number} ns The nanoseconds\n */\n static makeDateWrapper(\n timeZone,\n year,\n month = 0,\n day = 1,\n hour = 0,\n minute = 0,\n second = 0,\n ns = 0\n ) {\n const yearString = `${year}`.padStart(4, '0');\n const monthString = `${month + 1}`.padStart(2, '0');\n const dayString = `${day}`.padStart(2, '0');\n const hourString = `${hour}`.padStart(2, '0');\n const minuteString = `${minute}`.padStart(2, '0');\n const secondString = `${second}`.padStart(2, '0');\n const nanoString = `${ns}`.padStart(9, '0');\n\n const dateString = `${yearString}-${monthString}-${dayString} ${hourString}:${minuteString}:${secondString}.${nanoString}`;\n return dh.i18n.DateTimeFormat.parse(\n DateUtils.FULL_DATE_FORMAT,\n dateString,\n dh.i18n.TimeZone.getTimeZone(timeZone)\n );\n }\n\n /**\n * Takes the string the user entered and returns the next nanos value\n * @param {String} nanoString The nano string to get the next one of\n * @returns {Number} The value of the next nanos\n */\n static getNextNanos(nanoString) {\n const sigNanos = parseInt(nanoString, 10);\n // Get the zeroes needed for padding before adding one so we handle overflow properly.\n const zeros = '0'.repeat(9 - nanoString.length);\n const nextNanoString = `${sigNanos + 1}${zeros}`;\n return parseInt(nextNanoString, 10);\n }\n\n /**\n * @param {Object} components The string components that were parsed from the original string\n * @param {Object} values The values that were parsed from the components\n * @param {string} timeZone The time zone to parse the date in. E.g. America/New_York\n * @returns {dh.DateWrapper} Returns the DateWrapper for the next date, or null if a full date was passed in\n */\n static getNextDate(components, values, timeZone) {\n let { year, month, date, hours, minutes, seconds, nanos } = values;\n\n if (components.nanos != null) {\n if (components.nanos.length === 9) {\n // They want an exact match\n return null;\n }\n nanos = DateUtils.getNextNanos(components.nanos);\n if (nanos > 999999999) {\n // There's an overflow, add it to the seconds manually\n seconds += 1;\n nanos = 0;\n }\n } else if (components.seconds != null) {\n seconds += 1;\n } else if (components.minutes != null) {\n minutes += 1;\n } else if (components.hours != null) {\n hours += 1;\n } else if (components.date != null) {\n date += 1;\n } else if (components.month != null) {\n month += 1;\n } else {\n year += 1;\n }\n\n // Use the JS date to handle overflow rather than doing our own logic\n // Because handling leap years and stuff is a pain\n // Still need to add nanos after, and the overflow from that is already added to seconds above\n const jsDate = new Date(year, month, date, hours, minutes, seconds);\n return DateUtils.makeDateWrapper(\n timeZone,\n jsDate.getFullYear(),\n jsDate.getMonth(),\n jsDate.getDate(),\n jsDate.getHours(),\n jsDate.getMinutes(),\n jsDate.getSeconds(),\n nanos\n );\n }\n\n /**\n * Get the JS month value for the provided string.\n * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)\n * @param {string} monthString The string to parse to a JS month value\n * @returns number THe JS month value, which starts at 0 for january, or null if nothing could be parsed\n */\n static parseMonth(monthString) {\n const month = parseInt(monthString, 10);\n if (!Number.isNaN(month)) {\n if (month >= 1 && month <= 12) {\n return month - 1;\n }\n return NaN;\n }\n\n const cleanMonthString = monthString.trim().toLowerCase();\n if (cleanMonthString.length >= 3) {\n for (let i = 0; i < DateUtils.months.length; i += 1) {\n if (DateUtils.months[i].startsWith(cleanMonthString)) {\n return i;\n }\n }\n }\n\n return NaN;\n }\n\n /**\n * Parse a date object out of the provided string segments.\n * Also using `parseMonth` to get month names like Aug/August rather than\n * simply doing `parseInt`.\n * @param {string} yearString The year part of the string\n * @param {string} monthString The month part of the string\n * @param {string} dayString The day part of the string\n * @param {string} hourString The hour part of the string\n * @param {string} minuteString The minute part of the string\n * @param {string} secondString The second part of the string\n * @param {string} nanoString The milli part of the string\n */\n static parseDateValues(\n yearString,\n monthString,\n dayString,\n hourString,\n minuteString,\n secondString,\n nanoString\n ) {\n const year = parseInt(yearString, 10);\n const month = monthString != null ? this.parseMonth(monthString) : 0;\n const date = dayString != null ? parseInt(dayString, 10) : 1;\n const hours = hourString != null ? parseInt(hourString, 10) : 0;\n const minutes = minuteString != null ? parseInt(minuteString, 10) : 0;\n const seconds = secondString != null ? parseInt(secondString, 10) : 0;\n const nanos =\n nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;\n if (\n Number.isNaN(year) ||\n Number.isNaN(month) ||\n Number.isNaN(date) ||\n Number.isNaN(hours) ||\n Number.isNaN(minutes) ||\n Number.isNaN(seconds) ||\n Number.isNaN(nanos)\n ) {\n return null;\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parse out a date time string into it's string components.\n * Anything that is not captured in the string will be undefined.\n *\n * @param {string} dateTimeString The date time string to parse\n * @returns {object} Containing the date time components\n */\n static parseDateTimeString(dateTimeString) {\n const regex = /\\s*(\\d{4})([-./]([\\da-z]+))?([-./](\\d{1,2}))?([tT\\s](\\d{2})([:](\\d{2}))?([:](\\d{2}))?([.](\\d{1,9}))?)?(.*)/;\n const result = regex.exec(dateTimeString);\n if (result == null) {\n throw new Error(`Unexpected date string: ${dateTimeString}`);\n }\n\n const [\n ,\n year,\n ,\n month,\n ,\n date,\n ,\n hours,\n ,\n minutes,\n ,\n seconds,\n ,\n nanos,\n overflow,\n ] = result;\n if (overflow != null && overflow.length > 0) {\n throw new Error(\n `Unexpected characters after date string '${dateTimeString}': ${overflow}`\n );\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parses the date range provided from a string of text.\n * @param {string} text The string to parse the date from. Can be a keyword like \"today\", or in the format \"2018-08-04\"\n * @param {string} timeZone The time zone to parse this range in. E.g. America/New_York\n * @returns {[DateWrapper, DateWrapper]} A tuple with the start/end values for that date range\n */\n static parseDateRange(text, timeZone) {\n const cleanText = text.trim().toLowerCase();\n if (cleanText.length === 0) {\n throw new Error('Cannot parse date range from empty string');\n }\n\n if (cleanText === 'null') {\n return [null, null];\n }\n\n if (cleanText === 'today') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() + 1\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'yesterday') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() - 1\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'now') {\n const now = new Date(Date.now());\n const date = dh.DateWrapper.ofJsDate(now);\n return [date, null];\n }\n\n const components = DateUtils.parseDateTimeString(cleanText);\n if (\n components.year == null &&\n components.month == null &&\n components.date == null\n ) {\n throw new Error(`Unable to extract year, month, or day ${cleanText}`);\n }\n\n const values = DateUtils.parseDateValues(\n components.year,\n components.month,\n components.date,\n components.hours,\n components.minutes,\n components.seconds,\n components.nanos\n );\n\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n values.year,\n values.month,\n values.date,\n values.hours,\n values.minutes,\n values.seconds,\n values.nanos\n );\n\n const endDate = DateUtils.getNextDate(components, values, timeZone);\n return [startDate, endDate];\n }\n\n /**\n * Gets the Js Date object from the provided DateWrapper.\n * In unit test, DateWrapper is just a number provided in millis, so handles that case.\n * @param {DateWrapper|number} dateWrapper The DateWrapper object, or time in millis\n */\n static getJsDate(dateWrapper) {\n if (dateWrapper.asDate) {\n return dateWrapper.asDate();\n }\n return new Date(dateWrapper);\n }\n}\n\nexport default DateUtils;\n"],"file":"DateUtils.js"}
|
|
1
|
+
{"version":3,"sources":["../src/DateUtils.ts"],"names":["dh","DateUtils","makeDateWrapper","timeZone","year","month","day","hour","minute","second","ns","yearString","padStart","monthString","dayString","hourString","minuteString","secondString","nanoString","dateString","i18n","DateTimeFormat","parse","FULL_DATE_FORMAT","TimeZone","getTimeZone","getNextNanos","sigNanos","parseInt","zeros","repeat","length","nextNanoString","getNextDate","components","values","date","hours","minutes","seconds","nanos","jsDate","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","parseMonth","Number","isNaN","NaN","cleanMonthString","trim","toLowerCase","i","months","startsWith","parseDateValues","padEnd","parseDateTimeString","dateTimeString","regex","result","exec","Error","overflow","parseDateRange","text","cleanText","now","startDate","endDate","DateWrapper","ofJsDate","getJsDate","dateWrapper","asDate"],"mappings":";;AAAA,OAAOA,EAAP,MAAe,uBAAf;;AAaA,MAAMC,SAAN,CAAgB;AAkBd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACwB,SAAfC,eAAe,CACpBC,QADoB,EAEpBC,IAFoB,EASP;AAAA,QANbC,KAMa,uEANL,CAMK;AAAA,QALbC,GAKa,uEALP,CAKO;AAAA,QAJbC,IAIa,uEAJN,CA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;AACkB,SAATG,SAAS,CAACC,WAAD,EAA0C;AACxD,QAAI,OAAOA,WAAP,KAAuB,QAA3B,EAAqC;AACnC,aAAO,IAAInC,IAAJ,CAASmC,WAAT,CAAP;AACD;;AACD,WAAOA,WAAW,CAACC,MAAZ,EAAP;AACD;;AApVa;;gBAAV7E,S,sBACsB,+B;;gBADtBA,S,YAGY,CACd,SADc,EAEd,UAFc,EAGd,OAHc,EAId,OAJc,EAKd,KALc,EAMd,MANc,EAOd,MAPc,EAQd,QARc,EASd,WATc,EAUd,SAVc,EAWd,UAXc,EAYd,UAZc,C;;AAoVlB,eAAeA,SAAf","sourcesContent":["import dh from '@deephaven/jsapi-shim';\nimport type { DateWrapper } from '@deephaven/jsapi-shim';\n\ninterface DateParts<T> {\n year: T;\n month: T;\n date: T;\n hours: T;\n minutes: T;\n seconds: T;\n nanos: T;\n}\n\nclass DateUtils {\n static FULL_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS';\n\n static months = [\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ];\n\n /**\n *\n * @param timeZone The time zone to parse this time in. E.g. America/New_York\n * @param year The year for the date\n * @param month The month, starting at 0\n * @param day The day, starting at 1\n * @param hour The hours\n * @param minute The minutes\n * @param second The seconds\n * @param ns The nanoseconds\n */\n static makeDateWrapper(\n timeZone: string,\n year: number,\n month = 0,\n day = 1,\n hour = 0,\n minute = 0,\n second = 0,\n ns = 0\n ): DateWrapper {\n const yearString = `${year}`.padStart(4, '0');\n const monthString = `${month + 1}`.padStart(2, '0');\n const dayString = `${day}`.padStart(2, '0');\n const hourString = `${hour}`.padStart(2, '0');\n const minuteString = `${minute}`.padStart(2, '0');\n const secondString = `${second}`.padStart(2, '0');\n const nanoString = `${ns}`.padStart(9, '0');\n\n const dateString = `${yearString}-${monthString}-${dayString} ${hourString}:${minuteString}:${secondString}.${nanoString}`;\n return dh.i18n.DateTimeFormat.parse(\n DateUtils.FULL_DATE_FORMAT,\n dateString,\n dh.i18n.TimeZone.getTimeZone(timeZone)\n );\n }\n\n /**\n * Takes the string the user entered and returns the next nanos value\n * @param nanoString The nano string to get the next one of\n * @returns The value of the next nanos\n */\n static getNextNanos(nanoString: string): number {\n const sigNanos = parseInt(nanoString, 10);\n // Get the zeroes needed for padding before adding one so we handle overflow properly.\n const zeros = '0'.repeat(9 - nanoString.length);\n const nextNanoString = `${sigNanos + 1}${zeros}`;\n return parseInt(nextNanoString, 10);\n }\n\n /**\n * @param components The string components that were parsed from the original string\n * @param values The values that were parsed from the components\n * @param timeZone The time zone to parse the date in. E.g. America/New_York\n * @returns Returns the DateWrapper for the next date, or null if a full date was passed in\n */\n static getNextDate(\n components: DateParts<string>,\n values: DateParts<number>,\n timeZone: string\n ): DateWrapper | null {\n let { year, month, date, hours, minutes, seconds, nanos } = values;\n\n if (components.nanos != null) {\n if (components.nanos.length === 9) {\n // They want an exact match\n return null;\n }\n nanos = DateUtils.getNextNanos(components.nanos);\n if (nanos > 999999999) {\n // There's an overflow, add it to the seconds manually\n seconds += 1;\n nanos = 0;\n }\n } else if (components.seconds != null) {\n seconds += 1;\n } else if (components.minutes != null) {\n minutes += 1;\n } else if (components.hours != null) {\n hours += 1;\n } else if (components.date != null) {\n date += 1;\n } else if (components.month != null) {\n month += 1;\n } else {\n year += 1;\n }\n\n // Use the JS date to handle overflow rather than doing our own logic\n // Because handling leap years and stuff is a pain\n // Still need to add nanos after, and the overflow from that is already added to seconds above\n const jsDate = new Date(year, month, date, hours, minutes, seconds);\n return DateUtils.makeDateWrapper(\n timeZone,\n jsDate.getFullYear(),\n jsDate.getMonth(),\n jsDate.getDate(),\n jsDate.getHours(),\n jsDate.getMinutes(),\n jsDate.getSeconds(),\n nanos\n );\n }\n\n /**\n * Get the JS month value for the provided string.\n * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)\n * @param monthString The string to parse to a JS month value\n * @returns number The JS month value, which starts at 0 for january, or NaN if nothing could be parsed\n */\n static parseMonth(monthString: string): number {\n const month = parseInt(monthString, 10);\n if (!Number.isNaN(month)) {\n if (month >= 1 && month <= 12) {\n return month - 1;\n }\n return NaN;\n }\n\n const cleanMonthString = monthString.trim().toLowerCase();\n if (cleanMonthString.length >= 3) {\n for (let i = 0; i < DateUtils.months.length; i += 1) {\n if (DateUtils.months[i].startsWith(cleanMonthString)) {\n return i;\n }\n }\n }\n\n return NaN;\n }\n\n /**\n * Parse a date object out of the provided string segments.\n * Also using `parseMonth` to get month names like Aug/August rather than\n * simply doing `parseInt`.\n * @param yearString The year part of the string\n * @param monthString The month part of the string\n * @param dayString The day part of the string\n * @param hourString The hour part of the string\n * @param minuteString The minute part of the string\n * @param secondString The second part of the string\n * @param nanoString The milli part of the string\n */\n static parseDateValues(\n yearString: string,\n monthString: string,\n dayString: string,\n hourString: string,\n minuteString: string,\n secondString: string,\n nanoString: string\n ): DateParts<number> | null {\n const year = parseInt(yearString, 10);\n const month = monthString != null ? this.parseMonth(monthString) : 0;\n const date = dayString != null ? parseInt(dayString, 10) : 1;\n const hours = hourString != null ? parseInt(hourString, 10) : 0;\n const minutes = minuteString != null ? parseInt(minuteString, 10) : 0;\n const seconds = secondString != null ? parseInt(secondString, 10) : 0;\n const nanos =\n nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;\n if (\n Number.isNaN(year) ||\n Number.isNaN(month) ||\n Number.isNaN(date) ||\n Number.isNaN(hours) ||\n Number.isNaN(minutes) ||\n Number.isNaN(seconds) ||\n Number.isNaN(nanos)\n ) {\n return null;\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parse out a date time string into it's string components.\n * Anything that is not captured in the string will be undefined.\n *\n * @param dateTimeString The date time string to parse\n * @returns Containing the date time components\n */\n static parseDateTimeString(dateTimeString: string): DateParts<string> {\n const regex = /\\s*(\\d{4})([-./]([\\da-z]+))?([-./](\\d{1,2}))?([tT\\s](\\d{2})([:](\\d{2}))?([:](\\d{2}))?([.](\\d{1,9}))?)?(.*)/;\n const result = regex.exec(dateTimeString);\n if (result == null) {\n throw new Error(`Unexpected date string: ${dateTimeString}`);\n }\n\n const [\n ,\n year,\n ,\n month,\n ,\n date,\n ,\n hours,\n ,\n minutes,\n ,\n seconds,\n ,\n nanos,\n overflow,\n ] = result;\n if (overflow != null && overflow.length > 0) {\n throw new Error(\n `Unexpected characters after date string '${dateTimeString}': ${overflow}`\n );\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parses the date range provided from a string of text.\n * @param text The string to parse the date from. Can be a keyword like \"today\", or in the format \"2018-08-04\"\n * @param timeZone The time zone to parse this range in. E.g. America/New_York\n * @returns A tuple with the start and end value/null for that date range, or both null\n */\n static parseDateRange(\n text: string,\n timeZone: string\n ): [DateWrapper, DateWrapper | null] | [null, null] {\n const cleanText = text.trim().toLowerCase();\n if (cleanText.length === 0) {\n throw new Error('Cannot parse date range from empty string');\n }\n\n if (cleanText === 'null') {\n return [null, null];\n }\n\n if (cleanText === 'today') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() + 1\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'yesterday') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() - 1\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'now') {\n const now = new Date(Date.now());\n const date = dh.DateWrapper.ofJsDate(now);\n return [date, null];\n }\n\n const components = DateUtils.parseDateTimeString(cleanText);\n if (\n components.year == null &&\n components.month == null &&\n components.date == null\n ) {\n throw new Error(`Unable to extract year, month, or day ${cleanText}`);\n }\n\n const values = DateUtils.parseDateValues(\n components.year,\n components.month,\n components.date,\n components.hours,\n components.minutes,\n components.seconds,\n components.nanos\n );\n\n if (values == null) {\n throw new Error(`Unable to extract date values from ${components}`);\n }\n\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n values.year,\n values.month,\n values.date,\n values.hours,\n values.minutes,\n values.seconds,\n values.nanos\n );\n\n const endDate = DateUtils.getNextDate(components, values, timeZone);\n return [startDate, endDate];\n }\n\n /**\n * Gets the Js Date object from the provided DateWrapper.\n * In unit test, DateWrapper is just a number provided in millis, so handles that case.\n * @param dateWrapper The DateWrapper object, or time in millis\n */\n static getJsDate(dateWrapper: DateWrapper | number): Date {\n if (typeof dateWrapper === 'number') {\n return new Date(dateWrapper);\n }\n return dateWrapper.asDate();\n }\n}\n\nexport default DateUtils;\n"],"file":"DateUtils.js"}
|
package/dist/Formatter.d.ts
CHANGED
|
@@ -1,68 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
import { DataType } from './TableUtils';
|
|
2
|
+
import { DateTimeColumnFormatter, DecimalColumnFormatter, IntegerColumnFormatter, TableColumnFormat, TableColumnFormatter } from './formatters';
|
|
3
|
+
declare type ColumnName = string;
|
|
4
|
+
export interface FormattingRule {
|
|
5
|
+
columnType: string;
|
|
6
|
+
columnName: string;
|
|
7
|
+
format: TableColumnFormat;
|
|
8
|
+
}
|
|
2
9
|
declare class Formatter {
|
|
3
10
|
/**
|
|
4
|
-
* Converts [
|
|
5
|
-
* @param
|
|
11
|
+
* Converts FormattingRule[] to Map
|
|
12
|
+
* @param columnFormattingRules Array or column formatting rules
|
|
6
13
|
* @returns Map of columnName-to-format Maps indexed by normalized dataType
|
|
7
14
|
*/
|
|
8
|
-
static makeColumnFormatMap(columnFormattingRules:
|
|
15
|
+
static makeColumnFormatMap(columnFormattingRules: FormattingRule[]): Map<DataType, Map<ColumnName, TableColumnFormat>>;
|
|
9
16
|
/**
|
|
10
17
|
* Creates a column formatting rule
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
18
|
+
* @param columnType Normalized data type
|
|
19
|
+
* @param columnName Column name
|
|
20
|
+
* @param format Format object
|
|
14
21
|
*/
|
|
15
|
-
static makeColumnFormattingRule(columnType:
|
|
16
|
-
columnType: string;
|
|
17
|
-
columnName: string;
|
|
18
|
-
format: string;
|
|
19
|
-
};
|
|
22
|
+
static makeColumnFormattingRule(columnType: DataType, columnName: string, format: TableColumnFormat): FormattingRule;
|
|
20
23
|
/**
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
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
|
|
24
|
+
* @param columnFormattingRules Optional array of column formatting rules
|
|
25
|
+
* @param dateTimeOptions Optional object with DateTime configuration
|
|
26
|
+
* @param decimalFormatOptions Optional object with Decimal configuration
|
|
27
|
+
* @param integerFormatOptions Optional object with Integer configuration
|
|
27
28
|
*/
|
|
28
|
-
constructor(columnFormattingRules?:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
defaultDateTimeFormatString: string;
|
|
33
|
-
});
|
|
34
|
-
defaultColumnFormatter: DefaultColumnFormatter;
|
|
35
|
-
typeFormatterMap: Map<string, DateTimeColumnFormatter>;
|
|
36
|
-
columnFormatMap: any;
|
|
29
|
+
constructor(columnFormattingRules?: FormattingRule[], dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[0], decimalFormatOptions?: ConstructorParameters<typeof DecimalColumnFormatter>[0], integerFormatOptions?: ConstructorParameters<typeof IntegerColumnFormatter>[0]);
|
|
30
|
+
defaultColumnFormatter: TableColumnFormatter;
|
|
31
|
+
typeFormatterMap: Map<DataType, TableColumnFormatter>;
|
|
32
|
+
columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;
|
|
37
33
|
/**
|
|
38
34
|
* Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
35
|
+
* @param columnType column type
|
|
36
|
+
* @param createIfNecessary create new entry if true
|
|
41
37
|
* @returns Map of format strings indexed by column name or undefined if it doesn't exist
|
|
42
38
|
*/
|
|
43
|
-
getColumnFormatMapForType(columnType: string, createIfNecessary?: boolean):
|
|
39
|
+
getColumnFormatMapForType(columnType: string, createIfNecessary?: boolean): Map<string, TableColumnFormat> | undefined;
|
|
44
40
|
/**
|
|
45
41
|
* Gets a column format object for a given column type and name
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
42
|
+
* @param columnType column type
|
|
43
|
+
* @param columnName column name
|
|
48
44
|
* @returns format object or null for Default
|
|
49
45
|
*/
|
|
50
|
-
getColumnFormat(columnType: string, columnName: string):
|
|
51
|
-
getColumnTypeFormatter(columnType:
|
|
46
|
+
getColumnFormat(columnType: string, columnName: string): TableColumnFormat | null;
|
|
47
|
+
getColumnTypeFormatter(columnType: string): TableColumnFormatter;
|
|
52
48
|
/**
|
|
53
49
|
* Gets formatted string for a given value, column type and name
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
50
|
+
* @param value Value to format
|
|
51
|
+
* @param columnType Column type used to determine the formatting settings
|
|
52
|
+
* @param columnName Column name used to determine the formatting settings
|
|
53
|
+
* @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
|
|
58
54
|
*/
|
|
59
|
-
getFormattedString(value:
|
|
55
|
+
getFormattedString(value: unknown, columnType: string, columnName?: string, formatOverride?: TableColumnFormat): string;
|
|
60
56
|
/**
|
|
61
57
|
* Gets the timeZone name
|
|
62
|
-
* @returns
|
|
58
|
+
* @returns The time zone name E.g. America/New_York
|
|
63
59
|
*/
|
|
64
60
|
get timeZone(): string;
|
|
65
61
|
}
|
|
66
|
-
|
|
67
|
-
import { DateTimeColumnFormatter } from "./formatters";
|
|
62
|
+
export default Formatter;
|
|
68
63
|
//# sourceMappingURL=Formatter.d.ts.map
|
package/dist/Formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.
|
|
1
|
+
{"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.ts"],"names":[],"mappings":"AACA,OAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAGL,uBAAuB,EACvB,sBAAsB,EAEtB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAItB,aAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,cAAM,SAAS;IACb;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CACxB,qBAAqB,EAAE,cAAc,EAAE,GACtC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IAmBpD;;;;;OAKG;IACH,MAAM,CAAC,wBAAwB,CAC7B,UAAU,EAAE,QAAQ,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,iBAAiB,GACxB,cAAc;IAQjB;;;;;OAKG;gBAED,qBAAqB,GAAE,cAAc,EAAO,EAC5C,eAAe,CAAC,EAAE,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC,EAC1E,oBAAoB,CAAC,EAAE,qBAAqB,CAC1C,OAAO,sBAAsB,CAC9B,CAAC,CAAC,CAAC,EACJ,oBAAoB,CAAC,EAAE,qBAAqB,CAC1C,OAAO,sBAAsB,CAC9B,CAAC,CAAC,CAAC;IA+BN,sBAAsB,EAAE,oBAAoB,CAAC;IAE7C,gBAAgB,EAAE,GAAG,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEtD,eAAe,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE/D;;;;;OAKG;IACH,yBAAyB,CACvB,UAAU,EAAE,MAAM,EAClB,iBAAiB,UAAQ,GACxB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAa7C;;;;;OAKG;IACH,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,iBAAiB,GAAG,IAAI;IAK3B,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB;IAUhE;;;;;;OAMG;IACH,kBAAkB,CAChB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,SAAK,EACf,cAAc,CAAC,EAAE,iBAAiB,GACjC,MAAM;IAYT;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAKrB;CACF;AAED,eAAe,SAAS,CAAC"}
|
package/dist/Formatter.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { Log } from '@deephaven/log';
|
|
1
4
|
import TableUtils from "./TableUtils.js";
|
|
2
5
|
import { BooleanColumnFormatter, CharColumnFormatter, DateTimeColumnFormatter, DecimalColumnFormatter, DefaultColumnFormatter, IntegerColumnFormatter } from "./formatters/index.js";
|
|
6
|
+
var log = Log.module('Formatter');
|
|
3
7
|
|
|
4
8
|
class Formatter {
|
|
5
9
|
/**
|
|
6
|
-
* Converts [
|
|
7
|
-
* @param
|
|
10
|
+
* Converts FormattingRule[] to Map
|
|
11
|
+
* @param columnFormattingRules Array or column formatting rules
|
|
8
12
|
* @returns Map of columnName-to-format Maps indexed by normalized dataType
|
|
9
13
|
*/
|
|
10
14
|
static makeColumnFormatMap(columnFormattingRules) {
|
|
@@ -15,20 +19,24 @@ class Formatter {
|
|
|
15
19
|
return columnFormattingRules.reduce((map, next) => {
|
|
16
20
|
var dataType = TableUtils.getNormalizedType(next.columnType);
|
|
17
21
|
|
|
22
|
+
if (dataType === null) {
|
|
23
|
+
return map;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
if (!map.has(dataType)) {
|
|
19
27
|
map.set(dataType, new Map());
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
var formatMap = map.get(dataType);
|
|
23
|
-
formatMap.set(next.columnName, next.format);
|
|
31
|
+
formatMap === null || formatMap === void 0 ? void 0 : formatMap.set(next.columnName, next.format);
|
|
24
32
|
return map;
|
|
25
33
|
}, new Map());
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* Creates a column formatting rule
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
37
|
+
* @param columnType Normalized data type
|
|
38
|
+
* @param columnName Column name
|
|
39
|
+
* @param format Format object
|
|
32
40
|
*/
|
|
33
41
|
|
|
34
42
|
|
|
@@ -40,40 +48,51 @@ class Formatter {
|
|
|
40
48
|
};
|
|
41
49
|
}
|
|
42
50
|
/**
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
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
|
|
51
|
+
* @param columnFormattingRules Optional array of column formatting rules
|
|
52
|
+
* @param dateTimeOptions Optional object with DateTime configuration
|
|
53
|
+
* @param decimalFormatOptions Optional object with Decimal configuration
|
|
54
|
+
* @param integerFormatOptions Optional object with Integer configuration
|
|
49
55
|
*/
|
|
50
56
|
|
|
51
57
|
|
|
52
58
|
constructor() {
|
|
53
59
|
var columnFormattingRules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
54
|
-
var dateTimeOptions = arguments.length > 1
|
|
60
|
+
var dateTimeOptions = arguments.length > 1 ? arguments[1] : undefined;
|
|
61
|
+
var decimalFormatOptions = arguments.length > 2 ? arguments[2] : undefined;
|
|
62
|
+
var integerFormatOptions = arguments.length > 3 ? arguments[3] : undefined;
|
|
63
|
+
|
|
64
|
+
_defineProperty(this, "defaultColumnFormatter", void 0);
|
|
65
|
+
|
|
66
|
+
_defineProperty(this, "typeFormatterMap", void 0);
|
|
67
|
+
|
|
68
|
+
_defineProperty(this, "columnFormatMap", void 0);
|
|
69
|
+
|
|
55
70
|
// Formatting order:
|
|
56
71
|
// - columnFormatMap[type][name]
|
|
57
72
|
// - typeFormatterMap[type]
|
|
58
73
|
// - defaultColumnFormatter
|
|
59
74
|
this.defaultColumnFormatter = new DefaultColumnFormatter(); // Default formatters by data type
|
|
60
75
|
|
|
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
|
|
76
|
+
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
77
|
|
|
63
78
|
this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);
|
|
64
79
|
}
|
|
80
|
+
|
|
65
81
|
/**
|
|
66
82
|
* Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
83
|
+
* @param columnType column type
|
|
84
|
+
* @param createIfNecessary create new entry if true
|
|
69
85
|
* @returns Map of format strings indexed by column name or undefined if it doesn't exist
|
|
70
86
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
87
|
getColumnFormatMapForType(columnType) {
|
|
74
88
|
var createIfNecessary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
75
89
|
var dataType = TableUtils.getNormalizedType(columnType);
|
|
76
90
|
|
|
91
|
+
if (dataType === null) {
|
|
92
|
+
log.warn("Unknown columnType ".concat(columnType));
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
77
96
|
if (createIfNecessary && !this.columnFormatMap.has(dataType)) {
|
|
78
97
|
this.columnFormatMap.set(dataType, new Map());
|
|
79
98
|
}
|
|
@@ -82,43 +101,43 @@ class Formatter {
|
|
|
82
101
|
}
|
|
83
102
|
/**
|
|
84
103
|
* Gets a column format object for a given column type and name
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
104
|
+
* @param columnType column type
|
|
105
|
+
* @param columnName column name
|
|
87
106
|
* @returns format object or null for Default
|
|
88
107
|
*/
|
|
89
108
|
|
|
90
109
|
|
|
91
110
|
getColumnFormat(columnType, columnName) {
|
|
92
|
-
var
|
|
111
|
+
var _columnFormatMap$get;
|
|
93
112
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return null;
|
|
113
|
+
var columnFormatMap = this.getColumnFormatMapForType(columnType);
|
|
114
|
+
return (_columnFormatMap$get = columnFormatMap === null || columnFormatMap === void 0 ? void 0 : columnFormatMap.get(columnName)) !== null && _columnFormatMap$get !== void 0 ? _columnFormatMap$get : null;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
117
|
getColumnTypeFormatter(columnType) {
|
|
102
118
|
var dataType = TableUtils.getNormalizedType(columnType);
|
|
119
|
+
var columnTypeFormatter = this.defaultColumnFormatter;
|
|
120
|
+
|
|
121
|
+
if (dataType) {
|
|
122
|
+
var _this$typeFormatterMa;
|
|
103
123
|
|
|
104
|
-
|
|
105
|
-
return this.typeFormatterMap.get(dataType);
|
|
124
|
+
columnTypeFormatter = (_this$typeFormatterMa = this.typeFormatterMap.get(dataType)) !== null && _this$typeFormatterMa !== void 0 ? _this$typeFormatterMa : columnTypeFormatter;
|
|
106
125
|
}
|
|
107
126
|
|
|
108
|
-
return
|
|
127
|
+
return columnTypeFormatter;
|
|
109
128
|
}
|
|
110
129
|
/**
|
|
111
130
|
* Gets formatted string for a given value, column type and name
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
131
|
+
* @param value Value to format
|
|
132
|
+
* @param columnType Column type used to determine the formatting settings
|
|
133
|
+
* @param columnName Column name used to determine the formatting settings
|
|
134
|
+
* @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
|
|
116
135
|
*/
|
|
117
136
|
|
|
118
137
|
|
|
119
138
|
getFormattedString(value, columnType) {
|
|
120
139
|
var columnName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
121
|
-
var formatOverride = arguments.length > 3
|
|
140
|
+
var formatOverride = arguments.length > 3 ? arguments[3] : undefined;
|
|
122
141
|
|
|
123
142
|
if (value == null) {
|
|
124
143
|
return '';
|
|
@@ -126,18 +145,19 @@ class Formatter {
|
|
|
126
145
|
|
|
127
146
|
var formatter = this.getColumnTypeFormatter(columnType);
|
|
128
147
|
var format = formatOverride || this.getColumnFormat(columnType, columnName);
|
|
129
|
-
return formatter.format(value, format);
|
|
148
|
+
return formatter.format(value, format !== null && format !== void 0 ? format : undefined);
|
|
130
149
|
}
|
|
131
150
|
/**
|
|
132
151
|
* Gets the timeZone name
|
|
133
|
-
* @returns
|
|
152
|
+
* @returns The time zone name E.g. America/New_York
|
|
134
153
|
*/
|
|
135
154
|
|
|
136
155
|
|
|
137
156
|
get timeZone() {
|
|
138
|
-
var
|
|
157
|
+
var _formatter$dhTimeZone;
|
|
139
158
|
|
|
140
|
-
|
|
159
|
+
var formatter = this.typeFormatterMap.get(TableUtils.dataType.DATETIME);
|
|
160
|
+
return formatter === null || formatter === void 0 ? void 0 : (_formatter$dhTimeZone = formatter.dhTimeZone) === null || _formatter$dhTimeZone === void 0 ? void 0 : _formatter$dhTimeZone.id;
|
|
141
161
|
}
|
|
142
162
|
|
|
143
163
|
}
|
package/dist/Formatter.js.map
CHANGED
|
@@ -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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AKhB;AAAA,QAFAK,UAEA,uEAFa,EAEb;AAAA,QADAmB,cACA,uEADiB,IACjB;;AACA,QAAID,KAAK,IAAI,IAAb,EAAmB;AACjB,aAAO,EAAP;AACD;;AAED,QAAME,SAAS,GAAG,KAAKJ,sBAAL,CAA4BrB,UAA5B,CAAlB;AACA,QAAMM,MAAM,GACVkB,cAAc,IAAI,KAAKJ,eAAL,CAAqBpB,UAArB,EAAiCK,UAAjC,CADpB;AAGA,WAAOoB,SAAS,CAACnB,MAAV,CAAiBiB,KAAjB,EAAwBjB,MAAxB,CAAP;AACD;AAED;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.ts"],"names":["Log","TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","log","module","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","warn","undefined","getColumnFormat","getColumnTypeFormatter","columnTypeFormatter","getFormattedString","value","formatOverride","formatter","timeZone","dhTimeZone","id"],"mappings":";;AAAA,SAASA,GAAT,QAAoB,gBAApB;OACOC,U;SAELC,sB,EACAC,mB,EACAC,uB,EACAC,sB,EACAC,sB,EACAC,sB;AAKF,IAAMC,GAAG,GAAGR,GAAG,CAACS,MAAJ,CAAW,WAAX,CAAZ;;A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AAP,gDAAOA,SAAS,CAAEE,UAAlB,0DAAO,sBAAuBC,EAA9B;AACD;;AA/Ka;;AAkLhB,eAAe1C,SAAf","sourcesContent":["import { Log } from '@deephaven/log';\nimport TableUtils, { DataType } from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n TableColumnFormat,\n TableColumnFormatter,\n} from './formatters';\n\nconst log = Log.module('Formatter');\n\ntype ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: string;\n format: TableColumnFormat;\n}\n\nclass Formatter {\n /**\n * Converts FormattingRule[] to Map\n * @param columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(\n columnFormattingRules: FormattingRule[]\n ): Map<DataType, Map<ColumnName, TableColumnFormat>> {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (dataType === null) {\n return map;\n }\n\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<DataType, Map<ColumnName, TableColumnFormat>>());\n }\n\n /**\n * Creates a column formatting rule\n * @param columnType Normalized data type\n * @param columnName Column name\n * @param format Format object\n */\n static makeColumnFormattingRule(\n columnType: DataType,\n columnName: string,\n format: TableColumnFormat\n ): FormattingRule {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param columnFormattingRules Optional array of column formatting rules\n * @param dateTimeOptions Optional object with DateTime configuration\n * @param decimalFormatOptions Optional object with Decimal configuration\n * @param integerFormatOptions Optional object with Integer configuration\n */\n constructor(\n columnFormattingRules: FormattingRule[] = [],\n dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[0],\n decimalFormatOptions?: ConstructorParameters<\n typeof DecimalColumnFormatter\n >[0],\n integerFormatOptions?: ConstructorParameters<\n typeof IntegerColumnFormatter\n >[0]\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<DataType, TableColumnFormatter>([\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 defaultColumnFormatter: TableColumnFormatter;\n\n typeFormatterMap: Map<DataType, TableColumnFormatter>;\n\n columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param columnType column type\n * @param 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(\n columnType: string,\n createIfNecessary = false\n ): Map<string, TableColumnFormat> | undefined {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType === null) {\n log.warn(`Unknown columnType ${columnType}`);\n return undefined;\n }\n\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 columnType column type\n * @param columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(\n columnType: string,\n columnName: string\n ): TableColumnFormat | null {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n return columnFormatMap?.get(columnName) ?? null;\n }\n\n getColumnTypeFormatter(columnType: string): TableColumnFormatter {\n const dataType = TableUtils.getNormalizedType(columnType);\n let columnTypeFormatter = this.defaultColumnFormatter;\n if (dataType) {\n columnTypeFormatter =\n this.typeFormatterMap.get(dataType) ?? columnTypeFormatter;\n }\n return columnTypeFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param value Value to format\n * @param columnType Column type used to determine the formatting settings\n * @param columnName Column name used to determine the formatting settings\n * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value: unknown,\n columnType: string,\n columnName = '',\n formatOverride?: TableColumnFormat\n ): string {\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 ?? undefined);\n }\n\n /**\n * Gets the timeZone name\n * @returns The time zone name E.g. America/New_York\n */\n get timeZone(): string {\n const formatter = this.typeFormatterMap.get(\n TableUtils.dataType.DATETIME\n ) as DateTimeColumnFormatter;\n return formatter?.dhTimeZone?.id;\n }\n}\n\nexport default Formatter;\n"],"file":"Formatter.js"}
|
package/dist/FormatterUtils.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FormattingRule } from './Formatter';
|
|
2
|
+
import { DateTimeColumnFormatter } from './formatters';
|
|
2
3
|
declare class FormatterUtils {
|
|
3
|
-
static getColumnFormats(settings:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
static getColumnFormats(settings: {
|
|
5
|
+
formatter: FormattingRule[];
|
|
6
|
+
}): FormattingRule[];
|
|
7
|
+
static getDateTimeFormatterOptions(settings: {
|
|
8
|
+
timeZone: string;
|
|
9
|
+
defaultDateTimeFormat: string;
|
|
10
|
+
showTimeZone: boolean;
|
|
11
|
+
showTSeparator: boolean;
|
|
12
|
+
}): Required<ConstructorParameters<typeof DateTimeColumnFormatter>[0]>;
|
|
10
13
|
}
|
|
14
|
+
export default FormatterUtils;
|
|
11
15
|
//# sourceMappingURL=FormatterUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatterUtils.d.ts","sourceRoot":"","sources":["../src/FormatterUtils.
|
|
1
|
+
{"version":3,"file":"FormatterUtils.d.ts","sourceRoot":"","sources":["../src/FormatterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,cAAM,cAAc;IAClB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE;QAChC,SAAS,EAAE,cAAc,EAAE,CAAC;KAC7B,GAAG,cAAc,EAAE;IAKpB,MAAM,CAAC,2BAA2B,CAAC,QAAQ,EAAE;QAC3C,QAAQ,EAAE,MAAM,CAAC;QACjB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,EAAE,OAAO,CAAC;KACzB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;CAcvE;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/FormatterUtils.
|
|
1
|
+
{"version":3,"sources":["../src/FormatterUtils.ts"],"names":["FormatterUtils","getColumnFormats","settings","formatter","getDateTimeFormatterOptions","timeZone","defaultDateTimeFormat","showTimeZone","showTSeparator","defaultDateTimeFormatString"],"mappings":"AAGA,MAAMA,cAAN,CAAqB;AACI,SAAhBC,gBAAgB,CAACC,QAAD,EAEF;AACnB,QAAM;AAAEC,MAAAA;AAAF,QAAgBD,QAAtB;AACA,WAAOC,SAAP;AACD;;AAEiC,SAA3BC,2BAA2B,CAACF,QAAD,EAKqC;AACrE,QAAM;AACJG,MAAAA,QADI;AAEJC,MAAAA,qBAFI;AAGJC,MAAAA,YAHI;AAIJC,MAAAA;AAJI,QAKFN,QALJ;AAMA,WAAO;AACLG,MAAAA,QADK;AAELI,MAAAA,2BAA2B,EAAEH,qBAFxB;AAGLC,MAAAA,YAHK;AAILC,MAAAA;AAJK,KAAP;AAMD;;AA1BkB;;AA6BrB,eAAeR,cAAf","sourcesContent":["import type { FormattingRule } from './Formatter';\nimport { DateTimeColumnFormatter } from './formatters';\n\nclass FormatterUtils {\n static getColumnFormats(settings: {\n formatter: FormattingRule[];\n }): FormattingRule[] {\n const { formatter } = settings;\n return formatter;\n }\n\n static getDateTimeFormatterOptions(settings: {\n timeZone: string;\n defaultDateTimeFormat: string;\n showTimeZone: boolean;\n showTSeparator: boolean;\n }): Required<ConstructorParameters<typeof DateTimeColumnFormatter>[0]> {\n const {\n timeZone,\n defaultDateTimeFormat,\n showTimeZone,\n showTSeparator,\n } = settings;\n return {\n timeZone,\n defaultDateTimeFormatString: defaultDateTimeFormat,\n showTimeZone,\n showTSeparator,\n };\n }\n}\n\nexport default FormatterUtils;\n"],"file":"FormatterUtils.js"}
|
package/dist/IrisGrid.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export class IrisGrid extends React.Component<any, any, any> {
|
|
|
2
2
|
static minDebounce: number;
|
|
3
3
|
static maxDebounce: number;
|
|
4
4
|
static loadingSpinnerDelay: number;
|
|
5
|
-
static makeQuickFilter(column: any, text: any, timeZone: any):
|
|
5
|
+
static makeQuickFilter(column: any, text: any, timeZone: any): import("@deephaven/jsapi-shim").FilterCondition | null;
|
|
6
6
|
constructor(props: any);
|
|
7
7
|
handleAdvancedFilterChange(column: any, filter: any, options: any): void;
|
|
8
8
|
handleAdvancedFilterSortChange(column: any, direction: any, addToExisting?: boolean): void;
|
|
@@ -71,15 +71,17 @@ export class IrisGrid extends React.Component<any, any, any> {
|
|
|
71
71
|
lastLoadedConfig: {
|
|
72
72
|
advancedFilters: Map<any, any>;
|
|
73
73
|
customColumns: never[];
|
|
74
|
-
reverseType:
|
|
74
|
+
reverseType: "none";
|
|
75
75
|
quickFilters: Map<any, any>;
|
|
76
|
-
searchFilter:
|
|
76
|
+
searchFilter: import("@deephaven/jsapi-shim").FilterCondition | null;
|
|
77
77
|
sorts: never[];
|
|
78
78
|
} | null;
|
|
79
79
|
tooltip: 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;
|
|
@@ -416,7 +418,7 @@ export namespace IrisGrid {
|
|
|
416
418
|
export { selectDistinctColumns_1 as selectDistinctColumns };
|
|
417
419
|
const sorts_1: never[];
|
|
418
420
|
export { sorts_1 as sorts };
|
|
419
|
-
const reverseType_1:
|
|
421
|
+
const reverseType_1: "none";
|
|
420
422
|
export { reverseType_1 as reverseType };
|
|
421
423
|
const customColumns_1: never[];
|
|
422
424
|
export { customColumns_1 as customColumns };
|
|
@@ -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;
|
package/dist/IrisGrid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IrisGrid.d.ts","sourceRoot":"","sources":["../src/IrisGrid.jsx"],"names":[],"mappings":"AAiHA;IACE,2BAAyB;IAEzB,2BAAyB;IAEzB,mCAAiC;IAEjC,
|
|
1
|
+
{"version":3,"file":"IrisGrid.d.ts","sourceRoot":"","sources":["../src/IrisGrid.jsx"],"names":[],"mappings":"AAiHA;IACE,2BAAyB;IAEzB,2BAAyB;IAEzB,mCAAiC;IAEjC,sHAOC;IAED,wBA0QC;IAq0CD,yEAOC;IAED,2FA0BC;IAED,iCAEC;IAED,4CAEC;IAED,iDAeC;IA6TD;;;OAGG;IACH,gDAaC;IAhCD;;;OAGG;IACH,yDASC;IAqBD;;;OAGG;IACH,8CAeC;IAxoBD,4BAOC;IAED,6BAMC;IAED,2BAIC;IAuRD,0BAEC;IAED,uCAGC;IAED,kCAKC;IAED,wCASC;IAED,0EAOC;IAED,wCAOC;IAhDD,qBAEC;IAsED,mBAEC;IAED,wBAEC;IAUD,oCAIC;IAZD,uBAMC;IAQD,sCAWC;IA8DD,kDAQC;IAED,iFAEC;IAxED,qBA2BC;IA+CD,qCAOC;IApDD,sCA6BC;IAnHD,kEAoBC;IAwHD,oDA6EC;IAED,mCASC;IAoGD,oDAoBC;IA9GD,iCAUC;IAlBD,4CAEC;IAED,6CAEC;IAkID,0CAiBC;IAjCD,iCAcC;IAqBD,kCAGC;IAuBD,+BAMC;IA3BD,gGAWC;IAED,gCAMC;IA3tBD,wCAIC;IAED,4CAGC;IAED,gCAKC;IAED,4BAEC;IA/FD,8EAcC;IAED,sGAmBC;IA2pBD,4CAqBC;IA9qBD,+GAaC;IAxxCC,kBAAgB;IAChB,mCAAuB;IACvB,gCAAsC;IACtC;;;;;;;aAA4B;IAC5B,aAAmB;IACnB,iBAA4B;IAC5B,2BAA6B;IAC7B,6BAAkC;IAClC,yBAA8B;IAC9B,yBAA8B;IAG9B,qCAAiC;IACjC,sCAAkC;IAClC,oCAAwB;IACxB,2BAAsC;IACtC,8BAAsB;IACtB,qCAAuC;IACvC,qBAAwB;IACxB,8BAA0B;IAC1B,qC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FW,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 = {};
|
|
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,
|