@uwdata/mosaic-inputs 0.15.0 → 0.16.2

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.
@@ -74,6 +74,6 @@ export class Menu extends Input {
74
74
  queryResult(data: any): this;
75
75
  update(): this;
76
76
  }
77
- import { Selection } from '@uwdata/mosaic-core';
78
- import { Param } from '@uwdata/mosaic-core';
77
+ import type { Selection } from '@uwdata/mosaic-core';
78
+ import type { Param } from '@uwdata/mosaic-core';
79
79
  import { Input } from './input.js';
@@ -64,6 +64,6 @@ export class Search extends Input {
64
64
  update(): this;
65
65
  datalist: HTMLDataListElement;
66
66
  }
67
- import { Selection } from '@uwdata/mosaic-core';
68
- import { Param } from '@uwdata/mosaic-core';
67
+ import type { Selection } from '@uwdata/mosaic-core';
68
+ import type { Param } from '@uwdata/mosaic-core';
69
69
  import { Input } from './input.js';
@@ -79,6 +79,6 @@ export class Slider extends Input {
79
79
  clause(value: any): import("@uwdata/mosaic-core").SelectionClause;
80
80
  publish(value: any): void;
81
81
  }
82
- import { Selection } from '@uwdata/mosaic-core';
83
- import { Param } from '@uwdata/mosaic-core';
82
+ import type { Selection } from '@uwdata/mosaic-core';
83
+ import type { Param } from '@uwdata/mosaic-core';
84
84
  import { Input } from './input.js';
@@ -98,12 +98,7 @@ export class Table extends Input {
98
98
  sourceTable(): any;
99
99
  clause(rows?: any[]): import("@uwdata/mosaic-core").SelectionClause;
100
100
  requestData(offset?: number): void;
101
- fields(): {
102
- column: string;
103
- table: any;
104
- }[];
105
- fieldInfo(info: any): this;
106
- schema: any;
101
+ schema: import("@uwdata/mosaic-core").FieldInfo[];
107
102
  formats: any;
108
103
  query(filter?: any[]): import("@uwdata/mosaic-sql").SelectQuery;
109
104
  queryResult(data: any): this;
@@ -112,5 +107,5 @@ export class Table extends Input {
112
107
  update(): this;
113
108
  sort(event: any, column: any): void;
114
109
  }
115
- import { Selection } from '@uwdata/mosaic-core';
110
+ import type { Selection } from '@uwdata/mosaic-core';
116
111
  import { Input } from './input.js';
@@ -1,6 +1,6 @@
1
1
  export function stringify(x: any): string;
2
2
  export function formatTrim(value: any): any;
3
- export function formatDate(date: any): any;
3
+ export function formatDate(date: any): string;
4
4
  export function localize(f: any): (locale?: string) => any;
5
5
  export function formatLocaleAuto(locale?: string): any;
6
6
  export function formatLocaleNumber(locale?: string): any;
package/jsconfig.json ADDED
@@ -0,0 +1,11 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-inputs",
3
- "version": "0.15.0",
3
+ "version": "0.16.2",
4
4
  "description": "Mosaic input components.",
5
5
  "keywords": [
6
6
  "inputs",
@@ -10,6 +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
14
  "default": "./src/index.js"
14
15
  },
15
16
  "repository": {
@@ -17,14 +18,17 @@
17
18
  "url": "https://github.com/uwdata/mosaic.git"
18
19
  },
19
20
  "scripts": {
21
+ "prebuild": "rimraf dist && mkdir dist",
22
+ "build": "npm run types",
23
+ "types": "tsc -p tsconfig.json",
20
24
  "lint": "eslint src test",
21
- "test": "vitest run",
22
- "prepublishOnly": "npm run test && npm run lint"
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
28
  },
24
29
  "dependencies": {
25
- "@uwdata/mosaic-core": "^0.15.0",
26
- "@uwdata/mosaic-sql": "^0.15.0",
27
- "isoformat": "^0.2.1"
30
+ "@uwdata/mosaic-core": "^0.16.2",
31
+ "@uwdata/mosaic-sql": "^0.16.2"
28
32
  },
29
- "gitHead": "671ad1ba86749a8435bd4aa7e722e2a8553f2cb0"
33
+ "gitHead": "26d2719f4bcab471d2831145e1f03f39f3509869"
30
34
  }
package/src/Menu.js CHANGED
@@ -1,4 +1,5 @@
1
- import { Param, Selection, isParam, isSelection, clausePoint } from '@uwdata/mosaic-core';
1
+ /** @import { Param, Selection } from '@uwdata/mosaic-core' */
2
+ import { isParam, isSelection, clausePoint } from '@uwdata/mosaic-core';
2
3
  import { Query } from '@uwdata/mosaic-sql';
