derive-dashboards 0.1.0 → 0.1.1

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 (301) hide show
  1. package/README.md +4 -3
  2. package/dist/adapter/sql-adapter.mjs +4 -4
  3. package/dist/body.mjs +11 -1
  4. package/dist/cache.d.mts +1 -1
  5. package/dist/cli/check.mjs +14 -1
  6. package/dist/cli/import/dbt-schema.mjs +2 -2
  7. package/dist/cli/import/index.mjs +2 -2
  8. package/dist/core/conformance/cases.d.mts +3 -0
  9. package/dist/core/conformance/cases.mjs +20 -4
  10. package/dist/core/conformance/check.mjs +6 -3
  11. package/dist/core/conformance/drill-cases.mjs +120 -0
  12. package/dist/core/document/view.d.mts +26 -7
  13. package/dist/core/document/view.mjs +42 -11
  14. package/dist/core/engine/index.d.mts +14 -2
  15. package/dist/core/engine/index.mjs +12 -1
  16. package/dist/core/engine/members.mjs +1 -1
  17. package/dist/core/engine/postgres.mjs +1 -1
  18. package/dist/core/engine/record-layout.d.mts +11 -0
  19. package/dist/core/engine/record-layout.mjs +7 -7
  20. package/dist/core/engine/records.d.mts +3 -2
  21. package/dist/core/engine/records.mjs +2 -1
  22. package/dist/core/engine/segmented.mjs +5 -2
  23. package/dist/core/engine/sql-records.mjs +2 -1
  24. package/dist/core/engine/statement.mjs +37 -3
  25. package/dist/core/engine/types.d.mts +3 -0
  26. package/dist/core/engine/version.d.mts +1 -1
  27. package/dist/core/engine/version.mjs +1 -1
  28. package/dist/core/error/codes.d.mts +31 -0
  29. package/dist/core/error/codes.mjs +28 -1
  30. package/dist/core/index.d.mts +9 -5
  31. package/dist/core/index.mjs +5 -3
  32. package/dist/core/model/catalog/check.mjs +1 -1
  33. package/dist/core/model/hints.d.mts +36 -0
  34. package/dist/core/model/member.d.mts +4 -2
  35. package/dist/core/model/member.mjs +16 -3
  36. package/dist/core/model/types.d.mts +8 -6
  37. package/dist/core/model/validate/drill.mjs +70 -0
  38. package/dist/core/model/validate/index.mjs +3 -0
  39. package/dist/core/model/validate/shape.mjs +150 -0
  40. package/dist/core/model/validate/source.mjs +5 -3
  41. package/dist/core/query/alias.mjs +7 -1
  42. package/dist/core/query/drill/compose.d.mts +22 -0
  43. package/dist/core/query/drill/compose.mjs +85 -0
  44. package/dist/core/query/drill/fields.d.mts +21 -0
  45. package/dist/core/query/drill/fields.mjs +91 -0
  46. package/dist/core/query/drill/internal.d.mts +11 -0
  47. package/dist/core/query/drill/items.d.mts +29 -0
  48. package/dist/core/query/drill/items.mjs +98 -0
  49. package/dist/core/query/drill/line.d.mts +31 -0
  50. package/dist/core/query/drill/line.mjs +183 -0
  51. package/dist/core/query/drill/links.d.mts +33 -0
  52. package/dist/core/query/drill/links.mjs +31 -0
  53. package/dist/core/query/drill/operand.mjs +7 -0
  54. package/dist/core/query/drill/scopes.d.mts +22 -0
  55. package/dist/core/query/drill/scopes.mjs +58 -0
  56. package/dist/core/query/drill/selection.d.mts +37 -0
  57. package/dist/core/query/drill/selection.mjs +144 -0
  58. package/dist/core/query/drill/steps.d.mts +14 -0
  59. package/dist/core/query/drill/steps.mjs +35 -0
  60. package/dist/core/query/drill/synthetic-expr.mjs +85 -0
  61. package/dist/core/query/drill/synthetic.d.mts +22 -0
  62. package/dist/core/query/drill/synthetic.mjs +165 -0
  63. package/dist/core/query/drill/time.d.mts +11 -0
  64. package/dist/core/query/drill/time.mjs +71 -0
  65. package/dist/core/query/drill/types.d.mts +155 -0
  66. package/dist/core/query/drill/types.mjs +4 -0
  67. package/dist/core/query/drill/views.d.mts +62 -0
  68. package/dist/core/query/drill/views.mjs +257 -0
  69. package/dist/core/query/segments.d.mts +12 -2
  70. package/dist/core/query/segments.mjs +3 -1
  71. package/dist/core/result/columns.mjs +17 -4
  72. package/dist/core/result/types.d.mts +5 -1
  73. package/dist/core/schema/answer-parts.mjs +117 -0
  74. package/dist/core/schema/answers.d.mts +2108 -128
  75. package/dist/core/schema/answers.mjs +10 -113
  76. package/dist/core/schema/commands.d.mts +2 -2
  77. package/dist/core/schema/document.d.mts +1 -1
  78. package/dist/core/schema/drill-answers.mjs +179 -0
  79. package/dist/core/schema/drill.d.mts +260 -0
  80. package/dist/core/schema/drill.mjs +107 -0
  81. package/dist/core/schema/index.d.mts +4 -2
  82. package/dist/core/schema/index.mjs +4 -2
  83. package/dist/core/schema/picks.d.mts +35 -0
  84. package/dist/core/schema/picks.mjs +23 -0
  85. package/dist/core/schema/query.d.mts +1 -1
  86. package/dist/core/schema/tools.mjs +1 -1
  87. package/dist/core/schema/view.d.mts +0 -35
  88. package/dist/core/schema/view.mjs +19 -24
  89. package/dist/core/store/schema.d.mts +5 -0
  90. package/dist/core/store/schema.mjs +10 -0
  91. package/dist/core/types/api.d.mts +15 -1
  92. package/dist/core/types/api.mjs +1 -1
  93. package/dist/core/types/drill-api.d.mts +210 -0
  94. package/dist/core/types/options.d.mts +21 -0
  95. package/dist/core/types/viewer.d.mts +5 -0
  96. package/dist/cursor-seal.d.mts +8 -0
  97. package/dist/cursor-seal.mjs +98 -0
  98. package/dist/dashboard-id.mjs +1 -1
  99. package/dist/drill-access.mjs +93 -0
  100. package/dist/drill-change.mjs +76 -0
  101. package/dist/drill-crumbs.mjs +113 -0
  102. package/dist/drill-distinct.mjs +130 -0
  103. package/dist/drill-explain.mjs +64 -0
  104. package/dist/drill-identity.mjs +35 -0
  105. package/dist/drill-item-id.mjs +35 -0
  106. package/dist/drill-items.mjs +132 -0
  107. package/dist/drill-open.mjs +169 -0
  108. package/dist/drill-seal.mjs +170 -0
  109. package/dist/drill-secret.mjs +14 -0
  110. package/dist/drill-share.mjs +53 -0
  111. package/dist/drill-summary.mjs +158 -0
  112. package/dist/drill-targets.mjs +53 -0
  113. package/dist/drill-totals.mjs +8 -0
  114. package/dist/drill-views.mjs +175 -0
  115. package/dist/drill.mjs +157 -0
  116. package/dist/editing.mjs +2 -2
  117. package/dist/endpoints/dashboards.mjs +11 -3
  118. package/dist/endpoints/drill.mjs +55 -0
  119. package/dist/endpoints/index.d.mts +233 -2
  120. package/dist/endpoints/index.mjs +5 -1
  121. package/dist/endpoints/query.mjs +26 -4
  122. package/dist/execute.d.mts +19 -1
  123. package/dist/execute.mjs +15 -17
  124. package/dist/index.d.mts +3 -1
  125. package/dist/index.mjs +29 -2
  126. package/dist/mcp/drill.mjs +61 -0
  127. package/dist/mcp/format.mjs +27 -3
  128. package/dist/mcp/index.d.mts +15 -4
  129. package/dist/mcp/index.mjs +13 -7
  130. package/dist/mcp/query.d.mts +7 -2
  131. package/dist/mcp/query.mjs +7 -3
  132. package/dist/node-postgres.d.mts +8 -4
  133. package/dist/node-postgres.mjs +29 -6
  134. package/dist/owner.mjs +3 -3
  135. package/dist/postgres-connection.d.mts +8 -2
  136. package/dist/postgres-connection.mjs +2 -1
  137. package/dist/react/Dashboard.d.mts +10 -5
  138. package/dist/react/Dashboard.mjs +51 -23
  139. package/dist/react/DashboardList.mjs +30 -2
  140. package/dist/react/Discard.mjs +7 -2
  141. package/dist/react/Grid.mjs +12 -5
  142. package/dist/react/Header.mjs +9 -0
  143. package/dist/react/Parts.mjs +6 -2
  144. package/dist/react/ReviewPanel.mjs +13 -2
  145. package/dist/react/RowBody.d.mts +19 -0
  146. package/dist/react/RowBody.mjs +55 -0
  147. package/dist/react/Tile.d.mts +1 -1
  148. package/dist/react/Tile.mjs +54 -30
  149. package/dist/react/builder/state.d.mts +1 -1
  150. package/dist/react/client.d.mts +2 -0
  151. package/dist/react/client.mjs +1 -0
  152. package/dist/react/context.d.mts +15 -1
  153. package/dist/react/context.mjs +19 -4
  154. package/dist/react/drill/Bars.mjs +179 -0
  155. package/dist/react/drill/Controls.mjs +173 -0
  156. package/dist/react/drill/DashboardTile.d.mts +18 -0
  157. package/dist/react/drill/DashboardTile.mjs +107 -0
  158. package/dist/react/drill/DrillPanel.d.mts +31 -0
  159. package/dist/react/drill/DrillPanel.mjs +104 -0
  160. package/dist/react/drill/DrillTabs.mjs +52 -0
  161. package/dist/react/drill/Header.mjs +131 -0
  162. package/dist/react/drill/Items.d.mts +22 -0
  163. package/dist/react/drill/Items.mjs +164 -0
  164. package/dist/react/drill/ItemsFoot.mjs +60 -0
  165. package/dist/react/drill/Notes.mjs +58 -0
  166. package/dist/react/drill/PanelBody.mjs +74 -0
  167. package/dist/react/drill/PanelStates.mjs +37 -0
  168. package/dist/react/drill/board.d.mts +18 -0
  169. package/dist/react/drill/board.mjs +91 -0
  170. package/dist/react/drill/counts.mjs +14 -0
  171. package/dist/react/drill/host.mjs +26 -0
  172. package/dist/react/drill/item-parts.d.mts +5 -0
  173. package/dist/react/drill/item-parts.mjs +76 -0
  174. package/dist/react/drill/item-type.d.mts +26 -0
  175. package/dist/react/drill/item-type.mjs +7 -0
  176. package/dist/react/drill/lazy.d.mts +6 -0
  177. package/dist/react/drill/lazy.mjs +17 -0
  178. package/dist/react/drill/pages.mjs +48 -0
  179. package/dist/react/drill/panel-focus.mjs +51 -0
  180. package/dist/react/drill/props.d.mts +25 -0
  181. package/dist/react/drill/props.mjs +72 -0
  182. package/dist/react/drill/state.d.mts +18 -0
  183. package/dist/react/drill/state.mjs +68 -0
  184. package/dist/react/drill/useDrill.d.mts +46 -0
  185. package/dist/react/drill/useDrill.mjs +194 -0
  186. package/dist/react/drill/words.d.mts +98 -0
  187. package/dist/react/drill/words.mjs +77 -0
  188. package/dist/react/english.mjs +9 -1
  189. package/dist/react/format.d.mts +3 -3
  190. package/dist/react/format.mjs +34 -12
  191. package/dist/react/index.d.mts +27 -4
  192. package/dist/react/index.mjs +10 -3
  193. package/dist/react/messages.d.mts +14 -1
  194. package/dist/react/renderers/index.d.mts +10 -2
  195. package/dist/react/renderers/index.mjs +54 -14
  196. package/dist/react/renderers/list.d.mts +22 -0
  197. package/dist/react/renderers/list.mjs +118 -0
  198. package/dist/react/review-words.mjs +1 -1
  199. package/dist/react/review.mjs +2 -2
  200. package/dist/react/scope.mjs +2 -7
  201. package/dist/react/series.d.mts +37 -0
  202. package/dist/react/series.mjs +95 -0
  203. package/dist/react/theme.css +1823 -1296
  204. package/dist/react/theme.css.d.ts +1 -0
  205. package/dist/react/tile-store.mjs +15 -3
  206. package/dist/react/useBoard.d.mts +5 -0
  207. package/dist/react/useBoard.mjs +4 -1
  208. package/dist/react/useDashboard.d.mts +1 -0
  209. package/dist/react/useDashboard.mjs +2 -1
  210. package/dist/react/useTiles.mjs +50 -15
  211. package/dist/react/view.d.mts +9 -0
  212. package/dist/react/view.mjs +22 -10
  213. package/dist/reading.d.mts +2 -0
  214. package/dist/reading.mjs +9 -1
  215. package/dist/recharts/charts.d.mts +0 -1
  216. package/dist/recharts/charts.mjs +128 -34
  217. package/dist/recharts/index.d.mts +2 -2
  218. package/dist/recharts/index.mjs +2 -2
  219. package/dist/recharts/marks.mjs +83 -0
  220. package/dist/recharts/series.d.mts +2 -22
  221. package/dist/recharts/series.mjs +1 -64
  222. package/dist/records-read.mjs +44 -0
  223. package/dist/store/apply.mjs +5 -5
  224. package/dist/store/commands.mjs +4 -4
  225. package/dist/store/discard.mjs +7 -7
  226. package/dist/store/drafts.mjs +5 -5
  227. package/dist/store/editor.mjs +1 -1
  228. package/dist/store/publish.mjs +12 -12
  229. package/dist/store/reader.mjs +41 -22
  230. package/dist/store/review.mjs +16 -16
  231. package/dist/store/rows.mjs +20 -20
  232. package/dist/store/undo.mjs +3 -3
  233. package/dist/store/unpublished.mjs +4 -4
  234. package/dist/store/versions.mjs +14 -14
  235. package/dist/testing/adapter-suite.mjs +4 -4
  236. package/dist/tiles.mjs +37 -3
  237. package/package.json +8 -10
  238. package/dist/react/Records.d.mts +0 -12
  239. package/dist/react/Records.mjs +0 -97
  240. package/src/adapter/sql-adapter.ts +0 -95
  241. package/src/adapter/statement.ts +0 -185
  242. package/src/authorize.ts +0 -73
  243. package/src/body.ts +0 -169
  244. package/src/bounded.ts +0 -43
  245. package/src/cache.ts +0 -192
  246. package/src/checks.ts +0 -170
  247. package/src/custom-source.ts +0 -59
  248. package/src/dashboard-id.ts +0 -36
  249. package/src/dashboards.ts +0 -132
  250. package/src/editing.ts +0 -148
  251. package/src/endpoints/access.ts +0 -41
  252. package/src/endpoints/dashboards.ts +0 -92
  253. package/src/endpoints/drafts.ts +0 -138
  254. package/src/endpoints/index.ts +0 -21
  255. package/src/endpoints/meta.ts +0 -137
  256. package/src/endpoints/query.ts +0 -86
  257. package/src/endpoints/read.ts +0 -92
  258. package/src/endpoints/review.ts +0 -89
  259. package/src/endpoints/values.ts +0 -62
  260. package/src/endpoints/versions.ts +0 -104
  261. package/src/execute.ts +0 -207
  262. package/src/handler.ts +0 -232
  263. package/src/http.ts +0 -66
  264. package/src/index.ts +0 -163
  265. package/src/introspect.ts +0 -205
  266. package/src/mcp/api.ts +0 -59
  267. package/src/mcp/format.ts +0 -67
  268. package/src/mcp/index.ts +0 -151
  269. package/src/mcp/query.ts +0 -153
  270. package/src/mcp/resolve.ts +0 -114
  271. package/src/node-postgres.ts +0 -81
  272. package/src/owner.ts +0 -36
  273. package/src/postgres-connection.ts +0 -143
  274. package/src/postgres-store.ts +0 -82
  275. package/src/principal.ts +0 -39
  276. package/src/reading.ts +0 -56
  277. package/src/request-rows.ts +0 -23
  278. package/src/request.ts +0 -22
  279. package/src/storage.ts +0 -63
  280. package/src/store/apply.ts +0 -129
  281. package/src/store/commands.ts +0 -75
  282. package/src/store/conflicts.ts +0 -98
  283. package/src/store/create-tables.ts +0 -104
  284. package/src/store/discard.ts +0 -42
  285. package/src/store/drafts.ts +0 -133
  286. package/src/store/editor.ts +0 -28
  287. package/src/store/log.ts +0 -28
  288. package/src/store/publish.ts +0 -199
  289. package/src/store/publisher.ts +0 -21
  290. package/src/store/reader.ts +0 -139
  291. package/src/store/review.ts +0 -239
  292. package/src/store/rows.ts +0 -250
  293. package/src/store/tenant.ts +0 -28
  294. package/src/store/undo.ts +0 -56
  295. package/src/store/unpublished.ts +0 -33
  296. package/src/store/versions.ts +0 -106
  297. package/src/store/writer.ts +0 -19
  298. package/src/testing/adapter-suite.ts +0 -239
  299. package/src/testing/index.ts +0 -2
  300. package/src/tile-doc.ts +0 -46
  301. package/src/tiles.ts +0 -120
