@uwdata/mosaic-inputs 0.16.1 → 0.17.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.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Mosaic input components.",
5
5
  "keywords": [
6
6
  "inputs",
@@ -10,7 +10,7 @@
10
10
  "author": "Jeffrey Heer (https://idl.uw.edu)",
11
11
  "type": "module",
12
12
  "exports": {
13
- "types": "./dist/types/index.d.ts",
13
+ "types": "./dist/src/index.d.ts",
14
14
  "default": "./src/index.js"
15
15
  },
16
16
  "repository": {
@@ -19,16 +19,12 @@
19
19
  },
20
20
  "scripts": {
21
21
  "prebuild": "rimraf dist && mkdir dist",
22
- "build": "npm run types",
23
- "types": "tsc -p tsconfig.json",
24
22
  "lint": "eslint src test",
25
- "test": "vitest run && npm run tsc",
26
- "tsc": "tsc -p jsconfig.json",
27
- "prepublishOnly": "npm run test && npm run lint && npm run build"
23
+ "test": "vitest run && tsc",
24
+ "prepublishOnly": "npm run test && npm run lint && tsc"
28
25
  },
29
26
  "dependencies": {
30
- "@uwdata/mosaic-core": "^0.16.1",
31
- "@uwdata/mosaic-sql": "^0.16.1"
32
- },
33
- "gitHead": "e12af9927b0a35a0e3194850ef569d0d24a022ce"
27
+ "@uwdata/mosaic-core": "^0.17.0",
28
+ "@uwdata/mosaic-sql": "^0.17.0"
29
+ }
34
30
  }