3
4
  import { Input, input } from './input.js';
4
5
 
package/src/Search.js CHANGED
@@ -1,4 +1,5 @@
1
- import { Param, Selection, isParam, isSelection, clauseMatch } from '@uwdata/mosaic-core';
1
+ /** @import { Param, Selection } from '@uwdata/mosaic-core' */
2
+ import { isParam, isSelection, clauseMatch } from '@uwdata/mosaic-core';
2
3
  import { Query } from '@uwdata/mosaic-sql';
3
4
  import { Input, input } from './input.js';
4
5
 
package/src/Slider.js CHANGED
@@ -1,4 +1,5 @@
1
- import { Param, Selection, clauseInterval, clausePoint, isParam, isSelection } from '@uwdata/mosaic-core';
1
+ /** @import { Param, Selection } from '@uwdata/mosaic-core' */
2
+ import { clauseInterval, clausePoint, isParam, isSelection } from '@uwdata/mosaic-core';
2
3
  import { Query, max, min } from '@uwdata/mosaic-sql';
3
4
  import { Input, input } from './input.js';
4
5
 
package/src/Table.js CHANGED
@@ -1,4 +1,5 @@
1
- import { Selection, clausePoints, coordinator, isParam, isSelection, queryFieldInfo, toDataColumns } from '@uwdata/mosaic-core';
1
+ /** @import { Selection } from '@uwdata/mosaic-core' */
2
+ import { clausePoints, coordinator, isParam, isSelection, queryFieldInfo, toDataColumns } from '@uwdata/mosaic-core';
2
3
  import { Query, desc } from '@uwdata/mosaic-sql';
3
4
  import { formatDate, formatLocaleAuto, formatLocaleNumber } from './util/format.js';
4
5
  import { Input, input } from './input.js';
@@ -1,4 +1,3 @@
1
- import { format as isoformat } from 'isoformat';
2
1
 
3
2
  // Note: use formatAuto (or any other localized format) to present values to the
4
3
  // user; stringify is only intended for machine values.
@@ -48,3 +47,52 @@ export function localize(f) {
48
47
  ? value
49
48
  : (value = f(key = locale));
50
49
  }
50
+
51
+ // Code below modified from https://github.com/mbostock/isoformat/
52
+ // Added here due to longstanding unmerged fixes on original package
53
+ //
54
+ // Copyright 2021 Mike Bostock
55
+ //
56
+ // Permission to use, copy, modify, and/or distribute this software for any purpose
57
+ // with or without fee is hereby granted, provided that the above copyright notice
58
+ // and this permission notice appear in all copies.
59
+ //
60
+ // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
61
+ // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
62
+ // FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
63
+ // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
64
+ // OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65
+ // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
66
+ // THIS SOFTWARE.
67
+
68
+ /**
69
+ * Format a Date in ISO format.
70
+ * @param {Date} date The date to format
71
+ * @param {string | ((date: Date) => string)} fallback Fallback value or function.
72
+ * @returns {string}
73
+ */
74
+ function isoformat(date, fallback) {
75
+ if (!(date instanceof Date)) date = new Date(+date);
76
+ if (isNaN(+date)) return typeof fallback === "function" ? fallback(date) : fallback;
77
+ const hours = date.getUTCHours();
78
+ const minutes = date.getUTCMinutes();
79
+ const seconds = date.getUTCSeconds();
80
+ const milliseconds = date.getUTCMilliseconds();
81
+ return `${formatYear(date.getUTCFullYear())}-${pad(date.getUTCMonth() + 1, 2)}-${pad(date.getUTCDate(), 2)}${
82
+ hours || minutes || seconds || milliseconds ? `T${pad(hours, 2)}:${pad(minutes, 2)}${
83
+ seconds || milliseconds ? `:${pad(seconds, 2)}${
84
+ milliseconds ? `.${pad(milliseconds, 3)}` : ``
85
+ }` : ``
86
+ }Z` : ``
87
+ }`;
88
+ }
89
+
90
+ function formatYear(year) {
91
+ return year < 0 ? `-${pad(-year, 6)}`
92
+ : year > 9999 ? `+${pad(year, 6)}`
93
+ : pad(year, 4);
94
+ }
95
+
96
+ function pad(value, width) {
97
+ return `${value}`.padStart(width, "0");
98
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "include": ["src/**/*.js", "src/**/*.ts"],
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "declaration": true,
6
+ "emitDeclarationOnly": true,
7
+ "outDir": "dist/types",
8
+ "module": "node16",
9
+ "skipLibCheck": true
10
+ }
11
+ }
@@ -1 +0,0 @@
1
- export * from './index.js';