@@ -1,27 +1,50 @@
1
+ import { ItemFor } from "./drill/item-type.mjs";
1
2
  import { WidgetPreview } from "./builder/Preview.mjs";
2
3
  import { Builder, useBuilder } from "./builder/useBuilder.mjs";
3
4
  import { WidgetBuilder, WidgetBuilderProps } from "./builder/WidgetBuilder.mjs";
4
5
  import { DashboardsError, DashboardsErrorCode } from "./errors.mjs";
5
6
  import { ClientOptions, DashboardsClient, DashboardsServer, TypedCall, createDashboardsClient } from "./client.mjs";
6
- import { DashboardsProvider, DashboardsProviderProps, useDashboards } from "./context.mjs";
7
+ import { DashboardsProvider, DashboardsProviderProps, LinkComponent, LinkProps, useDashboards } from "./context.mjs";
7
8
  import { Dashboard, DashboardProps } from "./Dashboard.mjs";
8
- import { ENGLISH } from "./english.mjs";
9
9
  import { DashboardList } from "./DashboardList.mjs";
10
+ import { ENGLISH } from "./english.mjs";
10
11
  import { Attempt, DraftClosed, DraftEditor, DraftStatus, useDraft } from "./draft.mjs";
12
+ import { DashboardDrillProps, DrillEvent } from "./drill/board.mjs";
13
+ import { DashboardTile, DashboardTileProps } from "./drill/DashboardTile.mjs";
14
+ import { DrillPanelProps } from "./drill/DrillPanel.mjs";
15
+ import { ItemHelpers, ItemOptions } from "./drill/Items.mjs";
16
+ import { DrillPanel } from "./drill/lazy.mjs";
17
+ import { DrillMarkProps, TileDrill } from "./drill/props.mjs";
18
+ import { DrillChange, DrillHistory, drillFrom } from "./drill/state.mjs";
19
+ import { DrillController, DrillOptions, useDrill } from "./drill/useDrill.mjs";
20
+ import { DrillMessages, ENGLISH_DRILL } from "./drill/words.mjs";
11
21
  import { EditBar } from "./EditBar.mjs";
