@perspective-dev/viewer 5.1.0 → 5.3.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 (245) hide show
  1. package/dist/cdn/perspective-viewer.js +9 -9
  2. package/dist/cdn/perspective-viewer.js.map +4 -4
  3. package/dist/css/botanical.css +1 -1
  4. package/dist/css/dracula.css +1 -1
  5. package/dist/css/gruvbox-dark.css +1 -1
  6. package/dist/css/gruvbox.css +1 -1
  7. package/dist/css/icons.css +1 -1
  8. package/dist/css/intl/de.css +1 -1
  9. package/dist/css/intl/es.css +1 -1
  10. package/dist/css/intl/fr.css +1 -1
  11. package/dist/css/intl/ja.css +1 -1
  12. package/dist/css/intl/pt.css +1 -1
  13. package/dist/css/intl/zh.css +1 -1
  14. package/dist/css/intl.css +1 -1
  15. package/dist/css/monokai.css +1 -1
  16. package/dist/css/phosphor.css +1 -1
  17. package/dist/css/pro-dark.css +1 -1
  18. package/dist/css/pro.css +1 -1
  19. package/dist/css/solarized-dark.css +1 -1
  20. package/dist/css/solarized.css +1 -1
  21. package/dist/css/themes.css +1 -1
  22. package/dist/css/vaporwave.css +1 -1
  23. package/dist/docs/perspective-docs.json +1 -0
  24. package/dist/esm/column-format.d.ts +19 -28
  25. package/dist/esm/perspective-viewer.d.ts +3 -0
  26. package/dist/esm/perspective-viewer.inline.js +9 -9
  27. package/dist/esm/perspective-viewer.inline.js.map +4 -4
  28. package/dist/esm/perspective-viewer.js +9 -9
  29. package/dist/esm/perspective-viewer.js.map +4 -4
  30. package/dist/esm/plugin.d.ts +10 -0
  31. package/dist/esm/providers.d.ts +79 -0
  32. package/dist/esm/ts-rs/CompactDisplay.d.ts +5 -0
  33. package/dist/esm/ts-rs/CurrencyCode.d.ts +1 -0
  34. package/dist/esm/ts-rs/CurrencyDisplay.d.ts +1 -0
  35. package/dist/esm/ts-rs/CurrencyNumberFormatStyle.d.ts +8 -0
  36. package/dist/esm/ts-rs/CurrencySign.d.ts +1 -0
  37. package/dist/esm/ts-rs/CustomDatetimeFormat.d.ts +1 -0
  38. package/dist/esm/ts-rs/CustomDatetimeStyleConfig.d.ts +54 -0
  39. package/dist/esm/ts-rs/CustomNumberFormatConfig.d.ts +34 -0
  40. package/dist/esm/ts-rs/DatetimeColorMode.d.ts +1 -0
  41. package/dist/esm/ts-rs/DatetimeFormatType.d.ts +6 -0
  42. package/dist/esm/ts-rs/FormatMode.d.ts +1 -0
  43. package/dist/esm/ts-rs/FormatUnit.d.ts +1 -0
  44. package/dist/esm/ts-rs/Notation.d.ts +17 -0
  45. package/dist/esm/ts-rs/NumberFormatStyle.d.ts +18 -0
  46. package/dist/esm/ts-rs/PanelViewerConfig.d.ts +42 -2
  47. package/dist/esm/ts-rs/PluginStaticConfig.d.ts +35 -0
  48. package/dist/esm/ts-rs/RestoreOptions.d.ts +19 -0
  49. package/dist/esm/ts-rs/RoundingMode.d.ts +1 -0
  50. package/dist/esm/ts-rs/RoundingPriority.d.ts +1 -0
  51. package/dist/esm/ts-rs/SaveWorkspaceOptions.d.ts +10 -0
  52. package/dist/esm/ts-rs/SignDisplay.d.ts +1 -0
  53. package/dist/esm/ts-rs/SimpleDatetimeFormat.d.ts +1 -0
  54. package/dist/esm/ts-rs/SimpleDatetimeStyleConfig.d.ts +24 -0
  55. package/dist/esm/ts-rs/SplitRollupMode.d.ts +9 -0
  56. package/dist/esm/ts-rs/StringColorMode.d.ts +1 -0
  57. package/dist/esm/ts-rs/TrailingZeroDisplay.d.ts +1 -0
  58. package/dist/esm/ts-rs/Unit.d.ts +1 -0
  59. package/dist/esm/ts-rs/UnitDisplay.d.ts +1 -0
  60. package/dist/esm/ts-rs/UnitNumberFormatStyle.d.ts +6 -0
  61. package/dist/esm/ts-rs/UseGrouping.d.ts +1 -0
  62. package/dist/esm/ts-rs/ViewerConfig.d.ts +42 -2
  63. package/dist/esm/ts-rs/ViewerConfigInitial.d.ts +175 -0
  64. package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +63 -0
  65. package/dist/esm/ts-rs/WindowSpec.d.ts +3 -2
  66. package/dist/esm/ts-rs/WorkspaceConfig.d.ts +9 -1
  67. package/dist/esm/ts-rs/WorkspaceConfigUpdate.d.ts +20 -9
  68. package/dist/wasm/perspective-viewer.d.ts +157 -41
  69. package/dist/wasm/perspective-viewer.js +452 -151
  70. package/dist/wasm/perspective-viewer.wasm +0 -0
  71. package/dist/wasm/perspective-viewer.wasm.d.ts +22 -17
  72. package/package.json +2 -1
  73. package/src/css/_viewer_bundle.css +1 -0
  74. package/src/css/column-selector.css +8 -0
  75. package/src/css/column-settings-panel.css +9 -5
  76. package/src/css/column-style.css +209 -31
  77. package/src/css/config-selector.css +38 -3
  78. package/src/css/dom/select.css +2 -1
  79. package/src/css/form/code-editor.css +6 -7
  80. package/src/css/form/mirrored-textarea.css +81 -0
  81. package/src/css/viewer.css +328 -0
  82. package/src/rust/agent/client/mod.rs +19 -0
  83. package/src/rust/agent/client/protocol.rs +320 -0
  84. package/src/rust/agent/client/transport.rs +287 -0
  85. package/src/rust/agent/client/turn.rs +174 -0
  86. package/src/rust/agent/config.rs +159 -0
  87. package/src/rust/agent/docs.rs +293 -0
  88. package/src/rust/agent/markdown/block.rs +509 -0
  89. package/src/rust/agent/markdown/entity.rs +52 -0
  90. package/src/rust/agent/markdown/events.rs +71 -0
  91. package/src/rust/agent/markdown/inline.rs +497 -0
  92. package/src/rust/agent/markdown/mod.rs +466 -0
  93. package/src/rust/agent/mod.rs +23 -0
  94. package/src/rust/agent/preamble.md +16 -0
  95. package/src/rust/agent/runtime.rs +201 -0
  96. package/src/rust/agent/slot.rs +236 -0
  97. package/src/rust/agent/tools.rs +1141 -0
  98. package/src/rust/components/chat_panel.rs +289 -0
  99. package/src/rust/components/column_selector/active_column.rs +2 -2
  100. package/src/rust/components/column_selector/add_expression_button.rs +3 -3
  101. package/src/rust/components/column_selector/aggregate_selector.rs +2 -3
  102. package/src/rust/components/column_selector/config_selector.rs +84 -7
  103. package/src/rust/components/column_selector/expr_edit_button.rs +4 -10
  104. package/src/rust/components/column_selector/inactive_column.rs +2 -2
  105. package/src/rust/components/column_selector.rs +55 -4
  106. package/src/rust/components/column_settings_sidebar/style_tab/primitive_field.rs +293 -126
  107. package/src/rust/components/column_settings_sidebar/style_tab.rs +262 -225
  108. package/src/rust/components/column_settings_sidebar.rs +88 -69
  109. package/src/rust/components/containers/dragdrop_list.rs +37 -0
  110. package/src/rust/components/editable_header.rs +85 -144
  111. package/src/rust/components/expression_editor.rs +9 -16
  112. package/src/rust/components/form/code_editor.rs +29 -28
  113. package/src/rust/components/form/debug.rs +9 -5
  114. package/src/rust/components/form/mirrored_textarea.rs +165 -0
  115. package/src/rust/components/form/mod.rs +4 -1
  116. package/src/rust/components/form/multi_stop_gradient_selector.rs +476 -0
  117. package/src/rust/components/form/named_value_picker.rs +86 -0
  118. package/src/rust/components/form/palette_selector.rs +440 -0
  119. package/src/rust/components/main_panel/msg.rs +2 -2
  120. package/src/rust/components/main_panel/reconcile.rs +4 -4
  121. package/src/rust/components/mod.rs +2 -0
  122. package/src/rust/components/plugin_tab.rs +4 -28
  123. package/src/rust/components/settings_panel.rs +105 -22
  124. package/src/rust/components/viewer/msg.rs +46 -7
  125. package/src/rust/components/viewer/panels.rs +17 -20
  126. package/src/rust/components/viewer/render.rs +10 -3
  127. package/src/rust/components/viewer/settings.rs +163 -23
  128. package/src/rust/components/viewer/snapshots.rs +46 -21
  129. package/src/rust/components/viewer/wiring.rs +14 -25
  130. package/src/rust/components/viewer.rs +12 -8
  131. package/src/rust/components/window_editor.rs +75 -103
  132. package/src/rust/config/column_config_schema.rs +100 -41
  133. package/src/rust/config/css_scale.rs +882 -0
  134. package/src/rust/config/datetime_column_style/custom.rs +17 -0
  135. package/src/rust/config/datetime_column_style/simple.rs +10 -0
  136. package/src/rust/config/mod.rs +2 -0
  137. package/src/rust/config/number_string_format.rs +33 -0
  138. package/src/rust/config/options.rs +28 -0
  139. package/src/rust/config/plugin_static_config.rs +120 -5
  140. package/src/rust/config/viewer_config.rs +216 -3
  141. package/src/rust/config/workspace_config.rs +138 -10
  142. package/src/rust/custom_elements/viewer.rs +369 -119
  143. package/src/rust/custom_events.rs +43 -1
  144. package/src/rust/js/regular_layout.rs +3 -3
  145. package/src/rust/lib.rs +15 -0
  146. package/src/rust/presentation/column_locator.rs +19 -5
  147. package/src/rust/presentation.rs +200 -36
  148. package/src/rust/queries/column_locator.rs +74 -44
  149. package/src/rust/queries/get_viewer_config.rs +2 -1
  150. package/src/rust/queries/mod.rs +2 -0
  151. package/src/rust/queries/palette_set.rs +82 -0
  152. package/src/rust/queries/plugin_column_styles.rs +6 -2
  153. package/src/rust/renderer/dispatch.rs +16 -4
  154. package/src/rust/renderer/plugin_config.rs +309 -47
  155. package/src/rust/renderer.rs +15 -42
  156. package/src/rust/session/column_defaults_update.rs +32 -7
  157. package/src/rust/session/metadata.rs +23 -21
  158. package/src/rust/session/props.rs +1 -0
  159. package/src/rust/session/replace_expression_update.rs +1 -0
  160. package/src/rust/session.rs +9 -6
  161. package/src/rust/tasks/create_panel.rs +46 -49
  162. package/src/rust/tasks/edit_expression.rs +19 -23
  163. package/src/rust/tasks/edit_window.rs +9 -11
  164. package/src/rust/tasks/eject.rs +4 -1
  165. package/src/rust/tasks/pipeline.rs +2 -2
  166. package/src/rust/tasks/presize_panels.rs +44 -5
  167. package/src/rust/tasks/reset_all.rs +4 -4
  168. package/src/rust/tasks/restore_and_render.rs +17 -44
  169. package/src/rust/tasks/restore_panel.rs +37 -22
  170. package/src/rust/tasks/set_edit_mode.rs +3 -1
  171. package/src/rust/tasks/sync_update_panels.rs +18 -24
  172. package/src/rust/tasks/update_theme.rs +23 -18
  173. package/src/rust/utils/css_vars.rs +26 -0
  174. package/src/rust/utils/mod.rs +2 -0
  175. package/src/rust/utils/spawn.rs +1 -1
  176. package/src/rust/workspace.rs +454 -199
  177. package/src/svg/lock.svg +7 -0
  178. package/src/themes/botanical.css +10 -0
  179. package/src/themes/defaults.css +12 -0
  180. package/src/themes/dracula.css +17 -0
  181. package/src/themes/gruvbox-dark.css +20 -0
  182. package/src/themes/gruvbox.css +10 -0
  183. package/src/themes/icons.css +1 -0
  184. package/src/themes/intl/de.css +16 -0
  185. package/src/themes/intl/es.css +16 -0
  186. package/src/themes/intl/fr.css +16 -0
  187. package/src/themes/intl/ja.css +16 -0
  188. package/src/themes/intl/pt.css +16 -0
  189. package/src/themes/intl/zh.css +16 -0
  190. package/src/themes/intl.css +16 -0
  191. package/src/themes/monokai.css +22 -0
  192. package/src/themes/phosphor.css +5 -0
  193. package/src/themes/pro-dark.css +10 -0
  194. package/src/themes/solarized-dark.css +7 -0
  195. package/src/themes/solarized.css +7 -0
  196. package/src/themes/vaporwave.css +20 -0
  197. package/src/ts/column-format.ts +67 -46
  198. package/src/ts/perspective-viewer.ts +3 -0
  199. package/src/ts/plugin.ts +14 -0
  200. package/src/ts/providers.ts +96 -0
  201. package/src/ts/ts-rs/CompactDisplay.ts +3 -0
  202. package/src/ts/ts-rs/CurrencyCode.ts +3 -0
  203. package/src/ts/ts-rs/CurrencyDisplay.ts +3 -0
  204. package/src/ts/ts-rs/CurrencyNumberFormatStyle.ts +6 -0
  205. package/src/ts/ts-rs/CurrencySign.ts +3 -0
  206. package/src/ts/ts-rs/CustomDatetimeFormat.ts +3 -0
  207. package/src/ts/ts-rs/CustomDatetimeStyleConfig.ts +54 -0
  208. package/src/ts/ts-rs/CustomNumberFormatConfig.ts +25 -0
  209. package/src/ts/ts-rs/DatetimeColorMode.ts +3 -0
  210. package/src/ts/ts-rs/DatetimeFormatType.ts +8 -0
  211. package/src/ts/ts-rs/FormatMode.ts +3 -0
  212. package/src/ts/ts-rs/FormatUnit.ts +3 -0
  213. package/src/ts/ts-rs/Notation.ts +11 -0
  214. package/src/ts/ts-rs/NumberFormatStyle.ts +12 -0
  215. package/src/ts/ts-rs/PanelViewerConfig.ts +48 -2
  216. package/src/ts/ts-rs/PluginStaticConfig.ts +36 -1
  217. package/src/ts/ts-rs/RestoreOptions.ts +20 -0
  218. package/src/ts/ts-rs/RoundingMode.ts +3 -0
  219. package/src/ts/ts-rs/RoundingPriority.ts +3 -0
  220. package/src/ts/ts-rs/SaveWorkspaceOptions.ts +11 -0
  221. package/src/ts/ts-rs/SignDisplay.ts +3 -0
  222. package/src/ts/ts-rs/SimpleDatetimeFormat.ts +3 -0
  223. package/src/ts/ts-rs/SimpleDatetimeStyleConfig.ts +25 -0
  224. package/src/ts/ts-rs/SplitRollupMode.ts +11 -0
  225. package/src/ts/ts-rs/StringColorMode.ts +3 -0
  226. package/src/ts/ts-rs/TrailingZeroDisplay.ts +3 -0
  227. package/src/ts/ts-rs/Unit.ts +3 -0
  228. package/src/ts/ts-rs/UnitDisplay.ts +3 -0
  229. package/src/ts/ts-rs/UnitNumberFormatStyle.ts +5 -0
  230. package/src/ts/ts-rs/UseGrouping.ts +3 -0
  231. package/src/ts/ts-rs/ViewerConfig.ts +48 -2
  232. package/src/ts/ts-rs/ViewerConfigInitial.ts +164 -0
  233. package/src/ts/ts-rs/ViewerConfigUpdate.ts +72 -2
  234. package/src/ts/ts-rs/WindowSpec.ts +3 -2
  235. package/src/ts/ts-rs/WorkspaceConfig.ts +8 -2
  236. package/src/ts/ts-rs/WorkspaceConfigUpdate.ts +18 -9
  237. package/dist/esm/ts-rs/WindowAggregate.d.ts +0 -1
  238. package/src/rust/components/form/color_range_selector.rs +0 -137
  239. package/src/ts/ts-rs/WindowAggregate.ts +0 -3
  240. /package/dist/wasm/snippets/{perspective-viewer-8a8c7d5d696b43ae → perspective-viewer-39c3c3b28e3cbd48}/inline0.js +0 -0
  241. /package/dist/wasm/snippets/{perspective-viewer-8a8c7d5d696b43ae → perspective-viewer-39c3c3b28e3cbd48}/inline1.js +0 -0
  242. /package/dist/wasm/snippets/{perspective-viewer-8a8c7d5d696b43ae → perspective-viewer-39c3c3b28e3cbd48}/inline2.js +0 -0
  243. /package/dist/wasm/snippets/{perspective-viewer-8a8c7d5d696b43ae → perspective-viewer-39c3c3b28e3cbd48}/inline3.js +0 -0
  244. /package/dist/wasm/snippets/{perspective-viewer-8a8c7d5d696b43ae → perspective-viewer-39c3c3b28e3cbd48}/inline4.js +0 -0
  245. /package/dist/wasm/snippets/{perspective-viewer-8a8c7d5d696b43ae → perspective-viewer-39c3c3b28e3cbd48}/inline5.js +0 -0
