@deephaven/iris-grid 0.12.1-beta.5 → 0.13.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.
Files changed (161) hide show
  1. package/dist/AdvancedFilterCreator.d.ts +2 -2
  2. package/dist/AdvancedFilterCreator.d.ts.map +1 -1
  3. package/dist/AdvancedFilterCreator.js +2 -3
  4. package/dist/AdvancedFilterCreator.js.map +1 -1
  5. package/dist/AdvancedFilterCreatorFilterItem.d.ts +5 -11
  6. package/dist/AdvancedFilterCreatorFilterItem.d.ts.map +1 -1
  7. package/dist/AdvancedFilterCreatorFilterItem.js +21 -121
  8. package/dist/AdvancedFilterCreatorFilterItem.js.map +1 -1
  9. package/dist/AdvancedFilterCreatorSelectValue.d.ts +1 -1
  10. package/dist/AdvancedFilterCreatorSelectValue.d.ts.map +1 -1
  11. package/dist/AdvancedFilterCreatorSelectValue.js +1 -2
  12. package/dist/AdvancedFilterCreatorSelectValue.js.map +1 -1
  13. package/dist/AdvancedFilterCreatorSelectValueList.d.ts +1 -1
  14. package/dist/AdvancedFilterCreatorSelectValueList.js +1 -1
  15. package/dist/AdvancedFilterCreatorSelectValueList.js.map +1 -1
  16. package/dist/CrossColumnSearch.js +1 -1
  17. package/dist/CrossColumnSearch.js.map +1 -1
  18. package/dist/IrisGrid.d.ts.map +1 -1
  19. package/dist/IrisGrid.js +1 -4
  20. package/dist/IrisGrid.js.map +1 -1
  21. package/dist/IrisGridMetricCalculator.js +1 -1
  22. package/dist/IrisGridMetricCalculator.js.map +1 -1
  23. package/dist/IrisGridModel.d.ts +1 -1
  24. package/dist/IrisGridModel.d.ts.map +1 -1
  25. package/dist/IrisGridModel.js.map +1 -1
  26. package/dist/IrisGridModelFactory.d.ts +1 -1
  27. package/dist/IrisGridModelFactory.js +1 -1
  28. package/dist/IrisGridModelFactory.js.map +1 -1
  29. package/dist/IrisGridModelUpdater.d.ts +1 -2
  30. package/dist/IrisGridModelUpdater.d.ts.map +1 -1
  31. package/dist/IrisGridModelUpdater.js +1 -1
  32. package/dist/IrisGridModelUpdater.js.map +1 -1
  33. package/dist/IrisGridProxyModel.d.ts +1 -1
  34. package/dist/IrisGridProxyModel.d.ts.map +1 -1
  35. package/dist/IrisGridProxyModel.js +1 -2
  36. package/dist/IrisGridProxyModel.js.map +1 -1
  37. package/dist/IrisGridRenderer.js +1 -1
  38. package/dist/IrisGridRenderer.js.map +1 -1
  39. package/dist/IrisGridTableModel.d.ts +2 -2
  40. package/dist/IrisGridTableModel.d.ts.map +1 -1
  41. package/dist/IrisGridTableModel.js +1 -3
  42. package/dist/IrisGridTableModel.js.map +1 -1
  43. package/dist/IrisGridTestUtils.d.ts +1 -1
  44. package/dist/IrisGridTestUtils.js +1 -1
  45. package/dist/IrisGridTestUtils.js.map +1 -1
  46. package/dist/IrisGridUtils.d.ts.map +1 -1
  47. package/dist/IrisGridUtils.js +1 -2
  48. package/dist/IrisGridUtils.js.map +1 -1
  49. package/dist/format-context-menus/DateTimeFormatContextMenu.d.ts +1 -2
  50. package/dist/format-context-menus/DateTimeFormatContextMenu.d.ts.map +1 -1
  51. package/dist/format-context-menus/DateTimeFormatContextMenu.js +1 -2
  52. package/dist/format-context-menus/DateTimeFormatContextMenu.js.map +1 -1
  53. package/dist/format-context-menus/DecimalFormatContextMenu.d.ts +1 -1
  54. package/dist/format-context-menus/DecimalFormatContextMenu.d.ts.map +1 -1
  55. package/dist/format-context-menus/DecimalFormatContextMenu.js +1 -1
  56. package/dist/format-context-menus/DecimalFormatContextMenu.js.map +1 -1
  57. package/dist/format-context-menus/FormatContextMenuUtils.d.ts +1 -1
  58. package/dist/format-context-menus/FormatContextMenuUtils.d.ts.map +1 -1
  59. package/dist/format-context-menus/FormatContextMenuUtils.js +1 -1
  60. package/dist/format-context-menus/FormatContextMenuUtils.js.map +1 -1
  61. package/dist/format-context-menus/IntegerFormatContextMenu.d.ts +1 -1
  62. package/dist/format-context-menus/IntegerFormatContextMenu.d.ts.map +1 -1
  63. package/dist/format-context-menus/IntegerFormatContextMenu.js +1 -1
  64. package/dist/format-context-menus/IntegerFormatContextMenu.js.map +1 -1
  65. package/dist/index.d.ts +1 -5
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -5
  68. package/dist/index.js.map +1 -1
  69. package/dist/key-handlers/ReverseKeyHandler.d.ts.map +1 -1
  70. package/dist/key-handlers/ReverseKeyHandler.js +1 -1
  71. package/dist/key-handlers/ReverseKeyHandler.js.map +1 -1
  72. package/dist/mousehandlers/IrisGridContextMenuHandler.d.ts +1 -1
  73. package/dist/mousehandlers/IrisGridContextMenuHandler.d.ts.map +1 -1
  74. package/dist/mousehandlers/IrisGridContextMenuHandler.js +1 -2
  75. package/dist/mousehandlers/IrisGridContextMenuHandler.js.map +1 -1
  76. package/dist/sidebar/RollupRows.js +1 -1
  77. package/dist/sidebar/RollupRows.js.map +1 -1
  78. package/dist/sidebar/TableSaver.d.ts +2 -2
  79. package/dist/sidebar/TableSaver.d.ts.map +1 -1
  80. package/dist/sidebar/TableSaver.js +1 -2
  81. package/dist/sidebar/TableSaver.js.map +1 -1
  82. package/dist/sidebar/aggregations/AggregationEdit.d.ts.map +1 -1
  83. package/dist/sidebar/aggregations/AggregationEdit.js +1 -1
  84. package/dist/sidebar/aggregations/AggregationEdit.js.map +1 -1
  85. package/dist/sidebar/aggregations/AggregationUtils.js +1 -1
  86. package/dist/sidebar/aggregations/AggregationUtils.js.map +1 -1
  87. package/dist/sidebar/conditional-formatting/ConditionEditor.js +1 -1
  88. package/dist/sidebar/conditional-formatting/ConditionEditor.js.map +1 -1
  89. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts.map +1 -1
  90. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js +1 -1
  91. package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js.map +1 -1
  92. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js +1 -1
  93. package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js.map +1 -1
  94. package/dist/sidebar/index.d.ts +2 -1
  95. package/dist/sidebar/index.js +2 -1
  96. package/dist/sidebar/index.js.map +1 -1
  97. package/package.json +15 -14
  98. package/dist/DateUtils.d.ts +0 -82
  99. package/dist/DateUtils.d.ts.map +0 -1
  100. package/dist/DateUtils.js +0 -285
  101. package/dist/DateUtils.js.map +0 -1
  102. package/dist/Formatter.d.ts +0 -65
  103. package/dist/Formatter.d.ts.map +0 -1
  104. package/dist/Formatter.js +0 -169
  105. package/dist/Formatter.js.map +0 -1
  106. package/dist/FormatterUtils.d.ts +0 -24
  107. package/dist/FormatterUtils.d.ts.map +0 -1
  108. package/dist/FormatterUtils.js +0 -42
  109. package/dist/FormatterUtils.js.map +0 -1
  110. package/dist/TableUtils.d.ts +0 -191
  111. package/dist/TableUtils.d.ts.map +0 -1
  112. package/dist/TableUtils.js +0 -1326
  113. package/dist/TableUtils.js.map +0 -1
  114. package/dist/filters/FilterOperator.d.ts +0 -3
  115. package/dist/filters/FilterOperator.d.ts.map +0 -1
  116. package/dist/filters/FilterOperator.js +0 -2
  117. package/dist/filters/FilterOperator.js.map +0 -1
  118. package/dist/filters/FilterType.d.ts +0 -3
  119. package/dist/filters/FilterType.d.ts.map +0 -1
  120. package/dist/filters/FilterType.js +0 -2
  121. package/dist/filters/FilterType.js.map +0 -1
  122. package/dist/filters/index.d.ts +0 -3
  123. package/dist/filters/index.d.ts.map +0 -1
  124. package/dist/filters/index.js +0 -3
  125. package/dist/filters/index.js.map +0 -1
  126. package/dist/formatters/BooleanColumnFormatter.d.ts +0 -7
  127. package/dist/formatters/BooleanColumnFormatter.d.ts.map +0 -1
  128. package/dist/formatters/BooleanColumnFormatter.js +0 -26
  129. package/dist/formatters/BooleanColumnFormatter.js.map +0 -1
  130. package/dist/formatters/CharColumnFormatter.d.ts +0 -7
  131. package/dist/formatters/CharColumnFormatter.d.ts.map +0 -1
  132. package/dist/formatters/CharColumnFormatter.js +0 -15
  133. package/dist/formatters/CharColumnFormatter.js.map +0 -1
  134. package/dist/formatters/DateTimeColumnFormatter.d.ts +0 -40
  135. package/dist/formatters/DateTimeColumnFormatter.d.ts.map +0 -1
  136. package/dist/formatters/DateTimeColumnFormatter.js +0 -123
  137. package/dist/formatters/DateTimeColumnFormatter.js.map +0 -1
  138. package/dist/formatters/DecimalColumnFormatter.d.ts +0 -64
  139. package/dist/formatters/DecimalColumnFormatter.d.ts.map +0 -1
  140. package/dist/formatters/DecimalColumnFormatter.js +0 -128
  141. package/dist/formatters/DecimalColumnFormatter.js.map +0 -1
  142. package/dist/formatters/DefaultColumnFormatter.d.ts +0 -6
  143. package/dist/formatters/DefaultColumnFormatter.d.ts.map +0 -1
  144. package/dist/formatters/DefaultColumnFormatter.js +0 -14
  145. package/dist/formatters/DefaultColumnFormatter.js.map +0 -1
  146. package/dist/formatters/IntegerColumnFormatter.d.ts +0 -60
  147. package/dist/formatters/IntegerColumnFormatter.d.ts.map +0 -1
  148. package/dist/formatters/IntegerColumnFormatter.js +0 -121
  149. package/dist/formatters/IntegerColumnFormatter.js.map +0 -1
  150. package/dist/formatters/StringColumnFormatter.d.ts +0 -7
  151. package/dist/formatters/StringColumnFormatter.d.ts.map +0 -1
  152. package/dist/formatters/StringColumnFormatter.js +0 -13
  153. package/dist/formatters/StringColumnFormatter.js.map +0 -1
  154. package/dist/formatters/TableColumnFormatter.d.ts +0 -44
  155. package/dist/formatters/TableColumnFormatter.d.ts.map +0 -1
  156. package/dist/formatters/TableColumnFormatter.js +0 -65
  157. package/dist/formatters/TableColumnFormatter.js.map +0 -1
  158. package/dist/formatters/index.d.ts +0 -9
  159. package/dist/formatters/index.d.ts.map +0 -1
  160. package/dist/formatters/index.js +0 -9
  161. package/dist/formatters/index.js.map +0 -1
