@surfaces-ui/components 0.0.0-stage → 0.2.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 (264) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +48 -2
  4. package/dist/appComponents.d.ts +86 -0
  5. package/dist/appComponents.js +555 -0
  6. package/dist/appComponents.js.map +1 -0
  7. package/dist/chart/BulletGraph.d.ts +44 -0
  8. package/dist/chart/BulletGraph.js +40 -0
  9. package/dist/chart/BulletGraph.js.map +1 -0
  10. package/dist/chart/Chart.d.ts +177 -0
  11. package/dist/chart/Chart.js +279 -0
  12. package/dist/chart/Chart.js.map +1 -0
  13. package/dist/chart/Sparkline.d.ts +35 -0
  14. package/dist/chart/Sparkline.js +37 -0
  15. package/dist/chart/Sparkline.js.map +1 -0
  16. package/dist/chart/advice.d.ts +28 -0
  17. package/dist/chart/advice.js +39 -0
  18. package/dist/chart/advice.js.map +1 -0
  19. package/dist/chart/option.d.ts +90 -0
  20. package/dist/chart/option.js +252 -0
  21. package/dist/chart/option.js.map +1 -0
  22. package/dist/controls/Combobox.d.ts +39 -0
  23. package/dist/controls/Combobox.js +75 -0
  24. package/dist/controls/Combobox.js.map +1 -0
  25. package/dist/controls/ConfirmDialog.d.ts +35 -0
  26. package/dist/controls/ConfirmDialog.js +84 -0
  27. package/dist/controls/ConfirmDialog.js.map +1 -0
  28. package/dist/controls/ItemControls.d.ts +115 -0
  29. package/dist/controls/ItemControls.js +109 -0
  30. package/dist/controls/ItemControls.js.map +1 -0
  31. package/dist/controls/Popover.d.ts +31 -0
  32. package/dist/controls/Popover.js +114 -0
  33. package/dist/controls/Popover.js.map +1 -0
  34. package/dist/controls/ResizeHandle.d.ts +48 -0
  35. package/dist/controls/ResizeHandle.js +91 -0
  36. package/dist/controls/ResizeHandle.js.map +1 -0
  37. package/dist/controls/SegmentedControl.d.ts +27 -0
  38. package/dist/controls/SegmentedControl.js +17 -0
  39. package/dist/controls/SegmentedControl.js.map +1 -0
  40. package/dist/controls/StatusBadge.d.ts +17 -0
  41. package/dist/controls/StatusBadge.js +10 -0
  42. package/dist/controls/StatusBadge.js.map +1 -0
  43. package/dist/controls/context.d.ts +17 -0
  44. package/dist/controls/context.js +2 -0
  45. package/dist/controls/context.js.map +1 -0
  46. package/dist/controls/placement.d.ts +43 -0
  47. package/dist/controls/placement.js +19 -0
  48. package/dist/controls/placement.js.map +1 -0
  49. package/dist/controls/resize.d.ts +23 -0
  50. package/dist/controls/resize.js +49 -0
  51. package/dist/controls/resize.js.map +1 -0
  52. package/dist/data/DataSourceProvider.d.ts +11 -0
  53. package/dist/data/DataSourceProvider.js +21 -0
  54. package/dist/data/DataSourceProvider.js.map +1 -0
  55. package/dist/data/export.d.ts +33 -0
  56. package/dist/data/export.js +77 -0
  57. package/dist/data/export.js.map +1 -0
  58. package/dist/data/format.d.ts +44 -0
  59. package/dist/data/format.js +127 -0
  60. package/dist/data/format.js.map +1 -0
  61. package/dist/data/messages.d.ts +13 -0
  62. package/dist/data/messages.js +2 -0
  63. package/dist/data/messages.js.map +1 -0
  64. package/dist/data/useRowWindow.d.ts +70 -0
  65. package/dist/data/useRowWindow.js +175 -0
  66. package/dist/data/useRowWindow.js.map +1 -0
  67. package/dist/discovery/AskData.d.ts +22 -0
  68. package/dist/discovery/AskData.js +48 -0
  69. package/dist/discovery/AskData.js.map +1 -0
  70. package/dist/discovery/ContextBuilder.d.ts +49 -0
  71. package/dist/discovery/ContextBuilder.js +167 -0
  72. package/dist/discovery/ContextBuilder.js.map +1 -0
  73. package/dist/discovery/DataSearch.d.ts +27 -0
  74. package/dist/discovery/DataSearch.js +73 -0
  75. package/dist/discovery/DataSearch.js.map +1 -0
  76. package/dist/discovery/ObjectDetail.d.ts +38 -0
  77. package/dist/discovery/ObjectDetail.js +129 -0
  78. package/dist/discovery/ObjectDetail.js.map +1 -0
  79. package/dist/discovery/RelationshipGraph.d.ts +19 -0
  80. package/dist/discovery/RelationshipGraph.js +64 -0
  81. package/dist/discovery/RelationshipGraph.js.map +1 -0
  82. package/dist/discovery/shared.d.ts +38 -0
  83. package/dist/discovery/shared.js +64 -0
  84. package/dist/discovery/shared.js.map +1 -0
  85. package/dist/editor/SqlEditor.d.ts +41 -0
  86. package/dist/editor/SqlEditor.js +181 -0
  87. package/dist/editor/SqlEditor.js.map +1 -0
  88. package/dist/explore/Explorer.d.ts +110 -0
  89. package/dist/explore/Explorer.js +471 -0
  90. package/dist/explore/Explorer.js.map +1 -0
  91. package/dist/explore/ModelLineage.d.ts +22 -0
  92. package/dist/explore/ModelLineage.js +70 -0
  93. package/dist/explore/ModelLineage.js.map +1 -0
  94. package/dist/explore/ReportBuilder.d.ts +39 -0
  95. package/dist/explore/ReportBuilder.js +98 -0
  96. package/dist/explore/ReportBuilder.js.map +1 -0
  97. package/dist/explore/SemanticModelEditor.d.ts +60 -0
  98. package/dist/explore/SemanticModelEditor.js +220 -0
  99. package/dist/explore/SemanticModelEditor.js.map +1 -0
  100. package/dist/explore/SemanticRows.d.ts +42 -0
  101. package/dist/explore/SemanticRows.js +117 -0
  102. package/dist/explore/SemanticRows.js.map +1 -0
  103. package/dist/explore/SemanticsProvider.d.ts +31 -0
  104. package/dist/explore/SemanticsProvider.js +72 -0
  105. package/dist/explore/SemanticsProvider.js.map +1 -0
  106. package/dist/explore/model.d.ts +151 -0
  107. package/dist/explore/model.js +344 -0
  108. package/dist/explore/model.js.map +1 -0
  109. package/dist/explore/report.d.ts +60 -0
  110. package/dist/explore/report.js +92 -0
  111. package/dist/explore/report.js.map +1 -0
  112. package/dist/explore/semantic-proposal.d.ts +44 -0
  113. package/dist/explore/semantic-proposal.js +67 -0
  114. package/dist/explore/semantic-proposal.js.map +1 -0
  115. package/dist/explore/semantic.d.ts +44 -0
  116. package/dist/explore/semantic.js +154 -0
  117. package/dist/explore/semantic.js.map +1 -0
  118. package/dist/files/FileBrowser.d.ts +42 -0
  119. package/dist/files/FileBrowser.js +314 -0
  120. package/dist/files/FileBrowser.js.map +1 -0
  121. package/dist/files/files.d.ts +65 -0
  122. package/dist/files/files.js +165 -0
  123. package/dist/files/files.js.map +1 -0
  124. package/dist/filter/FilterBar.d.ts +49 -0
  125. package/dist/filter/FilterBar.js +153 -0
  126. package/dist/filter/FilterBar.js.map +1 -0
  127. package/dist/filter/QueryFilters.d.ts +25 -0
  128. package/dist/filter/QueryFilters.js +58 -0
  129. package/dist/filter/QueryFilters.js.map +1 -0
  130. package/dist/form/Form.d.ts +76 -0
  131. package/dist/form/Form.js +131 -0
  132. package/dist/form/Form.js.map +1 -0
  133. package/dist/graph/NodeGraph.d.ts +30 -0
  134. package/dist/graph/NodeGraph.js +86 -0
  135. package/dist/graph/NodeGraph.js.map +1 -0
  136. package/dist/graph/model.d.ts +68 -0
  137. package/dist/graph/model.js +122 -0
  138. package/dist/graph/model.js.map +1 -0
  139. package/dist/grid/DataGrid.d.ts +98 -0
  140. package/dist/grid/DataGrid.js +399 -0
  141. package/dist/grid/DataGrid.js.map +1 -0
  142. package/dist/index.d.ts +84 -0
  143. package/dist/index.js +86 -0
  144. package/dist/index.js.map +1 -0
  145. package/dist/locale/SurfacesText.d.ts +17 -0
  146. package/dist/locale/SurfacesText.js +17 -0
  147. package/dist/locale/SurfacesText.js.map +1 -0
  148. package/dist/locale/locale.d.ts +305 -0
  149. package/dist/locale/locale.js +359 -0
  150. package/dist/locale/locale.js.map +1 -0
  151. package/dist/menu/ContextMenu.d.ts +31 -0
  152. package/dist/menu/ContextMenu.js +95 -0
  153. package/dist/menu/ContextMenu.js.map +1 -0
  154. package/dist/metric/Metric.d.ts +33 -0
  155. package/dist/metric/Metric.js +63 -0
  156. package/dist/metric/Metric.js.map +1 -0
  157. package/dist/metric/useMeasure.d.ts +23 -0
  158. package/dist/metric/useMeasure.js +43 -0
  159. package/dist/metric/useMeasure.js.map +1 -0
  160. package/dist/model/ModelDiagram.d.ts +142 -0
  161. package/dist/model/ModelDiagram.js +699 -0
  162. package/dist/model/ModelDiagram.js.map +1 -0
  163. package/dist/panzoom/usePanZoom.d.ts +117 -0
  164. package/dist/panzoom/usePanZoom.js +313 -0
  165. package/dist/panzoom/usePanZoom.js.map +1 -0
  166. package/dist/pipeline/DatasetReview.d.ts +48 -0
  167. package/dist/pipeline/DatasetReview.js +157 -0
  168. package/dist/pipeline/DatasetReview.js.map +1 -0
  169. package/dist/pipeline/IngestWizard.d.ts +51 -0
  170. package/dist/pipeline/IngestWizard.js +79 -0
  171. package/dist/pipeline/IngestWizard.js.map +1 -0
  172. package/dist/pipeline/Pipeline.d.ts +171 -0
  173. package/dist/pipeline/Pipeline.js +203 -0
  174. package/dist/pipeline/Pipeline.js.map +1 -0
  175. package/dist/pipeline/PipelineView.d.ts +63 -0
  176. package/dist/pipeline/PipelineView.js +239 -0
  177. package/dist/pipeline/PipelineView.js.map +1 -0
  178. package/dist/pivot/PivotTable.d.ts +94 -0
  179. package/dist/pivot/PivotTable.js +171 -0
  180. package/dist/pivot/PivotTable.js.map +1 -0
  181. package/dist/plan/QueryPlan.d.ts +29 -0
  182. package/dist/plan/QueryPlan.js +79 -0
  183. package/dist/plan/QueryPlan.js.map +1 -0
  184. package/dist/result/QueryResult.d.ts +51 -0
  185. package/dist/result/QueryResult.js +255 -0
  186. package/dist/result/QueryResult.js.map +1 -0
  187. package/dist/review/ActionReceipt.d.ts +52 -0
  188. package/dist/review/ActionReceipt.js +32 -0
  189. package/dist/review/ActionReceipt.js.map +1 -0
  190. package/dist/review/PiiReview.d.ts +37 -0
  191. package/dist/review/PiiReview.js +29 -0
  192. package/dist/review/PiiReview.js.map +1 -0
  193. package/dist/review/PlanReview.d.ts +42 -0
  194. package/dist/review/PlanReview.js +37 -0
  195. package/dist/review/PlanReview.js.map +1 -0
  196. package/dist/review/StepFlow.d.ts +25 -0
  197. package/dist/review/StepFlow.js +21 -0
  198. package/dist/review/StepFlow.js.map +1 -0
  199. package/dist/review/pii.d.ts +21 -0
  200. package/dist/review/pii.js +67 -0
  201. package/dist/review/pii.js.map +1 -0
  202. package/dist/rows/RowList.d.ts +41 -0
  203. package/dist/rows/RowList.js +71 -0
  204. package/dist/rows/RowList.js.map +1 -0
  205. package/dist/schema/ObjectBrowser.d.ts +78 -0
  206. package/dist/schema/ObjectBrowser.js +467 -0
  207. package/dist/schema/ObjectBrowser.js.map +1 -0
  208. package/dist/schema/ObjectInfo.d.ts +25 -0
  209. package/dist/schema/ObjectInfo.js +69 -0
  210. package/dist/schema/ObjectInfo.js.map +1 -0
  211. package/dist/schema/SchemaExplorer.d.ts +32 -0
  212. package/dist/schema/SchemaExplorer.js +175 -0
  213. package/dist/schema/SchemaExplorer.js.map +1 -0
  214. package/dist/schema/refs.d.ts +32 -0
  215. package/dist/schema/refs.js +65 -0
  216. package/dist/schema/refs.js.map +1 -0
  217. package/dist/site/Site.d.ts +191 -0
  218. package/dist/site/Site.js +138 -0
  219. package/dist/site/Site.js.map +1 -0
  220. package/dist/source/ConnectionBuilder.d.ts +54 -0
  221. package/dist/source/ConnectionBuilder.js +115 -0
  222. package/dist/source/ConnectionBuilder.js.map +1 -0
  223. package/dist/source/SourceList.d.ts +17 -0
  224. package/dist/source/SourceList.js +71 -0
  225. package/dist/source/SourceList.js.map +1 -0
  226. package/dist/styles.css +9882 -0
  227. package/dist/styles.layer.css +9886 -0
  228. package/dist/table/DataTable.d.ts +72 -0
  229. package/dist/table/DataTable.js +68 -0
  230. package/dist/table/DataTable.js.map +1 -0
  231. package/dist/table/Pagination.d.ts +20 -0
  232. package/dist/table/Pagination.js +16 -0
  233. package/dist/table/Pagination.js.map +1 -0
  234. package/dist/table/SelectionBar.d.ts +43 -0
  235. package/dist/table/SelectionBar.js +18 -0
  236. package/dist/table/SelectionBar.js.map +1 -0
  237. package/dist/text/Markdown.d.ts +71 -0
  238. package/dist/text/Markdown.js +187 -0
  239. package/dist/text/Markdown.js.map +1 -0
  240. package/dist/text/highlight.d.ts +23 -0
  241. package/dist/text/highlight.js +196 -0
  242. package/dist/text/highlight.js.map +1 -0
  243. package/dist/theme/ThemePicker.d.ts +16 -0
  244. package/dist/theme/ThemePicker.js +49 -0
  245. package/dist/theme/ThemePicker.js.map +1 -0
  246. package/dist/theme/ThemeProvider.d.ts +43 -0
  247. package/dist/theme/ThemeProvider.js +107 -0
  248. package/dist/theme/ThemeProvider.js.map +1 -0
  249. package/dist/workspace/NavBar.d.ts +23 -0
  250. package/dist/workspace/NavBar.js +171 -0
  251. package/dist/workspace/NavBar.js.map +1 -0
  252. package/dist/workspace/SideNav.d.ts +61 -0
  253. package/dist/workspace/SideNav.js +149 -0
  254. package/dist/workspace/SideNav.js.map +1 -0
  255. package/dist/workspace/Workspace.d.ts +50 -0
  256. package/dist/workspace/Workspace.js +243 -0
  257. package/dist/workspace/Workspace.js.map +1 -0
  258. package/dist/workspace/icons.d.ts +34 -0
  259. package/dist/workspace/icons.js +37 -0
  260. package/dist/workspace/icons.js.map +1 -0
  261. package/dist/workspace/layout.d.ts +74 -0
  262. package/dist/workspace/layout.js +276 -0
  263. package/dist/workspace/layout.js.map +1 -0
  264. package/package.json +85 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Explorer.js","sourceRoot":"","sources":["../../src/explore/Explorer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAA8F,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7K,OAAO,EAAE,KAAK,EAAmB,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAoB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;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K,CAAC,IAAI,CAAC,GAAQ,EACzD,KAAK,CAAC,KAAK,IACP,CACR,EACA,IAAI,CAAC,OAAO,IACT,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type DataSource, collect } from \"@surfaces-ui/data\";\nimport type { SemanticModel } from \"@surfaces-ui/proto\";\nimport type { Field } from \"apache-arrow\";\nimport { type FormEvent, type KeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { Chart, type ChartGrain } from \"../chart/Chart.js\";\nimport type { OnContext } from \"../controls/context.js\";\nimport { ControlIcon, type ItemControl, ItemControls } from \"../controls/ItemControls.js\";\nimport type { FilterSpec } from \"@surfaces-ui/data\";\nimport { filtersExcept, filtersFromSpec } from \"@surfaces-ui/data\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { formatCell, numericValue } from \"../data/format.js\";\nimport { type FilterInit, messageOf } from \"../data/useRowWindow.js\";\nimport { QueryFilters } from \"../filter/QueryFilters.js\";\nimport { type MenuItem, useContextMenu } from \"../menu/ContextMenu.js\";\nimport {\n type ExploreChartType,\n type ExploreMeasureStyle,\n type ExploreState,\n type Pill,\n type PillAggregate,\n type PillFormat,\n type PillKind,\n addToShelf,\n emptyExplore,\n exploreChart,\n exploreQuery,\n movePill,\n normalizeExplore,\n pillColumn,\n pillId,\n pillNumber,\n pillProblem,\n pillsFromFields,\n suggestedView,\n removeFromShelf,\n setChartSettings,\n setMeasureStyle,\n setPill,\n suggestDerived,\n swapProblem,\n} from \"./model.js\";\nimport { canPromote, mergeModelPills, pillsWithModel } from \"./semantic.js\";\nimport { ModelLineage } from \"./ModelLineage.js\";\n\nexport interface ExplorerProps {\n /** Where the query runs. Left out, the model's source. */\n sourceId?: string;\n /** The query to explore: a table, or a join. Every pill is a column of it or a calculation over them. Left out, the model's query. */\n sql?: string;\n /**\n * The semantic model the fields come from. Its dimensions, measures and\n * metrics become pills marked as the model's, before pills generated for\n * the columns it leaves out; when it changes, its pills follow.\n */\n model?: SemanticModel;\n /**\n * Offers \"Add to the model\" on a pill that is not the model's own (made\n * here, written by an agent, or changed by hand). The host saves it, for\n * example with `useSemanticModel(...).promote`, and passes the new model.\n * Resolve to a sentence saying what happened.\n */\n onPromote?(pill: Pill, all: Pill[]): Promise<string | void> | string | void;\n /** What is on the shelves, when the host holds it. With no fields, pills are generated from the query's columns. */\n value?: ExploreState;\n defaultValue?: ExploreState;\n onChange?(state: ExploreState): void;\n /**\n * Shows a box to ask for a field or a view in words (\"refund rate by\n * region\"). The host passes the words to its agent, which answers by\n * setting `value`. The component never calls a model itself.\n */\n onAsk?(text: string, state: ExploreState): void;\n /** Name recorded on pills a person makes or edits. Defaults to \"you\". */\n editor?: string;\n /** Told what a person does here as they do it (a field put on a shelf, a field made or changed, a calculation suggested), for an agent's context. */\n onContext?: OnContext;\n /** Controls for the view, shown in its corner when it is pointed at or focused: a report's \"Add to report\". Chart or table is chosen under \"Draw as\". */\n controls?: ItemControl[];\n /** Height of the chart in px. Defaults to 300. */\n chartHeight?: number;\n /**\n * When it generates its pills and nothing is on the shelves, put a first\n * view there (see `suggestedView`), so something is drawn before anyone\n * presses a pill. Off by default: a host that holds the shelves decides.\n */\n startWithView?: boolean;\n /**\n * What the host does with the view, drawn under it at its end edge: \"Put\n * this chart on the page\". There, it sits with what it acts on and clear\n * of the view's own controls in its corner.\n */\n actions?: ReactNode;\n dataSource?: DataSource;\n className?: string;\n}\n\ntype Shelf = \"rows\" | \"split\" | \"values\";\nconst SHELVES: { id: Shelf; label: string; takes: PillKind[]; hint: string }[] = [\n { id: \"rows\", label: \"Break down by\", takes: [\"attribute\"], hint: \"An attribute: one bar, point or row for each of its values.\" },\n { id: \"split\", label: \"Split by\", takes: [\"attribute\"], hint: \"An attribute whose values become separate series.\" },\n { id: \"values\", label: \"Measure\", takes: [\"metric\", \"derived\"], hint: \"Metrics and calculations: what is counted or added up.\" },\n];\nconst GLYPH: Record<PillKind, string> = { attribute: \"Abc\", metric: \"Σ\", derived: \"ƒ\" };\n/** How long a finger holds a pill before it drags it rather than scrolling the page. Shorter than a long press, which opens the pill's menu. */\nexport const TOUCH_HOLD_MS = 300;\nconst KIND_WORD: Record<PillKind, string> = { attribute: \"attribute\", metric: \"metric\", derived: \"calculation\" };\nconst AGGREGATES: { value: PillAggregate; label: string }[] = [\n { value: \"sum\", label: \"Sum\" },\n { value: \"avg\", label: \"Average\" },\n { value: \"count\", label: \"Count\" },\n { value: \"count_distinct\", label: \"Count of distinct values\" },\n { value: \"min\", label: \"Smallest\" },\n { value: \"max\", label: \"Largest\" },\n { value: \"median\", label: \"Median\" },\n];\nconst GRAINS: ChartGrain[] = [\"day\", \"week\", \"month\", \"quarter\", \"year\"];\nconst FORMATS: PillFormat[] = [\"number\", \"compact\", \"currency\", \"percent\"];\n\ninterface ExploreRows {\n rows?: Record<string, unknown>[];\n types?: Record<string, Field[\"type\"]>;\n error?: string;\n}\n\n/** The grouped result of what is on the shelves, asked of the engine again whenever the shelves, the pills or the filters change. */\nfunction useExploreRows(dataSource: DataSource, sourceId: string, sql: string, state: ExploreState, limit: number): ExploreRows {\n const key = JSON.stringify([sourceId, sql, state.rows, state.split, state.values, state.filters, state.fields, limit]);\n const [result, setResult] = useState<ExploreRows & { key: string }>({ key: \"\" });\n // biome-ignore lint/correctness/useExhaustiveDependencies: `key` stands for the query.\n useEffect(() => {\n const controller = new AbortController();\n let query: ReturnType<typeof exploreQuery>;\n try {\n query = exploreQuery(state, sql, limit);\n } catch (error) {\n setResult({ key, error: messageOf(error) });\n return;\n }\n collect(dataSource.execute({ sourceId, query }, { signal: controller.signal }))\n .then((found) => {\n if (controller.signal.aborted) return;\n const types = Object.fromEntries(found.table.schema.fields.map((f) => [f.name, f.type]));\n setResult({ key, rows: found.table.toArray().map((row) => row.toJSON() as Record<string, unknown>), types });\n })\n .catch((error: unknown) => !controller.signal.aborted && setResult({ key, error: messageOf(error) }));\n return () => controller.abort();\n }, [dataSource, key]);\n return result.key === key ? result : {};\n}\n\nconst shelfPills = (state: ExploreState) => [...state.rows, ...(state.split ? [state.split] : []), ...state.values].map((id) => state.fields.find((p) => p.id === id)).filter((p): p is Pill => !!p);\n\n/** The grouped result of what is on the shelves, as a small table. The engine summarises; at most `limit` rows are asked for. */\nfunction ExploreTable({ dataSource, sourceId, sql, state, limit = 200 }: { dataSource: DataSource; sourceId: string; sql: string; state: ExploreState; limit?: number }) {\n const result = useExploreRows(dataSource, sourceId, sql, state, limit);\n const columns = shelfPills(state);\n if (result.error)\n return (\n <p className=\"sf-filter-problem\" role=\"alert\">\n {result.error}\n </p>\n );\n if (!result.rows) return <p className=\"sf-explore-hint\">Working it out…</p>;\n const cell = (pill: Pill, row: Record<string, unknown>) => {\n const value = row[pillColumn(pill)];\n const type = result.types?.[pillColumn(pill)];\n // A decimal arrives as its digits without the point; its type says where the point goes.\n if (pill.kind !== \"attribute\") return pillNumber(type ? numericValue(value, type) : value, pill.format);\n return value == null ? \"–\" : type ? formatCell(value, type).text : String(value);\n };\n return (\n <div className=\"sf-explore-table\" tabIndex={0} role=\"region\" aria-label=\"The numbers behind the view\">\n <table>\n <thead>\n <tr>\n {columns.map((pill) => (\n <th key={pill.id} scope=\"col\" data-number={pill.kind !== \"attribute\" || undefined}>\n {pill.label}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {result.rows.map((row, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: rows of one result do not move.\n <tr key={i}>\n {columns.map((pill) => (\n <td key={pill.id} data-number={pill.kind !== \"attribute\" || undefined}>\n {cell(pill, row)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n {result.rows.length >= limit && <p className=\"sf-explore-hint\">The first {limit} rows, in the order shown. Add a filter or a coarser breakdown to see fewer.</p>}\n </div>\n );\n}\n\n/** Values with nothing to break them down by: one number each, worked out by the engine, shown as headline figures. */\nfunction ExploreNumbers({ dataSource, sourceId, sql, state }: { dataSource: DataSource; sourceId: string; sql: string; state: ExploreState }) {\n const result = useExploreRows(dataSource, sourceId, sql, { ...state, rows: [], split: undefined }, 1);\n const values = state.values.map((id) => state.fields.find((p) => p.id === id)).filter((p): p is Pill => !!p);\n if (result.error)\n return (\n <p className=\"sf-filter-problem\" role=\"alert\">\n {result.error}\n </p>\n );\n return (\n <dl className=\"sf-explore-numbers\">\n {values.map((pill) => (\n <div key={pill.id}>\n <dt>{pill.label}</dt>\n <dd>{result.rows ? pillNumber(result.types?.[pill.id] ? numericValue(result.rows[0]?.[pill.id], result.types[pill.id]!) : result.rows[0]?.[pill.id], pill.format) : \"…\"}</dd>\n </div>\n ))}\n </dl>\n );\n}\n\nexport interface ExploreViewProps {\n sourceId: string;\n sql: string;\n /** The pills, the shelves and the filters to draw. */\n state: ExploreState;\n /** Chart or table. Defaults to the state's own, then a chart. Values with no breakdown are always numbers. */\n view?: \"chart\" | \"table\";\n /** Height of the chart in px. Defaults to 300. */\n height?: number;\n /** Accessible description of what is drawn. */\n label?: string;\n /**\n * Makes a bar chart a filter: called with the breakdown's column and the\n * value clicked. The view then leaves out filters on that column, so the\n * bars a person clicks stay. Only for a category breakdown.\n */\n onPointClick?(column: string, value: string | number): void;\n dataSource?: DataSource;\n}\n\n/**\n * What a set of shelves draws: a chart when there is something to break\n * down by, the numbers behind it as a table, or headline figures when there\n * is nothing to break down by. One tile of a report, or the explorer's own\n * result. Everything is worked out by the engine.\n */\nexport function ExploreView(props: ExploreViewProps) {\n const { sourceId, sql, state, height = 300, label, onPointClick } = props;\n const dataSource = useDataSource(props.dataSource);\n const chart = useMemo(() => exploreChart(state), [state]);\n const clickable = !!onPointClick && !!chart && !chart.xGrain;\n const [filters, problem] = useMemo((): [FilterInit[], string | undefined] => {\n try {\n return [filtersFromSpec(clickable ? filtersExcept(state.filters, chart!.x) : state.filters), undefined];\n } catch (error) {\n return [[], messageOf(error)];\n }\n }, [state.filters, clickable, chart]);\n if (state.values.length === 0) return null;\n if (problem)\n return (\n <p className=\"sf-filter-problem\" role=\"alert\">\n {problem}\n </p>\n );\n const shown = props.view ?? state.view ?? \"chart\";\n if (!chart) return <ExploreNumbers dataSource={dataSource} sourceId={sourceId} sql={sql} state={state} />;\n if (shown === \"table\") return <ExploreTable dataSource={dataSource} sourceId={sourceId} sql={sql} state={state} />;\n return (\n <Chart\n key={JSON.stringify(chart)}\n dataSource={dataSource}\n sourceId={sourceId}\n sql={sql}\n filters={filters}\n type={chart.type}\n x={chart.x}\n xGrain={chart.xGrain}\n splitBy={chart.splitBy}\n y={chart.y}\n xTitle={chart.xTitle}\n yTitle={chart.yTitle}\n yRightTitle={chart.yRightTitle}\n yFormat={chart.yFormat}\n horizontal={chart.horizontal}\n height={height}\n label={label}\n onPointClick={clickable ? (point) => point.x != null && onPointClick!(chart.x, point.x) : undefined}\n />\n );\n}\n\n/** What the shelves say, in words: \"Refund rate by Category, split by Channel\". */\nexport function exploreReading(state: ExploreState): string {\n const label = (id: string) => state.fields.find((p) => p.id === id)?.label;\n return [\n state.values.map(label).filter(Boolean).join(\" and \"),\n state.rows.length > 0 ? `by ${state.rows.map(label).filter(Boolean).join(\", then \")}` : \"\",\n state.split ? `split by ${label(state.split)}` : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\n/** The form a pill is made or changed in. Nothing is saved until it is valid. Used by `Explorer` and `SemanticModelEditor`, so a field is edited the same way in both. */\nexport function PillEditor({\n pill,\n all,\n columns,\n isNew,\n modelLabel,\n onSave,\n onCancel,\n onRemove,\n onPromote,\n}: {\n pill: Pill;\n all: Pill[];\n columns: Field[];\n isNew: boolean;\n modelLabel?: string;\n onSave(next: Pill): void;\n onCancel(): void;\n onRemove?(): void;\n onPromote?(): void;\n}) {\n const id = useId();\n const [draft, setDraft] = useState(pill);\n const others = all.filter((p) => p.id !== pill.id);\n const named = isNew ? { ...draft, id: pillId(draft.label || KIND_WORD[draft.kind], others.map((p) => p.id)) } : draft;\n const problem = pillProblem(named, [...others, named], columns.map((c) => c.name));\n const metrics = all.filter((p) => p.kind === \"metric\");\n const field = columns.find((c) => c.name === draft.column);\n const temporal = !!field && /Timestamp|Date/.test(String(field.type));\n // Calculations that name this metric follow any change to it; say so before it is saved.\n const dependents = isNew || pill.kind !== \"metric\" ? [] : all.filter((p) => p.kind === \"derived\" && new RegExp(`\\\\b${pill.id}\\\\b`).test(p.expression ?? \"\"));\n const changesMeaning = dependents.length > 0 && (draft.aggregate !== pill.aggregate || draft.column !== pill.column);\n const submit = (event: FormEvent) => {\n event.preventDefault();\n if (!problem) onSave(named);\n };\n return (\n <form className=\"sf-explore-editor\" onSubmit={submit} aria-label={isNew ? `New ${KIND_WORD[draft.kind]}` : `Edit ${pill.label}`}>\n <p className=\"sf-explore-editor-title\">\n <span className=\"sf-pill-glyph\" aria-hidden=\"true\">\n {GLYPH[draft.kind]}\n </span>\n {isNew ? `New ${KIND_WORD[draft.kind]}` : `Edit ${KIND_WORD[draft.kind]}`}\n {!isNew && pill.by && <span className=\"sf-explore-by\"> · made by {pill.by}</span>}\n </p>\n {modelLabel && <p className=\"sf-explore-hint\">Defined in the {modelLabel} model. A change here stays in this view until it is added to the model again.</p>}\n <label htmlFor={`${id}-label`}>Label</label>\n <input id={`${id}-label`} className=\"sf-input\" value={draft.label} autoFocus onChange={(e) => setDraft({ ...draft, label: e.target.value })} />\n {draft.kind !== \"derived\" && (\n <>\n <label htmlFor={`${id}-column`}>Column</label>\n <select id={`${id}-column`} className=\"sf-input\" value={draft.column ?? \"\"} onChange={(e) => setDraft({ ...draft, column: e.target.value || undefined })}>\n {draft.kind === \"metric\" && <option value=\"\">(rows)</option>}\n {columns.map((c) => (\n <option key={c.name} value={c.name}>\n {c.name}\n </option>\n ))}\n </select>\n </>\n )}\n {draft.kind === \"attribute\" && temporal && (\n <>\n <label htmlFor={`${id}-grain`}>Grouped by</label>\n <select id={`${id}-grain`} className=\"sf-input\" value={draft.grain ?? \"month\"} onChange={(e) => setDraft({ ...draft, grain: e.target.value as ChartGrain })}>\n {GRAINS.map((g) => (\n <option key={g} value={g}>\n {g}\n </option>\n ))}\n </select>\n </>\n )}\n {draft.kind === \"metric\" && (\n <>\n <label htmlFor={`${id}-aggregate`}>Summarised as</label>\n <select id={`${id}-aggregate`} className=\"sf-input\" value={draft.aggregate ?? \"sum\"} onChange={(e) => setDraft({ ...draft, aggregate: e.target.value as PillAggregate })}>\n {AGGREGATES.map((a) => (\n <option key={a.value} value={a.value}>\n {a.label}\n </option>\n ))}\n </select>\n </>\n )}\n {draft.kind === \"derived\" && (\n <>\n <label htmlFor={`${id}-expression`}>Calculation</label>\n <textarea\n id={`${id}-expression`}\n className=\"sf-input sf-explore-expression\"\n rows={2}\n spellCheck={false}\n value={draft.expression ?? \"\"}\n aria-describedby={`${id}-names`}\n placeholder=\"refund_amount / line_amount\"\n onChange={(e) => setDraft({ ...draft, expression: e.target.value })}\n />\n <p id={`${id}-names`} className=\"sf-explore-hint\">\n Metrics, numbers, + − × ÷ and parentheses. Worked out by the database after summarising. Press a metric to add it:\n </p>\n <div className=\"sf-explore-names\">\n {metrics.map((m) => (\n <button key={m.id} type=\"button\" className=\"sf-pill\" data-kind=\"metric\" title={m.label} onClick={() => setDraft({ ...draft, expression: `${draft.expression ?? \"\"}${draft.expression && !/[\\s(]$/.test(draft.expression) ? \" \" : \"\"}${m.id}` })}>\n <span className=\"sf-pill-glyph\" aria-hidden=\"true\">\n Σ\n </span>\n {m.id}\n </button>\n ))}\n </div>\n </>\n )}\n {draft.kind !== \"attribute\" && (\n <>\n <label htmlFor={`${id}-format`}>Shown as</label>\n <select id={`${id}-format`} className=\"sf-input\" value={draft.format ?? \"number\"} onChange={(e) => setDraft({ ...draft, format: e.target.value as PillFormat })}>\n {FORMATS.map((f) => (\n <option key={f} value={f}>\n {f}\n </option>\n ))}\n </select>\n </>\n )}\n <label htmlFor={`${id}-description`}>What it means (optional)</label>\n <input id={`${id}-description`} className=\"sf-input\" value={draft.description ?? \"\"} onChange={(e) => setDraft({ ...draft, description: e.target.value || undefined })} />\n {changesMeaning && (\n <p className=\"sf-explore-warning\" role=\"status\">\n {dependents.length === 1 ? \"A calculation uses\" : `${dependents.length} calculations use`} this metric and will change with it: {dependents.map((p) => p.label).join(\", \")}. To keep {dependents.length === 1 ? \"it\" : \"them\"} as {dependents.length === 1 ? \"it is\" : \"they are\"}, cancel and duplicate this metric instead.\n </p>\n )}\n {problem && (\n <p className=\"sf-filter-problem\" role=\"alert\">\n {problem}\n </p>\n )}\n <div className=\"sf-explore-editor-actions\">\n <button type=\"submit\" className=\"sf-button\" data-variant=\"primary\" disabled={!!problem}>\n {isNew ? \"Add\" : \"Save\"}\n </button>\n <button type=\"button\" className=\"sf-button\" onClick={onCancel}>\n Cancel\n </button>\n {onPromote && (\n <button type=\"button\" className=\"sf-button\" onClick={onPromote}>\n Add to the model\n </button>\n )}\n {onRemove && (\n <button type=\"button\" className=\"sf-button\" data-variant=\"danger\" onClick={onRemove}>\n Remove\n </button>\n )}\n </div>\n </form>\n );\n}\n\n/**\n * Exploring a query with pills. Every column becomes a pill generated on the\n * spot: an attribute to break down by or a metric to measure. Calculations\n * over metrics (a rate, a margin) are pills too, suggested, written by an\n * agent or made by hand, and every pill can be edited. Putting pills on the\n * shelves draws a chart and the numbers behind it, worked out by the\n * database. The shelves and the pills are plain data, so an agent can set\n * exactly what a person can drag, and sees what a person did.\n */\nexport function Explorer(props: ExplorerProps) {\n const { onChange, onAsk, editor = \"you\", chartHeight = 300, model } = props;\n const sourceId = props.sourceId ?? model?.sourceId ?? \"\";\n const sql = props.sql ?? model?.sql ?? \"\";\n const dataSource = useDataSource(props.dataSource);\n const menu = useContextMenu();\n const uid = useId();\n const [own, setOwn] = useState<ExploreState>(props.defaultValue ?? emptyExplore);\n const state = useMemo(() => normalizeExplore(props.value ?? own), [props.value, own]);\n // As given, before anything is taken off the shelves: shelves can name pills that are only generated once the columns are known.\n const latest = useRef(props.value ?? own);\n latest.current = props.value ?? own;\n const modelRef = useRef(model);\n modelRef.current = model;\n const set = useCallback(\n (next: ExploreState) => {\n const clean = normalizeExplore(next);\n setOwn(clean);\n onChange?.(clean);\n },\n [onChange],\n );\n\n const [columns, setColumns] = useState<Field[]>([]);\n const [problem, setProblem] = useState<string | undefined>();\n const [note, setNote] = useState(\"\");\n const [editing, setEditing] = useState<{ pill: Pill; isNew: boolean } | undefined>();\n const [search, setSearch] = useState(\"\");\n const context = useRef(props.onContext);\n context.current = props.onContext;\n /** Says what happened to the person, and tells the host the same as context for an agent. */\n const say = (kind: string, summary: string, subject?: Record<string, unknown>) => {\n setNote(summary);\n context.current?.({ kind, summary, ...(subject ? { subject } : {}) });\n };\n const [ask, setAsk] = useState(\"\");\n // Calculations and filters start folded unless there are some already; then each stays as a person leaves it.\n const [calculationsOpen, setCalculationsOpen] = useState(() => (props.value ?? props.defaultValue)?.fields?.some((p) => p.kind === \"derived\") ?? false);\n const [filtersOpen, setFiltersOpen] = useState(() => ((props.value ?? props.defaultValue)?.filters?.length ?? 0) > 0);\n const shown = state.view ?? \"chart\";\n\n // The query's columns: what a pill can be made from. With no pills given, they are generated from these.\n useEffect(() => {\n const controller = new AbortController();\n setProblem(undefined);\n collect(dataSource.execute({ sourceId, query: { baseSql: sql, page: { limit: 1 } } }, { signal: controller.signal }))\n .then((result) => {\n if (controller.signal.aborted) return;\n const found = result.table.schema.fields;\n setColumns(found);\n if (latest.current.fields.length === 0) {\n const fields = modelRef.current ? pillsWithModel(modelRef.current, found) : pillsFromFields(found);\n const empty = latest.current.rows.length === 0 && latest.current.values.length === 0 && !latest.current.split;\n set({ ...latest.current, fields, ...(props.startWithView && empty ? suggestedView(fields) : {}) });\n const own = fields.filter((p) => p.model).length;\n say(\n \"fields.generated\",\n own > 0 ? `${own} fields from the ${modelRef.current?.label || modelRef.current?.name} model, and ${fields.length - own} generated from the other columns.` : `${fields.length} fields generated from the columns. Edit any of them, or add your own.`,\n { fields: fields.map((p) => ({ id: p.id, kind: p.kind, label: p.label, ...(p.model ? { model: p.model } : {}) })) },\n );\n }\n })\n .catch((error: unknown) => !controller.signal.aborted && setProblem(messageOf(error)));\n return () => controller.abort();\n }, [dataSource, sourceId, sql]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // A model that changes (a field added to it here or elsewhere) brings its pills along; pills changed by hand stay as they are.\n useEffect(() => {\n if (!model || latest.current.fields.length === 0) return;\n const merged = mergeModelPills(latest.current.fields, model);\n if (JSON.stringify(merged) !== JSON.stringify(latest.current.fields)) set({ ...latest.current, fields: merged });\n }, [model]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const promote = async (target: Pill) => {\n if (!props.onPromote) return;\n try {\n const said = await props.onPromote(target, state.fields);\n say(\"field.promoted\", said || `${target.label} offered to the model.`, { field: target, ...(model ? { model: model.name } : {}) });\n } catch (error) {\n setNote(messageOf(error));\n }\n };\n const offer = (target: Pill) => !!props.onPromote && canPromote(target, model);\n\n const pill = (id: string) => state.fields.find((p) => p.id === id);\n const onShelf = (id: string): Shelf | undefined => (state.rows.includes(id) ? \"rows\" : state.split === id ? \"split\" : state.values.includes(id) ? \"values\" : undefined);\n const put = (id: string, shelf?: Shelf, at?: number) => {\n const target = pill(id);\n if (!target) return;\n const where = shelf ?? (target.kind === \"attribute\" ? \"rows\" : \"values\");\n const name = SHELVES.find((s) => s.id === where)!.label;\n if (!SHELVES.find((s) => s.id === where)!.takes.includes(target.kind)) return setNote(`${target.label} is ${target.kind === \"attribute\" ? \"an attribute\" : `a ${KIND_WORD[target.kind]}`}, so it cannot go on “${name}”.`);\n const was = onShelf(id);\n const next = addToShelf(state, id, where, at);\n set(next);\n const list = where === \"split\" ? [] : next[where];\n const place = list.indexOf(id) + 1;\n say(\n \"shelf.changed\",\n was === where && list.length > 1 ? `${target.label} moved to place ${place} of ${list.length} on “${name}”.` : `${target.label} added to “${name}”.`,\n { ...(was === where ? { moved: target.id } : { added: target.id }), shelf: where, rows: next.rows, split: next.split ?? null, values: next.values },\n );\n };\n const shift = (target: Pill, by: -1 | 1) => {\n const shelf = onShelf(target.id);\n if (shelf !== \"rows\" && shelf !== \"values\") return;\n const next = movePill(state, target.id, by);\n if (next === state) return setNote(`${target.label} is already ${by < 0 ? \"first\" : \"last\"} on “${SHELVES.find((s) => s.id === shelf)!.label}”.`);\n set(next);\n say(\"shelf.changed\", `${target.label} moved to place ${next[shelf].indexOf(target.id) + 1} of ${next[shelf].length} on “${SHELVES.find((s) => s.id === shelf)!.label}”.`, { moved: target.id, shelf, rows: next.rows, split: next.split ?? null, values: next.values });\n };\n const take = (id: string, shelf: Shelf) => {\n const next = removeFromShelf(state, id, shelf);\n set(next);\n say(\"shelf.changed\", `${pill(id)?.label ?? id} removed from “${SHELVES.find((s) => s.id === shelf)!.label}”.`, { removed: id, shelf, rows: next.rows, split: next.split ?? null, values: next.values });\n };\n const removeField = (target: Pill) => {\n set(setPill(state, target.id, undefined));\n say(\"field.removed\", `${target.label} removed.`, { field: target });\n };\n const CHART_WORD: Record<ExploreChartType, string> = { bar: \"bars\", line: \"a line\", area: \"an area\" };\n const chartTypeNow: ExploreChartType = state.chart?.type ?? (pill(state.rows[0] ?? \"\")?.grain ? \"line\" : \"bar\");\n const setType = (type: ExploreChartType) => {\n set({ ...setChartSettings(state, { type }), view: \"chart\" });\n say(\"chart.changed\", `Drawn as ${CHART_WORD[type]}.`, { chart: { type } });\n };\n const showTable = () => {\n set({ ...state, view: \"table\" });\n say(\"view.changed\", \"Shown as a table.\", { view: \"table\" });\n };\n const cannotSwap = swapProblem(state);\n const swapped = !!state.chart?.swap && !cannotSwap;\n const swap = () => {\n const next = !swapped;\n set(setChartSettings(state, { swap: next }));\n say(\"chart.changed\", next ? \"Axes swapped: the bars run across, the breakdown down the side.\" : \"Axes back: the bars stand up, the breakdown along the bottom.\", { chart: { swap: next } });\n };\n const styleOf = (id: string) => state.chart?.measures?.[id] ?? {};\n const restyle = (target: Pill, style: ExploreMeasureStyle) => {\n set(setMeasureStyle(state, target.id, style));\n const said = style.type ? `${target.label} drawn as ${CHART_WORD[style.type]}.` : style.axis === \"right\" ? `${target.label} measured on its own scale, at the right.` : `${target.label} measured on the left scale.`;\n say(\"chart.changed\", said, { measure: target.id, ...style });\n };\n // Two scales when some measures, but not all, are on the right (all on the right is drawn as one scale, on the left).\n const onRight = state.values.filter((id) => styleOf(id).axis === \"right\").length;\n const twoScales = onRight > 0 && onRight < state.values.length;\n // Which side's scale a measure is read against, marked on its pill when there are two.\n const sideOf = (id: string): \"left\" | \"right\" | undefined => (twoScales ? (styleOf(id).axis === \"right\" ? \"right\" : \"left\") : undefined);\n // What each shelf puts on the chart, said on the shelf itself.\n const axisOf: Record<Shelf, string> = { rows: swapped ? \"Y axis\" : \"X axis\", values: swapped ? \"X axis\" : twoScales ? \"Y axes\" : \"Y axis\", split: \"Colour\" };\n\n const blank = (kind: PillKind): Pill => ({ id: \"\", kind, label: \"\", by: editor, ...(kind === \"metric\" ? { aggregate: \"sum\" as const, column: columns.find((c) => /Int|Float|Decimal/.test(String(c.type)))?.name } : kind === \"attribute\" ? { column: columns[0]?.name } : { expression: \"\", format: \"number\" as const }) });\n\n const menuFor = (target: Pill): MenuItem[] => [\n ...(target.kind === \"attribute\"\n ? [\n { label: \"Break down by this\", onSelect: () => put(target.id, \"rows\"), hint: \"Enter\" },\n { label: \"Split by this\", onSelect: () => put(target.id, \"split\"), hint: \"S\" },\n ]\n : [{ label: \"Measure this\", onSelect: () => put(target.id, \"values\"), hint: \"Enter\" }]),\n ...(onShelf(target.id) ? [{ label: \"Take off the shelves\", onSelect: () => take(target.id, onShelf(target.id)!), hint: \"Delete\" }] : []),\n ...((onShelf(target.id) === \"rows\" || onShelf(target.id) === \"values\") && state[onShelf(target.id) as \"rows\" | \"values\"].length > 1\n ? [\n { label: \"Move earlier\", onSelect: () => shift(target, -1), hint: \"Alt+←\", disabled: state[onShelf(target.id) as \"rows\" | \"values\"][0] === target.id },\n { label: \"Move later\", onSelect: () => shift(target, 1), hint: \"Alt+→\", disabled: state[onShelf(target.id) as \"rows\" | \"values\"].at(-1) === target.id },\n ]\n : []),\n { separator: true },\n { label: \"Edit\", onSelect: () => setEditing({ pill: target, isNew: false }), hint: \"E\" },\n { label: \"Remove the field\", onSelect: () => removeField(target), hint: \"Shift+Delete\" },\n { label: \"Duplicate\", onSelect: () => setEditing({ pill: { ...target, label: `${target.label} copy`, by: editor, model: undefined }, isNew: true }), hint: \"D\" },\n ...(offer(target) ? [{ label: model && [...model.dimensions, ...model.measures, ...model.metrics].some((f) => f.name === target.id) ? \"Update it in the model\" : \"Add to the model\", onSelect: () => void promote(target), hint: \"M\" }] : []),\n ];\n\n // Dragging a pill: pointer events, so a finger and a pen work as a mouse does. A press that does not move is a click.\n // A finger has to hold still on a pill for a moment before it drags it (`TOUCH_HOLD_MS`): a finger that moves at once is scrolling the page,\n // which matters on a phone, where the pills fill the screen. A pen and a mouse drag at once.\n const [ghost, setGhost] = useState<{ label: string; kind: PillKind; x: number; y: number; over?: Shelf; id?: string; place?: number } | undefined>();\n const press = (target: Pill, from?: Shelf) => (event: ReactPointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n const start = { x: event.clientX, y: event.clientY };\n let dragging = false;\n let held = event.pointerType !== \"touch\";\n const shelfAt = (x: number, y: number) => (document.elementFromPoint(x, y)?.closest(\"[data-shelf]\") as HTMLElement | null)?.dataset.shelf as Shelf | undefined;\n // Where among the shelf's other pills the pointer is: before the first whose middle it has not passed, reading line by line.\n const placeAt = (shelf: Shelf, x: number, y: number): number | undefined => {\n if (shelf === \"split\") return undefined;\n const wraps = Array.from(document.querySelectorAll<HTMLElement>(`[data-shelf=\"${shelf}\"] [data-pill]`)).filter((w) => w.dataset.pill !== target.id);\n const index = wraps.findIndex((w) => {\n const r = w.getBoundingClientRect();\n return y < r.top || (y <= r.bottom && x < r.left + r.width / 2);\n });\n return index < 0 ? wraps.length : index;\n };\n const hold = held\n ? undefined\n : window.setTimeout(() => {\n held = true;\n // Lifted where the finger is, so the person sees it is now theirs to move.\n setGhost({ label: target.label, kind: target.kind, x: start.x, y: start.y, over: shelfAt(start.x, start.y) });\n }, TOUCH_HOLD_MS);\n // Once a finger holds a pill, the page must not scroll under it.\n const still = (e: TouchEvent) => held && e.cancelable && e.preventDefault();\n const move = (e: PointerEvent) => {\n const far = Math.hypot(e.clientX - start.x, e.clientY - start.y) >= 6;\n if (!held) return far ? void stop(e) : undefined;\n if (!dragging && !far) return;\n dragging = true;\n const over = shelfAt(e.clientX, e.clientY);\n setGhost({ label: target.label, kind: target.kind, x: e.clientX, y: e.clientY, over, id: target.id, ...(over ? { place: placeAt(over, e.clientX, e.clientY) } : {}) });\n };\n const stop = (e: Event) => {\n window.clearTimeout(hold);\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", up);\n window.removeEventListener(\"pointercancel\", stop);\n window.removeEventListener(\"contextmenu\", stop);\n window.removeEventListener(\"touchmove\", still);\n window.removeEventListener(\"keydown\", cancel);\n setGhost(undefined);\n return e;\n };\n const up = (e: PointerEvent) => {\n stop(e);\n if (!dragging) return;\n // The click that follows a drag must not also act.\n // Only the click the browser sends with this pointerup: when none comes (a drop outside any common ancestor), the next real click must still work.\n const swallow = (click: MouseEvent) => click.stopPropagation();\n window.addEventListener(\"click\", swallow, { capture: true, once: true });\n setTimeout(() => window.removeEventListener(\"click\", swallow, { capture: true }), 0);\n const shelf = shelfAt(e.clientX, e.clientY);\n if (shelf) put(target.id, shelf, placeAt(shelf, e.clientX, e.clientY));\n else if (from) take(target.id, from);\n };\n const cancel = (e: globalThis.KeyboardEvent) => e.key === \"Escape\" && stop(e);\n window.addEventListener(\"pointermove\", move);\n window.addEventListener(\"pointerup\", up);\n // The browser took the touch for a scroll, or a long press opened the pill's menu: no drag.\n window.addEventListener(\"pointercancel\", stop);\n window.addEventListener(\"contextmenu\", stop);\n window.addEventListener(\"touchmove\", still, { passive: false });\n window.addEventListener(\"keydown\", cancel);\n };\n\n const pillKeys = (target: Pill) => (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === \"s\" && target.kind === \"attribute\") put(target.id, \"split\");\n else if (event.key === \"e\") setEditing({ pill: target, isNew: false });\n else if (event.key === \"d\") setEditing({ pill: { ...target, label: `${target.label} copy`, by: editor, model: undefined }, isNew: true });\n else if (event.key === \"m\" && offer(target)) void promote(target);\n else if (event.altKey && (event.key === \"ArrowLeft\" || event.key === \"ArrowUp\")) shift(target, -1);\n else if (event.altKey && (event.key === \"ArrowRight\" || event.key === \"ArrowDown\")) shift(target, 1);\n else if ((event.key === \"Delete\" || event.key === \"Backspace\") && event.shiftKey) removeField(target);\n else if ((event.key === \"Delete\" || event.key === \"Backspace\") && onShelf(target.id)) take(target.id, onShelf(target.id)!);\n else return;\n event.preventDefault();\n };\n\n /** While dragging over a shelf: true for the pill the dragged one would land before. */\n const insertBefore = (shelf: Shelf, id: string) => {\n if (!ghost || ghost.place === undefined || shelf === \"split\") return false;\n const others = state[shelf].filter((item) => item !== ghost.id);\n return others[ghost.place] === id;\n };\n const drawPill = (target: Pill, shelf?: Shelf) => {\n const bad = pillProblem(target, state.fields, columns.length > 0 ? columns.map((c) => c.name) : undefined);\n const side = shelf === \"values\" && chart && shown === \"chart\" ? sideOf(target.id) : undefined;\n const tag = shelf ? undefined : target.model ? \"model\" : target.by && target.by !== \"the columns\" ? (target.by === \"suggested from the columns\" ? \"suggested\" : target.by) : undefined;\n return (\n <span key={target.id} className=\"sf-pill-wrap\" data-pill={shelf ? target.id : undefined} data-insert={shelf && ghost?.over === shelf && ghost.id !== target.id && insertBefore(shelf, target.id) ? \"before\" : undefined} data-kind={target.kind} data-on={(!shelf && onShelf(target.id)) || undefined} data-bad={bad ? \"true\" : undefined}>\n <button\n type=\"button\"\n className=\"sf-pill\"\n data-kind={target.kind}\n title={[target.description, bad, target.kind === \"derived\" ? target.expression : undefined, target.model ? `From the ${model?.label || target.model} model` : undefined, target.by ? `Made by ${target.by}` : undefined].filter(Boolean).join(\" · \")}\n aria-keyshortcuts={`Enter S E D${offer(target) ? \" M\" : \"\"} Delete Shift+Delete${shelf === \"rows\" || shelf === \"values\" ? \" Alt+ArrowLeft Alt+ArrowRight\" : \"\"} Shift+F10`}\n onPointerDown={press(target, shelf)}\n onClick={() => (shelf ? setEditing({ pill: target, isNew: false }) : put(target.id))}\n onKeyDown={pillKeys(target)}\n onContextMenu={(event) => menu.open(event, `${target.label} actions`, menuFor(target))}\n >\n <span className=\"sf-pill-glyph\" aria-hidden=\"true\">\n {GLYPH[target.kind]}\n </span>\n <span className=\"sf-pill-label\">\n {target.label}\n {/* Read after the visible name, so what is said begins with what is seen (WCAG 2.5.3). */}\n {\" \"}\n <span className=\"sf-visually-hidden\">{`(${KIND_WORD[target.kind]}${tag ? `, ${tag === \"model\" ? \"from the model\" : `by ${tag}`}` : \"\"}${side ? `, ${side} scale` : \"\"}${shelf ? \"\" : onShelf(target.id) ? \", in use\" : \"\"}${bad ? `, problem: ${bad}` : \"\"})`}</span>\n </span>\n {side && (\n <span className=\"sf-pill-side\" data-side={side} aria-hidden=\"true\">\n {side}\n </span>\n )}\n {tag && (\n <span className=\"sf-pill-by\" data-model={target.model ? \"true\" : undefined} aria-hidden=\"true\">\n {tag}\n </span>\n )}\n </button>\n {shelf ? (\n <button type=\"button\" className=\"sf-pill-x\" aria-label={`Take ${target.label} off “${SHELVES.find((s) => s.id === shelf)!.label}”`} onClick={() => take(target.id, shelf)}>\n <ControlIcon icon=\"close\" />\n </button>\n ) : (\n <>\n <button type=\"button\" className=\"sf-pill-x\" data-control=\"edit\" aria-label={`Edit ${target.label}`} onClick={() => setEditing({ pill: target, isNew: false })}>\n <ControlIcon icon=\"edit\" />\n </button>\n {/* A pill in use can be taken off from where it is picked, without finding it on its shelf. */}\n {onShelf(target.id) && (\n <button type=\"button\" className=\"sf-pill-x\" aria-label={`Take ${target.label} off “${SHELVES.find((s) => s.id === onShelf(target.id))!.label}”`} onClick={() => take(target.id, onShelf(target.id)!)}>\n <ControlIcon icon=\"close\" />\n </button>\n )}\n </>\n )}\n </span>\n );\n };\n\n const words = search.trim().toLowerCase();\n const group = (kind: PillKind) => state.fields.filter((p) => p.kind === kind && (!words || p.label.toLowerCase().includes(words) || p.id.includes(words)));\n const chart = useMemo(() => exploreChart(state), [state]);\n const reading = exploreReading(state);\n\n const suggest = () => {\n const found = suggestDerived(state.fields);\n if (found.length === 0) return setNote(\"Nothing more to suggest from these columns. Make a calculation of your own with “New calculation”.\");\n set({ ...state, fields: [...state.fields, ...found] });\n say(\"fields.suggested\", `${found.length} ${found.length === 1 ? \"calculation\" : \"calculations\"} suggested from the column names: ${found.map((p) => p.label).join(\", \")}. They are guesses to keep, edit or remove.`, { fields: found });\n };\n\n return (\n <div className={[\"sf-explore\", props.className].filter(Boolean).join(\" \")}>\n {model?.dataset && <ModelLineage model={model} compact />}\n {/* The layout is on this inner frame: `.sf-explore` is the container whose width it answers to, and a box cannot answer its own size query. */}\n <div className=\"sf-explore-frame\">\n <aside className=\"sf-explore-fields\" aria-label=\"Fields\">\n <input className=\"sf-input\" type=\"search\" placeholder=\"Find a field\" aria-label=\"Find a field\" value={search} onChange={(e) => setSearch(e.target.value)} />\n {([\"attribute\", \"metric\"] as PillKind[]).map((kind) => (\n <section key={kind} aria-label={kind === \"attribute\" ? \"Attributes\" : \"Metrics\"}>\n <h4 className=\"sf-explore-heading\">\n {kind === \"attribute\" ? \"Attributes\" : kind === \"metric\" ? \"Metrics\" : \"Calculations\"}\n <button type=\"button\" className=\"sf-explore-add\" aria-label={`New ${KIND_WORD[kind]}`} onClick={() => setEditing({ pill: blank(kind), isNew: true })}>\n <ControlIcon icon=\"add\" />\n </button>\n </h4>\n <div className=\"sf-explore-pills\">\n {group(kind).map((p) => drawPill(p))}\n {group(kind).length === 0 && <p className=\"sf-explore-hint\">{words ? \"None match.\" : \"None.\"}</p>}\n </div>\n </section>\n ))}\n {/* Calculations are for later: folded unless there were some to begin with, or a search finds one. */}\n <details className=\"sf-explore-more\" open={calculationsOpen || (!!words && group(\"derived\").length > 0)} onToggle={(e) => setCalculationsOpen(e.currentTarget.open)}>\n <summary>\n Calculations\n {state.fields.some((p) => p.kind === \"derived\") && <span className=\"sf-explore-count\">{state.fields.filter((p) => p.kind === \"derived\").length}</span>}\n </summary>\n <section aria-label=\"Calculations\">\n <h4 className=\"sf-explore-heading\">\n Calculations\n <button type=\"button\" className=\"sf-explore-add\" aria-label={`New ${KIND_WORD.derived}`} onClick={() => setEditing({ pill: blank(\"derived\"), isNew: true })}>\n <ControlIcon icon=\"add\" />\n </button>\n </h4>\n <div className=\"sf-explore-pills\">\n {group(\"derived\").map((p) => drawPill(p))}\n {group(\"derived\").length === 0 && <p className=\"sf-explore-hint\">{words ? \"None match.\" : \"None yet. A calculation is arithmetic over metrics: a rate, a margin, an average.\"}</p>}\n </div>\n </section>\n <button type=\"button\" className=\"sf-button\" onClick={suggest}>\n Suggest calculations\n </button>\n </details>\n {editing && (\n <PillEditor\n key={`${editing.pill.id}-${editing.isNew}`}\n pill={editing.pill}\n all={state.fields}\n columns={columns}\n isNew={editing.isNew}\n modelLabel={editing.pill.model ? model?.label || editing.pill.model : undefined}\n onPromote={!editing.isNew && offer(editing.pill) ? () => (void promote(editing.pill), setEditing(undefined)) : undefined}\n onCancel={() => setEditing(undefined)}\n onSave={(next) => {\n // Changed by hand, it is no longer the model's definition until it is added again.\n const changed = { ...next, by: editor, model: undefined };\n set(setPill(state, editing.isNew ? changed.id : editing.pill.id, changed));\n say(editing.isNew ? \"field.added\" : \"field.changed\", `${changed.label} ${editing.isNew ? \"added\" : \"saved\"}.`, { field: changed, ...(editing.isNew ? {} : { was: editing.pill }) });\n setEditing(undefined);\n }}\n onRemove={\n editing.isNew\n ? undefined\n : () => {\n set(setPill(state, editing.pill.id, undefined));\n say(\"field.removed\", `${editing.pill.label} removed.`, { field: editing.pill });\n setEditing(undefined);\n }\n }\n />\n )}\n </aside>\n\n <div className=\"sf-explore-main\">\n {onAsk && (\n <form\n className=\"sf-explore-ask\"\n onSubmit={(event) => {\n event.preventDefault();\n if (!ask.trim()) return;\n onAsk(ask.trim(), state);\n say(\"asked\", `Asked: “${ask.trim()}”.`, { text: ask.trim() });\n setAsk(\"\");\n }}\n >\n <input className=\"sf-input\" aria-label=\"Ask for a field or a view\" placeholder=\"Ask for a field or a view: refund rate by region, split by channel\" value={ask} onChange={(e) => setAsk(e.target.value)} />\n <button type=\"submit\" className=\"sf-button\" disabled={!ask.trim()}>\n Ask\n </button>\n </form>\n )}\n <div className=\"sf-explore-shelves\">\n {SHELVES.map((shelf) => {\n const ids = shelf.id === \"split\" ? (state.split ? [state.split] : []) : state[shelf.id];\n return (\n <div key={shelf.id} className=\"sf-explore-shelf\" data-shelf={shelf.id} data-over={ghost?.over === shelf.id || undefined} data-accepts={ghost ? shelf.takes.includes(ghost.kind) : undefined} role=\"group\" aria-label={shelf.label}>\n <span className=\"sf-explore-shelf-name\" title={shelf.hint}>\n {shelf.label}\n </span>\n {chart && shown === \"chart\" && (shelf.id !== \"split\" || state.values.length === 1) && (\n <span className=\"sf-explore-axis\" data-axis={shelf.id === \"split\" ? \"colour\" : axisOf[shelf.id] === \"X axis\" ? \"x\" : \"y\"} title={shelf.id === \"values\" && twoScales ? \"Each measure's pill says which side's scale it is read against.\" : undefined}>\n {axisOf[shelf.id]}\n </span>\n )}\n {ids.map((id) => pill(id)).filter((p): p is Pill => !!p).map((p) => drawPill(p, shelf.id))}\n {ids.length === 0 && <span className=\"sf-explore-hint\">{ghost ? (shelf.takes.includes(ghost.kind) ? \"Drop here\" : \"Not for this field\") : shelf.id === \"values\" ? \"Press a metric\" : shelf.id === \"rows\" ? \"Press an attribute\" : \"Optional\"}</span>}\n </div>\n );\n })}\n </div>\n {chart && (\n <div className=\"sf-explore-chart-settings\">\n <div className=\"sf-segmented sf-result-views\" role=\"group\" aria-label=\"Draw as\">\n {([\"bar\", \"line\", \"area\"] as ExploreChartType[]).map((type) => {\n const on = shown === \"chart\" && chartTypeNow === type;\n return (\n <button key={type} type=\"button\" className=\"sf-segment\" data-checked={on || undefined} aria-pressed={on} onClick={() => setType(type)}>\n {type === \"bar\" ? \"Bars\" : type === \"line\" ? \"Line\" : \"Area\"}\n </button>\n );\n })}\n <button type=\"button\" className=\"sf-segment\" data-checked={shown === \"table\" || undefined} aria-pressed={shown === \"table\"} onClick={showTable}>\n Table\n </button>\n </div>\n {shown === \"chart\" && (\n <>\n <button type=\"button\" className=\"sf-button\" aria-pressed={swapped} aria-disabled={!!cannotSwap || undefined} title={cannotSwap} aria-describedby={cannotSwap ? `${uid}-swap` : undefined} onClick={() => !cannotSwap && swap()}>\n Swap axes\n </button>\n {cannotSwap && (\n <span id={`${uid}-swap`} className=\"sf-explore-hint\">\n {cannotSwap}\n </span>\n )}\n {state.values.length > 1 && (\n <ul className=\"sf-explore-measures\" aria-label=\"Each measure\">\n {state.values.map((id) => pill(id)).filter((p): p is Pill => !!p).map((p) => (\n <li key={p.id}>\n <span className=\"sf-explore-measure-name\">{p.label}</span>\n <select className=\"sf-input\" aria-label={`Draw ${p.label} as`} value={styleOf(p.id).type ?? chartTypeNow} onChange={(e) => restyle(p, { type: e.target.value as ExploreChartType })}>\n <option value=\"bar\">Bars</option>\n <option value=\"line\">Line</option>\n <option value=\"area\">Area</option>\n </select>\n <select className=\"sf-input\" aria-label={`Scale for ${p.label}`} value={styleOf(p.id).axis ?? \"left\"} onChange={(e) => restyle(p, { axis: e.target.value as \"left\" | \"right\" })}>\n <option value=\"left\">Left scale</option>\n <option value=\"right\">Right scale</option>\n </select>\n </li>\n ))}\n </ul>\n )}\n </>\n )}\n </div>\n )}\n {/* Filters fold away until there are some. */}\n <details className=\"sf-explore-more\" open={filtersOpen} onToggle={(e) => setFiltersOpen(e.currentTarget.open)}>\n <summary>\n Filters\n {state.filters.length > 0 && <span className=\"sf-explore-count\">{state.filters.length}</span>}\n </summary>\n <QueryFilters sourceId={sourceId} sql={sql} filters={state.filters} onChange={(next: FilterSpec[]) => set({ ...state, filters: next })} onContext={props.onContext} dataSource={dataSource} />\n </details>\n\n {problem && (\n <p className=\"sf-filter-problem\" role=\"alert\">\n {problem}\n </p>\n )}\n {state.values.length === 0 ? (\n <p className=\"sf-explore-empty\">Press a metric to measure it, then an attribute to break it down. Each press, drag or edit asks the database again; nothing is worked out in this page.</p>\n ) : (\n // The view's own controls sit over its corner and show on hover or focus, like a tile's.\n <div className=\"sf-explore-result sf-controls-host\" data-controls=\"corner\">\n {props.controls?.length ? <ItemControls label={`${reading || \"View\"} controls`} controls={props.controls} /> : null}\n <p className=\"sf-explore-reading\">{reading}</p>\n {!chart && <p className=\"sf-explore-hint\">With nothing to break down by there is one number each. Press an attribute for a chart.</p>}\n <ExploreView dataSource={dataSource} sourceId={sourceId} sql={sql} state={state} view={shown} height={chartHeight} label={reading} />\n {props.actions && <div className=\"sf-explore-actions\">{props.actions}</div>}\n </div>\n )}\n <p className=\"sf-explore-note\" role=\"status\">\n {note}\n </p>\n </div>\n </div>\n {ghost && (\n <span className=\"sf-pill sf-pill-ghost\" data-kind={ghost.kind} aria-hidden=\"true\" style={{ left: ghost.x, top: ghost.y }}>\n <span className=\"sf-pill-glyph\">{GLYPH[ghost.kind]}</span>\n {ghost.label}\n </span>\n )}\n {menu.element}\n </div>\n );\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { type DatasetStanding, type Pipelines } from "@surfaces-ui/data";
2
+ import type { SemanticModel } from "@surfaces-ui/proto";
3
+ export interface ModelLineageProps {
4
+ /** A model whose rows are a pipeline's dataset (`model.dataset`). Anything else draws nothing. */
5
+ model: Pick<SemanticModel, "sourceId" | "sql" | "grain" | "primaryKey" | "dataset">;
6
+ /** Left out, the one from `PipelinesProvider`. Without either, only the dataset's name is shown. */
7
+ pipelines?: Pipelines;
8
+ /** One line, for above an explorer or a report; the full panel otherwise. */
9
+ compact?: boolean;
10
+ /** Offered when the model's grain or key differs from the dataset's: puts the dataset's in the draft. */
11
+ onUseDataset?(standing: DatasetStanding): void;
12
+ /** Opens the dataset in the pipeline view, when the host has one. */
13
+ onOpenDataset?(pipelineId: string, dataset: string): void;
14
+ }
15
+ /**
16
+ * Where a model's rows come from when they are a pipeline's dataset: which
17
+ * pipeline and dataset, when it was last built, how the latest run's checks
18
+ * went (failing ones first, as counts), whether the key the model relies on
19
+ * was checked, and what the dataset reads. Display only: it reads the
20
+ * pipeline's definition and latest run, and runs nothing.
21
+ */
22
+ export declare function ModelLineage(props: ModelLineageProps): import("react").JSX.Element | null;
@@ -0,0 +1,70 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { datasetStanding, semanticDatasetProblems, thePipeline } from "@surfaces-ui/data";
3
+ import { useEffect, useId, useState } from "react";
4
+ import { messageOf } from "../data/useRowWindow.js";
5
+ import { dateFormat } from "../locale/locale.js";
6
+ import { useOptionalPipelines } from "../pipeline/PipelineView.js";
7
+ /** The pipeline and its latest run, read once per model; nothing is queried. */
8
+ function useStanding(model, pipelines) {
9
+ const ref = model.dataset;
10
+ const [state, setState] = useState({});
11
+ useEffect(() => {
12
+ if (!ref?.pipelineId || !pipelines)
13
+ return setState({});
14
+ const controller = new AbortController();
15
+ const options = { signal: controller.signal };
16
+ (async () => {
17
+ let pipeline;
18
+ try {
19
+ pipeline = (await pipelines.getPipeline({ id: ref.pipelineId }, options)).pipeline;
20
+ }
21
+ catch {
22
+ return !controller.signal.aborted && setState({ gone: true });
23
+ }
24
+ if (!pipeline)
25
+ return setState({ gone: true });
26
+ const dataset = pipeline.datasets.find((d) => d.name === ref.dataset);
27
+ const runId = dataset?.lastRunId || pipeline.summary?.latestRun?.id;
28
+ const run = runId ? (await pipelines.getRun({ pipelineId: ref.pipelineId, runId }, options).catch(() => undefined))?.run : undefined;
29
+ if (!controller.signal.aborted)
30
+ setState({ pipeline, standing: datasetStanding(pipeline, ref.dataset, run) });
31
+ })().catch((error) => !controller.signal.aborted && setState({ problem: messageOf(error) }));
32
+ return () => controller.abort();
33
+ }, [pipelines, ref?.pipelineId, ref?.dataset]);
34
+ return state;
35
+ }
36
+ const when = (iso) => {
37
+ const date = new Date(iso);
38
+ return Number.isNaN(date.getTime()) ? iso : dateFormat({ dateStyle: "medium", timeStyle: "short" }).format(date);
39
+ };
40
+ /**
41
+ * Where a model's rows come from when they are a pipeline's dataset: which
42
+ * pipeline and dataset, when it was last built, how the latest run's checks
43
+ * went (failing ones first, as counts), whether the key the model relies on
44
+ * was checked, and what the dataset reads. Display only: it reads the
45
+ * pipeline's definition and latest run, and runs nothing.
46
+ */
47
+ export function ModelLineage(props) {
48
+ const { model, compact } = props;
49
+ const pipelines = useOptionalPipelines(props.pipelines);
50
+ const { pipeline, standing, problem, gone } = useStanding(model, pipelines);
51
+ const id = useId();
52
+ const ref = model.dataset;
53
+ if (!ref?.pipelineId)
54
+ return null;
55
+ const name = standing?.pipelineName || ref.pipelineId;
56
+ const problems = pipelines && (pipeline || gone) ? semanticDatasetProblems(model, pipeline) : [];
57
+ const tone = gone || problems.length > 0 || standing?.state === "failed" || (standing?.failing ?? 0) > 0 ? "warn" : standing && !standing.built ? "warn" : "ok";
58
+ const open = props.onOpenDataset && (_jsx("button", { type: "button", className: "sf-button", onClick: () => props.onOpenDataset?.(ref.pipelineId, ref.dataset), children: "Open in the pipeline" }));
59
+ if (compact) {
60
+ return (_jsxs("p", { className: "sf-lineage", "data-compact": true, "data-tone": tone, role: "note", children: [_jsx("span", { className: "sf-lineage-mark", "aria-hidden": "true", children: tone === "ok" ? "✓" : "!" }), _jsxs("span", { children: ["Rows from ", _jsx("strong", { children: ref.dataset }), ", built by ", thePipeline(name), standing?.builtAt ? ` · ${when(standing.builtAt)}` : standing && !standing.built ? " · not built yet" : "", standing &&
61
+ standing.checks.length > 0 &&
62
+ (standing.failing > 0
63
+ ? ` · ${standing.failing} of ${standing.checks.length} checks failing`
64
+ : standing.warnings > 0
65
+ ? ` · ${standing.warnings} ${standing.warnings === 1 ? "warning" : "warnings"}, no check failing`
66
+ : ` · checks passed`), gone && " · the pipeline is not there any more", problems.length > 0 && !gone && ` · ${problems.length === 1 ? "differs" : `${problems.length} differences`} from the dataset`] }), open] }));
67
+ }
68
+ return (_jsxs("section", { className: "sf-lineage", "data-tone": tone, "aria-labelledby": `${id}-title`, children: [_jsx("h4", { id: `${id}-title`, className: "sf-explore-heading", children: "From a pipeline" }), _jsxs("p", { children: ["The rows are the dataset ", _jsx("strong", { children: ref.dataset }), ", which ", thePipeline(name), " builds on ", model.sourceId, ". Its grain and key are checked after every build."] }), !pipelines && _jsx("p", { className: "sf-explore-hint", children: "How it was last built is shown where the pipelines can be read." }), problem && _jsxs("p", { className: "sf-filter-problem", children: ["The pipeline could not be read: ", problem] }), standing && (_jsxs("dl", { className: "sf-lineage-facts", children: [_jsx("dt", { children: "Last built" }), _jsx("dd", { children: standing.builtAt ? when(standing.builtAt) : "Not built yet: the query has no table to read until the pipeline runs." }), standing.state === "failed" || standing.state === "running" || standing.state === "skipped" ? (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Latest run" }), _jsx("dd", { children: standing.state === "failed" ? "Failed. The table holds what the last good build left." : standing.state === "running" ? "Under way." : "Skipped, because something it reads failed." })] })) : null, _jsx("dt", { children: "Grain" }), _jsx("dd", { children: standing.grain || "Not declared." }), _jsx("dt", { children: "Key" }), _jsx("dd", { children: standing.primaryKey.length ? `${standing.primaryKey.join(", ")} · ${standing.keyChecked ? "checked unique and not empty by the latest run" : "not checked by the latest run"}` : "Not declared." }), _jsx("dt", { children: "Reads" }), _jsx("dd", { children: standing.inputs.length ? `${standing.inputs.join(", ")}${standing.inputsDeclared ? "" : " (worked out from its query)"}` : "Nothing named." }), standing.owner && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Owner" }), _jsx("dd", { children: standing.owner })] }))] })), standing && standing.checks.length > 0 && (_jsx("ul", { className: "sf-lineage-checks", "aria-label": "Checks from the latest run", children: standing.checks.map((check) => (_jsxs("li", { "data-failing": check.failedRecords > 0 || undefined, children: [_jsx("span", { "aria-hidden": "true", children: check.failedRecords > 0 ? (check.severity === "warn" ? "!" : "✕") : "✓" }), " ", _jsx("code", { children: check.name }), " ", check.failedRecords > 0 ? `${check.severity === "warn" ? "warns" : "fails"}: ${check.summary}` : "passed"] }, check.name))) })), gone && _jsxs("p", { className: "sf-filter-problem", children: [thePipeline(ref.pipelineId).replace(/^t/, "T"), " is not there any more."] }), problems.length > 0 && !gone && (_jsxs("div", { className: "sf-filter-problem", role: "alert", children: [problems.map((p) => (_jsx("p", { children: p }, p))), props.onUseDataset && standing && (_jsx("button", { type: "button", className: "sf-button", onClick: () => props.onUseDataset?.(standing), children: "Use the dataset's grain and key" }))] })), open] }));
69
+ }
70
+ //# sourceMappingURL=ModelLineage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelLineage.js","sourceRoot":"","sources":["../../src/explore/ModelLineage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAwC,eAAe,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhI,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAenE,gFAAgF;AAChF,SAAS,WAAW,CAAC,KAAiC,EAAE,SAAgC;IACtF,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAwF,EAAE,CAAC,CAAC;IAC9H,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,EAAE,UAAU,IAAI,CAAC,SAAS;YAAE,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;QAC9C,CAAC,KAAK,IAAI,EAAE;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C,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAQ,OAAC,yBAAO,KAAK,CAAC,IAAI,GAAQ,EAAC,GAAG,EACtI,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,KAFnG,KAAK,CAAC,IAAI,CAGd,CACN,CAAC,GACC,CACN,EACA,IAAI,IAAI,aAAG,SAAS,EAAC,mBAAmB,aAAE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,+BAA4B,EACpH,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAC/B,eAAK,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,OAAO,aAC5C,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACnB,sBAAY,CAAC,IAAL,CAAC,CAAS,CACnB,CAAC,EACD,KAAK,CAAC,YAAY,IAAI,QAAQ,IAAI,CACjC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,WAAW,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,gDAEhF,CACV,IACG,CACP,EACA,IAAI,IACG,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { type DatasetStanding, type Pipelines, datasetStanding, semanticDatasetProblems, thePipeline } from \"@surfaces-ui/data\";\nimport type { Pipeline, SemanticModel } from \"@surfaces-ui/proto\";\nimport { useEffect, useId, useState } from \"react\";\nimport { messageOf } from \"../data/useRowWindow.js\";\nimport { dateFormat } from \"../locale/locale.js\";\nimport { useOptionalPipelines } from \"../pipeline/PipelineView.js\";\n\nexport interface ModelLineageProps {\n /** A model whose rows are a pipeline's dataset (`model.dataset`). Anything else draws nothing. */\n model: Pick<SemanticModel, \"sourceId\" | \"sql\" | \"grain\" | \"primaryKey\" | \"dataset\">;\n /** Left out, the one from `PipelinesProvider`. Without either, only the dataset's name is shown. */\n pipelines?: Pipelines;\n /** One line, for above an explorer or a report; the full panel otherwise. */\n compact?: boolean;\n /** Offered when the model's grain or key differs from the dataset's: puts the dataset's in the draft. */\n onUseDataset?(standing: DatasetStanding): void;\n /** Opens the dataset in the pipeline view, when the host has one. */\n onOpenDataset?(pipelineId: string, dataset: string): void;\n}\n\n/** The pipeline and its latest run, read once per model; nothing is queried. */\nfunction useStanding(model: ModelLineageProps[\"model\"], pipelines: Pipelines | undefined) {\n const ref = model.dataset;\n const [state, setState] = useState<{ pipeline?: Pipeline; standing?: DatasetStanding; problem?: string; gone?: boolean }>({});\n useEffect(() => {\n if (!ref?.pipelineId || !pipelines) return setState({});\n const controller = new AbortController();\n const options = { signal: controller.signal };\n (async () => {\n let pipeline: Pipeline | undefined;\n try {\n pipeline = (await pipelines.getPipeline({ id: ref.pipelineId }, options)).pipeline;\n } catch {\n return !controller.signal.aborted && setState({ gone: true });\n }\n if (!pipeline) return setState({ gone: true });\n const dataset = pipeline.datasets.find((d) => d.name === ref.dataset);\n const runId = dataset?.lastRunId || pipeline.summary?.latestRun?.id;\n const run = runId ? (await pipelines.getRun({ pipelineId: ref.pipelineId, runId }, options).catch(() => undefined))?.run : undefined;\n if (!controller.signal.aborted) setState({ pipeline, standing: datasetStanding(pipeline, ref.dataset, run) });\n })().catch((error: unknown) => !controller.signal.aborted && setState({ problem: messageOf(error) }));\n return () => controller.abort();\n }, [pipelines, ref?.pipelineId, ref?.dataset]);\n return state;\n}\n\nconst when = (iso: string) => {\n const date = new Date(iso);\n return Number.isNaN(date.getTime()) ? iso : dateFormat({ dateStyle: \"medium\", timeStyle: \"short\" }).format(date);\n};\n\n/**\n * Where a model's rows come from when they are a pipeline's dataset: which\n * pipeline and dataset, when it was last built, how the latest run's checks\n * went (failing ones first, as counts), whether the key the model relies on\n * was checked, and what the dataset reads. Display only: it reads the\n * pipeline's definition and latest run, and runs nothing.\n */\nexport function ModelLineage(props: ModelLineageProps) {\n const { model, compact } = props;\n const pipelines = useOptionalPipelines(props.pipelines);\n const { pipeline, standing, problem, gone } = useStanding(model, pipelines);\n const id = useId();\n const ref = model.dataset;\n if (!ref?.pipelineId) return null;\n\n const name = standing?.pipelineName || ref.pipelineId;\n const problems = pipelines && (pipeline || gone) ? semanticDatasetProblems(model, pipeline) : [];\n const tone = gone || problems.length > 0 || standing?.state === \"failed\" || (standing?.failing ?? 0) > 0 ? \"warn\" : standing && !standing.built ? \"warn\" : \"ok\";\n const open = props.onOpenDataset && (\n <button type=\"button\" className=\"sf-button\" onClick={() => props.onOpenDataset?.(ref.pipelineId, ref.dataset)}>\n Open in the pipeline\n </button>\n );\n\n if (compact) {\n return (\n <p className=\"sf-lineage\" data-compact data-tone={tone} role=\"note\">\n <span className=\"sf-lineage-mark\" aria-hidden=\"true\">\n {tone === \"ok\" ? \"✓\" : \"!\"}\n </span>\n <span>\n Rows from <strong>{ref.dataset}</strong>, built by {thePipeline(name)}\n {standing?.builtAt ? ` · ${when(standing.builtAt)}` : standing && !standing.built ? \" · not built yet\" : \"\"}\n {standing &&\n standing.checks.length > 0 &&\n (standing.failing > 0\n ? ` · ${standing.failing} of ${standing.checks.length} checks failing`\n : standing.warnings > 0\n ? ` · ${standing.warnings} ${standing.warnings === 1 ? \"warning\" : \"warnings\"}, no check failing`\n : ` · checks passed`)}\n {gone && \" · the pipeline is not there any more\"}\n {problems.length > 0 && !gone && ` · ${problems.length === 1 ? \"differs\" : `${problems.length} differences`} from the dataset`}\n </span>\n {open}\n </p>\n );\n }\n\n return (\n <section className=\"sf-lineage\" data-tone={tone} aria-labelledby={`${id}-title`}>\n <h4 id={`${id}-title`} className=\"sf-explore-heading\">\n From a pipeline\n </h4>\n <p>\n The rows are the dataset <strong>{ref.dataset}</strong>, which {thePipeline(name)} builds on {model.sourceId}. Its grain and key are checked after every build.\n </p>\n {!pipelines && <p className=\"sf-explore-hint\">How it was last built is shown where the pipelines can be read.</p>}\n {problem && <p className=\"sf-filter-problem\">The pipeline could not be read: {problem}</p>}\n {standing && (\n <dl className=\"sf-lineage-facts\">\n <dt>Last built</dt>\n <dd>{standing.builtAt ? when(standing.builtAt) : \"Not built yet: the query has no table to read until the pipeline runs.\"}</dd>\n {standing.state === \"failed\" || standing.state === \"running\" || standing.state === \"skipped\" ? (\n <>\n <dt>Latest run</dt>\n <dd>{standing.state === \"failed\" ? \"Failed. The table holds what the last good build left.\" : standing.state === \"running\" ? \"Under way.\" : \"Skipped, because something it reads failed.\"}</dd>\n </>\n ) : null}\n <dt>Grain</dt>\n <dd>{standing.grain || \"Not declared.\"}</dd>\n <dt>Key</dt>\n <dd>{standing.primaryKey.length ? `${standing.primaryKey.join(\", \")} · ${standing.keyChecked ? \"checked unique and not empty by the latest run\" : \"not checked by the latest run\"}` : \"Not declared.\"}</dd>\n <dt>Reads</dt>\n <dd>{standing.inputs.length ? `${standing.inputs.join(\", \")}${standing.inputsDeclared ? \"\" : \" (worked out from its query)\"}` : \"Nothing named.\"}</dd>\n {standing.owner && (\n <>\n <dt>Owner</dt>\n <dd>{standing.owner}</dd>\n </>\n )}\n </dl>\n )}\n {standing && standing.checks.length > 0 && (\n <ul className=\"sf-lineage-checks\" aria-label=\"Checks from the latest run\">\n {standing.checks.map((check) => (\n <li key={check.name} data-failing={check.failedRecords > 0 || undefined}>\n <span aria-hidden=\"true\">{check.failedRecords > 0 ? (check.severity === \"warn\" ? \"!\" : \"✕\") : \"✓\"}</span> <code>{check.name}</code>{\" \"}\n {check.failedRecords > 0 ? `${check.severity === \"warn\" ? \"warns\" : \"fails\"}: ${check.summary}` : \"passed\"}\n </li>\n ))}\n </ul>\n )}\n {gone && <p className=\"sf-filter-problem\">{thePipeline(ref.pipelineId).replace(/^t/, \"T\")} is not there any more.</p>}\n {problems.length > 0 && !gone && (\n <div className=\"sf-filter-problem\" role=\"alert\">\n {problems.map((p) => (\n <p key={p}>{p}</p>\n ))}\n {props.onUseDataset && standing && (\n <button type=\"button\" className=\"sf-button\" onClick={() => props.onUseDataset?.(standing)}>\n Use the dataset's grain and key\n </button>\n )}\n </div>\n )}\n {open}\n </section>\n );\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import type { DataSource } from "@surfaces-ui/data";
2
+ import type { SemanticModel } from "@surfaces-ui/proto";
3
+ import type { OnContext } from "../controls/context.js";
4
+ import type { Pill } from "./model.js";
5
+ import { type ReportState } from "./report.js";
6
+ export interface ReportBuilderProps {
7
+ /** Where the query runs. Left out, the model's source. */
8
+ sourceId?: string;
9
+ /** The query the report is over: a table, or a join wide enough for every view. Left out, the model's query. */
10
+ sql?: string;
11
+ /** The semantic model the report's fields come from: its metrics mean the same in this report as in every other on it. */
12
+ model?: SemanticModel;
13
+ /** Offers "Add to the model" on a field that is not the model's own. See `Explorer`. */
14
+ onPromote?(pill: Pill, all: Pill[]): Promise<string | void> | string | void;
15
+ /** The report, when the host holds it. With no fields, pills are generated from the query's columns. */
16
+ value?: ReportState;
17
+ defaultValue?: ReportState;
18
+ onChange?(report: ReportState): void;
19
+ /** "build" shows the pills and shelves above the report; "view" shows the report alone, with its filters. A person can switch unless the host sets it. */
20
+ mode?: "build" | "view";
21
+ onModeChange?(mode: "build" | "view"): void;
22
+ /** Shows a box to ask for a field, a view or a whole report in words. The host passes the words to its agent, which answers by setting `value`. */
23
+ onAsk?(text: string, report: ReportState): void;
24
+ /** Name recorded on pills a person makes or edits. Defaults to "you". */
25
+ editor?: string;
26
+ /** Told what a person does to the report as they do it (a view added, changed, moved or removed, a filter set, a bar clicked, a mode switched), for an agent's context. */
27
+ onContext?: OnContext;
28
+ dataSource?: DataSource;
29
+ className?: string;
30
+ }
31
+ /**
32
+ * Building a report from pills. The pills are the report's own: defined
33
+ * once, used by every view, so a metric means the same thing in each tile.
34
+ * A person (or an agent) puts pills on the shelves to make a view, keeps it
35
+ * as a tile, and makes the next from where they are. Every tile follows one
36
+ * set of filters, and a click on a bar filters the whole report. Switched
37
+ * to "view" it is the dashboard alone. The whole report is plain data.
38
+ */
39
+ export declare function ReportBuilder(props: ReportBuilderProps): import("react").JSX.Element;
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useState } from "react";
3
+ import { label as text } from "../locale/locale.js";
4
+ import { ItemControls, standardControls } from "../controls/ItemControls.js";
5
+ import { SegmentedControl } from "../controls/SegmentedControl.js";
6
+ import { chosenValues, toggleValueFilter } from "@surfaces-ui/data";
7
+ import { useDataSource } from "../data/DataSourceProvider.js";
8
+ import { QueryFilters } from "../filter/QueryFilters.js";
9
+ import { ExploreView, Explorer, exploreReading } from "./Explorer.js";
10
+ import { ModelLineage } from "./ModelLineage.js";
11
+ import { MAX_TILES, draftState, editTile, emptyReport, keepDraft, moveTile, normalizeReport, removeTile, setTile, tileState, withDraft } from "./report.js";
12
+ /**
13
+ * Building a report from pills. The pills are the report's own: defined
14
+ * once, used by every view, so a metric means the same thing in each tile.
15
+ * A person (or an agent) puts pills on the shelves to make a view, keeps it
16
+ * as a tile, and makes the next from where they are. Every tile follows one
17
+ * set of filters, and a click on a bar filters the whole report. Switched
18
+ * to "view" it is the dashboard alone. The whole report is plain data.
19
+ */
20
+ export function ReportBuilder(props) {
21
+ const { onChange, onAsk, editor, model } = props;
22
+ const sourceId = props.sourceId ?? model?.sourceId ?? "";
23
+ const sql = props.sql ?? model?.sql ?? "";
24
+ const dataSource = useDataSource(props.dataSource);
25
+ const [own, setOwn] = useState(props.defaultValue ?? emptyReport);
26
+ const report = useMemo(() => normalizeReport(props.value ?? own), [props.value, own]);
27
+ const set = useCallback((next) => {
28
+ const clean = normalizeReport(next);
29
+ setOwn(clean);
30
+ onChange?.(clean);
31
+ }, [onChange]);
32
+ const [ownMode, setOwnMode] = useState("build");
33
+ const mode = props.mode ?? ownMode;
34
+ const setMode = (next) => {
35
+ setOwnMode(next);
36
+ props.onModeChange?.(next);
37
+ props.onContext?.({ kind: "mode.changed", summary: next === "view" ? "Switched to viewing the report." : "Switched to building the report.", subject: { mode: next } });
38
+ };
39
+ const [note, setNote] = useState("");
40
+ /** Says what happened to the person, and tells the host the same as context for an agent. */
41
+ const say = (kind, summary, subject) => {
42
+ setNote(summary);
43
+ props.onContext?.({ kind, summary, ...(subject ? { subject } : {}) });
44
+ };
45
+ const shelves = (tile) => ({ rows: tile.rows, split: tile.split ?? null, values: tile.values, view: tile.view ?? "chart" });
46
+ const draft = useMemo(() => draftState(report), [report]);
47
+ const editing = report.tiles.find((t) => t.id === report.editing);
48
+ const full = !editing && report.tiles.length >= MAX_TILES;
49
+ const titleOf = (tile) => tile.title || exploreReading(tileState(report, tile)) || text("report.untitled");
50
+ const keep = () => {
51
+ const next = keepDraft(report);
52
+ if (next === report)
53
+ return setNote(full ? text("report.maxViews", { max: MAX_TILES }) : text("report.needMeasure"));
54
+ set(next);
55
+ const kept = editing ? next.tiles.find((t) => t.id === editing.id) : next.tiles.at(-1);
56
+ say(editing ? "view.changed" : "view.added", editing ? `${titleOf(editing)} updated: it now shows ${exploreReading(normalizeTile(report))}.` : `Added to the report: ${exploreReading(normalizeTile(report)) || "a view"}. The shelves are as you left them, for the next one.`, kept ? { tile: kept.id, ...shelves(kept) } : undefined);
57
+ };
58
+ const tiles = (_jsx("div", { className: "sf-report-tiles", "data-mode": mode, children: report.tiles.map((tile, index) => {
59
+ const state = tileState(report, tile);
60
+ const title = titleOf(tile);
61
+ return (_jsxs("section", { className: "sf-report-tile sf-controls-host", "data-controls": "corner", "data-span": tile.span ?? 1, "data-editing": report.editing === tile.id || undefined, "aria-label": title, children: [_jsxs("header", { className: "sf-report-tile-head", children: [mode === "build" ? (_jsx("input", { className: "sf-report-tile-title", "aria-label": text("report.tileTitle", { title }), value: tile.title ?? "", placeholder: exploreReading(state), onChange: (e) => set(setTile(report, tile.id, { title: e.target.value || undefined })) })) : (_jsx("h4", { className: "sf-report-tile-title", children: title })), mode === "build" && (_jsx(ItemControls, { label: text("report.tileControls", { title }), controls: standardControls(title, {
62
+ edit: () => (set(editTile(report, tile.id)), say("view.opened", `${title} is on the shelves. Change it, then press “Update view”.`, { tile: tile.id, ...shelves(tile) })),
63
+ ...(state.rows.length > 0 ? { view: { now: tile.view ?? "chart", toggle: () => (set(setTile(report, tile.id, { view: (tile.view ?? "chart") === "chart" ? "table" : "chart" })), say("view.changed", `${title} is shown as a ${(tile.view ?? "chart") === "chart" ? "table" : "chart"}.`, { tile: tile.id, view: (tile.view ?? "chart") === "chart" ? "table" : "chart" })) } } : {}),
64
+ wider: (tile.span ?? 1) < 3 ? () => (set(setTile(report, tile.id, { span: ((tile.span ?? 1) + 1) })), say("view.resized", `${title} made wider.`, { tile: tile.id, span: (tile.span ?? 1) + 1 })) : false,
65
+ narrower: (tile.span ?? 1) > 1 ? () => (set(setTile(report, tile.id, { span: ((tile.span ?? 1) - 1) })), say("view.resized", `${title} made narrower.`, { tile: tile.id, span: (tile.span ?? 1) - 1 })) : false,
66
+ earlier: index > 0 ? () => (set(moveTile(report, tile.id, -1)), say("view.moved", `${title} moved earlier.`, { tile: tile.id, order: moveTile(report, tile.id, -1).tiles.map((t) => t.id) })) : false,
67
+ later: index < report.tiles.length - 1 ? () => (set(moveTile(report, tile.id, 1)), say("view.moved", `${title} moved later.`, { tile: tile.id, order: moveTile(report, tile.id, 1).tiles.map((t) => t.id) })) : false,
68
+ remove: () => (set(removeTile(report, tile.id)), say("view.removed", `${title} removed from the report.`, { tile: tile.id, ...shelves(tile) })),
69
+ }) }))] }), _jsx(ExploreView, { dataSource: dataSource, sourceId: sourceId, sql: sql, state: state, height: 240, label: title, onPointClick: (column, value) => {
70
+ const filters = toggleValueFilter(report.filters, column, value);
71
+ set({ ...report, filters });
72
+ const chosen = chosenValues(filters, column);
73
+ const on = chosen.some((v) => String(v) === String(value));
74
+ say("point.selected", on
75
+ ? `Clicked ${value} in “${title}”: the report is filtered to ${column} ${chosen.length === 1 ? "is" : "is one of"} ${chosen.join(", ")}. Click the bar again to take it out.`
76
+ : `Clicked ${value} in “${title}” again: ${value} is taken out of the filter on ${column}${chosen.length === 0 ? ", which is now cleared" : ""}.`, { tile: tile.id, column, value, filters });
77
+ } })] }, tile.id));
78
+ }) }));
79
+ return (_jsxs("div", { className: ["sf-report", props.className].filter(Boolean).join(" "), "data-mode": mode, children: [_jsxs("header", { className: "sf-report-head", children: [mode === "build" ? (_jsx("input", { className: "sf-report-title", "aria-label": text("report.title"), placeholder: text("report.untitledReport"), value: report.title ?? "", onChange: (e) => set({ ...report, title: e.target.value || undefined }) })) : (_jsx("h3", { className: "sf-report-title", children: report.title || text("report.untitledReport") })), _jsx(SegmentedControl, { label: text("report.mode"), value: mode, onChange: setMode, options: [
80
+ { value: "build", label: text("report.build") },
81
+ { value: "view", label: text("report.view") },
82
+ ] })] }), model?.dataset && _jsx(ModelLineage, { model: model, compact: true }), mode === "build" && (_jsxs("section", { className: "sf-report-builder", "aria-label": text("report.builder"), children: [editing && (_jsxs("p", { className: "sf-report-editing", role: "status", children: [text("report.changing", { title: titleOf(editing) }), " ", _jsx("button", { type: "button", className: "sf-button", onClick: () => (set({ ...report, editing: undefined }), setNote(text("report.leftAsItWas"))), children: text("report.leaveAsItWas") })] })), _jsx(Explorer, { dataSource: dataSource, sourceId: sourceId, sql: sql, model: model, onPromote: props.onPromote, value: draft, onChange: (state) => set(withDraft(report, state)), onAsk: onAsk ? (text) => onAsk(text, report) : undefined, editor: editor, onContext: props.onContext, chartHeight: 240, controls: [
83
+ {
84
+ id: "keep",
85
+ label: editing ? text("report.updateView") : text("report.addToReport"),
86
+ icon: editing ? "confirm" : "add",
87
+ onSelect: keep,
88
+ disabled: full,
89
+ // The one thing a person has to be able to find without pointing at the chart first.
90
+ pinned: true,
91
+ },
92
+ ] })] })), _jsxs("section", { className: "sf-report-body", "aria-label": text("report.body"), children: [mode === "view" && report.fields.length > 0 && _jsx(QueryFilters, { dataSource: dataSource, sourceId: sourceId, sql: sql, filters: report.filters, onChange: (filters) => set({ ...report, filters }), onContext: props.onContext }), report.tiles.length === 0 ? (_jsx("p", { className: "sf-explore-empty", children: mode === "build" ? text("report.emptyBuild") : text("report.emptyView") })) : (tiles)] }), _jsx("p", { className: "sf-explore-note", role: "status", children: note })] }));
93
+ }
94
+ /** The draft as it would be kept, for saying what was added. */
95
+ function normalizeTile(report) {
96
+ return tileState(report, report.draft ?? { rows: [], values: [] });
97
+ }
98
+ //# sourceMappingURL=ReportBuilder.js.map