@deephaven/jsapi-utils 0.13.3-treemap.2 → 0.14.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/DateUtils.d.ts.map +1 -1
- package/dist/DateUtils.js +5 -0
- package/dist/DateUtils.js.map +1 -1
- package/dist/Formatter.d.ts +4 -4
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js.map +1 -1
- package/dist/FormatterUtils.d.ts +10 -10
- package/dist/FormatterUtils.d.ts.map +1 -1
- package/dist/FormatterUtils.js +15 -15
- package/dist/FormatterUtils.js.map +1 -1
- package/dist/TableUtils.d.ts +25 -19
- package/dist/TableUtils.d.ts.map +1 -1
- package/dist/TableUtils.js +23 -18
- package/dist/TableUtils.js.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.d.ts +1 -1
- package/dist/formatters/DateTimeColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.js.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.d.ts +1 -1
- package/dist/formatters/DecimalColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.js.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.d.ts +1 -1
- package/dist/formatters/IntegerColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.js.map +1 -1
- package/dist/formatters/TableColumnFormatter.d.ts +1 -1
- package/dist/formatters/TableColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/TableColumnFormatter.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/DateUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../src/DateUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAA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AAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ/C;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAChB,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,QAAQ,EAAE,MAAM,GACf,WAAW,GAAG,IAAI;IA4CrB;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAqB9C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,eAAe,CACpB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI;IAwB3B;;;;;;OAMG;IACH,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAiCrE;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;IAwFnD;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;CAM1D;AAED,eAAe,SAAS,CAAC"}
|
package/dist/DateUtils.js
CHANGED
|
@@ -20,6 +20,11 @@ export class DateUtils {
|
|
|
20
20
|
var minute = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
21
21
|
var second = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
|
|
22
22
|
var ns = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
|
|
23
|
+
|
|
24
|
+
if (!timeZone) {
|
|
25
|
+
throw new Error('No timezone provided');
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
var yearString = "".concat(year).padStart(4, '0');
|
|
24
29
|
var monthString = "".concat(month + 1).padStart(2, '0');
|
|
25
30
|
var dayString = "".concat(day).padStart(2, '0');
|
package/dist/DateUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,OAAO,MAAMC,SAAN,CAAgB;AAkBrB;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,CAIM;AAAA,QAHbC,MAGa,uEAHJ,CAGI;AAAA,QAFbC,MAEa,uEAFJ,CAEI;AAAA,QADbC,EACa,uEADR,CACQ;AACb,QAAMC,UAAU,GAAG,UAAGP,IAAH,EAAUQ,QAAV,CAAmB,CAAnB,EAAsB,GAAtB,CAAnB;AACA,QAAMC,WAAW,GAAG,UAAGR,KAAK,GAAG,CAAX,EAAeO,QAAf,CAA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,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\nexport class 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"}
|
|
1
|
+
{"version":3,"sources":["../src/DateUtils.ts"],"names":["dh","DateUtils","makeDateWrapper","timeZone","year","month","day","hour","minute","second","ns","Error","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","overflow","parseDateRange","text","cleanText","now","startDate","endDate","DateWrapper","ofJsDate","getJsDate","dateWrapper","asDate"],"mappings":";;AAAA,OAAOA,EAAP,MAAe,uBAAf;AAaA,OAAO,MAAMC,SAAN,CAAgB;AAkBrB;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,CAIM;AAAA,QAHbC,MAGa,uEAHJ,CAGI;AAAA,QAFbC,MAEa,uEAFJ,CAEI;AAAA,QADbC,EACa,uEADR,CACQ;;AACb,QAAI,CAACP,QAAL,EAAe;AACb,YAAM,IAAIQ,KAAJ,CAAU,sBAAV,CAAN;AACD;;AACD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J,CAASkC,WAAT,CAAP;AACD;;AACD,WAAOA,WAAW,CAACC,MAAZ,EAAP;AACD;;AAvVoB;;gBAAV7E,S,sBACe,+B;;gBADfA,S,YAGK,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;;AAuVlB,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\nexport class 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 if (!timeZone) {\n throw new Error('No timezone provided');\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 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
|
@@ -3,7 +3,7 @@ import { DateTimeColumnFormatter, DecimalColumnFormatter, IntegerColumnFormatter
|
|
|
3
3
|
declare type ColumnName = string;
|
|
4
4
|
export interface FormattingRule {
|
|
5
5
|
columnType: string;
|
|
6
|
-
columnName:
|
|
6
|
+
columnName: ColumnName;
|
|
7
7
|
format: TableColumnFormat;
|
|
8
8
|
}
|
|
9
9
|
export declare class Formatter {
|
|
@@ -19,7 +19,7 @@ export declare class Formatter {
|
|
|
19
19
|
* @param columnName Column name
|
|
20
20
|
* @param format Format object
|
|
21
21
|
*/
|
|
22
|
-
static makeColumnFormattingRule(columnType: DataType, columnName:
|
|
22
|
+
static makeColumnFormattingRule(columnType: DataType, columnName: ColumnName, format: TableColumnFormat): FormattingRule;
|
|
23
23
|
/**
|
|
24
24
|
* @param columnFormattingRules Optional array of column formatting rules
|
|
25
25
|
* @param dateTimeOptions Optional object with DateTime configuration
|
|
@@ -45,7 +45,7 @@ export declare class Formatter {
|
|
|
45
45
|
* @param columnName column name
|
|
46
46
|
* @returns format object or null for Default
|
|
47
47
|
*/
|
|
48
|
-
getColumnFormat(columnType: string, columnName:
|
|
48
|
+
getColumnFormat(columnType: string, columnName: ColumnName): TableColumnFormat | null;
|
|
49
49
|
getColumnTypeFormatter(columnType: string): TableColumnFormatter;
|
|
50
50
|
/**
|
|
51
51
|
* Gets formatted string for a given value, column type and name
|
|
@@ -54,7 +54,7 @@ export declare class Formatter {
|
|
|
54
54
|
* @param columnName Column name used to determine the formatting settings
|
|
55
55
|
* @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
|
|
56
56
|
*/
|
|
57
|
-
getFormattedString(value: unknown, columnType: string, columnName?: string, formatOverride?: TableColumnFormat): string;
|
|
57
|
+
getFormattedString(value: unknown, columnType: string, columnName?: string, formatOverride?: Partial<TableColumnFormat>): string;
|
|
58
58
|
/**
|
|
59
59
|
* Gets the timeZone name
|
|
60
60
|
* @returns The time zone name E.g. America/New_York
|
package/dist/Formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAGL,uBAAuB,EACvB,sBAAsB,EAEtB,sBAAsB,EAEtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,aAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAGL,uBAAuB,EACvB,sBAAsB,EAEtB,sBAAsB,EAEtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,aAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,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K,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,SAAK,EACf,cAAc,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAC1C,MAAM;IAYT;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAKrB;CACF;AAED,eAAe,SAAS,CAAC"}
|
package/dist/Formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Formatter.ts"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","StringColumnFormatter","Formatter","makeColumnFormatMap","columnFormattingRules","Map","reduce","map","next","dataType","getNormalizedType","columnType","has","set","formatMap","get","columnName","format","makeColumnFormattingRule","constructor","dateTimeOptions","decimalFormatOptions","integerFormatOptions","truncateNumbersWithPound","defaultColumnFormatter","typeFormatterMap","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","STRING","columnFormatMap","getColumnFormatMapForType","createIfNecessary","undefined","getColumnFormat","getColumnTypeFormatter","columnTypeFormatter","getFormattedString","value","formatOverride","formatter","timeZone","dhTimeZone","id"],"mappings":";;OAAOA,U;SAELC,sB,EACAC,mB,EACAC,uB,EACAC,sB,EACAC,sB,EACAC,sB,EACAC,qB;AAaF,OAAO,MAAMC,SAAN,CAAgB;AACrB;AACF;AACA;AACA;AACA;AAC4B,SAAnBC,mBAAmB,CACxBC,qBADwB,EAE2B;AACnD,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,GAAGf,UAAU,CAACgB,iBAAX,CAA6BF,IAAI,CAACG,UAAlC,CAAjB;;AACA,UAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACrB,eAAOF,GAAP;AACD;;AAED,UAAI,CAACA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,GAAGf,UAAU,CAACgB,iBAAX,CAA6BC,UAA7B,CAAjB;AACA,QAAI2B,mBAAmB,GAAG,KAAKd,sBAA/B;;AACA,QAAIf,QAAJ,EAAc;AAAA;;AACZ6B,MAAAA,mBAAmB,4BACjB,KAAKb,gBAAL,CAAsBV,GAAtB,CAA0BN,QAA1B,CADiB,yEACsB6B,mBADzC;AAED;;AACD,WAAOA,mBAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACEC,EAAAA,kBAAkB,CAChBC,KADgB,EAEhB7B,UAFgB,EAKR;AAAA,QAFRK,UAEQ,uEAFK,EAEL;AAAA,QADRyB,cACQ;;AACR,QAAID,KAAK,IAAI,IAAb,EAAmB;AACjB,aAAO,EAAP;AACD;;AAED,QAAME,SAAS,GAAG,KAAKL,sBAAL,CAA4B1B,UAA5B,CAAlB;AACA,QAAMM,MAAM,GACVwB,cAAc,IAAI,KAAKL,eAAL,CAAqBzB,UAArB,EAAiCK,UAAjC,CADpB;AAGA,WAAO0B,SAAS,CAACzB,MAAV,CAAiBuB,KAAjB,EAAwBvB,MAAxB,aAAwBA,MAAxB,cAAwBA,MAAxB,GAAkCkB,SAAlC,CAAP;AACD;AAED;AACF;AACA;AACA;;;AACc,MAARQ,QAAQ,GAAW;AAAA;;AACrB,QAAMD,SAAS,GAAG,KAAKjB,gBAAL,CAAsBV,GAAtB,CAChBrB,UAAU,CAACe,QAAX,CAAoBmB,QADJ,CAAlB;AAGA,WAAOc,SAAP,aAAOA,SAAP,gDAAOA,SAAS,CAAEE,UAAlB,0DAAO,sBAAuBC,EAA9B;AACD;;AApLoB;AAuLvB,eAAe3C,SAAf","sourcesContent":["import TableUtils, { DataType } from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n StringColumnFormatter,\n TableColumnFormat,\n TableColumnFormatter,\n} from './formatters';\n\ntype ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: string;\n format: TableColumnFormat;\n}\n\nexport class 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 * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end\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 truncateNumbersWithPound = false\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 [TableUtils.dataType.STRING, new StringColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n this.truncateNumbersWithPound = truncateNumbersWithPound;\n }\n\n defaultColumnFormatter: TableColumnFormatter;\n\n typeFormatterMap: Map<DataType, TableColumnFormatter>;\n\n columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;\n\n truncateNumbersWithPound: boolean;\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 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"}
|
|
1
|
+
{"version":3,"sources":["../src/Formatter.ts"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","StringColumnFormatter","Formatter","makeColumnFormatMap","columnFormattingRules","Map","reduce","map","next","dataType","getNormalizedType","columnType","has","set","formatMap","get","columnName","format","makeColumnFormattingRule","constructor","dateTimeOptions","decimalFormatOptions","integerFormatOptions","truncateNumbersWithPound","defaultColumnFormatter","typeFormatterMap","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","STRING","columnFormatMap","getColumnFormatMapForType","createIfNecessary","undefined","getColumnFormat","getColumnTypeFormatter","columnTypeFormatter","getFormattedString","value","formatOverride","formatter","timeZone","dhTimeZone","id"],"mappings":";;OAAOA,U;SAELC,sB,EACAC,mB,EACAC,uB,EACAC,sB,EACAC,sB,EACAC,sB,EACAC,qB;AAaF,OAAO,MAAMC,SAAN,CAAgB;AACrB;AACF;AACA;AACA;AACA;AAC4B,SAAnBC,mBAAmB,CACxBC,qBADwB,EAE2B;AACnD,QAAIA,qBAAqB,IAAI,IAA7B,EAAmC;AACjC,aAAO,IAAIC,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uBC,EAA9B;AACD;;AApLoB;AAuLvB,eAAe3C,SAAf","sourcesContent":["import TableUtils, { DataType } from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n StringColumnFormatter,\n TableColumnFormat,\n TableColumnFormatter,\n} from './formatters';\n\ntype ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: ColumnName;\n format: TableColumnFormat;\n}\n\nexport class 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: ColumnName,\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 * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end\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 truncateNumbersWithPound = false\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 [TableUtils.dataType.STRING, new StringColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n this.truncateNumbersWithPound = truncateNumbersWithPound;\n }\n\n defaultColumnFormatter: TableColumnFormatter;\n\n typeFormatterMap: Map<DataType, TableColumnFormatter>;\n\n columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;\n\n truncateNumbersWithPound: boolean;\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 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: ColumnName\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?: Partial<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,16 +1,16 @@
|
|
|
1
1
|
import type { FormattingRule } from './Formatter';
|
|
2
2
|
import Formatter from './Formatter';
|
|
3
3
|
import { DateTimeColumnFormatter } from './formatters';
|
|
4
|
-
|
|
5
|
-
static getColumnFormats(settings
|
|
6
|
-
formatter
|
|
7
|
-
}): FormattingRule[];
|
|
8
|
-
static getDateTimeFormatterOptions(settings
|
|
9
|
-
timeZone
|
|
10
|
-
defaultDateTimeFormat
|
|
11
|
-
showTimeZone
|
|
12
|
-
showTSeparator
|
|
13
|
-
}):
|
|
4
|
+
declare class FormatterUtils {
|
|
5
|
+
static getColumnFormats(settings?: {
|
|
6
|
+
formatter?: FormattingRule[];
|
|
7
|
+
}): FormattingRule[] | undefined;
|
|
8
|
+
static getDateTimeFormatterOptions(settings?: {
|
|
9
|
+
timeZone?: string;
|
|
10
|
+
defaultDateTimeFormat?: string;
|
|
11
|
+
showTimeZone?: boolean;
|
|
12
|
+
showTSeparator?: boolean;
|
|
13
|
+
} | null): ConstructorParameters<typeof DateTimeColumnFormatter>[0];
|
|
14
14
|
/**
|
|
15
15
|
* Check if the formatter has a custom format defined for the column name and type
|
|
16
16
|
* @param formatter Formatter to check
|
|
@@ -1 +1 @@
|
|
|
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,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAwB,MAAM,cAAc,CAAC;AAE7E,
|
|
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,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAwB,MAAM,cAAc,CAAC;AAE7E,cAAM,cAAc;IAClB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;QACjC,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;KAC9B,GAAG,cAAc,EAAE,GAAG,SAAS;IAQhC,MAAM,CAAC,2BAA2B,CAChC,QAAQ,CAAC,EAAE;QACT,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,GAAG,IAAI,GACP,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAS3D;;;;;;OAMG;IACH,MAAM,CAAC,2BAA2B,CAChC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO;CAQX;AAED,eAAe,cAAc,CAAC"}
|
package/dist/FormatterUtils.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { TableColumnFormatter } from "./formatters/index.js";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
class FormatterUtils {
|
|
3
4
|
static getColumnFormats(settings) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
if (settings && settings.formatter) {
|
|
6
|
+
var {
|
|
7
|
+
formatter
|
|
8
|
+
} = settings;
|
|
9
|
+
return formatter;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return undefined;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
static getDateTimeFormatterOptions(settings) {
|
|
11
|
-
var {
|
|
12
|
-
timeZone,
|
|
13
|
-
defaultDateTimeFormat,
|
|
14
|
-
showTimeZone,
|
|
15
|
-
showTSeparator
|
|
16
|
-
} = settings;
|
|
17
16
|
return {
|
|
18
|
-
timeZone,
|
|
19
|
-
defaultDateTimeFormatString: defaultDateTimeFormat,
|
|
20
|
-
showTimeZone,
|
|
21
|
-
showTSeparator
|
|
17
|
+
timeZone: settings === null || settings === void 0 ? void 0 : settings.timeZone,
|
|
18
|
+
defaultDateTimeFormatString: settings === null || settings === void 0 ? void 0 : settings.defaultDateTimeFormat,
|
|
19
|
+
showTimeZone: settings === null || settings === void 0 ? void 0 : settings.showTimeZone,
|
|
20
|
+
showTSeparator: settings === null || settings === void 0 ? void 0 : settings.showTSeparator
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
@@ -36,5 +35,6 @@ export class FormatterUtils {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
}
|
|
38
|
+
|
|
39
39
|
export default FormatterUtils;
|
|
40
40
|
//# sourceMappingURL=FormatterUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/FormatterUtils.ts"],"names":["TableColumnFormatter","FormatterUtils","getColumnFormats","settings","formatter","getDateTimeFormatterOptions","timeZone","defaultDateTimeFormat","showTimeZone","showTSeparator","
|
|
1
|
+
{"version":3,"sources":["../src/FormatterUtils.ts"],"names":["TableColumnFormatter","FormatterUtils","getColumnFormats","settings","formatter","undefined","getDateTimeFormatterOptions","timeZone","defaultDateTimeFormatString","defaultDateTimeFormat","showTimeZone","showTSeparator","isCustomColumnFormatDefined","columnName","columnType","columnFormat","getColumnFormat","type","TYPE_CONTEXT_PRESET","TYPE_CONTEXT_CUSTOM"],"mappings":"SAEkCA,oB;;AAElC,MAAMC,cAAN,CAAqB;AACI,SAAhBC,gBAAgB,CAACC,QAAD,EAEU;AAC/B,QAAIA,QAAQ,IAAIA,QAAQ,CAACC,SAAzB,EAAoC;AAClC,UAAM;AAAEA,QAAAA;AAAF,UAAgBD,QAAtB;AACA,aAAOC,SAAP;AACD;;AACD,WAAOC,SAAP;AACD;;AAEiC,SAA3BC,2BAA2B,CAChCH,QADgC,EAO0B;AAC1D,WAAO;AACLI,MAAAA,QAAQ,EAAEJ,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEI,QADf;AAELC,MAAAA,2BAA2B,EAAEL,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEM,qBAFlC;AAGLC,MAAAA,YAAY,EAAEP,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEO,YAHnB;AAILC,MAAAA,cAAc,EAAER,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEQ;AAJrB,KAAP;AAMD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACoC,SAA3BC,2BAA2B,CAChCR,SADgC,EAEhCS,UAFgC,EAGhCC,UAHgC,EAIvB;AACT,QAAMC,YAAY,GAAGX,SAAS,CAACY,eAAV,CAA0BF,UAA1B,EAAsCD,UAAtC,CAArB;AACA,WACEE,YAAY,IAAI,IAAhB,KACCA,YAAY,CAACE,IAAb,KAAsBjB,oBAAoB,CAACkB,mBAA3C,IACCH,YAAY,CAACE,IAAb,KAAsBjB,oBAAoB,CAACmB,mBAF7C,CADF;AAKD;;AA7CkB;;AAgDrB,eAAelB,cAAf","sourcesContent":["import type { FormattingRule } from './Formatter';\nimport Formatter from './Formatter';\nimport { DateTimeColumnFormatter, TableColumnFormatter } from './formatters';\n\nclass FormatterUtils {\n static getColumnFormats(settings?: {\n formatter?: FormattingRule[];\n }): FormattingRule[] | undefined {\n if (settings && settings.formatter) {\n const { formatter } = settings;\n return formatter;\n }\n return undefined;\n }\n\n static getDateTimeFormatterOptions(\n settings?: {\n timeZone?: string;\n defaultDateTimeFormat?: string;\n showTimeZone?: boolean;\n showTSeparator?: boolean;\n } | null\n ): ConstructorParameters<typeof DateTimeColumnFormatter>[0] {\n return {\n timeZone: settings?.timeZone,\n defaultDateTimeFormatString: settings?.defaultDateTimeFormat,\n showTimeZone: settings?.showTimeZone,\n showTSeparator: settings?.showTSeparator,\n };\n }\n\n /**\n * Check if the formatter has a custom format defined for the column name and type\n * @param formatter Formatter to check\n * @param columnName Column name\n * @param columnType Column type\n * @returns True, if a custom format is defined\n */\n static isCustomColumnFormatDefined(\n formatter: Formatter,\n columnName: string,\n columnType: string\n ): boolean {\n const columnFormat = formatter.getColumnFormat(columnType, columnName);\n return (\n columnFormat != null &&\n (columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_PRESET ||\n columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_CUSTOM)\n );\n }\n}\n\nexport default FormatterUtils;\n"],"file":"FormatterUtils.js"}
|
package/dist/TableUtils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeValue as FilterTypeValue, OperatorValue as FilterOperatorValue } from '@deephaven/filters';
|
|
2
2
|
import { Column, FilterCondition, FilterValue, LongWrapper, Sort, Table, TreeTable } from '@deephaven/jsapi-shim';
|
|
3
3
|
import { CancelablePromise } from '@deephaven/utils';
|
|
4
4
|
declare type Values<T> = T[keyof T];
|
|
@@ -9,6 +9,16 @@ export declare type AdvancedFilterItemType = {
|
|
|
9
9
|
selectedType: FilterTypeValue;
|
|
10
10
|
value: string;
|
|
11
11
|
};
|
|
12
|
+
export interface FilterItem {
|
|
13
|
+
selectedType: FilterTypeValue;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
export declare type AdvancedFilterOptions = {
|
|
17
|
+
filterItems: FilterItem[];
|
|
18
|
+
filterOperators: FilterOperatorValue[];
|
|
19
|
+
invertSelection: boolean;
|
|
20
|
+
selectedValues: unknown[];
|
|
21
|
+
};
|
|
12
22
|
/** Utility class to provide some functions for working with tables */
|
|
13
23
|
export declare class TableUtils {
|
|
14
24
|
static dataType: {
|
|
@@ -18,6 +28,7 @@ export declare class TableUtils {
|
|
|
18
28
|
readonly DECIMAL: "decimal";
|
|
19
29
|
readonly INT: "int";
|
|
20
30
|
readonly STRING: "string";
|
|
31
|
+
readonly UNKNOWN: "unknown";
|
|
21
32
|
};
|
|
22
33
|
static sortDirection: {
|
|
23
34
|
readonly ascending: "ASC";
|
|
@@ -38,20 +49,20 @@ export declare class TableUtils {
|
|
|
38
49
|
* @return The sort for the column, or null if it's not sorted
|
|
39
50
|
*/
|
|
40
51
|
static getSortForColumn(tableSort: Sort[], columnIndex: number): Sort | null;
|
|
41
|
-
static getFilterText(filter
|
|
52
|
+
static getFilterText(filter?: FilterCondition | null): string | null;
|
|
42
53
|
/** Return the valid filter types for the column */
|
|
43
|
-
static getFilterTypes(columnType: string):
|
|
44
|
-
static getNextSort(
|
|
45
|
-
static makeColumnSort(
|
|
54
|
+
static getFilterTypes(columnType: string): FilterTypeValue[];
|
|
55
|
+
static getNextSort(columns: Column[], sorts: Sort[], columnIndex: number): Sort | null;
|
|
56
|
+
static makeColumnSort(columns: Column[], columnIndex: number, direction: SortDirection, isAbs: boolean): Sort | null;
|
|
46
57
|
/**
|
|
47
58
|
* Toggles the sort for the specified column
|
|
48
59
|
* @param sorts The current sorts from IrisGrid.state
|
|
49
|
-
* @param
|
|
60
|
+
* @param columns The columns to apply the sort to
|
|
50
61
|
* @param columnIndex The column index to apply the sort to
|
|
51
62
|
* @param addToExisting Add this sort to the existing sort
|
|
52
63
|
*/
|
|
53
|
-
static toggleSortForColumn(sorts: Sort[],
|
|
54
|
-
static sortColumn(
|
|
64
|
+
static toggleSortForColumn(sorts: Sort[], columns: Column[], columnIndex: number, addToExisting?: boolean): Sort[];
|
|
65
|
+
static sortColumn(sorts: Sort[], columns: Column[], modelColumn: number, direction: SortDirection, isAbs: boolean, addToExisting: boolean): Sort[];
|
|
55
66
|
/**
|
|
56
67
|
* Sets the sort for the given column *and* removes any reverses
|
|
57
68
|
* @param tableSort The current sorts from IrisGrid.state
|
|
@@ -61,7 +72,7 @@ export declare class TableUtils {
|
|
|
61
72
|
* @returns Returns the modified array of sorts - removing reverses
|
|
62
73
|
*/
|
|
63
74
|
static setSortForColumn(tableSort: Sort[], columnIndex: number, sort: Sort | null, addToExisting?: boolean): Sort[];
|
|
64
|
-
static getNormalizedType(columnType: string): DataType
|
|
75
|
+
static getNormalizedType(columnType: string): DataType;
|
|
65
76
|
static isLongType(columnType: string): boolean;
|
|
66
77
|
static isDateType(columnType: string): boolean;
|
|
67
78
|
static isNumberType(columnType: string): boolean;
|
|
@@ -91,7 +102,7 @@ export declare class TableUtils {
|
|
|
91
102
|
* @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York
|
|
92
103
|
* @returns Returns the created filter, null if text could not be parsed
|
|
93
104
|
*/
|
|
94
|
-
static makeQuickFilter(column: Column, text: string, timeZone
|
|
105
|
+
static makeQuickFilter(column: Column, text: string, timeZone?: string): FilterCondition | null;
|
|
95
106
|
/**
|
|
96
107
|
* Create filter with the provided column and text of one component (no multiple conditions)
|
|
97
108
|
* @param column The column to set the filter on
|
|
@@ -99,10 +110,10 @@ export declare class TableUtils {
|
|
|
99
110
|
* @param timeZone The time zone to make this filter in if it is a date type. E.g. America/New_York
|
|
100
111
|
* @returns Returns the created filter, null if text could not be parsed
|
|
101
112
|
*/
|
|
102
|
-
static makeQuickFilterFromComponent(column: Column, text: string, timeZone
|
|
113
|
+
static makeQuickFilterFromComponent(column: Column, text: string, timeZone?: string): FilterCondition | null;
|
|
103
114
|
static makeQuickNumberFilter(column: Column, text: string): FilterCondition | null;
|
|
104
115
|
static makeQuickTextFilter(column: Column, text: string | null): FilterCondition | null;
|
|
105
|
-
static makeQuickBooleanFilter(column: Column, text: string): FilterCondition | null;
|
|
116
|
+
static makeQuickBooleanFilter(column: Column, text: string | number): FilterCondition | null;
|
|
106
117
|
/**
|
|
107
118
|
* Builds a date filter parsed from the text string which may or may not include an operator.
|
|
108
119
|
* @param column The column to build the filter from, with or without a leading operator.
|
|
@@ -141,12 +152,7 @@ export declare class TableUtils {
|
|
|
141
152
|
* @returns Resolves with the event data
|
|
142
153
|
*/
|
|
143
154
|
static makeCancelableTableEventPromise(table: Table | TreeTable, eventName: string, timeout?: number, matcher?: ((event: CustomEvent) => boolean) | null): CancelablePromise<CustomEvent>;
|
|
144
|
-
static makeAdvancedFilter(column: Column, options:
|
|
145
|
-
filterItems: AdvancedFilterItemType[];
|
|
146
|
-
filterOperators: FilterOperatorValue[];
|
|
147
|
-
invertSelection: boolean;
|
|
148
|
-
selectedValues: string[];
|
|
149
|
-
}, timeZone: string): FilterCondition | null;
|
|
155
|
+
static makeAdvancedFilter(column: Column, options: AdvancedFilterOptions, timeZone: string): FilterCondition;
|
|
150
156
|
static removeCommas(value: string): string;
|
|
151
157
|
/**
|
|
152
158
|
* @param columnType The column type to make the filter value from.
|
|
@@ -181,7 +187,7 @@ export declare class TableUtils {
|
|
|
181
187
|
* @param invertSelection Invert the selection (eg. All items are selected, then you deselect items)
|
|
182
188
|
* @returns Returns a `in` or `notIn` FilterCondition as necessary, or null if no filtering should be applied (everything selected)
|
|
183
189
|
*/
|
|
184
|
-
static makeSelectValueFilter(column: Column, selectedValues:
|
|
190
|
+
static makeSelectValueFilter(column: Column, selectedValues: unknown[], invertSelection: boolean): FilterCondition | null;
|
|
185
191
|
static isTreeTable(table: unknown): table is TreeTable;
|
|
186
192
|
/**
|
|
187
193
|
* Copies the provided array, sorts by column name case insensitive, and returns the sorted array.
|
package/dist/TableUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableUtils.d.ts","sourceRoot":"","sources":["../src/TableUtils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"TableUtils.d.ts","sourceRoot":"","sources":["../src/TableUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,IAAI,eAAe,EAC5B,aAAa,IAAI,mBAAmB,EACrC,MAAM,oBAAoB,CAAC;AAE5B,OAAW,EACT,MAAM,EACN,eAAe,EACf,WAAW,EACX,WAAW,EAEX,IAAI,EACJ,KAAK,EACL,SAAS,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAK1B,aAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5B,oBAAY,QAAQ,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC1D,oBAAY,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACpE,oBAAY,WAAW,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AACjE,oBAAY,sBAAsB,GAAG;IACnC,YAAY,EAAE,eAAe,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,eAAe,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,qBAAq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AAS;IAQtD;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,UAAO,GAAG,MAAM,EAAE;CAOpE;AAED,eAAe,UAAU,CAAC"}
|
package/dist/TableUtils.js
CHANGED
|
@@ -73,15 +73,15 @@ export class TableUtils {
|
|
|
73
73
|
return [];
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
static getNextSort(
|
|
77
|
-
if (!
|
|
76
|
+
static getNextSort(columns, sorts, columnIndex) {
|
|
77
|
+
if (!columns || columnIndex < 0 || columnIndex >= columns.length) {
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
var sort = TableUtils.getSortForColumn(
|
|
81
|
+
var sort = TableUtils.getSortForColumn(sorts, columnIndex);
|
|
82
82
|
|
|
83
83
|
if (sort === null) {
|
|
84
|
-
return
|
|
84
|
+
return columns[columnIndex].sort().asc();
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
if (sort.direction === TableUtils.sortDirection.ascending) {
|
|
@@ -91,8 +91,8 @@ export class TableUtils {
|
|
|
91
91
|
return null;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
static makeColumnSort(
|
|
95
|
-
if (!
|
|
94
|
+
static makeColumnSort(columns, columnIndex, direction, isAbs) {
|
|
95
|
+
if (!columns || columnIndex < 0 || columnIndex >= columns.length) {
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -100,7 +100,7 @@ export class TableUtils {
|
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
var sort =
|
|
103
|
+
var sort = columns[columnIndex].sort();
|
|
104
104
|
|
|
105
105
|
switch (direction) {
|
|
106
106
|
case TableUtils.sortDirection.ascending:
|
|
@@ -124,30 +124,30 @@ export class TableUtils {
|
|
|
124
124
|
/**
|
|
125
125
|
* Toggles the sort for the specified column
|
|
126
126
|
* @param sorts The current sorts from IrisGrid.state
|
|
127
|
-
* @param
|
|
127
|
+
* @param columns The columns to apply the sort to
|
|
128
128
|
* @param columnIndex The column index to apply the sort to
|
|
129
129
|
* @param addToExisting Add this sort to the existing sort
|
|
130
130
|
*/
|
|
131
131
|
|
|
132
132
|
|
|
133
|
-
static toggleSortForColumn(sorts,
|
|
133
|
+
static toggleSortForColumn(sorts, columns, columnIndex) {
|
|
134
134
|
var addToExisting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
135
135
|
|
|
136
|
-
if (
|
|
136
|
+
if (columnIndex < 0 || columnIndex >= columns.length) {
|
|
137
137
|
return [];
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
var newSort = TableUtils.getNextSort(
|
|
140
|
+
var newSort = TableUtils.getNextSort(columns, sorts, columnIndex);
|
|
141
141
|
return TableUtils.setSortForColumn(sorts, columnIndex, newSort, addToExisting);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
static sortColumn(
|
|
145
|
-
if (!
|
|
144
|
+
static sortColumn(sorts, columns, modelColumn, direction, isAbs, addToExisting) {
|
|
145
|
+
if (!sorts || modelColumn < 0 || modelColumn >= columns.length) {
|
|
146
146
|
return [];
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
var newSort = TableUtils.makeColumnSort(
|
|
150
|
-
return TableUtils.setSortForColumn(
|
|
149
|
+
var newSort = TableUtils.makeColumnSort(columns, modelColumn, direction, isAbs);
|
|
150
|
+
return TableUtils.setSortForColumn(sorts, modelColumn, newSort, addToExisting);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* Sets the sort for the given column *and* removes any reverses
|
|
@@ -227,7 +227,7 @@ export class TableUtils {
|
|
|
227
227
|
return TableUtils.dataType.INT;
|
|
228
228
|
|
|
229
229
|
default:
|
|
230
|
-
return
|
|
230
|
+
return TableUtils.dataType.UNKNOWN;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -413,7 +413,7 @@ export class TableUtils {
|
|
|
413
413
|
return this.makeQuickBooleanFilter(column, text);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
if (TableUtils.isDateType(type)) {
|
|
416
|
+
if (timeZone && TableUtils.isDateType(type)) {
|
|
417
417
|
return this.makeQuickDateFilter(column, text, timeZone);
|
|
418
418
|
}
|
|
419
419
|
|
|
@@ -991,6 +991,10 @@ export class TableUtils {
|
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
993
|
|
|
994
|
+
if (filter === null) {
|
|
995
|
+
throw new Error('filter is null');
|
|
996
|
+
}
|
|
997
|
+
|
|
994
998
|
return filter;
|
|
995
999
|
}
|
|
996
1000
|
|
|
@@ -1304,7 +1308,8 @@ _defineProperty(TableUtils, "dataType", {
|
|
|
1304
1308
|
DATETIME: 'datetime',
|
|
1305
1309
|
DECIMAL: 'decimal',
|
|
1306
1310
|
INT: 'int',
|
|
1307
|
-
STRING: 'string'
|
|
1311
|
+
STRING: 'string',
|
|
1312
|
+
UNKNOWN: 'unknown'
|
|
1308
1313
|
});
|
|
1309
1314
|
|
|
1310
1315
|
_defineProperty(TableUtils, "sortDirection", {
|