@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.
- package/CHANGELOG.md +113 -0
- package/README.md +2 -2
- package/dist/components/diagram/Diagram.d.ts +607 -0
- package/dist/components/diagram/DiagramAutoPan.d.ts +17 -0
- package/dist/components/diagram/DiagramBends.d.ts +70 -0
- package/dist/components/diagram/DiagramDragging.d.ts +66 -0
- package/dist/components/diagram/DiagramEdgeView.d.ts +78 -0
- package/dist/components/diagram/DiagramGrid.d.ts +13 -0
- package/dist/components/diagram/DiagramHistory.d.ts +16 -0
- package/dist/components/diagram/DiagramLinks.d.ts +177 -0
- package/dist/components/diagram/DiagramMap.d.ts +62 -0
- package/dist/components/diagram/DiagramNodeView.d.ts +143 -0
- package/dist/components/diagram/DiagramOverview.d.ts +20 -0
- package/dist/components/diagram/DiagramPanning.d.ts +34 -0
- package/dist/components/diagram/diagram-alignment.d.ts +2 -0
- package/dist/components/diagram/diagram-auto-pan-host.d.ts +8 -0
- package/dist/components/diagram/diagram-background.d.ts +2 -0
- package/dist/components/diagram/diagram-bends-host.d.ts +17 -0
- package/dist/components/diagram/diagram-card-kind.d.ts +42 -0
- package/dist/components/diagram/diagram-card-node.d.ts +11 -0
- package/dist/components/diagram/diagram-center-options.d.ts +6 -0
- package/dist/components/diagram/diagram-change.d.ts +11 -0
- package/dist/components/diagram/diagram-class-member.d.ts +13 -0
- package/dist/components/diagram/diagram-class-node.d.ts +12 -0
- package/dist/components/diagram/diagram-column-checked-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-connected-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-connecting-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-connection.d.ts +7 -0
- package/dist/components/diagram/diagram-data.d.ts +12 -0
- package/dist/components/diagram/diagram-deleted-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-deleting-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-dragging-host.d.ts +47 -0
- package/dist/components/diagram/diagram-drawn-node.d.ts +10 -0
- package/dist/components/diagram/diagram-edge-end.d.ts +2 -0
- package/dist/components/diagram/diagram-edge-path.d.ts +5 -0
- package/dist/components/diagram/diagram-edge-reshaped-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-edge-reshaping-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-edge.d.ts +49 -0
- package/dist/components/diagram/diagram-edit.d.ts +10 -0
- package/dist/components/diagram/diagram-export-options.d.ts +14 -0
- package/dist/components/diagram/diagram-export.d.ts +28 -0
- package/dist/components/diagram/diagram-fit-options.d.ts +12 -0
- package/dist/components/diagram/diagram-history-changed-event-args.d.ts +14 -0
- package/dist/components/diagram/diagram-history-step.d.ts +9 -0
- package/dist/components/diagram/diagram-kinds.d.ts +9 -0
- package/dist/components/diagram/diagram-layered.d.ts +39 -0
- package/dist/components/diagram/diagram-layout-direction.d.ts +2 -0
- package/dist/components/diagram/diagram-layout-options.d.ts +24 -0
- package/dist/components/diagram/diagram-layout-type.d.ts +5 -0
- package/dist/components/diagram/diagram-layout.d.ts +33 -0
- package/dist/components/diagram/diagram-line-look.d.ts +6 -0
- package/dist/components/diagram/diagram-line.d.ts +11 -0
- package/dist/components/diagram/diagram-links-host.d.ts +45 -0
- package/dist/components/diagram/diagram-links-options.d.ts +7 -0
- package/dist/components/diagram/diagram-map-props.d.ts +10 -0
- package/dist/components/diagram/diagram-map-target.d.ts +27 -0
- package/dist/components/diagram/diagram-marker.d.ts +6 -0
- package/dist/components/diagram/diagram-mini-map-options.d.ts +13 -0
- package/dist/components/diagram/diagram-mini-map-position.d.ts +2 -0
- package/dist/components/diagram/diagram-node-context.d.ts +26 -0
- package/dist/components/diagram/diagram-node-host.d.ts +23 -0
- package/dist/components/diagram/diagram-node-kind.d.ts +43 -0
- package/dist/components/diagram/diagram-node-move.d.ts +11 -0
- package/dist/components/diagram/diagram-node-resized-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-node-resizing-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-node-size.d.ts +8 -0
- package/dist/components/diagram/diagram-node-status.d.ts +2 -0
- package/dist/components/diagram/diagram-node-toggled-event-args.d.ts +7 -0
- package/dist/components/diagram/diagram-node.d.ts +56 -0
- package/dist/components/diagram/diagram-nodes-moved-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-nodes-moving-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-panning-host.d.ts +19 -0
- package/dist/components/diagram/diagram-pasted-event-args.d.ts +7 -0
- package/dist/components/diagram/diagram-pasting-event-args.d.ts +11 -0
- package/dist/components/diagram/diagram-path-ends.d.ts +11 -0
- package/dist/components/diagram/diagram-path-result.d.ts +6 -0
- package/dist/components/diagram/diagram-paths.d.ts +35 -0
- package/dist/components/diagram/diagram-point.d.ts +5 -0
- package/dist/components/diagram/diagram-port-place.d.ts +9 -0
- package/dist/components/diagram/diagram-port.d.ts +27 -0
- package/dist/components/diagram/diagram-props.d.ts +159 -0
- package/dist/components/diagram/diagram-reconnected-event-args.d.ts +10 -0
- package/dist/components/diagram/diagram-reconnecting-event-args.d.ts +11 -0
- package/dist/components/diagram/diagram-rect.d.ts +7 -0
- package/dist/components/diagram/diagram-resize-side.d.ts +2 -0
- package/dist/components/diagram/diagram-route.d.ts +10 -0
- package/dist/components/diagram/diagram-selection-changed-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-selection.d.ts +5 -0
- package/dist/components/diagram/diagram-side.d.ts +2 -0
- package/dist/components/diagram/diagram-table-column.d.ts +13 -0
- package/dist/components/diagram/diagram-table-node.d.ts +12 -0
- package/dist/components/diagram/diagram-tree.d.ts +14 -0
- package/dist/components/diagram/diagram-viewport-changed-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-viewport-options.d.ts +5 -0
- package/dist/components/diagram/diagram-viewport.d.ts +6 -0
- package/dist/components/diagram/index.d.ts +65 -0
- package/dist/components/diagram/swallow-next-click.d.ts +5 -0
- package/dist/components/expressioneditor/ExpressionEditor.d.ts +111 -0
- package/dist/components/expressioneditor/expression-editor-props.d.ts +24 -0
- package/dist/components/expressioneditor/index.d.ts +2 -0
- package/dist/components/formlayout/FormLayout.d.ts +10 -3
- package/dist/components/formlayout/form-editor-type.d.ts +1 -1
- package/dist/components/formlayout/form-item.d.ts +4 -1
- package/dist/components/formlayout/form-layout-props.d.ts +1 -1
- package/dist/components/formlayout/index.d.ts +1 -0
- package/dist/components/formlayout/schema-items.d.ts +26 -0
- package/dist/components/pivotgrid/model/PivotAxisWindow.d.ts +53 -1
- package/dist/components/pivotgrid/model/PivotCellWindow.d.ts +2 -0
- package/dist/components/pivotgrid/model/PivotWindows.d.ts +3 -6
- package/dist/components/toolbar/Toolbar.d.ts +5 -3
- package/dist/core/control.d.ts +2 -0
- package/dist/core/keyboard.d.ts +5 -0
- package/dist/core/measure/index.d.ts +2 -0
- package/dist/core/measure/picture.d.ts +27 -0
- package/dist/core/shortcut-options.d.ts +5 -2
- package/dist/core/ui-strings.d.ts +191 -0
- package/dist/generated/tokens.d.ts +1615 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11501 -705
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +180 -1
- package/dist/locales/tr.json +180 -1
- package/dist/styles.css +2262 -3
- package/dist/tokens/index.d.ts +1615 -0
- package/dist/tokens/index.js +1615 -0
- package/dist/tokens/index.js.map +1 -1
- package/dist/{tr-BGbF9uCs.js → tr-4GNbFdQh.js} +361 -3
- package/dist/{tr-BGbF9uCs.js.map → tr-4GNbFdQh.js.map} +1 -1
- package/docs/accordion.md +1 -1
- package/docs/actionsheet.md +1 -1
- package/docs/appbar.md +1 -1
- package/docs/appmenu-api.md +1 -1
- package/docs/appmenu-programmatic.md +1 -1
- package/docs/appmenu-search.md +1 -1
- package/docs/appmenu.md +1 -1
- package/docs/avatar.md +1 -1
- package/docs/badge.md +1 -1
- package/docs/bar-gauge-angles.md +1 -1
- package/docs/bar-gauge-data.md +1 -1
- package/docs/bar-gauge-labels.md +1 -1
- package/docs/bar-gauge.md +1 -1
- package/docs/barcode.md +1 -1
- package/docs/bottomnavigation.md +1 -1
- package/docs/bottomsheet.md +1 -1
- package/docs/breadcrumb.md +1 -1
- package/docs/button.md +1 -1
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +1 -1
- package/docs/calendar.md +1 -1
- package/docs/card.md +1 -1
- package/docs/chart-bars.md +1 -1
- package/docs/chart-candles.md +1 -1
- package/docs/chart-funnel.md +1 -1
- package/docs/chart-heatmap.md +1 -1
- package/docs/chart-lines.md +1 -1
- package/docs/chart-live.md +1 -1
- package/docs/chart-pie.md +1 -1
- package/docs/chart-radar.md +1 -1
- package/docs/chart-ranges.md +1 -1
- package/docs/chart-references.md +1 -1
- package/docs/chart-scatter.md +1 -1
- package/docs/chart-waterfall.md +1 -1
- package/docs/chart-zoom.md +1 -1
- package/docs/chart.md +1 -1
- package/docs/chat.md +1 -1
- package/docs/checkbox.md +1 -1
- package/docs/chip.md +1 -1
- package/docs/choice.md +1 -1
- package/docs/colorbox.md +1 -1
- package/docs/combobox.md +1 -1
- package/docs/commands.md +1 -1
- package/docs/control.md +1 -1
- package/docs/data.md +2 -2
- package/docs/datagrid-api.md +1 -1
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +1 -1
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +1 -1
- package/docs/datagrid-filtering.md +1 -1
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +1 -1
- package/docs/datagrid-layout.md +1 -1
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +1 -1
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +1 -1
- package/docs/datagrid.md +1 -1
- package/docs/datalayer-api.md +491 -0
- package/docs/datalayer-changes.md +501 -0
- package/docs/datalayer-odata.md +998 -0
- package/docs/datalayer-pivot.md +850 -0
- package/docs/datalayer-queries.md +516 -0
- package/docs/datalayer-rest.md +529 -0
- package/docs/datalayer-soap.md +576 -0
- package/docs/datalayer-source.md +464 -0
- package/docs/datalayer.md +264 -0
- package/docs/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- package/docs/diagram-api.md +200 -0
- package/docs/diagram-commands.md +79 -0
- package/docs/diagram-connections.md +157 -0
- package/docs/diagram-custom-nodes.md +325 -0
- package/docs/diagram-designer.md +816 -0
- package/docs/diagram-editing.md +62 -0
- package/docs/diagram-flow.md +157 -0
- package/docs/diagram-keyboard.md +58 -0
- package/docs/diagram-layout.md +354 -0
- package/docs/diagram-nodes.md +206 -0
- package/docs/diagram-tables.md +212 -0
- package/docs/diagram.md +217 -0
- package/docs/display.md +1 -1
- package/docs/draggable.md +1 -1
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +1 -1
- package/docs/editors.md +1 -1
- package/docs/expressioneditor.md +469 -0
- package/docs/expressions.md +431 -0
- package/docs/feedback.md +1 -1
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout-schema.md +143 -0
- package/docs/formlayout.md +16 -4
- package/docs/foundations.md +1 -1
- package/docs/gallery.md +1 -1
- package/docs/gauge-base.md +1 -1
- package/docs/gauge-circular.md +1 -1
- package/docs/gauge-dashboards.md +1 -1
- package/docs/gauge-linear.md +1 -1
- package/docs/gauge-markers.md +1 -1
- package/docs/gauge-marks.md +1 -1
- package/docs/gauge-ranges.md +1 -1
- package/docs/gauge-scales.md +1 -1
- package/docs/gauge.md +1 -1
- package/docs/home.md +1 -1
- package/docs/keyboard.md +2 -2
- package/docs/language.md +1 -1
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +1 -1
- package/docs/lookup.md +1 -1
- package/docs/markdown.md +1 -1
- package/docs/menus-api.md +1 -1
- package/docs/menus-context.md +1 -1
- package/docs/menus-customization.md +1 -1
- package/docs/menus-merging.md +1 -1
- package/docs/menus-programmatic.md +1 -1
- package/docs/menus.md +1 -1
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +1 -1
- package/docs/numberbox.md +1 -1
- package/docs/otpinput.md +1 -1
- package/docs/pagination.md +1 -1
- package/docs/pivotgrid-api.md +1 -1
- package/docs/pivotgrid-chart.md +1 -1
- package/docs/pivotgrid-drilldown.md +1 -1
- package/docs/pivotgrid-export.md +1 -1
- package/docs/pivotgrid-fields.md +1 -1
- package/docs/pivotgrid-keyboard.md +1 -1
- package/docs/pivotgrid-layout.md +1 -1
- package/docs/pivotgrid-panel.md +1 -1
- package/docs/pivotgrid-remote.md +122 -44
- package/docs/pivotgrid-sorting.md +3 -3
- package/docs/pivotgrid-state.md +1 -1
- package/docs/pivotgrid-summaries.md +1 -1
- package/docs/pivotgrid.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +1 -1
- package/docs/qrcode.md +1 -1
- package/docs/radiogroup.md +1 -1
- package/docs/rating.md +1 -1
- package/docs/resizable.md +1 -1
- package/docs/ribbonmenu-api.md +1 -1
- package/docs/ribbonmenu-commands.md +1 -1
- package/docs/ribbonmenu-customization.md +1 -1
- package/docs/ribbonmenu-display.md +1 -1
- package/docs/ribbonmenu-layouts.md +1 -1
- package/docs/ribbonmenu-programmatic.md +1 -1
- package/docs/ribbonmenu.md +1 -1
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +1 -1
- package/docs/scheduler-form.md +1 -1
- package/docs/scheduler-icalendar.md +1 -1
- package/docs/scheduler-mobile.md +1 -1
- package/docs/scheduler-recurrence.md +1 -1
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +1 -1
- package/docs/scrollview.md +1 -1
- package/docs/shortcuteditor.md +1 -1
- package/docs/showcase-flowstudio.md +61 -0
- package/docs/showcase-home.md +1 -1
- package/docs/showcase-mail.md +1 -1
- package/docs/showcase.md +1 -1
- package/docs/signature.md +1 -1
- package/docs/skeleton.md +1 -1
- package/docs/slider.md +1 -1
- package/docs/sortable.md +1 -1
- package/docs/sparkline.md +1 -1
- package/docs/speeddial.md +1 -1
- package/docs/splitter.md +1 -1
- package/docs/stepper.md +1 -1
- package/docs/switch.md +1 -1
- package/docs/tabdocs-dock.md +1 -1
- package/docs/tabdocs-drag.md +1 -1
- package/docs/tabdocs-menus.md +1 -1
- package/docs/tabdocs-mobile.md +1 -1
- package/docs/tabdocs-tabs.md +1 -1
- package/docs/tabdocs-windows.md +1 -1
- package/docs/tabdocs-workspace.md +1 -1
- package/docs/tabdocs.md +1 -1
- package/docs/tabs.md +1 -1
- package/docs/tagbox.md +1 -1
- package/docs/textarea.md +1 -1
- package/docs/textbox.md +1 -1
- package/docs/tileview.md +1 -1
- package/docs/timeline.md +1 -1
- package/docs/toast.md +1 -1
- package/docs/tokens.md +324 -1
- package/docs/toolbar-api.md +1 -1
- package/docs/toolbar-customization.md +1 -1
- package/docs/toolbar.md +1 -1
- package/docs/tooltip.md +1 -1
- package/docs/treeview.md +1 -1
- package/docs/validationsummary.md +1 -1
- package/docs/window.md +1 -1
- package/docs/wizard.md +1 -1
- package/llms-full.txt +10142 -462
- package/llms.txt +32 -1
- package/package.json +2 -2
package/docs/dropdown.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DropDown
|
|
2
2
|
|
|
3
|
-
> Choice · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Choice · @motifx-community/ui 0.1.0-beta.16
|
|
4
4
|
|
|
5
5
|
Selects one item from a list. The field shows the selected item, and the list opens below it on click or from the keyboard. The list can be searched, grouped and customized, and it stays fast with thousands of items.
|
|
6
6
|
|
package/docs/editors.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Editors
|
|
2
2
|
|
|
3
|
-
> Editors · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Editors · @motifx-community/ui 0.1.0-beta.16
|
|
4
4
|
|
|
5
5
|
Editors take values: text, numbers, dates and times, ranges, colors, ratings, codes, files and signatures. They share one field model, so a label, help text, validation and binding work the same in all of them.
|
|
6
6
|
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
# ExpressionEditor
|
|
2
|
+
|
|
3
|
+
> Editors · @motifx-community/ui 0.1.0-beta.16
|
|
4
|
+
|
|
5
|
+
A field for an expression of the data layer, or for a template with expressions in it. The text is colored as it is typed, its problems are underlined where they are, the words that may be written at the caret come in a list, and the call the caret is in shows its parameters. It has the label, help text and validation common to all fields.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { ExpressionEditor, type ExpressionEditorProps } from '@motifx-community/ui';
|
|
11
|
+
import { expression } from '@motifx-community/data';
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The language itself, what it reads and how it works out a value, is the data layer's: see [Expression language](expressions.md). The editor reads and checks the text with it; the value is the text.
|
|
15
|
+
|
|
16
|
+
## Declarative and programmatic
|
|
17
|
+
|
|
18
|
+
Every prop accepts a value or a function, and `x-model` provides two-way binding for the text. When you create the component with `new`, set the same properties programmatically.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { reactive } from '@motifx/core';
|
|
22
|
+
import { Button, ExpressionEditor, Stack } from '@motifx-community/ui';
|
|
23
|
+
import { orderSchema } from './order';
|
|
24
|
+
|
|
25
|
+
/** A condition bound with x-model, and template fields created with `new` and added programmatically. */
|
|
26
|
+
export default function Programmatic() {
|
|
27
|
+
const s = reactive({ when: "item.status = 'late' and item.total > 1000", log: '' });
|
|
28
|
+
let added = 0;
|
|
29
|
+
let host: Stack | null = null;
|
|
30
|
+
|
|
31
|
+
const addProgrammatic = () => {
|
|
32
|
+
const subject = new ExpressionEditor({ label: `Subject ${++added}`, template: true, schema: orderSchema, stretch: true });
|
|
33
|
+
subject.value = 'Order {{ item.id }} is late';
|
|
34
|
+
subject.onValueChanged((e) => (s.log = `${subject.label}: ${e.value}`));
|
|
35
|
+
host?.controls.add(subject);
|
|
36
|
+
subject.focus();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<ExpressionEditor label="&When" schema={orderSchema} expect="boolean" x-model={() => s.when} helpText={() => `${s.when.length} characters`} stretch />
|
|
42
|
+
<Stack orientation="horizontal" wrap align="center">
|
|
43
|
+
<Button text="Add a template field programmatically" variant="outline" onclick={addProgrammatic} />
|
|
44
|
+
<output class="ee-log">{() => s.log}</output>
|
|
45
|
+
</Stack>
|
|
46
|
+
<Stack ref={(c: Stack) => (host = c)} />
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Schema and problems
|
|
53
|
+
|
|
54
|
+
`schema` gives the names an expression may use and their types. The editor checks the text against it as it is typed: an unknown name or field, a function given the wrong arguments, and a value of the wrong type are underlined. A field that may be `null` and is read without `?.` is a warning. `expect` asks for the type of the whole value, as a condition asks for `boolean`.
|
|
55
|
+
|
|
56
|
+
`problems`, `tree` and `resultType` follow the text. An error fails validation with its text in the kit's language; a warning does not. Here `validateOn` is `input`, so the message shows at once.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import type { expression } from '@motifx-community/data';
|
|
60
|
+
|
|
61
|
+
/** The names the examples' expressions are given, and their types. */
|
|
62
|
+
export const orderSchema: expression.Schema = {
|
|
63
|
+
item: '{ id: number, customer: text, email: text?, total: number, status: text, dueOn: date, lines: list<{ product: text, quantity: number, price: number }> }',
|
|
64
|
+
rows: 'list<{ id: number, customer: text, total: number, status: text }>',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** Their values. */
|
|
68
|
+
export const orderNames = {
|
|
69
|
+
item: {
|
|
70
|
+
id: 1042,
|
|
71
|
+
customer: 'Ada Yılmaz',
|
|
72
|
+
email: null,
|
|
73
|
+
total: 1250,
|
|
74
|
+
status: 'late',
|
|
75
|
+
dueOn: '2026-03-01',
|
|
76
|
+
lines: [
|
|
77
|
+
{ product: 'Lamp', quantity: 2, price: 400 },
|
|
78
|
+
{ product: 'Shade', quantity: 3, price: 150 },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
rows: [
|
|
82
|
+
{ id: 1041, customer: 'Can Demir', total: 380, status: 'open' },
|
|
83
|
+
{ id: 1042, customer: 'Ada Yılmaz', total: 1250, status: 'late' },
|
|
84
|
+
{ id: 1043, customer: 'Ece Kaya', total: 2100, status: 'late' },
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Words for the caret
|
|
90
|
+
|
|
91
|
+
Typing a name, or a dot after a value, opens a list of what may be written there: after a dot the fields of the value, elsewhere the names of the schema, the parameters of the short functions the caret is in, the functions and the words of the language. After a value, the words that join it to the next come. Ctrl+Space opens the list at any place, and `suggest={false}` keeps it closed while typing.
|
|
92
|
+
|
|
93
|
+
Inside a call, a box above the caret shows the function's parameters, the one being written in bold, and what the function does; when the caret is on a problem, it says the problem.
|
|
94
|
+
|
|
95
|
+
## Templates
|
|
96
|
+
|
|
97
|
+
With `template`, the text is plain text with expressions in `{{ … }}`: a mail's subject or body, a message of a step. Only the expressions are checked and completed. `multiline` lets the text run over several lines.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import type { expression } from '@motifx-community/data';
|
|
101
|
+
|
|
102
|
+
/** The names the examples' expressions are given, and their types. */
|
|
103
|
+
export const orderSchema: expression.Schema = {
|
|
104
|
+
item: '{ id: number, customer: text, email: text?, total: number, status: text, dueOn: date, lines: list<{ product: text, quantity: number, price: number }> }',
|
|
105
|
+
rows: 'list<{ id: number, customer: text, total: number, status: text }>',
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** Their values. */
|
|
109
|
+
export const orderNames = {
|
|
110
|
+
item: {
|
|
111
|
+
id: 1042,
|
|
112
|
+
customer: 'Ada Yılmaz',
|
|
113
|
+
email: null,
|
|
114
|
+
total: 1250,
|
|
115
|
+
status: 'late',
|
|
116
|
+
dueOn: '2026-03-01',
|
|
117
|
+
lines: [
|
|
118
|
+
{ product: 'Lamp', quantity: 2, price: 400 },
|
|
119
|
+
{ product: 'Shade', quantity: 3, price: 150 },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
rows: [
|
|
123
|
+
{ id: 1041, customer: 'Can Demir', total: 380, status: 'open' },
|
|
124
|
+
{ id: 1042, customer: 'Ada Yılmaz', total: 1250, status: 'late' },
|
|
125
|
+
{ id: 1043, customer: 'Ece Kaya', total: 2100, status: 'late' },
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Functions of the application
|
|
131
|
+
|
|
132
|
+
`functions` adds the application's own functions to those of the library. They are offered, checked and described as the library's are; give the same list to `expression.run` to work them out. `insertText` writes a text at the caret, for a list of fields beside the editor.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import type { expression } from '@motifx-community/data';
|
|
136
|
+
|
|
137
|
+
/** The names the examples' expressions are given, and their types. */
|
|
138
|
+
export const orderSchema: expression.Schema = {
|
|
139
|
+
item: '{ id: number, customer: text, email: text?, total: number, status: text, dueOn: date, lines: list<{ product: text, quantity: number, price: number }> }',
|
|
140
|
+
rows: 'list<{ id: number, customer: text, total: number, status: text }>',
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** Their values. */
|
|
144
|
+
export const orderNames = {
|
|
145
|
+
item: {
|
|
146
|
+
id: 1042,
|
|
147
|
+
customer: 'Ada Yılmaz',
|
|
148
|
+
email: null,
|
|
149
|
+
total: 1250,
|
|
150
|
+
status: 'late',
|
|
151
|
+
dueOn: '2026-03-01',
|
|
152
|
+
lines: [
|
|
153
|
+
{ product: 'Lamp', quantity: 2, price: 400 },
|
|
154
|
+
{ product: 'Shade', quantity: 3, price: 150 },
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
rows: [
|
|
158
|
+
{ id: 1041, customer: 'Can Demir', total: 380, status: 'open' },
|
|
159
|
+
{ id: 1042, customer: 'Ada Yılmaz', total: 1250, status: 'late' },
|
|
160
|
+
{ id: 1043, customer: 'Ece Kaya', total: 2100, status: 'late' },
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Read-only, disabled and required
|
|
166
|
+
|
|
167
|
+
Read-only and disabled keep the colors and offer no words.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import type { expression } from '@motifx-community/data';
|
|
171
|
+
|
|
172
|
+
/** The names the examples' expressions are given, and their types. */
|
|
173
|
+
export const orderSchema: expression.Schema = {
|
|
174
|
+
item: '{ id: number, customer: text, email: text?, total: number, status: text, dueOn: date, lines: list<{ product: text, quantity: number, price: number }> }',
|
|
175
|
+
rows: 'list<{ id: number, customer: text, total: number, status: text }>',
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** Their values. */
|
|
179
|
+
export const orderNames = {
|
|
180
|
+
item: {
|
|
181
|
+
id: 1042,
|
|
182
|
+
customer: 'Ada Yılmaz',
|
|
183
|
+
email: null,
|
|
184
|
+
total: 1250,
|
|
185
|
+
status: 'late',
|
|
186
|
+
dueOn: '2026-03-01',
|
|
187
|
+
lines: [
|
|
188
|
+
{ product: 'Lamp', quantity: 2, price: 400 },
|
|
189
|
+
{ product: 'Shade', quantity: 3, price: 150 },
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
rows: [
|
|
193
|
+
{ id: 1041, customer: 'Can Demir', total: 380, status: 'open' },
|
|
194
|
+
{ id: 1042, customer: 'Ada Yılmaz', total: 1250, status: 'late' },
|
|
195
|
+
{ id: 1043, customer: 'Ece Kaya', total: 2100, status: 'late' },
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Keyboard
|
|
201
|
+
|
|
202
|
+
| Key | Description |
|
|
203
|
+
| --- | --- |
|
|
204
|
+
| `Ctrl + Space` | Shows the words that may be written at the caret. |
|
|
205
|
+
| `Arrow Down, Arrow Up, Page Down, Page Up` | While the list is open, move the highlight in it. |
|
|
206
|
+
| `Enter, Tab` | While the list is open, write the highlighted word. With no list, Enter starts a new line with `multiline` and does nothing on one line. |
|
|
207
|
+
| `Escape` | Closes the list, then the box above the caret. The key goes no further while either is open. |
|
|
208
|
+
| `Alt + key (`&Name`)` | Moves focus to the field (Control + Option + key on Apple platforms). |
|
|
209
|
+
|
|
210
|
+
## Accessibility
|
|
211
|
+
|
|
212
|
+
| Topic | Details |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `Element` | A native `<textarea>` associated with its `<label>` through `for`; `aria-multiline` says whether it takes several lines. The colored copy under it is hidden from screen readers. |
|
|
215
|
+
| `List of words` | `aria-autocomplete="list"`. While the list is open, `aria-controls` names it and `aria-activedescendant` the highlighted word, so the focus stays in the text. The list is named "Suggestions". |
|
|
216
|
+
| `Box above the caret` | A status region: the call the caret is in and the problem there are read when they change. |
|
|
217
|
+
| `Errors` | Color alone does not tell a problem: each has a line under it, and the first error is the field's message after validation (`aria-invalid="true"`, a polite live region). |
|
|
218
|
+
|
|
219
|
+
## Localization
|
|
220
|
+
|
|
221
|
+
The problems' texts, what each function of the library does and the name of the list come from `uiLocale.strings` (`expressionProblem…`, `expressionFunction…`, `expressionEditorSuggestions`). The language's own words, its types and function names, stay as they are written.
|
|
222
|
+
|
|
223
|
+
Outside the editor, `expressionProblemText(problem)` gives the text of a problem in the kit's language, for a list of problems an app shows itself, such as the problems of the expressions of a whole flow.
|
|
224
|
+
|
|
225
|
+
## Styling
|
|
226
|
+
|
|
227
|
+
The colors of the pieces, the problems' lines and the parts of the list and of the box above the caret are units of the editor's tokens (`expression-editor.*`); the font of the text is `expression-editor.font-family`. The copy lies under the text typed, so a design gives its pieces colors and lines only, never a weight or a size that would move the text.
|
|
228
|
+
|
|
229
|
+
| Hook | Description |
|
|
230
|
+
| --- | --- |
|
|
231
|
+
| `.mx-field.mx-expression-editor` | The field. `data-multiline`, `data-problems` while the text has an error, and the field attributes (`data-size`, `data-variant`, `data-invalid`, `data-readonly`, `data-disabled`, `data-filled`). |
|
|
232
|
+
| `.mx-expression-editor__input` | The textarea. Its own glyphs are not painted: the copy under it shows the text. |
|
|
233
|
+
| `.mx-expression-editor__layer` | The colored copy of the text, under it. |
|
|
234
|
+
| `.mx-expression-editor__piece[data-kind]` | A piece of the text: `number`, `text`, `date`, `name`, `function`, `field`, `keyword`, `constant`, `operator`, `punct`, `template`, `mark` or `error`. `data-problem="error"` or `"warning"` draws the line under it. |
|
|
235
|
+
| `.mx-expression-editor__popup` | The list of words: `.mx-list`, then `.mx-expression-editor__detail` for the highlighted function. |
|
|
236
|
+
| `.mx-expression-editor__help` | The box above the caret: `.mx-expression-editor__signature`, `.mx-expression-editor__param[data-current]`, `.mx-expression-editor__description` and `.mx-expression-editor__help-problem`. |
|
|
237
|
+
|
|
238
|
+
## API reference
|
|
239
|
+
|
|
240
|
+
### Props
|
|
241
|
+
|
|
242
|
+
| Prop | Type | Default | Description |
|
|
243
|
+
| --- | --- | --- | --- |
|
|
244
|
+
| `value` | `Bind<string>` | `''` | The text of the expression or the template. `x-model` provides two-way binding. |
|
|
245
|
+
| `label` | `Bind<string>` | `''` | The field label. Writing `&Name` assigns Alt+N as the access key. |
|
|
246
|
+
| `schema` | `Bind<expression.Schema>` | — | The names the expression is given and their types, such as `{ item: '{ total: number }' }`. The list of words offers them, and the text is checked against them. Without a schema only the writing is checked. |
|
|
247
|
+
| `template` | `Bind<boolean>` | `false` | The text is a template: plain text with `{{ … }}` expressions in it. |
|
|
248
|
+
| `multiline` | `Bind<boolean>` | `false` | The text may run over several lines, and Enter starts a new one. On one line, Enter breaks nothing and a pasted line break becomes a space. |
|
|
249
|
+
| `rows` | `Bind<number>` | `3` | The number of lines shown with `multiline`. |
|
|
250
|
+
| `expect` | `Bind<expression.Type \| string>` | — | The type the value is wanted as, such as `boolean` for a condition. A text that gives another type is a problem. |
|
|
251
|
+
| `functions` | `Bind<readonly expression.Function[]>` | `[]` | Functions of the application, besides those of the library. They are offered, checked and described as the library's are. |
|
|
252
|
+
| `placeholder` | `Bind<string>` | `''` | Displayed when the field is empty. |
|
|
253
|
+
| `suggest` | `Bind<boolean>` | `true` | Offers the words for the caret while typing. Ctrl+Space offers them either way. |
|
|
254
|
+
| `helpText, hint, prefix, suffix, icon, buttons` | see TextBox | | Parts common to all fields. |
|
|
255
|
+
| `readOnly, required, size, variant, stretch` | see TextBox | | States and appearance common to all fields. |
|
|
256
|
+
| `rules, error, validateOn, validationGroup` | see TextBox | | Validation works the same way as for all fields. An error of the text fails it, with its message; a warning does not. |
|
|
257
|
+
| `enabled / disabled, visible, tabStop, tabIndex` | see Control | | Properties shared by all controls. |
|
|
258
|
+
|
|
259
|
+
### Properties
|
|
260
|
+
|
|
261
|
+
| Property | Access | Description |
|
|
262
|
+
| --- | --- | --- |
|
|
263
|
+
| `every prop above` | read/write, reactive | Accepts a value or a function, the same as the prop. |
|
|
264
|
+
| `tree` | read-only, reactive | What the text reads as, a plain JSON tree; `null` while it does not read, or is empty. |
|
|
265
|
+
| `problems` | read-only, reactive | The problems of the text, errors and warnings, with where they are (`at`), their `code` and `params`. |
|
|
266
|
+
| `resultType` | read-only, reactive | The type of the value the expression gives, with a `schema`. |
|
|
267
|
+
| `isValid, validationMessage, validating` | read-only, reactive | The validation result. |
|
|
268
|
+
| `textAreaPart` | read-only | The native `<textarea>`. |
|
|
269
|
+
| `selectionStart, selectionEnd` | read-only | Where the selection starts and ends in the text; the caret when nothing is selected. |
|
|
270
|
+
|
|
271
|
+
### Methods
|
|
272
|
+
|
|
273
|
+
| Method | Returns | Description |
|
|
274
|
+
| --- | --- | --- |
|
|
275
|
+
| `insertText(text)` | `void` | Writes a text over the selection, or at the caret, as typing it would; the browser's undo takes it back. |
|
|
276
|
+
| `showSuggestions()` | `void` | Shows the words for the caret, as Ctrl+Space does. |
|
|
277
|
+
| `closeSuggestions()` | `void` | Closes the list of words. |
|
|
278
|
+
| `problemText(problem)` | `string` | The text of a problem in the kit's language, with what it names. |
|
|
279
|
+
| `functionText(fn)` | `string` | What a function does: in the kit's language for those of the library, its own `description` for the application's. |
|
|
280
|
+
| `validate()` | `Promise<boolean>` | Validates the value and displays the result. |
|
|
281
|
+
| `resetValidation()` | `void` | Clears the results of previous validation. |
|
|
282
|
+
| `focus()` | `boolean` | Sets focus on the text. |
|
|
283
|
+
| `select()` | `void` | Selects all text. |
|
|
284
|
+
| `setSelectionRange(start, end?)` | `void` | Selects from `start` to `end`, or puts the caret at `start` alone. |
|
|
285
|
+
|
|
286
|
+
### Events
|
|
287
|
+
|
|
288
|
+
| Event | When |
|
|
289
|
+
| --- | --- |
|
|
290
|
+
| `onValueChanged(e)` | Occurs when the value changes. `e`: `{ value, previousValue, byUser, source, event? }`. |
|
|
291
|
+
| `onValidated(e)` | Occurs when validation finishes. `e`: `{ valid, message, source }`. |
|
|
292
|
+
| `oninput, onkeydown, onfocusin, onfocusout` | DOM events from the textarea bubble up to the field. |
|
|
293
|
+
|
|
294
|
+
## Feedback
|
|
295
|
+
|
|
296
|
+
Loading issues…
|
|
297
|
+
|
|
298
|
+
## Example files
|
|
299
|
+
|
|
300
|
+
`Checking.tsx`
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
import { reactive } from '@motifx/core';
|
|
304
|
+
import { expression } from '@motifx-community/data';
|
|
305
|
+
import { ExpressionEditor } from '@motifx-community/ui';
|
|
306
|
+
import { orderNames, orderSchema } from './order';
|
|
307
|
+
|
|
308
|
+
/** Checked against the schema as it is typed: the problems where they are, the type it gives, and its value. */
|
|
309
|
+
export default function Checking() {
|
|
310
|
+
const s = reactive({ text: "count(filter(rows, r => r.status = 'late')) > 0 and item.emial = null" });
|
|
311
|
+
let editor: ExpressionEditor | null = null;
|
|
312
|
+
|
|
313
|
+
// Read with the text, so they follow it from the first value on.
|
|
314
|
+
const problems = () => (void s.text, (editor?.problems ?? []).map((p) => `${p.severity} at ${p.at[0]}–${p.at[1]}: ${editor!.problemText(p)}`).join('\n'));
|
|
315
|
+
const type = () => (void s.text, editor?.resultType ? expression.typeText(editor.resultType) : '—');
|
|
316
|
+
|
|
317
|
+
const value = () => {
|
|
318
|
+
try {
|
|
319
|
+
return JSON.stringify(expression.run(s.text, orderNames));
|
|
320
|
+
} catch (e) {
|
|
321
|
+
return e instanceof expression.ExpressionError ? `${e.code}: ${e.message}` : String(e);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
return (
|
|
326
|
+
<>
|
|
327
|
+
<ExpressionEditor ref={(c: ExpressionEditor) => (editor = c)} label="Condition" schema={orderSchema} expect="boolean" validateOn="input" x-model={() => s.text} stretch />
|
|
328
|
+
<pre class="ee-problems" tabindex="0" aria-label="The problems">
|
|
329
|
+
{() => problems() || 'No problems'}
|
|
330
|
+
</pre>
|
|
331
|
+
<output class="ee-type">{() => `Type: ${type()}`}</output>
|
|
332
|
+
<output class="ee-value">{() => `Value: ${value()}`}</output>
|
|
333
|
+
</>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
`order.ts`
|
|
339
|
+
|
|
340
|
+
```tsx
|
|
341
|
+
import type { expression } from '@motifx-community/data';
|
|
342
|
+
|
|
343
|
+
/** The names the examples' expressions are given, and their types. */
|
|
344
|
+
export const orderSchema: expression.Schema = {
|
|
345
|
+
item: '{ id: number, customer: text, email: text?, total: number, status: text, dueOn: date, lines: list<{ product: text, quantity: number, price: number }> }',
|
|
346
|
+
rows: 'list<{ id: number, customer: text, total: number, status: text }>',
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/** Their values. */
|
|
350
|
+
export const orderNames = {
|
|
351
|
+
item: {
|
|
352
|
+
id: 1042,
|
|
353
|
+
customer: 'Ada Yılmaz',
|
|
354
|
+
email: null,
|
|
355
|
+
total: 1250,
|
|
356
|
+
status: 'late',
|
|
357
|
+
dueOn: '2026-03-01',
|
|
358
|
+
lines: [
|
|
359
|
+
{ product: 'Lamp', quantity: 2, price: 400 },
|
|
360
|
+
{ product: 'Shade', quantity: 3, price: 150 },
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
rows: [
|
|
364
|
+
{ id: 1041, customer: 'Can Demir', total: 380, status: 'open' },
|
|
365
|
+
{ id: 1042, customer: 'Ada Yılmaz', total: 1250, status: 'late' },
|
|
366
|
+
{ id: 1043, customer: 'Ece Kaya', total: 2100, status: 'late' },
|
|
367
|
+
],
|
|
368
|
+
};
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
`Template.tsx`
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
import { reactive } from '@motifx/core';
|
|
375
|
+
import { expression } from '@motifx-community/data';
|
|
376
|
+
import { ExpressionEditor } from '@motifx-community/ui';
|
|
377
|
+
import { orderNames, orderSchema } from './order';
|
|
378
|
+
|
|
379
|
+
/** A template over several lines: plain text with expressions in {{ }}, and the text it writes. */
|
|
380
|
+
export default function Template() {
|
|
381
|
+
const s = reactive({
|
|
382
|
+
text: "Dear {{ item.customer }},\nyour order {{ item.id }} of {{ format(item.total, '#,##0.00', 'en-US') }} is {{ diffDays(item.dueOn, today()) }} days late.\nIt has {{ count(item.lines) }} lines: {{ join(map(item.lines, l => l.product), ', ') }}.",
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
const written = () => {
|
|
386
|
+
try {
|
|
387
|
+
return expression.render(s.text, orderNames, { now: new Date('2026-03-10T09:00:00Z'), timeZone: 'UTC' });
|
|
388
|
+
} catch (e) {
|
|
389
|
+
return e instanceof expression.ExpressionError ? e.message : String(e);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
return (
|
|
394
|
+
<>
|
|
395
|
+
<ExpressionEditor label="Message" template multiline rows={4} schema={orderSchema} x-model={() => s.text} stretch />
|
|
396
|
+
<pre class="ee-written">{() => written()}</pre>
|
|
397
|
+
</>
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
`OwnFunctions.tsx`
|
|
403
|
+
|
|
404
|
+
```tsx
|
|
405
|
+
import { reactive } from '@motifx/core';
|
|
406
|
+
import { expression } from '@motifx-community/data';
|
|
407
|
+
import { Button, ExpressionEditor, Stack } from '@motifx-community/ui';
|
|
408
|
+
import { orderNames, orderSchema } from './order';
|
|
409
|
+
|
|
410
|
+
/** A function of the application: offered, checked and described as the library's are. */
|
|
411
|
+
const vat: expression.Function = {
|
|
412
|
+
name: 'vat',
|
|
413
|
+
category: 'number',
|
|
414
|
+
params: [
|
|
415
|
+
{ name: 'amount', kinds: ['number'] },
|
|
416
|
+
{ name: 'rate', kinds: ['number'], optional: true },
|
|
417
|
+
],
|
|
418
|
+
returns: () => ({ name: 'number' }),
|
|
419
|
+
run: ([amount, rate]) => Math.round((amount as number) * ((rate as number | undefined) ?? 0.2) * 100) / 100,
|
|
420
|
+
description: 'The value added tax of an amount, at a rate (0.2 when none is given).',
|
|
421
|
+
example: 'vat(item.total)',
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const FIELDS = ['item.total', 'item.customer', 'item.dueOn', 'count(item.lines)'];
|
|
425
|
+
|
|
426
|
+
/** The application's function, and buttons that write a field at the caret. */
|
|
427
|
+
export default function OwnFunctions() {
|
|
428
|
+
const s = reactive({ text: 'item.total + vat(item.total)' });
|
|
429
|
+
let editor: ExpressionEditor | null = null;
|
|
430
|
+
|
|
431
|
+
const value = () => {
|
|
432
|
+
try {
|
|
433
|
+
return JSON.stringify(expression.run(s.text, orderNames, { functions: [vat] }));
|
|
434
|
+
} catch (e) {
|
|
435
|
+
return e instanceof expression.ExpressionError ? e.message : String(e);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
return (
|
|
440
|
+
<>
|
|
441
|
+
<ExpressionEditor ref={(c: ExpressionEditor) => (editor = c)} label="Total with tax" schema={orderSchema} functions={[vat]} expect="number" x-model={() => s.text} stretch />
|
|
442
|
+
<Stack orientation="horizontal" wrap>
|
|
443
|
+
{FIELDS.map((field) => (
|
|
444
|
+
<Button key={field} text={field} variant="outline" size="sm" onclick={() => editor?.insertText(field)} />
|
|
445
|
+
))}
|
|
446
|
+
</Stack>
|
|
447
|
+
<output class="ee-value">{() => `Value: ${value()}`}</output>
|
|
448
|
+
</>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
`States.tsx`
|
|
454
|
+
|
|
455
|
+
```tsx
|
|
456
|
+
import { ExpressionEditor } from '@motifx-community/ui';
|
|
457
|
+
import { orderSchema } from './order';
|
|
458
|
+
|
|
459
|
+
/** Read-only and disabled keep the colors; required fails while it is empty. */
|
|
460
|
+
export default function States() {
|
|
461
|
+
return (
|
|
462
|
+
<>
|
|
463
|
+
<ExpressionEditor label="Read-only" schema={orderSchema} value="sum(rows, r => r.total)" readOnly />
|
|
464
|
+
<ExpressionEditor label="Disabled" schema={orderSchema} value="item.total * 1.2" disabled />
|
|
465
|
+
<ExpressionEditor label="Required" schema={orderSchema} required placeholder="item.total > 0" />
|
|
466
|
+
</>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
```
|