@@ -0,0 +1,164 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { Aggregate } from "./Aggregate.js";
3
+ import type { Expressions } from "./Expressions.js";
4
+ import type { Filter } from "./Filter.js";
5
+ import type { FilterReducer } from "./FilterReducer.js";
6
+ import type { GroupRollupMode } from "./GroupRollupMode.js";
7
+ import type { Sort } from "./Sort.js";
8
+ import type { SplitRollupMode } from "./SplitRollupMode.js";
9
+ import type { Windows } from "./Windows.js";
10
+ import type { JsonValue } from "./serde_json/JsonValue.js";
11
+
12
+ /**
13
+ * The initial configuration of a NEW panel (`addPanel`, `restore`'s
14
+ * panel-creating upsert, `restoreWorkspace` `panels` entries). Unlike
15
+ * [`ViewerConfigUpdate`] — a patch against existing state — creation has
16
+ * no prior state: `table` is REQUIRED (a placed panel without a table
17
+ * binding would be permanently blank), absent fields mean "default"
18
+ * rather than "leave unchanged" (so no [`OptionalUpdate`] tri-state), and
19
+ * there is no `settings` field (element-level, not per-panel).
20
+ */
21
+ export type ViewerConfigInitial = {
22
+ /**
23
+ * Name of the `Table` the new panel renders, as hosted on the
24
+ * `Client`. REQUIRED: a placed panel with no table binding would be
25
+ * permanently blank.
26
+ */
27
+ table: string,
28
+ /**
29
+ * The `@perspective-dev/viewer` version a saved config was written
30
+ * by. Omit it when creating a panel.
31
+ */
32
+ version?: string,
33
+ /**
34
+ * Name of the visualization plugin, from the set registered on the
35
+ * page (the `list_plugins` agent tool, or the plugin picker).
36
+ * Decides what the view fields MEAN: `columns` is positional and
37
+ * every plugin reads the positions differently, and
38
+ * `group_by`/`split_by` draw different things per plugin. Absent
39
+ * uses the default plugin.
40
+ */
41
+ plugin?: string,
42
+ /**
43
+ * Panel title, shown in its tab. Absent renders the default title.
44
+ */
45
+ title?: string,
46
+ /**
47
+ * Theme NAME (e.g. `"Pro Dark"`) — not a CSS value. Valid names are
48
+ * the Perspective themes loaded on the page. Absent uses the
49
+ * default.
50
+ */
51
+ theme?: string,
52
+ /**
53
+ * Plugin-wide settings (as opposed to the per-column
54
+ * [`Self::columns_config`]). Opaque to the viewer and defined by
55
+ * the ACTIVE plugin; query the valid keys with `get_style_schema`
56
+ * rather than guessing.
57
+ */
58
+ plugin_config?: { [key in string]?: JsonValue },
59
+ /**
60
+ * Per-column styling — formatting, colors, and other per-column
61
+ * controls — keyed by column name. Plugin-defined like
62
+ * [`Self::plugin_config`]; see `get_style_schema`.
63
+ */
64
+ columns_config?: { [key in string]?: { [key in string]?: JsonValue } },
65
+ /**
66
+ * A group by _groups_ the dataset by the unique values of each column used
67
+ * as a group by - a close analogue in SQL to the `GROUP BY` statement.
68
+ * The underlying dataset is aggregated to show the values belonging to
69
+ * each group, and a total row is calculated for each group, showing
70
+ * the currently selected aggregated value (e.g. `sum`) of the column.
71
+ * Group by are useful for hierarchies, categorizing data and
72
+ * attributing values, i.e. showing the number of units sold based on
73
+ * State and City. In Perspective, group by are represented as an array
74
+ * of string column names to pivot, are applied in the order provided;
75
+ * For example, a group by of `["State", "City", "Postal Code"]` shows
76
+ * the values for each Postal Code, which are grouped by City,
77
+ * which are in turn grouped by State.
78
+ */
79
+ group_by?: Array<string>,
80
+ /**
81
+ * A split by _splits_ the dataset by the unique values of each column used
82
+ * as a split by. The underlying dataset is not aggregated, and a new
83
+ * column is created for each unique value of the split by. Each newly
84
+ * created column contains the parts of the dataset that correspond to
85
+ * the column header, i.e. a `View` that has `["State"]` as its split
86
+ * by will have a new column for each state. In Perspective, Split By
87
+ * are represented as an array of string column names to pivot.
88
+ */
89
+ split_by?: Array<string>,
90
+ /**
91
+ * The `columns` property specifies which columns should be included in the
92
+ * [`crate::View`]'s output. This allows users to show or hide a specific
93
+ * subset of columns, as well as control the order in which columns
94
+ * appear to the user. This is represented in Perspective as an array
95
+ * of string column names.
96
+ */
97
+ columns?: Array<string | null>,
98
+ /**
99
+ * The `filter` property specifies columns on which the query can be
100
+ * filtered, returning rows that pass the specified filter condition.
101
+ * This is analogous to the `WHERE` clause in SQL. There is no limit on
102
+ * the number of columns where `filter` is applied, but the resulting
103
+ * dataset is one that passes all the filter conditions, i.e. the
104
+ * filters are joined with an `AND` condition.
105
+ *
106
+ * Perspective represents `filter` as an array of arrays, with the values
107
+ * of each inner array being a string column name, a string filter
108
+ * operator, and a filter operand in the type of the column.
109
+ */
110
+ filter?: Array<Filter>,
111
+ /**
112
+ * The `sort` property specifies columns on which the query should be
113
+ * sorted, analogous to `ORDER BY` in SQL. A column can be sorted
114
+ * regardless of its data type, and sorts can be applied in ascending
115
+ * or descending order. Perspective represents `sort` as an array of
116
+ * arrays, with the values of each inner array being a string column
117
+ * name and a string sort direction. When `column-pivots` are applied,
118
+ * the additional sort directions `"col asc"` and `"col desc"` will
119
+ * determine the order of pivot columns groups.
120
+ *
121
+ * `sort` is the ONLY thing that orders a `View`'s rows — without it
122
+ * they keep the `Table`'s natural (insertion) order, which any
123
+ * consumer reading rows sequentially will reflect. Not to be
124
+ * confused with a window column's `order_by`, which orders rows
125
+ * WITHIN a window frame and does not reorder the `View`.
126
+ */
127
+ sort?: Array<Sort>,
128
+ /**
129
+ * The `expressions` property specifies _new_ columns in Perspective that
130
+ * are created using existing column values or arbitary scalar values
131
+ * defined within the expression. In `<perspective-viewer>`,
132
+ * expressions are added using the "New Column" button in the side
133
+ * panel.
134
+ */
135
+ expressions?: Expressions,
136
+ /**
137
+ * The `windows` property declares ordered, partitioned rolling
138
+ * computations (moving aggregates, cumulative sums) as _new_ columns
139
+ * keyed by output alias (`{"name": {...spec}}`, symmetric with
140
+ * `expressions`), analogous to SQL window functions. See
141
+ * [`crate::config::WindowSpec`].
142
+ */
143
+ windows?: Windows,
144
+ /**
145
+ * Aggregates perform a calculation over an entire column, and are
146
+ * displayed when one or more [Group By](#group-by) are applied to the
147
+ * `View`. Aggregates can be specified by the user, or Perspective will
148
+ * use the following sensible default aggregates based on column type:
149
+ *
150
+ * - "sum" for `integer` and `float` columns
151
+ * - "count" for all other columns
152
+ *
153
+ * Perspective provides a selection of aggregate functions that can be
154
+ * applied to columns in the `View` constructor using a dictionary of
155
+ * column name to aggregate function name.
156
+ *
157
+ * An aggregate also determines the column's RESULT TYPE, which need
158
+ * not match the input: `"count"` yields an `integer` whatever it
159
+ * counts, so a `date` column left on the default `"count"` is an
160
+ * `integer` in the resulting `View` — no longer a date. Set an
161
+ * aggregate that preserves the type (e.g. `"any"`, `"last"`) when
162
+ * the original type matters, such as a date used as a chart axis.
163
+ */
164
+ aggregates?: { [key in string]?: Aggregate }, group_by_depth?: number, filter_op?: FilterReducer, group_rollup_mode?: GroupRollupMode, split_rollup_mode?: SplitRollupMode, };
@@ -6,10 +6,67 @@ import type { FilterReducer } from "./FilterReducer.js";
6
6
  import type { GroupRollupMode } from "./GroupRollupMode.js";
