@vention/machine-ui 5.30.8 → 5.30.9
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/README.md +157 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Machine UI is Vention's component library for building applications and Human-Machine Interfaces (HMIs). This is the same library that Vention uses internally to build our own applications, now available for you to build custom applications for your Vention machines.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Complete documentation, including component examples, design system guidelines, and usage instructions, can be found at:
|
|
8
|
-
|
|
9
|
-
**[https://assets.vention.com/machine-ui-storybook/](https://assets.vention.com/machine-ui-storybook/index.html?path=/docs/guides-introduction--documentation)**
|
|
5
|
+
Each component's props and their types are in the package's type declarations, which your editor and `tsc` read. Look there for props; this README covers only defaults, behaviour and composition that the types can't show.
|
|
10
6
|
|
|
11
7
|
## 🚀 Installation
|
|
12
8
|
|
|
@@ -18,19 +14,169 @@ npm install @vention/machine-ui
|
|
|
18
14
|
|
|
19
15
|
For the latest version and release notes, visit the [npm package page](https://www.npmjs.com/package/@vention/machine-ui).
|
|
20
16
|
|
|
21
|
-
##
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
Machine UI builds on MUI v5. The app needs the peer dependencies `react` and `react-dom` 17 and `@mui/material` 5, plus `@emotion/react` and `@emotion/styled`, which MUI needs. `@tabler/icons-react`, `tss-react` and `react-draggable` come with the package.
|
|
20
|
+
|
|
21
|
+
Wrap the app in MUI's `ThemeProvider` with one of the two themes:
|
|
22
|
+
|
|
23
|
+
- `machineUiTheme`: the desktop theme. It sets the palette, the spacing scale (`theme.spacing(n)` reads `[0, 4, 8, 12, 16, 24, 28, 32, 40, 48, 56, 64, 80, 96, 128]` px) and the typography variants.
|
|
24
|
+
- `machineUiHmiTheme`: the touch HMI theme. It is `machineUiTheme` with thicker icon strokes (1.5px instead of 1.01px). Palette, spacing and typography are the same, so touch sizing comes from each component's `size` prop, not from the theme (see Components).
|
|
25
|
+
|
|
26
|
+
Both themes add typography variants you can pass to MUI's `Typography`: `heading36Bold`, `heading24SemiBold`, `heading24Medium`, `heading18SemiBold`, `heading16SemiBold`, `paragraph18Medium`, `paragraph18Regular`, `paragraph16Medium`, `paragraph16Regular`, `paragraph14Regular`, `code16Reg`, `code14Reg`, `code12Reg`, `uiText18SemiBold`, `uiText18Medium`, `uiText18Regular`, `uiText14SemiBold`, `uiText14Medium`, `uiText14Regular`, `uiText12SemiBold`, `uiText12Medium`, `uiText12Regular`, `uiTableNumbers14Reg`, `uiTableNumbers12Reg`, and for HMIs `hmiText20Regular`, `hmiText20SemiBold`, `hmiText22Regular`, `hmiText22Medium`, `hmiText22SemiBold`, `hmiText28SemiBold`, `hmiText32SemiBold`.
|
|
27
|
+
|
|
28
|
+
`COLORS` holds the raw palette: `COLORS.slate`, `COLORS.blue`, `COLORS.cyan`, `COLORS.green`, `COLORS.amber` and `COLORS.red`, each keyed by shade (`50`, `100` to `900`, `950`), for example `COLORS.slate[800]`. Use it where a component takes a color string, such as `VentionStatusDot`'s `color`.
|
|
29
|
+
|
|
30
|
+
Importing anything from the package applies its global styles (`box-sizing: border-box` on every element), so there is no `CssBaseline` to add. The themes use the `Inter` and `Roboto Mono` fonts, which the app loads itself, for example from Google Fonts in `index.html`:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&family=Roboto+Mono&display=swap" rel="stylesheet" />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { ThemeProvider, Typography } from "@mui/material"
|
|
38
|
+
import { COLORS, VentionButton, VentionStatusIndicator, machineUiHmiTheme } from "@vention/machine-ui"
|
|
39
|
+
|
|
40
|
+
export function App() {
|
|
41
|
+
return (
|
|
42
|
+
<ThemeProvider theme={machineUiHmiTheme}>
|
|
43
|
+
<div style={{ backgroundColor: COLORS.slate[50], padding: 24 }}>
|
|
44
|
+
<Typography variant="hmiText28SemiBold">Cell 1</Typography>
|
|
45
|
+
<VentionStatusIndicator label="Running" dotColor={COLORS.green[500]} size="xx-large" />
|
|
46
|
+
<VentionButton size="xx-large" variant="filled-brand" onClick={() => console.log("start")}>
|
|
47
|
+
Start cycle
|
|
48
|
+
</VentionButton>
|
|
49
|
+
</div>
|
|
50
|
+
</ThemeProvider>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
22
54
|
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
## Components
|
|
56
|
+
|
|
57
|
+
Every component is a named export of `@vention/machine-ui`. Most components take a `size` prop; the HMI sizes are `x-large` and `xx-large`.
|
|
58
|
+
|
|
59
|
+
Buttons, text inputs, selects and comboboxes share one height per size: `x-small` 16px, `small` 24px, `medium` 32px, `large` 40px, `x-large` 56px, `xx-large` 80px. A touch target should be at least 44px, so on a touch HMI use `x-large` or `xx-large`. At `xx-large`, input and select labels switch to `hmiText20*`; the value text and button labels keep their regular typography.
|
|
60
|
+
|
|
61
|
+
Components built on an MUI component (noted as "built on MUI `X`") accept that component's props too, so standard props such as `onClick`, `value`, `checked` and `onChange` work as they do in MUI.
|
|
62
|
+
|
|
63
|
+
### Actions
|
|
64
|
+
|
|
65
|
+
- `VentionButton`: the standard button. `size` defaults to `"small"` (24px), too small for touch, so use `size="x-large"` or `"xx-large"` on touch screens. `variant` defaults to `"filled-brand"`. The label is `children`, else `labelText`, and reads "Button" when both are missing. `type` defaults to `"button"`, so pass `type="submit"` to submit a form. Built on MUI `Button`.
|
|
66
|
+
- `VentionIconButton`: a square button that shows only an icon, passed as `children`. It takes the same `variant` and `size` as `VentionButton`, with the same `"small"` default. Built on MUI `IconButton`.
|
|
67
|
+
- `VentionDropdownButton`: a button that opens a menu of its children. Pass a `VentionMenu` wrapping `VentionMenu.Item` elements as `children`; the button renders children as-is, so bare items get no menu surface.
|
|
68
|
+
- `VentionLink`: an inline text link. `external` defaults to true and shows an external-link icon, so pass `external={false}` for an in-app link. Without `labelText` it reads "Button".
|
|
69
|
+
|
|
70
|
+
### Inputs
|
|
71
|
+
|
|
72
|
+
- `VentionTextInput`: a text field built on MUI `TextField`. Use `state` (`"error"`, `"warning"`, `"success"`, `"disabled"`) instead of `disabled` and `error`. `leftItemText` and `rightItemText` show fixed text inside the field, such as a unit, and `maxCharacters` shows a character count.
|
|
73
|
+
- `VentionSuggestionsInput`: a `VentionTextInput` that shows a list of suggestions as the user types. Pass either `value` (controlled) or `defaultValue`, not both.
|
|
74
|
+
- `VentionSelect`: a dropdown select. `onChange` receives the event, so read `event.target.value`. Each entry in `menuItems` is a `VentionSelectMenuItem` or a `VentionSelectDivider` (`{ type: "divider" }`). With `isMultiple`, `value` is an array. Built on MUI `Select`.
|
|
75
|
+
- `VentionSelectSkeleton`: the loading placeholder for `VentionSelect`, also available as `VentionSelect.Skeleton`.
|
|
76
|
+
- `VentionCombobox`: a searchable single-choice dropdown. `groups` are matched to options by each option's `group`.
|
|
77
|
+
- `VentionTagsInput`: a field that collects a list of text tags.
|
|
78
|
+
- `VentionCheckbox`: a checkbox with an optional label, built on MUI `FormControlLabel`, so `checked` and `onChange` work as there. Its size prop is `checkboxSize`.
|
|
79
|
+
- `VentionRadio`: a radio button, used inside MUI's `RadioGroup`. Its size prop is `radioSize`. Built on MUI `Radio`.
|
|
80
|
+
- `VentionRadioTile`: a large selectable tile with a radio button, used inside MUI's `RadioGroup`, good for touch choices. Built on MUI `FormControlLabel`.
|
|
81
|
+
- `VentionSwitch`: an on/off toggle. `checked` is a string (`"on"`, `"off"`, `"mixed"` or `"loading"`), not a boolean, and `onChange` receives `"on"` or `"off"`.
|
|
82
|
+
- `VentionSlider`: a range slider built on MUI `Slider`. `largeThumb` gives it a bigger handle, for touch.
|
|
83
|
+
- `VentionCounter`: a small pill that shows a number, such as a count of pending items.
|
|
84
|
+
- `VentionStepper`: a value with minus and plus buttons on each side. `value` is displayed as is. Put `onClick` and `disabled` for each button in `minusButtonProps` and `plusButtonProps`.
|
|
85
|
+
- `VentionInputGroupLabel`: a label placed beside a group of inputs.
|
|
86
|
+
- `VentionUploadFile`: one row in a list of uploaded files, with its status. Set `state` to `"indeterminate"` while uploading.
|
|
87
|
+
- `VentionDropZone`: an area to drop or pick files. `onFilesSelect(files)` returns an array of error messages, empty when every file is valid.
|
|
88
|
+
|
|
89
|
+
### Feedback
|
|
90
|
+
|
|
91
|
+
- `VentionAlert`: an alert box with optional actions. A button or link shows when its text is set, so pair each text with its click handler, such as `primaryButtonText` with `onPrimaryButtonClick`. Use `size="xx-large"` on touch HMIs.
|
|
92
|
+
- `VentionBanner`: a full-width colored strip for a machine or page state.
|
|
93
|
+
- `VentionCallout`: an inline highlighted note with optional actions.
|
|
94
|
+
- `VentionProgressBar`: a horizontal progress bar. `value` runs from 0 to 100.
|
|
95
|
+
- `VentionSpinner`: a circular progress indicator. With `type="progress"` it shows `value`, from 0 to 100.
|
|
96
|
+
- `VentionSkeleton`: a loading placeholder. `variant` (`"text"`, `"rounded"` or `"circular"`) decides which other props it needs.
|
|
97
|
+
- `VentionStatusDot`: a small colored dot. `color` takes any CSS color, such as a `COLORS` value.
|
|
98
|
+
- `VentionStatusIndicator`: a status dot with a text label, such as a machine state. Use `size="xx-large"` on touch HMIs.
|
|
99
|
+
- `VentionBadge`: a small labeled tag. Pair the color with a text label, since color alone is hard to read on a shop floor.
|
|
100
|
+
- `VentionTooltip`: a tooltip on hover or focus, built on MUI `Tooltip`. `placement` defaults to `"top-end"`. Hover does not exist on touch screens, so don't put information an operator needs only in a tooltip.
|
|
101
|
+
|
|
102
|
+
### Overlays
|
|
103
|
+
|
|
104
|
+
- `VentionModal`: a dialog with a title, body and up to two buttons. `type` sets the icon. `backDropClickClosable` defaults to true. `width` overrides the width that `modalSize` sets. Set `isTouchDevice` on touch HMIs for larger padding, icons, text and buttons.
|
|
105
|
+
- `VentionModalBase`: the empty modal frame for custom content. Set `isTouchDevice` on touch HMIs.
|
|
106
|
+
- `VentionModalBanner`: a colored banner to place at the top of a modal.
|
|
107
|
+
- `VentionDrawer`: a panel that slides in from a screen edge, built on MUI `Drawer`. When `onDrawerHandleClick` is set, the drawer stays mounted and shows a handle that calls it to toggle.
|
|
108
|
+
- `VentionPopover`: a floating card with an arrow, pointing at an element or a position. Place it with `anchorElement` (an `HTMLElement`) or `pos2D` (`{ top, left }` in px). `buttons` takes up to three `VentionButton` props objects.
|
|
109
|
+
- `VentionMenu`: a menu list that closes when the user clicks outside it. `showMenu` and `closeMenuOnClick` default to true. Fill it with `VentionMenu.Item` (`subMenuItems` makes a nested menu), `VentionMenu.Header` and `VentionMenu.Divider`.
|
|
110
|
+
- `VentionPositionedComponent`: places its `children` at a fixed position that stays inside the viewport. Pass either `anchorRect` (a `DOMRect`, such as from `getBoundingClientRect()`) or `position` (`{ top, left }`), not both.
|
|
111
|
+
|
|
112
|
+
### Navigation and layout
|
|
113
|
+
|
|
114
|
+
- `VentionTabs`: a row of tabs. `value` is the index of the selected tab, and `onChange(event, index)` receives the new index.
|
|
115
|
+
- `VentionSteps`: a vertical list of steps for a guided procedure. Use `size="xx-large"` on touch HMIs; `"small"` always shows dots.
|
|
116
|
+
- `VentionSidebarItem`: a profile entry in a sidebar.
|
|
117
|
+
- `VentionTreeItem`: one row of a tree, with nested `VentionTreeItem` children.
|
|
118
|
+
- `VentionDraggable`: a floating panel the user can drag around the screen. `tabLocation` shows a drag handle on that side; without it the whole panel drags.
|
|
119
|
+
|
|
120
|
+
### Identity
|
|
121
|
+
|
|
122
|
+
- `VentionAvatar`: a round user picture or initials.
|
|
123
|
+
- `VentionPersonCard`: an avatar with a name and a description line.
|
|
124
|
+
- `VentionPersonCardSkeleton`: the loading placeholder for `VentionPersonCard`, also available as `VentionPersonCard.Skeleton`.
|
|
125
|
+
- `VentionIcon`: an icon from the Vention icon set. `type` is an icon name such as `"player-play"` or `"status-warning-hmi"`. `size` is in px and defaults to 24. Icon strokes follow the theme, so they are thicker under `machineUiHmiTheme`. For other icons, `@tabler/icons-react` is installed with the package.
|
|
126
|
+
|
|
127
|
+
A small touch panel that uses several of these:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { useState } from "react"
|
|
131
|
+
import { VentionModal, VentionSelect, VentionSwitch } from "@vention/machine-ui"
|
|
132
|
+
|
|
133
|
+
export function RecipePanel() {
|
|
134
|
+
const [recipe, setRecipe] = useState<string>("small-box")
|
|
135
|
+
const [vacuum, setVacuum] = useState<"on" | "off">("off")
|
|
136
|
+
const [pendingRecipe, setPendingRecipe] = useState<string | null>(null)
|
|
25
137
|
|
|
26
|
-
function App() {
|
|
27
138
|
return (
|
|
28
|
-
|
|
139
|
+
<>
|
|
140
|
+
<VentionSelect
|
|
141
|
+
size="xx-large"
|
|
142
|
+
variant="outlined"
|
|
143
|
+
labelText="Recipe"
|
|
144
|
+
value={recipe}
|
|
145
|
+
onChange={event => setPendingRecipe(String(event.target.value))}
|
|
146
|
+
menuItems={[
|
|
147
|
+
{ value: "small-box", displayText: "Small box" },
|
|
148
|
+
{ value: "large-box", displayText: "Large box" },
|
|
149
|
+
{ type: "divider" },
|
|
150
|
+
{ value: "custom", displayText: "Custom", isDisabled: true },
|
|
151
|
+
]}
|
|
152
|
+
/>
|
|
153
|
+
<VentionSwitch size="xx-large" labelText="Vacuum" checked={vacuum} onChange={setVacuum} />
|
|
154
|
+
<VentionModal
|
|
155
|
+
isOpen={pendingRecipe !== null}
|
|
156
|
+
onClose={() => setPendingRecipe(null)}
|
|
157
|
+
isTouchDevice
|
|
158
|
+
type="warning"
|
|
159
|
+
titleText="Change recipe?"
|
|
160
|
+
body="The current cycle will stop."
|
|
161
|
+
primaryButton={{
|
|
162
|
+
text: "Change",
|
|
163
|
+
onClick: () => {
|
|
164
|
+
if (pendingRecipe !== null) setRecipe(pendingRecipe)
|
|
165
|
+
setPendingRecipe(null)
|
|
166
|
+
},
|
|
167
|
+
}}
|
|
168
|
+
secondaryButton={{ text: "Cancel", onClick: () => setPendingRecipe(null) }}
|
|
169
|
+
/>
|
|
170
|
+
</>
|
|
29
171
|
)
|
|
30
172
|
}
|
|
31
173
|
```
|
|
32
174
|
|
|
33
|
-
|
|
175
|
+
## Storybook
|
|
176
|
+
|
|
177
|
+
The Storybook is the visual reference: it renders every component in each of its variants and sizes, with interactive controls, plus design guidelines for color, typography and HMIs.
|
|
178
|
+
|
|
179
|
+
**[https://assets.vention.com/machine-ui-storybook/](https://assets.vention.com/machine-ui-storybook/index.html?path=/docs/guides-introduction--documentation)**
|
|
34
180
|
|
|
35
181
|
## 📋 Versioning Policy
|
|
36
182
|
|
|
@@ -61,5 +207,3 @@ Machine UI components work exceptionally well for industrial HMI applications. F
|
|
|
61
207
|
## 📄 License
|
|
62
208
|
|
|
63
209
|
This library is provided for use with Vention machines and applications.
|
|
64
|
-
|
|
65
|
-
|