@motifx-community/ui 0.1.0-beta.1 → 0.1.0-beta.3
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.
Potentially problematic release.
This version of @motifx-community/ui might be problematic. Click here for more details.
- package/CHANGELOG.md +147 -8
- package/README.md +19 -13
- package/dist/components/accordion/Accordion.d.ts +3 -3
- package/dist/components/accordion/AccordionItem.d.ts +1 -1
- package/dist/components/calendar/Calendar.d.ts +12 -0
- package/dist/components/calendar/calendar-props.d.ts +5 -0
- package/dist/components/card/Card.d.ts +1 -1
- package/dist/components/contextmenu/ContextMenu.d.ts +1 -1
- package/dist/components/datagrid/DataGrid.d.ts +5 -5
- package/dist/components/datagrid/data-grid-props.d.ts +2 -2
- package/dist/components/datagrid/grid-adaptive-row-expanded-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-adaptive-row-expanding-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-grouping-changed-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-grouping-changing-event-args.d.ts +2 -2
- package/dist/components/datagrid/grid-master-detail.d.ts +1 -1
- package/dist/components/datagrid/grid-row-expanded-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-row-expanding-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-search-text-changed-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-search-text-changing-event-args.d.ts +1 -1
- package/dist/components/datagrid/grid-sort-changing-event-args.d.ts +1 -1
- package/dist/components/datagrid/model/GridSearch.d.ts +1 -1
- package/dist/components/daterangebox/DateRangeBox.d.ts +121 -0
- package/dist/components/daterangebox/date-range-box-props.d.ts +35 -0
- package/dist/components/daterangebox/date-range-preset.d.ts +6 -0
- package/dist/components/daterangebox/date-range.d.ts +2 -0
- package/dist/components/daterangebox/index.d.ts +4 -0
- package/dist/components/draggable/Draggable.d.ts +99 -0
- package/dist/components/draggable/DropTarget.d.ts +38 -0
- package/dist/components/draggable/draggable-event-args.d.ts +17 -0
- package/dist/components/draggable/draggable-props.d.ts +37 -0
- package/dist/components/draggable/drop-event-args.d.ts +11 -0
- package/dist/components/draggable/drop-target-props.d.ts +13 -0
- package/dist/components/draggable/index.d.ts +6 -0
- package/dist/components/fileuploader/FileUploader.d.ts +133 -0
- package/dist/components/fileuploader/file-uploader-props.d.ts +46 -0
- package/dist/components/fileuploader/files-added-event-args.d.ts +9 -0
- package/dist/components/fileuploader/index.d.ts +7 -0
- package/dist/components/fileuploader/upload-event-args.d.ts +10 -0
- package/dist/components/fileuploader/upload-item.d.ts +12 -0
- package/dist/components/fileuploader/upload-mode.d.ts +2 -0
- package/dist/components/fileuploader/upload-status.d.ts +2 -0
- package/dist/components/filterbuilder/FilterBuilder.d.ts +1 -1
- package/dist/components/gallery/Gallery.d.ts +132 -0
- package/dist/components/gallery/gallery-item-click-event-args.d.ts +9 -0
- package/dist/components/gallery/gallery-item.d.ts +18 -0
- package/dist/components/gallery/gallery-props.d.ts +38 -0
- package/dist/components/gallery/index.d.ts +6 -0
- package/dist/components/gallery/slide-changed-event-args.d.ts +11 -0
- package/dist/components/gallery/slide-changing-event-args.d.ts +14 -0
- package/dist/components/layout/ChildSettings.d.ts +1 -1
- package/dist/components/layout/DockPanel.d.ts +2 -2
- package/dist/components/layout/Grid.d.ts +1 -1
- package/dist/components/layout/SplitContainer.d.ts +1 -1
- package/dist/components/layout/Stack.d.ts +1 -1
- package/dist/components/loadpanel/LoadPanel.d.ts +70 -0
- package/dist/components/loadpanel/index.d.ts +3 -0
- package/dist/components/loadpanel/load-panel-props.d.ts +29 -0
- package/dist/components/loadpanel/load-panel-target.d.ts +3 -0
- package/dist/components/multiview/MultiView.d.ts +87 -0
- package/dist/components/multiview/View.d.ts +41 -0
- package/dist/components/multiview/index.d.ts +6 -0
- package/dist/components/multiview/multi-view-props.d.ts +24 -0
- package/dist/components/multiview/view-props.d.ts +15 -0
- package/dist/components/multiview/view-selecting-event-args.d.ts +15 -0
- package/dist/components/multiview/view-selection-changed-event-args.d.ts +12 -0
- package/dist/components/numberbox/number-box-props.d.ts +1 -1
- package/dist/components/popover/Popover.d.ts +98 -0
- package/dist/components/popover/index.d.ts +5 -0
- package/dist/components/popover/popover-close-reason.d.ts +2 -0
- package/dist/components/popover/popover-closing-event-args.d.ts +8 -0
- package/dist/components/popover/popover-props.d.ts +39 -0
- package/dist/components/popover/popover-show-on.d.ts +2 -0
- package/dist/components/resizable/Resizable.d.ts +84 -0
- package/dist/components/resizable/index.d.ts +3 -0
- package/dist/components/resizable/resizable-props.d.ts +41 -0
- package/dist/components/resizable/resize-event-args.d.ts +13 -0
- package/dist/components/scheduler/AppointmentEditor.d.ts +1 -1
- package/dist/components/scheduler/scheduler-props.d.ts +1 -1
- package/dist/components/scrollview/ScrollView.d.ts +109 -0
- package/dist/components/scrollview/index.d.ts +7 -0
- package/dist/components/scrollview/pull-down-event-args.d.ts +9 -0
- package/dist/components/scrollview/reach-bottom-event-args.d.ts +9 -0
- package/dist/components/scrollview/scroll-event-args.d.ts +7 -0
- package/dist/components/scrollview/scroll-view-bars.d.ts +2 -0
- package/dist/components/scrollview/scroll-view-direction.d.ts +2 -0
- package/dist/components/scrollview/scroll-view-props.d.ts +31 -0
- package/dist/components/skeleton/Skeleton.d.ts +1 -1
- package/dist/components/sortable/Sortable.d.ts +106 -0
- package/dist/components/sortable/index.d.ts +5 -0
- package/dist/components/sortable/sortable-drag-event-args.d.ts +15 -0
- package/dist/components/sortable/sortable-drop-event-args.d.ts +11 -0
- package/dist/components/sortable/sortable-orientation.d.ts +2 -0
- package/dist/components/sortable/sortable-props.d.ts +34 -0
- package/dist/components/speeddial/SpeedDial.d.ts +129 -0
- package/dist/components/speeddial/index.d.ts +6 -0
- package/dist/components/speeddial/speed-dial-action-click-event-args.d.ts +9 -0
- package/dist/components/speeddial/speed-dial-action.d.ts +25 -0
- package/dist/components/speeddial/speed-dial-event-args.d.ts +8 -0
- package/dist/components/speeddial/speed-dial-props.d.ts +49 -0
- package/dist/components/speeddial/speed-dial-tooltip.d.ts +3 -0
- package/dist/components/splitter/SplitPane.d.ts +45 -0
- package/dist/components/splitter/Splitter.d.ts +116 -0
- package/dist/components/splitter/index.d.ts +6 -0
- package/dist/components/splitter/split-pane-props.d.ts +21 -0
- package/dist/components/splitter/splitter-collapse-event-args.d.ts +13 -0
- package/dist/components/splitter/splitter-props.d.ts +25 -0
- package/dist/components/splitter/splitter-resize-event-args.d.ts +10 -0
- package/dist/components/stepper/Stepper.d.ts +121 -0
- package/dist/components/stepper/Wizard.d.ts +112 -0
- package/dist/components/stepper/WizardStep.d.ts +44 -0
- package/dist/components/stepper/index.d.ts +13 -0
- package/dist/components/stepper/step-changed-event-args.d.ts +11 -0
- package/dist/components/stepper/step-changing-event-args.d.ts +18 -0
- package/dist/components/stepper/stepper-item.d.ts +20 -0
- package/dist/components/stepper/stepper-label-position.d.ts +2 -0
- package/dist/components/stepper/stepper-orientation.d.ts +1 -0
- package/dist/components/stepper/stepper-props.d.ts +32 -0
- package/dist/components/stepper/stepper-status.d.ts +2 -0
- package/dist/components/stepper/wizard-finishing-event-args.d.ts +7 -0
- package/dist/components/stepper/wizard-props.d.ts +48 -0
- package/dist/components/stepper/wizard-step-props.d.ts +32 -0
- package/dist/components/tabdocs/TabDocumentManager.d.ts +1 -1
- package/dist/components/tabs/Tabs.d.ts +2 -2
- package/dist/components/tileview/TileView.d.ts +128 -0
- package/dist/components/tileview/index.d.ts +6 -0
- package/dist/components/tileview/tile-click-event-args.d.ts +9 -0
- package/dist/components/tileview/tile-reorder-event-args.d.ts +11 -0
- package/dist/components/tileview/tile-selection-changed-event-args.d.ts +11 -0
- package/dist/components/tileview/tile-view-item.d.ts +18 -0
- package/dist/components/tileview/tile-view-props.d.ts +38 -0
- package/dist/components/timeline/Timeline.d.ts +113 -0
- package/dist/components/timeline/index.d.ts +5 -0
- package/dist/components/timeline/timeline-item-click-event-args.d.ts +9 -0
- package/dist/components/timeline/timeline-item.d.ts +24 -0
- package/dist/components/timeline/timeline-props.d.ts +30 -0
- package/dist/components/timeline/timeline-selection-changed-event-args.d.ts +11 -0
- package/dist/components/tooltip/Tooltip.d.ts +1 -1
- package/dist/components/treeview/TreeView.d.ts +1 -1
- package/dist/components/validationsummary/ValidationSummary.d.ts +56 -0
- package/dist/components/validationsummary/index.d.ts +3 -0
- package/dist/components/validationsummary/summary-item-click-event-args.d.ts +11 -0
- package/dist/components/validationsummary/validation-summary-props.d.ts +17 -0
- package/dist/core/control.d.ts +4 -4
- package/dist/core/flow-home.d.ts +6 -0
- package/dist/core/fold-text.d.ts +6 -0
- package/dist/core/ui-locale.d.ts +0 -2
- package/dist/core/ui-strings.d.ts +67 -0
- package/dist/generated/tokens.d.ts +7270 -4490
- package/dist/index.d.ts +17 -1
- package/dist/index.js +27131 -20490
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +59 -1
- package/dist/locales/tr.json +59 -1
- package/dist/parts/slide/slide-track-host.d.ts +19 -0
- package/dist/parts/slide/slide-track.d.ts +45 -0
- package/dist/styles.css +4916 -206
- package/dist/tokens/index.d.ts +7270 -4490
- package/dist/tokens/index.js +7270 -4490
- package/dist/tokens/index.js.map +1 -1
- package/dist/tr-C5IXRzAH.js +1233 -0
- package/dist/tr-C5IXRzAH.js.map +1 -0
- package/docs/accordion.md +9 -9
- package/docs/actionsheet.md +2 -2
- package/docs/avatar.md +5 -5
- package/docs/badge.md +6 -6
- package/docs/bottomsheet.md +6 -6
- package/docs/breadcrumb.md +4 -4
- package/docs/button.md +10 -10
- package/docs/buttongroup.md +5 -5
- package/docs/calendar.md +6 -6
- package/docs/card.md +6 -6
- package/docs/checkbox.md +9 -9
- package/docs/chip.md +5 -5
- package/docs/colorbox.md +3 -3
- package/docs/combobox.md +7 -7
- package/docs/control.md +12 -12
- package/docs/datagrid-api.md +7 -7
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +2 -2
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +2 -2
- package/docs/datagrid-filtering.md +3 -3
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +1 -1
- package/docs/datagrid-layout.md +4 -4
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +3 -3
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +3 -3
- package/docs/datagrid.md +8 -8
- package/docs/datebox.md +8 -8
- package/docs/daterangebox.md +192 -0
- package/docs/draggable.md +194 -0
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +10 -10
- package/docs/fileuploader.md +201 -0
- package/docs/filterbuilder.md +9 -9
- package/docs/formlayout.md +1 -1
- package/docs/gallery.md +244 -0
- package/docs/home.md +11 -7
- package/docs/keyboard.md +1 -1
- package/docs/language.md +229 -0
- package/docs/layout.md +15 -15
- package/docs/listbox.md +10 -10
- package/docs/loadpanel.md +184 -0
- package/docs/lookup.md +1 -1
- package/docs/menus.md +2 -2
- package/docs/multiview.md +202 -0
- package/docs/numberbox.md +9 -9
- package/docs/pagination.md +4 -4
- package/docs/popover.md +221 -0
- package/docs/progress.md +9 -9
- package/docs/radiogroup.md +7 -7
- package/docs/rating.md +4 -4
- package/docs/resizable.md +139 -0
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +5 -5
- 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 +2 -2
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +4 -4
- package/docs/scrollview.md +185 -0
- package/docs/showcase.md +1 -1
- package/docs/skeleton.md +2 -2
- package/docs/slider.md +9 -9
- package/docs/sortable.md +213 -0
- package/docs/speeddial.md +290 -0
- package/docs/splitter.md +204 -0
- package/docs/stepper.md +238 -0
- package/docs/switch.md +7 -7
- package/docs/tabdocs-dock.md +3 -3
- 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 +5 -5
- package/docs/tabs.md +11 -11
- package/docs/tagbox.md +10 -10
- package/docs/textarea.md +9 -9
- package/docs/textbox.md +10 -10
- package/docs/tileview.md +206 -0
- package/docs/timeline.md +174 -0
- package/docs/toast.md +7 -7
- package/docs/tokens.md +678 -122
- package/docs/toolbar.md +8 -8
- package/docs/tooltip.md +12 -12
- package/docs/treeview.md +11 -11
- package/docs/validationsummary.md +115 -0
- package/docs/window.md +7 -7
- package/docs/wizard.md +240 -0
- package/llms-full.txt +4813 -492
- package/llms.txt +21 -3
- package/package.json +9 -3
package/docs/toolbar.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Toolbar
|
|
2
2
|
|
|
3
|
-
> Buttons · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Buttons · @motifx-community/ui 0.1.0-beta.3
|
|
4
4
|
|
|
5
5
|
A bar of commands: buttons, toggle buttons, menus and fields in groups between separators. It is one Tab stop and the arrow keys move inside it; items that do not fit move into a “more” menu at the end. Items come as data, as JSX children, or both.
|
|
6
6
|
|
|
@@ -10,9 +10,9 @@ A bar of commands: buttons, toggle buttons, menus and fields in groups between s
|
|
|
10
10
|
import { Toolbar, ToolbarSeparator, type ToolbarItem } from '@motifx-community/ui';
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Declarative and programmatic
|
|
14
14
|
|
|
15
|
-
`items` describes the commands as data, each field a value or a function; JSX children (any control) come after them.
|
|
15
|
+
`items` describes the commands as data, each field a value or a function; JSX children (any control) come after them. Programmatically, a toolbar is filled like any control: `toolbar.controls.add(button)`. Every prop is also a property.
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
/** A small outline icon drawn from one path. */
|
|
@@ -41,21 +41,21 @@ import { reactive, type Component } from '@motifx/core';
|
|
|
41
41
|
import { Button, Toolbar } from '@motifx-community/ui';
|
|
42
42
|
|
|
43
43
|
/** A toolbar made with `new` and filled with `controls.add`. */
|
|
44
|
-
export default function
|
|
44
|
+
export default function Programmatic() {
|
|
45
45
|
const s = reactive({ log: '' });
|
|
46
46
|
let added = 0;
|
|
47
47
|
|
|
48
48
|
const bar = new Toolbar({ label: 'Actions', size: 'sm' });
|
|
49
49
|
bar.controls.add(new Button({ text: 'First', onclick: () => (s.log = 'First pressed') }));
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const addProgrammatic = () => {
|
|
52
52
|
const n = ++added;
|
|
53
53
|
bar.controls.add(new Button({ text: `Button ${n}`, onclick: () => (s.log = `Button ${n} pressed`) }));
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
57
|
<>
|
|
58
|
-
<Button text="Add a button
|
|
58
|
+
<Button text="Add a button programmatically" variant="outline" onclick={addProgrammatic} />
|
|
59
59
|
<div style="inline-size: 100%" ref={(c: Component<HTMLDivElement>) => c.controls.add(bar)} />
|
|
60
60
|
<output>{() => s.log}</output>
|
|
61
61
|
</>
|
|
@@ -167,7 +167,7 @@ The only text a toolbar writes itself is the name of its “more” button, from
|
|
|
167
167
|
|
|
168
168
|
```tsx
|
|
169
169
|
import { reactive } from '@motifx/core';
|
|
170
|
-
import { Button,
|
|
170
|
+
import { Button, uiLocale } from '@motifx-community/ui';
|
|
171
171
|
import { kitTexts } from '../../../shared/kit-texts';
|
|
172
172
|
|
|
173
173
|
/** Switches the texts of the kit; the “more” buttons take the new name at once. */
|
|
@@ -175,7 +175,7 @@ export default function Localization() {
|
|
|
175
175
|
const s = reactive({ lang: 'en' });
|
|
176
176
|
const toggle = () => {
|
|
177
177
|
s.lang = s.lang === 'en' ? 'tr' : 'en';
|
|
178
|
-
uiLocale.
|
|
178
|
+
void uiLocale.use(s.lang);
|
|
179
179
|
};
|
|
180
180
|
return (
|
|
181
181
|
<>
|
package/docs/tooltip.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Tooltip
|
|
2
2
|
|
|
3
|
-
> Feedback · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Feedback · @motifx-community/ui 0.1.0-beta.3
|
|
4
4
|
|
|
5
|
-
A short description shown next to an element: after the pointer rests on it, when it gets keyboard focus, or
|
|
5
|
+
A short description shown next to an element: after the pointer rests on it, when it gets keyboard focus, or programmatically. It can be hovered, Escape hides it, and one is open at a time on the page.
|
|
6
6
|
|
|
7
7
|
## Import
|
|
8
8
|
|
|
@@ -10,27 +10,27 @@ A short description shown next to an element: after the pointer rests on it, whe
|
|
|
10
10
|
import { Tooltip, addTooltip, type TooltipShowOn } from '@motifx-community/ui';
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Declarative and programmatic
|
|
14
14
|
|
|
15
|
-
In JSX a tooltip is placed anywhere and pointed at its `target`; where it sits does not matter.
|
|
15
|
+
In JSX a tooltip is placed anywhere and pointed at its `target`; where it sits does not matter. Programmatically, `new Tooltip({ target, text })` needs nothing else: it puts itself into the page when it first shows, and goes when its target component does.
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { Button, Tooltip } from '@motifx-community/ui';
|
|
19
19
|
|
|
20
|
-
/** A tooltip from JSX pointed at its target, and one created with `new` and opened
|
|
21
|
-
export default function
|
|
20
|
+
/** A tooltip from JSX pointed at its target, and one created with `new` and opened programmatically. */
|
|
21
|
+
export default function Programmatic() {
|
|
22
22
|
let save: Button | null = null;
|
|
23
23
|
let target: Button | null = null;
|
|
24
24
|
let tip: Tooltip | null = null;
|
|
25
25
|
let opened = 0;
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const openProgrammatic = () => {
|
|
28
28
|
if (!target) return;
|
|
29
29
|
if (!tip) {
|
|
30
30
|
tip = new Tooltip({ target });
|
|
31
31
|
tip.placement = 'end';
|
|
32
32
|
}
|
|
33
|
-
tip.text = `Made
|
|
33
|
+
tip.text = `Made programmatically, opened ${++opened} time(s)`;
|
|
34
34
|
tip.open();
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -39,7 +39,7 @@ export default function FromCode() {
|
|
|
39
39
|
<Button ref={(b: Button) => (save = b)} text="Save" tone="accent" />
|
|
40
40
|
<Tooltip target={() => save} text="Save the file (Ctrl+S)" />
|
|
41
41
|
<Button ref={(b: Button) => (target = b)} text="Target" variant="outline" />
|
|
42
|
-
<Button text="Open a tooltip
|
|
42
|
+
<Button text="Open a tooltip programmatically" variant="outline" onclick={openProgrammatic} />
|
|
43
43
|
</>
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -200,7 +200,7 @@ export default function RichContent() {
|
|
|
200
200
|
import { reactive } from '@motifx/core';
|
|
201
201
|
import { Button, Tooltip } from '@motifx-community/ui';
|
|
202
202
|
|
|
203
|
-
/** A tooltip opened only
|
|
203
|
+
/** A tooltip opened only programmatically, and one shown on keyboard focus while a toggle allows it. */
|
|
204
204
|
export default function ShowOn() {
|
|
205
205
|
const s = reactive({ on: true });
|
|
206
206
|
let help: Button | null = null;
|
|
@@ -209,7 +209,7 @@ export default function ShowOn() {
|
|
|
209
209
|
return (
|
|
210
210
|
<>
|
|
211
211
|
<Button ref={(b: Button) => (help = b)} text="Help" variant="outline" />
|
|
212
|
-
<Tooltip ref={(t: Tooltip) => (tip = t)} target={() => help} text="Shown
|
|
212
|
+
<Tooltip ref={(t: Tooltip) => (tip = t)} target={() => help} text="Shown programmatically" showOn="manual" placement="bottom" />
|
|
213
213
|
<Button text={() => (tip?.opened ? 'Hide it' : 'Show it')} onclick={() => tip && (tip.opened = !tip.opened)} />
|
|
214
214
|
<Button text={() => (s.on ? 'Tooltips on' : 'Tooltips off')} toggle x-model={() => s.on} variant="ghost" />
|
|
215
215
|
<Button ref={(b: Button) => (keyboardOnly = b)} text="Keyboard only" variant="outline" />
|
|
@@ -233,7 +233,7 @@ const SEATS = ['1', '2', '3', '4', '5', '6'].flatMap((row) =>
|
|
|
233
233
|
})),
|
|
234
234
|
);
|
|
235
235
|
|
|
236
|
-
/** A tooltip on each of 24 seats, made only when first needed, and one that is removed
|
|
236
|
+
/** A tooltip on each of 24 seats, made only when first needed, and one that is removed programmatically. */
|
|
237
237
|
export default function ManyElements() {
|
|
238
238
|
let removeGuideTip = () => {};
|
|
239
239
|
return (
|
package/docs/treeview.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TreeView
|
|
2
2
|
|
|
3
|
-
> Data · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Data · @motifx-community/ui 0.1.0-beta.3
|
|
4
4
|
|
|
5
5
|
A tree view shows items in a hierarchy. Rows open and close, are selected one or many at a time, can carry check boxes that add up to their parents, can be searched, and can load their children when they are first opened. Long trees draw only the rows in view.
|
|
6
6
|
|
|
@@ -10,9 +10,9 @@ A tree view shows items in a hierarchy. Rows open and close, are selected one or
|
|
|
10
10
|
import { TreeView } from '@motifx-community/ui';
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Declarative and programmatic
|
|
14
14
|
|
|
15
|
-
Items are objects with a `children` array (or a `parentId`, see below). `value` is the selected row's key and `x-model` binds it two-way. Created with `new`, the tree is filled and driven
|
|
15
|
+
Items are objects with a `children` array (or a `parentId`, see below). `value` is the selected row's key and `x-model` binds it two-way. Created with `new`, the tree is filled and driven programmatically; items changed in place, plain or reactive, show after `refresh()` (`refreshItem(key)` for one row).
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
/** A row of the trees on this page. */
|
|
@@ -84,7 +84,7 @@ export interface Entry {
|
|
|
84
84
|
|
|
85
85
|
## Search and filter
|
|
86
86
|
|
|
87
|
-
`searchEnabled` adds a search box; matches show with their parents, opened, and clearing the search brings the rows back as they were. `searchValue` (or `filter(text)`) filters
|
|
87
|
+
`searchEnabled` adds a search box; matches show with their parents, opened, and clearing the search brings the rows back as they were. `searchValue` (or `filter(text)`) filters programmatically; `searchMode` is `contains` or `startswith`.
|
|
88
88
|
|
|
89
89
|
```tsx
|
|
90
90
|
/** A row of the trees on this page. */
|
|
@@ -185,7 +185,7 @@ The tree writes four texts, all from `uiLocale.strings`: `noItems` (nothing to s
|
|
|
185
185
|
|
|
186
186
|
```tsx
|
|
187
187
|
import { reactive } from '@motifx/core';
|
|
188
|
-
import { Button,
|
|
188
|
+
import { Button, uiLocale } from '@motifx-community/ui';
|
|
189
189
|
import { kitTexts } from '../../../shared/kit-texts';
|
|
190
190
|
|
|
191
191
|
/** Switches the texts of the kit; the trees on the page follow at once. */
|
|
@@ -193,7 +193,7 @@ export default function Localization() {
|
|
|
193
193
|
const s = reactive({ lang: 'en' });
|
|
194
194
|
const toggle = () => {
|
|
195
195
|
s.lang = s.lang === 'en' ? 'tr' : 'en';
|
|
196
|
-
uiLocale.
|
|
196
|
+
void uiLocale.use(s.lang);
|
|
197
197
|
};
|
|
198
198
|
return (
|
|
199
199
|
<>
|
|
@@ -269,8 +269,8 @@ export default function Localization() {
|
|
|
269
269
|
| --- | --- | --- |
|
|
270
270
|
| `expand(key), collapse(key)` | `boolean` | Opens / closes a row; children load first if they have to. The cancelable events run. |
|
|
271
271
|
| `expandAll(), collapseAll()` | `void` | Every row whose children are known. No event per row. |
|
|
272
|
-
| `select(key), unselect(key), selectAll(), clearSelection()` | `void` |
|
|
273
|
-
| `check(key, checked?), uncheck(key), checkAll(), uncheckAll()` | `void` |
|
|
272
|
+
| `select(key), unselect(key), selectAll(), clearSelection()` | `void` | Programmatically; `select` adds to the selection with `multiple`. |
|
|
273
|
+
| `check(key, checked?), uncheck(key), checkAll(), uncheckAll()` | `void` | Programmatically. |
|
|
274
274
|
| `filter(text)` | `void` | Sets `searchValue`. |
|
|
275
275
|
| `scrollTo(key), focusNode(key)` | `boolean` | Opens the row's parents and scrolls it into view (and focuses it). |
|
|
276
276
|
| `reload(key?)` | `void` | Loads a row's children again (all loaded children without a key). |
|
|
@@ -291,7 +291,7 @@ export default function Localization() {
|
|
|
291
291
|
|
|
292
292
|
## Example files
|
|
293
293
|
|
|
294
|
-
`
|
|
294
|
+
`Programmatic.tsx`
|
|
295
295
|
|
|
296
296
|
```tsx
|
|
297
297
|
import { reactive } from '@motifx/core';
|
|
@@ -302,7 +302,7 @@ import { project } from './project';
|
|
|
302
302
|
const BOX = 'inline-size: 100%; max-inline-size: 26rem; background: var(--mx-color-bg-card)';
|
|
303
303
|
|
|
304
304
|
/** A tree bound with x-model, and a tree made with `new` whose items change in place and are read again on `refresh()`. */
|
|
305
|
-
export default function
|
|
305
|
+
export default function Programmatic() {
|
|
306
306
|
const s = reactive({ file: 'tree' as unknown, clicked: '' });
|
|
307
307
|
const menu = reactive<Entry[]>([
|
|
308
308
|
{ id: 'home', text: 'Home' },
|
|
@@ -327,7 +327,7 @@ export default function FromCode() {
|
|
|
327
327
|
</Panel>
|
|
328
328
|
<output class="tv-value">{() => `value: ${JSON.stringify(s.file)}`}</output>
|
|
329
329
|
<Stack orientation="horizontal" wrap align="center">
|
|
330
|
-
<Button text="Add a product
|
|
330
|
+
<Button text="Add a product programmatically" variant="outline" onclick={addProduct} />
|
|
331
331
|
<Button text="Expand all" variant="ghost" onclick={() => tree.expandAll()} />
|
|
332
332
|
<Button text="Collapse all" variant="ghost" onclick={() => tree.collapseAll()} />
|
|
333
333
|
<output class="tv-clicked">{() => s.clicked}</output>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# ValidationSummary
|
|
2
|
+
|
|
3
|
+
> Editors · @motifx-community/ui 0.1.0-beta.3
|
|
4
|
+
|
|
5
|
+
The failed fields of a `ValidationGroup`, one line each with the field’s label and its message, under a header; a press on a line goes to the field. It draws itself again whenever a field of the group is checked or reset, and stays out of sight while nothing has failed.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { ValidationSummary, ValidationGroup } from '@motifx-community/ui';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Above a form
|
|
14
|
+
|
|
15
|
+
Give it the `group` the fields join with `validationGroup`. After `group.validate()` the failed fields are listed; a field that passes again leaves the list, and `group.reset()` empties it. A press on a line focuses the field (`focusOnClick`).
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button, NumberBox, Stack, TextBox, ValidationGroup, ValidationSummary } from '@motifx-community/ui';
|
|
19
|
+
|
|
20
|
+
/** The failed fields of a form listed above it after Save; a press on a line goes to the field. */
|
|
21
|
+
export default function Form() {
|
|
22
|
+
const group = new ValidationGroup();
|
|
23
|
+
return (
|
|
24
|
+
<Stack gap="md" style="inline-size: 100%; max-inline-size: 420px">
|
|
25
|
+
<ValidationSummary class="vs-form" group={group} />
|
|
26
|
+
<TextBox label="Name" required validationGroup={group} />
|
|
27
|
+
<TextBox label="E-mail" required rules={[{ type: 'email' }]} validationGroup={group} />
|
|
28
|
+
<NumberBox label="Guests" required rules={[{ type: 'range', min: 1, max: 8 }]} validationGroup={group} />
|
|
29
|
+
<Stack orientation="horizontal" gap="sm">
|
|
30
|
+
<Button class="vs-save" text="Save" tone="accent" onclick={() => void group.validate({ focus: false })} />
|
|
31
|
+
<Button class="vs-reset" text="Start again" variant="outline" onclick={() => group.reset()} />
|
|
32
|
+
</Stack>
|
|
33
|
+
</Stack>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Programmatic use
|
|
39
|
+
|
|
40
|
+
`header` gives the line above the list, `showHeader` hides it; `onItemClick` tells which line was pressed, `failed` and `count` say what is listed.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { reactive } from '@motifx/core';
|
|
44
|
+
import { Button, Stack, TextBox, ValidationGroup, ValidationSummary } from '@motifx-community/ui';
|
|
45
|
+
|
|
46
|
+
/** A header of its own, or none; the lines tell which field was pressed, and `failed` says how many there are. */
|
|
47
|
+
export default function Programmatic() {
|
|
48
|
+
const group = new ValidationGroup();
|
|
49
|
+
const s = reactive({ header: true, told: '', count: 0 });
|
|
50
|
+
const summary = new ValidationSummary({
|
|
51
|
+
group,
|
|
52
|
+
header: 'Before you send it',
|
|
53
|
+
showHeader: () => s.header,
|
|
54
|
+
onItemClick: e => (s.told = `pressed: ${e.text}`)
|
|
55
|
+
});
|
|
56
|
+
return (
|
|
57
|
+
<Stack gap="md" style="inline-size: 100%; max-inline-size: 420px">
|
|
58
|
+
<span class="vs-coded" onConfig={c => c.controls.add(summary)} />
|
|
59
|
+
<TextBox label="Street" required validationGroup={group} />
|
|
60
|
+
<TextBox label="Town" required validationGroup={group} />
|
|
61
|
+
<Stack orientation="horizontal" wrap align="center">
|
|
62
|
+
<Button class="vs-coded-check" text="Check" tone="accent" onclick={async () => {
|
|
63
|
+
await group.validate({ focus: false });
|
|
64
|
+
s.count = summary.count;
|
|
65
|
+
}} />
|
|
66
|
+
<Button text="Header on and off" variant="outline" onclick={() => (s.header = !s.header)} />
|
|
67
|
+
<output class="vs-coded-told">{() => `${s.count} failed${s.told ? `, ${s.told}` : ''}`}</output>
|
|
68
|
+
</Stack>
|
|
69
|
+
</Stack>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Accessibility
|
|
75
|
+
|
|
76
|
+
| Topic | How |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `The summary` | A live region (`polite`): the lines are read out when they appear; out of sight while nothing has failed. |
|
|
79
|
+
| `A line` | A button with the field’s label and its message (“E-mail: Enter a valid e-mail address”); a press focuses the field. |
|
|
80
|
+
| `Glyph` | The mark before the header is decorative. |
|
|
81
|
+
|
|
82
|
+
## Styling
|
|
83
|
+
|
|
84
|
+
| Hook | What it is |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| `.mx-validation-summary` | The summary. `data-empty` while nothing has failed. |
|
|
87
|
+
| `.mx-validation-summary__header, .mx-validation-summary__icon, .mx-validation-summary__header-text` | The header, its glyph, its text. |
|
|
88
|
+
| `.mx-validation-summary__list, .mx-validation-summary__line, .mx-validation-summary__item` | The list, a line, the button in it. |
|
|
89
|
+
|
|
90
|
+
### Component tokens
|
|
91
|
+
|
|
92
|
+
| Token | What it sets |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `validation-summary.box, .icon, .header, .item` | Units: the box, the glyph before the header (`icon`), the header’s text, a line (`hover`, `focus`). |
|
|
95
|
+
| `validation-summary.gap, .line-gap` | Between the header and the list; between the lines. |
|
|
96
|
+
|
|
97
|
+
## API reference
|
|
98
|
+
|
|
99
|
+
### Props
|
|
100
|
+
|
|
101
|
+
| Prop | Type | Default | Description |
|
|
102
|
+
| --- | --- | --- | --- |
|
|
103
|
+
| `group` | `Bind<ValidationGroup \| null>` | `null` | The group whose failed fields are listed. |
|
|
104
|
+
| `header` | `Bind<string>` | the kit’s “Please correct the following” | The line above the list. |
|
|
105
|
+
| `showHeader` | `Bind<boolean>` | `true` | The header is shown. |
|
|
106
|
+
| `focusOnClick` | `Bind<boolean>` | `true` | A press on a line focuses its field. |
|
|
107
|
+
|
|
108
|
+
### Events, properties and methods
|
|
109
|
+
|
|
110
|
+
| Member | Kind | Description |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `onItemClick` | event | A line was pressed (`target`, `text`). |
|
|
113
|
+
| `failed` | read-only | The failed targets listed now, in the group’s order. |
|
|
114
|
+
| `count` | read-only | How many lines there are. |
|
|
115
|
+
| `refresh()` | `void` | Draws the lines again from the fields as they are now. |
|
package/docs/window.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Window and dialog
|
|
2
2
|
|
|
3
|
-
> Navigation · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Navigation · @motifx-community/ui 0.1.0-beta.3
|
|
4
4
|
|
|
5
5
|
A window or a dialog on a native `<dialog>`: one form, shown modeless or modal by whoever shows it. It has a title bar, moves, resizes, minimizes and maximizes; Enter and Escape press its buttons; forms open forms. `messageBox` and `confirm` cover the common questions.
|
|
6
6
|
|
|
@@ -10,9 +10,9 @@ A window or a dialog on a native `<dialog>`: one form, shown modeless or modal b
|
|
|
10
10
|
import { MxForm, messageBox, confirm, type FormResult } from '@motifx-community/ui';
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Declarative and programmatic
|
|
14
14
|
|
|
15
|
-
In JSX, `x-model` shows the form while the value is true and writes `false` when the user closes it; it is hidden, not disposed, and lives with its parent.
|
|
15
|
+
In JSX, `x-model` shows the form while the value is true and writes `false` when the user closes it; it is hidden, not disposed, and lives with its parent. Programmatically, a form (often a class with a `view()`) is shown with `show(host)` or `showDialog(host)`; it is added to the host and disposed when it closes.
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { reactive } from '@motifx/core';
|
|
@@ -206,7 +206,7 @@ export class RenameForm extends MxForm {
|
|
|
206
206
|
|
|
207
207
|
## Events
|
|
208
208
|
|
|
209
|
-
`onClosing` can keep the form open, here while it has changes; `reason` tells the user (close button, Escape)
|
|
209
|
+
`onClosing` can keep the form open, here while it has changes; `reason` tells the user (close button, Escape) programmatically and from the owner going away.
|
|
210
210
|
|
|
211
211
|
```tsx
|
|
212
212
|
import { reactive } from '@motifx/core';
|
|
@@ -327,7 +327,7 @@ The title bar buttons and the `ok`, `cancel`, `yes`, `no` buttons of a message b
|
|
|
327
327
|
|
|
328
328
|
```tsx
|
|
329
329
|
import { reactive } from '@motifx/core';
|
|
330
|
-
import { Button,
|
|
330
|
+
import { Button, messageBox, uiLocale } from '@motifx-community/ui';
|
|
331
331
|
|
|
332
332
|
/** Switches the names of the title bar buttons and of the message box buttons. */
|
|
333
333
|
export default function Localization() {
|
|
@@ -335,7 +335,7 @@ export default function Localization() {
|
|
|
335
335
|
|
|
336
336
|
const toggle = () => {
|
|
337
337
|
s.lang = s.lang === 'en' ? 'tr' : 'en';
|
|
338
|
-
uiLocale.
|
|
338
|
+
void uiLocale.use(s.lang);
|
|
339
339
|
};
|
|
340
340
|
|
|
341
341
|
const ask = () =>
|
|
@@ -451,7 +451,7 @@ import { reactive, type Component } from '@motifx/core';
|
|
|
451
451
|
import { Button, MxForm, Stack, TextBox, type FormResult } from '@motifx-community/ui';
|
|
452
452
|
import { RenameForm } from './RenameForm';
|
|
453
453
|
|
|
454
|
-
/** A modeless form in JSX shown through x-model, and a form class shown modal
|
|
454
|
+
/** A modeless form in JSX shown through x-model, and a form class shown modal programmatically. */
|
|
455
455
|
export default function JsxAndCode() {
|
|
456
456
|
const s = reactive({ find: false, query: '', found: '', renamed: '' });
|
|
457
457
|
let host: Component<HTMLDivElement> | null = null;
|
package/docs/wizard.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Wizard
|
|
2
|
+
|
|
3
|
+
> Navigation · @motifx-community/ui 0.1.0-beta.3
|
|
4
|
+
|
|
5
|
+
A task in steps: a [Stepper](stepper.md) above or beside one page per step, and the Back and Next buttons under them. Next validates the page first; on the last step it finishes.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Wizard, WizardStep } from '@motifx-community/ui';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Pages from JSX
|
|
14
|
+
|
|
15
|
+
Each `WizardStep` is a step and its page. Next validates the kit’s fields on the page, then the step’s own `validate`; a page that fails keeps the wizard, marks its step and focuses the first invalid field. On the last step Next reads Finish and raises `onFinished`.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { reactive } from '@motifx/core';
|
|
19
|
+
import { CheckBox, Stack, TextBox, Wizard, WizardStep } from '@motifx-community/ui';
|
|
20
|
+
|
|
21
|
+
/** Three pages with the kit's fields: Next validates the page first; Finish tells the app. */
|
|
22
|
+
export default function Basic() {
|
|
23
|
+
const s = reactive({ name: '', email: '', city: '', agreed: false, result: '' });
|
|
24
|
+
return (
|
|
25
|
+
<Stack gap="md" style="inline-size: 100%">
|
|
26
|
+
<Wizard label="Sign up" onFinished={() => (s.result = `Welcome, ${s.name}.`)}>
|
|
27
|
+
<WizardStep title="Account" description="Who you are">
|
|
28
|
+
<Stack orientation="horizontal" wrap align="center">
|
|
29
|
+
<TextBox label="Name" x-model={() => s.name} required />
|
|
30
|
+
<TextBox label="E-mail" x-model={() => s.email} required rules={[{ type: 'email' }]} />
|
|
31
|
+
</Stack>
|
|
32
|
+
</WizardStep>
|
|
33
|
+
<WizardStep title="Address" description="Where you live">
|
|
34
|
+
<TextBox label="City" x-model={() => s.city} required />
|
|
35
|
+
</WizardStep>
|
|
36
|
+
<WizardStep title="Review" validate={() => s.agreed}>
|
|
37
|
+
<p>{() => `${s.name || '—'}, ${s.email || '—'}, ${s.city || '—'}`}</p>
|
|
38
|
+
<CheckBox label="Everything is right" x-model={() => s.agreed} />
|
|
39
|
+
</WizardStep>
|
|
40
|
+
</Wizard>
|
|
41
|
+
<output class="wz-result">{() => s.result}</output>
|
|
42
|
+
</Stack>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Programmatic use
|
|
48
|
+
|
|
49
|
+
`steps` makes the steps from props, each page from a `content` factory when it is first shown; `add`, `insert` and `remove` change them later. `next()`, `previous()`, `goTo()` and `finish()` move it.
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { Component, reactive } from '@motifx/core';
|
|
53
|
+
import { Button, Stack, Wizard, WizardStep } from '@motifx-community/ui';
|
|
54
|
+
|
|
55
|
+
// A page made programmatically: any MotifJS component.
|
|
56
|
+
class Note extends Component<HTMLDivElement, { text: string }> {
|
|
57
|
+
override view() {
|
|
58
|
+
return <p>{this.props.text}</p>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A wizard made programmatically: its steps as props with content factories, moved with its methods, a step added later. */
|
|
63
|
+
export default function Programmatic() {
|
|
64
|
+
const s = reactive({ told: '' });
|
|
65
|
+
const wizard = new Wizard({
|
|
66
|
+
label: 'Setup',
|
|
67
|
+
steps: [
|
|
68
|
+
{ title: 'Welcome', content: () => new Note({ text: 'A page made by a factory, built when first shown.' }) },
|
|
69
|
+
{ title: 'Options', description: 'Pick what you need', content: () => new Note({ text: 'The second page.' }) },
|
|
70
|
+
{ title: 'Done', content: () => new Note({ text: 'The last page; Next reads Finish here.' }) }
|
|
71
|
+
],
|
|
72
|
+
onStepChanged: e => (s.told = `Step ${e.index + 1}: ${(e.item as { text: string }).text}`),
|
|
73
|
+
onFinished: () => (s.told = 'Finished.')
|
|
74
|
+
});
|
|
75
|
+
const addStep = () => {
|
|
76
|
+
wizard.insert(2, new WizardStep({ title: 'Extra', optional: true, content: () => new Note({ text: 'Added programmatically.' }) }));
|
|
77
|
+
};
|
|
78
|
+
return (
|
|
79
|
+
<Stack gap="md" style="inline-size: 100%">
|
|
80
|
+
<span onConfig={c => c.controls.add(wizard)} />
|
|
81
|
+
<Stack orientation="horizontal" wrap align="center">
|
|
82
|
+
<Button text="Go to Done" variant="outline" onclick={() => void wizard.goTo(wizard.steps.length - 1)} />
|
|
83
|
+
<Button text="Add a step" variant="outline" onclick={addStep} />
|
|
84
|
+
<output class="wz-told">{() => s.told}</output>
|
|
85
|
+
</Stack>
|
|
86
|
+
</Stack>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Standing
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { reactive } from '@motifx/core';
|
|
95
|
+
import { RadioGroup, Switch, TextArea, Wizard, WizardStep } from '@motifx-community/ui';
|
|
96
|
+
|
|
97
|
+
/** The stepper beside the pages, the texts after the indicators. */
|
|
98
|
+
export default function Vertical() {
|
|
99
|
+
const s = reactive({ plan: 'Team', notify: true, note: '' });
|
|
100
|
+
return (
|
|
101
|
+
<Wizard label="Subscription" orientation="vertical" style="min-block-size: 16rem; inline-size: 100%">
|
|
102
|
+
<WizardStep title="Plan" description="What you pay for">
|
|
103
|
+
<RadioGroup label="Plan" items={['Solo', 'Team', 'Business']} x-model={() => s.plan} />
|
|
104
|
+
</WizardStep>
|
|
105
|
+
<WizardStep title="Alerts" description="How we reach you">
|
|
106
|
+
<Switch label="Send me a monthly summary" x-model={() => s.notify} />
|
|
107
|
+
</WizardStep>
|
|
108
|
+
<WizardStep title="Notes" optional>
|
|
109
|
+
<TextArea label="Anything else?" x-model={() => s.note} rows={3} />
|
|
110
|
+
</WizardStep>
|
|
111
|
+
</Wizard>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Your own buttons, finishing that waits
|
|
117
|
+
|
|
118
|
+
`showNavigation={false}` takes the bar away; your own buttons call the methods. `onFinishing` may set a `promise`: the wizard finishes when it resolves to `true`, and stays otherwise.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { reactive } from '@motifx/core';
|
|
122
|
+
import { Button, Stack, TextBox, Wizard, WizardStep } from '@motifx-community/ui';
|
|
123
|
+
|
|
124
|
+
/** No bar: buttons of your own drive it; finishing waits for a promise (a server) and may be refused. */
|
|
125
|
+
export default function Custom() {
|
|
126
|
+
const s = reactive({ code: '', busy: false, note: '' });
|
|
127
|
+
let wizard!: Wizard;
|
|
128
|
+
const finish = () => {
|
|
129
|
+
s.note = '';
|
|
130
|
+
void wizard.finish().then(ok => (s.note = ok ? 'Saved.' : s.note || 'Not finished.'));
|
|
131
|
+
};
|
|
132
|
+
return (
|
|
133
|
+
<Stack gap="md" style="inline-size: 100%">
|
|
134
|
+
<Wizard
|
|
135
|
+
ref={(w: Wizard) => (wizard = w)}
|
|
136
|
+
label="Redeem"
|
|
137
|
+
showNavigation={false}
|
|
138
|
+
labelPosition="end"
|
|
139
|
+
onFinishing={e => {
|
|
140
|
+
s.busy = true;
|
|
141
|
+
e.promise = new Promise<boolean>(resolve => setTimeout(() => resolve(s.code.toUpperCase() === 'MOTIF'), 600)).then(ok => {
|
|
142
|
+
s.busy = false;
|
|
143
|
+
if (!ok) s.note = 'That code is not known.';
|
|
144
|
+
return ok;
|
|
145
|
+
});
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<WizardStep title="Code">
|
|
149
|
+
<TextBox label="Gift code" x-model={() => s.code} required placeholder="MOTIF" />
|
|
150
|
+
</WizardStep>
|
|
151
|
+
<WizardStep title="Confirm">
|
|
152
|
+
<p>{() => `Redeem “${s.code}”?`}</p>
|
|
153
|
+
</WizardStep>
|
|
154
|
+
</Wizard>
|
|
155
|
+
<Stack orientation="horizontal" wrap align="center">
|
|
156
|
+
<Button text="Back" variant="outline" onclick={() => void wizard.previous()} />
|
|
157
|
+
<Button text="Next" variant="outline" onclick={() => void wizard.next()} />
|
|
158
|
+
<Button text="Redeem" busy={() => s.busy} onclick={finish} />
|
|
159
|
+
<output class="wz-note">{() => s.note}</output>
|
|
160
|
+
</Stack>
|
|
161
|
+
</Stack>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Accessibility
|
|
167
|
+
|
|
168
|
+
| Topic | How |
|
|
169
|
+
| --- | --- |
|
|
170
|
+
| `Stepper` | A `nav` of steps as on the [Stepper](stepper.md) page: each a button with its position and status in its name, one Tab stop. |
|
|
171
|
+
| `Page` | A `group` named after its step; the hidden pages are out of the tree. |
|
|
172
|
+
| `Validation` | A page that fails keeps focus on its first invalid field, with its message; the step reads “Needs attention”. |
|
|
173
|
+
| `Buttons` | The kit’s buttons, named in the kit language: “Back”, “Next”, “Finish”. |
|
|
174
|
+
|
|
175
|
+
## Styling
|
|
176
|
+
|
|
177
|
+
| Hook | What it is |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| `.mx-wizard` | The wizard. `data-orientation`. |
|
|
180
|
+
| `.mx-wizard__stepper` | The stepper (`.mx-stepper` too). |
|
|
181
|
+
| `.mx-wizard__pages, .mx-wizard__page` | The pages and each page; a hidden page carries `hidden`. |
|
|
182
|
+
| `.mx-wizard__bar, .mx-wizard__previous, .mx-wizard__next` | The bar and its buttons. |
|
|
183
|
+
|
|
184
|
+
### Component tokens
|
|
185
|
+
|
|
186
|
+
| Token | What it sets |
|
|
187
|
+
| --- | --- |
|
|
188
|
+
| `wizard.frame, .page, .bar` | Units: the whole, a page, the bar (a rule over it, its padding). |
|
|
189
|
+
| `wizard.previous, wizard.next` | Places: the buttons’ look in the bar (`variant`). |
|
|
190
|
+
| `wizard.gap, .bar-gap, .rail-width` | Between the stepper, the pages and the bar; between the buttons; the stepper’s width when it stands beside the pages. |
|
|
191
|
+
|
|
192
|
+
## API reference
|
|
193
|
+
|
|
194
|
+
### Wizard props
|
|
195
|
+
|
|
196
|
+
| Prop | Type | Default | Description |
|
|
197
|
+
| --- | --- | --- | --- |
|
|
198
|
+
| `steps` | `readonly WizardStepProps[]` | `[]` | Steps made programmatically, each as the props of a `WizardStep`; the JSX `WizardStep` children come first. |
|
|
199
|
+
| `value` | `Bind<string \| number \| null>` | `0` | The current step: its `key`, else its index. `x-model` binds it two-way. |
|
|
200
|
+
| `linear` | `Bind<boolean>` | `true` | A step is reached only after the ones before it; optional steps may be skipped. |
|
|
201
|
+
| `orientation` | `Bind<StepperOrientation>` | `'horizontal'` | `horizontal`: the stepper above the pages; `vertical`: beside them. |
|
|
202
|
+
| `labelPosition` | `Bind<StepperLabelPosition>` | `'bottom'` | Where the stepper’s texts sit, horizontal only. |
|
|
203
|
+
| `size` | `Bind<ControlSize>` | `'md'` | The stepper’s size. |
|
|
204
|
+
| `showStepper, showNavigation` | `Bind<boolean>` | `true` | The stepper, and the bar with the Back and Next buttons. |
|
|
205
|
+
| `clickable` | `Bind<boolean>` | `true` | The steps of the stepper can be pressed. |
|
|
206
|
+
| `lazy` | `Bind<boolean>` | `true` | A page is built when first shown, then kept (a step’s own `lazy` wins). |
|
|
207
|
+
| `keepAlive` | `Bind<boolean>` | `true` | `false`: what a step’s `content` made is disposed while hidden and made again when it shows (a step’s own `keepAlive` wins). |
|
|
208
|
+
| `previousText, nextText, finishText` | `Bind<string>` | the kit’s “Back”, “Next”, “Finish” | The buttons’ texts. |
|
|
209
|
+
| `label` | `Bind<string>` | the kit’s “Steps” | What screen readers call the stepper. |
|
|
210
|
+
|
|
211
|
+
### WizardStep props
|
|
212
|
+
|
|
213
|
+
| Prop | Type | Default | Description |
|
|
214
|
+
| --- | --- | --- | --- |
|
|
215
|
+
| `title` | `Bind<string>` | `''` | The step’s text in the stepper. The same property as `text`. |
|
|
216
|
+
| `description` | `Bind<string>` | `''` | A second line under the title. |
|
|
217
|
+
| `key` | `Bind<string>` | the index | Names the step in `value`; the JSX `key` works too. |
|
|
218
|
+
| `icon` | `Bind<IconSource \| null>` | `null` | Drawn in the indicator in place of the number. |
|
|
219
|
+
| `optional` | `Bind<boolean>` | `false` | May be skipped; says so under the title. |
|
|
220
|
+
| `enabled` | `Bind<boolean>` | `true` | `false` keeps the step from being reached. |
|
|
221
|
+
| `error` | `Bind<boolean>` | `false` | Draws the step with an error; the wizard sets it when the page does not validate, and clears it when it does. |
|
|
222
|
+
| `validateFields` | `Bind<boolean>` | `true` | The kit’s fields on the page are validated before the wizard moves on from it; the first invalid one takes focus. |
|
|
223
|
+
| `validate` | `() => boolean \| Promise<boolean>` | — | Asked after the fields; `false` keeps the page and marks the step. |
|
|
224
|
+
| `lazy, keepAlive` | `Bind<boolean \| undefined>` | the wizard’s | See the wizard’s. |
|
|
225
|
+
| `content` | `() => ComponentBase \| ComponentBase[]` | — | Makes the page programmatically, when the page is built. |
|
|
226
|
+
|
|
227
|
+
### Events, properties and methods
|
|
228
|
+
|
|
229
|
+
| Member | Kind | Description |
|
|
230
|
+
| --- | --- | --- |
|
|
231
|
+
| `onStepChanging, onStepChanged` | event | The stepper’s events: `onStepChanging` (`cancel`, `promise`) runs before the page is validated. |
|
|
232
|
+
| `onFinishing` | event | The last page validated and the wizard is about to finish; `cancel = true` keeps it open, `promise` waits and finishes on `true`. |
|
|
233
|
+
| `onFinished` | event | The wizard finished: every step is drawn done. |
|
|
234
|
+
| `next(), previous(), goTo(step)` | `Promise<boolean>` | Next validates the page first and finishes on the last step; Back validates nothing; `goTo` validates when it goes forward. |
|
|
235
|
+
| `finish()` | `Promise<boolean>` | Validates the page, asks `onFinishing`, then finishes. |
|
|
236
|
+
| `leaveCheck()` | `Promise<boolean>` | Validates the current page the way Next does, without moving. |
|
|
237
|
+
| `add(step), insert(index, step), remove(step)` | `WizardStep` / `boolean` | Steps programmatically; a step of another wizard moves here. |
|
|
238
|
+
| `stepper, steps, currentStep, selectedIndex` | read-only | The `Stepper`, the `WizardStep`s in order, the current one and its index. |
|
|
239
|
+
| `isLast, isFinished` | read-only | The current step is the last that can be gone to (Next finishes); the wizard finished. |
|
|
240
|
+
| `previousButton, nextButton` | read-only | The kit’s buttons in the bar, for an icon or a look of your own. |
|