derive-dashboards 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 (410) hide show
  1. package/README.md +8 -5
  2. package/dist/adapter/sql-adapter.mjs +4 -4
  3. package/dist/body.mjs +11 -1
  4. package/dist/cache.d.mts +1 -1
  5. package/dist/cli/add.mjs +130 -0
  6. package/dist/cli/check.mjs +14 -1
  7. package/dist/cli/cli.mjs +14 -12
  8. package/dist/cli/config.mjs +12 -1
  9. package/dist/cli/doctor.mjs +147 -0
  10. package/dist/cli/import/dbt-schema.mjs +2 -2
  11. package/dist/cli/import/index.mjs +2 -2
  12. package/dist/cli/init.mjs +3 -2
  13. package/dist/cli/json.mjs +21 -0
  14. package/dist/cli/layers.mjs +33 -0
  15. package/dist/core/conformance/cases.d.mts +3 -0
  16. package/dist/core/conformance/cases.mjs +20 -4
  17. package/dist/core/conformance/check.mjs +6 -3
  18. package/dist/core/conformance/drill-cases.mjs +120 -0
  19. package/dist/core/document/layout.mjs +1 -1
  20. package/dist/core/document/view-layout.d.mts +14 -0
  21. package/dist/core/document/view-layout.mjs +157 -0
  22. package/dist/core/document/view.d.mts +26 -7
  23. package/dist/core/document/view.mjs +42 -11
  24. package/dist/core/engine/filter.mjs +2 -2
  25. package/dist/core/engine/index.d.mts +14 -2
  26. package/dist/core/engine/index.mjs +12 -1
  27. package/dist/core/engine/leaf.mjs +9 -4
  28. package/dist/core/engine/members.mjs +2 -2
  29. package/dist/core/engine/postgres.mjs +1 -1
  30. package/dist/core/engine/record-layout.d.mts +11 -0
  31. package/dist/core/engine/record-layout.mjs +7 -7
  32. package/dist/core/engine/records.d.mts +3 -2
  33. package/dist/core/engine/records.mjs +2 -1
  34. package/dist/core/engine/segmented.mjs +5 -2
  35. package/dist/core/engine/sql-records.mjs +2 -1
  36. package/dist/core/engine/statement.mjs +37 -3
  37. package/dist/core/engine/types.d.mts +3 -0
  38. package/dist/core/engine/version.d.mts +1 -1
  39. package/dist/core/engine/version.mjs +1 -1
  40. package/dist/core/error/codes.d.mts +33 -1
  41. package/dist/core/error/codes.mjs +30 -2
  42. package/dist/core/index.d.mts +13 -7
  43. package/dist/core/index.mjs +9 -5
  44. package/dist/core/model/catalog/check.mjs +1 -1
  45. package/dist/core/model/hints.d.mts +36 -0
  46. package/dist/core/model/member.d.mts +4 -2
  47. package/dist/core/model/member.mjs +19 -3
  48. package/dist/core/model/types.d.mts +21 -19
  49. package/dist/core/model/validate/drill.mjs +70 -0
  50. package/dist/core/model/validate/index.mjs +3 -0
  51. package/dist/core/model/validate/members.mjs +7 -4
  52. package/dist/core/model/validate/shape.mjs +150 -0
  53. package/dist/core/model/validate/source.mjs +5 -3
  54. package/dist/core/policy/bind-query.d.mts +12 -0
  55. package/dist/core/policy/bind-query.mjs +53 -0
  56. package/dist/core/query/alias.mjs +7 -1
  57. package/dist/core/query/drill/compose.d.mts +22 -0
  58. package/dist/core/query/drill/compose.mjs +85 -0
  59. package/dist/core/query/drill/fields.d.mts +21 -0
  60. package/dist/core/query/drill/fields.mjs +91 -0
  61. package/dist/core/query/drill/internal.d.mts +11 -0
  62. package/dist/core/query/drill/items.d.mts +29 -0
  63. package/dist/core/query/drill/items.mjs +98 -0
  64. package/dist/core/query/drill/line.d.mts +31 -0
  65. package/dist/core/query/drill/line.mjs +183 -0
  66. package/dist/core/query/drill/links.d.mts +33 -0
  67. package/dist/core/query/drill/links.mjs +31 -0
  68. package/dist/core/query/drill/operand.mjs +7 -0
  69. package/dist/core/query/drill/scopes.d.mts +22 -0
  70. package/dist/core/query/drill/scopes.mjs +58 -0
  71. package/dist/core/query/drill/selection.d.mts +37 -0
  72. package/dist/core/query/drill/selection.mjs +144 -0
  73. package/dist/core/query/drill/steps.d.mts +14 -0
  74. package/dist/core/query/drill/steps.mjs +35 -0
  75. package/dist/core/query/drill/synthetic-expr.mjs +85 -0
  76. package/dist/core/query/drill/synthetic.d.mts +22 -0
  77. package/dist/core/query/drill/synthetic.mjs +165 -0
  78. package/dist/core/query/drill/time.d.mts +11 -0
  79. package/dist/core/query/drill/time.mjs +71 -0
  80. package/dist/core/query/drill/types.d.mts +155 -0
  81. package/dist/core/query/drill/types.mjs +4 -0
  82. package/dist/core/query/drill/views.d.mts +62 -0
  83. package/dist/core/query/drill/views.mjs +257 -0
  84. package/dist/core/query/filter.d.mts +6 -0
  85. package/dist/core/query/picks.d.mts +8 -2
  86. package/dist/core/query/picks.mjs +11 -4
  87. package/dist/core/query/segments.d.mts +12 -2
  88. package/dist/core/query/segments.mjs +5 -2
  89. package/dist/core/result/columns.mjs +20 -4
  90. package/dist/core/result/types.d.mts +5 -1
  91. package/dist/core/schema/aliases.d.mts +7 -0
  92. package/dist/core/schema/aliases.mjs +77 -0
  93. package/dist/core/schema/answer-parts.mjs +117 -0
  94. package/dist/core/schema/answers.d.mts +2109 -128
  95. package/dist/core/schema/answers.mjs +11 -113
  96. package/dist/core/schema/commands.d.mts +2 -2
  97. package/dist/core/schema/document.d.mts +1 -1
  98. package/dist/core/schema/drill-answers.mjs +179 -0
  99. package/dist/core/schema/drill.d.mts +260 -0
  100. package/dist/core/schema/drill.mjs +107 -0
  101. package/dist/core/schema/index.d.mts +6 -3
  102. package/dist/core/schema/index.mjs +6 -3
  103. package/dist/core/schema/picks.d.mts +35 -0
  104. package/dist/core/schema/picks.mjs +23 -0
  105. package/dist/core/schema/query.d.mts +82 -1
  106. package/dist/core/schema/query.mjs +9 -5
  107. package/dist/core/schema/tools.mjs +1 -1
  108. package/dist/core/schema/view.d.mts +0 -35
  109. package/dist/core/schema/view.mjs +19 -24
  110. package/dist/core/store/schema.d.mts +5 -0
  111. package/dist/core/store/schema.mjs +10 -0
  112. package/dist/core/types/api.d.mts +21 -1
  113. package/dist/core/types/api.mjs +1 -1
  114. package/dist/core/types/drill-api.d.mts +210 -0
  115. package/dist/core/types/options.d.mts +21 -0
  116. package/dist/core/types/viewer.d.mts +5 -0
  117. package/dist/cursor-seal.d.mts +8 -0
  118. package/dist/cursor-seal.mjs +98 -0
  119. package/dist/dashboard-id.mjs +1 -1
  120. package/dist/dashboards.mjs +4 -0
  121. package/dist/drill-access.mjs +93 -0
  122. package/dist/drill-change.mjs +76 -0
  123. package/dist/drill-crumbs.mjs +113 -0
  124. package/dist/drill-distinct.mjs +130 -0
  125. package/dist/drill-explain.mjs +64 -0
  126. package/dist/drill-identity.mjs +35 -0
  127. package/dist/drill-item-id.mjs +35 -0
  128. package/dist/drill-items.mjs +132 -0
  129. package/dist/drill-open.mjs +169 -0
  130. package/dist/drill-seal.mjs +170 -0
  131. package/dist/drill-secret.mjs +14 -0
  132. package/dist/drill-share.mjs +53 -0
  133. package/dist/drill-summary.mjs +158 -0
  134. package/dist/drill-targets.mjs +53 -0
  135. package/dist/drill-totals.mjs +8 -0
  136. package/dist/drill-views.mjs +175 -0
  137. package/dist/drill.mjs +157 -0
  138. package/dist/editing.mjs +3 -3
  139. package/dist/endpoints/dashboards.mjs +28 -5
  140. package/dist/endpoints/drill.mjs +55 -0
  141. package/dist/endpoints/index.d.mts +245 -4
  142. package/dist/endpoints/index.mjs +5 -1
  143. package/dist/endpoints/meta.mjs +10 -1
  144. package/dist/endpoints/query.mjs +26 -4
  145. package/dist/execute.d.mts +19 -1
  146. package/dist/execute.mjs +34 -27
  147. package/dist/handler.mjs +5 -1
  148. package/dist/index.d.mts +3 -1
  149. package/dist/index.mjs +29 -2
  150. package/dist/llms.txt +22 -0
  151. package/dist/mcp/drill.mjs +61 -0
  152. package/dist/mcp/format.mjs +69 -11
  153. package/dist/mcp/index.d.mts +15 -4
  154. package/dist/mcp/index.mjs +13 -7
  155. package/dist/mcp/query.d.mts +7 -2
  156. package/dist/mcp/query.mjs +40 -6
  157. package/dist/node-postgres.d.mts +8 -4
  158. package/dist/node-postgres.mjs +29 -6
  159. package/dist/owner.mjs +3 -3
  160. package/dist/postgres-connection.d.mts +8 -2
  161. package/dist/postgres-connection.mjs +2 -1
  162. package/dist/postgres-store.mjs +1 -0
  163. package/dist/react/Canvas.mjs +28 -5
  164. package/dist/react/Cell.mjs +2 -1
  165. package/dist/react/Dashboard.d.mts +10 -5
  166. package/dist/react/Dashboard.mjs +62 -22
  167. package/dist/react/DashboardList.mjs +52 -24
  168. package/dist/react/DashboardListRow.mjs +49 -0
  169. package/dist/react/Discard.mjs +12 -4
  170. package/dist/react/Editing.mjs +19 -5
  171. package/dist/react/FilterBar.d.mts +7 -9
  172. package/dist/react/Grid.mjs +19 -24
  173. package/dist/react/Header.mjs +10 -1
  174. package/dist/react/History.mjs +5 -0
  175. package/dist/react/Parts.mjs +6 -2
  176. package/dist/react/ReadFailed.mjs +23 -0
  177. package/dist/react/ReviewPanel.mjs +13 -2
  178. package/dist/react/RowBody.d.mts +19 -0
  179. package/dist/react/RowBody.mjs +55 -0
  180. package/dist/react/Spaces.mjs +15 -1
  181. package/dist/react/Tile.d.mts +3 -1
  182. package/dist/react/Tile.mjs +84 -32
  183. package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
  184. package/dist/react/arrange-steps.mjs +16 -13
  185. package/dist/react/arrange.mjs +10 -3
  186. package/dist/react/builder/Calcs.mjs +35 -11
  187. package/dist/react/builder/FilterEditor.mjs +196 -0
  188. package/dist/react/builder/Filters.mjs +172 -116
  189. package/dist/react/builder/Formula.mjs +82 -0
  190. package/dist/react/builder/Groups.mjs +1 -0
  191. package/dist/react/builder/Preview.mjs +1 -1
  192. package/dist/react/builder/RangeEditor.mjs +184 -0
  193. package/dist/react/builder/Sections.mjs +41 -6
  194. package/dist/react/builder/Time.mjs +138 -60
  195. package/dist/react/builder/Values.mjs +85 -0
  196. package/dist/react/builder/WidgetBuilder.mjs +50 -49
  197. package/dist/react/builder/base.d.mts +5 -0
  198. package/dist/react/builder/base.mjs +33 -8
  199. package/dist/react/builder/calc.mjs +15 -1
  200. package/dist/react/builder/escape.d.mts +1 -0
  201. package/dist/react/builder/escape.mjs +62 -0
  202. package/dist/react/builder/filter-tree.d.mts +9 -0
  203. package/dist/react/builder/filter-tree.mjs +186 -0
  204. package/dist/react/builder/formula-parse.d.mts +18 -0
  205. package/dist/react/builder/formula-parse.mjs +136 -0
  206. package/dist/react/builder/labels.d.mts +1 -1
  207. package/dist/react/builder/state.d.mts +2 -1
  208. package/dist/react/builder/state.mjs +23 -37
  209. package/dist/react/builder/useBuilder.d.mts +12 -1
  210. package/dist/react/builder/useBuilder.mjs +6 -3
  211. package/dist/react/builder/words.d.mts +59 -0
  212. package/dist/react/builder/words.mjs +73 -0
  213. package/dist/react/client.d.mts +2 -0
  214. package/dist/react/client.mjs +1 -0
  215. package/dist/react/context.d.mts +28 -1
  216. package/dist/react/context.mjs +25 -4
  217. package/dist/react/drill/Bars.mjs +179 -0
  218. package/dist/react/drill/Controls.mjs +173 -0
  219. package/dist/react/drill/DashboardTile.d.mts +18 -0
  220. package/dist/react/drill/DashboardTile.mjs +107 -0
  221. package/dist/react/drill/DrillPanel.d.mts +31 -0
  222. package/dist/react/drill/DrillPanel.mjs +104 -0
  223. package/dist/react/drill/DrillTabs.mjs +52 -0
  224. package/dist/react/drill/Header.mjs +131 -0
  225. package/dist/react/drill/Items.d.mts +22 -0
  226. package/dist/react/drill/Items.mjs +164 -0
  227. package/dist/react/drill/ItemsFoot.mjs +60 -0
  228. package/dist/react/drill/Notes.mjs +58 -0
  229. package/dist/react/drill/PanelBody.mjs +74 -0
  230. package/dist/react/drill/PanelStates.mjs +37 -0
  231. package/dist/react/drill/board.d.mts +18 -0
  232. package/dist/react/drill/board.mjs +91 -0
  233. package/dist/react/drill/counts.mjs +14 -0
  234. package/dist/react/drill/host.mjs +26 -0
  235. package/dist/react/drill/item-parts.d.mts +5 -0
  236. package/dist/react/drill/item-parts.mjs +76 -0
  237. package/dist/react/drill/item-type.d.mts +26 -0
  238. package/dist/react/drill/item-type.mjs +7 -0
  239. package/dist/react/drill/lazy.d.mts +6 -0
  240. package/dist/react/drill/lazy.mjs +17 -0
  241. package/dist/react/drill/pages.mjs +48 -0
  242. package/dist/react/drill/panel-focus.mjs +51 -0
  243. package/dist/react/drill/props.d.mts +25 -0
  244. package/dist/react/drill/props.mjs +72 -0
  245. package/dist/react/drill/state.d.mts +18 -0
  246. package/dist/react/drill/state.mjs +68 -0
  247. package/dist/react/drill/useDrill.d.mts +46 -0
  248. package/dist/react/drill/useDrill.mjs +194 -0
  249. package/dist/react/drill/words.d.mts +101 -0
  250. package/dist/react/drill/words.mjs +79 -0
  251. package/dist/react/english.mjs +29 -6
  252. package/dist/react/filters/bar.d.mts +12 -0
  253. package/dist/react/filters/bar.mjs +135 -0
  254. package/dist/react/filters/calendar.mjs +193 -0
  255. package/dist/react/filters/chip.mjs +174 -0
  256. package/dist/react/filters/context.d.mts +22 -0
  257. package/dist/react/filters/context.mjs +78 -0
  258. package/dist/react/filters/dates.mjs +89 -0
  259. package/dist/react/filters/days.d.mts +36 -0
  260. package/dist/react/filters/days.mjs +87 -0
  261. package/dist/react/filters/field-step.mjs +81 -0
  262. package/dist/react/filters/hooks.d.mts +34 -0
  263. package/dist/react/filters/hooks.mjs +94 -0
  264. package/dist/react/filters/listbox.mjs +131 -0
  265. package/dist/react/filters/logic.d.mts +59 -0
  266. package/dist/react/filters/logic.mjs +109 -0
  267. package/dist/react/filters/menu-search.mjs +211 -0
  268. package/dist/react/filters/menu.mjs +85 -0
  269. package/dist/react/filters/number.mjs +127 -0
  270. package/dist/react/filters/numbers.d.mts +47 -0
  271. package/dist/react/filters/numbers.mjs +151 -0
  272. package/dist/react/filters/operator.mjs +104 -0
  273. package/dist/react/filters/phone.mjs +104 -0
  274. package/dist/react/filters/popover.d.mts +19 -0
  275. package/dist/react/filters/popover.mjs +153 -0
  276. package/dist/react/filters/rules.d.mts +8 -0
  277. package/dist/react/filters/rules.mjs +55 -0
  278. package/dist/react/filters/sheet.mjs +196 -0
  279. package/dist/react/filters/state.mjs +132 -0
  280. package/dist/react/filters/suggest.d.mts +47 -0
  281. package/dist/react/filters/suggest.mjs +97 -0
  282. package/dist/react/filters/values.mjs +166 -0
  283. package/dist/react/filters/words.d.mts +81 -0
  284. package/dist/react/filters/words.mjs +73 -0
  285. package/dist/react/format.d.mts +3 -3
  286. package/dist/react/format.mjs +45 -16
  287. package/dist/react/index.d.mts +34 -5
  288. package/dist/react/index.mjs +15 -4
  289. package/dist/react/messages.d.mts +47 -2
  290. package/dist/react/place.mjs +7 -3
  291. package/dist/react/renderers/index.d.mts +10 -2
  292. package/dist/react/renderers/index.mjs +116 -14
  293. package/dist/react/renderers/list.d.mts +22 -0
  294. package/dist/react/renderers/list.mjs +118 -0
  295. package/dist/react/review-words.mjs +1 -1
  296. package/dist/react/review.mjs +2 -2
  297. package/dist/react/scope.mjs +2 -7
  298. package/dist/react/series.d.mts +54 -0
  299. package/dist/react/series.mjs +191 -0
  300. package/dist/react/theme.css +2734 -1296
  301. package/dist/react/theme.css.d.ts +1 -0
  302. package/dist/react/tile-store.mjs +15 -3
  303. package/dist/react/useBoard.d.mts +7 -0
  304. package/dist/react/useBoard.mjs +4 -1
  305. package/dist/react/useDashboard.d.mts +4 -0
  306. package/dist/react/useDashboard.mjs +8 -1
  307. package/dist/react/useTiles.mjs +50 -15
  308. package/dist/react/view-grid.mjs +16 -0
  309. package/dist/react/view.d.mts +9 -0
  310. package/dist/react/view.mjs +22 -10
  311. package/dist/reading.d.mts +2 -0
  312. package/dist/reading.mjs +9 -1
  313. package/dist/recharts/axes.mjs +28 -0
  314. package/dist/recharts/axis.mjs +84 -0
  315. package/dist/recharts/bar.d.mts +7 -0
  316. package/dist/recharts/bar.mjs +140 -0
  317. package/dist/recharts/charts.d.mts +4 -6
  318. package/dist/recharts/charts.mjs +2 -114
  319. package/dist/recharts/index.d.mts +5 -3
  320. package/dist/recharts/index.mjs +6 -3
  321. package/dist/recharts/line.d.mts +2 -0
  322. package/dist/recharts/line.mjs +111 -0
  323. package/dist/recharts/marks.mjs +112 -0
  324. package/dist/recharts/parts.mjs +88 -0
  325. package/dist/recharts/series.d.mts +2 -22
  326. package/dist/recharts/series.mjs +1 -64
  327. package/dist/recharts/table.mjs +71 -0
  328. package/dist/records-read.mjs +44 -0
  329. package/dist/registry/filter-bar.json +26 -0
  330. package/dist/skills/derive-dashboards/SKILL.md +69 -0
  331. package/dist/store/apply.mjs +5 -5
  332. package/dist/store/commands.mjs +4 -4
  333. package/dist/store/discard.mjs +7 -7
  334. package/dist/store/drafts.mjs +5 -5
  335. package/dist/store/editor.mjs +1 -1
  336. package/dist/store/publish.mjs +12 -12
  337. package/dist/store/reader.mjs +41 -22
  338. package/dist/store/review.mjs +16 -16
  339. package/dist/store/rows.mjs +20 -20
  340. package/dist/store/undo.mjs +3 -3
  341. package/dist/store/unpublished.mjs +4 -4
  342. package/dist/store/versions.mjs +14 -14
  343. package/dist/testing/adapter-suite.mjs +4 -4
  344. package/dist/tiles.mjs +37 -3
  345. package/package.json +12 -10
  346. package/dist/react/FilterBar.mjs +0 -119
  347. package/dist/react/Records.d.mts +0 -12
  348. package/dist/react/Records.mjs +0 -97
  349. package/src/adapter/sql-adapter.ts +0 -95
  350. package/src/adapter/statement.ts +0 -185
  351. package/src/authorize.ts +0 -73
  352. package/src/body.ts +0 -169
  353. package/src/bounded.ts +0 -43
  354. package/src/cache.ts +0 -192
  355. package/src/checks.ts +0 -170
  356. package/src/custom-source.ts +0 -59
  357. package/src/dashboard-id.ts +0 -36
  358. package/src/dashboards.ts +0 -132
  359. package/src/editing.ts +0 -148
  360. package/src/endpoints/access.ts +0 -41
  361. package/src/endpoints/dashboards.ts +0 -92
  362. package/src/endpoints/drafts.ts +0 -138
  363. package/src/endpoints/index.ts +0 -21
  364. package/src/endpoints/meta.ts +0 -137
  365. package/src/endpoints/query.ts +0 -86
  366. package/src/endpoints/read.ts +0 -92
  367. package/src/endpoints/review.ts +0 -89
  368. package/src/endpoints/values.ts +0 -62
  369. package/src/endpoints/versions.ts +0 -104
  370. package/src/execute.ts +0 -207
  371. package/src/handler.ts +0 -232
  372. package/src/http.ts +0 -66
  373. package/src/index.ts +0 -163
  374. package/src/introspect.ts +0 -205
  375. package/src/mcp/api.ts +0 -59
  376. package/src/mcp/format.ts +0 -67
  377. package/src/mcp/index.ts +0 -151
  378. package/src/mcp/query.ts +0 -153
  379. package/src/mcp/resolve.ts +0 -114
  380. package/src/node-postgres.ts +0 -81
  381. package/src/owner.ts +0 -36
  382. package/src/postgres-connection.ts +0 -143
  383. package/src/postgres-store.ts +0 -82
  384. package/src/principal.ts +0 -39
  385. package/src/reading.ts +0 -56
  386. package/src/request-rows.ts +0 -23
  387. package/src/request.ts +0 -22
  388. package/src/storage.ts +0 -63
  389. package/src/store/apply.ts +0 -129
  390. package/src/store/commands.ts +0 -75
  391. package/src/store/conflicts.ts +0 -98
  392. package/src/store/create-tables.ts +0 -104
  393. package/src/store/discard.ts +0 -42
  394. package/src/store/drafts.ts +0 -133
  395. package/src/store/editor.ts +0 -28
  396. package/src/store/log.ts +0 -28
  397. package/src/store/publish.ts +0 -199
  398. package/src/store/publisher.ts +0 -21
  399. package/src/store/reader.ts +0 -139
  400. package/src/store/review.ts +0 -239
  401. package/src/store/rows.ts +0 -250
  402. package/src/store/tenant.ts +0 -28
  403. package/src/store/undo.ts +0 -56
  404. package/src/store/unpublished.ts +0 -33
  405. package/src/store/versions.ts +0 -106
  406. package/src/store/writer.ts +0 -19
  407. package/src/testing/adapter-suite.ts +0 -239
  408. package/src/testing/index.ts +0 -2
  409. package/src/tile-doc.ts +0 -46
  410. package/src/tiles.ts +0 -120
