vastgrid 0.1.1 → 0.2.1

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 +151 -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 +42 -17
  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 +169 -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 -68
  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 -22
  258. package/dist/components/filter-panel.d.ts.map +0 -1
  259. package/dist/components/filter-panel.js +0 -169
  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 -227
  274. package/dist/controller.d.ts.map +0 -1
  275. package/dist/controller.js +0 -845
  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 -704
  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 -180
  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 -293
  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 -945
  308. package/src/data-grid.tsx +0 -1035
  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,105 @@
1
+ /**
2
+ * The conditions of a plan's `where` (§6.2.1 of the specification) as a tree that the conditions menu edits: groups
3
+ * whose items all hold (`and`) or one of which holds (`or`), conditions on one column in the column menu's terms
4
+ * (`ColumnFilter`), and expressions that it does not take apart, kept as they are.
5
+ */
6
+ import { columnsOf, joinParts, partsOf } from "vastgrid-spec";
7
+ import { FilterTextError, filterParts, readFilter } from "./filters.js";
8
+ let nextId = 1;
9
+
10
+ /** A new id for a node, for React's keys. */
11
+ export function nodeId() {
12
+ return nextId++;
13
+ }
14
+ function nodeOf(expr) {
15
+ const names = columnsOf(expr);
16
+ if (names.size === 1) {
17
+ const [name] = names;
18
+ const filter = readFilter(partsOf(expr), name);
19
+ if (filter !== null && filter !== "other" && filter.kind === "condition") {
20
+ return {
21
+ kind: "condition",
22
+ id: nodeId(),
23
+ column: name,
24
+ filter
25
+ };
26
+ }
27
+ }
28
+ if ("fn" in expr && (expr.fn === "and" || expr.fn === "or")) {
29
+ return {
30
+ kind: "group",
31
+ id: nodeId(),
32
+ op: expr.fn,
33
+ items: expr.args.map(nodeOf)
34
+ };
35
+ }
36
+ return {
37
+ kind: "expression",
38
+ id: nodeId(),
39
+ expr
40
+ };
41
+ }
42
+
43
+ /**
44
+ * The conditions of `where` as a group of its parts that are not the search (`and`); a `where` that is one `or`
45
+ * is that group.
46
+ */
47
+ export function readConditions(where) {
48
+ const parts = partsOf(where).filter(part => !("search" in part));
49
+ if (parts.length === 1) {
50
+ const only = nodeOf(parts[0]);
51
+ if (only.kind === "group") return only;
52
+ }
53
+ return {
54
+ kind: "group",
55
+ id: nodeId(),
56
+ op: "and",
57
+ items: parts.map(nodeOf)
58
+ };
59
+ }
60
+
61
+ /** A condition that does not compile: the node, and which of its texts. */
62
+ export class ConditionError extends Error {
63
+ constructor(node, side) {
64
+ super("The text is not a value of the column.");
65
+ this.node = node;
66
+ this.side = side;
67
+ }
68
+ }
69
+ function exprOf(node, columns) {
70
+ switch (node.kind) {
71
+ case "expression":
72
+ return node.expr;
73
+ case "condition":
74
+ {
75
+ const column = columns.get(node.column);
76
+ if (!column) return undefined;
77
+ try {
78
+ return joinParts(filterParts(node.filter, column));
79
+ } catch (error) {
80
+ if (error instanceof FilterTextError) throw new ConditionError(node.id, error.side);
81
+ throw error;
82
+ }
83
+ }
84
+ case "group":
85
+ {
86
+ const items = node.items.flatMap(item => exprOf(item, columns) ?? []);
87
+ if (items.length <= 1) return items[0];
88
+ return {
89
+ fn: node.op,
90
+ args: items
91
+ };
92
+ }
93
+ }
94
+ }
95
+
96
+ /**
97
+ * The `where` of `filter.set` for a tree (the search is kept by the command): an `and` group gives its items as
98
+ * parts; conditions without text keep every row and are left out. Text that is not a value of its column throws a
99
+ * `ConditionError`.
100
+ */
101
+ export function writeConditions(group, columns) {
102
+ const byName = new Map(columns.map(column => [column.name, column]));
103
+ return exprOf(group, byName) ?? null;
104
+ }
105
+ //# sourceMappingURL=conditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["columnsOf","joinParts","partsOf","FilterTextError","filterParts","readFilter","nextId","nodeId","nodeOf","expr","names","size","name","filter","kind","id","column","fn","op","items","args","map","readConditions","where","parts","part","length","only","ConditionError","Error","constructor","node","side","exprOf","columns","get","undefined","error","flatMap","item","writeConditions","group","byName","Map"],"sources":["conditions.ts"],"sourcesContent":["/**\n * The conditions of a plan's `where` (§6.2.1 of the specification) as a tree that the conditions menu edits: groups\n * whose items all hold (`and`) or one of which holds (`or`), conditions on one column in the column menu's terms\n * (`ColumnFilter`), and expressions that it does not take apart, kept as they are.\n */\nimport { type Column, columnsOf, type Expr, type FunctionName, joinParts, partsOf } from \"vastgrid-spec\";\nimport { type ColumnFilter, FilterTextError, filterParts, readFilter } from \"./filters.js\";\n\nexport type ConditionNode =\n | { kind: \"group\"; id: number; op: \"and\" | \"or\"; items: ConditionNode[] }\n | { kind: \"condition\"; id: number; column: string; filter: ColumnFilter & { kind: \"condition\" } }\n | { kind: \"expression\"; id: number; expr: Expr };\n\nlet nextId = 1;\n\n/** A new id for a node, for React's keys. */\nexport function nodeId() {\n return nextId++;\n}\n\nfunction nodeOf(expr: Expr): ConditionNode {\n const names = columnsOf(expr);\n if (names.size === 1) {\n const [name] = names;\n const filter = readFilter(partsOf(expr), name);\n if (filter !== null && filter !== \"other\" && filter.kind === \"condition\") {\n return { kind: \"condition\", id: nodeId(), column: name, filter };\n }\n }\n if (\"fn\" in expr && (expr.fn === \"and\" || expr.fn === \"or\")) {\n return { kind: \"group\", id: nodeId(), op: expr.fn, items: expr.args.map(nodeOf) };\n }\n return { kind: \"expression\", id: nodeId(), expr };\n}\n\n/**\n * The conditions of `where` as a group of its parts that are not the search (`and`); a `where` that is one `or`\n * is that group.\n */\nexport function readConditions(where: Expr | undefined): ConditionNode & { kind: \"group\" } {\n const parts = partsOf(where).filter((part) => !(\"search\" in part));\n if (parts.length === 1) {\n const only = nodeOf(parts[0]);\n if (only.kind === \"group\") return only;\n }\n return { kind: \"group\", id: nodeId(), op: \"and\", items: parts.map(nodeOf) };\n}\n\n/** A condition that does not compile: the node, and which of its texts. */\nexport class ConditionError extends Error {\n constructor(\n readonly node: number,\n readonly side: \"first\" | \"second\",\n ) {\n super(\"The text is not a value of the column.\");\n }\n}\n\nfunction exprOf(node: ConditionNode, columns: ReadonlyMap<string, Column>): Expr | undefined {\n switch (node.kind) {\n case \"expression\":\n return node.expr;\n case \"condition\": {\n const column = columns.get(node.column);\n if (!column) return undefined;\n try {\n return joinParts(filterParts(node.filter, column));\n } catch (error) {\n if (error instanceof FilterTextError) throw new ConditionError(node.id, error.side);\n throw error;\n }\n }\n case \"group\": {\n const items = node.items.flatMap((item) => exprOf(item, columns) ?? []);\n if (items.length <= 1) return items[0];\n return { fn: node.op as FunctionName, args: items };\n }\n }\n}\n\n/**\n * The `where` of `filter.set` for a tree (the search is kept by the command): an `and` group gives its items as\n * parts; conditions without text keep every row and are left out. Text that is not a value of its column throws a\n * `ConditionError`.\n */\nexport function writeConditions(group: ConditionNode & { kind: \"group\" }, columns: readonly Column[]): Expr | null {\n const byName = new Map(columns.map((column) => [column.name, column]));\n return exprOf(group, byName) ?? null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAAsBA,SAAS,EAAgCC,SAAS,EAAEC,OAAO,QAAQ,eAAe;AACxG,SAA4BC,eAAe,EAAEC,WAAW,EAAEC,UAAU,QAAQ,cAAc;AAO1F,IAAIC,MAAM,GAAG,CAAC;;AAEd;AACA,OAAO,SAASC,MAAMA,CAAA,EAAG;EACvB,OAAOD,MAAM,EAAE;AACjB;AAEA,SAASE,MAAMA,CAACC,IAAU,EAAiB;EACzC,MAAMC,KAAK,GAAGV,SAAS,CAACS,IAAI,CAAC;EAC7B,IAAIC,KAAK,CAACC,IAAI,KAAK,CAAC,EAAE;IACpB,MAAM,CAACC,IAAI,CAAC,GAAGF,KAAK;IACpB,MAAMG,MAAM,GAAGR,UAAU,CAACH,OAAO,CAACO,IAAI,CAAC,EAAEG,IAAI,CAAC;IAC9C,IAAIC,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAK,OAAO,IAAIA,MAAM,CAACC,IAAI,KAAK,WAAW,EAAE;MACxE,OAAO;QAAEA,IAAI,EAAE,WAAW;QAAEC,EAAE,EAAER,MAAM,CAAC,CAAC;QAAES,MAAM,EAAEJ,IAAI;QAAEC;MAAO,CAAC;IAClE;EACF;EACA,IAAI,IAAI,IAAIJ,IAAI,KAAKA,IAAI,CAACQ,EAAE,KAAK,KAAK,IAAIR,IAAI,CAACQ,EAAE,KAAK,IAAI,CAAC,EAAE;IAC3D,OAAO;MAAEH,IAAI,EAAE,OAAO;MAAEC,EAAE,EAAER,MAAM,CAAC,CAAC;MAAEW,EAA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AOoB,SAAS;QAC7B,IAAI;UACF,OAAOnC,SAAS,CAACG,WAAW,CAAC2B,IAAI,CAAClB,MAAM,EAAEG,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC,OAAOqB,KAAK,EAAE;UACd,IAAIA,KAAK,YAAYlC,eAAe,EAAE,MAAM,IAAIyB,cAAc,CAACG,IAAI,CAAChB,EAAE,EAAEsB,KAAK,CAACL,IAAI,CAAC;UACnF,MAAMK,KAAK;QACb;MACF;IACA,KAAK,OAAO;MAAE;QACZ,MAAMlB,KAAK,GAAGY,IAAI,CAACZ,KAAK,CAACmB,OAAO,CAAEC,IAAI,IAAKN,MAAM,CAACM,IAAI,EAAEL,OAAO,CAAC,IAAI,EAAE,CAAC;QACvE,IAAIf,KAAK,CAACO,MAAM,IAAI,CAAC,EAAE,OAAOP,KAAK,CAAC,CAAC,CAAC;QACtC,OAAO;UAAEF,EAAE,EAAEc,IAAI,CAACb,EAAkB;UAAEE,IAAI,EAAED;QAAM,CAAC;MACrD;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASqB,eAAeA,CAACC,KAAwC,EAAEP,OAA0B,EAAe;EACjH,MAAMQ,MAAM,GAAG,IAAIC,GAAG,CAACT,OAAO,CAACb,GAAG,CAAEL,MAAM,IAAK,CAACA,MAAM,CAACJ,IAAI,EAAEI,MAAM,CAAC,CAAC,CAAC;EACtE,OAAOiB,MAAM,CAACQ,KAAK,EAAEC,MAAM,CAAC,IAAI,IAAI;AACtC","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Evaluates the `when` of a style rule (§5.1 of the specification) over a row of the view on screen, in the grid:
3
+ * the logic and comparisons that the menus write (§4.4: `and`, `or`, `not`, `coalesce`, comparisons, `in`,
4
+ * `is_null`, `is_blank`, `contains`, `starts_with` and `ends_with` over `lower` and `text`), with nulls as §3.6 has
5
+ * them. Other expressions are not evaluated here, and their rules are skipped.
6
+ */
7
+ import { type Column, type Expr, type JsonValue } from "vastgrid-spec";
8
+ /** Reads the value of a column of the row; undefined while it is not read. */
9
+ export type RowReader = (column: string) => JsonValue | undefined;
10
+ /** A compiled `when`: true, false or null for a row, or undefined while a value it needs is not read. */
11
+ export type Rule = (row: RowReader) => boolean | null | undefined;
12
+ /**
13
+ * A rule's `when` compiled over the columns of the view, or null when it names a column the view does not have or a
14
+ * function that the grid does not evaluate. `columns` lists the columns it reads.
15
+ */
16
+ export declare function compileRule(when: Expr, view: readonly Column[]): {
17
+ rule: Rule;
18
+ columns: string[];
19
+ } | null;
20
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/core/evaluate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,MAAM,EAAa,KAAK,IAAI,EAAW,KAAK,SAAS,EAAU,MAAM,eAAe,CAAC;AAQnG,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;AAElE,yGAAyG;AACzG,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AA0LlE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAYzG"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Evaluates the `when` of a style rule (§5.1 of the specification) over a row of the view on screen, in the grid:
3
+ * the logic and comparisons that the menus write (§4.4: `and`, `or`, `not`, `coalesce`, comparisons, `in`,
4
+ * `is_null`, `is_blank`, `contains`, `starts_with` and `ends_with` over `lower` and `text`), with nulls as §3.6 has
5
+ * them. Other expressions are not evaluated here, and their rules are skipped.
6
+ */
7
+ import { columnsOf, floatOf, textOf } from "vastgrid-spec";
8
+
9
+ /** A value of an expression: a JSON value with its column's type, or a string or boolean that it made. */
10
+
11
+ /** Reads the value of a column of the row; undefined while it is not read. */
12
+
13
+ /** A compiled `when`: true, false or null for a row, or undefined while a value it needs is not read. */
14
+
15
+ const NUMERIC = new Set(["integer", "bigint", "decimal", "float"]);
16
+
17
+ /** Compares exact decimal texts (`-12.50`) by their digits. */
18
+ function compareDecimal(a, b) {
19
+ const sign = text => text.startsWith("-") ? -1 : 1;
20
+ const [ai, af = ""] = a.replace(/^[+-]/, "").split(".");
21
+ const [bi, bf = ""] = b.replace(/^[+-]/, "").split(".");
22
+ const isZero = (i, f) => /^0*$/.test(i) && /^0*$/.test(f);
23
+ const as = isZero(ai, af) ? 0 : sign(a);
24
+ const bs = isZero(bi, bf) ? 0 : sign(b);
25
+ if (as !== bs) return as - bs;
26
+ const whole = x => x.replace(/^0+(?=\d)/, "");
27
+ const [x, y] = [whole(ai), whole(bi)];
28
+ const width = Math.max(af.length, bf.length);
29
+ const left = `${x.padStart(Math.max(x.length, y.length), "0")}${af.padEnd(width, "0")}`;
30
+ const right = `${y.padStart(Math.max(x.length, y.length), "0")}${bf.padEnd(width, "0")}`;
31
+ return (left < right ? -1 : left > right ? 1 : 0) * as;
32
+ }
33
+
34
+ /** Orders two values of one kind (§3.1), or null when they do not compare. */
35
+ function compare(a, b) {
36
+ if (a.value === null || b.value === null) return null;
37
+ if (NUMERIC.has(a.type) || NUMERIC.has(b.type) || typeof a.value === "number" && typeof b.value === "number") {
38
+ const float = a.type === "float" || b.type === "float" || typeof a.value === "number" || typeof b.value === "number";
39
+ if (float && !(typeof a.value === "string" && typeof b.value === "string")) {
40
+ const x = floatOf(a.value);
41
+ const y = floatOf(b.value);
42
+ // NaN is the greatest number (§3.1).
43
+ if (Number.isNaN(x) || Number.isNaN(y)) return Number.isNaN(x) ? Number.isNaN(y) ? 0 : 1 : -1;
44
+ return x < y ? -1 : x > y ? 1 : 0;
45
+ }
46
+ return compareDecimal(String(a.value), String(b.value));
47
+ }
48
+ if (typeof a.value === "boolean" && typeof b.value === "boolean") return Number(a.value) - Number(b.value);
49
+ if (typeof a.value === "string" && typeof b.value === "string") {
50
+ // Code point order.
51
+ const x = [...a.value];
52
+ const y = [...b.value];
53
+ for (let index = 0; index < Math.min(x.length, y.length); index++) {
54
+ const difference = (x[index].codePointAt(0) ?? 0) - (y[index].codePointAt(0) ?? 0);
55
+ if (difference !== 0) return difference;
56
+ }
57
+ return x.length - y.length;
58
+ }
59
+ return null;
60
+ }
61
+
62
+ /** `lower` (§3.4): each code point by itself, kept when its lower case is not one code point. */
63
+ function lower(text) {
64
+ let out = "";
65
+ for (const point of text) {
66
+ if (point === "İ") {
67
+ out += "i";
68
+ continue;
69
+ }
70
+ const mapped = point.toLowerCase();
71
+ out += [...mapped].length === 1 ? mapped : point;
72
+ }
73
+ return out;
74
+ }
75
+ const PENDING = Symbol("pending");
76
+ function compile(expr, columns) {
77
+ if ("col" in expr) {
78
+ const column = columns.get(expr.col);
79
+ if (!column) return null;
80
+ return row => {
81
+ const value = row(column.name);
82
+ return value === undefined ? undefined : {
83
+ value,
84
+ type: column.type
85
+ };
86
+ };
87
+ }
88
+ if ("lit" in expr) {
89
+ const value = {
90
+ value: expr.lit,
91
+ type: expr.type ?? (typeof expr.lit === "number" ? Number.isInteger(expr.lit) ? "bigint" : "float" : "text")
92
+ };
93
+ return () => value;
94
+ }
95
+ if ("search" in expr) return null;
96
+ const args = expr.args.map(arg => compile(arg, columns));
97
+ if (args.some(arg => arg === null)) return null;
98
+ const parts = args;
99
+ const read = row => {
100
+ const values = [];
101
+ for (const part of parts) {
102
+ const value = part(row);
103
+ if (value === undefined) throw PENDING;
104
+ values.push(value);
105
+ }
106
+ return values;
107
+ };
108
+ const truth = value => ({
109
+ value,
110
+ type: "boolean"
111
+ });
112
+ const run = body => {
113
+ return row => {
114
+ try {
115
+ return body(read(row));
116
+ } catch (error) {
117
+ if (error === PENDING) return undefined;
118
+ throw error;
119
+ }
120
+ };
121
+ };
122
+ switch (expr.fn) {
123
+ case "and":
124
+ case "or":
125
+ {
126
+ const stop = expr.fn === "or";
127
+ return run(values => {
128
+ let unknown = false;
129
+ for (const {
130
+ value
131
+ } of values) {
132
+ if (value === stop) return truth(stop);
133
+ if (value === null) unknown = true;
134
+ }
135
+ return truth(unknown ? null : !stop);
136
+ });
137
+ }
138
+ case "not":
139
+ return run(([a]) => truth(a.value === null ? null : !a.value));
140
+ case "coalesce":
141
+ return run(values => values.find(item => item.value !== null) ?? values[values.length - 1]);
142
+ case "is_null":
143
+ return run(([a]) => truth(a.value === null));
144
+ case "is_blank":
145
+ return run(([a]) => truth(a.value === null || a.type === "string" && a.value === ""));
146
+ case "eq":
147
+ case "ne":
148
+ case "lt":
149
+ case "le":
150
+ case "gt":
151
+ case "ge":
152
+ {
153
+ const fn = expr.fn;
154
+ return run(([a, b]) => {
155
+ const order = compare(a, b);
156
+ if (order === null) return truth(null);
157
+ const result = fn === "eq" ? order === 0 : fn === "ne" ? order !== 0 : fn === "lt" ? order < 0 : fn === "le" ? order <= 0 : fn === "gt" ? order > 0 : order >= 0;
158
+ return truth(result);
159
+ });
160
+ }
161
+ case "in":
162
+ return run(([a, ...list]) => {
163
+ if (a.value === null) return truth(null);
164
+ return truth(list.some(item => compare(a, item) === 0));
165
+ });
166
+ case "text":
167
+ return run(([a]) => ({
168
+ value: a.type === "text" ? a.value : textOf(a.value, {
169
+ type: a.type
170
+ }),
171
+ type: "text"
172
+ }));
173
+ case "lower":
174
+ return run(([a]) => ({
175
+ value: typeof a.value === "string" ? lower(a.value) : null,
176
+ type: "text"
177
+ }));
178
+ case "contains":
179
+ case "starts_with":
180
+ case "ends_with":
181
+ {
182
+ const fn = expr.fn;
183
+ return run(([a, b]) => {
184
+ if (typeof a.value !== "string" || typeof b.value !== "string") return truth(null);
185
+ return truth(fn === "contains" ? a.value.includes(b.value) : fn === "starts_with" ? a.value.startsWith(b.value) : a.value.endsWith(b.value));
186
+ });
187
+ }
188
+ default:
189
+ return null;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * A rule's `when` compiled over the columns of the view, or null when it names a column the view does not have or a
195
+ * function that the grid does not evaluate. `columns` lists the columns it reads.
196
+ */
197
+ export function compileRule(when, view) {
198
+ const byName = new Map(view.map(column => [column.name, column]));
199
+ const compiled = compile(when, byName);
200
+ if (!compiled) return null;
201
+ return {
202
+ rule: row => {
203
+ const result = compiled(row);
204
+ if (result === undefined) return undefined;
205
+ return typeof result.value === "boolean" ? result.value : null;
206
+ },
207
+ columns: [...columnsOf(when)]
208
+ };
209
+ }
210
+ //# sourceMappingURL=evaluate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["columnsOf","floatOf","textOf","NUMERIC","Set","compareDecimal","a","b","sign","text","startsWith","ai","af","replace","split","bi","bf","isZero","i","f","test","as","bs","whole","x","y","width","Math","max","length","left","padStart","padEnd","right","compare","value","has","type","float","Number","isNaN","String","index","min","difference","codePointAt","lower","out","point","mapped","toLowerCase","PENDING","Symbol","compile","expr","columns","column","get","col","row","name","undefined","lit","isInteger","args","map","arg","some","parts","read","values","part","push","truth","run","body","error","fn","stop","unknown","find","item","order","result","list","includes","endsWith","compileRule","when","view","byName","Map","compiled","rule"],"sources":["evaluate.ts"],"sourcesContent":["/**\n * Evaluates the `when` of a style rule (§5.1 of the specification) over a row of the view on screen, in the grid:\n * the logic and comparisons that the menus write (§4.4: `and`, `or`, `not`, `coalesce`, comparisons, `in`,\n * `is_null`, `is_blank`, `contains`, `starts_with` and `ends_with` over `lower` and `text`), with nulls as §3.6 has\n * them. Other expressions are not evaluated here, and their rules are skipped.\n */\nimport { type Column, columnsOf, type Expr, floatOf, type JsonValue, textOf } from \"vastgrid-spec\";\n\n/** A value of an expression: a JSON value with its column's type, or a string or boolean that it made. */\ninterface Value {\n value: JsonValue;\n type: Column[\"type\"] | \"text\";\n}\n\n/** Reads the value of a column of the row; undefined while it is not read. */\nexport type RowReader = (column: string) => JsonValue | undefined;\n\n/** A compiled `when`: true, false or null for a row, or undefined while a value it needs is not read. */\nexport type Rule = (row: RowReader) => boolean | null | undefined;\n\nconst NUMERIC = new Set([\"integer\", \"bigint\", \"decimal\", \"float\"]);\n\n/** Compares exact decimal texts (`-12.50`) by their digits. */\nfunction compareDecimal(a: string, b: string): number {\n const sign = (text: string) => (text.startsWith(\"-\") ? -1 : 1);\n const [ai, af = \"\"] = a.replace(/^[+-]/, \"\").split(\".\");\n const [bi, bf = \"\"] = b.replace(/^[+-]/, \"\").split(\".\");\n const isZero = (i: string, f: string) => /^0*$/.test(i) && /^0*$/.test(f);\n const as = isZero(ai, af) ? 0 : sign(a);\n const bs = isZero(bi, bf) ? 0 : sign(b);\n if (as !== bs) return as - bs;\n const whole = (x: string) => x.replace(/^0+(?=\\d)/, \"\");\n const [x, y] = [whole(ai), whole(bi)];\n const width = Math.max(af.length, bf.length);\n const left = `${x.padStart(Math.max(x.length, y.length), \"0\")}${af.padEnd(width, \"0\")}`;\n const right = `${y.padStart(Math.max(x.length, y.length), \"0\")}${bf.padEnd(width, \"0\")}`;\n return (left < right ? -1 : left > right ? 1 : 0) * as;\n}\n\n/** Orders two values of one kind (§3.1), or null when they do not compare. */\nfunction compare(a: Value, b: Value): number | null {\n if (a.value === null || b.value === null) return null;\n if (NUMERIC.has(a.type) || NUMERIC.has(b.type) || (typeof a.value === \"number\" && typeof b.value === \"number\")) {\n const float =\n a.type === \"float\" || b.type === \"float\" || typeof a.value === \"number\" || typeof b.value === \"number\";\n if (float && !(typeof a.value === \"string\" && typeof b.value === \"string\")) {\n const x = floatOf(a.value);\n const y = floatOf(b.value);\n // NaN is the greatest number (§3.1).\n if (Number.isNaN(x) || Number.isNaN(y)) return Number.isNaN(x) ? (Number.isNaN(y) ? 0 : 1) : -1;\n return x < y ? -1 : x > y ? 1 : 0;\n }\n return compareDecimal(String(a.value), String(b.value));\n }\n if (typeof a.value === \"boolean\" && typeof b.value === \"boolean\") return Number(a.value) - Number(b.value);\n if (typeof a.value === \"string\" && typeof b.value === \"string\") {\n // Code point order.\n const x = [...a.value];\n const y = [...b.value];\n for (let index = 0; index < Math.min(x.length, y.length); index++) {\n const difference = (x[index].codePointAt(0) ?? 0) - (y[index].codePointAt(0) ?? 0);\n if (difference !== 0) return difference;\n }\n return x.length - y.length;\n }\n return null;\n}\n\n/** `lower` (§3.4): each code point by itself, kept when its lower case is not one code point. */\nfunction lower(text: string): string {\n let out = \"\";\n for (const point of text) {\n if (point === \"İ\") {\n out += \"i\";\n continue;\n }\n const mapped = point.toLowerCase();\n out += [...mapped].length === 1 ? mapped : point;\n }\n return out;\n}\n\ntype Compiled = (row: RowReader) => Value | undefined;\n\nconst PENDING = Symbol(\"pending\");\n\nfunction compile(expr: Expr, columns: ReadonlyMap<string, Column>): Compiled | null {\n if (\"col\" in expr) {\n const column = columns.get(expr.col);\n if (!column) return null;\n return (row) => {\n const value = row(column.name);\n return value === undefined ? undefined : { value, type: column.type };\n };\n }\n if (\"lit\" in expr) {\n const value: Value = {\n value: expr.lit,\n type: expr.type ?? (typeof expr.lit === \"number\" ? (Number.isInteger(expr.lit) ? \"bigint\" : \"float\") : \"text\"),\n };\n return () => value;\n }\n if (\"search\" in expr) return null;\n const args = expr.args.map((arg) => compile(arg, columns));\n if (args.some((arg) => arg === null)) return null;\n const parts = args as Compiled[];\n const read = (row: RowReader) => {\n const values: Value[] = [];\n for (const part of parts) {\n const value = part(row);\n if (value === undefined) throw PENDING;\n values.push(value);\n }\n return values;\n };\n const truth = (value: boolean | null): Value => ({ value, type: \"boolean\" });\n const run = (body: (values: Value[]) => Value): Compiled => {\n return (row) => {\n try {\n return body(read(row));\n } catch (error) {\n if (error === PENDING) return undefined;\n throw error;\n }\n };\n };\n switch (expr.fn) {\n case \"and\":\n case \"or\": {\n const stop = expr.fn === \"or\";\n return run((values) => {\n let unknown = false;\n for (const { value } of values) {\n if (value === stop) return truth(stop);\n if (value === null) unknown = true;\n }\n return truth(unknown ? null : !stop);\n });\n }\n case \"not\":\n return run(([a]) => truth(a.value === null ? null : !a.value));\n case \"coalesce\":\n return run((values) => values.find((item) => item.value !== null) ?? values[values.length - 1]);\n case \"is_null\":\n return run(([a]) => truth(a.value === null));\n case \"is_blank\":\n return run(([a]) => truth(a.value === null || (a.type === \"string\" && a.value === \"\")));\n case \"eq\":\n case \"ne\":\n case \"lt\":\n case \"le\":\n case \"gt\":\n case \"ge\": {\n const fn = expr.fn;\n return run(([a, b]) => {\n const order = compare(a, b);\n if (order === null) return truth(null);\n const result =\n fn === \"eq\"\n ? order === 0\n : fn === \"ne\"\n ? order !== 0\n : fn === \"lt\"\n ? order < 0\n : fn === \"le\"\n ? order <= 0\n : fn === \"gt\"\n ? order > 0\n : order >= 0;\n return truth(result);\n });\n }\n case \"in\":\n return run(([a, ...list]) => {\n if (a.value === null) return truth(null);\n return truth(list.some((item) => compare(a, item) === 0));\n });\n case \"text\":\n return run(([a]) => ({\n value: a.type === \"text\" ? a.value : textOf(a.value, { type: a.type } as Column),\n type: \"text\",\n }));\n case \"lower\":\n return run(([a]) => ({ value: typeof a.value === \"string\" ? lower(a.value) : null, type: \"text\" }));\n case \"contains\":\n case \"starts_with\":\n case \"ends_with\": {\n const fn = expr.fn;\n return run(([a, b]) => {\n if (typeof a.value !== \"string\" || typeof b.value !== \"string\") return truth(null);\n return truth(\n fn === \"contains\"\n ? a.value.includes(b.value)\n : fn === \"starts_with\"\n ? a.value.startsWith(b.value)\n : a.value.endsWith(b.value),\n );\n });\n }\n default:\n return null;\n }\n}\n\n/**\n * A rule's `when` compiled over the columns of the view, or null when it names a column the view does not have or a\n * function that the grid does not evaluate. `columns` lists the columns it reads.\n */\nexport function compileRule(when: Expr, view: readonly Column[]): { rule: Rule; columns: string[] } | null {\n const byName = new Map(view.map((column) => [column.name, column]));\n const compiled = compile(when, byName);\n if (!compiled) return null;\n return {\n rule: (row) => {\n const result = compiled(row);\n if (result === undefined) return undefined;\n return typeof result.value === \"boolean\" ?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J;IACA;MACE,OAAO,IAAI;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASoD,WAAWA,CAACC,IAAU,EAAEC,IAAuB,EAA4C;EACzG,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAACF,IAAI,CAACxB,GAAG,CAAET,MAAM,IAAK,CAACA,MAAM,CAACI,IAAI,EAAEJ,MAAM,CAAC,CAAC,CAAC;EACnE,MAAMoC,QAAQ,GAAGvC,OAAO,CAACmC,IAAI,EAAEE,MAAM,CAAC;EACtC,IAAI,CAACE,QAAQ,EAAE,OAAO,IAAI;EAC1B,OAAO;IACLC,IAAI,EAAGlC,GAAG,IAAK;MACb,MAAMwB,MAAM,GAAGS,QAAQ,CAACjC,GAAG,CAAC;MAC5B,IAAIwB,MAAM,KAAKtB,SAAS,EAAE,OAAOA,SAAS;MAC1C,OAAO,OAAOsB,MAAM,CAAChD,KAAK,KAAK,SAAS,GAAGgD,MAAM,CAAChD,KAAK,GAAG,IAAI;IAChE,CAAC;IACDoB,OAAO,EAAE,CAAC,GAAGvD,SAAS,CAACwF,IAAI,CAAC;EAC9B,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The filter of one column as the column menu edits it: values ticked in a list, or a condition. Each is written
3
+ * as the parts of `where` that `filter.column` sets (§6.2.1 of the specification), and read back from them.
4
+ */
5
+ import { type Column, type Expr, type JsonValue, type LogicalType, type Plan } from "vastgrid-spec";
6
+ export type FilterOperator = "eq" | "ne" | "lt" | "le" | "gt" | "ge" | "between" | "contains" | "notContains" | "startsWith" | "endsWith" | "blank" | "notBlank";
7
+ export type ColumnFilter =
8
+ /** Rows with one of `values`, or blank (§3.2) with `blank`; with `exclude`, the other rows. */
9
+ {
10
+ kind: "values";
11
+ values: JsonValue[];
12
+ blank: boolean;
13
+ exclude: boolean;
14
+ }
15
+ /** A condition on typed text: `first`, and `second` for `between`; an empty text leaves that side out. */
16
+ | {
17
+ kind: "condition";
18
+ operator: FilterOperator;
19
+ first: string;
20
+ second: string;
21
+ };
22
+ /** The operators offered for a column's type. */
23
+ export declare function operatorsFor(type: LogicalType): FilterOperator[];
24
+ /** Whether an operator takes no text. */
25
+ export declare function takesNoValue(operator: FilterOperator): operator is "blank" | "notBlank";
26
+ export declare class FilterTextError extends Error {
27
+ readonly side: "first" | "second";
28
+ constructor(side: "first" | "second");
29
+ }
30
+ /**
31
+ * The parts of `where` for a column's filter; none when it keeps every row. Text that is not a value of the column
32
+ * throws a `FilterTextError` (§7.3 reads it as a cell's text is read).
33
+ */
34
+ export declare function filterParts(filter: ColumnFilter, column: Column): Expr[];
35
+ /**
36
+ * The filter that the conditions of a column (§6.2.1) make, when the menu wrote them or they have the same shape;
37
+ * null when there are none, and `"other"` for conditions written otherwise (an agent, a saved view).
38
+ */
39
+ export declare function readFilter(parts: readonly Expr[], name: string): ColumnFilter | "other" | null;
40
+ /** The conditions of a column (§6.2.1): the parts of `where` that are not the search and refer to it and no other. */
41
+ export declare function conditionsOf(where: Expr | undefined, name: string): Expr[];
42
+ /**
43
+ * The plan whose rows are a column's values and how many rows have each, the most common first: the rows of
44
+ * `plan` without its conditions on the column (so that the list holds the values that other filters leave), and
45
+ * with those whose text contains `search`, ignoring letter case. Null when the plan groups rows.
46
+ */
47
+ export declare function valuesPlan(plan: Plan, name: string, search: string): {
48
+ plan: Plan;
49
+ count: string;
50
+ } | null;
51
+ //# sourceMappingURL=filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/core/filters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,IAAI,EAET,KAAK,SAAS,EAGd,KAAK,WAAW,EAChB,KAAK,IAAI,EAGV,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,cAAc,GACtB,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,SAAS,GACT,U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