@cellaware/utils 8.6.21 → 8.6.22

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.
@@ -1,4 +1,4 @@
1
- import { isDateString } from "../util.js";
1
+ import { isDateString, truncateValue } from "../util.js";
2
2
  import { CHATWMS_DEFAULT_LANGUAGE } from "./user.js";
3
3
  export function initDatagridState() {
4
4
  return {
@@ -947,7 +947,7 @@ export function mapTeamsStyles(columnNames, htmlRowStyles, htmlColumnStyles, tea
947
947
  function buildHtmlTableHeader(columnNames) {
948
948
  let buf = '<table>\n\t<thead>\n\t\t<tr>';
949
949
  for (const columnName of columnNames) {
950
- buf += `\n\t\t\t<th>${columnName}</th>`;
950
+ buf += `\n\t\t\t<th>${truncateValue(columnName, 24)}</th>`;
951
951
  }
952
952
  buf += '\n\t\t</tr>\n\t</thead>';
953
953
  buf += '\n\t<tbody>';
@@ -971,11 +971,12 @@ function buildHtmlRow(rowValues, rowStyles, columnStyles, columnCount) {
971
971
  if (colIdx >= columnCount) {
972
972
  break;
973
973
  }
974
+ const truncValue = truncateValue(rowValue, 24);
974
975
  if (columnStyles[colIdx].styles.length > 0) {
975
- buf += `\n\t\t\t<td class="${columnStyles[colIdx].styles.join(' ')}">${rowValue}</td>`;
976
+ buf += `\n\t\t\t<td class="${columnStyles[colIdx].styles.join(' ')}">${truncValue}</td>`;
976
977
  }
977
978
  else {
978
- buf += `\n\t\t\t<td>${rowValue}</td>`;
979
+ buf += `\n\t\t\t<td>${truncValue}</td>`;
979
980
  }
980
981
  colIdx++;
981
982
  }
@@ -985,12 +986,9 @@ function buildHtmlRow(rowValues, rowStyles, columnStyles, columnCount) {
985
986
  function createTeamsTableColumnText(columnName) {
986
987
  return {
987
988
  type: "TextBlock",
988
- text: columnName,
989
+ text: truncateValue(columnName, 16),
989
990
  size: "Small",
990
- weight: "Bolder",
991
- wrap: false,
992
- maxLines: 1,
993
- spacing: "None"
991
+ weight: "Bolder"
994
992
  };
995
993
  }
996
994
  function createTeamsTableColumns(columnNames) {
@@ -1021,15 +1019,13 @@ function createTeamsTableCellText(value, columnStyle) {
1021
1019
  italic = styles.italic;
1022
1020
  }
1023
1021
  }
1022
+ const truncValue = truncateValue(value, 16);
1024
1023
  return {
1025
1024
  type: "TextBlock",
1026
- text: italic ? `*${value}*` : value,
1025
+ text: italic ? `*${truncValue}*` : truncValue,
1027
1026
  size: "Small",
1028
1027
  color,
1029
- weight: weight ?? "Default",
1030
- wrap: false,
1031
- maxLines: 1,
1032
- spacing: "None",
1028
+ weight,
1033
1029
  isSubtle
1034
1030
  };
1035
1031
  }
@@ -0,0 +1,5 @@
1
+ export interface SubscriptionIntegration {
2
+ vendor: 'teams' | 'slack';
3
+ type: 'webhook';
4
+ url: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -19,7 +19,6 @@ export declare function createTeamsTableCard(title: string, table: any[], summar
19
19
  type: string;
20
20
  roundedCorners: boolean;
21
21
  firstRowAsHeaders: boolean;
22
- columns: any;
23
22
  rows: any[];
24
23
  })[];
25
24
  };
@@ -27,7 +27,7 @@ export function createTeamsTableCard(title, table, summary) {
27
27
  type: "Table",
28
28
  roundedCorners: true,
29
29
  firstRowAsHeaders: true,
30
- columns: table.length === 0 ? [] : table[0].cells.map(() => ({ width: 3 })),
30
+ // columns: table.length === 0 ? [] : table[0].cells.map(() => ({ width: 3 })),
31
31
  rows: table
32
32
  },
33
33
  createTeamsSummaryItem(summary)
package/dist/util.d.ts CHANGED
@@ -7,6 +7,14 @@ export declare function reverse(str: string): string;
7
7
  export declare function base64Encode(str: string): string;
8
8
  export declare function base64Decode(str: string): string;
9
9
  export declare function isArrayLike(obj: any): boolean;
10
+ /**
11
+ * Default `idx` is 100.
12
+ */
13
+ export declare function truncateValue(value: string, idx?: number): string;
14
+ /**
15
+ * Default `idx` is 100.
16
+ */
17
+ export declare function truncateValuePreserveNewLines(value: string, idx?: number): string;
10
18
  export declare function initDate(timeZone?: string): Date;
11
19
  export declare function convertDateTimeZone(date: Date, timeZone: string): Date;
12
20
  export declare function isDaylightSavingTime(timeZone?: string): boolean;
package/dist/util.js CHANGED
@@ -17,6 +17,24 @@ export function isArrayLike(obj) {
17
17
  obj.hasOwnProperty("length") &&
18
18
  typeof obj.length === "number"));
19
19
  }
20
+ /**
21
+ * Default `idx` is 100.
22
+ */
23
+ export function truncateValue(value, idx) {
24
+ let truncValue = truncateValuePreserveNewLines(value, idx);
25
+ if (truncValue.includes('\n')) {
26
+ truncValue = value.slice(0, truncValue.indexOf('\n')) + '...';
27
+ }
28
+ return truncValue;
29
+ }
30
+ /**
31
+ * Default `idx` is 100.
32
+ */
33
+ export function truncateValuePreserveNewLines(value, idx) {
34
+ idx = idx ?? 100;
35
+ let truncValue = value.length > idx ? value.slice(0, idx) + '...' : value;
36
+ return truncValue;
37
+ }
20
38
  // Dates --------------------------------------------------------------------------
21
39
  export function initDate(timeZone) {
22
40
  const date = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.6.21",
3
+ "version": "8.6.22",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",