@@ -1,4 +1,5 @@
1
1
  import { useDashboards } from "../context.mjs";
2
+ import { FormulaEditor } from "./Formula.mjs";
2
3
  import { formulaText } from "./labels.mjs";
3
4
  import { Chip, Entry, Section } from "./Sections.mjs";
4
5
  import { useState } from "react";
@@ -43,14 +44,36 @@ function CalcEditor({ b, calc }) {
43
44
  ]
44
45
  });
45
46
  }
47
+ /** The presets that fit, and Formula, to add a calculation. */
48
+ function AddChips({ b, onFormula }) {
49
+ const { messages } = useDashboards();
50
+ return /* @__PURE__ */ jsxs("div", {
51
+ className: "dd-chips",
52
+ children: [b.presets.map((p) => /* @__PURE__ */ jsx(Chip, {
53
+ add: true,
54
+ on: false,
55
+ label: messages.presets[p],
56
+ onClick: () => {
57
+ b.addCalc(p);
58
+ }
59
+ }, p)), /* @__PURE__ */ jsx(Chip, {
60
+ add: true,
61
+ on: false,
62
+ label: messages.formula,
63
+ onClick: onFormula
64
+ })]
65
+ });
66
+ }
46
67
  /** Calculations: the ones added, each editable in place, and the presets that fit. */
