@uwdata/mosaic-inputs 0.10.0 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-inputs",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Mosaic input components.",
5
5
  "keywords": [
6
6
  "inputs",
@@ -21,13 +21,13 @@
21
21
  "prebuild": "rimraf dist && mkdir dist",
22
22
  "build": "node ../../esbuild.js mosaic-inputs",
23
23
  "lint": "eslint src test",
24
- "test": "mocha 'test/**/*-test.js'",
24
+ "test": "vitest run",
25
25
  "prepublishOnly": "npm run test && npm run lint && npm run build"
26
26
  },
27
27
  "dependencies": {
28
- "@uwdata/mosaic-core": "^0.10.0",
29
- "@uwdata/mosaic-sql": "^0.10.0",
28
+ "@uwdata/mosaic-core": "^0.12.0",
29
+ "@uwdata/mosaic-sql": "^0.12.0",
30
30
  "isoformat": "^0.2.1"
31
31
  },
32
- "gitHead": "94fc4f0d4efc622001f6afd6714d1e9dda745be2"
32
+ "gitHead": "523b1afe2a0880291c92f81e4a7b91829362d285"
33
33
  }
package/src/Table.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MosaicClient, clausePoints, coordinator, toDataColumns } from '@uwdata/mosaic-core';
1
+ import { MosaicClient, clausePoints, coordinator, isParam, toDataColumns } from '@uwdata/mosaic-core';
2
2
  import { Query, column, desc } from '@uwdata/mosaic-sql';
3
3
  import { formatDate, formatLocaleAuto, formatLocaleNumber } from './util/format.js';
4
4
  import { input } from './input.js';
@@ -33,6 +33,11 @@ export class Table extends MosaicClient {
33
33
  this.align = align;
34
34
  this.widths = typeof width === 'object' ? width : {};
35
35
 
36
+ if (isParam(from)) {
37
+ // if data table is a param, re-initialize upon change
38
+ from.addEventListener('value', () => this.initialize());
39
+ }
40
+
36
41
  this.offset = 0;
37
42
  this.limit = +rowBatch;
38
43
  this.pending = false;
@@ -94,6 +99,10 @@ export class Table extends MosaicClient {
94
99
  this.element.appendChild(this.style);
95
100
  }
96
101
 
102
+ sourceTable() {
103
+ return isParam(this.from) ? this.from.value : this.from;
104
+ }
105
+
97
106
  clause(rows = []) {
98
107
  const { data, limit, schema } = this;
99
108
  const fields = schema.map(s => s.column);
@@ -116,7 +125,8 @@ export class Table extends MosaicClient {
116
125
  }
117
126
 
118
127
  fields() {
119
- return this.columns.map(name => column(this.from, name));
128
+ const from = this.sourceTable();
129
+ return this.columns.map(name => column(name, from));
120
130
  }
121
131
 
122
132
  fieldInfo(info) {
@@ -148,8 +158,8 @@ export class Table extends MosaicClient {
148
158
  }
149
159
 
150
160
  query(filter = []) {
151
- const { from, limit, offset, schema, sortColumn, sortDesc } = this;
152
- return Query.from(from)
161
+ const { limit, offset, schema, sortColumn, sortDesc } = this;
162
+ return Query.from(this.sourceTable())
153
163
  .select(schema.map(s => s.column))
154
164
  .where(filter)
155
165
  .orderby(sortColumn ? (sortDesc ? desc(sortColumn) : sortColumn) : [])