@surfaces-ui/components 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +51 -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 +41 -0
  9. package/dist/chart/BulletGraph.js.map +1 -0
  10. package/dist/chart/Chart.d.ts +178 -0
  11. package/dist/chart/Chart.js +285 -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 +38 -0
  15. package/dist/chart/Sparkline.js.map +1 -0
  16. package/dist/chart/advice.d.ts +32 -0
  17. package/dist/chart/advice.js +48 -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/chart/wheel.d.ts +12 -0
  23. package/dist/chart/wheel.js +21 -0
  24. package/dist/chart/wheel.js.map +1 -0
  25. package/dist/controls/Combobox.d.ts +39 -0
  26. package/dist/controls/Combobox.js +75 -0
  27. package/dist/controls/Combobox.js.map +1 -0
  28. package/dist/controls/ConfirmDialog.d.ts +35 -0
  29. package/dist/controls/ConfirmDialog.js +84 -0
  30. package/dist/controls/ConfirmDialog.js.map +1 -0
  31. package/dist/controls/ItemControls.d.ts +115 -0
  32. package/dist/controls/ItemControls.js +109 -0
  33. package/dist/controls/ItemControls.js.map +1 -0
  34. package/dist/controls/Popover.d.ts +31 -0
  35. package/dist/controls/Popover.js +114 -0
  36. package/dist/controls/Popover.js.map +1 -0
  37. package/dist/controls/ResizeHandle.d.ts +48 -0
  38. package/dist/controls/ResizeHandle.js +91 -0
  39. package/dist/controls/ResizeHandle.js.map +1 -0
  40. package/dist/controls/SegmentedControl.d.ts +27 -0
  41. package/dist/controls/SegmentedControl.js +17 -0
  42. package/dist/controls/SegmentedControl.js.map +1 -0
  43. package/dist/controls/StatusBadge.d.ts +17 -0
  44. package/dist/controls/StatusBadge.js +10 -0
  45. package/dist/controls/StatusBadge.js.map +1 -0
  46. package/dist/controls/context.d.ts +17 -0
  47. package/dist/controls/context.js +2 -0
  48. package/dist/controls/context.js.map +1 -0
  49. package/dist/controls/placement.d.ts +43 -0
  50. package/dist/controls/placement.js +19 -0
  51. package/dist/controls/placement.js.map +1 -0
  52. package/dist/controls/resize.d.ts +23 -0
  53. package/dist/controls/resize.js +49 -0
  54. package/dist/controls/resize.js.map +1 -0
  55. package/dist/data/DataNotes.d.ts +13 -0
  56. package/dist/data/DataNotes.js +18 -0
  57. package/dist/data/DataNotes.js.map +1 -0
  58. package/dist/data/DataSourceProvider.d.ts +11 -0
  59. package/dist/data/DataSourceProvider.js +21 -0
  60. package/dist/data/DataSourceProvider.js.map +1 -0
  61. package/dist/data/export.d.ts +33 -0
  62. package/dist/data/export.js +77 -0
  63. package/dist/data/export.js.map +1 -0
  64. package/dist/data/format.d.ts +44 -0
  65. package/dist/data/format.js +127 -0
  66. package/dist/data/format.js.map +1 -0
  67. package/dist/data/messages.d.ts +13 -0
  68. package/dist/data/messages.js +2 -0
  69. package/dist/data/messages.js.map +1 -0
  70. package/dist/data/useRowWindow.d.ts +70 -0
  71. package/dist/data/useRowWindow.js +175 -0
  72. package/dist/data/useRowWindow.js.map +1 -0
  73. package/dist/discovery/AskData.d.ts +22 -0
  74. package/dist/discovery/AskData.js +49 -0
  75. package/dist/discovery/AskData.js.map +1 -0
  76. package/dist/discovery/ContextBuilder.d.ts +49 -0
  77. package/dist/discovery/ContextBuilder.js +167 -0
  78. package/dist/discovery/ContextBuilder.js.map +1 -0
  79. package/dist/discovery/DataSearch.d.ts +27 -0
  80. package/dist/discovery/DataSearch.js +73 -0
  81. package/dist/discovery/DataSearch.js.map +1 -0
  82. package/dist/discovery/ObjectDetail.d.ts +38 -0
  83. package/dist/discovery/ObjectDetail.js +129 -0
  84. package/dist/discovery/ObjectDetail.js.map +1 -0
  85. package/dist/discovery/RelationshipGraph.d.ts +19 -0
  86. package/dist/discovery/RelationshipGraph.js +64 -0
  87. package/dist/discovery/RelationshipGraph.js.map +1 -0
  88. package/dist/discovery/shared.d.ts +38 -0
  89. package/dist/discovery/shared.js +64 -0
  90. package/dist/discovery/shared.js.map +1 -0
  91. package/dist/editor/SqlEditor.d.ts +41 -0
  92. package/dist/editor/SqlEditor.js +181 -0
  93. package/dist/editor/SqlEditor.js.map +1 -0
  94. package/dist/explore/Explorer.d.ts +110 -0
  95. package/dist/explore/Explorer.js +471 -0
  96. package/dist/explore/Explorer.js.map +1 -0
  97. package/dist/explore/ModelLineage.d.ts +22 -0
  98. package/dist/explore/ModelLineage.js +70 -0
  99. package/dist/explore/ModelLineage.js.map +1 -0
  100. package/dist/explore/ReportBuilder.d.ts +39 -0
  101. package/dist/explore/ReportBuilder.js +98 -0
  102. package/dist/explore/ReportBuilder.js.map +1 -0
  103. package/dist/explore/SemanticModelEditor.d.ts +60 -0
  104. package/dist/explore/SemanticModelEditor.js +220 -0
  105. package/dist/explore/SemanticModelEditor.js.map +1 -0
  106. package/dist/explore/SemanticRows.d.ts +42 -0
  107. package/dist/explore/SemanticRows.js +121 -0
  108. package/dist/explore/SemanticRows.js.map +1 -0
  109. package/dist/explore/SemanticsProvider.d.ts +31 -0
  110. package/dist/explore/SemanticsProvider.js +72 -0
  111. package/dist/explore/SemanticsProvider.js.map +1 -0
  112. package/dist/explore/model.d.ts +151 -0
  113. package/dist/explore/model.js +344 -0
  114. package/dist/explore/model.js.map +1 -0
  115. package/dist/explore/report.d.ts +60 -0
  116. package/dist/explore/report.js +92 -0
  117. package/dist/explore/report.js.map +1 -0
  118. package/dist/explore/semantic-proposal.d.ts +44 -0
  119. package/dist/explore/semantic-proposal.js +67 -0
  120. package/dist/explore/semantic-proposal.js.map +1 -0
  121. package/dist/explore/semantic.d.ts +44 -0
  122. package/dist/explore/semantic.js +154 -0
  123. package/dist/explore/semantic.js.map +1 -0
  124. package/dist/files/FileBrowser.d.ts +42 -0
  125. package/dist/files/FileBrowser.js +314 -0
  126. package/dist/files/FileBrowser.js.map +1 -0
  127. package/dist/files/files.d.ts +65 -0
  128. package/dist/files/files.js +165 -0
  129. package/dist/files/files.js.map +1 -0
  130. package/dist/filter/FilterBar.d.ts +49 -0
  131. package/dist/filter/FilterBar.js +153 -0
  132. package/dist/filter/FilterBar.js.map +1 -0
  133. package/dist/filter/QueryFilters.d.ts +25 -0
  134. package/dist/filter/QueryFilters.js +58 -0
  135. package/dist/filter/QueryFilters.js.map +1 -0
  136. package/dist/form/Form.d.ts +76 -0
  137. package/dist/form/Form.js +131 -0
  138. package/dist/form/Form.js.map +1 -0
  139. package/dist/graph/NodeGraph.d.ts +30 -0
  140. package/dist/graph/NodeGraph.js +89 -0
  141. package/dist/graph/NodeGraph.js.map +1 -0
  142. package/dist/graph/model.d.ts +68 -0
  143. package/dist/graph/model.js +122 -0
  144. package/dist/graph/model.js.map +1 -0
  145. package/dist/grid/DataGrid.d.ts +98 -0
  146. package/dist/grid/DataGrid.js +400 -0
  147. package/dist/grid/DataGrid.js.map +1 -0
  148. package/dist/index.d.ts +85 -0
  149. package/dist/index.js +87 -0
  150. package/dist/index.js.map +1 -0
  151. package/dist/locale/SurfacesText.d.ts +17 -0
  152. package/dist/locale/SurfacesText.js +17 -0
  153. package/dist/locale/SurfacesText.js.map +1 -0
  154. package/dist/locale/locale.d.ts +305 -0
  155. package/dist/locale/locale.js +359 -0
  156. package/dist/locale/locale.js.map +1 -0
  157. package/dist/menu/ContextMenu.d.ts +31 -0
  158. package/dist/menu/ContextMenu.js +95 -0
  159. package/dist/menu/ContextMenu.js.map +1 -0
  160. package/dist/metric/Metric.d.ts +33 -0
  161. package/dist/metric/Metric.js +64 -0
  162. package/dist/metric/Metric.js.map +1 -0
  163. package/dist/metric/useMeasure.d.ts +25 -0
  164. package/dist/metric/useMeasure.js +44 -0
  165. package/dist/metric/useMeasure.js.map +1 -0
  166. package/dist/model/ModelDiagram.d.ts +142 -0
  167. package/dist/model/ModelDiagram.js +700 -0
  168. package/dist/model/ModelDiagram.js.map +1 -0
  169. package/dist/panzoom/usePanZoom.d.ts +117 -0
  170. package/dist/panzoom/usePanZoom.js +313 -0
  171. package/dist/panzoom/usePanZoom.js.map +1 -0
  172. package/dist/pipeline/DatasetReview.d.ts +48 -0
  173. package/dist/pipeline/DatasetReview.js +157 -0
  174. package/dist/pipeline/DatasetReview.js.map +1 -0
  175. package/dist/pipeline/IngestWizard.d.ts +51 -0
  176. package/dist/pipeline/IngestWizard.js +79 -0
  177. package/dist/pipeline/IngestWizard.js.map +1 -0
  178. package/dist/pipeline/Pipeline.d.ts +171 -0
  179. package/dist/pipeline/Pipeline.js +203 -0
  180. package/dist/pipeline/Pipeline.js.map +1 -0
  181. package/dist/pipeline/PipelineView.d.ts +63 -0
  182. package/dist/pipeline/PipelineView.js +239 -0
  183. package/dist/pipeline/PipelineView.js.map +1 -0
  184. package/dist/pivot/PivotTable.d.ts +94 -0
  185. package/dist/pivot/PivotTable.js +176 -0
  186. package/dist/pivot/PivotTable.js.map +1 -0
  187. package/dist/plan/QueryPlan.d.ts +29 -0
  188. package/dist/plan/QueryPlan.js +79 -0
  189. package/dist/plan/QueryPlan.js.map +1 -0
  190. package/dist/result/QueryResult.d.ts +51 -0
  191. package/dist/result/QueryResult.js +256 -0
  192. package/dist/result/QueryResult.js.map +1 -0
  193. package/dist/review/ActionReceipt.d.ts +52 -0
  194. package/dist/review/ActionReceipt.js +32 -0
  195. package/dist/review/ActionReceipt.js.map +1 -0
  196. package/dist/review/PiiReview.d.ts +37 -0
  197. package/dist/review/PiiReview.js +29 -0
  198. package/dist/review/PiiReview.js.map +1 -0
  199. package/dist/review/PlanReview.d.ts +42 -0
  200. package/dist/review/PlanReview.js +37 -0
  201. package/dist/review/PlanReview.js.map +1 -0
  202. package/dist/review/StepFlow.d.ts +25 -0
  203. package/dist/review/StepFlow.js +21 -0
  204. package/dist/review/StepFlow.js.map +1 -0
  205. package/dist/review/pii.d.ts +21 -0
  206. package/dist/review/pii.js +67 -0
  207. package/dist/review/pii.js.map +1 -0
  208. package/dist/rows/RowList.d.ts +41 -0
  209. package/dist/rows/RowList.js +72 -0
  210. package/dist/rows/RowList.js.map +1 -0
  211. package/dist/schema/ObjectBrowser.d.ts +78 -0
  212. package/dist/schema/ObjectBrowser.js +467 -0
  213. package/dist/schema/ObjectBrowser.js.map +1 -0
  214. package/dist/schema/ObjectInfo.d.ts +25 -0
  215. package/dist/schema/ObjectInfo.js +69 -0
  216. package/dist/schema/ObjectInfo.js.map +1 -0
  217. package/dist/schema/SchemaExplorer.d.ts +32 -0
  218. package/dist/schema/SchemaExplorer.js +175 -0
  219. package/dist/schema/SchemaExplorer.js.map +1 -0
  220. package/dist/schema/refs.d.ts +32 -0
  221. package/dist/schema/refs.js +65 -0
  222. package/dist/schema/refs.js.map +1 -0
  223. package/dist/site/Site.d.ts +191 -0
  224. package/dist/site/Site.js +138 -0
  225. package/dist/site/Site.js.map +1 -0
  226. package/dist/source/ConnectionBuilder.d.ts +54 -0
  227. package/dist/source/ConnectionBuilder.js +115 -0
  228. package/dist/source/ConnectionBuilder.js.map +1 -0
  229. package/dist/source/SourceList.d.ts +17 -0
  230. package/dist/source/SourceList.js +71 -0
  231. package/dist/source/SourceList.js.map +1 -0
  232. package/dist/styles.css +9930 -0
  233. package/dist/styles.layer.css +9934 -0
  234. package/dist/table/DataTable.d.ts +72 -0
  235. package/dist/table/DataTable.js +68 -0
  236. package/dist/table/DataTable.js.map +1 -0
  237. package/dist/table/Pagination.d.ts +20 -0
  238. package/dist/table/Pagination.js +16 -0
  239. package/dist/table/Pagination.js.map +1 -0
  240. package/dist/table/SelectionBar.d.ts +43 -0
  241. package/dist/table/SelectionBar.js +18 -0
  242. package/dist/table/SelectionBar.js.map +1 -0
  243. package/dist/text/Markdown.d.ts +71 -0
  244. package/dist/text/Markdown.js +187 -0
  245. package/dist/text/Markdown.js.map +1 -0
  246. package/dist/text/highlight.d.ts +23 -0
  247. package/dist/text/highlight.js +196 -0
  248. package/dist/text/highlight.js.map +1 -0
  249. package/dist/theme/ThemePicker.d.ts +16 -0
  250. package/dist/theme/ThemePicker.js +50 -0
  251. package/dist/theme/ThemePicker.js.map +1 -0
  252. package/dist/theme/ThemeProvider.d.ts +52 -0
  253. package/dist/theme/ThemeProvider.js +111 -0
  254. package/dist/theme/ThemeProvider.js.map +1 -0
  255. package/dist/workspace/NavBar.d.ts +23 -0
  256. package/dist/workspace/NavBar.js +171 -0
  257. package/dist/workspace/NavBar.js.map +1 -0
  258. package/dist/workspace/SideNav.d.ts +61 -0
  259. package/dist/workspace/SideNav.js +149 -0
  260. package/dist/workspace/SideNav.js.map +1 -0
  261. package/dist/workspace/Workspace.d.ts +53 -0
  262. package/dist/workspace/Workspace.js +243 -0
  263. package/dist/workspace/Workspace.js.map +1 -0
  264. package/dist/workspace/icons.d.ts +34 -0
  265. package/dist/workspace/icons.js +37 -0
  266. package/dist/workspace/icons.js.map +1 -0
  267. package/dist/workspace/layout.d.ts +74 -0
  268. package/dist/workspace/layout.js +276 -0
  269. package/dist/workspace/layout.js.map +1 -0
  270. package/package.json +85 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/locale/locale.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,IAAI,OAAO,GAAG,OAAO,CAAC;AACtB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;AACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA+B,CAAC;AAE3D;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,8EAA8E;IAC9E,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,GAA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AC;AAOX,IAAI,MAAM,GAAW,EAAE,GAAG,aAAa,EAAE,CAAC;AAE1C,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,OAAwB;IAChD,MAAM,IAAI,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAClD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,GAAG,IAAI,aAAa;YAAE,IAAI,CAAC,GAAe,CAAC,GAAG,IAAI,CAAC;IACrF,CAAC;IACD,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,WAAW;IACzB,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;AAChC,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,KAAK,CAAC,GAAa,EAAE,IAAsC;IACzE,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["/**\n * The locale every number and date in the components is written in, and the\n * words they show. Both are page-wide: one locale and one set of words per\n * page. A host sets them once, before the components render, with\n * `setLocale` and `setLabels` or the `SurfacesText` component.\n */\n\nlet current = \"en-US\";\nconst formats = new Map<string, Intl.NumberFormat>();\nconst dateFormats = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Sets the locale (a BCP 47 tag such as \"de-DE\") for every number and date the\n * components write. Platform forms with an underscore (\"en_US\", as iOS and\n * Android write them) are accepted.\n */\nexport function setLocale(locale: string): void {\n // Throws a RangeError on a malformed tag here rather than on the next render.\n current = Intl.getCanonicalLocales(locale.replaceAll(\"_\", \"-\"))[0] ?? \"en-US\";\n}\n\n/** The locale numbers and dates are written in. Defaults to \"en-US\". */\nexport function getLocale(): string {\n return current;\n}\n\n/** A number format in the current locale, kept for reuse. Call it when formatting, not once at load, so a later `setLocale` applies. */\nexport function numberFormat(options: Intl.NumberFormatOptions = {}): Intl.NumberFormat {\n const key = `${current}|${JSON.stringify(options)}`;\n let format = formats.get(key);\n if (!format) {\n format = new Intl.NumberFormat(current, options);\n formats.set(key, format);\n }\n return format;\n}\n\n/** A date and time format in the current locale, kept for reuse. */\nexport function dateFormat(options: Intl.DateTimeFormatOptions = {}): Intl.DateTimeFormat {\n const key = `${current}|${JSON.stringify(options)}`;\n let format = dateFormats.get(key);\n if (!format) {\n format = new Intl.DateTimeFormat(current, options);\n dateFormats.set(key, format);\n }\n return format;\n}\n\n/**\n * Every word the data-display components show, in English. `{name}` marks a\n * value filled in when the words are shown. Replace any of them with\n * `setLabels`, for another language or plainer words.\n */\nexport const defaultLabels = {\n // Cell values\n \"cell.null\": \"null\",\n \"cell.true\": \"true\",\n \"cell.false\": \"false\",\n\n // DataGrid\n \"grid.label\": \"Query result\",\n \"grid.sortAscending\": \"Sort ascending\",\n \"grid.sortDescending\": \"Sort descending\",\n \"grid.clearSorting\": \"Clear sorting\",\n \"grid.moveLeft\": \"Move left\",\n \"grid.moveRight\": \"Move right\",\n \"grid.hideColumn\": \"Hide column\",\n \"grid.showAllColumns\": \"Show all columns\",\n \"grid.showAllColumnsHidden\": \"Show all columns ({count} hidden)\",\n \"grid.resetWidth\": \"Reset width\",\n \"grid.resetWidthHint\": \"Double-click edge\",\n \"grid.resetLayout\": \"Reset column layout\",\n \"grid.copyColumnName\": \"Copy column name\",\n \"grid.sqlCountValues\": \"SQL: count each value\",\n \"grid.sqlRange\": \"SQL: range and missing values\",\n \"grid.copyValue\": \"Copy value\",\n \"grid.copyRowJson\": \"Copy row as JSON\",\n \"grid.filterToValue\": \"Filter to this value\",\n \"grid.leaveValueOut\": \"Leave this value out\",\n \"grid.copied\": \"Copied {what}.\",\n \"grid.copiedCell\": \"the cell\",\n \"grid.copiedRow\": \"the row\",\n \"grid.copiedColumnName\": \"the column name\",\n \"grid.copiedSql\": \"the SQL\",\n \"grid.copyFailed\": \"Could not copy: the browser refused access to the clipboard.\",\n \"grid.movedLeft\": \"Moved {name} left.\",\n \"grid.movedRight\": \"Moved {name} right.\",\n \"grid.moved\": \"Moved {name}.\",\n \"grid.columnMenu\": \"{name} column\",\n \"grid.cellMenu\": \"{name} cell\",\n \"grid.activeCellMenu\": \"Cell\",\n \"grid.failed\": \"Query failed\",\n \"grid.loading\": \"Loading…\",\n \"grid.rows\": \"{count} rows\",\n \"grid.rowsOne\": \"{count} row\",\n \"grid.noRows\": \"No rows match.\",\n \"grid.showHidden\": \"Show {count} hidden columns\",\n \"grid.showHiddenOne\": \"Show {count} hidden column\",\n \"grid.elapsed\": \"{ms} ms\",\n \"grid.asOf\": \"As of {time}\",\n \"grid.runAgain\": \"Run again\",\n \"grid.previous\": \"Previous\",\n \"grid.next\": \"Next\",\n \"grid.page\": \"Page {page} of {pages}\",\n\n // PivotTable\n \"pivot.label\": \"Pivot table\",\n \"pivot.loading\": \"Loading…\",\n \"pivot.choose\": \"Choose rows or columns and a measure.\",\n \"pivot.empty\": \"No rows match.\",\n \"pivot.total\": \"Total\",\n \"pivot.all\": \"All\",\n \"pivot.none\": \"(none)\",\n \"pivot.truncated\": \"This pivot has more than {limit} cells, so some are missing. Add a filter or choose columns with fewer values.\",\n \"pivot.hiddenColumns\": \"Showing the first {shown} of {total} column values.\",\n\n // Chart\n \"chart.empty\": \"No data to chart.\",\n \"chart.missingX\": \"Rows with no {x} are not drawn{detail}.\",\n \"chart.description\": \"{type} chart of {measures} by {x}\",\n \"chart.coloursRepeat\": \"{count} series share {colours} colours, so some repeat. Filter, or split by a column with fewer values.\",\n \"chart.advice\": \"{message} Better: {instead}\",\n \"chart.sampleNote\": \"Showing a random sample of {count} rows.\",\n \"chart.firstNote\": \"Showing the first {count} points.\",\n \"chart.largestNote\": \"Showing the largest {count} points.\",\n\n // RowList\n \"rows.loading\": \"Loading…\",\n \"rows.empty\": \"Nothing to show.\",\n \"rows.more\": \"Show more\",\n \"rows.some\": \"Showing the first {count}.\",\n \"rows.full\": \"Showing the first {count}. Filter to find others.\",\n\n // Metric, Sparkline, BulletGraph\n \"metric.loading\": \"…\",\n \"metric.none\": \"–\",\n \"sparkline.summary\": \"{label}: {now} now, from {first}; low {low}, high {high} over {count} {grain}s.\",\n \"sparkline.empty\": \"{label}: no data.\",\n \"bullet.loading\": \"{label}: loading.\",\n \"bullet.empty\": \"{label}: no data.\",\n \"bullet.reading\": \"{label}: {value}{band}{target}.\",\n \"bullet.targetMet\": \"; target {target}, met\",\n \"bullet.targetNotMet\": \"; target {target}, not met\",\n \"bullet.target\": \"Target {target}\",\n\n // FilterBar\n \"filter.active\": \"Active filters\",\n \"filter.remove\": \"Remove filter {filter}\",\n \"filter.form\": \"Add a filter\",\n \"filter.column\": \"Column\",\n \"filter.comparison\": \"Comparison\",\n \"filter.value\": \"Value\",\n \"filter.typeOrPick\": \"Type or pick a value\",\n \"filter.add\": \"Add filter\",\n \"filter.quickRange\": \"Quick date range\",\n \"filter.quickRangeChoose\": \"Quick range…\",\n \"filter.range7d\": \"Last 7 days\",\n \"filter.range30d\": \"Last 30 days\",\n \"filter.range90d\": \"Last 90 days\",\n \"filter.range12m\": \"Last 12 months\",\n \"filter.rangeMonth\": \"This month\",\n \"filter.rangeYear\": \"This year\",\n \"filter.isEmpty\": \"is empty\",\n \"filter.isNotEmpty\": \"is not empty\",\n \"filter.contains\": \"contains\",\n \"filter.is\": \"is\",\n \"filter.isNot\": \"is not\",\n \"filter.startsWith\": \"starts with\",\n \"filter.endsWith\": \"ends with\",\n \"filter.enterWholeNumber\": \"Enter a whole number.\",\n \"filter.enterNumber\": \"Enter a number.\",\n \"filter.enterTrueFalse\": \"Enter true or false.\",\n \"filter.enterDate\": \"Enter a date like 2026-01-31.\",\n \"filter.enterValue\": \"Enter a value.\",\n\n // QueryResult\n \"result.views\": \"Result view\",\n \"result.tabTable\": \"Table\",\n \"result.tabChart\": \"Chart\",\n \"result.tabPivot\": \"Pivot\",\n \"result.stopExport\": \"Stop export\",\n \"result.downloadCsv\": \"Download CSV\",\n \"result.copySql\": \"Copy SQL\",\n \"result.cancelQuery\": \"Cancel query\",\n \"result.format\": \"Format\",\n \"result.formatColumn\": \"Column to format\",\n \"result.chooseColumn\": \"Choose a column…\",\n \"result.howToShow\": \"How to show {column}\",\n \"result.asItIs\": \"As it is\",\n \"result.formatNumber\": \"Number\",\n \"result.formatCompact\": \"Short number (1.2M)\",\n \"result.formatCurrency\": \"Currency\",\n \"result.formatPercent\": \"Percent\",\n \"result.formatText\": \"Plain text\",\n \"result.formatDate\": \"Date only\",\n \"result.formatDatetime\": \"Date and time\",\n \"result.preparing\": \"Preparing the file…\",\n \"result.rowsSoFar\": \"{count} rows so far…\",\n \"result.saved\": \"Saved {count} rows.\",\n \"result.savedTruncated\": \"Saved {count} rows. The server's row limit was reached, so the file is not the whole result.\",\n \"result.exportStopped\": \"Export stopped.\",\n \"result.sqlCopied\": \"SQL copied.\",\n \"result.copyNotAllowed\": \"Copying is not allowed here.\",\n \"result.sqlSent\": \"SQL sent to the engine\",\n \"result.plan\": \"How the engine will run it\",\n \"result.stored\": \"The query ran once and its result was kept, so sorting, filtering and paging read the kept rows instead of running it again.\",\n \"result.chooseChart\": \"Choose columns to chart.\",\n \"result.choosePivot\": \"Choose what goes in the rows and the values.\",\n \"result.chartType\": \"Type\",\n \"result.slices\": \"Slices\",\n \"result.xAxis\": \"X axis\",\n \"result.yAxis\": \"Y axis\",\n \"result.every\": \"Every\",\n \"result.bins\": \"Bins\",\n \"result.binsEach\": \"each value\",\n \"result.binsAbout\": \"about {count}\",\n \"result.splitBy\": \"Split by\",\n \"result.nothing\": \"nothing\",\n \"result.legend\": \"Legend\",\n \"result.automatic\": \"automatic\",\n \"result.legendHidden\": \"hidden\",\n \"result.stack\": \"Stack\",\n \"result.plotEachRow\": \"Plot each row\",\n \"result.series\": \"Series {number}\",\n \"result.of\": \"of\",\n \"result.drawnAs\": \"Drawn as\",\n \"result.drawnAsChart\": \"chart type ({type})\",\n \"result.scale\": \"Scale\",\n \"result.leftAxis\": \"left axis\",\n \"result.rightAxis\": \"right axis\",\n \"result.removeSeries\": \"Remove series {number}\",\n \"result.remove\": \"Remove\",\n \"result.addSeries\": \"Add series\",\n \"result.rows\": \"Rows\",\n \"result.columns\": \"Columns\",\n \"result.none\": \"none\",\n \"result.datesBy\": \"Dates by\",\n \"result.values\": \"Values\",\n \"result.sum\": \"sum\",\n \"result.avg\": \"average\",\n \"result.median\": \"median\",\n \"result.count\": \"count of rows\",\n \"result.countDistinct\": \"distinct count\",\n \"result.min\": \"minimum\",\n \"result.max\": \"maximum\",\n \"result.stddev\": \"standard deviation\",\n \"result.p90\": \"90th percentile\",\n\n // Form\n \"form.submit\": \"Submit\",\n \"form.choose\": \"Choose…\",\n \"form.required\": \"(required)\",\n \"form.needsAttention\": \"Nothing was sent. {count} fields need attention.\",\n \"form.needsAttentionOne\": \"Nothing was sent. One field needs attention.\",\n \"form.sent\": \"Sent.\",\n \"form.notSaved\": \"The backend did not save it.\",\n \"form.saved\": \"Saved.\",\n \"form.couldNotSend\": \"Could not send: {error}\",\n \"form.sending\": \"Sending…\",\n \"form.connected\": \"Saved by the backend this page is connected to.\",\n \"form.notConnected\": \"Not connected to a backend: what you submit goes only to this page.\",\n\n // StepFlow\n \"flow.done\": \"Done\",\n \"flow.current\": \"In progress\",\n \"flow.waiting\": \"Waiting for you\",\n \"flow.pending\": \"Not started\",\n \"flow.failed\": \"Failed\",\n \"flow.skipped\": \"Skipped\",\n \"flow.count\": \"{done} of {total} done\",\n\n // PlanReview\n \"plan.riskLow\": \"Low risk\",\n \"plan.riskMedium\": \"Check this\",\n \"plan.riskHigh\": \"Changes or removes data\",\n \"plan.proposedBy\": \"Proposed by {who}. Nothing runs until you approve.\",\n \"plan.required\": \"Required\",\n \"plan.affects\": \"Affects: {what}\",\n \"plan.whatItWouldRun\": \"What it would run\",\n \"plan.approved\": \"Approved {count} of {total} steps.\",\n \"plan.rejected\": \"Rejected. Nothing was run.\",\n \"plan.decisionNote\": \" Note: {note}\",\n \"plan.noteLabel\": \"Note for the record (optional)\",\n \"plan.approve\": \"Approve {count} steps\",\n \"plan.approveOne\": \"Approve {count} step\",\n \"plan.reject\": \"Reject\",\n\n // ActionReceipt\n \"receipt.done\": \"Done\",\n \"receipt.partial\": \"Partly done\",\n \"receipt.failed\": \"Failed\",\n \"receipt.ran\": \"Ran\",\n \"receipt.by\": \"by {who}\",\n \"receipt.approved\": \"Approved\",\n \"receipt.noApproval\": \"No one approved this.\",\n \"receipt.whatChanged\": \"What changed\",\n \"receipt.what\": \"What\",\n \"receipt.before\": \"Before\",\n \"receipt.after\": \"After\",\n \"receipt.whatRan\": \"What ran\",\n \"receipt.cannotUndo\": \"This cannot be undone from here.\",\n \"receipt.undoClosed\": \"It could be undone until {time}; that time has passed.\",\n \"receipt.undoUntil\": \"Can be undone until {time}.\",\n \"receipt.undoRequested\": \"Undo requested. You will be asked to confirm it.\",\n\n // DataTable\n \"table.selectPage\": \"Select every row on this page\",\n \"table.selectRow\": \"Select {name}\",\n \"table.empty\": \"Nothing to show.\",\n \"table.loading\": \"Loading…\",\n \"table.rowControls\": \"{name} actions\",\n \"table.actions\": \"Actions\",\n \"table.select\": \"Select\",\n\n // SelectionBar\n \"selection.label\": \"With the selected rows\",\n \"selection.count\": \"{count} selected\",\n \"selection.pageSelected\": \"All {count} on this page are selected.\",\n \"selection.selectAllMatching\": \"Select all {total} that match\",\n \"selection.allMatching\": \"All {total} that match are selected.\",\n \"selection.onlyPage\": \"Only this page\",\n \"selection.clear\": \"Clear\",\n\n // Pagination\n \"pages.label\": \"Pages\",\n \"pages.range\": \"{from}–{to} of {total}\",\n \"pages.previous\": \"Previous\",\n \"pages.next\": \"Next\",\n\n // ConfirmDialog\n \"confirm.confirm\": \"Confirm\",\n \"confirm.cancel\": \"Cancel\",\n\n // Combobox\n \"combobox.loading\": \"Looking…\",\n \"combobox.none\": \"Nothing matches.\",\n \"combobox.count\": \"{count} suggestions\",\n \"combobox.countOne\": \"1 suggestion\",\n\n // ReportBuilder\n \"report.untitled\": \"Untitled\",\n \"report.untitledReport\": \"Untitled report\",\n \"report.title\": \"Report title\",\n \"report.tileTitle\": \"Title of {title}\",\n \"report.tileControls\": \"{title} controls\",\n \"report.mode\": \"Mode\",\n \"report.build\": \"Build\",\n \"report.view\": \"View\",\n \"report.builder\": \"Build a view\",\n \"report.body\": \"Report\",\n \"report.changing\": \"Changing “{title}”.\",\n \"report.leaveAsItWas\": \"Leave it as it was\",\n \"report.leftAsItWas\": \"Left as it was.\",\n \"report.updateView\": \"Update view\",\n \"report.addToReport\": \"Add to report\",\n \"report.maxViews\": \"A report holds at most {max} views.\",\n \"report.needMeasure\": \"Put a metric on “Measure” first: a view needs something to measure.\",\n \"report.emptyBuild\": \"Nothing on the report yet. Make a view above and press “Add to report”; each one you add appears here, and they all follow the same filters.\",\n \"report.emptyView\": \"This report has no views yet. Switch to Build to make one.\",\n} as const;\n\n/** The name of one replaceable word or sentence. A name not in `defaultLabels` is a type error. */\nexport type LabelKey = keyof typeof defaultLabels;\n/** Every label, by name. */\nexport type Labels = Record<LabelKey, string>;\n\nlet labels: Labels = { ...defaultLabels };\n\n/** Replaces some of the words. Names not given keep their current text. */\nexport function setLabels(partial: Partial<Labels>): void {\n const next = { ...labels };\n for (const [key, text] of Object.entries(partial)) {\n if (typeof text === \"string\" && key in defaultLabels) next[key as LabelKey] = text;\n }\n labels = next;\n}\n\n/** Puts every word back to its English default. */\nexport function resetLabels(): void {\n labels = { ...defaultLabels };\n}\n\n/** The text for a label, with each `{name}` replaced by `vars.name`. A name with no value is left as written. */\nexport function label(key: LabelKey, vars?: Record<string, string | number>): string {\n const text = labels[key];\n if (!vars) return text;\n return text.replace(/\\{(\\w+)\\}/g, (whole, name: string) => (name in vars ? String(vars[name]) : whole));\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { type MouseEvent, type ReactNode } from "react";
2
+ export interface MenuItem {
3
+ /** Leave out, with `separator: true`, for a dividing line. */
4
+ label?: string;
5
+ onSelect?(): void;
6
+ disabled?: boolean;
7
+ separator?: boolean;
8
+ /** A short note on the right, such as a keyboard shortcut. */
9
+ hint?: string;
10
+ }
11
+ export interface ContextMenu {
12
+ /**
13
+ * Opens the menu for a `contextmenu` event. That event comes from a right
14
+ * click, a long press on a touch screen, the Menu key and Shift+F10, so one
15
+ * handler covers them all. With no pointer position (a keyboard opening)
16
+ * the menu appears at the element itself.
17
+ */
18
+ open(event: MouseEvent<HTMLElement>, label: string, items: MenuItem[]): void;
19
+ close(): void;
20
+ /** Render this once, anywhere in the component. */
21
+ element: ReactNode;
22
+ }
23
+ /** Copies text, saying whether it worked. Clipboard access can be refused by the browser. */
24
+ export declare function copyText(text: string): Promise<boolean>;
25
+ /**
26
+ * A menu of actions for the thing under the pointer or the keyboard focus.
27
+ * Arrow keys move, Home and End jump, Enter or Space chooses, Escape or a
28
+ * click elsewhere closes, and focus returns to where it came from. Anything
29
+ * offered here must also be reachable another way; a menu is a shortcut.
30
+ */
31
+ export declare function useContextMenu(): ContextMenu;
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ /** Copies text, saying whether it worked. Clipboard access can be refused by the browser. */
4
+ export async function copyText(text) {
5
+ try {
6
+ await navigator.clipboard.writeText(text);
7
+ return true;
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ }
13
+ /**
14
+ * A menu of actions for the thing under the pointer or the keyboard focus.
15
+ * Arrow keys move, Home and End jump, Enter or Space chooses, Escape or a
16
+ * click elsewhere closes, and focus returns to where it came from. Anything
17
+ * offered here must also be reachable another way; a menu is a shortcut.
18
+ */
19
+ export function useContextMenu() {
20
+ const [menu, setMenu] = useState();
21
+ const list = useRef(null);
22
+ const close = useCallback(() => {
23
+ setMenu((current) => {
24
+ current?.from?.focus?.();
25
+ return undefined;
26
+ });
27
+ }, []);
28
+ const open = useCallback((event, label, items) => {
29
+ if (items.length === 0)
30
+ return;
31
+ event.preventDefault();
32
+ event.stopPropagation();
33
+ const target = event.currentTarget;
34
+ const box = target.getBoundingClientRect();
35
+ const keyboard = event.clientX === 0 && event.clientY === 0;
36
+ setMenu({ x: keyboard ? box.left + 12 : event.clientX, y: keyboard ? box.bottom : event.clientY, label, items, from: document.activeElement instanceof HTMLElement ? document.activeElement : target });
37
+ }, []);
38
+ const enabled = () => [...(list.current?.querySelectorAll('[role="menuitem"]:not(:disabled)') ?? [])];
39
+ // Keep the menu inside the window, then put focus on its first item.
40
+ useLayoutEffect(() => {
41
+ const element = list.current;
42
+ if (!menu || !element)
43
+ return;
44
+ const box = element.getBoundingClientRect();
45
+ const left = Math.max(4, Math.min(menu.x, window.innerWidth - box.width - 4));
46
+ const top = Math.max(4, Math.min(menu.y, window.innerHeight - box.height - 4));
47
+ element.style.left = `${left}px`;
48
+ element.style.top = `${top}px`;
49
+ enabled()[0]?.focus();
50
+ }, [menu]);
51
+ useEffect(() => {
52
+ if (!menu)
53
+ return;
54
+ const away = (event) => {
55
+ if (!list.current?.contains(event.target))
56
+ close();
57
+ };
58
+ document.addEventListener("pointerdown", away, true);
59
+ window.addEventListener("blur", close);
60
+ window.addEventListener("resize", close);
61
+ return () => {
62
+ document.removeEventListener("pointerdown", away, true);
63
+ window.removeEventListener("blur", close);
64
+ window.removeEventListener("resize", close);
65
+ };
66
+ }, [menu, close]);
67
+ const onKeyDown = (event) => {
68
+ const items = enabled();
69
+ const at = items.indexOf(document.activeElement);
70
+ const go = (index) => {
71
+ event.preventDefault();
72
+ event.stopPropagation();
73
+ items[(index + items.length) % items.length]?.focus();
74
+ };
75
+ if (event.key === "ArrowDown")
76
+ return go(at + 1);
77
+ if (event.key === "ArrowUp")
78
+ return go(at - 1);
79
+ if (event.key === "Home")
80
+ return go(0);
81
+ if (event.key === "End")
82
+ return go(items.length - 1);
83
+ if (event.key === "Escape" || event.key === "Tab") {
84
+ event.preventDefault();
85
+ event.stopPropagation();
86
+ close();
87
+ }
88
+ };
89
+ const element = menu ? (_jsx("div", { ref: list, className: "sf-menu", role: "menu", "aria-label": menu.label, style: { left: menu.x, top: menu.y }, onKeyDown: onKeyDown, onContextMenu: (event) => event.preventDefault(), children: menu.items.map((item, i) => item.separator ? (_jsx("div", { className: "sf-menu-separator", role: "separator" }, i)) : (_jsxs("button", { type: "button", role: "menuitem", className: "sf-menu-item", disabled: item.disabled, onClick: () => {
90
+ close();
91
+ item.onSelect?.();
92
+ }, children: [_jsx("span", { children: item.label }), item.hint && _jsx("span", { className: "sf-menu-hint", children: item.hint })] }, i))) })) : null;
93
+ return { open, close, element };
94
+ }
95
+ //# sourceMappingURL=ContextMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../src/menu/ContextMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuD,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAkCvI,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,EAAwB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yboardEvent, type MouseEvent, type ReactNode, useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\nexport interface MenuItem {\n /** Leave out, with `separator: true`, for a dividing line. */\n label?: string;\n onSelect?(): void;\n disabled?: boolean;\n separator?: boolean;\n /** A short note on the right, such as a keyboard shortcut. */\n hint?: string;\n}\n\ninterface OpenMenu {\n x: number;\n y: number;\n label: string;\n items: MenuItem[];\n /** Where focus goes back to when the menu closes. */\n from: HTMLElement | null;\n}\n\nexport interface ContextMenu {\n /**\n * Opens the menu for a `contextmenu` event. That event comes from a right\n * click, a long press on a touch screen, the Menu key and Shift+F10, so one\n * handler covers them all. With no pointer position (a keyboard opening)\n * the menu appears at the element itself.\n */\n open(event: MouseEvent<HTMLElement>, label: string, items: MenuItem[]): void;\n close(): void;\n /** Render this once, anywhere in the component. */\n element: ReactNode;\n}\n\n/** Copies text, saying whether it worked. Clipboard access can be refused by the browser. */\nexport async function copyText(text: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * A menu of actions for the thing under the pointer or the keyboard focus.\n * Arrow keys move, Home and End jump, Enter or Space chooses, Escape or a\n * click elsewhere closes, and focus returns to where it came from. Anything\n * offered here must also be reachable another way; a menu is a shortcut.\n */\nexport function useContextMenu(): ContextMenu {\n const [menu, setMenu] = useState<OpenMenu | undefined>();\n const list = useRef<HTMLDivElement>(null);\n\n const close = useCallback(() => {\n setMenu((current) => {\n current?.from?.focus?.();\n return undefined;\n });\n }, []);\n\n const open = useCallback((event: MouseEvent<HTMLElement>, label: string, items: MenuItem[]) => {\n if (items.length === 0) return;\n event.preventDefault();\n event.stopPropagation();\n const target = event.currentTarget;\n const box = target.getBoundingClientRect();\n const keyboard = event.clientX === 0 && event.clientY === 0;\n setMenu({ x: keyboard ? box.left + 12 : event.clientX, y: keyboard ? box.bottom : event.clientY, label, items, from: document.activeElement instanceof HTMLElement ? document.activeElement : target });\n }, []);\n\n const enabled = () => [...(list.current?.querySelectorAll<HTMLButtonElement>('[role=\"menuitem\"]:not(:disabled)') ?? [])];\n\n // Keep the menu inside the window, then put focus on its first item.\n useLayoutEffect(() => {\n const element = list.current;\n if (!menu || !element) return;\n const box = element.getBoundingClientRect();\n const left = Math.max(4, Math.min(menu.x, window.innerWidth - box.width - 4));\n const top = Math.max(4, Math.min(menu.y, window.innerHeight - box.height - 4));\n element.style.left = `${left}px`;\n element.style.top = `${top}px`;\n enabled()[0]?.focus();\n }, [menu]);\n\n useEffect(() => {\n if (!menu) return;\n const away = (event: globalThis.MouseEvent) => {\n if (!list.current?.contains(event.target as Node)) close();\n };\n document.addEventListener(\"pointerdown\", away, true);\n window.addEventListener(\"blur\", close);\n window.addEventListener(\"resize\", close);\n return () => {\n document.removeEventListener(\"pointerdown\", away, true);\n window.removeEventListener(\"blur\", close);\n window.removeEventListener(\"resize\", close);\n };\n }, [menu, close]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = enabled();\n const at = items.indexOf(document.activeElement as HTMLButtonElement);\n const go = (index: number) => {\n event.preventDefault();\n event.stopPropagation();\n items[(index + items.length) % items.length]?.focus();\n };\n if (event.key === \"ArrowDown\") return go(at + 1);\n if (event.key === \"ArrowUp\") return go(at - 1);\n if (event.key === \"Home\") return go(0);\n if (event.key === \"End\") return go(items.length - 1);\n if (event.key === \"Escape\" || event.key === \"Tab\") {\n event.preventDefault();\n event.stopPropagation();\n close();\n }\n };\n\n const element = menu ? (\n <div ref={list} className=\"sf-menu\" role=\"menu\" aria-label={menu.label} style={{ left: menu.x, top: menu.y }} onKeyDown={onKeyDown} onContextMenu={(event) => event.preventDefault()}>\n {menu.items.map((item, i) =>\n item.separator ? (\n <div key={i} className=\"sf-menu-separator\" role=\"separator\" />\n ) : (\n <button\n key={i}\n type=\"button\"\n role=\"menuitem\"\n className=\"sf-menu-item\"\n disabled={item.disabled}\n onClick={() => {\n close();\n item.onSelect?.();\n }}\n >\n <span>{item.label}</span>\n {item.hint && <span className=\"sf-menu-hint\">{item.hint}</span>}\n </button>\n ),\n )}\n </div>\n ) : null;\n\n return { open, close, element };\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import { type DataSource } from "@surfaces-ui/data";
2
+ import { type ChartAggregate } from "../chart/Chart.js";
3
+ import type { DataMessages } from "../data/messages.js";
4
+ import { type FilterInit, type TimeTravelInit } from "../data/useRowWindow.js";
5
+ export interface MetricProps extends DataMessages {
6
+ sourceId: string;
7
+ /** The base SQL. The engine reduces it to the one number. */
8
+ sql: string;
9
+ /** Column to summarise. Optional only for `count`, which then counts rows. */
10
+ column?: string;
11
+ aggregate: ChartAggregate;
12
+ /** For `percentile`: a fraction from 0 to 1. Defaults to 0.9. */
13
+ percentile?: number;
14
+ label: string;
15
+ /** How the number is written. Defaults to "number". */
16
+ format?: "number" | "compact" | "currency" | "percent";
17
+ /** ISO 4217 code for `currency`. Defaults to USD. */
18
+ currency?: string;
19
+ filters?: FilterInit[];
20
+ timeTravel?: TimeTravelInit;
21
+ /** ISO 8601 time of the run this belongs to; see `RowWindowQuery.notBefore`. */
22
+ notBefore?: string;
23
+ dataSource?: DataSource;
24
+ className?: string;
25
+ }
26
+ /** Writes a number the way a headline figure is read. */
27
+ export declare function formatMetric(value: number, format?: MetricProps["format"], currency?: string): string;
28
+ /**
29
+ * One headline number worked out by the engine from a query: a total, an
30
+ * average, a count. Unlike a number written into a page, it follows the
31
+ * data and any filters applied.
32
+ */
33
+ export declare function Metric(props: MetricProps): import("react").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { collect } from "@surfaces-ui/data";
3
+ import { useEffect, useState } from "react";
4
+ import { AGGREGATE_FUNCTIONS } from "../chart/Chart.js";
5
+ import { useDataSource } from "../data/DataSourceProvider.js";
6
+ import { DataNotes, dataNotes } from "../data/DataNotes.js";
7
+ import { numericValue } from "../data/format.js";
8
+ import { label as text, numberFormat } from "../locale/locale.js";
9
+ import { messageOf } from "../data/useRowWindow.js";
10
+ /** Writes a number the way a headline figure is read. */
11
+ export function formatMetric(value, format = "number", currency = "USD") {
12
+ const options = format === "currency"
13
+ ? // Cents only under a thousand: "$1,904" sits beside "$498.2K" as one way of writing money.
14
+ Math.abs(value) >= 100_000
15
+ ? { style: "currency", currency, notation: "compact", maximumFractionDigits: 1 }
16
+ : Math.abs(value) >= 1_000
17
+ ? { style: "currency", currency, minimumFractionDigits: 0, maximumFractionDigits: 0 }
18
+ : { style: "currency", currency, maximumFractionDigits: 2 }
19
+ : format === "percent"
20
+ ? { style: "percent", maximumFractionDigits: 1 }
21
+ : format === "compact"
22
+ ? { notation: "compact", maximumFractionDigits: 1 }
23
+ : { maximumFractionDigits: 2 };
24
+ return numberFormat(options).format(value);
25
+ }
26
+ /**
27
+ * One headline number worked out by the engine from a query: a total, an
28
+ * average, a count. Unlike a number written into a page, it follows the
29
+ * data and any filters applied.
30
+ */
31
+ export function Metric(props) {
32
+ const { sourceId, sql, column, aggregate, percentile, label, format, currency, filters, timeTravel, notBefore } = props;
33
+ const dataSource = useDataSource(props.dataSource);
34
+ const [state, setState] = useState({ loading: true });
35
+ const key = JSON.stringify([sourceId, sql, column, aggregate, percentile, filters, timeTravel, notBefore], (_, v) => (typeof v === "bigint" ? `${v}n` : v));
36
+ useEffect(() => {
37
+ const controller = new AbortController();
38
+ setState((previous) => ({ ...previous, loading: true, error: undefined }));
39
+ collect(dataSource.execute({
40
+ sourceId,
41
+ timeTravel,
42
+ notBefore,
43
+ query: {
44
+ baseSql: sql,
45
+ filters,
46
+ aggregates: [{ function: AGGREGATE_FUNCTIONS[aggregate], column: column ?? "", alias: "value", percentile: aggregate === "percentile" ? (percentile ?? 0.9) : 0 }],
47
+ },
48
+ }, { signal: controller.signal }))
49
+ .then((result) => {
50
+ if (controller.signal.aborted)
51
+ return;
52
+ const field = result.table.schema.fields.find((f) => f.name === "value");
53
+ const raw = result.table.getChild("value")?.get(0);
54
+ setState({ value: field ? numericValue(raw, field.type) : null, loading: false, notes: dataNotes(result.header.notices) });
55
+ })
56
+ .catch((error) => {
57
+ if (!controller.signal.aborted)
58
+ setState({ error: messageOf(error), loading: false });
59
+ });
60
+ return () => controller.abort();
61
+ }, [dataSource, key]); // eslint-disable-line react-hooks/exhaustive-deps
62
+ return (_jsxs("div", { className: ["sf-a2-stat sf-metric", props.className].filter(Boolean).join(" "), "aria-busy": state.loading, children: [_jsx("span", { className: "sf-a2-stat-label", children: label }), state.error ? (_jsx("span", { className: "sf-metric-error", role: "alert", "data-error": state.error, children: props.errorMessage ?? state.error })) : (_jsx("span", { className: "sf-a2-stat-value", children: state.value === undefined ? text("metric.loading") : state.value === null ? (props.emptyMessage ?? text("metric.none")) : formatMetric(state.value, format, currency) })), _jsx(DataNotes, { notes: state.notes })] }));
63
+ }
64
+ //# sourceMappingURL=Metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Metric.js","sourceRoot":"","sources":["../../src/metric/Metric.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAuB,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAwC,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAwB1F,yDAAyD;AACzD,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,MAAM,GAA0B,QAAQ,EAAE,QAAQ,GAAG,KAAK;IACpG,MAAM,OAAO,GACX,MAAM,KAAK,UAA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IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAQ,CAClN,EACD,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,IAC7B,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type DataSource, collect } from \"@surfaces-ui/data\";\nimport { useEffect, useState } from \"react\";\nimport { AGGREGATE_FUNCTIONS, type ChartAggregate } from \"../chart/Chart.js\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { DataNotes, dataNotes } from \"../data/DataNotes.js\";\nimport type { DataMessages } from \"../data/messages.js\";\nimport { numericValue } from \"../data/format.js\";\nimport { label as text, numberFormat } from \"../locale/locale.js\";\nimport { type FilterInit, type TimeTravelInit, messageOf } from \"../data/useRowWindow.js\";\n\nexport interface MetricProps extends DataMessages {\n sourceId: string;\n /** The base SQL. The engine reduces it to the one number. */\n sql: string;\n /** Column to summarise. Optional only for `count`, which then counts rows. */\n column?: string;\n aggregate: ChartAggregate;\n /** For `percentile`: a fraction from 0 to 1. Defaults to 0.9. */\n percentile?: number;\n label: string;\n /** How the number is written. Defaults to \"number\". */\n format?: \"number\" | \"compact\" | \"currency\" | \"percent\";\n /** ISO 4217 code for `currency`. Defaults to USD. */\n currency?: string;\n filters?: FilterInit[];\n timeTravel?: TimeTravelInit;\n /** ISO 8601 time of the run this belongs to; see `RowWindowQuery.notBefore`. */\n notBefore?: string;\n dataSource?: DataSource;\n className?: string;\n}\n\n/** Writes a number the way a headline figure is read. */\nexport function formatMetric(value: number, format: MetricProps[\"format\"] = \"number\", currency = \"USD\"): string {\n const options: Intl.NumberFormatOptions =\n format === \"currency\"\n ? // Cents only under a thousand: \"$1,904\" sits beside \"$498.2K\" as one way of writing money.\n Math.abs(value) >= 100_000\n ? { style: \"currency\", currency, notation: \"compact\", maximumFractionDigits: 1 }\n : Math.abs(value) >= 1_000\n ? { style: \"currency\", currency, minimumFractionDigits: 0, maximumFractionDigits: 0 }\n : { style: \"currency\", currency, maximumFractionDigits: 2 }\n : format === \"percent\"\n ? { style: \"percent\", maximumFractionDigits: 1 }\n : format === \"compact\"\n ? { notation: \"compact\", maximumFractionDigits: 1 }\n : { maximumFractionDigits: 2 };\n return numberFormat(options).format(value);\n}\n\n/**\n * One headline number worked out by the engine from a query: a total, an\n * average, a count. Unlike a number written into a page, it follows the\n * data and any filters applied.\n */\nexport function Metric(props: MetricProps) {\n const { sourceId, sql, column, aggregate, percentile, label, format, currency, filters, timeTravel, notBefore } = props;\n const dataSource = useDataSource(props.dataSource);\n const [state, setState] = useState<{ value?: number | null; error?: string; loading: boolean; notes?: string[] }>({ loading: true });\n const key = JSON.stringify([sourceId, sql, column, aggregate, percentile, filters, timeTravel, notBefore], (_, v) => (typeof v === \"bigint\" ? `${v}n` : v));\n\n useEffect(() => {\n const controller = new AbortController();\n setState((previous) => ({ ...previous, loading: true, error: undefined }));\n collect(\n dataSource.execute(\n {\n sourceId,\n timeTravel,\n notBefore,\n query: {\n baseSql: sql,\n filters,\n aggregates: [{ function: AGGREGATE_FUNCTIONS[aggregate], column: column ?? \"\", alias: \"value\", percentile: aggregate === \"percentile\" ? (percentile ?? 0.9) : 0 }],\n },\n },\n { signal: controller.signal },\n ),\n )\n .then((result) => {\n if (controller.signal.aborted) return;\n const field = result.table.schema.fields.find((f) => f.name === \"value\");\n const raw = result.table.getChild(\"value\")?.get(0);\n setState({ value: field ? numericValue(raw, field.type) : null, loading: false, notes: dataNotes(result.header.notices) });\n })\n .catch((error: unknown) => {\n if (!controller.signal.aborted) setState({ error: messageOf(error), loading: false });\n });\n return () => controller.abort();\n }, [dataSource, key]); // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div className={[\"sf-a2-stat sf-metric\", props.className].filter(Boolean).join(\" \")} aria-busy={state.loading}>\n <span className=\"sf-a2-stat-label\">{label}</span>\n {state.error ? (\n <span className=\"sf-metric-error\" role=\"alert\" data-error={state.error}>\n {props.errorMessage ?? state.error}\n </span>\n ) : (\n <span className=\"sf-a2-stat-value\">{state.value === undefined ? text(\"metric.loading\") : state.value === null ? (props.emptyMessage ?? text(\"metric.none\")) : formatMetric(state.value, format, currency)}</span>\n )}\n <DataNotes notes={state.notes} />\n </div>\n );\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { type DataSource } from "@surfaces-ui/data";
2
+ import { type ChartAggregate, type ChartGrain } from "../chart/Chart.js";
3
+ import { type FilterInit } from "../data/useRowWindow.js";
4
+ export interface MeasureQuery {
5
+ sourceId: string;
6
+ sql: string;
7
+ column?: string;
8
+ aggregate: ChartAggregate;
9
+ filters?: FilterInit[];
10
+ notBefore?: string;
11
+ /** With `x` and `grain`, one value per time bucket in order; without, one value. */
12
+ x?: string;
13
+ grain?: ChartGrain;
14
+ /** Most recent buckets to keep. */
15
+ points?: number;
16
+ }
17
+ export interface MeasureState {
18
+ values?: (number | null)[];
19
+ error?: string;
20
+ loading: boolean;
21
+ /** What the view was not filtered by, for its readers (see `DataNotes`). */
22
+ notes?: string[];
23
+ }
24
+ /** Asks the engine for one summarised number, or one per time bucket. Nothing is worked out in the browser. */
25
+ export declare function useMeasure(dataSource: DataSource, query: MeasureQuery): MeasureState;
@@ -0,0 +1,44 @@
1
+ import { collect } from "@surfaces-ui/data";
2
+ import { dataNotes } from "../data/DataNotes.js";
3
+ import { useEffect, useState } from "react";
4
+ import { AGGREGATE_FUNCTIONS, TIME_GRAINS } from "../chart/Chart.js";
5
+ import { numericValue } from "../data/format.js";
6
+ import { messageOf } from "../data/useRowWindow.js";
7
+ import { SortDirection } from "@surfaces-ui/proto";
8
+ /** Asks the engine for one summarised number, or one per time bucket. Nothing is worked out in the browser. */
9
+ export function useMeasure(dataSource, query) {
10
+ const [state, setState] = useState({ loading: true });
11
+ const key = JSON.stringify(query, (_, v) => (typeof v === "bigint" ? `${v}n` : v));
12
+ useEffect(() => {
13
+ const controller = new AbortController();
14
+ setState((previous) => ({ ...previous, loading: true, error: undefined }));
15
+ const { sourceId, sql, column, aggregate, filters, notBefore, x, grain, points = 60 } = query;
16
+ const series = x !== undefined && grain !== undefined;
17
+ collect(dataSource.execute({
18
+ sourceId,
19
+ notBefore,
20
+ query: {
21
+ baseSql: sql,
22
+ filters,
23
+ aggregates: [{ function: AGGREGATE_FUNCTIONS[aggregate], column: column ?? "", alias: "value", percentile: aggregate === "percentile" ? 0.9 : 0 }],
24
+ // Newest first so the limit keeps the most recent buckets; put back in order below.
25
+ ...(series ? { buckets: [{ column: x, by: { case: "grain", value: TIME_GRAINS[grain] } }], sorts: [{ column: x, direction: SortDirection.DESC }], page: { limit: points } } : {}),
26
+ },
27
+ }, { signal: controller.signal }))
28
+ .then((result) => {
29
+ if (controller.signal.aborted)
30
+ return;
31
+ const column = result.table.getChild("value");
32
+ const field = result.table.schema.fields.find((f) => f.name === "value");
33
+ const values = Array.from({ length: result.table.numRows }, (_, i) => (field ? numericValue(column?.get(i), field.type) : null));
34
+ setState({ values: series ? values.reverse() : values, loading: false, notes: dataNotes(result.header.notices) });
35
+ })
36
+ .catch((error) => {
37
+ if (!controller.signal.aborted)
38
+ setState({ error: messageOf(error), loading: false });
39
+ });
40
+ return () => controller.abort();
41
+ }, [dataSource, key]); // eslint-disable-line react-hooks/exhaustive-deps
42
+ return state;
43
+ }
44
+ //# sourceMappingURL=useMeasure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMeasure.js","sourceRoot":"","sources":["../../src/metric/useMeasure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,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AC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACjI,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACxF,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,kDAAkD;IACzE,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { type DataSource, collect } from \"@surfaces-ui/data\";\nimport { dataNotes } from \"../data/DataNotes.js\";\nimport { useEffect, useState } from \"react\";\nimport { AGGREGATE_FUNCTIONS, type ChartAggregate, type ChartGrain, TIME_GRAINS } from \"../chart/Chart.js\";\nimport { numericValue } from \"../data/format.js\";\nimport { type FilterInit, messageOf } from \"../data/useRowWindow.js\";\nimport { SortDirection } from \"@surfaces-ui/proto\";\n\nexport interface MeasureQuery {\n sourceId: string;\n sql: string;\n column?: string;\n aggregate: ChartAggregate;\n filters?: FilterInit[];\n notBefore?: string;\n /** With `x` and `grain`, one value per time bucket in order; without, one value. */\n x?: string;\n grain?: ChartGrain;\n /** Most recent buckets to keep. */\n points?: number;\n}\n\nexport interface MeasureState {\n values?: (number | null)[];\n error?: string;\n loading: boolean;\n /** What the view was not filtered by, for its readers (see `DataNotes`). */\n notes?: string[];\n}\n\n/** Asks the engine for one summarised number, or one per time bucket. Nothing is worked out in the browser. */\nexport function useMeasure(dataSource: DataSource, query: MeasureQuery): MeasureState {\n const [state, setState] = useState<MeasureState>({ loading: true });\n const key = JSON.stringify(query, (_, v) => (typeof v === \"bigint\" ? `${v}n` : v));\n useEffect(() => {\n const controller = new AbortController();\n setState((previous) => ({ ...previous, loading: true, error: undefined }));\n const { sourceId, sql, column, aggregate, filters, notBefore, x, grain, points = 60 } = query;\n const series = x !== undefined && grain !== undefined;\n collect(\n dataSource.execute(\n {\n sourceId,\n notBefore,\n query: {\n baseSql: sql,\n filters,\n aggregates: [{ function: AGGREGATE_FUNCTIONS[aggregate], column: column ?? \"\", alias: \"value\", percentile: aggregate === \"percentile\" ? 0.9 : 0 }],\n // Newest first so the limit keeps the most recent buckets; put back in order below.\n ...(series ? { buckets: [{ column: x, by: { case: \"grain\" as const, value: TIME_GRAINS[grain] } }], sorts: [{ column: x, direction: SortDirection.DESC }], page: { limit: points } } : {}),\n },\n },\n { signal: controller.signal },\n ),\n )\n .then((result) => {\n if (controller.signal.aborted) return;\n const column = result.table.getChild(\"value\");\n const field = result.table.schema.fields.find((f) => f.name === \"value\");\n const values = Array.from({ length: result.table.numRows }, (_, i) => (field ? numericValue(column?.get(i), field.type) : null));\n setState({ values: series ? values.reverse() : values, loading: false, notes: dataNotes(result.header.notices) });\n })\n .catch((error: unknown) => {\n if (!controller.signal.aborted) setState({ error: messageOf(error), loading: false });\n });\n return () => controller.abort();\n }, [dataSource, key]); // eslint-disable-line react-hooks/exhaustive-deps\n return state;\n}\n"]}
@@ -0,0 +1,142 @@
1
+ import { type DataSource, type Discovery, type TypeFamily, typeFamily } from "@surfaces-ui/data";
2
+ import { type Column, type ForeignKey } from "@surfaces-ui/proto";
3
+ export interface ModelJoinKey {
4
+ leftColumn: string;
5
+ rightColumn: string;
6
+ }
7
+ /** Which rows a join keeps, read from its left table to its right: only rows that match, every left row, every right row, or every row of both. */
8
+ export type JoinKind = "inner" | "left" | "right" | "full";
9
+ export declare const JOIN_KINDS: JoinKind[];
10
+ /** A relationship between two tables on the diagram. */
11
+ export interface ModelJoin {
12
+ left: string;
13
+ right: string;
14
+ keys: ModelJoinKey[];
15
+ /** Which rows it keeps. Left out, an inner join: only rows that match. */
16
+ type?: JoinKind;
17
+ /** True when guessed from names and types rather than drawn or confirmed by a person. */
18
+ inferred?: boolean;
19
+ /** True when the backend reports it as a foreign key the table declares. */
20
+ declared?: boolean;
21
+ }
22
+ export interface DataModel {
23
+ tables: string[];
24
+ joins: ModelJoin[];
25
+ }
26
+ export interface ModelDiagramProps {
27
+ sourceId: string;
28
+ /** Tables to start with. Changing this list starts the diagram again. */
29
+ tables?: string[];
30
+ /** Joins to start with. */
31
+ joins?: ModelJoin[];
32
+ /** Called whenever tables or joins change, and when the query changes because the tables' columns have been read; `query` is what `modelSql` makes of them. */
33
+ onChange?(model: DataModel, query: ModelSql): void;
34
+ /**
35
+ * The first table's rows are the result's rows, as in a semantic model:
36
+ * the first table is marked as where the rows come from and can be
37
+ * changed, the rest are laid out as the detail they add, a new join keeps
38
+ * every row of the side nearer the first table, each join says whether it
39
+ * adds one row of detail or can repeat rows, and each column shows its
40
+ * name in the result.
41
+ */
42
+ rowsFrom?: boolean;
43
+ /** Result column names something uses (a model's fields). Others are dimmed. */
44
+ usedColumns?: string[];
45
+ /** Shows a "Use as query" button and is called with SQL that joins the tables. */
46
+ onUseSql?(sql: string, model: DataModel): void;
47
+ /** Add the joins the discovery backend finds between tables on the diagram, labelled "Inferred". Defaults to true. */
48
+ suggestJoins?: boolean;
49
+ /** Height of the canvas in px. Defaults to 420. */
50
+ height?: number;
51
+ dataSource?: DataSource;
52
+ /** Supplies suggested joins and certification marks. Defaults to the one from DiscoveryProvider; optional. */
53
+ discovery?: Discovery;
54
+ /** Accessible name. Defaults to "Data model". */
55
+ label?: string;
56
+ className?: string;
57
+ }
58
+ /** A join's identity, whichever way round it was drawn. */
59
+ export declare function joinId(join: ModelJoin): string;
60
+ /** The text of a join condition, e.g. `orders.customer_id = customers.customer_id`. */
61
+ export declare function joinText(join: ModelJoin): string;
62
+ /** Which rows a join of this kind keeps, in words, named from the join's left and right tables. */
63
+ export declare function kindText(join: Pick<ModelJoin, "left" | "right">, kind: JoinKind): string;
64
+ /** The same join drawn the other way round: tables, columns and the side it keeps all swapped, so it keeps the same rows. */
65
+ export declare function flipJoin(join: ModelJoin): ModelJoin;
66
+ /** A join as the query reads it from `from`: drawn with `from` on its left. */
67
+ export declare function joinFrom(join: ModelJoin, from: string): ModelJoin;
68
+ /** One column of a joined result: the table and column it comes from, and its name in the result. */
69
+ export interface OutputColumn {
70
+ table: string;
71
+ column: string;
72
+ name: string;
73
+ }
74
+ /**
75
+ * The names the joined tables' columns take in the result, in the order the
76
+ * query reads the tables: the first use of a name keeps it, and a name a
77
+ * later table repeats gets `_1`, `_2` and so on (`store_id_1`). The query
78
+ * writes these as aliases, so the names are the same on every engine.
79
+ */
80
+ export declare function outputColumns(tables: string[], columnsOf: (table: string) => string[]): OutputColumn[];
81
+ export interface ModelSql {
82
+ sql: string;
83
+ /** Tables no join reaches, left out of the query rather than cross-joined. */
84
+ unjoined: string[];
85
+ /** The tables in the order the query reads them, the first table first. */
86
+ order: string[];
87
+ /** The result's columns, when every table's columns were known. */
88
+ columns?: OutputColumn[];
89
+ }
90
+ /**
91
+ * SQL that joins the diagram's tables, starting from the first and following
92
+ * joins outwards, each with the join kind it was given (an inner join when
93
+ * none). Tables no join reaches are returned in `unjoined`, not cross-joined.
94
+ *
95
+ * With `columnsOf` knowing every table's columns and two tables sharing a
96
+ * column name, the query names each
97
+ * column, giving a name a later table repeats its own alias
98
+ * (`outputColumns`). Engines differ over `SELECT *` across tables that share
99
+ * a column name (DuckDB renames, Teradata and others refuse it inside a
100
+ * query), so the named form is the one that runs everywhere. Without the
101
+ * columns it falls back to `SELECT *`.
102
+ */
103
+ export declare function modelSql(model: DataModel, columnsOf?: (table: string) => string[] | undefined): ModelSql;
104
+ /**
105
+ * Whether each row of `from` finds at most one row of the other table, from
106
+ * what the tables declare: "one" when the other side's columns are its whole
107
+ * primary key or `from` declares them as a foreign key to it, "many" when the
108
+ * other table has a primary key the join does not use, "unknown" when it
109
+ * declares none (files usually do not): ask the engine with `mostRowsPerKey`.
110
+ */
111
+ export type JoinShape = "one" | "many" | "unknown";
112
+ export declare function joinShape(join: ModelJoin, from: string, columnsOf: (table: string) => Column[] | undefined, foreignKeysOf?: (table: string) => ForeignKey[] | undefined): JoinShape;
113
+ /** How far each table is from the first through joins: 0 for the first, 1 for those it joins, and so on. Tables no join reaches come after the rest. */
114
+ export declare function joinDepths(tables: string[], joins: ModelJoin[]): Map<string, number>;
115
+ export { type TypeFamily, typeFamily };
116
+ export type JoinCheck = {
117
+ ok: true;
118
+ } | {
119
+ ok: false;
120
+ reason: string;
121
+ };
122
+ /**
123
+ * Whether a join can work at all. It refuses a table joined to itself, a
124
+ * column the table does not have, keys that cannot be compared (nested or
125
+ * binary data) and keys of different kinds, such as a number against text.
126
+ * `columnsOf` returns undefined for a table whose columns are not known yet;
127
+ * such a table is given the benefit of the doubt.
128
+ */
129
+ export declare function checkJoin(join: ModelJoin, columnsOf: (table: string) => Column[] | undefined): JoinCheck;
130
+ /** True when `from` already reaches `to` through joins, so one more join between them closes a loop. */
131
+ export declare function connected(joins: ModelJoin[], from: string, to: string): boolean;
132
+ /**
133
+ * A relationship diagram of tables: each table is a card listing its
134
+ * columns, and lines connect the columns that join. Drag a card to arrange
135
+ * it, drag a column onto a column of another table to draw a join, and drop
136
+ * a table from ObjectBrowser to add it. Suggested joins are dashed and
137
+ * labelled "Inferred" until a person confirms them.
138
+ *
139
+ * Everything the canvas does is also available from the keyboard through
140
+ * the lists and the "Add join" form beneath it.
141
+ */
142
+ export declare function ModelDiagram(props: ModelDiagramProps): import("react").JSX.Element;