@motifx-community/ui 0.1.0-beta.14 → 0.1.0-beta.16

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 (330) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +2 -2
  3. package/dist/components/diagram/Diagram.d.ts +607 -0
  4. package/dist/components/diagram/DiagramAutoPan.d.ts +17 -0
  5. package/dist/components/diagram/DiagramBends.d.ts +70 -0
  6. package/dist/components/diagram/DiagramDragging.d.ts +66 -0
  7. package/dist/components/diagram/DiagramEdgeView.d.ts +78 -0
  8. package/dist/components/diagram/DiagramGrid.d.ts +13 -0
  9. package/dist/components/diagram/DiagramHistory.d.ts +16 -0
  10. package/dist/components/diagram/DiagramLinks.d.ts +177 -0
  11. package/dist/components/diagram/DiagramMap.d.ts +62 -0
  12. package/dist/components/diagram/DiagramNodeView.d.ts +143 -0
  13. package/dist/components/diagram/DiagramOverview.d.ts +20 -0
  14. package/dist/components/diagram/DiagramPanning.d.ts +34 -0
  15. package/dist/components/diagram/diagram-alignment.d.ts +2 -0
  16. package/dist/components/diagram/diagram-auto-pan-host.d.ts +8 -0
  17. package/dist/components/diagram/diagram-background.d.ts +2 -0
  18. package/dist/components/diagram/diagram-bends-host.d.ts +17 -0
  19. package/dist/components/diagram/diagram-card-kind.d.ts +42 -0
  20. package/dist/components/diagram/diagram-card-node.d.ts +11 -0
  21. package/dist/components/diagram/diagram-center-options.d.ts +6 -0
  22. package/dist/components/diagram/diagram-change.d.ts +11 -0
  23. package/dist/components/diagram/diagram-class-member.d.ts +13 -0
  24. package/dist/components/diagram/diagram-class-node.d.ts +12 -0
  25. package/dist/components/diagram/diagram-column-checked-event-args.d.ts +9 -0
  26. package/dist/components/diagram/diagram-connected-event-args.d.ts +6 -0
  27. package/dist/components/diagram/diagram-connecting-event-args.d.ts +9 -0
  28. package/dist/components/diagram/diagram-connection.d.ts +7 -0
  29. package/dist/components/diagram/diagram-data.d.ts +12 -0
  30. package/dist/components/diagram/diagram-deleted-event-args.d.ts +8 -0
  31. package/dist/components/diagram/diagram-deleting-event-args.d.ts +9 -0
  32. package/dist/components/diagram/diagram-dragging-host.d.ts +47 -0
  33. package/dist/components/diagram/diagram-drawn-node.d.ts +10 -0
  34. package/dist/components/diagram/diagram-edge-end.d.ts +2 -0
  35. package/dist/components/diagram/diagram-edge-path.d.ts +5 -0
  36. package/dist/components/diagram/diagram-edge-reshaped-event-args.d.ts +8 -0
  37. package/dist/components/diagram/diagram-edge-reshaping-event-args.d.ts +6 -0
  38. package/dist/components/diagram/diagram-edge.d.ts +49 -0
  39. package/dist/components/diagram/diagram-edit.d.ts +10 -0
  40. package/dist/components/diagram/diagram-export-options.d.ts +14 -0
  41. package/dist/components/diagram/diagram-export.d.ts +28 -0
  42. package/dist/components/diagram/diagram-fit-options.d.ts +12 -0
  43. package/dist/components/diagram/diagram-history-changed-event-args.d.ts +14 -0
  44. package/dist/components/diagram/diagram-history-step.d.ts +9 -0
  45. package/dist/components/diagram/diagram-kinds.d.ts +9 -0
  46. package/dist/components/diagram/diagram-layered.d.ts +39 -0
  47. package/dist/components/diagram/diagram-layout-direction.d.ts +2 -0
  48. package/dist/components/diagram/diagram-layout-options.d.ts +24 -0
  49. package/dist/components/diagram/diagram-layout-type.d.ts +5 -0
  50. package/dist/components/diagram/diagram-layout.d.ts +33 -0
  51. package/dist/components/diagram/diagram-line-look.d.ts +6 -0
  52. package/dist/components/diagram/diagram-line.d.ts +11 -0
  53. package/dist/components/diagram/diagram-links-host.d.ts +45 -0
  54. package/dist/components/diagram/diagram-links-options.d.ts +7 -0
  55. package/dist/components/diagram/diagram-map-props.d.ts +10 -0
  56. package/dist/components/diagram/diagram-map-target.d.ts +27 -0
  57. package/dist/components/diagram/diagram-marker.d.ts +6 -0
  58. package/dist/components/diagram/diagram-mini-map-options.d.ts +13 -0
  59. package/dist/components/diagram/diagram-mini-map-position.d.ts +2 -0
  60. package/dist/components/diagram/diagram-node-context.d.ts +26 -0
  61. package/dist/components/diagram/diagram-node-host.d.ts +23 -0
  62. package/dist/components/diagram/diagram-node-kind.d.ts +43 -0
  63. package/dist/components/diagram/diagram-node-move.d.ts +11 -0
  64. package/dist/components/diagram/diagram-node-resized-event-args.d.ts +8 -0
  65. package/dist/components/diagram/diagram-node-resizing-event-args.d.ts +6 -0
  66. package/dist/components/diagram/diagram-node-size.d.ts +8 -0
  67. package/dist/components/diagram/diagram-node-status.d.ts +2 -0
  68. package/dist/components/diagram/diagram-node-toggled-event-args.d.ts +7 -0
  69. package/dist/components/diagram/diagram-node.d.ts +56 -0
  70. package/dist/components/diagram/diagram-nodes-moved-event-args.d.ts +6 -0
  71. package/dist/components/diagram/diagram-nodes-moving-event-args.d.ts +6 -0
  72. package/dist/components/diagram/diagram-panning-host.d.ts +19 -0
  73. package/dist/components/diagram/diagram-pasted-event-args.d.ts +7 -0
  74. package/dist/components/diagram/diagram-pasting-event-args.d.ts +11 -0
  75. package/dist/components/diagram/diagram-path-ends.d.ts +11 -0
  76. package/dist/components/diagram/diagram-path-result.d.ts +6 -0
  77. package/dist/components/diagram/diagram-paths.d.ts +35 -0
  78. package/dist/components/diagram/diagram-point.d.ts +5 -0
  79. package/dist/components/diagram/diagram-port-place.d.ts +9 -0
  80. package/dist/components/diagram/diagram-port.d.ts +27 -0
  81. package/dist/components/diagram/diagram-props.d.ts +159 -0
  82. package/dist/components/diagram/diagram-reconnected-event-args.d.ts +10 -0
  83. package/dist/components/diagram/diagram-reconnecting-event-args.d.ts +11 -0
  84. package/dist/components/diagram/diagram-rect.d.ts +7 -0
  85. package/dist/components/diagram/diagram-resize-side.d.ts +2 -0
  86. package/dist/components/diagram/diagram-route.d.ts +10 -0
  87. package/dist/components/diagram/diagram-selection-changed-event-args.d.ts +9 -0
  88. package/dist/components/diagram/diagram-selection.d.ts +5 -0
  89. package/dist/components/diagram/diagram-side.d.ts +2 -0
  90. package/dist/components/diagram/diagram-table-column.d.ts +13 -0
  91. package/dist/components/diagram/diagram-table-node.d.ts +12 -0
  92. package/dist/components/diagram/diagram-tree.d.ts +14 -0
  93. package/dist/components/diagram/diagram-viewport-changed-event-args.d.ts +8 -0
  94. package/dist/components/diagram/diagram-viewport-options.d.ts +5 -0
  95. package/dist/components/diagram/diagram-viewport.d.ts +6 -0
  96. package/dist/components/diagram/index.d.ts +65 -0
  97. package/dist/components/diagram/swallow-next-click.d.ts +5 -0
  98. package/dist/components/expressioneditor/ExpressionEditor.d.ts +111 -0
  99. package/dist/components/expressioneditor/expression-editor-props.d.ts +24 -0
  100. package/dist/components/expressioneditor/index.d.ts +2 -0
  101. package/dist/components/formlayout/FormLayout.d.ts +10 -3
  102. package/dist/components/formlayout/form-editor-type.d.ts +1 -1
  103. package/dist/components/formlayout/form-item.d.ts +4 -1
  104. package/dist/components/formlayout/form-layout-props.d.ts +1 -1
  105. package/dist/components/formlayout/index.d.ts +1 -0
  106. package/dist/components/formlayout/schema-items.d.ts +26 -0
  107. package/dist/components/pivotgrid/model/PivotAxisWindow.d.ts +53 -1
  108. package/dist/components/pivotgrid/model/PivotCellWindow.d.ts +2 -0
  109. package/dist/components/pivotgrid/model/PivotWindows.d.ts +3 -6
  110. package/dist/components/toolbar/Toolbar.d.ts +5 -3
  111. package/dist/core/control.d.ts +2 -0
  112. package/dist/core/keyboard.d.ts +5 -0
  113. package/dist/core/measure/index.d.ts +2 -0
  114. package/dist/core/measure/picture.d.ts +27 -0
  115. package/dist/core/shortcut-options.d.ts +5 -2
  116. package/dist/core/ui-strings.d.ts +191 -0
  117. package/dist/generated/tokens.d.ts +1615 -0
  118. package/dist/index.d.ts +2 -0
  119. package/dist/index.js +11501 -705
  120. package/dist/index.js.map +1 -1
  121. package/dist/locales/en.json +180 -1
  122. package/dist/locales/tr.json +180 -1
  123. package/dist/styles.css +2262 -3
  124. package/dist/tokens/index.d.ts +1615 -0
  125. package/dist/tokens/index.js +1615 -0
  126. package/dist/tokens/index.js.map +1 -1
  127. package/dist/{tr-BGbF9uCs.js → tr-4GNbFdQh.js} +361 -3
  128. package/dist/{tr-BGbF9uCs.js.map → tr-4GNbFdQh.js.map} +1 -1
  129. package/docs/accordion.md +1 -1
  130. package/docs/actionsheet.md +1 -1
  131. package/docs/appbar.md +1 -1
  132. package/docs/appmenu-api.md +1 -1
  133. package/docs/appmenu-programmatic.md +1 -1
  134. package/docs/appmenu-search.md +1 -1
  135. package/docs/appmenu.md +1 -1
  136. package/docs/avatar.md +1 -1
  137. package/docs/badge.md +1 -1
  138. package/docs/bar-gauge-angles.md +1 -1
  139. package/docs/bar-gauge-data.md +1 -1
  140. package/docs/bar-gauge-labels.md +1 -1
  141. package/docs/bar-gauge.md +1 -1
  142. package/docs/barcode.md +1 -1
  143. package/docs/bottomnavigation.md +1 -1
  144. package/docs/bottomsheet.md +1 -1
  145. package/docs/breadcrumb.md +1 -1
  146. package/docs/button.md +1 -1
  147. package/docs/buttongroup.md +1 -1
  148. package/docs/buttons.md +1 -1
  149. package/docs/calendar.md +1 -1
  150. package/docs/card.md +1 -1
  151. package/docs/chart-bars.md +1 -1
  152. package/docs/chart-candles.md +1 -1
  153. package/docs/chart-funnel.md +1 -1
  154. package/docs/chart-heatmap.md +1 -1
  155. package/docs/chart-lines.md +1 -1
  156. package/docs/chart-live.md +1 -1
  157. package/docs/chart-pie.md +1 -1
  158. package/docs/chart-radar.md +1 -1
  159. package/docs/chart-ranges.md +1 -1
  160. package/docs/chart-references.md +1 -1
  161. package/docs/chart-scatter.md +1 -1
  162. package/docs/chart-waterfall.md +1 -1
  163. package/docs/chart-zoom.md +1 -1
  164. package/docs/chart.md +1 -1
  165. package/docs/chat.md +1 -1
  166. package/docs/checkbox.md +1 -1
  167. package/docs/chip.md +1 -1
  168. package/docs/choice.md +1 -1
  169. package/docs/colorbox.md +1 -1
  170. package/docs/combobox.md +1 -1
  171. package/docs/commands.md +1 -1
  172. package/docs/control.md +1 -1
  173. package/docs/data.md +2 -2
  174. package/docs/datagrid-api.md +1 -1
  175. package/docs/datagrid-bands.md +1 -1
  176. package/docs/datagrid-drag-select.md +1 -1
  177. package/docs/datagrid-drag.md +1 -1
  178. package/docs/datagrid-editing.md +1 -1
  179. package/docs/datagrid-filtering.md +1 -1
  180. package/docs/datagrid-forms.md +1 -1
  181. package/docs/datagrid-grouping.md +1 -1
  182. package/docs/datagrid-layout.md +1 -1
  183. package/docs/datagrid-lookups.md +1 -1
  184. package/docs/datagrid-master-detail.md +1 -1
  185. package/docs/datagrid-scrolling.md +1 -1
  186. package/docs/datagrid-selection.md +1 -1
  187. package/docs/datagrid.md +1 -1
  188. package/docs/datalayer-api.md +491 -0
  189. package/docs/datalayer-changes.md +501 -0
  190. package/docs/datalayer-odata.md +998 -0
  191. package/docs/datalayer-pivot.md +850 -0
  192. package/docs/datalayer-queries.md +516 -0
  193. package/docs/datalayer-rest.md +529 -0
  194. package/docs/datalayer-soap.md +576 -0
  195. package/docs/datalayer-source.md +464 -0
  196. package/docs/datalayer.md +264 -0
  197. package/docs/datebox.md +1 -1
  198. package/docs/daterangebox.md +1 -1
  199. package/docs/diagram-api.md +200 -0
  200. package/docs/diagram-commands.md +79 -0
  201. package/docs/diagram-connections.md +157 -0
  202. package/docs/diagram-custom-nodes.md +325 -0
  203. package/docs/diagram-designer.md +816 -0
  204. package/docs/diagram-editing.md +62 -0
  205. package/docs/diagram-flow.md +157 -0
  206. package/docs/diagram-keyboard.md +58 -0
  207. package/docs/diagram-layout.md +354 -0
  208. package/docs/diagram-nodes.md +206 -0
  209. package/docs/diagram-tables.md +212 -0
  210. package/docs/diagram.md +217 -0
  211. package/docs/display.md +1 -1
  212. package/docs/draggable.md +1 -1
  213. package/docs/drawer.md +1 -1
  214. package/docs/dropdown.md +1 -1
  215. package/docs/editors.md +1 -1
  216. package/docs/expressioneditor.md +469 -0
  217. package/docs/expressions.md +431 -0
  218. package/docs/feedback.md +1 -1
  219. package/docs/fileuploader.md +1 -1
  220. package/docs/filterbuilder.md +1 -1
  221. package/docs/formlayout-schema.md +143 -0
  222. package/docs/formlayout.md +16 -4
  223. package/docs/foundations.md +1 -1
  224. package/docs/gallery.md +1 -1
  225. package/docs/gauge-base.md +1 -1
  226. package/docs/gauge-circular.md +1 -1
  227. package/docs/gauge-dashboards.md +1 -1
  228. package/docs/gauge-linear.md +1 -1
  229. package/docs/gauge-markers.md +1 -1
  230. package/docs/gauge-marks.md +1 -1
  231. package/docs/gauge-ranges.md +1 -1
  232. package/docs/gauge-scales.md +1 -1
  233. package/docs/gauge.md +1 -1
  234. package/docs/home.md +1 -1
  235. package/docs/keyboard.md +2 -2
  236. package/docs/language.md +1 -1
  237. package/docs/layout.md +1 -1
  238. package/docs/listbox.md +1 -1
  239. package/docs/loadpanel.md +1 -1
  240. package/docs/lookup.md +1 -1
  241. package/docs/markdown.md +1 -1
  242. package/docs/menus-api.md +1 -1
  243. package/docs/menus-context.md +1 -1
  244. package/docs/menus-customization.md +1 -1
  245. package/docs/menus-merging.md +1 -1
  246. package/docs/menus-programmatic.md +1 -1
  247. package/docs/menus.md +1 -1
  248. package/docs/multiview.md +1 -1
  249. package/docs/navigation.md +1 -1
  250. package/docs/numberbox.md +1 -1
  251. package/docs/otpinput.md +1 -1
  252. package/docs/pagination.md +1 -1
  253. package/docs/pivotgrid-api.md +1 -1
  254. package/docs/pivotgrid-chart.md +1 -1
  255. package/docs/pivotgrid-drilldown.md +1 -1
  256. package/docs/pivotgrid-export.md +1 -1
  257. package/docs/pivotgrid-fields.md +1 -1
  258. package/docs/pivotgrid-keyboard.md +1 -1
  259. package/docs/pivotgrid-layout.md +1 -1
  260. package/docs/pivotgrid-panel.md +1 -1
  261. package/docs/pivotgrid-remote.md +122 -44
  262. package/docs/pivotgrid-sorting.md +3 -3
  263. package/docs/pivotgrid-state.md +1 -1
  264. package/docs/pivotgrid-summaries.md +1 -1
  265. package/docs/pivotgrid.md +1 -1
  266. package/docs/popover.md +1 -1
  267. package/docs/progress.md +1 -1
  268. package/docs/qrcode.md +1 -1
  269. package/docs/radiogroup.md +1 -1
  270. package/docs/rating.md +1 -1
  271. package/docs/resizable.md +1 -1
  272. package/docs/ribbonmenu-api.md +1 -1
  273. package/docs/ribbonmenu-commands.md +1 -1
  274. package/docs/ribbonmenu-customization.md +1 -1
  275. package/docs/ribbonmenu-display.md +1 -1
  276. package/docs/ribbonmenu-layouts.md +1 -1
  277. package/docs/ribbonmenu-programmatic.md +1 -1
  278. package/docs/ribbonmenu.md +1 -1
  279. package/docs/scheduler-agenda.md +1 -1
  280. package/docs/scheduler-big-data.md +1 -1
  281. package/docs/scheduler-editing.md +1 -1
  282. package/docs/scheduler-form.md +1 -1
  283. package/docs/scheduler-icalendar.md +1 -1
  284. package/docs/scheduler-mobile.md +1 -1
  285. package/docs/scheduler-recurrence.md +1 -1
  286. package/docs/scheduler-resources.md +1 -1
  287. package/docs/scheduler-timeline.md +1 -1
  288. package/docs/scheduler.md +1 -1
  289. package/docs/scrollview.md +1 -1
  290. package/docs/shortcuteditor.md +1 -1
  291. package/docs/showcase-flowstudio.md +61 -0
  292. package/docs/showcase-home.md +1 -1
  293. package/docs/showcase-mail.md +1 -1
  294. package/docs/showcase.md +1 -1
  295. package/docs/signature.md +1 -1
  296. package/docs/skeleton.md +1 -1
  297. package/docs/slider.md +1 -1
  298. package/docs/sortable.md +1 -1
  299. package/docs/sparkline.md +1 -1
  300. package/docs/speeddial.md +1 -1
  301. package/docs/splitter.md +1 -1
  302. package/docs/stepper.md +1 -1
  303. package/docs/switch.md +1 -1
  304. package/docs/tabdocs-dock.md +1 -1
  305. package/docs/tabdocs-drag.md +1 -1
  306. package/docs/tabdocs-menus.md +1 -1
  307. package/docs/tabdocs-mobile.md +1 -1
  308. package/docs/tabdocs-tabs.md +1 -1
  309. package/docs/tabdocs-windows.md +1 -1
  310. package/docs/tabdocs-workspace.md +1 -1
  311. package/docs/tabdocs.md +1 -1
  312. package/docs/tabs.md +1 -1
  313. package/docs/tagbox.md +1 -1
  314. package/docs/textarea.md +1 -1
  315. package/docs/textbox.md +1 -1
  316. package/docs/tileview.md +1 -1
  317. package/docs/timeline.md +1 -1
  318. package/docs/toast.md +1 -1
  319. package/docs/tokens.md +324 -1
  320. package/docs/toolbar-api.md +1 -1
  321. package/docs/toolbar-customization.md +1 -1
  322. package/docs/toolbar.md +1 -1
  323. package/docs/tooltip.md +1 -1
  324. package/docs/treeview.md +1 -1
  325. package/docs/validationsummary.md +1 -1
  326. package/docs/window.md +1 -1
  327. package/docs/wizard.md +1 -1
  328. package/llms-full.txt +10142 -462
  329. package/llms.txt +32 -1
  330. package/package.json +2 -2