12
22
  import { FilterBar } from "./FilterBar.mjs";
13
23
  import { formatBucket, formatCell, formatInstant, formatTick, plotValue } from "./format.mjs";
14
24
  import { HistoryPanel, VersionBar } from "./History.mjs";
15
25
  import { CellFormat, Messages } from "./messages.mjs";
16
26
  import { ChangeList, Panel } from "./Panel.mjs";
17
- import { RecordsPanel } from "./Records.mjs";
18
27
  import { ReviewPanel } from "./ReviewPanel.mjs";
19
28
  import { ClientSchemas } from "./read.mjs";
20
29
  import { NumberTile, TableTile, TileRenderer, TileRendererProps } from "./renderers/index.mjs";
30
+ import { ListDisplay, ListTile } from "./renderers/list.mjs";
21
31
  import { Moved, Review, useReview } from "./review.mjs";
22
32
  import { ENGLISH_REVIEW, ReviewMessages } from "./review-words.mjs";
33
+ import { Drawn, OTHER_KEY, Point, Series, rowAt, toSeries } from "./series.mjs";
23
34
  import { Tile } from "./Tile.mjs";
24
35
  import { useBoard } from "./useBoard.mjs";
25
36
  import { useDashboard } from "./useDashboard.mjs";
26
37
  import { useTiles } from "./useTiles.mjs";
