@uwdata/mosaic-spec 0.7.1 → 0.8.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.
Files changed (154) hide show
  1. package/dist/mosaic-schema.json +186153 -0
  2. package/dist/mosaic-spec.js +2977 -4237
  3. package/dist/mosaic-spec.min.js +23 -23
  4. package/dist/types/ast/ASTNode.d.ts +26 -0
  5. package/dist/types/ast/DataNode.d.ts +60 -0
  6. package/dist/types/ast/ExpressionNode.d.ts +15 -0
  7. package/dist/types/ast/HConcatNode.d.ts +10 -0
  8. package/dist/types/ast/HSpaceNode.d.ts +11 -0
  9. package/dist/types/ast/InputNode.d.ts +8 -0
  10. package/dist/types/ast/LiteralNode.d.ts +7 -0
  11. package/dist/types/ast/OptionsNode.d.ts +10 -0
  12. package/dist/types/ast/ParamNode.d.ts +9 -0
  13. package/dist/types/ast/ParamRefNode.d.ts +8 -0
  14. package/dist/types/ast/PlotAttributeNode.d.ts +18 -0
  15. package/dist/types/ast/PlotFromNode.d.ts +9 -0
  16. package/dist/types/ast/PlotInteractorNode.d.ts +8 -0
  17. package/dist/types/ast/PlotLegendNode.d.ts +10 -0
  18. package/dist/types/ast/PlotMarkNode.d.ts +10 -0
  19. package/dist/types/ast/PlotNode.d.ts +11 -0
  20. package/dist/types/ast/SelectionNode.d.ts +12 -0
  21. package/dist/types/ast/SpecNode.d.ts +10 -0
  22. package/dist/types/ast/TransformNode.d.ts +13 -0
  23. package/dist/types/ast/VConcatNode.d.ts +10 -0
  24. package/dist/types/ast/VSpaceNode.d.ts +11 -0
  25. package/dist/types/ast-to-dom.d.ts +38 -0
  26. package/dist/types/ast-to-esm.d.ts +64 -0
  27. package/dist/types/config/components.d.ts +4 -0
  28. package/dist/types/config/extensions.d.ts +9 -0
  29. package/dist/types/config/inputs.d.ts +5 -0
  30. package/dist/types/config/plots.d.ts +34 -0
  31. package/dist/types/config/transforms.d.ts +4 -0
  32. package/dist/types/constants.d.ts +30 -0
  33. package/dist/types/index.d.ts +29 -0
  34. package/dist/types/parse-spec.d.ts +86 -0
  35. package/dist/types/spec/CSSStyles.d.ts +3 -0
  36. package/dist/types/spec/Data.d.ts +165 -0
  37. package/dist/types/spec/Expression.d.ts +27 -0
  38. package/dist/types/spec/HConcat.d.ts +8 -0
  39. package/dist/types/spec/HSpace.d.ts +9 -0
  40. package/dist/types/spec/Input.d.ts +182 -0
  41. package/dist/types/spec/Param.d.ts +51 -0
  42. package/dist/types/spec/Plot.d.ts +14 -0
  43. package/dist/types/spec/PlotAttribute.d.ts +1522 -0
  44. package/dist/types/spec/PlotFrom.d.ts +20 -0
  45. package/dist/types/spec/PlotInteractor.d.ts +8 -0
  46. package/dist/types/spec/PlotLegend.d.ts +68 -0
  47. package/dist/types/spec/PlotMark.d.ts +26 -0
  48. package/dist/types/spec/PlotTypes.d.ts +293 -0
  49. package/dist/types/spec/Spec.d.ts +45 -0
  50. package/dist/types/spec/Transform.d.ts +278 -0
  51. package/dist/types/spec/VConcat.d.ts +8 -0
  52. package/dist/types/spec/VSpace.d.ts +9 -0
  53. package/dist/types/spec/interactors/Highlight.d.ts +37 -0
  54. package/dist/types/spec/interactors/Interval1D.d.ts +63 -0
  55. package/dist/types/spec/interactors/Interval2D.d.ts +46 -0
  56. package/dist/types/spec/interactors/Nearest.d.ts +25 -0
  57. package/dist/types/spec/interactors/PanZoom.d.ts +58 -0
  58. package/dist/types/spec/interactors/Toggle.d.ts +51 -0
  59. package/dist/types/spec/marks/Area.d.ts +139 -0
  60. package/dist/types/spec/marks/Arrow.d.ts +94 -0
  61. package/dist/types/spec/marks/Axis.d.ts +281 -0
  62. package/dist/types/spec/marks/Bar.d.ts +150 -0
  63. package/dist/types/spec/marks/Cell.d.ts +57 -0
  64. package/dist/types/spec/marks/Contour.d.ts +23 -0
  65. package/dist/types/spec/marks/Delaunay.d.ts +86 -0
  66. package/dist/types/spec/marks/DenseLine.d.ts +27 -0
  67. package/dist/types/spec/marks/Density.d.ts +121 -0
  68. package/dist/types/spec/marks/Dot.d.ts +129 -0
  69. package/dist/types/spec/marks/Frame.d.ts +21 -0
  70. package/dist/types/spec/marks/Geo.d.ts +53 -0
  71. package/dist/types/spec/marks/Hexbin.d.ts +30 -0
  72. package/dist/types/spec/marks/Hexgrid.d.ts +25 -0
  73. package/dist/types/spec/marks/Image.d.ts +89 -0
  74. package/dist/types/spec/marks/Line.d.ts +82 -0
  75. package/dist/types/spec/marks/Link.d.ts +60 -0
  76. package/dist/types/spec/marks/Marks.d.ts +890 -0
  77. package/dist/types/spec/marks/Raster.d.ts +124 -0
  78. package/dist/types/spec/marks/Rect.d.ts +166 -0
  79. package/dist/types/spec/marks/Regression.d.ts +58 -0
  80. package/dist/types/spec/marks/Rule.d.ts +100 -0
  81. package/dist/types/spec/marks/Text.d.ts +106 -0
  82. package/dist/types/spec/marks/Tick.d.ts +61 -0
  83. package/dist/types/spec/marks/Vector.d.ts +99 -0
  84. package/dist/types/util.d.ts +12 -0
  85. package/jsconfig.json +10 -0
  86. package/package.json +16 -9
  87. package/src/ast/ASTNode.js +23 -2
  88. package/src/ast/DataNode.js +79 -21
  89. package/src/ast/HSpaceNode.js +1 -1
  90. package/src/ast/InputNode.js +1 -2
  91. package/src/ast/ParamNode.js +1 -2
  92. package/src/ast/PlotAttributeNode.js +1 -2
  93. package/src/ast/PlotInteractorNode.js +1 -2
  94. package/src/ast/PlotLegendNode.js +1 -2
  95. package/src/ast/PlotMarkNode.js +3 -2
  96. package/src/ast/TransformNode.js +1 -2
  97. package/src/ast/VSpaceNode.js +1 -1
  98. package/src/ast-to-dom.js +9 -3
  99. package/src/ast-to-esm.js +41 -12
  100. package/src/config/inputs.js +1 -0
  101. package/src/config/plots.js +4 -0
  102. package/src/index.js +4 -0
  103. package/src/parse-spec.js +38 -5
  104. package/src/spec/CSSStyles.ts +9 -0
  105. package/src/spec/Data.ts +184 -0
  106. package/src/spec/Expression.ts +31 -0
  107. package/src/spec/HConcat.ts +9 -0
  108. package/src/spec/HSpace.ts +9 -0
  109. package/src/spec/Input.ts +182 -0
  110. package/src/spec/Param.ts +68 -0
  111. package/src/spec/Plot.ts +15 -0
  112. package/src/spec/PlotAttribute.ts +1783 -0
  113. package/src/spec/PlotFrom.ts +23 -0
  114. package/src/spec/PlotInteractor.ts +25 -0
  115. package/src/spec/PlotLegend.ts +70 -0
  116. package/src/spec/PlotMark.ts +51 -0
  117. package/src/spec/PlotTypes.ts +519 -0
  118. package/src/spec/Spec.ts +63 -0
  119. package/src/spec/Transform.ts +394 -0
  120. package/src/spec/VConcat.ts +9 -0
  121. package/src/spec/VSpace.ts +9 -0
  122. package/src/spec/interactors/Highlight.ts +38 -0
  123. package/src/spec/interactors/Interval1D.ts +67 -0
  124. package/src/spec/interactors/Interval2D.ts +48 -0
  125. package/src/spec/interactors/Nearest.ts +28 -0
  126. package/src/spec/interactors/PanZoom.ts +65 -0
  127. package/src/spec/interactors/Toggle.ts +56 -0
  128. package/src/spec/marks/Area.ts +154 -0
  129. package/src/spec/marks/Arrow.ts +108 -0
  130. package/src/spec/marks/Axis.ts +305 -0
  131. package/src/spec/marks/Bar.ts +160 -0
  132. package/src/spec/marks/Cell.ts +62 -0
  133. package/src/spec/marks/Contour.ts +25 -0
  134. package/src/spec/marks/Delaunay.ts +95 -0
  135. package/src/spec/marks/DenseLine.ts +30 -0
  136. package/src/spec/marks/Density.ts +145 -0
  137. package/src/spec/marks/Dot.ts +147 -0
  138. package/src/spec/marks/Frame.ts +23 -0
  139. package/src/spec/marks/Geo.ts +58 -0
  140. package/src/spec/marks/Hexbin.ts +34 -0
  141. package/src/spec/marks/Hexgrid.ts +27 -0
  142. package/src/spec/marks/Image.ts +101 -0
  143. package/src/spec/marks/Line.ts +93 -0
  144. package/src/spec/marks/Link.ts +70 -0
  145. package/src/spec/marks/Marks.ts +1062 -0
  146. package/src/spec/marks/Raster.ts +145 -0
  147. package/src/spec/marks/Rect.ts +183 -0
  148. package/src/spec/marks/Regression.ts +63 -0
  149. package/src/spec/marks/Rule.ts +113 -0
  150. package/src/spec/marks/Text.ts +122 -0
  151. package/src/spec/marks/Tick.ts +69 -0
  152. package/src/spec/marks/Vector.ts +113 -0
  153. package/src/util.js +8 -0
  154. package/tsconfig.json +11 -0
