autoql-fe-utils 1.8.2 → 1.8.4

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/index.d.mts CHANGED
@@ -1141,7 +1141,7 @@ declare const formatQueryColumns: ({ columns, aggConfig, queryResponse, onTableH
1141
1141
  enableTableSorting?: boolean;
1142
1142
  dataFormatting?: DataFormatting;
1143
1143
  }) => Column[] | undefined;
1144
- declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, includeNumerics?: boolean) => {
1144
+ declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, includeNumerics?: boolean, defaultDateColumn?: string) => {
1145
1145
  stringColumnIndices: any;
1146
1146
  stringColumnIndex: any;
1147
1147
  legendColumnIndex?: undefined;
@@ -1150,7 +1150,7 @@ declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, in
1150
1150
  stringColumnIndices: any;
1151
1151
  legendColumnIndex: any;
1152
1152
  };
1153
- declare const getNumberColumnIndices: (columns: any, isPivot?: any) => {
1153
+ declare const getNumberColumnIndices: (columns: any, isPivot?: any, defaultAmountColumn?: string) => {
1154
1154
  numberColumnIndex: any;
1155
1155
  numberColumnIndices: any;
1156
1156
  numberColumnIndices2: any;
package/dist/index.d.ts CHANGED
@@ -1141,7 +1141,7 @@ declare const formatQueryColumns: ({ columns, aggConfig, queryResponse, onTableH
1141
1141
  enableTableSorting?: boolean;
1142
1142
  dataFormatting?: DataFormatting;
1143
1143
  }) => Column[] | undefined;
1144
- declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, includeNumerics?: boolean) => {
1144
+ declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, includeNumerics?: boolean, defaultDateColumn?: string) => {
1145
1145
  stringColumnIndices: any;
1146
1146
  stringColumnIndex: any;
1147
1147
  legendColumnIndex?: undefined;
@@ -1150,7 +1150,7 @@ declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, in
1150
1150
  stringColumnIndices: any;
1151
1151
  legendColumnIndex: any;
1152
1152
  };
1153
- declare const getNumberColumnIndices: (columns: any, isPivot?: any) => {
1153
+ declare const getNumberColumnIndices: (columns: any, isPivot?: any, defaultAmountColumn?: string) => {
1154
1154
  numberColumnIndex: any;
1155
1155
  numberColumnIndices: any;
1156
1156
  numberColumnIndices2: any;
@@ -17272,7 +17272,7 @@
17272
17272
  });
17273
17273
  return formattedColumns;
17274
17274
  };