27
- export { type Attempt, type Builder, type CellFormat, ChangeList, type ClientOptions, type ClientSchemas, Dashboard, DashboardList, type DashboardProps, type DashboardsClient, DashboardsError, type DashboardsErrorCode, DashboardsProvider, type DashboardsProviderProps, type DashboardsServer, type DraftClosed, type DraftEditor, type DraftStatus, ENGLISH, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, type Messages, type Moved, NumberTile, Panel, RecordsPanel, type Review, type ReviewMessages, ReviewPanel, TableTile, Tile, type TileRenderer, type TileRendererProps, type TypedCall, VersionBar, WidgetBuilder, type WidgetBuilderProps, WidgetPreview, createDashboardsClient, formatBucket, formatCell, formatInstant, formatTick, plotValue, useBoard, useBuilder, useDashboard, useDashboards, useDraft, useReview, useTiles };
38
+ import { ViewChange } from "./view.mjs";
39
+ import { DrillItem } from "derive-dashboards/core";
40
+ /**
41
+ * Register your server to type drill items by source:
42
+ * `declare module "derive-dashboards/react" { interface Register { server: typeof dashboards } }`.
43
+ * Then `item.source === "order"` narrows `item.key` to the order key's columns.
44
+ */
45
+ export interface Register {}
46
+ /** A drill item, typed from the registered server's model, or a plain `DrillItem` without one. */
47
+ export type Item = Register extends {
48
+ server: infer S;
49
+ } ? ItemFor<S> : DrillItem;
50
+ export { type Attempt, type Builder, type CellFormat, ChangeList, type ClientOptions, type ClientSchemas, Dashboard, type DashboardDrillProps, DashboardList, type DashboardProps, DashboardTile, type DashboardTileProps, type DashboardsClient, DashboardsError, type DashboardsErrorCode, DashboardsProvider, type DashboardsProviderProps, type DashboardsServer, type DraftClosed, type DraftEditor, type DraftStatus, type Drawn, type DrillChange, type DrillController, type DrillEvent, type DrillHistory, type DrillMarkProps, type DrillMessages, type DrillOptions, DrillPanel, type DrillPanelProps, ENGLISH, ENGLISH_DRILL, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, type ItemFor, type ItemHelpers, type ItemOptions, type LinkComponent, type LinkProps, type ListDisplay, ListTile, type Messages, type Moved, NumberTile, OTHER_KEY, Panel, type Point, type Review, type ReviewMessages, ReviewPanel, type Series, TableTile, Tile, type TileDrill, type TileRenderer, type TileRendererProps, type TypedCall, VersionBar, type ViewChange, WidgetBuilder, type WidgetBuilderProps, WidgetPreview, createDashboardsClient, drillFrom, formatBucket, formatCell, formatInstant, formatTick, plotValue, rowAt, toSeries, useBoard, useBuilder, useDashboard, useDashboards, useDraft, useDrill, useReview, useTiles };
@@ -1,25 +1,32 @@
1
+ "use client";
1
2
  import { WidgetPreview } from "./builder/Preview.mjs";
2
3
  import { useBuilder } from "./builder/useBuilder.mjs";
3
4
  import { WidgetBuilder } from "./builder/WidgetBuilder.mjs";
4
5
  import { createDashboardsClient } from "./client.mjs";
5
6
  import { DashboardsProvider, useDashboards } from "./context.mjs";
6
- import { DashboardsError } from "./errors.mjs";
7
7
  import { Dashboard } from "./Dashboard.mjs";
8
8
  import { DashboardList } from "./DashboardList.mjs";
9
+ import { DashboardsError } from "./errors.mjs";
9
10
  import { useDraft } from "./draft.mjs";
11
+ import { DashboardTile } from "./drill/DashboardTile.mjs";
12
+ import { DrillPanel } from "./drill/lazy.mjs";
13
+ import { drillFrom } from "./drill/state.mjs";
14
+ import { useDrill } from "./drill/useDrill.mjs";
15
+ import { ENGLISH_DRILL } from "./drill/words.mjs";
10
16
  import { EditBar } from "./EditBar.mjs";
11
17
  import { FilterBar } from "./FilterBar.mjs";
12
18
  import { formatBucket, formatCell, formatInstant, formatTick, plotValue } from "./format.mjs";
13
19
  import { HistoryPanel, VersionBar } from "./History.mjs";
14
20
  import { ENGLISH } from "./english.mjs";
15
21
  import { ChangeList, Panel } from "./Panel.mjs";
16
- import { RecordsPanel } from "./Records.mjs";
17
22
  import { ReviewPanel } from "./ReviewPanel.mjs";
18
23
  import { NumberTile, TableTile } from "./renderers/index.mjs";
24
+ import { ListTile } from "./renderers/list.mjs";
19
25
  import { useReview } from "./review.mjs";
20
26
  import { ENGLISH_REVIEW } from "./review-words.mjs";
27
+ import { OTHER_KEY, rowAt, toSeries } from "./series.mjs";
21
28
  import { Tile } from "./Tile.mjs";
22
29
  import { useBoard } from "./useBoard.mjs";
23
30
  import { useDashboard } from "./useDashboard.mjs";
24
31
  import { useTiles } from "./useTiles.mjs";