@@ -0,0 +1,431 @@
1
+ # Expression language
2
+
3
+ > Data · @motifx-community/ui 0.1.0-beta.16
4
+
5
+ The data package carries a small expression language for the conditions, values and texts an application computes from data: the condition of a rule, the value a flow writes into a step, the body of a message. An expression changes nothing and reaches nothing by itself — it reads only the names it is given and their own fields, the moment and the time zone come from the evaluation, and limits stop runaway work — so the same expression with the same values always gives the same result, in the browser and on a server. It is checked against a schema as it is written, and it travels as text with a plain JSON tree.
6
+
7
+ ## Import
8
+
9
+ Everything is in the `expression` namespace of the data package, so a page and a server use the same language without the kit. `run` reads and works out an expression at once, `render` a template; `parse`, `check` and `evaluate` split the same work into steps whose results can be kept.
10
+
11
+ ```tsx
12
+ import { expression } from '@motifx-community/data';
13
+
14
+ const rows = [{ total: 100 }, { total: 250 }];
15
+ expression.run('sum(rows, r => r.total) * 1.2', { rows }); // 420
16
+ expression.render('{{ count(rows) }} rows', { rows }); // '2 rows'
17
+ ```
18
+
19
+ ## Values
20
+
21
+ A value is a number, a text, a boolean, a day, a moment, a list, an object or `null`. Nothing converts by itself; the one exception is `+`, which writes the other side as text when one side is one. Spaces, tabs and line ends separate the pieces and mean nothing more; there are no comments.
22
+
23
+ | Written | Meaning |
24
+ | --- | --- |
25
+ | `12 3.5 0.25 1e6 2.5e-3` | A number: a 64-bit floating point value; whole numbers are exact up to 2^53. The decimal separator is a point, and there is no group separator. |
26
+ | `'Ada' "Ada"` | A text, in single or double quotes. The escapes are `\\`, `\'`, `\"`, `\n`, `\t` and `\u{1F600}`. |
27
+ | `true false` | The two boolean values. |
28
+ | `null` | No value. Every type may hold it. |
29
+ | `#2026-01-31#` | A day: a date of the calendar, with no clock time and no time zone. |
30
+ | `#2026-01-31 09:30#` | A moment, read on the clock of the time zone of the evaluation; seconds may follow (`#2026-01-31 09:30:15#`). |
31
+ | `#2026-01-31T09:30:00Z#` | An exact moment: `Z` or an offset (`+03:00`) names the instant itself. |
32
+ | `[1, 2, 3]` | A list. Its items may be of any type. |
33
+ | `{ name: 'Ada', total: 12 }` | An object of named fields. A key may also be a text: `{ 'full name': 'Ada' }`. |
34
+
35
+ ## Names and fields
36
+
37
+ A name starts with a letter or `_` and goes on with letters, digits and `_`; the letters of every language count. `and`, `or`, `not`, `in`, `true`, `false` and `null` are words of the language, so they cannot stand alone as names — but a keyword may follow a dot: `item.in` is a field like any other. A name the schema does not give is the `unknownName` problem.
38
+
39
+ `a.b` reads a field, `a[0]` an item of a list, `a['full name']` a field named by a text — the way to a name with spaces in it. Only an object's own fields are read; a field it does not have gives `null` when its type is open or `any` (on a closed type, the check reports `unknownField`), and a place past the end of a list gives `null`.
40
+
41
+ When `a` is `null`, `a.b` stops with the `nullPath` problem, so a missing value shows early. Write `a?.b` or `a?.[0]` to give `null` instead, and `??` to put a value in its place.
42
+
43
+ ```tsx
44
+ item.customer.name
45
+ rows[0].total
46
+ vars['full name']
47
+ item.email ?? 'no address'
48
+ item.contact?.email
49
+ ```
50
+
51
+ ## Operators
52
+
53
+ From the loosest to the tightest; parentheses group as usual.
54
+
55
+ | Operators | Meaning |
56
+ | --- | --- |
57
+ | `a ? b : c` | The condition: only the side chosen is worked out. The test is a boolean; `null` picks the `else` side. |
58
+ | `a ?? b` | `a`, or `b` when `a` is `null`. The right side is worked out only then. |
59
+ | `or \|\|` | Or, short-circuit: the right side is worked out only when the left is `false`. `\|\|` is read as `or`. |
60
+ | `and &&` | And, short-circuit: the right side is worked out only when the left is `true`. `&&` is read as `and`. |
61
+ | `= !=` | Equal and not equal, for any two values: lists and objects by their items and fields, and values of different types are not equal. `==` is a problem: compare with `=` alone. |
62
+ | `< <= > >= in not in` | Order: two numbers, two texts (by their characters, the same in every culture), or days and moments. `in` asks whether a value equals an item of a list. |
63
+ | `+ -` | Add and subtract. When either side of `+` is a text, the other is written as text and the two are joined. |
64
+ | `* / %` | Multiply, divide and remainder. A division by zero is a problem. |
65
+ | `-a not a` | A number with its sign turned, and a boolean turned. `!` is read as `not`. |
66
+ | `a.b a?.b a[0] a?.[0] f(x)` | Fields, items and calls bind tightest. |
67
+
68
+ `null` flows through quietly where that reads naturally: arithmetic and `<`, `<=`, `>`, `>=` with `null` give `null`, the condition, `and` and `or` count it as `false`, and `+` with a text writes it as nothing. Only `=` and `!=` answer about it: `item.email = null` is `true` when the field is empty. A path on `null` is the exception that stops (see above).
69
+
70
+ A short function is an argument of a function and nothing else: `filter(rows, r => r.total > 100)`, `avg(rows, r => r.total)`, `(a, b) => …` with more parameters. It is the whole of its argument; written anywhere else it is the `lambdaOutsideCall` problem.
71
+
72
+ ## Templates
73
+
74
+ A template is plain text with `{{ … }}` expressions in it, for subjects, messages and labels. `parseTemplate` reads it and `render` writes it out: each expression is worked out and written as text — `null` writes nothing, a day `YYYY-MM-DD`, a moment `YYYY-MM-DD HH:MM:SS` on the clock of the time zone, a list or an object as JSON. `{{` writes a literal `{{`.
75
+
76
+ ```tsx
77
+ Dear {{ item.name }}, {{ count(item.orders) }} of your orders are open.
78
+ Total: {{ format(sum(item.orders, o => o.total), '#,##0.00') }},
79
+ due {{ formatDate(addDays(today(), 3), 'dd MMMM yyyy') }}.
80
+ ```
81
+
82
+ ## Types and schemas
83
+
84
+ A schema names what the expression may read and the type of each name, as a `Type` value or as text:
85
+
86
+ | Type text | Meaning |
87
+ | --- | --- |
88
+ | `number text boolean date datetime` | The plain types. |
89
+ | `any` | A value whose type is known only while it runs, as the body of a service reply is. Checks on it wait until then. |
90
+ | `list<number>` | A list and the type of its items. |
91
+ | `{ id: number, email: text? }` | An object and its fields. `?` after a type: the value may be `null`. |
92
+ | `{ id: number, * }` | An open object: it may have fields the type does not name. |
93
+
94
+ `check` gives the type of the value and the problems, each with its place; it never throws. Reading a value that may be `null` without `?.` is the `mayBeNull` warning, and `expect` names the type the value is wanted as — a condition is `boolean` — anything else is the `resultType` problem.
95
+
96
+ ```tsx
97
+ const { tree } = expression.parse("count(filter(rows, r => r.status = 'late')) > 0");
98
+ const { type, problems } = expression.check(
99
+ tree!,
100
+ { rows: 'list<{ status: text, total: number }>' },
101
+ { expect: 'boolean' },
102
+ );
103
+ expression.typeText(type); // 'boolean'
104
+ ```
105
+
106
+ ## Functions
107
+
108
+ The library has 84 functions, called by name: `round(item.total, 2)`. A parameter marked `?` may be left out, and `…` takes as many arguments as are given. `if` and `coalesce` are lazy: they work out only the arguments they need, so the side not chosen never runs.
109
+
110
+ ### Text
111
+
112
+ | Function | Description | Example |
113
+ | --- | --- | --- |
114
+ | `len(text)` | The number of characters of a text. | `len('Merhaba')` |
115
+ | `upper(text)` | A text in capital letters, as the culture of the evaluation writes them. | `upper(item.city)` |
116
+ | `lower(text)` | A text in small letters, as the culture of the evaluation writes them. | `lower(item.email)` |
117
+ | `trim(text)` | A text without the spaces at its start and end. | `trim(item.name)` |
118
+ | `trimStart(text)` | A text without the spaces at its start. | `trimStart(item.code)` |
119
+ | `trimEnd(text)` | A text without the spaces at its end. | `trimEnd(item.code)` |
120
+ | `contains(text, part, ignoreCase?)` | Whether a text has a part in it; with `true`, whatever the case of its letters. | `contains(item.subject, 'urgent', true)` |
121
+ | `startsWith(text, part)` | Whether a text starts with a part. | `startsWith(item.code, 'TR')` |
122
+ | `endsWith(text, part)` | Whether a text ends with a part. | `endsWith(item.email, '.com')` |
123
+ | `indexOf(text, part)` | Where a part first stands in a text, from 0; -1 when it is not in it. | `indexOf(item.email, '@')` |
124
+ | `substring(text, start, length?)` | A part of a text: from a place (0 is the first character), so many characters or to its end. | `substring(item.code, 2, 4)` |
125
+ | `replace(text, find, with)` | A text with every place of a part written as another. | `replace(item.phone, ' ', '')` |
126
+ | `split(text, separator)` | The parts of a text between its separators, as a list. | `split(item.tags, ',')` |
127
+ | `join(list, separator)` | The items of a list as one text, a separator between them. | `join(map(rows, r => r.name), ', ')` |
128
+ | `padStart(text, length, fill?)` | A text made as long as a length, a fill (a space when none is given) added before it. | `padStart(text(item.no), 6, '0')` |
129
+ | `padEnd(text, length, fill?)` | A text made as long as a length, a fill (a space when none is given) added after it. | `padEnd(item.name, 20, '.')` |
130
+ | `repeat(text, count)` | A text written so many times. | `repeat('-', 10)` |
131
+ | `left(text, count)` | The first characters of a text. | `left(item.name, 1)` |
132
+ | `right(text, count)` | The last characters of a text. | `right(item.iban, 4)` |
133
+ | `text(value)` | A value as text: null is empty, a day YYYY-MM-DD, a moment YYYY-MM-DD HH:MM:SS, a list or an object JSON. | `'No ' + text(item.no)` |
134
+ | `format(value, pattern, culture?)` | A number, day or moment written with a pattern, the separators and names from the culture. | `format(item.total, '#,##0.00')` |
135
+
136
+ ### Number
137
+
138
+ | Function | Description | Example |
139
+ | --- | --- | --- |
140
+ | `round(number, digits?)` | A number rounded to so many decimal digits (none when not given), a half away from zero. | `round(item.price * 1.2, 2)` |
141
+ | `floor(number)` | The whole number at or below a number. | `floor(item.hours)` |
142
+ | `ceil(number)` | The whole number at or above a number. | `ceil(count(rows) / 20)` |
143
+ | `abs(number)` | A number without its sign. | `abs(item.balance)` |
144
+ | `min(...values)` | The smallest of the numbers given, null ones left out. | `min(item.stock, 10)` |
145
+ | `max(...values)` | The largest of the numbers given, null ones left out. | `max(item.discount, 0)` |
146
+ | `clamp(number, low, high)` | A number kept between a lowest and a highest. | `clamp(item.score, 0, 100)` |
147
+ | `pow(number, power)` | A number to a power. | `pow(1.01, 12)` |
148
+ | `sqrt(number)` | The square root of a number that is not below zero. | `sqrt(item.area)` |
149
+ | `sign(number)` | -1, 0 or 1, as a number is below, at or above zero. | `sign(item.balance)` |
150
+ | `number(value)` | A value as a number: a text written with a point for its decimals, true 1, false 0; null for anything else. | `number(item.amount) ?? 0` |
151
+
152
+ ### List
153
+
154
+ | Function | Description | Example |
155
+ | --- | --- | --- |
156
+ | `count(list)` | The number of items of a list; 0 for null. | `count(steps.orders.rows)` |
157
+ | `isEmpty(value)` | Whether a list, a text or an object has nothing in it; true for null. | `isEmpty(item.note)` |
158
+ | `first(list)` | The first item of a list; null when it has none. | `first(steps.orders.rows)?.email` |
159
+ | `last(list)` | The last item of a list; null when it has none. | `last(sortBy(rows, r => r.at))` |
160
+ | `at(list, index)` | The item at a place of a list, from 0; a place below zero counts from its end; null past it. | `at(rows, -1)` |
161
+ | `sum(list, select?)` | The sum of the numbers of a list, or of what a short function picks of its items; null ones left out. | `sum(rows, r => r.total)` |
162
+ | `avg(list, select?)` | The average of the numbers of a list, or of what a short function picks; null when there is none. | `avg(rows, r => r.total)` |
163
+ | `minOf(list, select?)` | The smallest value of a list, or of what a short function picks: a number, a text, a day or a moment. | `minOf(rows, r => r.orderedOn)` |
164
+ | `maxOf(list, select?)` | The largest value of a list, or of what a short function picks: a number, a text, a day or a moment. | `maxOf(rows, r => r.total)` |
165
+ | `filter(list, keep)` | The items of a list a short function answers true for. | `filter(rows, r => r.status = 'late')` |
166
+ | `map(list, make)` | A list of what a short function makes of each item of a list. | `map(rows, r => r.email)` |
167
+ | `find(list, match)` | The first item of a list a short function answers true for; null when there is none. | `find(rows, r => r.id = vars.id)` |
168
+ | `any(list, match?)` | Whether a list has an item a short function answers true for, or any item at all. | `any(rows, r => r.total > 1000)` |
169
+ | `all(list, match)` | Whether a short function answers true for every item of a list; true for an empty one. | `all(rows, r => r.paid)` |
170
+ | `sortBy(list, key, direction?)` | The items of a list sorted by what a short function picks of them, 'desc' from the largest; the order of equal ones kept. | `sortBy(rows, r => r.total, 'desc')` |
171
+ | `distinct(list, key?)` | The items of a list without the ones equal to one before them, or whose picked value is. | `distinct(map(rows, r => r.city))` |
172
+ | `take(list, count)` | The first items of a list. | `take(sortBy(rows, r => r.total, 'desc'), 5)` |
173
+ | `skip(list, count)` | The items of a list after the first ones. | `skip(rows, 10)` |
174
+ | `groupBy(list, key)` | The items of a list in groups of one picked value: a list of { key, items }, in the order the keys first come. | `map(groupBy(rows, r => r.city), g => g.key + ": " + text(count(g.items)))` |
175
+ | `flatten(list)` | The items of the lists in a list, as one list. | `flatten(map(rows, r => r.lines))` |
176
+ | `concat(...lists)` | The items of the lists given, one list after the other; null ones left out. | `concat(steps.a.rows, steps.b.rows)` |
177
+ | `range(start, count)` | A list of so many numbers, one after the other, from a start. | `range(1, 12)` |
178
+
179
+ ### Object
180
+
181
+ | Function | Description | Example |
182
+ | --- | --- | --- |
183
+ | `keys(object)` | The names of the fields of an object. | `keys(steps.http.body)` |
184
+ | `values(object)` | The values of the fields of an object. | `values(item.totals)` |
185
+ | `get(object, name)` | The field of an object a text names; null when it has none. | `get(item.prices, vars.currency)` |
186
+ | `has(object, name)` | Whether an object has a field of a name. | `has(steps.http.body, 'error')` |
187
+
188
+ ### Logic
189
+
190
+ | Function | Description | Example |
191
+ | --- | --- | --- |
192
+ | `if(condition, then, else)` | One of two values, as a condition is true or not; only that one is worked out. | `if(item.vip, 'Değerli müşterimiz', 'Sayın müşterimiz')` |
193
+ | `coalesce(...values)` | The first of the values that is not null; those after it are not worked out. | `coalesce(item.mobile, item.phone, "-")` |
194
+ | `bool(value)` | A value as true or false: a boolean, 'true' or 'false', 1 or 0; null for anything else. | `bool(steps.http.body.active)` |
195
+ | `typeOf(value)` | The kind of a value: 'number', 'text', 'boolean', 'date', 'datetime', 'list', 'object' or 'null'. | `typeOf(steps.http.body) = 'list'` |
196
+ | `parseJson(text)` | The value a JSON text writes. | `parseJson(steps.http.text).items` |
197
+ | `toJson(value)` | A value written as JSON. | `toJson({ id: item.id, total: item.total })` |
198
+ | `isNull(value)` | Whether a value is null. | `isNull(item.closedAt)` |
199
+
200
+ ### Days and moments
201
+
202
+ | Function | Description | Example |
203
+ | --- | --- | --- |
204
+ | `now()` | The moment the evaluation was given as now. | `formatDate(now(), 'HH:mm')` |
205
+ | `today()` | The day of the current moment in the time zone of the evaluation. | `diffDays(today(), item.dueOn)` |
206
+ | `date(value, month?, day?)` | A day from a year, a month and a day, from a text, or from the day a moment falls on; null for a text that is not a day. | `date(2026, 1, 31)` |
207
+ | `datetime(value)` | A moment read from a text, or the start of a day in the time zone; null for a text that is not a moment. | `datetime('2026-01-31 09:30')` |
208
+ | `year(value)` | The year of a day or moment, read in the time zone. | `year(today())` |
209
+ | `month(value)` | The month of a day or moment, 1 to 12, read in the time zone. | `month(item.dueOn)` |
210
+ | `day(value)` | The day of the month of a day or moment, read in the time zone. | `day(today())` |
211
+ | `hour(value)` | The hour of a moment in the time zone; 0 for a day. | `hour(now())` |
212
+ | `minute(value)` | The minute of a moment in the time zone; 0 for a day. | `minute(now())` |
213
+ | `weekday(value)` | The day of the week of a day or moment: Monday 1 to Sunday 7. | `weekday(today()) <= 5` |
214
+ | `addDays(value, days)` | The day or moment that many calendar days later; a moment keeps its clock time in the time zone. | `addDays(today(), 7)` |
215
+ | `addMonths(value, months)` | The day or moment that many months later, the day of the month clamped to the last day there is. | `addMonths(date(2026, 1, 31), 1)` |
216
+ | `addHours(value, hours)` | The moment that many hours later; a day starts from its first moment in the time zone. | `addHours(now(), 2)` |
217
+ | `addMinutes(value, minutes)` | The moment that many minutes later; a day starts from its first moment in the time zone. | `addMinutes(now(), 90)` |
218
+ | `diffDays(from, to)` | The calendar days from the first to the second, each taken as its day in the time zone. | `diffDays(item.orderedOn, today())` |
219
+ | `diffMinutes(from, to)` | The whole minutes from the first to the second, cut toward zero. | `diffMinutes(item.startedAt, now())` |
220
+ | `startOfMonth(value)` | The first day of the month a day or moment falls in. | `startOfMonth(today())` |
221
+ | `endOfMonth(value)` | The last day of the month a day or moment falls in. | `endOfMonth(today())` |
222
+ | `formatDate(value, pattern, culture?)` | A day or moment written with a pattern of yyyy, MM, dd, HH, mm and the like, the names from the culture. | `formatDate(addDays(today(), 1), 'dd MMMM yyyy', 'tr-TR')` |
223
+
224
+ ### Your own functions
225
+
226
+ An application gives its own functions with the `functions` option — the library itself never changes — and they are offered, checked and described exactly as the library's are. A function is its name, its category, its parameters, its result type from its argument types, and `run`, which receives the argument values: a short function arrives as a function of its parameters' values, and every argument of a `lazy` function as a function that works it out. The context carries `now`, `timeZone` and `culture`, and `step`, `checkList`, `checkText` and `fail` to keep the limits and report a bad argument.
227
+
228
+ ```tsx
229
+ const discount: expression.Function = {
230
+ name: 'discount',
231
+ category: 'number',
232
+ params: [{ name: 'total', kinds: ['number'] }],
233
+ returns: () => ({ name: 'number' }),
234
+ run: ([total], ctx) => {
235
+ ctx.step();
236
+ return (total as number) * 0.9;
237
+ },
238
+ description: 'A total with ten percent off.',
239
+ example: 'discount(item.total)',
240
+ };
241
+
242
+ expression.run('discount(100)', {}, { functions: [discount] }); // 90
243
+ ```
244
+
245
+ ## Days, moments and cultures
246
+
247
+ A day (`date`) is a date of the calendar with no clock time and no time zone: the value of `#2026-01-31#`, `today()` and `date(…)`. It is carried by the `Day` class (`year`, `month`, `day`, `serial`, `weekday`, `addDays`) and written as `YYYY-MM-DD`, in JSON too. A moment (`datetime`) is an exact instant. `now()` gives the moment the evaluation was given as now — pass `now` to replay an evaluation — and `today()` its day in the time zone.
248
+
249
+ The `timeZone` option is the clock everything is read and written on: a moment literal without a zone, the text a moment is written as, `year` through `weekday`, and the start of a day. A day compared with a moment counts as that day's start in the time zone. A text that reads as a day or a moment compares and equals one, so `item.dueOn = '2026-03-01'` also works when the data carries days as texts.
250
+
251
+ `formatDate` writes a day or a moment with a pattern of `yyyy`, `yy`, `MMMM`, `MMM`, `MM`, `M`, `dddd`, `ddd`, `dd`, `d`, `HH`, `H`, `mm` and `ss`; text in single quotes stays as it is. `format` writes a number with `0`, `#`, `.`, `,` and `%` (`'#,##0.00'`), and days and moments with the date patterns. The names of months and weekdays and the number separators come from the `culture` argument or option; with none, every culture reads the same text.
252
+
253
+ ## Problems and limits
254
+
255
+ Every problem has a code, a place (`at: [start, end]` in the text) and its params. `check` returns problems as values — `mayBeNull` is a warning, every other one an error — while reading and working out stop at the first problem: `parse` returns it, and `evaluate`, `run` and `render` throw an `ExpressionError` with `code`, `at` and `params`. `PROBLEM_TEXTS` holds the English text of every code; an interface gives its own texts by the code.
256
+
257
+ ### Writing
258
+
259
+ | Code | English text |
260
+ | --- | --- |
261
+ | `unexpectedEnd` | The expression ends too soon: {expected} is missing. |
262
+ | `unexpectedToken` | {found} was not expected here; {expected} was. |
263
+ | `unclosedText` | The text is not closed: a {quote} is missing at its end. |
264
+ | `badEscape` | {escape} is not an escape of a text. |
265
+ | `badNumber` | {text} is not a number. |
266
+ | `badDate` | {text} is not a day or a moment: write #2026-01-31# or #2026-01-31 09:30#. |
267
+ | `useSingleEquals` | Compare with = alone. |
268
+ | `lambdaOutsideCall` | A short function is written only as an argument of a function. |
269
+ | `unclosedTemplate` | The {{ is not closed with }}. |
270
+
271
+ ### Checking
272
+
273
+ | Code | English text |
274
+ | --- | --- |
275
+ | `unknownName` | {name} is not known here. |
276
+ | `unknownField` | {type} has no field {name}. |
277
+ | `unknownFunction` | There is no function {name}. |
278
+ | `argumentCount` | {name} takes {expected} arguments, not {count}. |
279
+ | `argumentType` | The argument {param} of {name} is {expected}, not {found}. |
280
+ | `operandType` | {op} does not take {left} and {right}. |
281
+ | `notAList` | {found} is not a list. |
282
+ | `notAnObject` | {found} has no fields. |
283
+ | `mayBeNull` | {name} may be null: write ?. to give null then. |
284
+ | `resultType` | The expression gives {found}; {expected} is wanted here. |
285
+
286
+ ### Working out
287
+
288
+ | Code | English text |
289
+ | --- | --- |
290
+ | `nullPath` | {name} is null: write ?. to give null then. |
291
+ | `divideByZero` | A division by zero. |
292
+ | `typeMismatch` | {op} does not take {left} and {right}. |
293
+ | `badArgument` | The argument {param} of {name} cannot be {value}. |
294
+ | `stepLimit` | The expression took more than {limit} steps. |
295
+ | `listLimit` | A list grew past {limit} items. |
296
+ | `textLimit` | A text grew past {limit} characters. |
297
+ | `depthLimit` | The expression went deeper than {limit} levels. |
298
+
299
+ ### Limits
300
+
301
+ The limits keep an expression from running away; `limits` raises or lowers any of them, and `DEFAULT_LIMITS` holds the defaults.
302
+
303
+ | Limit | Description |
304
+ | --- | --- |
305
+ | `steps: 100000` | Steps of work: every node worked out, every item `in` compares. Past it: `stepLimit`. |
306
+ | `listLength: 100000` | The longest list a literal or a function may build. Past it: `listLimit`. |
307
+ | `textLength: 1000000` | The longest text `+`, a template or a function may build. Past it: `textLimit`. |
308
+ | `depth: 64` | How deep the working out may nest. Past it: `depthLimit`. |
309
+
310
+ ## The tree
311
+
312
+ An expression is kept and sent as its text with its tree: plain JSON, `version: 1`, and a `root` of nodes. Every node carries `at: [start, end]`, where it stands in the text, which is how problems point at their place. A reader — a server, say — takes the tree without reading the text again.
313
+
314
+ ```tsx
315
+ { "version": 1, "source": "count(steps.orders.rows) > 0", "root": {
316
+ "kind": "binary", "op": ">", "at": [0, 28],
317
+ "left": { "kind": "call", "name": "count", "at": [0, 24], "args": [
318
+ { "kind": "member", "name": "rows", "at": [6, 23], "optional": false, "object":
319
+ { "kind": "member", "name": "orders", "at": [6, 18], "optional": false, "object":
320
+ { "kind": "name", "name": "steps", "at": [6, 11] } } }
321
+ ] },
322
+ "right": { "kind": "literal", "value": 0, "at": [27, 28] }
323
+ } }
324
+ ```
325
+
326
+ | Kind | Fields |
327
+ | --- | --- |
328
+ | `literal` | `value`; for a day or a moment also `type` (`date`, `datetime`), and `value` is its text. |
329
+ | `name` | `name`: a name of the schema, or a parameter of the short function it is in. |
330
+ | `member` | `object`, `name`, `optional` (`?.`). |
331
+ | `index` | `object`, `index`, `optional`. |
332
+ | `call` | `name`, `args`. |
333
+ | `lambda` | `params`, `body`. |
334
+ | `unary` | `op` (`-`, `not`), `operand`. `!` is written as `not`. |
335
+ | `binary` | `op`, `left`, `right`. `\|\|` and `&&` are written as `or` and `and`, `not in` as `notIn`. |
336
+ | `conditional` | `test`, `then`, `else`. |
337
+ | `list` | `items`. |
338
+ | `object` | `entries`: `{ key, value }` pairs. |
339
+ | `template` | `parts`: texts and nodes, in order. |
340
+
341
+ ## Try it
342
+
343
+ `ExpressionEditor` edits the language with the list of words, the signatures, the colors and the problems, all read from the same schema; [its own page](expressioneditor.md) shows the rest. Here, the value below the editor is `expression.run` with the same names, and a problem shows as the message of its `ExpressionError`.
344
+
345
+ ```tsx
346
+ import { reactive } from '@motifx/core';
347
+ import { expression } from '@motifx-community/data';
348
+ import { ExpressionEditor } from '@motifx-community/ui';
349
+
350
+ const schema: expression.Schema = {
351
+ item: '{ name: text, email: text?, total: number, orders: list<{ total: number, status: text }> }',
352
+ rows: 'list<{ total: number, status: text }>',
353
+ };
354
+
355
+ /** The values the expression is worked out with. */
356
+ const names = {
357
+ item: {
358
+ name: 'Ada Yılmaz',
359
+ email: null,
360
+ total: 1250,
361
+ orders: [
362
+ { total: 400, status: 'paid' },
363
+ { total: 850, status: 'late' },
364
+ ],
365
+ },
366
+ rows: [
367
+ { total: 380, status: 'open' },
368
+ { total: 1250, status: 'late' },
369
+ { total: 2100, status: 'paid' },
370
+ ],
371
+ };
372
+
373
+ /** Type an expression over `item` and `rows`; the value below follows it. */
374
+ export default function Playground() {
375
+ const s = reactive({ text: 'sum(item.orders, o => o.total) > 1000 ? upper(item.name) : item.name' });
376
+
377
+ const value = () => {
378
+ try {
379
+ return JSON.stringify(expression.run(s.text, names));
380
+ } catch (e) {
381
+ return e instanceof expression.ExpressionError ? `${e.code}: ${e.message}` : String(e);
382
+ }
383
+ };
384
+
385
+ return (
386
+ <>
387
+ <ExpressionEditor label="Expression" schema={schema} x-model={() => s.text} stretch />
388
+ <output>{() => `Value: ${value()}`}</output>
389
+ </>
390
+ );
391
+ }
392
+ ```
393
+
394
+ ## API reference
395
+
396
+ | Member | Returns | Description |
397
+ | --- | --- | --- |
398
+ | `parse(text)` | `{ tree, problems }` | Reads an expression. `tree` is `null` when the text does not read, with the problem that stopped it. |
399
+ | `parseTemplate(text)` | `{ tree, problems }` | Reads a template: plain text with `{{ … }}` expressions in it. The tree's root is a `template` node. |
400
+ | `check(tree, schema?, options?)` | `{ type, problems }` | The type of the value and the problems, errors and warnings, each where it is. It never throws. |
401
+ | `evaluate(tree, names?, options?)` | `unknown` | The value of the expression with the values of its names. A problem stops it with an `ExpressionError`. |
402
+ | `run(text, names?, options?)` | `unknown` | Reads and works out a text at once; a problem of the text or of the evaluation throws. |
403
+ | `render(text, names?, options?)` | `string` | Reads and works out a template: the text with its expressions written in. |
404
+ | `type(text)` | `Type` | A type read from its text (`list<{ id: number }>`); it throws on a text that is not one. |
405
+ | `typeText(type)` | `string` | A type as text, as `type` reads it. |
406
+ | `tokens(source, options?)` | `Token[]` | The pieces of the text, each with what it is, for an editor that colors them. It never throws. |
407
+ | `complete(source, at, schema?, options?)` | `CompletionResult \| null` | The words that may be written at an offset: fields after a dot, names, functions and keywords; `null` where nothing is written. |
408
+ | `signatureAt(source, at, options?)` | `SignatureHelp \| null` | The call the offset is in: its function and which argument, for an editor that shows its parameters. |
409
+ | `functions` | `readonly Function[]` | The 84 functions of the library, with their parameters, descriptions and examples. Checking and completion read the same list. |
410
+ | `problemText(code, params)` | `string` | The English text of a problem with its params written in. |
411
+ | `PROBLEM_TEXTS` | `Record<ProblemCode, string>` | The text of every problem code in English. A user interface gives its own texts by the code. |
412
+ | `DEFAULT_LIMITS` | `EvaluateLimits` | Steps `100000`, list `100000` items, text `1000000` characters, depth `64`. |
413
+ | `Day` | class | The value of the `date` type: a day of the calendar with no clock time and no time zone. |
414
+ | `ExpressionError` | class | The problem that stopped an evaluation: `code`, `at` and `params`, with the English text as `message`. |
415
+ | `nullable(type, may?) joinTypes(a, b)` | `Type` | Type helpers: the same type that may be `null` or may not, and the type of a value that is one of two. |
416
+ | `Node Tree Type Schema Problem Token Function` | types | The types, under the same namespace: `expression.Schema`, `expression.Problem`, `expression.Function` and the rest. |
417
+
418
+ ### Options
419
+
420
+ | Option | Default | Description |
421
+ | --- | --- | --- |
422
+ | `now` | The moment of the call | The moment `now()` gives, so an evaluation can be replayed. |
423
+ | `timeZone` | The runtime's | The time zone days and moments are read and written in (`Europe/Istanbul`). |
424
+ | `culture` | None | The culture of texts (`tr-TR`): the cases of letters, the names of months and weekdays, the number separators. None gives texts that read the same everywhere. |
425
+ | `limits` | `DEFAULT_LIMITS` | How far an evaluation may go; any of the four may be set. |
426
+ | `functions` | `[]` | Functions of the application, besides those of the library: `check`, `evaluate`, `complete` and the editor all take them. |
427
+ | `expect` | None | For `check`: the type the value is wanted as, as a condition is `boolean`. Another gives the `resultType` problem. |
428
+
429
+ ## Feedback
430
+
431
+ Loading issues…
package/docs/feedback.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Feedback
2
2
 