7
7
  import type { OptionalUpdate } from "./OptionalUpdate.js";
8
8
  import type { Sort } from "./Sort.js";
9
+ import type { SplitRollupMode } from "./SplitRollupMode.js";
9
10
  import type { Windows } from "./Windows.js";
10
11
  import type { JsonValue } from "./serde_json/JsonValue.js";
11
12
 
12
- export type ViewerConfigUpdate = { version?: OptionalUpdate<string>, plugin?: OptionalUpdate<string>, title?: OptionalUpdate<string>, table?: OptionalUpdate<string>, theme?: OptionalUpdate<string>, settings?: OptionalUpdate<boolean>, plugin_config?: OptionalUpdate<{ [key in string]?: JsonValue }>, columns_config?: OptionalUpdate<{ [key in string]?: { [key in string]?: JsonValue } }>,
13
+ export type ViewerConfigUpdate = {
14
+ /**
15
+ * The `@perspective-dev/viewer` version a saved config was written
16
+ * by, used to migrate older tokens. Omit it — the viewer stamps
17
+ * the current version on save.
18
+ */
19
+ version?: OptionalUpdate<string>,
20
+ /**
21
+ * Name of the visualization plugin to switch to, from the set
22
+ * registered on the page (the `list_plugins` agent tool, or the
23
+ * plugin picker). Changing it changes what the view fields MEAN:
24
+ * `columns` is positional and every plugin reads the positions
25
+ * differently, and `group_by`/`split_by` draw different things per
26
+ * plugin — so read the new plugin's roles before writing `columns`
27
+ * for it.
28
+ */
29
+ plugin?: OptionalUpdate<string>,
30
+ /**
31
+ * Panel title, shown in its tab. `null` restores the default
32
+ * title; omitting the field leaves the current one.
33
+ */
34
+ title?: OptionalUpdate<string>,
35
+ /**
36
+ * Name of the `Table` to render, as hosted on this panel's
37
+ * `Client`. Rebinding an existing panel to another table keeps the
38
+ * rest of the config, so column names that do not exist in the new
39
+ * table will fail validation.
40
+ */
41
+ table?: OptionalUpdate<string>,
42
+ /**
43
+ * Theme NAME (e.g. `"Pro Dark"`) — not a CSS value. Valid names are
44
+ * the Perspective themes loaded on the page, re-scanned by
45
+ * `resetThemes()`. `null` selects the default.
46
+ */
47
+ theme?: OptionalUpdate<string>,
48
+ /**
49
+ * Whether the settings sidebar is OPEN. Purely cosmetic chrome —
50
+ * it does not affect what the viewer renders, and it is
51
+ * element-level rather than per-panel.
52
+ */
53
+ settings?: OptionalUpdate<boolean>,
54
+ /**
55
+ * Plugin-wide settings (as opposed to the per-column
56
+ * [`Self::columns_config`]). The viewer passes these through
57
+ * opaquely — their valid keys are defined by the ACTIVE plugin and
58
+ * vary by plugin and by state, so query them with the
59
+ * `get_style_schema` agent tool rather than guessing.
60
+ */
61
+ plugin_config?: OptionalUpdate<{ [key in string]?: JsonValue }>,
62
+ /**
63
+ * Per-column styling — formatting, colors, and other per-column
64
+ * controls — keyed by column name. Opaque to the viewer and
65
+ * plugin-defined like [`Self::plugin_config`]; `get_style_schema`
66
+ * reports the valid keys for a given column under the active
67
+ * plugin.
68
+ */
69
+ columns_config?: OptionalUpdate<{ [key in string]?: { [key in string]?: JsonValue } }>,
13
70
  /**
14
71
  * A group by _groups_ the dataset by the unique values of each column used
15
72
  * as a group by - a close analogue in SQL to the `GROUP BY` statement.
@@ -65,6 +122,12 @@ filter?: Array<Filter>,
65
122
  * name and a string sort direction. When `column-pivots` are applied,
66
123
  * the additional sort directions `"col asc"` and `"col desc"` will
67
124
  * determine the order of pivot columns groups.
125
+ *
126
+ * `sort` is the ONLY thing that orders a `View`'s rows — without it
127
+ * they keep the `Table`'s natural (insertion) order, which any
128
+ * consumer reading rows sequentially will reflect. Not to be
129
+ * confused with a window column's `order_by`, which orders rows
130
+ * WITHIN a window frame and does not reorder the `View`.
68
131
  */
69
132
  sort?: Array<Sort>,
70
133
  /**
@@ -95,5 +158,12 @@ windows?: Windows,
95
158
  * Perspective provides a selection of aggregate functions that can be
96
159
  * applied to columns in the `View` constructor using a dictionary of
97
160
  * column name to aggregate function name.
161
+ *
162
+ * An aggregate also determines the column's RESULT TYPE, which need
163
+ * not match the input: `"count"` yields an `integer` whatever it
164
+ * counts, so a `date` column left on the default `"count"` is an
165
+ * `integer` in the resulting `View` — no longer a date. Set an
166
+ * aggregate that preserves the type (e.g. `"any"`, `"last"`) when
167
+ * the original type matters, such as a date used as a chart axis.
98
168
  */
99
- aggregates?: { [key in string]?: Aggregate }, group_by_depth?: number, filter_op?: FilterReducer, group_rollup_mode?: GroupRollupMode, };
169
+ aggregates?: { [key in string]?: Aggregate }, group_by_depth?: number, filter_op?: FilterReducer, group_rollup_mode?: GroupRollupMode, split_rollup_mode?: SplitRollupMode, };
@@ -1,5 +1,4 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
- import type { WindowAggregate } from "./WindowAggregate.js";
3
2
  import type { WindowSort } from "./WindowSort.js";
