@uwdata/mosaic-inputs 0.18.0 → 0.19.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.
@@ -12,6 +12,7 @@ export function menu(options?: {
12
12
  from?: string;
13
13
  column?: string;
14
14
  label?: string;
15
+ listMatch?: "any" | "all";
15
16
  }): HTMLElement;
16
17
  /**
17
18
  * A HTML <select>-based dropdown menu input.
@@ -44,8 +45,9 @@ export class Menu extends Input {
44
45
  * to pull menu options. The unique column values are used as menu options.
45
46
  * Used in conjunction with the *from* option.
46
47
  * @param {string} [options.label] A text label for this input.
48
+ * @param {'any' | 'all'} [options.listMatch] The list match mode.
47
49
  */
48
- constructor({ element, filterBy, as, from, column, label, format, options, value, field }?: {
50
+ constructor({ element, filterBy, as, from, column, label, format, options, value, field, listMatch, }?: {
49
51
  element?: HTMLElement;
50
52
  filterBy?: Selection;
51
53
  as?: Param<any>;
@@ -59,11 +61,13 @@ export class Menu extends Input {
59
61
  from?: string;
60
62
  column?: string;
61
63
  label?: string;
64
+ listMatch?: "any" | "all";
62
65
  });
63
66
  from: string;
64
67
  column: string;
65
68
  format: (value: any) => string;
66
69
  field: string;
70
+ listMatch: "any" | "all";
67
71
  selection: Param<any>;
68
72
  select: HTMLSelectElement;
69
73
  data: any[];
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../src/Menu.js"],"names":[],"mappings":"AAqCO,+BAzBJ;IAA8B,OAAO,GAA7B,WAAW;IAES,QAAQ,GAA5B,SAAS;IAEO,EAAE;IAED,KAAK,GAAtB,MAAM;IAE6C,OAAO,GAA1D,CAAC,GAAG,GAAG;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE;IAIP,MAAM,GAAvC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM;IAIV,KAAK,GAAjB,GAAC;IACgB,IAAI,GAArB,MAAM;IAEW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ACkB,SAAS,GAAjC,KAAK,GAAG,KAAK;CACrB,GAAU,WAAW,CAE2B;AAEnD;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,wGAzBG;QAA8B,OAAO,GAA7B,WAAW;QAES,QAAQ,GAA5B,SAAS;QAEO,EAAE;QAED,KAAK,GAAtB,MAAM;QAE6C,OAAO,GAA1D,CAAC,GAAG,GAAG;YAAE,KAAK,EAAE,GAAG,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,EAAE;QAIP,MAAM,GAAvC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM;QAIV,KAAK,GAAjB,GAAC;QACgB,IAAI,GAArB,MAAM;QAEW,MAAM,GAAvB,MAAM;QAGW,KAAK,GAAtB,MAAM;QACkB,SAAS,GAAjC,KAAK,GAAG,KAAK;KACvB,EAmEA;IApDC,aAAgB;IAChB,eAAoB;IACpB,gBA7BiB,GAAG,KAAK,MAAM,CA6BX;IACpB,cAAkB;IAClB,yBAA0B;IACR,sBAAmB;IAMrC,0BAA8C;IAK5C,YAAoE;IAsCxE,+CAYC;IAED,cAEC;IAQD,0BAWC;IAED,gEASC;IAED,6BAIC;IAED,eAqBC;CACF;+BAzNqC,qBAAqB;2BAArB,qBAAqB;sBAG9B,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-inputs",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Mosaic input components.",
5
5
  "keywords": [
6
6
  "inputs",
@@ -30,8 +30,8 @@
30
30
  "prepublishOnly": "npm run test && npm run lint && tsc --build"
31
31
  },
32
32
  "dependencies": {
33
- "@uwdata/mosaic-core": "^0.18.0",
34
- "@uwdata/mosaic-sql": "^0.18.0"
33
+ "@uwdata/mosaic-core": "^0.19.0",
34
+ "@uwdata/mosaic-sql": "^0.19.0"
35
35
  },
36
- "gitHead": "dfb9ded0b0307754e3185ca34cc49a1384fe8455"
36
+ "gitHead": "0ba4f2d710ca2fa53da7ff02a370e39a32dc2ce4"
37
37
  }
package/src/Menu.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** @import { Param, Selection } from '@uwdata/mosaic-core' */
2
- import { isParam, isSelection, clausePoint } from '@uwdata/mosaic-core';
3
- import { Query } from '@uwdata/mosaic-sql';
2
+ import { isParam, isSelection, clausePoint, clauseList } from '@uwdata/mosaic-core';
3
+ import { Query, unnest } from '@uwdata/mosaic-sql';
4
4
  import { Input, input } from './input.js';
5
5
 
6
6
  const isObject = v => {
@@ -33,6 +33,7 @@ const isObject = v => {
33
33
  * to pull menu options. The unique column values are used as menu options.
34
34
  * Used in conjunction with the *from* option.
35
35
  * @param {string} [options.label] A text label for this input.
36
+ * @param {'any' | 'all'} [options.listMatch] The list match mode.
36
37
  * @returns {HTMLElement} The container element for a menu input.
37
38
  */
38
39
  export const menu = options => input(Menu, options);
@@ -68,6 +69,7 @@ export class Menu extends Input {
68
69
  * to pull menu options. The unique column values are used as menu options.
69
70
  * Used in conjunction with the *from* option.
70
71
  * @param {string} [options.label] A text label for this input.
72
+ * @param {'any' | 'all'} [options.listMatch] The list match mode.
71
73
  */
72
74
  constructor({
73
75
  element,
@@ -79,13 +81,15 @@ export class Menu extends Input {
79
81
  format = x => x, // TODO
80
82
  options,
81
83
  value,
82
- field = column
84
+ field = column,
85
+ listMatch,
83
86
  } = {}) {
84
87
  super(filterBy, element);
85
88
  this.from = from;
86
89
  this.column = column;
87
90
  this.format = format;
88
91
  this.field = field;
92
+ this.listMatch = listMatch;
89
93
  const selection = this.selection = as;
90
94
 
91
95
  const lab = document.createElement('label');
@@ -160,10 +164,12 @@ export class Menu extends Input {
160
164
  }
161
165
 
162
166
  publish(value) {
163
- const { selection, field } = this;
167
+ const { selection, field, listMatch } = this;
164
168
  if (isSelection(selection)) {
165
169
  if (value === '') value = undefined; // 'All' option
166
- const clause = clausePoint(field, value, { source: this });
170
+ const clause = listMatch
171
+ ? clauseList(field, value, { source: this, listMatch })
172
+ : clausePoint(field, value, { source: this });
167
173
  selection.update(clause);
168
174
  } else if (isParam(selection)) {
169
175
  selection.update(value);
@@ -171,11 +177,11 @@ export class Menu extends Input {
171
177
  }
172
178
 
173
179
  query(filter = []) {
174
- const { from, column } = this;
180
+ const { from, column, listMatch } = this;
175
181
  if (!from) return null;
176
182
  return Query
177
183
  .from(from)
178
- .select({ value: column })
184
+ .select({ value: listMatch ? unnest(column) : column })
179
185
  .distinct()
180
186
  .where(filter)
181
187
  .orderby(column)
package/src/Table.js CHANGED
@@ -176,7 +176,7 @@ export class Table extends Input {
176
176
  const { columns } = data[~~(row / limit)];
177
177
  return fields.map(f => columns[f][row % limit]);
178
178
  });
179
- return clausePoints(fields, values, { source: /** @type {ClauseSource} */(this) });
179
+ return clausePoints(fields, values, { source: this });
180
180
  }
181
181
 
182
182
  requestData(offset = 0) {