25
- export { ChangeList, Dashboard, DashboardList, DashboardsError, DashboardsProvider, ENGLISH, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, NumberTile, Panel, RecordsPanel, ReviewPanel, TableTile, Tile, VersionBar, WidgetBuilder, WidgetPreview, createDashboardsClient, formatBucket, formatCell, formatInstant, formatTick, plotValue, useBoard, useBuilder, useDashboard, useDashboards, useDraft, useReview, useTiles };
32
+ export { ChangeList, Dashboard, DashboardList, DashboardTile, DashboardsError, DashboardsProvider, DrillPanel, ENGLISH, ENGLISH_DRILL, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, ListTile, NumberTile, OTHER_KEY, Panel, ReviewPanel, TableTile, Tile, VersionBar, WidgetBuilder, WidgetPreview, createDashboardsClient, drillFrom, formatBucket, formatCell, formatInstant, formatTick, plotValue, rowAt, toSeries, useBoard, useBuilder, useDashboard, useDashboards, useDraft, useDrill, useReview, useTiles };
@@ -1,3 +1,4 @@
1
+ import { DrillMessages } from "./drill/words.mjs";
1
2
  import { ReviewMessages } from "./review-words.mjs";
2
3
  import { ENGLISH } from "./english.mjs";
3
4
  import { RelativeRange } from "derive-dashboards/core";
@@ -5,7 +6,7 @@ import { RelativeRange } from "derive-dashboards/core";
5
6
  * Every word the built-in components show. English by default; pass `messages` to the
6
7
  * provider to change any of them, for another language or another house style.
7
8
  */
8
- export type Messages = ReviewMessages & {
9
+ export type Messages = ReviewMessages & DrillMessages & {
9
10
  /** A dimension cell for the values a limit left out. */
10
11
  other: string;
11
12
  /** A dimension cell for every value: a total row. */
@@ -19,6 +20,8 @@ export type Messages = ReviewMessages & {
19
20
  noData: string;
20
21
  noRows: string;
21
22
  dashboardFailed: string;
23
+ /** A dashboard already shown, while the server cannot be reached. */
24
+ dashboardUnreachable: string;
22
25
  /** A dashboard this viewer cannot find: never published, removed, or not shared with them. */
23
26
  dashboardMissing: string;
24
27
  rowsFailed: string;
@@ -26,6 +29,8 @@ export type Messages = ReviewMessages & {
26
29
  rows: string;
27
30
  close: string;
28
31
  showMore: string;
32
+ /** How many rows the rows panel shows, and whether there are more. */
33
+ rowsShowing: (n: number, more: boolean) => string;
29
34
  reset: string;
30
35
  rowsBehind: (title: string) => string;
31
36
  notFilteredBy: (controls: readonly string[]) => string;
@@ -123,6 +128,8 @@ export type Messages = ReviewMessages & {
123
128
  keepEditing: string;
124
129
  /** An edit that never reached the server: offline, or the server is down. */
125
130
  unreachable: string;
131
+ /** Said when a tile is removed while editing. */
132
+ removedTile: (title: string) => string;
126
133
  /** A tile whose request failed before any answer came. */
127
134
  tileUnreachable: string;
128
135
  /** Said once a draft is discarded, as focus returns to Edit. */
@@ -136,6 +143,10 @@ export type Messages = ReviewMessages & {
136
143
  untitledDashboard: string;
137
144
  /** Beside a dashboard only its maker sees yet. */
138
145
  unpublished: string;
146
+ /** Over the dashboards the app ships (`default:` ids), when the list has others too. */
147
+ builtIn: string;
148
+ /** Over the dashboards made in the app, under the built-in ones. */
149
+ madeHere: string;
139
150
  dashboardTitle: string;
140
151
  history: string;
141
152
  noHistory: string;
@@ -152,8 +163,10 @@ export type Messages = ReviewMessages & {
152
163
  previewFailed: string;
153
164
  };
154
165
  /** What formatting reads besides a cell and its column: the locale, and the words to show. */
166
+ /** What formatting a cell reads besides its column: the locale, the words, and the zone times show in. */
155
167
  export type CellFormat = {
156
168
  locale?: string | undefined;
157
169
  messages?: Messages;
170
+ timeZone?: string | undefined;
158
171
  };
159
172
  export { ENGLISH };
@@ -1,17 +1,25 @@
1
+ import { LinkComponent } from "../context.mjs";
2
+ import { TileDrill } from "../drill/props.mjs";
1
3
  import { Messages } from "../messages.mjs";
2
4
  import { ReactNode } from "react";
3
5
  import { TileAnswer, Widget } from "derive-dashboards/core";
4
- /** What a renderer draws, and how: pass the props as `formatCell`'s format to use both. */
6
+ /**
7
+ * What a renderer draws, and how: pass the props as `formatCell`'s format to use both. `drill`
8
+ * is there when drilling is on: spread `drill.props(row, entry)` on a mark to make it open.
9
+ */
5
10
  export type TileRendererProps = {
6
11
  answer: TileAnswer;
7
12
  widget: Widget;
8
13
  locale?: string;
9
14
  messages: Messages;
15
+ drill?: TileDrill;
16
+ /** The provider's link component, for a renderer that links rows into the app. */
17
+ link?: LinkComponent;
10
18
  };
11
19
  /** Draws one tile's answer. Register more by widget kind on the provider. */
12
20
  export type TileRenderer = (props: TileRendererProps) => ReactNode;
13
21
  /**
14
- * The first value column, large, from the total row when there is one, else the first row;
22
+ * The first calc or value column, large, from the total row when there is one, else the first row;
15
23
  * a change calc (a signed column) sits under it.
16
24
  */
17
25
  export declare function NumberTile(props: TileRendererProps): import("react").JSX.Element;
@@ -1,29 +1,63 @@
1
1
  import { formatCell } from "../format.mjs";
2
+ import { ListTile } from "./list.mjs";
2
3
  import { isMark } from "derive-dashboards/core";
3
4
  import { jsx, jsxs } from "react/jsx-runtime";
4
5
  // src/renderers/index.tsx
5
6
  const isMeasure = (column) => column.id.startsWith("m") || column.id.startsWith("c");
6
7
  const isAll = (cell) => isMark(cell) && cell.mark === "all";
8
+ /** A calc is what the query was built to show (a share, a rate); else its first value. */
9
+ const shownIndex = (columns) => {
10
+ const calc = columns.findIndex((c) => c.id.startsWith("c") && c.signed !== true);
11
+ return calc === -1 ? columns.findIndex((c) => isMeasure(c)) : calc;
12
+ };
7
13
  /**
8
- * The first value column, large, from the total row when there is one, else the first row;
14
+ * The first calc or value column, large, from the total row when there is one, else the first row;
9
15
  * a change calc (a signed column) sits under it.
10
16
  */
11
17
  function NumberTile(props) {
12
18
  const { answer } = props;
13
- const index = answer.columns.findIndex(isMeasure);
19
+ const index = shownIndex(answer.columns);
14
20
  const change = answer.columns.findIndex((c) => c.signed === true);
15
21
  const row = answer.rows.find((cells) => cells.some((cell) => isAll(cell))) ?? answer.rows[0];
16
22
  const cell = row?.[index] ?? null;
23
+ const entry = answer.columns[index]?.id;
24
+ const marks = row === void 0 ? void 0 : props.drill?.props(row, entry);
17
25
  return /* @__PURE__ */ jsxs("div", {
18
26
  className: "dd-number",
19
- children: [/* @__PURE__ */ jsx("span", {
20
- className: "dd-number-value",
21
- title: formatCell(cell, answer.columns[index], props),
22
- children: formatCell(cell, answer.columns[index], props)
23
- }), change === -1 ? null : /* @__PURE__ */ jsx("span", {
24
- className: "dd-number-change",
25
- children: formatCell(row?.[change] ?? null, answer.columns[change], props)
26
- })]
27
+ children: [
28
+ /* @__PURE__ */ jsx("span", {
29
+ className: "dd-number-value",
30
+ title: formatCell(cell, answer.columns[index], props),
31
+ ...marks,
32
+ children: formatCell(cell, answer.columns[index], props)
33
+ }),
34
+ change === -1 ? null : /* @__PURE__ */ jsx("span", {
35
+ className: "dd-number-change",
36
+ children: formatCell(row?.[change] ?? null, answer.columns[change], props)
37
+ }),
38
+ /* @__PURE__ */ jsx(Before, {
39
+ ...props,
40
+ index
41
+ })
42
+ ]
43
+ });
44
+ }
45
+ /** The value of the period before, when the answer compares: it opens that period's rows. */
46
+ function Before(props) {
47
+ const { answer, index } = props;
48
+ const before = answer.compare?.rows[0];
49
+ const column = answer.columns[index];
50
+ if (before === void 0 || column === void 0) return null;
51
+ const marks = props.drill?.props(before, column.id);
52
+ const text = props.messages.drillBefore(formatCell(before[index] ?? null, column, props));
53
+ const named = marks === void 0 ? marks : {
54
+ ...marks,
55
+ "aria-label": props.messages.drillMark(text)
56
+ };
57
+ return /* @__PURE__ */ jsx("span", {
58
+ className: "dd-number-before",
59
+ ...named,
60
+ children: text
27
61
  });
28
62
  }
29
63
  /** Cells as table cells: a run of equal marks is one cell spanning its columns. */
@@ -41,10 +75,13 @@ function spans(cells) {
41
75
  return out;
42
76
  }
43
77
  /** One table row. A row that folds dimensions is a summary, labelled where it folds them. */
44
- function Row({ cells, columns, format }) {
78
+ function Row({ cells, columns, format, drill }) {
45
79
  const summary = cells.some((cell) => isMark(cell));
80
+ const whole = drill?.props(cells);
81
+ const cellMarks = (column) => whole === void 0 && column !== void 0 && isMeasure(column) ? drill?.props(cells, column.id) : void 0;
46
82
  return /* @__PURE__ */ jsx("tr", {
47
83
  className: summary ? "dd-table-summary" : void 0,
84
+ ...whole,
48
85
  children: spans(cells).map(({ cell, at, span }) => {
49
86
  const column = columns[at];
50
87
  const numeric = column !== void 0 && isMeasure(column);
@@ -55,7 +92,8 @@ function Row({ cells, columns, format }) {
55
92
  }, column?.id ?? at);
56
93
  return /* @__PURE__ */ jsx("td", {
57
94
  "data-numeric": numeric,
58
- children: cell === null && column !== void 0 && !numeric ? format.messages.empty : formatCell(cell, column, format)
95
+ ...cellMarks(column),
96
+ children: cell === null && column !== void 0 && !numeric ? format.messages.drillNone(column.label) : formatCell(cell, column, format)
59
97
  }, column?.id ?? at);
60
98
  })
61
99
  });
@@ -74,12 +112,14 @@ function TableTile(props) {
74
112
  }, c.id)) }) }), /* @__PURE__ */ jsx("tbody", { children: answer.rows.map((cells) => /* @__PURE__ */ jsx(Row, {
75
113
  cells,
76
114
  columns,
77
- format: props
115
+ format: props,
116
+ drill: props.drill
78
117
  }, JSON.stringify(cells.slice(0, keys)))) })]