47
68
  function CalcSection({ b }) {
48
69
  const { messages } = useDashboards();
49
70
  const [open, setOpen] = useState();
71
+ const [writing, setWriting] = useState(false);
50
72
  const calcs = b.state.query?.calc ?? [];
51
73
  if (b.state.query === void 0) return null;
52
74
  return /* @__PURE__ */ jsxs(Section, {
53
75
  title: messages.calculations,
76
+ summary: calcs.length === 0 ? messages.noCalculations : calcs.map((c) => c.label ?? c.id).join(", "),
54
77
  children: [
55
78
  calcs.length === 0 ? /* @__PURE__ */ jsx("p", {
56
79
  className: "dd-muted",
@@ -70,17 +93,18 @@ function CalcSection({ b }) {
70
93
  b,
71
94
  calc: c
72
95
  }) : null] }, c.id)),
73
- /* @__PURE__ */ jsx("div", {
74
- className: "dd-chips",
75
- children: b.presets.map((p) => /* @__PURE__ */ jsx(Chip, {
76
- add: true,
77
- on: false,
78
- label: messages.presets[p],
79
- onClick: () => {
80
- b.addCalc(p);
81
- }
82
- }, p))
83
- })
96
+ /* @__PURE__ */ jsx(AddChips, {
97
+ b,
98
+ onFormula: () => {
99
+ setWriting(true);
100
+ }
101
+ }),
102
+ writing ? /* @__PURE__ */ jsx(FormulaEditor, {
103
+ b,
104
+ onDone: () => {
105
+ setWriting(false);
106
+ }
107
+ }) : null
84
108
  ]
