@motifx-community/ui 0.1.0-beta.10 → 0.1.0-beta.12
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 +59 -0
- package/dist/components/combobox/ComboBox.d.ts +5 -0
- package/dist/components/combobox/combo-box-props.d.ts +6 -0
- package/dist/components/datagrid/DataGrid.d.ts +4 -1
- package/dist/components/datagrid/grid-lookup.d.ts +8 -0
- package/dist/components/datagrid/model/FilterModel.d.ts +5 -0
- package/dist/components/datagrid/model/LookupTexts.d.ts +2 -0
- package/dist/components/datagrid/model/LookupValues.d.ts +4 -0
- package/dist/components/datagrid/view/ActionWidths.d.ts +13 -3
- package/dist/components/datagrid/view/GridRow.d.ts +1 -1
- package/dist/components/dropdown/DropDown.d.ts +5 -0
- package/dist/components/dropdown/drop-down-props.d.ts +6 -0
- package/dist/components/filterbuilder/filter-builder-lookup.d.ts +3 -0
- package/dist/components/listbox/ListBox.d.ts +5 -0
- package/dist/components/listbox/list-box-props.d.ts +6 -0
- package/dist/components/listbox/select-all-state.d.ts +1 -1
- package/dist/components/ribbonmenu/RibbonKeyHints.d.ts +1 -0
- package/dist/components/tagbox/TagBox.d.ts +5 -0
- package/dist/components/tagbox/tag-box-props.d.ts +6 -0
- package/dist/components/toolbar/Toolbar.d.ts +10 -2
- package/dist/core/measure/after-frame.d.ts +7 -0
- package/dist/core/measure/drawn.d.ts +7 -0
- package/dist/core/measure/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +571 -139
- package/dist/index.js.map +1 -1
- package/dist/parts/data/DataItems.d.ts +24 -0
- package/dist/parts/data/KeyedItems.d.ts +31 -5
- package/dist/parts/data/normalize-key.d.ts +7 -0
- package/dist/styles.css +32 -0
- 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 +2 -2
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +3 -5
- 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/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 +126 -0
- package/docs/control.md +1 -1
- package/docs/data.md +1 -1
- package/docs/datagrid-api.md +3 -3
- 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 +107 -1
- package/docs/datagrid-filtering.md +11 -3
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +1 -1
- package/docs/datagrid-layout.md +2 -2
- 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/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- 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 +3 -1
- package/docs/feedback.md +1 -1
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout.md +1 -1
- 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 +2 -2
- package/docs/keyboard.md +5 -3
- package/docs/language.md +2 -2
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +2 -2
- package/docs/lookup.md +1 -1
- package/docs/menus-api.md +142 -0
- package/docs/menus-context.md +126 -0
- package/docs/menus-customization.md +138 -0
- package/docs/menus-merging.md +208 -0
- package/docs/menus-programmatic.md +74 -0
- package/docs/menus.md +22 -179
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +7 -2
- package/docs/numberbox.md +3 -3
- package/docs/otpinput.md +1 -1
- package/docs/pagination.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +3 -3
- 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 +248 -0
- package/docs/showcase-home.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 +3 -3
- 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 +13 -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 +3774 -2692
- package/llms.txt +16 -6
- package/package.json +4 -4
package/docs/gauge-marks.md
CHANGED
package/docs/gauge-ranges.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Gauge: Ranges
|
|
2
2
|
|
|
3
|
-
> Gauges · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
Ranges give stretches of the scale a meaning, such as normal, high and critical. They show as a band beside the track, and the fill takes the color of the range its value is in.
|
|
6
6
|
|
package/docs/gauge-scales.md
CHANGED
package/docs/gauge.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Gauge
|
|
2
2
|
|
|
3
|
-
> Gauges · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
Shows a value against its scale, as an arc, a circle or a straight bar. Ranges give stretches of the scale a meaning, markers and marks point at values, and every part takes its look from the design language.
|
|
6
6
|
|
package/docs/home.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @motifx-community/ui
|
|
2
2
|
|
|
3
|
-
> Get started · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Get started · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
Components for MotifJS: objects you create when you need them, show anywhere and dispose when you are done, drawn from the MotifJS design system's tokens.
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ The library includes more than fifty components built on a shared base. Each one
|
|
|
28
28
|
|
|
29
29
|
| Group | Components |
|
|
30
30
|
| --- | --- |
|
|
31
|
-
| Buttons and commands | [`Button`](button.md) (menu, split, toggle, busy), [`ButtonGroup`](buttongroup.md), [`Toolbar`](toolbar.md), [`SpeedDial`](speeddial.md), [`MenuBar`](menus.md) and [`ContextMenu`](menus.md) |
|
|
31
|
+
| Buttons and commands | [`Button`](button.md) (menu, split, toggle, busy), [`ButtonGroup`](buttongroup.md), [`Toolbar`](toolbar.md), [`SpeedDial`](speeddial.md), [`MenuBar`](menus.md) and [`ContextMenu`](menus-context.md) |
|
|
32
32
|
| Editors | [`TextBox`](textbox.md) (mask, validation), [`TextArea`](textarea.md), [`NumberBox`](numberbox.md), [`DateBox`](datebox.md), [`DateRangeBox`](daterangebox.md), [`Calendar`](calendar.md), [`ColorBox`](colorbox.md) and [`ColorPicker`](colorbox.md), [`Slider`](slider.md), [`Rating`](rating.md), [`FileUploader`](fileuploader.md), [`ValidationSummary`](validationsummary.md) |
|
|
33
33
|
| Choice | [`CheckBox`](checkbox.md), [`Switch`](switch.md), [`RadioGroup`](radiogroup.md), [`DropDown`](dropdown.md), [`ComboBox`](combobox.md) and [`Autocomplete`](combobox.md), [`Lookup`](lookup.md), [`TagBox`](tagbox.md), [`ListBox`](listbox.md) |
|
|
34
34
|
| Display and feedback | [`Badge`](badge.md), [`Avatar`](avatar.md) and [`AvatarGroup`](avatar.md), [`Chip`](chip.md) and [`ChipGroup`](chip.md), [`Card`](card.md), [`Gallery`](gallery.md), [`TileView`](tileview.md), [`Timeline`](timeline.md), [`Skeleton`](skeleton.md), [`ProgressBar`](progress.md) and [`Spinner`](progress.md), [`LoadPanel`](loadpanel.md), [`Tooltip`](tooltip.md), [`Popover`](popover.md), [`Toast`](toast.md) |
|
package/docs/keyboard.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Keyboard and focus
|
|
2
2
|
|
|
3
|
-
> Foundations · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Foundations · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
Every control follows the same rules for Tab order, the active control of a container, focus handling, `&File` access keys and application-wide shortcuts.
|
|
6
6
|
|
|
@@ -149,6 +149,8 @@ export default class Shortcut extends Component {
|
|
|
149
149
|
}
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
+
Commands defined once, with their keys, for menus, toolbars and ribbons, the list of every shortcut with its conflicts, and the keys the user gives are on [Commands and shortcuts](commands.md). [ShortcutEditor](shortcuteditor.md) lets the user assign other keys to any shortcut with a name.
|
|
153
|
+
|
|
152
154
|
## Focus never lands on <body>
|
|
153
155
|
|
|
154
156
|
When the focused part of a control is disabled, hidden, removed (a list row, a tree branch) or disposed, focus moves to the next usable element from that position in the same window, or to the previous one. Clicking an empty area still clears focus as usual, and route changes are left to the router.
|
|
@@ -177,8 +179,8 @@ export default function FocusGuard() {
|
|
|
177
179
|
|
|
178
180
|
| Member | Return value / type | Description |
|
|
179
181
|
| --- | --- | --- |
|
|
180
|
-
| `addShortcut(
|
|
181
|
-
| `control.addShortcut(
|
|
182
|
+
| `addShortcut(keys, handler, options?)` | `() => void` | Registers a shortcut and returns a function that removes it. `keys` is one set of keys or a list of them. `options.scope` limits it to a component, `options.within` further to parts of it (a component, a list of components, or a function that returns them, such as the tabs of a strip: shortcuts of different parts may share keys), `options.inEditable` also enables it in text fields, and `options.name` lets the user assign other keys ([ShortcutEditor](shortcuteditor.md)). |
|
|
183
|
+
| `control.addShortcut(keys, handler, options?)` | `() => void` | Registers a shortcut scoped to the control and removes it when the control is disposed. |
|
|
182
184
|
| `parseAccessKey(text)` | `{ text, key, index }` | Parses `&Text` for your own controls. Render the result with the `mx-access-key` class and call `setAccessKey(key)`. |
|
|
183
185
|
| `tabIndex` | prop / property | The order inside the container. The default is 0. |
|
|
184
186
|
| `activeControl / restoreFocus()` | FocusContainer | See the Control page. |
|
package/docs/language.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Language
|
|
2
2
|
|
|
3
|
-
> Foundations · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Foundations · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
`uiLocale` controls the strings that controls display, the locale used for dates and numbers, and the text direction. The kit has one `uiLocale`, and each language pack is loaded on demand.
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ export default function Switch() {
|
|
|
45
45
|
|
|
46
46
|
| Rule | Details |
|
|
47
47
|
| --- | --- |
|
|
48
|
-
| `Start` | The initial language
|
|
48
|
+
| `Start` | The initial language comes from the page's `<html lang>` attribute, or from the browser language if it is not set. Set `lang` before creating the first control. `uiLocale.ready` resolves once that language has loaded. |
|
|
49
49
|
| `Texts` | Every string a control displays on its own, such as a button name, a message or “No items”, comes from the active language pack. English is used for anything the pack does not include. |
|
|
50
50
|
| `Formats` | Dates, numbers, the first day of the week and the 12 or 24-hour clock follow `uiLocale.locale`. A control's own `locale` prop takes precedence for that control. |
|
|
51
51
|
| `Direction` | `uiLocale.dir` is `rtl` for Arabic, Hebrew, Persian, Urdu and similar languages. Controls lay themselves out based on `<html dir>`, which `@motifx-community/i18n` keeps in sync. |
|
package/docs/layout.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Layout
|
|
2
2
|
|
|
3
|
-
> Navigation · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Navigation · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
Container controls for arranging other controls: `Stack` (a row or column), `Grid` (rows and columns), `Panel` (a plain box that can scroll), `GroupBox` (a titled frame), `DockPanel` (children docked to its edges) and `SplitContainer` (two panes with a splitter). All of them are controls, so they can disable and hide their content, and they lay out children added at any time.
|
|
6
6
|
|
package/docs/listbox.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ListBox
|
|
2
2
|
|
|
3
|
-
> Data · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Data · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
A list displayed directly on the page. Users select one or more items with the keyboard or pointer. Items can come from memory or a data source, can be searched and grouped, and long lists render only the visible rows.
|
|
6
6
|
|
package/docs/loadpanel.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# LoadPanel
|
|
2
2
|
|
|
3
|
-
> Feedback · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Feedback · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
A loading overlay for a container or the whole page. It includes a shade, a panel with the kit spinner and a message, and a Cancel button when the operation can be stopped. The content underneath is unavailable while it is shown, and focus returns afterward.
|
|
6
6
|
|
|
@@ -126,7 +126,7 @@ export default function Options() {
|
|
|
126
126
|
| Topic | Details |
|
|
127
127
|
| --- | --- |
|
|
128
128
|
| `Covering a container` | The panel is placed inside the container, above its content. The container gets `aria-busy`, and the content under the panel is inert, so it cannot be clicked or focused. |
|
|
129
|
-
| `Over the page` | Without a `target`, the panel covers the viewport and the rest of the page is inert.
|
|
129
|
+
| `Over the page` | Without a `target`, the panel covers the viewport and the rest of the page is inert. |
|
|
130
130
|
| `Focus` | Focus moves from the content underneath to the panel (to the Cancel button if there is one) and returns to its original position when the panel hides. |
|
|
131
131
|
| `Delay` | Quick operations show nothing. The panel appears after `delay`, and hiding it before then cancels it. |
|
|
132
132
|
| `Spinner.cover` | The kit spinner can cover a container with a single call (`Spinner.cover`). LoadPanel is the full component, with the panel, message, delay and button. |
|
package/docs/lookup.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lookup
|
|
2
2
|
|
|
3
|
-
> Choice · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Choice · @motifx-community/ui 0.1.0-beta.11
|
|
4
4
|
|
|
5
5
|
Selects one row from a table-style list, typically from a data source searched on the server, such as a customer by company, contact and city. The field shows the text of the selected row, and everything else works as in DropDown.
|
|
6
6
|
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# MenuBar: API reference
|
|
2
|
+
|
|
3
|
+
> MenuBar · @motifx-community/ui 0.1.0-beta.11
|
|
4
|
+
|
|
5
|
+
Every prop, property, method and event of `MenuBar` and `ContextMenu`, the fields of a menu item, and the styling hooks and tokens.
|
|
6
|
+
|
|
7
|
+
## MenuBar props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `items` | `Bind<readonly MenuItem[]>` | `[]` | The top-level items, whose `items` define the menus they open. A top-level item without `items` runs its `click`. |
|
|
12
|
+
| `label` | `Bind<string>` | `''` | The accessible name of the bar. This is the same property as `text`. |
|
|
13
|
+
| `focusOnF10` | `Bind<boolean>` | `false` | F10 moves focus to the bar from anywhere on the page. This is off by default because browsers use F10. |
|
|
14
|
+
| `openOnHover` | `Bind<boolean>` | `true` | While a menu is open, hovering another top-level item opens its menu, and hovering an item opens its submenu. |
|
|
15
|
+
| `customizable` | `Bind<boolean>` | `false` | The user can hide and move items from the menu of a right-click or Shift+F10. Each item can say otherwise. |
|
|
16
|
+
| `customization` | `Bind<MenuBarCustomization \| null>` | `null` | What the user changed, as `onCustomized` reported it, to restore. |
|
|
17
|
+
| `commands` | `Bind<readonly MenuItem[]>` | The app’s commands | The commands the user can add in the customizer, each with a `key`. |
|
|
18
|
+
| `customizer` | `Bind<boolean>` | `true` | The menu of a right-click offers the customizer when `customizable` is on. |
|
|
19
|
+
| `customizerKeyboard` | `Bind<boolean>` | `true` | The customizer has a Keyboard page ([ShortcutEditor](shortcuteditor.md)). |
|
|
20
|
+
| `mergeHost` | `Bind<boolean>` | `false` | The app’s bar: other bars merge their items into it. |
|
|
21
|
+
| `mergeName` | `Bind<string>` | `'main'` | The name of the app’s bar, when there are several. |
|
|
22
|
+
| `mergeInto` | `Bind<string \| MenuBar \| null>` | `null` | The app’s bar to merge into: its name or the bar itself. |
|
|
23
|
+
| `mergeWhen` | `Bind<'shown' \| 'focus' \| 'manual'>` | `'shown'` | When the bar merges. |
|
|
24
|
+
| `mergeScope` | `Bind<ComponentBase \| null>` | Its parent | The place whose being shown or focused merges the bar. |
|
|
25
|
+
| `hideWhenMerged` | `Bind<boolean>` | `true` | The bar is hidden while it is merged. |
|
|
26
|
+
| `enabled / disabled, visible, tabStop, tabIndex` | see Control | | Properties shared by all controls. |
|
|
27
|
+
|
|
28
|
+
## ContextMenu props
|
|
29
|
+
|
|
30
|
+
| Prop | Type | Default | Description |
|
|
31
|
+
| --- | --- | --- | --- |
|
|
32
|
+
| `items` | `Bind<readonly MenuItem[]>` | `[]` | The commands. `onOpening` can provide different ones for each component. |
|
|
33
|
+
| `target` | `Bind<Component \| null>` | Its parent | The component the menu belongs to. If not set, this is the component the `ContextMenu` is placed in. |
|
|
34
|
+
| `label` | `Bind<string>` | `''` | The accessible name of the menu. |
|
|
35
|
+
| `keyboard` | `Bind<boolean>` | `true` | The Menu key and Shift+F10 open the menu at the focused element. |
|
|
36
|
+
| `closeOnScroll` | `Bind<boolean>` | `true` | Scrolling the element out of view closes the menu. Until then, the menu follows the element. |
|
|
37
|
+
| `openOnHover` | `Bind<boolean>` | `true` | Hovering an item opens its submenu. |
|
|
38
|
+
| `enabled` | `Bind<boolean>` | `true` | `false` shows the browser’s own menu. |
|
|
39
|
+
|
|
40
|
+
## MenuItem
|
|
41
|
+
|
|
42
|
+
| Field | Type | Description |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| `key` | `string \| number` | Names the item in paths (`file/save`), in what the user changed and in merging. Without it, an item is named by its position. |
|
|
45
|
+
| `text` | `Bind<string>` | The label. `&Copy` makes C select the item while the menu is open (Alt+C on a top-level menu bar item). |
|
|
46
|
+
| `command` | `string` | The key of an app command (`commands`). What the item is not given, such as its text, icon, keys, state and action, comes from the command. |
|
|
47
|
+
| `icon, hint` | `Bind<…>` | An icon at the start, and a tooltip. |
|
|
48
|
+
| `shortcut` | `Bind<string>` | A key combination displayed at the end (`Ctrl+S`). It is for display only: register the key with `addShortcut`, or name a command, whose keys are shown and run. |
|
|
49
|
+
| `description` | `Bind<string>` | A second, dimmer text after the label that distinguishes the item, such as a folder name. It is part of the item’s name and never a key. |
|
|
50
|
+
| `items` | `Bind<readonly MenuItem[]>` | A submenu that opens at the side. |
|
|
51
|
+
| `checked` | `Bind<boolean>` | A check item (`menuitemcheckbox`). |
|
|
52
|
+
| `group` | `Bind<string>` | With `checked`, one choice in a group (`menuitemradio`), shown with a dot. |
|
|
53
|
+
| `enabled, visible` | `Bind<boolean>` | Dims the item so it cannot be selected, or removes it. |
|
|
54
|
+
| `beginGroup` | `Bind<boolean>` | Draws a separator before the item. |
|
|
55
|
+
| `tone` | `Bind<'standard' \| 'accent' \| 'success' \| 'caution' \| 'danger'>` | Colors the item with a kit tone (`danger` for destructive actions). A toolbar button moved into the overflow menu keeps its tone. |
|
|
56
|
+
| `customizable` | `Bind<boolean>` | `false` keeps the item shown and in its place in a customizable bar; nothing moves past it. |
|
|
57
|
+
| `merge` | `Bind<'auto' \| 'add' \| 'replace' \| 'remove' \| 'none'>` | In a bar merged into another: what the item does there. The default is `auto`. |
|
|
58
|
+
| `mergeAt` | `Bind<number \| { before } \| { after }>` | In a bar merged into another: where the item stands there. The default is the end. |
|
|
59
|
+
| `click` | `(e) => void` | Occurs when the item is selected, after the menu closes. `e`: `{ item, source, event }`. |
|
|
60
|
+
| `data` | `unknown` | A custom value. |
|
|
61
|
+
|
|
62
|
+
## Properties
|
|
63
|
+
|
|
64
|
+
| Property | Access | Description |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `MenuBar.openItem` | read-only, reactive | The top-level item whose menu is open. |
|
|
67
|
+
| `MenuBar.mergedBars` | read-only | On the app’s bar: the bars merged into it, in the order they came. |
|
|
68
|
+
| `MenuBar.mergedInto` | read-only | On a bar that merges: the app’s bar it is merged into, or `null`. |
|
|
69
|
+
| `MenuBar.mergedItems` | read-only | The top-level items as drawn now, the merged bars’ included. |
|
|
70
|
+
| `ContextMenu.opened` | read-only, reactive | Indicates whether it is open. |
|
|
71
|
+
| `ContextMenu.targetPart` | read-only, reactive | The component the menu was last opened on. |
|
|
72
|
+
| `ContextMenu.target` | read/write, reactive | The component the menu listens on. |
|
|
73
|
+
|
|
74
|
+
## Methods
|
|
75
|
+
|
|
76
|
+
| Method | Returns | Description |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| `MenuBar.open(item \| index \| key)` | `boolean` | Opens a top-level item’s menu with focus on its first item. |
|
|
79
|
+
| `MenuBar.close()` | `void` | Closes the open menu. |
|
|
80
|
+
| `MenuBar.findItem(path)` | `MenuItem \| null` | The item at the path, as it is now. |
|
|
81
|
+
| `MenuBar.addItem(parentPath, item, index?)` | `boolean` | Adds an item to the menu at `parentPath` (the bar when empty). |
|
|
82
|
+
| `MenuBar.removeItem(path)` | `boolean` | Removes the item with its menu. |
|
|
83
|
+
| `MenuBar.moveItem(path, index, toParent?)` | `boolean` | Moves the item in its menu or into another one. |
|
|
84
|
+
| `MenuBar.updateItem(path, changes)` | `boolean` | Changes fields of the item. |
|
|
85
|
+
| `MenuBar.beginUpdate(), endUpdate()` | `void` | Applies the changes made between them at once. |
|
|
86
|
+
| `MenuBar.openCustomizer()` | `boolean` | Opens the customizer window. Returns `false` when it is already open. |
|
|
87
|
+
| `MenuBar.merge(), unmerge()` | `boolean` | Merges the bar into the app’s bar, or takes its items back. |
|
|
88
|
+
| `MenuBar.refresh(), ContextMenu.refresh()` | `void` | Reads items changed in place again. The bar, the open menu and its submenus update. |
|
|
89
|
+
| `ContextMenu.open(at, target?)` | `boolean` | Opens the menu programmatically, at `{ x, y }` or at a component. |
|
|
90
|
+
| `ContextMenu.close()` | `void` | Closes it. |
|
|
91
|
+
| `attachContextMenu(target, items)` | `() => void` | Attaches a menu to a component. `items` can be a function of the opening event (`e.part`). Returns a function that removes the menu. |
|
|
92
|
+
|
|
93
|
+
## Events
|
|
94
|
+
|
|
95
|
+
| Event | When |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| `onItemClick(e)` | On both components, occurs when an item is selected, after its own `click`. `e`: `{ item, source, event }`. |
|
|
98
|
+
| `MenuBar.onCustomized(e)` | The user changed the bar. `e`: `{ customization, source }`, everything changed so far. |
|
|
99
|
+
| `MenuBar.onCustomMenuOpening(e)` | Before the menu of a right-click opens. `e`: `{ item, path, items, cancel, byKeyboard, event, source }`. |
|
|
100
|
+
| `MenuBar.onItemsChanged(e)` | After a change by path. `e`: `{ items, source }`, the new list to keep. |
|
|
101
|
+
| `MenuBar.onMerged(e), onUnmerged(e)` | On the app’s bar: a bar merged into it or left it. `e`: `{ bar, source }`. |
|
|
102
|
+
| `ContextMenu.onOpening(e)` | Occurs before the menu opens. `e`: `{ part, items, cancel, byKeyboard, event, source }`. Set `e.items` for the component `part`, or set `e.cancel = true`. |
|
|
103
|
+
| `ContextMenu.onClosed(reason)` | `escape`, `outside`, `focus` or `code`. |
|
|
104
|
+
|
|
105
|
+
## Keyboard
|
|
106
|
+
|
|
107
|
+
| Key | Description |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `Tab` | Moves focus into the menu bar (one Tab stop) and out of it. |
|
|
110
|
+
| `Left / Right` | On the bar, moves to the previous or next top-level item. In a menu, moves to the adjacent menu or closes a submenu (Right opens one). These keys are mirrored on right-to-left pages. |
|
|
111
|
+
| `Down, Enter, Space` | On the bar, opens the menu on its first item. Up opens it on the last item. |
|
|
112
|
+
| `Up / Down, Home / End` | In a menu, moves between items and wraps at the ends. |
|
|
113
|
+
| `A letter` | Moves to the next item that starts with that letter. An item’s `&` key selects it. |
|
|
114
|
+
| `Alt + key` | Opens the top-level item with that `&` key (Control + Option on Apple platforms). |
|
|
115
|
+
| `Escape` | Closes a submenu, then the menu, and returns to where it opened. |
|
|
116
|
+
| `F10` | Moves focus to the menu bar when `focusOnF10` is set. |
|
|
117
|
+
| `Menu key, Shift+F10` | Opens a context menu at the focused element; on a customizable bar, the menu of the focused item. |
|
|
118
|
+
|
|
119
|
+
## Styling
|
|
120
|
+
|
|
121
|
+
| Hook | Description |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| `.mx-menubar, .mx-menubar__bar, .mx-menubar__item` | The menu bar, its row and a top-level item (`aria-expanded="true"` while open). |
|
|
124
|
+
| `.mx-context-menu, .mx-context-menu__anchor` | The context menu, which has no box of its own, and the point it opens at. |
|
|
125
|
+
| `.mx-menu, .mx-menu__item, .mx-menu__separator` | A menu (shared with Button), an item and a separator. |
|
|
126
|
+
| `.mx-menu__check, .mx-menu__icon, .mx-menu__label, .mx-menu__description, .mx-menu__shortcut, .mx-menu__arrow` | The parts of an item. |
|
|
127
|
+
| `.mx-customizer__pages, .mx-customizer__tree, .mx-customizer__commands` | The customizer window: its pages, the tree of items and the list of commands. |
|
|
128
|
+
|
|
129
|
+
### Component tokens
|
|
130
|
+
|
|
131
|
+
| Token | Description |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `menubar.height, menubar.item-height` | The height of the bar and of a top-level item. |
|
|
134
|
+
| `menubar.bar, menubar.item, menubar.icon, menubar.mnemonic` | Units: the bar, a top-level item with its box per state (`hover`, `pressed`, `open`, `disabled`, `focus`), its icon, and its access key indicator (`shown`). |
|
|
135
|
+
| `menu.item, menu.item-height, menu.item-white-space` | Menu items, shared with the Button menu: the item unit in each state (`highlight`, `pressed`, `focus`, `checked`, `disabled`, `first`, `last`, each tone and `<tone>-highlight`), the row height, and text wrapping. |
|
|
136
|
+
| `menu.panel, menu.check, menu.icon, menu.check-mark, menu.radio-mark, menu.separator` | Units: the item column, the leading indicator and icon, the check and radio marks, and the separator between groups. |
|
|
137
|
+
| `menu.label, menu.description, menu.shortcut, menu.arrow` | Units: the item text, its description, the shortcut and the submenu arrow. |
|
|
138
|
+
| `customizer.page, .buttons, .footer` | Units: the gaps of a customizer page, of the buttons of its forms and of its footer. |
|
|
139
|
+
|
|
140
|
+
## Feedback
|
|
141
|
+
|
|
142
|
+
Loading issues…
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# MenuBar: ContextMenu
|
|
2
|
+
|
|
3
|
+
> MenuBar · @motifx-community/ui 0.1.0-beta.11
|
|
4
|
+
|
|
5
|
+
The menu of an element: it opens on a right-click at the pointer, and with the Menu key or Shift+F10 at the focused element. Its items are the same as those of a menu bar.
|
|
6
|
+
|
|
7
|
+
## A menu for each row
|
|
8
|
+
|
|
9
|
+
A `ContextMenu` placed in an element belongs to it (`target` can name another). `onOpening` builds the items for the component under the pointer, in this case a row in a list: a locked file cannot be renamed. Setting `e.cancel = true` outside a row leaves the browser’s own menu.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { reactive, type Component, type ComponentBase } from '@motifx/core';
|
|
13
|
+
import { ContextMenu, type MenuItem } from '@motifx-community/ui';
|
|
14
|
+
|
|
15
|
+
interface FileRow {
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
locked: boolean;
|
|
19
|
+
starred: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const BOX = 'inline-size: 100%; margin: 0; list-style: none; padding: var(--mx-space-4); background: var(--mx-color-bg-card); border: var(--mx-border-width-1) solid var(--mx-color-stroke-card); border-radius: var(--mx-radius-lg)';
|
|
23
|
+
|
|
24
|
+
/** A context menu whose items `onOpening` builds for the row of a list it opens on. */
|
|
25
|
+
export default function FileList() {
|
|
26
|
+
const s = reactive({
|
|
27
|
+
log: 'Nothing chosen yet.',
|
|
28
|
+
files: [
|
|
29
|
+
{ id: 1, name: 'report.docx', locked: false, starred: true },
|
|
30
|
+
{ id: 2, name: 'budget.xlsx', locked: true, starred: false },
|
|
31
|
+
{ id: 3, name: 'photo.png', locked: false, starred: false },
|
|
32
|
+
] as FileRow[],
|
|
33
|
+
});
|
|
34
|
+
let renamed = 0;
|
|
35
|
+
let list: Component<HTMLUListElement> | null = null;
|
|
36
|
+
|
|
37
|
+
const did = (what: string) => (s.log = what);
|
|
38
|
+
const rename = (row: FileRow) => {
|
|
39
|
+
row.name = `copy-${++renamed}-${row.name}`;
|
|
40
|
+
did(`Renamed to ${row.name}`);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const rowItems = (row: FileRow): MenuItem[] => [
|
|
44
|
+
{ text: '&Open', click: () => did(`Open ${row.name}`) },
|
|
45
|
+
{ text: '&Rename', enabled: !row.locked, click: () => rename(row) },
|
|
46
|
+
{ text: '&Star', checked: row.starred, click: () => (row.starred = !row.starred) },
|
|
47
|
+
{ text: '&Move to', items: ['Documents', 'Pictures', 'Archive'].map((folder) => ({ text: folder, click: () => did(`Move ${row.name} to ${folder}`) })) },
|
|
48
|
+
{ text: '&Delete', shortcut: 'Del', beginGroup: true, enabled: !row.locked, click: () => (s.files = s.files.filter((f) => f !== row)) },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const rowOf = (part: ComponentBase) => {
|
|
52
|
+
let id: string | null = null;
|
|
53
|
+
for (let at: ComponentBase | null = part; at && !id; at = at.parent) id = at.attr.get('data-id');
|
|
54
|
+
return s.files.find((f) => f.id === Number(id));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<ul class="cm-list" aria-label="Files" ref={(c: Component<HTMLUListElement>) => (list = c)} style={BOX}>
|
|
60
|
+
{s.files.map((file) => (
|
|
61
|
+
<li key={file.id} data-id={String(file.id)} tabindex="0" style="padding-block: var(--mx-space-2)">
|
|
62
|
+
{() => `${file.starred ? '★ ' : ''}${file.name}${file.locked ? ' (locked)' : ''}`}
|
|
63
|
+
</li>
|
|
64
|
+
))}
|
|
65
|
+
</ul>
|
|
66
|
+
<ContextMenu
|
|
67
|
+
target={() => list}
|
|
68
|
+
label="File"
|
|
69
|
+
onOpening={(e) => {
|
|
70
|
+
const row = rowOf(e.part);
|
|
71
|
+
if (row) e.items = rowItems(row);
|
|
72
|
+
else e.cancel = true;
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
<output class="cm-log">{() => s.log}</output>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## attachContextMenu
|
|
82
|
+
|
|
83
|
+
`attachContextMenu(target, items)` attaches a menu to a component without placing another one. `items` can be a function of the opening event. It returns a function that removes the menu.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { reactive, type Component } from '@motifx/core';
|
|
87
|
+
import { attachContextMenu } from '@motifx-community/ui';
|
|
88
|
+
|
|
89
|
+
const START = 'Right-click here, or focus me and press the Menu key.';
|
|
90
|
+
const BOX = 'padding: var(--mx-space-4); background: var(--mx-color-bg-card); border: var(--mx-border-width-1) solid var(--mx-color-stroke-card); border-radius: var(--mx-radius-lg)';
|
|
91
|
+
|
|
92
|
+
/** A menu given to a component with `attachContextMenu`, its items built from the opening. */
|
|
93
|
+
export default function AttachedMenu() {
|
|
94
|
+
const s = reactive({ zone: START });
|
|
95
|
+
|
|
96
|
+
const attach = (c: Component<HTMLDivElement>) => {
|
|
97
|
+
const remove = attachContextMenu(c, (e) => [
|
|
98
|
+
{ text: '&Say where', click: () => (s.zone = `Opened ${e.byKeyboard ? 'from the keyboard' : 'with the pointer'} on ${e.part === c ? 'the zone' : 'its content'}.`) },
|
|
99
|
+
{ text: '&Reset', click: () => (s.zone = START) },
|
|
100
|
+
]);
|
|
101
|
+
c.motif.setDisposable(remove);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div class="cm-zone" tabindex="0" style={BOX} onBuilt={attach}>
|
|
106
|
+
{() => s.zone}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Behavior
|
|
113
|
+
|
|
114
|
+
| Topic | Details |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `Opening` | A right-click opens the menu at the pointer; the Menu key and Shift+F10 open it at the focused element, on its first item. |
|
|
117
|
+
| `Items per element` | `onOpening` receives the component under the pointer or the focus (`e.part`) and sets `e.items` for it, or `e.cancel = true` to leave the browser’s own menu. |
|
|
118
|
+
| `Closing` | Escape, a click outside or choosing an item closes the menu; focus returns to the element it opened on. |
|
|
119
|
+
| `Scrolling` | The menu follows the element it opened on while the page scrolls, and closes once the element is out of view (`closeOnScroll`). |
|
|
120
|
+
| `Room` | A menu taller than the window scrolls inside and keeps its scroll position. |
|
|
121
|
+
|
|
122
|
+
The props, properties and events of `ContextMenu` are in the [API reference](menus-api.md).
|
|
123
|
+
|
|
124
|
+
## Feedback
|
|
125
|
+
|
|
126
|
+
Loading issues…
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# MenuBar: Customization
|
|
2
|
+
|
|
3
|
+
> MenuBar · @motifx-community/ui 0.1.0-beta.11
|
|
4
|
+
|
|
5
|
+
With `customizable`, the user arranges the bar: hides and moves items, renames them, adds commands and menus, and changes keyboard shortcuts. The items you give stay as they are; what the user changed is one object for the app to save.
|
|
6
|
+
|
|
7
|
+
## Changes by the user
|
|
8
|
+
|
|
9
|
+
The user right-clicks an item, or presses Shift+F10 on it, to hide it or move it along the bar or up and down its menu. An item with `customizable: false` stays shown and in its place, and nothing moves past it. “Customize…” in that menu, or `openCustomizer()`, opens the customizer window. On a touch screen the window takes the whole screen; `customizer: false` leaves the command out of the menu.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { reactive } from '@motifx/core';
|
|
13
|
+
import { Button, MenuBar, Stack, type MenuBarCustomization, type MenuItem } from '@motifx-community/ui';
|
|
14
|
+
|
|
15
|
+
const MENUS: MenuItem[] = [
|
|
16
|
+
{
|
|
17
|
+
key: 'file',
|
|
18
|
+
text: '&File',
|
|
19
|
+
items: [
|
|
20
|
+
{ key: 'new', text: '&New', shortcut: 'Ctrl+N' },
|
|
21
|
+
{ key: 'open', text: '&Open…', shortcut: 'Ctrl+O' },
|
|
22
|
+
{ key: 'save', text: '&Save', shortcut: 'Ctrl+S', beginGroup: true },
|
|
23
|
+
{ key: 'export', text: '&Export', items: [{ key: 'pdf', text: 'PDF' }, { key: 'html', text: 'HTML' }] },
|
|
24
|
+
{ key: 'exit', text: 'E&xit', beginGroup: true, customizable: false },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{ key: 'edit', text: '&Edit', items: [{ key: 'undo', text: '&Undo' }, { key: 'redo', text: '&Redo' }, { key: 'find', text: '&Find' }] },
|
|
28
|
+
{ key: 'view', text: '&View', items: [{ key: 'zoom', text: '&Zoom' }, { key: 'full', text: '&Full screen' }] },
|
|
29
|
+
{ key: 'help', text: '&Help', customizable: false, items: [{ key: 'about', text: '&About' }] },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
// Commands the user can add from the customizer.
|
|
33
|
+
const COMMANDS: MenuItem[] = [
|
|
34
|
+
{ key: 'print', text: '&Print', shortcut: 'Ctrl+P' },
|
|
35
|
+
{ key: 'share', text: 'S&hare' },
|
|
36
|
+
{ key: 'spelling', text: 'Check &spelling', shortcut: 'F7' },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/** Right-click an item, or press Shift+F10 on it, to hide or move it; what the user changed is one object to save. */
|
|
40
|
+
export default function CustomizableMenu() {
|
|
41
|
+
const s = reactive({ saved: null as MenuBarCustomization | null, told: 'Nothing yet.' });
|
|
42
|
+
let bar!: MenuBar;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Stack gap="md">
|
|
46
|
+
<MenuBar
|
|
47
|
+
ref={(b: MenuBar) => (bar = b)}
|
|
48
|
+
label="Editor"
|
|
49
|
+
items={MENUS}
|
|
50
|
+
customizable
|
|
51
|
+
commands={COMMANDS}
|
|
52
|
+
onCustomized={(e) => (s.saved = e.customization)}
|
|
53
|
+
onCustomMenuOpening={(e) => {
|
|
54
|
+
if (e.path) e.items.push({ text: 'Show the path', beginGroup: true, click: () => (s.told = `Path: ${e.path}`) });
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
<output class="mb-custom-told">{() => s.told}</output>
|
|
58
|
+
<pre class="mb-custom-saved">{() => JSON.stringify(s.saved ?? {}, null, 2)}</pre>
|
|
59
|
+
<Stack orientation="horizontal" gap="sm" wrap>
|
|
60
|
+
<Button text="Customize…" variant="outline" onclick={() => bar.openCustomizer()} />
|
|
61
|
+
<Button text="Forget the changes" variant="outline" onclick={() => (bar.customization = null)} />
|
|
62
|
+
<Button text="Restore the saved changes" variant="outline" onclick={() => (bar.customization = s.saved)} />
|
|
63
|
+
</Stack>
|
|
64
|
+
</Stack>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Page of the window | Content |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `Menus` | Every item in a tree. Its check box shows or hides it; the toolbar adds a menu of the user’s own, renames, deletes what the user added, moves items up, down or into another menu, and resets. Alt with an arrow moves the selected item, F2 renames it, Delete deletes it. |
|
|
72
|
+
| `Commands` | The commands given as `commands`, or the app’s commands (`commands.add`) when none are given, to add one to a menu. |
|
|
73
|
+
| `Keyboard` | A [ShortcutEditor](shortcuteditor.md): the app’s keyboard shortcuts, to assign other keys. `customizerKeyboard: false` leaves the page out. |
|
|
74
|
+
|
|
75
|
+
## Saving the changes
|
|
76
|
+
|
|
77
|
+
`onCustomized` reports everything the user changed so far as one plain object; assigning it to `customization` restores the changes, and `null` forgets them. An item of the app is named by its path in the items given and keeps that name wherever the user moves it, so a saved object still applies after the app adds items. How the object is stored is up to the app.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
bar.customization = JSON.parse(localStorage.getItem('menu') ?? 'null');
|
|
81
|
+
bar.onCustomized((e) => localStorage.setItem('menu', JSON.stringify(e.customization)));
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Field | Type | Description |
|
|
85
|
+
| --- | --- | --- |
|
|
86
|
+
| `hidden` | `string[]` | The items the user hid. |
|
|
87
|
+
| `order` | `Record<string, string[]>` | The order the user gave: the bar’s items under `''`, a menu’s items under the name of the menu. |
|
|
88
|
+
| `moves` | `Record<string, string>` | The items the user moved to another menu, and the menu each went to. |
|
|
89
|
+
| `texts` | `Record<string, string>` | The names the user gave to items. |
|
|
90
|
+
| `added` | `MenuBarAddedItem[]` | The commands and menus the user added, each with its `id` (`user:1`). |
|
|
91
|
+
|
|
92
|
+
## Commands of your own in the menu
|
|
93
|
+
|
|
94
|
+
`onCustomMenuOpening` occurs before the menu of a right-click opens, with the item, its path and the commands about to be shown: add commands of your own, leave some out, or set `cancel`. It occurs without `customizable` too, with no commands of the bar, so a bar can have a right-click menu of the app’s own.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { reactive } from '@motifx/core';
|
|
98
|
+
import { MenuBar, Stack, type MenuItem } from '@motifx-community/ui';
|
|
99
|
+
|
|
100
|
+
const MENUS: MenuItem[] = [
|
|
101
|
+
{ key: 'file', text: '&File', items: [{ key: 'new', text: '&New' }, { key: 'open', text: '&Open…' }] },
|
|
102
|
+
{ key: 'edit', text: '&Edit', items: [{ key: 'undo', text: '&Undo' }, { key: 'redo', text: '&Redo' }] },
|
|
103
|
+
{ key: 'help', text: '&Help', items: [{ key: 'about', text: '&About' }] },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The menu a right-click opens on the bar, with commands of the app's own: the bar is not `customizable`, so they are
|
|
108
|
+
* the only ones. Help opens no menu at all.
|
|
109
|
+
*/
|
|
110
|
+
export default function CustomMenuCommands() {
|
|
111
|
+
const s = reactive({ told: 'Nothing yet.' });
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Stack gap="md">
|
|
115
|
+
<MenuBar
|
|
116
|
+
label="Own commands"
|
|
117
|
+
items={MENUS}
|
|
118
|
+
onCustomMenuOpening={(e) => {
|
|
119
|
+
if (e.path === 'help') {
|
|
120
|
+
e.cancel = true;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const name = e.item ? String(e.item.text).replace('&', '') : 'the bar';
|
|
124
|
+
e.items.push(
|
|
125
|
+
{ text: `Copy the path of ${name}`, click: () => (s.told = `Path: ${e.path ?? '(none)'}`) },
|
|
126
|
+
{ text: 'Show all menus', beginGroup: true, click: () => (s.told = 'Every menu is shown.') },
|
|
127
|
+
);
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
<output class="mb-own-told">{() => s.told}</output>
|
|
131
|
+
</Stack>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Feedback
|
|
137
|
+
|
|
138
|
+
Loading issues…
|