79
118
  });
80
119
  }
81
120
  const BUILTIN_RENDERERS = {
82
121
  number: NumberTile,
83
- table: TableTile
122
+ table: TableTile,
123
+ list: ListTile
84
124
  };
85
125
  export { BUILTIN_RENDERERS, NumberTile, TableTile };
@@ -0,0 +1,22 @@
1
+ import { TileRendererProps } from "./index.mjs";
2
+ /**
3
+ * How a list draws its rows, by the query's entry ids. Every key is optional: with none, the
4
+ * first group is the title, the other groups the subtitle, and the last value the number.
5
+ */
6
+ export type ListDisplay = {
7
+ /** The entry shown as the row's title. */
8
+ title?: string;
9
+ /** Entries shown under the title, joined with a dot. */
10
+ subtitle?: readonly string[];
11
+ /** The entry whose initials make the row's avatar. */
12
+ avatar?: string;
13
+ /** The number at the end of the row. */
14
+ meta?: string;
15
+ /** A link per row, with `{entry}` replaced by that entry's value: "/a/{t}". */
16
+ href?: string;
17
+ };
18
+ /**
19
+ * Rows as a list: an avatar, a title, a subtitle and one number, each row a link into the
20
+ * app (`display.href`) or, without one, a drill like a table row. Summary rows are left out.
21
+ */
22
+ export declare function ListTile(props: TileRendererProps): import("react").JSX.Element;
@@ -0,0 +1,118 @@
1
+ import { formatCell } from "../format.mjs";
2
+ import { RowBody } from "../RowBody.mjs";
3
+ import { isMark } from "derive-dashboards/core";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/renderers/list.tsx
6
+ const initials = (text) => text.split(/[\s._@-]+/u).filter(Boolean).slice(0, 2).map((word) => word[0]?.toUpperCase()).join("");
7
+ const asText = (value) => typeof value === "string" ? value : void 0;
8
+ const asList = (value) => Array.isArray(value) && value.every((v) => typeof v === "string") ? value : void 0;
9
+ const isValue = (c) => c.id.startsWith("m") || c.id.startsWith("c");
10
+ /** With no display, the first group is the title, the others the subtitle, the last value the number. */
11
+ function defaults(columns) {
12
+ const groups = columns.filter((c) => !isValue(c)).map((c) => c.id);
13
+ const meta = columns.findLast((c) => isValue(c))?.id;
14
+ return {
15
+ title: groups[0],
16
+ subtitle: groups.slice(1),
17
+ meta
18
+ };
19
+ }
20
+ /**
21
+ * The answer names a query's entries by place (m1.. measures, d1.. groups, c1.. calcs), as the
22
+ * server runs it; `display` names them as the widget's query does. This maps one to the other.
23
+ */
24
+ function answerIds(widget) {
25
+ const query = widget.queries["main"];
26
+ if (query === void 0) return /* @__PURE__ */ new Map();
27
+ return new Map([
28
+ ...query.measures.map((entry, i) => [entry.id, `m${String(i + 1)}`]),
29
+ ...(query.dimensions ?? []).map((entry, i) => [entry.id, `d${String(i + 1)}`]),
30
+ ...(query.calc ?? []).map((entry, i) => [entry.id, `c${String(i + 1)}`])
31
+ ]);
32
+ }
33
+ function readDisplay(widget, columns) {
34
+ const display = widget.display ?? {};
35
+ const ids = answerIds(widget);
36
+ const id = (entry) => entry === void 0 ? void 0 : ids.get(entry) ?? entry;
37
+ const fallback = defaults(columns);
38
+ const href = asText(display["href"]);
39
+ return {
40
+ title: id(asText(display["title"])) ?? fallback.title,
41
+ subtitle: asList(display["subtitle"])?.map((entry) => id(entry) ?? entry) ?? fallback.subtitle,
42
+ avatar: id(asText(display["avatar"])),
43
+ meta: id(asText(display["meta"])) ?? fallback.meta,
44
+ href: href?.replaceAll(/\{([^}]+)\}/gu, (_, entry) => `{${id(entry) ?? entry}}`)
45
+ };
46
+ }
47
+ const text = ({ cells, at, props }, id) => {
48
+ const index = at(id);
49
+ if (index === -1) return "";
50
+ const cell = cells[index] ?? null;
51
+ return cell === null ? "" : formatCell(cell, props.answer.columns[index], props);
52
+ };
53
+ /** A row's link: each `{entry}` in the template becomes that entry's raw value, encoded. */
54
+ const linkOf = (template, line) => {
55
+ let missing = false;
56
+ const href = template.replaceAll(/\{([^}]+)\}/gu, (_, id) => {
57
+ const cell = line.cells[line.at(id)];
58
+ if (cell === void 0 || cell === null || isMark(cell)) {
59
+ missing = true;
60
+ return "";
61
+ }
62
+ return encodeURIComponent(typeof cell === "object" ? cell.v : String(cell));
63
+ });
64
+ return missing ? void 0 : href;
65
+ };
66
+ function Anchor(props) {
67
+ const Link = props.link;
68
+ return Link === void 0 ? /* @__PURE__ */ jsx("a", {
69
+ className: "dd-lines-row",
70
+ href: props.href,
71
+ children: props.children
72
+ }) : /* @__PURE__ */ jsx(Link, {
73
+ className: "dd-lines-row",
74
+ href: props.href,
75
+ children: props.children
76
+ });
77
+ }
78
+ /**
79
+ * Rows as a list: an avatar, a title, a subtitle and one number, each row a link into the
80
+ * app (`display.href`) or, without one, a drill like a table row. Summary rows are left out.
81
+ */
82
+ function ListTile(props) {
83
+ const { answer } = props;
84
+ const shown = readDisplay(props.widget, answer.columns);
85
+ const at = (id) => answer.columns.findIndex((c) => c.id === id);
86
+ const rows = answer.rows.filter((cells) => !cells.some((cell) => isMark(cell)));
87
+ return /* @__PURE__ */ jsx("ul", {
88
+ className: "dd-lines",
89
+ children: rows.map((cells) => {
90
+ const line = {
91
+ cells,
92
+ at,
93
+ props
94
+ };
95
+ const row = {
96
+ title: text(line, shown.title) || props.messages.empty,
97
+ meta: shown.subtitle.map((id) => text(line, id)).filter(Boolean),
98
+ lead: shown.avatar === void 0 ? void 0 : initials(text(line, shown.avatar)),
99
+ value: text(line, shown.meta)
100
+ };
101
+ const body = /* @__PURE__ */ jsx(RowBody, {
102
+ row,
103
+ family: "lines"
104
+ });
105
+ const href = shown.href === void 0 ? void 0 : linkOf(shown.href, line);
106
+ return /* @__PURE__ */ jsx("li", { children: href === void 0 ? /* @__PURE__ */ jsx("div", {
107
+ className: "dd-lines-row",
108
+ ...props.drill?.props(cells),
109
+ children: body
110
+ }) : /* @__PURE__ */ jsx(Anchor, {
111
+ href,
112
+ link: props.link,
113
+ children: body
114
+ }) }, JSON.stringify(cells));
115
+ })
116
+ });
117
+ }
118
+ export { ListTile };
@@ -95,7 +95,7 @@ const ENGLISH_REVIEW = {
95
95
  decideFirst: "Decide each change that no longer applies, then publish.",
96
96
  addWidgetFirst: "Add a widget to publish this dashboard.",
97
97
  headMoved: (n, who) => `${who ?? "Someone"} published version ${String(n)} just now. Showing your changes on top of it.`,
98
- widgetGone: "was removed in the version you are publishing over.",
98
+ widgetGone: "its tile was removed in the version you are publishing over.",
99
99
  layoutGaps: "The layout has gaps.",
100
100
  closeGaps: "Pull tiles left",
101
101
  pullLeft: "Pull tiles left",
@@ -4,7 +4,7 @@ import { useState } from "react";
4
4
  // src/review.ts
5
5
  /** The preview of what publishing would do, loaded on request, with its failure kept to show. */
6
6
  function usePreview(dashboardId) {
7
- const { client } = useDashboards();
7
+ const { client, messages } = useDashboards();
8
8
  const [preview, setPreview] = useState();
9
9
  const [loading, setLoading] = useState(false);
10
10
  const [failed, setFailed] = useState();
@@ -16,7 +16,7 @@ function usePreview(dashboardId) {
16
16
  setPreview(next);
17
17
  return next;
18
18
  } catch (failure) {
19
- setFailed(failure instanceof Error ? failure.message : String(failure));
19
+ setFailed(failure instanceof TypeError ? messages.unreachable : failure instanceof Error ? failure.message : String(failure));
20
20
  return null;
21
21
  } finally {
22
22
  setLoading(false);
@@ -1,9 +1,4 @@
1
- import { createContext, useContext } from "react";
1
+ import { createContext } from "react";
2
2
  // src/scope.tsx
3
3
  const ScopeContext = createContext(null);
4
- function useDashboardScope() {
5
- const scope = useContext(ScopeContext);
6
- if (scope === null) throw new Error("This part is drawn only inside a <Dashboard>.");
7
- return scope;
8
- }
9
- export { ScopeContext, useDashboardScope };
4
+ export { ScopeContext };
@@ -0,0 +1,37 @@
1
+ import { CellFormat } from "./messages.mjs";
2
+ import { ResultColumn, TileAnswer } from "derive-dashboards/core";
3
+ /** One point of a chart: its x label and a number per series key. */
4
+ export type Point = {
5
+ x: string;
6
+ } & Record<string, number | string | null>;
7
+ export type Series = {
8
+ key: string;
9
+ label: string;
10
+ column: ResultColumn;
11
+ };
12
+ /** The series key a dimension's Other draws as. */
13
+ export declare const OTHER_KEY = "other";
14
+ /**
15
+ * Chart data from an answer. The first non-value column is the x axis (the time bucket when
16
+ * there is one). With a second key column, the first value is split into one series per
17
+ * value of it, and Other in that column is one more series; otherwise every value column is
18
+ * its own series. Other on the x axis is one more point; totals are not drawn.
19
+ */
20
+ export declare function toSeries(answer: Pick<TileAnswer, "columns" | "rows">, format?: CellFormat): Drawn;
21
+ /**
22
+ * What a chart draws, and the way back from any chart kit's point to the answer's row:
23
+ * `rowAt(point, seriesKey)` gives the row's index in `answer.rows` (for a drill), or undefined
24
+ * for a point no row stands behind.
25
+ */
26
+ export type Drawn = {
27
+ points: Point[];
28
+ series: Series[];
29
+ split: boolean;
30
+ rowAt: (point: number | Point, seriesKey: string) => number | undefined;
31
+ };
32
+ /**
33
+ * The row of the answer behind a point of any chart kit's series, by the point's place (or the
34
+ * point) and the series key; undefined for a point no row stands behind. Pass it to
35
+ * `drill.open(row, series.column.id)` to open what is behind the point.
36
+ */
37
+ export declare const rowAt: (drawn: Drawn, point: number | Point, seriesKey: string) => number | undefined;
@@ -0,0 +1,95 @@
1
+ import { formatCell, plotValue } from "./format.mjs";
2
+ import { ENGLISH } from "./english.mjs";
3
+ import { isMark } from "derive-dashboards/core";
4
+ // src/series.ts
5
+ const isValue = (c) => c.id.startsWith("m") || c.id.startsWith("c");
6
+ /** The series key a dimension's Other draws as. */
7
+ const OTHER_KEY = "other";
8
+ const isAll = (cell) => isMark(cell) && cell.mark === "all";
9
+ /**
10
+ * Chart data from an answer. The first non-value column is the x axis (the time bucket when
11
+ * there is one). With a second key column, the first value is split into one series per
12
+ * value of it, and Other in that column is one more series; otherwise every value column is
13
+ * its own series. Other on the x axis is one more point; totals are not drawn.
14
+ */
15
+ function toSeries(answer, format = {}) {
16
+ const at = /* @__PURE__ */ new Map();
17
+ const drawn = drawSeries(answer, format, (point, key, row) => {
18
+ at.set(`${String(point)}|${key}`, row);
19
+ });
20
+ return {
21
+ ...drawn,
22
+ rowAt: (point, key) => {
23
+ const index = typeof point === "number" ? point : drawn.points.indexOf(point);
24
+ return at.get(`${String(index)}|${key}`) ?? at.get(`${String(index)}|*`);
25
+ }
26
+ };
27
+ }
28
+ function drawSeries(answer, format, seen) {
29
+ const keyCount = answer.columns.filter((c) => !isValue(c)).length;
30
+ const all = answer.columns.slice(keyCount);
31
+ const calcs = all.filter((c) => c.id.startsWith("c"));
32
+ const values = calcs.length > 0 ? calcs : all;
33
+ const rows = answer.rows.map((row, index) => ({
34
+ row,
35
+ index
36
+ })).filter(({ row }) => !row.some((cell) => isAll(cell)));
37
+ const keyText = (cell, column) => {
38
+ if (cell !== null && cell !== "") return formatCell(cell, column, format);
39
+ const words = format.messages ?? ENGLISH;
40
+ return column === void 0 ? words.empty : words.drillNone(column.label);
41
+ };
42
+ const xOf = (row) => keyText(row[0] ?? null, answer.columns[0]);
43
+ if (keyCount < 2) {
44
+ const series = values.map((column) => ({
45
+ key: column.id,
46
+ label: column.label,
47
+ column
48
+ }));
49
+ return {
50
+ points: rows.map(({ row, index }, i) => {
51
+ seen(i, "*", index);
52
+ return {
53
+ x: keyCount === 0 ? "" : xOf(row),
54
+ ...Object.fromEntries(values.map((c) => [c.id, plotValue(row[answer.columns.indexOf(c)] ?? null)]))
55
+ };
56
+ }),
57
+ series,
58
+ split: false
59
+ };
60
+ }
61
+ const first = values[0];
62
+ if (first === void 0) return {
63
+ points: [],
64
+ series: [],
65
+ split: true
66
+ };
67
+ const byX = /* @__PURE__ */ new Map();
68
+ const names = /* @__PURE__ */ new Map();
69
+ for (const { row, index } of rows) {
70
+ const split = row[1] ?? null;
71
+ const key = isMark(split) ? split.mark : `s${JSON.stringify(split)}`;
72
+ names.set(key, keyText(split, answer.columns[1]));
73
+ const point = byX.get(xOf(row)) ?? { x: xOf(row) };
74
+ point[key] = plotValue(row[keyCount] ?? null);
75
+ byX.set(xOf(row), point);
76
+ seen([...byX.keys()].indexOf(xOf(row)), key, index);
77
+ }
78
+ const series = [...names].map(([key, label]) => ({
79
+ key,
80
+ label,
81
+ column: first
82
+ })).toSorted((a, b) => Number(a.key === OTHER_KEY) - Number(b.key === OTHER_KEY));
83
+ return {
84
+ points: [...byX.values()],
85
+ series,
86
+ split: true
87
+ };
88
+ }
89
+ /**
90
+ * The row of the answer behind a point of any chart kit's series, by the point's place (or the
91
+ * point) and the series key; undefined for a point no row stands behind. Pass it to
92
+ * `drill.open(row, series.column.id)` to open what is behind the point.
93
+ */
94
+ const rowAt = (drawn, point, seriesKey) => drawn.rowAt(point, seriesKey);
95
+ export { OTHER_KEY, rowAt, toSeries };