85
109
  });
86
110
  }
@@ -0,0 +1,196 @@
1
+ import { useDashboards } from "../context.mjs";
2
+ import { fieldOptions } from "./options.mjs";
3
+ import { Chip } from "./Sections.mjs";
4
+ import { ValuePicker } from "./Values.mjs";
5
+ import { useState } from "react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/builder/FilterEditor.tsx
8
+ /** The operators a field's type has, in the order the editor offers them. */
9
+ const OPS = {
10
+ string: [
11
+ "in",
12
+ "notIn",
13
+ "contains",
14
+ "notContains",
15
+ "startsWith",
16
+ "notSet",
17
+ "set"
18
+ ],
19
+ number: [
20
+ "in",
21
+ "notIn",
22
+ "gt",
23
+ "gte",
24
+ "lt",
25
+ "lte",
26
+ "between",
27
+ "notSet",
28
+ "set"
29
+ ],
30
+ boolean: [
31
+ "in",
32
+ "notIn",
33
+ "notSet",
34
+ "set"
35
+ ]
36
+ };
37
+ const PICKS = /* @__PURE__ */ new Set(["in", "notIn"]);
38
+ const TEXT = /* @__PURE__ */ new Set([
39
+ "contains",
40
+ "notContains",
41
+ "startsWith"
42
+ ]);
43
+ const NUMBER = /* @__PURE__ */ new Set([
44
+ "gt",
45
+ "gte",
46
+ "lt",
47
+ "lte"
48
+ ]);
49
+ const NUMERIC = /* @__PURE__ */ new Set([
50
+ "number",
51
+ "int",
52
+ "decimal",
53
+ "float"
54
+ ]);
55
+ /** A field's type for its operators (string, number or boolean), from the fields it can filter by. */
56
+ function typeOf(b, member) {
57
+ const source = b.state.query?.source ?? "";
58
+ const type = fieldOptions(b.meta, source).find((o) => o.id === member)?.hint ?? "string";
59
+ return NUMERIC.has(type) ? "number" : type;
60
+ }
61
+ /** Typed numbers, `count` of them, or undefined when one is missing or not a number. */
62
+ function numbersOf(typed, count) {
63
+ const numbers = typed.slice(0, count).map((t) => t.trim() === "" ? NaN : Number(t));
64
+ return numbers.length === count && numbers.every((n) => Number.isFinite(n)) ? numbers : void 0;
65
+ }
66
+ const textOf = (typed) => typed[0] === void 0 || typed[0] === "" ? void 0 : [typed[0]];
67
+ /** Between's two ends, low first; undefined when they are the other way round. */
68
+ const ordered = (pair) => pair === void 0 || (pair[0] ?? 0) > (pair[1] ?? 0) ? void 0 : pair;
69
+ /** The values an operator needs, from what was typed or picked; undefined while incomplete. */
70
+ function valuesFor(op, picked, typed) {
71
+ if (op === "set" || op === "notSet") return [];
72
+ if (PICKS.has(op)) return picked.length === 0 ? void 0 : [...picked];
73
+ if (TEXT.has(op)) return textOf(typed);
74
+ return op === "between" ? ordered(numbersOf(typed, 2)) : numbersOf(typed, 1);
75
+ }
76
+ /** The input an operator reads: picked values, one text, one number, or two numbers. */
77
+ function Inputs(props) {
78
+ const { messages } = useDashboards();
79
+ const { op } = props;
80
+ if (PICKS.has(op)) return /* @__PURE__ */ jsx(ValuePicker, {
81
+ member: props.member,
82
+ chosen: props.picked,
83
+ onToggle: props.onToggle
84
+ });
85
+ if (op === "set" || op === "notSet") return null;
86
+ const box = (i, type) => /* @__PURE__ */ jsx("input", {
87
+ type,
88
+ "aria-label": i === 0 ? messages.value : messages.rangeTo,
89
+ value: props.typed[i] ?? "",
90
+ onChange: (e) => {
91
+ props.onType(i, e.target.value);
92
+ }
93
+ });
94
+ if (TEXT.has(op)) return /* @__PURE__ */ jsx("div", {
95
+ className: "dd-range-row",
96
+ children: box(0, "text")
97
+ });
98
+ if (NUMBER.has(op)) return /* @__PURE__ */ jsx("div", {
99
+ className: "dd-range-row",
100
+ children: box(0, "number")
101
+ });
102
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
103
+ className: "dd-range-row",
104
+ children: [
105
+ box(0, "number"),
106
+ " ",
107
+ messages.rangeTo,
108
+ " ",
109
+ box(1, "number")
110
+ ]
111
+ }), /* @__PURE__ */ jsx("p", {
112
+ className: "dd-builder-note",
113
+ children: messages.bothEnds
114
+ })] });
115
+ }
116
+ /** Cancel, and the button that adds what the editor holds once it is complete. */
117
+ function Actions(props) {
118
+ const { messages } = useDashboards();
119
+ return /* @__PURE__ */ jsxs("div", {
120
+ className: "dd-row",
121
+ children: [/* @__PURE__ */ jsx("button", {
122
+ type: "button",
123
+ className: "dd-button",
124
+ onClick: props.onCancel,
125
+ children: messages.cancel
126
+ }), /* @__PURE__ */ jsx("button", {
127
+ type: "button",
128
+ className: "dd-button dd-primary",
129
+ disabled: !props.ready,
130
+ onClick: props.onAdd,
131
+ children: props.label ?? messages.addFilter
132
+ })]
133
+ });
134
+ }
135
+ /** The operators a field offers, one on. */
136
+ function OpChips(props) {
137
+ const { messages } = useDashboards();
138
+ return /* @__PURE__ */ jsx("div", {
139
+ className: "dd-chips",
140
+ children: props.ops.map((o) => /* @__PURE__ */ jsx(Chip, {
141
+ on: props.on === o,
142
+ label: messages.ops[o],
143
+ onClick: () => {
144
+ props.pick(o);
145
+ }
146
+ }, o))
147
+ });
148
+ }
149
+ /** A new condition on `member`: the operators its type has, and what each one reads. */
150
+ function FilterEditor(props) {
151
+ const { b, member } = props;
152
+ const ops = OPS[typeOf(b, member)] ?? OPS.string ?? [];
153
+ const [op, setOp] = useState("in");
154
+ const [picked, setPicked] = useState([]);
155
+ const [typed, setTyped] = useState([]);
156
+ const values = valuesFor(op, picked, typed);
157
+ return /* @__PURE__ */ jsxs("div", {
158
+ className: "dd-inline",
159
+ children: [
160
+ /* @__PURE__ */ jsx("b", { children: b.labelOf(member) }),
161
+ /* @__PURE__ */ jsx(OpChips, {
162
+ ops,
163
+ on: op,
164
+ pick: setOp
165
+ }),
166
+ /* @__PURE__ */ jsx(Inputs, {
167
+ member,
168
+ op,
169
+ picked,
170
+ onToggle: (v) => {
171
+ setPicked((c) => c.includes(v) ? c.filter((x) => x !== v) : [...c, v]);
172
+ },
173
+ typed,
174
+ onType: (i, text) => {
175
+ setTyped((t) => Object.assign([...t], { [i]: text }));
176
+ }
177
+ }),
178
+ /* @__PURE__ */ jsx(Actions, {
179
+ ready: values !== void 0,
180
+ onCancel: props.onDone,
181
+ onAdd: () => {
182
+ if (values === void 0) return;
183
+ const group = props.group === void 0 ? {} : { group: props.group };
184
+ b.addFilter({
185
+ member,
186
+ op,
187
+ values,
188
+ ...group
189
+ });
190
+ props.onDone();
191
+ }
192
+ })
193
+ ]
194
+ });
195
+ }
196
+ export { Actions, FilterEditor };
@@ -1,164 +1,220 @@
1
1
  import { useDashboards } from "../context.mjs";