17275
- var getStringColumnIndices = (columns, supportsPivot = false, includeNumerics = false) => {
17275
+ var getStringColumnIndices = (columns, supportsPivot = false, includeNumerics = false, defaultDateColumn) => {
17276
17276
  var _a, _b;
17277
17277
  if (!columns) {
17278
17278
  return void 0;
@@ -17292,7 +17292,16 @@
17292
17292
  stringColumnIndex: drilldownIndex
17293
17293
  };
17294
17294
  }
17295
- let stringColumnIndex = stringColumnIndices.find((index) => !isColumnNumberType(columns[index]));
17295
+ let stringColumnIndex;
17296
+ if (defaultDateColumn) {
17297
+ const defaultDateIndex = columns.findIndex((col) => col.name === defaultDateColumn && col.is_visible);
17298
+ if (defaultDateIndex >= 0 && stringColumnIndices.includes(defaultDateIndex)) {
17299
+ stringColumnIndex = defaultDateIndex;
17300
+ }
17301
+ }
17302
+ if (stringColumnIndex === void 0) {
17303
+ stringColumnIndex = stringColumnIndices.find((index) => !isColumnNumberType(columns[index]));
17304
+ }
17296
17305
  if (includeNumerics && stringColumnIndex == void 0) {
17297
17306
  const { numberColumnIndices, numberColumnIndices2 } = getNumberColumnIndices(columns);
17298
17307
  stringColumnIndex = (_a = stringColumnIndices.find(
@@ -17311,7 +17320,7 @@
17311
17320
  const legendColumnIndex = stringColumnIndices.find((i) => i !== stringColumnIndex);
17312
17321
  return { stringColumnIndex, stringColumnIndices, legendColumnIndex };
17313
17322
  };
17314
- var getNumberColumnIndices = (columns, isPivot) => {
17323
+ var getNumberColumnIndices = (columns, isPivot, defaultAmountColumn) => {
17315
17324
  let quantityColumnIndices = [];
17316
17325
  let currencyColumnIndices = [];
17317
17326
  let ratioColumnIndices = [];
@@ -17336,22 +17345,42 @@
17336
17345
  let numberColumnIndex2;
17337
17346
  let numberColumnIndices2 = [];
17338
17347
  let numberColumnIndexType;
17339
- if (currencyColumnIndices.length) {
17340
- numberColumnIndex = currencyColumnIndices[0];
17341
- numberColumnIndices = currencyColumnIndices;
17342
- numberColumnIndexType = "currency";
17343
- } else if (quantityColumnIndices.length) {
17344
- numberColumnIndex = quantityColumnIndices[0];
17345
- numberColumnIndices = quantityColumnIndices;
17346
- numberColumnIndexType = "quantity";
17347
- } else if (ratioColumnIndices.length) {
17348
- numberColumnIndex = ratioColumnIndices[0];
17349
- numberColumnIndices = ratioColumnIndices;
17350
- numberColumnIndexType = "ratio";
17351
- } else if (countColumnIndices.length) {
17352
- numberColumnIndex = countColumnIndices[0];
17353
- numberColumnIndices = countColumnIndices;
17354
- numberColumnIndexType = "count";
17348
+ if (defaultAmountColumn) {
17349
+ const defaultAmountIndex = columns.findIndex((col) => col.name === defaultAmountColumn && col.is_visible);
17350
+ if (defaultAmountIndex >= 0) {
17351
+ const col = columns[defaultAmountIndex];
17352
+ const { type } = col;
17353
+ numberColumnIndex = defaultAmountIndex;
17354
+ numberColumnIndices = [defaultAmountIndex];
17355
+ if (type === "DOLLAR_AMT") {
17356
+ numberColumnIndexType = "currency";
17357
+ } else if (type === "QUANTITY") {
17358
+ numberColumnIndexType = "quantity";
17359
+ } else if (type === "PERCENT" || type === "RATIO") {
17360
+ numberColumnIndexType = "ratio";
17361
+ } else {
17362
+ numberColumnIndexType = "count";
17363
+ }
17364
+ }
17365
+ }
17366
+ if (numberColumnIndex === void 0) {
17367
+ if (currencyColumnIndices.length) {
17368
+ numberColumnIndex = currencyColumnIndices[0];
17369
+ numberColumnIndices = currencyColumnIndices;
17370
+ numberColumnIndexType = "currency";
17371
+ } else if (quantityColumnIndices.length) {
17372
+ numberColumnIndex = quantityColumnIndices[0];
17373
+ numberColumnIndices = quantityColumnIndices;
17374
+ numberColumnIndexType = "quantity";
17375
+ } else if (ratioColumnIndices.length) {
17376
+ numberColumnIndex = ratioColumnIndices[0];
17377
+ numberColumnIndices = ratioColumnIndices;
17378
+ numberColumnIndexType = "ratio";
17379
+ } else if (countColumnIndices.length) {
17380
+ numberColumnIndex = countColumnIndices[0];
17381
+ numberColumnIndices = countColumnIndices;
17382
+ numberColumnIndexType = "count";
17383
+ }
17355
17384
  }
17356
17385
  if (!isPivot) {
17357
17386
  numberColumnIndices = numberColumnIndex >= 0 ? [numberColumnIndex] : [];