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,150 @@
1
+ import type { Capabilities, Column, CommandError, DisplayedColumn, ErrorCode, GridDocument, GridSession, JsonValue, Operation, Plan, RowKey } from "vastgrid-spec";
2
+ /** The table's edits version and the number of cells written so far (§8.2 of the specification). */
3
+ export interface Edits {
4
+ version: number;
5
+ cells: number;
6
+ }
7
+ /** What `open` and `info` give (§8.2). */
8
+ export interface TableInfo {
9
+ /** The engine's id of the open table, for later requests. */
10
+ table: string;
11
+ revision: string | null;
12
+ edits: Edits;
13
+ status: "loading" | "ready" | "error";
14
+ progress: number | null;
15
+ /** Null while the table loads. */
16
+ rowCount: number | null;
17
+ readableRows: number;
18
+ columns: Column[];
19
+ capabilities: Capabilities;
20
+ format?: string;
21
+ byteSize?: number;
22
+ notes?: string[];
23
+ sheets?: {
24
+ name: string;
25
+ hidden?: boolean;
26
+ }[];
27
+ sheet?: string;
28
+ error?: string;
29
+ /** The file changed on disk since the table, which has written cells, was read (§7.6); `reload` reads it again. */
30
+ fileChanged?: boolean;
31
+ }
32
+ /** A view as `rows` reports it (§8.2, §9). */
33
+ export interface ViewInfo {
34
+ hash: string;
35
+ status: "building" | "ready";
36
+ rowCount: number;
37
+ rowCountExact: boolean;
38
+ readableRows: number;
39
+ columns: Column[];
40
+ edits: Edits;
41
+ partial?: boolean;
42
+ }
43
+ /** The result of `rows` (§8.2), with its block in the structured encoding. */
44
+ export interface RowsResult {
45
+ view: ViewInfo;
46
+ start: number;
47
+ end: number;
48
+ rowIds: number[] | null;
49
+ block: {
50
+ bytes: Uint8Array;
51
+ };
52
+ truncated?: Record<string, number[]>;
53
+ }
54
+ /** The `read` options of `open` (§8.2). */
55
+ export interface OpenOptions {
56
+ sheet?: string;
57
+ headerRow?: number;
58
+ keepEmptyRows?: boolean;
59
+ keepEmptyColumns?: boolean;
60
+ }
61
+ /** A request (§8.1). */
62
+ export interface RequestMessage {
63
+ v: 2;
64
+ id: number;
65
+ op: Operation;
66
+ [member: string]: unknown;
67
+ }
68
+ /**
69
+ * Rows read on a server for the first render (§7 of react.md): the table, the plan they were read for, and
70
+ * the answer of `rows`. A store given them shows these rows before it reads any.
71
+ */
72
+ export interface InitialView {
73
+ table: TableInfo;
74
+ plan: Plan;
75
+ rows: RowsResult;
76
+ }
77
+ /** A failed request (§8.7), or a response that does not follow §8 (`internal`). */
78
+ export declare class GridError extends Error {
79
+ readonly code: ErrorCode;
80
+ readonly reason?: string;
81
+ readonly path?: string;
82
+ readonly details?: Record<string, unknown>;
83
+ /** The operation of the request that failed. */
84
+ readonly op?: Operation;
85
+ constructor(code: ErrorCode, message: string, extra?: {
86
+ reason?: string;
87
+ path?: string;
88
+ details?: Record<string, unknown>;
89
+ op?: Operation;
90
+ });
91
+ }
92
+ /** What a dispatched command came to: its output, or why it failed (§4.2 of react.md). */
93
+ export type CommandOutcome = {
94
+ ok: true;
95
+ output?: unknown;
96
+ } | {
97
+ ok: false;
98
+ error: CommandError | GridError;
99
+ };
100
+ /** One update of a `write` request (§7.2 of the specification). */
101
+ export interface WriteUpdate {
102
+ readonly key: RowKey;
103
+ readonly column: string;
104
+ readonly value: JsonValue;
105
+ readonly previous?: JsonValue;
106
+ }
107
+ /**
108
+ * The last write that failed (§6.6 of react.md), which `retryWrite` sends again and `discardWrite` forgets.
109
+ * `retry` tells how it can be sent again: the same write (`"retry"`), after an `edit_conflict` without the
110
+ * `previous` values (`"overwrite"`), or not at all (null): the table has another revision now, or the engine
111
+ * refused the values or the cells.
112
+ */
113
+ export interface FailedWrite {
114
+ /** The command whose write it was. */
115
+ readonly command: string;
116
+ readonly updates: readonly WriteUpdate[];
117
+ readonly revision: string | null;
118
+ readonly rowKey?: string | readonly string[];
119
+ readonly error: GridError;
120
+ readonly retry: "retry" | "overwrite" | null;
121
+ }
122
+ /** What the grid shows. A snapshot is never changed: the store makes a new one for every change. */
123
+ export interface GridSnapshot {
124
+ readonly document: GridDocument;
125
+ readonly session: GridSession;
126
+ /** Null until the table is open. */
127
+ readonly table: TableInfo | null;
128
+ /** The view on screen; null until its first rows are read. */
129
+ readonly view: ViewInfo | null;
130
+ /** The displayed columns of the view on screen (§5.1.1), in display order. */
131
+ readonly displayed: readonly DisplayedColumn[];
132
+ /** A plan whose view is being read to replace the one on screen. */
133
+ readonly pending: {
134
+ readonly plan: Plan;
135
+ } | null;
136
+ readonly status: "idle" | "opening" | "ready" | "error";
137
+ /** The last failure that belongs to no command. */
138
+ readonly error: GridError | null;
139
+ /** The last write that failed, until it is sent again or discarded. */
140
+ readonly failedWrite: FailedWrite | null;
141
+ /**
142
+ * The totals row (§5.1): the total of each displayed column that has one, over the whole view on screen, with
143
+ * the types of the values; null without totals, or for a view that groups rows.
144
+ */
145
+ readonly totals: {
146
+ readonly values: Readonly<Record<string, JsonValue>>;
147
+ readonly columns: Readonly<Record<string, Column>>;
148
+ } | null;
149
+ }
150
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,eAAe,EACf,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,EACP,MAAM,eAAe,CAAC;AAEvB,oGAAoG;AACpG,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0CAA0C;AAC1C,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM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,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;QACrD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;KACpD,GAAG,IAAI,CAAC;CACV"}
@@ -0,0 +1,45 @@
1
+ /** The table's edits version and the number of cells written so far (§8.2 of the specification). */
2
+
3
+ /** What `open` and `info` give (§8.2). */
4
+
5
+ /** A view as `rows` reports it (§8.2, §9). */
6
+
7
+ /** The result of `rows` (§8.2), with its block in the structured encoding. */
8
+
9
+ /** The `read` options of `open` (§8.2). */
10
+
11
+ /** A request (§8.1). */
12
+
13
+ /**
14
+ * Rows read on a server for the first render (§7 of react.md): the table, the plan they were read for, and
15
+ * the answer of `rows`. A store given them shows these rows before it reads any.
16
+ */
17
+
18
+ /** A failed request (§8.7), or a response that does not follow §8 (`internal`). */
19
+ export class GridError extends Error {
20
+ /** The operation of the request that failed. */
21
+
22
+ constructor(code, message, extra = {}) {
23
+ super(message);
24
+ this.name = "GridError";
25
+ this.code = code;
26
+ if (extra.reason !== undefined) this.reason = extra.reason;
27
+ if (extra.path !== undefined) this.path = extra.path;
28
+ if (extra.details !== undefined) this.details = extra.details;
29
+ if (extra.op !== undefined) this.op = extra.op;
30
+ }
31
+ }
32
+
33
+ /** What a dispatched command came to: its output, or why it failed (§4.2 of react.md). */
34
+
35
+ /** One update of a `write` request (§7.2 of the specification). */
36
+
37
+ /**
38
+ * The last write that failed (§6.6 of react.md), which `retryWrite` sends again and `discardWrite` forgets.
39
+ * `retry` tells how it can be sent again: the same write (`"retry"`), after an `edit_conflict` without the
40
+ * `previous` values (`"overwrite"`), or not at all (null): the table has another revision now, or the engine
41
+ * refused the values or the cells.
42
+ */
43
+
44
+ /** What the grid shows. A snapshot is never changed: the store makes a new one for every change. */
45
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GridError","Error","constructor","code","message","extra","name","reason","undefined","path","details","op"],"sources":["types.ts"],"sourcesContent":["import type {\n Capabilities,\n Column,\n CommandError,\n DisplayedColumn,\n ErrorCode,\n GridDocument,\n GridSession,\n JsonValue,\n Operation,\n Plan,\n RowKey,\n} from \"vastgrid-spec\";\n\n/** The table's edits version and the number of cells written so far (§8.2 of the specification). */\nexport interface Edits {\n version: number;\n cells: number;\n}\n\n/** What `open` and `info` give (§8.2). */\nexport interface TableInfo {\n /** The engine's id of the open table, for later requests. */\n table: string;\n revision: string | null;\n edits: Edits;\n status: \"loading\" | \"ready\" | \"error\";\n progress: number | null;\n /** Null while the table loads. */\n rowCount: number | null;\n readableRows: number;\n columns: Column[];\n capabilities: Capabilities;\n format?: string;\n byteSize?: number;\n notes?: string[];\n sheets?: { name: string; hidden?: boolean }[];\n sheet?: string;\n error?: string;\n /** The file changed on disk since the table, which has written cells, was read (§7.6); `reload` reads it again. */\n fileChanged?: boolean;\n}\n\n/** A view as `rows` reports it (§8.2, §9). */\nexport interface ViewInfo {\n hash: string;\n status: \"building\" | \"ready\";\n rowCount: number;\n rowCountExact: boolean;\n readableRows: number;\n columns: Column[];\n edits: Edits;\n partial?: boolean;\n}\n\n/** The result of `rows` (§8.2), with its block in the structured encoding. */\nexport interface RowsResult {\n view: ViewInfo;\n start: number;\n end: number;\n rowIds: number[] | null;\n block: { bytes: Uint8Array };\n truncated?: Record<string, number[]>;\n}\n\n/** The `read` options of `open` (§8.2). */\nexport interface OpenOptions {\n sheet?: string;\n headerRow?: number;\n keepEmptyRows?: boolean;\n keepEmptyColumns?: boolean;\n}\n\n/** A request (§8.1). */\nexport interface RequestMessage {\n v: 2;\n id: number;\n op: Operation;\n [member: string]: unknown;\n}\n\n/**\n * Rows read on a server for the first render (§7 of react.md): the table, the plan they were read for, and\n * the answer of `rows`. A store given them shows these rows before it reads any.\n */\nexport interface InitialView {\n table: TableInfo;\n plan: Plan;\n rows: RowsResult;\n}\n\n/** A failed request (§8.7), or a response that does not follow §8 (`internal`). */\nexport class GridError extends Error {\n readonly code: ErrorCode;\n readonly reason?: string;\n readonly path?: string;\n readonly details?: Record<string, unknown>;\n /** The operation of the request that failed. */\n readonly op?: Operation;\n\n constructor(\n code: ErrorCode,\n message: string,\n extra: { reason?: string; path?: string; details?: Record<string, unknown>; op?: Operation } = {},\n ) {\n super(message);\n this.name = \"GridError\";\n this.code = code;\n if (extra.reason !== undefined) this.reason = extra.reason;\n if (extra.path !== undefined) this.path = extra.path;\n if (extra.details !== undefined) this.details = extra.details;\n if (extra.op !== undefined) this.op = extra.op;\n }\n}\n\n/** What a dispatched command came to: its output, or why it failed (§4.2 of react.md). */\nexport type CommandOutcome = { ok: true; output?: unknown } | { ok: false; error: CommandError | GridError };\n\n/** One update of a `write` request (§7.2 of the specification). */\nexport interface WriteUpdate {\n readonly key: RowKey;\n readonly column: string;\n readonly value: JsonValue;\n readonly previous?: JsonValue;\n}\n\n/**\n * The last write that failed (§6.6 of react.md), which `retryWrite` sends again and `discardWrite` forgets.\n * `retry` tells how it can be sent again: the same write (`\"retry\"`), after an `edit_conflict` without the\n * `previous` values (`\"overwrite\"`), or not at all (null): the table has another revision now, or the engine\n * refused the values or the cells.\n */\nexport interface FailedWrite {\n /** The command whose write it was. */\n readonly command: string;\n readonly updates: readonly WriteUpdate[];\n readonly revision: string | null;\n readonly rowKey?: string | readonly string[];\n readonly error: GridError;\n readonly retry: \"retry\" | \"overwrite\" | null;\n}\n\n/** What the grid shows. A snapshot is never changed: the store makes a new one for every change. */\nexport interface GridSnapshot {\n readonly document: GridDocument;\n readonly session: GridSession;\n /** Null until the table is open. */\n readonly table: TableInfo | null;\n /** The view on screen; null until its first rows are read. */\n readonly view: ViewInfo | null;\n /** The displayed columns of the view on screen (§5.1.1), in display order. */\n readonly displayed: readonly DisplayedColumn[];\n /** A plan whose view is being read to replace the one on screen. */\n readonly pending: { readonly plan: Plan } | null;\n readonly status: \"idle\" | \"opening\" | \"ready\" | \"error\";\n /** The last failure that belongs to no command. */\n readonly error: GridError | null;\n /** The last write that failed, until it is sent again or discarded. */\n readonly failedWrite: FailedWrite | null;\n /**\n * The totals row (§5.1): the total of each displayed column that has one, over the whole view on screen, with\n * the types of the values; null without totals, or for a view that groups rows.\n */\n readonly totals: {\n readonly values: Readonly<Record<string, JsonValue>>;\n readonly columns: Readonly<Record<string, Column>>;\n } | null;\n}\n"],"mappings":"AAcA;;AAMA;;AAuBA;;AAYA;;AAUA;;AAQA;;AAQA;AACA;AACA;AACA;;AAOA;AACA,OAAO,MAAMA,SAAS,SAASC,KAAK,CAAC;EAKnC;;EAGAC,WAAWA,CACTC,IAAe,EACfC,OAAe,EACfC,KAA4F,GAAG,CAAC,CAAC,EACjG;IACA,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,WAAW;IACvB,IAAI,CAACH,IAAI,GAAGA,IAAI;IAChB,IAAIE,KAAK,CAACE,MAAM,KAAKC,SAAS,EAAE,IAAI,CAACD,MAAM,GAAGF,KAAK,CAACE,MAAM;IAC1D,IAAIF,KAAK,CAACI,IAAI,KAAKD,SAAS,EAAE,IAAI,CAACC,IAAI,GAAGJ,KAAK,CAACI,IAAI;IACpD,IAAIJ,KAAK,CAACK,OAAO,KAAKF,SAAS,EAAE,IAAI,CAACE,OAAO,GAAGL,KAAK,CAACK,OAAO;IAC7D,IAAIL,KAAK,CAACM,EAAE,KAAKH,SAAS,EAAE,IAAI,CAACG,EAAE,GAAGN,KAAK,CAACM,EAAE;EAChD;AACF;;AAEA;;AAGA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAWA","ignoreList":[]}
package/dist/core.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The grid without React (§4 of react.md): the store, the client of the messages and the transports. Runs in
3
+ * browsers, workers and servers.
4
+ */
5
+ export { BLOCK_ROWS } from "./core/cache.js";
6
+ export { GridClient, type Transport } from "./core/client.js";
7
+ export { type Handler, RequestIds } from "./core/request-ids.js";
8
+ export type { Viewport } from "./core/rows.js";
9
+ export { CACHE_BYTES, createGridStore, type DispatchOptions, GridStore, type GridStoreOptions, } from "./core/store.js";
10
+ export { type Engine, type HttpTransportOptions, httpTransport, localTransport, serveEngine, serverFunctionTransport, type WorkerLike, workerTransport, } from "./core/transports.js";
11
+ export { type CommandOutcome, type Edits, type FailedWrite, GridError, type GridSnapshot, type InitialView, type OpenOptions, type RequestMessage, type RowsResult, type TableInfo, type ViewInfo, type WriteUpdate, } from "./core/types.js";
12
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,KAAK,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,eAAe,EACf,KAAK,eAAe,EACpB,SAAS,EACT,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,aAAa,EACb,cAAc,EACd,WAAW,EACX,uBAAuB,EACvB,KAAK,UAAU,EACf,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC"}
package/dist/core.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The grid without React (§4 of react.md): the store, the client of the messages and the transports. Runs in
3
+ * browsers, workers and servers.
4
+ */
5
+ export { BLOCK_ROWS } from "./core/cache.js";
6
+ export { GridClient } from "./core/client.js";
7
+ export { RequestIds } from "./core/request-ids.js";
8
+ export { CACHE_BYTES, createGridStore, GridStore } from "./core/store.js";
9
+ export { httpTransport, localTransport, serveEngine, serverFunctionTransport, workerTransport } from "./core/transports.js";
10
+ export { GridError } from "./core/types.js";
11
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BLOCK_ROWS","GridClient","RequestIds","CACHE_BYTES","createGridStore","GridStore","httpTransport","localTransport","serveEngine","serverFunctionTransport","workerTransport","GridError"],"sources":["core.ts"],"sourcesContent":["/**\n * The grid without React (§4 of react.md): the store, the client of the messages and the transports. Runs in\n * browsers, workers and servers.\n */\nexport { BLOCK_ROWS } from \"./core/cache.js\";\nexport { GridClient, type Transport } from \"./core/client.js\";\nexport { type Handler, RequestIds } from \"./core/request-ids.js\";\nexport type { Viewport } from \"./core/rows.js\";\nexport {\n CACHE_BYTES,\n createGridStore,\n type DispatchOptions,\n GridStore,\n type GridStoreOptions,\n} from \"./core/store.js\";\nexport {\n type Engine,\n type HttpTransportOptions,\n httpTransport,\n localTransport,\n serveEngine,\n serverFunctionTransport,\n type WorkerLike,\n workerTransport,\n} from \"./core/transports.js\";\nexport {\n type CommandOutcome,\n type Edits,\n type FailedWrite,\n GridError,\n type GridSnapshot,\n type InitialView,\n type OpenOptions,\n type RequestMessage,\n type RowsResult,\n type TableInfo,\n type ViewInfo,\n type WriteUpdate,\n} from \"./core/types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,UAAU,QAAwB,kBAAkB;AAC7D,SAAuBC,UAAU,QAAQ,uBAAuB;AAEhE,SACEC,WAAW,EACXC,eAAe,EAEfC,SAAS,QAEJ,iBAAiB;AACxB,SAGEC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAEvBC,eAAe,QACV,sBAAsB;AAC7B,SAIEC,SAAS,QASJ,iBAAiB","ignoreList":[]}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,16 @@
1
- export * from "vastgrid-core";
2
- export { type ColumnState, CopyTooLargeError, GridController, type GridOptions, type Hit, type HitZone, } from "./controller.js";
3
- export { DataGrid, type DataGridHandle, type DataGridProps } from "./data-grid.js";
4
- export { en, ja, type Messages, messagesFor } from "./messages.js";
5
- export { CanvasRenderer } from "./renderer.js";
6
- export { type GridTheme, resolveTheme } from "./theme.js";
1
+ export type { CommandName, CommandOutputs, GridCommand, GridDocument, GridSession } from "vastgrid-spec";
2
+ export type { Geometry, Hit } from "./canvas/geometry.js";
3
+ export { GridCanvas, type Settled } from "./canvas/grid-canvas.js";
4
+ export type { CellAction, CellHooks, CellStyle, ColumnGroup, DrawCellArgs, GridCell } from "./canvas/hooks.js";
5
+ export { isApple, type KeyInput, keyCommand } from "./canvas/keys.js";
6
+ /**
7
+ * vastgrid 0.2 for React (react.md): `DataGrid`, the hooks that read and change its store, and what the store
8
+ * and the transports give (also in `vastgrid/core`, without React).
9
+ */
10
+ export * from "./core.js";
11
+ export { DataGrid, type DataGridHandle, type DataGridProps, GridProvider } from "./react/data-grid.js";
12
+ export type { DetailPanelProps } from "./react/detail-panel.js";
13
+ export type { CellActionEvent } from "./react/grid-body.js";
14
+ export { readRows, shallowEqual, useCreateGridStore, useGridDispatch, useGridRows, useGridSelector, useGridStore, } from "./react/hooks.js";
15
+ export { type GridMessages, messagesFor } from "./react/messages.js";
7
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,WAAW,EAChB,iBAAiB,EACjB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,KAAK,OAAO,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzG,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE;;;GAGG;AACH,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACvG,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,eAAe,EACf,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,13 @@
1
- export * from "vastgrid-core";
2
- export { CopyTooLargeError, GridController, } from "./controller.js";
3
- export { DataGrid } from "./data-grid.js";
4
- export { en, ja, messagesFor } from "./messages.js";
5
- export { CanvasRenderer } from "./renderer.js";
6
- export { resolveTheme } from "./theme.js";
7
- //# sourceMappingURL=index.js.map
1
+ "use client";
2
+
3
+ export { GridCanvas } from "./canvas/grid-canvas.js";
4
+ export { isApple, keyCommand } from "./canvas/keys.js";
5
+ /**
6
+ * vastgrid 0.2 for React (react.md): `DataGrid`, the hooks that read and change its store, and what the store
7
+ * and the transports give (also in `vastgrid/core`, without React).
8
+ */
9
+ export * from "./core.js";
10
+ export { DataGrid, GridProvider } from "./react/data-grid.js";
11
+ export { readRows, shallowEqual, useCreateGridStore, useGridDispatch, useGridRows, useGridSelector, useGridStore } from "./react/hooks.js";
12
+ export { messagesFor } from "./react/messages.js";
13
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAEL,iBAAiB,EACjB,cAAc,GAIf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAA2C,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,EAAE,EAAE,EAAE,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAkB,YAAY,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"names":["GridCanvas","isApple","keyCommand","DataGrid","GridProvider","readRows","shallowEqual","useCreateGridStore","useGridDispatch","useGridRows","useGridSelector","useGridStore","messagesFor"],"sources":["index.ts"],"sourcesContent":["\"use client\";\n\nexport type { CommandName, CommandOutputs, GridCommand, GridDocument, GridSession } from \"vastgrid-spec\";\nexport type { Geometry, Hit } from \"./canvas/geometry.js\";\nexport { GridCanvas, type Settled } from \"./canvas/grid-canvas.js\";\nexport type { CellAction, CellHooks, CellStyle, ColumnGroup, DrawCellArgs, GridCell } from \"./canvas/hooks.js\";\nexport { isApple, type KeyInput, keyCommand } from \"./canvas/keys.js\";\n/**\n * vastgrid 0.2 for React (react.md): `DataGrid`, the hooks that read and change its store, and what the store\n * and the transports give (also in `vastgrid/core`, without React).\n */\nexport * from \"./core.js\";\nexport { DataGrid, type DataGridHandle, type DataGridProps, GridProvider } from \"./react/data-grid.js\";\nexport type { DetailPanelProps } from \"./react/detail-panel.js\";\nexport type { CellActionEvent } from \"./react/grid-body.js\";\nexport {\n readRows,\n shallowEqual,\n useCreateGridStore,\n useGridDispatch,\n useGridRows,\n useGridSelector,\n useGridStore,\n} from \"./react/hooks.js\";\nexport { type GridMessages, messagesFor } from \"./react/messages.js\";\n"],"mappings":"AAAA,YAAY;;AAIZ,SAASA,UAAU,QAAsB,yBAAyB;AAElE,SAASC,OAAO,EAAiBC,UAAU,QAAQ,kBAAkB;AACrE;AACA;AACA;AACA;AACA,cAAc,WAAW;AACzB,SAASC,QAAQ,EAA2CC,YAAY,QAAQ,sBAAsB;AAGtG,SACEC,QAAQ,EACRC,YAAY,EACZC,kBAAkB,EAClBC,eAAe,EACfC,WAAW,EACXC,eAAe,EACfC,YAAY,QACP,kBAAkB;AACzB,SAA4BC,WAAW,QAAQ,qBAAqB","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import type { GridCanvas } from "../canvas/grid-canvas.js";
2
+ /** The id of the element of a cell, for `aria-activedescendant`. */
3
+ export declare function cellId(id: string, row: number, column: number): string;
4
+ /**
5
+ * The rows on screen as ARIA rows and cells under the canvas (§6.4 of react.md), placed over the cells they
6
+ * stand for and drawn transparent, with the row of the active cell when it is elsewhere. They follow the canvas
7
+ * when scrolling pauses, in a Transition: one commit at a lower priority than anything the person does.
8
+ */
9
+ export declare function AccessibleRows({ canvas, id }: {
10
+ canvas: GridCanvas;
11
+ id: string;
12
+ }): import("react").JSX.Element;
13
+ //# sourceMappingURL=accessible-rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessible-rows.d.ts","sourceRoot":"","sources":["../../src/react/accessible-rows.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAW,MAAM,0BAA0B,CAAC;AAQpE,oEAAoE;AACpE,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAE7D;AAmJD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,+BA4EhF"}
@@ -0,0 +1,320 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { startTransition, useEffect, useState } from "react";
3
+ import { textOf } from "vastgrid-spec";
4
+ import { useGridSelector, useGridStore } from "./hooks.js";
5
+
6
+ /** Rows and columns that the accessibility tree holds at most. */
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ const MAX_ROWS = 200;
9
+ const MAX_COLUMNS = 60;
10
+
11
+ /** The id of the element of a cell, for `aria-activedescendant`. */
12
+ export function cellId(id, row, column) {
13
+ return `${id}-r${row}-c${column}`;
14
+ }
15
+ /** The display positions of the columns on screen: those that scroll into view, and those pinned. */
16
+ function shownColumns(settled, columns) {
17
+ const shown = [];
18
+ for (let column = 0; column < columns.length && shown.length < MAX_COLUMNS; column++) {
19
+ const scrolls = column >= settled.left && column <= settled.right;
20
+ if (scrolls || columns[column].setting.pin !== undefined) shown.push(column);
21
+ }
22
+ return shown;
23
+ }
24
+
25
+ /** A box of the canvas, in the scroller's content. */
26
+ function boxOf(canvas, x, y, width, height) {
27
+ return {
28
+ left: canvas.geometry.scrollX.native + x,
29
+ top: canvas.geometry.scrollY.native + y,
30
+ width,
31
+ height
32
+ };
33
+ }
34
+
35
+ /** A row's cells; a row that is not on screen is placed at the top of the screen. */
36
+ function readRow(canvas, store, columns, shown, row, onScreen) {
37
+ const {
38
+ geometry
39
+ } = canvas;
40
+ const y = onScreen ? geometry.rowY(row) : geometry.headerHeight;
41
+ const cells = shown.map(column => {
42
+ const item = columns[column].column;
43
+ const value = store.cell(row, item.name);
44
+ return {
45
+ column,
46
+ name: item.name,
47
+ text: value === undefined || value === null ? "" : canvas.text(row, item, value),
48
+ description: canvas.styleOf(row, item.name)?.description,
49
+ action: canvas.actionAt(row, column)?.action,
50
+ ...boxOf(canvas, geometry.columnX(column), y, geometry.columnWidth(column), geometry.rowHeight)
51
+ };
52
+ });
53
+ return {
54
+ row,
55
+ cells
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Where the headers and the cells on screen are, in the scroller's content, and their text. The canvas and the
61
+ * cache change inside their objects, so `settled` is an argument: they are read again when scrolling pauses or
62
+ * rows arrive (memoization, React Compiler's included, keys on it), and not when the selection moves.
63
+ */
64
+ function readScreen(canvas, store, settled, columns) {
65
+ const {
66
+ geometry
67
+ } = canvas;
68
+ const shown = shownColumns(settled, columns);
69
+ const header = shown.map(column => ({
70
+ column,
71
+ name: columns[column].column.name,
72
+ text: columns[column].setting.format?.label ?? columns[column].column.name,
73
+ groups: canvas.groupNames(column).join(" › "),
74
+ ...boxOf(canvas, geometry.columnX(column), 0, geometry.columnWidth(column), geometry.headerHeight)
75
+ }));
76
+ const rows = [];
77
+ const end = Math.min(settled.top + settled.rows, settled.top + MAX_ROWS);
78
+ for (let row = settled.top; row < end; row++) rows.push(readRow(canvas, store, columns, shown, row, true));
79
+ return {
80
+ header,
81
+ rows,
82
+ shown,
83
+ end
84
+ };
85
+ }
86
+
87
+ /** The display positions of a row's selected cells (§5.2), as text that stays the same while they do. */
88
+ function selectedOf(ranges, active, row) {
89
+ const selected = [];
90
+ for (const cell of row.cells) {
91
+ const inRange = (ranges ?? []).some(range => (range.rows === "all" || row.row >= range.rows[0] && row.row < range.rows[1]) && (range.columns === "all" || range.columns.includes(cell.name)));
92
+ if (inRange || active?.row === row.row && active.column === cell.name) selected.push(cell.column);
93
+ }
94
+ return selected.join(",");
95
+ }
96
+ function sortOf(sort, column) {
97
+ const key = sort?.find(item => item.column === column);
98
+ return key ? key.direction === "asc" ? "ascending" : "descending" : undefined;
99
+ }
100
+ const style = box => ({
101
+ left: box.left,
102
+ top: box.top,
103
+ width: box.width,
104
+ height: box.height
105
+ });
106
+
107
+ /** A row of the accessibility tree; it renders again only when its cells or its selected cells change. */
108
+ function AccessibleRow(t0) {
109
+ const $ = _c(14);
110
+ const {
111
+ id,
112
+ row,
113
+ selected
114
+ } = t0;
115
+ let t1;
116
+ if ($[0] !== selected) {
117
+ t1 = new Set(selected === "" ? [] : selected.split(",").map(Number));
118
+ $[0] = selected;
119
+ $[1] = t1;
120
+ } else {
121
+ t1 = $[1];
122
+ }
123
+ const marked = t1;
124
+ const t2 = row.row + 2;
125
+ let t3;
126
+ if ($[2] !== id || $[3] !== marked || $[4] !== row.cells || $[5] !== row.row) {
127
+ let t4;
128
+ if ($[7] !== id || $[8] !== marked || $[9] !== row.row) {
129
+ t4 = cell => /*#__PURE__*/_jsx("div", {
130
+ id: cellId(id, row.row, cell.column),
131
+ role: "gridcell",
132
+ "aria-colindex": cell.column + 1,
133
+ "aria-selected": marked.has(cell.column),
134
+ "aria-description": cell.description,
135
+ style: style(cell),
136
+ children: cell.action?.kind === "link" ? /*#__PURE__*/_jsx("span", {
137
+ role: "link",
138
+ "aria-label": cell.action.label,
139
+ children: cell.text
140
+ }) : cell.action?.kind === "button" ? /*#__PURE__*/_jsx("span", {
141
+ role: "button",
142
+ "aria-label": cell.action.label,
143
+ children: cell.text
144
+ }) : cell.text
145
+ }, cell.name);
146
+ $[7] = id;
147
+ $[8] = marked;
148
+ $[9] = row.row;
149
+ $[10] = t4;
150
+ } else {
151
+ t4 = $[10];
152
+ }
153
+ t3 = row.cells.map(t4);
154
+ $[2] = id;
155
+ $[3] = marked;
156
+ $[4] = row.cells;
157
+ $[5] = row.row;
158
+ $[6] = t3;
159
+ } else {
160
+ t3 = $[6];
161
+ }
162
+ let t4;
163
+ if ($[11] !== t2 || $[12] !== t3) {
164
+ t4 = /*#__PURE__*/_jsx("div", {
165
+ role: "row",
166
+ "aria-rowindex": t2,
167
+ children: t3
168
+ });
169
+ $[11] = t2;
170
+ $[12] = t3;
171
+ $[13] = t4;
172
+ } else {
173
+ t4 = $[13];
174
+ }
175
+ return t4;
176
+ }
177
+
178
+ /**
179
+ * The rows on screen as ARIA rows and cells under the canvas (§6.4 of react.md), placed over the cells they
180
+ * stand for and drawn transparent, with the row of the active cell when it is elsewhere. They follow the canvas
181
+ * when scrolling pauses, in a Transition: one commit at a lower priority than anything the person does.
182
+ */
183
+ export function AccessibleRows(t0) {
184
+ const $ = _c(25);
185
+ const {
186
+ canvas,
187
+ id
188
+ } = t0;
189
+ const {
190
+ geometry
191
+ } = canvas;
192
+ const store = useGridStore();
193
+ let t1;
194
+ if ($[0] !== canvas) {
195
+ t1 = () => canvas.getSettled();
196
+ $[0] = canvas;
197
+ $[1] = t1;
198
+ } else {
199
+ t1 = $[1];
200
+ }
201
+ const [settled, setSettled] = useState(t1);
202
+ let t2;
203
+ let t3;
204
+ if ($[2] !== canvas) {
205
+ t2 = () => canvas.subscribeSettled(() => {
206
+ startTransition(() => setSettled(canvas.getSettled()));
207
+ });
208
+ t3 = [canvas];
209
+ $[2] = canvas;
210
+ $[3] = t2;
211
+ $[4] = t3;
212
+ } else {
213
+ t2 = $[3];
214
+ t3 = $[4];
215
+ }
216
+ useEffect(t2, t3);
217
+ const columns = useGridSelector(_temp);
218
+ const sort = useGridSelector(_temp2);
219
+ const selection = useGridSelector(_temp3);
220
+ const active = useGridSelector(_temp4);
221
+ const totals = useGridSelector(_temp5);
222
+ let t4;
223
+ if ($[5] !== active || $[6] !== canvas || $[7] !== columns || $[8] !== geometry.bottom || $[9] !== geometry.footer || $[10] !== geometry.rowCount || $[11] !== id || $[12] !== selection || $[13] !== settled || $[14] !== sort || $[15] !== store || $[16] !== totals?.columns || $[17] !== totals?.values) {
224
+ const screen = readScreen(canvas, store, settled, columns);
225
+ const elsewhere = active && (active.row < settled.top || active.row >= screen.end) && active.row < geometry.rowCount ? readRow(canvas, store, columns, screen.shown, active.row, false) : null;
226
+ const rows = elsewhere ? [...screen.rows, elsewhere].sort(_temp6) : screen.rows;
227
+ let t5;
228
+ if ($[19] !== sort) {
229
+ t5 = cell => /*#__PURE__*/_jsx("div", {
230
+ role: "columnheader",
231
+ "aria-colindex": cell.column + 1,
232
+ "aria-sort": sortOf(sort, cell.name),
233
+ "aria-description": cell.groups || undefined,
234
+ style: style(cell),
235
+ children: cell.text
236
+ }, cell.name);
237
+ $[19] = sort;
238
+ $[20] = t5;
239
+ } else {
240
+ t5 = $[20];
241
+ }
242
+ let t6;
243
+ if ($[21] !== active || $[22] !== id || $[23] !== selection) {
244
+ t6 = row => /*#__PURE__*/_jsx(AccessibleRow, {
245
+ id: id,
246
+ row: row,
247
+ selected: selectedOf(selection, active, row)
248
+ }, row.row);
249
+ $[21] = active;
250
+ $[22] = id;
251
+ $[23] = selection;
252
+ $[24] = t6;
253
+ } else {
254
+ t6 = $[24];
255
+ }
256
+ t4 = /*#__PURE__*/_jsxs("div", {
257
+ className: "vg-a11y",
258
+ role: "rowgroup",
259
+ children: [/*#__PURE__*/_jsx("div", {
260
+ role: "row",
261
+ "aria-rowindex": 1,
262
+ children: screen.header.map(t5)
263
+ }), rows.map(t6), geometry.footer > 0 && /*#__PURE__*/_jsx("div", {
264
+ role: "row",
265
+ "aria-rowindex": geometry.rowCount + 2,
266
+ children: screen.header.map(cell_0 => {
267
+ const value = totals?.values[cell_0.name];
268
+ const type = totals?.columns[cell_0.name];
269
+ return /*#__PURE__*/_jsx("div", {
270
+ role: "gridcell",
271
+ "aria-colindex": cell_0.column + 1,
272
+ style: {
273
+ left: cell_0.left,
274
+ top: geometry.bottom,
275
+ width: cell_0.width,
276
+ height: geometry.footer
277
+ },
278
+ children: value === undefined || value === null || !type ? "" : textOf(value, type) ?? ""
279
+ }, cell_0.name);
280
+ })
281
+ })]
282
+ });
283
+ $[5] = active;
284
+ $[6] = canvas;
285
+ $[7] = columns;
286
+ $[8] = geometry.bottom;
287
+ $[9] = geometry.footer;
288
+ $[10] = geometry.rowCount;
289
+ $[11] = id;
290
+ $[12] = selection;
291
+ $[13] = settled;
292
+ $[14] = sort;
293
+ $[15] = store;
294
+ $[16] = totals?.columns;
295
+ $[17] = totals?.values;
296
+ $[18] = t4;
297
+ } else {
298
+ t4 = $[18];
299
+ }
300
+ return t4;
301
+ }
302
+ function _temp6(a, b) {
303
+ return a.row - b.row;
304
+ }
305
+ function _temp5(snapshot_3) {
306
+ return snapshot_3.totals;
307
+ }
308
+ function _temp4(snapshot_2) {
309
+ return snapshot_2.session.active;
310
+ }
311
+ function _temp3(snapshot_1) {
312
+ return snapshot_1.session.selection;
313
+ }
314
+ function _temp2(snapshot_0) {
315
+ return snapshot_0.document.plan?.sort;
316
+ }
317
+ function _temp(snapshot) {
318
+ return snapshot.displayed;
319
+ }
320
+ //# sourceMappingURL=accessible-rows.js.map