2
- import { useDebounced } from "../debounce.mjs";
2
+ import { FilterEditor } from "./FilterEditor.mjs";
3
+ import { treeOf } from "./filter-tree.mjs";
3
4
  import { fieldOptions } from "./options.mjs";
4
5
  import { Picker } from "./Picker.mjs";
5
- import { Chip, Entry, Section } from "./Sections.mjs";
6
- import { filterLeaves } from "./state.mjs";
6
+ import { Entry, Section } from "./Sections.mjs";
7
7
  import { useState } from "react";
8
- import useSWR from "swr";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
10
9
  // src/builder/Filters.tsx
11
- /** A field's values as chips, the chosen ones pressed. */
12
- function ValueChips(props) {
10
+ /** A condition's test in the viewer's words. */
11
+ function useTest() {
13
12
  const { messages } = useDashboards();
14
- return /* @__PURE__ */ jsx("div", {
15
- className: "dd-chips",
16
- children: props.values.map((v) => /* @__PURE__ */ jsx(Chip, {
17
- on: props.chosen.includes(v),
18
- label: v === null ? messages.empty : String(v),
13
+ return (c) => messages.filterTest(c.op, c.values.map((v) => v === null ? messages.empty : String(v)));
14
+ }
15
+ /** Chips that say how a part matches: all, any (and, for a group, none) of its conditions. */
16
+ function ModeChips(props) {
17
+ const { messages } = useDashboards();
18
+ return /* @__PURE__ */ jsx("span", {
19
+ className: "dd-seg",
20
+ children: props.modes.map((m) => /* @__PURE__ */ jsx("button", {
21
+ type: "button",
22
+ "aria-pressed": props.on === m,
19
23
  onClick: () => {
20
- props.onToggle(v);
21
- }
22
- }, String(v)))
24
+ props.pick(m);
25
+ },
26
+ children: messages.modes[m]
27
+ }, m))
23
28
  });
24
29
  }
25
- /** A field's values to pick from: the ones this viewer can see, narrowed as they type. */
26
- function ValuePicker(props) {
27
- const { client, messages } = useDashboards();
28
- const [search, setSearch] = useState("");
29
- const sent = useDebounced(search, 250);
30
- const values = useSWR([
31
- "dd-member-values",
32
- props.member,
33
- sent
34
- ], () => client.memberValues({
35
- member: props.member,
36
- limit: 50,
37
- ...sent === "" ? {} : { search: sent }
38
- }));
39
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
40
- className: "dd-search",
41
- type: "search",
42
- placeholder: messages.searchValues,
43
- value: search,
44
- onChange: (event) => {
45
- setSearch(event.target.value);
30
+ function ConditionEntry({ b, c }) {
31
+ const test = useTest();
32
+ return /* @__PURE__ */ jsx(Entry, {
33
+ label: b.labelOf(c.member),
34
+ detail: test(c),
35
+ onRemove: () => {
36
+ b.removeFilter(c.id);
46
37
  }
47
- }), /* @__PURE__ */ jsx(ValueChips, {
48
- values: values.data?.values ?? [],
49
- chosen: props.chosen,
50
- onToggle: props.onToggle
51
- })] });
38
+ });
52
39
  }
