@uwdata/mosaic-inputs 0.31.0 → 0.32.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,10 @@ import { Input } from './input.js';
13
13
  * @param {{ [name: string]: 'left' | 'right' | 'center' }} [options.align]
14
14
  * An object that maps column names to horizontal text alignment values. If
15
15
  * unspecified, alignment is determined based on the column data type.
16
- * @param {{ [name: string]: (value: any) => string }} [options.format] An
16
+ * @param {{ [name: string]: (value: any) => string | HTMLElement }} [options.format] An
17
17
  * object that maps column names to format functions to use for that
18
18
  * column's data. Each format function takes a value as input and generates
19
- * formatted text to show in the table.
19
+ * formatted text or an HTML element to show in the table.
20
20
  * @param {string} [options.from] The name of a database table to use as a data
21
21
  * source for this widget. Used in conjunction with the *columns* option.
22
22
  * @param {string[]} [options.columns] The name of database columns to include
@@ -40,7 +40,7 @@ export declare const table: (options: {
40
40
  [name: string]: 'left' | 'right' | 'center';
41
41
  };
42
42
  format?: {
43
- [name: string]: (value: any) => string;
43
+ [name: string]: (value: any) => string | HTMLElement;
44
44
  };
45
45
  from?: string;
46
46
  columns?: string[];
@@ -60,7 +60,7 @@ export declare class Table extends Input {
60
60
  from: string;
61
61
  columns: string[];
62
62
  format: {
63
- [name: string]: (value: any) => string;
63
+ [name: string]: (value: any) => string | HTMLElement;
64
64
  };
65
65
  align: {
66
66
  [name: string]: "center" | "left" | "right";
@@ -96,10 +96,10 @@ export declare class Table extends Input {
96
96
  * @param {{ [name: string]: 'left' | 'right' | 'center' }} [options.align]
97
97
  * An object that maps column names to horizontal text alignment values. If
98
98
  * unspecified, alignment is determined based on the column data type.
99
- * @param {{ [name: string]: (value: any) => string }} [options.format] An
99
+ * @param {{ [name: string]: (value: any) => string | HTMLElement }} [options.format] An
100
100
  * object that maps column names to format functions to use for that
101
101
  * column's data. Each format function takes a value as input and generates
102
- * formatted text to show in the table.
102
+ * formatted text or an HTML element to show in the table.
103
103
  * @param {string} [options.from] The name of a database table to use as a data
104
104
  * source for this widget. Used in conjunction with the *columns* option.
105
105
  * @param {string[]} [options.columns] The name of database columns to include
@@ -122,7 +122,7 @@ export declare class Table extends Input {
122
122
  [name: string]: 'left' | 'right' | 'center';
123
123
  };
124
124
  format?: {
125
- [name: string]: (value: any) => string;
125
+ [name: string]: (value: any) => string | HTMLElement;
126
126
  };
127
127
  from?: string;
128
128
  columns?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.js"],"names":[],"mappings":"AACG,OAAQ,KAAA,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAChD;AAAA,OAAQ,KAAA,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAKnD,OAAO,EAAE,KAAK,EAAS,MAAM,YAAY,CAAC;AAI1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,KAAK,YA5Bf;IAA8B,OAAO,AAArC,CAEA,EAFQ,WAAW,CAEnB;IAA4B,QAAQ,AAApC,CAEA,EAFQ,SAAS,CAEjB;IAA4B,EAAE,AAA9B,CAEA,EAFQ,SAAS,CAEjB;IAAkE,KAAK,AAAvE,CAGA,EAHQ;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;KAAE,CAGvD;IAA6D,MAAM,AAAnE,CAIA,EAJQ;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;KAAE,CAIlD;IAAyB,IAAI,AAA7B,CAEA,EAFQ,MAAM,CAEd;IAA2B,OAAO,AAAlC,CAGA,EAHQ,MAAM,EAAE,CAGhB;IAAsD,KAAK,AAA3D,CAGA,EAHQ,MAAM,GAAG;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAG3C;IAAyB,QAAQ,AAAjC,CACA,EADQ,MAAM,CACd;IAAyB,M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SAAE,CAIhE;QAAyB,IAAI,AAA7B,CAEA,EAFQ,MAAM,CAEd;QAA2B,OAAO,AAAlC,CAGA,EAHQ,MAAM,EAAE,CAGhB;QAAsD,KAAK,AAA3D,CAGA,EAHQ,MAAM,GAAG;YAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAG3C;QAAyB,QAAQ,AAAjC,CACA,EADQ,MAAM,CACd;QAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;QAAyB,QAAQ,AAAjC,CAGF,EAHU,MAAM,CAGhB;KAaK,EA0EL;IAED,WAAW,QAEV;IAED,MAAM,CAAC,IAAI,QAAK,iDAQf;IAED,WAAW,CAAC,MAAM,SAAI,QASrB;IAEK,OAAO,kBA6BZ;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,GAFD,UAEM,4CAQhB;IAED,WAAW,CAAC,IAAI,KAAA,QAUf;IAED,MAAM,SAiCL;IAED,QAAQ,SAIP;IAED,IAAI,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA,QAsBjB;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-inputs",
3
- "version": "0.31.0",
3
+ "version": "0.32.0-beta.0",
4
4
  "description": "Mosaic input components.",
5
5
  "keywords": [
6
6
  "inputs",
@@ -23,8 +23,8 @@
23
23
  "url": "https://github.com/uwdata/mosaic.git"
24
24
  },
25
25
  "dependencies": {
26
- "@uwdata/mosaic-core": "^0.31.0",
27
- "@uwdata/mosaic-sql": "^0.31.0"
26
+ "@uwdata/mosaic-core": "^0.32.0-beta.0",
27
+ "@uwdata/mosaic-sql": "^0.32.0-beta.0"
28
28
  },
29
29
  "scripts": {
30
30
  "clean": "rimraf dist && mkdir dist",
package/src/Table.js CHANGED
@@ -21,10 +21,10 @@ let _id = -1;
21
21
  * @param {{ [name: string]: 'left' | 'right' | 'center' }} [options.align]
22
22
  * An object that maps column names to horizontal text alignment values. If
23
23
  * unspecified, alignment is determined based on the column data type.
24
- * @param {{ [name: string]: (value: any) => string }} [options.format] An
24
+ * @param {{ [name: string]: (value: any) => string | HTMLElement }} [options.format] An
25
25
  * object that maps column names to format functions to use for that
26
26
  * column's data. Each format function takes a value as input and generates
27
- * formatted text to show in the table.
27
+ * formatted text or an HTML element to show in the table.
28
28
  * @param {string} [options.from] The name of a database table to use as a data
29
29
  * source for this widget. Used in conjunction with the *columns* option.
30
30
  * @param {string[]} [options.columns] The name of database columns to include
@@ -59,10 +59,10 @@ export class Table extends Input {
59
59
  * @param {{ [name: string]: 'left' | 'right' | 'center' }} [options.align]
60
60
  * An object that maps column names to horizontal text alignment values. If
61
61
  * unspecified, alignment is determined based on the column data type.
62
- * @param {{ [name: string]: (value: any) => string }} [options.format] An
62
+ * @param {{ [name: string]: (value: any) => string | HTMLElement }} [options.format] An
63
63
  * object that maps column names to format functions to use for that
64
64
  * column's data. Each format function takes a value as input and generates
65
- * formatted text to show in the table.
65
+ * formatted text or an HTML element to show in the table.
66
66
  * @param {string} [options.from] The name of a database table to use as a data
67
67
  * source for this widget. Used in conjunction with the *columns* option.
68
68
  * @param {string[]} [options.columns] The name of database columns to include
@@ -260,7 +260,13 @@ export class Table extends Input {
260
260
  for (let j = 0; j < nf; ++j) {
261
261
  const value = cols[j][i];
262
262
  const td = document.createElement('td');
263
- td.innerText = value == null ? '' : formats[j](value);
263
+ const formatted = value == null ? '' : formats[j](value);
264
+ if (formatted instanceof HTMLElement || formatted instanceof SVGElement) {
265
+ td.appendChild(formatted);
266
+ } else {
267
+ td.innerText = formatted;
268
+ }
269
+
264
270
  tr.appendChild(td);
265
271
  }
266
272
  body.appendChild(tr);
@@ -298,7 +304,7 @@ export class Table extends Input {
298
304
  } else {
299
305
  if (currentHeader) currentHeader.firstChild.textContent = '';
300
306
  this.sortHeader = th;
301
- th.firstChild.textContent = this.sortDesc ? "▾" : "▴";
307
+ th.firstChild.textContent = this.sortDesc ? '▾' : '▴';
302
308
  }
303
309
 
304
310
  // issue query for sorted data
@@ -73,7 +73,7 @@ export function localize(f) {
73
73
  */
74
74
  function isoformat(date, fallback) {
75
75
  if (!(date instanceof Date)) date = new Date(+date);
76
- if (isNaN(+date)) return typeof fallback === "function" ? fallback(date) : fallback;
76
+ if (isNaN(+date)) return typeof fallback === 'function' ? fallback(date) : fallback;
77
77
  const hours = date.getUTCHours();
78
78
  const minutes = date.getUTCMinutes();
79
79
  const seconds = date.getUTCSeconds();
@@ -81,9 +81,9 @@ function isoformat(date, fallback) {
81
81
  return `${formatYear(date.getUTCFullYear())}-${pad(date.getUTCMonth() + 1, 2)}-${pad(date.getUTCDate(), 2)}${
82
82
  hours || minutes || seconds || milliseconds ? `T${pad(hours, 2)}:${pad(minutes, 2)}${
83
83
  seconds || milliseconds ? `:${pad(seconds, 2)}${
84
- milliseconds ? `.${pad(milliseconds, 3)}` : ``
85
- }` : ``
86
- }Z` : ``
84
+ milliseconds ? `.${pad(milliseconds, 3)}` : ''
85
+ }` : ''
86
+ }Z` : ''
87
87
  }`;
88
88
  }
89
89
 
@@ -94,5 +94,5 @@ function formatYear(year) {
94
94
  }
95
95
 
96
96
  function pad(value, width) {
97
- return `${value}`.padStart(width, "0");
97
+ return `${value}`.padStart(width, '0');
98
98
  }