vastgrid 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/README.md +175 -13
  2. package/dist/canvas/geometry.d.ts +92 -0
  3. package/dist/canvas/geometry.d.ts.map +1 -0
  4. package/dist/canvas/geometry.js +197 -0
  5. package/dist/canvas/geometry.js.map +1 -0
  6. package/dist/canvas/grid-canvas.d.ts +161 -0
  7. package/dist/canvas/grid-canvas.d.ts.map +1 -0
  8. package/dist/canvas/grid-canvas.js +1146 -0
  9. package/dist/canvas/grid-canvas.js.map +1 -0
  10. package/dist/canvas/hooks.d.ts +61 -0
  11. package/dist/canvas/hooks.d.ts.map +1 -0
  12. package/dist/canvas/hooks.js +2 -0
  13. package/dist/canvas/hooks.js.map +1 -0
  14. package/dist/canvas/keys.d.ts +26 -0
  15. package/dist/canvas/keys.d.ts.map +1 -0
  16. package/dist/canvas/keys.js +133 -0
  17. package/dist/canvas/keys.js.map +1 -0
  18. package/dist/canvas/layout.d.ts +26 -0
  19. package/dist/canvas/layout.d.ts.map +1 -0
  20. package/dist/canvas/layout.js +73 -0
  21. package/dist/canvas/layout.js.map +1 -0
  22. package/dist/canvas/scroll.d.ts +31 -0
  23. package/dist/canvas/scroll.d.ts.map +1 -0
  24. package/dist/canvas/scroll.js +111 -0
  25. package/dist/canvas/scroll.js.map +1 -0
  26. package/dist/canvas/text.d.ts +23 -0
  27. package/dist/canvas/text.d.ts.map +1 -0
  28. package/dist/canvas/text.js +142 -0
  29. package/dist/canvas/text.js.map +1 -0
  30. package/dist/{theme.d.ts → canvas/theme.d.ts} +8 -0
  31. package/dist/canvas/theme.d.ts.map +1 -0
  32. package/dist/canvas/theme.js +62 -0
  33. package/dist/canvas/theme.js.map +1 -0
  34. package/dist/core/cache.d.ts +48 -0
  35. package/dist/core/cache.d.ts.map +1 -0
  36. package/dist/core/cache.js +222 -0
  37. package/dist/core/cache.js.map +1 -0
  38. package/dist/core/checked.d.ts +20 -0
  39. package/dist/core/checked.d.ts.map +1 -0
  40. package/dist/core/checked.js +61 -0
  41. package/dist/core/checked.js.map +1 -0
  42. package/dist/core/client.d.ts +33 -0
  43. package/dist/core/client.d.ts.map +1 -0
  44. package/dist/core/client.js +103 -0
  45. package/dist/core/client.js.map +1 -0
  46. package/dist/core/conditions.d.ts +48 -0
  47. package/dist/core/conditions.d.ts.map +1 -0
  48. package/dist/core/conditions.js +105 -0
  49. package/dist/core/conditions.js.map +1 -0
  50. package/dist/core/evaluate.d.ts +20 -0
  51. package/dist/core/evaluate.d.ts.map +1 -0
  52. package/dist/core/evaluate.js +210 -0
  53. package/dist/core/evaluate.js.map +1 -0
  54. package/dist/core/filters.d.ts +51 -0
  55. package/dist/core/filters.d.ts.map +1 -0
  56. package/dist/core/filters.js +303 -0
  57. package/dist/core/filters.js.map +1 -0
  58. package/dist/core/format.d.ts +14 -0
  59. package/dist/core/format.d.ts.map +1 -0
  60. package/dist/core/format.js +303 -0
  61. package/dist/core/format.js.map +1 -0
  62. package/dist/core/measures.d.ts +26 -0
  63. package/dist/core/measures.d.ts.map +1 -0
  64. package/dist/core/measures.js +105 -0
  65. package/dist/core/measures.js.map +1 -0
  66. package/dist/core/request-ids.d.ts +20 -0
  67. package/dist/core/request-ids.d.ts.map +1 -0
  68. package/dist/core/request-ids.js +55 -0
  69. package/dist/core/request-ids.js.map +1 -0
  70. package/dist/core/rows.d.ts +79 -0
  71. package/dist/core/rows.d.ts.map +1 -0
  72. package/dist/core/rows.js +173 -0
  73. package/dist/core/rows.js.map +1 -0
  74. package/dist/core/store.d.ts +233 -0
  75. package/dist/core/store.d.ts.map +1 -0
  76. package/dist/core/store.js +1162 -0
  77. package/dist/core/store.js.map +1 -0
  78. package/dist/core/totals.d.ts +24 -0
  79. package/dist/core/totals.d.ts.map +1 -0
  80. package/dist/core/totals.js +49 -0
  81. package/dist/core/totals.js.map +1 -0
  82. package/dist/core/trace.d.ts +7 -0
  83. package/dist/core/trace.d.ts.map +1 -0
  84. package/dist/core/trace.js +26 -0
  85. package/dist/core/trace.js.map +1 -0
  86. package/dist/core/transports.d.ts +50 -0
  87. package/dist/core/transports.d.ts.map +1 -0
  88. package/dist/core/transports.js +160 -0
  89. package/dist/core/transports.js.map +1 -0
  90. package/dist/core/types.d.ts +150 -0
  91. package/dist/core/types.d.ts.map +1 -0
  92. package/dist/core/types.js +45 -0
  93. package/dist/core/types.js.map +1 -0
  94. package/dist/core.d.ts +12 -0
  95. package/dist/core.d.ts.map +1 -0
  96. package/dist/core.js +11 -0
  97. package/dist/core.js.map +1 -0
  98. package/dist/index.d.ts +15 -6
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +13 -7
  101. package/dist/index.js.map +1 -1
  102. package/dist/react/accessible-rows.d.ts +13 -0
  103. package/dist/react/accessible-rows.d.ts.map +1 -0
  104. package/dist/react/accessible-rows.js +320 -0
  105. package/dist/react/accessible-rows.js.map +1 -0
  106. package/dist/react/cell-editor.d.ts +22 -0
  107. package/dist/react/cell-editor.d.ts.map +1 -0
  108. package/dist/react/cell-editor.js +431 -0
  109. package/dist/react/cell-editor.js.map +1 -0
  110. package/dist/react/cell-menu.d.ts +18 -0
  111. package/dist/react/cell-menu.d.ts.map +1 -0
  112. package/dist/react/cell-menu.js +299 -0
  113. package/dist/react/cell-menu.js.map +1 -0
  114. package/dist/react/column-menu.d.ts +16 -0
  115. package/dist/react/column-menu.d.ts.map +1 -0
  116. package/dist/react/column-menu.js +1311 -0
  117. package/dist/react/column-menu.js.map +1 -0
  118. package/dist/react/columns-menu.d.ts +7 -0
  119. package/dist/react/columns-menu.d.ts.map +1 -0
  120. package/dist/react/columns-menu.js +249 -0
  121. package/dist/react/columns-menu.js.map +1 -0
  122. package/dist/react/conditions-menu.d.ts +10 -0
  123. package/dist/react/conditions-menu.d.ts.map +1 -0
  124. package/dist/react/conditions-menu.js +795 -0
  125. package/dist/react/conditions-menu.js.map +1 -0
  126. package/dist/react/context.d.ts +29 -0
  127. package/dist/react/context.d.ts.map +1 -0
  128. package/dist/react/context.js +18 -0
  129. package/dist/react/context.js.map +1 -0
  130. package/dist/react/data-grid.d.ts +79 -0
  131. package/dist/react/data-grid.d.ts.map +1 -0
  132. package/dist/react/data-grid.js +653 -0
  133. package/dist/react/data-grid.js.map +1 -0
  134. package/dist/react/detail-panel.d.ts +22 -0
  135. package/dist/react/detail-panel.d.ts.map +1 -0
  136. package/dist/react/detail-panel.js +242 -0
  137. package/dist/react/detail-panel.js.map +1 -0
  138. package/dist/react/export-menu.d.ts +11 -0
  139. package/dist/react/export-menu.d.ts.map +1 -0
  140. package/dist/react/export-menu.js +304 -0
  141. package/dist/react/export-menu.js.map +1 -0
  142. package/dist/react/find-bar.d.ts +11 -0
  143. package/dist/react/find-bar.d.ts.map +1 -0
  144. package/dist/react/find-bar.js +303 -0
  145. package/dist/react/find-bar.js.map +1 -0
  146. package/dist/react/format-form.d.ts +12 -0
  147. package/dist/react/format-form.d.ts.map +1 -0
  148. package/dist/react/format-form.js +863 -0
  149. package/dist/react/format-form.js.map +1 -0
  150. package/dist/react/formula-menu.d.ts +6 -0
  151. package/dist/react/formula-menu.d.ts.map +1 -0
  152. package/dist/react/formula-menu.js +343 -0
  153. package/dist/react/formula-menu.js.map +1 -0
  154. package/dist/react/grid-body.d.ts +33 -0
  155. package/dist/react/grid-body.d.ts.map +1 -0
  156. package/dist/react/grid-body.js +1389 -0
  157. package/dist/react/grid-body.js.map +1 -0
  158. package/dist/react/group-menu.d.ts +7 -0
  159. package/dist/react/group-menu.d.ts.map +1 -0
  160. package/dist/react/group-menu.js +508 -0
  161. package/dist/react/group-menu.js.map +1 -0
  162. package/dist/react/hooks.d.ts +33 -0
  163. package/dist/react/hooks.d.ts.map +1 -0
  164. package/dist/react/hooks.js +161 -0
  165. package/dist/react/hooks.js.map +1 -0
  166. package/dist/react/messages.d.ts +180 -0
  167. package/dist/react/messages.d.ts.map +1 -0
  168. package/dist/react/messages.js +414 -0
  169. package/dist/react/messages.js.map +1 -0
  170. package/dist/react/save.d.ts +9 -0
  171. package/dist/react/save.d.ts.map +1 -0
  172. package/dist/react/save.js +102 -0
  173. package/dist/react/save.js.map +1 -0
  174. package/dist/react/static-rows.d.ts +9 -0
  175. package/dist/react/static-rows.d.ts.map +1 -0
  176. package/dist/react/static-rows.js +176 -0
  177. package/dist/react/static-rows.js.map +1 -0
  178. package/dist/react/status-bar.d.ts +12 -0
  179. package/dist/react/status-bar.d.ts.map +1 -0
  180. package/dist/react/status-bar.js +413 -0
  181. package/dist/react/status-bar.js.map +1 -0
  182. package/dist/react/toolbar-popover.d.ts +14 -0
  183. package/dist/react/toolbar-popover.d.ts.map +1 -0
  184. package/dist/react/toolbar-popover.js +143 -0
  185. package/dist/react/toolbar-popover.js.map +1 -0
  186. package/dist/react/toolbar.d.ts +13 -0
  187. package/dist/react/toolbar.d.ts.map +1 -0
  188. package/dist/react/toolbar.js +344 -0
  189. package/dist/react/toolbar.js.map +1 -0
  190. package/dist/server.d.ts +22 -0
  191. package/dist/server.d.ts.map +1 -0
  192. package/dist/server.js +45 -0
  193. package/dist/server.js.map +1 -0
  194. package/dist/styles.css +496 -316
  195. package/package.json +43 -18
  196. package/src/canvas/geometry.ts +197 -0
  197. package/src/canvas/grid-canvas.ts +1222 -0
  198. package/src/canvas/hooks.ts +61 -0
  199. package/src/canvas/keys.ts +96 -0
  200. package/src/canvas/layout.ts +77 -0
  201. package/src/canvas/scroll.ts +120 -0
  202. package/src/canvas/text.ts +155 -0
  203. package/src/{theme.ts → canvas/theme.ts} +14 -1
  204. package/src/core/cache.ts +247 -0
  205. package/src/core/checked.ts +64 -0
  206. package/src/core/client.ts +103 -0
  207. package/src/core/conditions.ts +89 -0
  208. package/src/core/evaluate.ts +221 -0
  209. package/src/core/filters.ts +268 -0
  210. package/src/core/format.ts +309 -0
  211. package/src/core/measures.ts +99 -0
  212. package/src/core/request-ids.ts +54 -0
  213. package/src/core/rows.ts +213 -0
  214. package/src/core/store.ts +1122 -0
  215. package/src/core/totals.ts +59 -0
  216. package/src/core/trace.ts +44 -0
  217. package/src/core/transports.ts +177 -0
  218. package/src/core/types.ts +168 -0
  219. package/src/core.ts +39 -0
  220. package/src/index.ts +24 -12
  221. package/src/react/accessible-rows.tsx +242 -0
  222. package/src/react/cell-editor.tsx +216 -0
  223. package/src/react/cell-menu.tsx +166 -0
  224. package/src/react/column-menu.tsx +619 -0
  225. package/src/react/columns-menu.tsx +116 -0
  226. package/src/react/conditions-menu.tsx +289 -0
  227. package/src/react/context.ts +33 -0
  228. package/src/react/data-grid.tsx +286 -0
  229. package/src/react/detail-panel.tsx +92 -0
  230. package/src/react/export-menu.tsx +112 -0
  231. package/src/react/find-bar.tsx +112 -0
  232. package/src/react/format-form.tsx +421 -0
  233. package/src/react/formula-menu.tsx +163 -0
  234. package/src/react/grid-body.tsx +744 -0
  235. package/src/react/group-menu.tsx +214 -0
  236. package/src/react/hooks.ts +104 -0
  237. package/src/react/messages.ts +556 -0
  238. package/src/react/save.ts +42 -0
  239. package/src/react/static-rows.tsx +59 -0
  240. package/src/react/status-bar.tsx +175 -0
  241. package/src/react/toolbar-popover.tsx +69 -0
  242. package/src/react/toolbar.tsx +152 -0
  243. package/src/server.ts +58 -0
  244. package/src/styles.css +496 -316
  245. package/dist/components/bars.d.ts +0 -14
  246. package/dist/components/bars.d.ts.map +0 -1
  247. package/dist/components/bars.js +0 -67
  248. package/dist/components/bars.js.map +0 -1
  249. package/dist/components/cell-inspector.d.ts +0 -11
  250. package/dist/components/cell-inspector.d.ts.map +0 -1
  251. package/dist/components/cell-inspector.js +0 -37
  252. package/dist/components/cell-inspector.js.map +0 -1
  253. package/dist/components/columns-panel.d.ts +0 -12
  254. package/dist/components/columns-panel.d.ts.map +0 -1
  255. package/dist/components/columns-panel.js +0 -11
  256. package/dist/components/columns-panel.js.map +0 -1
  257. package/dist/components/filter-panel.d.ts +0 -17
  258. package/dist/components/filter-panel.d.ts.map +0 -1
  259. package/dist/components/filter-panel.js +0 -165
  260. package/dist/components/filter-panel.js.map +0 -1
  261. package/dist/components/find-bar.d.ts +0 -9
  262. package/dist/components/find-bar.d.ts.map +0 -1
  263. package/dist/components/find-bar.js +0 -46
  264. package/dist/components/find-bar.js.map +0 -1
  265. package/dist/components/popover.d.ts +0 -38
  266. package/dist/components/popover.d.ts.map +0 -1
  267. package/dist/components/popover.js +0 -104
  268. package/dist/components/popover.js.map +0 -1
  269. package/dist/components/stats-panel.d.ts +0 -12
  270. package/dist/components/stats-panel.d.ts.map +0 -1
  271. package/dist/components/stats-panel.js +0 -40
  272. package/dist/components/stats-panel.js.map +0 -1
  273. package/dist/controller.d.ts +0 -218
  274. package/dist/controller.d.ts.map +0 -1
  275. package/dist/controller.js +0 -788
  276. package/dist/controller.js.map +0 -1
  277. package/dist/data-grid.d.ts +0 -51
  278. package/dist/data-grid.d.ts.map +0 -1
  279. package/dist/data-grid.js +0 -698
  280. package/dist/data-grid.js.map +0 -1
  281. package/dist/labels.d.ts +0 -9
  282. package/dist/labels.d.ts.map +0 -1
  283. package/dist/labels.js +0 -38
  284. package/dist/labels.js.map +0 -1
  285. package/dist/messages.d.ts +0 -99
  286. package/dist/messages.d.ts.map +0 -1
  287. package/dist/messages.js +0 -276
  288. package/dist/messages.js.map +0 -1
  289. package/dist/renderer.d.ts +0 -52
  290. package/dist/renderer.d.ts.map +0 -1
  291. package/dist/renderer.js +0 -522
  292. package/dist/renderer.js.map +0 -1
  293. package/dist/text.d.ts +0 -14
  294. package/dist/text.d.ts.map +0 -1
  295. package/dist/text.js +0 -63
  296. package/dist/text.js.map +0 -1
  297. package/dist/theme.d.ts.map +0 -1
  298. package/dist/theme.js +0 -54
  299. package/dist/theme.js.map +0 -1
  300. package/src/components/bars.tsx +0 -179
  301. package/src/components/cell-inspector.tsx +0 -70
  302. package/src/components/columns-panel.tsx +0 -59
  303. package/src/components/filter-panel.tsx +0 -290
  304. package/src/components/find-bar.tsx +0 -104
  305. package/src/components/popover.tsx +0 -194
  306. package/src/components/stats-panel.tsx +0 -153
  307. package/src/controller.ts +0 -887
  308. package/src/data-grid.tsx +0 -1029
  309. package/src/labels.ts +0 -46
  310. package/src/messages.ts +0 -390
  311. package/src/renderer.ts +0 -535
  312. package/src/text.ts +0 -55