4
3
 
5
4
  /**
@@ -10,7 +9,7 @@ export type WindowSpec = {
10
9
  * The input column - either a real `Table` column or an expression
11
10
  * alias from the same `ViewConfig`.
12
11
  */
13
- column: string, aggregate: WindowAggregate,
12
+ column: string, aggregate: string,
14
13
  /**
15
14
  * Columns whose distinct value tuples partition the rows; empty
16
15
  * partitions the whole `Table` as one group.
@@ -18,6 +17,8 @@ column: string, aggregate: WindowAggregate,
18
17
  partition_by?: Array<string>,
19
18
  /**
20
19
  * The `Table` column which orders each partition, and the direction.
20
+ * This orders rows WITHIN the window frame only — it does not
21
+ * reorder the `View`, which is what the view-level `sort` does.
21
22
  */
22
23
  order_by?: WindowSort | null,
23
24
  /**
@@ -4,7 +4,7 @@ import type { Layout } from "./Layout.js";
4
4
  import type { PanelViewerConfig } from "./PanelViewerConfig.js";
5
5
 
6
6
  /**
7
- * The whole-element config format (`{version, active?, layout, panels}`) —
7
+ * The workspace config format (`{version, active?, layout, panels}`) —
8
8
  * the multi-panel counterpart of the single-panel [`ViewerConfig`] — as
9
9
  * emitted by [`PerspectiveViewerElement::save`].
10
10
  *
@@ -33,4 +33,10 @@ global_filters?: Array<Filter>,
33
33
  * which master contributed which clause does not — restored
34
34
  * `global_filters` are one unattributed bucket. Omitted when empty.
35
35
  */
