@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,91 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { defaultResizeStep, dragResize, keyResize } from "./resize.js";
4
+ /**
5
+ * A handle on the right, left or bottom edge of something, dragged to change its
6
+ * width or height: the one Arrange draws under a component and between a
7
+ * Grid's columns, for any app to place. A focusable `separator` with its
8
+ * value, least and most; dragged with pointer events so a mouse, a pen and a
9
+ * finger all work; moved by the arrow keys (Shift for bigger steps), Home and
10
+ * End; and put back by Enter or a double click. It holds no size of its own:
11
+ * the host keeps `value` and draws the change.
12
+ */
13
+ export function ResizeHandle(props) {
14
+ const { edge, value, min, max, snap, label } = props;
15
+ const bounds = { ...(min !== undefined ? { min } : {}), ...(max !== undefined ? { max } : {}), ...(snap !== undefined ? { snap } : {}) };
16
+ const latest = useRef(props);
17
+ latest.current = props;
18
+ const [dragging, setDragging] = useState(false);
19
+ // A drag in progress when the handle goes away is given up, back where it started, rather than left listening on the window.
20
+ const giveUp = useRef(undefined);
21
+ useEffect(() => () => giveUp.current?.(), []);
22
+ const from = (handle) => value ?? props.startFrom?.(handle) ?? min ?? 0;
23
+ const perUnit = (handle) => (typeof props.unitPixels === "function" ? props.unitPixels(handle) : (props.unitPixels ?? 1));
24
+ const onPointerDown = (event) => {
25
+ if (event.pointerType === "mouse" && event.button !== 0)
26
+ return;
27
+ event.preventDefault();
28
+ event.stopPropagation();
29
+ const handle = event.currentTarget;
30
+ const start = from(handle);
31
+ const unit = perUnit(handle);
32
+ const along = (e) => (edge === "bottom" ? e.clientY : edge === "left" ? -e.clientX : e.clientX);
33
+ const origin = along(event);
34
+ let now = start;
35
+ setDragging(true);
36
+ const finish = (committed, gone = false) => {
37
+ window.removeEventListener("pointermove", move);
38
+ window.removeEventListener("pointerup", up);
39
+ window.removeEventListener("pointercancel", cancel);
40
+ window.removeEventListener("keydown", key, true);
41
+ giveUp.current = undefined;
42
+ if (!gone)
43
+ setDragging(false);
44
+ if (!committed)
45
+ latest.current.onChange?.(start);
46
+ latest.current.onChangeEnd?.(committed ? now : start, { committed, via: "pointer" });
47
+ };
48
+ const move = (e) => {
49
+ e.preventDefault();
50
+ const next = dragResize(start, along(e) - origin, unit, bounds);
51
+ if (next === now)
52
+ return;
53
+ now = next;
54
+ latest.current.onChange?.(next);
55
+ };
56
+ const up = () => finish(true);
57
+ const cancel = () => finish(false);
58
+ const key = (e) => {
59
+ if (e.key !== "Escape")
60
+ return;
61
+ e.preventDefault();
62
+ e.stopPropagation();
63
+ finish(false);
64
+ };
65
+ giveUp.current = () => finish(false, true);
66
+ window.addEventListener("pointermove", move, { passive: false });
67
+ window.addEventListener("pointerup", up);
68
+ window.addEventListener("pointercancel", cancel);
69
+ window.addEventListener("keydown", key, true);
70
+ };
71
+ const onKeyDown = (event) => {
72
+ if (event.key === "Enter") {
73
+ if (!props.onReset)
74
+ return;
75
+ event.preventDefault();
76
+ props.onReset();
77
+ return;
78
+ }
79
+ const current = from(event.currentTarget);
80
+ const next = keyResize(event.key, current, edge, props.step ?? defaultResizeStep(bounds), bounds, event.shiftKey);
81
+ if (next === undefined)
82
+ return;
83
+ event.preventDefault();
84
+ if (next === current && value !== undefined)
85
+ return;
86
+ props.onChange?.(next);
87
+ props.onChangeEnd?.(next, { committed: true, via: "keyboard" });
88
+ };
89
+ return (_jsx("div", { className: ["sf-resize-handle", props.className].filter(Boolean).join(" "), "data-edge": edge, "data-always": props.always || undefined, "data-dragging": dragging || undefined, role: "separator", tabIndex: props.tabbable === false ? -1 : 0, "aria-orientation": edge === "bottom" ? "horizontal" : "vertical", "aria-label": label, "aria-valuenow": value === undefined ? undefined : Math.round(value * 100) / 100, "aria-valuemin": min, "aria-valuemax": max, "aria-valuetext": props.valueText, onPointerDown: onPointerDown, onKeyDown: onKeyDown, onDoubleClick: props.onReset ? () => props.onReset?.() : undefined }));
90
+ }
91
+ //# sourceMappingURL=ResizeHandle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResizeHandle.js","sourceRoot":"","sources":["../../src/controls/ResizeHandle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8D,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChH,OAAO,EAAsC,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAqC3G;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACrD,M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KAAK,mBACF,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,mBAC/D,GAAG,mBACH,GAAG,oBACF,KAAK,CAAC,SAAS,EAC/B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAClE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { type KeyboardEvent, type PointerEvent as ReactPointerEvent, useEffect, useRef, useState } from \"react\";\nimport { type ResizeBounds, type ResizeEdge, defaultResizeStep, dragResize, keyResize } from \"./resize.js\";\n\nexport interface ResizeHandleProps {\n /** Which edge of its parent it sits on: \"right\" sizes a width (dragged left and right), \"left\" a width that grows leftwards (a panel docked on the right), \"bottom\" a height (dragged up and down). The parent must be positioned. */\n edge: ResizeEdge;\n /** The size it stands for, in any unit (pixels, a share, a percentage). Undefined when no size is set yet: a drag then starts from `startFrom`. */\n value: number | undefined;\n min?: number;\n max?: number;\n /** Values land on multiples of this while dragging and by key (10 rounds to ten pixels). */\n snap?: number;\n /** How far an arrow key moves it; Shift moves five steps. Defaults to a twentieth of the range, or 10. */\n step?: number;\n /** How many pixels on screen one unit of value is: 1 for pixels, a container's width for a share of it. Read when a drag starts. Defaults to 1. */\n unitPixels?: number | ((handle: HTMLElement) => number);\n /** Where a drag or key starts when `value` is undefined, such as the height drawn now. */\n startFrom?(handle: HTMLElement): number;\n /** Each new value while it is dragged, and after each key. Draw the new size here. */\n onChange?(value: number): void;\n /** When a drag is released or cancelled (Escape, a lost pointer, or the handle going away mid-drag), and after each key: where to keep the size. `committed` is false for a cancelled drag, whose value is where it started. */\n onChangeEnd?(value: number, end: { committed: boolean; via: \"pointer\" | \"keyboard\" }): void;\n /** Enter or a double click: back to the size it had before anyone changed it. Without it, Enter does nothing. */\n onReset?(): void;\n /** What it resizes, for assistive technology: \"Resize the map and the list\". */\n label: string;\n /** The value in words, when a number alone does not say it (\"40% and 60%\"). */\n valueText?: string;\n /** Shown all the time, rather than when its parent is pointed at or it has focus. */\n always?: boolean;\n /**\n * Whether Tab stops on it (default true). False leaves it to the pointer and to focus given in code: an editor with\n * a handle on every element keeps Tab to one stop each, and offers the handles of the one selected.\n */\n tabbable?: boolean;\n className?: string;\n}\n\n/**\n * A handle on the right, left or bottom edge of something, dragged to change its\n * width or height: the one Arrange draws under a component and between a\n * Grid's columns, for any app to place. A focusable `separator` with its\n * value, least and most; dragged with pointer events so a mouse, a pen and a\n * finger all work; moved by the arrow keys (Shift for bigger steps), Home and\n * End; and put back by Enter or a double click. It holds no size of its own:\n * the host keeps `value` and draws the change.\n */\nexport function ResizeHandle(props: ResizeHandleProps) {\n const { edge, value, min, max, snap, label } = props;\n const bounds: ResizeBounds = { ...(min !== undefined ? { min } : {}), ...(max !== undefined ? { max } : {}), ...(snap !== undefined ? { snap } : {}) };\n const latest = useRef(props);\n latest.current = props;\n const [dragging, setDragging] = useState(false);\n // A drag in progress when the handle goes away is given up, back where it started, rather than left listening on the window.\n const giveUp = useRef<(() => void) | undefined>(undefined);\n useEffect(() => () => giveUp.current?.(), []);\n\n const from = (handle: HTMLElement) => value ?? props.startFrom?.(handle) ?? min ?? 0;\n const perUnit = (handle: HTMLElement) => (typeof props.unitPixels === \"function\" ? props.unitPixels(handle) : (props.unitPixels ?? 1));\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.pointerType === \"mouse\" && event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n const handle = event.currentTarget;\n const start = from(handle);\n const unit = perUnit(handle);\n const along = (e: { clientX: number; clientY: number }) => (edge === \"bottom\" ? e.clientY : edge === \"left\" ? -e.clientX : e.clientX);\n const origin = along(event);\n let now = start;\n setDragging(true);\n const finish = (committed: boolean, gone = false) => {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", up);\n window.removeEventListener(\"pointercancel\", cancel);\n window.removeEventListener(\"keydown\", key, true);\n giveUp.current = undefined;\n if (!gone) setDragging(false);\n if (!committed) latest.current.onChange?.(start);\n latest.current.onChangeEnd?.(committed ? now : start, { committed, via: \"pointer\" });\n };\n const move = (e: PointerEvent) => {\n e.preventDefault();\n const next = dragResize(start, along(e) - origin, unit, bounds);\n if (next === now) return;\n now = next;\n latest.current.onChange?.(next);\n };\n const up = () => finish(true);\n const cancel = () => finish(false);\n const key = (e: globalThis.KeyboardEvent) => {\n if (e.key !== \"Escape\") return;\n e.preventDefault();\n e.stopPropagation();\n finish(false);\n };\n giveUp.current = () => finish(false, true);\n window.addEventListener(\"pointermove\", move, { passive: false });\n window.addEventListener(\"pointerup\", up);\n window.addEventListener(\"pointercancel\", cancel);\n window.addEventListener(\"keydown\", key, true);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n if (!props.onReset) return;\n event.preventDefault();\n props.onReset();\n return;\n }\n const current = from(event.currentTarget);\n const next = keyResize(event.key, current, edge, props.step ?? defaultResizeStep(bounds), bounds, event.shiftKey);\n if (next === undefined) return;\n event.preventDefault();\n if (next === current && value !== undefined) return;\n props.onChange?.(next);\n props.onChangeEnd?.(next, { committed: true, via: \"keyboard\" });\n };\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: a focusable separator is the ARIA pattern for a resize handle; <hr> cannot be focused or dragged.\n <div\n className={[\"sf-resize-handle\", props.className].filter(Boolean).join(\" \")}\n data-edge={edge}\n data-always={props.always || undefined}\n data-dragging={dragging || undefined}\n role=\"separator\"\n tabIndex={props.tabbable === false ? -1 : 0}\n // A handle on a right or left edge is a line between things side by side, so the separator stands upright.\n aria-orientation={edge === \"bottom\" ? \"horizontal\" : \"vertical\"}\n aria-label={label}\n aria-valuenow={value === undefined ? undefined : Math.round(value * 100) / 100}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuetext={props.valueText}\n onPointerDown={onPointerDown}\n onKeyDown={onKeyDown}\n onDoubleClick={props.onReset ? () => props.onReset?.() : undefined}\n />\n );\n}\n"]}
@@ -0,0 +1,27 @@
1
+ /** One choice of a `SegmentedControl`. */
2
+ export interface SegmentedOption<T extends string = string> {
3
+ value: T;
4
+ label: string;
5
+ /** Shown greyed and still reachable, for a choice that makes no sense right now. */
6
+ disabled?: boolean;
7
+ }
8
+ export interface SegmentedControlProps<T extends string = string> {
9
+ /** What is being chosen, for assistive technology: "Mode", "Preview mode". */
10
+ label: string;
11
+ /** The choices, in order. Two to eight; they share the width equally and one thumb slides between them. */
12
+ options: readonly SegmentedOption<T>[];
13
+ /** The chosen option's value. */
14
+ value: T;
15
+ onChange(value: T): void;
16
+ /** "content" (the default) is as wide as its options need; "fill" takes its parent's width. */
17
+ fit?: "content" | "fill";
18
+ /** The radio group's name, when a form reads it. Made up otherwise. */
19
+ name?: string;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * A few equal choices of which exactly one holds, as one bar: build or view, chart or table, light or dark. A radio
24
+ * group, so one tab stop with the arrow keys moving the choice; the chosen segment is a thumb that slides between
25
+ * them. Use it for switching what is shown in place; for actions, use buttons.
26
+ */
27
+ export declare function SegmentedControl<T extends string = string>(props: SegmentedControlProps<T>): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ /**
4
+ * A few equal choices of which exactly one holds, as one bar: build or view, chart or table, light or dark. A radio
5
+ * group, so one tab stop with the arrow keys moving the choice; the chosen segment is a thumb that slides between
6
+ * them. Use it for switching what is shown in place; for actions, use buttons.
7
+ */
8
+ export function SegmentedControl(props) {
9
+ const { label, options, value, onChange, fit = "content", className } = props;
10
+ const made = useId();
11
+ const name = props.name ?? made;
12
+ return (_jsx("div", { className: ["sf-segmented", "sf-segmented-control", className].filter(Boolean).join(" "), "data-fit": fit, role: "radiogroup", "aria-label": label, children: options.map((option) => (_jsxs("label", { className: "sf-segment", "data-checked": option.value === value || undefined, "data-disabled": option.disabled || undefined, children: [_jsx("input", { type: "radio", name: name, value: option.value, checked: option.value === value, "aria-disabled": option.disabled || undefined, onChange: () => {
13
+ if (!option.disabled)
14
+ onChange(option.value);
15
+ } }), option.label] }, option.value))) }));
16
+ }
17
+ //# sourceMappingURL=SegmentedControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentedControl.js","sourceRoot":"","sources":["../../src/controls/SegmentedControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAyB9B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAA4B,KAA+B;IACzF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC9E,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;IACrB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC;IAChC,OAAO,CACL,cAAK,SAAS,EAAE,CAAC,cAAc,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,cAAY,GAAG,EAAE,IAAI,EAAC,YAAY,gBAAa,KAAK,YAC9I,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,iBAA0B,SAAS,EAAC,YAAY,kBAAe,MAAM,CAAC,KAAK,KAAK,KAAK,IAAI,SAAS,mBAAiB,MAAM,CAAC,QAAQ,IAAI,SAAS,aAC7I,gBACE,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,OAAO,EAAE,MAAM,CAAC,KAAK,KAAK,KAAK,mBAChB,MAAM,CAAC,QAAQ,IAAI,SAAS,EAC3C,QAAQ,EAAE,GAAG,EAAE;wBACb,IAAI,CAAC,MAAM,CAAC,QAAQ;4BAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAC/C,CAAC,GACD,EACD,MAAM,CAAC,KAAK,KAXH,MAAM,CAAC,KAAK,CAYhB,CACT,CAAC,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useId } from \"react\";\n\n/** One choice of a `SegmentedControl`. */\nexport interface SegmentedOption<T extends string = string> {\n value: T;\n label: string;\n /** Shown greyed and still reachable, for a choice that makes no sense right now. */\n disabled?: boolean;\n}\n\nexport interface SegmentedControlProps<T extends string = string> {\n /** What is being chosen, for assistive technology: \"Mode\", \"Preview mode\". */\n label: string;\n /** The choices, in order. Two to eight; they share the width equally and one thumb slides between them. */\n options: readonly SegmentedOption<T>[];\n /** The chosen option's value. */\n value: T;\n onChange(value: T): void;\n /** \"content\" (the default) is as wide as its options need; \"fill\" takes its parent's width. */\n fit?: \"content\" | \"fill\";\n /** The radio group's name, when a form reads it. Made up otherwise. */\n name?: string;\n className?: string;\n}\n\n/**\n * A few equal choices of which exactly one holds, as one bar: build or view, chart or table, light or dark. A radio\n * group, so one tab stop with the arrow keys moving the choice; the chosen segment is a thumb that slides between\n * them. Use it for switching what is shown in place; for actions, use buttons.\n */\nexport function SegmentedControl<T extends string = string>(props: SegmentedControlProps<T>) {\n const { label, options, value, onChange, fit = \"content\", className } = props;\n const made = useId();\n const name = props.name ?? made;\n return (\n <div className={[\"sf-segmented\", \"sf-segmented-control\", className].filter(Boolean).join(\" \")} data-fit={fit} role=\"radiogroup\" aria-label={label}>\n {options.map((option) => (\n <label key={option.value} className=\"sf-segment\" data-checked={option.value === value || undefined} data-disabled={option.disabled || undefined}>\n <input\n type=\"radio\"\n name={name}\n value={option.value}\n checked={option.value === value}\n aria-disabled={option.disabled || undefined}\n onChange={() => {\n if (!option.disabled) onChange(option.value);\n }}\n />\n {option.label}\n </label>\n ))}\n </div>\n );\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /** What a `StatusBadge` says about the thing it marks. */
2
+ export type StatusTone = "neutral" | "info" | "success" | "warning" | "danger";
3
+ export interface StatusBadgeProps {
4
+ /** The status in a word or two: "On", "Turned off", "Admin". The words carry the meaning; the tone only backs them up. */
5
+ label: string;
6
+ /** "neutral" (the default), "info", "success", "warning" or "danger". */
7
+ tone?: StatusTone;
8
+ /** A sentence more, shown on hover and read after the label: "Turned off by Ana on 3 May". */
9
+ description?: string;
10
+ className?: string;
11
+ }
12
+ /**
13
+ * A short status beside the thing it describes: an account on or turned off, a job running or failed. Marked by its
14
+ * words and a shape as well as a colour, so it reads the same without colour. For data that is certified or
15
+ * deprecated use `CertificationBadge`.
16
+ */
17
+ export declare function StatusBadge({ label, tone, description, className }: StatusBadgeProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * A short status beside the thing it describes: an account on or turned off, a job running or failed. Marked by its
4
+ * words and a shape as well as a colour, so it reads the same without colour. For data that is certified or
5
+ * deprecated use `CertificationBadge`.
6
+ */
7
+ export function StatusBadge({ label, tone = "neutral", description, className }) {
8
+ return (_jsxs("span", { className: ["sf-status", className].filter(Boolean).join(" "), "data-tone": tone, title: description, children: [_jsx("span", { className: "sf-status-mark", "aria-hidden": "true" }), label, description && _jsxs("span", { className: "sf-visually-hidden", children: [": ", description] })] }));
9
+ }
10
+ //# sourceMappingURL=StatusBadge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusBadge.js","sourceRoot":"","sources":["../../src/controls/StatusBadge.tsx"],"names":[],"mappings":";AAaA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS,EAAE,WAAW,EAAE,SAAS,EAAoB;IAC/F,OAAO,CACL,gBAAM,SAAS,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,eAAa,IAAI,EAAE,KAAK,EAAE,WAAW,aACtG,eAAM,SAAS,EAAC,gBAAgB,iBAAa,MAAM,GAAG,EACrD,KAAK,EACL,WAAW,IAAI,gBAAM,SAAS,EAAC,oBAAoB,mBAAI,WAAW,IAAQ,IACtE,CACR,CAAC;AACJ,CAAC","sourcesContent":["/** What a `StatusBadge` says about the thing it marks. */\nexport type StatusTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface StatusBadgeProps {\n /** The status in a word or two: \"On\", \"Turned off\", \"Admin\". The words carry the meaning; the tone only backs them up. */\n label: string;\n /** \"neutral\" (the default), \"info\", \"success\", \"warning\" or \"danger\". */\n tone?: StatusTone;\n /** A sentence more, shown on hover and read after the label: \"Turned off by Ana on 3 May\". */\n description?: string;\n className?: string;\n}\n\n/**\n * A short status beside the thing it describes: an account on or turned off, a job running or failed. Marked by its\n * words and a shape as well as a colour, so it reads the same without colour. For data that is certified or\n * deprecated use `CertificationBadge`.\n */\nexport function StatusBadge({ label, tone = \"neutral\", description, className }: StatusBadgeProps) {\n return (\n <span className={[\"sf-status\", className].filter(Boolean).join(\" \")} data-tone={tone} title={description}>\n <span className=\"sf-status-mark\" aria-hidden=\"true\" />\n {label}\n {description && <span className=\"sf-visually-hidden\">: {description}</span>}\n </span>\n );\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Something a person did in a component, told to whoever keeps an agent's
3
+ * context: which view they added, which field they changed, what they
4
+ * filtered by, what they picked. It is a note, not a request: it starts no
5
+ * turn and asks for nothing. Every component that a person can change takes
6
+ * `onContext` and sends these, so an agent knows what happened between its
7
+ * turns and not only where things ended up.
8
+ */
9
+ export interface ContextNote {
10
+ /** What kind of thing, as a dotted word: "view.added", "field.changed", "filter.changed", "point.selected". */
11
+ kind: string;
12
+ /** The same in a sentence, as the component told the person. */
13
+ summary: string;
14
+ /** What it was about, as plain data: a pill, a tile's shelves, a filter list. Names and settings, and a value only where the person chose it. */
15
+ subject?: Record<string, unknown>;
16
+ }
17
+ export type OnContext = (note: ContextNote) => void;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/controls/context.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Something a person did in a component, told to whoever keeps an agent's\n * context: which view they added, which field they changed, what they\n * filtered by, what they picked. It is a note, not a request: it starts no\n * turn and asks for nothing. Every component that a person can change takes\n * `onContext` and sends these, so an agent knows what happened between its\n * turns and not only where things ended up.\n */\nexport interface ContextNote {\n /** What kind of thing, as a dotted word: \"view.added\", \"field.changed\", \"filter.changed\", \"point.selected\". */\n kind: string;\n /** The same in a sentence, as the component told the person. */\n summary: string;\n /** What it was about, as plain data: a pill, a tile's shelves, a filter list. Names and settings, and a value only where the person chose it. */\n subject?: Record<string, unknown>;\n}\n\nexport type OnContext = (note: ContextNote) => void;\n"]}
@@ -0,0 +1,43 @@
1
+ /** A box on screen, in CSS pixels from the window's top left. */
2
+ export interface Box {
3
+ left: number;
4
+ top: number;
5
+ right: number;
6
+ bottom: number;
7
+ }
8
+ export interface PlacementInput {
9
+ /** Where the button that opens the panel is. */
10
+ trigger: Box;
11
+ /** The panel's own size (its border box, before any height is taken away). */
12
+ panel: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ /** The window's size, without its scroll bars. */
17
+ viewport: {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ /** The gap between the panel and the button, which is also the least room kept between the panel and the window's edge. */
22
+ gap: number;
23
+ /** Line the panel up with the button's start edge or its end edge. */
24
+ align: "start" | "end";
25
+ /** Right to left, where the start edge is the right one. */
26
+ rtl?: boolean;
27
+ }
28
+ export interface Placement {
29
+ /** The panel's left edge. */
30
+ left: number;
31
+ /** The panel's top edge. */
32
+ top: number;
33
+ /** The most height it has room for; it scrolls inside beyond that. */
34
+ maxHeight: number;
35
+ /** Below the button, or above it when there was more room there and not enough below. */
36
+ side: "below" | "above";
37
+ }
38
+ /**
39
+ * Where a panel opened from a button goes: below it, lined up with its start or end edge, moved along so it stays
40
+ * inside the window, and above the button only when it does not fit below and there is more room above. On a phone
41
+ * the panel may be as wide as the window less a gap each side, never wider.
42
+ */
43
+ export declare function placePanel({ trigger, panel, viewport, gap, align, rtl }: PlacementInput): Placement;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Where a panel opened from a button goes: below it, lined up with its start or end edge, moved along so it stays
3
+ * inside the window, and above the button only when it does not fit below and there is more room above. On a phone
4
+ * the panel may be as wide as the window less a gap each side, never wider.
5
+ */
6
+ export function placePanel({ trigger, panel, viewport, gap, align, rtl = false }) {
7
+ const leftEdge = (align === "start") !== rtl;
8
+ const wanted = leftEdge ? trigger.left : trigger.right - panel.width;
9
+ const most = viewport.width - gap - panel.width;
10
+ const left = Math.max(gap, Math.min(wanted, most));
11
+ const below = viewport.height - trigger.bottom - 2 * gap;
12
+ const above = trigger.top - 2 * gap;
13
+ const side = panel.height <= below || below >= above ? "below" : "above";
14
+ const room = Math.max(0, side === "below" ? below : above);
15
+ const height = Math.min(panel.height, room);
16
+ const top = side === "below" ? trigger.bottom + gap : trigger.top - gap - height;
17
+ return { left, top, maxHeight: room, side };
18
+ }
19
+ //# sourceMappingURL=placement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/controls/placement.ts"],"names":[],"mappings":"AAkCA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,EAAkB;IAC9F,MAAM,QAAQ,GAAG,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,GAAG,CAAC;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACrE,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEnD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;IACjF,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/** A box on screen, in CSS pixels from the window's top left. */\nexport interface Box {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nexport interface PlacementInput {\n /** Where the button that opens the panel is. */\n trigger: Box;\n /** The panel's own size (its border box, before any height is taken away). */\n panel: { width: number; height: number };\n /** The window's size, without its scroll bars. */\n viewport: { width: number; height: number };\n /** The gap between the panel and the button, which is also the least room kept between the panel and the window's edge. */\n gap: number;\n /** Line the panel up with the button's start edge or its end edge. */\n align: \"start\" | \"end\";\n /** Right to left, where the start edge is the right one. */\n rtl?: boolean;\n}\n\nexport interface Placement {\n /** The panel's left edge. */\n left: number;\n /** The panel's top edge. */\n top: number;\n /** The most height it has room for; it scrolls inside beyond that. */\n maxHeight: number;\n /** Below the button, or above it when there was more room there and not enough below. */\n side: \"below\" | \"above\";\n}\n\n/**\n * Where a panel opened from a button goes: below it, lined up with its start or end edge, moved along so it stays\n * inside the window, and above the button only when it does not fit below and there is more room above. On a phone\n * the panel may be as wide as the window less a gap each side, never wider.\n */\nexport function placePanel({ trigger, panel, viewport, gap, align, rtl = false }: PlacementInput): Placement {\n const leftEdge = (align === \"start\") !== rtl;\n const wanted = leftEdge ? trigger.left : trigger.right - panel.width;\n const most = viewport.width - gap - panel.width;\n const left = Math.max(gap, Math.min(wanted, most));\n\n const below = viewport.height - trigger.bottom - 2 * gap;\n const above = trigger.top - 2 * gap;\n const side = panel.height <= below || below >= above ? \"below\" : \"above\";\n const room = Math.max(0, side === \"below\" ? below : above);\n const height = Math.min(panel.height, room);\n const top = side === \"below\" ? trigger.bottom + gap : trigger.top - gap - height;\n return { left, top, maxHeight: room, side };\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /** Which edge of what it sizes a handle sits on: a right or left edge sizes a width, a bottom edge a height. */
2
+ export type ResizeEdge = "right" | "left" | "bottom";
3
+ /** Bounds and steps for a resize handle's value. */
4
+ export interface ResizeBounds {
5
+ min?: number;
6
+ max?: number;
7
+ /** Values land on multiples of this (10 rounds to ten pixels). None by default. */
8
+ snap?: number;
9
+ }
10
+ /** A value kept within `min` and `max`, and on a multiple of `snap` that is still within them. */
11
+ export declare function clampResize(value: number, { min, max, snap }: ResizeBounds): number;
12
+ /** The value after a drag of `pixels` along the handle's axis, from `start`, where one unit of value is `unitPixels` on screen. */
13
+ export declare function dragResize(start: number, pixels: number, unitPixels: number, bounds: ResizeBounds): number;
14
+ /**
15
+ * The value a key gives, or undefined for a key the handle does not take. A
16
+ * handle on a right edge moves with Left and Right, one on a bottom edge with
17
+ * Up and Down; one on a left edge (a panel docked on the right) grows with
18
+ * Left, the way its edge moves. Shift takes five steps at once; Home and End
19
+ * go to `min` and `max` where there are some.
20
+ */
21
+ export declare function keyResize(key: string, value: number, edge: ResizeEdge, step: number, bounds: ResizeBounds, shift?: boolean): number | undefined;
22
+ /** A step for the arrow keys when none is given: a twentieth of the range, or ten without one. */
23
+ export declare function defaultResizeStep({ min, max }: ResizeBounds): number;
@@ -0,0 +1,49 @@
1
+ /*
2
+ * The arithmetic of a resize handle, kept apart from the component so it can
3
+ * be tested without a pointer or a layout: where a value lands for a drag of
4
+ * so many pixels, and for each key.
5
+ */
6
+ /** A value kept within `min` and `max`, and on a multiple of `snap` that is still within them. */
7
+ export function clampResize(value, { min, max, snap }) {
8
+ let next = Number.isFinite(value) ? value : (min ?? 0);
9
+ if (snap && snap > 0)
10
+ next = Math.round(next / snap) * snap;
11
+ if (min !== undefined && next < min)
12
+ next = snap && snap > 0 ? Math.ceil(min / snap) * snap : min;
13
+ if (max !== undefined && next > max)
14
+ next = snap && snap > 0 ? Math.floor(max / snap) * snap : max;
15
+ // A snap that leaves no multiple between the bounds gives the bound itself.
16
+ if (min !== undefined && next < min)
17
+ next = min;
18
+ return next;
19
+ }
20
+ /** The value after a drag of `pixels` along the handle's axis, from `start`, where one unit of value is `unitPixels` on screen. */
21
+ export function dragResize(start, pixels, unitPixels, bounds) {
22
+ const per = unitPixels > 0 && Number.isFinite(unitPixels) ? unitPixels : 1;
23
+ return clampResize(start + pixels / per, bounds);
24
+ }
25
+ /**
26
+ * The value a key gives, or undefined for a key the handle does not take. A
27
+ * handle on a right edge moves with Left and Right, one on a bottom edge with
28
+ * Up and Down; one on a left edge (a panel docked on the right) grows with
29
+ * Left, the way its edge moves. Shift takes five steps at once; Home and End
30
+ * go to `min` and `max` where there are some.
31
+ */
32
+ export function keyResize(key, value, edge, step, bounds, shift = false) {
33
+ const by = step * (shift ? 5 : 1);
34
+ const [less, more] = edge === "right" ? ["ArrowLeft", "ArrowRight"] : edge === "left" ? ["ArrowRight", "ArrowLeft"] : ["ArrowUp", "ArrowDown"];
35
+ if (key === less)
36
+ return clampResize(value - by, bounds);
37
+ if (key === more)
38
+ return clampResize(value + by, bounds);
39
+ if (key === "Home" && bounds.min !== undefined)
40
+ return clampResize(bounds.min, bounds);
41
+ if (key === "End" && bounds.max !== undefined)
42
+ return clampResize(bounds.max, bounds);
43
+ return undefined;
44
+ }
45
+ /** A step for the arrow keys when none is given: a twentieth of the range, or ten without one. */
46
+ export function defaultResizeStep({ min, max }) {
47
+ return min !== undefined && max !== undefined && max > min ? (max - min) / 20 : 10;
48
+ }
49
+ //# sourceMappingURL=resize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resize.js","sourceRoot":"","sources":["../../src/controls/resize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,kGAAkG;AAClG,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAgB;IACzE,IAAI,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5D,IAAI,GAAG,KAAK,SAAS,IAAI,IAAI,GAAG,GAAG;QAAE,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAA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,EAAE,MAAM,CAAC,CAAC;IACzD,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,WAAW,CAAC,KAAK,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IACzD,IAAI,GAAG,KAAK,MAAM,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACvF,IAAI,GAAG,KAAK,KAAK,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAgB;IAC1D,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACrF,CAAC","sourcesContent":["/*\n * The arithmetic of a resize handle, kept apart from the component so it can\n * be tested without a pointer or a layout: where a value lands for a drag of\n * so many pixels, and for each key.\n */\n\n/** Which edge of what it sizes a handle sits on: a right or left edge sizes a width, a bottom edge a height. */\nexport type ResizeEdge = \"right\" | \"left\" | \"bottom\";\n\n/** Bounds and steps for a resize handle's value. */\nexport interface ResizeBounds {\n min?: number;\n max?: number;\n /** Values land on multiples of this (10 rounds to ten pixels). None by default. */\n snap?: number;\n}\n\n/** A value kept within `min` and `max`, and on a multiple of `snap` that is still within them. */\nexport function clampResize(value: number, { min, max, snap }: ResizeBounds): number {\n let next = Number.isFinite(value) ? value : (min ?? 0);\n if (snap && snap > 0) next = Math.round(next / snap) * snap;\n if (min !== undefined && next < min) next = snap && snap > 0 ? Math.ceil(min / snap) * snap : min;\n if (max !== undefined && next > max) next = snap && snap > 0 ? Math.floor(max / snap) * snap : max;\n // A snap that leaves no multiple between the bounds gives the bound itself.\n if (min !== undefined && next < min) next = min;\n return next;\n}\n\n/** The value after a drag of `pixels` along the handle's axis, from `start`, where one unit of value is `unitPixels` on screen. */\nexport function dragResize(start: number, pixels: number, unitPixels: number, bounds: ResizeBounds): number {\n const per = unitPixels > 0 && Number.isFinite(unitPixels) ? unitPixels : 1;\n return clampResize(start + pixels / per, bounds);\n}\n\n/**\n * The value a key gives, or undefined for a key the handle does not take. A\n * handle on a right edge moves with Left and Right, one on a bottom edge with\n * Up and Down; one on a left edge (a panel docked on the right) grows with\n * Left, the way its edge moves. Shift takes five steps at once; Home and End\n * go to `min` and `max` where there are some.\n */\nexport function keyResize(key: string, value: number, edge: ResizeEdge, step: number, bounds: ResizeBounds, shift = false): number | undefined {\n const by = step * (shift ? 5 : 1);\n const [less, more] = edge === \"right\" ? [\"ArrowLeft\", \"ArrowRight\"] : edge === \"left\" ? [\"ArrowRight\", \"ArrowLeft\"] : [\"ArrowUp\", \"ArrowDown\"];\n if (key === less) return clampResize(value - by, bounds);\n if (key === more) return clampResize(value + by, bounds);\n if (key === \"Home\" && bounds.min !== undefined) return clampResize(bounds.min, bounds);\n if (key === \"End\" && bounds.max !== undefined) return clampResize(bounds.max, bounds);\n return undefined;\n}\n\n/** A step for the arrow keys when none is given: a twentieth of the range, or ten without one. */\nexport function defaultResizeStep({ min, max }: ResizeBounds): number {\n return min !== undefined && max !== undefined && max > min ? (max - min) / 20 : 10;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ /** The notice messages from a result header that are for the people reading the view. */
2
+ export declare function dataNotes(notices: readonly {
3
+ code: string;
4
+ message: string;
5
+ }[] | undefined): string[];
6
+ /**
7
+ * Says under a view what it was not filtered by, in words: a page-wide filter
8
+ * on a column the view's rows lack is left out by the engine, and the view is
9
+ * drawn without it rather than failing.
10
+ */
11
+ export declare function DataNotes({ notes }: {
12
+ notes: readonly string[] | undefined;
13
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** Notices a view's readers should see: a filter it could not take, because its rows lack the column. */
3
+ const SHOWN = new Set(["FILTER_COLUMN_MISSING"]);
4
+ /** The notice messages from a result header that are for the people reading the view. */
5
+ export function dataNotes(notices) {
6
+ return [...new Set((notices ?? []).filter((n) => SHOWN.has(n.code)).map((n) => n.message))];
7
+ }
8
+ /**
9
+ * Says under a view what it was not filtered by, in words: a page-wide filter
10
+ * on a column the view's rows lack is left out by the engine, and the view is
11
+ * drawn without it rather than failing.
12
+ */
13
+ export function DataNotes({ notes }) {
14
+ if (!notes || notes.length === 0)
15
+ return null;
16
+ return (_jsx("span", { className: "sf-data-note", role: "note", children: notes.join(" ") }));
17
+ }
18
+ //# sourceMappingURL=DataNotes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataNotes.js","sourceRoot":"","sources":["../../src/data/DataNotes.tsx"],"names":[],"mappings":";AAAA,yGAAyG;AACzG,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAEjD,yFAAyF;AACzF,MAAM,UAAU,SAAS,CAAC,OAAiE;IACzF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,KAAK,EAA4C;IAC3E,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,CACL,eAAM,SAAS,EAAC,cAAc,EAAC,IAAI,EAAC,MAAM,YACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GACX,CACR,CAAC;AACJ,CAAC","sourcesContent":["/** Notices a view's readers should see: a filter it could not take, because its rows lack the column. */\nconst SHOWN = new Set([\"FILTER_COLUMN_MISSING\"]);\n\n/** The notice messages from a result header that are for the people reading the view. */\nexport function dataNotes(notices: readonly { code: string; message: string }[] | undefined): string[] {\n return [...new Set((notices ?? []).filter((n) => SHOWN.has(n.code)).map((n) => n.message))];\n}\n\n/**\n * Says under a view what it was not filtered by, in words: a page-wide filter\n * on a column the view's rows lack is left out by the engine, and the view is\n * drawn without it rather than failing.\n */\nexport function DataNotes({ notes }: { notes: readonly string[] | undefined }) {\n if (!notes || notes.length === 0) return null;\n return (\n <span className=\"sf-data-note\" role=\"note\">\n {notes.join(\" \")}\n </span>\n );\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { DataSource } from "@surfaces-ui/data";
2
+ import { type ReactNode } from "react";
3
+ export interface DataSourceProviderProps {
4
+ /** Any implementation: a Connect client, `memoryDataSource`, or your own. */
5
+ dataSource: DataSource;
6
+ children: ReactNode;
7
+ }
8
+ /** Makes a DataSource available to every data component below it. */
9
+ export declare function DataSourceProvider({ dataSource, children }: DataSourceProviderProps): import("react").JSX.Element;
10
+ /** The DataSource from the nearest provider, or the one passed as a prop. */
11
+ export declare function useDataSource(override?: DataSource): DataSource;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DATA_SOURCE_TRACE } from "@surfaces-ui/trace";
3
+ import { useProvided, useTraced } from "@surfaces-ui/trace/react";
4
+ import { createContext, useContext } from "react";
5
+ const DataSourceContext = createContext(undefined);
6
+ /** Makes a DataSource available to every data component below it. */
7
+ export function DataSourceProvider({ dataSource, children }) {
8
+ // With a recorder above (dev tools), it is told which backend the page uses. Nothing happens without one.
9
+ useProvided("dataSource", dataSource);
10
+ return _jsx(DataSourceContext.Provider, { value: dataSource, children: children });
11
+ }
12
+ /** The DataSource from the nearest provider, or the one passed as a prop. */
13
+ export function useDataSource(override) {
14
+ const fromContext = useContext(DataSourceContext);
15
+ // Traced, as a child of the component asking, when a recorder is above; the backend itself otherwise.
16
+ const dataSource = useTraced("DataSource", override ?? fromContext, DATA_SOURCE_TRACE);
17
+ if (!dataSource)
18
+ throw new Error("No DataSource: wrap the component in <DataSourceProvider> or pass dataSource.");
19
+ return dataSource;
20
+ }
21
+ //# sourceMappingURL=DataSourceProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataSourceProvider.js","sourceRoot":"","sources":["../../src/data/DataSourceProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAkB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,iBAAiB,GAAG,aAAa,CAAyB,SAAS,CAAC,CAAC;AAQ3E,qEAAqE;AACrE,MAAM,UAAU,kBAAkB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAA2B;IAClF,0GAA0G;IAC1G,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACtC,OAAO,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,YAAG,QAAQ,GAA8B,CAAC;AAChG,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,aAAa,CAAC,QAAqB;IACjD,MAAM,WAAW,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAClD,sGAAsG;IACtG,MAAM,UAAU,GAAG,SAAS,CAAC,YAAY,EAAE,QAAQ,IAAI,WAAW,EAAE,iBAAiB,CAAC,CAAC;IACvF,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IAClH,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { DataSource } from \"@surfaces-ui/data\";\nimport { DATA_SOURCE_TRACE } from \"@surfaces-ui/trace\";\nimport { useProvided, useTraced } from \"@surfaces-ui/trace/react\";\nimport { type ReactNode, createContext, useContext } from \"react\";\n\nconst DataSourceContext = createContext<DataSource | undefined>(undefined);\n\nexport interface DataSourceProviderProps {\n /** Any implementation: a Connect client, `memoryDataSource`, or your own. */\n dataSource: DataSource;\n children: ReactNode;\n}\n\n/** Makes a DataSource available to every data component below it. */\nexport function DataSourceProvider({ dataSource, children }: DataSourceProviderProps) {\n // With a recorder above (dev tools), it is told which backend the page uses. Nothing happens without one.\n useProvided(\"dataSource\", dataSource);\n return <DataSourceContext.Provider value={dataSource}>{children}</DataSourceContext.Provider>;\n}\n\n/** The DataSource from the nearest provider, or the one passed as a prop. */\nexport function useDataSource(override?: DataSource): DataSource {\n const fromContext = useContext(DataSourceContext);\n // Traced, as a child of the component asking, when a recorder is above; the backend itself otherwise.\n const dataSource = useTraced(\"DataSource\", override ?? fromContext, DATA_SOURCE_TRACE);\n if (!dataSource) throw new Error(\"No DataSource: wrap the component in <DataSourceProvider> or pass dataSource.\");\n return dataSource;\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import type { MessageInitShape } from "@bufbuild/protobuf";
2
+ import { type DataSource } from "@surfaces-ui/data";
3
+ import type { ExecuteRequestSchema } from "@surfaces-ui/proto";
4
+ import { type Field } from "apache-arrow";
5
+ /**
6
+ * One CSV field. Quotes are doubled, and text that a spreadsheet would run
7
+ * as a formula (starting with =, +, - or @) is prefixed with a quote so that
8
+ * opening an export cannot execute anything.
9
+ */
10
+ export declare function csvField(text: string, isText: boolean): string;
11
+ /** A header line for a result's columns. */
12
+ export declare function csvHeader(fields: Field[]): string;
13
+ /** One line of CSV. Nulls are empty; numbers are written in full, not abbreviated. */
14
+ export declare function csvRow(fields: Field[], values: unknown[]): string;
15
+ export interface ExportResult {
16
+ blob: Blob;
17
+ rows: number;
18
+ /** True when the backend stopped at its row limit, so the file is not the whole result. */
19
+ truncated: boolean;
20
+ }
21
+ export interface ExportOptions {
22
+ signal?: AbortSignal;
23
+ /** Called as rows arrive. */
24
+ onProgress?(rows: number): void;
25
+ }
26
+ /**
27
+ * Writes a whole query result to CSV. The rows are streamed from the backend
28
+ * and turned into text a batch at a time, so the grid's window is not the
29
+ * limit: the backend's own row limit is.
30
+ */
31
+ export declare function exportCsv(dataSource: DataSource, request: MessageInitShape<typeof ExecuteRequestSchema>, options?: ExportOptions): Promise<ExportResult>;
32
+ /** Hands a file to the browser to save. */
33
+ export declare function downloadBlob(blob: Blob, filename: string): void;
@@ -0,0 +1,77 @@
1
+ import { decodeStream } from "@surfaces-ui/data";
2
+ import { DataType } from "apache-arrow";
3
+ import { formatCell } from "./format.js";
4
+ /**
5
+ * One CSV field. Quotes are doubled, and text that a spreadsheet would run
6
+ * as a formula (starting with =, +, - or @) is prefixed with a quote so that
7
+ * opening an export cannot execute anything.
8
+ */
9
+ export function csvField(text, isText) {
10
+ const safe = isText && /^[=+\-@\t\r]/.test(text) ? `'${text}` : text;
11
+ return /[",\n\r]/.test(safe) ? `"${safe.replace(/"/g, '""')}"` : safe;
12
+ }
13
+ const textual = (type) => !(DataType.isInt(type) || DataType.isFloat(type) || DataType.isDecimal(type) || DataType.isBool(type) || DataType.isTimestamp(type) || DataType.isDate(type));
14
+ /** A header line for a result's columns. */
15
+ export function csvHeader(fields) {
16
+ return `${fields.map((f) => csvField(f.name, true)).join(",")}\r\n`;
17
+ }
18
+ /** One line of CSV. Nulls are empty; numbers are written in full, not abbreviated. */
19
+ export function csvRow(fields, values) {
20
+ return `${fields
21
+ .map((field, i) => {
22
+ const value = values[i];
23
+ if (value == null)
24
+ return "";
25
+ const raw = DataType.isFloat(field.type) ? String(value) : formatCell(value, field.type).text;
26
+ return csvField(raw, textual(field.type));
27
+ })
28
+ .join(",")}\r\n`;
29
+ }
30
+ /**
31
+ * Writes a whole query result to CSV. The rows are streamed from the backend
32
+ * and turned into text a batch at a time, so the grid's window is not the
33
+ * limit: the backend's own row limit is.
34
+ */
35
+ export async function exportCsv(dataSource, request, options = {}) {
36
+ const parts = [];
37
+ let schema;
38
+ let fields = [];
39
+ let rows = 0;
40
+ let truncated = false;
41
+ for await (const message of dataSource.execute(request, { signal: options.signal })) {
42
+ const part = message.part;
43
+ if (part.case === "header") {
44
+ schema = part.value.arrowSchema;
45
+ fields = decodeStream(schema, []).schema.fields;
46
+ parts.push(csvHeader(fields));
47
+ }
48
+ else if (part.case === "batch" && schema) {
49
+ const table = decodeStream(schema, [part.value.arrowBatch]);
50
+ const columns = fields.map((_, i) => table.getChildAt(i));
51
+ let chunk = "";
52
+ for (let r = 0; r < table.numRows; r++)
53
+ chunk += csvRow(fields, columns.map((column) => column?.get(r)));
54
+ parts.push(chunk);
55
+ rows += table.numRows;
56
+ options.onProgress?.(rows);
57
+ }
58
+ else if (part.case === "footer")
59
+ truncated = part.value.truncated;
60
+ }
61
+ if (!schema)
62
+ throw new Error("The result ended before it began.");
63
+ // The byte order mark makes spreadsheets read the file as UTF-8.
64
+ return { blob: new Blob(["", ...parts], { type: "text/csv;charset=utf-8" }), rows, truncated };
65
+ }
66
+ /** Hands a file to the browser to save. */
67
+ export function downloadBlob(blob, filename) {
68
+ const url = URL.createObjectURL(blob);
69
+ const link = document.createElement("a");
70
+ link.href = url;
71
+ link.download = filename;
72
+ document.body.append(link);
73
+ link.click();
74
+ link.remove();
75
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
76
+ }
77
+ //# sourceMappingURL=export.js.map