53
- /** A new filter: is or is not, and values from what this viewer can see of the field. */
54
- function FilterEditor({ b, member, onDone }) {
40
+ /** A group: how it matches, its conditions, and adding one more to it. */
41
+ function Group(props) {
55
42
  const { messages } = useDashboards();
56
- const [chosen, setChosen] = useState([]);
57
- const [negate, setNegate] = useState(false);
58
- const toggle = (v) => {
59
- setChosen((c) => c.includes(v) ? c.filter((x) => x !== v) : [...c, v]);
60
- };
61
- const add = () => {
62
- b.addFilter({
63
- member,
64
- values: chosen,
65
- negate
66
- });
67
- onDone();
68
- };
43
+ const { b, child } = props;
69
44
  return /* @__PURE__ */ jsxs("div", {
70
- className: "dd-inline",
45
+ className: "dd-filter-group",
46
+ "data-mode": child.mode,
71
47
  children: [
72
48
  /* @__PURE__ */ jsxs("div", {
73
- className: "dd-chips",
49
+ className: "dd-range-row",
74
50
  children: [
75
- /* @__PURE__ */ jsx("b", { children: b.labelOf(member) }),
76
- /* @__PURE__ */ jsx(Chip, {
77
- on: !negate,
78
- label: messages.is,
79
- onClick: () => {
80
- setNegate(false);
51
+ /* @__PURE__ */ jsx(ModeChips, {
52
+ modes: [
53
+ "all",
54
+ "any",
55
+ "none"
56
+ ],
57
+ on: child.mode,
58
+ pick: (mode) => {
59
+ b.setFilterMode({
60
+ mode,
61
+ group: child.id
62
+ });
81
63
  }
82
64
  }),
83
- /* @__PURE__ */ jsx(Chip, {
84
- on: negate,
85
- label: messages.isNot,
65
+ /* @__PURE__ */ jsx("span", {
66
+ className: "dd-grow",
67
+ children: messages.ofThese
68
+ }),
69
+ /* @__PURE__ */ jsx("button", {
70
+ type: "button",
71
+ className: "dd-entry-remove",
72
+ "aria-label": messages.removeGroup,
73
+ title: messages.removeGroup,
86
74
  onClick: () => {
87
- setNegate(true);
88
- }
75
+ b.removeFilter(child.id);
76
+ },
77
+ children: "×"
89
78
  })
90
79
  ]
91
80
  }),
92
- /* @__PURE__ */ jsx(ValuePicker, {
93
- member,
94
- chosen,
95
- onToggle: toggle
96
- }),
97
- /* @__PURE__ */ jsxs("div", {
98
- className: "dd-row",
99
- children: [/* @__PURE__ */ jsx("button", {
100
- type: "button",
101
- className: "dd-button",
102
- onClick: onDone,
103
- children: messages.cancel
104
- }), /* @__PURE__ */ jsx("button", {
105
- type: "button",
106
- className: "dd-button dd-primary",
107
- disabled: chosen.length === 0,
108
- onClick: add,
109
- children: messages.addFilter
110
- })]
81
+ child.conditions.map((c) => /* @__PURE__ */ jsx(ConditionEntry, {
82
+ b,
83
+ c
84
+ }, c.id)),
85
+ /* @__PURE__ */ jsx("button", {
86
+ type: "button",
87
+ className: "dd-link",
88
+ onClick: props.onAdd,
89
+ children: messages.addToGroup
111
90
  })
112
91
  ]
113
92
  });
114
93
  }
115
- /** "is done, review" or "is not done", in the viewer's words. */
116
- function leafDetail(f, words) {
117
- if (!("values" in f)) return "";
118
- const values = f.values.map((v) => v === null ? words.empty : String(v)).join(", ");
119
- return `${f.op === "notIn" ? words.isNot : words.is} ${values}`;
94
+ function ChildView(props) {
95
+ const { messages } = useDashboards();
96
+ const { b, child } = props;
97
+ if (child.kind === "condition") return /* @__PURE__ */ jsx(ConditionEntry, {
98
+ b,
99
+ c: child.node
100
+ });
101
+ if (child.kind === "group") return /* @__PURE__ */ jsx(Group, {
102
+ b,
103
+ child,
104
+ onAdd: () => {
105
+ props.onAddTo(child.id);
106
+ }
107
+ });
108
+ const node = child.node;
109
+ const own = "member" in node;
110
+ return /* @__PURE__ */ jsx(Entry, {
111
+ label: own ? b.labelOf(node.member) : messages.keptNested,
112
+ ...own ? { detail: messages.keptAsWritten } : {},
113
+ onRemove: () => {
114
+ b.removeFilter(node.id);
115
+ }
116
+ });
117
+ }
118
+ /** The fields a filter tests, in one line. */
119
+ function summaryOf(b, children, test, words) {
120
+ if (children.length === 0) return words.none;
121
+ return children.map((c) => {
122
+ if (c.kind === "condition") return `${b.labelOf(c.node.member)} ${test(c.node)}`;
123
+ if (c.kind === "group") return `(${c.conditions.map((k) => b.labelOf(k.member)).join(", ")})`;
124
+ return "member" in c.node ? b.labelOf(c.node.member) : words.nested;
125
+ }).join(", ");
126
+ }
127
+ /** Picking a field, then its condition, for wherever `target` says. */
128
+ function Adding(props) {
129
+ const { messages } = useDashboards();
130
+ const [member, setMember] = useState();
131
+ const source = props.b.state.query?.source ?? "";
132
+ if (member === void 0) return /* @__PURE__ */ jsx(Picker, {
133
+ options: fieldOptions(props.b.meta, source),
134
+ placeholder: messages.searchFields,
135
+ autoFocus: true,
136
+ onPick: setMember,
137
+ onClose: props.onDone
138
+ });
139
+ return /* @__PURE__ */ jsx(FilterEditor, {
140
+ b: props.b,
141
+ member,
142
+ ...props.target,
143
+ onDone: props.onDone
144
+ });
145
+ }
146
+ /** The filter in one line, for its folded section. */
147
+ function useSummary(b) {
148
+ const { messages } = useDashboards();
149
+ const test = useTest();
150
+ return summaryOf(b, treeOf(b.state.query?.filters).children, test, {
151
+ none: messages.noFilters,
152
+ nested: messages.keptNested
153
+ });
154
+ }
155
+ /** How the top matches its parts: "Rows matching all of these". */
156
+ function TopMode({ b, mode }) {
157
+ const { messages } = useDashboards();
158
+ return /* @__PURE__ */ jsxs("div", {
159
+ className: "dd-range-row",
160
+ children: [
161
+ messages.matching,
162
+ /* @__PURE__ */ jsx(ModeChips, {
163
+ modes: ["all", "any"],
164
+ on: mode,
165
+ pick: (m) => {
166
+ b.setFilterMode({ mode: m });
167
+ }
168
+ }),
169
+ messages.ofThese
170
+ ]
171
+ });
120
172
  }
121
173
  /** Filters: the widget's own, on top of whatever the dashboard applies. */
122
174
  function FilterSection({ b }) {
175
+ const summary = useSummary(b);
123
176
  const { messages } = useDashboards();
124
- const [adding, setAdding] = useState(false);
125
- const [member, setMember] = useState();
177
+ const [target, setTarget] = useState();
126
178
  const query = b.state.query;
127
179
  if (query === void 0) return null;
128
- const leaves = filterLeaves(query.filters);
180
+ const tree = treeOf(query.filters);
129
181
  const done = () => {
130
- setMember(void 0);
131
- setAdding(false);
182
+ setTarget(void 0);
132
183
  };
133
184
  return /* @__PURE__ */ jsxs(Section, {
134
185
  title: messages.filters,
186
+ summary,
135
187
  onAdd: () => {
136
- setAdding(true);
188
+ setTarget({});
137
189
  },
138
190
  children: [
139
- leaves.length === 0 && !adding ? /* @__PURE__ */ jsx("p", {
191
+ tree.children.length === 0 && target === void 0 ? /* @__PURE__ */ jsx("p", {
140
192
  className: "dd-muted",
141
193
  children: messages.noFilters
142
194
  }) : null,
143
- leaves.map((f) => /* @__PURE__ */ jsx(Entry, {
144
- label: "member" in f ? b.labelOf(f.member) : f.id,
145
- detail: leafDetail(f, messages),
146
- onRemove: () => {
147
- b.removeFilter(f.id);
148
- }
149
- }, f.id)),
150
- adding && member === void 0 ? /* @__PURE__ */ jsx(Picker, {
151
- options: fieldOptions(b.meta, query.source),
152
- placeholder: messages.searchFields,
153
- autoFocus: true,
154
- onPick: setMember,
155
- onClose: done
195
+ tree.children.length > 1 ? /* @__PURE__ */ jsx(TopMode, {
196
+ b,
197
+ mode: tree.mode
156
198
  }) : null,
157
- member === void 0 ? null : /* @__PURE__ */ jsx(FilterEditor, {
199
+ tree.children.map((child) => /* @__PURE__ */ jsx(ChildView, {
158
200
  b,
159
- member,
201
+ child,
202
+ onAddTo: (group) => {
203
+ setTarget({ group });
204
+ }
205
+ }, child.kind === "group" ? child.id : child.node.id)),
206
+ target === void 0 && tree.children.length === 0 ? null : target === void 0 ? /* @__PURE__ */ jsx("button", {
207
+ type: "button",
208
+ className: "dd-link",
209
+ onClick: () => {
210
+ setTarget({ group: "new" });
211
+ },
212
+ children: messages.addGroup
213
+ }) : /* @__PURE__ */ jsx(Adding, {
214
+ b,
215
+ target,
160
216
  onDone: done
161
- })
217
+ }, target.group ?? "top")
162
218
  ]
163
219
  });
164
220
  }
@@ -0,0 +1,82 @@
1
+ import { useDashboards } from "../context.mjs";
2
+ import { Actions } from "./FilterEditor.mjs";
3
+ import { parseFormula } from "./formula-parse.mjs";
4
+ import { useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/builder/Formula.tsx
7
+ /** The names a formula can use: the widget's measures and calcs, by their labels. */
8
+ function namesOf(b) {
9
+ const query = b.state.query;
10
+ return [...(query?.measures ?? []).map((m) => m.id), ...(query?.calc ?? []).map((c) => c.id)].map((id) => ({
11
+ id,
12
+ label: b.entryLabel(id)
13
+ }));
14
+ }
15
+ /** What the formula uses, or what is wrong with it. */
16
+ function FormulaNote(props) {
17
+ const { messages } = useDashboards();
18
+ const { parsed } = props;
19
+ if (parsed.ok) return /* @__PURE__ */ jsx("p", {
20
+ className: "dd-builder-note",
21
+ children: messages.formulaUses(parsed.uses.map((id) => props.b.entryLabel(id)))
22
+ });
23
+ return /* @__PURE__ */ jsx("p", {
24
+ className: props.empty ? "dd-builder-note" : "dd-builder-error",
25
+ children: messages.formulaProblem(parsed.problem)
26
+ });
27
+ }
28
+ /** A calculation of your own: its name, and a formula over the widget's measures, read as you type. */
29
+ function FormulaEditor({ b, onDone }) {
30
+ const { messages } = useDashboards();
31
+ const [label, setLabel] = useState("");
32
+ const [text, setText] = useState("");
33
+ const names = namesOf(b);
34
+ const parsed = parseFormula(text, names);
35
+ const ready = parsed.ok && label.trim() !== "";
36
+ return /* @__PURE__ */ jsxs("div", {
37
+ className: "dd-inline",
38
+ children: [
39
+ /* @__PURE__ */ jsxs("label", {
40
+ className: "dd-row",
41
+ children: [messages.name, /* @__PURE__ */ jsx("input", {
42
+ className: "dd-search",
43
+ value: label,
44
+ onChange: (e) => {
45
+ setLabel(e.target.value);
46
+ }
47
+ })]
48
+ }),
49
+ /* @__PURE__ */ jsxs("label", {
50
+ className: "dd-row",
51
+ children: ["=", /* @__PURE__ */ jsx("input", {
52
+ className: "dd-search",
53
+ "aria-label": messages.formula,
54
+ "aria-invalid": !parsed.ok && text !== "",
55
+ value: text,
56
+ onChange: (e) => {
57
+ setText(e.target.value);
58
+ }
59
+ })]
60
+ }),
61
+ /* @__PURE__ */ jsx(FormulaNote, {
62
+ b,
63
+ parsed,
64
+ empty: text === ""
65
+ }),
66
+ /* @__PURE__ */ jsx(Actions, {
67
+ ready,
68
+ label: messages.addCalculation,
69
+ onCancel: onDone,
70
+ onAdd: () => {
71
+ if (!parsed.ok) return;
72
+ b.addFormula({
73
+ label: label.trim(),
74
+ formula: parsed.formula
75
+ });
76
+ onDone();
77
+ }
78
+ })
79
+ ]
80
+ });
81
+ }
82
+ export { FormulaEditor };