3
- > Feedback · @motifx-community/ui 0.1.0-beta.14
3
+ > Feedback · @motifx-community/ui 0.1.0-beta.16
4
4
 
5
5
  Feedback components tell the reader what is happening: how far a task has come, that something is loading, what a control does, and what has just happened.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # FileUploader
2
2
 
3
- > Editors · @motifx-community/ui 0.1.0-beta.14
3
+ > Editors · @motifx-community/ui 0.1.0-beta.16
4
4
 
5
5
  Lets users select files with a button or drop them on the box. Files are listed with their size and status, and can upload automatically, on a button click or programmatically, with progress, cancel, retry and remove for each file. Files that exceed the limits are listed with the reason.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # FilterBuilder
2
2
 
3
- > Data · @motifx-community/ui 0.1.0-beta.14
3
+ > Data · @motifx-community/ui 0.1.0-beta.16
4
4
 
5
5
  Lets users build a filter visually, using groups joined by And, Or, Not And or Not Or, and conditions made of a field, an operation and a value. Its value is a data layer filter expression, so it works directly with in-memory rows and every adapter. DataGrid opens it from the filter panel, and you can also use it on its own for reports or saved searches.
6
6
 
@@ -0,0 +1,143 @@
1
+ # FormLayout: From a schema
2
+
3
+ > Navigation · @motifx-community/ui 0.1.0-beta.16
4
+
5
+ A form can be made from a schema of its data object: a field for each property, with the editor its type, values and format call for, its title as the label and its description as the help text. The same schema checks the value in the form, in the application and on a server, with the data layer's `jsonSchema`, a subset of JSON Schema.
6
+
7
+ ## Import
8
+
9
+ ```tsx
10
+ import { FormLayout, schemaItems } from '@motifx-community/ui';
11
+ import { jsonSchema } from '@motifx-community/data';
12
+ ```
13
+
14
+ ## A form from a schema
15
+
16
+ `schemaItems` makes the items; put your own after them, such as a button. The data starts from the schema's defaults with `jsonSchema.defaults`, and `jsonSchema.validate` checks the value the form wrote, as a server would. The subject and the body are templates (`x-editor`), and their names come from `options.editorProps`.
17
+
18
+ ```tsx
19
+ import { reactive } from '@motifx/core';
20
+ import { jsonSchema } from '@motifx-community/data';
21
+ import { FormLayout, schemaItems } from '@motifx-community/ui';
22
+
23
+ /** The settings of a step that sends an email: what the step needs, as a schema the form and a server both read. */
24
+ const emailStep: jsonSchema.JsonSchema = {
25
+ type: 'object',
26
+ required: ['account', 'to', 'subject'],
27
+ properties: {
28
+ kind: { const: 'email' },
29
+ account: { type: 'string', title: 'Account', description: 'An email account the server knows by name.', enum: ['sales', 'support'] },
30
+ to: { type: 'array', title: 'To', items: { type: 'string', format: 'email' } },
31
+ subject: { type: 'string', title: 'Subject', maxLength: 120, 'x-editor': 'template' },
32
+ body: { type: 'string', title: 'Body', 'x-editor': 'template', 'x-editorProps': { multiline: true, rows: 4 } },
33
+ priority: { type: 'string', title: 'Priority', enum: ['low', 'normal', 'high'], default: 'normal' },
34
+ retries: { type: 'integer', title: 'Retries', minimum: 0, maximum: 5, default: 2 },
35
+ sendOn: { type: ['string', 'null'], title: 'Send on', format: 'date' },
36
+ reply: {
37
+ type: 'object',
38
+ title: 'Reply to',
39
+ properties: {
40
+ name: { type: 'string', title: 'Name' },
41
+ address: { type: 'string', title: 'Address', format: 'email' },
42
+ },
43
+ },
44
+ },
45
+ };
46
+
47
+ /** The names the templates may use. */
48
+ const names = { item: '{ id: number, customer: text, total: number, dueOn: date }' };
49
+
50
+ /** A form made from the schema, its data started from the schema's defaults, and the same schema checking the value. */
51
+ export default function EmailStep() {
52
+ const settings = reactive(jsonSchema.defaults(emailStep) as Record<string, unknown>);
53
+ const s = reactive({ result: '' });
54
+ const items = [...schemaItems(emailStep, { editorProps: { template: { schema: names } } }), { button: { text: 'Check', tone: 'accent' as const, submit: true } }];
55
+
56
+ const check = () => {
57
+ const { valid, problems } = jsonSchema.validate(emailStep, settings);
58
+ s.result = valid ? 'The value fits the schema.' : problems.map((p) => `${p.path.join('.')}: ${p.message}`).join('\n');
59
+ };
60
+
61
+ return (
62
+ <>
63
+ <FormLayout data={settings} columns={2} items={items} onValidSubmit={check} onInvalidSubmit={check} />
64
+ <pre class="fl-schema-value">{() => JSON.stringify(settings, null, 2)}</pre>
65
+ <pre class="fl-schema-result">{() => s.result}</pre>
66
+ </>
67
+ );
68
+ }
69
+ ```
70
+
71
+ ## What the schema says
72
+
73
+ | Keyword | In the form | In validate |
74
+ | --- | --- | --- |
75
+ | `type` | The editor, with `format` and `enum`. | The type of the value. A list of types such as `["string", "null"]` lets the value be `null`. |
76
+ | `title, description` | The label and the help text. | — |
77
+ | `default` | — | —; `jsonSchema.defaults` starts a value with it. |
78
+ | `enum` | A drop-down of the values. | The value is one of them. |
79
+ | `const` | Not shown: the value is the data's. | The value is it. |
80
+ | `minimum, maximum` | The number box's bounds. | A number at or above, at or below. |
81
+ | `minLength, maxLength` | The text box stops at `maxLength`. | The characters of a text. |
82
+ | `pattern` | — | A regular expression the text matches somewhere; write `^…$` for the whole text. |
83
+ | `format` | A date box for `date` and `date-time`, an email box for `email`. | `date`, `date-time` (with its offset), `email`, `uri`. |
84
+ | `required` | The field asks for a value. | The field is there. |
85
+ | `properties` | A field each; an object is a group that edits the object in it. | Each field that is there, against its schema. |
86
+ | `items` | A list of texts, numbers or values of an `enum` is a tag box. | Each item, against the schema. |
87
+ | `x-editor, x-editorProps` | An editor of `FormLayout.editors` by name, and its props. | Not read: keys that start with `x-` are the application's. |
88
+
89
+ A field the user empties is left out of the data, or written as `null` where its type allows it, so the form and `validate` agree: an empty field that is not required passes both, and a required one fails both. A required text with nothing in it is not there.
90
+
91
+ ## Editors
92
+
93
+ The editor of a property comes from its schema, in this order:
94
+
95
+ | Schema | Editor |
96
+ | --- | --- |
97
+ | `enum` | DropDown (`dropdown`) |
98
+ | `boolean` | CheckBox (`checkbox`) |
99
+ | `integer, number` | NumberBox (`number`); an integer takes no decimals |
100
+ | `string` | TextBox (`text`) |
101
+ | `string, format: date` | DateBox (`date`); the value is kept as `2026-01-31` |
102
+ | `string, format: date-time` | DateBox (`datetime`); the value is kept with its offset, `2026-01-31T06:30:00.000Z` |
103
+ | `string, format: email` | TextBox (`email`) |
104
+ | `string, format: uri` | TextBox (`text`, of type `url`) |
105
+ | `array of string, number or enum` | TagBox (`tagbox`); typed texts are added, numbers read as numbers |
106
+ | `object with properties` | A group with the object's fields |
107
+ | `const` | No field |
108
+
109
+ `x-editor` picks any editor of `FormLayout.editors` instead, by name: `expression` and `template` are the kit's ExpressionEditor, and an application registers its own once (`FormLayout.editors.set('schedule', (props) => new ScheduleEditor(props))`). `x-editorProps` gives that one field its props, and `options.editorProps` gives every field of an editor the same ones. The value still goes through the schema's checks.
110
+
111
+ ## Checks
112
+
113
+ Each field runs the data layer's `jsonSchema.validate` on its own value with its property's schema, the same check an application or a server makes, and shows the first problem with the kit's text in its language. The editors' own checks come first: a number box's bounds, a date box's dates.
114
+
115
+ ```tsx
116
+ const { valid, problems } = jsonSchema.validate(emailStep, settings);
117
+ // problems: [{ code: 'required', path: ['subject'], params: { name: 'subject' }, message: 'subject is required.' }]
118
+ ```
119
+
120
+ ## What is not read
121
+
122
+ A key the subset does not read is not left out silently. `jsonSchema.check` lists every such key and every key whose value is not what it should be, each where it is; in development, `schemaItems` tells them once, with the properties no editor can hold (a value of two types, a list of objects) and an `x-editor` that is not registered.
123
+
124
+ ```tsx
125
+ jsonSchema.check({ type: 'object', additionalProperties: false });
126
+ // [{ code: 'unsupportedKeyword', path: ['additionalProperties'],
127
+ // message: 'additionalProperties is not read; the value is not checked against it.' }]
128
+ ```
129
+
130
+ ## API reference
131
+
132
+ | Member | Returns | Description |
133
+ | --- | --- | --- |
134
+ | `schemaItems(schema, options?)` | `FormItem[]` | The items of a form from a schema. `options.editorProps` gives the editors props by their name: `{ template: { schema: names } }`. |
135
+ | `jsonSchema.validate(schema, value)` | `{ valid, problems }` | Every problem of a value, each with its `code`, its `path` down to the value, its `params` and its English `message`. |
136
+ | `jsonSchema.check(schema)` | `SchemaProblem[]` | The problems of a schema itself: a key that is not read (`unsupportedKeyword`) and a key whose value is not what it should be (`badKeyword`). |
137
+ | `jsonSchema.defaults(schema)` | `unknown` | The value a schema starts with: its `const` or `default`, and for an object the fields that have one. |
138
+ | `jsonSchema.matchesFormat(format, text)` | `boolean` | Whether a text is in one of the four formats. |
139
+ | `jsonSchema.SCHEMA_PROBLEM_TEXTS` | `Record<SchemaProblemCode, string>` | The English text of each problem; an interface gives its own by the code. |
140
+
141
+ ## Feedback
142
+
143
+ Loading issues…