@maxio-com/react-ui-components 9.31.0 → 9.33.0
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/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/skills/maxio-react/SKILL.md +3 -0
- package/dist/skills/maxio-react/references/components-action-menu.md +9 -1
- package/dist/skills/maxio-react/references/components-avatar.md +1 -0
- package/dist/skills/maxio-react/references/components-copy-to-clipboard.md +1 -1
- package/dist/skills/maxio-react/references/components-data-table.md +9 -2
- package/dist/skills/maxio-react/references/components-dialog.md +45 -0
- package/dist/skills/maxio-react/references/components-drawer.md +7 -1
- package/dist/skills/maxio-react/references/components-flex.md +4 -4
- package/dist/skills/maxio-react/references/components-grid.md +11 -11
- package/dist/skills/maxio-react/references/components-icon.md +1 -0
- package/dist/skills/maxio-react/references/components-loading-spinner.md +1 -0
- package/dist/skills/maxio-react/references/components-logo.md +1 -0
- package/dist/skills/maxio-react/references/components-modal.md +507 -0
- package/dist/skills/maxio-react/references/components-notifications-alert.md +6 -0
- package/dist/skills/maxio-react/references/components-notifications-banner.md +6 -0
- package/dist/skills/maxio-react/references/components-notifications-toast.md +6 -0
- package/dist/skills/maxio-react/references/components-pagination.md +6 -0
- package/dist/skills/maxio-react/references/components-popover.md +1 -1
- package/dist/skills/maxio-react/references/components-progressbar.md +2 -1
- package/dist/skills/maxio-react/references/components-tabs.md +7 -0
- package/dist/skills/maxio-react/references/components-tag.md +1 -0
- package/dist/skills/maxio-react/references/components-tile.md +1 -0
- package/dist/skills/maxio-react/references/components-toggle.md +7 -1
- package/dist/skills/maxio-react/references/components-tooltip.md +8 -1
- package/dist/skills/maxio-react/references/foundations-testing.md +191 -0
- package/dist/skills/maxio-react/references/patterns-side-nav.md +6 -0
- package/dist/skills/maxio-react/references/patterns-top-bar.md +1 -0
- package/dist/temporary-typings/src/components/ActionMenu/components/Menu/Menu.d.ts +3 -2
- package/dist/temporary-typings/src/components/ActionMenu/components/Menu/Menu.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ActionMenu/components/MenuButton/MenuButton.d.ts +1 -1
- package/dist/temporary-typings/src/components/ActionMenu/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ActionMenu/components/MenuButton/types.d.ts +2 -1
- package/dist/temporary-typings/src/components/ActionMenu/components/MenuButton/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ActionMenu/components/MenuList/MenuList.d.ts +3 -2
- package/dist/temporary-typings/src/components/ActionMenu/components/MenuList/MenuList.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ActionMenu/contexts/MenuContext.d.ts +3 -1
- package/dist/temporary-typings/src/components/ActionMenu/contexts/MenuContext.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Avatar/Avatar.d.ts +1 -1
- package/dist/temporary-typings/src/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Avatar/Avatar.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Avatar/Avatar.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/DataTable/DataTable.d.ts +1 -1
- package/dist/temporary-typings/src/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/DataTable/DataTable.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/DataTable/DataTable.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/DataTable/components/RowRenderer/RowRenderer.d.ts +2 -1
- package/dist/temporary-typings/src/components/DataTable/components/RowRenderer/RowRenderer.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/DataTable/components/Table/Table.d.ts +1 -1
- package/dist/temporary-typings/src/components/DataTable/components/Table/Table.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/DataTable/components/Table/Table.types.d.ts +1 -0
- package/dist/temporary-typings/src/components/DataTable/components/Table/Table.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Dialog/Dialog.d.ts +5 -0
- package/dist/temporary-typings/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/Dialog/index.d.ts +3 -0
- package/dist/temporary-typings/src/components/Dialog/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/Dialog/types.d.ts +15 -0
- package/dist/temporary-typings/src/components/Dialog/types.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/Drawer/Drawer.d.ts +1 -1
- package/dist/temporary-typings/src/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Drawer/types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Drawer/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Icon/Icon.d.ts +1 -1
- package/dist/temporary-typings/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Icon/Icon.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Icon/Icon.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/LoadingSpinner/LoadingSpinner.d.ts +1 -1
- package/dist/temporary-typings/src/components/LoadingSpinner/LoadingSpinner.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/LoadingSpinner/types.d.ts +2 -1
- package/dist/temporary-typings/src/components/LoadingSpinner/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Logo/Logo.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Logo/Logo.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Logo/Logo.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Modal/Modal.d.ts +5 -0
- package/dist/temporary-typings/src/components/Modal/Modal.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/Modal/index.d.ts +3 -0
- package/dist/temporary-typings/src/components/Modal/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/Modal/types.d.ts +10 -0
- package/dist/temporary-typings/src/components/Modal/types.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/Notifications/Alert/Alert.d.ts +1 -1
- package/dist/temporary-typings/src/components/Notifications/Alert/Alert.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Notifications/Alert/Alert.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Notifications/Alert/Alert.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Notifications/Banner/Banner.d.ts +1 -1
- package/dist/temporary-typings/src/components/Notifications/Banner/Banner.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Notifications/Banner/Banner.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Notifications/Banner/Banner.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Notifications/Toast/Toast/Toast.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Notifications/Toast/Toast/Toast.types.d.ts +1 -0
- package/dist/temporary-typings/src/components/Notifications/Toast/Toast/Toast.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/OverlayTrigger/OverlayTrigger.d.ts +1 -0
- package/dist/temporary-typings/src/components/OverlayTrigger/OverlayTrigger.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Pagination/Pagination.d.ts +1 -1
- package/dist/temporary-typings/src/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Pagination/Pagination.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Pagination/Pagination.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ProgressBar/ProgressBar.d.ts +3 -2
- package/dist/temporary-typings/src/components/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/SideNav/contexts/types.d.ts +1 -0
- package/dist/temporary-typings/src/components/SideNav/contexts/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tabs/Tab/types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Tabs/Tab/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tabs/TabPanel/TabPanel.d.ts +2 -1
- package/dist/temporary-typings/src/components/Tabs/TabPanel/TabPanel.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tabs/Tabs/Tabs.d.ts +1 -1
- package/dist/temporary-typings/src/components/Tabs/Tabs/Tabs.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tabs/contexts/types.d.ts +1 -0
- package/dist/temporary-typings/src/components/Tabs/contexts/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tag/Tag.d.ts +1 -1
- package/dist/temporary-typings/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tag/Tag.types.d.ts +2 -1
- package/dist/temporary-typings/src/components/Tag/Tag.types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tile/Tile.d.ts +3 -2
- package/dist/temporary-typings/src/components/Tile/Tile.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Toggle/Toggle.d.ts +2 -1
- package/dist/temporary-typings/src/components/Toggle/Toggle.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/temporary-typings/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/TooltipTrigger/TooltipTrigger.d.ts +1 -1
- package/dist/temporary-typings/src/components/TooltipTrigger/TooltipTrigger.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/TopBar/TopBar.d.ts +1 -1
- package/dist/temporary-typings/src/components/TopBar/TopBar.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/TopBar/types.d.ts +2 -1
- package/dist/temporary-typings/src/components/TopBar/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/index.d.ts +5 -1
- package/dist/temporary-typings/src/components/index.d.ts.map +1 -1
- package/dist/temporary-typings/src/hooks/useIsOverflowing/index.d.ts +2 -0
- package/dist/temporary-typings/src/hooks/useIsOverflowing/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/hooks/useIsOverflowing/useIsOverflowing.d.ts +3 -0
- package/dist/temporary-typings/src/hooks/useIsOverflowing/useIsOverflowing.d.ts.map +1 -0
- package/dist/temporary-typings/src/utils/index.d.ts +2 -0
- package/dist/temporary-typings/src/utils/index.d.ts.map +1 -1
- package/dist/temporary-typings/src/utils/testId.d.ts +5 -0
- package/dist/temporary-typings/src/utils/testId.d.ts.map +1 -0
- package/package.json +2 -2
- package/typings/index.d.ts +76 -40
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
# Modal
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Modal is a centered overlay that blocks the rest of the page until the user
|
|
8
|
+
finishes or dismisses a focused task. Put a `Dialog` inside it for the
|
|
9
|
+
title, body and footer.
|
|
10
|
+
|
|
11
|
+
Modal is built from two components, as in React Aria:
|
|
12
|
+
|
|
13
|
+
- **`Modal`**: the overlay and the centered panel. It holds the open state, blocks the page, locks scroll and handles dismissal. The backdrop is internal.
|
|
14
|
+
- **`Dialog`**: the content. It renders the title (the accessible name), an optional description, the body, the footer and a close button. `Dialog` also works inside a [Popover](components-popover.md).
|
|
15
|
+
|
|
16
|
+
#### When to Use
|
|
17
|
+
|
|
18
|
+
- Use Modal for a focused task or decision that must be finished or dismissed before returning to the page: confirmations, short forms, details.
|
|
19
|
+
- Use `role="alertdialog"` for confirmations that need an explicit answer, such as deleting or voiding a record.
|
|
20
|
+
- Use a blocking modal (no dismissal) only while a required process runs, and close it from code when it ends.
|
|
21
|
+
|
|
22
|
+
#### When Not to Use
|
|
23
|
+
|
|
24
|
+
- Do not use Modal for content that benefits from staying next to the page, such as long forms or detail panels. Use [Drawer](components-drawer.md) instead.
|
|
25
|
+
- Do not use Modal for brief, anchored content or a few actions. Use [Popover](components-popover.md) instead.
|
|
26
|
+
- Do not use Modal for simple status messages. Use a Toast or an Alert instead.
|
|
27
|
+
|
|
28
|
+
### Behavior
|
|
29
|
+
|
|
30
|
+
- **Mouse and touch**: a backdrop click closes the modal unless `isDismissable={false}`.
|
|
31
|
+
- **Keyboard**: Escape closes the top modal unless `isKeyboardDismissDisabled` is set. Tab and Shift+Tab stay inside the modal.
|
|
32
|
+
- **Focus management**: focus moves into the dialog on open and returns to the trigger on close.
|
|
33
|
+
- **Scroll**: the page behind does not scroll. Long content scrolls inside the body, which then joins the tab order so keyboard users can scroll it.
|
|
34
|
+
- **Sizes**: `sm` (24rem), `md` (40rem) and `lg` (56rem, default) are max-widths that shrink with the viewport. The height follows the content up to the viewport.
|
|
35
|
+
- **Stacking**: a modal can open another modal; Escape closes only the top one.
|
|
36
|
+
|
|
37
|
+
### Patterns
|
|
38
|
+
|
|
39
|
+
| Pattern | `Modal` props | `Dialog` props |
|
|
40
|
+
| :----------- | :-------------------------------------------------- | :------------------------ |
|
|
41
|
+
| Default | — | — |
|
|
42
|
+
| Confirmation | `isDismissable={false}` | `role="alertdialog"` |
|
|
43
|
+
| Blocking | `isDismissable={false}` `isKeyboardDismissDisabled` | `showCloseButton={false}` |
|
|
44
|
+
|
|
45
|
+
### Layering
|
|
46
|
+
|
|
47
|
+
Modal stacks at `--maxio-z-overlay` (40), the same layer as Drawer. Overlays from older code can sit higher, such as legacy modals at z-index 1050–1060.
|
|
48
|
+
|
|
49
|
+
- **Stay below** legacy overlays: keep the default values.
|
|
50
|
+
- **Go above** them: re-base `--maxio-z-overlay` once in the app stylesheet, for example `:root { --maxio-z-overlay: 1070; }`. The panel renders inside the fixed backdrop, so only the backdrop's layer sets the stacking order: a z-index through `className`, or re-basing `--maxio-z-modal`, has no effect.
|
|
51
|
+
|
|
52
|
+
### Accessibility
|
|
53
|
+
|
|
54
|
+
- Always provide a `title`; it is the dialog's visible heading and its accessible name.
|
|
55
|
+
- Use `role="alertdialog"` for confirmations so screen readers announce them as urgent.
|
|
56
|
+
- Keep a visible way to close the dialog unless it is a blocking process.
|
|
57
|
+
- Put actions in `footer` rather than at the end of a scrollable body.
|
|
58
|
+
|
|
59
|
+
### Content
|
|
60
|
+
|
|
61
|
+
- Keep `title` short and specific, such as "Void invoice?" rather than "Confirm".
|
|
62
|
+
- Name the primary action after its result, such as "Void invoice" rather than "OK".
|
|
63
|
+
- Use `description` for one line of secondary context.
|
|
64
|
+
|
|
65
|
+
### Related
|
|
66
|
+
|
|
67
|
+
- **[Drawer](components-drawer.md)**: for longer tasks that slide in from an edge.
|
|
68
|
+
- **[Popover](components-popover.md)**: for lighter, anchored content; it can also host a `Dialog`.
|
|
69
|
+
|
|
70
|
+
## React
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { Modal, Dialog, DialogTrigger } from '@maxio-com/react-ui-components';
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Both components follow the React Aria API and pass extra props through to React Aria. `Modal` adds `size`; `Dialog` adds `title`, `description`, `footer` and `showCloseButton`. `children` and `footer` can be functions that receive `close`.
|
|
77
|
+
|
|
78
|
+
## Imports
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { Body, Button, Dialog, DialogTrigger, Modal, Select, TextField } from "@maxio-com/react-ui-components";
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Prop Types
|
|
85
|
+
|
|
86
|
+
### Modal
|
|
87
|
+
|
|
88
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
89
|
+
| --- | --- | --- | --- | --- | --- |
|
|
90
|
+
| `children` | `ReactNode` | yes | - | The modal content, usually a `Dialog`. | ModalProps |
|
|
91
|
+
| `className` | `string` | no | - | Applied to the panel. The backdrop is internal and cannot be styled. | ModalProps |
|
|
92
|
+
| `size` | `"sm" \| "md" \| "lg"` | no | `lg` | Fixed max-width of the panel. It shrinks with the viewport. | ModalProps |
|
|
93
|
+
| `style` | `CSSProperties` | no | - | Applied to the panel. | ModalProps |
|
|
94
|
+
|
|
95
|
+
## Stories
|
|
96
|
+
|
|
97
|
+
### Default
|
|
98
|
+
|
|
99
|
+
Use DialogTrigger for the simplest, uncontrolled setup. The close button,
|
|
100
|
+
Escape and a backdrop click close the modal; footer actions receive `close`.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
const Default = () => <DialogTrigger>
|
|
104
|
+
<Button variant="secondary">Open modal</Button>
|
|
105
|
+
<Modal size="md" isDismissable isKeyboardDismissDisabled={false}>
|
|
106
|
+
<Dialog
|
|
107
|
+
title="Merge payments"
|
|
108
|
+
description="Combine duplicate payments into one record."
|
|
109
|
+
footer={({ close }) => (
|
|
110
|
+
<>
|
|
111
|
+
<Button variant="secondary" onClick={close}>
|
|
112
|
+
Cancel
|
|
113
|
+
</Button>
|
|
114
|
+
<Button onClick={close}>Merge</Button>
|
|
115
|
+
</>
|
|
116
|
+
)}>
|
|
117
|
+
<Body size="sm">{LOREM}</Body>
|
|
118
|
+
</Dialog>
|
|
119
|
+
</Modal>
|
|
120
|
+
</DialogTrigger>;
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Controlled (external state)
|
|
124
|
+
|
|
125
|
+
Use `isOpen` and `onOpenChange` when the open state lives elsewhere, for
|
|
126
|
+
example in a store or in a different part of the page than the trigger.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
const Controlled = () => {
|
|
130
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<>
|
|
134
|
+
<Button variant="secondary" onClick={() => setIsOpen(true)}>Open modal
|
|
135
|
+
</Button>
|
|
136
|
+
<Modal
|
|
137
|
+
size="md"
|
|
138
|
+
isDismissable
|
|
139
|
+
isKeyboardDismissDisabled={false}
|
|
140
|
+
isOpen={isOpen}
|
|
141
|
+
onOpenChange={setIsOpen}>
|
|
142
|
+
<Dialog title="Payment details">
|
|
143
|
+
<Body size="sm">{LOREM}</Body>
|
|
144
|
+
</Dialog>
|
|
145
|
+
</Modal>
|
|
146
|
+
</>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Sizes
|
|
152
|
+
|
|
153
|
+
Sizes are fixed max-widths that shrink with the viewport: `sm` for
|
|
154
|
+
confirmations, `md` for short forms and `lg` (default) for richer content.
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
const Sizes = () => {
|
|
158
|
+
const sizes: ModalSize[] = ['sm', 'md', 'lg'];
|
|
159
|
+
const [openSize, setOpenSize] = React.useState<ModalSize | null>(null);
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div style={{ display: 'flex', gap: '0.75rem' }}>
|
|
163
|
+
{sizes.map((size) => (
|
|
164
|
+
<Button
|
|
165
|
+
key={size}
|
|
166
|
+
variant="secondary"
|
|
167
|
+
onClick={() => setOpenSize(size)}
|
|
168
|
+
>
|
|
169
|
+
{size}
|
|
170
|
+
</Button>
|
|
171
|
+
))}
|
|
172
|
+
{sizes.map((size) => (
|
|
173
|
+
<Modal
|
|
174
|
+
key={size}
|
|
175
|
+
size={size}
|
|
176
|
+
isOpen={openSize === size}
|
|
177
|
+
onOpenChange={(isOpen) => !isOpen && setOpenSize(null)}
|
|
178
|
+
>
|
|
179
|
+
<Dialog title={`size="${size}"`}>
|
|
180
|
+
<Body size="sm">{LOREM}</Body>
|
|
181
|
+
</Dialog>
|
|
182
|
+
</Modal>
|
|
183
|
+
))}
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Confirmation
|
|
190
|
+
|
|
191
|
+
Use `role="alertdialog"` for confirmations that need an explicit answer.
|
|
192
|
+
Turn off backdrop dismissal so a stray click doesn't discard the decision.
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
const Confirmation = () => (
|
|
196
|
+
<DialogTrigger>
|
|
197
|
+
<Button variant="danger">Void invoice</Button>
|
|
198
|
+
<Modal size="sm" isDismissable={false}>
|
|
199
|
+
<Dialog
|
|
200
|
+
role="alertdialog"
|
|
201
|
+
title="Void invoice?"
|
|
202
|
+
footer={({ close }) => (
|
|
203
|
+
<>
|
|
204
|
+
<Button variant="secondary" onClick={close}>
|
|
205
|
+
Cancel
|
|
206
|
+
</Button>
|
|
207
|
+
<Button variant="danger" onClick={close}>
|
|
208
|
+
Void invoice
|
|
209
|
+
</Button>
|
|
210
|
+
</>
|
|
211
|
+
)}
|
|
212
|
+
>
|
|
213
|
+
<Body size="sm">
|
|
214
|
+
The invoice will be marked as void and can no longer be paid.
|
|
215
|
+
</Body>
|
|
216
|
+
</Dialog>
|
|
217
|
+
</Modal>
|
|
218
|
+
</DialogTrigger>
|
|
219
|
+
);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Blocking
|
|
223
|
+
|
|
224
|
+
Block every user dismissal while a required process runs, and close the
|
|
225
|
+
modal from code when it finishes. This example closes after 3 seconds.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
const Blocking = () => {
|
|
229
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
230
|
+
|
|
231
|
+
React.useEffect(() => {
|
|
232
|
+
if (!isOpen) return undefined;
|
|
233
|
+
|
|
234
|
+
const timer = setTimeout(() => setIsOpen(false), 3000);
|
|
235
|
+
return () => clearTimeout(timer);
|
|
236
|
+
}, [isOpen]);
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<>
|
|
240
|
+
<Button variant="secondary" onClick={() => setIsOpen(true)}>
|
|
241
|
+
Sync with Xero
|
|
242
|
+
</Button>
|
|
243
|
+
<Modal
|
|
244
|
+
size="sm"
|
|
245
|
+
isOpen={isOpen}
|
|
246
|
+
onOpenChange={setIsOpen}
|
|
247
|
+
isDismissable={false}
|
|
248
|
+
isKeyboardDismissDisabled
|
|
249
|
+
>
|
|
250
|
+
<Dialog title="Syncing with Xero…" showCloseButton={false}>
|
|
251
|
+
<Body size="sm">This can take a few minutes.</Body>
|
|
252
|
+
</Dialog>
|
|
253
|
+
</Modal>
|
|
254
|
+
</>
|
|
255
|
+
);
|
|
256
|
+
};
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### With form
|
|
260
|
+
|
|
261
|
+
Forms keep their actions in the footer. Point the submit button at the form
|
|
262
|
+
with the `form` attribute, and keep the modal open until the save resolves:
|
|
263
|
+
while it saves, Escape, backdrop click, Close and Cancel are disabled.
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
const WithForm = () => {
|
|
267
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
268
|
+
const [isSaving, setIsSaving] = React.useState(false);
|
|
269
|
+
|
|
270
|
+
React.useEffect(() => {
|
|
271
|
+
if (!isSaving) return undefined;
|
|
272
|
+
|
|
273
|
+
const timer = setTimeout(() => {
|
|
274
|
+
setIsSaving(false);
|
|
275
|
+
setIsOpen(false);
|
|
276
|
+
}, 1000);
|
|
277
|
+
return () => clearTimeout(timer);
|
|
278
|
+
}, [isSaving]);
|
|
279
|
+
|
|
280
|
+
const onSubmit = (event: React.FormEvent) => {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
setIsSaving(true);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<>
|
|
287
|
+
<Button variant="secondary" onClick={() => setIsOpen(true)}>Add customer
|
|
288
|
+
</Button>
|
|
289
|
+
<Modal
|
|
290
|
+
size="md"
|
|
291
|
+
isOpen={isOpen}
|
|
292
|
+
onOpenChange={setIsOpen}
|
|
293
|
+
isDismissable={args.isDismissable && !isSaving}
|
|
294
|
+
isKeyboardDismissDisabled={args.isKeyboardDismissDisabled || isSaving}>
|
|
295
|
+
<Dialog
|
|
296
|
+
title="Add customer"
|
|
297
|
+
showCloseButton={!isSaving}
|
|
298
|
+
footer={
|
|
299
|
+
<>
|
|
300
|
+
<Button
|
|
301
|
+
variant="secondary"
|
|
302
|
+
onClick={() => setIsOpen(false)}
|
|
303
|
+
disabled={isSaving}
|
|
304
|
+
>
|
|
305
|
+
Cancel
|
|
306
|
+
</Button>
|
|
307
|
+
<Button type="submit" form="add-customer" disabled={isSaving}>
|
|
308
|
+
{isSaving ? 'Saving…' : 'Save'}
|
|
309
|
+
</Button>
|
|
310
|
+
</>
|
|
311
|
+
}>
|
|
312
|
+
<form
|
|
313
|
+
id="add-customer"
|
|
314
|
+
onSubmit={onSubmit}
|
|
315
|
+
style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
316
|
+
<TextField label="Name" placeholder="Acme Inc." />
|
|
317
|
+
<TextField label="Email" placeholder="billing@acme.com" />
|
|
318
|
+
<Select label="Plan" options={PLAN_OPTIONS} />
|
|
319
|
+
</form>
|
|
320
|
+
</Dialog>
|
|
321
|
+
</Modal>
|
|
322
|
+
</>
|
|
323
|
+
);
|
|
324
|
+
};
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Long content
|
|
328
|
+
|
|
329
|
+
Long content scrolls inside the body while the title and actions stay
|
|
330
|
+
visible. The body joins the tab order so it can be scrolled by keyboard.
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
const LongContent = () => <DialogTrigger>
|
|
334
|
+
<Button variant="secondary">Open modal</Button>
|
|
335
|
+
<Modal size="md" isDismissable isKeyboardDismissDisabled={false}>
|
|
336
|
+
<Dialog
|
|
337
|
+
title="Terms of service"
|
|
338
|
+
footer={({ close }) => <Button onClick={close}>Accept</Button>}>
|
|
339
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
340
|
+
{Array.from({ length: 20 }, (_, i) => (
|
|
341
|
+
<Body key={i} size="sm">
|
|
342
|
+
{i + 1}. {LOREM}
|
|
343
|
+
</Body>
|
|
344
|
+
))}
|
|
345
|
+
</div>
|
|
346
|
+
</Dialog>
|
|
347
|
+
</Modal>
|
|
348
|
+
</DialogTrigger>;
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Stacked
|
|
352
|
+
|
|
353
|
+
A modal can open another one, such as a discard confirmation on top of a
|
|
354
|
+
form. Escape closes only the top modal.
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
const Stacked = () => {
|
|
358
|
+
const [isFormOpen, setIsFormOpen] = React.useState(false);
|
|
359
|
+
const [isConfirmOpen, setIsConfirmOpen] = React.useState(false);
|
|
360
|
+
|
|
361
|
+
return (
|
|
362
|
+
<>
|
|
363
|
+
<Button variant="secondary" onClick={() => setIsFormOpen(true)}>
|
|
364
|
+
Edit plan
|
|
365
|
+
</Button>
|
|
366
|
+
<Modal size="md" isOpen={isFormOpen} onOpenChange={setIsFormOpen}>
|
|
367
|
+
<Dialog
|
|
368
|
+
title="Edit plan"
|
|
369
|
+
footer={
|
|
370
|
+
<Button
|
|
371
|
+
variant="secondary"
|
|
372
|
+
onClick={() => setIsConfirmOpen(true)}
|
|
373
|
+
>
|
|
374
|
+
Discard changes
|
|
375
|
+
</Button>
|
|
376
|
+
}
|
|
377
|
+
>
|
|
378
|
+
<TextField label="Plan name" placeholder="Growth" />
|
|
379
|
+
</Dialog>
|
|
380
|
+
</Modal>
|
|
381
|
+
<Modal
|
|
382
|
+
size="sm"
|
|
383
|
+
isDismissable={false}
|
|
384
|
+
isOpen={isConfirmOpen}
|
|
385
|
+
onOpenChange={setIsConfirmOpen}
|
|
386
|
+
>
|
|
387
|
+
<Dialog
|
|
388
|
+
role="alertdialog"
|
|
389
|
+
title="Discard changes?"
|
|
390
|
+
footer={
|
|
391
|
+
<>
|
|
392
|
+
<Button
|
|
393
|
+
variant="secondary"
|
|
394
|
+
onClick={() => setIsConfirmOpen(false)}
|
|
395
|
+
>
|
|
396
|
+
Keep editing
|
|
397
|
+
</Button>
|
|
398
|
+
<Button
|
|
399
|
+
variant="danger"
|
|
400
|
+
onClick={() => {
|
|
401
|
+
setIsConfirmOpen(false);
|
|
402
|
+
setIsFormOpen(false);
|
|
403
|
+
}}
|
|
404
|
+
>
|
|
405
|
+
Discard
|
|
406
|
+
</Button>
|
|
407
|
+
</>
|
|
408
|
+
}
|
|
409
|
+
>
|
|
410
|
+
<Body size="sm">Your changes to this plan will be lost.</Body>
|
|
411
|
+
</Dialog>
|
|
412
|
+
</Modal>
|
|
413
|
+
</>
|
|
414
|
+
);
|
|
415
|
+
};
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Native dialog (HTML)
|
|
419
|
+
|
|
420
|
+
HTML apps use a native `<dialog class="maxio-modal">` with a `maxio-dialog`
|
|
421
|
+
block inside. `aria-labelledby` (and `role="alertdialog"` for
|
|
422
|
+
confirmations) go on `<dialog>`; open it with `showModal()`.
|
|
423
|
+
|
|
424
|
+
```tsx
|
|
425
|
+
const NativeDialog = () => {
|
|
426
|
+
const ref = React.useRef<HTMLDialogElement>(null);
|
|
427
|
+
const pointerDownOnBackdrop = React.useRef(false);
|
|
428
|
+
const close = () => ref.current?.close();
|
|
429
|
+
|
|
430
|
+
return (
|
|
431
|
+
<>
|
|
432
|
+
<button
|
|
433
|
+
id="merge-dialog-open"
|
|
434
|
+
type="button"
|
|
435
|
+
className="maxio-button maxio-button--secondary"
|
|
436
|
+
onClick={() => ref.current?.showModal()}
|
|
437
|
+
>
|
|
438
|
+
Open dialog
|
|
439
|
+
</button>
|
|
440
|
+
<dialog
|
|
441
|
+
ref={ref}
|
|
442
|
+
id="merge-dialog"
|
|
443
|
+
className="maxio-modal"
|
|
444
|
+
data-size="md"
|
|
445
|
+
aria-labelledby="merge-title"
|
|
446
|
+
aria-describedby="merge-description"
|
|
447
|
+
onPointerDown={(event) => {
|
|
448
|
+
pointerDownOnBackdrop.current = event.target === ref.current;
|
|
449
|
+
}}
|
|
450
|
+
onClick={(event) => {
|
|
451
|
+
if (pointerDownOnBackdrop.current && event.target === ref.current) {
|
|
452
|
+
close();
|
|
453
|
+
}
|
|
454
|
+
}}
|
|
455
|
+
>
|
|
456
|
+
<div className="maxio-dialog">
|
|
457
|
+
<header className="maxio-dialog__header">
|
|
458
|
+
<div className="maxio-dialog__title-group">
|
|
459
|
+
<h2
|
|
460
|
+
id="merge-title"
|
|
461
|
+
className="maxio-dialog__title maxio-heading-md"
|
|
462
|
+
>
|
|
463
|
+
Merge payments
|
|
464
|
+
</h2>
|
|
465
|
+
<p id="merge-description" className="maxio-dialog__description">
|
|
466
|
+
Combine duplicate payments into one record.
|
|
467
|
+
</p>
|
|
468
|
+
</div>
|
|
469
|
+
<button
|
|
470
|
+
type="button"
|
|
471
|
+
aria-label="Close"
|
|
472
|
+
className="maxio-button maxio-button--icon maxio-button--ghost maxio-button--sm maxio-dialog__close"
|
|
473
|
+
onClick={close}
|
|
474
|
+
>
|
|
475
|
+
<i
|
|
476
|
+
className="fa-kit fa-cross maxio-button__trailing-element"
|
|
477
|
+
aria-hidden="true"
|
|
478
|
+
/>
|
|
479
|
+
</button>
|
|
480
|
+
</header>
|
|
481
|
+
<div className="maxio-dialog__body">
|
|
482
|
+
<div>
|
|
483
|
+
<p className="maxio-body-sm">{LOREM}</p>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
<footer className="maxio-dialog__footer">
|
|
487
|
+
<button
|
|
488
|
+
type="button"
|
|
489
|
+
className="maxio-button maxio-button--secondary"
|
|
490
|
+
onClick={close}
|
|
491
|
+
>
|
|
492
|
+
Cancel
|
|
493
|
+
</button>
|
|
494
|
+
<button
|
|
495
|
+
type="button"
|
|
496
|
+
className="maxio-button maxio-button--primary"
|
|
497
|
+
onClick={close}
|
|
498
|
+
>
|
|
499
|
+
Merge
|
|
500
|
+
</button>
|
|
501
|
+
</footer>
|
|
502
|
+
</div>
|
|
503
|
+
</dialog>
|
|
504
|
+
</>
|
|
505
|
+
);
|
|
506
|
+
};
|
|
507
|
+
```
|
|
@@ -54,6 +54,11 @@ Choose the sentiment that matches the message tone and user urgency. The default
|
|
|
54
54
|
- Use link text for a concrete next step, such as "View verification status" or "Update payment method".
|
|
55
55
|
- Avoid repeating the sentiment in copy when the title can describe the outcome directly.
|
|
56
56
|
|
|
57
|
+
### Testing
|
|
58
|
+
|
|
59
|
+
- Pass `data-testid` to set it on the alert. The dismiss button derives `<id>.dismiss`.
|
|
60
|
+
- See [Testing](foundations-testing.md) for when to use test IDs and how to name them.
|
|
61
|
+
|
|
57
62
|
### Related
|
|
58
63
|
|
|
59
64
|
- **[Banner](components-notifications-banner.md)**: use for page-level, account-level, or system-wide announcements.
|
|
@@ -79,6 +84,7 @@ import { Alert } from "@maxio-com/react-ui-components";
|
|
|
79
84
|
| --- | --- | --- | --- | --- | --- |
|
|
80
85
|
| `children` | `string` | no | - | Displays alert message | TypeLiteral |
|
|
81
86
|
| `className` | `string` | no | - | Additional CSS class name to be applied to the alert | TypeLiteral |
|
|
87
|
+
| `data-testid` | `string` | no | - | Test ID set on the component's root element. Components with internal parts derive their IDs from it (e.g. `<id>.row.<rowId>`). | TypeLiteral |
|
|
82
88
|
| `display` | `"inline" \| "block"` | no | `inline` | Changes the display of the alert. Defaults to `inline` | TypeLiteral |
|
|
83
89
|
| `href` | `string` | no | - | Sets the link target - `href` must be present to include a link | TypeLiteral |
|
|
84
90
|
| `linkExternal` | `boolean` | no | - | Sets the link target to '_blank' | TypeLiteral |
|
|
@@ -52,6 +52,11 @@ Choose the sentiment that matches the urgency and consequence of the message.
|
|
|
52
52
|
- Avoid vague titles such as "Notice" or "Update".
|
|
53
53
|
- Use dismissible banners for guidance users can safely hide, not for required account or error states.
|
|
54
54
|
|
|
55
|
+
### Testing
|
|
56
|
+
|
|
57
|
+
- Pass `data-testid` to set it on the banner. The dismiss button derives `<id>.dismiss`.
|
|
58
|
+
- See [Testing](foundations-testing.md) for when to use test IDs and how to name them.
|
|
59
|
+
|
|
55
60
|
### Related
|
|
56
61
|
|
|
57
62
|
- **[Toast](components-notifications-toast.md)**: use for transient success, warning, or error feedback that can disappear automatically.
|
|
@@ -78,6 +83,7 @@ import { Banner } from "@maxio-com/react-ui-components";
|
|
|
78
83
|
| --- | --- | --- | --- | --- | --- |
|
|
79
84
|
| `children` | `string` | yes | - | Displays banner message | TypeLiteral |
|
|
80
85
|
| `className` | `string` | no | - | Additional CSS class name to be applied to the banner | TypeLiteral |
|
|
86
|
+
| `data-testid` | `string` | no | - | Test ID set on the component's root element. Components with internal parts derive their IDs from it (e.g. `<id>.row.<rowId>`). | TypeLiteral |
|
|
81
87
|
| `display` | `"inline" \| "block"` | no | `inline` | Changes the display of the banner. Defaults to `inline` | TypeLiteral |
|
|
82
88
|
| `href` | `string` | no | - | Sets the link target - `href` must be present to include a link | TypeLiteral |
|
|
83
89
|
| `linkExternal` | `boolean` | no | - | Sets the link target to '_blank' | TypeLiteral |
|
|
@@ -52,6 +52,12 @@ Use sentiment to match the tone of the message. The sentiment changes the icon c
|
|
|
52
52
|
- Use links only for a direct follow-up action, such as viewing the created object.
|
|
53
53
|
- Avoid stacking multiple toasts for the same event. Update the existing flow or use page-level feedback instead.
|
|
54
54
|
|
|
55
|
+
### Testing
|
|
56
|
+
|
|
57
|
+
- Toasts are created as data, so set the test ID with the `testId` field when adding the toast: `addToast({ title: 'Saved', testId: 'invoice.saved-toast' })`.
|
|
58
|
+
- The dismiss button derives `<testId>.dismiss`.
|
|
59
|
+
- See [Testing](foundations-testing.md) for when to use test IDs and how to name them.
|
|
60
|
+
|
|
55
61
|
### Related
|
|
56
62
|
|
|
57
63
|
- **[Alert](components-notifications-alert.md)**: use for contextual page feedback that should stay near related content.
|
|
@@ -35,6 +35,11 @@ many rows or records are shown at once.
|
|
|
35
35
|
- Keep the displayed item range, total item count, and total page count accurate after every dataset update.
|
|
36
36
|
- Do not rely on the chevron icons alone; preserve accessible button names for previous and next navigation.
|
|
37
37
|
|
|
38
|
+
### Testing
|
|
39
|
+
|
|
40
|
+
- Pass `data-testid` to set it on the pagination container. The previous and next buttons derive `<id>.prev` and `<id>.next`.
|
|
41
|
+
- See [Testing](foundations-testing.md) for when to use test IDs and how to name them.
|
|
42
|
+
|
|
38
43
|
### Related
|
|
39
44
|
|
|
40
45
|
- **[DataTable](components-data-table.md)**: use with Pagination when tabular data needs paging, sorting, or selection.
|
|
@@ -80,6 +85,7 @@ import { Pagination } from "@maxio-com/react-ui-components";
|
|
|
80
85
|
| Prop | Type | Required | Default | Description | Source |
|
|
81
86
|
| --- | --- | --- | --- | --- | --- |
|
|
82
87
|
| `currentPage` | `number` | no | `1` | Current page index | TypeLiteral |
|
|
88
|
+
| `data-testid` | `string` | no | - | Test ID set on the component's root element. Components with internal parts derive their IDs from it (e.g. `<id>.row.<rowId>`). | TypeLiteral |
|
|
83
89
|
| `itemsPerPage` | `number` | no | `30` | Number of items shown per page | TypeLiteral |
|
|
84
90
|
| `manualPageInput` | `boolean` | no | `false` | Use manual page input instead of dropdown for extremely large datasets | TypeLiteral |
|
|
85
91
|
| `onChange` | `((pageInfo: PageInfo) => void)` | no | - | Export of currentPage and itemsPerPage data as an object | TypeLiteral |
|
|
@@ -17,7 +17,7 @@ Popover positions dismissible overlay content next to a trigger.
|
|
|
17
17
|
|
|
18
18
|
- Do not use for brief explanatory text. Use Tooltip instead.
|
|
19
19
|
- Do not use for a simple list of contextual actions. Use ActionMenu instead.
|
|
20
|
-
- Do not use for page-level or blocking decisions. Use
|
|
20
|
+
- Do not use for page-level or blocking decisions. Use [Modal](components-modal.md) instead.
|
|
21
21
|
- Do not use Popover by itself when you need trigger state, focus return, or dismissal behavior. Pair it with a React Aria trigger.
|
|
22
22
|
|
|
23
23
|
### Behavior
|
|
@@ -75,13 +75,14 @@ import { ProgressBar } from "@maxio-com/react-ui-components";
|
|
|
75
75
|
|
|
76
76
|
| Prop | Type | Required | Default | Description | Source |
|
|
77
77
|
| --- | --- | --- | --- | --- | --- |
|
|
78
|
+
| `data-testid` | `string` | no | - | Test ID set on the component's root element. Components with internal parts derive their IDs from it (e.g. `<id>.row.<rowId>`). | TypeLiteral |
|
|
78
79
|
| `helperText` | `string` | no | - | Helper text for the progress bar | ProgressBarProps |
|
|
79
80
|
| `label` | `string` | yes | - | Label for the progress bar | ProgressBarProps |
|
|
80
81
|
| `maxValue` | `number` | no | `100` | Defines the maximum value of the progress bar | ProgressBarProps |
|
|
81
82
|
| `size` | `"md" \| "lg"` | no | `md` | Defines the size of the progress bar | ProgressBarProps |
|
|
82
83
|
| `status` | `"error" \| "success"` | no | - | Defines the status of the progress bar | ProgressBarProps |
|
|
83
84
|
| `value` | `number` | no | - | Defines the current value of the progress bar. If `undefined` the progress bar will be indeterminate. | ProgressBarProps |
|
|
84
|
-
| `variant` | `"
|
|
85
|
+
| `variant` | `"default" \| "inline" \| "indent"` | no | `default` | Defines the position applied to the label and helper text | ProgressBarProps |
|
|
85
86
|
|
|
86
87
|
## Stories
|
|
87
88
|
|
|
@@ -53,6 +53,12 @@ Choose the visual treatment that fits the surrounding surface.
|
|
|
53
53
|
- Avoid long tab labels that wrap or make the active section hard to scan.
|
|
54
54
|
- Use icons as supporting context; do not rely on icons alone unless the meaning is unmistakable.
|
|
55
55
|
|
|
56
|
+
### Testing
|
|
57
|
+
|
|
58
|
+
- Pass `data-testid` to `Tabs` to set it on the tabs container.
|
|
59
|
+
- Tabs and panels don't derive IDs, because they are only identified by position. Pass `data-testid` to each `Tab` or `TabPanel` that a test needs to reach.
|
|
60
|
+
- See [Testing](foundations-testing.md) for when to use test IDs and how to name them.
|
|
61
|
+
|
|
56
62
|
### Related
|
|
57
63
|
|
|
58
64
|
- **[SideNav](patterns-side-nav.md)**: use for primary navigation across app areas.
|
|
@@ -154,6 +160,7 @@ import { Body, Card, Icon, Tab, TabList, TabPanel, TabPanels, Tabs } from "@maxi
|
|
|
154
160
|
|
|
155
161
|
| Prop | Type | Required | Default | Description | Source |
|
|
156
162
|
| --- | --- | --- | --- | --- | --- |
|
|
163
|
+
| `data-testid` | `string` | no | - | Test ID set on the root element. | TypeLiteral |
|
|
157
164
|
| `defaultIndex` | `number` | no | `0` | Indicates which tab should be active by default | TypeLiteral |
|
|
158
165
|
| `index` | `number` | no | - | Indicates which tab should be active in controlled mode. | TypeLiteral |
|
|
159
166
|
| `onChange` | `TabsOnChange` | no | - | Callback function that is fired when the tab is changed | TypeLiteral |
|
|
@@ -76,6 +76,7 @@ import { Tag } from "@maxio-com/react-ui-components";
|
|
|
76
76
|
| Prop | Type | Required | Default | Description | Source |
|
|
77
77
|
| --- | --- | --- | --- | --- | --- |
|
|
78
78
|
| `children` | `ReactNode` | yes | - | React children nodes | TypeLiteral |
|
|
79
|
+
| `data-testid` | `string` | no | - | Test ID set on the component's root element. Components with internal parts derive their IDs from it (e.g. `<id>.row.<rowId>`). | TypeLiteral |
|
|
79
80
|
| `kind` | `"primary" \| "secondary" \| "tertiary"` | no | `primary` | Modifier for the tag Kind | TypeLiteral |
|
|
80
81
|
| `leadingIcon` | `string` | no | - | Element allowing leading icon selection | TypeLiteral |
|
|
81
82
|
| `sentiment` | `"danger" \| "info" \| "success" \| "warning" \| "highlight"` | no | - | Modifier for the tag Sentiment | TypeLiteral |
|
|
@@ -66,6 +66,7 @@ import { Tile } from "@maxio-com/react-ui-components";
|
|
|
66
66
|
|
|
67
67
|
| Prop | Type | Required | Default | Description | Source |
|
|
68
68
|
| --- | --- | --- | --- | --- | --- |
|
|
69
|
+
| `data-testid` | `string` | no | - | Test ID set on the component's root element. Components with internal parts derive their IDs from it (e.g. `<id>.row.<rowId>`). | TypeLiteral |
|
|
69
70
|
| `disabled` | `boolean` | no | - | - | TypeLiteral |
|
|
70
71
|
| `href` | `string` | no | - | - | TypeLiteral |
|
|
71
72
|
| `onClick` | `((() => void) & MouseEventHandler<HTMLDivElement>)` | no | - | - | TypeLiteral, DOMAttributes |
|
|
@@ -40,6 +40,11 @@ Toggle lets users turn a setting on or off.
|
|
|
40
40
|
- Keep labels short and specific enough to scan in dense settings pages.
|
|
41
41
|
- Place explanatory or eligibility copy near the toggle when a disabled state needs context.
|
|
42
42
|
|
|
43
|
+
### Testing
|
|
44
|
+
|
|
45
|
+
- Pass `data-testid` to set it on the toggle container. Without it, the container keeps the default `toggle-container`.
|
|
46
|
+
- See [Testing](foundations-testing.md) for when to use test IDs and how to name them.
|
|
47
|
+
|
|
43
48
|
### Related
|
|
44
49
|
|
|
45
50
|
- **[Checkbox](components-forms-checkbox.md)**: use for independent selections in a form or list.
|
|
@@ -93,13 +98,14 @@ import { ToggleComponent } from "@maxio-com/react-ui-components";
|
|
|
93
98
|
| `aria-label` | `string` | no | - | Aria label for the toggle - should be provided if no valueDescription is provided | TypeLiteral |
|
|
94
99
|
| `checked` | `boolean` | no | - | The state of the toggle | TypeLiteral |
|
|
95
100
|
| `className` | `string` | no | - | Class name for the main container | TypeLiteral |
|
|
101
|
+
| `data-testid` | `string` | no | `toggle-container` | Test ID set on the root element | TypeLiteral |
|
|
96
102
|
| `defaultChecked` | `boolean` | no | - | The state for uncontrolled toggle. | TypeLiteral |
|
|
97
103
|
| `disabled` | `boolean` | no | - | Is the toggle disabled | TypeLiteral |
|
|
98
104
|
| `id` | `string` | no | - | Toggle id - if id not provided then it will be generated automatically | TypeLiteral |
|
|
99
105
|
| `name` | `string` | no | - | Toggle name | TypeLiteral |
|
|
100
106
|
| `onChange` | `((value: boolean, event?: ChangeEvent<HTMLInputElement, Element> \| KeyboardEvent<HTMLInputElement>) => void)` | no | - | The onChange function | TypeLiteral |
|
|
101
107
|
| `valueDescription` | `string` | no | - | Toggle label | TypeLiteral |
|
|
102
|
-
| `valueDescriptionPosition` | `"
|
|
108
|
+
| `valueDescriptionPosition` | `"left" \| "right"` | no | - | Toggle label position | TypeLiteral |
|
|
103
109
|
|
|
104
110
|
## Stories
|
|
105
111
|
|