36
- masters?: Array<string>, };
36
+ masters?: Array<string>,
37
+ /**
38
+ * Named color-scale definitions shared by every panel: CSS custom
39
+ * property name (`--psp-user--<kind>-<name>`) → canonical CSS
40
+ * value.
41
+ */
42
+ palette?: { [key in string]?: string }, };
@@ -1,24 +1,33 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
2
  import type { Filter } from "./Filter.js";
3
3
  import type { Layout } from "./Layout.js";
4
- import type { ViewerConfigUpdate } from "./ViewerConfigUpdate.js";
4
+ import type { ViewerConfigInitial } from "./ViewerConfigInitial.js";
5
5
 
6
6
  /**
7
- * The parse target of a whole-element config in
8
- * [`PerspectiveViewerElement::restore`]. Mirrors [`WorkspaceConfig`],
9
- * but `panels` entries are full [`ViewerConfigUpdate`]s so a stray per-panel
10
- * `settings` can be detected (warned, then ignored — `create_panel` strips
11
- * it).
7
+ * The parse target of a workspace config in
8
+ * [`PerspectiveViewerElement::restoreWorkspace`]. Mirrors
9
+ * [`WorkspaceConfig`], but `panels` entries are [`ViewerConfigInitial`]s —
10
+ * every entry creates a NEW panel, so `table` is required by type (a
11
+ * stray per-panel `settings` key is ignored; it is element-level state,
12
+ * carried by the top-level `active` field).
12
13
  */