package/dist/DateUtils.js DELETED
@@ -1,285 +0,0 @@
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 dh from '@deephaven/jsapi-shim';
4
-
5
- class DateUtils {
6
- /**
7
- *
8
- * @param timeZone The time zone to parse this time in. E.g. America/New_York
9
- * @param year The year for the date
10
- * @param month The month, starting at 0
11
- * @param day The day, starting at 1
12
- * @param hour The hours
13
- * @param minute The minutes
14
- * @param second The seconds
15
- * @param ns The nanoseconds
16
- */
17
- static makeDateWrapper(timeZone, year) {
18
- var month = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
19
- var day = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
20
- var hour = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
21
- var minute = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
22
- var second = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
23
- var ns = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
24
- var yearString = "".concat(year).padStart(4, '0');
25
- var monthString = "".concat(month + 1).padStart(2, '0');
26
- var dayString = "".concat(day).padStart(2, '0');
27
- var hourString = "".concat(hour).padStart(2, '0');
28
- var minuteString = "".concat(minute).padStart(2, '0');
29
- var secondString = "".concat(second).padStart(2, '0');
30
- var nanoString = "".concat(ns).padStart(9, '0');
31
- var dateString = "".concat(yearString, "-").concat(monthString, "-").concat(dayString, " ").concat(hourString, ":").concat(minuteString, ":").concat(secondString, ".").concat(nanoString);
32
- return dh.i18n.DateTimeFormat.parse(DateUtils.FULL_DATE_FORMAT, dateString, dh.i18n.TimeZone.getTimeZone(timeZone));
33
- }
34
- /**
35
- * Takes the string the user entered and returns the next nanos value
36
- * @param nanoString The nano string to get the next one of
37
- * @returns The value of the next nanos
38
- */
39
-
40
-
41
- static getNextNanos(nanoString) {
42
- var sigNanos = parseInt(nanoString, 10); // Get the zeroes needed for padding before adding one so we handle overflow properly.
43
-
44
- var zeros = '0'.repeat(9 - nanoString.length);
45
- var nextNanoString = "".concat(sigNanos + 1).concat(zeros);
46
- return parseInt(nextNanoString, 10);
47
- }
48
- /**
49
- * @param components The string components that were parsed from the original string
50
- * @param values The values that were parsed from the components
51
- * @param timeZone The time zone to parse the date in. E.g. America/New_York
52
- * @returns Returns the DateWrapper for the next date, or null if a full date was passed in
53
- */
54
-
55
-
56
- static getNextDate(components, values, timeZone) {
57
- var {
58
- year,
59
- month,
60
- date,
61
- hours,
62
- minutes,
63
- seconds,
64
- nanos
65
- } = values;
66
-
67
- if (components.nanos != null) {
68
- if (components.nanos.length === 9) {
69
- // They want an exact match
70
- return null;
71
- }
72
-
73
- nanos = DateUtils.getNextNanos(components.nanos);
74
-
75
- if (nanos > 999999999) {
76
- // There's an overflow, add it to the seconds manually
77
- seconds += 1;
78
- nanos = 0;
79
- }
80
- } else if (components.seconds != null) {
81
- seconds += 1;
82
- } else if (components.minutes != null) {
83
- minutes += 1;
84
- } else if (components.hours != null) {
85
- hours += 1;
86
- } else if (components.date != null) {
87
- date += 1;
88
- } else if (components.month != null) {
89
- month += 1;
90
- } else {
91
- year += 1;
92
- } // Use the JS date to handle overflow rather than doing our own logic
93
- // Because handling leap years and stuff is a pain
94
- // Still need to add nanos after, and the overflow from that is already added to seconds above
95
-
96
-
97
- var jsDate = new Date(year, month, date, hours, minutes, seconds);
98
- return DateUtils.makeDateWrapper(timeZone, jsDate.getFullYear(), jsDate.getMonth(), jsDate.getDate(), jsDate.getHours(), jsDate.getMinutes(), jsDate.getSeconds(), nanos);
99
- }
100
- /**
101
- * Get the JS month value for the provided string.
102
- * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)
103
- * @param monthString The string to parse to a JS month value
104
- * @returns number The JS month value, which starts at 0 for january, or NaN if nothing could be parsed
105
- */
106
-
107
-
108
- static parseMonth(monthString) {
109
- var month = parseInt(monthString, 10);
110
-
111
- if (!Number.isNaN(month)) {
112
- if (month >= 1 && month <= 12) {
113
- return month - 1;
114
- }
115
-
116
- return NaN;
117
- }
118
-
119
- var cleanMonthString = monthString.trim().toLowerCase();
120
-
121
- if (cleanMonthString.length >= 3) {
122
- for (var i = 0; i < DateUtils.months.length; i += 1) {
123
- if (DateUtils.months[i].startsWith(cleanMonthString)) {
124
- return i;
125
- }
126
- }
127
- }
128
-
129
- return NaN;
130
- }
131
- /**
132
- * Parse a date object out of the provided string segments.
133
- * Also using `parseMonth` to get month names like Aug/August rather than
134
- * simply doing `parseInt`.
135
- * @param yearString The year part of the string
136
- * @param monthString The month part of the string
137
- * @param dayString The day part of the string
138
- * @param hourString The hour part of the string
139
- * @param minuteString The minute part of the string
140
- * @param secondString The second part of the string
141
- * @param nanoString The milli part of the string
142
- */
143
-
144
-
145
- static parseDateValues(yearString, monthString, dayString, hourString, minuteString, secondString, nanoString) {
146
- var year = parseInt(yearString, 10);
147
- var month = monthString != null ? this.parseMonth(monthString) : 0;
148
- var date = dayString != null ? parseInt(dayString, 10) : 1;
149
- var hours = hourString != null ? parseInt(hourString, 10) : 0;
150
- var minutes = minuteString != null ? parseInt(minuteString, 10) : 0;
151
- var seconds = secondString != null ? parseInt(secondString, 10) : 0;
152
- var nanos = nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;
153
-
154
- if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(date) || Number.isNaN(hours) || Number.isNaN(minutes) || Number.isNaN(seconds) || Number.isNaN(nanos)) {
155
- return null;
156
- }
157
-
158
- return {
159
- year,
160
- month,
161
- date,
162
- hours,
163
- minutes,
164
- seconds,
165
- nanos
166
- };
167
- }
168
- /**
169
- * Parse out a date time string into it's string components.
170
- * Anything that is not captured in the string will be undefined.
171
- *
172
- * @param dateTimeString The date time string to parse
173
- * @returns Containing the date time components
174
- */
175
-
176
-
177
- static parseDateTimeString(dateTimeString) {
178
- var regex = /\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/;
179
- var result = regex.exec(dateTimeString);
180
-
181
- if (result == null) {
182
- throw new Error("Unexpected date string: ".concat(dateTimeString));
183
- }
184
-
185
- var [, year,, month,, date,, hours,, minutes,, seconds,, nanos, overflow] = result;
186
-
187
- if (overflow != null && overflow.length > 0) {
188
- throw new Error("Unexpected characters after date string '".concat(dateTimeString, "': ").concat(overflow));
189
- }
190
-
191
- return {
192
- year,
193
- month,
194
- date,
195
- hours,
196
- minutes,
197
- seconds,
198
- nanos
199
- };
200
- }
201
- /**
202
- * Parses the date range provided from a string of text.
203
- * @param text The string to parse the date from. Can be a keyword like "today", or in the format "2018-08-04"
204
- * @param timeZone The time zone to parse this range in. E.g. America/New_York
205
- * @returns A tuple with the start and end value/null for that date range, or both null
206
- */
207
-
208
-
209
- static parseDateRange(text, timeZone) {
210
- var cleanText = text.trim().toLowerCase();
211
-
212
- if (cleanText.length === 0) {
213
- throw new Error('Cannot parse date range from empty string');
214
- }
215
-
216
- if (cleanText === 'null') {
217
- return [null, null];
218
- }
219
-
220
- if (cleanText === 'today') {
221
- var now = new Date(Date.now());
222
-
223
- var _startDate = DateUtils.makeDateWrapper(timeZone, now.getFullYear(), now.getMonth(), now.getDate());
224
-
225
- var _endDate = DateUtils.makeDateWrapper(timeZone, now.getFullYear(), now.getMonth(), now.getDate() + 1);
226
-
227
- return [_startDate, _endDate];
228
- }
229
-
230
- if (cleanText === 'yesterday') {
231
- var _now = new Date(Date.now());
232
-
233
- var _startDate2 = DateUtils.makeDateWrapper(timeZone, _now.getFullYear(), _now.getMonth(), _now.getDate() - 1);
234
-
235
- var _endDate2 = DateUtils.makeDateWrapper(timeZone, _now.getFullYear(), _now.getMonth(), _now.getDate());
236
-
237
- return [_startDate2, _endDate2];
238
- }
239
-
240
- if (cleanText === 'now') {
241
- var _now2 = new Date(Date.now());
242
-
243
- var date = dh.DateWrapper.ofJsDate(_now2);
244
- return [date, null];
245
- }
246
-
247
- var components = DateUtils.parseDateTimeString(cleanText);
248
-
249
- if (components.year == null && components.month == null && components.date == null) {
250
- throw new Error("Unable to extract year, month, or day ".concat(cleanText));
251
- }
252
-
253
- var values = DateUtils.parseDateValues(components.year, components.month, components.date, components.hours, components.minutes, components.seconds, components.nanos);
254
-
255
- if (values == null) {
256
- throw new Error("Unable to extract date values from ".concat(components));
257
- }
258
-
259
- var startDate = DateUtils.makeDateWrapper(timeZone, values.year, values.month, values.date, values.hours, values.minutes, values.seconds, values.nanos);
260
- var endDate = DateUtils.getNextDate(components, values, timeZone);
261
- return [startDate, endDate];
262
- }
263
- /**
264
- * Gets the Js Date object from the provided DateWrapper.
265
- * In unit test, DateWrapper is just a number provided in millis, so handles that case.
266
- * @param dateWrapper The DateWrapper object, or time in millis
267
- */
268
-
269
-
270
- static getJsDate(dateWrapper) {
271
- if (typeof dateWrapper === 'number') {
272
- return new Date(dateWrapper);
273
- }
274
-
275
- return dateWrapper.asDate();
276
- }
277
-
278
- }
279
-
280
- _defineProperty(DateUtils, "FULL_DATE_FORMAT", 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS');
281
-
282
- _defineProperty(DateUtils, "months", ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']);
283
-
284
- export default DateUtils;
285
- //# sourceMappingURL=DateUtils.js.map
@@ -1 +0,0 @@
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,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EAOhBH,MAAM,CAACI,OAPS,EAQhBJ,MAAM,CAACK,KARS,CAAlB;AAWA,QAAMiC,OAAO,GAAGxE,SAAS,CAACgC,WAAV,CAAsBC,UAAtB,EAAkCC,MAAlC,EAA0ChC,QAA1C,CAAhB;AACA,WAAO,CAACqE,SAAD,EAAYC,OAAZ,CAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;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"}
@@ -1,65 +0,0 @@
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
- }
9
- declare class Formatter {
10
- /**
11
- * Converts FormattingRule[] to Map
12
- * @param columnFormattingRules Array or column formatting rules
13
- * @returns Map of columnName-to-format Maps indexed by normalized dataType
14
- */
15
- static makeColumnFormatMap(columnFormattingRules: FormattingRule[]): Map<DataType, Map<ColumnName, TableColumnFormat>>;
16
- /**
17
- * Creates a column formatting rule
18
- * @param columnType Normalized data type
19
- * @param columnName Column name
20
- * @param format Format object
21
- */
22
- static makeColumnFormattingRule(columnType: DataType, columnName: string, format: TableColumnFormat): FormattingRule;
23
- /**
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
28
- * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
29
- */
30
- constructor(columnFormattingRules?: FormattingRule[], dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[0], decimalFormatOptions?: ConstructorParameters<typeof DecimalColumnFormatter>[0], integerFormatOptions?: ConstructorParameters<typeof IntegerColumnFormatter>[0], truncateNumbersWithPound?: boolean);
31
- defaultColumnFormatter: TableColumnFormatter;
32
- typeFormatterMap: Map<DataType, TableColumnFormatter>;
33
- columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;
34
- truncateNumbersWithPound: boolean;
35
- /**
36
- * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
37
- * @param columnType column type
38
- * @param createIfNecessary create new entry if true
39
- * @returns Map of format strings indexed by column name or undefined if it doesn't exist
40
- */
41
- getColumnFormatMapForType(columnType: string, createIfNecessary?: boolean): Map<string, TableColumnFormat> | undefined;
42
- /**
43
- * Gets a column format object for a given column type and name
44
- * @param columnType column type
45
- * @param columnName column name
46
- * @returns format object or null for Default
47
- */
48
- getColumnFormat(columnType: string, columnName: string): TableColumnFormat | null;
49
- getColumnTypeFormatter(columnType: string): TableColumnFormatter;
50
- /**
51
- * Gets formatted string for a given value, column type and name
52
- * @param value Value to format
53
- * @param columnType Column type used to determine the formatting settings
54
- * @param columnName Column name used to determine the formatting settings
55
- * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
56
- */
57
- getFormattedString(value: unknown, columnType: string, columnName?: string, formatOverride?: TableColumnFormat): string;
58
- /**
59
- * Gets the timeZone name
60
- * @returns The time zone name E.g. America/New_York
61
- */
62
- get timeZone(): string;
63
- }
64
- export default Formatter;
65
- //# sourceMappingURL=Formatter.d.ts.map
@@ -1 +0,0 @@
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,EACtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAGtB,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;;;;;;OAMG;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,EACJ,wBAAwB,UAAQ;IAiClC,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,wBAAwB,EAAE,OAAO,CAAC;IAElC;;;;;OAKG;IACH,yBAAyB,CACvB,UAAU,EAAE,MAAM,EAClB,iBAAiB,UAAQ,GACxB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAY7C;;;;;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 DELETED
@@ -1,169 +0,0 @@
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 TableUtils from "./TableUtils.js";
4
- import { BooleanColumnFormatter, CharColumnFormatter, DateTimeColumnFormatter, DecimalColumnFormatter, DefaultColumnFormatter, IntegerColumnFormatter } from "./formatters/index.js";
5
- import StringColumnFormatter from "./formatters/StringColumnFormatter.js";
6
-
7
- class Formatter {
8
- /**
9
- * Converts FormattingRule[] to Map
10
- * @param columnFormattingRules Array or column formatting rules
11
- * @returns Map of columnName-to-format Maps indexed by normalized dataType
12
- */
13
- static makeColumnFormatMap(columnFormattingRules) {
14
- if (columnFormattingRules == null) {
15
- return new Map();
16
- }
17
-
18
- return columnFormattingRules.reduce((map, next) => {
19
- var dataType = TableUtils.getNormalizedType(next.columnType);
20
-
21
- if (dataType === null) {
22
- return map;
23
- }
24
-
25
- if (!map.has(dataType)) {
26
- map.set(dataType, new Map());
27
- }
28
-
29
- var formatMap = map.get(dataType);
30
- formatMap === null || formatMap === void 0 ? void 0 : formatMap.set(next.columnName, next.format);
31
- return map;
32
- }, new Map());
33
- }
34
- /**
35
- * Creates a column formatting rule
36
- * @param columnType Normalized data type
37
- * @param columnName Column name
38
- * @param format Format object
39
- */
40
-
41
-
42
- static makeColumnFormattingRule(columnType, columnName, format) {
43
- return {
44
- columnType,
45
- columnName,
46
- format
47
- };
48
- }
49
- /**
50
- * @param columnFormattingRules Optional array of column formatting rules
51
- * @param dateTimeOptions Optional object with DateTime configuration
52
- * @param decimalFormatOptions Optional object with Decimal configuration
53
- * @param integerFormatOptions Optional object with Integer configuration
54
- * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
55
- */
56
-
57
-
58
- constructor() {
59
- var columnFormattingRules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
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
- var truncateNumbersWithPound = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
64
-
65
- _defineProperty(this, "defaultColumnFormatter", void 0);
66
-
67
- _defineProperty(this, "typeFormatterMap", void 0);
68
-
69
- _defineProperty(this, "columnFormatMap", void 0);
70
-
71
- _defineProperty(this, "truncateNumbersWithPound", void 0);
72
-
73
- // Formatting order:
74
- // - columnFormatMap[type][name]
75
- // - typeFormatterMap[type]
76
- // - defaultColumnFormatter
77
- this.defaultColumnFormatter = new DefaultColumnFormatter(); // Default formatters by data type
78
-
79
- 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)], [TableUtils.dataType.STRING, new StringColumnFormatter()]]); // Formats indexed by data type and column name
80
-
81
- this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);
82
- this.truncateNumbersWithPound = truncateNumbersWithPound;
83
- }
84
-
85
- /**
86
- * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
87
- * @param columnType column type
88
- * @param createIfNecessary create new entry if true
89
- * @returns Map of format strings indexed by column name or undefined if it doesn't exist
90
- */
91
- getColumnFormatMapForType(columnType) {
92
- var createIfNecessary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
93
- var dataType = TableUtils.getNormalizedType(columnType);
94
-
95
- if (dataType === null) {
96
- return undefined;
97
- }
98
-
99
- if (createIfNecessary && !this.columnFormatMap.has(dataType)) {
100
- this.columnFormatMap.set(dataType, new Map());
101
- }
102
-
103
- return this.columnFormatMap.get(dataType);
104
- }
105
- /**
106
- * Gets a column format object for a given column type and name
107
- * @param columnType column type
108
- * @param columnName column name
109
- * @returns format object or null for Default
110
- */
111
-
112
-
113
- getColumnFormat(columnType, columnName) {
114
- var _columnFormatMap$get;
115
-
116
- var columnFormatMap = this.getColumnFormatMapForType(columnType);
117
- return (_columnFormatMap$get = columnFormatMap === null || columnFormatMap === void 0 ? void 0 : columnFormatMap.get(columnName)) !== null && _columnFormatMap$get !== void 0 ? _columnFormatMap$get : null;
118
- }
119
-
120
- getColumnTypeFormatter(columnType) {
121
- var dataType = TableUtils.getNormalizedType(columnType);
122
- var columnTypeFormatter = this.defaultColumnFormatter;
123
-
124
- if (dataType) {
125
- var _this$typeFormatterMa;
126
-
127
- columnTypeFormatter = (_this$typeFormatterMa = this.typeFormatterMap.get(dataType)) !== null && _this$typeFormatterMa !== void 0 ? _this$typeFormatterMa : columnTypeFormatter;
128
- }
129
-
130
- return columnTypeFormatter;
131
- }
132
- /**
133
- * Gets formatted string for a given value, column type and name
134
- * @param value Value to format
135
- * @param columnType Column type used to determine the formatting settings
136
- * @param columnName Column name used to determine the formatting settings
137
- * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
138
- */
139
-
140
-
141
- getFormattedString(value, columnType) {
142
- var columnName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
143
- var formatOverride = arguments.length > 3 ? arguments[3] : undefined;
144
-
145
- if (value == null) {
146
- return '';
147
- }
148
-
149
- var formatter = this.getColumnTypeFormatter(columnType);
150
- var format = formatOverride || this.getColumnFormat(columnType, columnName);
151
- return formatter.format(value, format !== null && format !== void 0 ? format : undefined);
152
- }
153
- /**
154
- * Gets the timeZone name
155
- * @returns The time zone name E.g. America/New_York
156
- */
157
-
158
-
159
- get timeZone() {
160
- var _formatter$dhTimeZone;
161
-
162
- var formatter = this.typeFormatterMap.get(TableUtils.dataType.DATETIME);
163
- return formatter === null || formatter === void 0 ? void 0 : (_formatter$dhTimeZone = formatter.dhTimeZone) === null || _formatter$dhTimeZone === void 0 ? void 0 : _formatter$dhTimeZone.id;
164
- }
165
-
166
- }
167
-
168
- export default Formatter;
169
- //# sourceMappingURL=Formatter.js.map
@@ -1 +0,0 @@
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,s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;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;;AApLa;;AAuLhB,eAAe3C,SAAf","sourcesContent":["import TableUtils, { DataType } from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n TableColumnFormat,\n TableColumnFormatter,\n} from './formatters';\nimport StringColumnFormatter from './formatters/StringColumnFormatter';\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 * @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,24 +0,0 @@
1
- import type { FormattingRule } from './Formatter';
2
- import Formatter from './Formatter';
3
- import { DateTimeColumnFormatter } from './formatters';
4
- declare class FormatterUtils {
5
- static getColumnFormats(settings: {
6
- formatter: FormattingRule[];
7
- }): FormattingRule[];
8
- static getDateTimeFormatterOptions(settings: {
9
- timeZone: string;
10
- defaultDateTimeFormat: string;
11
- showTimeZone: boolean;
12
- showTSeparator: boolean;
13
- }): Required<ConstructorParameters<typeof DateTimeColumnFormatter>[0]>;
14
- /**
15
- * Check if the formatter has a custom format defined for the column name and type
16
- * @param formatter Formatter to check
17
- * @param columnName Column name
18
- * @param columnType Column type
19
- * @returns True, if a custom format is defined
20
- */
21
- static isCustomColumnFormatDefined(formatter: Formatter, columnName: string, columnType: string): boolean;
22
- }
23
- export default FormatterUtils;
24
- //# sourceMappingURL=FormatterUtils.d.ts.map
@@ -1 +0,0 @@
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,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;IAetE;;;;;;OAMG;IACH,MAAM,CAAC,2BAA2B,CAChC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO;CAQX;AAED,eAAe,cAAc,CAAC"}