@@ -0,0 +1,233 @@
1
+ import { type Column, type GridCommand, type GridDocument, type GridSession, type JsonValue, type Measure, type RowKey } from "vastgrid-spec";
2
+ import { type Transport } from "./client.js";
3
+ import { type Viewport } from "./rows.js";
4
+ import { type CommandOutcome, GridError, type GridSnapshot, type InitialView, type OpenOptions } from "./types.js";
5
+ /** Bytes of rows that a store keeps for the view on screen, by default. */
6
+ export declare const CACHE_BYTES: number;
7
+ export interface GridStoreOptions {
8
+ /** Where the engine is. */
9
+ transport: Transport;
10
+ /** The `ref` of the table to open (§8.2). */
11
+ table: string;
12
+ /** The `read` options of `open`. */
13
+ open?: OpenOptions;
14
+ /** The document to start with (§5.1); the empty document by default. */
15
+ document?: GridDocument;
16
+ /** The session to start with (§5.2). */
17
+ session?: GridSession;
18
+ /** Rows read on a server, shown before the first read (§7 of react.md). */
19
+ initial?: InitialView;
20
+ /** Bytes of rows to keep (`CACHE_BYTES` by default). */
21
+ cacheBytes?: number;
22
+ }
23
+ export interface DispatchOptions {
24
+ /** What `edit.paste` pastes. */
25
+ clipboard?: {
26
+ text?: string;
27
+ html?: string;
28
+ };
29
+ }
30
+ type Part = "document" | "session";
31
+ interface Events {
32
+ document: GridDocument;
33
+ session: GridSession;
34
+ error: GridError;
35
+ }
36
+ /**
37
+ * The grid without a screen (§4 of react.md): the state of the specification as immutable snapshots, the
38
+ * commands that change it, and the rows of the view on screen, read through a transport. Making a store has
39
+ * no side effects; `connect` opens the table and starts reading.
40
+ */
41
+ export declare class GridStore {
42
+ private readonly options;
43
+ private snapshot;
44
+ private readonly listeners;
45
+ private readonly rowListeners;
46
+ private readonly events;
47
+ private readonly controlled;
48
+ /** What a command made of a controlled part, until the host passes it back (§5.2 of react.md). */
49
+ private readonly proposed;
50
+ private client;
51
+ /** Counts connections, so that answers to an earlier one are dropped. */
52
+ private connection;
53
+ /** Whether the table is open for the current connection. */
54
+ private opened;
55
+ private current;
56
+ private next;
57
+ private readonly reader;
58
+ /**
59
+ * Values of writes (§7.2) that the rows read do not hold yet, by the key text of their row and by column, with
60
+ * the write that gave them: the grid shows them at once, and drops them when the write fails or once the view
61
+ * of its edits version is on screen.
62
+ */
63
+ private readonly written;
64
+ private writes;
65
+ /** The edits version that each write that succeeded made. */
66
+ private readonly writeVersions;
67
+ /** Settles once the writes sent so far are answered and their steps are in the history. */
68
+ private writing;
69
+ private readonly totals;
70
+ private rowsVersion;
71
+ constructor(options: GridStoreOptions);
72
+ getSnapshot: () => GridSnapshot;
73
+ subscribe: (listener: () => void) => (() => void);
74
+ /** Follows changes of the document or the session (reported also when they are controlled), and errors. */
75
+ on<K extends keyof Events>(event: K, listener: (value: Events[K]) => void): () => void;
76
+ private emit;
77
+ private publish;
78
+ /** Reads the one row of a plan that aggregates without keys: its values and their types, by column name. */
79
+ private measure;
80
+ /**
81
+ * Measures (§4.5) over the rows of the document's plan, for the column statistics: an `aggregate` without keys
82
+ * (`measuresPlan`). Fails for a plan that groups rows.
83
+ */
84
+ aggregate(measures: Measure[], signal?: AbortSignal): Promise<{
85
+ values: Record<string, JsonValue>;
86
+ columns: Record<string, Column>;
87
+ }>;
88
+ private displayedOf;
89
+ /** The state that commands apply to: what was proposed for controlled parts, or what is shown. */
90
+ private base;
91
+ /** The value of a cell of the view on screen; undefined while it is not read. */
92
+ cell(row: number, column: string): JsonValue | undefined;
93
+ /** Whether the engine cut a cell's value to the text limit (§8.4). */
94
+ isCut(row: number, column: string): boolean;
95
+ /** The key of a row of the view on screen (§5.3); undefined while it is not read. */
96
+ rowKey(row: number): RowKey | undefined;
97
+ /** The row ID of a row of the view on screen. */
98
+ rowId(row: number): number | undefined;
99
+ /** Changes whenever rows of the view on screen arrive or leave. */
100
+ getRowsVersion: () => number;
101
+ /** Follows the arrival of rows (the snapshot does not change when rows arrive). */
102
+ subscribeRows: (listener: () => void) => (() => void);
103
+ private emitRows;
104
+ /** Tells the store what the canvas shows, so that it reads those rows and a page around them. */
105
+ setViewport(viewport: Viewport): void;
106
+ /** Reads rows `[start, end)` of `columns` of the view on screen if they are not read, for cells React renders. */
107
+ ensure(start: number, end: number, columns: readonly string[]): void;
108
+ /**
109
+ * Opens the table, follows its events and reads the view of the document's plan. Gives the function that
110
+ * undoes all of it; connecting again afterwards works (Strict Mode does it, §4.3 of react.md).
111
+ */
112
+ connect(): () => void;
113
+ /** The table is open: repairs the document for it and reads the view (§5.5). */
114
+ private opening;
115
+ private onEvent;
116
+ private fail;
117
+ /** A read failed: unless it was cancelled, the failure belongs to no command (§4.2 of react.md). */
118
+ private readFailed;
119
+ /** Shows rows read on a server before the table is open. */
120
+ private seed;
121
+ /**
122
+ * Reads the view of a plan while the view on screen stays, and shows it when its first rows arrive, with the
123
+ * session moved by `view.update` (§5.4; §4.2 of react.md).
124
+ */
125
+ private showPlan;
126
+ private live;
127
+ private prepare;
128
+ private contextFor;
129
+ /** A row as commands read it, with the values of writes that its rows do not hold yet. */
130
+ private withWritten;
131
+ /** Shows the values of a write until it is answered (§7.2). */
132
+ private markWritten;
133
+ /** Forgets the values of writes: one that failed, or those that the rows on screen now hold. */
134
+ private dropWritten;
135
+ /** Makes a part controlled: commands report what they make of it, and only `setDocument`/`setSession` show it. */
136
+ control(part: Part, controlled: boolean): void;
137
+ /** Shows a document given by the host (a controlled prop, a saved view, an agent). */
138
+ setDocument(document: GridDocument): void;
139
+ /** Shows a session given by the host. */
140
+ setSession(session: GridSession): void;
141
+ /**
142
+ * Applies a new state from a command: shows what is not controlled, with `extra` members of the snapshot in the
143
+ * same step, and reports both parts that changed.
144
+ */
145
+ private change;
146
+ /** Applies a command now, or tells why it cannot be applied (rows to read first included). */
147
+ private applyNow;
148
+ /**
149
+ * Applies a command (§4.2 of react.md). The state changes at once when the command has what it needs;
150
+ * a command that needs rows that are not read reads them first. Resolves once the command's requests are
151
+ * answered, and never rejects. The same function for the life of the store.
152
+ */
153
+ readonly dispatch: (command: GridCommand, options?: DispatchOptions) => Promise<CommandOutcome>;
154
+ /**
155
+ * Applies a command synchronously, as a `copy` event needs (its clipboard is written before the handler
156
+ * returns). A command that needs rows that are not read fails with `not_loaded`; its requests are sent.
157
+ */
158
+ dispatchSync(command: GridCommand, options?: DispatchOptions): CommandOutcome;
159
+ /**
160
+ * Sends the failed write again (§6.6 of react.md): the same updates, or after an `edit_conflict` without their
161
+ * `previous`, so that they write over what the cells hold now. It succeeds as its command would have: the history
162
+ * gets its step, or an undo or a redo whose step is still the last moves it. Resolves as `dispatch` does.
163
+ */
164
+ readonly retryWrite: () => Promise<CommandOutcome>;
165
+ /** Forgets the failed write: its cells show what the engine holds. */
166
+ discardWrite(): void;
167
+ /** Keeps a write that failed, for `retryWrite` and `discardWrite`. */
168
+ private failWrite;
169
+ /** Whether a failed undo or redo has its step still last in its list, where its write then moves it from. */
170
+ private stillLast;
171
+ /** Where the file of an `export` without a target can be downloaded (`Transport.exportUrl`), or null. */
172
+ exportUrl(target: string): string | null;
173
+ /** A name for the file of an export that an engine answers as data: the table's name with the format's extension. */
174
+ exportName(format: string): string;
175
+ /**
176
+ * Reads the table's file as it is now (`reload`, §7.6), without the cells written into the table as it was read:
177
+ * for a file that changed on disk while the table had written cells (`fileChanged` of the table).
178
+ */
179
+ reload(): Promise<void>;
180
+ /** Another revision of the table (§5.4): the document is repaired for its columns (§5.5), and the view read. */
181
+ private adopt;
182
+ /** Counts and sums the cells of ranges of the view on screen (`summarize`, §8.2). */
183
+ summarize(ranges: [number, number][], columns: string[], signal?: AbortSignal): Promise<{
184
+ count: number;
185
+ numericCount: number;
186
+ sum: unknown;
187
+ min: unknown;
188
+ max: unknown;
189
+ average: unknown;
190
+ }>;
191
+ /**
192
+ * The values of a column with how many rows have each, the most common first, for the column menu's list: the
193
+ * rows of the document's plan without the column's own conditions, and those whose text contains `search`
194
+ * (`valuesPlan`). At most `limit` of them; `truncated` when there are more.
195
+ */
196
+ values(column: string, { search, limit }?: {
197
+ search?: string;
198
+ limit?: number;
199
+ }, signal?: AbortSignal): Promise<{
200
+ values: {
201
+ value: JsonValue;
202
+ count: number;
203
+ }[];
204
+ truncated: boolean;
205
+ }>;
206
+ /**
207
+ * Finds the next cell of the view on screen after `from` (before it with `direction` −1) whose text contains
208
+ * `text` (`find`, §8.2), among the displayed columns in display order, wrapping around; null when none does.
209
+ */
210
+ find(text: string, { from, direction, caseSensitive, }: {
211
+ from: {
212
+ row: number;
213
+ column: string;
214
+ };
215
+ direction?: 1 | -1;
216
+ caseSensitive?: boolean;
217
+ }, signal?: AbortSignal): Promise<{
218
+ row: number;
219
+ column: string;
220
+ } | null>;
221
+ /** The whole value of a cell of the view on screen, also when the engine cut its text (§8.4), and its type. */
222
+ fullValue(row: number, column: string, signal?: AbortSignal): Promise<{
223
+ value: JsonValue;
224
+ column: Column;
225
+ }>;
226
+ /** Sends the requests of a command and applies the commands of §6.7 that their answers call for. */
227
+ private send;
228
+ private sendNow;
229
+ }
230
+ /** Makes a store (§4 of react.md). */
231
+ export declare function createGridStore(options: GridStoreOptions): GridStore;
232
+ export {};
233
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EAYX,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EAGd,KAAK,OAAO,EAMZ,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG7E,OAAO,EACL,KAAK,cAAc,EAEnB,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,WAAW,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