package/src/parse-spec.js CHANGED
@@ -5,27 +5,52 @@ import { ParamRefNode } from './ast/ParamRefNode.js';
5
5
  import { parseAttribute } from './ast/PlotAttributeNode.js';
6
6
  import { SelectionNode } from './ast/SelectionNode.js';
7
7
  import { SpecNode } from './ast/SpecNode.js';
8
-
9
8
  import { componentMap } from './config/components.js';
10
9
  import { inputNames } from './config/inputs.js';
11
10
  import { plotNames } from './config/plots.js';
12
11
  import { transformNames } from './config/transforms.js';
12
+ import { error, paramRef } from './util.js';
13
13
 
14
- import { error, isString, paramRef } from './util.js';
14
+ /**
15
+ * @typedef {{
16
+ * attributes: Set<string>;
17
+ * interactors: Set<string>;
18
+ * legends: Set<string>;
19
+ * marks: Set<string>;
20
+ * }} PlotNames names for supported plot elements
21
+ */
15
22
 
16
23
  /**
17
24
  * Parse a Mosaic specification to an AST (abstract syntax tree).
18
- * @param {object|string} spec The input specification as an object
19
- * or JSON string.
25
+ * @param {import('./spec/Spec.js').Spec} spec The input specification.
20
26
  * @param {object} [options] Optional parse options object.
27
+ * @param {Map<string, Function>} [options.components] Map of component names to parse functions.
28
+ * @param {Set<string>} [options.transforms] The names of allowed transform functions.
29
+ * @param {Set<string>} [options.inputs] The names of supported input widgets.
30
+ * @param {PlotNames} [options.plot] The names of supported plot elements.
31
+ * @param {any[]} [options.params] An array of [name, node] pairs of pre-parsed
32
+ * Param or Selection AST nodes.
33
+ * @param {any[]} [options.datasets] An array of [name, node] pairs of pre-parsed
34
+ * dataset definition AST nodes.
21
35
  * @returns {SpecNode} The top-level AST spec node.
22
36
  */