package/tsconfig.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
- "include": ["src/**/*.js", "src/**/*.ts"],
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src/**/*"],
3
4
  "compilerOptions": {
4
- "allowJs": true,
5
- "declaration": true,
6
5
  "emitDeclarationOnly": true,
7
- "outDir": "dist/types",
8
- "module": "node16",
9
- "skipLibCheck": true
10
- }
11
- }
6
+ "outDir": "dist"
7
+ },
8
+ "references": [{ "path": "../core" }, { "path": "../sql" }]
9
+ }
package/LICENSE DELETED
@@ -1,47 +0,0 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2023, UW Interactive Data Lab
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are met:
7
-
8
- 1. Redistributions of source code must retain the above copyright notice, this
9
- list of conditions and the following disclaimer.
10
-
11
- 2. Redistributions in binary form must reproduce the above copyright notice,
12
- this list of conditions and the following disclaimer in the documentation
13
- and/or other materials provided with the distribution.
14
-
15
- 3. Neither the name of the copyright holder nor the names of its
16
- contributors may be used to endorse or promote products derived from
17
- this software without specific prior written permission.
18
-
19
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- ---
31
-
32
- Portions of this software are derived from Observable Plot, which is released
33
- under the ISC license.
34
-
35
- Copyright 2020-2023 Observable, Inc.
36
-
37
- Permission to use, copy, modify, and/or distribute this software for any purpose
38
- with or without fee is hereby granted, provided that the above copyright notice
39
- and this permission notice appear in all copies.
40
-
41
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43
- FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45
- OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
46
- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
47
- THIS SOFTWARE.
@@ -1,79 +0,0 @@
1
- export function menu(options?: {
2
- element?: HTMLElement;
3
- filterBy?: Selection;
4
- as?: Param;
5
- field?: string;
6
- options?: (any | {
7
- value: any;
8
- label?: string;
9
- })[];
10
- format?: (value: any) => string;
11
- value?: any;
12
- from?: string;
13
- column?: string;
14
- label?: string;
15
- }): HTMLElement;
16
- /**
17
- * A HTML <select>-based dropdown menu input.
18
- * @extends {Input}
19
- */
20
- export class Menu extends Input {
21
- /**
22
- * Create a new menu input.
23
- * @param {object} [options] Options object
24
- * @param {HTMLElement} [options.element] The parent DOM element in which to
25
- * place the menu elements. If undefined, a new `div` element is created.
26
- * @param {Selection} [options.filterBy] A selection to filter the database
27
- * table indicated by the *from* option.
28
- * @param {Param} [options.as] The output param or selection. A selection
29
- * clause is added for the currently selected menu option.
30
- * @param {string} [options.field] The database column name to use within
31
- * generated selection clause predicates. Defaults to the *column* option.
32
- * @param {(any | { value: any, label?: string })[]} [options.options] An
33
- * array of menu options, as literal values or option objects. Option
34
- * objects have a `value` property and an optional `label` property. If no
35
- * label or *format* function is provided, the string-coerced value is used.
36
- * @param {(value: any) => string} [options.format] A format function that
37
- * takes an option value as input and generates a string label. The format
38
- * function is not applied when an explicit label is provided in an option
39
- * object.
40
- * @param {*} [options.value] The initial selected menu value.
41
- * @param {string} [options.from] The name of a database table to use as a data
42
- * source for this widget. Used in conjunction with the *column* option.
43
- * @param {string} [options.column] The name of a database column from which
44
- * to pull menu options. The unique column values are used as menu options.
45
- * Used in conjunction with the *from* option.
46
- * @param {string} [options.label] A text label for this input.
47
- */
48
- constructor({ element, filterBy, as, from, column, label, format, options, value, field }?: {
49
- element?: HTMLElement;
50
- filterBy?: Selection;
51
- as?: Param;
52
- field?: string;
53
- options?: (any | {
54
- value: any;
55
- label?: string;
56
- })[];
57
- format?: (value: any) => string;
58
- value?: any;
59
- from?: string;
60
- column?: string;
61
- label?: string;
62
- });
63
- from: string;
64
- column: string;
65
- format: (value: any) => string;
66
- field: string;
67
- selection: Param;
68
- select: HTMLSelectElement;
69
- data: any[];
70
- selectedValue(value: any, ...args: any[]): any;
71
- reset(): void;
72
- publish(value: any): void;
73
- query(filter?: any[]): import("@uwdata/mosaic-sql").SelectQuery;
74
- queryResult(data: any): this;
75
- update(): this;
76
- }
77
- import type { Selection } from '@uwdata/mosaic-core';
78
- import type { Param } from '@uwdata/mosaic-core';
79
- import { Input } from './input.js';
@@ -1,69 +0,0 @@
1
- export function search(options?: {
2
- element?: HTMLElement;
3
- filterBy?: Selection;
4
- as?: Param;
5
- field?: string;
6
- type?: "contains" | "prefix" | "suffix" | "regexp";
7
- from?: string;
8
- column?: string;
9
- label?: string;
10
- }): HTMLElement;
11
- /**
12
- * A HTML text search input.
13
- * @extends {Input}
14
- */
15
- export class Search extends Input {
16
- /**
17
- * Create a new text search input.
18
- * @param {object} [options] Options object
19
- * @param {HTMLElement} [options.element] The parent DOM element in which to
20
- * place the search elements. If undefined, a new `div` element is created.
21
- * @param {Selection} [options.filterBy] A selection to filter the database
22
- * table indicated by the *from* option.
23
- * @param {Param} [options.as] The output param or selection. A selection
24
- * clause is added based on the current text search query.
25
- * @param {string} [options.field] The database column name to use within
26
- * generated selection clause predicates. Defaults to the *column* option.
27
- * @param {'contains' | 'prefix' | 'suffix' | 'regexp'} [options.type] The
28
- * type of text search query to perform. One of:
29
- * - `"contains"` (default): the query string may appear anywhere in the text
30
- * - `"prefix"`: the query string must appear at the start of the text
31
- * - `"suffix"`: the query string must appear at the end of the text
32
- * - `"regexp"`: the query string is a regular expression the text must match
33
- * @param {string} [options.from] The name of a database table to use as an
34
- * autocomplete data source for this widget. Used in conjunction with the
35
- * *column* option.
36
- * @param {string} [options.column] The name of a database column from which
37
- * to pull valid search results. The unique column values are used as search
38
- * autocomplete values. Used in conjunction with the *from* option.
39
- * @param {string} [options.label] A text label for this input.
40
- */
41
- constructor({ element, filterBy, from, column, label, type, field, as }?: {
42
- element?: HTMLElement;
43
- filterBy?: Selection;
44
- as?: Param;
45
- field?: string;
46
- type?: "contains" | "prefix" | "suffix" | "regexp";
47
- from?: string;
48
- column?: string;
49
- label?: string;
50
- });
51
- id: string;
52
- type: "contains" | "prefix" | "suffix" | "regexp";
53
- from: string;
54
- column: string;
55
- selection: Param;
56
- field: string;
57
- searchbox: HTMLInputElement;
58
- reset(): void;
59
- clause(value: any): import("@uwdata/mosaic-core").SelectionClause;
60
- publish(value: any): void;
61
- query(filter?: any[]): import("@uwdata/mosaic-sql").SelectQuery;
62
- queryResult(data: any): this;
63
- data: any;
64
- update(): this;
65
- datalist: HTMLDataListElement;
66
- }
67
- import type { Selection } from '@uwdata/mosaic-core';
68
- import type { Param } from '@uwdata/mosaic-core';
69
- import { Input } from './input.js';
@@ -1,84 +0,0 @@
1
- export function slider(options?: {
2
- element?: HTMLElement;
3
- filterBy?: Selection;
4
- as?: Param;
5
- field?: string;
6
- select?: "point" | "interval";
7
- min?: number;
8
- max?: number;
9
- step?: number;
10
- value?: number;
11
- from?: string;
12
- column?: string;
13
- label?: string;
14
- width?: number;
15
- }): HTMLElement;
16
- /**
17
- * A HTML range-based slider input.
18
- * @extends {Input}
19
- */
20
- export class Slider extends Input {
21
- /**
22
- * Create a new slider input.
23
- * @param {object} [options] Options object
24
- * @param {HTMLElement} [options.element] The parent DOM element in which to
25
- * place the slider elements. If undefined, a new `div` element is created.
26
- * @param {Selection} [options.filterBy] A selection to filter the database
27
- * table indicated by the *from* option.
28
- * @param {Param} [options.as] The output param or selection. A selection
29
- * clause is added based on the currently selected slider option.
30
- * @param {string} [options.field] The database column name to use within
31
- * generated selection clause predicates. Defaults to the *column* option.
32
- * @param {'point' | 'interval'} [options.select] The type of selection clause
33
- * predicate to generate if the **as** option is a Selection. If `'point'`
34
- * (the default), the selection predicate is an equality check for the slider
35
- * value. If `'interval'`, the predicate checks an interval from the minimum
36
- * to the current slider value.
37
- * @param {number} [options.min] The minimum slider value.
38
- * @param {number} [options.max] The maximum slider value.
39
- * @param {number} [options.step] The slider step, the amount to increment
40
- * between consecutive values.
41
- * @param {number} [options.value] The initial slider value.
42
- * @param {string} [options.from] The name of a database table to use as a data
43
- * source for this widget. Used in conjunction with the *column* option.
44
- * The minimum and maximum values of the column determine the slider range.
45
- * @param {string} [options.column] The name of a database column whose values
46
- * determine the slider range. Used in conjunction with the *from* option.
47
- * The minimum and maximum values of the column determine the slider range.
48
- * @param {string} [options.label] A text label for this input.
49
- * @param {number} [options.width] The width of the slider in screen pixels.
50
- */
51
- constructor({ element, filterBy, as, min, max, step, from, column, label, value, select, field, width }?: {
52
- element?: HTMLElement;
53
- filterBy?: Selection;
54
- as?: Param;
55
- field?: string;
56
- select?: "point" | "interval";
57
- min?: number;
58
- max?: number;
59
- step?: number;
60
- value?: number;
61
- from?: string;
62
- column?: string;
63
- label?: string;
64
- width?: number;
65
- });
66
- id: string;
67
- from: string;
68
- column: string;
69
- selection: Param;
70
- selectionType: "point" | "interval";
71
- field: string;
72
- min: number;
73
- max: number;
74
- step: number;
75
- slider: HTMLInputElement;
76
- curval: HTMLLabelElement;
77
- query(filter?: any[]): import("@uwdata/mosaic-sql").SelectQuery;
78
- queryResult(data: any): this;
79
- clause(value: any): import("@uwdata/mosaic-core").SelectionClause;
80
- publish(value: any): void;
81
- }
82
- import type { Selection } from '@uwdata/mosaic-core';
83
- import type { Param } from '@uwdata/mosaic-core';
84
- import { Input } from './input.js';
@@ -1,111 +0,0 @@
1
- export function table(options: {
2
- element?: HTMLElement;
3
- filterBy?: Selection;
4
- as?: Selection;
5
- align?: {
6
- [name: string]: "left" | "right" | "center";
7
- };
8
- format?: {
9
- [name: string]: (value: any) => string;
10
- };
11
- from?: string;
12
- columns?: string[];
13
- width?: number | {
14
- [name: string]: number;
15
- };
16
- maxWidth?: number;
17
- height?: number;
18
- rowBatch?: number;
19
- }): HTMLElement;
20
- /**
21
- * A HTML table based table component.
22
- * @extends {Input}
23
- */
24
- export class Table extends Input {
25
- /**
26
- * Create a new Table instance.
27
- * @param {object} options Options object
28
- * @param {HTMLElement} [options.element] The parent DOM element in which to
29
- * place the table element. If undefined, a new `div` element is created.
30
- * @param {Selection} [options.filterBy] A selection to filter the database
31
- * table indicated by the *from* option.
32
- * @param {Selection} [options.as] The output selection. A selection
33
- * clause is added for the currently selected table row.
34
- * @param {{ [name: string]: 'left' | 'right' | 'center' }} [options.align]
35
- * An object that maps column names to horiztonal text alignment values. If
36
- * unspecified, alignment is determined based on the column data type.
37
- * @param {{ [name: string]: (value: any) => string }} [options.format] An
38
- * object that maps column names to format functions to use for that
39
- * column's data. Each format function takes a value as input and generates
40
- * formatted text to show in the table.
41
- * @param {string} [options.from] The name of a database table to use as a data
42
- * source for this widget. Used in conjunction with the *columns* option.
43
- * @param {string[]} [options.columns] The name of database columns to include
44
- * in the table component. If unspecified, all columns are included.
45
- * Used in conjunction with the *from* option.
46
- * @param {number | { [name: string]: number }} [options.width] If a number,
47
- * sets the desired width of the table, in pixels. If an object, is used to
48
- * set explicit pixel widts for each named column included in the object.
49
- * @param {number} [options.maxWidth] The maximum width of the table, in pixels.
50
- * @param {number} [options.height] The desired height of the table, in pixels.
51
- * @param {number} [options.rowBatch] The number of rows to request per query
52
- * batch. The batch size will be used to prefetch data beyond the currently
53
- * visible range.
54
- */
55
- constructor({ element, filterBy, from, columns, align, format, width, maxWidth, height, rowBatch, as }?: {
56
- element?: HTMLElement;
57
- filterBy?: Selection;
58
- as?: Selection;
59
- align?: {
60
- [name: string]: "left" | "right" | "center";
61
- };
62
- format?: {
63
- [name: string]: (value: any) => string;
64
- };
65
- from?: string;
66
- columns?: string[];
67
- width?: number | {
68
- [name: string]: number;
69
- };
70
- maxWidth?: number;
71
- height?: number;
72
- rowBatch?: number;
73
- });
74
- id: string;
75
- from: string;
76
- columns: string[];
77
- format: {
78
- [name: string]: (value: any) => string;
79
- };
80
- align: {
81
- [name: string]: "left" | "right" | "center";
82
- };
83
- widths: {
84
- [name: string]: number;
85
- };
86
- offset: number;
87
- limit: number;
88
- isPending: boolean;
89
- selection: Selection;
90
- currentRow: number;
91
- sortHeader: any;
92
- sortColumn: any;
93
- sortDesc: boolean;
94
- tbl: HTMLTableElement;
95
- head: HTMLTableSectionElement;
96
- body: HTMLTableSectionElement;
97
- style: HTMLStyleElement;
98
- sourceTable(): any;
99
- clause(rows?: any[]): import("@uwdata/mosaic-core").SelectionClause;
100
- requestData(offset?: number): void;
101
- schema: import("@uwdata/mosaic-core").FieldInfo[];
102
- formats: any;
103
- query(filter?: any[]): import("@uwdata/mosaic-sql").SelectQuery;
104
- queryResult(data: any): this;
105
- loaded: boolean;
106
- data: any[];
107
- update(): this;
108
- sort(event: any, column: any): void;
109
- }
110
- import type { Selection } from '@uwdata/mosaic-core';
111
- import { Input } from './input.js';
@@ -1,4 +0,0 @@
1
- export { Menu, menu } from "./Menu.js";
2
- export { Search, search } from "./Search.js";
3
- export { Slider, slider } from "./Slider.js";
4
- export { Table, table } from "./Table.js";
@@ -1,28 +0,0 @@
1
- /**
2
- * Instantiate an input, register it with the coordinator, and
3
- * return the corresponding HTML element.
4
- * @template {new (...args: any) => Input} T
5
- * @param {T} InputClass
6
- * @param {ConstructorParameters<T>} params
7
- * @returns {HTMLElement} The container element of the input.
8
- */
9
- export function input<T extends new (...args: any) => Input>(InputClass: T, ...params: ConstructorParameters<T>): HTMLElement;
10
- /**
11
- * Base class for input components.
12
- * @import {Activatable} from '@uwdata/mosaic-core'
13
- * @implements {Activatable}
14
- */
15
- export class Input extends MosaicClient implements Activatable {
16
- /**
17
- * Create a new input instance.
18
- * @param {import('@uwdata/mosaic-core').Selection} [filterBy] A selection
19
- * with which to filter backing data that parameterizes this input.
20
- * @param {HTMLElement} [element] Optional container HTML element to use.
21
- * @param {string} [className] A class name to set on the container element.
22
- */
23
- constructor(filterBy?: import("@uwdata/mosaic-core").Selection, element?: HTMLElement, className?: string);
24
- element: HTMLElement;
25
- activate(): void;
26
- }
27
- import type { Activatable } from '@uwdata/mosaic-core';
28
- import { MosaicClient } from '@uwdata/mosaic-core';
@@ -1,8 +0,0 @@
1
- export function stringify(x: any): string;
2
- export function formatTrim(value: any): any;
3
- export function formatDate(date: any): string;
4
- export function localize(f: any): (locale?: string) => any;
5
- export function formatLocaleAuto(locale?: string): any;
6
- export function formatLocaleNumber(locale?: string): any;
7
- export const formatAuto: any;
8
- export const formatNumber: any;
package/jsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "include": ["src/**/*"],
3
- "compilerOptions": {
4
- "checkJs": true,
5
- "noEmit": true,
6
- "noImplicitAny": false,
7
- "module": "node16",
8
- "skipLibCheck": true,
9
- "types": []
10
- }
11
- }