13
- export type WorkspaceConfigUpdate = { active?: string, layout?: Layout, panels: { [key in string]?: ViewerConfigUpdate },
14
+ export type WorkspaceConfigUpdate = { active?: string, layout?: Layout, panels: { [key in string]?: ViewerConfigInitial },
14
15
  /**
15
16
  * The element-level global (master/detail cross-) filters to re-apply as
16
17
  * a transient overlay on every DETAIL panel. Restored as one
17
18
  * unattributed bucket: the next selection on any master replaces it.
19
+ * `Option` so an explicit `undefined` property deserializes as
20
+ * `None` like an absent key (also `masters` / `palette` below).
18
21
  */
19
- global_filters?: Array<Filter>,
22
+ global_filters?: Array<Filter> | null,
20
23
  /**
21
24
  * The master (filter-source) panels, by saved `panels` key. An id not in
22
25
  * `panels` warns and is dropped.
23
26
  */
24
- masters?: Array<string>, };
27
+ masters?: Array<string> | null,
28
+ /**
29
+ * Named color-scale definitions to apply to the host (see
30
+ * [`WorkspaceConfig::palette`]), replacing any previously restored
31
+ * palette.
32
+ */
33
+ palette?: { [key in string]?: string } | null, };
@@ -1 +0,0 @@
1
- export type WindowAggregate = "sum" | "avg" | "count" | "min" | "max" | "stddev" | "var" | "first" | "last" | "lag" | "lead" | "diff" | "rate" | "ema";
@@ -1,137 +0,0 @@
1
- // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
- // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
- // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
- // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
- // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
- // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
- // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
- // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
- // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
- // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
- // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
-
13
- use wasm_bindgen::JsCast;
14
- use web_sys::*;
15
- use yew::prelude::*;
16
-
17
- #[derive(Properties, PartialEq, Clone)]
18
- pub struct ColorRangeProps {
19
- /// Extra class appended to the positive input's `class` attribute,
20
- /// so callers can target the pos / neg sides independently from CSS.
21
- /// Paired with `neg_class`; both default to empty.
22
- #[prop_or_default]
23
- pub pos_class: Classes,
24
- #[prop_or_default]
25
- pub neg_class: Classes,
26
- pub pos_color: String,
27
- pub neg_color: String,
28
- pub is_gradient: bool,
29
- pub on_pos_color: Callback<String>,
30
- pub on_neg_color: Callback<String>,
31
- pub on_reset: Callback<()>,
32
- pub is_modified: bool,
33
- }
34
-
35
- #[function_component(ColorRangeSelector)]
36
- pub fn color_chooser_component(props: &ColorRangeProps) -> Html {
37
- let on_pos_color = use_callback(
38
- props.on_pos_color.clone(),
39
- |event: InputEvent, on_pos_color| {
40
- let color = event
41
- .target()
42
- .unwrap()
43
- .unchecked_into::<HtmlInputElement>()
44
- .value();
45
- on_pos_color.emit(color);
46
- },
47
- );
48
-
49
- let on_neg_color = use_callback(
50
- props.on_neg_color.clone(),
51
- |event: InputEvent, on_neg_color| {
52
- let color = event
53
- .target()
54
- .unwrap()
55
- .unchecked_into::<HtmlInputElement>()
56
- .value();
57
- on_neg_color.emit(color);
58
- },
59
- );
60
-
61
- let fg_pos = infer_fg(&props.pos_color);
62
- let fg_neg = infer_fg(&props.neg_color);
63
- let style = if props.is_gradient {
64
- format!(
65
- "background:linear-gradient(to right, {} 0%, transparent 50%, {} 100%)",
66
- props.pos_color, props.neg_color
67
- )
68
- } else {
69
- format!(
70
- "background:linear-gradient(to right, {} 0%, {} 50%, {} 50%, {} 100%)",
71
- props.pos_color, props.pos_color, props.neg_color, props.neg_color
72
- )
73
- };
74
-
75
- let on_reset = use_callback(props.clone(), |_: MouseEvent, deps| deps.on_reset.emit(()));
76
-
77
- let pos_class = classes!("parameter", "pos-color-param", props.pos_class.clone());
78
- let neg_class = classes!("parameter", "neg-color-param", props.neg_class.clone());
79
-
80
- html! {
81
- <>
82
- <label id="color-range-label" />
83
- <div class="color-gradient-container">
84
- <div style={fg_pos} class="color-selector">
85
- <input
86
- class={pos_class}
87
- type="color"
88
- value={props.pos_color.to_owned()}
89
- data-value={props.pos_color.to_owned()}
90
- oninput={on_pos_color}
91
- />
92
- <label class="color-label">{ "+" }</label>
93
- </div>
94
- <div class="color-thermometer" {style} />
95
- <div style={fg_neg} class="color-selector">
96
- <input
97
- class={neg_class}
98
- type="color"
99
- value={props.neg_color.to_owned()}
100
- data-value={props.neg_color.to_owned()}
101
- oninput={on_neg_color}
102
- />
103
- <label class="color-label">{ "-" }</label>
104
- </div>
105
- if props.is_modified {
106
- <span class="reset-default-style" onclick={on_reset} />
107
- } else {
108
- <span class="reset-default-style-disabled" />
109
- }
110
- </div>
111
- </>
112
- }
113
- }
114
-
115
- fn infer_fg(color: &str) -> &'static str {
116
- if color.len() >= 7 {
117
- let r = i32::from_str_radix(&color[1..3], 16).unwrap_or(255) as f64;
118
- let g = i32::from_str_radix(&color[3..5], 16).unwrap_or(0) as f64;
119
- let b = i32::from_str_radix(&color[5..7], 16).unwrap_or(0) as f64;
120
- if (r * r * 0.299 + g * g * 0.587 + b * b * 0.114).sqrt() > 130.0 {
121
- "--sign--color:var(--psp--color)"
122
- } else {
123
- "--sign--color:var(--psp--background-color)"
124
- }
125
- } else if color.len() == 4 {
126
- let r = i32::from_str_radix(&color[1..2], 16).unwrap_or(15) as f64;
127
- let g = i32::from_str_radix(&color[2..3], 16).unwrap_or(0) as f64;
128
- let b = i32::from_str_radix(&color[3..4], 16).unwrap_or(0) as f64;
129
- if (r * r * 0.299 + g * g * 0.587 + b * b * 0.114).sqrt() > 8.0 {
130
- "--sign--color:var(--psp--color)"
131
- } else {
132
- "--sign--color:var(--psp--background-color)"
133
- }
134
- } else {
135
- "--sign--color:var(--psp--color)"
136
- }
137
- }
@@ -1,3 +0,0 @@
1
- // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
-
3
- export type WindowAggregate = "sum" | "avg" | "count" | "min" | "max" | "stddev" | "var" | "first" | "last" | "lag" | "lead" | "diff" | "rate" | "ema";