23
37
  export function parseSpec(spec, options) {
24
- spec = isString(spec) ? JSON.parse(spec) : spec;
25
38
  return new ParseContext(options).parse(spec);
26
39
  }
27
40
 
28
41
  export class ParseContext {
42
+ /**
43
+ * Create a new parser context.
44
+ * @param {object} [options]
45
+ * @param {Map<string, Function>} [options.components] Map of component names to parse functions.
46
+ * @param {Set<string>} [options.transforms] The names of allowed transform functions.
47
+ * @param {Set<string>} [options.inputs] The names of supported input widgets.
48
+ * @param {PlotNames} [options.plot] The names of supported plot elements.
49
+ * @param {any[]} [options.params] An array of [name, node] pairs of pre-parsed
50
+ * Param or Selection AST nodes.
51
+ * @param {any[]} [options.datasets] An array of [name, node] pairs of pre-parsed
52
+ * dataset definition AST nodes.
53
+ */
29
54
  constructor({
30
55
  components = componentMap(),
31
56
  transforms = transformNames(),
@@ -87,6 +112,14 @@ export class ParseContext {
87
112
  this.error(`Invalid specification.`, spec);
88
113
  }
89
114
 
115
+ /**
116
+ * Test if a value is param reference, if so, generate a paramter definition
117
+ * as needed and return a new ParamRefNode. Otherwise, return a LiteralNode.
118
+ * @param {*} value The value to test.
119
+ * @param {() => ParamNode | SelectionNode} [makeNode] A Param of Selection AST
120
+ * node constructor.
121
+ * @returns {ParamRefNode|LiteralNode} An AST node for the input value.
122
+ */
90
123
  maybeParam(value, makeNode = () => new ParamNode) {
91
124
  const { params } = this;
92
125
  const name = paramRef(value);
@@ -0,0 +1,9 @@
1
+ type OmittedProperties =
2
+ | 'parentRule'
3
+ | 'getPropertyPriority'
4
+ | 'getPropertyValue'
5
+ | 'item'
6
+ | 'removeProperty'
7
+ | 'setProperty';
8
+
9
+ export type CSSStyles = Partial<Omit<CSSStyleDeclaration, OmittedProperties>>;
@@ -0,0 +1,184 @@
1
+ export interface DataBaseOptions {
2
+ /**
3
+ * A list of column names to extract upon load.
4
+ * Any other columns are omitted.
5
+ */
6
+ select?: string[];
7
+ /**
8
+ * A filter (WHERE clause) to apply upon load.
9
+ * Only rows that pass the filted are included.
10
+ */
11
+ where?: string | string[];
12
+ /**
13
+ * Flag (default `false`) to generate a view instead of a table.
14
+ */
15
+ view?: boolean;
16
+ /**
17
+ * Flag (default `true`) to generate a temporary view or table.
18
+ */
19
+ temp?: boolean;
20
+ /**
21
+ * Flag (default `true`) to replace an existing table of the same name.
22
+ * If `false`, creating a new table with an existing name raises an error.
23
+ */
24
+ replace?: boolean;
25
+ }
26
+
27
+ /**
28
+ * A SQL query defining a new temporary database table.
29
+ */
30
+ export type DataQuery = string;
31
+
32
+ /**
33
+ * An inline array of data objects to treat as JSON data.
34
+ */
35
+ export type DataArray = object[];
36
+
37
+ /**
38
+ * A data definition that loads an external data file.
39
+ */
40
+ export interface DataFile extends DataBaseOptions {
41
+ /**
42
+ * The data file to load. If no type option is provided,
43
+ * the file suffix must be one of `.csv`, `.json`, or `.parquet`.
44
+ */
45
+ file: `${string}.parquet` | `${string}.csv` | `${string}.json`;
46
+ }
47
+
48
+ /**
49
+ * A data definition that queries an existing table.
50
+ */
51
+ export interface DataTable extends DataBaseOptions {
52
+ /**
53
+ * The data source type. One of:
54
+ * - `"table"`: Define a new table based on a SQL query.
55
+ * - `"csv"`: Load a comma-separated values (CSV) file.
56
+ * - `"json"`: Load JavaScript Object Notation (json) data.
57
+ * - `"parquet"`: Load a Parquet file.
58
+ * - `"spatial"`: Load a spatial data file format via `ST_Read`.
59
+ */
60
+ type: 'table';
61
+ /**
62
+ * A SQL query string for the desired table data.
63
+ */
64
+ query: string;
65
+ }
66
+
67
+ /**
68
+ * A data definition that loads a parquet file.
69
+ */
70
+ export interface DataParquet extends DataBaseOptions {
71
+ /**
72
+ * The data source type. One of:
73
+ * - `"table"`: Define a new table based on a SQL query.
74
+ * - `"csv"`: Load a comma-separated values (CSV) file.
75
+ * - `"json"`: Load JavaScript Object Notation (json) data.
76
+ * - `"parquet"`: Load a Parquet file.
77
+ * - `"spatial"`: Load a spatial data file format via `ST_Read`.
78
+ */
79
+ type: 'parquet';
80
+ /**
81
+ * The file path for the dataset to load.
82
+ */
83
+ file: string;
84
+ }
85
+
86
+ /**
87
+ * A data definition that loads a csv file.
88
+ */
89
+ export interface DataCSV extends DataBaseOptions {
90
+ /**
91
+ * The data source type. One of:
92
+ * - `"table"`: Define a new table based on a SQL query.
93
+ * - `"csv"`: Load a comma-separated values (CSV) file.
94
+ * - `"json"`: Load JavaScript Object Notation (json) data.
95
+ * - `"parquet"`: Load a Parquet file.
96
+ * - `"spatial"`: Load a spatial data file format via `ST_Read`.
97
+ */
98
+ type: 'csv';
99
+ /**
100
+ * The file path for the dataset to load.
101
+ */
102
+ file: string;
103
+ /**
104
+ * The column delimiter string. If not specified, DuckDB will try to infer
105
+ * the delimiter automatically.
106
+ */
107
+ delimiter?: string,
108
+ /**
109
+ * The sample size, in table rows, to consult for type inference.
110
+ * Set to `-1` to process all rows in the dataset.
111
+ */
112
+ sample_size?: number;
113
+ }
114
+
115
+ /**
116
+ * A data definition that loads a supported spatial data file format.
117
+ */
118
+ export interface DataSpatial extends DataBaseOptions {
119
+ /**
120
+ * The data source type. One of:
121
+ * - `"table"`: Define a new table based on a SQL query.
122
+ * - `"csv"`: Load a comma-separated values (CSV) file.
123
+ * - `"json"`: Load JavaScript Object Notation (json) data.
124
+ * - `"parquet"`: Load a Parquet file.
125
+ * - `"spatial"`: Load a spatial data file format via `ST_Read`.
126
+ */
127
+ type: 'spatial';
128
+ /**
129
+ * The file path for the spatial dataset to load. See the [DuckDB spatial
130
+ * documention][1] for more information on supported file types.
131
+ *
132
+ * [1]: https://duckdb.org/docs/extensions/spatial.html#st_read--read-spatial-data-from-files
133
+ */
134
+ file: string;
135
+ /**
136
+ * The named layer to load from the file. For example, in a TopoJSON file
137
+ * the layer is the named object to extract. For Excel spreadsheet files,
138
+ * the layer is the name of the worksheet to extract.
139
+ */
140
+ layer?: string;
141
+ }
142
+
143
+ export interface DataJSON extends DataBaseOptions {
144
+ /**
145
+ * The data source type. One of:
146
+ * - `"table"`: Define a new table based on a SQL query.
147
+ * - `"csv"`: Load a comma-separated values (CSV) file.
148
+ * - `"json"`: Load JavaScript Object Notation (json) data.
149
+ * - `"parquet"`: Load a Parquet file.
150
+ * - `"spatial"`: Load a spatial data file format via `ST_Read`.
151
+ */
152
+ type: 'json';
153
+ /**
154
+ * The file path for the dataset to load.
155
+ */
156
+ file: string;
157
+ }
158
+
159
+ export interface DataJSONObjects extends DataBaseOptions {
160
+ /**
161
+ * The data source type. One of:
162
+ * - `"table"`: Define a new table based on a SQL query.
163
+ * - `"csv"`: Load a comma-separated values (CSV) file.
164
+ * - `"json"`: Load JavaScript Object Notation (json) data.
165
+ * - `"parquet"`: Load a Parquet file.
166
+ * - `"spatial"`: Load a spatial data file format via `ST_Read`.
167
+ */
168
+ type?: 'json';
169
+ /**
170
+ * An array of inline objects in JSON-style format.
171
+ */
172
+ data: object[];
173
+ }
174
+
175
+ export type DataDefinition =
176
+ | DataQuery
177
+ | DataArray
178
+ | DataFile
179
+ | DataTable
180
+ | DataParquet
181
+ | DataCSV
182
+ | DataSpatial
183
+ | DataJSON
184
+ | DataJSONObjects;
@@ -0,0 +1,31 @@
1
+ export type Expression =
2
+ | SQLExpression
3
+ | AggregateExpression;
4
+
5
+ /** A custom SQL expression. */
6
+ export interface SQLExpression {
7
+ /**
8
+ * A SQL expression string to derive a new column value.
9
+ * Embedded Param refrences, such as `$param + 1`, are supported.
10
+ * For expressions with aggregate functions, use *agg* instead.
11
+ */
12
+ sql: string;
13
+ /**
14
+ * A label for this expression, for example to label a plot axis.
15
+ */
16
+ label?: string;
17
+ }
18
+
19
+ /** A custom SQL aggregate expression. */
20
+ export interface AggregateExpression {
21
+ /**
22
+ * A SQL expression string to calculate an aggregate value.
23
+ * Embedded Param references, such as `SUM($param + 1)`, are supported.
24
+ * For expressions without aggregate functions, use *sql* instead.
25
+ */
26
+ agg: string;
27
+ /**
28
+ * A label for this expression, for example to label a plot axis.
29
+ */
30
+ label?: string;
31
+ }
@@ -0,0 +1,9 @@
1
+ import { Component } from './Spec.js';
2
+
3
+ /** An hconcat component. */
4
+ export interface HConcat {
5
+ /**
6
+ * Horizontally concatenate components in a row layout.
7
+ */
8
+ hconcat: Component[];
9
+ }
@@ -0,0 +1,9 @@
1
+ /** An hspace component. */
2
+ export interface HSpace {
3
+ /**
4
+ * Horizontal space to place between components.
5
+ * Number values indicate screen pixels.
6
+ * String values may use CSS units (em, pt, px, etc).
7
+ */
8
+ hspace: number | string;
9
+ }
@@ -0,0 +1,182 @@
1
+ import { ParamRef } from './Param.js';
2
+
3
+ /** A menu input component. */
4
+ export interface Menu {
5
+ /**
6
+ * A menu input widget.
7
+ */
8
+ input: 'menu';
9
+ /**
10
+ * The output selection. A selection clause is added for the
11
+ * currently selected menu option.
12
+ */
13
+ as?: ParamRef;
14
+ /**
15
+ * The name of a database table to use as a data source for this widget.
16
+ * Used in conjunction with the `column` property.
17
+ */
18
+ from?: string;
19
+ /**
20
+ * The name of a database column from which to pull menu options.
21
+ * The unique column values are used as menu options.
22
+ * Used in conjunction with the `from` property.
23
+ */
24
+ column?: string;
25
+ /**
26
+ * A selection to filter the database table indicated by the `from` property.
27
+ */
28
+ filterBy?: ParamRef;
29
+ /**
30
+ * A text label for this input.
31
+ */
32
+ label?: string;
33
+ /**
34
+ * An array of menu options, as literal values or option objects.
35
+ * Option objects have a `value` property and an optional `label` property.
36
+ * If no label is provided, the (string-coerced) value is used.
37
+ */
38
+ options?: Array<any>;
39
+ /**
40
+ * The initial selected menu option.
41
+ */
42
+ value?: any;
43
+ }
44
+
45
+ /** A search input component. */
46
+ export interface Search {
47
+ /**
48
+ * A text search input widget.
49
+ */
50
+ input: 'search';
51
+ /**
52
+ * The output selection. A selection clause is added for the
53
+ * current text search query.
54
+ */
55
+ as?: ParamRef;
56
+ /**
57
+ * The type of text search query to perform. One of:
58
+ * - `"contains"` (default): the query string may appear anywhere in the text
59
+ * - `"prefix"`: the query string must appear at the start of the text
60
+ * - `"suffix"`: the query string must appear at the end of the text
61
+ * - `"regexp"`: the query string is a regular expression the text must match
62
+ */
63
+ type?: 'contains' | 'prefix' | 'suffix' | 'regexp';
64
+ /**
65
+ * The name of a database table to use as an autocomplete data source
66
+ * for this widget. Used in conjunction with the `column` property.
67
+ */
68
+ from?: string;
69
+ /**
70
+ * The name of a database column from which to pull valid search results.
71
+ * The unique column values are used as search autocomplete values.
72
+ * Used in conjunction with the `from` property.
73
+ */
74
+ column?: string;
75
+ /**
76
+ * A selection to filter the database table indicated by the `from` property.
77
+ */
78
+ filterBy?: ParamRef;
79
+ /**
80
+ * A text label for this input.
81
+ */
82
+ label?: string;
83
+ }
84
+
85
+ /** A slider input component. */
86
+ export interface Slider {
87
+ /**
88
+ * A slider input widget.
89
+ */
90
+ input: 'slider';
91
+ /**
92
+ * The output selection. A selection clause is added for the
93
+ * currently selected slider option.
94
+ */
95
+ as?: ParamRef;
96
+ /**
97
+ * The name of a database table to use as a data source for this widget.
98
+ * Used in conjunction with the `column` property.
99
+ * The minimum and maximum values of the column determine the slider range.
100
+ */
101
+ from?: string;
102
+ /**
103
+ * The name of a database column whose values determine the slider range.
104
+ * Used in conjunction with the `from` property.
105
+ * The minimum and maximum values of the column determine the slider range.
106
+ */
107
+ column?: string;
108
+ /**
109
+ * A selection to filter the database table indicated by the `from` property.
110
+ */
111
+ filterBy?: ParamRef;
112
+ /**
113
+ * The minumum slider value.
114
+ */
115
+ min?: number;
116
+ /**
117
+ * The maximum slider value.
118
+ */
119
+ max?: number;
120
+ /**
121
+ * The slider step, the amount to increment between consecutive values.
122
+ */
123
+ step?: number;
124
+ /**
125
+ * A text label for this input.
126
+ */
127
+ label?: string;
128
+ /**
129
+ * The initial slider value.
130
+ */
131
+ value?: number;
132
+ /**
133
+ * The width of the slider in screen pixels.
134
+ */
135
+ width?: number;
136
+ }
137
+
138
+ /** A table grid view component. */
139
+ export interface Table {
140
+ /**
141
+ * A table grid widget.
142
+ */
143
+ input: 'table';
144
+ /**
145
+ * The name of a database table to use as a data source for this widget.
146
+ */
147
+ from: string;
148
+ /**
149
+ * A list of column names to include in the table grid.
150
+ * If unspecified, all table columns are included.
151
+ */
152
+ columns?: string[];
153
+ /**
154
+ * A selection to filter the database table indicated by the `from` property.
155
+ */
156
+ filterBy?: ParamRef;
157
+ /**
158
+ * An object of per-column alignment values.
159
+ * Column names should be object keys, which map to alignment values.
160
+ * Valid alignment values are: `"left"`, `"right"`, `"center"`, and `"justify"`.
161
+ * By default, numbers are right-aligned and other values are left-aligned.
162
+ */
163
+ align?: { [column: string]: 'left' | 'right' | 'center' | 'justify' };
164
+ /**
165
+ * If a number, sets the total width of the table widget, in pixels.
166
+ * If an object, provides per-column pixel width values.
167
+ * Column names should be object keys, mapped to numeric width values.
168
+ */
169
+ width?: number | { [column : string]: number };
170
+ /**
171
+ * The maximum width of the table widget, in pixels.
172
+ */
173
+ maxWidth?: number;
174
+ /**
175
+ * The height of the table widget, in pixels.
176
+ */
177
+ height?: number;
178
+ /**
179
+ * The number of rows load in a new batch upon table scroll.
180
+ */
181
+ rowBatch?: number;
182
+ }
@@ -0,0 +1,68 @@
1
+ export type ParamRef = `$${string}`;
2
+
3
+ /** Base properties shared by Param definitions. */
4
+ export interface ParamBase {
5
+ /**
6
+ * The type of reactive parameter. One of:
7
+ * - `"value"` (default) for a standard `Param`
8
+ * - `"intersect"` for a `Selection` that intersects clauses (logical "and")
9
+ * - `"union"` for a `Selection` that unions clauses (logical "or")
10
+ * - `"single"` for a `Selection` that retains a single clause only
11
+ * - `"crossfilter"` for a cross-filtered intersection `Selection`
12
+ */
13
+ select?: 'value';
14
+ }
15
+
16
+ /** A Param definition. */
17
+ export interface Param extends ParamBase {
18
+ /**
19
+ * The initial parameter value.
20
+ */
21
+ value: ParamValue;
22
+ }
23
+
24
+ /** A Date-valued Param definition. */
25
+ export interface ParamDate extends ParamBase {
26
+ /**
27
+ * The initial parameter value as an ISO date/time
28
+ * string to be parsed to a Date object.
29
+ */
30
+ date: string;
31
+ }
32
+
33
+ /** Literal Param values. */
34
+ export type ParamLiteral =
35
+ | string
36
+ | number
37
+ | boolean;
38
+
39
+ /** Valid Param values. */
40
+ export type ParamValue =
41
+ | ParamLiteral
42
+ | Array<ParamLiteral | ParamRef>;
43
+
44
+ /** A Selection definition. */
45
+ export interface Selection {
46
+ /**
47
+ * The type of reactive parameter. One of:
48
+ * - `"value"` (default) for a standard `Param`
49
+ * - `"intersect"` for a `Selection` that intersects clauses (logical "and")
50
+ * - `"union"` for a `Selection` that unions clauses (logical "or")
51
+ * - `"single"` for a `Selection` that retains a single clause only
52
+ * - `"crossfilter"` for a cross-filtered intersection `Selection`
53
+ */
54
+ select: 'crossfilter' | 'intersect' | 'single' | 'union';
55
+
56
+ /**
57
+ * A flag for cross-filtering, where selections made in a plot filter others
58
+ * but not oneself (default `false`, except for `crossfilter` selections).
59
+ */
60
+ cross?: boolean;
61
+ }
62
+
63
+ /** A Param or Selection definition. */
64
+ export type ParamDefinition =
65
+ | ParamValue
66
+ | Param
67
+ | ParamDate
68
+ | Selection;
@@ -0,0 +1,15 @@
1
+ import { PlotAttributes } from './PlotAttribute.js';
2
+ import { PlotInteractor } from './PlotInteractor.js';
3
+ import { PlotLegend } from './PlotLegend.js';
4
+ import { PlotMark } from './PlotMark.js';
5
+
6
+ /** A plot component. */
7
+ export interface Plot extends PlotAttributes {
8
+ /**
9
+ * An array of plot marks, interactors, or legends.
10
+ * Marks are graphical elements that make up plot layers.
11
+ * Unless otherwise configured, interactors will use the nearest
12
+ * previous mark as a basis for which data fields to select.
13
+ */
14
+ plot: (PlotMark | PlotInteractor | PlotLegend)[];
15
+ }